示例#1
0
def IsExtensionFunc(func_name):
	"""Determine if the named function is a core function, or extension."""
	cat = apiutil.Category(func_name)
	if cat == "1.0" or cat == "1.1" or cat == "1.2" or cat == "1.3":
		return 0
	else:
		return 1
示例#2
0
def PrintProto(func_name,f,no_special):
	if no_special == 1:
		if apiutil.FindSpecial( "packertest", func_name ):
			return

	if not allfuncs:
		if not apiutil.HasPackOpcode(func_name):
			return

	pointers_ok = 0

	return_type = apiutil.ReturnType(func_name)
	params = apiutil.Parameters(func_name)

	if "Chromium" == apiutil.Category(func_name):
		is_extended = 1
	else:
		is_extended = 0

	if is_extended:
		f.write( "gl%s gl%s_func = (gl%s_t)crGetProcAddress(\"gl%s\");\n" % (func_name,func_name,func_name,func_name))

	if return_type != 'void':
		# Yet another gross hack for glGetString
		if string.find( return_type, '*' ) == -1:
			return_type = return_type + " *"

	#if "get" in apiutil.Properties(func_name):
			#pointers_ok = 1

	if func_name == 'Writeback':
		pointers_ok = 1

	f.write( 'void crPackTest%s (void);\n' % func_name)
示例#3
0
def GetTestWrapper(func_name):
    """Return a C preprocessor token to test in order to wrap code.
	This handles extensions.
	Example: GetTestWrapper("glActiveTextureARB") = "CR_multitexture"
	Example: GetTestWrapper("glBegin") = ""
	"""
    cat = apiutil.Category(func_name)
    if (cat == "1.0" or cat == "1.1" or cat == "1.2" or cat == "Chromium"
            or cat == "GL_chromium"):
        return ''
    elif cat[0] == '1':
        # i.e. OpenGL 1.3 or 1.4 or 1.5
        return "OPENGL_VERSION_" + string.replace(cat, ".", "_")
    else:
        assert cat != ''
        return string.replace(cat, "GL_", "")
示例#4
0
def PrintDynProto(func_name, f):
	if apiutil.FindSpecial( "packertest", func_name ):
		return

	if not allfuncs:
		if not apiutil.HasPackOpcode(func_name):
			return

	pointers_ok = 0
	params = apiutil.Parameters(func_name)

	if "Chromium" ==  apiutil.Category(func_name):
		is_extended = 1
	else:
		is_extended = 0

	if is_extended:
		f.write( "typedef %s (APIENTRY *gl%s_t) (%s);\n" % (return_type,func_name,apiutil.MakeDeclarationString(params)))
		f.write( "static gl%s_t %s_func;\n" % (func_name,func_name))
示例#5
0
"""

print """
struct name_address {
  const char *name;
  CR_PROC address;
};

PROC WINAPI wglGetProcAddress_prox( LPCSTR name );

static struct name_address functions[] = {
"""

keys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
for func_name in keys:
    if "Chromium" == apiutil.Category(func_name):
        continue
    if "VBox" == apiutil.Category(func_name):
        continue
    if func_name == "BoundsInfoCR":
        continue
    if "GL_chromium" == apiutil.Category(func_name):
        pass  #continue

    wrap = apiutil.GetCategoryWrapper(func_name)
    name = "gl" + func_name
    address = "cr_gl" + func_name
    if wrap:
        print '#ifdef CR_%s' % wrap
    print '\t{ "%s", (CR_PROC) %s },' % (name, address)
    if wrap:
示例#6
0
 * interested in.
 */
int
crLoadOpenGLExtensions( const crOpenGLInterface *interface, SPUNamedFunctionTable table[] )
{
	struct extfunc {
		const char *funcName;
		const char *aliasName;
		SPUGenericFunction nopFunction;
	};
	static const struct extfunc functions[] = {
"""

for func_name in keys:
	if IsExtensionFunc(func_name):
		if apiutil.Category(func_name) == "Chromium":
			prefix = "cr"
		else:
			prefix = "gl"
		s = '\t\t{ "' + prefix + func_name + '", '
		a = apiutil.ReverseAlias(func_name)
		if a:
			s += '"' + prefix + a + '", '
		else:
			s += 'NULL, '
		s += '(SPUGenericFunction) Nop' + func_name + ' },'
		print s

print """
		{ NULL, NULL, NULL}
	};
示例#7
0
def GenerateEntrypoints():

    #apiutil.CopyrightC()

    # Get sorted list of dispatched functions.
    # The order is very important - it must match cr_opcodes.h
    # and spu_dispatch_table.h
    print '%include "iprt/asmdefs.mac"'
    print ""
    print "%ifdef RT_ARCH_AMD64"
    print "extern glim"
    print "%else ; X86"
    print "extern glim"
    print "%endif"
    print ""

    keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

    for index in range(len(keys)):
        func_name = keys[index]
        if apiutil.Category(func_name) == "Chromium":
            continue
        if apiutil.Category(func_name) == "VBox":
            continue

        print "BEGINPROC_EXPORTED gl%s" % func_name
        print "%ifdef RT_ARCH_AMD64"
        print "\tmov \trax, qword glim+%d" % (8 * index)
        print "\tjmp \t[rax]"
        print "%else ; X86"
        print "\tmov \teax, dword glim+%d" % (4 * index)
        print "\tjmp \t[eax]"
        print "%endif"
        print "ENDPROC gl%s" % func_name
        print ""

    print ';'
    print '; Aliases'
    print ';'

    # Now loop over all the functions and take care of any aliases
    allkeys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
    for func_name in allkeys:
        if "omit" in apiutil.ChromiumProps(func_name):
            continue

        if func_name in keys:
            # we already processed this function earlier
            continue

        # alias is the function we're aliasing
        alias = apiutil.Alias(func_name)
        if alias:
            # this dict lookup should never fail (raise an exception)!
            index = keys.index(alias)
            print "BEGINPROC_EXPORTED gl%s" % func_name
            print "%ifdef RT_ARCH_AMD64"
            print "\tmov \trax, qword glim+%d" % (8 * index)
            print "\tjmp \t[rax]"
            print "%else ; X86"
            print "\tmov \teax, dword glim+%d" % (4 * index)
            print "\tjmp \t[eax]"
            print "%endif"
            print "ENDPROC gl%s" % func_name
            print ""

    print ';'
    print '; No-op stubs'
    print ';'

    # Now generate no-op stub functions
    for func_name in allkeys:
        if "stub" in apiutil.ChromiumProps(func_name):
            print "BEGINPROC_EXPORTED gl%s" % func_name
            print "\tleave"
            print "\tret"
            print "ENDPROC gl%s" % func_name
            print ""
示例#8
0
        crFree( rb );
        return;
    }
#ifdef DEBUG_misha
    WARN(("Pending command returns value"));
#endif
    CRDBGPTR_SETZ(&cr_server.writeback_ptr);
    CRDBGPTR_SETZ(&cr_server.return_ptr);
}
""")

keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

for func_name in keys:
    params = apiutil.Parameters(func_name)
    return_type = apiutil.ReturnType(func_name)
    if apiutil.FindSpecial("server", func_name):
        continue
    if "VBox" == apiutil.Category(func_name):
        continue
    if return_type != 'void':
        print('%s SERVER_DISPATCH_APIENTRY crServerDispatch%s(%s)' %
              (return_type, func_name, apiutil.MakeDeclarationString(params)))
        print('{')
        print('\t%s retval;' % return_type)
        print('\tretval = cr_server.head_spu->dispatch_table.%s(%s);' %
              (func_name, apiutil.MakeCallString(params)))
        print('\tcrServerReturnValue( &retval, sizeof(retval) );')
        print('\treturn retval; /* WILL PROBABLY BE IGNORED */')
        print('}')
def GenerateEntrypoints(hacks=[]):
    """Emit code for all the OpenGL/Chromium entrypoints.
    hacks is an optional list of functions which are special cased.
    """

    apiutil.CopyrightC()

    print('#define GL_GLEXT_PROTOTYPES')
    print('#include <stdio.h>')
    print('#include <stdlib.h>')
    print('#include <GL/gl.h>')
    print('#include "chromium.h"')
    print('#include "stub.h"')
    print('#include "dri_glx.h"')
    print('')
    print('#ifdef __GNUC__')
    print('# if (__GNUC__ << 16) + __GNUC_MINOR__ >= 0x40002')
    print('#  pragma GCC diagnostic ignored "-Wunused-parameter"')
    print('# endif')
    print('#endif')

    # Get sorted list of dispatched functions.
    # The order is very important - it must match cr_opcodes.h
    # and spu_dispatch_table.h
    keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

    for index in range(len(keys)):
        func_name = keys[index]
        if apiutil.Category(func_name) == "Chromium":
            # this function is defined in stub.c
            continue

        return_type = apiutil.ReturnType(func_name)
        params = apiutil.Parameters(func_name)

        if func_name in hacks:
            print("/* hacked entrypoint: %s */" % func_name)
            if func_name == "TexImage3D":
                # Pretty common: internalformat is GLenum, not GLint
                print(
                    "void glTexImage3D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
                )
                print("{")
                print(
                    "\tglim.TexImage3D( target, level, (GLint) internalformat, width, height, depth, border, format, type, pixels );"
                )
                print("}")
            elif func_name == "TexImage2D":
                # Pretty common: internalformat is GLenum, not GLint
                print(
                    "void glTexImage2D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
                )
                print("{")
                print(
                    "\tglim.TexImage2D( target, level, (GLint) internalformat, width, height, border, format, type, pixels );"
                )
                print("}")
            elif func_name == "TexImage1D":
                # Pretty common: internalformat is GLenum, not GLint
                print(
                    "void glTexImage1D( GLenum target, GLint level, GLenum internalformat, GLsizei width, GLint border, GLenum format, GLenum type, const GLvoid *pixels )"
                )
                print("{")
                print(
                    "\tglim.TexImage1D( target, level, (GLint) internalformat, width, border, format, type, pixels );"
                )
                print("}")
            elif func_name == "EdgeFlagPointer":
                # second arg is GLboolean instead of GLvoid
                print(
                    "void glEdgeFlagPointer( GLsizei stride, const GLboolean *pointer )"
                )
                print("{")
                print("\tglim.EdgeFlagPointer( stride, pointer );")
                print("}")
            elif func_name == "ProgramParameters4fvNV":
                print(
                    "void glProgramParameters4fvNV( GLenum target, GLuint index, GLuint num, const GLfloat *params )"
                )
                print("{")
                print(
                    "\tglim.ProgramParameters4fvNV( target, index, num, params );"
                )
                print("}")
            elif func_name == "MultiDrawElementsEXT":
                print(
                    "void glMultiDrawElementsEXT(GLenum mode, GLsizei *count, GLenum type, const GLvoid **indices, GLsizei primcount)"
                )
                print("{")
                print(
                    "\tglim.MultiDrawElementsEXT(mode, count,type, indices, primcount);"
                )
                print("}")
            elif func_name == "ProgramParameters4dvNV":
                print(
                    "void glProgramParameters4dvNV( GLenum target, GLuint index, GLuint num, const GLdouble *params )"
                )
                print("{")
                print(
                    "\tglim.ProgramParameters4dvNV( target, index, num, params );"
                )
                print("}")
        else:
            # the usual path
            print("%s VBOXGLTAG(gl%s)(%s);" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("")
            print("%s VBOXGLTAG(gl%s)(%s)" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("{")
            print("\t", end="")
            if return_type != "void":
                print("return ", end=" ")
            print("glim.%s(%s);" % (func_name, apiutil.MakeCallString(params)))
            print("}")
            print("")

    print('/*')
    print('* Aliases')
    print('*/')

    # Now loop over all the functions and take care of any aliases
    allkeys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
    for func_name in allkeys:
        if "omit" in apiutil.ChromiumProps(func_name):
            continue

        if func_name in keys:
            # we already processed this function earlier
            continue

        # alias is the function we're aliasing
        alias = apiutil.Alias(func_name)
        if alias:
            if func_name in hacks:
                print("/* hacked entrypoint: %s */" % func_name)
                if func_name == "MultiDrawArrays":
                    print(
                        "void glMultiDrawArrays( GLenum mode, const GLint *first, const GLsizei *count, GLsizei primcount )"
                    )
                    print("{")
                    print(
                        "\tglim.MultiDrawArraysEXT( mode, (GLint*)first, (GLsizei*)count, primcount );"
                    )
                    print("}")
                elif func_name == "BufferData":
                    print(
                        "void glBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage)"
                    )
                    print("{")
                    print("\tglim.BufferDataARB(target, size, data, usage);")
                    print("}")
                elif func_name == "BufferSubData":
                    print(
                        "void glBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data)"
                    )
                    print("{")
                    print(
                        "\tglim.BufferSubDataARB(target, offset, size, data);")
                    print("}")
                elif func_name == "GetBufferSubData":
                    print(
                        "void glGetBufferSubData(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data)"
                    )
                    print("{")
                    print(
                        "\tglim.GetBufferSubDataARB(target, offset, size, data);"
                    )
                    print("}")
            else:
                return_type = apiutil.ReturnType(func_name)
                params = apiutil.Parameters(func_name)
                print("%s VBOXGLTAG(gl%s)(%s);" %
                      (return_type, func_name,
                       apiutil.MakeDeclarationString(params)))
                print("")
                print("%s VBOXGLTAG(gl%s)(%s)" %
                      (return_type, func_name,
                       apiutil.MakeDeclarationString(params)))
                print("{")
                print("\t", end="")
                if return_type != "void":
                    print("return ", end=" ")
                print("glim.%s(%s);" % (alias, apiutil.MakeCallString(params)))
                print("}")
                print("")

    print('/*')
    print('* No-op stubs')
    print('*/')

    # Now generate no-op stub functions
    for func_name in allkeys:
        if "stub" in apiutil.ChromiumProps(func_name):
            return_type = apiutil.ReturnType(func_name)
            params = apiutil.Parameters(func_name)

            print("%s VBOXGLTAG(gl%s)(%s);" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("")
            print("%s VBOXGLTAG(gl%s)(%s)" %
                  (return_type, func_name,
                   apiutil.MakeDeclarationString(params)))
            print("{")
            if return_type != "void":
                print("return (%s) 0" % return_type)
            print("}")
            print("")
示例#10
0
print """
#ifndef HIDDENLINE_SPU_PROTO_H
#define HIDDENLINE_SPU_PROTO_H 1

"""

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

# Determine which functions to ignore
ignore_functions = []
for func_name in keys:
	if ("get" in apiutil.Properties(func_name) or
		"setclient" in apiutil.Properties(func_name) or
		"useclient" in apiutil.Properties(func_name) or
		apiutil.Category(func_name) == "Chromium" or
		apiutil.Category(func_name) == "GL_chromium"):
		ignore_functions.append(func_name)

specials = apiutil.AllSpecials( "hiddenline" ) + apiutil.AllSpecials( "hiddenline_pixel" )

# emit prototypes
for func_name in specials:
	return_type = apiutil.ReturnType(func_name)
	params = apiutil.Parameters(func_name)
	print 'extern %s HIDDENLINESPU_APIENTRY hiddenlinespu_%s(%s);' % (return_type, func_name, apiutil.MakeDeclarationString(params))


print """
#endif
"""
示例#11
0
    "TexCoord2fv", "TexCoord3f", "TexCoord3fv", "TexCoord4f", "TexCoord4fv",
    "Vertex2f", "Vertex2fv", "Vertex3f", "Vertex3fv", "Vertex4f", "Vertex4fv",
    "VertexAttrib1fNV", "VertexAttrib1fvNV", "VertexAttrib2fNV",
    "VertexAttrib2fvNV", "VertexAttrib3fNV", "VertexAttrib3fvNV",
    "VertexAttrib4fNV", "VertexAttrib4fvNV", "VertexAttrib1fARB",
    "VertexAttrib1fvARB", "VertexAttrib2fARB", "VertexAttrib2fvARB",
    "VertexAttrib3fARB", "VertexAttrib3fvARB", "VertexAttrib4fARB",
    "VertexAttrib4fvARB", "EvalMesh1", "EvalMesh2", "Rectf", "DrawArrays",
    "DrawElements", "DrawRangeElements"
]

# Extern-like declarations
keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

for func_name in keys:
    if "Chromium" == apiutil.Category(func_name):
        continue
    if func_name == "BoundsInfoCR":
        continue

    return_type = apiutil.ReturnType(func_name)
    params = apiutil.Parameters(func_name)

    if func_name in commoncall_special:
        print "extern %s vboxDD_gl%s( %s );" % (
            return_type, func_name, apiutil.MakeDeclarationString(params))
    else:
        if apiutil.MakeDeclarationString(params) == "void":
            print "extern %s vboxDD_gl%s( GLcontext *ctx );" % (return_type,
                                                                func_name)
        else:
示例#12
0
def GenerateEntrypoints():

    apiutil.CopyrightC()

    print '#include "chromium.h"'
    print '#include "stub.h"'
    print ''
    print '#define NAKED __declspec(naked)'
    print '#define UNUSED(x) ((void)(x))'
    print ''

    # Get sorted list of dispatched functions.
    # The order is very important - it must match cr_opcodes.h
    # and spu_dispatch_table.h
    keys = apiutil.GetDispatchedFunctions(sys.argv[1] + "/APIspec.txt")

    for index in range(len(keys)):
        func_name = keys[index]
        if apiutil.Category(func_name) == "Chromium":
            continue
        if apiutil.Category(func_name) == "VBox":
            continue

        return_type = apiutil.ReturnType(func_name)
        params = apiutil.Parameters(func_name)

        print "NAKED %s cr_gl%s( %s )" % (
            return_type, func_name, apiutil.MakeDeclarationString(params))
        print "{"
        print "\t__asm jmp [glim.%s]" % func_name
        for (name, type, vecSize) in params:
            print "\tUNUSED( %s );" % name
        print "}"
        print ""

    print '/*'
    print '* Aliases'
    print '*/'

    # Now loop over all the functions and take care of any aliases
    allkeys = apiutil.GetAllFunctions(sys.argv[1] + "/APIspec.txt")
    for func_name in allkeys:
        if "omit" in apiutil.ChromiumProps(func_name):
            continue

        if func_name in keys:
            # we already processed this function earlier
            continue

        # alias is the function we're aliasing
        alias = apiutil.Alias(func_name)
        if alias:
            return_type = apiutil.ReturnType(func_name)
            params = apiutil.Parameters(func_name)
            print "NAKED %s cr_gl%s( %s )" % (
                return_type, func_name, apiutil.MakeDeclarationString(params))
            print "{"
            print "\t__asm jmp [glim.%s]" % alias
            for (name, type, vecSize) in params:
                print "\tUNUSED( %s );" % name
            print "}"
            print ""

    print '/*'
    print '* No-op stubs'
    print '*/'

    # Now generate no-op stub functions
    for func_name in allkeys:
        if "stub" in apiutil.ChromiumProps(func_name):
            return_type = apiutil.ReturnType(func_name)
            params = apiutil.Parameters(func_name)
            print "NAKED %s cr_gl%s( %s )" % (
                return_type, func_name, apiutil.MakeDeclarationString(params))
            print "{"
            if return_type != "void":
                print "return (%s) 0" % return_type
            print "}"
            print ""
示例#13
0
def GenerateEntrypoints():

	apiutil.CopyrightC()

	# Get sorted list of dispatched functions.
	# The order is very important - it must match cr_opcodes.h
	# and spu_dispatch_table.h
	keys = apiutil.GetDispatchedFunctions("../glapi_parser/APIspec.txt")

	for index in range(len(keys)):
		func_name = keys[index]
		if apiutil.Category(func_name) == "Chromium":
			continue

		print "\t.align 4"
		print ".globl gl%s" % func_name
		print "\t.type gl%s,@function" % func_name
		print "gl%s:" % func_name
		print "\tmovl glim+%d, %%eax" % (4*index)
		print "\tjmp *%eax"
		print ""


	print '/*'
	print '* Aliases'
	print '*/'

	# Now loop over all the functions and take care of any aliases
	allkeys = apiutil.GetAllFunctions("../glapi_parser/APIspec.txt")
	for func_name in allkeys:
		if "omit" in apiutil.ChromiumProps(func_name):
			continue

		if func_name in keys:
			# we already processed this function earlier
			continue

		# alias is the function we're aliasing
		alias = apiutil.Alias(func_name)
		if alias:
			# this dict lookup should never fail (raise an exception)!
			index = keys.index(alias)
			print "\t.align 4"
			print ".globl gl%s" % func_name
			print "\t.type gl%s,@function" % func_name
			print "gl%s:" % func_name
			print "\tmovl glim+%d, %%eax" % (4*index)
			print "\tjmp *%eax"
			print ""


	print '/*'
	print '* No-op stubs'
	print '*/'

	# Now generate no-op stub functions
	for func_name in allkeys:
		if "stub" in apiutil.ChromiumProps(func_name):
			print "\t.align 4"
			print ".globl gl%s" % func_name
			print "\t.type gl%s,@function" % func_name
			print "gl%s:" % func_name
			print "\tleave"
			print "\tret"
			print ""