summaryrefslogtreecommitdiff
path: root/src/VBox/GuestHost/OpenGL/spu_loader/spuchange.py
blob: 0f763f8de80063c948e0d4cdbbded479f8f1107d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (c) 2001, Stanford University
# All rights reserved.
#
# See the file LICENSE.txt for information on redistributing this software.

import sys
import apiutil


apiutil.CopyrightC()

print """

/* DO NOT EDIT - THIS FILE AUTOMATICALLY GENERATED BY spuchange.py SCRIPT */

#include "cr_spu.h"
#include "cr_error.h"

void crSPUChangeInterface( SPUDispatchTable *table, void *orig_func, void *new_func )
{
	struct _copy_list_node *temp;
	if (table->mark == 1)
	{
		return;
	}
	if (orig_func == new_func) 
	{
		return;
	}
	table->mark = 1;
"""

keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
for func_name in keys:
	print '\tif ((void *)table->%s == orig_func)' % func_name
	print '\t{'
	print '\t\ttable->%s = (%sFunc_t)new_func;' % (func_name, func_name)
	print '\t\tfor (temp = table->copyList ; temp ; temp = temp->next)'
	print '\t\t{'
	print '\t\t\tcrSPUChangeInterface( temp->copy, orig_func, new_func );'
	print '\t\t}'
	print '\t}'

print """
	if (table->copy_of != NULL)
	{
		crSPUChangeInterface( table->copy_of, orig_func, new_func );
	}
	for (temp = table->copyList ; temp ; temp = temp->next)
	{
		crSPUChangeInterface( temp->copy, orig_func, new_func );
	}
	table->mark = 0;
"""
print '}'

print """
void crSPUChangeDispatch(SPUDispatchTable *dispatch, const SPUNamedFunctionTable *newtable)
{
    SPUGenericFunction func;
"""
keys = apiutil.GetDispatchedFunctions(sys.argv[1]+"/APIspec.txt")
for func_name in keys:
    print '\tfunc = crSPUFindFunction(newtable, "%s");' % func_name
    print '\tif (func && ((SPUGenericFunction)dispatch->%s!=func))' % func_name
    print '\t{'
    print '\t\tcrDebug("%%s changed from %%p to %%p", "gl%s", dispatch->%s, func);' % (func_name, func_name)
    print '\t\tcrSPUChangeInterface(dispatch, dispatch->%s, func);' % func_name
    print '\t}\n'
print """
}
"""