#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"
}
}
+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)
{
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);
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);
}
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;