With v3.12.0 shfmt changed the behavior of the `--simplify` option to
ignore any EditorConfig when it's provided. Therefore, this option is
now moved to the EditorConfig as suggested by the shfmt author. See
https://github.com/mvdan/sh/issues/1173 for details.
Currently we don't mix storage images and storage buffers in the same
shader. Also we don't sample textures when we use storage buffers.
In the future we need to avoid shifting descriptor sets.
Instead of looking up the location of spirv-reflect for every shader,
this is now being done once and cached for all shaders. This results in
shader compilation being slightly faster.
Instead of compiling SPIR-V shaders twice, once with debug info and once
without, this uses `spirv-opt` to remove the debug info from the SPIR-V
shaders with debug info. This results in notable performance gains, as
stripping the debug info from existing shaders is much faster than
compiling them.
As a result of this change the contents of the non-debug shaders change
once. That's because shaders with debug info contain much more
instructions and therefore more result ids. Stripping the debug
info from shaders results in different result ids being used as when
generating ones without debug info. While that doesn't result in a
difference in the functionality of the shaders, it's a difference in
their binary representation, causing their content hashs and therefore
file names to change. After that one-time change the result ids are
reproducible again.
Instead of redefining the VkDescriptorType enum for every shader, only
define it once. This avoids unnecessary computation and slightly
increases performance.
b2cdb1e6b4 broke compiling of SPIR-V shaders on Windows, as the output
of `spirv-reflect` contains CRLF as line separators there. This commit
fixes that.
This drops the program name from the SPIR-V shader file name, which
allows deduplicating shaders belonging to different programs. While that
has no significant impact on compilation performance it reduces the
number of required SPIR-V shaders.
One downside this has it that it's not directly visible from the file
name of a shader anymore to which program it belongs.
For each program this parallelizes the generation of shaders by program
combinations. This leads to significantly faster shader generation on
systems with multiple CPU-cores. The resulting shaders are identical to
the ones prior to this change.
This ensures the file names of SPIR-V program combinations and shaders
are reproducible. Up to now they only were if the order of program
combinations in the rules.json didn't change, as the file names
contained the position of the program combination in the rules.json.
With this change files names of program combinations will be named based
on the details of the combination used to create them and the file names
of shaders will be based on their content respectively.
Changing the file names avoids wrong shaders when partially rebuilding
them after a new combination for a program got added in between the
other combinations in rules.json and removes the need for keeping track
of identical shaders in the script. It's also a preparation for being
able to build shaders in parallel, while also keeping the result
reproducible.
The script build-archive.sh sets a variable SPIRV_REFLECT, even respects
it if it's set in env but without support from the compile.py script for
it there isn't much point.
This commit adds support SPIRV_REFLECT in compile.py and and adds a
fallback to use vendored spirv-reflect for when the envvar is unset and
the tool can't be found in PATH
Signed-off-by: Ralph Sennhauser <ralph.sennhauser@gmail.com>
This commit enables a bunch of unrelated ruff rules, which only require
minimal changes to the code base to enable them.
The rules enabled by this commit are:
- check the use of datetime objects without timezone (DTZ005)
- check the performance of try-except in loops (PERF203)
- check the number of function arguments (PLR0913)
- check for mutable class defaults (RUF012)
- check for the use of secure hashing algorithms (S324)
- check for raising base exceptions (TRY002)
- check for raising other exceptions where TypeErrors should be raised
(TRY004)
Previously when checking if two SPIR-V shaders are identical the
hashs of their file content would be compared and afterwards their
(unhashed) file contents as well. Comparing the file contents isn't
necessary, as the hash function used is a cryptographic one, which
guarantees the hash can be used as a representative of the hashed data.
While the desired options for indent size and style are Python's
defaults, let's make it explicit by specifying it in the EditorConfig.
As part of this, this also removes unnecessary inline formatting options
for Python files.
This explicitly uses UTF-8 encoding when reading or writing files with
Python. This is necessary as the default locale varies between
operating systems.
This enables some ruff rules to check for ambiguous and dead Python
code, which might cause unintended side-effects.
The enabled rules are:
- a bunch of rules related to shadowing of builtin structures (A)
- a bunch of rules checking for unused arguments (ARG)
- a rule checking for useless expressions (B018)
- a rule checking for unbound loop variables (B023)
- a rule checking redefined function parameters (PLR1704)
In the ruff config file added in #6954 explicitly selecting the ruff
rules to check was missed, resulting in ruff only checking a very small
subset of its available rules. That hasn't been desired, so this is the
first of a series of commits enabling more rules. In this PR all rules
whose violations can be either automatically fixed by ruff or are
trivial to fix manually get enabled. For the follow up PRs it's intended
to focus on one area of rules per PR to gradually improve the Python
code quality.