mesa: add support propagate uniform support for packed uniforms
authorTimothy Arceri <tarceri@itsqueeze.com>
Tue, 13 Mar 2018 05:44:06 +0000 (16:44 +1100)
committerTimothy Arceri <tarceri@itsqueeze.com>
Tue, 20 Mar 2018 03:17:34 +0000 (14:17 +1100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/mesa/program/ir_to_mesa.cpp

index 0dad6f9c71272fa6e78119ef6fbbc19a2e93f63c..b0b322865b71db1f1d06a5103d42926579a3fb54 100644 (file)
@@ -2639,8 +2639,24 @@ _mesa_associate_uniform_storage(struct gl_context *ctx,
           */
          if (propagate_to_storage) {
             unsigned array_elements = MAX2(1, storage->array_elements);
-            _mesa_propagate_uniforms_to_driver_storage(storage, 0,
-                                                       array_elements);
+            if (ctx->Const.PackedDriverUniformStorage && !prog->is_arb_asm &&
+                (storage->is_bindless || !storage->type->contains_opaque())) {
+               const int dmul = storage->type->is_64bit() ? 2 : 1;
+               const unsigned components =
+                  storage->type->vector_elements *
+                  storage->type->matrix_columns;
+
+               for (unsigned s = 0; s < storage->num_driver_storage; s++) {
+                  gl_constant_value *uni_storage = (gl_constant_value *)
+                     storage->driver_storage[s].data;
+                  memcpy(uni_storage, storage->storage,
+                         sizeof(storage->storage[0]) * components *
+                         array_elements * dmul);
+               }
+            } else {
+               _mesa_propagate_uniforms_to_driver_storage(storage, 0,
+                                                          array_elements);
+            }
          }
 
              last_location = location;