[Mesa-dev] [PATCH 06/17] mesa: add packing support for setting uniform handles

Timothy Arceri tarceri at itsqueeze.com
Sun Jun 25 01:31:38 UTC 2017


---
 src/mesa/main/uniform_query.cpp | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index 0b22683..dadad87 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -1515,24 +1515,34 @@ _mesa_uniform_handle(GLint location, GLsizei count, const GLvoid *values,
     * will have already generated an error.
     */
    if (uni->array_elements != 0) {
       count = MIN2(count, (int) (uni->array_elements - offset));
    }
 
    _mesa_flush_vertices_for_uniforms(ctx, uni);
 
    /* Store the data in the "actual type" backing storage for the uniform.
     */
-   memcpy(&uni->storage[size_mul * components * offset], values,
-          sizeof(uni->storage[0]) * components * count * size_mul);
+   gl_constant_value *storage;
+   if (ctx->Const.PackedDriverUniformStorage) {
+      for (unsigned s = 0; s < uni->num_driver_storage; s++) {
+         storage = (gl_constant_value *)
+            uni->driver_storage[s].data + (size_mul * offset * components);
+         memcpy(storage, values,
+                sizeof(uni->storage[0]) * components * count * size_mul);
+      }
+   } else {
+      memcpy(&uni->storage[size_mul * components * offset], values,
+             sizeof(uni->storage[0]) * components * count * size_mul);
 
-   _mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
+      _mesa_propagate_uniforms_to_driver_storage(uni, offset, count);
+   }
 
    if (uni->type->is_sampler()) {
       /* Mark this bindless sampler as not bound to a texture unit because
        * it refers to a texture handle.
        */
       for (int i = 0; i < MESA_SHADER_STAGES; i++) {
          struct gl_linked_shader *const sh = shProg->_LinkedShaders[i];
 
          /* If the shader stage doesn't use the sampler uniform, skip this. */
          if (!uni->opaque[i].active)
-- 
2.9.4



More information about the mesa-dev mailing list