Share retained GL runtime dispatch adapters
This commit is contained in:
@@ -698,7 +698,11 @@ powershell -ExecutionPolicy Bypass -File scripts\automation\apple-remote-build.p
|
||||
with app startup, app clear, app UI viewport/scissor, and command-convert
|
||||
renderer state callbacks, so those files no longer duplicate local raw GL
|
||||
adapter clusters for capability, blend, clear, viewport, scissor, active
|
||||
texture, or 2D texture-unbind execution.
|
||||
texture, or 2D texture-unbind execution. Retained HMD viewport setup, text
|
||||
atlas texture-unit activation, Windows/legacy default framebuffer binding,
|
||||
platform render-hint enable callbacks, the global OpenGL error drain, and
|
||||
Windows debug message callback installation also now reuse the shared retained
|
||||
dispatch headers instead of file-local raw entrypoint adapters.
|
||||
Canvas mode overlay, mask, and transform paths also consume backend-owned
|
||||
blend/depth state execution, active texture unit dispatch, transform/cut
|
||||
viewport execution, 2D texture copy targets, and RGBA8 readback format tokens;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Modernization Debt Log
|
||||
|
||||
Status: live
|
||||
Last updated: 2026-06-05
|
||||
Last updated: 2026-06-06
|
||||
|
||||
Every shortcut, temporary adapter, retained vendored dependency, skipped
|
||||
platform gate, compatibility shim, or incomplete automation path must be
|
||||
@@ -417,6 +417,13 @@ agent or engineer to remove them without reconstructing context from chat.
|
||||
`src/main.cpp`, and `src/app_shaders.cpp` no longer carry duplicated raw
|
||||
runtime-query callback clusters. Renderer services still need to own runtime
|
||||
and capability probing before this bridge can be removed.
|
||||
- 2026-06-06: DEBT-0036/DEBT-0017 were narrowed again. Retained HMD viewport
|
||||
setup, text atlas texture-unit activation, Windows/legacy default framebuffer
|
||||
binding, platform render-hint enable callbacks, the global OpenGL error drain,
|
||||
and Windows debug message callback installation now reuse
|
||||
`legacy_ui_gl_dispatch`/`legacy_gl_runtime_dispatch` instead of file-local raw
|
||||
OpenGL entrypoint adapters. Renderer/context services still need to own these
|
||||
paths before the retained dispatch bridges can be removed.
|
||||
- 2026-06-05: DEBT-0061 was opened. `pp_platform_api` now owns a tested desktop
|
||||
XR runtime-selection policy that prefers OpenXR and labels OpenVR as a
|
||||
legacy fallback; `WindowsPlatformServices` consumes that policy before
|
||||
|
||||
@@ -979,7 +979,10 @@ result while the backend owns the query set and order. The Windows entrypoint
|
||||
also uses that contract for early context logging and renderer-name window
|
||||
title construction before replacing the temporary WGL context. Retained runtime
|
||||
info and extension query callback endpoints now share
|
||||
`legacy_gl_runtime_dispatch`.
|
||||
`legacy_gl_runtime_dispatch`. The global OpenGL error drain and Windows debug
|
||||
message callback installation now also route through that retained runtime
|
||||
dispatch, keeping those entrypoints beside the other runtime callbacks until
|
||||
renderer/runtime services own context diagnostics.
|
||||
The default app clear color and color-buffer clear operation now dispatch
|
||||
through `pp_renderer_gl` as well, moving another direct OpenGL operation out
|
||||
of `App::clear` while preserving the current gray clear behavior; the live
|
||||
@@ -2782,9 +2785,17 @@ Results:
|
||||
- Retained app startup logging, Windows early context logging/window-title
|
||||
detection, and shader capability detection now share
|
||||
`legacy_gl_runtime_dispatch` for runtime string and extension enumeration
|
||||
callbacks, removing duplicated raw runtime-query clusters from `src/app.cpp`,
|
||||
`src/main.cpp`, and `src/app_shaders.cpp` while runtime/capability probing
|
||||
remains retained under DEBT-0036.
|
||||
callbacks, plus the global OpenGL error drain and Windows debug message
|
||||
callback installation now use the same retained runtime dispatch. This removes
|
||||
duplicated raw runtime-query clusters from `src/app.cpp`, `src/main.cpp`, and
|
||||
`src/app_shaders.cpp` and the last active one-off runtime entrypoints from
|
||||
`src/util.cpp` and `src/platform_windows/windows_platform_services.cpp` while
|
||||
runtime/capability probing remains retained under DEBT-0036.
|
||||
- Retained desktop HMD viewport setup, text atlas texture-unit activation,
|
||||
Windows/legacy platform default framebuffer binding, and platform render-hint
|
||||
enable callbacks now reuse `legacy_ui_gl_dispatch` instead of local raw GL
|
||||
adapters while renderer/context ownership remains retained under DEBT-0036
|
||||
and DEBT-0017.
|
||||
- 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
|
||||
|
||||
14
src/font.cpp
14
src/font.cpp
@@ -2,6 +2,7 @@
|
||||
#include "log.h"
|
||||
#include "font.h"
|
||||
#include "legacy_gl_mesh_dispatch.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "shader.h"
|
||||
#include "asset.h"
|
||||
#include "util.h"
|
||||
@@ -24,20 +25,9 @@ namespace {
|
||||
return static_cast<GLint>(pp::renderer::gl::texture_format_for_channel_count(1U).pixel_format);
|
||||
}
|
||||
|
||||
void activate_texture_adapter(std::uint32_t texture_unit) noexcept
|
||||
{
|
||||
glActiveTexture(static_cast<GLenum>(texture_unit));
|
||||
}
|
||||
|
||||
void activate_text_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 = activate_texture_adapter,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("Text active texture dispatch failed because: %s", status.message);
|
||||
pp::legacy::ui_gl::activate_texture_unit(unit_index, "Text");
|
||||
}
|
||||
|
||||
[[nodiscard]] std::span<const pp::renderer::gl::OpenGlVertexAttribute> text_mesh_vertex_attributes() noexcept
|
||||
|
||||
20
src/hmd.cpp
20
src/hmd.cpp
@@ -1,30 +1,14 @@
|
||||
#include "pch.h"
|
||||
#include "hmd.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "log.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
#include <array>
|
||||
|
||||
namespace {
|
||||
|
||||
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 apply_hmd_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("HMD viewport dispatch failed because: %s", status.message);
|
||||
pp::legacy::ui_gl::apply_viewport(x, y, width, height, "HMD");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -24,6 +24,21 @@ inline const char* query_opengl_indexed_string(std::uint32_t name, std::uint32_t
|
||||
glGetStringi(static_cast<GLenum>(name), static_cast<GLuint>(index)));
|
||||
}
|
||||
|
||||
inline std::uint32_t query_opengl_error() noexcept
|
||||
{
|
||||
return static_cast<std::uint32_t>(glGetError());
|
||||
}
|
||||
|
||||
inline bool has_opengl_debug_message_callback() noexcept
|
||||
{
|
||||
return glDebugMessageCallback != nullptr;
|
||||
}
|
||||
|
||||
inline void install_opengl_debug_message_callback(GLDEBUGPROC callback, const void* user_param) noexcept
|
||||
{
|
||||
glDebugMessageCallback(callback, user_param);
|
||||
}
|
||||
|
||||
inline pp::renderer::gl::OpenGlRuntimeInfoDispatch runtime_info_dispatch() noexcept
|
||||
{
|
||||
return pp::renderer::gl::OpenGlRuntimeInfoDispatch {
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
|
||||
#include "app.h"
|
||||
#include "app_core/document_platform_io.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "log.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
#include "platform_api/platform_policy.h"
|
||||
@@ -59,11 +60,6 @@ void invoke_picked_path_if_selected(
|
||||
callback(path);
|
||||
}
|
||||
|
||||
void enable_gl_capability(std::uint32_t state) noexcept
|
||||
{
|
||||
glEnable(static_cast<GLenum>(state));
|
||||
}
|
||||
|
||||
// DEBT-0017: fallback for platforms that do not inject PlatformServices yet.
|
||||
class LegacyPlatformServices final : public pp::platform::PlatformServices {
|
||||
public:
|
||||
@@ -249,8 +245,8 @@ public:
|
||||
|
||||
void bind_default_render_target() override
|
||||
{
|
||||
glBindFramebuffer(
|
||||
static_cast<GLenum>(pp::renderer::gl::framebuffer_target()),
|
||||
pp::legacy::ui_gl::bind_opengl_framebuffer(
|
||||
pp::renderer::gl::framebuffer_target(),
|
||||
pp::renderer::gl::default_framebuffer_id());
|
||||
}
|
||||
|
||||
@@ -268,7 +264,7 @@ public:
|
||||
#if defined(__OSX__)
|
||||
const auto status = pp::renderer::gl::apply_opengl_render_platform_hints(
|
||||
pp::renderer::gl::OpenGlRenderPlatformHintDispatch {
|
||||
.enable = enable_gl_capability,
|
||||
.enable = pp::legacy::ui_gl::enable_opengl_state,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL legacy render platform hints failed: %s", status.message);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "platform_windows/windows_platform_services.h"
|
||||
|
||||
#include "log.h"
|
||||
#include "legacy_gl_runtime_dispatch.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
#include "platform_api/network_tls_policy.h"
|
||||
#include "platform_api/platform_policy.h"
|
||||
#include "renderer_gl/opengl_capabilities.h"
|
||||
@@ -84,11 +86,6 @@ void handle_gl_callback(
|
||||
}
|
||||
}
|
||||
|
||||
void enable_gl_capability(std::uint32_t state) noexcept
|
||||
{
|
||||
glEnable(static_cast<GLenum>(state));
|
||||
}
|
||||
|
||||
void show_cursor(bool visible)
|
||||
{
|
||||
std::lock_guard<std::mutex> lock(main_task_mutex);
|
||||
@@ -313,9 +310,7 @@ public:
|
||||
void acquire_render_context() override
|
||||
{
|
||||
async_lock();
|
||||
glBindFramebuffer(
|
||||
static_cast<GLenum>(pp::renderer::gl::framebuffer_target()),
|
||||
static_cast<GLuint>(pp::renderer::gl::default_framebuffer_id()));
|
||||
bind_default_render_target();
|
||||
}
|
||||
|
||||
void release_render_context() override
|
||||
@@ -330,8 +325,8 @@ public:
|
||||
|
||||
void bind_default_render_target() override
|
||||
{
|
||||
glBindFramebuffer(
|
||||
static_cast<GLenum>(pp::renderer::gl::framebuffer_target()),
|
||||
pp::legacy::ui_gl::bind_opengl_framebuffer(
|
||||
pp::renderer::gl::framebuffer_target(),
|
||||
pp::renderer::gl::default_framebuffer_id());
|
||||
}
|
||||
|
||||
@@ -344,7 +339,7 @@ public:
|
||||
{
|
||||
const auto status = pp::renderer::gl::apply_opengl_render_platform_hints(
|
||||
pp::renderer::gl::OpenGlRenderPlatformHintDispatch {
|
||||
.enable = enable_gl_capability,
|
||||
.enable = pp::legacy::ui_gl::enable_opengl_state,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL render platform hints failed: %s", status.message);
|
||||
@@ -352,15 +347,15 @@ public:
|
||||
|
||||
void install_render_debug_callback() override
|
||||
{
|
||||
if (!glDebugMessageCallback)
|
||||
if (!pp::legacy::gl_runtime::has_opengl_debug_message_callback())
|
||||
return;
|
||||
|
||||
// colors: http://stackoverflow.com/questions/4053837/colorizing-text-in-the-console-with-c
|
||||
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE), &render_debug_console_info);
|
||||
glDebugMessageCallback(handle_gl_callback, nullptr);
|
||||
pp::legacy::gl_runtime::install_opengl_debug_message_callback(handle_gl_callback, nullptr);
|
||||
const auto status = pp::renderer::gl::apply_opengl_debug_output_states(
|
||||
pp::renderer::gl::OpenGlDebugOutputStateDispatch {
|
||||
.enable = enable_gl_capability,
|
||||
.enable = pp::legacy::ui_gl::enable_opengl_state,
|
||||
});
|
||||
if (!status.ok())
|
||||
LOG("OpenGL debug output states failed: %s", status.message);
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <poly2tri.h>
|
||||
#include "app.h"
|
||||
#include "legacy_gl_framebuffer_dispatch.h"
|
||||
#include "legacy_gl_runtime_dispatch.h"
|
||||
#include "legacy_gl_sampler_dispatch.h"
|
||||
#include "legacy_gl_shader_dispatch.h"
|
||||
#include "legacy_ui_gl_dispatch.h"
|
||||
@@ -631,7 +632,7 @@ std::string str_replace(const std::string& string, const std::string& search, co
|
||||
return ret;
|
||||
}
|
||||
|
||||
static const char* gl2str(GLenum err)
|
||||
static const char* gl2str(std::uint32_t err)
|
||||
{
|
||||
return pp::renderer::gl::opengl_error_name(err);
|
||||
}
|
||||
@@ -652,8 +653,8 @@ double now_seconds()
|
||||
|
||||
void check_OpenGLError(const char* stmt, const char* fname, int line)
|
||||
{
|
||||
GLenum err;
|
||||
while ((err = glGetError()) != pp::renderer::gl::no_error_code())
|
||||
std::uint32_t err = 0U;
|
||||
while ((err = pp::legacy::gl_runtime::query_opengl_error()) != pp::renderer::gl::no_error_code())
|
||||
{
|
||||
LOG("OpenGL error %08x (%s), at %s:%i - for %s", err, gl2str(err), fname, line, stmt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user