Skip to content

feat: enable OrigTexture in glsl shaders, fix shader UI desync#679

Open
DrFlarp wants to merge 11 commits intoLoveRetro:mainfrom
DrFlarp:shaders_origtexture
Open

feat: enable OrigTexture in glsl shaders, fix shader UI desync#679
DrFlarp wants to merge 11 commits intoLoveRetro:mainfrom
DrFlarp:shaders_origtexture

Conversation

@DrFlarp
Copy link

@DrFlarp DrFlarp commented Mar 15, 2026

Implement OrigTexture so all shaders in the chain can access the unaltered core output image.

Also addresses #678 with a proposed fix: split Shader into two objects, let's call them ShaderProgram and ShaderPass

ShaderProgram: contains only values directly pertaining to an individual .glsl compilation unit

  • shader program handle
  • uniform locations
  • pragma uniform locations

(This allows us to reuse all of this information when we run overlay.glsl up to 3 times in our pipeline, each time with different configs)

ShaderPass: contains everything else previously held in Shader

  • alpha has been added as a property to this struct (removed from runShaderPass call)

Other related changes/fixes:

  • a bunch of shader init code has been moved from PLAT_updateShader to a new function init_shader_program that sets up a ShaderProgram object. This new function is now also called by PLAT_initShaders to set up the .system shaders.
  • g_shader_default et. al have been removed and replaced by ShaderPrograms, they still serve the same purpose but are now bundled with their uniform locations
  • RunShaderPass call has been changed, I'm not fully satisfied with what I've come up and would like one more iteration on this. (in particular, the way srcw/h, texw/h is also a part of ShaderPass but not used by the function) (edit: better now!)
  • RunShaderPass: filter is now called next_filter for clarity
  • Checking for null shader prorgram has been moved from PLAT_GL_Swap to RunShaderPass
  • bugfix: OrigInputSize now always properly provides the size of the core's framebuffer (instead of srcw/h which might have been scaled if srctype is relative)
  • OrigTextureSize also added (matches OrigInputSize for now)
  • load_shader_from_file now takes a full filepath (the caller has already concatenated it for us)

The only behavioral changes should be the availability of OrigTexture/OrigTextureSize and the fix for OrigInputSize which only affects a very specific setup of lcd1x (the included presets real-gameboy and real-gba still work the same). As far as my testing goes, all other shaders should work exactly as before.

DrFlarp added 2 commits March 14, 2026 18:38
currently shaders residing in .system are sent to runShaderPass with incomplete initialization - in particular, all uniformLocations are passed in as 0's.

As it stands, the only uniform in these shaders is the sampler2D (texture unit), so it's mostly a lot of wrong-type error no-op's, but it does prevent the proposed OrigTexture feature from working properly.
@DrFlarp
Copy link
Author

DrFlarp commented Mar 15, 2026

huh, build-linux is failing on building settings.elf. nextui and minarch seem to build fine however

Edit: github ci runners seem to be janking us out

@DrFlarp DrFlarp marked this pull request as ready for review March 17, 2026 09:41
@DrFlarp DrFlarp marked this pull request as draft March 17, 2026 21:46
@DrFlarp DrFlarp marked this pull request as ready for review March 17, 2026 22:10
@DrFlarp DrFlarp marked this pull request as draft March 17, 2026 22:31
@DrFlarp DrFlarp changed the title feat: enable OrigTexture in glsl shaders feat: enable OrigTexture in glsl shaders, fix shader UI desync Mar 18, 2026
@DrFlarp DrFlarp marked this pull request as ready for review March 18, 2026 15:39
@DrFlarp
Copy link
Author

DrFlarp commented Mar 18, 2026

Ok, it took a few tries but I think it's ready to go :)

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