Merge pull request #729 from KhronosGroup/fix-728
HLSL: Use same logic as GLSL for picking cbuffer block name.
This commit is contained in:
commit
bfeb388edf
@ -1,9 +1,10 @@
|
||||
cbuffer _5 : register(b0)
|
||||
cbuffer _4_5 : register(b0)
|
||||
{
|
||||
column_major float2x4 _5_m0 : packoffset(c0);
|
||||
float4 _5_m1 : packoffset(c4);
|
||||
};
|
||||
|
||||
|
||||
static float2 _3;
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
|
@ -1,8 +1,9 @@
|
||||
cbuffer registers
|
||||
cbuffer Registers
|
||||
{
|
||||
float registers_foo : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float FragColor;
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
|
@ -1,12 +1,13 @@
|
||||
RWByteAddressBuffer _10 : register(u0);
|
||||
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
|
||||
{
|
||||
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
|
||||
uint3 SPIRV_Cross_NumWorkgroups_1_count : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count);
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_1_count);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
@ -1,9 +1,10 @@
|
||||
RWByteAddressBuffer _10 : register(u0);
|
||||
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
|
||||
{
|
||||
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
|
||||
uint3 SPIRV_Cross_NumWorkgroups_1_count : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static uint3 gl_WorkGroupID;
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
@ -12,7 +13,7 @@ struct SPIRV_Cross_Input
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count + gl_WorkGroupID);
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_1_count + gl_WorkGroupID);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
@ -1,10 +1,11 @@
|
||||
RWByteAddressBuffer _28 : register(u0);
|
||||
cbuffer _68 : register(b1)
|
||||
cbuffer UBO : register(b1)
|
||||
{
|
||||
int _68_index0 : packoffset(c0);
|
||||
int _68_index1 : packoffset(c0.y);
|
||||
};
|
||||
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
float4x4 _253 = asfloat(uint4x4(_28.Load(64), _28.Load(80), _28.Load(96), _28.Load(112), _28.Load(68), _28.Load(84), _28.Load(100), _28.Load(116), _28.Load(72), _28.Load(88), _28.Load(104), _28.Load(120), _28.Load(76), _28.Load(92), _28.Load(108), _28.Load(124)));
|
||||
|
@ -7,7 +7,7 @@ struct CBO_1
|
||||
};
|
||||
|
||||
ConstantBuffer<CBO_1> cbo[2][4] : register(b4, space0);
|
||||
cbuffer push
|
||||
cbuffer PushMe
|
||||
{
|
||||
float4 push_a : packoffset(c0);
|
||||
float4 push_b : packoffset(c1);
|
||||
@ -15,6 +15,7 @@ cbuffer push
|
||||
float4 push_d : packoffset(c3);
|
||||
};
|
||||
|
||||
|
||||
static float4 FragColor;
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
|
@ -1,11 +1,13 @@
|
||||
cbuffer cbuf : register(b3)
|
||||
cbuffer CBuffer : register(b3)
|
||||
{
|
||||
float4 cbuf_a : packoffset(c0);
|
||||
};
|
||||
cbuffer registers
|
||||
|
||||
cbuffer PushMe
|
||||
{
|
||||
float4 registers_d : packoffset(c0);
|
||||
};
|
||||
|
||||
Texture2D<float4> uSampledImage : register(t4);
|
||||
SamplerState _uSampledImage_sampler : register(s4);
|
||||
Texture2D<float4> uTexture : register(t5);
|
||||
|
@ -4,11 +4,12 @@ struct Foo
|
||||
row_major float4x4 w;
|
||||
};
|
||||
|
||||
cbuffer _17 : register(b0)
|
||||
cbuffer UBO : register(b0)
|
||||
{
|
||||
Foo _17_foo : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 FragColor;
|
||||
static float4 vUV;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
static const int Value = 2;
|
||||
|
||||
cbuffer _15 : register(b0)
|
||||
cbuffer SpecConstArray : register(b0)
|
||||
{
|
||||
float4 _15_samples[Value] : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 FragColor;
|
||||
static int Index;
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
cbuffer _16
|
||||
cbuffer UBO
|
||||
{
|
||||
row_major float4x4 _16_uMVP : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 gl_Position;
|
||||
static float4 aVertex;
|
||||
static float3 vNormal;
|
||||
|
@ -1,8 +1,9 @@
|
||||
cbuffer _104 : register(b0)
|
||||
cbuffer Block : register(b0)
|
||||
{
|
||||
column_major float2x3 _104_var[3][4] : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 gl_Position;
|
||||
static float4 a_position;
|
||||
static float v_vtxResult;
|
||||
|
@ -1,9 +1,10 @@
|
||||
cbuffer _5 : register(b0)
|
||||
cbuffer _4_5 : register(b0)
|
||||
{
|
||||
column_major float2x4 _5_m0 : packoffset(c0);
|
||||
float4 _5_m1 : packoffset(c4);
|
||||
};
|
||||
|
||||
|
||||
static float2 _3;
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
|
@ -1,8 +1,9 @@
|
||||
cbuffer registers
|
||||
cbuffer Registers
|
||||
{
|
||||
float registers_foo : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float FragColor;
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
|
@ -1,12 +1,13 @@
|
||||
RWByteAddressBuffer _10 : register(u0);
|
||||
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
|
||||
{
|
||||
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
|
||||
uint3 SPIRV_Cross_NumWorkgroups_1_count : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count);
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_1_count);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
@ -1,9 +1,10 @@
|
||||
RWByteAddressBuffer _10 : register(u0);
|
||||
cbuffer SPIRV_Cross_NumWorkgroups : register(b0)
|
||||
{
|
||||
uint3 SPIRV_Cross_NumWorkgroups_count : packoffset(c0);
|
||||
uint3 SPIRV_Cross_NumWorkgroups_1_count : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static uint3 gl_WorkGroupID;
|
||||
struct SPIRV_Cross_Input
|
||||
{
|
||||
@ -12,7 +13,7 @@ struct SPIRV_Cross_Input
|
||||
|
||||
void comp_main()
|
||||
{
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_count + gl_WorkGroupID);
|
||||
_10.Store3(0, SPIRV_Cross_NumWorkgroups_1_count + gl_WorkGroupID);
|
||||
}
|
||||
|
||||
[numthreads(1, 1, 1)]
|
||||
|
@ -1,10 +1,11 @@
|
||||
RWByteAddressBuffer _28 : register(u0);
|
||||
cbuffer _68 : register(b1)
|
||||
cbuffer UBO : register(b1)
|
||||
{
|
||||
int _68_index0 : packoffset(c0);
|
||||
int _68_index1 : packoffset(c0.y);
|
||||
};
|
||||
|
||||
|
||||
void row_to_col()
|
||||
{
|
||||
float4x4 _55 = asfloat(uint4x4(_28.Load(64), _28.Load(80), _28.Load(96), _28.Load(112), _28.Load(68), _28.Load(84), _28.Load(100), _28.Load(116), _28.Load(72), _28.Load(88), _28.Load(104), _28.Load(120), _28.Load(76), _28.Load(92), _28.Load(108), _28.Load(124)));
|
||||
|
@ -7,7 +7,7 @@ struct CBO_1
|
||||
};
|
||||
|
||||
ConstantBuffer<CBO_1> cbo[2][4] : register(b4, space0);
|
||||
cbuffer push
|
||||
cbuffer PushMe
|
||||
{
|
||||
float4 push_a : packoffset(c0);
|
||||
float4 push_b : packoffset(c1);
|
||||
@ -15,6 +15,7 @@ cbuffer push
|
||||
float4 push_d : packoffset(c3);
|
||||
};
|
||||
|
||||
|
||||
static float4 FragColor;
|
||||
|
||||
struct SPIRV_Cross_Output
|
||||
|
@ -6,11 +6,12 @@ struct B
|
||||
|
||||
static const B _80 = { 10.0f, 20.0f };
|
||||
|
||||
cbuffer _42 : register(b0)
|
||||
cbuffer UBO : register(b0)
|
||||
{
|
||||
int _42_some_value : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
void partial_inout(inout float4 x)
|
||||
{
|
||||
x.x = 10.0f;
|
||||
|
@ -1,11 +1,13 @@
|
||||
cbuffer cbuf : register(b3)
|
||||
cbuffer CBuffer : register(b3)
|
||||
{
|
||||
float4 cbuf_a : packoffset(c0);
|
||||
};
|
||||
cbuffer registers
|
||||
|
||||
cbuffer PushMe
|
||||
{
|
||||
float4 registers_d : packoffset(c0);
|
||||
};
|
||||
|
||||
Texture2D<float4> uSampledImage : register(t4);
|
||||
SamplerState _uSampledImage_sampler : register(s4);
|
||||
Texture2D<float4> uTexture : register(t5);
|
||||
|
@ -10,11 +10,12 @@ struct Foo
|
||||
row_major float4x4 w;
|
||||
};
|
||||
|
||||
cbuffer _17 : register(b0)
|
||||
cbuffer UBO : register(b0)
|
||||
{
|
||||
Foo _17_foo : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 FragColor;
|
||||
static float4 vUV;
|
||||
|
||||
|
@ -1,10 +1,11 @@
|
||||
static const int Value = 2;
|
||||
|
||||
cbuffer _15 : register(b0)
|
||||
cbuffer SpecConstArray : register(b0)
|
||||
{
|
||||
float4 _15_samples[Value] : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 FragColor;
|
||||
static int Index;
|
||||
|
||||
|
@ -1,8 +1,9 @@
|
||||
cbuffer _16
|
||||
cbuffer UBO
|
||||
{
|
||||
row_major float4x4 _16_uMVP : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 gl_Position;
|
||||
static float4 aVertex;
|
||||
static float3 vNormal;
|
||||
|
@ -1,8 +1,9 @@
|
||||
cbuffer _104 : register(b0)
|
||||
cbuffer Block : register(b0)
|
||||
{
|
||||
column_major float2x3 _104_var[3][4] : packoffset(c0);
|
||||
};
|
||||
|
||||
|
||||
static float4 gl_Position;
|
||||
static float4 a_position;
|
||||
static float v_vtxResult;
|
||||
|
@ -512,6 +512,8 @@ public:
|
||||
// For other names like remapped names for variables, etc, it's generally enough to query the name of the variables
|
||||
// after compiling, block names are an exception to this rule.
|
||||
// ID is the name of a variable as returned by Resource::id, and must be a variable with a Block-like type.
|
||||
//
|
||||
// This also applies to HLSL cbuffers.
|
||||
std::string get_remapped_declared_block_name(uint32_t id) const;
|
||||
|
||||
// For buffer block variables, get the decorations for that variable.
|
||||
|
@ -1858,9 +1858,25 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
|
||||
// this restriction is similar to GLSL where layout(offset) is not possible on sub-structs.
|
||||
flattened_structs.insert(var.self);
|
||||
|
||||
// Prefer the block name if possible.
|
||||
auto buffer_name = to_name(type.self, false);
|
||||
if (ir.meta[type.self].decoration.alias.empty() || resource_names.find(buffer_name) != end(resource_names))
|
||||
buffer_name = get_block_fallback_name(var.self);
|
||||
add_variable(resource_names, buffer_name);
|
||||
|
||||
// If for some reason buffer_name is an illegal name, make a final fallback to a workaround name.
|
||||
// This cannot conflict with anything else, so we're safe now.
|
||||
if (buffer_name.empty())
|
||||
buffer_name = join("_", get<SPIRType>(var.basetype).self, "_", var.self);
|
||||
|
||||
resource_names.insert(buffer_name);
|
||||
|
||||
// Save for post-reflection later.
|
||||
declared_block_names[var.self] = buffer_name;
|
||||
|
||||
type.member_name_cache.clear();
|
||||
add_resource_name(var.self);
|
||||
statement("cbuffer ", to_name(var.self), to_resource_binding(var));
|
||||
statement("cbuffer ", buffer_name, to_resource_binding(var));
|
||||
begin_scope();
|
||||
|
||||
uint32_t i = 0;
|
||||
@ -1876,6 +1892,7 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
|
||||
}
|
||||
|
||||
end_scope_decl();
|
||||
statement("");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user