/* TODO: images */
meta->attribute_count = 0;
meta->varying_count = 0;
+ state->shared_size = s->info.cs.shared_size;
break;
default:
unreachable("Unknown shader state");
*/
#include "pan_context.h"
+#include "pan_bo.h"
#include "util/u_memory.h"
#include "nir_serialize.h"
/* TODO: Stub */
struct midgard_payload_vertex_tiler *payload = &ctx->payloads[PIPE_SHADER_COMPUTE];
+ struct panfrost_shader_variants *all = ctx->shader[PIPE_SHADER_COMPUTE];
+ struct panfrost_shader_state *ss = &all->variants[all->active_variant];
/* We implement OpenCL inputs as uniforms (or a UBO -- same thing), so
* reuse the graphics path for this by lowering to Gallium */
panfrost_emit_for_draw(ctx, false);
+ unsigned single_size = util_next_power_of_two(MAX2(ss->shared_size, 128));
+ unsigned shared_size = single_size * info->grid[0] * info->grid[1] * info->grid[2] * 4;
+
struct mali_shared_memory shared = {
- .shared_workgroup_count = ~0
+ .shared_memory = panfrost_batch_get_shared_memory(batch, shared_size, 1)->gpu,
+ .shared_workgroup_count =
+ util_logbase2_ceil(info->grid[0]) +
+ util_logbase2_ceil(info->grid[1]) +
+ util_logbase2_ceil(info->grid[2]),
+ .shared_unk1 = 0x2,
+ .shared_shift = util_logbase2(single_size) - 1
};
payload->postfix.shared_memory =
bool reads_face;
bool reads_frag_coord;
unsigned stack_size;
+ unsigned shared_size;
struct mali_attr_meta varyings[PIPE_MAX_ATTRIBS];
gl_varying_slot varyings_loc[PIPE_MAX_ATTRIBS];
return batch->scratchpad;
}
+struct panfrost_bo *
+panfrost_batch_get_shared_memory(struct panfrost_batch *batch,
+ unsigned size,
+ unsigned workgroup_count)
+{
+ if (batch->shared_memory) {
+ assert(batch->shared_memory->size >= size);
+ } else {
+ batch->shared_memory = panfrost_batch_create_bo(batch, size,
+ PAN_BO_INVISIBLE,
+ PAN_BO_ACCESS_PRIVATE |
+ PAN_BO_ACCESS_RW |
+ PAN_BO_ACCESS_VERTEX_TILER);
+ }
+
+ return batch->shared_memory;
+}
+
struct panfrost_bo *
panfrost_batch_get_tiler_heap(struct panfrost_batch *batch)
{
/* Amount of thread local storage required per thread */
unsigned stack_size;
+ /* Amount of shared memory needed per workgroup (for compute) */
+ unsigned shared_size;
+
/* Whether this job uses the corresponding requirement (PAN_REQ_*
* bitmask) */
unsigned requirements;
/* Polygon list bound to the batch, or NULL if none bound yet */
struct panfrost_bo *polygon_list;
- /* Scratchpath BO bound to the batch, or NULL if none bound yet */
+ /* Scratchpad BO bound to the batch, or NULL if none bound yet */
struct panfrost_bo *scratchpad;
+ /* Shared memory BO bound to the batch, or NULL if none bound yet */
+ struct panfrost_bo *shared_memory;
+
/* Tiler heap BO bound to the batch, or NULL if none bound yet */
struct panfrost_bo *tiler_heap;
struct panfrost_bo *
panfrost_batch_get_scratchpad(struct panfrost_batch *batch, unsigned shift, unsigned thread_tls_alloc, unsigned core_count);
+struct panfrost_bo *
+panfrost_batch_get_shared_memory(struct panfrost_batch *batch, unsigned size, unsigned workgroup_count);
+
mali_ptr
panfrost_batch_get_polygon_list(struct panfrost_batch *batch, unsigned size);