diff --git a/reference/shaders-msl/frag/separate-image-sampler-argument.frag b/reference/shaders-msl/frag/separate-image-sampler-argument.frag new file mode 100644 index 00000000..46c0524a --- /dev/null +++ b/reference/shaders-msl/frag/separate-image-sampler-argument.frag @@ -0,0 +1,24 @@ +#pragma clang diagnostic ignored "-Wmissing-prototypes" + +#include +#include + +using namespace metal; + +struct main0_out +{ + float4 FragColor [[color(0)]]; +}; + +float4 samp(thread const texture2d t, thread const sampler s) +{ + return t.sample(s, float2(0.5)); +} + +fragment main0_out main0(texture2d uDepth [[texture(0)]], sampler uSampler [[sampler(0)]]) +{ + main0_out out = {}; + out.FragColor = samp(uDepth, uSampler); + return out; +} + diff --git a/shaders-msl/frag/separate-image-sampler-argument.frag b/shaders-msl/frag/separate-image-sampler-argument.frag new file mode 100644 index 00000000..0475b019 --- /dev/null +++ b/shaders-msl/frag/separate-image-sampler-argument.frag @@ -0,0 +1,16 @@ +#version 310 es +precision mediump float; + +layout(set = 0, binding = 0) uniform mediump sampler uSampler; +layout(set = 0, binding = 1) uniform mediump texture2D uDepth; +layout(location = 0) out vec4 FragColor; + +vec4 samp(texture2D t, mediump sampler s) +{ + return texture(sampler2D(t, s), vec2(0.5)); +} + +void main() +{ + FragColor = samp(uDepth, uSampler); +} diff --git a/spirv_glsl.hpp b/spirv_glsl.hpp index 83cc8b45..f27b14c6 100644 --- a/spirv_glsl.hpp +++ b/spirv_glsl.hpp @@ -366,7 +366,7 @@ protected: uint64_t combined_decoration_for_member(const SPIRType &type, uint32_t index); std::string layout_for_variable(const SPIRVariable &variable); std::string to_combined_image_sampler(uint32_t image_id, uint32_t samp_id); - bool skip_argument(uint32_t id) const; + virtual bool skip_argument(uint32_t id) const; bool ssbo_is_std430_packing(const SPIRType &type); uint32_t type_to_std430_base_size(const SPIRType &type); diff --git a/spirv_msl.cpp b/spirv_msl.cpp index c0324103..56ee2a70 100644 --- a/spirv_msl.cpp +++ b/spirv_msl.cpp @@ -2198,6 +2198,11 @@ size_t CompilerMSL::get_declared_type_alignment(uint32_t type_id, uint64_t dec_m } } +bool CompilerMSL::skip_argument(uint32_t) const +{ + return false; +} + bool CompilerMSL::OpCodePreprocessor::handle(Op opcode, const uint32_t * /*args*/, uint32_t /*length*/) { switch (opcode) diff --git a/spirv_msl.hpp b/spirv_msl.hpp index abe442a0..dc5c47d7 100644 --- a/spirv_msl.hpp +++ b/spirv_msl.hpp @@ -196,6 +196,7 @@ protected: void align_struct(SPIRType &ib_type); bool is_member_packable(SPIRType &ib_type, uint32_t index); MSLStructMemberKey get_struct_member_key(uint32_t type_id, uint32_t index); + bool skip_argument(uint32_t id) const override; Options options; std::unordered_map func_name_overrides;