libretro / RetroArch

Cross-platform, sophisticated frontend for the libretro API. Licensed GPLv3.
http://www.libretro.com
GNU General Public License v3.0
10.28k stars 1.83k forks source link

Can't combinate different SLANG shaders with same name of parameter. #10985

Open ofry opened 4 years ago

ofry commented 4 years ago

First and foremost consider this:

Description

Can't combinate different SLANG shaders with same name of parameter.

Expected behavior

Shader preset should create. And Retroarch should know which parameter goes to which shader.

Actual behavior

Failed to save such shader preset.

Steps to reproduce the bug

Described in https://github.com/libretro/slang-shaders/issues/142

Bisect Results

[Try to bisect and tell us when this started happening]

Version/Commit

You can find this information under Information/System Information

Environment information

ofry commented 4 years ago

Maybe it's related feature request: https://github.com/libretro/RetroArch/issues/9115

so each parameters can be applied to one shader instead of all.

hizzlekizzle commented 4 years ago

This is expected behavior and not easily fixed, or in fact desirable, since it's very useful to be able to set a single parameter value that propagates throughout the shader passes.

It's good practice (but rarely actually done) for shaders to name their parameter variables something unique, like image adjustment's "ia_contrast" instead of just "contrast", since that's very likely to conflict with other shaders. OTOH, multipass shaders are not typically designed around the idea of their individual passes being mix-and-match building blocks, though many people use them that way.

HyperspaceMadness commented 4 years ago

I agree with @hizzlekizzle it's often important to reuse the same parameter within multiple passes, to the proper solution to this in my opinion is to use prefixes like "ia_contrast" instead of just "contrast".

Initially I had the same thought as you @ofry but after using the system for a little bit and understanding how the parameter binding works, it seems best that it works the way it currently does especially because of reuse between passes and because the parameter list is global to the entire preset.

This also avoids the same name appearing in the parameter list for two different things which would make it unclear which is which.