diff --git a/src/asahi/libagx/draws.cl b/src/asahi/libagx/draws.cl index 6bbdf89b5b1..7fca8fbec67 100644 --- a/src/asahi/libagx/draws.cl +++ b/src/asahi/libagx/draws.cl @@ -162,7 +162,7 @@ libagx_draw_robust_index(global uint32_t *vdm, global struct poly_heap *heap, /* Allocate memory for the shadow index buffer */ global uchar *padded; if (first) { - padded = poly_heap_alloc_nonatomic(heap, out_size_B); + padded = poly_heap_alloc(heap, out_size_B); } padded = (global uchar *)sub_group_broadcast((uintptr_t)padded, 0); diff --git a/src/asahi/libagx/geometry.cl b/src/asahi/libagx/geometry.cl index 5a8c3d94056..8ba80b527cb 100644 --- a/src/asahi/libagx/geometry.cl +++ b/src/asahi/libagx/geometry.cl @@ -147,7 +147,7 @@ libagx_prefix_sum_tess(global struct poly_tess_params *p, global uint *c_prims, /* Allocate 4-byte indices */ uint32_t elsize_B = sizeof(uint32_t); uint32_t size_B = total * elsize_B; - uint alloc_B = poly_heap_alloc_nonatomic_offs(p->heap, size_B); + uint alloc_B = poly_heap_alloc_offs(p->heap, size_B); p->index_buffer = (global uint32_t *)(((uintptr_t)p->heap->base) + alloc_B); /* ...and now we can generate the API indexed draw */ diff --git a/src/asahi/libagx/tessellation.cl b/src/asahi/libagx/tessellation.cl index 6010c988b76..172c1b12984 100644 --- a/src/asahi/libagx/tessellation.cl +++ b/src/asahi/libagx/tessellation.cl @@ -44,7 +44,7 @@ libagx_tess_setup_indirect( alloc += vb_size; /* Allocate all patch calculations in one go */ - global uchar *blob = poly_heap_alloc_nonatomic(p->heap, alloc); + global uchar *blob = poly_heap_alloc(p->heap, alloc); p->tcs_buffer = (global float *)(blob + tcs_out_offs); p->patches_per_instance = in_patches; diff --git a/src/poly/cl/restart.h b/src/poly/cl/restart.h index 512f988549c..5a2159f18bc 100644 --- a/src/poly/cl/restart.h +++ b/src/poly/cl/restart.h @@ -149,7 +149,7 @@ poly_setup_unroll_for_draw(global struct poly_heap *heap, * TODO: For multidraw, should be atomic. But multidraw+unroll isn't * currently wired up in any driver. */ - uint old_heap_bottom_B = poly_heap_alloc_nonatomic_offs(heap, alloc_size); + uint old_heap_bottom_B = poly_heap_alloc_offs(heap, alloc_size); /* Setup most of the descriptor. Count will be determined after unroll. */ out_draw[1] = in_draw[1]; /* instance count */ diff --git a/src/poly/cl/tessellator.h b/src/poly/cl/tessellator.h index 66e08971c4f..798ca25210e 100644 --- a/src/poly/cl/tessellator.h +++ b/src/poly/cl/tessellator.h @@ -193,7 +193,7 @@ poly_heap_alloc_points(constant struct poly_tess_params *p, uint patch, } uint32_t elsize_B = sizeof(struct poly_tess_point); - uint32_t alloc_B = poly_heap_alloc_atomic_offs(p->heap, elsize_B * count); + uint32_t alloc_B = poly_heap_alloc_offs(p->heap, elsize_B * count); uint32_t alloc_el = alloc_B / elsize_B; p->coord_allocs[patch] = alloc_el; diff --git a/src/poly/geometry.h b/src/poly/geometry.h index 4aa8806a312..163491021b2 100644 --- a/src/poly/geometry.h +++ b/src/poly/geometry.h @@ -116,17 +116,12 @@ static_assert(sizeof(struct poly_heap) == 4 * 4); #ifdef __OPENCL_VERSION__ static inline uint -_poly_heap_alloc_offs(global struct poly_heap *heap, uint size_B, bool atomic) +poly_heap_alloc_offs(global struct poly_heap *heap, uint size_B) { size_B = align(size_B, 16); - uint offs; - if (atomic) { - offs = atomic_fetch_add((volatile atomic_uint *)(&heap->bottom), size_B); - } else { - offs = heap->bottom; - heap->bottom = offs + size_B; - } + uint offs = + atomic_fetch_add((volatile atomic_uint *)(&heap->bottom), size_B); /* Use printf+abort because assert is stripped from release builds. */ if (heap->bottom >= heap->size) { @@ -140,22 +135,10 @@ _poly_heap_alloc_offs(global struct poly_heap *heap, uint size_B, bool atomic) return offs; } -static inline uint -poly_heap_alloc_nonatomic_offs(global struct poly_heap *heap, uint size_B) -{ - return _poly_heap_alloc_offs(heap, size_B, false); -} - -static inline uint -poly_heap_alloc_atomic_offs(global struct poly_heap *heap, uint size_B) -{ - return _poly_heap_alloc_offs(heap, size_B, true); -} - static inline global void * -poly_heap_alloc_nonatomic(global struct poly_heap *heap, uint size_B) +poly_heap_alloc(global struct poly_heap *heap, uint size_B) { - return heap->base + poly_heap_alloc_nonatomic_offs(heap, size_B); + return heap->base + poly_heap_alloc_offs(heap, size_B); } uint64_t nir_load_ro_sink_address_poly(void); @@ -648,18 +631,17 @@ poly_gs_setup_indirect(uint64_t index_buffer, constant uint *draw, poly_tcs_in_size(vertex_count * instance_count, vs_outputs); if (is_prefix_summing) { - p->count_buffer = poly_heap_alloc_nonatomic( + p->count_buffer = poly_heap_alloc( heap, p->input_primitives * p->count_buffer_stride); } - vp->output_buffer = - (uintptr_t)poly_heap_alloc_nonatomic(heap, vertex_buffer_size); + vp->output_buffer = (uintptr_t)poly_heap_alloc(heap, vertex_buffer_size); vp->outputs = vs_outputs; if (shape == POLY_GS_SHAPE_DYNAMIC_INDEXED) { const uint32_t index_offset = - poly_heap_alloc_nonatomic_offs(heap, p->draw.index_count * 4); + poly_heap_alloc_offs(heap, p->draw.index_count * 4); p->draw.first_index = index_offset / 4; p->output_index_buffer = (global uint *)(heap->base + index_offset); }