glsl_to_nir: support conversion of opaque function params

Here we can assume anything that is not an input is bindless.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/27108>
This commit is contained in:
Timothy Arceri 2024-01-18 14:35:28 +11:00
parent de7574f70a
commit c6c150b4cd
2 changed files with 26 additions and 27 deletions

View file

@ -1519,10 +1519,15 @@ nir_visitor::visit(ir_call *ir)
ir_rvalue *param_rvalue = (ir_rvalue *) actual_node; ir_rvalue *param_rvalue = (ir_rvalue *) actual_node;
ir_variable *sig_param = (ir_variable *) formal_node; ir_variable *sig_param = (ir_variable *) formal_node;
nir_deref_instr *param_deref;
if (sig_param->data.mode == ir_var_function_in &&
glsl_contains_opaque(sig_param->type)) {
param_deref = evaluate_deref(param_rvalue);
} else {
nir_variable *param = nir_variable *param =
nir_local_variable_create(this->impl, sig_param->type, "param"); nir_local_variable_create(this->impl, sig_param->type, "param");
param->data.precision = sig_param->data.precision; param->data.precision = sig_param->data.precision;
nir_deref_instr *param_deref = nir_build_deref_var(&b, param); param_deref = nir_build_deref_var(&b, param);
if (sig_param->data.mode == ir_var_function_in || if (sig_param->data.mode == ir_var_function_in ||
sig_param->data.mode == ir_var_function_inout) { sig_param->data.mode == ir_var_function_inout) {
@ -1534,6 +1539,7 @@ nir_visitor::visit(ir_call *ir)
nir_copy_deref(&b, param_deref, evaluate_deref(param_rvalue)); nir_copy_deref(&b, param_deref, evaluate_deref(param_rvalue));
} }
} }
}
call->params[i] = nir_src_for_ssa(&param_deref->def); call->params[i] = nir_src_for_ssa(&param_deref->def);
@ -2381,7 +2387,8 @@ nir_visitor::visit(ir_texture *ir)
/* check for bindless handles */ /* check for bindless handles */
if (!nir_deref_mode_is(sampler_deref, nir_var_uniform) || if (!nir_deref_mode_is(sampler_deref, nir_var_uniform) ||
nir_deref_instr_get_variable(sampler_deref)->data.bindless) { (nir_deref_instr_get_variable(sampler_deref) &&
nir_deref_instr_get_variable(sampler_deref)->data.bindless)) {
nir_def *load = nir_load_deref(&b, sampler_deref); nir_def *load = nir_load_deref(&b, sampler_deref);
instr->src[0] = nir_tex_src_for_ssa(nir_tex_src_texture_handle, load); instr->src[0] = nir_tex_src_for_ssa(nir_tex_src_texture_handle, load);
instr->src[1] = nir_tex_src_for_ssa(nir_tex_src_sampler_handle, load); instr->src[1] = nir_tex_src_for_ssa(nir_tex_src_sampler_handle, load);
@ -2517,8 +2524,13 @@ nir_visitor::visit(ir_dereference_variable *ir)
i++; i++;
} }
nir_variable_mode mode =
glsl_contains_opaque(ir->variable_referenced()->type) &&
ir->variable_referenced()->data.mode == ir_var_function_in ?
nir_var_uniform : nir_var_function_temp;
this->deref = nir_build_deref_cast(&b, nir_load_param(&b, i), this->deref = nir_build_deref_cast(&b, nir_load_param(&b, i),
nir_var_function_temp, ir->type, 0); mode, ir->type, 0);
return; return;
} }

View file

@ -2618,19 +2618,6 @@ public:
unsupported = true; unsupported = true;
return visit_stop; return visit_stop;
} }
/* For opaque types, we want the inlined variable references
* referencing the passed in variable, since that will have
* the location information, which an assignment of an opaque
* variable wouldn't.
*
* We have no way to handle this in NIR or the glsl to nir pass
* currently so let the GLSL IR lowering handle it.
*/
if (glsl_contains_opaque(param->type)) {
unsupported = true;
return visit_stop;
}
} }
return visit_continue; return visit_continue;