2023-05-25 13:22:45 -04:00
|
|
|
/*
|
|
|
|
|
* Copyright 2023 Alyssa Rosenzweig
|
|
|
|
|
* Copyright 2021 Intel Corporation
|
|
|
|
|
* SPDX-License-Identifier: MIT
|
|
|
|
|
*/
|
|
|
|
|
|
2024-01-09 15:50:27 -04:00
|
|
|
#include "nir.h"
|
2023-05-25 13:22:45 -04:00
|
|
|
#include "nir_builder.h"
|
|
|
|
|
|
2025-04-14 22:53:46 +01:00
|
|
|
static nir_def *
|
2025-12-31 13:01:59 -05:00
|
|
|
alpha_to_coverage(nir_builder *b, nir_def *alpha, bool has_intrinsic)
|
2025-04-14 22:53:46 +01:00
|
|
|
{
|
|
|
|
|
if (has_intrinsic)
|
|
|
|
|
return nir_alpha_to_coverage(b, alpha);
|
|
|
|
|
|
2025-12-31 13:01:59 -05:00
|
|
|
/* The following formula is used to compute final sample mask:
|
|
|
|
|
* m = int(round(16.0 * clamp(src0_alpha, 0.0, 1.0)))
|
|
|
|
|
* dither_mask = 0x1111 * ((0xf7540 >> (m & ~3)) & 0xf) |
|
|
|
|
|
* 0x0404 * (m & 2) | 0x0080 * (m & 1)
|
|
|
|
|
* sample_mask = sample_mask & dither_mask
|
2025-04-14 22:53:46 +01:00
|
|
|
*
|
2025-12-31 13:01:59 -05:00
|
|
|
* It gives a number of ones proportional to the alpha for 2, 4, 8 or 16
|
|
|
|
|
* least significant bits of the result:
|
|
|
|
|
*
|
|
|
|
|
* 0.0000 0000000000000000
|
|
|
|
|
* 0.0625 0000000010000000
|
|
|
|
|
* 0.1250 0000100000001000
|
|
|
|
|
* 0.1875 0000100010001000
|
|
|
|
|
* 0.2500 0100010001000100
|
|
|
|
|
* 0.3125 0100010011000100
|
|
|
|
|
* 0.3750 0100110001001100
|
|
|
|
|
* 0.4375 0100110011001100
|
|
|
|
|
* 0.5000 0101010101010101
|
|
|
|
|
* 0.5625 0101010111010101
|
|
|
|
|
* 0.6250 0101110101011101
|
|
|
|
|
* 0.6875 0101110111011101
|
|
|
|
|
* 0.7500 0111011101110111
|
|
|
|
|
* 0.8125 0111011111110111
|
|
|
|
|
* 0.8750 0111111101111111
|
|
|
|
|
* 0.9375 0111111111111111
|
|
|
|
|
* 1.0000 1111111111111111
|
|
|
|
|
*
|
|
|
|
|
* We use 16-bit math for the multiplies because the result always fits
|
|
|
|
|
* into 16 bits and that is typically way cheaper than full 32-bit
|
|
|
|
|
* multiplies.
|
|
|
|
|
*/
|
|
|
|
|
nir_def *m =
|
|
|
|
|
nir_f2i32(b, nir_fround_even(b, nir_fmul_imm(b, nir_fsat(b, alpha), 16.0)));
|
|
|
|
|
|
|
|
|
|
nir_def *part_a =
|
|
|
|
|
nir_u2u16(b, nir_iand_imm(b, nir_ushr(b, nir_imm_int(b, 0xf7540),
|
|
|
|
|
nir_iand_imm(b, m, ~3)),
|
|
|
|
|
0xf));
|
|
|
|
|
|
|
|
|
|
nir_def *part_b = nir_iand_imm(b, nir_u2u16(b, m), 2);
|
|
|
|
|
nir_def *part_c = nir_iand_imm(b, nir_u2u16(b, m), 1);
|
|
|
|
|
|
|
|
|
|
nir_def *mask = nir_ior(b, nir_imul_imm(b, part_a, 0x1111),
|
|
|
|
|
nir_ior(b, nir_imul_imm(b, part_b, 0x0404),
|
|
|
|
|
nir_imul_imm(b, part_c, 0x0080)));
|
|
|
|
|
|
|
|
|
|
/* Rotate the mask based on (pixel.x % 2) + (pixel.y % 2). This provides
|
|
|
|
|
* dithering and randomizes the sample locations.
|
2025-04-14 22:53:46 +01:00
|
|
|
*/
|
2025-12-31 13:01:59 -05:00
|
|
|
nir_def *pixel = nir_f2u32(b, nir_channels(b, nir_load_frag_coord(b), 0x3));
|
|
|
|
|
nir_def *rotate_amount =
|
|
|
|
|
nir_iadd(b, nir_iand_imm(b, nir_channel(b, pixel, 0), 0x1),
|
|
|
|
|
nir_iand_imm(b, nir_channel(b, pixel, 1), 0x1));
|
|
|
|
|
mask = nir_ior(b, nir_ushr(b, mask, rotate_amount),
|
|
|
|
|
nir_ishl(b, mask, nir_isub_imm(b, 16, rotate_amount)));
|
|
|
|
|
return nir_u2u32(b, mask);
|
2025-04-14 22:53:46 +01:00
|
|
|
}
|
|
|
|
|
|
2023-05-25 13:22:45 -04:00
|
|
|
/*
|
|
|
|
|
* Lower alpha-to-coverage to sample_mask and some math. May run on either a
|
|
|
|
|
* monolithic pixel shader or a fragment epilogue.
|
|
|
|
|
*/
|
2024-01-09 15:50:27 -04:00
|
|
|
bool
|
2025-12-31 13:01:59 -05:00
|
|
|
nir_lower_alpha_to_coverage(nir_shader *shader, bool has_intrinsic, nir_def *dyn_enable)
|
2023-05-25 13:22:45 -04:00
|
|
|
{
|
|
|
|
|
/* nir_lower_io_to_temporaries ensures that stores are in the last block */
|
|
|
|
|
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
|
|
|
|
nir_block *block = nir_impl_last_block(impl);
|
|
|
|
|
|
|
|
|
|
/* The store is probably at the end of the block, so search in reverse. */
|
|
|
|
|
nir_intrinsic_instr *store = NULL;
|
|
|
|
|
nir_foreach_instr_reverse(instr, block) {
|
|
|
|
|
if (instr->type != nir_instr_type_intrinsic)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
|
|
|
|
if (intr->intrinsic != nir_intrinsic_store_output)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
nir_io_semantics sem = nir_intrinsic_io_semantics(intr);
|
|
|
|
|
if (sem.location != FRAG_RESULT_DATA0)
|
|
|
|
|
continue;
|
|
|
|
|
if (sem.dual_source_blend_index != 0)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
store = intr;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* If render target 0 isn't written, the alpha value input to
|
|
|
|
|
* alpha-to-coverage is undefined. We assume that the alpha would be 1.0,
|
|
|
|
|
* which would effectively disable alpha-to-coverage, skipping the lowering.
|
2024-01-09 15:50:27 -04:00
|
|
|
*
|
|
|
|
|
* Similarly, if there are less than 4 components, alpha is undefined.
|
2023-05-25 13:22:45 -04:00
|
|
|
*/
|
2024-01-09 15:50:27 -04:00
|
|
|
nir_def *rgba = store ? store->src[0].ssa : NULL;
|
|
|
|
|
if (!rgba || rgba->num_components < 4) {
|
treewide: Switch to nir_progress
Via the Coccinelle patch at the end of the commit message, followed by
sed -ie 's/progress = progress | /progress |=/g' $(git grep -l 'progress = prog')
ninja -C ~/mesa/build clang-format
cd ~/mesa/src/compiler/nir && clang-format -i *.c
agxfmt
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
-return prog;
+return nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-return true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-return false;
-}
+bool progress = prog_expr;
+return nir_progress(progress, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, prog ? (metadata) : nir_metadata_all);
-return prog;
+return nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, prog ? (metadata) : nir_metadata_all);
+nir_progress(prog, impl, metadata);
@@
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
-return true;
+return nir_progress(true, impl, metadata);
@@
expression impl;
@@
-nir_metadata_preserve(impl, nir_metadata_all);
-return false;
+return nir_no_progress(impl);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
-other_prog |= prog;
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+nir_progress(prog, impl, metadata);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-other_prog = true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
identifier prog;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-prog = true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+prog = prog | nir_progress(impl_progress, impl, metadata);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-other_prog = true;
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
identifier prog;
@@
-if (prog_expr) {
-prog = true;
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+prog = prog | nir_progress(impl_progress, impl, metadata);
@@
expression prog_expr, impl, metadata;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+nir_progress(impl_progress, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
-prog = true;
+prog = nir_progress(true, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-}
-return prog;
+return nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-}
+nir_progress(prog, impl, metadata);
@@
expression impl;
@@
-nir_metadata_preserve(impl, nir_metadata_all);
+nir_no_progress(impl);
@@
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
+nir_progress(true, impl, metadata);
squashme! sed -ie 's/progress = progress | /progress |=/g' $(git grep -l 'progress = prog')
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33722>
2025-02-24 15:10:33 -05:00
|
|
|
return nir_no_progress(impl);
|
2024-01-09 15:50:27 -04:00
|
|
|
}
|
2023-05-25 13:22:45 -04:00
|
|
|
|
2023-07-04 22:24:28 -04:00
|
|
|
nir_builder _b = nir_builder_at(nir_before_instr(&store->instr));
|
|
|
|
|
nir_builder *b = &_b;
|
2023-05-25 13:22:45 -04:00
|
|
|
|
2023-08-12 16:17:15 -04:00
|
|
|
nir_def *alpha = nir_channel(b, rgba, 3);
|
2025-08-28 17:14:20 +01:00
|
|
|
if (dyn_enable)
|
|
|
|
|
alpha = nir_bcsel(b, dyn_enable, alpha, nir_imm_floatN_t(b, 1.0f, alpha->bit_size));
|
2025-12-31 13:01:59 -05:00
|
|
|
nir_def *mask = alpha_to_coverage(b, alpha, has_intrinsic);
|
2023-05-25 13:22:45 -04:00
|
|
|
|
|
|
|
|
/* Discard samples that aren't covered */
|
2025-04-08 16:27:11 +01:00
|
|
|
nir_demote_samples(b, nir_inot(b, mask));
|
2023-06-14 12:34:34 -04:00
|
|
|
shader->info.fs.uses_discard = true;
|
treewide: Switch to nir_progress
Via the Coccinelle patch at the end of the commit message, followed by
sed -ie 's/progress = progress | /progress |=/g' $(git grep -l 'progress = prog')
ninja -C ~/mesa/build clang-format
cd ~/mesa/src/compiler/nir && clang-format -i *.c
agxfmt
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
-return prog;
+return nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-return true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-return false;
-}
+bool progress = prog_expr;
+return nir_progress(progress, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, prog ? (metadata) : nir_metadata_all);
-return prog;
+return nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, prog ? (metadata) : nir_metadata_all);
+nir_progress(prog, impl, metadata);
@@
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
-return true;
+return nir_progress(true, impl, metadata);
@@
expression impl;
@@
-nir_metadata_preserve(impl, nir_metadata_all);
-return false;
+return nir_no_progress(impl);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
-other_prog |= prog;
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+nir_progress(prog, impl, metadata);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-other_prog = true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
identifier prog;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-prog = true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+prog = prog | nir_progress(impl_progress, impl, metadata);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-other_prog = true;
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
identifier prog;
@@
-if (prog_expr) {
-prog = true;
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+prog = prog | nir_progress(impl_progress, impl, metadata);
@@
expression prog_expr, impl, metadata;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+nir_progress(impl_progress, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
-prog = true;
+prog = nir_progress(true, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-}
-return prog;
+return nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-}
+nir_progress(prog, impl, metadata);
@@
expression impl;
@@
-nir_metadata_preserve(impl, nir_metadata_all);
+nir_no_progress(impl);
@@
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
+nir_progress(true, impl, metadata);
squashme! sed -ie 's/progress = progress | /progress |=/g' $(git grep -l 'progress = prog')
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33722>
2025-02-24 15:10:33 -05:00
|
|
|
return nir_progress(true, impl, nir_metadata_control_flow);
|
2023-05-25 13:22:45 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Modify the inputs to store_output instructions in a pixel shader when
|
|
|
|
|
* alpha-to-one is used. May run on either a monolithic pixel shader or a
|
|
|
|
|
* fragment epilogue.
|
|
|
|
|
*/
|
2024-01-09 15:50:27 -04:00
|
|
|
bool
|
2025-04-08 16:27:11 +01:00
|
|
|
nir_lower_alpha_to_one(nir_shader *shader)
|
2023-05-25 13:22:45 -04:00
|
|
|
{
|
2024-01-09 15:50:27 -04:00
|
|
|
bool progress = false;
|
|
|
|
|
|
2023-05-25 13:22:45 -04:00
|
|
|
/* nir_lower_io_to_temporaries ensures that stores are in the last block */
|
|
|
|
|
nir_function_impl *impl = nir_shader_get_entrypoint(shader);
|
|
|
|
|
nir_block *block = nir_impl_last_block(impl);
|
|
|
|
|
|
|
|
|
|
nir_foreach_instr(instr, block) {
|
|
|
|
|
if (instr->type != nir_instr_type_intrinsic)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
nir_intrinsic_instr *intr = nir_instr_as_intrinsic(instr);
|
|
|
|
|
if (intr->intrinsic != nir_intrinsic_store_output)
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
/* The OpenGL spec is a bit confusing here, but seemingly alpha-to-one
|
|
|
|
|
* applies to all render targets. Piglit
|
|
|
|
|
* ext_framebuffer_multisample-draw-buffers-alpha-to-one checks this.
|
|
|
|
|
*
|
|
|
|
|
* Even more confusingly, it seems to apply to dual-source blending too.
|
|
|
|
|
* ext_framebuffer_multisample-alpha-to-one-dual-src-blend checks this.
|
|
|
|
|
*/
|
|
|
|
|
nir_io_semantics sem = nir_intrinsic_io_semantics(intr);
|
|
|
|
|
if (sem.location < FRAG_RESULT_DATA0)
|
|
|
|
|
continue;
|
|
|
|
|
|
2023-08-12 16:17:15 -04:00
|
|
|
nir_def *rgba = intr->src[0].ssa;
|
2023-05-25 13:22:45 -04:00
|
|
|
if (rgba->num_components < 4)
|
|
|
|
|
continue;
|
|
|
|
|
|
2023-07-04 22:24:28 -04:00
|
|
|
nir_builder b = nir_builder_at(nir_before_instr(instr));
|
2023-08-12 16:17:15 -04:00
|
|
|
nir_def *rgb1 = nir_vector_insert_imm(
|
2023-07-04 22:24:28 -04:00
|
|
|
&b, rgba, nir_imm_floatN_t(&b, 1.0, rgba->bit_size), 3);
|
2023-05-25 13:22:45 -04:00
|
|
|
|
2023-08-17 15:44:47 -05:00
|
|
|
nir_src_rewrite(&intr->src[0], rgb1);
|
2024-01-09 15:50:27 -04:00
|
|
|
progress = true;
|
2023-05-25 13:22:45 -04:00
|
|
|
}
|
2024-01-09 15:50:27 -04:00
|
|
|
|
treewide: Switch to nir_progress
Via the Coccinelle patch at the end of the commit message, followed by
sed -ie 's/progress = progress | /progress |=/g' $(git grep -l 'progress = prog')
ninja -C ~/mesa/build clang-format
cd ~/mesa/src/compiler/nir && clang-format -i *.c
agxfmt
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
-return prog;
+return nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-return true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-return false;
-}
+bool progress = prog_expr;
+return nir_progress(progress, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, prog ? (metadata) : nir_metadata_all);
-return prog;
+return nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, prog ? (metadata) : nir_metadata_all);
+nir_progress(prog, impl, metadata);
@@
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
-return true;
+return nir_progress(true, impl, metadata);
@@
expression impl;
@@
-nir_metadata_preserve(impl, nir_metadata_all);
-return false;
+return nir_no_progress(impl);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
-other_prog |= prog;
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+nir_progress(prog, impl, metadata);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-other_prog = true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
identifier prog;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-prog = true;
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+prog = prog | nir_progress(impl_progress, impl, metadata);
@@
identifier other_prog, prog;
expression impl, metadata;
@@
-if (prog) {
-other_prog = true;
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+other_prog = other_prog | nir_progress(prog, impl, metadata);
@@
expression prog_expr, impl, metadata;
identifier prog;
@@
-if (prog_expr) {
-prog = true;
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+prog = prog | nir_progress(impl_progress, impl, metadata);
@@
expression prog_expr, impl, metadata;
@@
-if (prog_expr) {
-nir_metadata_preserve(impl, metadata);
-} else {
-nir_metadata_preserve(impl, nir_metadata_all);
-}
+bool impl_progress = prog_expr;
+nir_progress(impl_progress, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
-prog = true;
+prog = nir_progress(true, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-}
-return prog;
+return nir_progress(prog, impl, metadata);
@@
identifier prog;
expression impl, metadata;
@@
-if (prog) {
-nir_metadata_preserve(impl, metadata);
-}
+nir_progress(prog, impl, metadata);
@@
expression impl;
@@
-nir_metadata_preserve(impl, nir_metadata_all);
+nir_no_progress(impl);
@@
expression impl, metadata;
@@
-nir_metadata_preserve(impl, metadata);
+nir_progress(true, impl, metadata);
squashme! sed -ie 's/progress = progress | /progress |=/g' $(git grep -l 'progress = prog')
Signed-off-by: Alyssa Rosenzweig <alyssa@rosenzweig.io>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Acked-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/33722>
2025-02-24 15:10:33 -05:00
|
|
|
return nir_progress(progress, impl, nir_metadata_control_flow);
|
2023-05-25 13:22:45 -04:00
|
|
|
}
|