Remove duplicate swizzles in remap_swizzle.

Makes HLSL image-load-store look much nicer.
This commit is contained in:
Hans-Kristian Arntzen 2017-12-12 13:01:10 +01:00
Родитель 1c7980a778
Коммит ffad50b3c2
4 изменённых файлов: 11 добавлений и 9 удалений

Просмотреть файл

@ -13,7 +13,7 @@ void comp_main()
InterlockedAdd(uImage[int2(1, 5)], 1u, _19);
uint _27;
InterlockedAdd(uImage[int2(1, 5)], 1u, _27);
iImage[int2(1, 6)] = int(_27).xxxx.x;
iImage[int2(1, 6)] = int(_27).x;
uint _32;
InterlockedOr(uImage[int2(1, 5)], 1u, _32);
uint _34;

Просмотреть файл

@ -34,13 +34,13 @@ struct SPIRV_Cross_Input
void comp_main()
{
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;
uImageOutF[int2(gl_GlobalInvocationID.xy)] = uImageInF[int2(gl_GlobalInvocationID.xy)].x;
uImageOutI[int2(gl_GlobalInvocationID.xy)] = uImageInI[int2(gl_GlobalInvocationID.xy)].x;
uImageOutU[int2(gl_GlobalInvocationID.xy)] = uImageInU[int2(gl_GlobalInvocationID.xy)].x;
uImageOutBuffer[int(gl_GlobalInvocationID.x)] = uImageInBuffer[int(gl_GlobalInvocationID.x)].x;
uImageOutF2[int2(gl_GlobalInvocationID.xy)] = uImageInF2[int2(gl_GlobalInvocationID.xy)].xy;
uImageOutI2[int2(gl_GlobalInvocationID.xy)] = uImageInI2[int2(gl_GlobalInvocationID.xy)].xy;
uImageOutU2[int2(gl_GlobalInvocationID.xy)] = uImageInU2[int2(gl_GlobalInvocationID.xy)].xy;
float4 _135 = uImageInBuffer2[int(gl_GlobalInvocationID.x)].xyyy;
uImageOutBuffer2[int(gl_GlobalInvocationID.x)] = _135.xy;
uImageOutF4[int2(gl_GlobalInvocationID.xy)] = uImageInF4[int2(gl_GlobalInvocationID.xy)];

Просмотреть файл

@ -13,7 +13,7 @@ void comp_main()
InterlockedAdd(uImage[int2(1, 5)], 1u, _19);
uint _27;
InterlockedAdd(uImage[int2(1, 5)], 1u, _27);
iImage[int2(1, 6)] = int(_27).xxxx.x;
iImage[int2(1, 6)] = int(_27).x;
uint _32;
InterlockedOr(uImage[int2(1, 5)], 1u, _32);
uint _34;

Просмотреть файл

@ -1732,6 +1732,8 @@ string CompilerGLSL::remap_swizzle(const SPIRType &out_type, uint32_t input_comp
e += index_to_swizzle(min(c, input_components - 1));
if (backend.swizzle_is_function && out_type.vecsize > 1)
e += "()";
remove_duplicate_swizzle(e);
return e;
}
}