From: Erico Nunes Date: Fri, 20 Dec 2019 18:20:58 +0000 (+0100) Subject: lima/ppir: fix lod bias src X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=d56710ab82a0803b5a66c6c489a356de28779ffa;p=mesa.git lima/ppir: fix lod bias src 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: 721d82cf061 lima/ppir: add lod-bias support Signed-off-by: Erico Nunes Reviewed-by: Vasily Khoruzhick Tested-by: Marge Bot Part-of: --- diff --git a/src/gallium/drivers/lima/ir/pp/codegen.c b/src/gallium/drivers/lima/ir/pp/codegen.c index 76db5628ffc..919bb334147 100644 --- a/src/gallium/drivers/lima/ir/pp/codegen.c +++ b/src/gallium/drivers/lima/ir/pp/codegen.c @@ -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: diff --git a/src/gallium/drivers/lima/ir/pp/lower.c b/src/gallium/drivers/lima/ir/pp/lower.c index 397adf82eab..c141e5374b5 100644 --- a/src/gallium/drivers/lima/ir/pp/lower.c +++ b/src/gallium/drivers/lima/ir/pp/lower.c @@ -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); diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index 235a462eaa6..2d0d97eadec 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -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"); diff --git a/src/gallium/drivers/lima/ir/pp/node.c b/src/gallium/drivers/lima/ir/pp/node.c index d06748904a5..a5748a22200 100644 --- a/src/gallium/drivers/lima/ir/pp/node.c +++ b/src/gallium/drivers/lima/ir/pp/node.c @@ -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: diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h index 5895a696db8..6b550a3c9d1 100644 --- a/src/gallium/drivers/lima/ir/pp/ppir.h +++ b/src/gallium/drivers/lima/ir/pp/ppir.h @@ -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: