Fix separate sampler images in MSL.

This commit is contained in:
Hans-Kristian Arntzen 2017-05-07 12:36:14 +02:00
parent 36e1c470a2
commit f081fe1125
5 changed files with 47 additions and 1 deletions

View File

@ -0,0 +1,24 @@
#pragma clang diagnostic ignored "-Wmissing-prototypes"
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
struct main0_out
{
float4 FragColor [[color(0)]];
};
float4 samp(thread const texture2d<float> t, thread const sampler s)
{
return t.sample(s, float2(0.5));
}
fragment main0_out main0(texture2d<float> uDepth [[texture(0)]], sampler uSampler [[sampler(0)]])
{
main0_out out = {};
out.FragColor = samp(uDepth, uSampler);
return out;
}

View File

@ -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);
}

View File

@ -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);

View File

@ -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)

View File

@ -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<std::string, std::string> func_name_overrides;