From f1e2743d58ecfd19229594d849baa10aa5bb82a0 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Mon, 1 Jun 2026 18:11:44 +0200 Subject: [PATCH] Move render target texture parameters to renderer gl --- docs/modernization/build-inventory.md | 16 +++++++++------- docs/modernization/roadmap.md | 23 +++++++++++++---------- src/renderer_gl/opengl_capabilities.cpp | 18 ++++++++++++++++++ src/renderer_gl/opengl_capabilities.h | 6 ++++++ src/rtt.cpp | 11 +++++++---- tests/renderer_gl/capabilities_tests.cpp | 16 ++++++++++++++++ 6 files changed, 69 insertions(+), 21 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index b17a9f1..cb74bed 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -130,13 +130,15 @@ Known local toolchain state: upload-type mapping used by legacy `Texture2D` and `RTT` creation. It also validates image channel-count to OpenGL texture format mapping, including invalid channel counts rejected by `Texture2D::create(Image)`, and - framebuffer status naming used by `RTT` diagnostics. It also validates - Shape index-type and fill/stroke primitive-mode mapping used by the legacy - mesh draw path, plus the PanoPainter cube-face to OpenGL texture-target - mapping used by `TextureCube`. The PanoPainter shader attribute binding - catalog used by legacy `Shader` creation also lives here. It also owns the - PanoPainter shader uniform catalog and legacy hash mapping used by `Shader` - active-uniform discovery and the uniform uniqueness check. + framebuffer status naming used by `RTT` diagnostics. It also owns and + validates the default linear clamp-to-edge render-target texture parameters + used by `RTT::create`. It also validates Shape index-type and fill/stroke + primitive-mode mapping used by the legacy mesh draw path, plus the + PanoPainter cube-face to OpenGL texture-target mapping used by `TextureCube`. + The PanoPainter shader attribute binding catalog used by legacy `Shader` + creation also lives here. It also owns the PanoPainter shader uniform catalog + and legacy hash mapping used by `Shader` active-uniform discovery and the + uniform uniqueness check. - `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 8da6f83..5a09b8f 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -390,11 +390,13 @@ OpenGL capability detection for framebuffer fetch, map-buffer alignment, and float texture support. It also owns the OpenGL texture upload-type mapping used by legacy `Texture2D` and `RTT` creation, plus image channel-count to texture format mapping for `Texture2D` image uploads and framebuffer status naming for -`RTT` diagnostics. Mesh index-type and primitive-mode decisions used by legacy -`Shape` drawing and the PanoPainter cube-face to OpenGL texture-target mapping -used by `TextureCube` also live in `pp_renderer_gl`. The legacy app delegates -extension, upload-format, framebuffer diagnostic, mesh draw-mode, and cube-face -texture-target interpretation to that backend library. The PanoPainter shader attribute +`RTT` diagnostics. The default render-target texture parameters used by +`RTT::create` also live in `pp_renderer_gl`. Mesh index-type and primitive-mode +decisions used by legacy `Shape` drawing and the PanoPainter cube-face to +OpenGL texture-target mapping used by `TextureCube` also live in +`pp_renderer_gl`. The legacy app delegates extension, upload-format, +framebuffer diagnostic, render-target texture parameter, mesh draw-mode, and +cube-face texture-target interpretation to that backend library. The PanoPainter shader attribute binding catalog also lives in `pp_renderer_gl` and is consumed by legacy `Shader` creation. Shader uniform hashing, catalog validation, active-uniform mapping, and the legacy uniform uniqueness check now delegate to @@ -641,11 +643,12 @@ Results: WebGL exclusion behavior, upload types for RGBA8/RGBA16F/RGBA32F internal formats, image channel-count format mapping including invalid counts, and framebuffer status names, plus Shape index-type and fill/stroke primitive - mode mapping and PanoPainter cube-face texture-target order. Shader attribute - binding catalog validation covers the current `pos`, `uvs`, `uvs2`, `col`, - and `nor` bindings and rejects empty, unnamed, null-name, and duplicate-name - catalogs while preserving legacy shared locations. Shader uniform catalog - validation covers the 43 legacy uniform + mode mapping, PanoPainter cube-face texture-target order, and the linear + clamp-to-edge render-target texture parameter set used by `RTT::create`. + Shader attribute binding catalog validation covers the current `pos`, `uvs`, + `uvs2`, `col`, and `nor` bindings and rejects empty, unnamed, null-name, and + duplicate-name catalogs while preserving legacy shared locations. Shader + uniform catalog validation covers the 43 legacy uniform names used by `Shader`, preserves the legacy hash ids, and rejects empty, unnamed, null-name, mismatched-hash, and duplicate-name catalogs. - PowerShell analyze automation returns JSON summaries and includes the shader diff --git a/src/renderer_gl/opengl_capabilities.cpp b/src/renderer_gl/opengl_capabilities.cpp index 992eab2..4066b54 100644 --- a/src/renderer_gl/opengl_capabilities.cpp +++ b/src/renderer_gl/opengl_capabilities.cpp @@ -38,6 +38,12 @@ constexpr std::uint32_t gl_texture_cube_map_positive_y = 0x8517U; 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_texture_mag_filter = 0x2800U; +constexpr std::uint32_t gl_texture_min_filter = 0x2801U; +constexpr std::uint32_t gl_texture_wrap_s = 0x2802U; +constexpr std::uint32_t gl_texture_wrap_t = 0x2803U; +constexpr std::uint32_t gl_clamp_to_edge = 0x812FU; [[nodiscard]] bool contains(std::string_view text, std::string_view needle) noexcept { @@ -195,4 +201,16 @@ std::uint32_t cube_face_texture_target(std::uint32_t face_index) noexcept return targets[face_index]; } +std::span default_render_target_texture_parameters() noexcept +{ + static constexpr std::array parameters { + OpenGlTextureParameter { .name = gl_texture_mag_filter, .value = gl_linear }, + OpenGlTextureParameter { .name = gl_texture_min_filter, .value = gl_linear }, + OpenGlTextureParameter { .name = gl_texture_wrap_s, .value = gl_clamp_to_edge }, + OpenGlTextureParameter { .name = gl_texture_wrap_t, .value = gl_clamp_to_edge }, + }; + + return parameters; +} + } diff --git a/src/renderer_gl/opengl_capabilities.h b/src/renderer_gl/opengl_capabilities.h index 6b6dd41..9072c52 100644 --- a/src/renderer_gl/opengl_capabilities.h +++ b/src/renderer_gl/opengl_capabilities.h @@ -26,6 +26,11 @@ struct OpenGlPixelFormat { std::uint32_t channel_count = 0; }; +struct OpenGlTextureParameter { + std::uint32_t name = 0; + std::uint32_t value = 0; +}; + [[nodiscard]] OpenGlCapabilities detect_opengl_capabilities( std::span extensions, OpenGlRuntime runtime) noexcept; @@ -38,5 +43,6 @@ struct OpenGlPixelFormat { [[nodiscard]] std::uint32_t primitive_mode_for_stroke_count(std::uint32_t vertex_or_index_count) noexcept; [[nodiscard]] std::span panopainter_cube_face_texture_targets() noexcept; [[nodiscard]] std::uint32_t cube_face_texture_target(std::uint32_t face_index) noexcept; +[[nodiscard]] std::span default_render_target_texture_parameters() noexcept; } diff --git a/src/rtt.cpp b/src/rtt.cpp index 537df31..98ef02a4 100644 --- a/src/rtt.cpp +++ b/src/rtt.cpp @@ -213,10 +213,13 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format, glBindTexture(GL_TEXTURE_2D, texID); if (tex == -1) glTexImage2D(GL_TEXTURE_2D, 0, internal_format, width, height, 0, GL_RGBA, ifmt, 0); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + for (const auto parameter : pp::renderer::gl::default_render_target_texture_parameters()) + { + glTexParameterf( + GL_TEXTURE_2D, + static_cast(parameter.name), + static_cast(parameter.value)); + } glBindTexture(GL_TEXTURE_2D, 0); // Create a renderbuffer object to store depth info diff --git a/tests/renderer_gl/capabilities_tests.cpp b/tests/renderer_gl/capabilities_tests.cpp index a7d092e..cc718d5 100644 --- a/tests/renderer_gl/capabilities_tests.cpp +++ b/tests/renderer_gl/capabilities_tests.cpp @@ -174,6 +174,21 @@ void maps_panopainter_cube_faces_to_texture_targets(pp::tests::Harness& h) PP_EXPECT(h, pp::renderer::gl::cube_face_texture_target(6U) == 0U); } +void exposes_default_render_target_texture_parameters(pp::tests::Harness& h) +{ + const auto parameters = pp::renderer::gl::default_render_target_texture_parameters(); + + PP_EXPECT(h, parameters.size() == 4U); + PP_EXPECT(h, parameters[0].name == 0x2800U); + PP_EXPECT(h, parameters[0].value == 0x2601U); + PP_EXPECT(h, parameters[1].name == 0x2801U); + PP_EXPECT(h, parameters[1].value == 0x2601U); + PP_EXPECT(h, parameters[2].name == 0x2802U); + PP_EXPECT(h, parameters[2].value == 0x812FU); + PP_EXPECT(h, parameters[3].name == 0x2803U); + PP_EXPECT(h, parameters[3].value == 0x812FU); +} + void exposes_shader_attribute_binding_catalog(pp::tests::Harness& h) { const auto bindings = pp::renderer::gl::panopainter_shader_attribute_bindings(); @@ -277,6 +292,7 @@ int main() harness.run("names_framebuffer_status_codes", names_framebuffer_status_codes); harness.run("maps_shape_index_and_primitive_modes", maps_shape_index_and_primitive_modes); harness.run("maps_panopainter_cube_faces_to_texture_targets", maps_panopainter_cube_faces_to_texture_targets); + harness.run("exposes_default_render_target_texture_parameters", exposes_default_render_target_texture_parameters); harness.run("exposes_shader_attribute_binding_catalog", exposes_shader_attribute_binding_catalog); harness.run("rejects_invalid_shader_attribute_binding_catalogs", rejects_invalid_shader_attribute_binding_catalogs); harness.run("exposes_shader_uniform_catalog", exposes_shader_uniform_catalog);