+
+ /* Even if the texture operation doesn't need a sampler by
+ * itself, we still need to add the sampler configuration
+ * parameter if the output is 32 bit
+ */
+ bool output_type_32_bit = (c->key->tex[unit].return_size == 32 &&
+ !instr->is_shadow);
+
+ if (output_type_32_bit || texture_instr_need_sampler(instr)) {
+ struct V3D41_TMU_CONFIG_PARAMETER_1 p1_unpacked = {
+ .output_type_32_bit = output_type_32_bit,
+
+ .unnormalized_coordinates = (instr->sampler_dim ==
+ GLSL_SAMPLER_DIM_RECT),
+ };
+
+ /* Word enables can't ask for more channels than the
+ * output type could provide (2 for f16, 4 for
+ * 32-bit).
+ */
+ assert(!p1_unpacked.output_type_32_bit ||
+ p0_unpacked.return_words_of_texture_data < (1 << 4));
+ assert(p1_unpacked.output_type_32_bit ||
+ p0_unpacked.return_words_of_texture_data < (1 << 2));
+
+ uint32_t p1_packed;
+ V3D41_TMU_CONFIG_PARAMETER_1_pack(NULL,
+ (uint8_t *)&p1_packed,
+ &p1_unpacked);
+
+ /* Load unit number into the high bits of the sampler
+ * address field, which will be be used by the driver
+ * to decide which sampler to put in the actual
+ * address field.
+ */
+ p1_packed |= unit << 24;
+
+ vir_WRTMUC(c, QUNIFORM_TMU_CONFIG_P1, p1_packed);
+ }
+