I tested it and I can’t have a cbuffer in a cbuffer, it gives me a syntax error, and if I move states out of the buffer and fill in the states with the normal SetBuffer() it works, but I don’t want that because I need to read data back from states every few seconds so I need it to be constant.
After some testing I have come to the conclusion that you just can’t use constant buffers with unity in compute shader, and the best thing to do is to set the buffer as uniform and use SetBuffer() to set that buffer.
I guess I don’t but then again maybe making it constant could be more performant is my thought process, and the thing is I need to make a NEW compute buffer with 4096 elements every few seconds if I don’t make it constant or uniform, and so I’ve now gone ahead and done “uniform RWStructuredBuffer states” and I only need to create the buffer once and dispose it when the game ends and it seems to have cut down a bit of the lag.
hi , i met same problem ,i did’t not get errors, but the values always zero,just like this : https://discussions.unity.com/t/876126 , i wonder know how to use setbuffer method? pls give me an example?