ac,radeonsi: fix load_first_vertex
GL doesn't use it, so this change is not necessary, but it's better this way. There is also a small cleanup using si_unpack_param. Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7721>
This commit is contained in:
@@ -3316,7 +3316,8 @@ static void visit_intrinsic(struct ac_nir_context *ctx, nir_intrinsic_instr *ins
|
|||||||
}
|
}
|
||||||
case nir_intrinsic_load_base_vertex:
|
case nir_intrinsic_load_base_vertex:
|
||||||
case nir_intrinsic_load_first_vertex:
|
case nir_intrinsic_load_first_vertex:
|
||||||
result = ctx->abi->load_base_vertex(ctx->abi);
|
result = ctx->abi->load_base_vertex(ctx->abi,
|
||||||
|
instr->intrinsic == nir_intrinsic_load_base_vertex);
|
||||||
break;
|
break;
|
||||||
case nir_intrinsic_load_local_group_size:
|
case nir_intrinsic_load_local_group_size:
|
||||||
result = ctx->abi->load_local_group_size(ctx->abi);
|
result = ctx->abi->load_local_group_size(ctx->abi);
|
||||||
|
@@ -145,7 +145,7 @@ struct ac_shader_abi {
|
|||||||
|
|
||||||
LLVMValueRef (*load_sample_mask_in)(struct ac_shader_abi *abi);
|
LLVMValueRef (*load_sample_mask_in)(struct ac_shader_abi *abi);
|
||||||
|
|
||||||
LLVMValueRef (*load_base_vertex)(struct ac_shader_abi *abi);
|
LLVMValueRef (*load_base_vertex)(struct ac_shader_abi *abi, bool non_indexed_is_zero);
|
||||||
|
|
||||||
LLVMValueRef (*emit_fbfetch)(struct ac_shader_abi *abi);
|
LLVMValueRef (*emit_fbfetch)(struct ac_shader_abi *abi);
|
||||||
|
|
||||||
|
@@ -863,7 +863,7 @@ load_patch_vertices_in(struct ac_shader_abi *abi)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static LLVMValueRef radv_load_base_vertex(struct ac_shader_abi *abi)
|
static LLVMValueRef radv_load_base_vertex(struct ac_shader_abi *abi, bool non_indexed_is_zero)
|
||||||
{
|
{
|
||||||
struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
|
struct radv_shader_context *ctx = radv_shader_context_from_abi(abi);
|
||||||
return ac_get_arg(&ctx->ac, ctx->args->ac.base_vertex);
|
return ac_get_arg(&ctx->ac, ctx->args->ac.base_vertex);
|
||||||
|
@@ -1054,18 +1054,19 @@ void si_llvm_build_vs_prolog(struct si_shader_context *ctx, union si_shader_part
|
|||||||
si_llvm_build_ret(ctx, ret);
|
si_llvm_build_ret(ctx, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
static LLVMValueRef get_base_vertex(struct ac_shader_abi *abi)
|
static LLVMValueRef get_base_vertex(struct ac_shader_abi *abi, bool non_indexed_is_zero)
|
||||||
{
|
{
|
||||||
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
|
struct si_shader_context *ctx = si_shader_context_from_abi(abi);
|
||||||
|
|
||||||
|
/* This doesn't happen with GL: */
|
||||||
|
if (!non_indexed_is_zero)
|
||||||
|
return ac_get_arg(&ctx->ac, ctx->args.base_vertex);
|
||||||
|
|
||||||
/* For non-indexed draws, the base vertex set by the driver
|
/* For non-indexed draws, the base vertex set by the driver
|
||||||
* (for direct draws) or the CP (for indirect draws) is the
|
* (for direct draws) or the CP (for indirect draws) is the
|
||||||
* first vertex ID, but GLSL expects 0 to be returned.
|
* first vertex ID, but GLSL expects 0 to be returned.
|
||||||
*/
|
*/
|
||||||
LLVMValueRef vs_state = ac_get_arg(&ctx->ac, ctx->vs_state_bits);
|
LLVMValueRef indexed = si_unpack_param(ctx, ctx->vs_state_bits, 1, 1);
|
||||||
LLVMValueRef indexed;
|
|
||||||
|
|
||||||
indexed = LLVMBuildLShr(ctx->ac.builder, vs_state, ctx->ac.i32_1, "");
|
|
||||||
indexed = LLVMBuildTrunc(ctx->ac.builder, indexed, ctx->ac.i1, "");
|
indexed = LLVMBuildTrunc(ctx->ac.builder, indexed, ctx->ac.i1, "");
|
||||||
|
|
||||||
return LLVMBuildSelect(ctx->ac.builder, indexed, ac_get_arg(&ctx->ac, ctx->args.base_vertex),
|
return LLVMBuildSelect(ctx->ac.builder, indexed, ac_get_arg(&ctx->ac, ctx->args.base_vertex),
|
||||||
|
Reference in New Issue
Block a user