cr_pack.h revision f3f69e0e8d6a713566e129aa3ab321b1e6b07fbc
/* Copyright (c) 2001, Stanford University
* All rights reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#ifndef CR_PACK_H
#define CR_PACK_H
#include "cr_compiler.h"
#include "cr_error.h"
#include "cr_protocol.h"
#include "cr_opcodes.h"
#include "cr_endian.h"
#include "state/cr_statetypes.h"
#include "state/cr_currentpointers.h"
#include "state/cr_client.h"
#ifdef CHROMIUM_THREADSAFE
#include "cr_threads.h"
#endif
#ifdef __cplusplus
extern "C" {
#endif
typedef struct CRPackContext_t CRPackContext;
/**
* Packer buffer
*/
typedef struct
{
unsigned int size; /**< size of pack[] buffer */
unsigned int mtu;
} CRPackBuffer;
typedef void (*CRPackFlushFunc)(void *arg);
typedef void (*CRPackSendHugeFunc)(CROpcode, void *);
#define CRPACKBLOCKSTATE_OP_BEGIN 0x01
#define CRPACKBLOCKSTATE_OP_NEWLIST 0x02
#define CRPACKBLOCKSTATE_OP_BEGINQUERY 0x04
#define CRPACKBLOCKSTATE_OP_ALL 0x07
} while (0)
} while (0)
/**
* Packer context
*/
struct CRPackContext_t
{
void *flush_arg;
int updateBBOX;
int swapping;
#ifdef CHROMIUM_THREADSAFE
#endif
char *file; /**< for debugging only */
int line; /**< for debugging only */
};
#if !defined(IN_RING0)
# define CR_PACKER_CONTEXT_ARGSINGLEDECL
# define CR_PACKER_CONTEXT_ARGDECL
# define CR_PACKER_CONTEXT_ARG
# define CR_PACKER_CONTEXT_ARGCTX(C)
# ifdef CHROMIUM_THREADSAFE
extern CRtsd _PackerTSD;
# else
# define CR_LOCK_PACKER_CONTEXT(PC)
# define CR_UNLOCK_PACKER_CONTEXT(PC)
# endif
extern int cr_packer_cmd_blocks_enabled;
#else /* if defined IN_RING0 */
# define CR_PACKER_CONTEXT_ARG _pCtx,
# define CR_PACKER_CONTEXT_ARGCTX(C) C,
# define CR_LOCK_PACKER_CONTEXT(PC)
# define CR_UNLOCK_PACKER_CONTEXT(PC)
#endif
extern DECLEXPORT(void) crPackSetBufferDEBUG( const char *file, int line, CRPackContext *pc, CRPackBuffer *buffer );
#ifdef IN_RING0
, unsigned int num_opcodes
#endif
);
{
}
extern DECLEXPORT(void) crPackNullCurrentPointers( void );
extern DECLEXPORT(void) crPackAppendBoundedBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *buffer, const CRrecti *bounds );
extern DECLEXPORT(int) crPackCanHoldBoundedBuffer( CR_PACKER_CONTEXT_ARGDECL const CRPackBuffer *buffer );
#define CR_UNALIGNED_ACCESS_OKAY
#else
#endif
#ifndef IN_RING0
#endif
extern DECLEXPORT(void) crPackExpandDrawArrays(GLenum mode, GLint first, GLsizei count, CRClientState *c);
extern DECLEXPORT(void) crPackExpandDrawArraysSWAP(GLenum mode, GLint first, GLsizei count, CRClientState *c);
extern DECLEXPORT(void) crPackUnrollDrawElements(GLsizei count, GLenum type, const GLvoid *indices);
extern DECLEXPORT(void) crPackUnrollDrawElementsSWAP(GLsizei count, GLenum type, const GLvoid *indices);
extern DECLEXPORT(void) crPackExpandDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c);
extern DECLEXPORT(void) crPackExpandDrawElementsSWAP(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c);
extern DECLEXPORT(void) crPackExpandDrawRangeElements(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c);
extern DECLEXPORT(void) crPackExpandDrawRangeElementsSWAP(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, const GLvoid *indices, CRClientState *c);
extern DECLEXPORT(void) crPackExpandMultiDrawArraysEXT( GLenum mode, GLint *first, GLsizei *count, GLsizei primcount, CRClientState *c );
extern DECLEXPORT(void) crPackExpandMultiDrawArraysEXTSWAP( GLenum mode, GLint *first, GLsizei *count, GLsizei primcount, CRClientState *c );
extern DECLEXPORT(void) crPackExpandMultiDrawElementsEXT( GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount, CRClientState *c );
extern DECLEXPORT(void) crPackExpandMultiDrawElementsEXTSWAP( GLenum mode, const GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount, CRClientState *c );
/**
* Return number of opcodes in given buffer.
*/
static INLINE int
{
}
/**
* Return amount of data (in bytes) in buffer.
*/
static INLINE int
{
}
static INLINE int
{
+ num_opcode + num_data
}
do { \
} while (0)
do { \
} while (0)
do { \
if (!cr_packer_cmd_blocks_enabled) break; \
THREADASSERT( pc ); \
} \
else { \
} \
} \
else { \
} \
} \
} while (0)
do { \
if (!cr_packer_cmd_blocks_enabled) break; \
THREADASSERT( pc ); \
} \
} \
else { \
} \
} \
else { \
} \
} \
} while (0)
/**
* Alloc space for a message of 'len' bytes (plus 1 opcode).
* Only flush if buffer is full.
*/
do { \
THREADASSERT( pc ); \
} \
} while (0)
/**
* As above, flush if the buffer contains vertex data and we're
*/
do { \
CRASSERT( 0 ); /* should never be here currently */ \
} \
} while (0)
/**
* As above, but without lock.
*/
do { \
CRASSERT( 0 ); /* should never be here currently */ \
} \
} while (0)
/**
*/
do { \
} \
} while (0)
/**
* as glFinish().
*/
#define CR_GET_BUFFERED_POINTER_NO_ARGS( pc ) \
/* Write data to current location and auto increment */
{ \
}
#ifdef CR_UNALIGNED_ACCESS_OKAY
#else
# ifndef IN_RING0
# else
# endif
#endif
#ifndef IN_RING0
#else
#endif
#ifdef __cplusplus
}
#endif
#endif /* CR_PACK_H */