From 5a710d608adc43d7dc837aecddc6400785615db3 Mon Sep 17 00:00:00 2001 From: Samuel Pitoiset Date: Wed, 29 Aug 2018 15:49:27 +0200 Subject: [PATCH] fix v2 Signed-off-by: Samuel Pitoiset --- src/amd/vulkan/radv_nir_to_llvm.c | 23 +++++++++++++++++++++-- src/amd/vulkan/radv_shader_info.c | 7 +++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/amd/vulkan/radv_nir_to_llvm.c b/src/amd/vulkan/radv_nir_to_llvm.c index 4940e3230f..e0b70a1fb4 100644 --- a/src/amd/vulkan/radv_nir_to_llvm.c +++ b/src/amd/vulkan/radv_nir_to_llvm.c @@ -2098,9 +2098,10 @@ handle_fs_input_decl(struct radv_shader_context *ctx, int idx = variable->data.location; unsigned attrib_count = glsl_count_attribute_slots(variable->type, false); LLVMValueRef interp = NULL; + uint64_t mask; variable->data.driver_location = idx * 4; - ctx->input_mask |= ((1ull << attrib_count) - 1) << variable->data.location; + mask = ((1ull << attrib_count) - 1) << variable->data.location; if (glsl_get_base_type(glsl_without_array(variable->type)) == GLSL_TYPE_FLOAT) { unsigned interp_type; @@ -2121,6 +2122,14 @@ handle_fs_input_decl(struct radv_shader_context *ctx, for (unsigned i = 0; i < attrib_count; ++i) ctx->inputs[ac_llvm_reg_index_soa(idx + i, 0)] = interp; + if (idx == VARYING_SLOT_CLIP_DIST0) { + /* Do not account for the number of attribute slots because + * we only want to know if clip distances are present. + */ + mask = 1ull << VARYING_SLOT_CLIP_DIST0; + } + + ctx->input_mask |= mask; } static void @@ -2179,7 +2188,8 @@ handle_fs_inputs(struct radv_shader_context *ctx, continue; if (i >= VARYING_SLOT_VAR0 || i == VARYING_SLOT_PNTC || - i == VARYING_SLOT_PRIMITIVE_ID || i == VARYING_SLOT_LAYER) { + i == VARYING_SLOT_PRIMITIVE_ID || i == VARYING_SLOT_LAYER || + i == VARYING_SLOT_CLIP_DIST0) { interp_param = *inputs; interp_fs_input(ctx, index, interp_param, ctx->abi.prim_mask, inputs); @@ -2569,6 +2579,7 @@ handle_vs_outputs_post(struct radv_shader_context *ctx, if (i != VARYING_SLOT_LAYER && i != VARYING_SLOT_PRIMITIVE_ID && + i != VARYING_SLOT_CLIP_DIST0 && i < VARYING_SLOT_VAR0) continue; @@ -2590,6 +2601,14 @@ handle_vs_outputs_post(struct radv_shader_context *ctx, ctx->shader_info->info.gs.output_usage_mask[i]; } + if (i == VARYING_SLOT_CLIP_DIST0) { + /* The output usage mask is wrong for clip distances. + * Use all channels. */ + output_usage_mask = 0xf; + } + + output_usage_mask = 0xf; /* WTF???? */ + radv_export_param(ctx, param_count, values, output_usage_mask); outinfo->vs_output_param_offset[i] = param_count++; diff --git a/src/amd/vulkan/radv_shader_info.c b/src/amd/vulkan/radv_shader_info.c index 8026cca46c..1608318120 100644 --- a/src/amd/vulkan/radv_shader_info.c +++ b/src/amd/vulkan/radv_shader_info.c @@ -127,6 +127,13 @@ gather_intrinsic_store_deref_info(const nir_shader *nir, unsigned comp = var->data.location_frac; unsigned const_offset = 0; + if (idx == VARYING_SLOT_CLIP_DIST0) { + /* Gathering the output usage mask for clip distances + * is currently broken, we will always use 0xf. + */ + return; + } + get_deref_offset(nir_instr_as_deref(instr->src[0].ssa->parent_instr), &const_offset); switch (nir->info.stage) { -- 2.18.0