summaryrefslogtreecommitdiffstats
path: root/src/gallium/auxiliary/gallivm
diff options
context:
space:
mode:
authorJosé Fonseca <[email protected]>2012-12-04 14:52:44 +0000
committerJosé Fonseca <[email protected]>2012-12-07 15:03:07 +0000
commit1d35f77228ad540a551a8e09e062b764a6e31f5e (patch)
treea9128d5c57a248616077b3977ef88b5e45e33b6d /src/gallium/auxiliary/gallivm
parent35840ab189595b817fa8b1a1df8cc92474a7c38d (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/gallivm')
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_limits.h3
-rw-r--r--src/gallium/auxiliary/gallivm/lp_bld_tgsi_soa.c19
2 files changed, 19 insertions, 3 deletions
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) {