aboutsummaryrefslogtreecommitdiff
path: root/mesalib/src/mesa/main/api_arrayelt.c
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2013-06-04 09:07:26 +0200
committermarha <marha@users.sourceforge.net>2013-06-04 09:07:26 +0200
commit150771e7aabf4c864b0b970c5b8d773634793abe (patch)
tree3d544cc0d8d06dd70e843d6ca7e4b0ef421d2758 /mesalib/src/mesa/main/api_arrayelt.c
parentfbe681216618af573ce29ca03b382b39b5919a52 (diff)
downloadvcxsrv-150771e7aabf4c864b0b970c5b8d773634793abe.tar.gz
vcxsrv-150771e7aabf4c864b0b970c5b8d773634793abe.tar.bz2
vcxsrv-150771e7aabf4c864b0b970c5b8d773634793abe.zip
xwininfo fontconfig libX11 libXau libXdmcp libXext mesa libXinerama libxcb libxcb/xcb-proto libfontenc pixman xkbcomp mkfontscale xkeyboard-config git update 4 Jun 2013
xserver commit c21344add2fc589df83b29be5831c36a372201bd libxcb commit 9ae84ad187e2ba440c40f44b8eb21c82c2fdbf12 libxcb/xcb-proto commit bdfedfa57a13ff805580cfacafc70f9cc55df363 xkeyboard-config commit dad9ade4e83d1ef5a517fcc4cc9ad3a79b47acce libX11 commit 8496122eb00ce6cd5d2308ee54f64b68c378e455 libXdmcp commit 0b443c1b769b9c9a3b45b4252afe07e18b709ff4 libXext commit d8366afbb0d2e4fbb1e419b1187f490522270bea libfontenc commit 3acba630d8b57084f7e92c15732408711ed5137a libXinerama commit 6e1d1dc328ba8162bba2f4694e7f3c706a1491ff libXau commit 899790011304c4029e15abf410e49ce7cec17e0a xkbcomp commit ed582f4fccd4e23abcfba8b3b03649fea6414f44 pixman commit 2acfac5f8e097ee2ae225d986f981b55d65dd152 mkfontscale commit 19e2cb7c6a3ec2c5b1bc0d24866fa685eef0ee13 xwininfo commit ba0d1b0da21d2dbdd81098ed5778f3792b472e13 fontconfig commit cd9b1033a68816a7acfbba1718ba0aa5888f6ec7 mesa commit 7bafd88c153e395274b632e7eae4bc9fc3aec1d2
Diffstat (limited to 'mesalib/src/mesa/main/api_arrayelt.c')
-rw-r--r--mesalib/src/mesa/main/api_arrayelt.c110
1 files changed, 70 insertions, 40 deletions
diff --git a/mesalib/src/mesa/main/api_arrayelt.c b/mesalib/src/mesa/main/api_arrayelt.c
index ea3361488..8e581c8d9 100644
--- a/mesalib/src/mesa/main/api_arrayelt.c
+++ b/mesalib/src/mesa/main/api_arrayelt.c
@@ -17,9 +17,10 @@
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*/
/**
@@ -40,7 +41,6 @@
#include "context.h"
#include "imports.h"
#include "macros.h"
-#include "mfeatures.h"
#include "mtypes.h"
#include "main/dispatch.h"
@@ -64,13 +64,19 @@ typedef struct {
AEattrib attribs[VERT_ATTRIB_MAX + 1];
GLuint NewState;
+ /* List of VBOs we need to map before executing ArrayElements */
struct gl_buffer_object *vbo[VERT_ATTRIB_MAX];
GLuint nr_vbos;
- GLboolean mapped_vbos;
-
+ GLboolean mapped_vbos; /**< Any currently mapped VBOs? */
} AEcontext;
-#define AE_CONTEXT(ctx) ((AEcontext *)(ctx)->aelt_context)
+
+/** Cast wrapper */
+static INLINE AEcontext *
+AE_CONTEXT(struct gl_context *ctx)
+{
+ return (AEcontext *) ctx->aelt_context;
+}
/*
@@ -78,7 +84,12 @@ typedef struct {
* in the range [0, 7]. Luckily these type tokens are sequentially
* numbered in gl.h, except for GL_DOUBLE.
*/
-#define TYPE_IDX(t) ( (t) == GL_DOUBLE ? 7 : (t) & 7 )
+static INLINE int
+TYPE_IDX(GLenum t)
+{
+ return t == GL_DOUBLE ? 7 : t & 7;
+}
+
#define NUM_TYPES 8
@@ -1245,8 +1256,6 @@ VertexAttribI4uiv(GLuint index, const GLuint *v)
}
-
-
/*
* Array [unnormalized/normalized/integer][size][type] of VertexAttrib
* functions
@@ -1396,10 +1405,9 @@ static attrib_func AttribFuncsARB[3][4][NUM_TYPES] = {
}
};
-/**********************************************************************/
-
-GLboolean _ae_create_context( struct gl_context *ctx )
+GLboolean
+_ae_create_context(struct gl_context *ctx)
{
if (ctx->aelt_context)
return GL_TRUE;
@@ -1432,22 +1440,29 @@ GLboolean _ae_create_context( struct gl_context *ctx )
}
-void _ae_destroy_context( struct gl_context *ctx )
+void
+_ae_destroy_context(struct gl_context *ctx)
{
- if ( AE_CONTEXT( ctx ) ) {
+ if (AE_CONTEXT(ctx)) {
free(ctx->aelt_context);
ctx->aelt_context = NULL;
}
}
-static void check_vbo( AEcontext *actx,
- struct gl_buffer_object *vbo )
+
+/**
+ * Check if the given vertex buffer object exists and is not mapped.
+ * If so, add it to the list of buffers we must map before executing
+ * an glArrayElement call.
+ */
+static void
+check_vbo(AEcontext *actx, struct gl_buffer_object *vbo)
{
if (_mesa_is_bufferobj(vbo) && !_mesa_bufferobj_mapped(vbo)) {
GLuint i;
for (i = 0; i < actx->nr_vbos; i++)
- if (actx->vbo[i] == vbo)
- return;
+ if (actx->vbo[i] == vbo)
+ return; /* already in the list, we're done */
assert(actx->nr_vbos < VERT_ATTRIB_MAX);
actx->vbo[actx->nr_vbos++] = vbo;
}
@@ -1460,11 +1475,12 @@ static void check_vbo( AEcontext *actx,
* etc).
* Note: this may be called during display list construction.
*/
-static void _ae_update_state( struct gl_context *ctx )
+static void
+_ae_update_state(struct gl_context *ctx)
{
AEcontext *actx = AE_CONTEXT(ctx);
- AEarray *aa = actx->arrays;
- AEattrib *at = actx->attribs;
+ AEarray *aa = actx->arrays; /* non-indexed arrays (ex: glNormal) */
+ AEattrib *at = actx->attribs; /* indexed arrays (ex: glMultiTexCoord) */
GLuint i;
struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
@@ -1508,7 +1524,8 @@ static void _ae_update_state( struct gl_context *ctx )
aa++;
}
for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++) {
- struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)];
+ struct gl_client_array *attribArray =
+ &arrayObj->VertexAttrib[VERT_ATTRIB_TEX(i)];
if (attribArray->Enabled) {
/* NOTE: we use generic glVertexAttribNV functions here.
* If we ever remove GL_NV_vertex_program this will have to change.
@@ -1524,9 +1541,10 @@ static void _ae_update_state( struct gl_context *ctx )
}
}
- /* generic vertex attribute arrays */
+ /* generic vertex attribute arrays */
for (i = 1; i < VERT_ATTRIB_GENERIC_MAX; i++) { /* skip zero! */
- struct gl_client_array *attribArray = &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
+ struct gl_client_array *attribArray =
+ &arrayObj->VertexAttrib[VERT_ATTRIB_GENERIC(i)];
if (attribArray->Enabled) {
GLint intOrNorm;
at->array = attribArray;
@@ -1580,11 +1598,17 @@ static void _ae_update_state( struct gl_context *ctx )
actx->NewState = 0;
}
-void _ae_map_vbos( struct gl_context *ctx )
+
+/**
+ * Before replaying glArrayElements calls we need to map (for reading) any
+ * VBOs referenced by the enabled vertex arrays.
+ */
+void
+_ae_map_vbos(struct gl_context *ctx)
{
AEcontext *actx = AE_CONTEXT(ctx);
GLuint i;
-
+
if (actx->mapped_vbos)
return;
@@ -1601,7 +1625,12 @@ void _ae_map_vbos( struct gl_context *ctx )
actx->mapped_vbos = GL_TRUE;
}
-void _ae_unmap_vbos( struct gl_context *ctx )
+
+/**
+ * Unmap VBOs
+ */
+void
+_ae_unmap_vbos(struct gl_context *ctx)
{
AEcontext *actx = AE_CONTEXT(ctx);
GLuint i;
@@ -1624,7 +1653,8 @@ void _ae_unmap_vbos( struct gl_context *ctx )
* for all enabled vertex arrays (for elt-th element).
* Note: this may be called during display list construction.
*/
-void GLAPIENTRY _ae_ArrayElement( GLint elt )
+void GLAPIENTRY
+_ae_ArrayElement(GLint elt)
{
GET_CURRENT_CONTEXT(ctx);
const AEcontext *actx = AE_CONTEXT(ctx);
@@ -1636,14 +1666,14 @@ void GLAPIENTRY _ae_ArrayElement( GLint elt )
/* If PrimitiveRestart is enabled and the index is the RestartIndex
* then we call PrimitiveRestartNV and return.
*/
- if (ctx->Array._PrimitiveRestart && (elt == ctx->Array._RestartIndex)) {
+ if (ctx->Array.PrimitiveRestart && (elt == ctx->Array.RestartIndex)) {
CALL_PrimitiveRestartNV((struct _glapi_table *)disp, ());
return;
}
if (actx->NewState) {
assert(!actx->mapped_vbos);
- _ae_update_state( ctx );
+ _ae_update_state(ctx);
}
/* Determine if we need to map/unmap VBOs */
@@ -1651,13 +1681,13 @@ void GLAPIENTRY _ae_ArrayElement( GLint elt )
if (do_map)
_ae_map_vbos(ctx);
-
+
/* emit generic attribute elements */
for (at = actx->attribs; at->func; at++) {
const GLubyte *src
= ADD_POINTERS(at->array->BufferObj->Pointer, at->array->Ptr)
+ elt * at->array->StrideB;
- at->func( at->index, src );
+ at->func(at->index, src);
}
/* emit conventional arrays elements */
@@ -1665,8 +1695,7 @@ void GLAPIENTRY _ae_ArrayElement( GLint elt )
const GLubyte *src
= ADD_POINTERS(aa->array->BufferObj->Pointer, aa->array->Ptr)
+ elt * aa->array->StrideB;
- CALL_by_offset( disp, (array_func), aa->offset,
- ((const void *) src) );
+ CALL_by_offset(disp, (array_func), aa->offset, ((const void *) src));
}
if (do_map)
@@ -1674,16 +1703,16 @@ void GLAPIENTRY _ae_ArrayElement( GLint elt )
}
-void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state )
+void
+_ae_invalidate_state(struct gl_context *ctx, GLuint new_state)
{
AEcontext *actx = AE_CONTEXT(ctx);
-
/* Only interested in this subset of mesa state. Need to prune
* this down as both tnl/ and the drivers can raise statechanges
* for arcane reasons in the middle of seemingly atomic operations
* like DrawElements, over which we'd like to keep a known set of
- * arrays and vbo's mapped.
+ * arrays and vbo's mapped.
*
* Luckily, neither the drivers nor tnl muck with the state that
* concerns us here:
@@ -1696,8 +1725,9 @@ void _ae_invalidate_state( struct gl_context *ctx, GLuint new_state )
}
-void _mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
- const GLvertexformat *vfmt)
+void
+_mesa_install_arrayelt_vtxfmt(struct _glapi_table *disp,
+ const GLvertexformat *vfmt)
{
SET_ArrayElement(disp, vfmt->ArrayElement);
}