mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-27 12:40:09 +01:00
etnaviv: rename from immedaite to uniform in some places
This naming change should clarify what we are actually doing here. We are defining/managing what data is stored in the GPUs uniform data storage area. A shader can access this area with the ETNA_RGROUP_UNIFORM register group. In this uniform data area we need to store const buffer data and own immediate/constant data. Signed-off-by: Christian Gmeiner <christian.gmeiner@gmail.com> Reviewed-by: Lucas Stach <l.stach@pengutronix.de> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8062>
This commit is contained in:
parent
ad19b0714a
commit
fefbafb6ff
4 changed files with 36 additions and 36 deletions
|
|
@ -217,9 +217,9 @@ src_swizzle(hw_src src, unsigned swizzle)
|
|||
*/
|
||||
|
||||
#define CONST_VAL(a, b) (nir_const_value) {.u64 = (uint64_t)(a) << 32 | (uint64_t)(b)}
|
||||
#define CONST(x) CONST_VAL(ETNA_IMMEDIATE_CONSTANT, x)
|
||||
#define UNIFORM(x) CONST_VAL(ETNA_IMMEDIATE_UNIFORM, x)
|
||||
#define TEXSCALE(x, i) CONST_VAL(ETNA_IMMEDIATE_TEXRECT_SCALE_X + (i), x)
|
||||
#define CONST(x) CONST_VAL(ETNA_UNIFORM_CONSTANT, x)
|
||||
#define UNIFORM(x) CONST_VAL(ETNA_UNIFORM_UNIFORM, x)
|
||||
#define TEXSCALE(x, i) CONST_VAL(ETNA_UNIFORM_TEXRECT_SCALE_X + (i), x)
|
||||
|
||||
static int
|
||||
const_add(uint64_t *c, uint64_t value)
|
||||
|
|
@ -238,7 +238,7 @@ const_src(struct etna_compile *c, nir_const_value *value, unsigned num_component
|
|||
{
|
||||
/* use inline immediates if possible */
|
||||
if (c->specs->halti >= 2 && num_components == 1 &&
|
||||
value[0].u64 >> 32 == ETNA_IMMEDIATE_CONSTANT) {
|
||||
value[0].u64 >> 32 == ETNA_UNIFORM_CONSTANT) {
|
||||
uint32_t bits = value[0].u32;
|
||||
|
||||
/* "float" - shifted by 12 */
|
||||
|
|
@ -573,7 +573,7 @@ emit_intrinsic(struct etna_compile *c, nir_intrinsic_instr * intr)
|
|||
.type = INST_TYPE_U32,
|
||||
.dst = ra_dest(c, &intr->dest, &dst_swiz),
|
||||
.src[0] = get_src(c, &intr->src[1]),
|
||||
.src[1] = const_src(c, &CONST_VAL(ETNA_IMMEDIATE_UBO0_ADDR + idx, 0), 1),
|
||||
.src[1] = const_src(c, &CONST_VAL(ETNA_UNIFORM_UBO0_ADDR + idx, 0), 1),
|
||||
});
|
||||
} break;
|
||||
case nir_intrinsic_load_front_face:
|
||||
|
|
@ -897,7 +897,7 @@ emit_shader(struct etna_compile *c, unsigned *num_temps, unsigned *num_consts)
|
|||
if (intr->intrinsic != nir_intrinsic_load_uniform)
|
||||
break;
|
||||
nir_const_value *off = nir_src_as_const_value(intr->src[0]);
|
||||
if (!off || off[0].u64 >> 32 != ETNA_IMMEDIATE_CONSTANT) {
|
||||
if (!off || off[0].u64 >> 32 != ETNA_UNIFORM_CONSTANT) {
|
||||
have_indirect_uniform = true;
|
||||
indirect_max = nir_intrinsic_base(intr) + nir_intrinsic_range(intr);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -160,7 +160,7 @@ struct etna_compile {
|
|||
bool dead_inst[ETNA_MAX_TOKENS];
|
||||
|
||||
/* Immediate data */
|
||||
enum etna_immediate_contents imm_contents[ETNA_MAX_IMM];
|
||||
enum etna_uniform_contents imm_contents[ETNA_MAX_IMM];
|
||||
uint32_t imm_data[ETNA_MAX_IMM];
|
||||
uint32_t imm_base; /* base of immediates (in 32 bit units) */
|
||||
uint32_t imm_size; /* size of immediates (in 32 bit units) */
|
||||
|
|
@ -369,7 +369,7 @@ assign_inouts_to_temporaries(struct etna_compile *c, uint file)
|
|||
* there is already an immediate with that value, return that.
|
||||
*/
|
||||
static struct etna_inst_src
|
||||
alloc_imm(struct etna_compile *c, enum etna_immediate_contents contents,
|
||||
alloc_imm(struct etna_compile *c, enum etna_uniform_contents contents,
|
||||
uint32_t value)
|
||||
{
|
||||
int idx;
|
||||
|
|
@ -383,7 +383,7 @@ alloc_imm(struct etna_compile *c, enum etna_immediate_contents contents,
|
|||
/* look if there is an unused slot */
|
||||
if (idx == c->imm_size) {
|
||||
for (idx = 0; idx < c->imm_size; ++idx) {
|
||||
if (c->imm_contents[idx] == ETNA_IMMEDIATE_UNUSED)
|
||||
if (c->imm_contents[idx] == ETNA_UNIFORM_UNUSED)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -411,11 +411,11 @@ alloc_imm(struct etna_compile *c, enum etna_immediate_contents contents,
|
|||
static struct etna_inst_src
|
||||
alloc_imm_u32(struct etna_compile *c, uint32_t value)
|
||||
{
|
||||
return alloc_imm(c, ETNA_IMMEDIATE_CONSTANT, value);
|
||||
return alloc_imm(c, ETNA_UNIFORM_CONSTANT, value);
|
||||
}
|
||||
|
||||
static struct etna_inst_src
|
||||
alloc_imm_vec4u(struct etna_compile *c, enum etna_immediate_contents contents,
|
||||
alloc_imm_vec4u(struct etna_compile *c, enum etna_uniform_contents contents,
|
||||
const uint32_t *values)
|
||||
{
|
||||
struct etna_inst_src imm_src = { };
|
||||
|
|
@ -479,7 +479,7 @@ etna_imm_vec4f(struct etna_compile *c, const float *vec4)
|
|||
for (int i = 0; i < 4; i++)
|
||||
val[i] = fui(vec4[i]);
|
||||
|
||||
return alloc_imm_vec4u(c, ETNA_IMMEDIATE_CONSTANT, val);
|
||||
return alloc_imm_vec4u(c, ETNA_UNIFORM_CONSTANT, val);
|
||||
}
|
||||
|
||||
/* Pass -- check register file declarations and immediates */
|
||||
|
|
@ -504,7 +504,7 @@ etna_compile_parse_declarations(struct etna_compile *c)
|
|||
unsigned idx = c->imm_size++;
|
||||
|
||||
c->imm_data[idx] = imm->u[i].Uint;
|
||||
c->imm_contents[idx] = ETNA_IMMEDIATE_CONSTANT;
|
||||
c->imm_contents[idx] = ETNA_UNIFORM_CONSTANT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
|
@ -1699,12 +1699,12 @@ trans_sampler(const struct instr_translater *t, struct etna_compile *c,
|
|||
ins[0].opcode = INST_OPCODE_MUL;
|
||||
ins[0].dst = etna_native_to_dst(temp, INST_COMPS_X);
|
||||
ins[0].src[0] = src[0];
|
||||
ins[0].src[1] = alloc_imm(c, ETNA_IMMEDIATE_TEXRECT_SCALE_X, unit);
|
||||
ins[0].src[1] = alloc_imm(c, ETNA_UNIFORM_TEXRECT_SCALE_X, unit);
|
||||
|
||||
ins[1].opcode = INST_OPCODE_MUL;
|
||||
ins[1].dst = etna_native_to_dst(temp, INST_COMPS_Y);
|
||||
ins[1].src[0] = src[0];
|
||||
ins[1].src[1] = alloc_imm(c, ETNA_IMMEDIATE_TEXRECT_SCALE_Y, unit);
|
||||
ins[1].src[1] = alloc_imm(c, ETNA_UNIFORM_TEXRECT_SCALE_Y, unit);
|
||||
|
||||
emit_inst(c, &ins[0]);
|
||||
emit_inst(c, &ins[1]);
|
||||
|
|
@ -2299,7 +2299,7 @@ copy_uniform_state_to_shader(struct etna_compile *c, struct etna_shader_variant
|
|||
|
||||
uinfo->imm_contents = malloc(count * sizeof(*c->imm_contents));
|
||||
for (unsigned i = 0; i < c->imm_base; i++)
|
||||
uinfo->imm_contents[i] = ETNA_IMMEDIATE_UNIFORM;
|
||||
uinfo->imm_contents[i] = ETNA_UNIFORM_UNIFORM;
|
||||
memcpy(&uinfo->imm_contents[c->imm_base], c->imm_contents, c->imm_size * sizeof(*c->imm_contents));
|
||||
|
||||
etna_set_shader_uniforms_dirty_flags(sobj);
|
||||
|
|
|
|||
|
|
@ -90,18 +90,18 @@ struct etna_shader_state {
|
|||
struct etna_shader_variant *vs, *fs;
|
||||
};
|
||||
|
||||
enum etna_immediate_contents {
|
||||
ETNA_IMMEDIATE_UNUSED = 0,
|
||||
ETNA_IMMEDIATE_CONSTANT,
|
||||
ETNA_IMMEDIATE_UNIFORM,
|
||||
ETNA_IMMEDIATE_TEXRECT_SCALE_X,
|
||||
ETNA_IMMEDIATE_TEXRECT_SCALE_Y,
|
||||
ETNA_IMMEDIATE_UBO0_ADDR,
|
||||
ETNA_IMMEDIATE_UBOMAX_ADDR = ETNA_IMMEDIATE_UBO0_ADDR + ETNA_MAX_CONST_BUF - 1,
|
||||
enum etna_uniform_contents {
|
||||
ETNA_UNIFORM_UNUSED = 0,
|
||||
ETNA_UNIFORM_CONSTANT,
|
||||
ETNA_UNIFORM_UNIFORM,
|
||||
ETNA_UNIFORM_TEXRECT_SCALE_X,
|
||||
ETNA_UNIFORM_TEXRECT_SCALE_Y,
|
||||
ETNA_UNIFORM_UBO0_ADDR,
|
||||
ETNA_UNIFORM_UBOMAX_ADDR = ETNA_UNIFORM_UBO0_ADDR + ETNA_MAX_CONST_BUF - 1,
|
||||
};
|
||||
|
||||
struct etna_shader_uniform_info {
|
||||
enum etna_immediate_contents *imm_contents;
|
||||
enum etna_uniform_contents *imm_contents;
|
||||
uint32_t *imm_data;
|
||||
uint32_t imm_count;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -46,13 +46,13 @@ get_const_idx(const struct etna_context *ctx, bool frag, unsigned samp_id)
|
|||
|
||||
static uint32_t
|
||||
get_texrect_scale(const struct etna_context *ctx, bool frag,
|
||||
enum etna_immediate_contents contents, uint32_t data)
|
||||
enum etna_uniform_contents contents, uint32_t data)
|
||||
{
|
||||
unsigned index = get_const_idx(ctx, frag, data);
|
||||
struct pipe_sampler_view *texture = ctx->sampler_view[index];
|
||||
uint32_t dim;
|
||||
|
||||
if (contents == ETNA_IMMEDIATE_TEXRECT_SCALE_X)
|
||||
if (contents == ETNA_UNIFORM_TEXRECT_SCALE_X)
|
||||
dim = texture->texture->width0;
|
||||
else
|
||||
dim = texture->texture->height0;
|
||||
|
|
@ -82,23 +82,23 @@ etna_uniforms_write(const struct etna_context *ctx,
|
|||
uint32_t val = uinfo->imm_data[i];
|
||||
|
||||
switch (uinfo->imm_contents[i]) {
|
||||
case ETNA_IMMEDIATE_CONSTANT:
|
||||
case ETNA_UNIFORM_CONSTANT:
|
||||
etna_cmd_stream_emit(stream, val);
|
||||
break;
|
||||
|
||||
case ETNA_IMMEDIATE_UNIFORM:
|
||||
case ETNA_UNIFORM_UNIFORM:
|
||||
assert(cb->user_buffer && val * 4 < cb->buffer_size);
|
||||
etna_cmd_stream_emit(stream, ((uint32_t*) cb->user_buffer)[val]);
|
||||
break;
|
||||
|
||||
case ETNA_IMMEDIATE_TEXRECT_SCALE_X:
|
||||
case ETNA_IMMEDIATE_TEXRECT_SCALE_Y:
|
||||
case ETNA_UNIFORM_TEXRECT_SCALE_X:
|
||||
case ETNA_UNIFORM_TEXRECT_SCALE_Y:
|
||||
etna_cmd_stream_emit(stream,
|
||||
get_texrect_scale(ctx, frag, uinfo->imm_contents[i], val));
|
||||
break;
|
||||
|
||||
case ETNA_IMMEDIATE_UBO0_ADDR ... ETNA_IMMEDIATE_UBOMAX_ADDR:
|
||||
idx = uinfo->imm_contents[i] - ETNA_IMMEDIATE_UBO0_ADDR;
|
||||
case ETNA_UNIFORM_UBO0_ADDR ... ETNA_UNIFORM_UBOMAX_ADDR:
|
||||
idx = uinfo->imm_contents[i] - ETNA_UNIFORM_UBO0_ADDR;
|
||||
etna_cmd_stream_reloc(stream, &(struct etna_reloc) {
|
||||
.bo = etna_resource(cb[idx].buffer)->bo,
|
||||
.flags = ETNA_RELOC_READ,
|
||||
|
|
@ -106,7 +106,7 @@ etna_uniforms_write(const struct etna_context *ctx,
|
|||
});
|
||||
break;
|
||||
|
||||
case ETNA_IMMEDIATE_UNUSED:
|
||||
case ETNA_UNIFORM_UNUSED:
|
||||
etna_cmd_stream_emit(stream, 0);
|
||||
break;
|
||||
}
|
||||
|
|
@ -126,8 +126,8 @@ etna_set_shader_uniforms_dirty_flags(struct etna_shader_variant *sobj)
|
|||
default:
|
||||
break;
|
||||
|
||||
case ETNA_IMMEDIATE_TEXRECT_SCALE_X:
|
||||
case ETNA_IMMEDIATE_TEXRECT_SCALE_Y:
|
||||
case ETNA_UNIFORM_TEXRECT_SCALE_X:
|
||||
case ETNA_UNIFORM_TEXRECT_SCALE_Y:
|
||||
dirty |= ETNA_DIRTY_SAMPLER_VIEWS;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue