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


Python Graphics.compareDepthBuffers方法代码示例

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


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

示例1: calculateStatistics

# 需要导入模块: import Graphics [as 别名]
# 或者: from Graphics import compareDepthBuffers [as 别名]
def calculateStatistics(project, trace):
  """
  Calculate derived OpenGL ES statistics instrumentation sensor data and trace events.
  """
  
  if not "code" in project.targets:
    raise ValueError("No code information in project file")

  task      = Task.startTask("gles-stats", "Calculating OpenGL ES statistics", len(trace.events))
  library   = project.targets["code"].library
  constants = Collections.DictProxy(library.constants)
  
  # Create the derived sensors
  trace.sensors["average_triangle_size"]   = Trace.InstrumentationSensor("Average triangle size", isAverage = True)
  trace.sensors["texel_fetches_per_pixel"] = Trace.InstrumentationSensor("Texel fetches per pixel", isAverage = True)
  trace.sensors["texel_uploads"]           = Trace.InstrumentationSensor("Texel uploads")
  trace.sensors["vertices_in"]             = Trace.InstrumentationSensor("Vertices in")
  trace.sensors["triangles_in"]            = Trace.InstrumentationSensor("Triangles in")
  trace.sensors["render_calls"]            = Trace.InstrumentationSensor("Rendering calls")
  trace.sensors["rasterizer_discarded_pixels"] = Trace.InstrumentationSensor("Rasterizer discarded pixels")
  trace.sensors["draw_ratio"]              = Trace.InstrumentationSensor("Draw ratio")
  
  prevRenderEvent = None
  depthMask       = 1
  
  for event in trace.events:
    task.step()
    
    func = library.functions[event.name]

    if func.isRenderCall:
      event.sensorData["render_calls"] = 1

    if func.isRenderCall and "count" in event.values and "mode" in event.values:
      m = event.values["mode"]
      if m == constants.GL_TRIANGLES:
        event.sensorData["triangles_in"] = int(event.values["count"] / 3)
      elif m == constants.GL_TRIANGLE_STRIP:
        event.sensorData["triangles_in"] = int(event.values["count"] - 2)
      elif m == constants.GL_TRIANGLE_FAN:
        event.sensorData["triangles_in"] = int(event.values["count"] - 2)
      elif m == constants.GL_POINTS:
        event.sensorData["triangles_in"] = int(event.values["count"] * 2)
      elif m == constants.GL_LINES:
        event.sensorData["triangles_in"] = int(event.values["count"])
      elif m == constants.GL_LINE_STRIP:
        event.sensorData["triangles_in"] = int(event.values["count"] * 2)
      elif m == constants.GL_LINE_LOOP:
        event.sensorData["triangles_in"] = int(event.values["count"] * 2 + 2)

    fragments  = event.sensorData.get("rasterizer_pixels", 0)
    triangles  = event.sensorData.get("triangles_in", 0)
    texFetches = event.sensorData.get("rasterizer_texel_fetches", 0)
    
    if triangles and fragments:
      event.sensorData["average_triangle_size"] = fragments / float(triangles)
      
    if fragments and texFetches:
      event.sensorData["texel_fetches_per_pixel"] = fragments / float(texFetches)
      
    if event.name in ["glTexImage2D", "glTexSubImage2D"]:
      event.sensorData["texel_uploads"] = int(event.values["width"] * event.values["height"])

    if func.isRenderCall and "count" in event.values:
      event.sensorData["vertices_in"] = int(event.values["count"])
      
    if event.name == "glDepthMask":
      depthMask = event.values["flag"]
      
    # If we have the depth buffers for this event and the previous draw event, see how many pixels
    # actually changed and use that value to estimate overdraw
    if func.isRenderCall and not "rasterizer_discarded_pixels" in event.sensorData:
      if depthMask and prevRenderEvent and "depth_stride" in event.sensorData and "depth_mask" in event.sensorData:
        f1 = player.Instrumentation.getBufferFileName(prevRenderEvent, "depth")
        f2 = player.Instrumentation.getBufferFileName(event, "depth")
        if f1 and f2:
          diff = Graphics.compareDepthBuffers(f1, f2, event.sensorData["depth_stride"], event.sensorData["depth_mask"])
          event.sensorData["rasterizer_discarded_pixels"] = fragments - diff
      prevRenderEvent = event
    
    discFragments = event.sensorData.get("rasterizer_discarded_pixels", 0)
    width         = event.sensorData.get("render_surface_width", 0)
    height        = event.sensorData.get("render_surface_height", 0)

    if fragments and width and height:
      event.sensorData["draw_ratio"] = (fragments - discFragments) / float(width * height)
开发者ID:se210,项目名称:tracy,代码行数:88,代码来源:GlesTraceOperations.py


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