diff --git a/src/panfrost/bifrost/ISA.xml b/src/panfrost/bifrost/ISA.xml
index 7abe88f58ba..8be9a1e88e0 100644
--- a/src/panfrost/bifrost/ISA.xml
+++ b/src/panfrost/bifrost/ISA.xml
@@ -8593,6 +8593,12 @@
u32
u16
+
+ flat32
+ flat16
+ f32
+ f16
+
center
centroid
@@ -8623,6 +8629,12 @@
u32
u16
+
+ flat32
+ flat16
+ f32
+ f16
+
center
centroid
@@ -8653,6 +8665,12 @@
u32
u16
+
+ flat32
+ flat16
+ f32
+ f16
+
center
centroid
@@ -8683,6 +8701,12 @@
u32
u16
+
+ flat32
+ flat16
+ f32
+ f16
+
center
centroid
diff --git a/src/panfrost/bifrost/bifrost_compile.c b/src/panfrost/bifrost/bifrost_compile.c
index 4ea115a15d3..305d6e19db0 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -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);
diff --git a/src/panfrost/bifrost/compiler.h b/src/panfrost/bifrost/compiler.h
index bfdd27c4d81..a2eb6b1b092 100644
--- a/src/panfrost/bifrost/compiler.h
+++ b/src/panfrost/bifrost/compiler.h
@@ -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 */
diff --git a/src/panfrost/bifrost/valhall/test/test-packing.cpp b/src/panfrost/bifrost/valhall/test/test-packing.cpp
index ce46da36422..7d44bac1320 100644
--- a/src/panfrost/bifrost/valhall/test/test-packing.cpp
+++ b/src/panfrost/bifrost/valhall/test/test-packing.cpp
@@ -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);
}
diff --git a/src/panfrost/bifrost/valhall/va_pack.c b/src/panfrost/bifrost/valhall/va_pack.c
index 5f37934692d..b0df089f26f 100644
--- a/src/panfrost/bifrost/valhall/va_pack.c
+++ b/src/panfrost/bifrost/valhall/va_pack.c
@@ -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