[Mesa-dev] [PATCH 2/3] mesa: Introduce enabled bitfield helper functions.
Mathias Froehlich
Mathias.Froehlich at gmx.net
Thu Dec 29 14:13:57 PST 2011
Depending on the installed shader type, different arrays are used
from gl_array_object. Provide helper functions that compute
the bitmask of these arrays that are finally enabled for a given
shader type. The will be used in a followup change.
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich at web.de>
---
src/mesa/main/arrayobj.h | 38 ++++++++++++++++++++++++++++++++++++++
src/mesa/main/mtypes.h | 4 ++++
2 files changed, 42 insertions(+), 0 deletions(-)
diff --git a/src/mesa/main/arrayobj.h b/src/mesa/main/arrayobj.h
index 0b5a013..938fa1e 100644
--- a/src/mesa/main/arrayobj.h
+++ b/src/mesa/main/arrayobj.h
@@ -29,6 +29,7 @@
#define ARRAYOBJ_H
#include "glheader.h"
+#include "mtypes.h"
struct gl_context;
@@ -64,6 +65,43 @@ extern void
_mesa_update_array_object_max_element(struct gl_context *ctx,
struct gl_array_object *arrayObj);
+/** Returns the bitmask of all enabled arrays in fixed function mode.
+ *
+ * In fixed function mode only the traditional fixed function arrays
+ * are available.
+ */
+static inline GLbitfield64
+_mesa_array_object_get_enabled_ff(const struct gl_array_object *arrayObj)
+{
+ return arrayObj->_Enabled & VERT_BIT_FF_ALL;
+}
+
+/** Returns the bitmask of all enabled arrays in nv shader mode.
+ *
+ * In nv shader mode any the generic nv arrays superseed the traditional
+ * fixed function arrays. The nv generic arrays take precedence
+ * over the legacy arrays.
+ */
+static inline GLbitfield64
+_mesa_array_object_get_enabled_nv(const struct gl_array_object *arrayObj)
+{
+ GLbitfield64 enabled = arrayObj->_Enabled;
+ return enabled & ~(VERT_BIT_FF_NVALIAS & (enabled >>
VERT_ATTRIB_GENERIC0));
+}
+
+/** Returns the bitmask of all enabled arrays in arb/glsl shader mode.
+ *
+ * In arb/glsl shader mode all the fixed function and the arg/glsl generic
+ * arrays are available. Here only the first generic array takes
+ * precedence over the legacy position array.
+ */
+static inline GLbitfield64
+_mesa_array_object_get_enabled_arb(const struct gl_array_object *arrayObj)
+{
+ GLbitfield64 enabled = arrayObj->_Enabled;
+ return enabled & ~(VERT_BIT_POS & (enabled >> VERT_ATTRIB_GENERIC0));
+}
+
/*
* API functions
diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
index 451d442..3bef71d 100644
--- a/src/mesa/main/mtypes.h
+++ b/src/mesa/main/mtypes.h
@@ -206,9 +206,13 @@ typedef enum
#define VERT_BIT_TEX(i) VERT_BIT(VERT_ATTRIB_TEX(i))
#define VERT_BIT_TEX_ALL \
BITFIELD64_RANGE(VERT_ATTRIB_TEX(0), VERT_ATTRIB_TEX_MAX)
+#define VERT_BIT_FF_NVALIAS \
+ BITFIELD64_RANGE(VERT_ATTRIB_POS, VERT_ATTRIB_GENERIC_NV_MAX)
+
#define VERT_BIT_GENERIC_NV(i) VERT_BIT(VERT_ATTRIB_GENERIC_NV(i))
#define VERT_BIT_GENERIC_NV_ALL \
BITFIELD64_RANGE(VERT_ATTRIB_GENERIC_NV(0), VERT_ATTRIB_GENERIC_NV_MAX)
+
#define VERT_BIT_GENERIC(i) VERT_BIT(VERT_ATTRIB_GENERIC(i))
#define VERT_BIT_GENERIC_ALL \
BITFIELD64_RANGE(VERT_ATTRIB_GENERIC(0), VERT_ATTRIB_GENERIC_MAX)
--
1.7.4.4
More information about the mesa-dev
mailing list