mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 15:20:10 +01:00
pan/mdg: Handle non-blend framebuffer lowering
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5755>
This commit is contained in:
parent
ed4d2739fe
commit
2fa60b70e0
3 changed files with 32 additions and 9 deletions
|
|
@ -1720,7 +1720,6 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
|
|||
|
||||
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 */
|
||||
|
|
@ -1739,7 +1738,6 @@ emit_intrinsic(compiler_context *ctx, nir_intrinsic_instr *instr)
|
|||
|
||||
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);
|
||||
|
||||
|
|
@ -2766,9 +2764,8 @@ midgard_compile_shader_nir(nir_shader *nir, panfrost_program *program, bool is_b
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -640,7 +640,7 @@ pan_lower_fb_load(nir_shader *shader,
|
|||
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);
|
||||
|
|
@ -656,13 +656,39 @@ pan_lower_fb_load(nir_shader *shader,
|
|||
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;
|
||||
|
|
@ -680,7 +706,7 @@ pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
|
|||
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);
|
||||
|
|
@ -709,7 +735,7 @@ pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
|
|||
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);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,6 @@ enum pan_format_class pan_format_class_load(const struct util_format_description
|
|||
enum pan_format_class pan_format_class_store(const struct util_format_description *desc, unsigned quirks);
|
||||
|
||||
bool pan_lower_framebuffer(nir_shader *shader, enum pipe_format *rt_fmts,
|
||||
unsigned quirks);
|
||||
bool is_blend, unsigned quirks);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue