weixin_39574720
weixin_39574720
2020-12-01 18:25

[0x80004005 - unknown error] 'internal error: no storage type for block output"

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

该提问来源于开源项目:Auburn/FastNoise

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答

6条回答

  • weixin_39602976 weixin_39602976 5月前

    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!

    点赞 评论 复制链接分享
  • weixin_39574720 weixin_39574720 5月前

    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.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.

    点赞 评论 复制链接分享
  • weixin_39602976 weixin_39602976 5月前

    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.

    点赞 评论 复制链接分享
  • weixin_39574720 weixin_39574720 5月前

    hi reece, after some more testing, you can use more than 4 global variables - using my test code, i imported all 15 of the noise structs settings in an array, and as long as i dont set fractal_type or cellular_distance_func , it works fine. I will paste the code below. I think i have found the reason behind it, but i dont fully understand it.. to quote microsoft: Additionally, HLSL packs data so that it does not cross a 16-byte boundary. the full page on hlsl data packing is here: https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules, but in short, when it gets to the end of a 16bytes block it will bump the next value to the start of the next block, so I am wondering if the underlying structure for fractal_type and cellular_distance_func is more than 16 bytes, in which case it when it is attempting to split the struct data in 16 byte blocks, it will get stuck on those... or something like that anyway... i also read somewhere that while the struct is just used to pass data internally, it is merely 'sugar' (thats what they called it), and doesnt effect the underlying process, but when it has to interact with something external, the data blocking becomes important...

    点赞 评论 复制链接分享
  • weixin_39574720 weixin_39574720 5月前

    void CSMain (uint3 id : SV_DispatchThreadID) { fnl_state noise = fnlCreateState(settings[0]); noise.frequency = settings[1]; noise.noise_type = settings[2];
    noise.rotation_type_3d = settings[3]; noise.fractal_type = 1; noise.octaves = settings[5]; noise.lacunarity = settings[6]; noise.gain = settings[7]; noise.weighted_strength = settings[8]; noise.ping_pong_strength = settings[9]; noise.cellular_distance_func = 1; noise.cellular_return_type = settings[11]; noise.cellular_jitter_mod = settings[12]; noise.domain_warp_amp = settings[13]; noise.domain_warp_type = settings[14];

    float thisnoise = Remap(fnlGetNoise2D(noise,id.x % 256, id.x / 256), -1, 1, 0, 1);
    Result[id.x] = float4(thisnoise, thisnoise, thisnoise, 1.0f);
    
    点赞 评论 复制链接分享
  • weixin_39574720 weixin_39574720 5月前

    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? the only work around i can think of that might work is to create a seperate compute shader pragma for each fractal and distance function choice, thus each choice is precompiled.

    fnl_state CustomfnlCreateState(float settings[15], int fractal) {

    switch (fractal)
    {
    case 0:
        fnl_state newState0;
        newState0.seed = settings[0];
        newState0.frequency = settings[1];
        newState0.noise_type = (int)settings[2];
        newState0.rotation_type_3d = (int)settings[3];
        newState0.fractal_type = 0;
        newState0.octaves = settings[5];
        newState0.lacunarity = settings[6];
        newState0.gain = settings[7];
        newState0.weighted_strength = settings[8];
        newState0.ping_pong_strength = settings[9];
        newState0.cellular_distance_func = 0;
        newState0.cellular_return_type = settings[11];
        newState0.cellular_jitter_mod = settings[12];
        newState0.domain_warp_amp = settings[13];
        newState0.domain_warp_type = settings[14];
        return newState0;
    
    case 1:
        fnl_state newState1;
        newState1.seed = settings[0];
        newState1.frequency = settings[1];
        newState1.noise_type = (int)settings[2];
        newState1.rotation_type_3d = (int)settings[3];
        newState1.fractal_type = 1;
        newState1.octaves = settings[5];
        newState1.lacunarity = settings[6];
        newState1.gain = settings[7];
        newState1.weighted_strength = settings[8];
        newState1.ping_pong_strength = settings[9];
        newState1.cellular_distance_func = 0;
        newState1.cellular_return_type = settings[11];
        newState1.cellular_jitter_mod = settings[12];
        newState1.domain_warp_amp = settings[13];
        newState1.domain_warp_type = settings[14];
        return newState1;
    
    case 2:
        fnl_state newState2;
        newState2.seed = settings[0];
        newState2.frequency = settings[1];
        newState2.noise_type = (int)settings[2];
        newState2.rotation_type_3d = (int)settings[3];
        newState2.fractal_type = 2;
        newState2.octaves = settings[5];
        newState2.lacunarity = settings[6];
        newState2.gain = settings[7];
        newState2.weighted_strength = settings[8];
        newState2.ping_pong_strength = settings[9];
        newState2.cellular_distance_func = 0;
        newState2.cellular_return_type = settings[11];
        newState2.cellular_jitter_mod = settings[12];
        newState2.domain_warp_amp = settings[13];
        newState2.domain_warp_type = settings[14];
        return newState2;
    
    case 3:
        fnl_state newState3;
        newState3.seed = settings[0];
        newState3.frequency = settings[1];
        newState3.noise_type = (int)settings[2];
        newState3.rotation_type_3d = (int)settings[3];
        newState3.fractal_type = 3;
        newState3.octaves = settings[5];
        newState3.lacunarity = settings[6];
        newState3.gain = settings[7];
        newState3.weighted_strength = settings[8];
        newState3.ping_pong_strength = settings[9];
        newState3.cellular_distance_func = 0;
        newState3.cellular_return_type = settings[11];
        newState3.cellular_jitter_mod = settings[12];
        newState3.domain_warp_amp = settings[13];
        newState3.domain_warp_type = settings[14];
        return newState3;
    
    default:
        fnl_state newState4;
        newState4.seed = 1337;
        newState4.frequency = 0.01f;
        newState4.noise_type = 1;
        newState4.rotation_type_3d = 1;
        newState4.fractal_type = 1;
        newState4.octaves = 3;
        newState4.lacunarity = 2.0f;
        newState4.gain = 0.5f;
        newState4.weighted_strength = 0.0f;
        newState4.ping_pong_strength = 2.0f;
        newState4.cellular_distance_func = 1;
        newState4.cellular_return_type = 1;
        newState4.cellular_jitter_mod = 1.0f;
        newState4.domain_warp_amp = 30.0f;
        newState4.domain_warp_type = 1;
        return newState4;
    }
    
    点赞 评论 复制链接分享

相关推荐