diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h index 9df4c0a0af2..db95af9f8cb 100644 --- a/src/gallium/drivers/panfrost/pan_context.h +++ b/src/gallium/drivers/panfrost/pan_context.h @@ -250,6 +250,52 @@ struct pan_linkage { uint32_t stride; }; +/* System value infrastructure */ +#define MAX_SYSVAL_COUNT 32 + +/* Allow 2D of sysval IDs, while allowing nonparametric sysvals to equal + * their class for equal comparison */ + +#define PAN_SYSVAL(type, no) (((no) << 16) | PAN_SYSVAL_##type) +#define PAN_SYSVAL_TYPE(sysval) ((sysval)&0xffff) +#define PAN_SYSVAL_ID(sysval) ((sysval) >> 16) + +/* Define some common types. We start at one for easy indexing of hash + * tables internal to the compiler */ + +enum { + PAN_SYSVAL_VIEWPORT_SCALE = 1, + PAN_SYSVAL_VIEWPORT_OFFSET = 2, + PAN_SYSVAL_TEXTURE_SIZE = 3, + PAN_SYSVAL_SSBO = 4, + PAN_SYSVAL_NUM_WORK_GROUPS = 5, + PAN_SYSVAL_SAMPLER = 7, + PAN_SYSVAL_LOCAL_GROUP_SIZE = 8, + PAN_SYSVAL_WORK_DIM = 9, + PAN_SYSVAL_IMAGE_SIZE = 10, + PAN_SYSVAL_SAMPLE_POSITIONS = 11, + PAN_SYSVAL_MULTISAMPLED = 12, + PAN_SYSVAL_RT_CONVERSION = 13, + PAN_SYSVAL_VERTEX_INSTANCE_OFFSETS = 14, + PAN_SYSVAL_DRAWID = 15, + PAN_SYSVAL_BLEND_CONSTANTS = 16, + PAN_SYSVAL_XFB = 17, + PAN_SYSVAL_NUM_VERTICES = 18, +}; + +#define PAN_TXS_SYSVAL_ID(texidx, dim, is_array) \ + ((texidx) | ((dim) << 7) | ((is_array) ? (1 << 9) : 0)) + +#define PAN_SYSVAL_ID_TO_TXS_TEX_IDX(id) ((id)&0x7f) +#define PAN_SYSVAL_ID_TO_TXS_DIM(id) (((id) >> 7) & 0x3) +#define PAN_SYSVAL_ID_TO_TXS_IS_ARRAY(id) !!((id) & (1 << 9)) + +struct panfrost_sysvals { + /* The mapping of sysvals to uniforms, the count, and the off-by-one inverse */ + unsigned sysvals[MAX_SYSVAL_COUNT]; + unsigned sysval_count; +}; + #define RSD_WORDS 16 /* Variants bundle together to form the backing CSO, bundling multiple @@ -375,6 +421,7 @@ bool panfrost_disk_cache_retrieve( void panfrost_disk_cache_init(struct panfrost_screen *screen); bool panfrost_nir_remove_fragcolor_stores(nir_shader *s, unsigned nr_cbufs); + bool panfrost_nir_lower_sysvals(nir_shader *s, struct panfrost_sysvals *sysvals); diff --git a/src/panfrost/util/pan_ir.h b/src/panfrost/util/pan_ir.h index 0ed6ef2202e..45dd9fbf6fd 100644 --- a/src/panfrost/util/pan_ir.h +++ b/src/panfrost/util/pan_ir.h @@ -77,58 +77,11 @@ enum pan_special_varying { * special varying */ #define PAN_MAX_VARYINGS (MAX_VARYING + PAN_VARY_MAX - 1) -/* Define the general compiler entry point */ - -#define MAX_SYSVAL_COUNT 32 - -/* Allow 2D of sysval IDs, while allowing nonparametric sysvals to equal - * their class for equal comparison */ - -#define PAN_SYSVAL(type, no) (((no) << 16) | PAN_SYSVAL_##type) -#define PAN_SYSVAL_TYPE(sysval) ((sysval)&0xffff) -#define PAN_SYSVAL_ID(sysval) ((sysval) >> 16) - -/* Define some common types. We start at one for easy indexing of hash - * tables internal to the compiler */ - -enum { - PAN_SYSVAL_VIEWPORT_SCALE = 1, - PAN_SYSVAL_VIEWPORT_OFFSET = 2, - PAN_SYSVAL_TEXTURE_SIZE = 3, - PAN_SYSVAL_SSBO = 4, - PAN_SYSVAL_NUM_WORK_GROUPS = 5, - PAN_SYSVAL_SAMPLER = 7, - PAN_SYSVAL_LOCAL_GROUP_SIZE = 8, - PAN_SYSVAL_WORK_DIM = 9, - PAN_SYSVAL_IMAGE_SIZE = 10, - PAN_SYSVAL_SAMPLE_POSITIONS = 11, - PAN_SYSVAL_MULTISAMPLED = 12, - PAN_SYSVAL_RT_CONVERSION = 13, - PAN_SYSVAL_VERTEX_INSTANCE_OFFSETS = 14, - PAN_SYSVAL_DRAWID = 15, - PAN_SYSVAL_BLEND_CONSTANTS = 16, - PAN_SYSVAL_XFB = 17, - PAN_SYSVAL_NUM_VERTICES = 18, -}; - -#define PAN_TXS_SYSVAL_ID(texidx, dim, is_array) \ - ((texidx) | ((dim) << 7) | ((is_array) ? (1 << 9) : 0)) - -#define PAN_SYSVAL_ID_TO_TXS_TEX_IDX(id) ((id)&0x7f) -#define PAN_SYSVAL_ID_TO_TXS_DIM(id) (((id) >> 7) & 0x3) -#define PAN_SYSVAL_ID_TO_TXS_IS_ARRAY(id) !!((id) & (1 << 9)) - /* Special attribute slots for vertex builtins. Sort of arbitrary but let's be * consistent with the blob so we can compare traces easier. */ enum { PAN_VERTEX_ID = 16, PAN_INSTANCE_ID = 17, PAN_MAX_ATTRIBUTE }; -struct panfrost_sysvals { - /* The mapping of sysvals to uniforms, the count, and the off-by-one inverse */ - unsigned sysvals[MAX_SYSVAL_COUNT]; - unsigned sysval_count; -}; - /* Architecturally, Bifrost/Valhall can address 128 FAU slots of 64-bits each. * In practice, the maximum number of FAU slots is limited by implementation. * All known Bifrost and Valhall devices limit to 64 FAU slots. Therefore the