The biggest bottleneck of my code is fetching texture RGB values from memory.
My code looks something like this:
game loop{
for every mesh{
perform clipping;
for every 3 verticies in mesh {
draw triangle {
interpolate texture coordinates;
fetch texture RGB and place value in backbuffer;
}
}
}
}
Fetching the texture RGB value from memory takes up so much time!!
I am not familiar with multithreading but I'm assuming there is some way to apply it here. Let me know what suggestions you have and how I should go about doing this!
[code] ibuffer = mesh->texture->intbuffer[(int)textureX + mesh->texture->width (int)textureY]; [\code]
The integer I copy from the texture to the backbuffer overwrites the R value of the next pixel in the back buffer. I do this so as to not use bitwise operations used to extract the RGB values from texture memory and store in backbuffer.
– Benjamin Loisch Jul 20 '17 at 16:05If my texture is allocated on the heap, and the texture is being accessed vertically... I do not understand how the cache is filling up with unecessary values. I suppose if I tiled my texture, the cache would guess the next values and store them in registers and since it's tiled, those values would more likely be the correct ones to use.
– Benjamin Loisch Jul 24 '17 at 22:41