Add Constructor for UniformBuffer

This commit is contained in:
Georg Hagen
2025-01-05 23:54:42 +01:00
parent 6cfd760034
commit ceee3ef12e
3 changed files with 8 additions and 14 deletions

View File

@@ -70,6 +70,7 @@ namespace OpenVulkano::Scene
LabelDrawable::LabelDrawable(const std::shared_ptr<AtlasData>& atlasData, const LabelDrawableSettings& settings)
: Drawable(DrawEncoder::GetDrawEncoder<LabelDrawable>(), DrawPhase::MAIN), m_atlasData(atlasData)
, m_labelBuffer(sizeof(LabelUniformData), &m_labelData, 4)
{
if (atlasData->glyphs.empty() || !atlasData->texture.size)
{
@@ -77,7 +78,6 @@ namespace OpenVulkano::Scene
}
SetLabelSettings(settings);
SetShader(IsBillboard() ? &BACKGROUND_BILLBOARD_SHADER : &BACKGROUND_SHADER);
SetupBuffers();
}
void LabelDrawable::SetLabelSettings(const LabelDrawableSettings& settings)
@@ -116,12 +116,4 @@ namespace OpenVulkano::Scene
{
return ray.IntersectAABB(m_bbox);
}
void LabelDrawable::SetupBuffers()
{
m_labelBuffer.size = sizeof(LabelUniformData);
m_labelBuffer.data = &m_labelData;
m_labelBuffer.setId = 4;
m_labelBuffer.binding = UniformBuffer::DESCRIPTOR_SET_LAYOUT_BINDING;
}
}

View File

@@ -57,13 +57,11 @@ namespace OpenVulkano::Scene
std::optional<RayHit> Intersect(const Ray& ray) const override;
private:
void SetupBuffers();
std::shared_ptr<AtlasData> m_atlasData;
UniformBuffer m_labelBuffer;
std::list<TextDrawable> m_texts; // Using list instead of vector for stable iterators
LabelDrawableSettings m_settings;
LabelUniformData m_labelData;
std::shared_ptr<AtlasData> m_atlasData;
Math::Vector3f m_position = { 0, 0, 0 };
Math::AABB m_bbox;
};

View File

@@ -19,11 +19,15 @@ namespace OpenVulkano::Scene
DescriptorSetLayoutBinding binding;
uint32_t setId;
size_t size = 0;
const void* data = nullptr;
size_t size;
const void* data;
UpdateFrequency updateFrequency = UpdateFrequency::Never;
bool updated = true;
UniformBuffer(size_t size = 0, const void* data = nullptr, uint32_t setId = 2, const DescriptorSetLayoutBinding& binding = DESCRIPTOR_SET_LAYOUT_BINDING)
: binding(binding), setId(setId), size(size), data(data)
{}
void Init(size_t size, const void* data, uint32_t setId = 2, const DescriptorSetLayoutBinding& binding = DESCRIPTOR_SET_LAYOUT_BINDING)
{
this->size = size;