From 77c2a68cc5130dc848f6d9b07bf2aa194c9077b1 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Tue, 2 Jun 2026 18:30:46 +0200 Subject: [PATCH] Map renderer blit filters to OpenGL --- docs/modernization/build-inventory.md | 3 ++- docs/modernization/roadmap.md | 3 ++- src/renderer_gl/opengl_capabilities.cpp | 12 ++++++++++++ src/renderer_gl/opengl_capabilities.h | 2 ++ tests/renderer_gl/capabilities_tests.cpp | 11 +++++++++++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 70c6860..64ae0e2 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -195,7 +195,8 @@ Known local toolchain state: tokens used by `Texture2D`, plus cube-map binding and allocation face targets used by `TextureCube`. It also owns and validates framebuffer blit color mask and linear/nearest filters used by - `RTT::resize` and `RTT::copy`, plus the default linear clamp-to-edge + `RTT::resize` and `RTT::copy`, renderer API blit-filter to OpenGL token + mapping, plus the default linear clamp-to-edge render-target texture parameters, texture/renderbuffer targets, depth format, framebuffer targets, binding queries, attachment points, and completion status used by `RTT::create` and framebuffer bind/restore paths, plus RTT diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index cd840be..cc63976 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -449,7 +449,8 @@ face targets, RGBA allocation format, and unsigned-byte component type also delegate to `pp_renderer_gl`. RGBA8/RGBA32F readback formats, checked byte-count math, and PBO pixel-buffer target/usage/access tokens used by `RTT` and `PBO` readbacks now live in `pp_renderer_gl`. The framebuffer blit color mask and linear/nearest -filter tokens used by `RTT::resize` and `RTT::copy`, plus the default +filter tokens used by `RTT::resize` and `RTT::copy`, renderer API blit-filter +to OpenGL token mapping, plus the default render-target texture parameters, texture/renderbuffer targets, depth format, framebuffer targets, binding queries, attachment points, and completion status used by `RTT::create` and framebuffer bind/restore paths, also live in diff --git a/src/renderer_gl/opengl_capabilities.cpp b/src/renderer_gl/opengl_capabilities.cpp index 43b0239..022f560 100644 --- a/src/renderer_gl/opengl_capabilities.cpp +++ b/src/renderer_gl/opengl_capabilities.cpp @@ -475,6 +475,18 @@ std::uint32_t framebuffer_blit_filter(bool linear) noexcept return linear ? gl_linear : gl_nearest; } +OpenGlEnumMapping blit_filter_for_renderer_filter(pp::renderer::BlitFilter filter) noexcept +{ + switch (filter) { + case pp::renderer::BlitFilter::nearest: + return OpenGlEnumMapping { .value = gl_nearest, .supported = true }; + case pp::renderer::BlitFilter::linear: + return OpenGlEnumMapping { .value = gl_linear, .supported = true }; + default: + return OpenGlEnumMapping {}; + } +} + std::uint32_t primitive_mode_for_renderer_topology(pp::renderer::PrimitiveTopology topology) noexcept { switch (topology) { diff --git a/src/renderer_gl/opengl_capabilities.h b/src/renderer_gl/opengl_capabilities.h index 7ed704f..cf807b3 100644 --- a/src/renderer_gl/opengl_capabilities.h +++ b/src/renderer_gl/opengl_capabilities.h @@ -100,6 +100,8 @@ struct OpenGlWindowsWglContextConfig { [[nodiscard]] std::uint32_t framebuffer_depth_buffer_mask() noexcept; [[nodiscard]] std::uint32_t color_write_mask_query() noexcept; [[nodiscard]] std::uint32_t framebuffer_blit_filter(bool linear) noexcept; +[[nodiscard]] OpenGlEnumMapping blit_filter_for_renderer_filter( + pp::renderer::BlitFilter filter) noexcept; [[nodiscard]] std::uint32_t primitive_mode_for_renderer_topology( pp::renderer::PrimitiveTopology topology) noexcept; [[nodiscard]] std::uint32_t index_type_for_index_size(std::uint32_t index_size_bytes) noexcept; diff --git a/tests/renderer_gl/capabilities_tests.cpp b/tests/renderer_gl/capabilities_tests.cpp index 27f4f38..076e43b 100644 --- a/tests/renderer_gl/capabilities_tests.cpp +++ b/tests/renderer_gl/capabilities_tests.cpp @@ -251,11 +251,22 @@ void maps_framebuffer_render_target_parameters(pp::tests::Harness& h) void maps_framebuffer_blit_parameters(pp::tests::Harness& h) { + const auto nearest = pp::renderer::gl::blit_filter_for_renderer_filter(pp::renderer::BlitFilter::nearest); + const auto linear = pp::renderer::gl::blit_filter_for_renderer_filter(pp::renderer::BlitFilter::linear); + const auto invalid = pp::renderer::gl::blit_filter_for_renderer_filter( + static_cast(255U)); + PP_EXPECT(h, pp::renderer::gl::framebuffer_color_buffer_mask() == 0x00004000U); PP_EXPECT(h, pp::renderer::gl::framebuffer_depth_buffer_mask() == 0x00000100U); PP_EXPECT(h, pp::renderer::gl::color_write_mask_query() == 0x0C23U); PP_EXPECT(h, pp::renderer::gl::framebuffer_blit_filter(true) == 0x2601U); PP_EXPECT(h, pp::renderer::gl::framebuffer_blit_filter(false) == 0x2600U); + PP_EXPECT(h, nearest.supported); + PP_EXPECT(h, nearest.value == 0x2600U); + PP_EXPECT(h, linear.supported); + PP_EXPECT(h, linear.value == 0x2601U); + PP_EXPECT(h, !invalid.supported); + PP_EXPECT(h, invalid.value == 0U); } void maps_renderer_primitive_topologies_to_draw_modes(pp::tests::Harness& h)