nir: Report progress from nir_lower_system_values().
Signed-off-by: Kenneth Graunke <kenneth@whitecape.org> Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
This commit is contained in:
@@ -1835,7 +1835,7 @@ void nir_lower_phis_to_scalar(nir_shader *shader);
|
|||||||
void nir_lower_samplers(nir_shader *shader,
|
void nir_lower_samplers(nir_shader *shader,
|
||||||
const struct gl_shader_program *shader_program);
|
const struct gl_shader_program *shader_program);
|
||||||
|
|
||||||
void nir_lower_system_values(nir_shader *shader);
|
bool nir_lower_system_values(nir_shader *shader);
|
||||||
|
|
||||||
typedef struct nir_lower_tex_options {
|
typedef struct nir_lower_tex_options {
|
||||||
/**
|
/**
|
||||||
|
@@ -28,15 +28,15 @@
|
|||||||
#include "nir.h"
|
#include "nir.h"
|
||||||
#include "main/mtypes.h"
|
#include "main/mtypes.h"
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
convert_instr(nir_intrinsic_instr *instr)
|
convert_instr(nir_intrinsic_instr *instr)
|
||||||
{
|
{
|
||||||
if (instr->intrinsic != nir_intrinsic_load_var)
|
if (instr->intrinsic != nir_intrinsic_load_var)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
nir_variable *var = instr->variables[0]->var;
|
nir_variable *var = instr->variables[0]->var;
|
||||||
if (var->data.mode != nir_var_system_value)
|
if (var->data.mode != nir_var_system_value)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
void *mem_ctx = ralloc_parent(instr);
|
void *mem_ctx = ralloc_parent(instr);
|
||||||
|
|
||||||
@@ -54,36 +54,45 @@ convert_instr(nir_intrinsic_instr *instr)
|
|||||||
|
|
||||||
nir_instr_insert_before(&instr->instr, &new_instr->instr);
|
nir_instr_insert_before(&instr->instr, &new_instr->instr);
|
||||||
nir_instr_remove(&instr->instr);
|
nir_instr_remove(&instr->instr);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool
|
static bool
|
||||||
convert_block(nir_block *block, void *state)
|
convert_block(nir_block *block, void *state)
|
||||||
{
|
{
|
||||||
(void) state;
|
bool *progress = state;
|
||||||
|
|
||||||
nir_foreach_instr_safe(block, instr) {
|
nir_foreach_instr_safe(block, instr) {
|
||||||
if (instr->type == nir_instr_type_intrinsic)
|
if (instr->type == nir_instr_type_intrinsic)
|
||||||
convert_instr(nir_instr_as_intrinsic(instr));
|
*progress = convert_instr(nir_instr_as_intrinsic(instr)) || *progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static bool
|
||||||
convert_impl(nir_function_impl *impl)
|
convert_impl(nir_function_impl *impl)
|
||||||
{
|
{
|
||||||
nir_foreach_block(impl, convert_block, NULL);
|
bool progress;
|
||||||
|
|
||||||
|
nir_foreach_block(impl, convert_block, &progress);
|
||||||
nir_metadata_preserve(impl, nir_metadata_block_index |
|
nir_metadata_preserve(impl, nir_metadata_block_index |
|
||||||
nir_metadata_dominance);
|
nir_metadata_dominance);
|
||||||
|
return progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
bool
|
||||||
nir_lower_system_values(nir_shader *shader)
|
nir_lower_system_values(nir_shader *shader)
|
||||||
{
|
{
|
||||||
|
bool progress = false;
|
||||||
|
|
||||||
nir_foreach_overload(shader, overload) {
|
nir_foreach_overload(shader, overload) {
|
||||||
if (overload->impl)
|
if (overload->impl)
|
||||||
convert_impl(overload->impl);
|
progress = convert_impl(overload->impl) || progress;
|
||||||
}
|
}
|
||||||
|
|
||||||
exec_list_make_empty(&shader->system_values);
|
exec_list_make_empty(&shader->system_values);
|
||||||
|
|
||||||
|
return progress;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user