Fix padding size calculation

This commit is contained in:
Benau 2022-07-24 14:32:37 +08:00
parent 593f78a230
commit a2228adef1
2 changed files with 11 additions and 3 deletions

View File

@ -23,6 +23,16 @@ GEConfig* getGEConfig();
void deinit(); void deinit();
uint64_t getMonoTimeMs(); uint64_t getMonoTimeMs();
void mathPlaneFrustumf(float* out, const irr::core::matrix4& pvm); void mathPlaneFrustumf(float* out, const irr::core::matrix4& pvm);
inline size_t getPadding(size_t in, size_t alignment)
{
if (in == 0 || alignment == 0)
return 0;
size_t mod = in % alignment;
if (mod == 0)
return 0;
else
return alignment - mod;
}
} }
#endif #endif

View File

@ -432,9 +432,7 @@ void GEVulkanDrawCall::uploadDynamicData(GEVulkanDriver* vk,
const size_t object_data_size = const size_t object_data_size =
sizeof(ObjectData) * m_visible_objects.size(); sizeof(ObjectData) * m_visible_objects.size();
size_t ubo_alignment = limit.minUniformBufferOffsetAlignment; size_t ubo_alignment = limit.minUniformBufferOffsetAlignment;
size_t ubo_padding = 0; size_t ubo_padding = getPadding(object_data_size, ubo_alignment);
if (ubo_alignment > 0)
ubo_padding = object_data_size % ubo_alignment;
m_object_data_padded_size = object_data_size + ubo_padding; m_object_data_padded_size = object_data_size + ubo_padding;
// https://github.com/google/filament/pull/3814 // https://github.com/google/filament/pull/3814