18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-28 22:03:20 +01:00
Commit Graph

3 Commits

Author SHA1 Message Date
jerrrrycho
57a0a71f48 fix(ci): build and run the shader validator again (#437)
* fix(ci): build and run the shader validator again

- gl/glsl_common.h and gl/shader.cpp include utilities/Globals.h and
  utilities/Logs.h now, so the stand-in headers of the validator move to
  ci_shadervalidator/utilities/.
- gl/ubo.h needs std::span and gl/shader.cpp uses contains(), so the
  script builds with -std=c++20. The stand-in stdafx.h gives <array>,
  <algorithm> and <string_view>, which the precompiled header of the
  simulator gives otherwise.
- build.sh runs from any directory and stops on the first error.
- glslang defines the GL_ARB_gpu_shader5 macro without the #extension
  directive, so light_common.glsl took its textureGather() path without
  the extension enabled and 25 material shaders failed on desktop GL with
  the shadows on. The validator adds the directive which the simulator
  gives on the drivers with the extension.
- The shader goes to the temporary directory of the system instead of a
  fixed /tmp, a shader which can't be preprocessed fails instead of
  ending the run, the shaders go in name order and the failed ones are
  listed at the end.

* fix(ci): write the validated shader to a unique temporary file

The shader validator wrote every preprocessed shader to a file with a
fixed name in the temporary directory (/tmp/shader on Linux) and opened
it with std::ofstream. In a shared /tmp anyone can create that name in
advance, as a file or a link to another file, and the validator would
then write through it (Sonar rule S5443, publicly writable directories).

The shader now goes to a file with a unique name which is created
exclusively: mkstemp() on Linux, and on Windows, which has no mkstemp(),
a random name opened with fopen_s(..., "wx"), which fails when the file
exists. The file is removed after glslangValidator has checked it, and
when it cannot be written completely. glslangValidator gets the stage
with -S, so the file still needs no extension.

* docs(ci): the standalone validator no longer checks the PCF fallback path

The comment of has_gl_extension() said the validator compiles the 16-tap
PCF fallback of light_common.glsl. Since the validator adds the
GL_ARB_gpu_shader5 directive itself, it checks the textureGather() path.
2026-11-25 05:12:15 +01:00
jerrrrycho
04b55c866a fix(render): alpha to coverage only where it is on, full coverage on flat alpha
Review of the alpha to coverage change for alpha tested surfaces:

- An alpha which is flat over the pixel (fwidth 0) and equal to the opacity
  threshold got a coverage of 0.5, so e.g. opacity 1 on an opaque or DXT1
  texture turned half see-through with multisampling. Without an alpha edge
  in the pixel the plain test decides now: step(opacity, alpha).
- The shaders took the coverage path whenever they were built with
  multisampling, also where alpha to coverage is off (the reflections pass)
  or does nothing (the single-sampled model previews), and grew the cut-outs
  there by about half a pixel. model_ubo gets an alpha_to_coverage flag, set
  together with the GL state, and the shaders keep the plain alpha test
  without it. The previews no longer turn alpha to coverage on. The flag
  takes 4 of the 12 padding bytes after shadow_tone, so the std140 layout and
  the size of the block stay the same.
- The shader validator never set iMultisampling, so it never compiled the
  alpha to coverage branches. Its "features on" configuration uses the
  default of 2 now, on desktop GL and GLES.
2026-11-08 20:03:32 +01:00
milek7
56eba08a6f CI shader validation 2021-01-21 15:51:03 +01:00