GLSL maximum number of instructions

爷,独闯天下 提交于 2019-12-04 16:48:52

问题


Is there a maximum number of assembly language instructions to be loaded into the fragment program unit? I have an algorithm on to port from cpu to gpu and apparently it doesn't fit on the gpu.


回答1:


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

  • 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 instruction slots for vertex and pixel shaders on OpenGL 2.x (SM3) capable hardware
    • 65536 executed instructions
  • 4096 vertex and 65536 pixel shader instruction slots on 3.x (SM4) hardware
    • 65536 executed vertex shader instructions, unlimited pixel shader instructions
  • At least 24 dynamic branches possible on 2.x (SM3) hardware
  • Fully dynamic branching (no limits) on SM4 hardware
  • Only conditional move available on SM2.x, everything else must be accomodated by code duplication and loop unrolling, or must fail



回答2:


There is a limit on the maximum amount of instructions a shader can have. As far as I know, it varies from GPU to GPU. If your shader is too large, compilation will generate an error.



来源:https://stackoverflow.com/questions/2617957/glsl-maximum-number-of-instructions

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!