MCPcopy Create free account
hub / github.com/VirtualGL/virtualgl / doTest

Function doTest

util/pftest.c:84–184  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

82
83
84static int doTest(int width, int height, PF *srcpf, PF *dstpf)
85{
86 int retval = 0, iter = 0, srcPitch = BMPPAD(width * srcpf->size),
87 dstPitch = BMPPAD(width * dstpf->size);
88 unsigned char *srcBuf = NULL, *dstBuf = NULL, *srcPixel, *dstPixel;
89 double tStart, elapsed;
90
91 if((srcBuf = (unsigned char *)malloc(srcPitch * height)) == NULL)
92 THROW("Could not allocate memory");
93 initBuf(srcBuf, width, srcPitch, height, srcpf, dstpf);
94 if((dstBuf = (unsigned char *)malloc(dstPitch * height)) == NULL)
95 THROW("Could not allocate memory");
96 memset(dstBuf, 0, dstPitch * height);
97
98 if(getSetRGB)
99 {
100 printf("%-8s --> %-8s (getRGB/setRGB): ", srcpf->name, dstpf->name);
101 tStart = GetTime();
102 iter = 0;
103 do
104 {
105 int h = height;
106 unsigned char *srcRow = srcBuf, *dstRow = dstBuf;
107 if(dstpf->bpc == 10 && srcpf->bpc == 8)
108 {
109 while(h--)
110 {
111 int w = width;
112 srcPixel = srcRow; dstPixel = dstRow;
113 while(w--)
114 {
115 int r, g, b;
116 srcpf->getRGB(srcPixel, &r, &g, &b);
117 r <<= 2; g <<= 2; b <<= 2;
118 dstpf->setRGB(dstPixel, r, g, b);
119 srcPixel += srcpf->size; dstPixel += dstpf->size;
120 }
121 srcRow += srcPitch; dstRow += dstPitch;
122 }
123 }
124 else if(srcpf->bpc == 10 && dstpf->bpc == 8)
125 {
126 while(h--)
127 {
128 int w = width;
129 srcPixel = srcRow; dstPixel = dstRow;
130 while(w--)
131 {
132 int r, g, b;
133 srcpf->getRGB(srcPixel, &r, &g, &b);
134 r >>= 2; g >>= 2; b >>= 2;
135 dstpf->setRGB(dstPixel, r, g, b);
136 srcPixel += srcpf->size; dstPixel += dstpf->size;
137 }
138 srcRow += srcPitch; dstRow += dstPitch;
139 }
140 }
141 else

Callers 1

mainFunction · 0.70

Calls 3

GetTimeFunction · 0.85
initBufFunction · 0.70
cmpBufFunction · 0.70

Tested by

no test coverage detected