cleaned up renderer

This commit is contained in:
Jorijn van der Graaf 2026-03-09 20:10:19 +01:00
commit d661c88ee2
58 changed files with 3030 additions and 4722 deletions

View file

@ -34,7 +34,7 @@ typedef DescriptorSetLayoutVulkanConst<1, {{
}}> descriptorSetLayoutImage;
int main() {
VulkanDevice::CreateDevice();
Device::CreateDevice();
WindowVulkan window(1280, 720, "HelloVulkan");
VkCommandBuffer cmd = window.StartInit();
@ -60,7 +60,7 @@ int main() {
std::array<std::uint32_t, 3> index {{2,1,0}};
triangleMesh.Build(verts, index, cmd);
RenderingElement3DVulkan renderer = {
RenderingElement3D renderer = {
.instance = {
.instanceCustomIndex = 0,
.mask = 0xFF,
@ -70,16 +70,16 @@ int main() {
}
};
RenderingElement3DVulkan::elements.emplace_back(&renderer);
RenderingElement3D::elements.emplace_back(&renderer);
MatrixRowMajor<float, 4, 3, 1> transform = MatrixRowMajor<float, 4, 3, 1>::Identity();
std::memcpy(renderer.instance.transform.matrix, transform.m, sizeof(transform.m));
RenderingElement3DVulkan::tlases.resize(WindowVulkan::numFrames);
RenderingElement3DVulkan::BuildTLAS(cmd, 0);
RenderingElement3DVulkan::BuildTLAS(cmd, 1);
RenderingElement3DVulkan::BuildTLAS(cmd, 2);
RenderingElement3D::tlases.resize(Window::numFrames);
RenderingElement3D::BuildTLAS(cmd, 0);
RenderingElement3D::BuildTLAS(cmd, 1);
RenderingElement3D::BuildTLAS(cmd, 2);
VkDescriptorImageInfo imageInfo[WindowVulkan::numFrames] = {
VkDescriptorImageInfo imageInfo[Window::numFrames] = {
{
.imageView = window.imageViews[0],
.imageLayout = VK_IMAGE_LAYOUT_GENERAL
@ -97,7 +97,7 @@ int main() {
VkWriteDescriptorSetAccelerationStructureKHR writeDescriptorSetAccelerationStructure {
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
.accelerationStructureCount = 1,
.pAccelerationStructures = &RenderingElement3DVulkan::tlases[0].accelerationStructure
.pAccelerationStructures = &RenderingElement3D::tlases[0].accelerationStructure
};
VkWriteDescriptorSet write[4];
@ -112,7 +112,7 @@ int main() {
.descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
};
for(std::uint32_t i = 0; i < WindowVulkan::numFrames; i++) {
for(std::uint32_t i = 0; i < Window::numFrames; i++) {
write[i+1] = {
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET,
.dstSet = pool.sets[i+1],
@ -123,7 +123,7 @@ int main() {
.pImageInfo = &imageInfo[i]
};
}
vkUpdateDescriptorSets(VulkanDevice::device, 4, write, 0, nullptr);
vkUpdateDescriptorSets(Device::device, 4, write, 0, nullptr);
window.descriptorsRt = {pool.sets[0], pool.sets[1]};
/*
@ -147,12 +147,12 @@ int main() {
MatrixRowMajor<float, 4, 3, 1> transform = MatrixRowMajor<float, 4, 3, 1>::Translation(value, 0, 0);
std::memcpy(renderer.instance.transform.matrix, transform.m, sizeof(transform.m));
RenderingElement3DVulkan::BuildTLAS(window.drawCmdBuffers[window.currentBuffer], window.currentBuffer);
RenderingElement3D::BuildTLAS(window.drawCmdBuffers[window.currentBuffer], window.currentBuffer);
VkWriteDescriptorSetAccelerationStructureKHR writeDescriptorSetAccelerationStructure {
.sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET_ACCELERATION_STRUCTURE_KHR,
.accelerationStructureCount = 1,
.pAccelerationStructures = &RenderingElement3DVulkan::tlases[window.currentBuffer].accelerationStructure
.pAccelerationStructures = &RenderingElement3D::tlases[window.currentBuffer].accelerationStructure
};
VkWriteDescriptorSet write = {
@ -164,7 +164,7 @@ int main() {
.descriptorCount = 1,
.descriptorType = VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR,
};
vkUpdateDescriptorSets(VulkanDevice::device, 1, &write, 0, nullptr);
vkUpdateDescriptorSets(Device::device, 1, &write, 0, nullptr);
window.descriptorsRt[1] = pool.sets[window.currentBuffer+1];
});