Ejemplo n.º 1
0
def wrap_compile(functionName):
    params = apiutil.Parameters(functionName)
    return_type = apiutil.ReturnType(functionName)
    # Make sure the return type is void.  It's nonsensical to compile
    # an element with any other return type.
    if return_type != 'void':
        print '/* Nonsense: DL function %s has a %s return type?!? */' % (
            functionName, return_type)

    # Define a structure to hold all the parameters.  Note that the
    # top parameters must exactly match the DLMInstanceList structure
    # in include/cr_dlm.h, or everything will break horribly.
    # Start off by getting all the pointer info we could ever use
    # from the parameters
    (pointers, pointername, pointerarg, pointertype, pointersize,
     pointercomment) = GetPointerInfo(functionName)

    # Finally, the compile wrapper.  This one will diverge strongly
    # depending on whether or not there are pointer parameters.
    callstring = apiutil.MakeCallString(params)
    argstring = apiutil.MakeDeclarationString(params)
    props = apiutil.Properties(functionName)
    if "useclient" in props or "pixelstore" in props:
        callstring += ", c"
        argstring += ", CRClientState *c"
    print 'void DLM_APIENTRY crDLMCompile%s(%s)' % (functionName, argstring)
    print '{'
    print '    CRDLMContextState *state = CURRENT_STATE();'
    print '    struct instance%s *instance;' % (functionName)

    # The calling SPU is supposed to verify that the element is supposed to be
    # compiled before it is actually compiled; typically, this is done based
    # on whether a glNewList has been executed more recently than a glEndList.
    # But some functions are dual-natured, sometimes being compiled, and sometimes
    # being executed immediately.  We can check for this here.
    if "checklist" in apiutil.ChromiumProps(functionName):
        print '    if (crDLMCheckList%s(%s))' % (
            functionName, apiutil.MakeCallString(params))
        print '    {'
        print '        crdlm_error(__LINE__, __FILE__, GL_INVALID_OPERATION,'
        print '            "this instance of function %s should not be compiled");' % functionName
        print '        return;'
        print '    }'

    if len(pointers) > 1 or pointersize == 'special':
        # Pass NULL, to just allocate space
        print '    instance = crCalloc(sizeof(struct instance%s) + crdlm_pointers_%s(NULL, %s));' % (
            functionName, functionName, callstring)
    else:
        print '    instance = crCalloc(sizeof(struct instance%s));' % (
            functionName)
    print '    if (!instance)'
    print '    {'
    print '        crdlm_error(__LINE__, __FILE__, GL_OUT_OF_MEMORY,'
    print '            "out of memory adding %s to display list");' % (
        functionName)
    print '        return;'
    print '    }'

    # Put in the fields that must always exist
    print '    instance->execute = execute%s;' % functionName

    # Apply all the simple (i.e. non-pointer) parameters
    for index in range(len(params)):
        if index not in pointers:
            name = params[index][0]
            print '    instance->%s = %s;' % (name, name)

    # We need to know instance size in bytes in order to save its state later.
    print '    instance->cbInstance = sizeof(struct instance%s);' % functionName

    # Set OPCODE.
    print '    instance->iVBoxOpCode = VBOX_DL_OPCODE_%s;' % functionName

    # If there's a pointer parameter, apply it.
    if len(pointers) == 1:

        print '    if (%s == NULL)' % (params[pointers[0]][0])
        print '        instance->%s = NULL;' % (params[pointers[0]][0])
        print '    else'
        print '        instance->%s = instance->%s;' % (params[pointers[0]][0],
                                                        pointerarg)

        if pointersize == 'special':
            print '    instance->cbInstance += crdlm_pointers_%s(instance, %s);' % (
                functionName, callstring)
        else:
            print '    crMemcpy((void *)instance->%s, (void *) %s, %s*sizeof(%s));' % (
                params[pointers[0]][0], params[pointers[0]][0], pointersize,
                pointertype)
    elif len(pointers) == 2:
        # this seems to work
        print '    instance->cbInstance += crdlm_pointers_%s(instance, %s);' % (
            functionName, callstring)
    elif len(pointers) > 2:
        print "#error don't know how to handle pointer parameters for %s" % (
            functionName)

    # Add the element to the current display list
    AddInstanceToList('    ')
    # If the element is a state-changing element, add it to the current state list
    if apiutil.SetsTrackedState(functionName):
        AddInstanceToStateList('    ')
    print '}'
Ejemplo n.º 2
0
#include "packspu_proto.h"

/* This function is called through the dispatch table below when we hit a
 * compiled CallList function. Essentially a recursive hack. */
static void PACKSPU_APIENTRY packspu_StateCallList( GLuint list )
{
    crDLMReplayListState(list, &pack_spu.state_DT);
}
    
/* This function is called through the dispatch table below when we hit a
 * compiled CallLists function. Essentially a recursive hack. */
static void PACKSPU_APIENTRY packspu_StateCallLists( GLsizei n, GLenum type, const GLvoid * lists )
{
    crDLMReplayListsState(n, type, lists, &pack_spu.state_DT);
}

void packspuCreateStateTable( void )
{"""

keys = apiutil.GetDispatchedFunctions("../glapi_parser/APIspec.txt")

for func_name in keys:
	# These functions are special to the state API
	if func_name in ['CallList', 'CallLists']:
	    print '\tpack_spu.state_DT.%s = (%sFunc_t) packspu_State%s;' % (func_name, func_name, func_name)
	elif apiutil.SetsTrackedState(func_name):
	    print '\tpack_spu.state_DT.%s = (%sFunc_t) crState%s;' % (func_name, func_name, func_name)
	else:
	    print '\tpack_spu.state_DT.%s = NULL;' % (func_name)
print '}'
Ejemplo n.º 3
0
"""

pack_specials = []

keys = apiutil.GetDispatchedFunctions("../glapi_parser/APIspec.txt")

# make list of special functions
## VMGL: Because of state resume, a few more functions have specialized
## implementations by the new autogen script
for func_name in keys:
    if ("get" in apiutil.Properties(func_name)
            or apiutil.FindSpecial("packspu", func_name)
            or apiutil.FindSpecial("packspu_flush", func_name)
            or apiutil.FindSpecial("packspu_vertex", func_name)
            or apiutil.CanCompile(func_name)
            or apiutil.SetsTrackedState(func_name)):

        pack_specials.append(func_name)

for func_name in keys:
    if apiutil.FindSpecial("packspu_unimplemented", func_name):
        continue
    if func_name in pack_specials:
        return_type = apiutil.ReturnType(func_name)
        params = apiutil.Parameters(func_name)
        print 'extern %s PACKSPU_APIENTRY packspu_%s( %s );' % (
            return_type, func_name, apiutil.MakeDeclarationString(params))

print """
#endif
"""
Ejemplo n.º 4
0
			print 'extern %s TILESORTSPU_APIENTRY tilesortspu_State%s( %s );' % (return_type, func_name, declarationString)
		continue


	# This dispatch table is used only for replaying display lists state.
	# It can safely have NULL entries in all the non-compilable or non-state functions.
	if not apiutil.CanCompile(func_name):
		if mode == 'table':
			print '\tt->%s = NULL;' % func_name
		elif mode == 'header':
			pass
		continue

	# The only entries left are those that manage tracked state.  Everything
	# else gets a NULL.
	if not apiutil.SetsTrackedState(func_name):
		if mode == 'table':
			print '\tt->%s = NULL;' % func_name
		elif mode == 'header':
			pass
	else:
		if mode == 'table':
			print '\tt->%s = crState%s;' % (func_name, func_name)
		elif mode == 'header':
			pass


# Done with the whole file.  Print out any ending necessary.
if mode == 'table':
	print '}'
elif mode == 'header':