{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_atomic_counter_derefs);
+
nir_foreach_function(function, shader) {
if (!function->impl)
continue;
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_texture_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress |= lower_impl(function->impl, shader_program,
bool progress = false;
struct lower_samplers_as_deref_state state;
+ nir_assert_lowered_derefs(shader, nir_lower_texture_derefs);
+
state.shader = shader;
state.shader_program = shader_program;
state.remap_table = _mesa_hash_table_create(NULL, _mesa_key_hash_string,
shader->num_outputs = 0;
shader->num_uniforms = 0;
shader->num_shared = 0;
+ shader->lowered_derefs = 0;
return shader;
}
* access plus one
*/
unsigned num_inputs, num_uniforms, num_outputs, num_shared;
+
+ /* temporary, tracking for which derefs instructions have been lowered
+ * to deref chains
+ */
+ unsigned lowered_derefs;
} nir_shader;
+#define nir_assert_lowered_derefs(shader, mask) \
+ assert(((shader)->lowered_derefs & (mask)) == (mask))
+
+#define nir_assert_unlowered_derefs(shader, mask) \
+ assert(!((shader)->lowered_derefs & (mask)))
+
static inline nir_function_impl *
nir_shader_get_entrypoint(nir_shader *shader)
{
nir_lower_atomic_counter_derefs = (1 << 3),
nir_lower_atomic_derefs = (1 << 4),
nir_lower_image_derefs = (1 << 5),
+ nir_lower_all_derefs = (1 << 6) - 1,
};
bool nir_lower_deref_instrs(nir_shader *shader,
ns->num_uniforms = s->num_uniforms;
ns->num_outputs = s->num_outputs;
ns->num_shared = s->num_shared;
+ ns->lowered_derefs = s->lowered_derefs;
free_clone_state(&state);
progress |= nir_lower_deref_instrs_impl(function->impl, flags);
}
+ shader->lowered_derefs |= flags;
+
return progress;
}
void
nir_shader_gather_info(nir_shader *shader, nir_function_impl *entrypoint)
{
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs);
+
shader->info.num_textures = 0;
shader->info.num_images = 0;
nir_foreach_variable(var, &shader->uniforms) {
{
assert(producer->info.stage != MESA_SHADER_FRAGMENT);
assert(consumer->info.stage != MESA_SHADER_VERTEX);
+ nir_assert_lowered_derefs(producer, nir_lower_load_store_derefs);
+ nir_assert_lowered_derefs(consumer, nir_lower_load_store_derefs);
uint64_t read[4] = { 0 }, written[4] = { 0 };
uint64_t patches_read[4] = { 0 }, patches_written[4] = { 0 };
nir_loop_analyze_impl(nir_function_impl *impl,
nir_variable_mode indirect_mask)
{
+ nir_assert_lowered_derefs(impl->function->shader, nir_lower_load_store_derefs);
nir_index_ssa_defs(impl);
foreach_list_typed(nir_cf_node, node, node, &impl->body)
process_loops(node, indirect_mask);
{
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
nir_function_impl *impl = function->impl;
nir_builder b;
.shader = shader,
};
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress |= lower_impl(&state, function->impl);
{
bool progress = false;
+ nir_assert_lowered_derefs(nir, nir_lower_load_store_derefs);
+
if (nir->info.stage <= MESA_SHADER_GEOMETRY)
progress |= combine_clip_cull(nir, &nir->outputs, true);
.shader = shader,
};
+ /* note that this pass already assumes texture/sampler derefs are already
+ * lowered to index
+ */
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
nir_foreach_function(function, shader) {
_mesa_hash_table_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs |
+ nir_lower_atomic_counter_derefs | nir_lower_atomic_derefs | nir_lower_image_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl) {
nir_foreach_block(block, function->impl)
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress = lower_indirects_impl(function->impl, modes) || progress;
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs | nir_lower_atomic_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl) {
progress |= nir_lower_io_impl(function->impl, modes,
_mesa_hash_table_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs);
+
uint64_t indirects[4] = {0}, patch_indirects[4] = {0};
lower_io_arrays_to_elements(shader, nir_var_shader_out, indirects,
_mesa_hash_table_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
+ nir_assert_lowered_derefs(producer, nir_lower_load_store_derefs | nir_lower_interp_derefs);
+ nir_assert_lowered_derefs(consumer, nir_lower_load_store_derefs | nir_lower_interp_derefs);
+
uint64_t indirects[4] = {0}, patch_indirects[4] = {0};
create_indirects_mask(producer, indirects, patch_indirects,
nir_var_shader_out);
_mesa_hash_table_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs | nir_lower_interp_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl) {
nir_builder b;
{
struct lower_io_types_state state;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
state.shader = shader;
exec_list_make_empty(&state.new_ins);
exec_list_make_empty(&state.new_outs);
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress = nir_lower_locals_to_regs_impl(function->impl) || progress;
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress = lower_phis_to_scalar_impl(function->impl) || progress;
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress = convert_impl(function->impl) || progress;
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_texture_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress |= nir_lower_tex_impl(function->impl, options);
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress |= lower_var_copies_impl(function->impl);
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress |= nir_lower_vars_to_ssa_impl(function->impl);
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl) {
nir_builder_init(&b, function->impl);
.shader = shader,
};
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
nir_foreach_function(function, shader) {
{
struct copy_prop_var_state state;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
state.shader = shader;
state.mem_ctx = ralloc_context(NULL);
list_inithead(&state.copies);
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress |= nir_opt_peephole_select_impl(function->impl, limit);
nir_builder b;
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl) {
nir_builder_init(&b, function->impl);
struct set *invariants = _mesa_set_create(NULL, _mesa_hash_pointer,
_mesa_key_pointer_equal);
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
bool progress = false;
nir_foreach_function(function, shader) {
if (function->impl && propagate_invariant_impl(function->impl, invariants))
struct set *live =
_mesa_set_create(NULL, _mesa_hash_pointer, _mesa_key_pointer_equal);
+ nir_assert_lowered_derefs(shader, nir_lower_all_derefs);
+
add_var_use_shader(shader, live, modes);
if (modes & nir_var_uniform)
blob_write_uint32(blob, nir->num_uniforms);
blob_write_uint32(blob, nir->num_outputs);
blob_write_uint32(blob, nir->num_shared);
+ blob_write_uint32(blob, nir->lowered_derefs);
blob_write_uint32(blob, exec_list_length(&nir->functions));
nir_foreach_function(fxn, nir) {
ctx.nir->num_uniforms = blob_read_uint32(blob);
ctx.nir->num_outputs = blob_read_uint32(blob);
ctx.nir->num_shared = blob_read_uint32(blob);
+ ctx.nir->lowered_derefs = blob_read_uint32(blob);
unsigned num_functions = blob_read_uint32(blob);
for (unsigned i = 0; i < num_functions; i++)
{
bool progress = false;
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
+
nir_foreach_function(function, shader) {
if (function->impl)
progress = split_var_copies_impl(function->impl) || progress;
void
st_nir_lower_builtin(nir_shader *shader)
{
+ nir_assert_lowered_derefs(shader, nir_lower_load_store_derefs);
lower_builtin_state state;
state.shader = shader;
nir_foreach_function(function, shader) {