Пример #1
0
    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
        if function.name in self.array_pointer_function_names and arg.name == 'pointer':
            print '    %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)
            return

        if function.name in self.draw_elements_function_names and arg.name == 'indices' or\
           function.name in self.draw_indirect_function_names and arg.name == 'indirect':
            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
            return

        # Handle pointer with offsets into the current pack pixel buffer
        # object.
        if function.name in self.pack_function_names and arg.output:
            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
            return

        if arg.type is glapi.GLlocation \
           and 'program' not in function.argNames():
            print '    GLint program = -1;'
            print '    glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
        
        if arg.type is glapi.GLlocationARB \
           and 'programObj' not in function.argNames():
            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'

        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)

        # Don't try to use more samples than the implementation supports
        if arg.name == 'samples':
            assert arg.type is glapi.GLsizei
            print '    GLint max_samples = 0;'
            print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
            print '    if (samples > max_samples) {'
            print '        samples = max_samples;'
            print '    }'
Пример #2
0
    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
        if function.name in self.array_pointer_function_names and arg.name == 'pointer':
            print '    %s = static_cast<%s>(retrace::toPointer(%s, true));' % (
                lvalue, arg_type, rvalue)
            return

        if self.draw_elements_function_regex.match(function.name) and arg.name == 'indices' or\
           self.draw_indirect_function_regex.match(function.name) and arg.name == 'indirect':
            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
            return

        # Handle pointer with offsets into the current pack pixel buffer
        # object.
        if self.pack_function_regex.match(function.name) and arg.output:
            assert isinstance(
                arg_type,
                (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque))
            print '    %s = static_cast<%s>((%s).toPointer());' % (
                lvalue, arg_type, rvalue)
            return
        if function.name.startswith('glGetQueryObject') and arg.output:
            print '    %s = static_cast<%s>((%s).toPointer());' % (
                lvalue, arg_type, rvalue)
            return

        if (arg.type.depends(glapi.GLlocation) or \
            arg.type.depends(glapi.GLsubroutine)) \
           and 'program' not in function.argNames():
            # Determine the active program for uniforms swizzling
            print '    GLint program = _getActiveProgram();'

        if arg.type is glapi.GLlocationARB \
           and 'programObj' not in function.argNames():
            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'

        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)

        # Don't try to use more samples than the implementation supports
        if arg.name == 'samples':
            if function.name == 'glRasterSamplesEXT':
                assert arg.type is glapi.GLuint
                print '    GLint max_samples = 0;'
                print '    glGetIntegerv(GL_MAX_RASTER_SAMPLES_EXT, &max_samples);'
                print '    if (samples > static_cast<GLuint>(max_samples)) {'
                print '        samples = static_cast<GLuint>(max_samples);'
                print '    }'
            else:
                assert arg.type is glapi.GLsizei
                print '    GLint max_samples = 0;'
                print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
                print '    if (samples > max_samples) {'
                print '        samples = max_samples;'
                print '    }'

        # These parameters are referred beyond the call life-time
        # TODO: Replace ad-hoc solution for bindable parameters with general one
        if function.name in ('glFeedbackBuffer',
                             'glSelectBuffer') and arg.output:
            print '    _allocator.bind(%s);' % arg.name
Пример #3
0
    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
        if function.name in self.array_pointer_function_names and arg.name == 'pointer':
            print '    %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)
            return

        if function.name in self.draw_elements_function_names and arg.name == 'indices' or\
           function.name in self.draw_indirect_function_names and arg.name == 'indirect':
            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
            return

        # Handle pointer with offsets into the current pack pixel buffer
        # object.
        if function.name in self.pack_function_names and arg.output:
            assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque))
            print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue)
            return

        if arg.type is glapi.GLlocation \
           and 'program' not in function.argNames():
            # Determine the active program for uniforms swizzling
            print '    GLint program = -1;'
            print '    if (glretrace::insideList) {'
            print '        // glUseProgram & glUseProgramObjectARB are display-list-able'
            print r'    glretrace::Context *currentContext = glretrace::getCurrentContext();'
            print '        program = _program_map[currentContext->activeProgram];'
            print '    } else {'
            print '        GLint pipeline = 0;'
            print '        if (_pipelineHasBeenBound) {'
            print '            glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);'
            print '        }'
            print '        if (pipeline) {'
            print '            glGetProgramPipelineiv(pipeline, GL_ACTIVE_PROGRAM, &program);'
            print '        } else {'
            print '            glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
            print '        }'
            print '    }'
            print

        if arg.type is glapi.GLlocationARB \
           and 'programObj' not in function.argNames():
            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'

        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)

        # Don't try to use more samples than the implementation supports
        if arg.name == 'samples':
            assert arg.type is glapi.GLsizei
            print '    GLint max_samples = 0;'
            print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
            print '    if (samples > max_samples) {'
            print '        samples = max_samples;'
            print '    }'

        # These parameters are referred beyond the call life-time
        # TODO: Replace ad-hoc solution for bindable parameters with general one
        if function.name in ('glFeedbackBuffer', 'glSelectBuffer') and arg.output:
            print '    _allocator.bind(%s);' % arg.name
Пример #4
0
    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
        if function.name in self.array_pointer_function_names and arg.name == 'pointer':
            print '    %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)
            return

        if self.draw_elements_function_regex.match(function.name) and arg.name == 'indices' or\
           self.draw_indirect_function_regex.match(function.name) and arg.name == 'indirect':
            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
            return

        # Handle pointer with offsets into the current pack pixel buffer
        # object.
        if self.pack_function_regex.match(function.name) and arg.output:
            assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque))
            print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue)
            return
        if function.name.startswith('glGetQueryObject') and arg.output:
            print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue)
            return

        if (arg.type.depends(glapi.GLlocation) or \
            arg.type.depends(glapi.GLsubroutine)) \
           and 'program' not in function.argNames():
            # Determine the active program for uniforms swizzling
            print '    GLint program = _getActiveProgram();'

        if arg.type is glapi.GLlocationARB \
           and 'programObj' not in function.argNames():
            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'

        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)

        # Don't try to use more samples than the implementation supports
        if arg.name == 'samples':
            if function.name == 'glRasterSamplesEXT':
                assert arg.type is glapi.GLuint
                print '    GLint max_samples = 0;'
                print '    glGetIntegerv(GL_MAX_RASTER_SAMPLES_EXT, &max_samples);'
                print '    if (samples > static_cast<GLuint>(max_samples)) {'
                print '        samples = static_cast<GLuint>(max_samples);'
                print '    }'
            else:
                assert arg.type is glapi.GLsizei
                print '    GLint max_samples = 0;'
                print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
                print '    if (samples > max_samples) {'
                print '        samples = max_samples;'
                print '    }'

        # These parameters are referred beyond the call life-time
        # TODO: Replace ad-hoc solution for bindable parameters with general one
        if function.name in ('glFeedbackBuffer', 'glSelectBuffer') and arg.output:
            print '    _allocator.bind(%s);' % arg.name
Пример #5
0
    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
        if function.name in self.array_pointer_function_names and arg.name == "pointer":
            print "    %s = static_cast<%s>(retrace::toPointer(%s, true));" % (lvalue, arg_type, rvalue)
            return

        if (
            function.name in self.draw_elements_function_names
            and arg.name == "indices"
            or function.name in self.draw_indirect_function_names
            and arg.name == "indirect"
        ):
            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
            return

        # Handle pointer with offsets into the current pack pixel buffer
        # object.
        if function.name in self.pack_function_names and arg.output:
            assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque))
            print "    %s = static_cast<%s>((%s).toPointer());" % (lvalue, arg_type, rvalue)
            return

        if arg.type is glapi.GLlocation and "program" not in function.argNames():
            # Determine the active program for uniforms swizzling
            print "    GLint program = -1;"
            print "    GLint pipeline = 0;"
            print "    if (_pipelineHasBeenBound) {"
            print "        glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);"
            print "    }"
            print "    if (pipeline) {"
            print "        glGetProgramPipelineiv(pipeline, GL_ACTIVE_PROGRAM, &program);"
            print "    } else {"
            print "        glGetIntegerv(GL_CURRENT_PROGRAM, &program);"
            print "    }"
            print

        if arg.type is glapi.GLlocationARB and "programObj" not in function.argNames():
            print "    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);"

        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)

        # Don't try to use more samples than the implementation supports
        if arg.name == "samples":
            assert arg.type is glapi.GLsizei
            print "    GLint max_samples = 0;"
            print "    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);"
            print "    if (samples > max_samples) {"
            print "        samples = max_samples;"
            print "    }"

        # These parameters are referred beyond the call life-time
        # TODO: Replace ad-hoc solution for bindable parameters with general one
        if function.name in ("glFeedbackBuffer", "glSelectBuffer") and arg.output:
            print "    _allocator.bind(%s);" % arg.name
Пример #6
0
    def extractArg(self, function, arg, arg_type, lvalue, rvalue):
        if function.name in self.array_pointer_function_names and arg.name == 'pointer':
            print '    %s = static_cast<%s>(retrace::toPointer(%s, true));' % (lvalue, arg_type, rvalue)
            return

        if function.name in self.draw_elements_function_names and arg.name == 'indices' or\
           function.name in self.draw_indirect_function_names and arg.name == 'indirect':
            self.extractOpaqueArg(function, arg, arg_type, lvalue, rvalue)
            return

        # Handle pointer with offsets into the current pack pixel buffer
        # object.
        if function.name in self.pack_function_names and arg.output:
            assert isinstance(arg_type, (stdapi.Pointer, stdapi.Array, stdapi.Blob, stdapi.Opaque))
            print '    %s = static_cast<%s>((%s).toPointer());' % (lvalue, arg_type, rvalue)
            return

        if arg.type is glapi.GLlocation \
           and 'program' not in function.argNames():
            print '    GLint program = -1;'
            print '    glGetIntegerv(GL_CURRENT_PROGRAM, &program);'
        
        if arg.type is glapi.GLlocationARB \
           and 'programObj' not in function.argNames():
            print '    GLhandleARB programObj = glGetHandleARB(GL_PROGRAM_OBJECT_ARB);'

        Retracer.extractArg(self, function, arg, arg_type, lvalue, rvalue)

        # Don't try to use more samples than the implementation supports
        if arg.name == 'samples':
            assert arg.type is glapi.GLsizei
            print '    GLint max_samples = 0;'
            print '    glGetIntegerv(GL_MAX_SAMPLES, &max_samples);'
            print '    if (samples > max_samples) {'
            print '        samples = max_samples;'
            print '    }'

        # These parameters are referred beyond the call life-time
        # TODO: Replace ad-hoc solution for bindable parameters with general one
        if function.name in ('glFeedbackBuffer', 'glSelectBuffer') and arg.output:
            print '    _allocator.bind(%s);' % arg.name