panfrost: Pack vertex properties when compiling
They only depend on shader properties so we can do all this work at CSO create time, reducing draw-time overhead. 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:
committed by
Tomeu Vizoso
parent
5393d734a8
commit
a29fb64c16
@@ -38,6 +38,45 @@
|
||||
|
||||
#include "tgsi/tgsi_dump.h"
|
||||
|
||||
static void
|
||||
pan_pack_midgard_props(struct panfrost_shader_state *state,
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
pan_pack(&state->properties, MIDGARD_PROPERTIES, cfg) {
|
||||
cfg.uniform_buffer_count = state->ubo_count;
|
||||
cfg.uniform_count = state->uniform_count;
|
||||
cfg.work_register_count = state->work_reg_count;
|
||||
cfg.writes_globals = state->writes_global;
|
||||
cfg.suppress_inf_nan = true; /* XXX */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
pan_pack_bifrost_props(struct panfrost_shader_state *state,
|
||||
gl_shader_stage stage)
|
||||
{
|
||||
switch (stage) {
|
||||
case MESA_SHADER_VERTEX:
|
||||
pan_pack(&state->properties, BIFROST_PROPERTIES, cfg) {
|
||||
cfg.unknown = 0x800000; /* XXX */
|
||||
cfg.uniform_buffer_count = state->ubo_count;
|
||||
}
|
||||
|
||||
pan_pack(&state->preload, PRELOAD_VERTEX, cfg) {
|
||||
cfg.uniform_count = state->uniform_count;
|
||||
cfg.vertex_id = true;
|
||||
cfg.instance_id = true;
|
||||
}
|
||||
|
||||
break;
|
||||
case MESA_SHADER_FRAGMENT:
|
||||
/* TODO */
|
||||
break;
|
||||
default:
|
||||
unreachable("TODO");
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned
|
||||
pan_format_from_nir_base(nir_alu_type base)
|
||||
{
|
||||
@@ -282,6 +321,11 @@ panfrost_shader_compile(struct panfrost_context *ctx,
|
||||
}
|
||||
}
|
||||
|
||||
/* Needed for linkage */
|
||||
state->attribute_count = attribute_count;
|
||||
state->varying_count = varying_count;
|
||||
state->ubo_count = s->info.num_ubos + 1; /* off-by-one for uniforms */
|
||||
|
||||
/* Prepare the descriptors at compile-time */
|
||||
pan_pack(&state->shader, SHADER, cfg) {
|
||||
cfg.shader = shader;
|
||||
@@ -291,10 +335,10 @@ panfrost_shader_compile(struct panfrost_context *ctx,
|
||||
cfg.sampler_count = cfg.texture_count;
|
||||
}
|
||||
|
||||
/* Needed for linkage */
|
||||
state->attribute_count = attribute_count;
|
||||
state->varying_count = varying_count;
|
||||
state->ubo_count = s->info.num_ubos + 1; /* off-by-one for uniforms */
|
||||
if (dev->quirks & IS_BIFROST)
|
||||
pan_pack_bifrost_props(state, stage);
|
||||
else
|
||||
pan_pack_midgard_props(state, stage);
|
||||
|
||||
/* In both clone and tgsi_to_nir paths, the shader is ralloc'd against
|
||||
* a NULL context */
|
||||
|
||||
@@ -316,38 +316,10 @@ panfrost_emit_compute_shader(struct panfrost_context *ctx,
|
||||
|
||||
memset(meta, 0, sizeof(*meta));
|
||||
memcpy(&meta->shader, &ss->shader, sizeof(ss->shader));
|
||||
memcpy(&meta->midgard_props, &ss->properties, sizeof(ss->properties));
|
||||
|
||||
if (dev->quirks & IS_BIFROST) {
|
||||
struct mali_bifrost_properties_packed prop;
|
||||
struct mali_preload_vertex_packed preload;
|
||||
|
||||
pan_pack(&prop, BIFROST_PROPERTIES, cfg) {
|
||||
cfg.unknown = 0x800000; /* XXX */
|
||||
cfg.uniform_buffer_count = ss->ubo_count;
|
||||
}
|
||||
|
||||
/* TODO: True compute shaders */
|
||||
pan_pack(&preload, PRELOAD_VERTEX, cfg) {
|
||||
cfg.uniform_count = ss->uniform_count;
|
||||
cfg.vertex_id = true;
|
||||
cfg.instance_id = true;
|
||||
}
|
||||
|
||||
memcpy(&meta->bifrost_props, &prop, sizeof(prop));
|
||||
memcpy(&meta->bifrost_preload, &preload, sizeof(preload));
|
||||
} else {
|
||||
struct mali_midgard_properties_packed prop;
|
||||
|
||||
pan_pack(&prop, MIDGARD_PROPERTIES, cfg) {
|
||||
cfg.uniform_buffer_count = ss->ubo_count;
|
||||
cfg.uniform_count = ss->uniform_count;
|
||||
cfg.work_register_count = ss->work_reg_count;
|
||||
cfg.writes_globals = ss->writes_global;
|
||||
cfg.suppress_inf_nan = true; /* XXX */
|
||||
}
|
||||
|
||||
memcpy(&meta->midgard_props, &prop, sizeof(prop));
|
||||
}
|
||||
if (dev->quirks & IS_BIFROST)
|
||||
memcpy(&meta->bifrost_preload, &ss->preload, sizeof(ss->preload));
|
||||
}
|
||||
|
||||
static unsigned
|
||||
|
||||
@@ -184,6 +184,8 @@ struct panfrost_shader_state {
|
||||
/* Compiled, mapped descriptor, ready for the hardware */
|
||||
bool compiled;
|
||||
struct mali_shader_packed shader;
|
||||
struct mali_midgard_properties_packed properties;
|
||||
struct mali_preload_packed preload;
|
||||
|
||||
/* Non-descript information */
|
||||
unsigned uniform_count;
|
||||
|
||||
Reference in New Issue
Block a user