Share CanvasLayer GL dispatch adapters

This commit is contained in:
2026-06-05 14:00:33 +02:00
parent 745a5898da
commit 2641db35ac
5 changed files with 50 additions and 110 deletions

View File

@@ -518,8 +518,12 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
paths also consume backend-owned blend-state tokens.
Canvas layer cube/equirect generation, clear, restore, and snapshot paths
also consume backend-owned cube/2D texture targets, active texture units,
cube texture binding, blend/clear state, viewport execution, target-aware
framebuffer-to-texture copies, and RGBA8 read/write pixel mapping.
cube texture binding, blend/clear state, viewport execution, color-buffer
clear, clear-color query/restore, and RGBA8 read/write pixel mapping. Their
active-texture, cube-texture binding, viewport, blend capability,
clear-color, and color-buffer clear adapter endpoints now share
`legacy_ui_gl_dispatch`; the retained cube-face framebuffer-to-texture copy
remains tracked by DEBT-0036.
`NodePanelGrid` heightmap preview and lightmap baking also consume
backend-owned texture readback formats, sampler filters, depth/blend state,
depth clears, viewport queries, color-mask booleans, active texture units,
@@ -558,6 +562,11 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
`CanvasMode` overlay, mask, transform, and canvas-tip pick paths now also
share that bridge for active texture, capability query/apply, viewport,
read-framebuffer query, and RGBA8 pixel-readback adapter endpoints.
`CanvasLayer` cube/equirect generation and frame clears also share the bridge
for active texture, cube texture binding, viewport execution, blend
capability execution, clear-color query/restore, and color-buffer clear
adapter endpoints, while its cube-face framebuffer-to-texture copy remains a
retained local copy bridge.
`NodePanelGrid` heightmap draw and bake setup also shares it for active
texture, depth/blend capability query/apply, viewport query/execution, depth
clears, and color-write-mask adapter endpoints.

File diff suppressed because one or more lines are too long

View File

@@ -1228,8 +1228,12 @@ Simple UI text, text-input, border, scroll, and animation timeline draw paths
now also execute blend-state changes through the shared UI GL adapter.
Canvas layer cube/equirect generation, clear, restore, and snapshot paths now
also delegate cube/2D texture targets, active texture units, blend/clear state,
viewport execution, target-aware framebuffer-to-texture copies, cube texture
binding, and RGBA8 read/write pixel mapping to `pp_renderer_gl`.
viewport execution, cube texture binding, color-buffer clears, clear-color
query/restore, and RGBA8 read/write pixel mapping to `pp_renderer_gl`. Its
active-texture, cube-texture binding, viewport, blend capability, clear-color,
and color-buffer clear adapter endpoints now share `legacy_ui_gl_dispatch`;
the retained cube-face framebuffer-to-texture copy remains tracked under
DEBT-0036 until a renderer-owned cube copy command replaces it.
`NodePanelGrid` heightmap preview and lightmap baking now delegate texture
readback formats, sampler filters, depth/blend state, depth clears, viewport
queries, color-mask booleans, active texture units, and float render-target
@@ -2493,10 +2497,12 @@ Results:
- Canvas layer merge rendering and explicit layer-merge compositing now route
depth/blend state, active texture units, fallback 2D texture unbinds, and
merge framebuffer copy targets through the renderer GL backend mapping.
- Canvas layer cube/equirect generation and frame clears now route blend state,
active texture units, viewport execution, color clears, and cube-face
framebuffer-to-texture copies through tested renderer GL backend dispatch
contracts.
- Canvas layer cube/equirect generation and frame clears now share
`legacy_ui_gl_dispatch` for active-texture selection, cube texture binding,
viewport execution, blend capability execution, clear-color query/restore,
and color-buffer clear adapter endpoints backed by tested renderer GL
backend dispatch contracts. The cube-face framebuffer-to-texture copy remains
the retained local copy bridge tracked by DEBT-0036.
- `NodePanelGrid` live heightmap drawing and bake setup now route depth/blend
state, depth clears, color-write-mask toggles, active texture selection, and
bake viewport execution through tested renderer GL backend dispatch

View File

@@ -1,6 +1,7 @@
#include "pch.h"
#include "canvas_layer.h"
#include "app.h"
#include "legacy_ui_gl_dispatch.h"
#include "log.h"
#include "renderer_gl/opengl_capabilities.h"
#include "rtt.h"
@@ -12,46 +13,6 @@ uint32_t Layer::s_count = 0;
namespace {
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_active_texture(std::uint32_t texture_unit) noexcept
{
glActiveTexture(static_cast<GLenum>(texture_unit));
}
void bind_opengl_texture(std::uint32_t target, std::uint32_t texture) noexcept
{
glBindTexture(static_cast<GLenum>(target), static_cast<GLuint>(texture));
}
void set_opengl_clear_color(float r, float g, float b, float a) noexcept
{
glClearColor(r, g, b, a);
}
void clear_opengl_buffer(std::uint32_t mask) noexcept
{
glClear(static_cast<GLbitfield>(mask));
}
void get_opengl_float(std::uint32_t name, float* values) noexcept
{
glGetFloatv(static_cast<GLenum>(name), values);
}
void copy_opengl_tex_sub_image_2d(
std::uint32_t target,
std::int32_t level,
@@ -75,53 +36,22 @@ void copy_opengl_tex_sub_image_2d(
void apply_layer_viewport(std::int32_t x, std::int32_t y, std::int32_t width, std::int32_t height)
{
const auto status = pp::renderer::gl::apply_opengl_viewport(
pp::renderer::gl::OpenGlViewportRect {
.x = x,
.y = y,
.width = width,
.height = height,
},
pp::renderer::gl::OpenGlViewportDispatch {
.viewport = set_opengl_viewport,
});
if (!status.ok())
LOG("Layer viewport dispatch failed because: %s", status.message);
pp::legacy::ui_gl::apply_viewport(x, y, width, height, "Layer");
}
void apply_layer_capability(std::uint32_t state, bool enabled)
{
const auto status = pp::renderer::gl::apply_opengl_capability(
state,
enabled,
pp::renderer::gl::OpenGlCapabilityDispatch {
.enable = enable_opengl_state,
.disable = disable_opengl_state,
});
if (!status.ok())
LOG("Layer capability dispatch failed because: %s", status.message);
pp::legacy::ui_gl::set_capability(state, enabled, "Layer");
}
void set_layer_active_texture_unit(std::uint32_t unit_index)
{
const auto status = pp::renderer::gl::activate_opengl_texture_unit(
unit_index,
pp::renderer::gl::OpenGlActiveTextureDispatch {
.active_texture = set_opengl_active_texture,
});
if (!status.ok())
LOG("Layer active texture dispatch failed because: %s", status.message);
pp::legacy::ui_gl::activate_texture_unit(unit_index, "Layer");
}
void bind_layer_texture_cube(std::uint32_t texture_id)
{
const auto status = pp::renderer::gl::bind_opengl_texture_cube(
texture_id,
pp::renderer::gl::OpenGlTexture2DBindDispatch {
.bind_texture = bind_opengl_texture,
});
if (!status.ok())
LOG("Layer cube texture bind dispatch failed because: %s", status.message);
pp::legacy::ui_gl::bind_texture_cube(texture_id, "Layer");
}
void copy_layer_framebuffer_to_texture(
@@ -152,40 +82,17 @@ void copy_layer_framebuffer_to_texture(
void clear_layer_color_buffer(const glm::vec4& color)
{
const auto status = pp::renderer::gl::clear_opengl_render_target(
pp::renderer::gl::OpenGlDefaultClear {
.color = { color.r, color.g, color.b, color.a },
.mask = pp::renderer::gl::framebuffer_color_buffer_mask(),
},
pp::renderer::gl::OpenGlClearDispatch {
.clear_color = set_opengl_clear_color,
.clear = clear_opengl_buffer,
});
if (!status.ok())
LOG("Layer clear dispatch failed because: %s", status.message);
pp::legacy::ui_gl::clear_color_buffer({ color.r, color.g, color.b, color.a }, "Layer");
}
std::array<float, 4> query_layer_clear_color()
{
const auto result = pp::renderer::gl::query_opengl_clear_color(
pp::renderer::gl::OpenGlClearColorQueryDispatch {
.get_float = get_opengl_float,
});
if (!result.ok()) {
LOG("Layer clear-color query dispatch failed because: %s", result.status().message);
}
return result.value();
return pp::legacy::ui_gl::query_clear_color("Layer");
}
void restore_layer_clear_color(std::array<float, 4> color)
{
const auto status = pp::renderer::gl::apply_opengl_clear_color(
color,
pp::renderer::gl::OpenGlClearColorDispatch {
.clear_color = set_opengl_clear_color,
});
if (!status.ok())
LOG("Layer clear-color dispatch failed because: %s", status.message);
pp::legacy::ui_gl::set_clear_color(color, "Layer");
}
}

View File

@@ -326,4 +326,15 @@ inline void unbind_texture_2d(const char* context)
LOG("%s texture bind dispatch failed because: %s", context, status.message);
}
inline void bind_texture_cube(std::uint32_t texture_id, const char* context)
{
const auto status = pp::renderer::gl::bind_opengl_texture_cube(
texture_id,
pp::renderer::gl::OpenGlTexture2DBindDispatch {
.bind_texture = bind_opengl_texture,
});
if (!status.ok())
LOG("%s cube texture bind dispatch failed because: %s", context, status.message);
}
} // namespace pp::legacy::ui_gl