mirror of
https://github.com/KhronosGroup/glslang
synced 2024-11-09 12:00:05 +00:00
Fix HLSL offsets for non-cbuffers (#3668)
This commit is contained in:
parent
4b73607b89
commit
9f34b25f30
@ -5404,6 +5404,8 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType
|
||||
memberAlignment = componentAlignment;
|
||||
|
||||
// Don't add unnecessary padding after this member
|
||||
// (undo std140 bumping size to a mutliple of vec4)
|
||||
if (explicitLayout == glslang::ElpStd140) {
|
||||
if (memberType.isMatrix()) {
|
||||
if (matrixLayout == glslang::ElmRowMajor)
|
||||
memberSize -= componentSize * (4 - memberType.getMatrixCols());
|
||||
@ -5412,6 +5414,7 @@ void TGlslangToSpvTraverser::updateMemberOffset(const glslang::TType& structType
|
||||
} else if (memberType.isArray())
|
||||
memberSize -= componentSize * (4 - memberType.getVectorSize());
|
||||
}
|
||||
}
|
||||
|
||||
// Bump up to member alignment
|
||||
glslang::RoundToPow2(currentOffset, memberAlignment);
|
||||
|
81
Test/baseResults/hlsl.buffer-offsets.comp.out
Normal file
81
Test/baseResults/hlsl.buffer-offsets.comp.out
Normal file
@ -0,0 +1,81 @@
|
||||
hlsl.buffer-offsets.comp
|
||||
Shader version: 500
|
||||
local_size = (1, 1, 1)
|
||||
0:? Sequence
|
||||
0:12 Function Definition: @main( ( temp void)
|
||||
0:12 Function Parameters:
|
||||
0:12 Function Definition: main( ( temp void)
|
||||
0:12 Function Parameters:
|
||||
0:? Sequence
|
||||
0:12 Function Call: @main( ( temp void)
|
||||
0:? Linker Objects
|
||||
0:? 'bIterData' (layout( binding=2 row_major std430) readonly buffer block{layout( row_major std430) buffer unsized 1-element array of structure{ temp 24-element array of float mIntegrationTrafo, temp 3-element array of float mWind, temp uint mIsTurning} @data})
|
||||
|
||||
|
||||
Linked compute stage:
|
||||
|
||||
|
||||
Shader version: 500
|
||||
local_size = (1, 1, 1)
|
||||
0:? Sequence
|
||||
0:12 Function Definition: @main( ( temp void)
|
||||
0:12 Function Parameters:
|
||||
0:12 Function Definition: main( ( temp void)
|
||||
0:12 Function Parameters:
|
||||
0:? Sequence
|
||||
0:12 Function Call: @main( ( temp void)
|
||||
0:? Linker Objects
|
||||
0:? 'bIterData' (layout( binding=2 row_major std430) readonly buffer block{layout( row_major std430) buffer unsized 1-element array of structure{ temp 24-element array of float mIntegrationTrafo, temp 3-element array of float mWind, temp uint mIsTurning} @data})
|
||||
|
||||
// Module Version 10000
|
||||
// Generated by (magic number): 8000b
|
||||
// Id's are bound by 20
|
||||
|
||||
Capability Shader
|
||||
1: ExtInstImport "GLSL.std.450"
|
||||
MemoryModel Logical GLSL450
|
||||
EntryPoint GLCompute 4 "main"
|
||||
ExecutionMode 4 LocalSize 1 1 1
|
||||
Source HLSL 500
|
||||
Name 4 "main"
|
||||
Name 6 "@main("
|
||||
Name 15 "GfxIterationData"
|
||||
MemberName 15(GfxIterationData) 0 "mIntegrationTrafo"
|
||||
MemberName 15(GfxIterationData) 1 "mWind"
|
||||
MemberName 15(GfxIterationData) 2 "mIsTurning"
|
||||
Name 17 "bIterData"
|
||||
MemberName 17(bIterData) 0 "@data"
|
||||
Name 19 "bIterData"
|
||||
Decorate 12 ArrayStride 4
|
||||
Decorate 14 ArrayStride 4
|
||||
MemberDecorate 15(GfxIterationData) 0 Offset 0
|
||||
MemberDecorate 15(GfxIterationData) 1 Offset 96
|
||||
MemberDecorate 15(GfxIterationData) 2 Offset 108
|
||||
Decorate 16 ArrayStride 112
|
||||
Decorate 17(bIterData) BufferBlock
|
||||
MemberDecorate 17(bIterData) 0 NonWritable
|
||||
MemberDecorate 17(bIterData) 0 Offset 0
|
||||
Decorate 19(bIterData) Binding 2
|
||||
Decorate 19(bIterData) DescriptorSet 0
|
||||
2: TypeVoid
|
||||
3: TypeFunction 2
|
||||
9: TypeFloat 32
|
||||
10: TypeInt 32 0
|
||||
11: 10(int) Constant 24
|
||||
12: TypeArray 9(float) 11
|
||||
13: 10(int) Constant 3
|
||||
14: TypeArray 9(float) 13
|
||||
15(GfxIterationData): TypeStruct 12 14 10(int)
|
||||
16: TypeRuntimeArray 15(GfxIterationData)
|
||||
17(bIterData): TypeStruct 16
|
||||
18: TypePointer Uniform 17(bIterData)
|
||||
19(bIterData): 18(ptr) Variable Uniform
|
||||
4(main): 2 Function None 3
|
||||
5: Label
|
||||
8: 2 FunctionCall 6(@main()
|
||||
Return
|
||||
FunctionEnd
|
||||
6(@main(): 2 Function None 3
|
||||
7: Label
|
||||
Return
|
||||
FunctionEnd
|
13
Test/hlsl.buffer-offsets.comp
Normal file
13
Test/hlsl.buffer-offsets.comp
Normal file
@ -0,0 +1,13 @@
|
||||
// See https://github.com/KhronosGroup/glslang/issues/3668
|
||||
|
||||
struct GfxIterationData {
|
||||
float mIntegrationTrafo[24];
|
||||
float mWind[3];
|
||||
uint mIsTurning;
|
||||
};
|
||||
|
||||
StructuredBuffer<GfxIterationData> bIterData : register(t2);
|
||||
|
||||
void main()
|
||||
{
|
||||
}
|
@ -170,6 +170,7 @@ INSTANTIATE_TEST_SUITE_P(
|
||||
{"hlsl.basic.geom", "main"},
|
||||
{"hlsl.boolConv.vert", "main"},
|
||||
{"hlsl.buffer.frag", "PixelShaderFunction"},
|
||||
{"hlsl.buffer-offsets.comp", "main"},
|
||||
{"hlsl.calculatelod.dx10.frag", "main"},
|
||||
{"hlsl.calculatelodunclamped.dx10.frag", "main"},
|
||||
{"hlsl.cast.frag", "PixelShaderFunction"},
|
||||
|
Loading…
Reference in New Issue
Block a user