Module: Mesa Branch: master Commit: af135bb8afeb1d67bd8e0fe2662da8fd0e2124e8 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=af135bb8afeb1d67bd8e0fe2662da8fd0e2124e8
Author: Eric Anholt <[email protected]> Date: Tue Dec 22 13:02:20 2020 -0800 gallium/tgsi_exec: Simplify GS output vertex count tracking. We had this strange 5-dword-per-stream storage for the single dword current vertex count, due to copy and paste. We can make much cleaner code by just having a 4-element array in the machine. Reviewed-by: Adam Jackson <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8283> --- src/gallium/auxiliary/draw/draw_gs.c | 26 ++----------------- src/gallium/auxiliary/tgsi/tgsi_exec.c | 46 +++++++++------------------------- src/gallium/auxiliary/tgsi/tgsi_exec.h | 21 ++++++---------- 3 files changed, 21 insertions(+), 72 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_gs.c b/src/gallium/auxiliary/draw/draw_gs.c index 3e087b9c923..940e3b1d4b6 100644 --- a/src/gallium/auxiliary/draw/draw_gs.c +++ b/src/gallium/auxiliary/draw/draw_gs.c @@ -218,30 +218,8 @@ static void tgsi_gs_run(struct draw_geometry_shader *shader, /* run interpreter */ tgsi_exec_machine_run(machine, 0); - for (i = 0; i < 4; i++) { - int prim_i; - int prim_c; - switch (i) { - case 0: - prim_i = TGSI_EXEC_TEMP_PRIMITIVE_I; - prim_c = TGSI_EXEC_TEMP_PRIMITIVE_C; - break; - case 1: - prim_i = TGSI_EXEC_TEMP_PRIMITIVE_S1_I; - prim_c = TGSI_EXEC_TEMP_PRIMITIVE_S1_C; - break; - case 2: - prim_i = TGSI_EXEC_TEMP_PRIMITIVE_S2_I; - prim_c = TGSI_EXEC_TEMP_PRIMITIVE_S2_C; - break; - case 3: - prim_i = TGSI_EXEC_TEMP_PRIMITIVE_S3_I; - prim_c = TGSI_EXEC_TEMP_PRIMITIVE_S3_C; - break; - }; - - out_prims[i] = machine->Temps[prim_i].xyzw[prim_c].u[0]; - } + for (i = 0; i < 4; i++) + out_prims[i] = machine->OutputPrimCount[i]; } #ifdef LLVM_AVAILABLE diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 9237aa303de..1db19914451 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -976,26 +976,6 @@ enum tgsi_exec_datatype { */ #define TEMP_KILMASK_I TGSI_EXEC_TEMP_KILMASK_I #define TEMP_KILMASK_C TGSI_EXEC_TEMP_KILMASK_C -#define TEMP_OUTPUT_I TGSI_EXEC_TEMP_OUTPUT_I -#define TEMP_OUTPUT_C TGSI_EXEC_TEMP_OUTPUT_C -#define TEMP_PRIMITIVE_I TGSI_EXEC_TEMP_PRIMITIVE_I -#define TEMP_PRIMITIVE_C TGSI_EXEC_TEMP_PRIMITIVE_C -#define TEMP_PRIMITIVE_S1_I TGSI_EXEC_TEMP_PRIMITIVE_S1_I -#define TEMP_PRIMITIVE_S1_C TGSI_EXEC_TEMP_PRIMITIVE_S1_C -#define TEMP_PRIMITIVE_S2_I TGSI_EXEC_TEMP_PRIMITIVE_S2_I -#define TEMP_PRIMITIVE_S2_C TGSI_EXEC_TEMP_PRIMITIVE_S2_C -#define TEMP_PRIMITIVE_S3_I TGSI_EXEC_TEMP_PRIMITIVE_S3_I -#define TEMP_PRIMITIVE_S3_C TGSI_EXEC_TEMP_PRIMITIVE_S3_C - -static const struct { - int idx; - int chan; -} temp_prim_idxs[] = { - { TEMP_PRIMITIVE_I, TEMP_PRIMITIVE_C }, - { TEMP_PRIMITIVE_S1_I, TEMP_PRIMITIVE_S1_C }, - { TEMP_PRIMITIVE_S2_I, TEMP_PRIMITIVE_S2_C }, - { TEMP_PRIMITIVE_S3_I, TEMP_PRIMITIVE_S3_C }, -}; /** The execution mask depends on the conditional mask and the loop mask */ #define UPDATE_EXEC_MASK(MACH) \ @@ -1889,8 +1869,7 @@ store_dest_dstret(struct tgsi_exec_machine *mach, break; case TGSI_FILE_OUTPUT: - index = mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] - + reg->Register.Index; + index = mach->OutputVertexOffset + reg->Register.Index; dst = &mach->Outputs[offset + index].xyzw[chan_index]; #if 0 debug_printf("NumOutputs = %d, TEMP_O_C/I = %d, redindex = %d\n", @@ -2049,7 +2028,7 @@ emit_vertex(struct tgsi_exec_machine *mach, { union tgsi_exec_channel r[1]; unsigned stream_id; - unsigned *prim_count; + unsigned prim_count; /* FIXME: check for exec mask correctly unsigned i; for (i = 0; i < TGSI_QUAD_SIZE; ++i) { @@ -2057,15 +2036,15 @@ emit_vertex(struct tgsi_exec_machine *mach, */ IFETCH(&r[0], 0, TGSI_CHAN_X); stream_id = r[0].u[0]; - prim_count = &mach->Temps[temp_prim_idxs[stream_id].idx].xyzw[temp_prim_idxs[stream_id].chan].u[0]; + prim_count = mach->OutputPrimCount[stream_id]; if (mach->ExecMask) { - if (mach->Primitives[stream_id][*prim_count] >= mach->MaxOutputVertices) + if (mach->Primitives[stream_id][prim_count] >= mach->MaxOutputVertices) return; - if (mach->Primitives[stream_id][*prim_count] == 0) - mach->PrimitiveOffsets[stream_id][*prim_count] = mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0]; - mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] += mach->NumOutputs; - mach->Primitives[stream_id][*prim_count]++; + if (mach->Primitives[stream_id][prim_count] == 0) + mach->PrimitiveOffsets[stream_id][prim_count] = mach->OutputVertexOffset; + mach->OutputVertexOffset += mach->NumOutputs; + mach->Primitives[stream_id][prim_count]++; } } @@ -2085,7 +2064,7 @@ emit_primitive(struct tgsi_exec_machine *mach, IFETCH(&r[0], 0, TGSI_CHAN_X); stream_id = r[0].u[0]; } - prim_count = &mach->Temps[temp_prim_idxs[stream_id].idx].xyzw[temp_prim_idxs[stream_id].chan].u[0]; + prim_count = &mach->OutputPrimCount[stream_id]; if (mach->ExecMask) { ++(*prim_count); debug_assert((*prim_count * mach->NumOutputs) < mach->MaxGeometryShaderOutputs); @@ -2097,8 +2076,7 @@ static void conditional_emit_primitive(struct tgsi_exec_machine *mach) { if (PIPE_SHADER_GEOMETRY == mach->ShaderType) { - int emitted_verts = - mach->Primitives[0][mach->Temps[temp_prim_idxs[0].idx].xyzw[temp_prim_idxs[0].chan].u[0]]; + int emitted_verts = mach->Primitives[0][mach->OutputPrimCount[0]]; if (emitted_verts) { emit_primitive(mach, NULL); } @@ -6254,11 +6232,11 @@ tgsi_exec_machine_setup_masks(struct tgsi_exec_machine *mach) uint default_mask = 0xf; mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0; - mach->Temps[TEMP_OUTPUT_I].xyzw[TEMP_OUTPUT_C].u[0] = 0; + mach->OutputVertexOffset = 0; if (mach->ShaderType == PIPE_SHADER_GEOMETRY) { for (unsigned i = 0; i < TGSI_MAX_VERTEX_STREAMS; i++) { - mach->Temps[temp_prim_idxs[i].idx].xyzw[temp_prim_idxs[i].chan].u[0] = 0; + mach->OutputPrimCount[i] = 0; mach->Primitives[i][0] = 0; } /* GS runs on a single primitive for now */ diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.h b/src/gallium/auxiliary/tgsi/tgsi_exec.h index 798538e1b7f..16f44c3736f 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.h +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.h @@ -220,12 +220,6 @@ struct tgsi_sampler #define TGSI_EXEC_TEMP_KILMASK_I (TGSI_EXEC_NUM_TEMPS + 0) #define TGSI_EXEC_TEMP_KILMASK_C 0 -#define TGSI_EXEC_TEMP_OUTPUT_I (TGSI_EXEC_NUM_TEMPS + 0) -#define TGSI_EXEC_TEMP_OUTPUT_C 1 - -#define TGSI_EXEC_TEMP_PRIMITIVE_I (TGSI_EXEC_NUM_TEMPS + 0) -#define TGSI_EXEC_TEMP_PRIMITIVE_C 2 - /* 4 register buffer for various purposes */ #define TGSI_EXEC_TEMP_R0 (TGSI_EXEC_NUM_TEMPS + 1) #define TGSI_EXEC_NUM_TEMP_R 4 @@ -233,14 +227,7 @@ struct tgsi_sampler #define TGSI_EXEC_TEMP_ADDR (TGSI_EXEC_NUM_TEMPS + 5) #define TGSI_EXEC_NUM_ADDRS 3 -#define TGSI_EXEC_TEMP_PRIMITIVE_S1_I (TGSI_EXEC_NUM_TEMPS + 8) -#define TGSI_EXEC_TEMP_PRIMITIVE_S1_C 0 -#define TGSI_EXEC_TEMP_PRIMITIVE_S2_I (TGSI_EXEC_NUM_TEMPS + 9) -#define TGSI_EXEC_TEMP_PRIMITIVE_S2_C 1 -#define TGSI_EXEC_TEMP_PRIMITIVE_S3_I (TGSI_EXEC_NUM_TEMPS + 10) -#define TGSI_EXEC_TEMP_PRIMITIVE_S3_C 2 - -#define TGSI_EXEC_NUM_TEMP_EXTRAS 11 +#define TGSI_EXEC_NUM_TEMP_EXTRAS 8 @@ -349,11 +336,17 @@ struct tgsi_exec_machine enum pipe_shader_type ShaderType; /**< PIPE_SHADER_x */ /* GEOMETRY processor only. */ + /* Number of vertices emitted per emitted primitive. */ unsigned *Primitives[TGSI_MAX_VERTEX_STREAMS]; + /* Offsets in ->Outputs of the primitives' vertex output data */ unsigned *PrimitiveOffsets[TGSI_MAX_VERTEX_STREAMS]; unsigned NumOutputs; unsigned MaxGeometryShaderOutputs; unsigned MaxOutputVertices; + /* Offset in ->Outputs for the current vertex to be emitted. */ + unsigned OutputVertexOffset; + /* Number of primitives emitted. */ + unsigned OutputPrimCount[TGSI_MAX_VERTEX_STREAMS]; /* FRAGMENT processor only. */ const struct tgsi_interp_coef *InterpCoefs; _______________________________________________ mesa-commit mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/mesa-commit
