Share retained utility GL dispatch bridges

This commit is contained in:
2026-06-05 15:05:07 +02:00
parent ad9b91eeda
commit 96d1903cf2
5 changed files with 69 additions and 108 deletions

View File

@@ -548,9 +548,11 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
viewport changes through tested `pp_renderer_gl` dispatch adapters. Grid
depth-state snapshots and sun overlay viewport queries now use tested backend
query dispatch as well.
Legacy `util.cpp` OpenGL error naming and `gl_state` save/restore also
consume backend-owned error codes, state queries, framebuffer targets,
texture binding targets, and active texture units.
Legacy `util.cpp` OpenGL error naming, framebuffer-to-texture copy helper,
and `gl_state` save/restore also consume backend-owned error codes, state
queries, framebuffer targets, texture binding targets, active texture units,
shader program use, and sampler binding through the shared retained bridge
headers instead of local raw OpenGL callbacks.
`NodeStrokePreview` brush preview rendering also consumes backend-owned
depth/scissor/blend state, tested viewport/clear-color query dispatch,
clear-color restore, active texture unit execution, fallback 2D texture

File diff suppressed because one or more lines are too long

View File

@@ -1265,9 +1265,11 @@ readback also goes through the tested framebuffer-backed texture readback
dispatch instead of direct `glGetTexImage`. Grid depth-state snapshots and sun
overlay viewport queries now also use tested backend query dispatch instead of
direct state reads.
Legacy `util.cpp` OpenGL error naming and `gl_state` save/restore now delegate
error codes, state queries, framebuffer targets, texture binding targets, and
active texture units to `pp_renderer_gl`.
Legacy `util.cpp` OpenGL error naming, framebuffer-to-texture copy helper, and
`gl_state` save/restore now delegate error codes, state queries, framebuffer
targets, texture binding targets, active texture units, shader program use, and
sampler binding to `pp_renderer_gl` through the shared retained bridge headers
instead of owning local raw OpenGL callbacks.
`NodeStrokePreview` brush preview rendering now delegates depth/scissor/blend
state, tested viewport/clear-color query dispatch, clear-color restore, active
texture unit execution, fallback 2D texture unbinds, 2D texture targets, copy
@@ -2585,6 +2587,11 @@ Results:
`legacy_gl_shader_dispatch`, removing duplicated raw shader/program/uniform
callback ownership from `src/shader.cpp` while shader-program ownership
remains retained under DEBT-0036.
- Retained `gl_state` save/restore and `copy_framebuffer_to_texture_target`
now reuse `legacy_ui_gl_dispatch`, `legacy_gl_framebuffer_dispatch`,
`legacy_gl_shader_dispatch`, and `legacy_gl_sampler_dispatch`, removing the
local raw state/copy callback cluster from `src/util.cpp` while renderer
state and framebuffer-copy execution remain retained under DEBT-0036.
- Canvas draw-merge shader-blend selection now consumes the extracted
`pp_paint_renderer` stroke composite planner for current layer and primary
brush blend modes, while preserving legacy OpenGL compositing execution under

View File

@@ -91,6 +91,27 @@ inline void read_opengl_pixels(
pixels);
}
inline void copy_opengl_tex_sub_image_2d(
std::uint32_t target,
std::int32_t level,
std::int32_t destination_x,
std::int32_t destination_y,
std::int32_t source_x,
std::int32_t source_y,
std::int32_t width,
std::int32_t height) noexcept
{
glCopyTexSubImage2D(
static_cast<GLenum>(target),
static_cast<GLint>(level),
static_cast<GLint>(destination_x),
static_cast<GLint>(destination_y),
static_cast<GLint>(source_x),
static_cast<GLint>(source_y),
static_cast<GLsizei>(width),
static_cast<GLsizei>(height));
}
inline pp::renderer::gl::OpenGlTexture2DReadbackDispatch texture_2d_readback_dispatch() noexcept
{
return pp::renderer::gl::OpenGlTexture2DReadbackDispatch {
@@ -123,6 +144,13 @@ inline pp::renderer::gl::OpenGlFramebufferReadbackDispatch framebuffer_readback_
};
}
inline pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch framebuffer_to_texture_copy_dispatch() noexcept
{
return pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {
.copy_tex_sub_image_2d = copy_opengl_tex_sub_image_2d,
};
}
inline pp::renderer::gl::OpenGlFramebufferBindDispatch framebuffer_bind_dispatch() noexcept
{
return pp::renderer::gl::OpenGlFramebufferBindDispatch {

View File

@@ -3,93 +3,12 @@
#include "util.h"
#include <poly2tri.h>
#include "app.h"
#include "legacy_gl_framebuffer_dispatch.h"
#include "legacy_gl_sampler_dispatch.h"
#include "legacy_gl_shader_dispatch.h"
#include "legacy_ui_gl_dispatch.h"
#include "renderer_gl/opengl_capabilities.h"
namespace {
std::uint8_t is_opengl_enabled(std::uint32_t state) noexcept
{
return static_cast<std::uint8_t>(glIsEnabled(static_cast<GLenum>(state)));
}
void query_opengl_integer(std::uint32_t name, std::int32_t* value) noexcept
{
glGetIntegerv(static_cast<GLenum>(name), reinterpret_cast<GLint*>(value));
}
void query_opengl_float(std::uint32_t name, float* value) noexcept
{
glGetFloatv(static_cast<GLenum>(name), value);
}
void set_opengl_active_texture(std::uint32_t texture_unit) noexcept
{
glActiveTexture(static_cast<GLenum>(texture_unit));
}
void enable_opengl_state(std::uint32_t state) noexcept
{
glEnable(static_cast<GLenum>(state));
}
void disable_opengl_state(std::uint32_t state) noexcept
{
glDisable(static_cast<GLenum>(state));
}
void set_opengl_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height) noexcept
{
glViewport(static_cast<GLint>(x), static_cast<GLint>(y), static_cast<GLsizei>(width), static_cast<GLsizei>(height));
}
void set_opengl_clear_color(float r, float g, float b, float a) noexcept
{
glClearColor(r, g, b, a);
}
void bind_opengl_framebuffer(std::uint32_t target, std::uint32_t framebuffer) noexcept
{
glBindFramebuffer(static_cast<GLenum>(target), static_cast<GLuint>(framebuffer));
}
void use_opengl_program(std::uint32_t program) noexcept
{
glUseProgram(static_cast<GLuint>(program));
}
void bind_opengl_texture(std::uint32_t target, std::uint32_t texture) noexcept
{
glBindTexture(static_cast<GLenum>(target), static_cast<GLuint>(texture));
}
void bind_opengl_sampler(std::uint32_t unit, std::uint32_t sampler) noexcept
{
glBindSampler(static_cast<GLuint>(unit), static_cast<GLuint>(sampler));
}
void copy_opengl_tex_sub_image_2d(
std::uint32_t target,
std::int32_t level,
std::int32_t destination_x,
std::int32_t destination_y,
std::int32_t source_x,
std::int32_t source_y,
std::int32_t width,
std::int32_t height) noexcept
{
glCopyTexSubImage2D(
static_cast<GLenum>(target),
static_cast<GLint>(level),
static_cast<GLint>(destination_x),
static_cast<GLint>(destination_y),
static_cast<GLint>(source_x),
static_cast<GLint>(source_y),
static_cast<GLsizei>(width),
static_cast<GLsizei>(height));
}
}
template<>
std::vector<vertex_t> poly_remove_duplicate<vertex_t>(const std::vector<vertex_t>& v, const float tollerance)
{
@@ -761,9 +680,7 @@ bool copy_framebuffer_to_texture_target(
.width = width,
.height = height,
},
pp::renderer::gl::OpenGlTexture2DFramebufferCopyDispatch {
.copy_tex_sub_image_2d = copy_opengl_tex_sub_image_2d,
});
pp::legacy::gl_framebuffer::framebuffer_to_texture_copy_dispatch());
if (!status.ok()) {
LOG("OpenGL framebuffer-to-texture copy failed: %s", status.message);
return false;
@@ -866,10 +783,10 @@ void gl_state::save()
const auto snapshot = pp::renderer::gl::snapshot_opengl_state(
pp::renderer::gl::OpenGlStateSnapshotDispatch {
.is_enabled = is_opengl_enabled,
.get_integer = query_opengl_integer,
.get_float = query_opengl_float,
.active_texture = set_opengl_active_texture,
.is_enabled = pp::legacy::ui_gl::is_opengl_state_enabled,
.get_integer = pp::legacy::gl_framebuffer::query_opengl_integer,
.get_float = pp::legacy::ui_gl::get_opengl_float,
.active_texture = pp::legacy::ui_gl::activate_opengl_texture,
});
if (!snapshot.ok()) {
LOG("OpenGL state snapshot failed: %s", snapshot.status().message);
@@ -920,15 +837,15 @@ void gl_state::restore()
const auto status = pp::renderer::gl::restore_opengl_state(
state,
pp::renderer::gl::OpenGlStateRestoreDispatch {
.enable = enable_opengl_state,
.disable = disable_opengl_state,
.viewport = set_opengl_viewport,
.clear_color = set_opengl_clear_color,
.bind_framebuffer = bind_opengl_framebuffer,
.use_program = use_opengl_program,
.active_texture = set_opengl_active_texture,
.bind_texture = bind_opengl_texture,
.bind_sampler = bind_opengl_sampler,
.enable = pp::legacy::ui_gl::enable_opengl_state,
.disable = pp::legacy::ui_gl::disable_opengl_state,
.viewport = pp::legacy::ui_gl::set_opengl_viewport,
.clear_color = pp::legacy::ui_gl::set_opengl_clear_color,
.bind_framebuffer = pp::legacy::ui_gl::bind_opengl_framebuffer,
.use_program = pp::legacy::gl_shader::use_opengl_program,
.active_texture = pp::legacy::ui_gl::activate_opengl_texture,
.bind_texture = pp::legacy::ui_gl::bind_opengl_texture,
.bind_sampler = pp::legacy::gl_sampler::bind_opengl_sampler,
});
if (!status.ok())
LOG("OpenGL state restore failed: %s", status.message);