Halide icon indicating copy to clipboard operation
Halide copied to clipboard

GLSL shaders problem on macOS

Open magpier84 opened this issue 6 years ago • 1 comments

OpenGL target doesn't work on macOS (tested on 10.15.4). For example here is output of opengl_test (Radeon Pro 560X/Intel UHD Graphics 630)

test_blur Entering Pipeline halide_blur_glsl Target: x86-64-osx-avx-avx2-debug-f16c-fma-no_runtime-opengl-sse41 Input Buffer input8: buffer(0, 0x0, 0x7fec9b00b880, 0, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) Output Buffer blur_filter: buffer(0, 0x0, 0x7fec9b00be80, 0, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) In initialize_kernels Halide running on OpenGL 2.1 vertex_array_objects: no texture_rg: yes have_texture_rgb8_rgba8: no texture_float: yes Compiling GLSL kernel (size = 375): GL_VERTEX_SHADER SOURCE: attribute vec4 _varyingf0_attrib; varying vec4 _varyingf0; uniform ivec2 output_min; uniform ivec2 output_extent; void main() { vec2 position = vec2(_varyingf0_attrib[0], _varyingf0_attrib[1]); gl_Position = vec4(position, 0.0, 1.0); vec2 texcoord = 0.5 * position + 0.5; vec2 pixcoord = texcoord * vec2(output_extent.xy) + vec2(output_min.xy); _varyingf0 = _varyingf0_attrib; _varyingf0.xy = pixcoord; } GL_FRAGMENT_SHADER SOURCE:

// ll suffix in OpenCL is reserved for 128-bit integers. #if defined OPENCL_VERSION #define ADD_INT64_T_SUFFIX(x) x##l #define ADD_UINT64_T_SUFFIX(x) x##ul // HLSL doesn't have any suffixes. #elif defined HLSL_VERSION #define ADD_INT64_T_SUFFIX(x) x #define ADD_UINT64_T_SUFFIX(x) x #else #define ADD_INT64_T_SUFFIX(x) x##ll #define ADD_UINT64_T_SUFFIX(x) x##ull #endif Could not link GLSL program: ERROR: Compiled fragment shader was corrupt.

test_blur complete test_ycc Entering Pipeline halide_ycc_glsl Target: x86-64-osx-avx-avx2-debug-f16c-fma-no_runtime-opengl-sse41 Input Buffer input8: buffer(0, 0x0, 0x7fec9980a080, 0, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) Output Buffer out: buffer(0, 0x0, 0x7fec9980e480, 0, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) In initialize_kernels Compiling GLSL kernel (size = 375): GL_VERTEX_SHADER SOURCE: attribute vec4 _varyingf0_attrib; varying vec4 _varyingf0; uniform ivec2 output_min; uniform ivec2 output_extent; void main() { vec2 position = vec2(_varyingf0_attrib[0], _varyingf0_attrib[1]); gl_Position = vec4(position, 0.0, 1.0); vec2 texcoord = 0.5 * position + 0.5; vec2 pixcoord = texcoord * vec2(output_extent.xy) + vec2(output_min.xy); _varyingf0 = _varyingf0_attrib; _varyingf0.xy = pixcoord; } GL_FRAGMENT_SHADER SOURCE:

// ll suffix in OpenCL is reserved for 128-bit integers. #if defined OPENCL_VERSION #define ADD_INT64_T_SUFFIX(x) x##l #define ADD_UINT64_T_SUFFIX(x) x##ul // HLSL doesn't have any suffixes. #elif defined HLSL_VERSION #define ADD_INT64_T_SUFFIX(x) x #define ADD_UINT64_T_SUFFIX(x) x #else #define ADD_INT64_T_SUFFIX(x) x##ll #define ADD_UINT64_T_SUFFIX(x) x##ull #endif Could not link GLSL program: ERROR: Compiled fragment shader was corrupt.

Ycc complete halide_copy_to_device validating input buffer: buffer(0, 0x0, 0x7fec9980a080, 1, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) halide_device_malloc validating input buffer: buffer(0, 0x0, 0x7fec9980a080, 1, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) halide_device_malloc: target device interface 0x10b360938 Allocated texture 1 of size 12 x 32 halide_copy_to_device 0x7ffee48c88f0 host is dirty Saved OpenGL state halide_opengl_copy_to_device: 1 Warning: In copy_to_device, host buffer is not interleaved. Doing slow interleave. Restoring OpenGL state halide_device_sync validating input buffer: buffer(1, 0x10b360938, 0x7fec9980a080, 0, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) halide_opengl_device_sync: took 1.271700e+01usec Test device sync complete. halide_device_free validating input buffer: buffer(1, 0x10b360938, 0x0, 0, uint8, {0, 12, 1}, {0, 32, 12}, {0, 3, 384}) halide_opengl_device_free: Deleting texture 1 halide_opengl_release opengl_test(59766,0x115dc3dc0) malloc: *** error for object 0xa000000000000000: pointer being freed was not allocated opengl_test(59766,0x115dc3dc0) malloc: *** set a breakpoint in malloc_error_break to debug

magpier84 avatar Apr 21 '20 15:04 magpier84

Unfortunately, we don't have anyone maintaining the OpenGL backend currently, but patches/fixes are very much appreciated.

shoaibkamil avatar Apr 21 '20 16:04 shoaibkamil