mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Move scalar-offset calculating helper into common DXBC code
This commit is contained in:
@@ -434,6 +434,7 @@ struct CBufferVariableType
|
||||
rdcarray<CBufferVariable> members;
|
||||
};
|
||||
|
||||
void RecalculateScalarOffsetsSizes(CBufferVariableType &type);
|
||||
rdcstr TypeName(CBufferVariableType desc);
|
||||
|
||||
struct CBufferVariable
|
||||
|
||||
@@ -386,6 +386,38 @@ ShaderStage GetShaderStage(ShaderType type)
|
||||
}
|
||||
}
|
||||
|
||||
// DXIL wonderfully provides us with offsets that are completely useless/pointless for structured
|
||||
// buffers. We need to recalculate them now based on tight packing
|
||||
void RecalculateScalarOffsetsSizes(CBufferVariableType &type)
|
||||
{
|
||||
uint32_t offset = 0;
|
||||
uint32_t pendingOffsetIncr = 0;
|
||||
uint32_t lastBitfieldOffset = 0;
|
||||
for(DXBC::CBufferVariable &var : type.members)
|
||||
{
|
||||
// if we encounter a non-bitfield, or the offset goes backwards, apply the 'real' offset now
|
||||
if(var.bitFieldSize == 0 || var.bitFieldOffset < lastBitfieldOffset)
|
||||
{
|
||||
offset += pendingOffsetIncr;
|
||||
pendingOffsetIncr = 0;
|
||||
}
|
||||
|
||||
var.offset = offset;
|
||||
|
||||
// all bitfields share the same offset, which will be incremented at the next bitfield boundary (above)
|
||||
if(var.bitFieldSize > 0)
|
||||
{
|
||||
pendingOffsetIncr = var.type.bytesize;
|
||||
lastBitfieldOffset = var.bitFieldOffset + var.bitFieldSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
offset += var.type.rows * var.type.cols * VarTypeByteSize(var.type.varType) * var.type.elements;
|
||||
|
||||
RecalculateScalarOffsetsSizes(var.type);
|
||||
}
|
||||
}
|
||||
|
||||
rdcstr TypeName(CBufferVariableType desc)
|
||||
{
|
||||
rdcstr ret;
|
||||
|
||||
@@ -1255,38 +1255,6 @@ static DXBC::CBufferVariableType MakeCBufferVariableType(const TypeInfo &typeInf
|
||||
return ret;
|
||||
}
|
||||
|
||||
// DXIL wonderfully provides us with offsets that are completely useless/pointless for structured
|
||||
// buffers. We need to recalculate them now based on tight packing
|
||||
void RecalculateScalarOffsetsSizes(DXBC::CBufferVariableType &type)
|
||||
{
|
||||
uint32_t offset = 0;
|
||||
uint32_t pendingOffsetIncr = 0;
|
||||
uint32_t lastBitfieldOffset = 0;
|
||||
for(DXBC::CBufferVariable &var : type.members)
|
||||
{
|
||||
// if we encounter a non-bitfield, or the offset goes backwards, apply the 'real' offset now
|
||||
if(var.bitFieldSize == 0 || var.bitFieldOffset < lastBitfieldOffset)
|
||||
{
|
||||
offset += pendingOffsetIncr;
|
||||
pendingOffsetIncr = 0;
|
||||
}
|
||||
|
||||
var.offset = offset;
|
||||
|
||||
// all bitfields share the same offset, which will be incremented at the next bitfield boundary (above)
|
||||
if(var.bitFieldSize > 0)
|
||||
{
|
||||
pendingOffsetIncr = var.type.bytesize;
|
||||
lastBitfieldOffset = var.bitFieldOffset + var.bitFieldSize;
|
||||
continue;
|
||||
}
|
||||
|
||||
offset += var.type.rows * var.type.cols * VarTypeByteSize(var.type.varType) * var.type.elements;
|
||||
|
||||
RecalculateScalarOffsetsSizes(var.type);
|
||||
}
|
||||
}
|
||||
|
||||
static void AddResourceBind(DXBC::Reflection *refl, const TypeInfo &typeInfo, const Metadata *r,
|
||||
const bool srv)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user