Fix texture GatherRed/Green/etc. methods for SM 5.0
Unlike GLSL, the component is selected by calling a specific method.
This commit is contained in:
parent
0eaa2dee13
commit
02e6be7288
@ -89,7 +89,16 @@ void frag_main()
|
||||
texcolor += tex1dArray.Sample(_tex1dArray_sampler, texCoord2d);
|
||||
texcolor += tex2dArray.Sample(_tex2dArray_sampler, texCoord3d);
|
||||
texcolor += texCubeArray.Sample(_texCubeArray_sampler, texCoord4d);
|
||||
texcolor += tex2d.Gather(_tex2d_sampler, texCoord2d, 0);
|
||||
texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d);
|
||||
texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d);
|
||||
texcolor += tex2d.GatherGreen(_tex2d_sampler, texCoord2d);
|
||||
texcolor += tex2d.GatherBlue(_tex2d_sampler, texCoord2d);
|
||||
texcolor += tex2d.GatherAlpha(_tex2d_sampler, texCoord2d);
|
||||
texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1));
|
||||
texcolor += tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1));
|
||||
texcolor += tex2d.GatherGreen(_tex2d_sampler, texCoord2d, int2(1, 1));
|
||||
texcolor += tex2d.GatherBlue(_tex2d_sampler, texCoord2d, int2(1, 1));
|
||||
texcolor += tex2d.GatherAlpha(_tex2d_sampler, texCoord2d, int2(1, 1));
|
||||
texcolor += tex2d.Load(int3(int2(1, 2), 0));
|
||||
texcolor += separateTex2d.Sample(samplerNonDepth, texCoord2d);
|
||||
texcolor.w += separateTex2dDepth.SampleCmp(samplerDepth, texCoord3d.xy, texCoord3d.z);
|
||||
|
@ -61,6 +61,16 @@ void main()
|
||||
texcolor += texture(texCubeArray, texCoord4d);
|
||||
|
||||
texcolor += textureGather(tex2d, texCoord2d);
|
||||
texcolor += textureGather(tex2d, texCoord2d, 0);
|
||||
texcolor += textureGather(tex2d, texCoord2d, 1);
|
||||
texcolor += textureGather(tex2d, texCoord2d, 2);
|
||||
texcolor += textureGather(tex2d, texCoord2d, 3);
|
||||
|
||||
texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1));
|
||||
texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 0);
|
||||
texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 1);
|
||||
texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 2);
|
||||
texcolor += textureGatherOffset(tex2d, texCoord2d, ivec2(1, 1), 3);
|
||||
|
||||
texcolor += texelFetch(tex2d, ivec2(1, 2), 0);
|
||||
|
||||
|
@ -1463,7 +1463,36 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
||||
if (imgtype.image.depth)
|
||||
texop += ".SampleCmp";
|
||||
else if (gather)
|
||||
texop += ".Gather";
|
||||
{
|
||||
uint32_t comp_num = get<SPIRConstant>(comp).scalar();
|
||||
if (options.shader_model >= 50)
|
||||
{
|
||||
switch (comp_num)
|
||||
{
|
||||
case 0:
|
||||
texop += ".GatherRed";
|
||||
break;
|
||||
case 1:
|
||||
texop += ".GatherGreen";
|
||||
break;
|
||||
case 2:
|
||||
texop += ".GatherBlue";
|
||||
break;
|
||||
case 3:
|
||||
texop += ".GatherAlpha";
|
||||
break;
|
||||
default:
|
||||
SPIRV_CROSS_THROW("Invalid component.");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (comp_num == 0)
|
||||
texop += ".Gather";
|
||||
else
|
||||
SPIRV_CROSS_THROW("HLSL shader model 4 can only gather from the red component.");
|
||||
}
|
||||
}
|
||||
else if (bias)
|
||||
texop += ".SampleBias";
|
||||
else if (grad_x || grad_y)
|
||||
@ -1641,13 +1670,6 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
||||
expr += to_expression(offset);
|
||||
}
|
||||
|
||||
if (comp)
|
||||
{
|
||||
forward = forward && should_forward(comp);
|
||||
expr += ", ";
|
||||
expr += to_expression(comp);
|
||||
}
|
||||
|
||||
if (sample)
|
||||
{
|
||||
expr += ", ";
|
||||
|
Loading…
Reference in New Issue
Block a user