summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Pitoiset <[email protected]>2017-05-29 22:47:24 +0200
committerSamuel Pitoiset <[email protected]>2017-06-14 10:04:36 +0200
commit990c8d15ac3de8623940b32b662ef956703cc6bc (patch)
tree412da93fe93bf2fcccc181eb41b678e3c97d5369
parentfe9f7095e826aa8702f724e7445ff8dc539cfd7d (diff)
mesa: fix setting uniform variables for bindless samplers/images
This fixes a 64-bit vs 32-bit mismatch when setting an array of bindless samplers. Also, we need to unconditionally set size_mul to 2 when the underlying uniform is bindless. Signed-off-by: Samuel Pitoiset <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r--src/mesa/main/uniform_query.cpp25
1 files changed, 19 insertions, 6 deletions
diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 5ac85c014ee..fed33df6fb0 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -322,12 +322,16 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
{
unsigned elements = uni->type->components();
- /* XXX: Remove the sampler/image check workarounds when bindless is fully
- * implemented.
- */
- const int dmul =
- (uni->type->is_64bit() && !uni->type->is_sampler() && !uni->type->is_image()) ? 2 : 1;
const int rmul = glsl_base_type_is_64bit(returnType) ? 2 : 1;
+ int dmul = (uni->type->is_64bit()) ? 2 : 1;
+
+ if ((uni->type->is_sampler() || uni->type->is_image()) &&
+ !uni->is_bindless) {
+ /* Non-bindless samplers/images are represented using unsigned integer
+ * 32-bit, while bindless handles are 64-bit.
+ */
+ dmul = 1;
+ }
/* Calculate the source base address *BEFORE* modifying elements to
* account for the size of the user's buffer.
@@ -1056,9 +1060,18 @@ _mesa_uniform(GLint location, GLsizei count, const GLvoid *values,
/* Store the data in the "actual type" backing storage for the uniform.
*/
- if (!uni->type->is_boolean()) {
+ if (!uni->type->is_boolean() && !uni->is_bindless) {
memcpy(&uni->storage[size_mul * components * offset], values,
sizeof(uni->storage[0]) * components * count * size_mul);
+ } else if (uni->is_bindless) {
+ const union gl_constant_value *src =
+ (const union gl_constant_value *) values;
+ GLuint64 *dst = (GLuint64 *)&uni->storage[components * offset].i;
+ const unsigned elems = components * count;
+
+ for (unsigned i = 0; i < elems; i++) {
+ dst[i] = src[i].i;
+ }
} else {
const union gl_constant_value *src =
(const union gl_constant_value *) values;