Skip to content

feat: enable custom material and postprocess shaders on GLES backend - #47

Open
emawind84 wants to merge 6 commits into
questzdoom-r15-maintfrom
questzdoom-r15-gles-shaders-impl
Open

feat: enable custom material and postprocess shaders on GLES backend#47
emawind84 wants to merge 6 commits into
questzdoom-r15-maintfrom
questzdoom-r15-gles-shaders-impl

Conversation

@emawind84

Copy link
Copy Markdown
Owner

Wires up the GLES backend (backend 2) to support user/mod-supplied
hardware material shaders and postprocess shaders (gl_customshader,
gl_custompost), previously only working on the GL backend (backend 0).

Postprocess ping-pong buffers (gles_renderbuffers.*): scene now renders
directly into pipeline texture 0 (matching GL's non-multisampled,
non-G-buffer path), which doubles as the first postprocess texture -
no separate scene texture or blit needed. Added the second ping-pong
texture/FBO pair, GLPPRenderState (PPRenderState implementation
mirroring GLPPRenderState in gl_renderbuffers.cpp), and the
BindSceneColorTexture/BlitSceneToTexture/BindNextFB/NextTexture
plumbing hw_postprocess.cpp needs to drive Pass1/Pass2.

FGLRenderer::PostProcessScene (gles_postprocess.cpp) now actually
calls hw_postprocess.Pass1/Pass2 instead of no-op'ing; added
BlurScene/ClearTonemapPalette (gles_framebuffer.*, gles_renderer.h)
so menu blur and palette flash, previously silently hitting
DFrameBuffer's empty stub, actually run.

Enabled usershaders compilation in gles_shader.cpp (was #if 0'd out,
with gl_customshader hardcoded false in gles_system.cpp); added
mUserShaderPath to FShader so a mod-supplied custom shader's literal
path isn't rewritten into the shaders_gles/ tree the way built-in
shader paths are.

Fixed two GLDataBuffer bugs (gles_buffers.*) that left postprocess
shader uniforms reading zeroed/garbage data even after the above was
wired up: the constructor was passing buffer target 0 (now
GL_UNIFORM_BUFFER/GL_SHADER_STORAGE_BUFFER per is_ssbo), and BindBase()
was an empty stub. Root cause went one level deeper than the target
fix alone: GLBuffer's constructor only ever calls glGenBuffers() for
GL_ARRAY_BUFFER/GL_ELEMENT_ARRAY_BUFFER, so GLDataBuffer never actually
had a backing GL buffer object regardless of target - added a separate
hasGLBuffer flag (independent of isData, which still governs the CPU
shadow copy that viewpoint/lights/bones read via a raw pointer and
must keep working unmodified) so Bind()/SetData()/SetSubData() do the
real glBufferData/glBufferSubData upload for uniform/storage buffers
too. This is what let VanRes.fp (Vanilla Essence mod) actually read
its uniforms instead of texelFetch-ing a near-constant coordinate and
covering the 3D view in a single color.

@emawind84
emawind84 force-pushed the questzdoom-r15-gles-shaders-impl branch from b29d5b1 to 7802789 Compare August 6, 2026 05:18
…oid crashes on some devices

Also set shader version to '300 es' by default when running on GLES device, it can be overridden by +gles_force_glsl_v100 1 command line parameter, which will force shader version to '100' and disable all shaders for backend 2.
- Ensures GLES uses the current pipeline framebuffer when appropriate instead of always binding `mSceneFB`
@emawind84
emawind84 force-pushed the questzdoom-r15-gles-shaders-impl branch from e2f8f05 to c00cf82 Compare August 11, 2026 05:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant