state_init.c revision 0c0e78bbdcbeec81f856e8aa1097a9504c16bb1c
/* Copyright (c) 2001, Stanford University
* All rights reserved
*
* See the file LICENSE.txt for information on redistributing this software.
*/
#include "state.h"
#include "cr_mem.h"
#include "cr_error.h"
#include "cr_spu.h"
#ifdef CHROMIUM_THREADSAFE
#else
#endif
/**
* Allocate a new shared state object.
* Contains texture objects, display lists, etc.
*/
static CRSharedState *
crStateAllocShared(void)
{
if (s) {
s->textureTable = crAllocHashtable();
s->dlistTable = crAllocHashtable();
}
return s;
}
/**
* Callback used for crFreeHashtable().
*/
static void
DeleteTextureCallback(void *texObj)
{
#ifndef IN_GUEST
#endif
}
/**
* Decrement shared state's refcount and delete when it hits zero.
*/
static void
{
s->refCount--;
if (s->refCount <= 0) {
crFree(s);
}
}
/*
* Helper for crStateCreateContext, below.
*/
static CRContext *
{
int j;
int node32 = i >> 5;
int node = i & 0x1f;
for (j=0;j<CR_MAX_BITARRAY;j++){
if (j == node32) {
} else {
}
}
if (shareCtx) {
}
else {
}
/* use Chromium's OpenGL defaults */
crStateBufferInit( ctx );
crStateFogInit( ctx );
crStateHintInit( ctx );
crStateLineInit( ctx );
crStateListsInit( ctx );
crStatePixelInit( ctx );
crStatePointInit( ctx );
crStateViewportInit ( ctx );
/* This has to come last. */
/* Initialize values that depend on the visual mode */
if (visBits & CR_DOUBLE_BIT) {
}
if (visBits & CR_RGB_BIT) {
if (visBits & CR_ALPHA_BIT) {
}
}
else {
}
if (visBits & CR_DEPTH_BIT) {
}
if (visBits & CR_STENCIL_BIT) {
}
if (visBits & CR_ACCUM_BIT) {
if (visBits & CR_ALPHA_BIT) {
}
}
if (visBits & CR_STEREO_BIT) {
}
if (visBits & CR_MULTISAMPLE_BIT) {
}
if (visBits & CR_OVERLAY_BIT) {
}
return ctx;
}
/*@todo crStateAttribDestroy*/
static void
{
}
/*
* Allocate the state (dirty) bits data structures.
* This should be called before we create any contexts.
* it the current context by default. This means that if someone
* tries to set GL state before calling MakeCurrent() they'll be
* modifying the default state object, and not segfaulting on a NULL
* pointer somewhere.
*/
void crStateInit(void)
{
unsigned int i;
/* Purely initialize the context bits */
if (!__currentBits) {
} else
crWarning("State tracker is being re-initialized..\n");
for (i=0;i<CR_MAX_CONTEXTS;i++)
g_availableContexts[i] = 0;
if (defaultContext) {
* Ensures context bits are reset */
#ifdef CHROMIUM_THREADSAFE
#else
#endif
}
/* Reset diff_api */
CRASSERT(g_availableContexts[0] == 0);
#ifdef CHROMIUM_THREADSAFE
#else
#endif
}
void crStateDestroy(void)
{
if (__currentBits)
{
}
#ifdef CHROMIUM_THREADSAFE
#endif
}
/*
* Notes on context switching and the "default context".
*
* See the paper "Tracking Graphics State for Networked Rendering"
* by Ian Buck, Greg Humphries and Pat Hanrahan for background
* information about how the state tracker and context switching
* works.
*
* When we make a new context current, we call crStateSwitchContext()
* in order to transform the 'from' context into the 'to' context
* (i.e. the old context to the new context). The transformation
* is accomplished by calling GL functions through the 'diff_api'
* so that the downstream GL machine (represented by the __currentContext
* structure) is updated to reflect the new context state. Finally,
* we point __currentContext to the new context.
*
* A subtle problem we have to deal with is context destruction.
* This issue arose while testing with Glean. We found that when
* the currently bound context was getting destroyed that state
* tracking was incorrect when a subsequent new context was activated.
* In DestroyContext, the __hwcontext was being set to NULL and effectively
* going away. Later in MakeCurrent we had no idea what the state of the
* downstream GL machine was (since __hwcontext was gone). This meant
* we had nothing to 'diff' against and the downstream GL machine was
* in an unknown state.
*
* default context is created the first time CreateContext is called
* and is never freed. Whenever we get a crStateMakeCurrent(NULL) call
* or destroy the currently bound context in crStateDestroyContext()
* we call crStateSwitchContext() to switch to the default context and
* then set the __currentContext pointer to point to the default context.
* This ensures that the dirty bits are updated and the diff_api functions
* are called to keep the downstream GL machine in a known state.
* Finally, the __hwcontext variable is no longer needed now.
*
* Yeah, this is kind of a mind-bender, but it really solves the problem
* pretty cleanly.
*
* -Brian
*/
{
int i;
/* Must have created the default context via crStateInit() first */
for (i = 1 ; i < CR_MAX_CONTEXTS ; i++)
{
if (!g_availableContexts[i])
{
}
}
crError( "Out of available contexts in crStateCreateContexts (max %d)",
/* never get here */
return NULL;
}
crStateCreateContextEx(const CRLimitsState *limits, GLint visBits, CRContext *share, GLint presetID)
{
if (presetID>0)
{
}
}
{
/* destroying the current context - have to be careful here */
/* Check to see if the differencer exists first,
we may not have one, aka the packspu */
#ifdef CHROMIUM_THREADSAFE
#else
#endif
/* ensure matrix state is also current */
}
}
{
return; /* no-op */
if (current) {
/* Check to see if the differencer exists first,
we may not have one, aka the packspu */
}
#ifdef CHROMIUM_THREADSAFE
#else
#endif
/* ensure matrix state is also current */
}
/*
* As above, but don't call crStateSwitchContext().
*/
{
return; /* no-op */
#ifdef CHROMIUM_THREADSAFE
#else
#endif
/* ensure matrix state is also current */
}
CRContext *crStateGetCurrent(void)
{
return GetCurrentContext();
}
void crStateUpdateColorBits(void)
{
/* This is a hack to force updating the 'current' attribs */
}
void STATE_APIENTRY
{
/* This no-op function helps smooth code-gen */
}
void STATE_APIENTRY
{
/* This no-op function helps smooth code-gen */
}
void STATE_APIENTRY
{
/* This no-op function helps smooth code-gen */
}
void STATE_APIENTRY
crStateGetChromiumParametervCR( GLenum target, GLuint index, GLenum type, GLsizei count, GLvoid *values )
{
/* This no-op function helps smooth code-gen */
}
void STATE_APIENTRY
{
/* This no-op function helps smooth code-gen */
}