diff --git a/src/asahi/lib/shaders/tessellation.cl b/src/asahi/lib/shaders/tessellation.cl index a5725af6d5a..1ad831460df 100644 --- a/src/asahi/lib/shaders/tessellation.cl +++ b/src/asahi/lib/shaders/tessellation.cl @@ -187,6 +187,25 @@ libagx_tess_setup_indirect(global struct libagx_tess_args *p, bool with_counts, /* TODO */ } + global struct agx_ia_state *ia = p->ia; + ia->verts_per_instance = count; + + /* If indexing is enabled, the third word is the offset into the index buffer + * in elements. Apply that offset now that we have it. For a hardware + * indirect draw, the hardware would do this for us, but for software input + * assembly we need to do it ourselves. + * + * XXX: Deduplicate? + */ + if (p->in_index_size_B) { + ia->index_buffer = + libagx_index_buffer(p->in_index_buffer, p->in_index_buffer_range_el, + p->indirect[2], p->in_index_size_B, 0); + + ia->index_buffer_range_el = libagx_index_buffer_range_el( + p->in_index_buffer_range_el, p->indirect[2]); + } + /* VS grid size */ p->grids[0] = count; p->grids[1] = instance_count; diff --git a/src/asahi/lib/shaders/tessellator.h b/src/asahi/lib/shaders/tessellator.h index 4350a5573a2..c987fd277cf 100644 --- a/src/asahi/lib/shaders/tessellator.h +++ b/src/asahi/lib/shaders/tessellator.h @@ -81,6 +81,9 @@ struct libagx_tess_args { */ GLOBAL(uint32_t) grids; + /* For indirect draws, the output input assembly descriptor */ + GLOBAL(struct agx_ia_state) ia; + /* For indirect draws, the indirect draw descriptor. */ GLOBAL(uint32_t) indirect; @@ -91,6 +94,11 @@ struct libagx_tess_args { */ GLOBAL(uint64_t) vertex_output_buffer_ptr; + /* Yet more indirect draw garbage. I need a refactor. */ + uint64_t in_index_buffer; + uint32_t in_index_buffer_range_el; + uint32_t in_index_size_B; + /* When geom+tess used together, the buffer containing TES outputs (executed * as a hardware compute shader). */ @@ -126,4 +134,4 @@ struct libagx_tess_args { /* Number of patches being tessellated */ uint32_t nr_patches; } PACKED; -AGX_STATIC_ASSERT(sizeof(struct libagx_tess_args) == 42 * 4); +AGX_STATIC_ASSERT(sizeof(struct libagx_tess_args) == 48 * 4);