Skip to content

fix: water shader under LÖVE 12 — make effect()'s parameter precision a define - #82

Open
luisgonzaleznf wants to merge 1 commit into
DramaticShape:devfrom
luisgonzaleznf:fix/water-shader-effect-precision-love12
Open

fix: water shader under LÖVE 12 — make effect()'s parameter precision a define#82
luisgonzaleznf wants to merge 1 commit into
DramaticShape:devfrom
luisgonzaleznf:fix/water-shader-effect-precision-love12

Conversation

@luisgonzaleznf

Copy link
Copy Markdown

Fixes #76.

effect()'s float parameters are pinned to mediump to match LÖVE 11's forward declaration — the signature's own comment explains why, and the Xclipse case it names is real. LÖVE 12 forward-declares effect() under a different precision, so on 12 the pin is the mismatch, from the other side:

ERROR: 0:546: 'mediump' : overloaded functions must have the same parameter precision qualifiers for argument 1
ERROR: 0:546: 'mediump' : overloaded functions must have the same parameter precision qualifiers for argument 3
ERROR: 0:546: 'mediump' : overloaded functions must have the same parameter precision qualifiers for argument 4

Arguments 1, 3 and 4 are exactly the three qualified floats; argument 2 is Image tex and carries no qualifier, which is why it is not flagged. The trailing missing #endif in the log is a cascade — the directives balance, and the compiler reports compilation terminated before reaching the closing one.

The shader then falls back to flat water, silently apart from the warning. On iOS that is the current state, since the iOS shell runs LÖVE 12.

Rather than swap one hardcoded precision for another and break the case the original comment was defending, the qualifier becomes a define the Lua side fills in, and Water.shader compiles the pinned form first and the bare form only if that is refused. Whichever prototype a runtime brought, one of the two agrees with it — Xclipse still gets its pinned mediump on the first attempt, LÖVE 12 falls through to the bare one. The warning now fires only when both shapes are refused, which is a driver that was never going to draw this water anyway.

No version or platform checks.

Verified on LÖVE 12.0 nightly + Metal on macOS, the configuration that was failing:

shader plain: true
shader grid: true
reflective pass began: true
reflective water drew: true

with shoreline and dock reflections visible in-game and no shader warning. Both variants compile, so the wireframe path is covered too. LÖVE 11.5 / OpenGL is unchanged — it takes the pinned form on the first attempt, exactly as before, and the second pcall never runs.

Independent of #75 (shadow map under LÖVE 12); they touch different files and can land in either order.

… define

The float params were pinned to mediump to match LOVE 11's forward
declaration of effect(), because a definition whose precisions differ
from the prototype's reads as a second function to some compilers.  LOVE
12 declares it under a different precision, so the pin became the
mismatch there and the shader stopped compiling -- lakes drew flat on
any LOVE 12 + Metal build, iOS included.

The qualifier is a define now, and Water.shader compiles the pinned form
first and the bare one only if that is refused, so whichever prototype a
runtime brought, one of the two agrees with it.  The warning fires only
when both are refused.
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.

Water shader fails to compile under LÖVE 12 + Metal (mediump parameter qualifiers on effect) — lakes draw flat on iOS

1 participant