From b85c530df7e66b093a9828f2e08943e93160c9af Mon Sep 17 00:00:00 2001 From: omigamedev Date: Tue, 2 Jun 2026 08:24:58 +0200 Subject: [PATCH] Move image node state mapping to renderer gl --- docs/modernization/build-inventory.md | 3 +++ docs/modernization/roadmap.md | 3 +++ src/node_image.cpp | 16 ++++++++++++---- src/renderer_gl/opengl_capabilities.cpp | 6 ++++++ src/renderer_gl/opengl_capabilities.h | 1 + tests/renderer_gl/capabilities_tests.cpp | 1 + 6 files changed, 26 insertions(+), 4 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index 3868dd1..a9fc6a9 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -171,6 +171,9 @@ Known local toolchain state: clear-color query, color-buffer clear mask, and blend-state tokens. `NodeImageTexture` preview drawing also consumes backend-owned fallback 2D texture bind and blend-state tokens. + `NodeImage` drawing and remote-image texture creation also consume + backend-owned mipmapped sampler filters, blend-state tokens, and RGBA8/RGBA + texture format mapping. - `windows-msvc-vcpkg-headless` validates manifest install/configure/build/test for the current headless component matrix; see DEBT-0007 for remaining app and platform triplet migration. diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 6b5682f..d9b09e4 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -438,6 +438,9 @@ clear-color query, color-buffer clear mask, and blend-state tokens to `pp_renderer_gl`. `NodeImageTexture` preview drawing now delegates its fallback 2D texture bind target and blend-state tokens to `pp_renderer_gl`. +`NodeImage` drawing and remote-image texture creation now delegate mipmapped +sampler filters, blend-state tokens, and RGBA8/RGBA texture format mapping to +`pp_renderer_gl`. The existing renderer classes are not yet fully behind the renderer interfaces. diff --git a/src/node_image.cpp b/src/node_image.cpp index 2403937..7ee4e0a 100644 --- a/src/node_image.cpp +++ b/src/node_image.cpp @@ -1,6 +1,7 @@ #include "pch.h" #include "log.h" #include "node_image.h" +#include "renderer_gl/opengl_capabilities.h" #include "shader.h" #include "app.h" @@ -13,7 +14,9 @@ void NodeImage::static_init() m_plane.create<1>(1, 1); m_sampler.create(); m_sampler_mips.create(); - m_sampler_mips.set_filter(GL_LINEAR_MIPMAP_LINEAR, GL_LINEAR); + m_sampler_mips.set_filter( + pp::renderer::gl::linear_mipmap_linear_texture_filter(), + pp::renderer::gl::linear_texture_filter()); } Node* NodeImage::clone_instantiate() const @@ -99,7 +102,7 @@ void NodeImage::draw() auto& sampler = m_use_mipmaps ? m_sampler_mips : m_sampler; sampler.bind(0); - glEnable(GL_BLEND); + glEnable(pp::renderer::gl::blend_state()); if (m_use_atlas) { ShaderManager::use(kShader::Atlas); @@ -114,7 +117,7 @@ void NodeImage::draw() ShaderManager::u_mat4(kShaderUniform::MVP, m_mvp * glm::scale(glm::vec3(m_scale, 1.f))); m_plane.draw_fill(); sampler.unbind(); - glDisable(GL_BLEND); + glDisable(pp::renderer::gl::blend_state()); } bool NodeImage::set_image(const std::string& path) @@ -155,7 +158,12 @@ void NodeImage::load_url(const std::string& url) int w, h, c; uint8_t* rgba = stbi_load_from_memory(m_remote_asset->m_data, m_remote_asset->m_len, &w, &h, &c, 4); m_remote_texture = std::make_shared(); - m_remote_texture->create(w, h, GL_RGBA8, GL_RGBA, rgba); + m_remote_texture->create( + w, + h, + pp::renderer::gl::rgba8_internal_format(), + pp::renderer::gl::rgba_pixel_format(), + rgba); if (m_use_mipmaps) m_remote_texture->create_mipmaps(); delete rgba; diff --git a/src/renderer_gl/opengl_capabilities.cpp b/src/renderer_gl/opengl_capabilities.cpp index 8409639..a90119c 100644 --- a/src/renderer_gl/opengl_capabilities.cpp +++ b/src/renderer_gl/opengl_capabilities.cpp @@ -85,6 +85,7 @@ constexpr std::uint32_t gl_texture_cube_map_negative_y = 0x8518U; constexpr std::uint32_t gl_texture_cube_map_positive_z = 0x8519U; constexpr std::uint32_t gl_texture_cube_map_negative_z = 0x851AU; constexpr std::uint32_t gl_linear = 0x2601U; +constexpr std::uint32_t gl_linear_mipmap_linear = 0x2703U; constexpr std::uint32_t gl_nearest = 0x2600U; constexpr std::uint32_t gl_texture_mag_filter = 0x2800U; constexpr std::uint32_t gl_texture_min_filter = 0x2801U; @@ -548,6 +549,11 @@ std::uint32_t linear_texture_filter() noexcept return gl_linear; } +std::uint32_t linear_mipmap_linear_texture_filter() noexcept +{ + return gl_linear_mipmap_linear; +} + std::uint32_t nearest_texture_filter() noexcept { return gl_nearest; diff --git a/src/renderer_gl/opengl_capabilities.h b/src/renderer_gl/opengl_capabilities.h index 0ecd9d0..fa7b95e 100644 --- a/src/renderer_gl/opengl_capabilities.h +++ b/src/renderer_gl/opengl_capabilities.h @@ -112,6 +112,7 @@ struct OpenGlReadbackFormat { [[nodiscard]] std::uint32_t max_blend_equation() noexcept; [[nodiscard]] std::uint32_t rgba8_internal_format() noexcept; [[nodiscard]] std::uint32_t linear_texture_filter() noexcept; +[[nodiscard]] std::uint32_t linear_mipmap_linear_texture_filter() noexcept; [[nodiscard]] std::uint32_t nearest_texture_filter() noexcept; [[nodiscard]] std::uint32_t repeat_texture_wrap() noexcept; [[nodiscard]] std::uint32_t active_texture_unit(std::uint32_t unit_index) noexcept; diff --git a/tests/renderer_gl/capabilities_tests.cpp b/tests/renderer_gl/capabilities_tests.cpp index 471ae43..dde6b56 100644 --- a/tests/renderer_gl/capabilities_tests.cpp +++ b/tests/renderer_gl/capabilities_tests.cpp @@ -337,6 +337,7 @@ void maps_app_initialization_parameters(pp::tests::Harness& h) PP_EXPECT(h, pp::renderer::gl::max_blend_equation() == 0x8008U); PP_EXPECT(h, pp::renderer::gl::rgba8_internal_format() == 0x8058U); PP_EXPECT(h, pp::renderer::gl::linear_texture_filter() == 0x2601U); + PP_EXPECT(h, pp::renderer::gl::linear_mipmap_linear_texture_filter() == 0x2703U); PP_EXPECT(h, pp::renderer::gl::nearest_texture_filter() == 0x2600U); PP_EXPECT(h, pp::renderer::gl::repeat_texture_wrap() == 0x2901U); PP_EXPECT(h, pp::renderer::gl::active_texture_unit(0U) == 0x84C0U);