Commit 6d03a7f8 authored by Jesse Natalie's avatar Jesse Natalie Committed by Erik Faye-Lund

microsoft/clc: Deal with kernel inputs as uniforms instead of shader_in

parent 80351602
...@@ -360,44 +360,6 @@ clc_lower_input_image_deref(nir_builder *b, struct clc_image_lower_context *cont ...@@ -360,44 +360,6 @@ clc_lower_input_image_deref(nir_builder *b, struct clc_image_lower_context *cont
static void static void
clc_lower_images(nir_shader *nir, struct clc_image_lower_context *context) clc_lower_images(nir_shader *nir, struct clc_image_lower_context *context)
{ {
/* We'll do this in three steps:
* 1. Change the deref mode for derefs of images/samplers to uniform.
* 2. Run nir_opt_deref to remove casts, now that the deref modes match
* 3. We should have unbroken deref chains from variables to their loads/stores,
* so follow those chains and adjust the variables to something saner.
*/
nir_foreach_function(func, nir) {
if (!func->is_entrypoint)
continue;
assert(func->impl);
nir_builder b;
nir_builder_init(&b, func->impl);
nir_foreach_block(block, func->impl) {
nir_foreach_instr_safe(instr, block) {
if (instr->type == nir_instr_type_deref) {
context->deref = nir_instr_as_deref(instr);
if (context->deref->mode == nir_var_shader_in &&
(glsl_type_is_image(context->deref->type) ||
glsl_type_is_sampler(context->deref->type))) {
assert(context->deref->deref_type == nir_deref_type_var);
context->deref->mode = nir_var_uniform;
nir_variable *var = nir_deref_instr_get_variable(context->deref);
var->data.mode = nir_var_uniform;
exec_node_remove(&var->node);
nir_shader_add_variable(nir, var);
}
}
}
}
}
nir_opt_deref(nir);
nir_foreach_function(func, nir) { nir_foreach_function(func, nir) {
if (!func->is_entrypoint) if (!func->is_entrypoint)
continue; continue;
...@@ -1267,7 +1229,7 @@ clc_to_dxil(struct clc_context *ctx, ...@@ -1267,7 +1229,7 @@ clc_to_dxil(struct clc_context *ctx,
// Calculate input offsets/metadata. // Calculate input offsets/metadata.
unsigned uav_id = 0, sampler_id = 0, offset = 0; unsigned uav_id = 0, sampler_id = 0, offset = 0;
dxil_wrap_sampler_state int_sampler_states[PIPE_MAX_SHADER_SAMPLER_VIEWS] = {{{0}}}; dxil_wrap_sampler_state int_sampler_states[PIPE_MAX_SHADER_SAMPLER_VIEWS] = {{{0}}};
nir_foreach_variable(var, &nir->inputs) { nir_foreach_variable(var, &nir->uniforms) {
int i = var->data.location; int i = var->data.location;
if (i < 0) if (i < 0)
continue; continue;
...@@ -1301,7 +1263,7 @@ clc_to_dxil(struct clc_context *ctx, ...@@ -1301,7 +1263,7 @@ clc_to_dxil(struct clc_context *ctx,
// Second pass over inputs to calculate image bindings // Second pass over inputs to calculate image bindings
unsigned srv_id = 0; unsigned srv_id = 0;
nir_foreach_variable(var, &nir->inputs) { nir_foreach_variable(var, &nir->uniforms) {
int i = var->data.location; int i = var->data.location;
if (i < 0) if (i < 0)
continue; continue;
...@@ -1418,6 +1380,7 @@ clc_to_dxil(struct clc_context *ctx, ...@@ -1418,6 +1380,7 @@ clc_to_dxil(struct clc_context *ctx,
NIR_PASS_V(nir, nir_lower_vars_to_ssa); NIR_PASS_V(nir, nir_lower_vars_to_ssa);
NIR_PASS_V(nir, nir_lower_alu); NIR_PASS_V(nir, nir_lower_alu);
NIR_PASS_V(nir, nir_opt_dce); NIR_PASS_V(nir, nir_opt_dce);
NIR_PASS_V(nir, nir_opt_deref);
// Needs to come before lower_explicit_io // Needs to come before lower_explicit_io
struct clc_image_lower_context image_lower_context = { metadata, &srv_id, &uav_id }; struct clc_image_lower_context image_lower_context = { metadata, &srv_id, &uav_id };
...@@ -1431,7 +1394,7 @@ clc_to_dxil(struct clc_context *ctx, ...@@ -1431,7 +1394,7 @@ clc_to_dxil(struct clc_context *ctx,
assert(nir->scratch_size == 0); assert(nir->scratch_size == 0);
NIR_PASS_V(nir, nir_lower_vars_to_explicit_types, NIR_PASS_V(nir, nir_lower_vars_to_explicit_types,
nir_var_mem_shared | nir_var_function_temp | nir_var_shader_in | nir_var_mem_global | nir_var_mem_constant, nir_var_mem_shared | nir_var_function_temp | nir_var_uniform | nir_var_mem_global | nir_var_mem_constant,
glsl_get_cl_type_size_align); glsl_get_cl_type_size_align);
NIR_PASS_V(nir, dxil_nir_lower_ubo_to_temp); NIR_PASS_V(nir, dxil_nir_lower_ubo_to_temp);
...@@ -1445,7 +1408,7 @@ clc_to_dxil(struct clc_context *ctx, ...@@ -1445,7 +1408,7 @@ clc_to_dxil(struct clc_context *ctx,
NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_ssbo, NIR_PASS_V(nir, nir_lower_explicit_io, nir_var_mem_ssbo,
nir_address_format_32bit_index_offset_pack64); nir_address_format_32bit_index_offset_pack64);
NIR_PASS_V(nir, nir_lower_explicit_io, NIR_PASS_V(nir, nir_lower_explicit_io,
nir_var_mem_shared | nir_var_function_temp | nir_var_shader_in, nir_var_mem_shared | nir_var_function_temp | nir_var_uniform,
nir_address_format_32bit_offset_as_64bit); nir_address_format_32bit_offset_as_64bit);
NIR_PASS_V(nir, nir_lower_system_values); NIR_PASS_V(nir, nir_lower_system_values);
......
...@@ -396,8 +396,7 @@ clc_nir_dedupe_const_samplers(nir_shader *nir) ...@@ -396,8 +396,7 @@ clc_nir_dedupe_const_samplers(nir_shader *nir)
if (!sampler) if (!sampler)
continue; continue;
assert(sampler->data.mode == nir_var_shader_in || assert(sampler->data.mode == nir_var_uniform);
(sampler->data.mode == nir_var_uniform && sampler->data.sampler.is_inline_sampler));
if (!sampler->data.sampler.is_inline_sampler) if (!sampler->data.sampler.is_inline_sampler)
continue; continue;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment