Commit 31106441 authored by Marek Olšák's avatar Marek Olšák Committed by Marge Bot

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: 44b7e149 - st/mesa: don't generate TGSI for the draw VS because it now supports NIR too
Closes: mesa/mesa#3949
Closes: mesa/mesa#3965Reviewed-by: Zoltán Böszörményi's avatarZoltán Böszörményi <zboszor@gmail.com>
Reviewed-by: Eric Anholt's avatarEric Anholt <eric@anholt.net>
Part-of: <mesa/mesa!8046>
parent e4cdbeab
......@@ -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;
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);
const struct nir_shader_compiler_options *options = s->options;
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;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment