various UI and rt changes

This commit is contained in:
Dynamitos
2025-01-29 16:15:48 +01:00
parent 4e6eb02e74
commit e5ac354527
29 changed files with 314 additions and 223 deletions
+17 -33
View File
@@ -58,40 +58,21 @@ void UIPass::beginFrame(const Component::Camera& cam) {
for (auto& render : renderElements) {
float x = render.position.x;
float y = render.position.y;
if (render.text.empty()) {
//todo: convert using actual tree depth
elements.add(RenderElementStyle{
.x = x,
.y = y,
.w = render.dimensions.x,
.h = render.dimensions.y,
.color = render.backgroundColor,
.z = render.level / 100.f,
});
} else {
y = y + render.baseline;
for (uint32 c : render.text) {
const FontAsset::Glyph& glyph = render.font->getGlyphData(c, render.fontSize);
Vector2 bearing = Vector2(glyph.bearing);
Vector2 size = Vector2(glyph.size);
float xpos = x + glyph.bearing.x;
float ypos = y - bearing.y;
float w = size.x;
float h = size.y;
glyphs.add(GlyphInstanceData{
.x = xpos,
.y = ypos,
.z = render.level / 100.0f,
.width = w,
.height = h,
.glyphIndex = (uint32)usedTextures.size(),
});
usedTextures.add(glyph.texture);
x += glyph.advance / 64.0f;
}
//todo: convert using actual tree depth
uint32 textureIndex = -1ul;
if (render.backgroundTexture != nullptr) {
textureIndex = usedTextures.size();
usedTextures.add(render.backgroundTexture);
}
elements.add(RenderElementStyle{
.x = x,
.y = y,
.w = render.dimensions.x,
.h = render.dimensions.y,
.color = render.backgroundColor,
.z = render.level / 100.f,
.textureIndex = textureIndex,
});
}
glyphInstanceBuffer->rotateBuffer(sizeof(GlyphInstanceData) * glyphs.size());
glyphInstanceBuffer->updateContents(0, sizeof(GlyphInstanceData) * glyphs.size(), glyphs.data());
@@ -115,6 +96,9 @@ void UIPass::beginFrame(const Component::Camera& cam) {
uiDescriptorSet = uiDescriptorLayout->allocateDescriptorSet();
uiDescriptorSet->updateBuffer(0, 0, elementBuffer);
uiDescriptorSet->updateSampler(1, 0, glyphSampler);
for (uint32 i = 0; i < usedTextures.size(); ++i) {
uiDescriptorSet->updateTexture(2, i, usedTextures[i]);
}
uiDescriptorSet->writeChanges();
}
+1 -2
View File
@@ -122,7 +122,6 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
.flags = 0,
.size = buildSizesInfo.accelerationStructureSize,
.usage = VK_BUFFER_USAGE_ACCELERATION_STRUCTURE_STORAGE_BIT_KHR | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT,
},
VmaAllocationCreateInfo{
.usage = VMA_MEMORY_USAGE_AUTO,
@@ -156,7 +155,7 @@ TopLevelAS::TopLevelAS(PGraphics graphics, const Gfx::TopLevelASCreateInfo& crea
VkAccelerationStructureBuildGeometryInfoKHR buildGeometry = {
.sType = VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_BUILD_GEOMETRY_INFO_KHR,
.pNext = nullptr,
.flags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR,
.flags = VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR,
.mode = VK_BUILD_ACCELERATION_STRUCTURE_MODE_BUILD_KHR,
.dstAccelerationStructure = handle,
.geometryCount = 1,