refactor(renderer): route Shader/Texture/Framebuffer through GfxDevice (RC5)#42
Merged
Conversation
…e (RC5) Collapse the duplicate GPU-resource layer onto a single device boundary plus a single state cache — the keystone of RC5's "GfxDevice as sole GPU entry". The resource classes used to call raw glXxx directly, bypassing GfxDevice and silently desyncing StateTracker's cache. - GfxDevice: add createProgram/deleteProgram/getAttribLocation/setClearStencil/ setUnpackFlipY and Depth24Stencil8 / DepthStencil enums. GLDevice implements them (the multi-step shader compile/link protocol moves out of Shader.cpp into GLDevice, so the WebGL-only constants stay in the one GL file). - StateTracker: cache VAO/VBO/IBO/framebuffer binds (was program/texture/render state only); promote it to a per-App service so every renderer subsystem shares one authoritative cache instead of each binding behind its back. - Shader/Texture/Framebuffer: become thin RAII handles over GfxDevice with zero raw gl and zero GL includes. Texture drops its ES_PLATFORM_WEB-only bodies, so native textures work again instead of being dead. - ResourceManager now holds the GfxDevice& (it is the GPU-resource factory); EstellaContext creates GLDevice before it and injects it. RenderTarget / RenderTargetManager thread the device through to Framebuffer. Tests: MockGfxDevice + three native CTest harnesses (state_tracker, shader_device, texture_fb) that compile the converted classes against the mock — linking proves GL-decoupling, and they run without emsdk. Raw gl* outside GLDevice: 135 -> 41 (Shader/Texture/Framebuffer eliminated). Follow-up (separate, CI-verified PR): convert Buffer/VAO + CustomGeometry, retire Renderer/BatchRenderer2D and rebase ImmediateDraw on TransientBufferPool, then add the CI guard that fails the build on any gl* outside GLDevice.
689cba2 to
7a2b60f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
RC5 step toward "GfxDevice as the sole GPU entry" (see
docs/REARCHITECTURE.md). The renderer had two parallel ways to reach the GPU: throughGfxDevice/StateTracker, and rawglXxxinside the resource classes — the latter bypassed the device and silently desyncedStateTracker's cache (e.g. aShader::bind()could leave the tracker thinking a different program was bound, so a later cache hit would skip the real bind → wrong shader, silently).This collapses that onto one device boundary + one state cache.
Changes
createProgram/deleteProgram/getAttribLocation/setClearStencil/setUnpackFlipYandDepth24Stencil8/DepthStencilenums.GLDeviceimplements them — the multi-step shader compile/link protocol moves out ofShader.cppintoGLDevice, so the WebGL-only constants live in the one GL file.GfxDevicewith zero raw gl and zero GL includes.Texturedrops itsES_PLATFORM_WEB-only bodies, so native textures work again instead of being dead.GfxDevice&(it is the GPU-resource factory);EstellaContextcreatesGLDevicebefore it.RenderTarget/RenderTargetManagerthread the device through toFramebuffer.Verification
No emsdk locally, so the production web build is validated in CI. Locally, the converted resource classes are compiled against a new
tests/renderer/MockGfxDevice.hpp— linking proves they no longer touch GL — plus three native CTest harnesses (state_tracker,shader_device,texture_fb, all green) that need no GL/emsdk and run in CI.Raw
gl*outsideGLDevice: 135 → 41 (Shader/Texture/Framebuffer eliminated).Follow-up (separate PR)
Convert
Buffer/VertexArray+CustomGeometry; retireRenderer/BatchRenderer2Dand rebaseImmediateDrawonTransientBufferPool; then a CI guard that fails the build on anygl*outsideGLDevice.