cr_glstate.h revision f350d4fb2d12fd22c0905fe9c7a121499da7b52d
/* Copyright (c) 2001, Stanford University
* All rights reserved.
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#ifndef CR_GLSTATE_H
#define CR_GLSTATE_H
struct CRContext;
#include "cr_version.h"
#include "state/cr_buffer.h"
#include "state/cr_bufferobject.h"
#include "state/cr_client.h"
#include "state/cr_current.h"
#include "state/cr_evaluators.h"
#include "state/cr_feedback.h"
#include "state/cr_lighting.h"
#include "state/cr_limits.h"
#include "state/cr_lists.h"
#include "state/cr_multisample.h"
#include "state/cr_occlude.h"
#include "state/cr_pixel.h"
#include "state/cr_point.h"
#include "state/cr_polygon.h"
#include "state/cr_program.h"
#include "state/cr_regcombiner.h"
#include "state/cr_stencil.h"
#include "state/cr_texture.h"
#include "state/cr_transform.h"
#include "state/cr_viewport.h"
#include "state/cr_attrib.h"
#include "state/cr_framebuffer.h"
#include "state/cr_statefuncs.h"
#include "state/cr_stateerror.h"
#include "spu_dispatch_table.h"
#ifdef CHROMIUM_THREADSAFE
# include <cr_threads.h>
#endif
# define CR_STATE_SHAREDOBJ_USAGE_INIT(_pObj) (crMemset((_pObj)->ctxUsage, 0, sizeof ((_pObj)->ctxUsage)))
# define CR_STATE_SHAREDOBJ_USAGE_CLEAR(_pObj, _pCtx) (CR_STATE_SHAREDOBJ_USAGE_CLEAR_IDX((_pObj), (_pCtx)->id))
# define CR_STATE_SHAREDOBJ_USAGE_IS_USED(_pObj) (ASMBitFirstSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3) >= 0)
# define CR_STATE_SHAREDOBJ_USAGE_GET_FIRST_USED_IDX(_pObj) (ASMBitFirstSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3))
# define CR_STATE_SHAREDOBJ_USAGE_GET_NEXT_USED_IDX(_pObj, _i) (ASMBitNextSet((_pObj)->ctxUsage, sizeof ((_pObj)->ctxUsage)<<3, (_i)))
# define CR_STATE_SHAREDOBJ_USAGE_FOREACH_USED_IDX(_pObj, _i) for ((_i) = CR_STATE_SHAREDOBJ_USAGE_GET_FIRST_USED_IDX(_pObj); ((int)(_i)) >= 0; (_i) = CR_STATE_SHAREDOBJ_USAGE_GET_NEXT_USED_IDX((_pObj), ((int)(_i))))
#define CR_MAX_EXTENTS 256
#ifdef __cplusplus
extern "C" {
#endif
/**
* Bit vectors describing GL state
*/
typedef struct {
#ifdef CR_ARB_vertex_buffer_object
#endif
#endif
} CRStateBits;
typedef void (*CRStateFlushFunc)( void *arg );
typedef struct _CRSharedState {
/* Indicates that we have to resend data to GPU on first glMakeCurrent call with owning context */
/**
* Chromium version of the state variables in OpenGL
*/
struct CRContext {
int id;
#ifdef CHROMIUM_THREADSAFE
/* we keep reference counting of context's makeCurrent for different threads
* this is primarily needed to avoid having an invalid memory reference in the TLS
* when the context is assigned to more than one threads and then destroyed from
* one of those, i.e.
* 1. Thread1 -> MakeCurrent(ctx1);
* 2. Thread2 -> MakeCurrent(ctx1);
* 3. Thread1 -> Destroy(ctx1);
* => Thread2 still refers to destroyed ctx1
* */
#endif
void *flush_arg;
#ifdef CR_ARB_vertex_buffer_object
#endif
#endif
#ifdef CR_EXT_framebuffer_object
#endif
#ifdef CR_OPENGL_VERSION_2_0
#endif
/*@{*/
/*@}*/
};
DECLEXPORT(void) crStateInit(void);
DECLEXPORT(void) crStateDestroy(void);
DECLEXPORT(void) crStateVBoxDetachThread();
DECLEXPORT(void) crStateVBoxAttachThread();
DECLEXPORT(CRContext *) crStateCreateContext(const CRLimitsState *limits, GLint visBits, CRContext *share);
DECLEXPORT(CRContext *) crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID);
void crStateSwitchPrepare(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
void crStateSwitchPostprocess(CRContext *toCtx, CRContext *fromCtx, GLuint idDrawFBO, GLuint idReadFBO);
DECLEXPORT(void) crStateUpdateColorBits( void );
typedef struct CRFBDataElement
{
/* FBO, can be NULL */
/* to be used for glDraw/ReadBuffer, i.e. GL_FRONT, GL_BACK, GL_COLOR_ATTACHMENTX */
typedef struct CRFBData
{
/* override default draw and read buffers to be used for offscreen rendering */
} CRFBData;
#ifndef IN_GUEST
typedef FNCRSTATE_CONTEXT_GET *PFNCRSTATE_CONTEXT_GET;
DECLEXPORT(int32_t) crStateLoadContext(CRContext *pContext, CRHashTable * pCtxTable, PFNCRSTATE_CONTEXT_GET pfnCtxGet, PSSMHANDLE pSSM, uint32_t u32Version);
DECLEXPORT(void) crStateGlobalSharedRelease();
#endif
/* XXX move these! */
DECLEXPORT(void) STATE_APIENTRY
DECLEXPORT(void) STATE_APIENTRY
DECLEXPORT(void) STATE_APIENTRY
DECLEXPORT(void) STATE_APIENTRY
DECLEXPORT(void) STATE_APIENTRY
#ifdef __cplusplus
}
#endif
#endif /* CR_GLSTATE_H */