How to make SetPixels32 faster

i use SetPixels32 to make 2 pictures (3456 * 1296) every frame. a little big. my FPS just 20, and the profiler show “SetPixels32” function cost 60%+ cpu. i want to make it fast, my target is 30 FPS.

result = GetFramePixels(_handle, _frameHandle.AddrOfPinnedObject(), _texture.width, _texture.height);

            if (result)
            {
                _texture.SetPixels32(_frameData);
                _texture.Apply();
            }

i think multithreading may be a good idear. but i don’t konw how to split SetPixels32 in multithreading. who can tell me thanks!

my other cpu is little but main is full. my cpu have 32 core, just one full, other all empty. and my memory is 64G engphe.

Try to use RenderTexture.

do you mean just change “_texture” to RenderTexture Style?

No, he means use you should never use SetPixel for something you do every frame. If possible you should be doing everything on the GPU using render textures and Blit.

can you tell me how to use it.
thank you!

It depends on what you’re trying to do, but the short version is SetPixels(), or more specifically Apply() is very slow because it’s having to transfer data from the CPU to the GPU. If you can do things with Blit() and custom shaders instead of doing things in C# scripts it can be significantly faster as everything is happening on the GPU.

Check the following docs: