[Mesa-dev] [PATCH 1/2] llvmpipe: Simplify and fix system variables fetch.
The system array values concept doesn't really because it expects the system values to be fixed per call, which is wrong for gl_VertexID and iffy for gl_SampleID. So this patch does two things: - kill the array, have emit_fetch_system_value directly pick the values it needs (only gl_InstanceID for now, as the previous code) - correctly handle the expected type in emit_fetch_system_value Signed-off-by: Olivier Galibert --- src/gallium/auxiliary/draw/draw_llvm.c | 10 +-- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 11 +-- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 88 +++ src/gallium/drivers/llvmpipe/lp_state_fs.c |2 +- 4 files changed, 33 insertions(+), 78 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 4058e11..d5eb727 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -456,7 +456,7 @@ generate_vs(struct draw_llvm *llvm, LLVMBuilderRef builder, LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS], const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS], -LLVMValueRef system_values_array, +LLVMValueRef instance_id, LLVMValueRef context_ptr, struct lp_build_sampler_soa *draw_sampler, boolean clamp_vertex_color) @@ -488,7 +488,7 @@ generate_vs(struct draw_llvm *llvm, vs_type, NULL /*struct lp_build_mask_context *mask*/, consts_ptr, - system_values_array, + instance_id, NULL /*pos*/, inputs, outputs, @@ -1246,7 +1246,6 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, LLVMValueRef stride, step, io_itr; LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr; LLVMValueRef instance_id; - LLVMValueRef system_values_array; LLVMValueRef zero = lp_build_const_int32(gallivm, 0); LLVMValueRef one = lp_build_const_int32(gallivm, 1); struct draw_context *draw = llvm->draw; @@ -1337,9 +1336,6 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, lp_build_context_init(&bld, gallivm, lp_type_int(32)); - system_values_array = lp_build_system_values_array(gallivm, vs_info, - instance_id, NULL); - /* function will return non-zero i32 value if any clipped vertices */ ret_ptr = lp_build_alloca(gallivm, int32_type, ""); LLVMBuildStore(builder, zero, ret_ptr); @@ -1415,7 +1411,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, builder, outputs, ptr_aos, - system_values_array, + instance_id, context_ptr, sampler, variant->key.clamp_vertex_color); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 141e799..c4e690c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -205,7 +205,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, struct lp_type type, struct lp_build_mask_context *mask, LLVMValueRef consts_ptr, - LLVMValueRef system_values_array, + LLVMValueRef instance_id, const LLVMValueRef *pos, const LLVMValueRef (*inputs)[4], LLVMValueRef (*outputs)[4], @@ -225,13 +225,6 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm, const struct tgsi_shader_info *info); -LLVMValueRef -lp_build_system_values_array(struct gallivm_state *gallivm, - const struct tgsi_shader_info *info, - LLVMValueRef instance_id, - LLVMValueRef facing); - - struct lp_exec_mask { struct lp_build_context *bld; @@ -388,7 +381,7 @@ struct lp_build_tgsi_soa_context */ LLVMValueRef inputs_array; - LLVMValueRef system_values_array; + LLVMValueRef instance_id; /** bitmask indicating which register files are accessed indirectly */ unsigned indirect_files; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 412dc0c..26be902 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -786,18 +786,37 @@ emit_fetch_system_value( { struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); struct gallivm_state *gallivm = bld->bld_base.base.gallivm; + const struct tgsi_shader_info *info = bld->bld_base.info; LLVMBuilderRef builder = gallivm->builder; - LLVMValueRef index; /* inde
[Mesa-dev] [PATCH 1/2] llvmpipe: Simplify and fix system variables fetch.
The system array values concept doesn't really because it expects the system values to be fixed per call, which is wrong for gl_VertexID and iffy for gl_SampleID. So this patch does two things: - kill the array, have emit_fetch_system_value directly pick the values it needs (only gl_InstanceID for now, as the previous code) - correctly handle the expected type in emit_fetch_system_value Signed-off-by: Olivier Galibert --- src/gallium/auxiliary/draw/draw_llvm.c | 10 +-- src/gallium/auxiliary/gallivm/lp_bld_tgsi.h | 11 +-- src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 88 +++ src/gallium/drivers/llvmpipe/lp_state_fs.c |2 +- 4 files changed, 33 insertions(+), 78 deletions(-) diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 4058e11..d5eb727 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -456,7 +456,7 @@ generate_vs(struct draw_llvm *llvm, LLVMBuilderRef builder, LLVMValueRef (*outputs)[TGSI_NUM_CHANNELS], const LLVMValueRef (*inputs)[TGSI_NUM_CHANNELS], -LLVMValueRef system_values_array, +LLVMValueRef instance_id, LLVMValueRef context_ptr, struct lp_build_sampler_soa *draw_sampler, boolean clamp_vertex_color) @@ -488,7 +488,7 @@ generate_vs(struct draw_llvm *llvm, vs_type, NULL /*struct lp_build_mask_context *mask*/, consts_ptr, - system_values_array, + instance_id, NULL /*pos*/, inputs, outputs, @@ -1246,7 +1246,6 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, LLVMValueRef stride, step, io_itr; LLVMValueRef io_ptr, vbuffers_ptr, vb_ptr; LLVMValueRef instance_id; - LLVMValueRef system_values_array; LLVMValueRef zero = lp_build_const_int32(gallivm, 0); LLVMValueRef one = lp_build_const_int32(gallivm, 1); struct draw_context *draw = llvm->draw; @@ -1337,9 +1336,6 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, lp_build_context_init(&bld, gallivm, lp_type_int(32)); - system_values_array = lp_build_system_values_array(gallivm, vs_info, - instance_id, NULL); - /* function will return non-zero i32 value if any clipped vertices */ ret_ptr = lp_build_alloca(gallivm, int32_type, ""); LLVMBuildStore(builder, zero, ret_ptr); @@ -1415,7 +1411,7 @@ draw_llvm_generate(struct draw_llvm *llvm, struct draw_llvm_variant *variant, builder, outputs, ptr_aos, - system_values_array, + instance_id, context_ptr, sampler, variant->key.clamp_vertex_color); diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h index 141e799..c4e690c 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi.h @@ -205,7 +205,7 @@ lp_build_tgsi_soa(struct gallivm_state *gallivm, struct lp_type type, struct lp_build_mask_context *mask, LLVMValueRef consts_ptr, - LLVMValueRef system_values_array, + LLVMValueRef instance_id, const LLVMValueRef *pos, const LLVMValueRef (*inputs)[4], LLVMValueRef (*outputs)[4], @@ -225,13 +225,6 @@ lp_build_tgsi_aos(struct gallivm_state *gallivm, const struct tgsi_shader_info *info); -LLVMValueRef -lp_build_system_values_array(struct gallivm_state *gallivm, - const struct tgsi_shader_info *info, - LLVMValueRef instance_id, - LLVMValueRef facing); - - struct lp_exec_mask { struct lp_build_context *bld; @@ -388,7 +381,7 @@ struct lp_build_tgsi_soa_context */ LLVMValueRef inputs_array; - LLVMValueRef system_values_array; + LLVMValueRef instance_id; /** bitmask indicating which register files are accessed indirectly */ unsigned indirect_files; diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index 412dc0c..26be902 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -786,18 +786,37 @@ emit_fetch_system_value( { struct lp_build_tgsi_soa_context * bld = lp_soa_context(bld_base); struct gallivm_state *gallivm = bld->bld_base.base.gallivm; + const struct tgsi_shader_info *info = bld->bld_base.info; LLVMBuilderRef builder = gallivm->builder; - LLVMValueRef index; /* inde