case nir_intrinsic_load_raw_output_pan: {
reg = nir_dest_index(&instr->dest);
- assert(ctx->is_blend);
/* T720 and below use different blend opcodes with slightly
* different semantics than T760 and up */
case nir_intrinsic_load_output: {
reg = nir_dest_index(&instr->dest);
- assert(ctx->is_blend);
midgard_instruction ld = m_ld_color_buffer_as_fp16(reg, 0);
NIR_PASS_V(nir, nir_lower_vars_to_ssa);
unsigned pan_quirks = panfrost_get_quirks(gpu_id);
- if (is_blend)
NIR_PASS_V(nir, pan_lower_framebuffer,
- program->rt_formats, pan_quirks);
+ program->rt_formats, is_blend, pan_quirks);
NIR_PASS_V(nir, nir_lower_io, nir_var_shader_in | nir_var_shader_out,
glsl_type_size, 0);
nir_builder *b,
nir_intrinsic_instr *intr,
const struct util_format_description *desc,
- unsigned quirks)
+ unsigned base, unsigned quirks)
{
nir_intrinsic_instr *new = nir_intrinsic_instr_create(shader,
nir_intrinsic_load_raw_output_pan);
if (desc->colorspace == UTIL_FORMAT_COLORSPACE_SRGB)
unpacked = pan_srgb_to_linear(b, unpacked);
+ /* Convert to the size of the load intrinsic.
+ *
+ * We can assume that the type will match with the framebuffer format:
+ *
+ * Page 170 of the PDF of the OpenGL ES 3.0.6 spec says:
+ *
+ * If [UNORM or SNORM, convert to fixed-point]; otherwise no type
+ * conversion is applied. If the values written by the fragment shader
+ * do not match the format(s) of the corresponding color buffer(s),
+ * the result is undefined.
+ */
+
+ unsigned bits = nir_dest_bit_size(intr->dest);
+
+ nir_alu_type src_type;
+ if (desc->channel[0].pure_integer) {
+ if (desc->channel[0].type == UTIL_FORMAT_TYPE_SIGNED)
+ src_type = nir_type_int;
+ else
+ src_type = nir_type_uint;
+ } else {
+ src_type = nir_type_float;
+ }
+
+ unpacked = nir_convert_to_bit_size(b, unpacked, src_type, bits);
+
nir_src rewritten = nir_src_for_ssa(unpacked);
nir_ssa_def_rewrite_uses_after(&intr->dest.ssa, rewritten, &intr->instr);
}
bool
pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
- unsigned quirks)
+ bool lower_store, unsigned quirks)
{
if (shader->info.stage != MESA_SHADER_FRAGMENT)
return false;
bool is_load = intr->intrinsic == nir_intrinsic_load_deref;
bool is_store = intr->intrinsic == nir_intrinsic_store_deref;
- if (!(is_load || is_store))
+ if (!(is_load || (is_store && lower_store)))
continue;
nir_variable *var = nir_intrinsic_get_var(intr, 0);
pan_lower_fb_store(shader, &b, intr, desc, quirks);
} else {
b.cursor = nir_after_instr(instr);
- pan_lower_fb_load(shader, &b, intr, desc, quirks);
+ pan_lower_fb_load(shader, &b, intr, desc, base, quirks);
}
nir_instr_remove(instr);