且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

GLSL最大指令数

更新时间:2023-02-26 18:00:31

存在一些硬性限制和软性限制,其中一些并不立即显而易见:

There are several hard and soft limits, some of which are not immediately obvious:

  • 指令槽:硬件可以在本地内存中容纳的指令总数.
  • 已执行指令:将要执行的最大指令数(包括在循环中运行多次的指令)
  • 一条GLSL指令可以映射到十几条或更多指令
  • 根据优化程序的质量(例如乘加,点,lerp),几条GLSL指令可以映射到一条指令
  • 有限的临时寄存器(仅32个)可能需要比SM4之前的硬件所需的指令更多的指令(​​对于4096,则没有这种问题).
  • 如今,
  • 打扰通常不需要额外的指令,但是在某些较旧的硬件上确实需要,并且在某些硬件上在某些情况下可以(尤其是gl_FragColor是这样的一种选择)
  • 不管实际使用的指令如何,OpenGL 2.0兼容的硬件仅限于8个依赖纹理的获取(在可以执行OpenGL 2.1或更高版本的硬件上不受限制)
  • Instruction slots: The total number of instructions that the hardware can accomodate in local memory.
  • Executed instructions: The maximum number of instructions that will execute (including instructions that run several times in a loop)
  • A single GLSL instruction can map to a dozen or more instructions
  • Several GLSL instructions can map to a single instruction depending on the optimizer's quality (e.g. multiply-add, dot, lerp)
  • Limited temp registers (only 32) may require more instructions than necessary on pre-SM4 hardware (no such problem with 4096).
  • Swizzling usually does not cost extra instructions nowadays, but does on some older hardware, and may in some situations on some hardware (esp. gl_FragColor is such a candidate)
  • Regardless of actual instructions, OpenGL 2.0 compatible hardware is limited to 8 dependent texture fetches (unlimited on hardware that can do OpenGL 2.1 or better)

您具有这些保证的下限(大多数卡具有更多下注):

You have these guaranteed minimums (most cards have more):

  • 512个指令槽,用于支持OpenGL 2.x(SM3)的硬件上的顶点和像素着色器
    • 65536已执行指令
    • 512 instruction slots for vertex and pixel shaders on OpenGL 2.x (SM3) capable hardware
      • 65536 executed instructions
      • 65536执行的顶点着色器指令,无限像素着色器指令