From 49994dc8cb5555dfc35be67d2852acc2d7274331 Mon Sep 17 00:00:00 2001 From: Asahi Lina Date: Wed, 28 Jun 2023 17:09:19 +0900 Subject: [PATCH] asahi: Identify the separate varying count fields Flat/goraud/linear and 32/16 need to be specified separately. This change identifies the new fields but should be a functional no-op. Signed-off-by: Asahi Lina Part-of: --- docs/drivers/asahi.rst | 65 ++++++++++++++++++--------- src/asahi/lib/agx_ppp.h | 4 +- src/asahi/lib/cmdbuf.xml | 15 +++---- src/asahi/lib/decode.c | 4 +- src/gallium/drivers/asahi/agx_state.c | 12 ++--- 5 files changed, 61 insertions(+), 39 deletions(-) diff --git a/docs/drivers/asahi.rst b/docs/drivers/asahi.rst index 809c061beca..be3f97e1d03 100644 --- a/docs/drivers/asahi.rst +++ b/docs/drivers/asahi.rst @@ -39,41 +39,66 @@ of the shader in the "Bind Vertex Pipeline" packet. The value may be interpreted consist of a single 32-bit value or an aligned 16-bit register pair, depending on whether interpolation should happen at 32-bit or 16-bit. Vertex outputs are indexed starting from 0, with the *vertex position* always coming first, the -32-bit user varyings coming next, then 16-bit user varyings, and finally *point -size* and *clip distances* at the end if present. Note that *clip distances* are -not accessible from the fragment shader; if the fragment shader needs to read -the interpolated clip distance, the vertex shader must *also* write the clip -distance values to a user varying for the fragment shader to interpolate. Also -note there is no clip plane enable mask anywhere; that must lowered for APIs -that require this (OpenGL but not Vulkan). +32-bit user varyings coming next with perspective, flat, and linear interpolated +varyings grouped in that order, then 16-bit user varyings with the same groupings, +and finally *point size* and *clip distances* at the end if present. Note that +*clip distances* are not accessible from the fragment shader; if the fragment +shader needs to read the interpolated clip distance, the vertex shader must +*also* write the clip distance values to a user varying for the fragment shader +to interpolate. Also note there is no clip plane enable mask anywhere; that must +lowered for APIs that require this (OpenGL but not Vulkan). .. list-table:: Ordering of vertex outputs with all outputs used :widths: 25 75 :header-rows: 1 - * - Index + * - Size (words) - Value - * - 0 - - Vertex position * - 4 - - 32-bit varying 0 + - Vertex position + * - 1 + - 32-bit smooth varying 0 * - - ... - * - 4 + m - - 32-bit varying m - * - 4 + m + 1 - - Packed pair of 16-bit varyings 0 + * - 1 + - 32-bit smooth varying m + * - 1 + - 32-bit flat varying 0 * - - ... - * - 4 + m + 1 + n - - Packed pair of 16-bit varyings n - * - 4 + m + 1 + n + 1 + * - 1 + - 32-bit flat varying n + * - 1 + - 32-bit linear varying 0 + * - + - ... + * - 1 + - 32-bit linear varying o + * - 1 + - Packed pair of 16-bit smooth varyings 0 + * - + - ... + * - 1 + - Packed pair of 16-bit smooth varyings p + * - 1 + - Packed pair of 16-bit flat varyings 0 + * - + - ... + * - 1 + - Packed pair of 16-bit flat varyings q + * - 1 + - Packed pair of 16-bit linear varyings 0 + * - + - ... + * - 1 + - Packed pair of 16-bit linear varyings r + * - 1 - Point size - * - 4 + m + 1 + n + 2 + 0 + * - 1 - Clip distance for plane 0 * - - ... - * - 4 + m + 1 + n + 2 + 15 + * - 1 - Clip distance for plane 15 Remapping diff --git a/src/asahi/lib/agx_ppp.h b/src/asahi/lib/agx_ppp.h index 2902e9dd83d..bb35b2df0b1 100644 --- a/src/asahi/lib/agx_ppp.h +++ b/src/asahi/lib/agx_ppp.h @@ -40,8 +40,8 @@ agx_ppp_update_size(struct AGX_PPP_HEADER *present) PPP_CASE(viewport, VIEWPORT); PPP_CASE(w_clamp, W_CLAMP); PPP_CASE(output_select, OUTPUT_SELECT); - PPP_CASE(varying_word_0, VARYING_0); - PPP_CASE(varying_word_1, VARYING_1); + PPP_CASE(varying_counts_32, VARYING_COUNTS); + PPP_CASE(varying_counts_16, VARYING_COUNTS); PPP_CASE(cull, CULL); PPP_CASE(cull_2, CULL_2); PPP_CASE(fragment_shader, FRAGMENT_SHADER); diff --git a/src/asahi/lib/cmdbuf.xml b/src/asahi/lib/cmdbuf.xml index 806f9d6068c..77d575b9739 100644 --- a/src/asahi/lib/cmdbuf.xml +++ b/src/asahi/lib/cmdbuf.xml @@ -361,8 +361,8 @@ - - + + @@ -485,13 +485,10 @@ - - - - - - - + + + + diff --git a/src/asahi/lib/decode.c b/src/asahi/lib/decode.c index e88796e6428..edb22d8384e 100644 --- a/src/asahi/lib/decode.c +++ b/src/asahi/lib/decode.c @@ -438,8 +438,8 @@ agxdecode_record(uint64_t va, size_t size, bool verbose) PPP_PRINT(map, viewport, VIEWPORT, "Viewport"); PPP_PRINT(map, w_clamp, W_CLAMP, "W clamp"); PPP_PRINT(map, output_select, OUTPUT_SELECT, "Output select"); - PPP_PRINT(map, varying_word_0, VARYING_0, "Varying word 0"); - PPP_PRINT(map, varying_word_1, VARYING_1, "Varying word 1"); + PPP_PRINT(map, varying_counts_32, VARYING_COUNTS, "Varying counts 32"); + PPP_PRINT(map, varying_counts_16, VARYING_COUNTS, "Varying counts 16"); PPP_PRINT(map, cull, CULL, "Cull"); PPP_PRINT(map, cull_2, CULL_2, "Cull 2"); diff --git a/src/gallium/drivers/asahi/agx_state.c b/src/gallium/drivers/asahi/agx_state.c index 19b122acbf8..bd9cd68b6df 100644 --- a/src/gallium/drivers/asahi/agx_state.c +++ b/src/gallium/drivers/asahi/agx_state.c @@ -2199,7 +2199,7 @@ agx_batch_init_state(struct agx_batch *batch) struct agx_ppp_update ppp = agx_new_ppp_update(&batch->pool, (struct AGX_PPP_HEADER){ .w_clamp = true, - .varying_word_1 = true, + .varying_counts_16 = true, .cull_2 = true, .occlusion_query_2 = true, .output_unknown = true, @@ -2208,7 +2208,7 @@ agx_batch_init_state(struct agx_batch *batch) /* clang-format off */ agx_ppp_push(&ppp, W_CLAMP, cfg) cfg.w_clamp = 1e-10; - agx_ppp_push(&ppp, VARYING_1, cfg); + agx_ppp_push(&ppp, VARYING_COUNTS, cfg); agx_ppp_push(&ppp, CULL_2, cfg); agx_ppp_push(&ppp, FRAGMENT_OCCLUSION_QUERY_2, cfg); agx_ppp_push(&ppp, OUTPUT_UNKNOWN, cfg); @@ -2402,7 +2402,7 @@ agx_encode_state(struct agx_batch *batch, uint8_t *out, bool is_lines, .fragment_back_face_2 = object_type_dirty || IS_DIRTY(FS_PROG), .fragment_back_stencil = IS_DIRTY(ZS), .output_select = IS_DIRTY(VS_PROG) || IS_DIRTY(FS_PROG), - .varying_word_0 = IS_DIRTY(VS_PROG), + .varying_counts_32 = IS_DIRTY(VS_PROG), .cull = IS_DIRTY(RS), .fragment_shader = IS_DIRTY(FS) || varyings_dirty || IS_DIRTY(SAMPLE_MASK), @@ -2493,9 +2493,9 @@ agx_encode_state(struct agx_batch *batch, uint8_t *out, bool is_lines, } } - if (dirty.varying_word_0) { - agx_ppp_push(&ppp, VARYING_0, cfg) { - cfg.count = agx_num_general_outputs(&ctx->vs->info.varyings.vs); + if (dirty.varying_counts_32) { + agx_ppp_push(&ppp, VARYING_COUNTS, cfg) { + cfg.smooth = agx_num_general_outputs(&ctx->vs->info.varyings.vs); } }