Skip to content
Snippets Groups Projects
Commit 924388a6 authored by Alexander Gauggel's avatar Alexander Gauggel
Browse files

[#70] Allowing drawcall recording without index buffer, which fixes...

[#70] Allowing drawcall recording without index buffer, which fixes voxelization vis at higher resolutions
parent 424334df
No related branches found
No related tags found
1 merge request!57Resolve "Basic voxelization"
Pipeline #25818 passed
......@@ -58,7 +58,7 @@ vkcv::ShaderProgram loadVoxelBufferToImageShader() {
return shader;
}
const uint32_t voxelResolution = 32;
const uint32_t voxelResolution = 128;
const size_t voxelCount = voxelResolution * voxelResolution * voxelResolution;
const vk::Format voxelizationDummyFormat = vk::Format::eR8Unorm;
......@@ -68,7 +68,6 @@ Voxelization::Voxelization(vkcv::Core* corePtr, const Dependencies& dependencies
m_voxelImage(m_corePtr->createImage(vk::Format::eR16G16B16A16Sfloat, voxelResolution, voxelResolution, voxelResolution, true)),
m_dummyRenderTarget(m_corePtr->createImage(voxelizationDummyFormat, voxelResolution, voxelResolution, 1, false, true)),
m_voxelInfoBuffer(m_corePtr->createBuffer<VoxelizationInfo>(vkcv::BufferType::UNIFORM, 1)),
m_visualisationIndexBuffer(m_corePtr->createBuffer<uint16_t>(vkcv::BufferType::INDEX, voxelCount)),
m_voxelBuffer(m_corePtr->createBuffer<VoxelBufferContent>(vkcv::BufferType::STORAGE, voxelCount)){
const vkcv::ShaderProgram voxelizationShader = loadVoxelizationShader();
......@@ -143,7 +142,6 @@ Voxelization::Voxelization(vkcv::Core* corePtr, const Dependencies& dependencies
for (int i = 0; i < voxelCount; i++) {
voxelIndexData.push_back(i);
}
m_visualisationIndexBuffer.fill(voxelIndexData);
vkcv::DescriptorWrites voxelVisualisationDescriptorWrite;
voxelVisualisationDescriptorWrite.storageImageWrites =
......@@ -274,7 +272,7 @@ void Voxelization::renderVoxelVisualisation(
const vkcv::PushConstantData voxelVisualisationPushConstantData((void*)&viewProjectin, sizeof(glm::mat4));
const auto drawcall = vkcv::DrawcallInfo(
vkcv::Mesh({}, m_visualisationIndexBuffer.getVulkanHandle(), voxelCount),
vkcv::Mesh({}, nullptr, voxelCount),
{ vkcv::DescriptorSetUsage(0, m_corePtr->getDescriptorSet(m_visualisationDescriptorSet).vulkanHandle) });
m_corePtr->recordDrawcallsToCmdStream(
......
......@@ -46,7 +46,6 @@ private:
vkcv::PassHandle m_visualisationPass;
vkcv::PipelineHandle m_visualisationPipe;
vkcv::Buffer<uint16_t> m_visualisationIndexBuffer;
vkcv::DescriptorSetHandle m_visualisationDescriptorSet;
......
......@@ -23,8 +23,6 @@ namespace vkcv {
nullptr);
}
cmdBuffer.bindIndexBuffer(drawcall.mesh.indexBuffer, 0, vk::IndexType::eUint16); //FIXME: choose proper size
const size_t drawcallPushConstantOffset = drawcallIndex * pushConstantData.sizePerDrawcall;
// char* cast because void* does not support pointer arithmetic
const void* drawcallPushConstantData = drawcallPushConstantOffset + (char*)pushConstantData.data;
......@@ -36,6 +34,12 @@ namespace vkcv {
pushConstantData.sizePerDrawcall,
drawcallPushConstantData);
cmdBuffer.drawIndexed(drawcall.mesh.indexCount, 1, 0, 0, {});
if (drawcall.mesh.indexBuffer) {
cmdBuffer.bindIndexBuffer(drawcall.mesh.indexBuffer, 0, vk::IndexType::eUint16); //FIXME: choose proper size
cmdBuffer.drawIndexed(drawcall.mesh.indexCount, 1, 0, 0, {});
}
else {
cmdBuffer.draw(drawcall.mesh.indexCount, 1, 0, 0, {});
}
}
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment