It seems that the current disassembler is always using cbuffer layout rules regardless of the resource type when printing the layout preamble.
For example, for the following source code:
cbuffer MyCbuffer {
float3 CB_a;
int CB_b[3];
float3 CB_c;
}
struct S {
float3 a;
int b[3];
float3 c;
};
StructuredBuffer<S> MySBuffer;
float4 main() : SV_Target {
return CB_a[0] + MySBuffer[0].c[0];
}
fxc.exe -T ps_5_1 generates the following preamble:
// Buffer Definitions:
//
// cbuffer MyCbuffer
// {
//
// float3 CB_a; // Offset: 0 Size: 12
// int CB_b[3]; // Offset: 16 Size: 36 [unused]
// float3 CB_c; // Offset: 52 Size: 12 [unused]
//
// }
//
// Resource bind info for MySBuffer
// {
//
// struct S
// {
//
// float3 a; // Offset: 0
// int b[3]; // Offset: 12
// float3 c; // Offset: 24
//
// } $Element; // Offset: 0 Size: 36
//
// }
But dxc.exe -T ps_5_1 generates the following:
; cbuffer MyCbuffer
; {
;
; struct MyCbuffer
; {
;
; float3 CB_a; ; Offset: 0
; int CB_b[3]; ; Offset: 16
; float3 CB_c; ; Offset: 52
;
; } MyCbuffer ; Offset: 0 Size: 64
;
; }
;
; Resource bind info for MySBuffer
; {
;
; struct struct.S
; {
;
; float3 a; ; Offset: 0
; int b[3]; ; Offset: 16
; float3 c; ; Offset: 52
;
; } $Element; ; Offset: 0 Size: 36
;
; }
The DXIL bufferLoad function call is consistent with fxc.exe about S::c's offset (24):
%3 = call %dx.types.ResRet.f32 @dx.op.bufferLoad.f32(i32 68, %dx.types.Handle %MySBuffer_texture_structbuf, i32 0, i32 24) ; BufferLoad(srv,index,wot)
%4 = extractvalue %dx.types.ResRet.f32 %3, 0
It seems that the current disassembler is always using cbuffer layout rules regardless of the resource type when printing the layout preamble.
For example, for the following source code:
fxc.exe -T ps_5_1generates the following preamble:But
dxc.exe -T ps_5_1generates the following:The DXIL
bufferLoadfunction call is consistent withfxc.exeaboutS::c's offset (24):