当前位置: 首页>>代码示例>>Python>>正文


Python Tracer.trace_function_impl_body方法代码示例

本文整理汇总了Python中trace.Tracer.trace_function_impl_body方法的典型用法代码示例。如果您正苦于以下问题:Python Tracer.trace_function_impl_body方法的具体用法?Python Tracer.trace_function_impl_body怎么用?Python Tracer.trace_function_impl_body使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在trace.Tracer的用法示例。


在下文中一共展示了Tracer.trace_function_impl_body方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: trace_function_impl_body

# 需要导入模块: from trace import Tracer [as 别名]
# 或者: from trace.Tracer import trace_function_impl_body [as 别名]
    def trace_function_impl_body(self, function):
        # Defer tracing of user array pointers...
        if function.name in self.array_pointer_function_names:
            print "    GLint __array_buffer = 0;"
            print "    __glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);"
            print "    if (!__array_buffer) {"
            print "        __user_arrays = true;"
            self.dispatch_function(function)
            print "        return;"
            print "    }"

        # ... to the draw calls
        if function.name in self.draw_function_names:
            print "    if (__need_user_arrays()) {"
            arg_names = ", ".join([arg.name for arg in function.args[1:]])
            print "        GLuint maxindex = __%s_maxindex(%s);" % (function.name, arg_names)
            print "        __trace_user_arrays(maxindex);"
            print "    }"

        # And also break down glInterleavedArrays into the individual calls
        if function.name == "glInterleavedArrays":
            print "    GLint __array_buffer = 0;"
            print "    __glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);"
            print "    if (!__array_buffer) {"
            print "        __user_arrays = true;"
            self.dispatch_function(function)
            print

            # Initialize the enable flags
            for camelcase_name, uppercase_name in self.arrays:
                flag_name = "__" + uppercase_name.lower()
                print "        GLboolean %s = GL_FALSE;" % flag_name
            print

            # Swicth for the interleaved formats
            print "        switch (format) {"
            for format in self.interleaved_formats:
                print "            case %s:" % format
                for camelcase_name, uppercase_name in self.arrays:
                    flag_name = "__" + uppercase_name.lower()
                    if format.find("_" + uppercase_name[0]) >= 0:
                        print "                %s = GL_TRUE;" % flag_name
                print "                break;"
            print "            default:"
            print "               return;"
            print "        }"
            print

            # Emit fake glEnableClientState/glDisableClientState flags
            for camelcase_name, uppercase_name in self.arrays:
                flag_name = "__" + uppercase_name.lower()
                enable_name = "GL_%s_ARRAY" % uppercase_name

                # Emit a fake function
                print "        {"
                print "            static const Trace::FunctionSig &__sig = %s ? __glEnableClientState_sig : __glDisableClientState_sig;" % flag_name
                print "            unsigned __call = Trace::BeginEnter(__sig);"
                print "            Trace::BeginArg(0);"
                dump_instance(glapi.GLenum, enable_name)
                print "            Trace::EndArg();"
                print "            Trace::EndEnter();"
                print "            Trace::BeginLeave(__call);"
                print "            Trace::EndLeave();"
                print "        }"

            print "        return;"
            print "    }"

        # Emit a fake memcpy on
        if function.name in ("glUnmapBuffer", "glUnmapBufferARB"):
            print "    struct buffer_mapping *mapping = get_buffer_mapping(target);"
            print "    if (mapping && mapping->write) {"
            print "        unsigned __call = Trace::BeginEnter(__memcpy_sig);"
            print "        Trace::BeginArg(0);"
            print "        Trace::LiteralOpaque(mapping->map);"
            print "        Trace::EndArg();"
            print "        Trace::BeginArg(1);"
            print "        Trace::LiteralBlob(mapping->map, mapping->length);"
            print "        Trace::EndArg();"
            print "        Trace::BeginArg(2);"
            print "        Trace::LiteralUInt(mapping->length);"
            print "        Trace::EndArg();"
            print "        Trace::EndEnter();"
            print "        Trace::BeginLeave(__call);"
            print "        Trace::EndLeave();"
            print "    }"

        Tracer.trace_function_impl_body(self, function)
开发者ID:putsman,项目名称:apitrace,代码行数:90,代码来源:gltrace.py

示例2: trace_function_impl_body

# 需要导入模块: from trace import Tracer [as 别名]
# 或者: from trace.Tracer import trace_function_impl_body [as 别名]
    def trace_function_impl_body(self, function):
        # Defer tracing of user array pointers...
        if function.name in self.array_pointer_function_names:
            print '    GLint __array_buffer = 0;'
            print '    __glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);'
            print '    if (!__array_buffer) {'
            print '        __user_arrays = true;'
            self.dispatch_function(function)

            # And also break down glInterleavedArrays into the individual calls
            if function.name == 'glInterleavedArrays':
                print

                # Initialize the enable flags
                for camelcase_name, uppercase_name in self.arrays:
                    flag_name = '__' + uppercase_name.lower()
                    print '        GLboolean %s = GL_FALSE;' % flag_name
                print

                # Switch for the interleaved formats
                print '        switch (format) {'
                for format in self.interleaved_formats:
                    print '            case %s:' % format
                    for camelcase_name, uppercase_name in self.arrays:
                        flag_name = '__' + uppercase_name.lower()
                        if format.find('_' + uppercase_name[0]) >= 0:
                            print '                %s = GL_TRUE;' % flag_name
                    print '                break;'
                print '            default:'
                print '               return;'
                print '        }'
                print

                # Emit fake glEnableClientState/glDisableClientState flags
                for camelcase_name, uppercase_name in self.arrays:
                    flag_name = '__' + uppercase_name.lower()
                    enable_name = 'GL_%s_ARRAY' % uppercase_name

                    # Emit a fake function
                    print '        {'
                    print '            static const Trace::FunctionSig &__sig = %s ? __glEnableClientState_sig : __glDisableClientState_sig;' % flag_name
                    print '            unsigned __call = Trace::BeginEnter(__sig);'
                    print '            Trace::BeginArg(0);'
                    dump_instance(glapi.GLenum, enable_name)
                    print '            Trace::EndArg();'
                    print '            Trace::EndEnter();'
                    print '            Trace::BeginLeave(__call);'
                    print '            Trace::EndLeave();'
                    print '        }'

            print '        return;'
            print '    }'

        # ... to the draw calls
        if function.name in self.draw_function_names:
            print '    if (__need_user_arrays()) {'
            arg_names = ', '.join([arg.name for arg in function.args[1:]])
            print '        GLuint maxindex = __%s_maxindex(%s);' % (function.name, arg_names)
            print '        __trace_user_arrays(maxindex);'
            print '    }'
        
        # Emit a fake memcpy on
        if function.name in ('glUnmapBuffer', 'glUnmapBufferARB'):
            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
            print '    if (mapping && mapping->write) {'
            print '        unsigned __call = Trace::BeginEnter(__memcpy_sig);'
            print '        Trace::BeginArg(0);'
            print '        Trace::LiteralOpaque(mapping->map);'
            print '        Trace::EndArg();'
            print '        Trace::BeginArg(1);'
            print '        Trace::LiteralBlob(mapping->map, mapping->length);'
            print '        Trace::EndArg();'
            print '        Trace::BeginArg(2);'
            print '        Trace::LiteralUInt(mapping->length);'
            print '        Trace::EndArg();'
            print '        Trace::EndEnter();'
            print '        Trace::BeginLeave(__call);'
            print '        Trace::EndLeave();'
            print '    }'

        Tracer.trace_function_impl_body(self, function)
开发者ID:mariuz,项目名称:apitrace,代码行数:83,代码来源:gltrace.py

示例3: trace_function_impl_body

# 需要导入模块: from trace import Tracer [as 别名]
# 或者: from trace.Tracer import trace_function_impl_body [as 别名]
    def trace_function_impl_body(self, function):
        # Defer tracing of user array pointers...
        if function.name in self.array_pointer_function_names:
            print '    GLint __array_buffer = 0;'
            print '    __glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &__array_buffer);'
            print '    if (!__array_buffer) {'
            print '        tracer_context *ctx = __get_context();'
            print '        ctx->user_arrays = true;'
            if function.name == "glVertexAttribPointerARB":
                print '        ctx->user_arrays_arb = true;'
            if function.name == "glVertexAttribPointerNV":
                print '        ctx->user_arrays_nv = true;'
            self.dispatch_function(function)

            # And also break down glInterleavedArrays into the individual calls
            if function.name == 'glInterleavedArrays':
                print

                # Initialize the enable flags
                for camelcase_name, uppercase_name in self.arrays:
                    flag_name = '__' + uppercase_name.lower()
                    print '        GLboolean %s = GL_FALSE;' % flag_name
                print

                # Switch for the interleaved formats
                print '        switch (format) {'
                for format in self.interleaved_formats:
                    print '            case %s:' % format
                    for camelcase_name, uppercase_name in self.arrays:
                        flag_name = '__' + uppercase_name.lower()
                        if format.find('_' + uppercase_name[0]) >= 0:
                            print '                %s = GL_TRUE;' % flag_name
                    print '                break;'
                print '            default:'
                print '               return;'
                print '        }'
                print

                # Emit fake glEnableClientState/glDisableClientState flags
                for camelcase_name, uppercase_name in self.arrays:
                    flag_name = '__' + uppercase_name.lower()
                    enable_name = 'GL_%s_ARRAY' % uppercase_name

                    # Emit a fake function
                    print '        {'
                    print '            static const trace::FunctionSig &__sig = %s ? __glEnableClientState_sig : __glDisableClientState_sig;' % flag_name
                    print '            unsigned __call = trace::localWriter.beginEnter(&__sig);'
                    print '            trace::localWriter.beginArg(0);'
                    dump_instance(glapi.GLenum, enable_name)
                    print '            trace::localWriter.endArg();'
                    print '            trace::localWriter.endEnter();'
                    print '            trace::localWriter.beginLeave(__call);'
                    print '            trace::localWriter.endLeave();'
                    print '        }'

            print '        return;'
            print '    }'

        # ... to the draw calls
        if function.name in self.draw_function_names:
            print '    if (__need_user_arrays()) {'
            arg_names = ', '.join([arg.name for arg in function.args[1:]])
            print '        GLuint maxindex = __%s_maxindex(%s);' % (function.name, arg_names)
            print '        __trace_user_arrays(maxindex);'
            print '    }'
        
        # Emit a fake memcpy on buffer uploads
        if function.name in ('glUnmapBuffer', 'glUnmapBufferARB', ):
            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
            print '    if (mapping && mapping->write && !mapping->explicit_flush) {'
            self.emit_memcpy('mapping->map', 'mapping->map', 'mapping->length')
            print '    }'
        if function.name in ('glFlushMappedBufferRange', 'glFlushMappedBufferRangeAPPLE'):
            print '    struct buffer_mapping *mapping = get_buffer_mapping(target);'
            print '    if (mapping) {'
            if function.name.endswith('APPLE'):
                 print '        GLsizeiptr length = size;'
                 print '        mapping->explicit_flush = true;'
            print '        //assert(offset + length <= mapping->length);'
            self.emit_memcpy('(char *)mapping->map + offset', '(const char *)mapping->map + offset', 'length')
            print '    }'
        # FIXME: glFlushMappedNamedBufferRangeEXT

        # Don't leave vertex attrib locations to chance.  Instead emit fake
        # glBindAttribLocation calls to ensure that the same locations will be
        # used when retracing.  Trying to remap locations after the fact would
        # be an herculian task given that vertex attrib locations appear in
        # many entry-points, including non-shader related ones.
        if function.name == 'glLinkProgram':
            Tracer.dispatch_function(self, function)
            print '    GLint active_attributes = 0;'
            print '    __glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &active_attributes);'
            print '    for (GLint attrib = 0; attrib < active_attributes; ++attrib) {'
            print '        GLint size = 0;'
            print '        GLenum type = 0;'
            print '        GLchar name[256];'
            # TODO: Use ACTIVE_ATTRIBUTE_MAX_LENGTH instead of 256
            print '        __glGetActiveAttrib(program, attrib, sizeof name, NULL, &size, &type, name);'
            print "        if (name[0] != 'g' || name[1] != 'l' || name[2] != '_') {"
            print '            GLint location = __glGetAttribLocation(program, name);'
#.........这里部分代码省略.........
开发者ID:kanru,项目名称:apitrace,代码行数:103,代码来源:gltrace.py


注:本文中的trace.Tracer.trace_function_impl_body方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。