- Home /
Question by
Ziddon · Sep 14, 2020 at 03:02 AM ·
compute shadermemory usage
ComputeBuffer-Can multiple Indices of compute shader modify the same index???
Hello my friends!
I'm having a problem with using too much memory in my dynamic mesh creation >_< Part of my algorithm computes lots and lots and lots of Booleans.
___
As far as I can tell though, the smallest blittable data type I can send back and forth between the processor and gpu is 4 bytes. (int, for example).
So I'm thinking...well, if I could find a way in my compute shader to modify the first index of my ComputeBuffer on multiple SV_DispatchThreadIDs, I could store 32 of my booleans in a single int with a few bit shifts and Bitwise Operations!___
Is such a thing possible???___
If not, does anyone have any tricks for getting the most out of those 4 byte chunks?___
(I also had the thought of packing the data the way I described after reading the memory back from the ComputeBuffer. But, I would still be temporarily using some big chunks of memory).___
For anyone curious there is a different trick I've found. I can set up a struct on the cpu as bytes public struct test_struct { public byte value1; public byte value2; public byte value3; public byte value4; }___
Then in the compute shader as an integer struct test_struct { int value; }; And by bit shifting by 8 spaces I can assign 4 different values into a single integer.
Comment