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

Hi,

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

        int baseKernel = Compute.FindKernel("CopyBase");

        // ... Attempting to bind Texture ID xxx as UAV, the texture wasn't created with the UAV usage flag set!
        Compute.SetTexture(baseKernel, "AmbientRT", RT_0);

The solution was to completely re-new all used RT_0 = new RenderTexture(…);
Can not reproduce the issue after this fix.

2 Likes

I’m also experiencing this bug. Could you help me understand your fix? Thanks you very much!

new RenderTexture via code, and set enableRandomWrite=true can work.

Could you please submit a bug report for this issue if you’re able to reproduce it?

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.

1 Like

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:

void CreateRenderTxture(ref RenderTexture rt, int w,int h)
    {
        rt = new RenderTexture(w,h,0,RenderTextureFormat.ARGB32, RenderTextureReadWrite.sRGB);
        rt.enableRandomWrite = true;
        rt.Create();
    }
  
    void Create2DTexture(ref Texture2D tx, int w,int h)
    {
        tx = new Texture2D(w,h,TextureFormat.ARGB32, false);
        tx.Apply();
    }

and Here is Compute Shader Code:

RWTexture2D<float4> Result;
Texture2D<float4> Source;

[numthreads(8,8,1)]
void CSMain (uint2 id : SV_DispatchThreadID)
{
    Result[id] = float4(Source[id].x,Source[id].y,Source[id].z,1);

}

Any Idea why I cant copy RT to Texture2D in IOS platform?

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.

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.

file enablereadwrite = true;
the tex.Create();
the error is because u r creating first and the enablereadwrite later.