Marching-Cubes icon indicating copy to clipboard operation
Marching-Cubes copied to clipboard

Error: Unable to link compute shader

Open alecvn opened this issue 5 years ago • 5 comments

Hi

When I check out the project I get the following error:

-------- GLSL link error: Compute info
------------
0(53) : error C5041: cannot locate suitable resource to bind variable "TempArray0". Possibly large array.
0(14) : error C5041: cannot locate suitable resource to bind variable "ImmCB_0_0_1". Possibly large array.

I'm on Ubuntu 18.04 and Unity 2018.3.0f2. My graphics API is OpenGLCore.

alecvn avatar May 20 '19 22:05 alecvn

So it would seem like the reason for this is that I'm on OpenGLCore and not DirectX. I will see if I can make it work for OpenGL and post a solution here, but I'm a little in over my head.

alecvn avatar May 22 '19 19:05 alecvn

@alecvn Did you ever get this working? I've taken a stab at the issue, and it seems to be related to the fact that the Lookup Table for the Marching cubes is a convenient 4096 ints long. According to what I'm seeing you can't have an integer array that large in OpenGL and you have to use a buffer to store said information. But I'm unsure of how to set everything up in hlsl.

I'm going to work on this myself, but I'm hoping you have a head start that I can use as I'm a bit over my head as well. It should be noted that issue #11 is the same issue.

My current plan is to try and switch over to vulkan and get that working, but the (probably) simpler solution would be to implement it in openGL properly using buffers.

StripedMonkey avatar May 14 '20 17:05 StripedMonkey

@StripedMonkey I'm afraid I never got this working, no. I don't think Sebastian really has time to help people out with these Coding Adventures either, as I've never seen him respond to tickets against them. So I think you're on your own I'm afraid. You'll probably get at least some support over at the GameDev StackExchange. Please do update here if you manage to solve the problem.

alecvn avatar May 15 '20 09:05 alecvn

I fixed it by changing the array of 256x16 ints to only 256x2. Each value was at most 11, so it only really needs 4bits out of the 32 an int holds. I also replaced the "-1" values with 15(binary 1111 or hex F). After the permutation of the corners is known, I convert the 2 ints back into an array of 16. Still, I'm pretty sure that shaders are not meant to hold look-up tables of any sort. I just altered what was already there, rather than doing it as it really should be done(presumably with buffers).

Changed-Files.zip

kolop315 avatar Feb 23 '21 11:02 kolop315

Lookup tables are 100% not what shaders or GPUs are really designed to hold heh. I'm glad you got it working. :D

It's been a bit since I messed with this, but if I recall correctly I had concluded that DX11 had the ability to have arbitrary static integer tables larger than 256 (or was it 1024?) but OpenGL had nothing that would have been viable in the previous state of the tables and Vulkan was a bit beyond what I was willing to sink the time investment into, so that didn't really come to pass.

Based on what I'm reading buffers might indeed be the "proper" solution, but I can't seem to figure out why they didn't come up as a solution when I was reading about it. Was the vulkan conversion of hlsl shaders broken for buffers? I recall something like that being a thing.

StripedMonkey avatar Feb 23 '21 19:02 StripedMonkey