(未使用的)GLSL制服/进/出有助于形成压力吗? [英] Do (Unused) GLSL uniforms/in/out Contribute to Register Pressure?

查看:67
本文介绍了(未使用的)GLSL制服/进/出有助于形成压力吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道制服在记忆中的表现方式.

I don't know how uniforms are represented in memory.

制服似乎会占用宝贵的寄存器空间,但是最终它们会传入/传出/传出到全局内存中,对吧?

Uniforms seem like they could take up valuable register space, but they're ultimately passed in/through/out into global memory, right?

不用制服时情况会改变吗?编译器可以优化它们吗?-在这种情况下,我已经获得了无效的(-1)作为绑定位置,因此我认为是.

Does the situation change when the uniforms are unused? Can the compiler optimize them away?--I have gotten invalid (-1) as a binding location when this is the case, so I assume yes.

推荐答案

首先,GLSL规范并未对其概念的实际实现进行任何说明,因此以下详细说明当然应理解为可以无论如何,但如今通常是那样."

First of all the GLSL specification doesn't say anything about the actual implementation of it's concepts, so the following elaborations are of course to be read as "could be any way, but nowadays it's usually that way".

就我(可能有限)的图形硬件知识而言,制服通常存在于所谓的恒定内存中,该内存是全局设备内存的一部分(并且甚至应缓存在较新的硬件上),因为它们无法更改无论如何,都是由着色器程序进行的,并且对于该程序的所有调用都是全局的(可以并且应该在不同的多处理器上并行运行).因此,它们本身不会占用任何每个多处理器的寄存器空间.

As to my (maybe limited) knowledge about graphics hardware, uniforms usually live in the so-called constant memory, which is part of the global device memory (and on newer hardware should even be cached), since they cannot be changed by the shader program anyway and are global to all invocations of the program (that could and should run on different multiprocessors in parallel). So they don't take up any per-multiprocessor register space themselves.

您也是对的,因为GLSL编译器可以(并且通常会)优化掉所有未使用的制服(以及属性),但前提是,当然,前提是那些未在任何可能的执行分支中使用的制服.因此,您获得统一位置-1的经历是完全正确的(并且通常是期望的)行为.

You are also right in that the GLSL compiler can (and usually will) optimize away any unused uniforms (and also attributes), but only if those are not used in any possible branch of execution, of course. So what you experienced with getting a uniform location of -1 is perfectly valid (and usually desired) behaviour.

这篇关于(未使用的)GLSL制服/进/出有助于形成压力吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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