Changeset 46453 in vbox for trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Timestamp:
- Jun 7, 2013 9:27:03 PM (12 years ago)
- Location:
- trunk/src/VBox/GuestHost/OpenGL/state_tracker
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump.cpp
r46402 r46453 165 165 } 166 166 167 VBOXDUMPDECL(size_t) crDmpFormatRawArrayf(char *pString, size_t cbString, const float *pVal, uint32_t cVal) 167 DECLINLINE(size_t) crDmpFormatVal(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbVal, const void *pvVal) 168 { 169 if (pszElFormat[0] != '%' || pszElFormat[1] == '\0') 170 { 171 crWarning("invalid format %s", pszElFormat); 172 return 0; 173 } 174 switch (cbVal) 175 { 176 case 8: 177 return sprintf_s(pString, cbString, pszElFormat, *((double*)pvVal)); 178 case 4: 179 { 180 /* we do not care only about type specifiers, all the rest is not accepted */ 181 switch (pszElFormat[1]) 182 { 183 case 'f': 184 /* float would be promoted to double */ 185 return sprintf_s(pString, cbString, pszElFormat, *((float*)pvVal)); 186 default: 187 return sprintf_s(pString, cbString, pszElFormat, *((uint32_t*)pvVal)); 188 } 189 } 190 case 2: 191 return sprintf_s(pString, cbString, pszElFormat, *((uint16_t*)pvVal)); 192 case 1: 193 return sprintf_s(pString, cbString, pszElFormat, *((uint8_t*)pvVal)); 194 default: 195 crWarning("unsupported size %d", cbVal); 196 return 0; 197 } 198 } 199 200 VBOXDUMPDECL(size_t) crDmpFormatRawArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal) 168 201 { 169 202 if (cbString < 2) … … 177 210 --cbString; 178 211 size_t cbWritten; 212 const uint8_t *pu8Val = (const uint8_t *)pvVal; 179 213 for (uint32_t i = 0; i < cVal; ++i) 180 214 { 181 cbWritten = sprintf_s(pString, cbString,182 (i != cVal - 1) ? "%f, " : "%f", *pVal);215 cbWritten = crDmpFormatVal(pString, cbString, pszElFormat, cbEl, (const void *)pu8Val); 216 pu8Val += cbEl; 183 217 Assert(cbString >= cbWritten); 184 218 pString += cbWritten; 185 219 cbString -= cbWritten; 220 if (i != cVal - 1) 221 { 222 cbWritten = sprintf_s(pString, cbString, ", "); 223 Assert(cbString >= cbWritten); 224 pString += cbWritten; 225 cbString -= cbWritten; 226 } 186 227 } 187 228 … … 204 245 } 205 246 206 VBOXDUMPDECL(size_t) crDmpFormatMatrixArray f(char *pString, size_t cbString, const float *pVal, uint32_t cX, uint32_t cY)247 VBOXDUMPDECL(size_t) crDmpFormatMatrixArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cX, uint32_t cY) 207 248 { 208 249 if (cbString < 2) … … 216 257 --cbString; 217 258 size_t cbWritten; 259 const uint8_t *pu8Val = (const uint8_t *)pvVal; 218 260 for (uint32_t i = 0; i < cY; ++i) 219 261 { 220 cbWritten = crDmpFormatRawArrayf(pString, cbString, pVal, cX); 262 cbWritten = crDmpFormatRawArray(pString, cbString, pszElFormat, cbEl, (const void *)pu8Val, cX); 263 pu8Val += (cbEl * cX); 221 264 Assert(cbString >= cbWritten); 222 265 pString += cbWritten; … … 253 296 } 254 297 255 VBOXDUMPDECL(size_t) crDmpFormatArray f(char *pString, size_t cbString, const float *pVal, uint32_t cVal)298 VBOXDUMPDECL(size_t) crDmpFormatArray(char *pString, size_t cbString, const char *pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal) 256 299 { 257 300 switch(cVal) 258 301 { 259 302 case 1: 260 return sprintf_s(pString, cbString, "%f", *pVal);303 return crDmpFormatVal(pString, cbString, pszElFormat, cbEl, pvVal); 261 304 case 16: 262 return crDmpFormatMatrixArray f(pString, cbString, pVal, 4, 4);305 return crDmpFormatMatrixArray(pString, cbString, pszElFormat, cbEl, pvVal, 4, 4); 263 306 case 9: 264 return crDmpFormatMatrixArray f(pString, cbString, pVal, 3, 3);307 return crDmpFormatMatrixArray(pString, cbString, pszElFormat, cbEl, pvVal, 3, 3); 265 308 case 0: 266 309 crWarning("value array is empty"); 267 310 return 0; 268 311 default: 269 return crDmpFormatRawArrayf(pString, cbString, pVal, cVal); 270 } 312 return crDmpFormatRawArray(pString, cbString, pszElFormat, cbEl, pvVal, cVal); 313 } 314 } 315 316 VBOXDUMPDECL(void) crRecDumpVertAttrv(CR_RECORDER *pRec, CRContext *ctx, GLuint idx, const char*pszElFormat, uint32_t cbEl, const void *pvVal, uint32_t cVal) 317 { 318 char aBuf[1024]; 319 crDmpFormatRawArray(aBuf, sizeof (aBuf), pszElFormat, cbEl, pvVal, cVal); 320 crDmpStrF(pRec->pDumper, "(%u, %s)", idx, aBuf); 321 } 322 323 VBOXDUMPDECL(void) crRecDumpVertAttrV(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, va_list pArgList) 324 { 325 crDmpStrV(pRec->pDumper, pszFormat, pArgList); 326 } 327 328 VBOXDUMPDECL(void) crRecDumpVertAttrF(CR_RECORDER *pRec, CRContext *ctx, const char*pszFormat, ...) 329 { 330 va_list pArgList; 331 va_start(pArgList, pszFormat); 332 crRecDumpVertAttrV(pRec, ctx, pszFormat, pArgList); 333 va_end(pArgList); 271 334 } 272 335 -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/dump_gen.py
r46401 r46453 73 73 { 74 74 char aBuf[4096]; 75 crDmpFormatArray f(aBuf, sizeof (aBuf), pfData, pDesc->num_values);75 crDmpFormatArray(aBuf, sizeof (aBuf), "%f", sizeof (float), pfData, pDesc->num_values); 76 76 crDmpStrF(pDumper, "%s = %s;", pDesc->pszName, aBuf); 77 77 }
Note:
See TracChangeset
for help on using the changeset viewer.