Module: Mesa
Branch: master
Commit: 7f914734146a3008dc0e5b185f7ccab44a803bc9
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=7f914734146a3008dc0e5b185f7ccab44a803bc9

Author: Timothy Arceri <tarc...@itsqueeze.com>
Date:   Mon Feb 26 21:59:43 2018 +1100

radeonsi: create get_base_vertex() helper

Reviewed-by: Samuel Pitoiset <samuel.pitoi...@gmail.com>
Reviewed-by: Marek Olšák <marek.ol...@amd.com>

---

 src/gallium/drivers/radeonsi/si_shader.c | 34 +++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 14 deletions(-)

diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index b69c1bbb24..aa9b50a7a2 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -1908,6 +1908,25 @@ static LLVMValueRef get_sample_id(struct 
si_shader_context *ctx)
        return unpack_param(ctx, SI_PARAM_ANCILLARY, 8, 4);
 }
 
+static LLVMValueRef get_base_vertex(struct ac_shader_abi *abi)
+{
+       struct si_shader_context *ctx = si_shader_context_from_abi(abi);
+
+       /* For non-indexed draws, the base vertex set by the driver
+        * (for direct draws) or the CP (for indirect draws) is the
+        * first vertex ID, but GLSL expects 0 to be returned.
+        */
+       LLVMValueRef vs_state = LLVMGetParam(ctx->main_fn,
+                                            ctx->param_vs_state_bits);
+       LLVMValueRef indexed;
+
+       indexed = LLVMBuildLShr(ctx->ac.builder, vs_state, ctx->i32_1, "");
+       indexed = LLVMBuildTrunc(ctx->ac.builder, indexed, ctx->i1, "");
+
+       return LLVMBuildSelect(ctx->ac.builder, indexed, ctx->abi.base_vertex,
+                              ctx->i32_0, "");
+}
+
 static LLVMValueRef get_block_size(struct ac_shader_abi *abi)
 {
        struct si_shader_context *ctx = si_shader_context_from_abi(abi);
@@ -2068,21 +2087,8 @@ void si_load_system_value(struct si_shader_context *ctx,
                break;
 
        case TGSI_SEMANTIC_BASEVERTEX:
-       {
-               /* For non-indexed draws, the base vertex set by the driver
-                * (for direct draws) or the CP (for indirect draws) is the
-                * first vertex ID, but GLSL expects 0 to be returned.
-                */
-               LLVMValueRef vs_state = LLVMGetParam(ctx->main_fn, 
ctx->param_vs_state_bits);
-               LLVMValueRef indexed;
-
-               indexed = LLVMBuildLShr(ctx->ac.builder, vs_state, ctx->i32_1, 
"");
-               indexed = LLVMBuildTrunc(ctx->ac.builder, indexed, ctx->i1, "");
-
-               value = LLVMBuildSelect(ctx->ac.builder, indexed,
-                                       ctx->abi.base_vertex, ctx->i32_0, "");
+               value = get_base_vertex(&ctx->abi);
                break;
-       }
 
        case TGSI_SEMANTIC_BASEINSTANCE:
                value = ctx->abi.start_instance;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to