{
nir_builder b;
char name[64];
- const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_MS,
false,
input_img->data.descriptor_set = 0;
input_img->data.binding = 0;
- nir_variable *fs_pos_in = nir_variable_create(b.shader, nir_var_shader_in, vec2, "fs_pos_in");
- fs_pos_in->data.location = VARYING_SLOT_POS;
-
nir_variable *color_out = nir_variable_create(b.shader, nir_var_shader_out,
vec4, "f_color");
color_out->data.location = FRAG_RESULT_DATA0;
- nir_ssa_def *pos_in = nir_load_var(&b, fs_pos_in);
+ nir_ssa_def *pos_in = nir_channels(&b, nir_load_frag_coord(&b), 0x3);
nir_intrinsic_instr *src_offset = nir_intrinsic_instr_create(b.shader, nir_intrinsic_load_push_constant);
nir_intrinsic_set_base(src_offset, 0);
nir_intrinsic_set_range(src_offset, 8);
{
nir_builder b;
char name[64];
- const struct glsl_type *vec2 = glsl_vector_type(GLSL_TYPE_FLOAT, 2);
const struct glsl_type *vec4 = glsl_vec4_type();
const struct glsl_type *sampler_type = glsl_sampler_type(GLSL_SAMPLER_DIM_2D,
false,
input_img->data.descriptor_set = 0;
input_img->data.binding = 0;
- nir_variable *fs_pos_in = nir_variable_create(b.shader, nir_var_shader_in, vec2, "fs_pos_in");
- fs_pos_in->data.location = VARYING_SLOT_POS;
-
nir_variable *fs_out = nir_variable_create(b.shader,
nir_var_shader_out, vec4,
"f_out");
fs_out->data.location =
index == DEPTH_RESOLVE ? FRAG_RESULT_DEPTH : FRAG_RESULT_STENCIL;
- nir_ssa_def *pos_in = nir_load_var(&b, fs_pos_in);
+ nir_ssa_def *pos_in = nir_channels(&b, nir_load_frag_coord(&b), 0x3);
nir_intrinsic_instr *src_offset = nir_intrinsic_instr_create(b.shader, nir_intrinsic_load_push_constant);
nir_intrinsic_set_base(src_offset, 0);
ctx->abi.prim_mask, false, inputs);
++index;
}
- } else if (i == VARYING_SLOT_POS) {
- for(int i = 0; i < 3; ++i)
- inputs[i] = ctx->abi.frag_pos[i];
-
- inputs[3] = ac_build_fdiv(&ctx->ac, ctx->ac.f32_1,
- ctx->abi.frag_pos[3]);
}
}
ctx->shader_info->fs.num_interp = index;
.phys_ssbo_addr_format = nir_address_format_64bit_global,
.push_const_addr_format = nir_address_format_logical,
.shared_addr_format = nir_address_format_32bit_offset,
+ .frag_coord_is_sysval = true,
};
nir = spirv_to_nir(spirv, module->size / 4,
spec_entries, num_spec_entries,
NIR_PASS_V(nir, nir_split_per_member_structs);
if (nir->info.stage == MESA_SHADER_FRAGMENT)
- NIR_PASS_V(nir, nir_lower_input_attachments);
+ NIR_PASS_V(nir, nir_lower_input_attachments, true);
NIR_PASS_V(nir, nir_remove_dead_variables,
nir_var_shader_in | nir_var_shader_out | nir_var_system_value);
bool nir_lower_idiv(nir_shader *shader);
-bool nir_lower_input_attachments(nir_shader *shader);
+bool nir_lower_input_attachments(nir_shader *shader, bool use_fragcoord_sysval);
bool nir_lower_clip_vs(nir_shader *shader, unsigned ucp_enables, bool use_vars);
bool nir_lower_clip_fs(nir_shader *shader, unsigned ucp_enables);
}
static bool
-try_lower_input_load(nir_function_impl *impl, nir_intrinsic_instr *load)
+try_lower_input_load(nir_function_impl *impl, nir_intrinsic_instr *load,
+ bool use_fragcoord_sysval)
{
nir_deref_instr *deref = nir_src_as_deref(load->src[0]);
assert(glsl_type_is_image(deref->type));
nir_builder_init(&b, impl);
b.cursor = nir_instr_remove(&load->instr);
- nir_ssa_def *frag_coord = nir_f2i32(&b, load_frag_coord(&b));
+ nir_ssa_def *frag_coord = use_fragcoord_sysval ? nir_load_frag_coord(&b)
+ : load_frag_coord(&b);
+ frag_coord = nir_f2i32(&b, frag_coord);
nir_ssa_def *offset = nir_ssa_for_src(&b, load->src[1], 2);
nir_ssa_def *pos = nir_iadd(&b, frag_coord, offset);
}
bool
-nir_lower_input_attachments(nir_shader *shader)
+nir_lower_input_attachments(nir_shader *shader, bool use_fragcoord_sysval)
{
assert(shader->info.stage == MESA_SHADER_FRAGMENT);
bool progress = false;
if (load->intrinsic != nir_intrinsic_image_deref_load)
continue;
- progress |= try_lower_input_load(function->impl, load);
+ progress |= try_lower_input_load(function->impl, load,
+ use_fragcoord_sysval);
}
}
}
if (nir->info.stage == MESA_SHADER_FRAGMENT) {
NIR_PASS_V(nir, nir_lower_wpos_center, pipeline->sample_shading_enable);
- NIR_PASS_V(nir, nir_lower_input_attachments);
+ NIR_PASS_V(nir, nir_lower_input_attachments, false);
}
NIR_PASS_V(nir, anv_nir_lower_ycbcr_textures, layout);