[Fix] (Diligent/PSO): Set stride value for layout element.

This commit is contained in:
BZLZHH
2025-06-08 18:56:56 +08:00
parent c183203264
commit e645167c94
@@ -43,13 +43,18 @@ namespace MG_Diligent {
} }
} }
if (attribName.empty()) {
continue;
// This can happen if an attribute is bound but not used by the shader program.
}
MG_State::QueryProgramAttributeLocation(program, attribName.c_str()); MG_State::QueryProgramAttributeLocation(program, attribName.c_str());
if (attribIndex == -1) { if (attribIndex == -1) {
continue; continue;
} }
Diligent::LayoutElement element; Diligent::LayoutElement element;
element.InputIndex = static_cast<Diligent::Uint32>(attribIndex); element.InputIndex = attribIndex;
element.BufferSlot = 0; element.BufferSlot = 0;
element.NumComponents = attrib.size; element.NumComponents = attrib.size;
@@ -67,16 +72,18 @@ namespace MG_Diligent {
} }
element.IsNormalized = attrib.normalized; element.IsNormalized = attrib.normalized;
element.RelativeOffset = static_cast<Diligent::Uint32>(reinterpret_cast<size_t>(attrib.pointer)); element.Stride = attrib.stride; // Set stride by attrib.stride
element.RelativeOffset = static_cast<Diligent::Uint32>(reinterpret_cast<uintptr_t>(attrib.pointer));
inputLayout.push_back(element); inputLayout.push_back(element);
MG_Util::Debug::LogD("Built LayoutElement for attrib '%s' (location %d): " MG_Util::Debug::LogD("Built LayoutElement for attrib '%s' (location %d): "
"NumComponents=%d, ValueType=%d, IsNormalized=%s, RelativeOffset=%u", "NumComponents=%d, ValueType=%d, IsNormalized=%s, RelativeOffset=%u, Stride=%u",
attribName.c_str(), attribIndex, attribName.c_str(), attribIndex,
element.NumComponents, element.ValueType, element.NumComponents, element.ValueType,
element.IsNormalized ? "true" : "false", element.IsNormalized ? "true" : "false",
element.RelativeOffset); element.RelativeOffset, element.Stride);
} }
} }