[Mesa-dev] [PATCH 14/20] mesa: Add _mesa_uniform_{attach, detach_all}_driver_storage functions

Ian Romanick idr at freedesktop.org
Fri Oct 28 10:42:41 PDT 2011


From: Ian Romanick <ian.d.romanick at intel.com>

This functions are used to create and destroy the connections between
a uniform and the storage used by the driver to hold its value.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/mesa/main/uniform_query.cpp |    1 +
 src/mesa/main/uniforms.c        |   47 +++++++++++++++++++++++++++++++++++++++
 src/mesa/main/uniforms.h        |   11 +++++++++
 3 files changed, 59 insertions(+), 0 deletions(-)

diff --git a/src/mesa/main/uniform_query.cpp b/src/mesa/main/uniform_query.cpp
index c693055..1817164 100644
--- a/src/mesa/main/uniform_query.cpp
+++ b/src/mesa/main/uniform_query.cpp
@@ -25,6 +25,7 @@
 #include "main/core.h"
 #include "main/context.h"
 #include "ir.h"
+#include "ir_uniform.h"
 #include "../glsl/program.h"
 #include "../glsl/ir_uniform.h"
 
diff --git a/src/mesa/main/uniforms.c b/src/mesa/main/uniforms.c
index 4977133..13574ce 100644
--- a/src/mesa/main/uniforms.c
+++ b/src/mesa/main/uniforms.c
@@ -75,6 +75,53 @@ _mesa_update_shader_textures_used(struct gl_program *prog)
    }
 }
 
+/**
+ * Connect a piece of driver storage with a part of a uniform
+ *
+ * \param uni            The uniform with which the storage will be associated
+ * \param element_stride Byte-stride between array elements.
+ *                       \sa gl_uniform_driver_storage::element_stride.
+ * \param vector_stride  Byte-stride between vectors (in a matrix).
+ *                       \sa gl_uniform_driver_storage::vector_stride.
+ * \param format         Conversion from native format to driver format
+ *                       required by the driver.
+ * \param data           Location to dump the data.
+ */
+void
+_mesa_uniform_attach_driver_storage(struct gl_uniform_storage *uni,
+				    unsigned element_stride,
+				    unsigned vector_stride,
+				    enum gl_uniform_driver_format format,
+				    void *data)
+{
+   uni->driver_storage = (struct gl_uniform_driver_storage*)
+      realloc(uni->driver_storage,
+	      sizeof(struct gl_uniform_driver_storage)
+	      * (uni->num_driver_storage + 1));
+
+   uni->driver_storage[uni->num_driver_storage].element_stride = element_stride;
+   uni->driver_storage[uni->num_driver_storage].vector_stride = vector_stride;
+   uni->driver_storage[uni->num_driver_storage].format = (uint8_t) format;
+   uni->driver_storage[uni->num_driver_storage].data = data;
+
+   uni->num_driver_storage++;
+}
+
+/**
+ * Sever all connections with all pieces of driver storage for all uniforms
+ *
+ * \warning
+ * This function does \b not release any of the \c data pointers
+ * previously passed in to \c _mesa_uniform_attach_driver_stoarge.
+ */
+void
+_mesa_uniform_detach_all_driver_storage(struct gl_uniform_storage *uni)
+{
+   free(uni->driver_storage);
+   uni->driver_storage = NULL;
+   uni->num_driver_storage = 0;
+}
+
 void GLAPIENTRY
 _mesa_Uniform1fARB(GLint location, GLfloat v0)
 {
diff --git a/src/mesa/main/uniforms.h b/src/mesa/main/uniforms.h
index 4698ffc..b90f64b 100644
--- a/src/mesa/main/uniforms.h
+++ b/src/mesa/main/uniforms.h
@@ -27,6 +27,7 @@
 
 #include "glheader.h"
 #include "program/prog_parameter.h"
+#include "../glsl/ir_uniform.h"
 
 struct gl_program;
 struct _glapi_table;
@@ -189,6 +190,16 @@ _mesa_get_uniform(struct gl_context *ctx, GLuint program, GLint location,
 		  GLsizei bufSize, GLenum returnType, GLvoid *paramsOut);
 
 extern void
+_mesa_uniform_attach_driver_storage(struct gl_uniform_storage *,
+				    unsigned element_stride,
+				    unsigned vector_stride,
+				    enum gl_uniform_driver_format format,
+				    void *data);
+
+extern void
+_mesa_uniform_detach_all_driver_storage(struct gl_uniform_storage *uni);
+
+extern void
 _mesa_propagate_uniforms_to_driver_storage(struct gl_uniform_storage *uni,
 					   unsigned array_index,
 					   unsigned count);
-- 
1.7.6.4



More information about the mesa-dev mailing list