diff --git a/projects/voxelization/src/Voxelization.cpp b/projects/voxelization/src/Voxelization.cpp index e9748aa3393588f775cdf977e1e3e16a1fca772d..6ce571a3e10d95588a232a5e40dc22fa559c49dd 100644 --- a/projects/voxelization/src/Voxelization.cpp +++ b/projects/voxelization/src/Voxelization.cpp @@ -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( diff --git a/projects/voxelization/src/Voxelization.hpp b/projects/voxelization/src/Voxelization.hpp index f0f8849362051b117f447cc9b8d9c61a83ecefaa..f9b96998b39e24a3481d130efa68ebaa813b8256 100644 --- a/projects/voxelization/src/Voxelization.hpp +++ b/projects/voxelization/src/Voxelization.hpp @@ -46,7 +46,6 @@ private: vkcv::PassHandle m_visualisationPass; vkcv::PipelineHandle m_visualisationPipe; - vkcv::Buffer<uint16_t> m_visualisationIndexBuffer; vkcv::DescriptorSetHandle m_visualisationDescriptorSet; diff --git a/src/vkcv/DrawcallRecording.cpp b/src/vkcv/DrawcallRecording.cpp index 85b6eeb5fa413223b7b7f10f77b868252912041b..df7b7bbcb3fe278622cd160593eb750db00ec7b1 100644 --- a/src/vkcv/DrawcallRecording.cpp +++ b/src/vkcv/DrawcallRecording.cpp @@ -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