picasso icon indicating copy to clipboard operation
picasso copied to clipboard

Disallow DVLE-Specific Directives When Using .nodvle

Open Wyatt-James opened this issue 1 year ago • 3 comments

Bug Report

What's the issue you encountered?

Certain directives perform no function, or worse, enable undefined behavior when used with the .nodvle directive. A compilation error should be raised in these circumstances.

Affected directives include:

  • all .const directives
  • all .set directives
  • .entry

How can the issue be reproduced?

Compile a group of shader files, with at least one file containing the .nodvle directive and one or more of the aforementioned directives. This program will compile normally.

Environment?

  • What host OS are you using?
    • Win10 x64 with Ubuntu LTS 18.04 under WSL2
  • Official release or unofficial/self-compiled build:
    • Official Release

Additional context?

According to the README, constants are never shared between DVLEs. Despite this, they can be declared inside of shader source files containing the .nodvle directive. These constants will not have a defined value, as constants are only ever initialized when a DVLE is selected, thus causing undefined behavior that can be very difficult to trace if a developer is unfamiliar with their function.

The same applies to the .set directives, which are also only ever executed in files with DVLEs.

The .entry directive, while harmless, has no function within a .nodvle file.

Wyatt-James avatar Jul 26 '24 03:07 Wyatt-James

This is a good point. However, I think it would be more intuitive to add a way to actually instantiate these constants in all dvles that make use of procedures contained in the non-dvle pica source code file.

fincs avatar Jul 26 '24 18:07 fincs

It would be convenient for sure, but performance on shader swaps would be slightly worse than using shared uniforms.

Actually, that's true for any constant, is it not? At least under C3D, since I believe it re-sends all constants on a shader load.

Wyatt-James avatar Jul 27 '24 03:07 Wyatt-James

There usually aren't that many constants per DVLE. Rewriting shader code memory (when using shaders from different shbins) is much more expensive. I'd say it's not really a concern.

fincs avatar Jul 27 '24 09:07 fincs