diff --git a/reference/opt/shaders-msl/frag/gather-dref.frag b/reference/opt/shaders-msl/frag/gather-dref.frag new file mode 100644 index 0000000..d567dab --- /dev/null +++ b/reference/opt/shaders-msl/frag/gather-dref.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float3 vUV [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], depth2d uT [[texture(0)]], sampler uTSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = uT.gather_compare(uTSmplr, in.vUV.xy, in.vUV.z); + return out; +} + diff --git a/reference/opt/shaders/frag/gather-dref.frag b/reference/opt/shaders/frag/gather-dref.frag new file mode 100644 index 0000000..5416f79 --- /dev/null +++ b/reference/opt/shaders/frag/gather-dref.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2DShadow uT; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec3 vUV; + +void main() +{ + FragColor = textureGather(uT, vUV.xy, vUV.z); +} + diff --git a/reference/shaders-msl/frag/gather-dref.frag b/reference/shaders-msl/frag/gather-dref.frag new file mode 100644 index 0000000..d567dab --- /dev/null +++ b/reference/shaders-msl/frag/gather-dref.frag @@ -0,0 +1,22 @@ +#include +#include + +using namespace metal; + +struct main0_in +{ + float3 vUV [[user(locn0)]]; +}; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +fragment main0_out main0(main0_in in [[stage_in]], depth2d uT [[texture(0)]], sampler uTSmplr [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = uT.gather_compare(uTSmplr, in.vUV.xy, in.vUV.z); + return out; +} + diff --git a/reference/shaders/frag/gather-dref.frag b/reference/shaders/frag/gather-dref.frag new file mode 100644 index 0000000..5416f79 --- /dev/null +++ b/reference/shaders/frag/gather-dref.frag @@ -0,0 +1,14 @@ +#version 310 es +precision mediump float; +precision highp int; + +layout(binding = 0) uniform mediump sampler2DShadow uT; + +layout(location = 0) out vec4 FragColor; +layout(location = 0) in vec3 vUV; + +void main() +{ + FragColor = textureGather(uT, vUV.xy, vUV.z); +} + diff --git a/shaders-msl/frag/gather-dref.frag b/shaders-msl/frag/gather-dref.frag new file mode 100644 index 0000000..a8aac56 --- /dev/null +++ b/shaders-msl/frag/gather-dref.frag @@ -0,0 +1,11 @@ +#version 310 es +precision mediump float; + +layout(binding = 0) uniform mediump sampler2DShadow uT; +layout(location = 0) in vec3 vUV; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = textureGather(uT, vUV.xy, vUV.z); +} diff --git a/shaders/frag/gather-dref.frag b/shaders/frag/gather-dref.frag new file mode 100644 index 0000000..a8aac56 --- /dev/null +++ b/shaders/frag/gather-dref.frag @@ -0,0 +1,11 @@ +#version 310 es +precision mediump float; + +layout(binding = 0) uniform mediump sampler2DShadow uT; +layout(location = 0) in vec3 vUV; +layout(location = 0) out vec4 FragColor; + +void main() +{ + FragColor = textureGather(uT, vUV.xy, vUV.z); +} diff --git a/spirv_glsl.cpp b/spirv_glsl.cpp index fcb9066..34a56ab 100644 --- a/spirv_glsl.cpp +++ b/spirv_glsl.cpp @@ -3940,7 +3940,7 @@ std::string CompilerGLSL::convert_separate_image_to_combined(uint32_t id) } // Returns the function args for a texture sampling function for the specified image and sampling characteristics. -string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool, bool is_proj, +string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool is_fetch, bool is_gather, bool is_proj, uint32_t coord, uint32_t coord_components, uint32_t dref, uint32_t grad_x, uint32_t grad_y, uint32_t lod, uint32_t coffset, uint32_t offset, uint32_t bias, uint32_t comp, uint32_t sample, bool *p_forward) @@ -3998,7 +3998,7 @@ string CompilerGLSL::to_function_args(uint32_t img, const SPIRType &imgtype, boo forward = forward && should_forward(dref); // SPIR-V splits dref and coordinate. - if (coord_components == 4) // GLSL also splits the arguments in two. + if (is_gather || coord_components == 4) // GLSL also splits the arguments in two. Same for textureGather. { farg_str += ", "; farg_str += to_expression(coord);