HLSL/MSL: Fix texture projection with Dref.
We need to divide the Dref by q.
This commit is contained in:
Родитель
7430e78a8c
Коммит
18a4accd2f
|
@ -22,26 +22,11 @@ struct SPIRV_Cross_Output
|
|||
float FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float SPIRV_Cross_projectTextureCoordinate(float2 coord)
|
||||
{
|
||||
return coord.x / coord.y;
|
||||
}
|
||||
|
||||
float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)
|
||||
{
|
||||
return float2(coord.x, coord.y) / coord.z;
|
||||
}
|
||||
|
||||
float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)
|
||||
{
|
||||
return float3(coord.x, coord.y, coord.z) / coord.w;
|
||||
}
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float4 _80 = vDirRef;
|
||||
_80.z = vDirRef.w;
|
||||
FragColor = (((((((uSampler2D.SampleCmp(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)) + uSampler2DArray.SampleCmp(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmp(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSamplerCubeArray.SampleCmp(_uSamplerCubeArray_sampler, vDirRef, 0.5f)) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1))) + uSampler2DArray.SampleCmpLevelZero(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmpLevelZero(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSampler2D.SampleCmp(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_80.xyz), vDirRef.z, int2(1, 1))) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_80.xyz), vDirRef.z, int2(1, 1));
|
||||
FragColor = (((((((uSampler2D.SampleCmp(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1)) + uSampler2DArray.SampleCmp(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmp(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSamplerCubeArray.SampleCmp(_uSamplerCubeArray_sampler, vDirRef, 0.5f)) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1))) + uSampler2DArray.SampleCmpLevelZero(_uSampler2DArray_sampler, vDirRef.xyz, vDirRef.w, int2(-1, -1))) + uSamplerCube.SampleCmpLevelZero(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w)) + uSampler2D.SampleCmp(_uSampler2D_sampler, _80.xy / _80.z, vDirRef.z / _80.z, int2(1, 1))) + uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, _80.xy / _80.z, vDirRef.z / _80.z, int2(1, 1));
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
|
|
@ -42,24 +42,12 @@ struct SPIRV_Cross_Output
|
|||
float4 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float SPIRV_Cross_projectTextureCoordinate(float2 coord)
|
||||
{
|
||||
return coord.x / coord.y;
|
||||
}
|
||||
|
||||
float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)
|
||||
{
|
||||
return float2(coord.x, coord.y) / coord.z;
|
||||
}
|
||||
|
||||
float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)
|
||||
{
|
||||
return float3(coord.x, coord.y, coord.z) / coord.w;
|
||||
}
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float4 _162 = (((((((((((((((((((tex1d.Sample(_tex1d_sampler, texCoord1d) + tex1d.Sample(_tex1d_sampler, texCoord1d, 1)) + tex1d.SampleLevel(_tex1d_sampler, texCoord1d, 2.0f)) + tex1d.SampleGrad(_tex1d_sampler, texCoord1d, 1.0f, 2.0f)) + tex1d.Sample(_tex1d_sampler, SPIRV_Cross_projectTextureCoordinate(float2(texCoord1d, 2.0f)))) + tex1d.SampleBias(_tex1d_sampler, texCoord1d, 1.0f)) + tex2d.Sample(_tex2d_sampler, texCoord2d)) + tex2d.Sample(_tex2d_sampler, texCoord2d, int2(1, 2))) + tex2d.SampleLevel(_tex2d_sampler, texCoord2d, 2.0f)) + tex2d.SampleGrad(_tex2d_sampler, texCoord2d, float2(1.0f, 2.0f), float2(3.0f, 4.0f))) + tex2d.Sample(_tex2d_sampler, SPIRV_Cross_projectTextureCoordinate(float3(texCoord2d, 2.0f)))) + tex2d.SampleBias(_tex2d_sampler, texCoord2d, 1.0f)) + tex3d.Sample(_tex3d_sampler, texCoord3d)) + tex3d.Sample(_tex3d_sampler, texCoord3d, int3(1, 2, 3))) + tex3d.SampleLevel(_tex3d_sampler, texCoord3d, 2.0f)) + tex3d.SampleGrad(_tex3d_sampler, texCoord3d, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f))) + tex3d.Sample(_tex3d_sampler, SPIRV_Cross_projectTextureCoordinate(float4(texCoord3d, 2.0f)))) + tex3d.SampleBias(_tex3d_sampler, texCoord3d, 1.0f)) + texCube.Sample(_texCube_sampler, texCoord3d)) + texCube.SampleLevel(_texCube_sampler, texCoord3d, 2.0f)) + texCube.SampleBias(_texCube_sampler, texCoord3d, 1.0f);
|
||||
float2 _41 = float2(texCoord1d, 2.0f);
|
||||
float3 _88 = float3(texCoord2d, 2.0f);
|
||||
float4 _135 = float4(texCoord3d, 2.0f);
|
||||
float4 _162 = (((((((((((((((((((tex1d.Sample(_tex1d_sampler, texCoord1d) + tex1d.Sample(_tex1d_sampler, texCoord1d, 1)) + tex1d.SampleLevel(_tex1d_sampler, texCoord1d, 2.0f)) + tex1d.SampleGrad(_tex1d_sampler, texCoord1d, 1.0f, 2.0f)) + tex1d.Sample(_tex1d_sampler, _41.x / _41.y)) + tex1d.SampleBias(_tex1d_sampler, texCoord1d, 1.0f)) + tex2d.Sample(_tex2d_sampler, texCoord2d)) + tex2d.Sample(_tex2d_sampler, texCoord2d, int2(1, 2))) + tex2d.SampleLevel(_tex2d_sampler, texCoord2d, 2.0f)) + tex2d.SampleGrad(_tex2d_sampler, texCoord2d, float2(1.0f, 2.0f), float2(3.0f, 4.0f))) + tex2d.Sample(_tex2d_sampler, _88.xy / _88.z)) + tex2d.SampleBias(_tex2d_sampler, texCoord2d, 1.0f)) + tex3d.Sample(_tex3d_sampler, texCoord3d)) + tex3d.Sample(_tex3d_sampler, texCoord3d, int3(1, 2, 3))) + tex3d.SampleLevel(_tex3d_sampler, texCoord3d, 2.0f)) + tex3d.SampleGrad(_tex3d_sampler, texCoord3d, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f))) + tex3d.Sample(_tex3d_sampler, _135.xyz / _135.w)) + tex3d.SampleBias(_tex3d_sampler, texCoord3d, 1.0f)) + texCube.Sample(_texCube_sampler, texCoord3d)) + texCube.SampleLevel(_texCube_sampler, texCoord3d, 2.0f)) + texCube.SampleBias(_texCube_sampler, texCoord3d, 1.0f);
|
||||
float4 _333 = _162;
|
||||
_333.w = ((_162.w + tex1dShadow.SampleCmp(_tex1dShadow_sampler, float3(texCoord1d, 0.0f, 0.0f).x, 0.0f)) + tex2dShadow.SampleCmp(_tex2dShadow_sampler, float3(texCoord2d, 0.0f).xy, 0.0f)) + texCubeShadow.SampleCmp(_texCubeShadow_sampler, float4(texCoord3d, 0.0f).xyz, 0.0f);
|
||||
float4 _308 = ((((((((((((((_333 + tex1dArray.Sample(_tex1dArray_sampler, texCoord2d)) + tex2dArray.Sample(_tex2dArray_sampler, texCoord3d)) + texCubeArray.Sample(_texCubeArray_sampler, texCoord4d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d)) + tex2d.GatherGreen(_tex2d_sampler, texCoord2d)) + tex2d.GatherBlue(_tex2d_sampler, texCoord2d)) + tex2d.GatherAlpha(_tex2d_sampler, texCoord2d)) + tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherRed(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherGreen(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherBlue(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.GatherAlpha(_tex2d_sampler, texCoord2d, int2(1, 1))) + tex2d.Load(int3(int2(1, 2), 0))) + separateTex2d.Sample(samplerNonDepth, texCoord2d);
|
||||
|
|
|
@ -26,32 +26,17 @@ struct SPIRV_Cross_Output
|
|||
float FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float SPIRV_Cross_projectTextureCoordinate(float2 coord)
|
||||
{
|
||||
return coord.x / coord.y;
|
||||
}
|
||||
|
||||
float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)
|
||||
{
|
||||
return float2(coord.x, coord.y) / coord.z;
|
||||
}
|
||||
|
||||
float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)
|
||||
{
|
||||
return float3(coord.x, coord.y, coord.z) / coord.w;
|
||||
}
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float4 _20 = vClip4;
|
||||
_20.y = vClip4.w;
|
||||
FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, SPIRV_Cross_projectTextureCoordinate(_20.xy), vClip4.z);
|
||||
FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, _20.x / _20.y, vClip4.z / _20.y);
|
||||
float4 _30 = vClip4;
|
||||
_30.z = vClip4.w;
|
||||
FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, SPIRV_Cross_projectTextureCoordinate(_30.xyz), vClip4.z);
|
||||
FragColor = uSampler1D.Sample(_uSampler1D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip2)).x;
|
||||
FragColor = uSampler2D.Sample(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip3)).x;
|
||||
FragColor = uSampler3D.Sample(_uSampler3D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip4)).x;
|
||||
FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, _30.xy / _30.z, vClip4.z / _30.z);
|
||||
FragColor = uSampler1D.Sample(_uSampler1D_sampler, vClip2.x / vClip2.y).x;
|
||||
FragColor = uSampler2D.Sample(_uSampler2D_sampler, vClip3.xy / vClip3.z).x;
|
||||
FragColor = uSampler3D.Sample(_uSampler3D_sampler, vClip4.xyz / vClip4.w).x;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
|
|
@ -20,7 +20,7 @@ fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[te
|
|||
main0_out out = {};
|
||||
float4 _20 = in.vClip4;
|
||||
_20.z = in.vClip4.w;
|
||||
out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z);
|
||||
out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z / _20.z);
|
||||
out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x;
|
||||
out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x;
|
||||
out.FragColor = uSampler3D.sample(uSampler3DSmplr, in.vClip4.xyz / in.vClip4.w).x;
|
||||
|
|
|
@ -22,21 +22,6 @@ struct SPIRV_Cross_Output
|
|||
float FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float SPIRV_Cross_projectTextureCoordinate(float2 coord)
|
||||
{
|
||||
return coord.x / coord.y;
|
||||
}
|
||||
|
||||
float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)
|
||||
{
|
||||
return float2(coord.x, coord.y) / coord.z;
|
||||
}
|
||||
|
||||
float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)
|
||||
{
|
||||
return float3(coord.x, coord.y, coord.z) / coord.w;
|
||||
}
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float s0 = uSampler2D.SampleCmp(_uSampler2D_sampler, vUVRef.xy, vUVRef.z, int2(-1, -1));
|
||||
|
@ -48,10 +33,10 @@ void frag_main()
|
|||
float l2 = uSamplerCube.SampleCmpLevelZero(_uSamplerCube_sampler, vDirRef.xyz, vDirRef.w);
|
||||
float4 _80 = vDirRef;
|
||||
_80.z = vDirRef.w;
|
||||
float p0 = uSampler2D.SampleCmp(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_80.xyz), vDirRef.z, int2(1, 1));
|
||||
float p0 = uSampler2D.SampleCmp(_uSampler2D_sampler, _80.xy / _80.z, vDirRef.z / _80.z, int2(1, 1));
|
||||
float4 _87 = vDirRef;
|
||||
_87.z = vDirRef.w;
|
||||
float p1 = uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(_87.xyz), vDirRef.z, int2(1, 1));
|
||||
float p1 = uSampler2D.SampleCmpLevelZero(_uSampler2D_sampler, _87.xy / _87.z, vDirRef.z / _87.z, int2(1, 1));
|
||||
FragColor = (((((((s0 + s1) + s2) + s3) + l0) + l1) + l2) + p0) + p1;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,40 +42,28 @@ struct SPIRV_Cross_Output
|
|||
float4 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float SPIRV_Cross_projectTextureCoordinate(float2 coord)
|
||||
{
|
||||
return coord.x / coord.y;
|
||||
}
|
||||
|
||||
float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)
|
||||
{
|
||||
return float2(coord.x, coord.y) / coord.z;
|
||||
}
|
||||
|
||||
float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)
|
||||
{
|
||||
return float3(coord.x, coord.y, coord.z) / coord.w;
|
||||
}
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float4 texcolor = tex1d.Sample(_tex1d_sampler, texCoord1d);
|
||||
texcolor += tex1d.Sample(_tex1d_sampler, texCoord1d, 1);
|
||||
texcolor += tex1d.SampleLevel(_tex1d_sampler, texCoord1d, 2.0f);
|
||||
texcolor += tex1d.SampleGrad(_tex1d_sampler, texCoord1d, 1.0f, 2.0f);
|
||||
texcolor += tex1d.Sample(_tex1d_sampler, SPIRV_Cross_projectTextureCoordinate(float2(texCoord1d, 2.0f)));
|
||||
float2 _41 = float2(texCoord1d, 2.0f);
|
||||
texcolor += tex1d.Sample(_tex1d_sampler, _41.x / _41.y);
|
||||
texcolor += tex1d.SampleBias(_tex1d_sampler, texCoord1d, 1.0f);
|
||||
texcolor += tex2d.Sample(_tex2d_sampler, texCoord2d);
|
||||
texcolor += tex2d.Sample(_tex2d_sampler, texCoord2d, int2(1, 2));
|
||||
texcolor += tex2d.SampleLevel(_tex2d_sampler, texCoord2d, 2.0f);
|
||||
texcolor += tex2d.SampleGrad(_tex2d_sampler, texCoord2d, float2(1.0f, 2.0f), float2(3.0f, 4.0f));
|
||||
texcolor += tex2d.Sample(_tex2d_sampler, SPIRV_Cross_projectTextureCoordinate(float3(texCoord2d, 2.0f)));
|
||||
float3 _88 = float3(texCoord2d, 2.0f);
|
||||
texcolor += tex2d.Sample(_tex2d_sampler, _88.xy / _88.z);
|
||||
texcolor += tex2d.SampleBias(_tex2d_sampler, texCoord2d, 1.0f);
|
||||
texcolor += tex3d.Sample(_tex3d_sampler, texCoord3d);
|
||||
texcolor += tex3d.Sample(_tex3d_sampler, texCoord3d, int3(1, 2, 3));
|
||||
texcolor += tex3d.SampleLevel(_tex3d_sampler, texCoord3d, 2.0f);
|
||||
texcolor += tex3d.SampleGrad(_tex3d_sampler, texCoord3d, float3(1.0f, 2.0f, 3.0f), float3(4.0f, 5.0f, 6.0f));
|
||||
texcolor += tex3d.Sample(_tex3d_sampler, SPIRV_Cross_projectTextureCoordinate(float4(texCoord3d, 2.0f)));
|
||||
float4 _135 = float4(texCoord3d, 2.0f);
|
||||
texcolor += tex3d.Sample(_tex3d_sampler, _135.xyz / _135.w);
|
||||
texcolor += tex3d.SampleBias(_tex3d_sampler, texCoord3d, 1.0f);
|
||||
texcolor += texCube.Sample(_texCube_sampler, texCoord3d);
|
||||
texcolor += texCube.SampleLevel(_texCube_sampler, texCoord3d, 2.0f);
|
||||
|
|
|
@ -26,32 +26,17 @@ struct SPIRV_Cross_Output
|
|||
float FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float SPIRV_Cross_projectTextureCoordinate(float2 coord)
|
||||
{
|
||||
return coord.x / coord.y;
|
||||
}
|
||||
|
||||
float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)
|
||||
{
|
||||
return float2(coord.x, coord.y) / coord.z;
|
||||
}
|
||||
|
||||
float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)
|
||||
{
|
||||
return float3(coord.x, coord.y, coord.z) / coord.w;
|
||||
}
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float4 _20 = vClip4;
|
||||
_20.y = vClip4.w;
|
||||
FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, SPIRV_Cross_projectTextureCoordinate(_20.xy), vClip4.z);
|
||||
FragColor = uShadow1D.SampleCmp(_uShadow1D_sampler, _20.x / _20.y, vClip4.z / _20.y);
|
||||
float4 _30 = vClip4;
|
||||
_30.z = vClip4.w;
|
||||
FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, SPIRV_Cross_projectTextureCoordinate(_30.xyz), vClip4.z);
|
||||
FragColor = uSampler1D.Sample(_uSampler1D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip2)).x;
|
||||
FragColor = uSampler2D.Sample(_uSampler2D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip3)).x;
|
||||
FragColor = uSampler3D.Sample(_uSampler3D_sampler, SPIRV_Cross_projectTextureCoordinate(vClip4)).x;
|
||||
FragColor = uShadow2D.SampleCmp(_uShadow2D_sampler, _30.xy / _30.z, vClip4.z / _30.z);
|
||||
FragColor = uSampler1D.Sample(_uSampler1D_sampler, vClip2.x / vClip2.y).x;
|
||||
FragColor = uSampler2D.Sample(_uSampler2D_sampler, vClip3.xy / vClip3.z).x;
|
||||
FragColor = uSampler3D.Sample(_uSampler3D_sampler, vClip4.xyz / vClip4.w).x;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
|
|
@ -163,7 +163,7 @@ fragment void main0(constant spvAux& spvAuxBuffer [[buffer(0)]], texture1d<float
|
|||
c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), tex3dSwzl);
|
||||
float4 _152 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_152.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _152.xy / _152.z, float4(0.0, 0.0, 1.0, 1.0).z), depth2dSwzl);
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _152.xy / _152.z, float4(0.0, 0.0, 1.0, 1.0).z / _152.z), depth2dSwzl);
|
||||
c = spvTextureSwizzle(tex1d.sample(tex1dSamp, 0.0), tex1dSwzl);
|
||||
c = spvTextureSwizzle(tex2d.sample(tex2dSamp, float2(0.0), level(0.0)), tex2dSwzl);
|
||||
c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float3(0.0), level(0.0)), tex3dSwzl);
|
||||
|
@ -176,7 +176,7 @@ fragment void main0(constant spvAux& spvAuxBuffer [[buffer(0)]], texture1d<float
|
|||
c = spvTextureSwizzle(tex3d.sample(tex3dSamp, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), tex3dSwzl);
|
||||
float4 _202 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_202.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _202.xy / _202.z, float4(0.0, 0.0, 1.0, 1.0).z, level(0.0)), depth2dSwzl);
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSamp, _202.xy / _202.z, float4(0.0, 0.0, 1.0, 1.0).z / _202.z, level(0.0)), depth2dSwzl);
|
||||
c = spvTextureSwizzle(tex1d.read(uint(0)), tex1dSwzl);
|
||||
c = spvTextureSwizzle(tex2d.read(uint2(int2(0)), 0), tex2dSwzl);
|
||||
c = spvTextureSwizzle(tex3d.read(uint3(int3(0)), 0), tex3dSwzl);
|
||||
|
|
|
@ -153,7 +153,7 @@ float4 doSwizzle(thread texture1d<float> tex1d, thread const sampler tex1dSmplr,
|
|||
c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), tex3dSwzl);
|
||||
float4 _103 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_103.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _103.xy / _103.z, float4(0.0, 0.0, 1.0, 1.0).z), depth2dSwzl);
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _103.xy / _103.z, float4(0.0, 0.0, 1.0, 1.0).z / _103.z), depth2dSwzl);
|
||||
c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl);
|
||||
c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0), level(0.0)), tex2dSwzl);
|
||||
c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0), level(0.0)), tex3dSwzl);
|
||||
|
@ -166,7 +166,7 @@ float4 doSwizzle(thread texture1d<float> tex1d, thread const sampler tex1dSmplr,
|
|||
c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), tex3dSwzl);
|
||||
float4 _131 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_131.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _131.xy / _131.z, float4(0.0, 0.0, 1.0, 1.0).z, level(0.0)), depth2dSwzl);
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _131.xy / _131.z, float4(0.0, 0.0, 1.0, 1.0).z / _131.z, level(0.0)), depth2dSwzl);
|
||||
c = spvTextureSwizzle(tex1d.read(uint(0)), tex1dSwzl);
|
||||
c = spvTextureSwizzle(tex2d.read(uint2(int2(0)), 0), tex2dSwzl);
|
||||
c = spvTextureSwizzle(tex3d.read(uint3(int3(0)), 0), tex3dSwzl);
|
||||
|
|
|
@ -163,7 +163,7 @@ fragment void main0(constant spvAux& spvAuxBuffer [[buffer(0)]], texture1d<float
|
|||
c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), tex3dSwzl);
|
||||
float4 _100 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_100.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _100.xy / _100.z, float4(0.0, 0.0, 1.0, 1.0).z), depth2dSwzl);
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _100.xy / _100.z, float4(0.0, 0.0, 1.0, 1.0).z / _100.z), depth2dSwzl);
|
||||
c = spvTextureSwizzle(tex1d.sample(tex1dSmplr, 0.0), tex1dSwzl);
|
||||
c = spvTextureSwizzle(tex2d.sample(tex2dSmplr, float2(0.0), level(0.0)), tex2dSwzl);
|
||||
c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float3(0.0), level(0.0)), tex3dSwzl);
|
||||
|
@ -176,7 +176,7 @@ fragment void main0(constant spvAux& spvAuxBuffer [[buffer(0)]], texture1d<float
|
|||
c = spvTextureSwizzle(tex3d.sample(tex3dSmplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), tex3dSwzl);
|
||||
float4 _128 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_128.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _128.xy / _128.z, float4(0.0, 0.0, 1.0, 1.0).z, level(0.0)), depth2dSwzl);
|
||||
c.x = spvTextureSwizzle(depth2d.sample_compare(depth2dSmplr, _128.xy / _128.z, float4(0.0, 0.0, 1.0, 1.0).z / _128.z, level(0.0)), depth2dSwzl);
|
||||
c = spvTextureSwizzle(tex1d.read(uint(0)), tex1dSwzl);
|
||||
c = spvTextureSwizzle(tex2d.read(uint2(int2(0)), 0), tex2dSwzl);
|
||||
c = spvTextureSwizzle(tex3d.read(uint3(int3(0)), 0), tex3dSwzl);
|
||||
|
|
|
@ -158,7 +158,7 @@ float4 do_samples(thread const texture1d<float> t1, thread const sampler t1Smplr
|
|||
c = spvTextureSwizzle(t3.sample(t3Smplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w), t3Swzl);
|
||||
float4 _119 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_119.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _119.xy / _119.z, float4(0.0, 0.0, 1.0, 1.0).z), d2Swzl);
|
||||
c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _119.xy / _119.z, float4(0.0, 0.0, 1.0, 1.0).z / _119.z), d2Swzl);
|
||||
c = spvTextureSwizzle(t1.sample(t1Smplr, 0.0), t1Swzl);
|
||||
c = spvTextureSwizzle(t2.sample(defaultSampler, float2(0.0), level(0.0)), t2Swzl);
|
||||
c = spvTextureSwizzle(t3.sample(t3Smplr, float3(0.0), level(0.0)), t3Swzl);
|
||||
|
@ -171,7 +171,7 @@ float4 do_samples(thread const texture1d<float> t1, thread const sampler t1Smplr
|
|||
c = spvTextureSwizzle(t3.sample(t3Smplr, float4(0.0, 0.0, 0.0, 1.0).xyz / float4(0.0, 0.0, 0.0, 1.0).w, level(0.0)), t3Swzl);
|
||||
float4 _153 = float4(0.0, 0.0, 1.0, 1.0);
|
||||
_153.z = float4(0.0, 0.0, 1.0, 1.0).w;
|
||||
c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _153.xy / _153.z, float4(0.0, 0.0, 1.0, 1.0).z, level(0.0)), d2Swzl);
|
||||
c.x = spvTextureSwizzle(d2.sample_compare(d2Smplr, _153.xy / _153.z, float4(0.0, 0.0, 1.0, 1.0).z / _153.z, level(0.0)), d2Swzl);
|
||||
c = spvTextureSwizzle(t1.read(uint(0)), t1Swzl);
|
||||
c = spvTextureSwizzle(t2.read(uint2(int2(0)), 0), t2Swzl);
|
||||
c = spvTextureSwizzle(t3.read(uint3(int3(0)), 0), t3Swzl);
|
||||
|
|
|
@ -20,7 +20,7 @@ fragment main0_out main0(main0_in in [[stage_in]], depth2d<float> uShadow2D [[te
|
|||
main0_out out = {};
|
||||
float4 _20 = in.vClip4;
|
||||
_20.z = in.vClip4.w;
|
||||
out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z);
|
||||
out.FragColor = uShadow2D.sample_compare(uShadow2DSmplr, _20.xy / _20.z, in.vClip4.z / _20.z);
|
||||
out.FragColor = uSampler1D.sample(uSampler1DSmplr, in.vClip2.x / in.vClip2.y).x;
|
||||
out.FragColor = uSampler2D.sample(uSampler2DSmplr, in.vClip3.xy / in.vClip3.z).x;
|
||||
out.FragColor = uSampler3D.sample(uSampler3DSmplr, in.vClip4.xyz / in.vClip4.w).x;
|
||||
|
|
|
@ -1390,50 +1390,6 @@ void CompilerHLSL::emit_resources()
|
|||
}
|
||||
}
|
||||
|
||||
if (requires_textureProj)
|
||||
{
|
||||
if (hlsl_options.shader_model >= 40)
|
||||
{
|
||||
statement("float SPIRV_Cross_projectTextureCoordinate(float2 coord)");
|
||||
begin_scope();
|
||||
statement("return coord.x / coord.y;");
|
||||
end_scope();
|
||||
statement("");
|
||||
|
||||
statement("float2 SPIRV_Cross_projectTextureCoordinate(float3 coord)");
|
||||
begin_scope();
|
||||
statement("return float2(coord.x, coord.y) / coord.z;");
|
||||
end_scope();
|
||||
statement("");
|
||||
|
||||
statement("float3 SPIRV_Cross_projectTextureCoordinate(float4 coord)");
|
||||
begin_scope();
|
||||
statement("return float3(coord.x, coord.y, coord.z) / coord.w;");
|
||||
end_scope();
|
||||
statement("");
|
||||
}
|
||||
else
|
||||
{
|
||||
statement("float4 SPIRV_Cross_projectTextureCoordinate(float2 coord)");
|
||||
begin_scope();
|
||||
statement("return float4(coord.x, 0.0, 0.0, coord.y);");
|
||||
end_scope();
|
||||
statement("");
|
||||
|
||||
statement("float4 SPIRV_Cross_projectTextureCoordinate(float3 coord)");
|
||||
begin_scope();
|
||||
statement("return float4(coord.x, coord.y, 0.0, coord.z);");
|
||||
end_scope();
|
||||
statement("");
|
||||
|
||||
statement("float4 SPIRV_Cross_projectTextureCoordinate(float4 coord)");
|
||||
begin_scope();
|
||||
statement("return coord;");
|
||||
end_scope();
|
||||
statement("");
|
||||
}
|
||||
}
|
||||
|
||||
if (required_textureSizeVariants != 0)
|
||||
{
|
||||
static const char *types[QueryTypeCount] = { "float4", "int4", "uint4" };
|
||||
|
@ -2575,8 +2531,6 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
|||
if (dref)
|
||||
inherited_expressions.push_back(dref);
|
||||
|
||||
if (proj)
|
||||
coord_components++;
|
||||
if (imgtype.image.arrayed)
|
||||
coord_components++;
|
||||
|
||||
|
@ -2775,17 +2729,14 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
|||
bool forward = should_forward(coord);
|
||||
|
||||
// The IR can give us more components than we need, so chop them off as needed.
|
||||
auto coord_expr = to_expression(coord) + swizzle(coord_components, expression_type(coord).vecsize);
|
||||
string coord_expr;
|
||||
if (coord_components != expression_type(coord).vecsize)
|
||||
coord_expr = to_enclosed_expression(coord) + swizzle(coord_components, expression_type(coord).vecsize);
|
||||
else
|
||||
coord_expr = to_expression(coord);
|
||||
|
||||
if (proj)
|
||||
{
|
||||
if (!requires_textureProj)
|
||||
{
|
||||
requires_textureProj = true;
|
||||
force_recompile = true;
|
||||
}
|
||||
coord_expr = "SPIRV_Cross_projectTextureCoordinate(" + coord_expr + ")";
|
||||
}
|
||||
if (proj && hlsl_options.shader_model >= 40) // Legacy HLSL has "proj" operations which do this for us.
|
||||
coord_expr = coord_expr + " / " + to_extract_component_expression(coord, coord_components);
|
||||
|
||||
if (hlsl_options.shader_model < 40 && lod)
|
||||
{
|
||||
|
@ -2822,9 +2773,16 @@ void CompilerHLSL::emit_texture_op(const Instruction &i)
|
|||
|
||||
if (dref)
|
||||
{
|
||||
if (hlsl_options.shader_model < 40)
|
||||
SPIRV_CROSS_THROW("Legacy HLSL does not support comparison sampling.");
|
||||
|
||||
forward = forward && should_forward(dref);
|
||||
expr += ", ";
|
||||
expr += to_expression(dref);
|
||||
|
||||
if (proj)
|
||||
expr += to_enclosed_expression(dref) + " / " + to_extract_component_expression(coord, coord_components);
|
||||
else
|
||||
expr += to_expression(dref);
|
||||
}
|
||||
|
||||
if (!dref && (grad_x || grad_y))
|
||||
|
|
|
@ -184,7 +184,6 @@ private:
|
|||
|
||||
Options hlsl_options;
|
||||
bool requires_op_fmod = false;
|
||||
bool requires_textureProj = false;
|
||||
bool requires_fp16_packing = false;
|
||||
bool requires_explicit_fp16_packing = false;
|
||||
bool requires_unorm8_packing = false;
|
||||
|
|
|
@ -3503,32 +3503,30 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
|||
bool is_cube_fetch = false;
|
||||
|
||||
string tex_coords = coord_expr;
|
||||
const char *alt_coord = "";
|
||||
uint32_t alt_coord_component = 0;
|
||||
|
||||
switch (imgtype.image.dim)
|
||||
{
|
||||
|
||||
case Dim1D:
|
||||
if (coord_type.vecsize > 1)
|
||||
tex_coords += ".x";
|
||||
tex_coords = enclose_expression(tex_coords) + ".x";
|
||||
|
||||
if (is_fetch)
|
||||
tex_coords = "uint(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")";
|
||||
|
||||
alt_coord = ".y";
|
||||
|
||||
alt_coord_component = 1;
|
||||
break;
|
||||
|
||||
case DimBuffer:
|
||||
if (coord_type.vecsize > 1)
|
||||
tex_coords += ".x";
|
||||
tex_coords = enclose_expression(tex_coords) + ".x";
|
||||
|
||||
// Metal texel buffer textures are 2D, so convert 1D coord to 2D.
|
||||
if (is_fetch)
|
||||
tex_coords = "spvTexelBufferCoord(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")";
|
||||
|
||||
alt_coord = ".y";
|
||||
|
||||
alt_coord_component = 1;
|
||||
break;
|
||||
|
||||
case DimSubpassData:
|
||||
|
@ -3540,24 +3538,22 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
|||
|
||||
case Dim2D:
|
||||
if (coord_type.vecsize > 2)
|
||||
tex_coords += ".xy";
|
||||
tex_coords = enclose_expression(tex_coords) + ".xy";
|
||||
|
||||
if (is_fetch)
|
||||
tex_coords = "uint2(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")";
|
||||
|
||||
alt_coord = ".z";
|
||||
|
||||
alt_coord_component = 2;
|
||||
break;
|
||||
|
||||
case Dim3D:
|
||||
if (coord_type.vecsize > 3)
|
||||
tex_coords += ".xyz";
|
||||
tex_coords = enclose_expression(tex_coords) + ".xyz";
|
||||
|
||||
if (is_fetch)
|
||||
tex_coords = "uint3(" + round_fp_tex_coords(tex_coords, coord_is_fp) + ")";
|
||||
|
||||
alt_coord = ".w";
|
||||
|
||||
alt_coord_component = 3;
|
||||
break;
|
||||
|
||||
case DimCube:
|
||||
|
@ -3570,11 +3566,10 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
|||
else
|
||||
{
|
||||
if (coord_type.vecsize > 3)
|
||||
tex_coords += ".xyz";
|
||||
tex_coords = enclose_expression(tex_coords) + ".xyz";
|
||||
}
|
||||
|
||||
alt_coord = ".w";
|
||||
|
||||
alt_coord_component = 3;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
@ -3604,7 +3599,7 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
|||
|
||||
// If projection, use alt coord as divisor
|
||||
if (is_proj)
|
||||
tex_coords += " / " + coord_expr + alt_coord;
|
||||
tex_coords += " / " + to_extract_component_expression(coord, alt_coord_component);
|
||||
|
||||
if (!farg_str.empty())
|
||||
farg_str += ", ";
|
||||
|
@ -3615,9 +3610,9 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
|||
{
|
||||
// Special case for cube arrays, face and layer are packed in one dimension.
|
||||
if (imgtype.image.arrayed)
|
||||
farg_str += ", uint(" + join(coord_expr, ".z) % 6u");
|
||||
farg_str += ", uint(" + to_extract_component_expression(coord, 2) + ") % 6u";
|
||||
else
|
||||
farg_str += ", uint(" + round_fp_tex_coords(coord_expr + ".z", coord_is_fp) + ")";
|
||||
farg_str += ", uint(" + round_fp_tex_coords(to_extract_component_expression(coord, 2), coord_is_fp) + ")";
|
||||
}
|
||||
|
||||
// If array, use alt coord
|
||||
|
@ -3625,9 +3620,11 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
|||
{
|
||||
// Special case for cube arrays, face and layer are packed in one dimension.
|
||||
if (imgtype.image.dim == DimCube && is_fetch)
|
||||
farg_str += ", uint(" + join(coord_expr, ".z) / 6u");
|
||||
farg_str += ", uint(" + to_extract_component_expression(coord, 2) + ") / 6u";
|
||||
else
|
||||
farg_str += ", uint(" + round_fp_tex_coords(coord_expr + alt_coord, coord_is_fp) + ")";
|
||||
farg_str += ", uint(" +
|
||||
round_fp_tex_coords(to_extract_component_expression(coord, alt_coord_component), coord_is_fp) +
|
||||
")";
|
||||
}
|
||||
|
||||
// Depth compare reference value
|
||||
|
@ -3635,7 +3632,12 @@ string CompilerMSL::to_function_args(uint32_t img, const SPIRType &imgtype, bool
|
|||
{
|
||||
forward = forward && should_forward(dref);
|
||||
farg_str += ", ";
|
||||
farg_str += to_expression(dref);
|
||||
|
||||
if (is_proj)
|
||||
farg_str +=
|
||||
to_enclosed_expression(dref) + " / " + to_extract_component_expression(coord, alt_coord_component);
|
||||
else
|
||||
farg_str += to_expression(dref);
|
||||
|
||||
if (msl_options.is_macos() && (grad_x || grad_y))
|
||||
{
|
||||
|
|
Загрузка…
Ссылка в новой задаче