OpenGL:绘制单个巨大原语的性能 [英] OpenGL: Performance of drawing a single gigantic primative

查看:176
本文介绍了OpenGL:绘制单个巨大原语的性能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我绘制一个巨大的基元,其边界远远超过可视区域,例如在X和Y(在NDC空间)覆盖50,000到-50,000的四边形,OpenGL会剪切基元,使其执行方式与if四元组只是刚刚超过NDC空间边界(例如1.1到-1.1)?

If I draw a massive primitive whose bounds far exceed the viewing area, like a quad that covers 50,000 to -50,000 in X and Y (in NDC space), will OpenGL clip the primitive such that it performs just as well as if the quad only barely exceeded NDC space boundaries (1.1 to -1.1 for instance)?

我问的原因是我需要绘制一个网格来调试摄像机,

The reason I ask is I need to draw a grid to debug the camera and how it's viewing a space, and I'm wondering if I can skip manually clipping how long the grid lines are drawn.

推荐答案

如果我们可以看到一个空格,硬件执行剪辑它在规范中描述的方式,绘制一个巨大的原语将是一个只是几乎大于剪辑音量相同的性能。根据规范,通过修改从顶点着色器出来的顶点坐标,并在必要时添加新的顶点,剪辑发生在剪辑坐标空间中。

If the hardware performs clipping the way it's described in the spec, drawing a gigantic primitive will be the same performance as one that is just barely larger than the clip volume. According to the spec, clipping happens in clip coordinate space, by modifying the vertex coordinates coming out of the vertex shader, and adding new vertices if necessary.

这不是保证剪切发生这种方式,虽然。一如往常,实现可以自由地做任何他们想要的,只要他们的行为 他们遵循规范描述。所有我们知道,剪辑发生基于顶点着色器出来的顶点,并且将在剪辑体积之外的片段不会进入片段着色器。

This doesn't guarantee that clipping happens this way, though. As always, implementations are free to do anything they want, as long as they behave as if they followed the spec description. All we know for sure that clipping happens based on the vertices coming out of the vertex shader, and that fragments that would be outside the clip volume will not enter the fragment shader.

在顶点和片段着色器之间的固定功能块中消除不可见部分的程度完全取决于实现。在某些硬件上,它可能发生在顶点空间中。其他人可能首先光栅化,然后消除将在窗口外(或剪刀矩形)的潜在碎片。或者他们可能使用这两种方法的混合,取决于各种标准。

How exactly the invisible parts are eliminated in the fixed function blocks between vertex and fragment shaders is completely up to the implementation. On some hardware, it may happen in vertex space. Others might rasterize first, and then eliminate the potential fragments that would be outside the window (or scissor rectangle). Or they might use a mix of both methods, depending on various criteria.

因此,有可能绘制巨大的图元可能会更慢,因为它可能会导致额外的光栅化开销。唯一的方法来知道,如果这是真正的情况下,你关心的系统,如果它导致可衡量的效果,是尝试它并测量。

So it's possible that drawing gigantic primitives could be slower because it can result in extra rasterization overhead. The only way to know if this is indeed the case on systems you care about, and if it causes a measurable effect, is to try it out and measure.

这篇关于OpenGL:绘制单个巨大原语的性能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆