diff options
author | José Fonseca <[email protected]> | 2012-12-04 14:52:44 +0000 |
---|---|---|
committer | José Fonseca <[email protected]> | 2012-12-07 15:03:07 +0000 |
commit | 1d35f77228ad540a551a8e09e062b764a6e31f5e (patch) | |
tree | a9128d5c57a248616077b3977ef88b5e45e33b6d /src/gallium/auxiliary | |
parent | 35840ab189595b817fa8b1a1df8cc92474a7c38d (diff) |
gallivm,llvmpipe,draw: Support multiple constant buffers.
Support 16 (defined in LP_MAX_TGSI_CONST_BUFFERS) as opposed to 32 (as
defined by PIPE_MAX_CONSTANT_BUFFERS) because that would make the jit
context become unnecessarily large.
v2: Bump limit from 4 to 16 to cover ARB_uniform_buffer_object needs,
per Dave Airlie.
Reviewed-by: Brian Paul <[email protected]>
Diffstat (limited to 'src/gallium/auxiliary')
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.c | 5 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_llvm.h | 9 | ||||
-rw-r--r-- | src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c | 16 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_limits.h | 3 | ||||
-rw-r--r-- | src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c | 19 |
5 files changed, 37 insertions, 15 deletions
diff --git a/src/gallium/auxiliary/draw/draw_llvm.c b/src/gallium/auxiliary/draw/draw_llvm.c index 6f0e1de7481..039db8fce49 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.c +++ b/src/gallium/auxiliary/draw/draw_llvm.c @@ -161,8 +161,9 @@ create_jit_context_type(struct gallivm_state *gallivm, LLVMTypeRef elem_types[5]; LLVMTypeRef context_type; - elem_types[0] = LLVMPointerType(float_type, 0); /* vs_constants */ - elem_types[1] = LLVMPointerType(float_type, 0); /* gs_constants */ + elem_types[0] = LLVMArrayType(LLVMPointerType(float_type, 0), /* vs_constants */ + LP_MAX_TGSI_CONST_BUFFERS); + elem_types[1] = elem_types[0]; /* gs_constants */ elem_types[2] = LLVMPointerType(LLVMArrayType(LLVMArrayType(float_type, 4), DRAW_TOTAL_CLIP_PLANES), 0); elem_types[3] = LLVMPointerType(float_type, 0); /* viewport */ diff --git a/src/gallium/auxiliary/draw/draw_llvm.h b/src/gallium/auxiliary/draw/draw_llvm.h index d7a630eb015..bd11886149d 100644 --- a/src/gallium/auxiliary/draw/draw_llvm.h +++ b/src/gallium/auxiliary/draw/draw_llvm.h @@ -32,6 +32,7 @@ #include "draw/draw_vs.h" #include "gallivm/lp_bld_sample.h" +#include "gallivm/lp_bld_limits.h" #include "pipe/p_context.h" #include "util/u_simple_list.h" @@ -94,8 +95,8 @@ enum { */ struct draw_jit_context { - const float *vs_constants; - const float *gs_constants; + const float *vs_constants[LP_MAX_TGSI_CONST_BUFFERS]; + const float *gs_constants[LP_MAX_TGSI_CONST_BUFFERS]; float (*planes) [DRAW_TOTAL_CLIP_PLANES][4]; float *viewport; @@ -104,10 +105,10 @@ struct draw_jit_context #define draw_jit_context_vs_constants(_gallivm, _ptr) \ - lp_build_struct_get(_gallivm, _ptr, 0, "vs_constants") + lp_build_struct_get_ptr(_gallivm, _ptr, 0, "vs_constants") #define draw_jit_context_gs_constants(_gallivm, _ptr) \ - lp_build_struct_get(_gallivm, _ptr, 1, "gs_constants") + lp_build_struct_get_ptr(_gallivm, _ptr, 1, "gs_constants") #define draw_jit_context_planes(_gallivm, _ptr) \ lp_build_struct_get(_gallivm, _ptr, 2, "planes") diff --git a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c index 04b286f0f5b..507c1586947 100644 --- a/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c +++ b/src/gallium/auxiliary/draw/draw_pt_fetch_shade_pipeline_llvm.c @@ -81,6 +81,8 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle, const unsigned nr = MAX2( shader->base.info.num_inputs, shader->base.info.num_outputs + 1 ); + unsigned i; + fpme->input_prim = in_prim; fpme->opt = opt; @@ -138,7 +140,6 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle, } else { /* Need to create new variant */ - unsigned i; /* First check if we've created too many variants. If so, free * 25% of the LRU to avoid using too much memory. @@ -171,11 +172,14 @@ llvm_middle_end_prepare( struct draw_pt_middle_end *middle, fpme->current_variant = variant; - /*XXX we only support one constant buffer */ - fpme->llvm->jit_context.vs_constants = - draw->pt.user.vs_constants[0]; - fpme->llvm->jit_context.gs_constants = - draw->pt.user.gs_constants[0]; + for (i = 0; i < Elements(fpme->llvm->jit_context.vs_constants); ++i) { + fpme->llvm->jit_context.vs_constants[i] = + draw->pt.user.vs_constants[i]; + } + for (i = 0; i < Elements(fpme->llvm->jit_context.gs_constants); ++i) { + fpme->llvm->jit_context.gs_constants[i] = + draw->pt.user.gs_constants[i]; + } fpme->llvm->jit_context.planes = (float (*) [DRAW_TOTAL_CLIP_PLANES][4]) draw->pt.user.planes[0]; fpme->llvm->jit_context.viewport = diff --git a/src/gallium/auxiliary/gallivm/lp_bld_limits.h b/src/gallium/auxiliary/gallivm/lp_bld_limits.h index 905070e7ae8..30bed1ba31f 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_limits.h +++ b/src/gallium/auxiliary/gallivm/lp_bld_limits.h @@ -51,6 +51,9 @@ #define LP_MAX_TGSI_PREDS 16 +#define LP_MAX_TGSI_CONST_BUFFERS 16 + + /** * Maximum control flow nesting * diff --git a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c index cdc784cf0df..9caac21fd9b 100644 --- a/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c +++ b/src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c @@ -63,6 +63,7 @@ #include "lp_bld_debug.h" #include "lp_bld_printf.h" #include "lp_bld_sample.h" +#include "lp_bld_struct.h" static void lp_exec_mask_init(struct lp_exec_mask *mask, struct lp_build_context *bld) @@ -588,10 +589,22 @@ emit_fetch_constant( struct lp_build_context *uint_bld = &bld_base->uint_bld; LLVMValueRef indirect_index = NULL; struct lp_build_context *bld_fetch = stype_to_fetch(bld_base, stype); - + unsigned dimension = 0; + LLVMValueRef dimension_index; + LLVMValueRef consts_ptr; + /* XXX: Handle fetching xyzw components as a vector */ assert(swizzle != ~0); + if (reg->Register.Dimension) { + assert(!reg->Dimension.Indirect); + dimension = reg->Dimension.Index; + assert(dimension < LP_MAX_TGSI_CONST_BUFFERS); + } + + dimension_index = lp_build_const_int32(gallivm, dimension); + consts_ptr = lp_build_array_get(gallivm, bld->consts_ptr, dimension_index); + if (reg->Register.Indirect) { indirect_index = get_indirect_index(bld, reg->Register.File, @@ -609,7 +622,7 @@ emit_fetch_constant( index_vec = lp_build_add(uint_bld, index_vec, swizzle_vec); /* Gather values from the constant buffer */ - return build_gather(bld_fetch, bld->consts_ptr, index_vec); + return build_gather(bld_fetch, consts_ptr, index_vec); } else { LLVMValueRef index; /* index into the const buffer */ @@ -617,7 +630,7 @@ emit_fetch_constant( index = lp_build_const_int32(gallivm, reg->Register.Index*4 + swizzle); - scalar_ptr = LLVMBuildGEP(builder, bld->consts_ptr, + scalar_ptr = LLVMBuildGEP(builder, consts_ptr, &index, 1, ""); if (stype != TGSI_TYPE_FLOAT && stype != TGSI_TYPE_UNTYPED) { |