mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
UpscaleBackbuffer::begin_pass: use separate renderpass to clear framebuffer if texture was recreated
Fixes wipes potentially reading invalid data from the framebuffer if the texture was recreated but not yet rendered to.
This commit is contained in:
parent
2ec5d3e6b0
commit
a7382ca9d0
2 changed files with 25 additions and 12 deletions
|
|
@ -37,6 +37,19 @@ void UpscaleBackbuffer::begin_pass(Rhi& rhi, Handle<GraphicsContext> ctx)
|
||||||
remake = true;
|
remake = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
auto new_renderpass = [&rhi = rhi](AttachmentLoadOp load_op, AttachmentStoreOp store_op)
|
||||||
|
{
|
||||||
|
RenderPassDesc desc {};
|
||||||
|
desc.use_depth_stencil = true;
|
||||||
|
desc.color_load_op = load_op;
|
||||||
|
desc.color_store_op = store_op;
|
||||||
|
desc.depth_load_op = load_op;
|
||||||
|
desc.depth_store_op = store_op;
|
||||||
|
desc.stencil_load_op = load_op;
|
||||||
|
desc.stencil_store_op = store_op;
|
||||||
|
return rhi.create_render_pass(desc);
|
||||||
|
};
|
||||||
|
|
||||||
if (remake)
|
if (remake)
|
||||||
{
|
{
|
||||||
if (color_)
|
if (color_)
|
||||||
|
|
@ -63,23 +76,22 @@ void UpscaleBackbuffer::begin_pass(Rhi& rhi, Handle<GraphicsContext> ctx)
|
||||||
depth_tex.height = vid_height;
|
depth_tex.height = vid_height;
|
||||||
|
|
||||||
depth_ = rhi.create_renderbuffer(depth_tex);
|
depth_ = rhi.create_renderbuffer(depth_tex);
|
||||||
}
|
|
||||||
|
|
||||||
if (!renderpass_)
|
if (!renderpass_clear_)
|
||||||
|
{
|
||||||
|
renderpass_clear_ = new_renderpass(AttachmentLoadOp::kClear, AttachmentStoreOp::kStore);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
RenderPassDesc desc {};
|
if (!renderpass_)
|
||||||
desc.use_depth_stencil = true;
|
{
|
||||||
desc.color_load_op = AttachmentLoadOp::kLoad;
|
renderpass_ = new_renderpass(AttachmentLoadOp::kLoad, AttachmentStoreOp::kStore);
|
||||||
desc.color_store_op = AttachmentStoreOp::kStore;
|
}
|
||||||
desc.depth_load_op = AttachmentLoadOp::kLoad;
|
|
||||||
desc.depth_store_op = AttachmentStoreOp::kStore;
|
|
||||||
desc.stencil_load_op = AttachmentLoadOp::kLoad;
|
|
||||||
desc.stencil_store_op = AttachmentStoreOp::kStore;
|
|
||||||
renderpass_ = rhi.create_render_pass(desc);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RenderPassBeginInfo begin_info {};
|
RenderPassBeginInfo begin_info {};
|
||||||
begin_info.render_pass = renderpass_;
|
begin_info.render_pass = remake ? renderpass_clear_ : renderpass_;
|
||||||
begin_info.clear_color = {0, 0, 0, 1};
|
begin_info.clear_color = {0, 0, 0, 1};
|
||||||
begin_info.color_attachment = color_;
|
begin_info.color_attachment = color_;
|
||||||
begin_info.depth_stencil_attachment = depth_;
|
begin_info.depth_stencil_attachment = depth_;
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@ class UpscaleBackbuffer
|
||||||
rhi::Handle<rhi::Texture> color_;
|
rhi::Handle<rhi::Texture> color_;
|
||||||
rhi::Handle<rhi::Renderbuffer> depth_;
|
rhi::Handle<rhi::Renderbuffer> depth_;
|
||||||
rhi::Handle<rhi::RenderPass> renderpass_;
|
rhi::Handle<rhi::RenderPass> renderpass_;
|
||||||
|
rhi::Handle<rhi::RenderPass> renderpass_clear_;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
UpscaleBackbuffer();
|
UpscaleBackbuffer();
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue