Dylan Baker
5488fa80dd
util/glsl2spirv: simplify subprocess handling
...
Since we're not doing anything fancy, we can just use `subprocess.run`.
I've also removed the custom error class, we're not going to catch it,
so just printing and exiting is fine.
v2:
- Print stdout as well as stderr in case of a glslang failure
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
87c83c041a
util/glsl2spirv: close resources as soon as possible
...
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
949c3b55db
util/glsl2spirv: add type annotations
...
Which are all clean
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
c01cd8cad1
util/glsl2spirv: add some error handling for unexpected code paths
...
We expect that convert_to_static_variable and override_version will find
and replace something, so let's fail loudly if they don't.
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
6a5863df82
util/glsl2spriv: make --vn required
...
I'm not 100% sure whether it's right to make --vn required, or to avoid
the static conversion, but this seems correct. Mypy (type checking
coming soon) points out that if --vn is None then the
convert_to_static_variable function will fail. Our one use of this sets
--vn, so there is no change there. Making --vn required
ensures that it will never be None, avoiding the problem.
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
4ffa8a9ac0
util/glsl2spirv: fix appending extra flags
...
The variable is called `extra`, but what's written is `extra - flags`,
and `flags` is undefined, so if the variable was ever passed there would
be an uncaught exception.
fixes: 9786d9ef2a
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
041d9ac3dc
util/glsl2spirv: let argparse actually enforce the restrictions we've set
...
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
f9df046436
util/glsl2spirv: drop inconsistent use of io.open
...
In Python 3 (the only python we support) `io.open` is an alias of the
builtin `open` function, so it's not getting us anything, and we're not
using it consistently.
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Dylan Baker
76e3b482be
util/glsl2spirv: fix type error in argument handling
...
args.Olib is set to `store_true`, which means it will always be `True`
or `False`, this means that the we always, unconditionally, add
`--keep-uncalled` to the command line.
fixes: 9786d9ef2a
Reviewed-by: Luis Felipe Strano Moraes <luis.strano@gmail.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19449 >
2022-11-10 21:14:17 +00:00
Mauro Rossi
db946364df
util: glsl2spirv.py: ensure '#endif' is printed in new line
...
Fixes the following building errors:
In file included from ../src/intel/vulkan/anv_pipeline_cache.c:34:
src/intel/vulkan/float64_spv.h:3316:3: error: expected identifier or '('
};#endif // FLOAT64_SPV_H
^
src/intel/vulkan/float64_spv.h:1:2: error: unterminated conditional directive
^
../src/intel/vulkan/anv_pipeline_cache.c:59:17: error: use of undeclared identifier 'anv_shader_bin_serialize'; did you mean 'anv_shader_bin_deserialize'?
.serialize = anv_shader_bin_serialize,
^~~~~~~~~~~~~~~~~~~~~~~~
anv_shader_bin_deserialize
../src/intel/vulkan/anv_pipeline_cache.c:41:1: note: 'anv_shader_bin_deserialize' declared here
anv_shader_bin_deserialize(struct vk_device *device,
^
../src/intel/vulkan/anv_pipeline_cache.c:59:17: error: incompatible pointer types initializing 'bool (*)(struct vk_pipeline_cache_object *, struct blob *)' with an expression of type 'struct vk_pipeline_cache_object *(struct vk_device *, const void *, size_t, struct blob_reader *)' (aka 'struct vk_pipeline_cache_object *(struct vk_device *, const void *, unsigned long, struct blob_reader *)') [-Werror,-Wincompatible-pointer-types]
.serialize = anv_shader_bin_serialize,
^~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.
Fixes: 9786d9e
("util: Add glsl2spirv.py script")
Reviewed-by: Mykhailo Skorokhodov <mykhailo.skorokhodov@globallogic.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19394 >
2022-10-30 14:14:21 +01:00
Mykhailo Skorokhodov
9786d9ef2a
util: Add glsl2spirv.py script
...
Signed-off-by: Mykhailo Skorokhodov <mykhailo.skorokhodov@globallogic.com >
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com >
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18854 >
2022-10-28 10:08:50 +00:00