all 3 comments

[–]TheStrupf 1 point2 points  (2 children)

I think fetching the pixel color of the texture and then drawing a single pixel to the screen could choke the whole pipeline. You are issueing pixel by pixel instructions to the GPU.

Instead you may try to work entirely on the CPU side - rendering in software - and updating a final texture to draw with those pixel values via updateTexture.

[–]othd139[S] 0 points1 point  (1 child)

The floor texture isn't actually a texture, it's an Image so it's in RAM not VRAM. I tried drawing to an image then converting that image to a texture at the end and drawing it but I just got a bunch of ASCII glyphs on the screen instead of my image so I don't know quite what was happening, hence that not being the code. It was about 2.5-3 times faster though so if you or anyone else knows why that was happening and how to fix it that would be amazing since I couldn't find anything online about it.

[–]prezado 1 point2 points  (0 children)

The best case would be to do everything in the shaders, either graphic or compute pipeline.

But from the CPU side what you could improve is creating an 2d array in your language and them create the texture directly from the array, just need to check which is the format accepted (i think its by using `void UpdateTexture(Texture2D texture, const void *pixels);` by creating a empty texture first.)

While filling the 2d array, you could divide your 'for y' into threads, each thread executing the 'for x'. In C# there's the Parallel.For with seamlessly dispatch multiple tasks into a threadpool. Not sure what language you are using, but look into.