From c514ac99aa3f0e8e2cc07d12885010930666476f Mon Sep 17 00:00:00 2001 From: omigamedev Date: Thu, 4 Jun 2026 23:54:15 +0200 Subject: [PATCH] Route VR texture state through GL dispatch --- docs/modernization/build-inventory.md | 4 ++-- docs/modernization/debt.md | 4 +++- docs/modernization/roadmap.md | 9 +++++---- src/app_vr.cpp | 22 ++++++++++++++++++++-- 4 files changed, 30 insertions(+), 9 deletions(-) diff --git a/docs/modernization/build-inventory.md b/docs/modernization/build-inventory.md index e904fd4..8be9146 100644 --- a/docs/modernization/build-inventory.md +++ b/docs/modernization/build-inventory.md @@ -437,8 +437,8 @@ Known local toolchain state: counts so automation can assert backend interpretation without an OpenGL context. Desktop VR drawing also consumes backend-owned scissor/depth/blend state, - blend/depth state query-restore, depth clear masks, active texture units, - and fallback 2D texture unbind targets; VR SDK start/stop now dispatches + blend/depth state query-restore, depth clear masks, active texture unit + dispatch, and fallback 2D texture unbind dispatch; VR SDK start/stop now dispatches through `PlatformServices` while retaining the existing Windows OpenVR bridge shape. Canvas mode overlay, mask, and transform paths also consume backend-owned diff --git a/docs/modernization/debt.md b/docs/modernization/debt.md index 4eb6c53..338a676 100644 --- a/docs/modernization/debt.md +++ b/docs/modernization/debt.md @@ -23,7 +23,9 @@ agent or engineer to remove them without reconstructing context from chat. tested `pp_renderer_gl` capability-state dispatch; CanvasLayer equirect export now binds cube textures through tested `pp_renderer_gl` dispatch; and `Font` text drawing now activates texture units through tested - `pp_renderer_gl` dispatch. The debt remains open for live stroke + `pp_renderer_gl` dispatch. Desktop VR drawing also now routes active texture + unit switches and fallback 2D texture unbinds through tested `pp_renderer_gl` + dispatch. The debt remains open for live stroke rasterization, dual-brush compositing, pattern feedback math, thumbnail layer compositing, brush-preview compositing, and retained `ShaderManager::ext_*` compatibility fields. diff --git a/docs/modernization/roadmap.md b/docs/modernization/roadmap.md index 11a4816..898f623 100644 --- a/docs/modernization/roadmap.md +++ b/docs/modernization/roadmap.md @@ -798,9 +798,10 @@ VR UI framebuffer viewport and scissor-test setup now also consumes those `pp_renderer_gl` contracts, keeping desktop and VR UI rendering aligned while the retained OpenVR app path is split incrementally. VR draw blend/depth state snapshots, transitions, restore, and depth-buffer -clears now use generic tested `pp_renderer_gl` capability query/apply and clear -dispatch contracts, reducing direct OpenGL execution in the retained VR app -path without changing state restore behavior. +clears, active texture unit switches, and fallback 2D texture unbinds now use +generic tested `pp_renderer_gl` capability query/apply, clear, active-texture, +and texture-bind dispatch contracts, reducing direct OpenGL execution in the +retained VR app path without changing state restore behavior. The retained `gl_state` save/restore utility now snapshots and restores through tested `pp_renderer_gl` saved-state dispatch contracts, covering capability state, viewport, clear color, framebuffer/program bindings, active texture, @@ -2034,7 +2035,7 @@ Results: wrapper and compiled headless foundation/tool/test targets. - Desktop VR drawing now routes generic OpenGL scissor/depth/blend state, blend/depth state snapshots and restores, depth clears, active texture units, - and fallback 2D texture unbinds through the renderer GL backend mapping; + and fallback 2D texture unbinds through tested renderer GL backend dispatch; platform VR SDK bridges remain isolated for later platform-shell extraction. Eye framebuffer viewport execution in the retained HMD path also routes through tested `pp_renderer_gl` viewport dispatch. diff --git a/src/app_vr.cpp b/src/app_vr.cpp index 3f0d4ea..d526a66 100644 --- a/src/app_vr.cpp +++ b/src/app_vr.cpp @@ -11,12 +11,30 @@ namespace { void set_active_texture_unit(std::uint32_t unit_index) { - glActiveTexture(pp::renderer::gl::active_texture_unit(unit_index)); + const auto status = pp::renderer::gl::activate_opengl_texture_unit( + unit_index, + pp::renderer::gl::OpenGlActiveTextureDispatch { + .active_texture = [](std::uint32_t texture_unit) noexcept + { + glActiveTexture(static_cast(texture_unit)); + }, + }); + if (!status.ok()) + LOG("OpenGL VR active texture dispatch failed: %s", status.message); } void unbind_texture_2d() { - glBindTexture(pp::renderer::gl::texture_2d_target(), 0); + const auto status = pp::renderer::gl::bind_opengl_texture_2d( + 0U, + pp::renderer::gl::OpenGlTexture2DBindDispatch { + .bind_texture = [](std::uint32_t target, std::uint32_t texture) noexcept + { + glBindTexture(static_cast(target), static_cast(texture)); + }, + }); + if (!status.ok()) + LOG("OpenGL VR texture unbind dispatch failed: %s", status.message); } void enable_opengl_state(std::uint32_t state) noexcept