pan/bi: Model Valhall source formats

LD_VAR_BUF instructions on Valhall take a source format, indicating the
in-memory format of the varying independent from the register format, which we
still model within the compiler for compatibility with Bifrost. (Prior to
Valhall, source format is specified in the attribute descriptor as a physical
pixel format.)

Model this information, allowing us to generate fp16 LD_VAR_BUF instructions
correctly on Valhall.

Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/16752>
This commit is contained in:
Alyssa Rosenzweig
2022-05-30 15:29:56 -04:00
parent 06886c3861
commit 93f69e4b1c
5 changed files with 45 additions and 13 deletions
+24
View File
@@ -8593,6 +8593,12 @@
<opt>u32</opt>
<opt>u16</opt>
</mod>
<mod name="source_format" size="2">
<opt>flat32</opt>
<opt>flat16</opt>
<opt>f32</opt>
<opt>f16</opt>
</mod>
<mod name="sample" size="3">
<opt>center</opt>
<opt>centroid</opt>
@@ -8623,6 +8629,12 @@
<opt>u32</opt>
<opt>u16</opt>
</mod>
<mod name="source_format" size="2">
<opt>flat32</opt>
<opt>flat16</opt>
<opt>f32</opt>
<opt>f16</opt>
</mod>
<mod name="sample" size="3">
<opt>center</opt>
<opt>centroid</opt>
@@ -8653,6 +8665,12 @@
<opt>u32</opt>
<opt>u16</opt>
</mod>
<mod name="source_format" size="2">
<opt>flat32</opt>
<opt>flat16</opt>
<opt>f32</opt>
<opt>f16</opt>
</mod>
<mod name="sample" size="3">
<opt>center</opt>
<opt>centroid</opt>
@@ -8683,6 +8701,12 @@
<opt>u32</opt>
<opt>u16</opt>
</mod>
<mod name="source_format" size="2">
<opt>flat32</opt>
<opt>flat16</opt>
<opt>f32</opt>
<opt>f16</opt>
</mod>
<mod name="sample" size="3">
<opt>center</opt>
<opt>centroid</opt>
+9 -5
View File
@@ -552,6 +552,9 @@ bi_emit_load_vary(bi_builder *b, nir_intrinsic_instr *instr)
b->shader->info.bifrost->uses_flat_shading = true;
}
enum bi_source_format source_format =
smooth ? BI_SOURCE_FORMAT_F32 : BI_SOURCE_FORMAT_FLAT32;
nir_src *offset = nir_get_io_offset_src(instr);
unsigned imm_index = 0;
bool immediate = bi_is_intr_immediate(instr, &imm_index, 20);
@@ -559,9 +562,9 @@ bi_emit_load_vary(bi_builder *b, nir_intrinsic_instr *instr)
if (b->shader->malloc_idvs && immediate) {
/* Immediate index given in bytes. */
bi_ld_var_buf_imm_f32_to(b, dest, src0, regfmt, sample, update,
vecsize,
bi_varying_offset(b->shader, instr));
bi_ld_var_buf_imm_to(b, sz, dest, src0, regfmt,
sample, source_format, update, vecsize,
bi_varying_offset(b->shader, instr));
} else if (immediate && smooth) {
I = bi_ld_var_imm_to(b, dest, src0, regfmt, sample, update,
vecsize, imm_index);
@@ -582,8 +585,9 @@ bi_emit_load_vary(bi_builder *b, nir_intrinsic_instr *instr)
if (vbase != 0)
idx_bytes = bi_iadd_u32(b, idx, bi_imm_u32(vbase), false);
bi_ld_var_buf_f32_to(b, dest, src0, idx_bytes, regfmt,
sample, update, vecsize);
bi_ld_var_buf_to(b, sz, dest, src0, idx_bytes, regfmt,
sample, source_format, update,
vecsize);
} else if (smooth) {
if (base != 0)
idx = bi_iadd_u32(b, idx, bi_imm_u32(base), false);
+2 -1
View File
@@ -487,6 +487,7 @@ typedef struct {
enum bi_varying_name varying_name; /* LD_VAR_SPECIAL */
bool skip; /* VAR_TEX, TEXS, TEXC */
bool lod_mode; /* VAR_TEX, TEXS, implicitly for TEXC */
enum bi_source_format source_format; /* LD_VAR_BUF */
/* Used for valhall texturing */
bool shadow;
@@ -500,7 +501,7 @@ typedef struct {
};
/* Maximum size, for hashing */
unsigned flags[11];
unsigned flags[14];
struct {
enum bi_subgroup subgroup; /* WMASK, CLPER */
@@ -258,16 +258,19 @@ TEST_F(ValhallPacking, LdAttrImm) {
TEST_F(ValhallPacking, LdVarBufImmF16) {
CASE(bi_ld_var_buf_imm_f16_to(b, bi_register(2), bi_register(61),
BI_REGISTER_FORMAT_F16, BI_SAMPLE_CENTER,
BI_SOURCE_FORMAT_F16,
BI_UPDATE_RETRIEVE, BI_VECSIZE_V4, 0),
0x005d82143300003d);
CASE(bi_ld_var_buf_imm_f16_to(b, bi_register(0), bi_register(61),
BI_REGISTER_FORMAT_F16, BI_SAMPLE_SAMPLE,
BI_SOURCE_FORMAT_F16,
BI_UPDATE_STORE, BI_VECSIZE_V4, 0),
0x005d80843300003d);
CASE(bi_ld_var_buf_imm_f16_to(b, bi_register(0), bi_register(61),
BI_REGISTER_FORMAT_F16, BI_SAMPLE_CENTROID,
BI_SOURCE_FORMAT_F16,
BI_UPDATE_STORE, BI_VECSIZE_V4, 8),
0x005d80443308003d);
}
+7 -7
View File
@@ -266,14 +266,14 @@ va_pack_combine(enum bi_swizzle swz)
static enum va_source_format
va_pack_source_format(const bi_instr *I)
{
switch (I->register_format) {
case BI_REGISTER_FORMAT_AUTO:
case BI_REGISTER_FORMAT_S32:
case BI_REGISTER_FORMAT_U32: return VA_SOURCE_FORMAT_SRC_FLAT32;
case BI_REGISTER_FORMAT_F32: return VA_SOURCE_FORMAT_SRC_F32;
case BI_REGISTER_FORMAT_F16: return VA_SOURCE_FORMAT_SRC_F16;
default: unreachable("unhandled register format");
switch (I->source_format) {
case BI_SOURCE_FORMAT_FLAT32: return VA_SOURCE_FORMAT_SRC_FLAT32;
case BI_SOURCE_FORMAT_FLAT16: return VA_SOURCE_FORMAT_SRC_FLAT16;
case BI_SOURCE_FORMAT_F32: return VA_SOURCE_FORMAT_SRC_F32;
case BI_SOURCE_FORMAT_F16: return VA_SOURCE_FORMAT_SRC_F16;
}
unreachable("unhandled source format");
}
static uint64_t