HLSL: Report which cbuffer failed validation.
This commit is contained in:
parent
b56c2f4271
commit
e73d9bee38
@ -1867,11 +1867,6 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
|
||||
{
|
||||
if (type.array.empty())
|
||||
{
|
||||
if (buffer_is_packing_standard(type, BufferPackingHLSLCbufferPackOffset))
|
||||
set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset);
|
||||
else
|
||||
SPIRV_CROSS_THROW("cbuffer cannot be expressed with either HLSL packing layout or packoffset.");
|
||||
|
||||
// Flatten the top-level struct so we can use packoffset,
|
||||
// this restriction is similar to GLSL where layout(offset) is not possible on sub-structs.
|
||||
flattened_structs.insert(var.self);
|
||||
@ -1892,6 +1887,14 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
|
||||
if (buffer_name.empty())
|
||||
buffer_name = join("_", get<SPIRType>(var.basetype).self, "_", var.self);
|
||||
|
||||
if (buffer_is_packing_standard(type, BufferPackingHLSLCbufferPackOffset))
|
||||
set_extended_decoration(type.self, SPIRVCrossDecorationExplicitOffset);
|
||||
else
|
||||
{
|
||||
SPIRV_CROSS_THROW(join("cbuffer ID ", var.self, " (name: ", buffer_name,
|
||||
") cannot be expressed with either HLSL packing layout or packoffset."));
|
||||
}
|
||||
|
||||
block_names.insert(buffer_name);
|
||||
|
||||
// Save for post-reflection later.
|
||||
@ -1927,13 +1930,16 @@ void CompilerHLSL::emit_buffer_block(const SPIRVariable &var)
|
||||
SPIRV_CROSS_THROW(
|
||||
"Need ConstantBuffer<T> to use arrays of UBOs, but this is only supported in SM 5.1.");
|
||||
|
||||
// ConstantBuffer<T> does not support packoffset, so it is unuseable unless everything aligns as we expect.
|
||||
if (!buffer_is_packing_standard(type, BufferPackingHLSLCbuffer))
|
||||
SPIRV_CROSS_THROW("HLSL ConstantBuffer<T> cannot be expressed with normal HLSL packing rules.");
|
||||
|
||||
add_resource_name(type.self);
|
||||
add_resource_name(var.self);
|
||||
|
||||
// ConstantBuffer<T> does not support packoffset, so it is unuseable unless everything aligns as we expect.
|
||||
if (!buffer_is_packing_standard(type, BufferPackingHLSLCbuffer))
|
||||
{
|
||||
SPIRV_CROSS_THROW(join("HLSL ConstantBuffer<T> ID ", var.self, " (name: ", to_name(type.self),
|
||||
") cannot be expressed with normal HLSL packing rules."));
|
||||
}
|
||||
|
||||
emit_struct(get<SPIRType>(type.self));
|
||||
statement("ConstantBuffer<", to_name(type.self), "> ", to_name(var.self), type_to_array_glsl(type),
|
||||
to_resource_binding(var), ";");
|
||||
|
Loading…
Reference in New Issue
Block a user