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>
This commit is contained in:
Alyssa Rosenzweig
2020-08-21 14:16:18 -04:00
committed by Tomeu Vizoso
parent 8c14482cdf
commit 1e4c49e0b5
3 changed files with 36 additions and 0 deletions

View File

@@ -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);

View File

@@ -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);
}

View File

@@ -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;