Repository navigation
Shader translator: accept HLSL C-style casts like (float)k (#560, #825) - #829
Merged
Merged
Conversation
MilkDrop's compiler accepts `(float)k * 0.2`, `(float2)x` and `(int)(a+b)`; GLSL has only the constructor form, so the stage failed with "not compiled". Found while building a CaYaDev preset. The cast binds to the term right after it (name, number or parenthesised group, then calls, .members and [index]), as in HLSL; (int) maps to trunc() like int(). A parenthesised type preceded by an identifier is left alone. The corpus has no such casts, so no corpus shader changes. Co-authored-by: caganturgut <271973834+caganturgut@users.noreply.github.com>
|
CaYaDraft — pull request Summary Files
Note Stopping here. I will not merge, push, or change this pull request until you ask.
|
This was referenced Oct 22, 2026
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.
MilkDrop's compiler accepts HLSL C-style casts (
(float)k * 0.2,(float2)x,(int)(a + b)). Our GLSL translator did not, so the stage was dropped as "not compiled". Found while building a CaYaDev preset (#825).Change
src/shared/milkdrop-shader.js:cCast()turns a cast into a GLSL constructor. It binds to the term right after the cast, as in HLSL: a name, number or parenthesised group, then calls,.membersand[index].(int)goes through the existingint(→trunc(path. A parenthesised type preceded by an identifier (sizeof(float)) is left alone.tests/milkdrop-compile-gaps.test.js: two tests (scalar cast in a loop; vector, group and member-chain casts; function parameters untouched).Verified
for (int k…) a += (float)k * 0.2;) now compiles in WebGL in the preview harness. Before the change it showed "comp: derlenmedi".(type)with optional spaces finds none), so no existing preset's shader changes.npm test: 3511/3511. The test count is updated in README, README.tr and ROADMAP.Refs #560, #825