Move app render state mapping to renderer gl

This commit is contained in:
2026-06-02 07:01:07 +02:00
parent 3930f39b14
commit 217450e161
6 changed files with 90 additions and 14 deletions

View File

@@ -158,7 +158,9 @@ Known local toolchain state:
check. App OpenGL initialization debug severity, debug output, GL info string,
default depth/program-point/line-smooth state, blend factor/equation, and UI
render-target RGBA8 format tokens are cataloged and tested here too, including
the legacy convert command and resize path.
the legacy convert command and resize path. App clear color-buffer masks,
default framebuffer binding, scissor state, and sampler filter/wrap tokens
also consume the backend 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.

View File

@@ -423,7 +423,9 @@ directly. App OpenGL initialization debug severity, debug output, GL info
string, default depth/program-point/line-smooth state, blend factor/equation,
and UI render-target RGBA8 format tokens are now also cataloged and tested in
`pp_renderer_gl`; the legacy convert command and resize path consume the same
backend-owned mapping. The existing renderer classes are not yet fully
backend-owned mapping. App clear color-buffer masks, default framebuffer
binding, scissor state, and sampler filter/wrap tokens now share that backend
mapping too. The existing renderer classes are not yet fully
behind the renderer interfaces.
Implementation tasks:

View File

@@ -97,6 +97,11 @@ namespace {
return static_cast<GLenum>(pp::renderer::gl::depth_test_state());
}
[[nodiscard]] GLenum scissor_test_state() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::scissor_test_state());
}
[[nodiscard]] GLenum program_point_size_state() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::program_point_size_state());
@@ -132,6 +137,36 @@ namespace {
return static_cast<GLint>(pp::renderer::gl::rgba8_internal_format());
}
[[nodiscard]] GLenum linear_texture_filter() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::linear_texture_filter());
}
[[nodiscard]] GLenum nearest_texture_filter() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::nearest_texture_filter());
}
[[nodiscard]] GLenum repeat_texture_wrap() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::repeat_texture_wrap());
}
[[nodiscard]] GLenum framebuffer_target() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::framebuffer_target());
}
[[nodiscard]] GLuint default_framebuffer_id() noexcept
{
return static_cast<GLuint>(pp::renderer::gl::default_framebuffer_id());
}
[[nodiscard]] GLbitfield framebuffer_color_buffer_mask() noexcept
{
return static_cast<GLbitfield>(pp::renderer::gl::framebuffer_color_buffer_mask());
}
}
std::thread App::render_thread;
std::thread::id App::render_thread_id;
@@ -256,7 +291,7 @@ bool App::request_close()
void App::clear()
{
glClearColor(.1f, .1f, .1f, 1.f);
glClear(GL_COLOR_BUFFER_BIT);
glClear(framebuffer_color_buffer_mask());
}
void App::initAssets()
@@ -265,9 +300,9 @@ void App::initAssets()
FontManager::init();
LOG("initializing assets create sampler");
sampler.create(GL_NEAREST);
sampler_stencil.create(GL_LINEAR, GL_REPEAT);
sampler_linear.create(GL_LINEAR);
sampler.create(nearest_texture_filter());
sampler_stencil.create(linear_texture_filter(), repeat_texture_wrap());
sampler_linear.create(linear_texture_filter());
m_face_plane.create<1>(2, 2);
sphere.create<8, 8>(1);
LOG("initializing assets load uvs texture");
@@ -587,7 +622,7 @@ void App::async_start()
android_async_lock();
#elif _WIN32
async_lock();
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
#elif __LINUX__ || __WEB__
glfwMakeContextCurrent(glfw_window);
#endif
@@ -686,13 +721,13 @@ void App::draw(float dt)
uirtt.bindFramebuffer();
uirtt.clear();
glViewport(0, 0, uirtt.getWidth(), uirtt.getHeight());
glEnable(GL_SCISSOR_TEST);
glEnable(scissor_test_state());
for (int i = 1; i < layout[main_id]->m_children.size(); i++)
layout[main_id]->m_children[i]->watch(observer);
for (int i = 0; layout_designer.get(main_id) && i < layout_designer[main_id]->m_children.size(); i++)
layout_designer[main_id]->m_children[i]->watch(observer);
//msgbox->watch(observer);
glDisable(GL_SCISSOR_TEST);
glDisable(scissor_test_state());
uirtt.unbindFramebuffer();
}
@@ -701,16 +736,16 @@ void App::draw(float dt)
#if __IOS__
[ios_view->glview bindDrawable];
#else
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
#endif
glViewport(off_x, off_y, (GLsizei)width, (GLsizei)height);
glEnable(GL_SCISSOR_TEST);
glEnable(scissor_test_state());
for (int i = 0; i < layout[main_id]->m_children.size(); i++)
layout[main_id]->m_children[i]->watch(observer);
for (int i = 0; layout_designer.get(main_id) && i < layout_designer[main_id]->m_children.size(); i++)
layout_designer[main_id]->m_children[i]->watch(observer);
//msgbox->watch(observer);
glDisable(GL_SCISSOR_TEST);
glDisable(scissor_test_state());
}
redraw = false;
@@ -1012,7 +1047,7 @@ void App::ui_thread_tick()
update(0);
render_task([this]
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
clear();
draw(0);
async_swap();
@@ -1114,7 +1149,7 @@ void App::ui_thread_main()
update(t_frame);
render_task([this, t_frame]
{
glBindFramebuffer(GL_FRAMEBUFFER, 0);
glBindFramebuffer(framebuffer_target(), default_framebuffer_id());
clear();
draw(t_frame);
async_swap();

View File

@@ -33,6 +33,7 @@ constexpr std::uint32_t gl_debug_severity_notification = 0x826BU;
constexpr std::uint32_t gl_src_alpha = 0x0302U;
constexpr std::uint32_t gl_one_minus_src_alpha = 0x0303U;
constexpr std::uint32_t gl_line_smooth = 0x0B20U;
constexpr std::uint32_t gl_scissor_test = 0x0C11U;
constexpr std::uint32_t gl_depth_test = 0x0B71U;
constexpr std::uint32_t gl_func_add = 0x8006U;
constexpr std::uint32_t gl_max = 0x8008U;
@@ -86,6 +87,7 @@ constexpr std::uint32_t gl_texture_wrap_s = 0x2802U;
constexpr std::uint32_t gl_texture_wrap_t = 0x2803U;
constexpr std::uint32_t gl_texture_wrap_r = 0x8072U;
constexpr std::uint32_t gl_texture_border_color = 0x1004U;
constexpr std::uint32_t gl_repeat = 0x2901U;
constexpr std::uint32_t gl_clamp_to_edge = 0x812FU;
constexpr std::uint32_t gl_pixel_pack_buffer = 0x88EBU;
constexpr std::uint32_t gl_pixel_unpack_buffer = 0x88ECU;
@@ -277,6 +279,11 @@ std::uint32_t framebuffer_complete_status() noexcept
return gl_framebuffer_complete;
}
std::uint32_t default_framebuffer_id() noexcept
{
return 0U;
}
const char* framebuffer_status_name(std::uint32_t status) noexcept
{
switch (status) {
@@ -465,6 +472,11 @@ std::uint32_t depth_test_state() noexcept
return gl_depth_test;
}
std::uint32_t scissor_test_state() noexcept
{
return gl_scissor_test;
}
std::uint32_t program_point_size_state() noexcept
{
return gl_program_point_size;
@@ -500,6 +512,21 @@ std::uint32_t rgba8_internal_format() noexcept
return gl_rgba8;
}
std::uint32_t linear_texture_filter() noexcept
{
return gl_linear;
}
std::uint32_t nearest_texture_filter() noexcept
{
return gl_nearest;
}
std::uint32_t repeat_texture_wrap() noexcept
{
return gl_repeat;
}
std::uint32_t texture_cube_map_target() noexcept
{
return gl_texture_cube_map;

View File

@@ -67,6 +67,7 @@ struct OpenGlReadbackFormat {
[[nodiscard]] std::uint32_t framebuffer_color_attachment() noexcept;
[[nodiscard]] std::uint32_t framebuffer_depth_attachment() noexcept;
[[nodiscard]] std::uint32_t framebuffer_complete_status() noexcept;
[[nodiscard]] std::uint32_t default_framebuffer_id() noexcept;
[[nodiscard]] const char* framebuffer_status_name(std::uint32_t status) noexcept;
[[nodiscard]] std::uint32_t framebuffer_color_buffer_mask() noexcept;
[[nodiscard]] std::uint32_t framebuffer_depth_buffer_mask() noexcept;
@@ -97,6 +98,7 @@ struct OpenGlReadbackFormat {
[[nodiscard]] std::uint32_t renderer_string_name() noexcept;
[[nodiscard]] std::uint32_t shading_language_version_string_name() noexcept;
[[nodiscard]] std::uint32_t depth_test_state() noexcept;
[[nodiscard]] std::uint32_t scissor_test_state() noexcept;
[[nodiscard]] std::uint32_t program_point_size_state() noexcept;
[[nodiscard]] std::uint32_t line_smooth_state() noexcept;
[[nodiscard]] std::uint32_t source_alpha_blend_factor() noexcept;
@@ -104,6 +106,9 @@ struct OpenGlReadbackFormat {
[[nodiscard]] std::uint32_t add_blend_equation() noexcept;
[[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 nearest_texture_filter() noexcept;
[[nodiscard]] std::uint32_t repeat_texture_wrap() noexcept;
[[nodiscard]] std::uint32_t texture_cube_map_target() noexcept;
[[nodiscard]] std::uint32_t cube_map_allocation_face_texture_target(std::uint32_t face_index) noexcept;
[[nodiscard]] std::span<const std::uint32_t> panopainter_cube_face_texture_targets() noexcept;

View File

@@ -174,6 +174,7 @@ void maps_framebuffer_render_target_parameters(pp::tests::Harness& h)
PP_EXPECT(h, pp::renderer::gl::read_framebuffer_binding_query() == 0x8CAAU);
PP_EXPECT(h, pp::renderer::gl::framebuffer_color_attachment() == 0x8CE0U);
PP_EXPECT(h, pp::renderer::gl::framebuffer_depth_attachment() == 0x8D00U);
PP_EXPECT(h, pp::renderer::gl::default_framebuffer_id() == 0U);
}
void maps_framebuffer_blit_parameters(pp::tests::Harness& h)
@@ -321,6 +322,7 @@ void maps_app_initialization_parameters(pp::tests::Harness& h)
PP_EXPECT(h, pp::renderer::gl::shading_language_version_string_name() == 0x8B8CU);
PP_EXPECT(h, pp::renderer::gl::depth_test_state() == 0x0B71U);
PP_EXPECT(h, pp::renderer::gl::scissor_test_state() == 0x0C11U);
PP_EXPECT(h, pp::renderer::gl::program_point_size_state() == 0x8642U);
PP_EXPECT(h, pp::renderer::gl::line_smooth_state() == 0x0B20U);
PP_EXPECT(h, pp::renderer::gl::source_alpha_blend_factor() == 0x0302U);
@@ -328,6 +330,9 @@ void maps_app_initialization_parameters(pp::tests::Harness& h)
PP_EXPECT(h, pp::renderer::gl::add_blend_equation() == 0x8006U);
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::nearest_texture_filter() == 0x2600U);
PP_EXPECT(h, pp::renderer::gl::repeat_texture_wrap() == 0x2901U);
}
void rejects_invalid_shader_attribute_binding_catalogs(pp::tests::Harness& h)