Repository navigation
Remove sampler_state blocks from the shader code again - #1061
Open
Coastrnaut wants to merge 1 commit into
Open
Coastrnaut wants to merge 1 commit into
Coastrnaut wants to merge 1 commit into
Conversation
Since 83292ed (projectM-visualizer#958), PreprocessPresetShader() removed sampler_state blocks only from the comment-stripped copy used for searching, not from the actual program. The blocks stayed in the shader, which then failed to parse with "expected ';' near 'AddressU'", and the shader_body position found in the shortened copy no longer matched the program, so the entry point was inserted in the wrong place. The block is now removed from the program and the stripped copy is recreated, keeping positions in sync. A range is only removed if it actually contains the sampler_state, so malformed declarations can't remove unrelated code. PreprocessPresetShader() is now a static member taking the shader type, so it can be unit tested without an OpenGL context. The new tests call the actual implementation; the existing SamplerStateRemoval tests use a copy of the logic, which is why they didn't catch this. Of 19,210 warp/comp shaders in the official preset packs, 55 shaders (all in cream-of-the-crop) parse again with this change. The generated GLSL of all other shaders is unchanged.
Coastrnaut
added a commit
to Coastrnaut/projectm
that referenced
this pull request
Nov 12, 2026
Moves the declaration away from the lines around PreprocessPresetShader() that projectM-visualizer#1061 changes, so the two branches merge without a conflict.
This branch has not been deployed
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.
Problem
Since 83292ed (#958),
MilkdropShader::PreprocessPresetShader()removessampler_stateblocks only from the comment-stripped copy used for searching, not from the actual program. This has two effects:expected ';' near 'AddressU'.shader_bodyposition found in the shortened copy no longer matches the program, so the entry point is inserted in the wrong place.No release contains this regression yet.
Change
sampler_state, so a malformed declaration can't remove unrelated code.PreprocessPresetShader()is now a public static member that takes the shader type, so it can be unit tested without an OpenGL context. The existingSamplerStateRemovaltests inMilkdropShaderCommentParsingTest.cpptest a copy of the logic, which is why they didn't catch this.Tests
MilkdropShaderPreprocessTest.cppwith 4 tests that call the real implementation. Two of them fail on master. libprojectM suite: 168/168.sampler_state)sampler_state)The GLSL wasn't compiled on a GPU and rendering wasn't checked.
Retested on current master (2026-11-12)