Apply startup GL state through renderer GL
This commit is contained in:
@@ -460,8 +460,9 @@ Known local toolchain state:
|
||||
the debt-tracked adapter isolated in
|
||||
`src/platform_legacy/legacy_platform_services.*`.
|
||||
- `pp_renderer_gl` owns the tested `OpenGlInitialState` startup depth/blend
|
||||
policy consumed by `App::init`, plus renderer API to OpenGL token mapping
|
||||
and command-planning contracts used by the OpenGL parity work.
|
||||
policy and dispatch application consumed by `App::init`, plus renderer API
|
||||
to OpenGL token mapping and command-planning contracts used by the OpenGL
|
||||
parity work.
|
||||
- `pano_cli plan-cloud-upload` exposes `pp_app_core` cloud upload availability,
|
||||
new-document warning, publish prompt, and save-before-upload planning as JSON;
|
||||
the live cloud upload command consumes the same start contract before
|
||||
|
||||
@@ -36,10 +36,10 @@ agent or engineer to remove them without reconstructing context from chat.
|
||||
| DEBT-0015 | Open | Modernization | Cursor visibility requests now consume pure `pp_app_core` planning through `pano_cli plan-cursor-visibility`, `App::show_cursor`/`App::hide_cursor` dispatch through `PlatformServices` without platform guards, and Windows live execution uses injected `WindowsPlatformServices`, but macOS cursor execution still reaches the retained fallback adapter | Keep canvas cursor behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-cursor-visibility --visible`; `ctest --preset desktop-fast --build-config Debug` | Cursor visibility execution is owned by injected `pp_platform_*` services for every supported platform |
|
||||
| DEBT-0016 | Open | Modernization | Clipboard get/set requests now consume pure `pp_app_core` planning through `pano_cli plan-clipboard-read` and `pano_cli plan-clipboard-write`, and Windows live execution uses injected `WindowsPlatformServices`, but Apple/Android clipboard execution still reaches retained fallback adapter branches from `App::clipboard_get_text` and `App::clipboard_set_text` | Keep picker/color text clipboard behavior stable while platform shells are extracted incrementally | `pp_app_core_document_platform_io_tests`; `pano_cli plan-clipboard-write --text #ff00aa`; `ctest --preset desktop-fast --build-config Debug` | Clipboard execution is owned by injected `pp_platform_*` services for every supported platform |
|
||||
| DEBT-0017 | Open | Modernization | Startup storage path preparation, `App::clipboard_get_text`, `App::clipboard_set_text`, `App::show_cursor`, `App::hide_cursor`, `App::showKeyboard`, `App::hideKeyboard`, `App::display_file`, `App::share_file`, native app/window close, UI-thread lifecycle hooks, render-context acquire/release/present hooks, render-target binding hooks, render platform hint hooks, render debug callback hooks, render-capture frame hooks, recording cleanup, live asset/layout reload policy, diagnostic stacktrace/crash hooks, per-frame platform hooks, `App::pick_image`, `App::pick_file`, the non-writer `App::pick_file_save`, `App::pick_dir`, and prepared-file save/download handoff now call the SDK-free `pp::platform::PlatformServices` interface, and Windows injects `WindowsPlatformServices` from `src/platform_windows/windows_platform_services.*`; non-Windows live implementations still use `src/platform_legacy/legacy_platform_services.*`, a named fallback adapter that forwards to retained Apple/Android/Linux/Web bridge functions and retained no-op branches | Preserve behavior while moving platform execution behind a testable service boundary before platform shell implementations are injected | `pp_platform_api_tests`; `pp_app_core_document_platform_io_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Replace `src/platform_legacy/legacy_platform_services.*` with injected `pp_platform_*` service implementations owned by each non-Windows platform shell |
|
||||
| DEBT-0018 | Open | Modernization | `pp_renderer_gl` owns a tested `OpenGlInitialState` plan for PanoPainter startup depth/blend policy, but `App::init` still executes the plan through direct OpenGL calls | Preserve behavior while moving renderer policy into the backend boundary before a live `IRenderDevice`/command context owns startup execution | `pp_renderer_gl_capabilities_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Initial render state is applied by a renderer backend service/device rather than direct `App::init` OpenGL calls |
|
||||
|
||||
## Closed Debt
|
||||
|
||||
| ID | Status | Owner | Item | Reason | Validation | Removal Condition |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| DEBT-0006 | Closed | Modernization | `pano_cli create-document` validates and emits JSON command contracts but does not yet invoke the legacy document/app model | The document model had not been extracted from `Canvas`/`App` yet | `ctest --preset desktop-fast --build-config Debug`; `pano_cli_create_document_smoke` | Closed on 2026-05-31: command now constructs a real `pp_document::CanvasDocument` |
|
||||
| DEBT-0018 | Closed | Modernization | `pp_renderer_gl` owned a tested `OpenGlInitialState` plan for PanoPainter startup depth/blend policy, but `App::init` still executed the plan through direct OpenGL calls | Preserve behavior while moving renderer policy into the backend boundary before a live `IRenderDevice`/command context owns startup execution | `pp_renderer_gl_capabilities_tests`; `ctest --preset desktop-fast --build-config Debug`; `powershell -ExecutionPolicy Bypass -File scripts\automation\package-smoke.ps1 -Preset windows-msvc-default -Configuration Debug` | Closed on 2026-06-03: `pp_renderer_gl::apply_panopainter_initial_state` now applies the startup state through a tested backend dispatch contract consumed by `App::init` |
|
||||
|
||||
@@ -514,10 +514,10 @@ Windows OpenGL debug callback setup now dispatches through `PlatformServices`,
|
||||
moving Win32 console coloring, debug-output enablement, and debug-break callback
|
||||
behavior into `WindowsPlatformServices` while keeping other platform adapters
|
||||
as no-ops.
|
||||
Initial PanoPainter OpenGL depth/blend startup state is now represented by a
|
||||
tested `pp_renderer_gl` `OpenGlInitialState` plan before the app applies it,
|
||||
so the policy is owned by the renderer backend boundary instead of being
|
||||
hard-coded inside `App::init`.
|
||||
Initial PanoPainter OpenGL depth/blend startup state is now represented and
|
||||
applied by tested `pp_renderer_gl` startup-state contracts; `App::init`
|
||||
delegates to the backend dispatch path instead of hard-coding the policy or
|
||||
operation order.
|
||||
Windows RenderDoc frame capture hooks now also dispatch through
|
||||
`PlatformServices`, keeping capture integration in the platform service while
|
||||
leaving non-Windows adapters as no-ops.
|
||||
|
||||
41
src/app.cpp
41
src/app.cpp
@@ -50,6 +50,26 @@ namespace {
|
||||
return static_cast<GLenum>(pp::renderer::gl::scissor_test_state());
|
||||
}
|
||||
|
||||
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_blend_func(std::uint32_t source_factor, std::uint32_t destination_factor) noexcept
|
||||
{
|
||||
glBlendFunc(static_cast<GLenum>(source_factor), static_cast<GLenum>(destination_factor));
|
||||
}
|
||||
|
||||
void set_opengl_blend_equation_separate(std::uint32_t color_equation, std::uint32_t alpha_equation) noexcept
|
||||
{
|
||||
glBlendEquationSeparate(static_cast<GLenum>(color_equation), static_cast<GLenum>(alpha_equation));
|
||||
}
|
||||
|
||||
[[nodiscard]] GLint rgba8_internal_format() noexcept
|
||||
{
|
||||
return static_cast<GLint>(pp::renderer::gl::rgba8_internal_format());
|
||||
@@ -389,19 +409,16 @@ void App::init()
|
||||
// }
|
||||
//}
|
||||
|
||||
const auto initial_state = pp::renderer::gl::panopainter_initial_state();
|
||||
if (initial_state.depth_test_enabled)
|
||||
glEnable(static_cast<GLenum>(initial_state.depth_test_state));
|
||||
else
|
||||
glDisable(static_cast<GLenum>(initial_state.depth_test_state));
|
||||
|
||||
App::I->apply_render_platform_hints();
|
||||
glBlendFunc(
|
||||
static_cast<GLenum>(initial_state.source_color_factor),
|
||||
static_cast<GLenum>(initial_state.destination_color_factor));
|
||||
glBlendEquationSeparate(
|
||||
static_cast<GLenum>(initial_state.color_equation),
|
||||
static_cast<GLenum>(initial_state.alpha_equation));
|
||||
const auto startup_state_status = pp::renderer::gl::apply_panopainter_initial_state(
|
||||
pp::renderer::gl::OpenGlStateDispatch {
|
||||
.enable = enable_opengl_state,
|
||||
.disable = disable_opengl_state,
|
||||
.blend_func = set_opengl_blend_func,
|
||||
.blend_equation_separate = set_opengl_blend_equation_separate,
|
||||
});
|
||||
if (!startup_state_status.ok())
|
||||
LOG("OpenGL startup state failed: %s", startup_state_status.message);
|
||||
});
|
||||
|
||||
int run_counter = Settings::value<Serializer::Integer>("run_counter") + 1;
|
||||
|
||||
@@ -224,6 +224,27 @@ OpenGlInitialState panopainter_initial_state() noexcept
|
||||
};
|
||||
}
|
||||
|
||||
pp::foundation::Status apply_panopainter_initial_state(OpenGlStateDispatch dispatch) noexcept
|
||||
{
|
||||
if (dispatch.enable == nullptr
|
||||
|| dispatch.disable == nullptr
|
||||
|| dispatch.blend_func == nullptr
|
||||
|| dispatch.blend_equation_separate == nullptr)
|
||||
{
|
||||
return pp::foundation::Status::invalid_argument("OpenGL state dispatch callbacks must not be null");
|
||||
}
|
||||
|
||||
const auto state = panopainter_initial_state();
|
||||
if (state.depth_test_enabled)
|
||||
dispatch.enable(state.depth_test_state);
|
||||
else
|
||||
dispatch.disable(state.depth_test_state);
|
||||
|
||||
dispatch.blend_func(state.source_color_factor, state.destination_color_factor);
|
||||
dispatch.blend_equation_separate(state.color_equation, state.alpha_equation);
|
||||
return pp::foundation::Status::success();
|
||||
}
|
||||
|
||||
std::uint32_t extension_count_query() noexcept
|
||||
{
|
||||
return gl_num_extensions;
|
||||
|
||||
@@ -124,12 +124,24 @@ struct OpenGlInitialState {
|
||||
std::uint32_t alpha_equation = 0;
|
||||
};
|
||||
|
||||
using OpenGlCapabilityFn = void (*)(std::uint32_t state) noexcept;
|
||||
using OpenGlBlendFuncFn = void (*)(std::uint32_t source_factor, std::uint32_t destination_factor) noexcept;
|
||||
using OpenGlBlendEquationSeparateFn = void (*)(std::uint32_t color_equation, std::uint32_t alpha_equation) noexcept;
|
||||
|
||||
struct OpenGlStateDispatch {
|
||||
OpenGlCapabilityFn enable = nullptr;
|
||||
OpenGlCapabilityFn disable = nullptr;
|
||||
OpenGlBlendFuncFn blend_func = nullptr;
|
||||
OpenGlBlendEquationSeparateFn blend_equation_separate = nullptr;
|
||||
};
|
||||
|
||||
[[nodiscard]] OpenGlCapabilities detect_opengl_capabilities(
|
||||
std::span<const std::string_view> extensions,
|
||||
OpenGlRuntime runtime) noexcept;
|
||||
[[nodiscard]] pp::renderer::RenderDeviceFeatures render_device_features(
|
||||
OpenGlCapabilities capabilities) noexcept;
|
||||
[[nodiscard]] OpenGlInitialState panopainter_initial_state() noexcept;
|
||||
[[nodiscard]] pp::foundation::Status apply_panopainter_initial_state(OpenGlStateDispatch dispatch) noexcept;
|
||||
|
||||
[[nodiscard]] std::uint32_t extension_count_query() noexcept;
|
||||
[[nodiscard]] std::uint32_t extension_string_name() noexcept;
|
||||
|
||||
@@ -7,9 +7,59 @@
|
||||
#include <cstring>
|
||||
#include <limits>
|
||||
#include <string_view>
|
||||
#include <vector>
|
||||
|
||||
namespace {
|
||||
|
||||
struct RecordedOpenGlStateCall {
|
||||
enum class Kind {
|
||||
enable,
|
||||
disable,
|
||||
blend_func,
|
||||
blend_equation_separate,
|
||||
};
|
||||
|
||||
Kind kind = Kind::enable;
|
||||
std::uint32_t first = 0;
|
||||
std::uint32_t second = 0;
|
||||
};
|
||||
|
||||
std::vector<RecordedOpenGlStateCall> recorded_state_calls;
|
||||
|
||||
void record_enable(std::uint32_t state) noexcept
|
||||
{
|
||||
recorded_state_calls.push_back(RecordedOpenGlStateCall {
|
||||
.kind = RecordedOpenGlStateCall::Kind::enable,
|
||||
.first = state,
|
||||
});
|
||||
}
|
||||
|
||||
void record_disable(std::uint32_t state) noexcept
|
||||
{
|
||||
recorded_state_calls.push_back(RecordedOpenGlStateCall {
|
||||
.kind = RecordedOpenGlStateCall::Kind::disable,
|
||||
.first = state,
|
||||
});
|
||||
}
|
||||
|
||||
void record_blend_func(std::uint32_t source_factor, std::uint32_t destination_factor) noexcept
|
||||
{
|
||||
recorded_state_calls.push_back(RecordedOpenGlStateCall {
|
||||
.kind = RecordedOpenGlStateCall::Kind::blend_func,
|
||||
.first = source_factor,
|
||||
.second = destination_factor,
|
||||
});
|
||||
}
|
||||
|
||||
void record_blend_equation_separate(std::uint32_t color_equation, std::uint32_t alpha_equation) noexcept
|
||||
{
|
||||
recorded_state_calls.push_back(RecordedOpenGlStateCall {
|
||||
.kind = RecordedOpenGlStateCall::Kind::blend_equation_separate,
|
||||
.first = color_equation,
|
||||
.second = alpha_equation,
|
||||
});
|
||||
}
|
||||
|
||||
void detects_common_extension_capabilities(pp::tests::Harness& h)
|
||||
{
|
||||
constexpr std::array<std::string_view, 2> extensions {
|
||||
@@ -651,6 +701,43 @@ void maps_app_initialization_parameters(pp::tests::Harness& h)
|
||||
PP_EXPECT(h, pp::renderer::gl::active_texture_unit(4U) == 0x84C4U);
|
||||
}
|
||||
|
||||
void applies_app_initialization_state(pp::tests::Harness& h)
|
||||
{
|
||||
recorded_state_calls.clear();
|
||||
|
||||
const auto status = pp::renderer::gl::apply_panopainter_initial_state(
|
||||
pp::renderer::gl::OpenGlStateDispatch {
|
||||
.enable = record_enable,
|
||||
.disable = record_disable,
|
||||
.blend_func = record_blend_func,
|
||||
.blend_equation_separate = record_blend_equation_separate,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, status.ok());
|
||||
PP_EXPECT(h, recorded_state_calls.size() == 3U);
|
||||
PP_EXPECT(h, recorded_state_calls[0].kind == RecordedOpenGlStateCall::Kind::disable);
|
||||
PP_EXPECT(h, recorded_state_calls[0].first == 0x0B71U);
|
||||
PP_EXPECT(h, recorded_state_calls[1].kind == RecordedOpenGlStateCall::Kind::blend_func);
|
||||
PP_EXPECT(h, recorded_state_calls[1].first == 0x0302U);
|
||||
PP_EXPECT(h, recorded_state_calls[1].second == 0x0303U);
|
||||
PP_EXPECT(h, recorded_state_calls[2].kind == RecordedOpenGlStateCall::Kind::blend_equation_separate);
|
||||
PP_EXPECT(h, recorded_state_calls[2].first == 0x8006U);
|
||||
PP_EXPECT(h, recorded_state_calls[2].second == 0x8008U);
|
||||
}
|
||||
|
||||
void rejects_incomplete_app_initialization_state_dispatch(pp::tests::Harness& h)
|
||||
{
|
||||
const auto status = pp::renderer::gl::apply_panopainter_initial_state(
|
||||
pp::renderer::gl::OpenGlStateDispatch {
|
||||
.enable = record_enable,
|
||||
.disable = record_disable,
|
||||
.blend_func = record_blend_func,
|
||||
});
|
||||
|
||||
PP_EXPECT(h, !status.ok());
|
||||
PP_EXPECT(h, status.code == pp::foundation::StatusCode::invalid_argument);
|
||||
}
|
||||
|
||||
void maps_renderer_viewports_and_scissors(pp::tests::Harness& h)
|
||||
{
|
||||
const auto viewport = pp::renderer::gl::viewport_for_renderer_viewport(
|
||||
@@ -1025,6 +1112,8 @@ int main()
|
||||
harness.run("maps_renderer_sampler_states", maps_renderer_sampler_states);
|
||||
harness.run("exposes_shader_attribute_binding_catalog", exposes_shader_attribute_binding_catalog);
|
||||
harness.run("maps_app_initialization_parameters", maps_app_initialization_parameters);
|
||||
harness.run("applies_app_initialization_state", applies_app_initialization_state);
|
||||
harness.run("rejects_incomplete_app_initialization_state_dispatch", rejects_incomplete_app_initialization_state_dispatch);
|
||||
harness.run("maps_renderer_viewports_and_scissors", maps_renderer_viewports_and_scissors);
|
||||
harness.run("maps_renderer_blend_state_tokens", maps_renderer_blend_state_tokens);
|
||||
harness.run("maps_renderer_color_write_masks", maps_renderer_color_write_masks);
|
||||
|
||||
Reference in New Issue
Block a user