Commit 7542c559 authored by Alyssa Rosenzweig's avatar Alyssa Rosenzweig 💜

panfrost: Support float/vec2/vec3 attributes

Previously, we had hard-coded the number of components to equal 4
(vec4), due to mysterious issues occurring when the count was less than
4. Further investigation shows that not only the component count needs
updating but also the magic value in the unknown1 field. That field
still needs to be further decoded - I suspect it controls how extra
components are padded out - but for now, this patch allows these
attributes to work at all.

This enables Sway to render.
parent b53f54c3
......@@ -1277,6 +1277,7 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
} else if (ctx->stage == MESA_SHADER_VERTEX) {
midgard_instruction ins = m_load_attr_32(reg, offset);
ins.load_store.unknown = 0x1E1E; /* XXX: What is this? */
ins.load_store.mask = (1 << instr->num_components) - 1;
emit_mir_instruction(ctx, ins);
} else {
printf("Unknown load\n");
......
......@@ -1833,8 +1833,6 @@ panfrost_create_vertex_elements_state(
}
so->hw[i].type = type;
so->nr_components[i] = desc->nr_channels;
so->hw[i].nr_components = MALI_POSITIVE(4); /* XXX: Why is this needed? */
so->hw[i].not_normalised = !chan.normalized;
/* Bit used for both signed/unsigned and full/half designation */
......@@ -1843,7 +1841,21 @@ panfrost_create_vertex_elements_state(
(chan.type == UTIL_FORMAT_TYPE_FLOAT && chan.size != 32) ? 1 :
0;
so->hw[i].unknown1 = 0x2a22;
so->hw[i].nr_components = MALI_POSITIVE(desc->nr_channels);
so->nr_components[i] = desc->nr_channels;
/* The meaning of these magic values is unclear at the moment,
* but likely has to do with how attributes are padded */
unsigned unknown1_for_components[4] = {
0x2c82, /* float */
0x2c22, /* vec2 */
0x2a22, /* vec3 */
0x1a22, /* vec4 */
};
so->hw[i].unknown1 = unknown1_for_components[desc->nr_channels];
so->hw[i].unknown2 = 0x1;
/* The field itself should probably be shifted over */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment