Skip to content

Commit

Permalink
Revert "Fix not clearing texture in the raytrace render pass"
Browse files Browse the repository at this point in the history
This reverts commit bbd246b.
  • Loading branch information
MrRaveYard authored and dpjudas committed Sep 15, 2023
1 parent 5c0e9e0 commit 37a6ccc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 43 deletions.
51 changes: 10 additions & 41 deletions src/lightmap/gpuraytracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,20 @@ void GPURaytracer::RenderAtlasImage(size_t pageIndex)
{
LightmapImage& img = atlasImages[pageIndex];

// Begin with clear
{
const auto beginPass = [&]() {
RenderPassBegin()
.RenderPass(raytrace.renderPassBegin.get())
.RenderPass(raytrace.renderPass.get())
.RenderArea(0, 0, atlasImageSize, atlasImageSize)
.Framebuffer(img.raytrace.Framebuffer.get())
.AddClearColor(0.0f, 0.0f, 0.0f, 0.0f)
.Execute(cmdbuffer.get());

VkDeviceSize offset = 0;
cmdbuffer->bindVertexBuffers(0, 1, &sceneVertexBuffer->buffer, &offset);
cmdbuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipeline.get());
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipelineLayout.get(), 0, raytrace.descriptorSet0.get());
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipelineLayout.get(), 1, raytrace.descriptorSet1.get());
}
};
beginPass();

for (size_t i = 0; i < mesh->surfaces.size(); i++)
{
Expand Down Expand Up @@ -170,19 +169,7 @@ void GPURaytracer::RenderAtlasImage(size_t pageIndex)
firstLight = 0;
firstVertex = 0;
BeginCommands();

// Begin without clear
RenderPassBegin()
.RenderPass(raytrace.renderPassBegin.get())
.RenderArea(0, 0, atlasImageSize, atlasImageSize)
.Framebuffer(img.raytrace.Framebuffer.get())
.Execute(cmdbuffer.get());

VkDeviceSize offset = 0;
cmdbuffer->bindVertexBuffers(0, 1, &sceneVertexBuffer->buffer, &offset);
cmdbuffer->bindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipeline.get());
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipelineLayout.get(), 0, raytrace.descriptorSet0.get());
cmdbuffer->bindDescriptorSet(VK_PIPELINE_BIND_POINT_GRAPHICS, raytrace.pipelineLayout.get(), 1, raytrace.descriptorSet1.get());
beginPass();

printf(".");

Expand Down Expand Up @@ -758,11 +745,11 @@ void GPURaytracer::CreateRaytracePipeline()
.DebugName("raytrace.pipelineLayout")
.Create(device.get());

raytrace.renderPassBegin = RenderPassBuilder()
raytrace.renderPass = RenderPassBuilder()
.AddAttachment(
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_SAMPLE_COUNT_4_BIT,
VK_ATTACHMENT_LOAD_OP_CLEAR,
VK_ATTACHMENT_LOAD_OP_DONT_CARE,
VK_ATTACHMENT_STORE_OP_STORE,
VK_IMAGE_LAYOUT_UNDEFINED,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
Expand All @@ -773,30 +760,12 @@ void GPURaytracer::CreateRaytracePipeline()
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT)
.DebugName("raytrace.renderpassBegin")
.Create(device.get());

raytrace.renderPassContinue = RenderPassBuilder()
.AddAttachment(
VK_FORMAT_R16G16B16A16_SFLOAT,
VK_SAMPLE_COUNT_4_BIT,
VK_ATTACHMENT_LOAD_OP_LOAD,
VK_ATTACHMENT_STORE_OP_STORE,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
.AddSubpass()
.AddSubpassColorAttachmentRef(0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL)
.AddExternalSubpassDependency(
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT,
VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT,
VK_ACCESS_COLOR_ATTACHMENT_READ_BIT)
.DebugName("raytrace.renderpassContinue")
.DebugName("raytrace.renderpass")
.Create(device.get());

raytrace.pipeline = GraphicsPipelineBuilder()
.Layout(raytrace.pipelineLayout.get())
.RenderPass(raytrace.renderPassBegin.get())
.RenderPass(raytrace.renderPass.get())
.AddVertexShader(vertShader.get())
.AddFragmentShader(fragShader.get())
.AddVertexBufferBinding(0, sizeof(SceneVertex))
Expand Down Expand Up @@ -937,7 +906,7 @@ LightmapImage GPURaytracer::CreateImage(int width, int height)
.Create(device.get());

img.raytrace.Framebuffer = FramebufferBuilder()
.RenderPass(raytrace.renderPassBegin.get())
.RenderPass(raytrace.renderPass.get())
.Size(width, height)
.AddAttachment(img.raytrace.View.get())
.DebugName("LightmapImage.raytrace.Framebuffer")
Expand Down
3 changes: 1 addition & 2 deletions src/lightmap/gpuraytracer.h
Original file line number Diff line number Diff line change
Expand Up @@ -197,8 +197,7 @@ class GPURaytracer
std::unique_ptr<VulkanDescriptorSetLayout> descriptorSetLayout1;
std::unique_ptr<VulkanPipelineLayout> pipelineLayout;
std::unique_ptr<VulkanPipeline> pipeline;
std::unique_ptr<VulkanRenderPass> renderPassBegin;
std::unique_ptr<VulkanRenderPass> renderPassContinue;
std::unique_ptr<VulkanRenderPass> renderPass;
std::unique_ptr<VulkanDescriptorPool> descriptorPool0;
std::unique_ptr<VulkanDescriptorPool> descriptorPool1;
std::unique_ptr<VulkanDescriptorSet> descriptorSet0;
Expand Down

0 comments on commit 37a6ccc

Please sign in to comment.