etnaviv: emit varying interpolation state on halti5
Pull the interpolation qualifiers from NIR and translate them to HALTI5_SHADER_ATTRIBUTES states. Signed-off-by: Lucas Stach <l.stach@pengutronix.de> Reviewed-by: Christian Gmeiner <cgmeiner@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32991>
This commit is contained in:
@@ -61,7 +61,8 @@ struct etna_compiler {
|
|||||||
struct etna_shader_inout {
|
struct etna_shader_inout {
|
||||||
int reg; /* native register */
|
int reg; /* native register */
|
||||||
int slot; /* nir: gl_varying_slot or gl_vert_attrib */
|
int slot; /* nir: gl_varying_slot or gl_vert_attrib */
|
||||||
int num_components;
|
uint8_t interpolation;
|
||||||
|
uint8_t num_components;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct etna_shader_io_file {
|
struct etna_shader_io_file {
|
||||||
@@ -137,6 +138,7 @@ struct etna_varying {
|
|||||||
uint32_t pa_attributes;
|
uint32_t pa_attributes;
|
||||||
uint8_t num_components;
|
uint8_t num_components;
|
||||||
uint8_t use[4];
|
uint8_t use[4];
|
||||||
|
uint8_t semantic;
|
||||||
uint8_t reg;
|
uint8_t reg;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -1212,6 +1212,7 @@ etna_compile_shader(struct etna_shader_variant *v)
|
|||||||
unsigned idx = var->data.driver_location;
|
unsigned idx = var->data.driver_location;
|
||||||
sf->reg[idx].reg = idx;
|
sf->reg[idx].reg = idx;
|
||||||
sf->reg[idx].slot = var->data.location;
|
sf->reg[idx].slot = var->data.location;
|
||||||
|
sf->reg[idx].interpolation = var->data.interpolation;
|
||||||
sf->reg[idx].num_components = glsl_get_components(var->type);
|
sf->reg[idx].num_components = glsl_get_components(var->type);
|
||||||
sf->num_reg = MAX2(sf->num_reg, idx+1);
|
sf->num_reg = MAX2(sf->num_reg, idx+1);
|
||||||
}
|
}
|
||||||
@@ -1221,6 +1222,7 @@ etna_compile_shader(struct etna_shader_variant *v)
|
|||||||
unsigned idx = var->data.driver_location;
|
unsigned idx = var->data.driver_location;
|
||||||
sf->reg[idx].reg = idx + 1;
|
sf->reg[idx].reg = idx + 1;
|
||||||
sf->reg[idx].slot = var->data.location;
|
sf->reg[idx].slot = var->data.location;
|
||||||
|
sf->reg[idx].interpolation = var->data.interpolation;
|
||||||
sf->reg[idx].num_components = glsl_get_components(var->type);
|
sf->reg[idx].num_components = glsl_get_components(var->type);
|
||||||
sf->num_reg = MAX2(sf->num_reg, idx+1);
|
sf->num_reg = MAX2(sf->num_reg, idx+1);
|
||||||
count++;
|
count++;
|
||||||
@@ -1405,6 +1407,21 @@ etna_link_shader(struct etna_shader_link_info *info,
|
|||||||
varying->use[i] = VARYING_COMPONENT_USE_GENERIC;
|
varying->use[i] = VARYING_COMPONENT_USE_GENERIC;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (fsio->interpolation) {
|
||||||
|
case INTERP_MODE_NONE:
|
||||||
|
case INTERP_MODE_SMOOTH:
|
||||||
|
varying->semantic = VARYING_INTERPOLATION_MODE_SMOOTH;
|
||||||
|
break;
|
||||||
|
case INTERP_MODE_NOPERSPECTIVE:
|
||||||
|
varying->semantic = VARYING_INTERPOLATION_MODE_NONPERSPECTIVE;
|
||||||
|
break;
|
||||||
|
case INTERP_MODE_FLAT:
|
||||||
|
varying->semantic = VARYING_INTERPOLATION_MODE_FLAT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
unreachable("unsupported varying interpolation mode");
|
||||||
|
}
|
||||||
|
|
||||||
/* point/tex coord is an input to the PS without matching VS output,
|
/* point/tex coord is an input to the PS without matching VS output,
|
||||||
* so it gets a varying slot without being assigned a VS register.
|
* so it gets a varying slot without being assigned a VS register.
|
||||||
*/
|
*/
|
||||||
|
@@ -150,6 +150,9 @@ emit_halti5_only_state(struct etna_context *ctx, int vs_output_count)
|
|||||||
/*01080*/ EMIT_STATE(PS_VARYING_NUM_COMPONENTS(0), ctx->shader_state.GL_VARYING_NUM_COMPONENTS[0]);
|
/*01080*/ EMIT_STATE(PS_VARYING_NUM_COMPONENTS(0), ctx->shader_state.GL_VARYING_NUM_COMPONENTS[0]);
|
||||||
/*01084*/ EMIT_STATE(PS_VARYING_NUM_COMPONENTS(1), ctx->shader_state.GL_VARYING_NUM_COMPONENTS[1]);
|
/*01084*/ EMIT_STATE(PS_VARYING_NUM_COMPONENTS(1), ctx->shader_state.GL_VARYING_NUM_COMPONENTS[1]);
|
||||||
/*03888*/ EMIT_STATE(GL_HALTI5_SH_SPECIALS, ctx->shader_state.GL_HALTI5_SH_SPECIALS);
|
/*03888*/ EMIT_STATE(GL_HALTI5_SH_SPECIALS, ctx->shader_state.GL_HALTI5_SH_SPECIALS);
|
||||||
|
for (int x = 0; x < ctx->shader_state.halti5_shader_attributes_states; ++x) {
|
||||||
|
/*038C0*/ EMIT_STATE(GL_HALTI5_SHADER_ATTRIBUTES(x), ctx->shader_state.GL_HALTI5_SHADER_ATTRIBUTES[x]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (unlikely(dirty & (ETNA_DIRTY_BLEND))) {
|
if (unlikely(dirty & (ETNA_DIRTY_BLEND))) {
|
||||||
for (int i = 1; i < ctx->framebuffer.num_rt; i++) {
|
for (int i = 1; i < ctx->framebuffer.num_rt; i++) {
|
||||||
|
@@ -253,6 +253,8 @@ struct compiled_shader_state {
|
|||||||
uint32_t GL_VARYING_TOTAL_COMPONENTS;
|
uint32_t GL_VARYING_TOTAL_COMPONENTS;
|
||||||
uint32_t GL_VARYING_NUM_COMPONENTS[2];
|
uint32_t GL_VARYING_NUM_COMPONENTS[2];
|
||||||
uint32_t GL_VARYING_COMPONENT_USE[4];
|
uint32_t GL_VARYING_COMPONENT_USE[4];
|
||||||
|
uint32_t GL_HALTI5_SHADER_ATTRIBUTES[VIVS_GL_HALTI5_SHADER_ATTRIBUTES__LEN];
|
||||||
|
int halti5_shader_attributes_states;
|
||||||
uint32_t GL_HALTI5_SH_SPECIALS;
|
uint32_t GL_HALTI5_SH_SPECIALS;
|
||||||
uint32_t FE_HALTI5_ID_CONFIG;
|
uint32_t FE_HALTI5_ID_CONFIG;
|
||||||
unsigned vs_inst_mem_size;
|
unsigned vs_inst_mem_size;
|
||||||
|
@@ -232,12 +232,16 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
|
|||||||
uint32_t total_components = 0;
|
uint32_t total_components = 0;
|
||||||
DEFINE_ETNA_BITARRAY(num_components, ETNA_NUM_VARYINGS, 4) = {0};
|
DEFINE_ETNA_BITARRAY(num_components, ETNA_NUM_VARYINGS, 4) = {0};
|
||||||
DEFINE_ETNA_BITARRAY(component_use, 4 * ETNA_NUM_VARYINGS, 2) = {0};
|
DEFINE_ETNA_BITARRAY(component_use, 4 * ETNA_NUM_VARYINGS, 2) = {0};
|
||||||
|
DEFINE_ETNA_BITARRAY(halti5_varying_semantic, 4 * 32, 4) = {0};
|
||||||
for (int idx = 0; idx < link.num_varyings; ++idx) {
|
for (int idx = 0; idx < link.num_varyings; ++idx) {
|
||||||
const struct etna_varying *varying = &link.varyings[idx];
|
const struct etna_varying *varying = &link.varyings[idx];
|
||||||
|
|
||||||
etna_bitarray_set(num_components, 4, idx, varying->num_components);
|
etna_bitarray_set(num_components, 4, idx, varying->num_components);
|
||||||
for (int comp = 0; comp < varying->num_components; ++comp) {
|
for (int comp = 0; comp < varying->num_components; ++comp) {
|
||||||
etna_bitarray_set(component_use, 2, total_components, varying->use[comp]);
|
if (ctx->screen->info->halti >= 5)
|
||||||
|
etna_bitarray_set(halti5_varying_semantic, 4, total_components, varying->semantic);
|
||||||
|
else
|
||||||
|
etna_bitarray_set(component_use, 2, total_components, varying->use[comp]);
|
||||||
total_components += 1;
|
total_components += 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -246,6 +250,9 @@ etna_link_shaders(struct etna_context *ctx, struct compiled_shader_state *cs,
|
|||||||
VIVS_GL_VARYING_TOTAL_COMPONENTS_NUM(align(total_components, 2));
|
VIVS_GL_VARYING_TOTAL_COMPONENTS_NUM(align(total_components, 2));
|
||||||
memcpy(cs->GL_VARYING_NUM_COMPONENTS, num_components, sizeof(uint32_t) * 2);
|
memcpy(cs->GL_VARYING_NUM_COMPONENTS, num_components, sizeof(uint32_t) * 2);
|
||||||
memcpy(cs->GL_VARYING_COMPONENT_USE, component_use, sizeof(uint32_t) * 4);
|
memcpy(cs->GL_VARYING_COMPONENT_USE, component_use, sizeof(uint32_t) * 4);
|
||||||
|
memcpy(cs->GL_HALTI5_SHADER_ATTRIBUTES, halti5_varying_semantic,
|
||||||
|
sizeof(uint32_t) * VIVS_GL_HALTI5_SHADER_ATTRIBUTES__LEN);
|
||||||
|
cs->halti5_shader_attributes_states = DIV_ROUND_UP(total_components, 8);
|
||||||
|
|
||||||
cs->GL_HALTI5_SH_SPECIALS =
|
cs->GL_HALTI5_SH_SPECIALS =
|
||||||
0x7f7f0000 | /* unknown bits, probably other PS inputs */
|
0x7f7f0000 | /* unknown bits, probably other PS inputs */
|
||||||
|
Reference in New Issue
Block a user