New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[0x80004005 - unknown error] 'internal error: no storage type for block output" #54
Comments
Did you receive any form of error messages or stack traces (beyond what you stated in the title)? If so could you please share them in the form of a gist? Thank you! |
hi reece,it was me that reported the error. Sorry, im a bit new to all this... I created a simple version of my compute shader to reproduce the bug.
the error that came up on unity was this :
Shader error in 'bug test1.compute': Compilation failed for kernel 'CSMain' [0x80004005 - unknown error] 'internal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block outputinternal error: no storage type for block output' at kernel CSMain
I dont know what a stack trace is or how to find it... any pointers?
ive created a gist - unity compute shader that uses FastNoiseLite.hlsl, produces an unknown bug.
|
|
|
| | |
|
|
|
| |
unity compute shader that uses FastNoiseLite.hlsl, produces an unknown bug.
unity compute shader that uses FastNoiseLite.hlsl, produces an unknown bug. - bugtest1.compute
|
|
|
btw, i changed the FastNoiseLite.hlsl to a .cginc because unity seemed to be having a hard time including the .hlsl. I was getting the error message when it was a hlsl as well.
thanks for taking a look. This is incredibly fast (around 5ms), if i could get it to work in a way that would be useful!!
many thanks
paul
On Thursday, November 19, 2020, 03:12:54 PM GMT, Reece Mackie <notifications@github.com> wrote:
Did you receive any form of error messages or stack traces? If so could you please share them in the form of a gist? Thank you!
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
Okay, after researching this I have found that if you set more than 4 fields in the state struct from global compute shader parameters, the compiler dislikes it. I'm going to reach out to some Unity developers over the weekend when I have more time and will discuss this issue with them. I will get back to you. In the meantime the workaround would be to use as many hardcoded values (locally scoped, i.e. within your main function, not outside) until this issue can be resolved. |
hi reece, |
void CSMain (uint3 id : SV_DispatchThreadID)
|
hi, further testing: i created a switch statement that created a new noise instance and hardcoded the fractal type, depending on what the fractal type was, which worked until i tried to then pass a variable into the switch statement to decide which new instance to create, and then it threw the same error. I'll post the code below if i explained that badly. Im wondering if there is something in the fractal algorithm and distance function that has to be precompiled and cant be changed once set? fnl_state CustomfnlCreateState(float settings[15], int fractal)
|
Same issue here. I have tried refactoring Fastnoise to use two arrays of ints and floats as parameters instead of a state struct to no avail. Really weird stuff. |
Alright, took me a while but I found a workaround that doesn't require rewriting the entire library. Here's how to use this shader with Unity with the added benefits of it compiling. Buckle up, it's a journey. A bit of context first; for my personal use case, I am using a Unity compute shader to fill up a RenderTexture with values from this shader; this texture is then passed around to a few other compute shaders for them to change values for a mesh I'm rendering, all without leaving the GPU. First problem: Unity's compute shaders apparently don't support structs as parameters, at all. Not entirely sure about the reason but since it's Unity, it's probably a bad one. Now, I have two arrays which make up the state of my noise generation in my compute shader. Using Unity's SetInts() and SetFloats() to fill them up sounds good, right? Wrong, as of today they're bugged to hell and back and won't pass your values properly to anything that's not an array of int4s or float4s [EDIT: It has come to my attention that what I thought was a bug is in fact the documented padding requirements of SetInts() and SetFloats(). My bad]. So, pass int / float values individually with SetInt() and SetFloat() (or use a structured buffer, I haven't tried yet but it should work), then fill up your state arrays in your shader calls. It's inefficient, sure, but you're using a library with runtime nested switches in a shader, so you're probably not hung up on efficiency anyway. Then comes the error that started this issue ; what is a block output and why is there no storage type for it? After some trial and error I also narrowed it down to switches - for some reason the switches for noise type and cellular distance functions just don't want to compile; hardcoding the return values instead worked. Looking at the HLSL documentation, Microsoft states that "the compiler may use a hardware switch or emit a series of if statements", probably depending on driver implementation. Little-known feature of HLSL (at least, to me), you can pass attributes to switches to force a certain optimization behavior. Tried it with [flatten] or [branch] on the offending switches and bingo, the shader compiles. Now with [forcecase], which forces a hardware switch, and we get our errors again. So, my guess is there is some kind of bug in my driver which makes it have trouble organizing the switch instruction blocks - for info, I have an Intel HD 620 with up-to-date drivers, so I am not some kind of rare homebrew graphics card user. Now, I won't make a pull request for this since it's kind of a dirty hack and removes the state struct, but attached are the fixed library file and my compute shader as an example. |
Thank you for looking into this, when I get the time I'll sit down and look into a way of reworking the hlsl port taking into account these things you have found, and attempt to implement them in a hackless, or at least less-hacky, manner. |
I'm thinking the best way of doing this is to create a separate, Unity-optimized variant of FNL (with a .cginc extension while we're at it) that:
I'm going to try my hand at this, I will get back to you soon. |
A few hours of investigating later...
After thinking about it for a while, I'm getting increasingly convinced by the last solution. Not only is it much faster to implement, but I feel like FNL's philosophy is more of a playing ground for noise testing than something meant for very efficient noise production (which would probably just use hardcoded function choices). |
hi, FHomps et al, did anyone manage to make any progress on this? i'm afraid its too complex for my level of shader language to fix myself, but i still need a HLSL noise library for unity, if anyone has a version of this library that doesnt piss unity off... |
Hi @gaiastellar, |
@Rover656 @FHomps @gaiastellar Hi all, I have the same error, after reading the discussion, I added changes to the FastNoiseLite.hlsl library and error disappeared |
This would be great if it does fix the issue, I don't really know much about HLSL to verify or test if this is the correct fix. @Rover656 what are your thoughts on the fix? |
I'm not familiar with the deeper details of the HLSL compiler, I can try and get a unity app up and running to see for myself but if it works I'm not opposed to it being brought in. From some basic research all this is doing is reducing the amount of branching in the compiled output, which I guess is helping with this odd storage error. |
@Akeyn Thanks! That worked for me 👍 |
I'm happy to take this change if someone wants to PR it |
This should now be fixed with 95900f7 |
hi,
came across this while writing a compute shader on Unity. After extensive testing the error only occurs when using FastNoiseLite.
Initialisation of noise and settings variables with values works, like this:
fnl_state noise = fnlCreateState(1337);
noise.noise_type = 2;
noise.frequency = 0.02f;
noise.fractal_type = 2;
etc etc
no problem, but using variables to set the parameters causes the error, like this:
float myseed = 1212;
float myfrequency = 0.02f;
int mynoisetype = 1;
int myrotationtype = 1;
int myfractaltype = 2;
float mygain = 0.5f;
fnl_state noise = fnlCreateState(myseed);
noise.frequency = myfrequency;
noise.noise_type = mynoisetype;
noise.rotation_type_3d = myrotationtype;
noise.fractal_type = myfractaltype;
noise.gain = mygain;
In reality, im sending the variable paremeters from CPU side, which in Unity is SetFloat("mygain", 0.5f), which generally works fine, but when setting parameters like this and one of them is fractal_type, throws the error. if fractal_type is set with a definate value the error doesnt occur eg: noise.fractal_type = 2;
I originally thought this was an error in Unity in the way it was handling variables, but i wrote something using variables in a similar way, not using the FastNoiseLite HLSL library and i couldnt replicate the error, so im guessing theres something in the library in the way it is utilising gpu memory that is throwing the error, but this really isnt my area, so im only guessing.
I want to be able to send the values for noise parameters from CPU side into the compute shader, so this is really limiting the way i can use it.
many thanks
The text was updated successfully, but these errors were encountered: