Swizzle scalars when splatting in HLSL.
This commit is contained in:
parent
950732512e
commit
1c7980a778
@ -14,8 +14,7 @@ struct SPIRV_Cross_Output
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
float _23 = float(gl_VertexID + gl_InstanceID);
|
||||
gl_Position = float4(_23, _23, _23, _23);
|
||||
gl_Position = float(gl_VertexID + gl_InstanceID).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
@ -5,7 +5,7 @@ RWByteAddressBuffer ReadWrite : register(u1);
|
||||
void comp_main()
|
||||
{
|
||||
WriteOnly.Store4(0, asuint(asfloat(ReadOnly.Load4(0))));
|
||||
ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + float4(10.0f, 10.0f, 10.0f, 10.0f)));
|
||||
ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + 10.0f.xxxx));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
@ -13,8 +13,7 @@ void comp_main()
|
||||
InterlockedAdd(uImage[int2(1, 5)], 1u, _19);
|
||||
uint _27;
|
||||
InterlockedAdd(uImage[int2(1, 5)], 1u, _27);
|
||||
int _28 = int(_27);
|
||||
iImage[int2(1, 6)] = int4(_28, _28, _28, _28).x;
|
||||
iImage[int2(1, 6)] = int(_27).xxxx.x;
|
||||
uint _32;
|
||||
InterlockedOr(uImage[int2(1, 5)], 1u, _32);
|
||||
uint _34;
|
||||
|
@ -6,25 +6,25 @@ RWTexture2D<uint> uImageInU : register(u4);
|
||||
RWTexture2D<uint> uImageOutU : register(u5);
|
||||
RWBuffer<float> uImageInBuffer : register(u6);
|
||||
RWBuffer<float> uImageOutBuffer : register(u7);
|
||||
RWTexture2D<float2> uImageInF2 : register(u0);
|
||||
RWTexture2D<float2> uImageOutF2 : register(u1);
|
||||
RWTexture2D<int2> uImageInI2 : register(u2);
|
||||
RWTexture2D<int2> uImageOutI2 : register(u3);
|
||||
RWTexture2D<uint2> uImageInU2 : register(u4);
|
||||
RWTexture2D<uint2> uImageOutU2 : register(u5);
|
||||
RWBuffer<float2> uImageInBuffer2 : register(u6);
|
||||
RWBuffer<float2> uImageOutBuffer2 : register(u7);
|
||||
RWTexture2D<float4> uImageInF4 : register(u0);
|
||||
RWTexture2D<float4> uImageOutF4 : register(u1);
|
||||
RWTexture2D<int4> uImageInI4 : register(u2);
|
||||
RWTexture2D<int4> uImageOutI4 : register(u3);
|
||||
RWTexture2D<uint4> uImageInU4 : register(u4);
|
||||
RWTexture2D<uint4> uImageOutU4 : register(u5);
|
||||
RWBuffer<float4> uImageInBuffer4 : register(u6);
|
||||
RWBuffer<float4> uImageOutBuffer4 : register(u7);
|
||||
RWTexture2D<float4> uImageNoFmtF : register(u8);
|
||||
RWTexture2D<uint4> uImageNoFmtU : register(u9);
|
||||
RWTexture2D<int4> uImageNoFmtI : register(u10);
|
||||
RWTexture2D<float2> uImageInF2 : register(u8);
|
||||
RWTexture2D<float2> uImageOutF2 : register(u9);
|
||||
RWTexture2D<int2> uImageInI2 : register(u10);
|
||||
RWTexture2D<int2> uImageOutI2 : register(u11);
|
||||
RWTexture2D<uint2> uImageInU2 : register(u12);
|
||||
RWTexture2D<uint2> uImageOutU2 : register(u13);
|
||||
RWBuffer<float2> uImageInBuffer2 : register(u14);
|
||||
RWBuffer<float2> uImageOutBuffer2 : register(u15);
|
||||
RWTexture2D<float4> uImageInF4 : register(u16);
|
||||
RWTexture2D<float4> uImageOutF4 : register(u17);
|
||||
RWTexture2D<int4> uImageInI4 : register(u18);
|
||||
RWTexture2D<int4> uImageOutI4 : register(u19);
|
||||
RWTexture2D<uint4> uImageInU4 : register(u20);
|
||||
RWTexture2D<uint4> uImageOutU4 : register(u21);
|
||||
RWBuffer<float4> uImageInBuffer4 : register(u22);
|
||||
RWBuffer<float4> uImageOutBuffer4 : register(u23);
|
||||
RWTexture2D<float4> uImageNoFmtF : register(u24);
|
||||
RWTexture2D<uint4> uImageNoFmtU : register(u25);
|
||||
RWTexture2D<int4> uImageNoFmtI : register(u26);
|
||||
|
||||
static uint3 gl_GlobalInvocationID;
|
||||
struct SPIRV_Cross_Input
|
||||
@ -34,10 +34,10 @@ struct SPIRV_Cross_Input
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
uImageOutF[int2(gl_GlobalInvocationID.xy)] = float4(uImageInF[int2(gl_GlobalInvocationID.xy)]).x;
|
||||
uImageOutI[int2(gl_GlobalInvocationID.xy)] = int4(uImageInI[int2(gl_GlobalInvocationID.xy)]).x;
|
||||
uImageOutU[int2(gl_GlobalInvocationID.xy)] = uint4(uImageInU[int2(gl_GlobalInvocationID.xy)]).x;
|
||||
uImageOutBuffer[int(gl_GlobalInvocationID.x)] = float4(uImageInBuffer[int(gl_GlobalInvocationID.x)]).x;
|
||||
uImageOutF[int2(gl_GlobalInvocationID.xy)] = uImageInF[int2(gl_GlobalInvocationID.xy)].xxxx.x;
|
||||
uImageOutI[int2(gl_GlobalInvocationID.xy)] = uImageInI[int2(gl_GlobalInvocationID.xy)].xxxx.x;
|
||||
uImageOutU[int2(gl_GlobalInvocationID.xy)] = uImageInU[int2(gl_GlobalInvocationID.xy)].xxxx.x;
|
||||
uImageOutBuffer[int(gl_GlobalInvocationID.x)] = uImageInBuffer[int(gl_GlobalInvocationID.x)].xxxx.x;
|
||||
uImageOutF2[int2(gl_GlobalInvocationID.xy)] = uImageInF2[int2(gl_GlobalInvocationID.xy)].xyyy.xy;
|
||||
uImageOutI2[int2(gl_GlobalInvocationID.xy)] = uImageInI2[int2(gl_GlobalInvocationID.xy)].xyyy.xy;
|
||||
uImageOutU2[int2(gl_GlobalInvocationID.xy)] = uImageInU2[int2(gl_GlobalInvocationID.xy)].xyyy.xy;
|
||||
|
@ -13,8 +13,7 @@ struct SPIRV_Cross_Output
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
bool _21 = x0.x > x0.y;
|
||||
bool2 _27 = bool2(_21, _21);
|
||||
bool2 _27 = (x0.x > x0.y).xx;
|
||||
FragColor = float2(_27.x ? float2(1.0f, 0.0f).x : float2(0.0f, 1.0f).x, _27.y ? float2(1.0f, 0.0f).y : float2(0.0f, 1.0f).y);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
Texture2D<float4> uSampler : register(t1);
|
||||
SamplerState _uSampler_sampler : register(s1);
|
||||
Texture2D<float4> uSampler : register(t0);
|
||||
SamplerState _uSampler_sampler : register(s0);
|
||||
Texture2D<float4> uSamplerShadow : register(t1);
|
||||
SamplerComparisonState _uSamplerShadow_sampler : register(s1);
|
||||
|
||||
|
@ -47,8 +47,7 @@ float4 mod(float4 x, float4 y)
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float _41 = mod(a1, b1);
|
||||
FragColor = ((mod(a4, b4) + mod(a3, b3).xyzx) + mod(a2, b2).xyxy) + float4(_41, _41, _41, _41);
|
||||
FragColor = ((mod(a4, b4) + mod(a3, b3).xyzx) + mod(a2, b2).xyxy) + mod(a1, b1).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
@ -15,14 +15,13 @@ struct SPIRV_Cross_Output
|
||||
float4 FragColor : SV_Target0;
|
||||
};
|
||||
|
||||
float _146[(c + 2)];
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
float _113 = a + b;
|
||||
float vec0[(c + 3)][8];
|
||||
vec0[0][0] = 10.0f;
|
||||
Foo foo;
|
||||
FragColor = ((float4(_113, _113, _113, _113) + float4(vec0[0][0], vec0[0][0], vec0[0][0], vec0[0][0])) + float4(_146[0], _146[0], _146[0], _146[0])) + float4(foo.elems[c], foo.elems[c], foo.elems[c], foo.elems[c]);
|
||||
foo.elems[c] = 10.0f;
|
||||
FragColor = (((a + b).xxxx + vec0[0][0].xxxx) + 20.0f.xxxx) + foo.elems[c].xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main()
|
||||
|
@ -14,8 +14,7 @@ struct SPIRV_Cross_Output
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
float _19 = float(gl_VertexIndex + gl_InstanceIndex);
|
||||
gl_Position = float4(_19, _19, _19, _19);
|
||||
gl_Position = float(gl_VertexIndex + gl_InstanceIndex).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
@ -14,8 +14,7 @@ struct SPIRV_Cross_Output
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
float _23 = float(gl_VertexID + gl_InstanceID);
|
||||
gl_Position = float4(_23, _23, _23, _23);
|
||||
gl_Position = float(gl_VertexID + gl_InstanceID).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
@ -5,7 +5,7 @@ RWByteAddressBuffer ReadWrite : register(u1);
|
||||
void comp_main()
|
||||
{
|
||||
WriteOnly.Store4(0, asuint(asfloat(ReadOnly.Load4(0))));
|
||||
ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + float4(10.0f, 10.0f, 10.0f, 10.0f)));
|
||||
ReadWrite.Store4(0, asuint(asfloat(ReadWrite.Load4(0)) + 10.0f.xxxx));
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
@ -13,8 +13,7 @@ void comp_main()
|
||||
InterlockedAdd(uImage[int2(1, 5)], 1u, _19);
|
||||
uint _27;
|
||||
InterlockedAdd(uImage[int2(1, 5)], 1u, _27);
|
||||
int _28 = int(_27);
|
||||
iImage[int2(1, 6)] = int4(_28, _28, _28, _28).x;
|
||||
iImage[int2(1, 6)] = int(_27).xxxx.x;
|
||||
uint _32;
|
||||
InterlockedOr(uImage[int2(1, 5)], 1u, _32);
|
||||
uint _34;
|
||||
|
@ -6,25 +6,25 @@ RWTexture2D<uint> uImageInU : register(u4);
|
||||
RWTexture2D<uint> uImageOutU : register(u5);
|
||||
RWBuffer<float> uImageInBuffer : register(u6);
|
||||
RWBuffer<float> uImageOutBuffer : register(u7);
|
||||
RWTexture2D<float2> uImageInF2 : register(u0);
|
||||
RWTexture2D<float2> uImageOutF2 : register(u1);
|
||||
RWTexture2D<int2> uImageInI2 : register(u2);
|
||||
RWTexture2D<int2> uImageOutI2 : register(u3);
|
||||
RWTexture2D<uint2> uImageInU2 : register(u4);
|
||||
RWTexture2D<uint2> uImageOutU2 : register(u5);
|
||||
RWBuffer<float2> uImageInBuffer2 : register(u6);
|
||||
RWBuffer<float2> uImageOutBuffer2 : register(u7);
|
||||
RWTexture2D<float4> uImageInF4 : register(u0);
|
||||
RWTexture2D<float4> uImageOutF4 : register(u1);
|
||||
RWTexture2D<int4> uImageInI4 : register(u2);
|
||||
RWTexture2D<int4> uImageOutI4 : register(u3);
|
||||
RWTexture2D<uint4> uImageInU4 : register(u4);
|
||||
RWTexture2D<uint4> uImageOutU4 : register(u5);
|
||||
RWBuffer<float4> uImageInBuffer4 : register(u6);
|
||||
RWBuffer<float4> uImageOutBuffer4 : register(u7);
|
||||
RWTexture2D<float4> uImageNoFmtF : register(u8);
|
||||
RWTexture2D<uint4> uImageNoFmtU : register(u9);
|
||||
RWTexture2D<int4> uImageNoFmtI : register(u10);
|
||||
RWTexture2D<float2> uImageInF2 : register(u8);
|
||||
RWTexture2D<float2> uImageOutF2 : register(u9);
|
||||
RWTexture2D<int2> uImageInI2 : register(u10);
|
||||
RWTexture2D<int2> uImageOutI2 : register(u11);
|
||||
RWTexture2D<uint2> uImageInU2 : register(u12);
|
||||
RWTexture2D<uint2> uImageOutU2 : register(u13);
|
||||
RWBuffer<float2> uImageInBuffer2 : register(u14);
|
||||
RWBuffer<float2> uImageOutBuffer2 : register(u15);
|
||||
RWTexture2D<float4> uImageInF4 : register(u16);
|
||||
RWTexture2D<float4> uImageOutF4 : register(u17);
|
||||
RWTexture2D<int4> uImageInI4 : register(u18);
|
||||
RWTexture2D<int4> uImageOutI4 : register(u19);
|
||||
RWTexture2D<uint4> uImageInU4 : register(u20);
|
||||
RWTexture2D<uint4> uImageOutU4 : register(u21);
|
||||
RWBuffer<float4> uImageInBuffer4 : register(u22);
|
||||
RWBuffer<float4> uImageOutBuffer4 : register(u23);
|
||||
RWTexture2D<float4> uImageNoFmtF : register(u24);
|
||||
RWTexture2D<uint4> uImageNoFmtU : register(u25);
|
||||
RWTexture2D<int4> uImageNoFmtI : register(u26);
|
||||
|
||||
static uint3 gl_GlobalInvocationID;
|
||||
struct SPIRV_Cross_Input
|
||||
@ -34,13 +34,13 @@ struct SPIRV_Cross_Input
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
float4 f = float4(uImageInF[int2(gl_GlobalInvocationID.xy)]);
|
||||
float4 f = uImageInF[int2(gl_GlobalInvocationID.xy)].xxxx;
|
||||
uImageOutF[int2(gl_GlobalInvocationID.xy)] = f.x;
|
||||
int4 i = int4(uImageInI[int2(gl_GlobalInvocationID.xy)]);
|
||||
int4 i = uImageInI[int2(gl_GlobalInvocationID.xy)].xxxx;
|
||||
uImageOutI[int2(gl_GlobalInvocationID.xy)] = i.x;
|
||||
uint4 u = uint4(uImageInU[int2(gl_GlobalInvocationID.xy)]);
|
||||
uint4 u = uImageInU[int2(gl_GlobalInvocationID.xy)].xxxx;
|
||||
uImageOutU[int2(gl_GlobalInvocationID.xy)] = u.x;
|
||||
float4 b = float4(uImageInBuffer[int(gl_GlobalInvocationID.x)]);
|
||||
float4 b = uImageInBuffer[int(gl_GlobalInvocationID.x)].xxxx;
|
||||
uImageOutBuffer[int(gl_GlobalInvocationID.x)] = b.x;
|
||||
float4 f2 = uImageInF2[int2(gl_GlobalInvocationID.xy)].xyyy;
|
||||
uImageOutF2[int2(gl_GlobalInvocationID.xy)] = f2.xy;
|
||||
|
@ -13,8 +13,7 @@ struct SPIRV_Cross_Output
|
||||
|
||||
void frag_main()
|
||||
{
|
||||
bool _21 = x0.x > x0.y;
|
||||
bool2 _27 = bool2(_21, _21);
|
||||
bool2 _27 = (x0.x > x0.y).xx;
|
||||
FragColor = float2(_27.x ? float2(1.0f, 0.0f).x : float2(0.0f, 1.0f).x, _27.y ? float2(1.0f, 0.0f).y : float2(0.0f, 1.0f).y);
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
Texture2D<float4> uSampler : register(t1);
|
||||
SamplerState _uSampler_sampler : register(s1);
|
||||
Texture2D<float4> uSampler : register(t0);
|
||||
SamplerState _uSampler_sampler : register(s0);
|
||||
Texture2D<float4> uSamplerShadow : register(t1);
|
||||
SamplerComparisonState _uSamplerShadow_sampler : register(s1);
|
||||
|
||||
|
@ -66,6 +66,7 @@ uint SPIRV_Cross_textureSize(Buffer<float4> Tex, uint Level, out uint Param)
|
||||
{
|
||||
uint ret;
|
||||
Tex.GetDimensions(ret.x);
|
||||
Param = 0u;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -48,6 +48,7 @@ uint SPIRV_Cross_textureSize(Buffer<float4> Tex, uint Level, out uint Param)
|
||||
{
|
||||
uint ret;
|
||||
Tex.GetDimensions(ret.x);
|
||||
Param = 0u;
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,7 @@ void frag_main()
|
||||
float3 m1 = mod(a3, b3);
|
||||
float2 m2 = mod(a2, b2);
|
||||
float m3 = mod(a1, b1);
|
||||
FragColor = ((m0 + m1.xyzx) + m2.xyxy) + float4(m3, m3, m3, m3);
|
||||
FragColor = ((m0 + m1.xyzx) + m2.xyxy) + m3.xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
@ -61,11 +61,13 @@ void frag_main()
|
||||
int c35 = int(g);
|
||||
uint c36 = uint(g);
|
||||
float c37 = float(g);
|
||||
float _113 = t0 + t1;
|
||||
float vec0[(c + 3)][8];
|
||||
vec0[0][0] = 10.0f;
|
||||
float vec1[(c + 2)];
|
||||
vec1[0] = 20.0f;
|
||||
Foo foo;
|
||||
FragColor = ((float4(_113, _113, _113, _113) + float4(vec0[0][0], vec0[0][0], vec0[0][0], vec0[0][0])) + float4(vec1[0], vec1[0], vec1[0], vec1[0])) + float4(foo.elems[c], foo.elems[c], foo.elems[c], foo.elems[c]);
|
||||
foo.elems[c] = 10.0f;
|
||||
FragColor = (((t0 + t1).xxxx + vec0[0][0].xxxx) + vec1[0].xxxx) + foo.elems[c].xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main()
|
||||
|
@ -14,8 +14,7 @@ struct SPIRV_Cross_Output
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
float _19 = float(gl_VertexIndex + gl_InstanceIndex);
|
||||
gl_Position = float4(_19, _19, _19, _19);
|
||||
gl_Position = float(gl_VertexIndex + gl_InstanceIndex).xxxx;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
|
@ -5371,12 +5371,17 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
bool splat = in_type.vecsize == 1 && in_type.columns == 1 && !composite && backend.use_constructor_splatting;
|
||||
bool swizzle_splat = in_type.vecsize == 1 && in_type.columns == 1 && backend.can_swizzle_scalar;
|
||||
|
||||
if (splat)
|
||||
if (splat || swizzle_splat)
|
||||
{
|
||||
uint32_t input = elems[0];
|
||||
for (uint32_t i = 0; i < length; i++)
|
||||
{
|
||||
if (input != elems[i])
|
||||
{
|
||||
splat = false;
|
||||
swizzle_splat = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
string constructor_op;
|
||||
@ -5391,7 +5396,7 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
constructor_op += build_composite_combiner(elems, length);
|
||||
constructor_op += " }";
|
||||
}
|
||||
else if (splat && swizzle_splat && !composite)
|
||||
else if (swizzle_splat && !composite)
|
||||
{
|
||||
constructor_op = remap_swizzle(get<SPIRType>(result_type), 1, to_expression(elems[0]));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user