Fix HLSL regression with struct declaration.
It actually worked surprisingly. Fix it properly.
This commit is contained in:
parent
921c555cf3
commit
06041985d0
44
reference/opt/shaders-hlsl/vert/struct-composite-decl.vert
Normal file
44
reference/opt/shaders-hlsl/vert/struct-composite-decl.vert
Normal file
@ -0,0 +1,44 @@
|
||||
struct VOut
|
||||
{
|
||||
float4 a;
|
||||
float4 b;
|
||||
float4 c;
|
||||
float4 d;
|
||||
};
|
||||
|
||||
static VOut vout;
|
||||
static float4 a;
|
||||
static float4 b;
|
||||
static float4 c;
|
||||
static float4 d;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float4 a : TEXCOORD0;
|
||||
float4 b : TEXCOORD1;
|
||||
float4 c : TEXCOORD2;
|
||||
float4 d : TEXCOORD3;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
VOut vout : TEXCOORD0;
|
||||
};
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
VOut _26 = { a, b, c, d };
|
||||
vout = _26;
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
a = stage_input.a;
|
||||
b = stage_input.b;
|
||||
c = stage_input.c;
|
||||
d = stage_input.d;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.vout = vout;
|
||||
return stage_output;
|
||||
}
|
50
reference/shaders-hlsl/vert/struct-composite-decl.vert
Normal file
50
reference/shaders-hlsl/vert/struct-composite-decl.vert
Normal file
@ -0,0 +1,50 @@
|
||||
struct VOut
|
||||
{
|
||||
float4 a;
|
||||
float4 b;
|
||||
float4 c;
|
||||
float4 d;
|
||||
};
|
||||
|
||||
static VOut vout;
|
||||
static float4 a;
|
||||
static float4 b;
|
||||
static float4 c;
|
||||
static float4 d;
|
||||
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
float4 a : TEXCOORD0;
|
||||
float4 b : TEXCOORD1;
|
||||
float4 c : TEXCOORD2;
|
||||
float4 d : TEXCOORD3;
|
||||
};
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
{
|
||||
VOut vout : TEXCOORD0;
|
||||
};
|
||||
|
||||
void emit_result(VOut v)
|
||||
{
|
||||
vout = v;
|
||||
}
|
||||
|
||||
void vert_main()
|
||||
{
|
||||
VOut _26 = { a, b, c, d };
|
||||
VOut param = _26;
|
||||
emit_result(param);
|
||||
}
|
||||
|
||||
SPIRV_Cross_Output main(SPIRV_Cross_Input stage_input)
|
||||
{
|
||||
a = stage_input.a;
|
||||
b = stage_input.b;
|
||||
c = stage_input.c;
|
||||
d = stage_input.d;
|
||||
vert_main();
|
||||
SPIRV_Cross_Output stage_output;
|
||||
stage_output.vout = vout;
|
||||
return stage_output;
|
||||
}
|
26
shaders-hlsl/vert/struct-composite-decl.vert
Normal file
26
shaders-hlsl/vert/struct-composite-decl.vert
Normal file
@ -0,0 +1,26 @@
|
||||
#version 310 es
|
||||
|
||||
layout(location = 0) in vec4 a;
|
||||
layout(location = 1) in vec4 b;
|
||||
layout(location = 2) in vec4 c;
|
||||
layout(location = 3) in vec4 d;
|
||||
|
||||
struct VOut
|
||||
{
|
||||
vec4 a;
|
||||
vec4 b;
|
||||
vec4 c;
|
||||
vec4 d;
|
||||
};
|
||||
|
||||
layout(location = 0) out VOut vout;
|
||||
|
||||
void emit_result(VOut v)
|
||||
{
|
||||
vout = v;
|
||||
}
|
||||
|
||||
void main()
|
||||
{
|
||||
emit_result(VOut(a, b, c, d));
|
||||
}
|
@ -5481,12 +5481,16 @@ void CompilerGLSL::emit_instruction(const Instruction &instruction)
|
||||
}
|
||||
}
|
||||
|
||||
if (out_type.basetype == SPIRType::Struct && !backend.can_declare_struct_inline)
|
||||
forward = false;
|
||||
|
||||
string constructor_op;
|
||||
if (backend.use_initializer_list && composite)
|
||||
{
|
||||
// Only use this path if we are building composites.
|
||||
// This path cannot be used for arithmetic.
|
||||
constructor_op += type_to_glsl_constructor(get<SPIRType>(result_type));
|
||||
if (backend.use_typed_initializer_list)
|
||||
constructor_op += type_to_glsl_constructor(get<SPIRType>(result_type));
|
||||
constructor_op += "{ ";
|
||||
if (splat)
|
||||
constructor_op += to_expression(elems[0]);
|
||||
|
@ -313,6 +313,8 @@ protected:
|
||||
bool flexible_member_array_supported = true;
|
||||
bool explicit_struct_type = false;
|
||||
bool use_initializer_list = false;
|
||||
bool use_typed_initializer_list = false;
|
||||
bool can_declare_struct_inline = true;
|
||||
bool native_row_major_matrix = true;
|
||||
bool use_constructor_splatting = true;
|
||||
bool boolean_mix_support = true;
|
||||
|
@ -3644,6 +3644,7 @@ string CompilerHLSL::compile()
|
||||
backend.use_constructor_splatting = false;
|
||||
backend.boolean_mix_support = false;
|
||||
backend.can_swizzle_scalar = true;
|
||||
backend.can_declare_struct_inline = false;
|
||||
|
||||
update_active_builtins();
|
||||
analyze_sampler_comparison_states();
|
||||
|
@ -69,6 +69,7 @@ string CompilerMSL::compile()
|
||||
backend.swizzle_is_function = false;
|
||||
backend.shared_is_implied = false;
|
||||
backend.use_initializer_list = true;
|
||||
backend.use_typed_initializer_list = true;
|
||||
backend.native_row_major_matrix = false;
|
||||
backend.flexible_member_array_supported = false;
|
||||
backend.force_temp_use_for_two_vector_shuffles = true;
|
||||
|
Loading…
Reference in New Issue
Block a user