Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Bug Attempting to bind Texture ID as UAV, the texture wasn't created with the UAV usage flag set!

Discussion in '2020.1 Beta' started by Quatum1000, Feb 2, 2020.

  1. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Hi,

    happens after initializing a serialized RT and use a compute shader during the Serialization 2.0 convert, I think.

    Code (CSharp):
    1.         int baseKernel = Compute.FindKernel("CopyBase");
    2.  
    3.         // ... Attempting to bind Texture ID xxx as UAV, the texture wasn't created with the UAV usage flag set!
    4.         Compute.SetTexture(baseKernel, "AmbientRT", RT_0);
    5.  
    The solution was to completely re-new all used RT_0 = new RenderTexture(....);
    Can not reproduce the issue after this fix.
     
    PuzzledBoy and h0neyfr0g like this.
  2. h0neyfr0g

    h0neyfr0g

    Joined:
    Jul 13, 2019
    Posts:
    35
    I'm also experiencing this bug. Could you help me understand your fix? Thanks you very much!
     
  3. PuzzledBoy

    PuzzledBoy

    Joined:
    Sep 9, 2014
    Posts:
    23
    new RenderTexture via code, and set enableRandomWrite=true can work.
     
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,136
    Could you please submit a bug report for this issue if you're able to reproduce it?
     
  5. Quatum1000

    Quatum1000

    Joined:
    Oct 5, 2014
    Posts:
    889
    Sorry for the late reply.

    Normally you can use a simple checkmate sniped to initialize an RT by
    If (RT==default) RT = new RenderTexture(...);
    The serialization process knows about the RT declaration and stores the RT initialization.
    As long as the RT is not default the RT will not being renewed.

    Now with the update process of the serialization system 2.0, the RT was updated into a new internal version with any missing ID reference, (or what ever they do internally)

    So when calling If (RT==default) RT = new RenderTexture(...); in the new version of Unity Ser. 2 ,
    RT stays != default.
    The computeshader.set... compares the new serialization 2 properties with some old fragments from the previous serialization 1 fragments.

    If you force a renew by a temporal:
    RT.Release(); If (RT==default) RT = new RenderTexture(...);
    It's simply fixed in my case.
     
    Last edited: Sep 13, 2020
    andywatts likes this.
  6. asa989

    asa989

    Joined:
    Dec 18, 2015
    Posts:
    52
    im having same issue on IOS. I'm trying to coppy from RenderTexture to Texture2D but i get error in Xcode "Compute shader (ImageShot): Property (Result) at kernel index (0): Attempting to bind Texture ID 181 as UAV but the texture wasn't created with the UAV usage flag set!"

    I can copy from Texture2D to RT without any problem though. These are the C# functions for my textures:
    Code (CSharp):
    1. void CreateRenderTxture(ref RenderTexture rt, int w,int h)
    2.     {
    3.         rt = new RenderTexture(w,h,0,RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
    4.         rt.enableRandomWrite = true;
    5.         rt.Create();
    6.     }
    7.  
    8.     void Create2DTexture(ref Texture2D tx, int w,int h)
    9.     {
    10.         tx = new Texture2D(w,h,TextureFormat.ARGB32, false);
    11.         tx.Apply();
    12.     }
    and Here is Compute Shader Code:
    Code (CSharp):
    1. RWTexture2D<float4> Result;
    2. Texture2D<float4> Source;
    3.  
    4. [numthreads(8,8,1)]
    5. void CSMain (uint2 id : SV_DispatchThreadID)
    6. {
    7.     Result[id] = float4(Source[id].x,Source[id].y,Source[id].z,1);
    8.  
    9. }
    Any Idea why I cant copy RT to Texture2D in IOS platform?
     
  7. FHomps

    FHomps

    Joined:
    Apr 6, 2021
    Posts:
    1
    Can confirm. After further investigation, it appears that SetInts() somehow only sends every 4th int from its source array to its destination array? Another absurd bug to add to the list, I guess. Probably comes from someone hardcoding behaviour meant for int4 and float4 only.
     
  8. Dublwatr

    Dublwatr

    Joined:
    Dec 20, 2016
    Posts:
    1
    Has this been fixed? I get the error on my shader as well, and even when I create a brand new shader and don't change anything in it at all it still does not work. Both RT.Release(); and enableRandomWrite=true don't affect outcome.
     
  9. IndieIndian

    IndieIndian

    Joined:
    Aug 11, 2022
    Posts:
    3
    file enablereadwrite = true;
    the tex.Create();
    the error is because u r creating first and the enablereadwrite later.