asahi: Fix varying XML

Lots of changes from reverse-engineering harder the interactions with
fp16 and noperspective and such, and comparing against the PowerVR
driver code in Mesa that's been released since this XML was
originally written.

Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/17198>
This commit is contained in:
Alyssa Rosenzweig
2022-06-19 18:10:09 -04:00
parent ed215183e2
commit c67169d218
5 changed files with 55 additions and 46 deletions

View File

@@ -1538,22 +1538,28 @@ static void
agx_remap_varyings_fs(nir_shader *nir, struct agx_varyings *varyings, agx_remap_varyings_fs(nir_shader *nir, struct agx_varyings *varyings,
unsigned *remap) unsigned *remap)
{ {
struct agx_varying_packed *packed = varyings->packed; struct agx_cf_binding_packed *packed = varyings->packed;
unsigned base = 0; unsigned base = 0;
agx_pack(packed, VARYING, cfg) { agx_pack(packed, CF_BINDING, cfg) {
cfg.type = AGX_VARYING_TYPE_FRAGCOORD_W; /* W component */
cfg.shade_model = AGX_SHADE_MODEL_GOURAUD;
cfg.components = 1; cfg.components = 1;
cfg.triangle_slot = cfg.point_slot = base; cfg.base_slot = base;
cfg.base_coefficient_register = base;
} }
base++; base++;
packed++; packed++;
agx_pack(packed, VARYING, cfg) { agx_pack(packed, CF_BINDING, cfg) {
cfg.type = AGX_VARYING_TYPE_FRAGCOORD_Z; /* Z component */
cfg.shade_model = AGX_SHADE_MODEL_GOURAUD;
cfg.perspective = true;
cfg.fragcoord_z = true;
cfg.components = 1; cfg.components = 1;
cfg.triangle_slot = cfg.point_slot = base; cfg.base_slot = base;
cfg.base_coefficient_register = base;
} }
base++; base++;
@@ -1585,15 +1591,18 @@ agx_remap_varyings_fs(nir_shader *nir, struct agx_varyings *varyings,
remap[var->data.driver_location] = base; remap[var->data.driver_location] = base;
for (int c = 0; c < sz; ++c) { for (int c = 0; c < sz; ++c) {
agx_pack(packed, VARYING, cfg) { agx_pack(packed, CF_BINDING, cfg) {
cfg.type = (var->data.location == VARYING_SLOT_PNTC) ? cfg.shade_model =
AGX_VARYING_TYPE_POINT_COORDINATES :
(var->data.interpolation == INTERP_MODE_FLAT) ? (var->data.interpolation == INTERP_MODE_FLAT) ?
AGX_VARYING_TYPE_FLAT_LAST : AGX_SHADE_MODEL_FLAT_VERTEX_2 :
AGX_VARYING_TYPE_SMOOTH; AGX_SHADE_MODEL_GOURAUD;
cfg.perspective = (var->data.interpolation != INTERP_MODE_FLAT);
cfg.point_sprite = (var->data.location == VARYING_SLOT_PNTC);
cfg.components = channels; cfg.components = channels;
cfg.triangle_slot = cfg.point_slot = base; cfg.base_slot = base;
cfg.base_coefficient_register = base;
} }
base += channels; base += channels;

View File

@@ -86,7 +86,7 @@ struct agx_push {
struct agx_varyings { struct agx_varyings {
unsigned nr_descs, nr_slots; unsigned nr_descs, nr_slots;
struct agx_varying_packed packed[AGX_MAX_VARYINGS]; struct agx_cf_binding_packed packed[AGX_MAX_VARYINGS];
}; };
struct agx_shader_info { struct agx_shader_info {

View File

@@ -137,25 +137,25 @@
<value name="XR" value="5"/> <value name="XR" value="5"/>
</enum> </enum>
<struct name="Varying header" size="4"> <struct name="CF binding header" size="4">
<field name="Triangle slots" size="8" start="0:0" type="uint"/> <field name="Number of 32-bit slots" size="8" start="0:0" type="uint"/>
<field name="Point slots" size="8" start="0:8" type="uint"/> <field name="Number of coefficient registers" size="8" start="0:8" type="uint"/>
</struct> </struct>
<enum name="Varying Type"> <enum name="Shade model">
<value name="Flat (first)" value="0"/> <value name="Flat vertex 0" value="0"/>
<value name="Flat (last)" value="2"/> <value name="Flat vertex 2" value="2"/>
<value name="Fragcoord W" value="3"/> <value name="Gouraud" value="3"/>
<value name="Smooth" value="7"/>
<value name="Fragcoord Z" value="11"/>
<value name="Point coordinates" value="19"/>
</enum> </enum>
<struct name="Varying" size="4"> <struct name="CF binding" size="4">
<field name="Components" size="2" start="0" type="uint" modifier="minus(1)"/> <field name="Components" size="2" start="0" type="uint" modifier="minus(1)"/>
<field name="Type" size="6" start="2" type="Varying Type" default="Smooth"/> <field name="Shade model" size="2" start="2" type="Shade model"/>
<field name="Triangle slot" size="8" start="8" type="uint"/> <field name="Perspective" size="1" start="4" type="bool"/>
<field name="Point slot" size="8" start="16" type="uint"/> <field name="Fragcoord Z" size="1" start="5" type="bool"/>
<field name="Point sprite" size="1" start="6" type="bool"/>
<field name="Base slot" size="8" start="8" type="uint"/>
<field name="Base coefficient register" size="8" start="16" type="uint"/>
</struct> </struct>
<struct name="Format" size="2"> <struct name="Format" size="2">
@@ -472,7 +472,6 @@
<!-- When more than 48 textures bound, switches to 0x8, unk1 switches to <!-- When more than 48 textures bound, switches to 0x8, unk1 switches to
0x6, and some funny sort of bindless access(?) is used in the shader --> 0x6, and some funny sort of bindless access(?) is used in the shader -->
<field name="Unk 2" size="4" start="1:12" type="hex" default="0x1"/> <field name="Unk 2" size="4" start="1:12" type="hex" default="0x1"/>
<field name="Input count" size="8" start="1:16" type="uint" default="0"/>
<field name="Padding 1" size="8" start="1:24" type="hex" default="0x0"/> <field name="Padding 1" size="8" start="1:24" type="hex" default="0x0"/>
<field name="Pipeline" size="32" start="2:0" type="address"/> <field name="Pipeline" size="32" start="2:0" type="address"/>
<field name="Output count 1" size="8" start="3:0" type="uint" default="0"/> <field name="Output count 1" size="8" start="3:0" type="uint" default="0"/>
@@ -491,10 +490,10 @@
<!-- When more than 48 textures bound, switches to 0x8, unk1 switches to <!-- When more than 48 textures bound, switches to 0x8, unk1 switches to
0x6, and some funny sort of bindless access(?) is used in the shader --> 0x6, and some funny sort of bindless access(?) is used in the shader -->
<field name="Unk 2" size="4" start="1:12" type="hex" default="0x1"/> <field name="Unk 2" size="4" start="1:12" type="hex" default="0x1"/>
<field name="Input count" size="8" start="1:16" type="uint" default="0"/> <field name="CF binding count" size="8" start="1:16" type="uint" default="0"/>
<field name="Padding 1" size="8" start="1:24" type="hex" default="0x0"/> <field name="Padding 1" size="8" start="1:24" type="hex" default="0x0"/>
<field name="Pipeline" size="32" start="2:0" type="address"/> <field name="Pipeline" size="32" start="2:0" type="address"/>
<field name="Varyings" size="32" start="3:0" type="address"/> <field name="CF bindings" size="32" start="3:0" type="address"/>
<field name="Padding 2" size="16" start="3:16" type="hex" default="0x0"/> <field name="Padding 2" size="16" start="3:16" type="hex" default="0x0"/>
<field name="More than 4 textures" start="4:0" size="1" type="bool"/> <field name="More than 4 textures" start="4:0" size="1" type="bool"/>
</struct> </struct>

View File

@@ -427,17 +427,16 @@ agxdecode_record(uint64_t va, size_t size, bool verbose)
agx_unpack(agxdecode_dump_stream, map, BIND_FRAGMENT_PIPELINE, cmd); agx_unpack(agxdecode_dump_stream, map, BIND_FRAGMENT_PIPELINE, cmd);
agxdecode_stateful(cmd.pipeline, "Pipeline", agxdecode_pipeline, verbose); agxdecode_stateful(cmd.pipeline, "Pipeline", agxdecode_pipeline, verbose);
/* TODO: parse */ if (cmd.cf_bindings) {
if (cmd.varyings) { uint8_t *map = agxdecode_fetch_gpu_mem(cmd.cf_bindings, 128);
uint8_t *map = agxdecode_fetch_gpu_mem(cmd.varyings, 128);
hexdump(agxdecode_dump_stream, map, 128, false); hexdump(agxdecode_dump_stream, map, 128, false);
DUMP_CL(VARYING_HEADER, map, "Varying header:"); DUMP_CL(CF_BINDING_HEADER, map, "Coefficient binding header:");
map += AGX_VARYING_HEADER_LENGTH; map += AGX_CF_BINDING_HEADER_LENGTH;
for (unsigned i = 0; i < cmd.input_count; ++i) { for (unsigned i = 0; i < cmd.cf_binding_count; ++i) {
DUMP_CL(VARYING, map, "Varying:"); DUMP_CL(CF_BINDING, map, "Coefficient binding:");
map += AGX_VARYING_LENGTH; map += AGX_CF_BINDING_LENGTH;
} }
} }

View File

@@ -943,15 +943,17 @@ agx_update_shader(struct agx_context *ctx, struct agx_compiled_shader **out,
agx_compile_shader_nir(nir, &key->base, &binary, &compiled->info); agx_compile_shader_nir(nir, &key->base, &binary, &compiled->info);
struct agx_varyings *varyings = &compiled->info.varyings; struct agx_varyings *varyings = &compiled->info.varyings;
unsigned packed_varying_sz = (AGX_VARYING_HEADER_LENGTH + varyings->nr_descs * AGX_VARYING_LENGTH); unsigned packed_varying_sz = (AGX_CF_BINDING_HEADER_LENGTH +
varyings->nr_descs * AGX_CF_BINDING_LENGTH);
uint8_t *packed_varyings = alloca(packed_varying_sz); uint8_t *packed_varyings = alloca(packed_varying_sz);
agx_pack(packed_varyings, VARYING_HEADER, cfg) { agx_pack(packed_varyings, CF_BINDING_HEADER, cfg) {
cfg.triangle_slots = cfg.point_slots = varyings->nr_slots; cfg.number_of_32_bit_slots = varyings->nr_slots;
cfg.number_of_coefficient_registers = varyings->nr_slots;
} }
memcpy(packed_varyings + AGX_VARYING_HEADER_LENGTH, varyings->packed, memcpy(packed_varyings + AGX_CF_BINDING_HEADER_LENGTH,
varyings->nr_descs * AGX_VARYING_LENGTH); varyings->packed, varyings->nr_descs * AGX_CF_BINDING_LENGTH);
if (binary.size) { if (binary.size) {
struct agx_device *dev = agx_device(ctx->base.screen); struct agx_device *dev = agx_device(ctx->base.screen);
@@ -1366,9 +1368,9 @@ demo_launch_fragment(struct agx_context *ctx, struct agx_pool *pool, uint32_t pi
cfg.groups_of_8_immediate_textures = DIV_ROUND_UP(tex_count, 8); cfg.groups_of_8_immediate_textures = DIV_ROUND_UP(tex_count, 8);
cfg.groups_of_4_samplers = DIV_ROUND_UP(tex_count, 4); cfg.groups_of_4_samplers = DIV_ROUND_UP(tex_count, 4);
cfg.more_than_4_textures = tex_count >= 4; cfg.more_than_4_textures = tex_count >= 4;
cfg.input_count = input_count; cfg.cf_binding_count = input_count;
cfg.pipeline = pipeline; cfg.pipeline = pipeline;
cfg.varyings = varyings; cfg.cf_bindings = varyings;
}; };
return t.gpu; return t.gpu;