Manual loop unrolling
This commit is contained in:
parent
4768169ea2
commit
4db50f3f73
10
main.c
10
main.c
@ -68,9 +68,9 @@ void drawTexInto(struct texture tex, struct texture buffer, struct rect texbound
|
|||||||
i32 bufi = 3 * (x + buffer.width * y);
|
i32 bufi = 3 * (x + buffer.width * y);
|
||||||
// You can get rid of this for loop for more performance, but probably
|
// You can get rid of this for loop for more performance, but probably
|
||||||
// not a big deal with -O3, it'll be unrolled
|
// not a big deal with -O3, it'll be unrolled
|
||||||
for(int i = 0; i < 3; i++) {
|
buffer.data[bufi] = tex.data[texi];
|
||||||
buffer.data[bufi + i] = tex.data[texi + i];
|
buffer.data[bufi + 1] = tex.data[texi + 1];
|
||||||
}
|
buffer.data[bufi + 2] = tex.data[texi + 2];
|
||||||
texx += stepx;
|
texx += stepx;
|
||||||
}
|
}
|
||||||
texy += stepy;
|
texy += stepy;
|
||||||
@ -98,10 +98,10 @@ int main() {
|
|||||||
|
|
||||||
// We actually stretch a texture here
|
// We actually stretch a texture here
|
||||||
struct rect texrect = { 0, 0, 16, 16 };
|
struct rect texrect = { 0, 0, 16, 16 };
|
||||||
struct rect bufrect = { 10, 13, 502, 509 };
|
struct rect bufrect = { 10, 10, 26, 26 };
|
||||||
|
|
||||||
clock_t start = clock();
|
clock_t start = clock();
|
||||||
for(int i = 0; i < 50; i++) { //overdraw factor
|
for(int i = 0; i < 50000; i++) { //overdraw factor
|
||||||
drawTexInto(tex, fb, texrect, bufrect);
|
drawTexInto(tex, fb, texrect, bufrect);
|
||||||
}
|
}
|
||||||
clock_t end = clock();
|
clock_t end = clock();
|
||||||
|
Loading…
Reference in New Issue
Block a user