Share retained renderbuffer dispatch bridge

This commit is contained in:
2026-06-05 14:22:21 +02:00
parent 76a8db1ef8
commit df21d673dd
6 changed files with 134 additions and 142 deletions

View File

@@ -437,9 +437,11 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
`RTT::create`/`RTT::destroy` and framebuffer bind/restore paths, plus RTT
clear color/depth masks. RTT render-target clear, masked color clear with
color-write-mask restore, and texture bind/unbind now execute through tested
dispatch contracts here. Optional RTT depth renderbuffer allocation/storage/delete
and framebuffer depth attach/detach, plus canvas object-drawing depth
renderbuffer setup, also execute through tested dispatch contracts here. Renderer API render-pass color/depth/stencil
dispatch contracts here. Optional RTT depth renderbuffer
allocation/storage/delete and framebuffer depth attach/detach, plus canvas
object-drawing depth renderbuffer setup, also execute through tested dispatch
contracts here and share the retained `legacy_gl_renderbuffer_dispatch` raw
callback bridge. Renderer API render-pass color/depth/stencil
clear-mask and clear-value mapping, and color-write-mask query tokens. `RTT` no longer
spells GL enum names directly. `RTT` also exposes a retained RGBA8
region-readback helper that uses the tested framebuffer readback dispatch for
@@ -559,8 +561,9 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
`pp_renderer_gl` dispatch helpers. Retained `Canvas` active texture, fallback
texture unbind, viewport/scissor execution, viewport and clear-color query,
clear-color restore, and capability query/apply adapter endpoints now share
`legacy_ui_gl_dispatch`; Canvas depth renderbuffer allocation/attachment/delete
remains a separate retained renderer-resource bridge. `NodeCanvas` saved
`legacy_ui_gl_dispatch`; Canvas and RTT depth renderbuffer
allocation/attachment/delete now share `legacy_gl_renderbuffer_dispatch`
while renderer-resource ownership remains retained. `NodeCanvas` saved
viewport/clear-color query, density/offscreen color clear, and clear-color
restore paths use the same helpers. `NodeCanvas` and `NodeStrokePreview` now share
`legacy_ui_gl_dispatch` for active texture, texture unbind, viewport/scissor,

File diff suppressed because one or more lines are too long

View File

@@ -1152,7 +1152,8 @@ status used by `RTT::create`/`RTT::destroy` and framebuffer bind/restore paths,
also live in `pp_renderer_gl`. Depth renderbuffer allocation/storage/delete and
framebuffer depth attach/detach sequences used by retained `RTT` and canvas
object-drawing helpers now execute through tested `pp_renderer_gl` dispatch
contracts. 2D framebuffer-to-texture
contracts and share the retained `legacy_gl_renderbuffer_dispatch` raw callback
bridge. 2D framebuffer-to-texture
copies used by canvas, transform, layer-conversion, panorama UI, brush preview,
and CanvasLayer cube-face generation paths now route through a tested
`pp_renderer_gl` copy dispatch via the retained target-aware framebuffer-copy
@@ -1271,8 +1272,9 @@ query plus clear-color restore paths also use tested `pp_renderer_gl` dispatch
helpers. The retained `Canvas` active-texture, fallback texture unbind,
viewport/scissor execution, viewport and clear-color query, clear-color
restore, and capability query/apply adapter endpoints now share
`legacy_ui_gl_dispatch`; Canvas depth renderbuffer allocation/attachment/delete
remains a separate retained renderer-resource bridge under DEBT-0036.
`legacy_ui_gl_dispatch`; Canvas and RTT depth renderbuffer
allocation/attachment/delete now share `legacy_gl_renderbuffer_dispatch` while
resource lifetime ownership remains retained under DEBT-0036.
`NodeCanvas` saved viewport/clear-color query, density target color clear, and
clear-color restore paths use the same helpers. `NodeCanvas` and
`NodeStrokePreview` now share that retained UI GL dispatch bridge for
@@ -2539,9 +2541,12 @@ Results:
viewport/clear-state queries from `src/canvas.cpp` and the frame clear path.
Their active-texture selection, fallback 2D texture unbind, viewport/scissor
execution, clear-color restore, and capability query/apply adapter endpoints
now share `legacy_ui_gl_dispatch`; retained Canvas depth renderbuffer
allocation/attachment/delete remains open as a renderer-resource bridge under
DEBT-0036.
now share `legacy_ui_gl_dispatch`.
- Retained Canvas and RTT depth renderbuffer allocation, framebuffer depth
attachment, and renderbuffer deletion now share
`legacy_gl_renderbuffer_dispatch`, removing duplicated raw renderbuffer
callbacks from `src/canvas.cpp` and `src/rtt.cpp` while resource lifetime
ownership remains open 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
@@ -2571,7 +2576,7 @@ Results:
viewport/clear/blend state, active texture units, readback format/type,
framebuffer copy targets, and depth renderbuffer allocation plus framebuffer
depth attach/detach through tested renderer GL backend dispatch contracts;
`src/canvas.cpp` no longer contains raw `GL_*` constants.
`src/canvas.cpp` no longer owns raw renderbuffer callbacks.
- Retained Canvas, NodeCanvas, NodeStrokePreview, and HMD viewport/scissor/
capability execution now compiles through the renderer GL backend dispatch
adapters with `pp_legacy_paint_document`, `pp_panopainter_ui`, and

View File

@@ -2,6 +2,7 @@
#include "log.h"
#include "canvas.h"
#include "app.h"
#include "legacy_gl_renderbuffer_dispatch.h"
#include "legacy_ui_gl_dispatch.h"
#include "texture.h"
#include "node_progress_bar.h"
@@ -188,84 +189,26 @@ bool query_canvas_capability(std::uint32_t state)
return pp::legacy::ui_gl::query_capability(state, "Canvas");
}
void gen_opengl_renderbuffers(std::uint32_t count, std::uint32_t* ids) noexcept
{
glGenRenderbuffers(static_cast<GLsizei>(count), reinterpret_cast<GLuint*>(ids));
}
void delete_opengl_renderbuffers(std::uint32_t count, const std::uint32_t* ids) noexcept
{
glDeleteRenderbuffers(static_cast<GLsizei>(count), reinterpret_cast<const GLuint*>(ids));
}
void bind_opengl_renderbuffer(std::uint32_t target, std::uint32_t renderbuffer) noexcept
{
glBindRenderbuffer(static_cast<GLenum>(target), static_cast<GLuint>(renderbuffer));
}
void set_opengl_renderbuffer_storage(
std::uint32_t target,
std::uint32_t internal_format,
std::int32_t width,
std::int32_t height) noexcept
{
glRenderbufferStorage(
static_cast<GLenum>(target),
static_cast<GLenum>(internal_format),
static_cast<GLsizei>(width),
static_cast<GLsizei>(height));
}
void attach_opengl_framebuffer_renderbuffer(
std::uint32_t target,
std::uint32_t attachment,
std::uint32_t renderbuffer_target,
std::uint32_t renderbuffer) noexcept
{
glFramebufferRenderbuffer(
static_cast<GLenum>(target),
static_cast<GLenum>(attachment),
static_cast<GLenum>(renderbuffer_target),
static_cast<GLuint>(renderbuffer));
}
GLuint allocate_canvas_depth_renderbuffer(int width, int height)
{
const auto result = pp::renderer::gl::allocate_opengl_depth_renderbuffer(
return static_cast<GLuint>(pp::legacy::gl_renderbuffer::allocate_depth_renderbuffer(
width,
height,
pp::renderer::gl::OpenGlDepthRenderbufferAllocationDispatch {
.gen_renderbuffers = gen_opengl_renderbuffers,
.bind_renderbuffer = bind_opengl_renderbuffer,
.renderbuffer_storage = set_opengl_renderbuffer_storage,
});
if (!result.ok()) {
LOG("OpenGL canvas depth renderbuffer allocation failed: %s", result.status().message);
return 0U;
}
return static_cast<GLuint>(result.value());
"OpenGL canvas depth renderbuffer allocation"));
}
void attach_canvas_depth_renderbuffer(GLuint renderbuffer)
{
const auto status = pp::renderer::gl::attach_opengl_depth_renderbuffer(
pp::legacy::gl_renderbuffer::attach_depth_renderbuffer(
static_cast<std::uint32_t>(renderbuffer),
pp::renderer::gl::OpenGlDepthRenderbufferAttachmentDispatch {
.framebuffer_renderbuffer = attach_opengl_framebuffer_renderbuffer,
});
if (!status.ok())
LOG("OpenGL canvas depth renderbuffer attachment failed: %s", status.message);
"OpenGL canvas depth renderbuffer attachment");
}
void delete_canvas_renderbuffer(GLuint renderbuffer)
{
const auto status = pp::renderer::gl::delete_opengl_renderbuffer(
pp::legacy::gl_renderbuffer::delete_renderbuffer(
static_cast<std::uint32_t>(renderbuffer),
pp::renderer::gl::OpenGlRenderbufferDeleteDispatch {
.delete_renderbuffers = delete_opengl_renderbuffers,
});
if (!status.ok())
LOG("OpenGL canvas renderbuffer delete failed: %s", status.message);
"OpenGL canvas renderbuffer delete");
}
}

View File

@@ -0,0 +1,90 @@
#pragma once
#include <cstdint>
#include "log.h"
#include "renderer_gl/opengl_capabilities.h"
namespace pp::legacy::gl_renderbuffer {
inline void gen_opengl_renderbuffers(std::uint32_t count, std::uint32_t* ids) noexcept
{
glGenRenderbuffers(static_cast<GLsizei>(count), reinterpret_cast<GLuint*>(ids));
}
inline void delete_opengl_renderbuffers(std::uint32_t count, const std::uint32_t* ids) noexcept
{
glDeleteRenderbuffers(static_cast<GLsizei>(count), reinterpret_cast<const GLuint*>(ids));
}
inline void bind_opengl_renderbuffer(std::uint32_t target, std::uint32_t renderbuffer) noexcept
{
glBindRenderbuffer(static_cast<GLenum>(target), static_cast<GLuint>(renderbuffer));
}
inline void set_opengl_renderbuffer_storage(
std::uint32_t target,
std::uint32_t internal_format,
std::int32_t width,
std::int32_t height) noexcept
{
glRenderbufferStorage(
static_cast<GLenum>(target),
static_cast<GLenum>(internal_format),
static_cast<GLsizei>(width),
static_cast<GLsizei>(height));
}
inline void attach_opengl_framebuffer_renderbuffer(
std::uint32_t target,
std::uint32_t attachment,
std::uint32_t renderbuffer_target,
std::uint32_t renderbuffer) noexcept
{
glFramebufferRenderbuffer(
static_cast<GLenum>(target),
static_cast<GLenum>(attachment),
static_cast<GLenum>(renderbuffer_target),
static_cast<GLuint>(renderbuffer));
}
inline std::uint32_t allocate_depth_renderbuffer(std::int32_t width, std::int32_t height, const char* context)
{
const auto result = pp::renderer::gl::allocate_opengl_depth_renderbuffer(
width,
height,
pp::renderer::gl::OpenGlDepthRenderbufferAllocationDispatch {
.gen_renderbuffers = gen_opengl_renderbuffers,
.bind_renderbuffer = bind_opengl_renderbuffer,
.renderbuffer_storage = set_opengl_renderbuffer_storage,
});
if (!result.ok()) {
LOG("%s failed because: %s", context, result.status().message);
return 0U;
}
return result.value();
}
inline void attach_depth_renderbuffer(std::uint32_t renderbuffer, const char* context)
{
const auto status = pp::renderer::gl::attach_opengl_depth_renderbuffer(
renderbuffer,
pp::renderer::gl::OpenGlDepthRenderbufferAttachmentDispatch {
.framebuffer_renderbuffer = attach_opengl_framebuffer_renderbuffer,
});
if (!status.ok())
LOG("%s failed because: %s", context, status.message);
}
inline void delete_renderbuffer(std::uint32_t renderbuffer, const char* context)
{
const auto status = pp::renderer::gl::delete_opengl_renderbuffer(
renderbuffer,
pp::renderer::gl::OpenGlRenderbufferDeleteDispatch {
.delete_renderbuffers = delete_opengl_renderbuffers,
});
if (!status.ok())
LOG("%s failed because: %s", context, status.message);
}
} // namespace pp::legacy::gl_renderbuffer

View File

@@ -3,6 +3,7 @@
#include "rtt.h"
#include "util.h"
#include "app.h"
#include "legacy_gl_renderbuffer_dispatch.h"
#include "renderer_gl/opengl_capabilities.h"
#include <cstdint>
@@ -14,11 +15,6 @@ namespace {
return static_cast<GLenum>(pp::renderer::gl::texture_2d_target());
}
[[nodiscard]] GLenum renderbuffer_target() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::renderbuffer_target());
}
[[nodiscard]] GLenum framebuffer_target() noexcept
{
return static_cast<GLenum>(pp::renderer::gl::framebuffer_target());
@@ -120,34 +116,6 @@ void set_opengl_texture_parameter_f(std::uint32_t target, std::uint32_t paramete
glTexParameterf(static_cast<GLenum>(target), static_cast<GLenum>(parameter), static_cast<GLfloat>(value));
}
void gen_opengl_renderbuffers(std::uint32_t count, std::uint32_t* ids) noexcept
{
glGenRenderbuffers(static_cast<GLsizei>(count), reinterpret_cast<GLuint*>(ids));
}
void delete_opengl_renderbuffers(std::uint32_t count, const std::uint32_t* ids) noexcept
{
glDeleteRenderbuffers(static_cast<GLsizei>(count), reinterpret_cast<const GLuint*>(ids));
}
void bind_opengl_renderbuffer(std::uint32_t target, std::uint32_t renderbuffer) noexcept
{
glBindRenderbuffer(static_cast<GLenum>(target), static_cast<GLuint>(renderbuffer));
}
void set_opengl_renderbuffer_storage(
std::uint32_t target,
std::uint32_t internal_format,
std::int32_t width,
std::int32_t height) noexcept
{
glRenderbufferStorage(
static_cast<GLenum>(target),
static_cast<GLenum>(internal_format),
static_cast<GLsizei>(width),
static_cast<GLsizei>(height));
}
void gen_opengl_framebuffers(std::uint32_t count, std::uint32_t* ids) noexcept
{
glGenFramebuffers(static_cast<GLsizei>(count), reinterpret_cast<GLuint*>(ids));
@@ -173,19 +141,6 @@ void attach_opengl_framebuffer_texture_2d(
static_cast<GLint>(level));
}
void attach_opengl_framebuffer_renderbuffer(
std::uint32_t target,
std::uint32_t attachment,
std::uint32_t renderbuffer_target,
std::uint32_t renderbuffer) noexcept
{
glFramebufferRenderbuffer(
static_cast<GLenum>(target),
static_cast<GLenum>(attachment),
static_cast<GLenum>(renderbuffer_target),
static_cast<GLuint>(renderbuffer));
}
std::uint32_t check_opengl_framebuffer_status(std::uint32_t target) noexcept
{
return static_cast<std::uint32_t>(glCheckFramebufferStatus(static_cast<GLenum>(target)));
@@ -400,13 +355,9 @@ void RTT::destroy()
{
if (rboID)
{
const auto status = pp::renderer::gl::delete_opengl_renderbuffer(
pp::legacy::gl_renderbuffer::delete_renderbuffer(
static_cast<std::uint32_t>(rboID),
pp::renderer::gl::OpenGlRenderbufferDeleteDispatch {
.delete_renderbuffers = delete_opengl_renderbuffers,
});
if (!status.ok())
LOG("RTT::destroy renderbuffer delete failed because: %s", status.message);
"RTT::destroy renderbuffer delete");
}
if (texID)
{
@@ -587,21 +538,16 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format,
// Create a renderbuffer object to store depth info
if (depth_buffer)
{
const auto renderbuffer = pp::renderer::gl::allocate_opengl_depth_renderbuffer(
const auto renderbuffer = pp::legacy::gl_renderbuffer::allocate_depth_renderbuffer(
width,
height,
pp::renderer::gl::OpenGlDepthRenderbufferAllocationDispatch {
.gen_renderbuffers = gen_opengl_renderbuffers,
.bind_renderbuffer = bind_opengl_renderbuffer,
.renderbuffer_storage = set_opengl_renderbuffer_storage,
});
if (!renderbuffer.ok())
"RTT::create depth renderbuffer allocation");
if (renderbuffer == 0U)
{
LOG("RTT::create depth renderbuffer allocation failed because: %s", renderbuffer.status().message);
status = 0;
return;
}
rboID = static_cast<GLuint>(renderbuffer.value());
rboID = static_cast<GLuint>(renderbuffer);
}
// Create a framebuffer object
@@ -613,7 +559,7 @@ bool RTT::create(int width, int height, int tex/* = -1*/, GLint internal_format,
.get_integer = query_opengl_integer,
.bind_framebuffer = bind_opengl_framebuffer,
.framebuffer_texture_2d = attach_opengl_framebuffer_texture_2d,
.framebuffer_renderbuffer = attach_opengl_framebuffer_renderbuffer,
.framebuffer_renderbuffer = pp::legacy::gl_renderbuffer::attach_opengl_framebuffer_renderbuffer,
.check_framebuffer_status = check_opengl_framebuffer_status,
});
if (!framebuffer.ok())