diff --git a/01-HelloTriangle/hellotriangle.cpp b/01-HelloTriangle/hellotriangle.cpp index 46d7d3e..abe01a6 100644 --- a/01-HelloTriangle/hellotriangle.cpp +++ b/01-HelloTriangle/hellotriangle.cpp @@ -232,7 +232,7 @@ struct HelloWorld : public AppBase { auto nextimg = swapchain->ImageAtIndex(presentConfig.imageIndex); auto nextImgSize = nextimg->GetSize(); - renderPass->SetAttachmentTexture(0, nextimg); + renderPass->SetAttachmentTexture(0, nextimg->GetDefaultView()); commandBuffer->BeginRendering(renderPass); diff --git a/02-Cubes/cubes.cpp b/02-Cubes/cubes.cpp index f83af86..bd08cc9 100644 --- a/02-Cubes/cubes.cpp +++ b/02-Cubes/cubes.cpp @@ -207,7 +207,7 @@ struct Cubes : public ExampleFramework { }); // the depth texture is not swapchained so we can set it once - renderPass->SetDepthAttachmentTexture(depthTexture.get()); + renderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // create command buffer commandBuffer = commandQueue->CreateCommandBuffer(); @@ -229,7 +229,7 @@ struct Cubes : public ExampleFramework { auto nextimg = swapchain->ImageAtIndex(presentConfig.imageIndex); auto nextImgSize = nextimg->GetSize(); - renderPass->SetAttachmentTexture(0, nextimg); + renderPass->SetAttachmentTexture(0, nextimg->GetDefaultView()); commandBuffer->BeginRendering(renderPass); @@ -247,7 +247,7 @@ struct Cubes : public ExampleFramework { commandBuffer->SetVertexBuffer(vertexBuffer); commandBuffer->SetIndexBuffer(indexBuffer); commandBuffer->SetFragmentSampler(textureSampler,0); - commandBuffer->SetFragmentTexture(sampledTexture.get(), 1); + commandBuffer->SetFragmentTexture(sampledTexture->GetDefaultView(), 1); commandBuffer->DrawIndexed(std::size(BasicObjects::Cube::indices), { .nInstances = nCubes }); @@ -266,7 +266,7 @@ struct Cubes : public ExampleFramework { void onresize(int width, int height) final { createDepthTexture(); - renderPass->SetDepthAttachmentTexture(depthTexture.get()); // we recreated it so we need to reset it + renderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // we recreated it so we need to reset it } void sampleshutdown() final { diff --git a/03-Imgui/imgui.cpp b/03-Imgui/imgui.cpp index dde6333..cd16c16 100644 --- a/03-Imgui/imgui.cpp +++ b/03-Imgui/imgui.cpp @@ -270,7 +270,7 @@ void main(){ auto nextimg = swapchain->ImageAtIndex(presentConfig.imageIndex); auto nextImgSize = nextimg->GetSize(); - renderPass->SetAttachmentTexture(0, nextimg); + renderPass->SetAttachmentTexture(0, nextimg->GetDefaultView()); // create the unified vert / ind buffer refreshBuffers(vertexBufferLength, indexBufferLength); @@ -359,7 +359,7 @@ void main(){ if (ImTextureID tex_id = pcmd->GetTexID()) { commandBuffer->SetFragmentSampler(textureSampler, 0); - commandBuffer->SetFragmentTexture(fontsTexture.get(),1); + commandBuffer->SetFragmentTexture(fontsTexture->GetDefaultView(),1); } commandBuffer->SetVertexBytes(ubo, 0); diff --git a/04-Deferred/deferred.cpp b/04-Deferred/deferred.cpp index 12887d9..c881de8 100644 --- a/04-Deferred/deferred.cpp +++ b/04-Deferred/deferred.cpp @@ -523,15 +523,15 @@ struct Deferred : public ExampleFramework { }); // the depth texture is not swapchained so we can set it once - deferredRenderPass->SetDepthAttachmentTexture(depthTexture.get()); - deferredRenderPass->SetAttachmentTexture(0, colorTexture.get()); - deferredRenderPass->SetAttachmentTexture(1, normalTexture.get()); - deferredRenderPass->SetAttachmentTexture(2, positionTexture.get()); - deferredRenderPass->SetAttachmentTexture(3, idTexture.get()); + deferredRenderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(0, colorTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(1, normalTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(2, positionTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(3, idTexture->GetDefaultView()); - dirLightRenderPass->SetAttachmentTexture(0, lightingTexture.get()); - dirLightRenderPass->SetDepthAttachmentTexture(depthTexture.get()); - finalRenderPass->SetDepthAttachmentTexture(depthTexture.get()); + dirLightRenderPass->SetAttachmentTexture(0, lightingTexture->GetDefaultView()); + dirLightRenderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); + finalRenderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // create command buffer commandBuffer = commandQueue->CreateCommandBuffer(); @@ -590,15 +590,15 @@ struct Deferred : public ExampleFramework { .extent = {nextImgSize.width, nextImgSize.height} }); commandBuffer->SetFragmentBytes(lightingAndFinalStageUbo, 0); - commandBuffer->SetFragmentTexture(colorTexture.get(), 1); - commandBuffer->SetFragmentTexture(normalTexture.get(), 2); + commandBuffer->SetFragmentTexture(colorTexture->GetDefaultView(), 1); + commandBuffer->SetFragmentTexture(normalTexture->GetDefaultView(), 2); commandBuffer->SetFragmentSampler(textureSampler, 0); commandBuffer->SetVertexBuffer(screenTriVerts); commandBuffer->Draw(std::size(BasicObjects::ScreenTriangle::vertices)); commandBuffer->EndRendering(); // next do the final render - finalRenderPass->SetAttachmentTexture(0, nextimg); + finalRenderPass->SetAttachmentTexture(0, nextimg->GetDefaultView()); commandBuffer->BeginRendering(finalRenderPass); @@ -611,7 +611,7 @@ struct Deferred : public ExampleFramework { }); commandBuffer->BindRenderPipeline(finalRenderPipeline); - commandBuffer->SetFragmentTexture(lightingTexture.get(), 1); + commandBuffer->SetFragmentTexture(lightingTexture->GetDefaultView(), 1); commandBuffer->SetFragmentSampler(textureSampler,0); commandBuffer->SetVertexBuffer(screenTriVerts); commandBuffer->SetFragmentBytes(lightingAndFinalStageUbo, 0); @@ -640,15 +640,15 @@ struct Deferred : public ExampleFramework { void onresize(int width, int height) final { updateGBuffers(); - deferredRenderPass->SetDepthAttachmentTexture(depthTexture.get()); // we recreated it so we need to reset it - finalRenderPass->SetDepthAttachmentTexture(depthTexture.get()); - dirLightRenderPass->SetDepthAttachmentTexture(depthTexture.get()); - deferredRenderPass->SetAttachmentTexture(0, colorTexture.get()); - deferredRenderPass->SetAttachmentTexture(1, normalTexture.get()); - deferredRenderPass->SetAttachmentTexture(2, positionTexture.get()); - deferredRenderPass->SetAttachmentTexture(3, idTexture.get()); + deferredRenderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // we recreated it so we need to reset it + finalRenderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); + dirLightRenderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(0, colorTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(1, normalTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(2, positionTexture->GetDefaultView()); + deferredRenderPass->SetAttachmentTexture(3, idTexture->GetDefaultView()); - dirLightRenderPass->SetAttachmentTexture(0, lightingTexture.get()); + dirLightRenderPass->SetAttachmentTexture(0, lightingTexture->GetDefaultView()); } void updateSelectedObject() { @@ -663,7 +663,8 @@ struct Deferred : public ExampleFramework { auto tmpfence = device->CreateFence(false); tmpcmd->Begin(); - tmpcmd->CopyTextureToBuffer(idTexture.get(), { .offset = {x,y}, .extent = {1,1} }, 0, imageDownloadBuffer); + auto view = idTexture->GetDefaultView(); + tmpcmd->CopyTextureToBuffer(view, { .offset = {x,y}, .extent = {1,1} }, 0, imageDownloadBuffer); tmpcmd->End(); tmpcmd->Commit({ diff --git a/05-XR/xr.cpp b/05-XR/xr.cpp index 792aa08..3c90898 100644 --- a/05-XR/xr.cpp +++ b/05-XR/xr.cpp @@ -655,7 +655,7 @@ struct XR : public ExampleFramework { }); // the depth texture is not swapchained so we can set it once - renderPass->SetDepthAttachmentTexture(depthTexture.get()); + renderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // create command buffer commandBuffer = commandQueue->CreateCommandBuffer(); @@ -713,8 +713,8 @@ struct XR : public ExampleFramework { auto render = [this](RGL::ITexture* nextimg, RGL::ITexture* depthTexture, glm::mat4 viewProj) { auto nextImgSize = nextimg->GetSize(); - renderPass->SetAttachmentTexture(0, nextimg); - renderPass->SetDepthAttachmentTexture(depthTexture); // we recreated it so we need to reset it + renderPass->SetAttachmentTexture(0, nextimg->GetDefaultView()); + renderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // we recreated it so we need to reset it commandBuffer->BeginRendering(renderPass); diff --git a/06-Asteroids/asteroids.cpp b/06-Asteroids/asteroids.cpp index c1b7926..d11ed8d 100644 --- a/06-Asteroids/asteroids.cpp +++ b/06-Asteroids/asteroids.cpp @@ -327,7 +327,7 @@ struct Asteroids : public ExampleFramework { }); // the depth texture is not swapchained so we can set it once - renderPass->SetDepthAttachmentTexture(depthTexture.get()); + renderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // create command buffer commandBuffer = commandQueue->CreateCommandBuffer(); @@ -377,7 +377,7 @@ struct Asteroids : public ExampleFramework { auto nextimg = swapchain->ImageAtIndex(presentConfig.imageIndex); auto nextImgSize = nextimg->GetSize(); - renderPass->SetAttachmentTexture(0, nextimg); + renderPass->SetAttachmentTexture(0, nextimg->GetDefaultView()); commandBuffer->BeginCompute(lodPipeline); commandBuffer->SetComputeBytes(ubo,0); @@ -440,7 +440,7 @@ struct Asteroids : public ExampleFramework { void onresize(int width, int height) final { createDepthTexture(); - renderPass->SetDepthAttachmentTexture(depthTexture.get()); // we recreated it so we need to reset it + renderPass->SetDepthAttachmentTexture(depthTexture->GetDefaultView()); // we recreated it so we need to reset it } void sampleshutdown() final { diff --git a/07-Mipmap/mipmap.cpp b/07-Mipmap/mipmap.cpp index 40d083a..7849ce0 100644 --- a/07-Mipmap/mipmap.cpp +++ b/07-Mipmap/mipmap.cpp @@ -26,7 +26,7 @@ struct Mipmap : public ExampleFramework { RGLRenderPassPtr renderPass; constexpr static auto num_mips = 4; - constexpr static auto img_size = 4096; + constexpr static auto img_size = 1024; constexpr static glm::vec4 colors[] = { {195/255.f,88/255.f,49/255.f, 1}, {96/255.f,111/255.f,140/255.f, 1}, @@ -253,14 +253,15 @@ struct Mipmap : public ExampleFramework { } void sampleshutdown() final { - commandBuffer.reset(); renderPass.reset(); - renderPipeline.reset(); mipTexture.reset(); mipSampler.reset(); depthTexture.reset(); indexBuffer.reset(); vertexBuffer.reset(); + renderPipeline.reset(); + mipPipeline.reset(); + commandBuffer.reset(); } void createDepthTexture() diff --git a/deps/RGL b/deps/RGL index e254146..f44eca7 160000 --- a/deps/RGL +++ b/deps/RGL @@ -1 +1 @@ -Subproject commit e2541465143ec94dfaff3105d74d7a82afcddf0d +Subproject commit f44eca79664c6f52fc9691b3ccac7f497d46cbfa