summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>2020-08-21 14:16:18 -0400
committerTomeu Vizoso <tomeu.vizoso@collabora.com>2020-08-25 17:05:38 +0200
commit1e4c49e0b5db350528e9fbc730803338ad4995fb (patch)
tree5b6c1daeca4742cca85d147a1ddfd0832fc7f9d2
parent8c14482cdf134a9dcae6807671106bbc54e5aadb (diff)
panfrost: Upload shader descriptors at CSO create
Now that we've fixed all the implicit state dependencies, these don't change after the variant is created. Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Reviewed-by: Tomeu Vizoso <tomeu.vizoso@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6440>
-rw-r--r--src/gallium/drivers/panfrost/pan_assemble.c22
-rw-r--r--src/gallium/drivers/panfrost/pan_context.c5
-rw-r--r--src/gallium/drivers/panfrost/pan_context.h9
3 files changed, 36 insertions, 0 deletions
diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c
index 21c1810de75..236acd77046 100644
--- a/src/gallium/drivers/panfrost/pan_assemble.c
+++ b/src/gallium/drivers/panfrost/pan_assemble.c
@@ -35,6 +35,7 @@
#include "midgard/midgard_compile.h"
#include "bifrost/bifrost_compile.h"
#include "util/u_dynarray.h"
+#include "util/u_upload_mgr.h"
#include "tgsi/tgsi_dump.h"
@@ -98,6 +99,24 @@ pan_pack_bifrost_props(struct panfrost_shader_state *state,
}
}
+static void
+pan_upload_shader_descriptor(struct panfrost_context *ctx,
+ struct panfrost_shader_state *state)
+{
+ const struct panfrost_device *dev = pan_device(ctx->base.screen);
+ struct mali_shader_meta meta;
+
+ memset(&meta, 0, sizeof(meta));
+ memcpy(&meta.shader, &state->shader, sizeof(state->shader));
+ memcpy(&meta.midgard_props, &state->properties, sizeof(state->properties));
+
+ if (dev->quirks & IS_BIFROST)
+ memcpy(&meta.bifrost_preload, &state->preload, sizeof(state->preload));
+
+ u_upload_data(ctx->state_uploader, 0, sizeof(meta), sizeof(meta),
+ &meta, &state->upload.offset, &state->upload.rsrc);
+}
+
static unsigned
pan_format_from_nir_base(nir_alu_type base)
{
@@ -361,6 +380,9 @@ panfrost_shader_compile(struct panfrost_context *ctx,
else
pan_pack_midgard_props(state, stage);
+ if (stage != MESA_SHADER_FRAGMENT)
+ pan_upload_shader_descriptor(ctx, state);
+
/* In both clone and tgsi_to_nir paths, the shader is ralloc'd against
* a NULL context */
ralloc_free(s);
diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c
index 3002e551f6b..bcf0d199bd4 100644
--- a/src/gallium/drivers/panfrost/pan_context.c
+++ b/src/gallium/drivers/panfrost/pan_context.c
@@ -486,10 +486,15 @@ panfrost_delete_shader_state(
for (unsigned i = 0; i < cso->variant_count; ++i) {
struct panfrost_shader_state *shader_state = &cso->variants[i];
panfrost_bo_unreference(shader_state->bo);
+
+ if (shader_state->upload.rsrc)
+ pipe_resource_reference(&shader_state->upload.rsrc, NULL);
+
shader_state->bo = NULL;
}
free(cso->variants);
+
free(so);
}
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index d490f4aca56..b7314c59e5f 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -188,6 +188,15 @@ struct panfrost_rasterizer {
struct panfrost_shader_state {
/* Compiled, mapped descriptor, ready for the hardware */
bool compiled;
+
+ /* Uploaded shader descriptor (TODO: maybe stuff the packed unuploaded
+ * bits in a union to save some memory?) */
+
+ struct {
+ struct pipe_resource *rsrc;
+ uint32_t offset;
+ } upload;
+
struct mali_shader_packed shader;
struct mali_midgard_properties_packed properties;
struct mali_preload_packed preload;