mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 15:38:09 +02:00
nir_to_tgsi: fix NIR options instead of asserting
Drivers can return any NIR options, but nir_to_tgsi doesn't support
any options because it was written to assume certain options are set.
This fixes a regression caused when st/mesa switched to NIR for passing
shaders to the draw module.
Fixes: 44b7e1497f - st/mesa: don't generate TGSI for the draw VS because it now supports NIR too
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3949
Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3965
Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Eric Anholt <eric@anholt.net>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8046>
This commit is contained in:
parent
e4cdbeab81
commit
311064419d
1 changed files with 30 additions and 10 deletions
|
|
@ -31,6 +31,7 @@
|
|||
#include "tgsi/tgsi_info.h"
|
||||
#include "tgsi/tgsi_ureg.h"
|
||||
#include "util/debug.h"
|
||||
#include "util/u_memory.h"
|
||||
|
||||
struct ntt_compile {
|
||||
nir_shader *s;
|
||||
|
|
@ -2509,17 +2510,30 @@ nir_to_tgsi_lower_64bit_to_vec2(nir_shader *s)
|
|||
}
|
||||
|
||||
static void
|
||||
ntt_sanity_check_driver_options(struct nir_shader *s)
|
||||
ntt_fix_nir_options(struct nir_shader *s)
|
||||
{
|
||||
UNUSED const struct nir_shader_compiler_options *options = s->options;
|
||||
const struct nir_shader_compiler_options *options = s->options;
|
||||
|
||||
assert(options->lower_extract_byte);
|
||||
assert(options->lower_extract_word);
|
||||
assert(options->lower_fdph);
|
||||
assert(options->lower_flrp64);
|
||||
assert(options->lower_fmod);
|
||||
assert(options->lower_rotate);
|
||||
assert(options->lower_vector_cmp);
|
||||
if (!options->lower_extract_byte ||
|
||||
!options->lower_extract_word ||
|
||||
!options->lower_fdph ||
|
||||
!options->lower_flrp64 ||
|
||||
!options->lower_fmod ||
|
||||
!options->lower_rotate ||
|
||||
!options->lower_vector_cmp) {
|
||||
struct nir_shader_compiler_options *new_options =
|
||||
mem_dup(s->options, sizeof(*s->options));
|
||||
|
||||
new_options->lower_extract_byte = true;
|
||||
new_options->lower_extract_word = true;
|
||||
new_options->lower_fdph = true;
|
||||
new_options->lower_flrp64 = true;
|
||||
new_options->lower_fmod = true;
|
||||
new_options->lower_rotate = true;
|
||||
new_options->lower_vector_cmp = true;
|
||||
|
||||
s->options = new_options;
|
||||
}
|
||||
}
|
||||
|
||||
const void *
|
||||
|
|
@ -2533,8 +2547,9 @@ nir_to_tgsi(struct nir_shader *s,
|
|||
bool native_integers = screen->get_shader_param(screen,
|
||||
pipe_shader_type_from_mesa(s->info.stage),
|
||||
PIPE_SHADER_CAP_INTEGERS);
|
||||
const struct nir_shader_compiler_options *original_options = s->options;
|
||||
|
||||
ntt_sanity_check_driver_options(s);
|
||||
ntt_fix_nir_options(s);
|
||||
|
||||
NIR_PASS_V(s, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
|
||||
type_size, (nir_lower_io_options)0);
|
||||
|
|
@ -2647,6 +2662,11 @@ nir_to_tgsi(struct nir_shader *s,
|
|||
|
||||
ralloc_free(c);
|
||||
|
||||
if (s->options != original_options) {
|
||||
free((void*)s->options);
|
||||
s->options = original_options;
|
||||
}
|
||||
|
||||
return tgsi_tokens;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue