MCPcopy Create free account
hub / github.com/defold/defold / CalculateStd140StructSize

Function CalculateStd140StructSize

engine/graphics/src/graphics.cpp:1613–1643  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1611 }
1612
1613 static uint32_t CalculateStd140StructSize(const ShaderResourceTypeInfo* type_infos, uint32_t type_index, bool update_offsets)
1614 {
1615 const ShaderResourceTypeInfo& type_info = type_infos[type_index];
1616
1617 const uint32_t STRUCT_ALIGNMENT = 16;
1618 uint32_t offset = 0;
1619 uint32_t max_alignment = STRUCT_ALIGNMENT;
1620
1621 for (uint32_t i = 0; i < type_info.m_MemberCount; ++i)
1622 {
1623 ShaderResourceMember& member = type_info.m_Members[i];
1624
1625 uint32_t alignment = STRUCT_ALIGNMENT;
1626
1627 if (!member.m_Type.m_UseTypeIndex)
1628 {
1629 alignment = GetStd140BaseAlignment(member.m_Type.m_ShaderType);
1630 }
1631
1632 offset = DM_ALIGN(offset, alignment);
1633
1634 if (update_offsets)
1635 member.m_Offset = offset;
1636
1637 offset += CalculateStd140MemberSize(type_infos, member, update_offsets);
1638
1639 max_alignment = dmMath::Max(max_alignment, alignment);
1640 }
1641
1642 return DM_ALIGN(offset, max_alignment);
1643 }
1644
1645 static uint32_t CalculateShaderTypesSize(uint32_t root_type_index, const ShaderResourceTypeInfo* type_infos, uint32_t num_type_infos)
1646 {

Callers 3

CalculateShaderTypesSizeFunction · 0.85
UpdateShaderTypesOffsetsFunction · 0.85

Calls 3

GetStd140BaseAlignmentFunction · 0.85
MaxFunction · 0.50

Tested by

no test coverage detected