diff --git a/src/hwr2/blit_postimg_screens.cpp b/src/hwr2/blit_postimg_screens.cpp index f98a6d35b..cdadb0bdd 100644 --- a/src/hwr2/blit_postimg_screens.cpp +++ b/src/hwr2/blit_postimg_screens.cpp @@ -119,21 +119,6 @@ void BlitPostimgScreens::draw(Rhi& rhi) void BlitPostimgScreens::prepass(Rhi& rhi) { - if (!renderpass_) - { - renderpass_ = rhi.create_render_pass( - { - false, - AttachmentLoadOp::kClear, - AttachmentStoreOp::kStore, - AttachmentLoadOp::kDontCare, - AttachmentStoreOp::kDontCare, - AttachmentLoadOp::kDontCare, - AttachmentStoreOp::kDontCare - } - ); - } - if (!pipeline_) { pipeline_ = rhi.create_pipeline(kPostimgPipelineDesc); diff --git a/src/hwr2/blit_postimg_screens.hpp b/src/hwr2/blit_postimg_screens.hpp index f4fec80fb..f3077ae83 100644 --- a/src/hwr2/blit_postimg_screens.hpp +++ b/src/hwr2/blit_postimg_screens.hpp @@ -53,7 +53,6 @@ private: rhi::Handle pipeline_; rhi::Handle indexed_pipeline_; - rhi::Handle renderpass_; rhi::Handle quad_vbo_; rhi::Handle quad_ibo_; bool upload_quad_buffer_; diff --git a/src/hwr2/screen_capture.hpp b/src/hwr2/screen_capture.hpp index fa5ecad5a..0d00f2bbf 100644 --- a/src/hwr2/screen_capture.hpp +++ b/src/hwr2/screen_capture.hpp @@ -21,7 +21,6 @@ namespace srb2::hwr2 class ScreenshotPass { - rhi::Handle render_pass_; std::vector pixel_data_; std::vector packed_data_; uint32_t width_ = 0; diff --git a/src/hwr2/twodee_renderer.hpp b/src/hwr2/twodee_renderer.hpp index b71b85fc4..b2250b23e 100644 --- a/src/hwr2/twodee_renderer.hpp +++ b/src/hwr2/twodee_renderer.hpp @@ -94,7 +94,6 @@ class TwodeeRenderer final std::vector cmd_lists_; std::vector, std::size_t>> vbos_; std::vector, std::size_t>> ibos_; - rhi::Handle render_pass_; rhi::Handle output_; rhi::Handle default_tex_; std::unordered_map> pipelines_; diff --git a/src/hwr2/upscale_backbuffer.cpp b/src/hwr2/upscale_backbuffer.cpp index 3af6f9ed1..9a71509b4 100644 --- a/src/hwr2/upscale_backbuffer.cpp +++ b/src/hwr2/upscale_backbuffer.cpp @@ -38,19 +38,6 @@ void UpscaleBackbuffer::begin_pass(Rhi& rhi) remake = true; } - auto new_renderpass = [&rhi = rhi](AttachmentLoadOp load_op, AttachmentStoreOp store_op) - { - RenderPassDesc desc {}; - desc.use_depth_stencil = false; - 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 (color_) @@ -70,23 +57,16 @@ void UpscaleBackbuffer::begin_pass(Rhi& rhi) RenderbufferDesc depth_tex {}; depth_tex.width = vid_width; depth_tex.height = vid_height; - - if (!renderpass_clear_) - { - renderpass_clear_ = new_renderpass(AttachmentLoadOp::kClear, AttachmentStoreOp::kStore); - } - } - else - { - if (!renderpass_) - { - renderpass_ = new_renderpass(AttachmentLoadOp::kLoad, AttachmentStoreOp::kStore); - } } RenderPassBeginInfo begin_info {}; - begin_info.render_pass = remake ? renderpass_clear_ : renderpass_; begin_info.clear_color = {0, 0, 0, 1}; begin_info.color_attachment = color_; + begin_info.color_load_op = rhi::AttachmentLoadOp::kLoad; + begin_info.color_store_op = rhi::AttachmentStoreOp::kStore; + begin_info.depth_load_op = rhi::AttachmentLoadOp::kLoad; + begin_info.depth_store_op = rhi::AttachmentStoreOp::kStore; + begin_info.stencil_load_op = rhi::AttachmentLoadOp::kLoad; + begin_info.stencil_store_op = rhi::AttachmentStoreOp::kStore; rhi.begin_render_pass(begin_info); } diff --git a/src/hwr2/upscale_backbuffer.hpp b/src/hwr2/upscale_backbuffer.hpp index 6c39d6639..0bf087663 100644 --- a/src/hwr2/upscale_backbuffer.hpp +++ b/src/hwr2/upscale_backbuffer.hpp @@ -19,8 +19,6 @@ namespace srb2::hwr2 class UpscaleBackbuffer { rhi::Handle color_; - rhi::Handle renderpass_; - rhi::Handle renderpass_clear_; public: UpscaleBackbuffer(); diff --git a/src/rhi/gl2/gl2_rhi.cpp b/src/rhi/gl2/gl2_rhi.cpp index d591e554c..eec381004 100644 --- a/src/rhi/gl2/gl2_rhi.cpp +++ b/src/rhi/gl2/gl2_rhi.cpp @@ -585,19 +585,6 @@ Gl2Rhi::Gl2Rhi(std::unique_ptr&& platform, GlLoadFunc load_func) : Gl2Rhi::~Gl2Rhi() = default; -rhi::Handle Gl2Rhi::create_render_pass(const rhi::RenderPassDesc& desc) -{ - // GL has no formal render pass object - Gl2RenderPass pass; - pass.desc = desc; - return render_pass_slab_.insert(std::move(pass)); -} - -void Gl2Rhi::destroy_render_pass(rhi::Handle handle) -{ - render_pass_slab_.remove(handle); -} - rhi::Handle Gl2Rhi::create_texture(const rhi::TextureDesc& desc) { GLenum internal_format = map_internal_texture_format(desc.format); @@ -1224,10 +1211,6 @@ void Gl2Rhi::begin_render_pass(const RenderPassBeginInfo& info) { SRB2_ASSERT(current_render_pass_.has_value() == false); - SRB2_ASSERT(render_pass_slab_.is_valid(info.render_pass) == true); - auto& rp = render_pass_slab_[info.render_pass]; - SRB2_ASSERT(rp.desc.use_depth_stencil == info.depth_stencil_attachment.has_value()); - auto fb_itr = framebuffers_.find(Gl2FramebufferKey {info.color_attachment, info.depth_stencil_attachment}); if (fb_itr == framebuffers_.end()) { @@ -1237,12 +1220,10 @@ void Gl2Rhi::begin_render_pass(const RenderPassBeginInfo& info) GL_ASSERT; gl_->BindFramebuffer(GL_FRAMEBUFFER, fb_name); GL_ASSERT; - fb_itr = framebuffers_ - .insert( - {Gl2FramebufferKey {info.color_attachment, info.depth_stencil_attachment}, - static_cast(fb_name)} - ) - .first; + fb_itr = framebuffers_.insert({ + Gl2FramebufferKey {info.color_attachment, info.depth_stencil_attachment}, + static_cast(fb_name) + }).first; SRB2_ASSERT(texture_slab_.is_valid(info.color_attachment)); auto& texture = texture_slab_[info.color_attachment]; @@ -1250,7 +1231,7 @@ void Gl2Rhi::begin_render_pass(const RenderPassBeginInfo& info) gl_->FramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture.texture, 0); GL_ASSERT; - if (rp.desc.use_depth_stencil && info.depth_stencil_attachment.has_value()) + if (info.depth_stencil_attachment.has_value()) { SRB2_ASSERT(renderbuffer_slab_.is_valid(*info.depth_stencil_attachment)); auto& renderbuffer = renderbuffer_slab_[*info.depth_stencil_attachment]; @@ -1270,24 +1251,21 @@ void Gl2Rhi::begin_render_pass(const RenderPassBeginInfo& info) GL_ASSERT; GLint clear_bits = 0; - if (rp.desc.color_load_op == rhi::AttachmentLoadOp::kClear) + if (info.color_load_op == rhi::AttachmentLoadOp::kClear) { gl_->ClearColor(info.clear_color.r, info.clear_color.g, info.clear_color.b, info.clear_color.a); clear_bits |= GL_COLOR_BUFFER_BIT; } - if (rp.desc.use_depth_stencil) + if (info.depth_load_op == rhi::AttachmentLoadOp::kClear) { - if (rp.desc.depth_load_op == rhi::AttachmentLoadOp::kClear) - { - gl_->ClearDepth(1.f); - clear_bits |= GL_DEPTH_BUFFER_BIT; - } - if (rp.desc.stencil_load_op == rhi::AttachmentLoadOp::kClear) - { - gl_->ClearStencil(0); - clear_bits |= GL_STENCIL_BUFFER_BIT; - } + gl_->ClearDepth(1.f); + clear_bits |= GL_DEPTH_BUFFER_BIT; + } + if (info.stencil_load_op == rhi::AttachmentLoadOp::kClear) + { + gl_->ClearStencil(0); + clear_bits |= GL_STENCIL_BUFFER_BIT; } if (clear_bits != 0) diff --git a/src/rhi/gl2/gl2_rhi.hpp b/src/rhi/gl2/gl2_rhi.hpp index fcb26b962..5a7504926 100644 --- a/src/rhi/gl2/gl2_rhi.hpp +++ b/src/rhi/gl2/gl2_rhi.hpp @@ -87,11 +87,6 @@ struct Gl2Buffer : public rhi::Buffer rhi::BufferDesc desc; }; -struct Gl2RenderPass : public rhi::RenderPass -{ - rhi::RenderPassDesc desc; -}; - struct Gl2Renderbuffer : public rhi::Renderbuffer { uint32_t renderbuffer; @@ -132,7 +127,6 @@ class Gl2Rhi final : public Rhi std::unique_ptr gl_; - Slab render_pass_slab_; Slab texture_slab_; Slab buffer_slab_; Slab renderbuffer_slab_; @@ -164,8 +158,6 @@ public: Gl2Rhi(std::unique_ptr&& platform, GlLoadFunc load_func); virtual ~Gl2Rhi(); - virtual Handle create_render_pass(const RenderPassDesc& desc) override; - virtual void destroy_render_pass(Handle handle) override; virtual Handle create_pipeline(const PipelineDesc& desc) override; virtual void destroy_pipeline(Handle handle) override; diff --git a/src/rhi/rhi.hpp b/src/rhi/rhi.hpp index da6c65740..5f6d580f1 100644 --- a/src/rhi/rhi.hpp +++ b/src/rhi/rhi.hpp @@ -42,10 +42,6 @@ struct Pipeline { }; -struct RenderPass -{ -}; - /// @brief Depth-stencil image attachment. struct Renderbuffer { @@ -461,17 +457,6 @@ struct PipelineDesc glm::vec4 blend_color; }; -struct RenderPassDesc -{ - bool use_depth_stencil; - AttachmentLoadOp color_load_op; - AttachmentStoreOp color_store_op; - AttachmentLoadOp depth_load_op; - AttachmentStoreOp depth_store_op; - AttachmentLoadOp stencil_load_op; - AttachmentStoreOp stencil_store_op; -}; - struct RenderbufferDesc { uint32_t width; @@ -511,10 +496,15 @@ struct BufferDesc struct RenderPassBeginInfo { - Handle render_pass; Handle color_attachment; std::optional> depth_stencil_attachment; glm::vec4 clear_color; + AttachmentLoadOp color_load_op; + AttachmentStoreOp color_store_op; + AttachmentLoadOp depth_load_op; + AttachmentStoreOp depth_store_op; + AttachmentLoadOp stencil_load_op; + AttachmentStoreOp stencil_store_op; }; using UniformVariant = std::variant< @@ -598,8 +588,6 @@ struct Rhi { virtual ~Rhi(); - virtual Handle create_render_pass(const RenderPassDesc& desc) = 0; - virtual void destroy_render_pass(Handle handle) = 0; virtual Handle create_pipeline(const PipelineDesc& desc) = 0; virtual void destroy_pipeline(Handle handle) = 0;