ppir has some code that operates on all ppir_src variables, and for that
uses ppir_node_get_src.
lod bias support introduced a separate ppir_src that is inaccessible by
that function, causing it to be missed by the compiler in some routines.
Ultimately this caused, in some cases, a bug in const lowering:
.../pp/lower.c:42: ppir_lower_const: Assertion `src != NULL' failed.
This fix moves the ppir_srcs in ppir_load_texture_node together so they
don't get missed.
Fixes: 721d82cf06 lima/ppir: add lod-bias support
Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com>
Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3185>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3185>
master
| @@ -130,7 +130,7 @@ static void ppir_codegen_encode_texld(ppir_node *node, void *code) | |||
| f->lod_bias_en = ldtex->lod_bias_en; | |||
| f->explicit_lod = ldtex->explicit_lod; | |||
| if (ldtex->lod_bias_en) | |||
| ppir_target_get_src_reg_index(&ldtex->lod_bias); | |||
| ppir_target_get_src_reg_index(&ldtex->src[1]); | |||
| switch (ldtex->sampler_dim) { | |||
| case GLSL_SAMPLER_DIM_2D: | |||
| @@ -168,7 +168,7 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node) | |||
| return false; | |||
| list_addtail(&load->node.list, &node->list); | |||
| load->src = load_tex->src_coords; | |||
| load->src = load_tex->src[0]; | |||
| load->num_src = 1; | |||
| if (load_tex->sampler_dim == GLSL_SAMPLER_DIM_CUBE) | |||
| load->num_components = 3; | |||
| @@ -187,8 +187,8 @@ static bool ppir_lower_texture(ppir_block *block, ppir_node *node) | |||
| } | |||
| assert(load); | |||
| load_tex->src_coords.type = load->dest.type = ppir_target_pipeline; | |||
| load_tex->src_coords.pipeline = load->dest.pipeline = ppir_pipeline_reg_discard; | |||
| load_tex->src[0].type = load->dest.type = ppir_target_pipeline; | |||
| load_tex->src[0].pipeline = load->dest.pipeline = ppir_pipeline_reg_discard; | |||
| if (ppir_node_has_single_src_succ(node)) { | |||
| ppir_node *succ = ppir_node_first_succ(node); | |||
| @@ -486,19 +486,21 @@ static ppir_node *ppir_emit_tex(ppir_block *block, nir_instr *ni) | |||
| node->sampler_dim = instr->sampler_dim; | |||
| for (int i = 0; i < instr->coord_components; i++) | |||
| node->src_coords.swizzle[i] = i; | |||
| node->src[0].swizzle[i] = i; | |||
| for (int i = 0; i < instr->num_srcs; i++) { | |||
| switch (instr->src[i].src_type) { | |||
| case nir_tex_src_coord: | |||
| ppir_node_add_src(block->comp, &node->node, &node->src_coords, &instr->src[i].src, | |||
| ppir_node_add_src(block->comp, &node->node, &node->src[0], &instr->src[i].src, | |||
| u_bit_consecutive(0, instr->coord_components)); | |||
| node->num_src++; | |||
| break; | |||
| case nir_tex_src_bias: | |||
| case nir_tex_src_lod: | |||
| node->lod_bias_en = true; | |||
| node->explicit_lod = (instr->src[i].src_type == nir_tex_src_lod); | |||
| ppir_node_add_src(block->comp, &node->node, &node->lod_bias, &instr->src[i].src, 1); | |||
| ppir_node_add_src(block->comp, &node->node, &node->src[1], &instr->src[i].src, 1); | |||
| node->num_src++; | |||
| break; | |||
| default: | |||
| ppir_error("unsupported texture source type\n"); | |||
| @@ -456,7 +456,8 @@ void ppir_node_replace_child(ppir_node *parent, ppir_node *old_child, ppir_node | |||
| case ppir_node_type_load_texture: | |||
| { | |||
| ppir_load_texture_node *load_texture = ppir_node_to_load_texture(parent); | |||
| _ppir_node_replace_child(&load_texture->src_coords, old_child, new_child); | |||
| for (int i = 0; i < load_texture->num_src; i++) | |||
| _ppir_node_replace_child(ppir_node_get_src(parent, i), old_child, new_child); | |||
| break; | |||
| } | |||
| case ppir_node_type_store: | |||
| @@ -270,12 +270,13 @@ typedef struct { | |||
| typedef struct { | |||
| ppir_node node; | |||
| ppir_dest dest; | |||
| ppir_src src_coords; /* not to be used after lowering */ | |||
| ppir_src src[2]; /* src[0] temporarily stores src_coords, | |||
| not to be used after lowering */ | |||
| int num_src; | |||
| int sampler; | |||
| int sampler_dim; | |||
| bool lod_bias_en; | |||
| bool explicit_lod; | |||
| ppir_src lod_bias; | |||
| } ppir_load_texture_node; | |||
| typedef struct { | |||
| @@ -475,6 +476,7 @@ static inline int ppir_node_get_src_num(ppir_node *node) | |||
| case ppir_node_type_load: | |||
| return ppir_node_to_load(node)->num_src; | |||
| case ppir_node_type_load_texture: | |||
| return ppir_node_to_load_texture(node)->num_src; | |||
| case ppir_node_type_store: | |||
| return 1; | |||
| default: | |||
| @@ -495,7 +497,7 @@ static inline ppir_src *ppir_node_get_src(ppir_node *node, int idx) | |||
| case ppir_node_type_branch: | |||
| return &ppir_node_to_branch(node)->src[idx]; | |||
| case ppir_node_type_load_texture: | |||
| return &ppir_node_to_load_texture(node)->src_coords; | |||
| return &ppir_node_to_load_texture(node)->src[idx]; | |||
| case ppir_node_type_load: | |||
| return &ppir_node_to_load(node)->src; | |||
| case ppir_node_type_store: | |||