072f0b86f23a38efb7454da3144cbce76805be76vboxsync# $Id$
072f0b86f23a38efb7454da3144cbce76805be76vboxsync# This script generates calls for display list compilation
072f0b86f23a38efb7454da3144cbce76805be76vboxsync# and state management.
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncimport sys
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncsys.path.append( "../../glapi_parser" )
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncimport apiutil
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncapiutil.CopyrightC()
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncprint """
072f0b86f23a38efb7454da3144cbce76805be76vboxsync/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY expando.py SCRIPT */
072f0b86f23a38efb7454da3144cbce76805be76vboxsync#include <stdio.h>
072f0b86f23a38efb7454da3144cbce76805be76vboxsync#include "cr_error.h"
072f0b86f23a38efb7454da3144cbce76805be76vboxsync#include "cr_spu.h"
072f0b86f23a38efb7454da3144cbce76805be76vboxsync#include "cr_dlm.h"
072f0b86f23a38efb7454da3144cbce76805be76vboxsync#include "expandospu.h"
072f0b86f23a38efb7454da3144cbce76805be76vboxsync"""
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncallFunctions = []
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncgeneratedFunctions = []
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncfor func_name in apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt"):
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if apiutil.FindSpecial("expando", func_name):
072f0b86f23a38efb7454da3144cbce76805be76vboxsync allFunctions.append(func_name)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync elif apiutil.CanCompile(func_name) or apiutil.SetsClientState(func_name):
072f0b86f23a38efb7454da3144cbce76805be76vboxsync generatedFunctions.append(func_name)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync allFunctions.append(func_name)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncfor func_name in generatedFunctions:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync params = apiutil.Parameters(func_name)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync return_type = apiutil.ReturnType(func_name)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync basicCallString = apiutil.MakeCallString(params)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync declarationString = apiutil.MakeDeclarationString(params)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync dlmCallString = basicCallString
072f0b86f23a38efb7454da3144cbce76805be76vboxsync chromiumProps = apiutil.ChromiumProps(func_name)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync needClientState = 0
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if apiutil.UsesClientState(func_name):
072f0b86f23a38efb7454da3144cbce76805be76vboxsync dlmCallString = basicCallString + ", clientState"
072f0b86f23a38efb7454da3144cbce76805be76vboxsync needClientState = 1
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync needDL = 0
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if apiutil.CanCompile(func_name):
072f0b86f23a38efb7454da3144cbce76805be76vboxsync needDL = 1
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print 'static %s EXPANDOSPU_APIENTRY expando%s( %s )' % ( return_type, func_name, declarationString)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '{'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if needDL:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\tGLenum dlMode = crDLMGetCurrentMode();'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if needClientState:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\tCRContext *stateContext = crStateGetCurrent();'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\tCRClientState *clientState = NULL;'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\tif (stateContext != NULL) {'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\t\tclientState = &(stateContext->client);'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\t}'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if needDL:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if "checklist" in chromiumProps:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\tif (dlMode != GL_FALSE && crDLMCheckList%s(%s)) {' % (func_name, basicCallString)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync else:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\tif (dlMode != GL_FALSE) {'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\t\tcrDLMCompile%s(%s);' % (func_name, dlmCallString)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync # If we're only compiling, return now.
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\t\tif (dlMode == GL_COMPILE) return %s;' % '0' if return_type != "void" else ""
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\t}'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync # If it gets this far, we're either just executing, or executing
072f0b86f23a38efb7454da3144cbce76805be76vboxsync # and compiling. Either way, pass the call to the super SPU,
072f0b86f23a38efb7454da3144cbce76805be76vboxsync # and to the state tracker (if appropriate; note that we only
072f0b86f23a38efb7454da3144cbce76805be76vboxsync # track client-side state, not all state).
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if return_type != "void":
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\t%s rc = expando_spu.super.%s(%s);' % (return_type, func_name, basicCallString)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync else:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\texpando_spu.super.%s(%s);' % (func_name, basicCallString)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if apiutil.SetsClientState(func_name):
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\tcrState%s( %s );' % (func_name, basicCallString)
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync if return_type != "void":
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print "\treturn rc;"
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '}'
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print ''
072f0b86f23a38efb7454da3144cbce76805be76vboxsync
072f0b86f23a38efb7454da3144cbce76805be76vboxsync# Generate the table of named functions. including all the static generated
072f0b86f23a38efb7454da3144cbce76805be76vboxsync# functions as well as the special functions.
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncprint 'SPUNamedFunctionTable _cr_expando_table[] = {'
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncfor func_name in allFunctions:
072f0b86f23a38efb7454da3144cbce76805be76vboxsync print '\t{ "%s", (SPUGenericFunction) expando%s },' % (func_name, func_name )
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncprint '\t{ NULL, NULL }'
072f0b86f23a38efb7454da3144cbce76805be76vboxsyncprint '};'