nir: add const qualifiers, move some decls in nir_to_tgsi_info.c

Signed-off-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17062>
This commit is contained in:
Brian Paul
2022-06-02 12:33:01 -06:00
parent 36c22b5dfb
commit 3e50112861
+11 -10
View File
@@ -35,7 +35,7 @@
#include "tgsi/tgsi_scan.h"
#include "tgsi/tgsi_from_mesa.h"
static nir_variable* tex_get_texture_var(nir_tex_instr *instr)
static nir_variable* tex_get_texture_var(const nir_tex_instr *instr)
{
for (unsigned i = 0; i < instr->num_srcs; i++) {
switch (instr->src[i].src_type) {
@@ -49,7 +49,7 @@ static nir_variable* tex_get_texture_var(nir_tex_instr *instr)
return NULL;
}
static nir_variable* intrinsic_get_var(nir_intrinsic_instr *instr)
static nir_variable* intrinsic_get_var(const nir_intrinsic_instr *instr)
{
return nir_deref_instr_get_variable(nir_src_as_deref(instr->src[0]));
}
@@ -136,7 +136,7 @@ static void gather_intrinsic_load_deref_info(const nir_shader *nir,
const nir_intrinsic_instr *instr,
const nir_deref_instr *deref,
bool need_texcoord,
nir_variable *var,
const nir_variable *var,
struct tgsi_shader_info *info)
{
assert(var && var->data.mode == nir_var_shader_in);
@@ -170,10 +170,10 @@ static void gather_intrinsic_load_deref_info(const nir_shader *nir,
static void scan_instruction(const struct nir_shader *nir,
bool need_texcoord,
struct tgsi_shader_info *info,
nir_instr *instr)
const nir_instr *instr)
{
if (instr->type == nir_instr_type_alu) {
nir_alu_instr *alu = nir_instr_as_alu(instr);
const nir_alu_instr *alu = nir_instr_as_alu(instr);
switch (alu->op) {
case nir_op_fddx:
@@ -189,7 +189,7 @@ static void scan_instruction(const struct nir_shader *nir,
}
} else if (instr->type == nir_instr_type_tex) {
nir_tex_instr *tex = nir_instr_as_tex(instr);
nir_variable *texture = tex_get_texture_var(tex);
const nir_variable *texture = tex_get_texture_var(tex);
if (texture && texture->data.bindless)
info->uses_bindless_samplers = true;
@@ -329,8 +329,8 @@ static void scan_instruction(const struct nir_shader *nir,
info->writes_memory = true;
break;
case nir_intrinsic_load_deref: {
nir_variable *var = intrinsic_get_var(intr);
nir_variable_mode mode = var->data.mode;
const nir_variable *var = intrinsic_get_var(intr);
const nir_variable_mode mode = var->data.mode;
nir_deref_instr *const deref = nir_src_as_deref(intr->src[0]);
enum glsl_base_type base_type =
glsl_get_base_type(glsl_without_array(var->type));
@@ -408,7 +408,6 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
struct tgsi_shader_info *info,
bool need_texcoord)
{
nir_function *func;
unsigned i;
info->processor = pipe_shader_type_from_mesa(nir->info.stage);
@@ -805,7 +804,9 @@ void nir_tgsi_scan_shader(const struct nir_shader *nir,
if (info->processor == PIPE_SHADER_FRAGMENT)
info->uses_kill = nir->info.fs.uses_discard;
func = (struct nir_function *)exec_list_get_head_const(&nir->functions);
nir_function *func = (struct nir_function *)
exec_list_get_head_const(&nir->functions);
nir_foreach_block(block, func->impl) {
nir_foreach_instr(instr, block)
scan_instruction(nir, need_texcoord, info, instr);