asahi: factor out agx_usc_shared_non_fragment

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/30981>
This commit is contained in:
Alyssa Rosenzweig
2024-08-17 15:09:30 -04:00
committed by Marge Bot
parent 4541688a85
commit 93695ceb48
2 changed files with 35 additions and 21 deletions
+34
View File
@@ -6,6 +6,7 @@
#pragma once
#include "asahi/genxml/agx_pack.h"
#include "agx_compile.h"
/* Opaque structure representing a USC program being constructed */
struct agx_usc_builder {
@@ -103,3 +104,36 @@ agx_usc_shared_none(struct agx_usc_builder *b)
cfg.bytes_per_threadgroup = 65536;
}
}
static void
agx_usc_shared_non_fragment(struct agx_usc_builder *b,
struct agx_shader_info *info,
unsigned variable_shared_mem)
{
if (info->stage == PIPE_SHADER_FRAGMENT) {
return;
} else if (info->stage == PIPE_SHADER_COMPUTE && info->imageblock_stride) {
assert(info->local_size == 0 && "we don't handle this interaction");
assert(variable_shared_mem == 0 && "we don't handle this interaction");
agx_usc_pack(b, SHARED, cfg) {
cfg.layout = AGX_SHARED_LAYOUT_32X32;
cfg.uses_shared_memory = true;
cfg.sample_count = 1;
cfg.sample_stride_in_8_bytes =
DIV_ROUND_UP(info->imageblock_stride, 8);
cfg.bytes_per_threadgroup = cfg.sample_stride_in_8_bytes * 8 * 32 * 32;
}
} else if (info->stage == PIPE_SHADER_COMPUTE ||
info->stage == PIPE_SHADER_TESS_CTRL) {
unsigned size = info->local_size + variable_shared_mem;
agx_usc_pack(b, SHARED, cfg) {
cfg.layout = AGX_SHARED_LAYOUT_VERTEX_COMPUTE;
cfg.bytes_per_threadgroup = size > 0 ? size : 65536;
cfg.uses_shared_memory = size > 0;
}
} else {
agx_usc_shared_none(b);
}
}
+1 -21
View File
@@ -2986,28 +2986,8 @@ agx_build_pipeline(struct agx_batch *batch, struct agx_compiled_shader *cs,
if (stage == PIPE_SHADER_FRAGMENT) {
agx_usc_push_packed(&b, SHARED, &batch->tilebuffer_layout.usc);
} else if (stage == PIPE_SHADER_COMPUTE && cs->b.info.imageblock_stride) {
assert(cs->b.info.local_size == 0 && "we don't handle this interaction");
assert(variable_shared_mem == 0 && "we don't handle this interaction");
agx_usc_pack(&b, SHARED, cfg) {
cfg.layout = AGX_SHARED_LAYOUT_32X32;
cfg.uses_shared_memory = true;
cfg.sample_count = 1;
cfg.sample_stride_in_8_bytes =
DIV_ROUND_UP(cs->b.info.imageblock_stride, 8);
cfg.bytes_per_threadgroup = cfg.sample_stride_in_8_bytes * 8 * 32 * 32;
}
} else if (stage == PIPE_SHADER_COMPUTE || stage == PIPE_SHADER_TESS_CTRL) {
unsigned size = cs->b.info.local_size + variable_shared_mem;
agx_usc_pack(&b, SHARED, cfg) {
cfg.layout = AGX_SHARED_LAYOUT_VERTEX_COMPUTE;
cfg.bytes_per_threadgroup = size > 0 ? size : 65536;
cfg.uses_shared_memory = size > 0;
}
} else {
agx_usc_shared_none(&b);
agx_usc_shared_non_fragment(&b, &cs->b.info, variable_shared_mem);
}
if (linked) {