From: Andreas Baierl Date: Fri, 31 May 2019 07:54:27 +0000 (+0200) Subject: lima/ppir: Add gl_PointCoord handling X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=4627a0c4ebc777716e7cadfd80e4f9d5b411762b;p=mesa.git lima/ppir: Add gl_PointCoord handling Treat gl_PointCoord as a system value and add the necessary bits for correct codegen. Signed-off-by: Andreas Baierl Reviewed-by: Qiang Yu Reviewed-by: Eric Anholt --- diff --git a/src/gallium/drivers/lima/ir/pp/codegen.c b/src/gallium/drivers/lima/ir/pp/codegen.c index 09cf5e623bd..6a90dc6ede7 100644 --- a/src/gallium/drivers/lima/ir/pp/codegen.c +++ b/src/gallium/drivers/lima/ir/pp/codegen.c @@ -56,7 +56,8 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code) if (num_components) { assert(node->op == ppir_op_load_varying || node->op == ppir_op_load_coords || - node->op == ppir_op_load_fragcoord); + node->op == ppir_op_load_fragcoord || + node->op == ppir_op_load_pointcoord); f->imm.dest = index >> 2; f->imm.mask = dest->write_mask << (index & 0x3); @@ -70,9 +71,16 @@ static void ppir_codegen_encode_varying(ppir_node *node, void *code) else f->imm.index = load->index >> alignment; - if (node->op == ppir_op_load_fragcoord) { - f->imm.source_type = 2; - f->imm.perspective = 3; + switch (node->op) { + case ppir_op_load_fragcoord: + f->imm.source_type = 2; + f->imm.perspective = 3; + break; + case ppir_op_load_pointcoord: + f->imm.source_type = 3; + break; + default: + break; } } else { diff --git a/src/gallium/drivers/lima/ir/pp/nir.c b/src/gallium/drivers/lima/ir/pp/nir.c index 55d96191910..c7858640f01 100644 --- a/src/gallium/drivers/lima/ir/pp/nir.c +++ b/src/gallium/drivers/lima/ir/pp/nir.c @@ -285,6 +285,17 @@ static ppir_node *ppir_emit_intrinsic(ppir_block *block, nir_instr *ni) lnode->num_components = instr->num_components; return &lnode->node; + case nir_intrinsic_load_point_coord: + if (!instr->dest.is_ssa) + mask = u_bit_consecutive(0, instr->num_components); + + lnode = ppir_node_create_dest(block, ppir_op_load_pointcoord, &instr->dest, mask); + if (!lnode) + return NULL; + + lnode->num_components = instr->num_components; + return &lnode->node; + case nir_intrinsic_load_uniform: if (!instr->dest.is_ssa) mask = u_bit_consecutive(0, instr->num_components); diff --git a/src/gallium/drivers/lima/ir/pp/node.c b/src/gallium/drivers/lima/ir/pp/node.c index 5522b875269..280e08e9e2d 100644 --- a/src/gallium/drivers/lima/ir/pp/node.c +++ b/src/gallium/drivers/lima/ir/pp/node.c @@ -254,6 +254,13 @@ const ppir_op_info ppir_op_infos[] = { PPIR_INSTR_SLOT_VARYING, PPIR_INSTR_SLOT_END }, }, + [ppir_op_load_pointcoord] = { + .name = "ld_pointcoord", + .type = ppir_node_type_load, + .slots = (int []) { + PPIR_INSTR_SLOT_VARYING, PPIR_INSTR_SLOT_END + }, + }, [ppir_op_load_uniform] = { .name = "ld_uni", .type = ppir_node_type_load, diff --git a/src/gallium/drivers/lima/ir/pp/node_to_instr.c b/src/gallium/drivers/lima/ir/pp/node_to_instr.c index 22678ae3349..fc1671985e3 100644 --- a/src/gallium/drivers/lima/ir/pp/node_to_instr.c +++ b/src/gallium/drivers/lima/ir/pp/node_to_instr.c @@ -240,7 +240,8 @@ static bool ppir_do_node_to_instr(ppir_block *block, ppir_node *node) load->dest.pipeline = ppir_pipeline_reg_uniform; } else if (node->op == ppir_op_load_varying || - node->op == ppir_op_load_fragcoord) { + node->op == ppir_op_load_fragcoord || + node->op == ppir_op_load_pointcoord) { /* delay the load varying dup to scheduler */ if (!create_new_instr(block, node)) return false; diff --git a/src/gallium/drivers/lima/ir/pp/ppir.h b/src/gallium/drivers/lima/ir/pp/ppir.h index dafbd942532..3395a13ee56 100644 --- a/src/gallium/drivers/lima/ir/pp/ppir.h +++ b/src/gallium/drivers/lima/ir/pp/ppir.h @@ -103,6 +103,7 @@ typedef enum { ppir_op_load_varying, ppir_op_load_coords, ppir_op_load_fragcoord, + ppir_op_load_pointcoord, ppir_op_load_texture, ppir_op_load_temp, diff --git a/src/gallium/drivers/lima/lima_screen.c b/src/gallium/drivers/lima/lima_screen.c index 7cced495696..b3f7fff26c4 100644 --- a/src/gallium/drivers/lima/lima_screen.c +++ b/src/gallium/drivers/lima/lima_screen.c @@ -117,6 +117,7 @@ lima_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) return 1; case PIPE_CAP_TGSI_FS_POSITION_IS_SYSVAL: + case PIPE_CAP_TGSI_FS_POINT_IS_SYSVAL: return 1; case PIPE_CAP_MAX_TEXTURE_2D_SIZE: