Skip to content

Commit 164cbf6

Browse files
fix all Vulkan validation errors in example 5, except the ImageView dying.
1 parent 0752520 commit 164cbf6

File tree

1 file changed

+30
-24
lines changed
  • examples_tests/05.NablaTutorialExample

1 file changed

+30
-24
lines changed

examples_tests/05.NablaTutorialExample/main.cpp

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ class NablaTutorialExampleApp : public ApplicationBase
296296

297297
IGPUBuffer::SCreationParams creationParams = {};
298298
creationParams.canUpdateSubRange = true;
299-
creationParams.usage = asset::IBuffer::EUF_UNIFORM_BUFFER_BIT;
299+
creationParams.usage = core::bitflag(asset::IBuffer::EUF_UNIFORM_BUFFER_BIT)|asset::IBuffer::EUF_TRANSFER_DST_BIT;
300300
IDriverMemoryBacked::SDriverMemoryRequirements memReq;
301301
memReq.vulkanReqs.size = sizeof(SBasicViewParameters);
302302
memReq.vulkanReqs.alignment = physicalDevice->getLimits().UBOAlignment;
@@ -459,7 +459,10 @@ class NablaTutorialExampleApp : public ApplicationBase
459459
auto& fence = frameComplete[resourceIx];
460460

461461
if (fence)
462-
while (logicalDevice->waitForFences(1u, &fence.get(), false, MAX_TIMEOUT) == video::IGPUFence::ES_TIMEOUT) {}
462+
{
463+
logicalDevice->blockForFences(1u,&fence.get());
464+
logicalDevice->resetFences(1u,&fence.get());
465+
}
463466
else
464467
fence = logicalDevice->createFence(static_cast<video::IGPUFence::E_CREATE_FLAGS>(0));
465468

@@ -510,6 +513,31 @@ class NablaTutorialExampleApp : public ApplicationBase
510513
viewport.width = WIN_W;
511514
viewport.height = WIN_H;
512515
commandBuffer->setViewport(0u, 1u, &viewport);
516+
VkRect2D scissor;
517+
scissor.offset = {0u,0u};
518+
scissor.extent = {WIN_W,WIN_H};
519+
commandBuffer->setScissor(0u,1u,&scissor);
520+
521+
const auto viewProjection = camera.getConcatenatedMatrix();
522+
core::matrix3x4SIMD modelMatrix;
523+
modelMatrix.setRotation(nbl::core::quaternion(0, 1, 0));
524+
525+
auto mv = core::concatenateBFollowedByA(camera.getViewMatrix(), modelMatrix);
526+
auto mvp = core::concatenateBFollowedByA(viewProjection, modelMatrix);
527+
core::matrix3x4SIMD normalMat;
528+
mv.getSub3x3InverseTranspose(normalMat);
529+
530+
/*
531+
Updating UBO for basic view parameters and sending
532+
updated data to staging buffer that will redirect
533+
the data to graphics card - to vertex shader.
534+
*/
535+
536+
SBasicViewParameters uboData;
537+
memcpy(uboData.MV, mv.pointer(), sizeof(mv));
538+
memcpy(uboData.MVP, mvp.pointer(), sizeof(mvp));
539+
memcpy(uboData.NormalMat, normalMat.pointer(), sizeof(normalMat));
540+
commandBuffer->updateBuffer(gpuubo.get(), 0ull, gpuubo->getSize(), &uboData);
513541

514542
swapchain->acquireNextImage(MAX_TIMEOUT, imageAcquire[resourceIx].get(), nullptr, &acquiredNextFBO);
515543

@@ -531,30 +559,8 @@ class NablaTutorialExampleApp : public ApplicationBase
531559
beginInfo.renderArea = area;
532560
beginInfo.clearValues = clear;
533561
}
534-
535562
commandBuffer->beginRenderPass(&beginInfo, nbl::asset::ESC_INLINE);
536563

537-
const auto viewProjection = camera.getConcatenatedMatrix();
538-
core::matrix3x4SIMD modelMatrix;
539-
modelMatrix.setRotation(nbl::core::quaternion(0, 1, 0));
540-
541-
auto mv = core::concatenateBFollowedByA(camera.getViewMatrix(), modelMatrix);
542-
auto mvp = core::concatenateBFollowedByA(viewProjection, modelMatrix);
543-
core::matrix3x4SIMD normalMat;
544-
mv.getSub3x3InverseTranspose(normalMat);
545-
546-
/*
547-
Updating UBO for basic view parameters and sending
548-
updated data to staging buffer that will redirect
549-
the data to graphics card - to vertex shader.
550-
*/
551-
552-
SBasicViewParameters uboData;
553-
memcpy(uboData.MV, mv.pointer(), sizeof(mv));
554-
memcpy(uboData.MVP, mvp.pointer(), sizeof(mvp));
555-
memcpy(uboData.NormalMat, normalMat.pointer(), sizeof(normalMat));
556-
commandBuffer->updateBuffer(gpuubo.get(), 0ull, gpuubo->getSize(), &uboData);
557-
558564
/*
559565
Binding the most important objects needed to
560566
render anything on the screen with textures:

0 commit comments

Comments
 (0)