mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-24 21:50:12 +01:00
Merge branch 'dev/nir_lower_null_descriptors' into 'main'
nir: commonize lower_null_descriptors pass See merge request mesa/mesa!37659
This commit is contained in:
commit
b1289926e6
6 changed files with 36 additions and 31 deletions
|
|
@ -201,6 +201,7 @@ else
|
||||||
'nir_lower_memcpy.c',
|
'nir_lower_memcpy.c',
|
||||||
'nir_lower_memory_model.c',
|
'nir_lower_memory_model.c',
|
||||||
'nir_lower_non_uniform_access.c',
|
'nir_lower_non_uniform_access.c',
|
||||||
|
'nir_lower_null_descriptors.c',
|
||||||
'nir_lower_packing.c',
|
'nir_lower_packing.c',
|
||||||
'nir_lower_passthrough_edgeflags.c',
|
'nir_lower_passthrough_edgeflags.c',
|
||||||
'nir_lower_patch_vertices.c',
|
'nir_lower_patch_vertices.c',
|
||||||
|
|
|
||||||
|
|
@ -6946,6 +6946,18 @@ bool nir_unlower_io_to_vars(nir_shader *nir, bool keep_intrinsics);
|
||||||
|
|
||||||
bool nir_opt_barycentric(nir_shader *shader, bool lower_sample_to_pos);
|
bool nir_opt_barycentric(nir_shader *shader, bool lower_sample_to_pos);
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
nir_lower_null_descriptor_ubo = BITFIELD_BIT(0),
|
||||||
|
nir_lower_null_descriptor_ssbo = BITFIELD_BIT(1),
|
||||||
|
nir_lower_null_descriptor_global = BITFIELD_BIT(2),
|
||||||
|
nir_lower_null_descriptor_texture = BITFIELD_BIT(3),
|
||||||
|
nir_lower_null_descriptor_image = BITFIELD_BIT(4),
|
||||||
|
|
||||||
|
nir_lower_null_descriptor_all = BITFIELD_MASK(5),
|
||||||
|
} nir_lower_null_descriptor_options;
|
||||||
|
|
||||||
|
bool nir_lower_null_descriptors(nir_shader *shader, nir_lower_null_descriptor_options options);
|
||||||
|
|
||||||
#include "nir_inline_helpers.h"
|
#include "nir_inline_helpers.h"
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
||||||
|
|
@ -8,12 +8,17 @@
|
||||||
|
|
||||||
#include "compiler/nir/nir.h"
|
#include "compiler/nir/nir.h"
|
||||||
#include "compiler/nir/nir_builder.h"
|
#include "compiler/nir/nir_builder.h"
|
||||||
#include "pco_internal.h"
|
|
||||||
|
|
||||||
static nir_def *get_is_null(nir_builder *b,
|
/* This pass provides a primitive implementation of VK_EXT_robustness2's
|
||||||
nir_instr *instr,
|
* nullDescriptor feature for hardware that lacks native support for it, by
|
||||||
nir_def **def,
|
* wrapping the selected descriptor access in control flow.
|
||||||
pco_nir_lower_null_descriptor_options options)
|
*/
|
||||||
|
|
||||||
|
static nir_def *
|
||||||
|
get_is_null(nir_builder *b,
|
||||||
|
nir_instr *instr,
|
||||||
|
nir_def **def,
|
||||||
|
nir_lower_null_descriptor_options options)
|
||||||
{
|
{
|
||||||
bool is_deref = false;
|
bool is_deref = false;
|
||||||
*def = NULL;
|
*def = NULL;
|
||||||
|
|
@ -28,7 +33,7 @@ static nir_def *get_is_null(nir_builder *b,
|
||||||
case nir_intrinsic_image_deref_store:
|
case nir_intrinsic_image_deref_store:
|
||||||
case nir_intrinsic_image_deref_atomic:
|
case nir_intrinsic_image_deref_atomic:
|
||||||
case nir_intrinsic_image_deref_atomic_swap:
|
case nir_intrinsic_image_deref_atomic_swap:
|
||||||
if (!(options & pco_nir_lower_null_descriptor_image))
|
if (!(options & nir_lower_null_descriptor_image))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
is_deref = true;
|
is_deref = true;
|
||||||
|
|
@ -43,14 +48,14 @@ static nir_def *get_is_null(nir_builder *b,
|
||||||
case nir_intrinsic_global_atomic_swap_2x32:
|
case nir_intrinsic_global_atomic_swap_2x32:
|
||||||
case nir_intrinsic_store_global:
|
case nir_intrinsic_store_global:
|
||||||
case nir_intrinsic_store_global_2x32:
|
case nir_intrinsic_store_global_2x32:
|
||||||
if (!(options & pco_nir_lower_null_descriptor_global))
|
if (!(options & nir_lower_null_descriptor_global))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nir_intrinsic_get_ubo_size:
|
case nir_intrinsic_get_ubo_size:
|
||||||
case nir_intrinsic_load_ubo:
|
case nir_intrinsic_load_ubo:
|
||||||
if (!(options & pco_nir_lower_null_descriptor_ubo))
|
if (!(options & nir_lower_null_descriptor_ubo))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -60,7 +65,7 @@ static nir_def *get_is_null(nir_builder *b,
|
||||||
case nir_intrinsic_ssbo_atomic:
|
case nir_intrinsic_ssbo_atomic:
|
||||||
case nir_intrinsic_ssbo_atomic_swap:
|
case nir_intrinsic_ssbo_atomic_swap:
|
||||||
case nir_intrinsic_store_ssbo:
|
case nir_intrinsic_store_ssbo:
|
||||||
if (!(options & pco_nir_lower_null_descriptor_ssbo))
|
if (!(options & nir_lower_null_descriptor_ssbo))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
@ -80,7 +85,7 @@ static nir_def *get_is_null(nir_builder *b,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (instr->type == nir_instr_type_tex) {
|
if (instr->type == nir_instr_type_tex) {
|
||||||
if (!(options & pco_nir_lower_null_descriptor_texture))
|
if (!(options & nir_lower_null_descriptor_texture))
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
nir_tex_instr *tex = nir_instr_as_tex(instr);
|
nir_tex_instr *tex = nir_instr_as_tex(instr);
|
||||||
|
|
@ -95,9 +100,10 @@ static nir_def *get_is_null(nir_builder *b,
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool lower(nir_builder *b, nir_instr *instr, void *data)
|
static bool
|
||||||
|
lower(nir_builder *b, nir_instr *instr, void *data)
|
||||||
{
|
{
|
||||||
pco_nir_lower_null_descriptor_options *options = data;
|
nir_lower_null_descriptor_options *options = data;
|
||||||
b->cursor = nir_before_instr(instr);
|
b->cursor = nir_before_instr(instr);
|
||||||
|
|
||||||
nir_def *def;
|
nir_def *def;
|
||||||
|
|
@ -134,9 +140,10 @@ static bool lower(nir_builder *b, nir_instr *instr, void *data)
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool pco_nir_lower_null_descriptors(
|
bool
|
||||||
|
nir_lower_null_descriptors(
|
||||||
nir_shader *shader,
|
nir_shader *shader,
|
||||||
pco_nir_lower_null_descriptor_options options)
|
nir_lower_null_descriptor_options options)
|
||||||
{
|
{
|
||||||
return nir_shader_instructions_pass(shader,
|
return nir_shader_instructions_pass(shader,
|
||||||
lower,
|
lower,
|
||||||
|
|
@ -18,7 +18,6 @@ libpowervr_compiler_files = files(
|
||||||
'pco_nir.c',
|
'pco_nir.c',
|
||||||
'pco_nir_compute.c',
|
'pco_nir_compute.c',
|
||||||
'pco_nir_io.c',
|
'pco_nir_io.c',
|
||||||
'pco_nir_lower_null_descriptors.c',
|
|
||||||
'pco_nir_pvfio.c',
|
'pco_nir_pvfio.c',
|
||||||
'pco_nir_sync.c',
|
'pco_nir_sync.c',
|
||||||
'pco_nir_tex.c',
|
'pco_nir_tex.c',
|
||||||
|
|
|
||||||
|
|
@ -1782,20 +1782,6 @@ bool pco_ra(pco_shader *shader);
|
||||||
bool pco_schedule(pco_shader *shader);
|
bool pco_schedule(pco_shader *shader);
|
||||||
bool pco_shrink_vecs(pco_shader *shader);
|
bool pco_shrink_vecs(pco_shader *shader);
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
pco_nir_lower_null_descriptor_ubo = (1 << 0),
|
|
||||||
pco_nir_lower_null_descriptor_ssbo = (1 << 1),
|
|
||||||
pco_nir_lower_null_descriptor_global = (1 << 2),
|
|
||||||
pco_nir_lower_null_descriptor_texture = (1 << 3),
|
|
||||||
pco_nir_lower_null_descriptor_image = (1 << 4),
|
|
||||||
|
|
||||||
pco_nir_lower_null_descriptor_all = BITFIELD_MASK(5),
|
|
||||||
} pco_nir_lower_null_descriptor_options;
|
|
||||||
|
|
||||||
bool pco_nir_lower_null_descriptors(
|
|
||||||
nir_shader *shader,
|
|
||||||
pco_nir_lower_null_descriptor_options options);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Returns the PCO bits for a bit size.
|
* \brief Returns the PCO bits for a bit size.
|
||||||
*
|
*
|
||||||
|
|
|
||||||
|
|
@ -858,8 +858,8 @@ void pco_lower_nir(pco_ctx *ctx, nir_shader *nir, pco_data *data)
|
||||||
if (data->common.null_descriptor) {
|
if (data->common.null_descriptor) {
|
||||||
NIR_PASS(_,
|
NIR_PASS(_,
|
||||||
nir,
|
nir,
|
||||||
pco_nir_lower_null_descriptors,
|
nir_lower_null_descriptors,
|
||||||
pco_nir_lower_null_descriptor_all);
|
nir_lower_null_descriptor_all);
|
||||||
}
|
}
|
||||||
|
|
||||||
NIR_PASS(_, nir, pco_nir_lower_vk, data);
|
NIR_PASS(_, nir, pco_nir_lower_vk, data);
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue