poke1024 / tove2d

Animated vector graphics for LÖVE.
Other
171 stars 8 forks source link

More NVIDIA graphic card issues in renderers demo #6

Closed pdesaulniers closed 5 years ago

pdesaulniers commented 5 years ago

Now, I'm getting the following error:

Error

Cannot link shader program object:
Fragment info
-------------
Internal error: assembly compile error for fragment shader at offset 1587:
-- error message --
line 47, column 9:  error: invalid parameter array size
line 55, column 16:  error: out of bounds array access
line 59, column 24:  error: out of bounds array access
line 97, column 16:  error: out of bounds array access
line 150, column 15:  error: out of bounds array access
line 157, column 15:  error: out of bounds array access
line 162, column 16:  error: out of bounds array access
line 163, column 15:  error: out of bounds array access
line 167, column 15:  error: out of bounds array access
line 180, column 16:  error: out of bounds array access
line 513, column 16:  error: out of bounds array access
line 525, column 13:  error: out of bounds array access

(insert lots of internal assembly text here)

Traceback

[C]: in function 'newShader'
tove/init.lua:1324: in function 'newGeometryFillShader'
tove/init.lua:1750: in function 'newComputeFeedData'
tove/init.lua:1793: in function 'gen'
tove/init.lua:2284: in function 'shaders'
tove/init.lua:2470: in function 'f'
tove/init.lua:2502: in function '_create'
tove/init.lua:2217: in function 'draw'
assets/tovedemo.lua:109: in function 'draw'
main.lua:28: in function 'draw'
[C]: in function 'xpcall'

I'm using a GeForce GTX 860M with the proprietary drivers on Linux.

poke1024 commented 5 years ago

Ok, thanks for this report.

A short first assessment of this: I need to add a different optional, more robust way of passing in certain large data (the LUT uniform float lut[2 * LUT_SIZE]) into the GLSL shader.

The trace above is probably the problem described here: https://stackoverflow.com/questions/53313978/uniform-registers-requirement-on-nvidia-with-a-sampler-in-vertex-shader

Workarounds are UBOs or textures: https://stackoverflow.com/questions/20647207/glsl-replace-large-uniform-int-array-with-buffer-or-texture

AFAIK love2d doesn't support UBOs at this time (I might be wrong, need to research). So I should look into passing in lut as a texture (which might be slow due to a binary search done on it).

poke1024 commented 5 years ago

Further analysis: the effect described in https://stackoverflow.com/questions/53313978/uniform-registers-requirement-on-nvidia-with-a-sampler-in-vertex-shader matches the bug described here. Tove also uses values from a uniform array as coordinates/parameters to ensuing texture() calls.

Since we're in the context of LÖVE (restricted GLSL features), options are limited. For now, I reduced the uniform buffer sizes and applied the workaround described under https://sergeyext.github.io/sergeyext/nvidia_abnormal_gpr_requirement.html, namely putting the uniform sampler2D declaration before the uniform array declarations (see https://github.com/poke1024/tove2d/commit/c847fc35c5e0558bd3bcfc2a986e11b082a42676#diff-2b285b33a182216545ae00750b327cad). Maybe that makes a difference?

pdesaulniers commented 5 years ago

OK, it runs now: 2019-03-03-20 44 23 I guess we can close this issue in favor of https://github.com/poke1024/tove2d/issues/1 .