Merge pull request #365 from KhronosGroup/fix-363

Validate HLSL output through FXC, fix various HLSL bugs.
This commit is contained in:
Hans-Kristian Arntzen 2017-12-12 16:06:25 +01:00 коммит произвёл GitHub
Родитель f7b1ac2e6a 51a48a7cef
Коммит fa27b56e26
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
35 изменённых файлов: 153 добавлений и 106 удалений

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

@ -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).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()
{
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;
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,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).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)

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

@ -10,27 +10,27 @@ layout(r32ui, binding = 5) uniform writeonly uimage2D uImageOutU;
layout(r32f, binding = 6) uniform readonly imageBuffer uImageInBuffer;
layout(r32f, binding = 7) uniform writeonly imageBuffer uImageOutBuffer;
layout(rg32f, binding = 0) uniform readonly image2D uImageInF2;
layout(rg32f, binding = 1) uniform writeonly image2D uImageOutF2;
layout(rg32i, binding = 2) uniform readonly iimage2D uImageInI2;
layout(rg32i, binding = 3) uniform writeonly iimage2D uImageOutI2;
layout(rg32ui, binding = 4) uniform readonly uimage2D uImageInU2;
layout(rg32ui, binding = 5) uniform writeonly uimage2D uImageOutU2;
layout(rg32f, binding = 6) uniform readonly imageBuffer uImageInBuffer2;
layout(rg32f, binding = 7) uniform writeonly imageBuffer uImageOutBuffer2;
layout(rg32f, binding = 8) uniform readonly image2D uImageInF2;
layout(rg32f, binding = 9) uniform writeonly image2D uImageOutF2;
layout(rg32i, binding = 10) uniform readonly iimage2D uImageInI2;
layout(rg32i, binding = 11) uniform writeonly iimage2D uImageOutI2;
layout(rg32ui, binding = 12) uniform readonly uimage2D uImageInU2;
layout(rg32ui, binding = 13) uniform writeonly uimage2D uImageOutU2;
layout(rg32f, binding = 14) uniform readonly imageBuffer uImageInBuffer2;
layout(rg32f, binding = 15) uniform writeonly imageBuffer uImageOutBuffer2;
layout(rgba32f, binding = 0) uniform readonly image2D uImageInF4;
layout(rgba32f, binding = 1) uniform writeonly image2D uImageOutF4;
layout(rgba32i, binding = 2) uniform readonly iimage2D uImageInI4;
layout(rgba32i, binding = 3) uniform writeonly iimage2D uImageOutI4;
layout(rgba32ui, binding = 4) uniform readonly uimage2D uImageInU4;
layout(rgba32ui, binding = 5) uniform writeonly uimage2D uImageOutU4;
layout(rgba32f, binding = 6) uniform readonly imageBuffer uImageInBuffer4;
layout(rgba32f, binding = 7) uniform writeonly imageBuffer uImageOutBuffer4;
layout(rgba32f, binding = 16) uniform readonly image2D uImageInF4;
layout(rgba32f, binding = 17) uniform writeonly image2D uImageOutF4;
layout(rgba32i, binding = 18) uniform readonly iimage2D uImageInI4;
layout(rgba32i, binding = 19) uniform writeonly iimage2D uImageOutI4;
layout(rgba32ui, binding = 20) uniform readonly uimage2D uImageInU4;
layout(rgba32ui, binding = 21) uniform writeonly uimage2D uImageOutU4;
layout(rgba32f, binding = 22) uniform readonly imageBuffer uImageInBuffer4;
layout(rgba32f, binding = 23) uniform writeonly imageBuffer uImageOutBuffer4;
layout(binding = 8) uniform writeonly image2D uImageNoFmtF;
layout(binding = 9) uniform writeonly uimage2D uImageNoFmtU;
layout(binding = 10) uniform writeonly iimage2D uImageNoFmtI;
layout(binding = 24) uniform writeonly image2D uImageNoFmtF;
layout(binding = 25) uniform writeonly uimage2D uImageNoFmtU;
layout(binding = 26) uniform writeonly iimage2D uImageNoFmtI;
void main()
{

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

@ -1,7 +1,7 @@
#version 310 es
precision mediump float;
layout(set = 0, binding = 1) uniform mediump sampler2D uSampler;
layout(set = 0, binding = 0) uniform mediump sampler2D uSampler;
layout(set = 0, binding = 1) uniform mediump sampler2DShadow uSamplerShadow;
layout(location = 0) out float FragColor;

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

@ -71,7 +71,10 @@ void main()
// Flexible sized arrays with spec constants and spec constant ops.
float vec0[c + 3][8];
float vec1[c + 2];
vec0[0][0] = 10.0;
vec1[0] = 20.0;
Foo foo;
foo.elems[c] = 10.0;
FragColor = vec4(t0 + t1) + vec0[0][0] + vec1[0] + foo.elems[c];
}

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

@ -1722,7 +1722,7 @@ string CompilerGLSL::remap_swizzle(const SPIRType &out_type, uint32_t input_comp
{
if (out_type.vecsize == input_components)
return expr;
else if (input_components == 1)
else if (input_components == 1 && !backend.can_swizzle_scalar)
return join(type_to_glsl(out_type), "(", expr, ")");
else
{
@ -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;
}
}
@ -5369,13 +5371,19 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
// Arrays and structs must be initialized properly in full.
bool composite = !out_type.array.empty() || out_type.basetype == SPIRType::Struct;
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;
@ -5390,6 +5398,10 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
constructor_op += build_composite_combiner(elems, length);
constructor_op += " }";
}
else if (swizzle_splat && !composite)
{
constructor_op = remap_swizzle(get<SPIRType>(result_type), 1, to_expression(elems[0]));
}
else
{
constructor_op = type_to_glsl_constructor(get<SPIRType>(result_type)) + "(";

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

@ -320,6 +320,7 @@ protected:
bool use_constructor_splatting = true;
bool boolean_mix_support = true;
bool allow_precision_qualifiers = false;
bool can_swizzle_scalar = false;
} backend;
void emit_struct(SPIRType &type);

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

@ -1232,7 +1232,10 @@ void CompilerHLSL::emit_resources()
if (has_lod[index])
statement("Tex.GetDimensions(Level, ret.x, Param);");
else
{
statement("Tex.GetDimensions(ret.x);");
statement("Param = 0u;");
}
break;
case 2:
if (has_lod[index])
@ -3596,6 +3599,7 @@ string CompilerHLSL::compile()
backend.use_initializer_list = true;
backend.use_constructor_splatting = false;
backend.boolean_mix_support = false;
backend.can_swizzle_scalar = true;
update_active_builtins();
analyze_sampler_comparison_states();

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

@ -105,10 +105,43 @@ def cross_compile_msl(shader, spirv, opt):
subprocess.check_call(['spirv-val', spirv_path])
return (spirv_path, msl_path)
def shader_model_hlsl(shader):
if '.vert' in shader:
return '-Tvs_5_1'
elif '.frag' in shader:
return '-Tps_5_1'
elif '.comp' in shader:
return '-Tcs_5_1'
else:
return None
def shader_to_win_path(shader):
# It's (very) convenient to be able to run HLSL testing in wine on Unix-likes, so support that.
try:
with subprocess.Popen(['winepath', '-w', shader], stdout = subprocess.PIPE, stderr = subprocess.PIPE) as f:
stdout_data, stderr_data = f.communicate()
return stdout_data.decode('utf-8')
except OSError as oe:
if (oe.errno != os.errno.ENOENT): # Ignore not found errors
return shader
except subprocess.CalledProcessError:
raise
return shader
def validate_shader_hlsl(shader):
subprocess.check_call(['glslangValidator', '-e', 'main', '-D', '-V', shader])
if (not force_no_external_validation) and os.path.exists('fxc'):
subprocess.check_call(['fxc', shader])
is_no_fxc = '.nofxc.' in shader
if (not force_no_external_validation) and (not is_no_fxc):
try:
win_path = shader_to_win_path(shader)
subprocess.check_call(['fxc', '-nologo', shader_model_hlsl(shader), win_path])
except OSError as oe:
if (oe.errno != os.errno.ENOENT): # Ignore not found errors
raise
except subprocess.CalledProcessError:
print('Failed compiling HLSL shader:', shader, 'with FXC.')
sys.exit(1)
def shader_to_sm(shader):
if '.sm51.' in shader:

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

@ -3,7 +3,7 @@
echo "Building spirv-cross"
make -j$(nproc)
export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:$PATH"
export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:.:$PATH"
echo "Using glslangValidation in: $(which glslangValidator)."
echo "Using spirv-opt in: $(which spirv-opt)."

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

@ -3,7 +3,7 @@
echo "Building spirv-cross"
make -j$(nproc)
export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:$PATH"
export PATH="./external/glslang-build/StandAlone:./external/spirv-tools-build/tools:.:$PATH"
echo "Using glslangValidation in: $(which glslangValidator)."
echo "Using spirv-opt in: $(which spirv-opt)."