Changeset 45027 in vbox for trunk/src/VBox/GuestHost
- Timestamp:
- Mar 13, 2013 6:17:40 PM (12 years ago)
- svn:sync-xref-src-repo-rev:
- 84269
- Location:
- trunk/src/VBox/GuestHost/OpenGL
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/GuestHost/OpenGL/include/cr_hash.h
r44887 r45027 30 30 DECLEXPORT(GLuint) crHashIdPoolAllocBlock( CRHashIdPool *pool, GLuint count ); 31 31 DECLEXPORT(void) crHashIdPoolFreeBlock( CRHashIdPool *pool, GLuint first, GLuint count ); 32 /* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */ 32 33 DECLEXPORT(GLboolean) crHashIdPoolAllocId( CRHashIdPool *pool, GLuint id ); 33 34 … … 40 41 * which will also ensure there is no entry with the specified key left in the table */ 41 42 DECLEXPORT(GLuint) crHashtableAllocKeys( CRHashTable *h, GLsizei range ); 43 /* @return GL_TRUE if the id is allocated, and GL_FALSE if the id was already allocated */ 42 44 DECLEXPORT(GLboolean) crHashtableAllocRegisterKey( CRHashTable *h, GLuint key); 43 45 DECLEXPORT(void) crHashtableDelete( CRHashTable *h, unsigned long key, CRHashtableCallback deleteCallback ); -
trunk/src/VBox/GuestHost/OpenGL/include/state/cr_glsl.h
r44529 r45027 100 100 DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint id, GLenum type); 101 101 DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateProgram(GLuint id); 102 DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( GLhandleARB obj ); 102 103 103 104 DECLEXPORT(GLboolean) STATE_APIENTRY crStateIsProgramUniformsCached(GLuint program); -
trunk/src/VBox/GuestHost/OpenGL/state_tracker/state_glsl.c
r44930 r45027 259 259 } 260 260 261 DECLEXPORT(GLuint) STATE_APIENTRY crStateDeleteObjectARB( GLhandleARB obj ) 262 { 263 GLuint hwId = crStateGetProgramHWID(obj); 264 if (hwId) 265 { 266 crStateDeleteProgram(obj); 267 } 268 else 269 { 270 hwId = crStateGetShaderHWID(obj); 271 crStateDeleteShader(obj); 272 } 273 return hwId; 274 } 275 261 276 DECLEXPORT(GLuint) STATE_APIENTRY crStateCreateShader(GLuint hwid, GLenum type) 262 277 { … … 268 283 CRASSERT(!crStateGetShaderObj(stateId)); 269 284 #else 285 /* the proogram and shader names must not intersect because DeleteObjectARB must distinguish between them 286 * see crStateDeleteObjectARB 287 * this is why use programs table for shader keys allocation */ 288 stateId = crHashtableAllocKeys(g->glsl.programs, 1); 289 if (!stateId) 290 { 291 crWarning("failed to allocate program key"); 292 return 0; 293 } 294 270 295 /* the id may not necesserily be hwid after save state restoration */ 271 296 while ((pShader = crStateGetShaderObj(stateId)) != NULL) … … 312 337 } 313 338 #else 314 /* the id may not necesserily be hwid after save state restoration */ 315 while ((pProgram = crStateGetProgramObj(stateId)) != NULL) 316 { 317 GLuint newStateId = stateId + 7; 318 crDebug("Program object %d already exists, generating a new one, %d", stateId, newStateId); 319 stateId = newStateId; 339 stateId = crHashtableAllocKeys(g->glsl.programs, 1); 340 if (!stateId) 341 { 342 crWarning("failed to allocate program key"); 343 return 0; 320 344 } 321 345 #endif … … 324 348 if (!pProgram) 325 349 { 326 crWarning("crStateCreate Shader: Out of memory!");350 crWarning("crStateCreateProgram: Out of memory!"); 327 351 return 0; 328 352 } … … 364 388 } 365 389 390 static void crStateDbgCheckNoProgramOfId(void *data) 391 { 392 crError("Unexpected Program id"); 393 } 394 366 395 DECLEXPORT(void) STATE_APIENTRY crStateDeleteShader(GLuint shader) 367 396 { … … 379 408 CRContext *g = GetCurrentContext(); 380 409 crHashtableDelete(g->glsl.shaders, shader, crStateFreeGLSLShader); 410 /* since we use programs table for key allocation key allocation, we need to 411 * free the key in the programs table. 412 * See comment in crStateCreateShader */ 413 crHashtableDelete(g->glsl.programs, shader, crStateDbgCheckNoProgramOfId); 381 414 } 382 415 } -
trunk/src/VBox/GuestHost/OpenGL/util/blitter.cpp
r45009 r45027 112 112 113 113 /* GL_TRIANGLE_FAN */ 114 DECLINLINE(GLfloat*) crBltVtRectTFNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff )114 DECLINLINE(GLfloat*) crBltVtRectTFNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, uint32_t height) 115 115 { 116 116 /* going ccw: … … 121 121 /* xLeft yTop */ 122 122 pBuff[0] = ((float)pRect->xLeft)/((float)normalX); 123 pBuff[1] = ((float) pRect->yTop)/((float)normalY);123 pBuff[1] = ((float)(height ? height - pRect->yTop : pRect->yTop))/((float)normalY); 124 124 125 125 /* xLeft yBottom */ 126 126 pBuff[2] = pBuff[0]; 127 pBuff[3] = ((float) pRect->yBottom)/((float)normalY);127 pBuff[3] = ((float)(height ? height - pRect->yBottom : pRect->yBottom))/((float)normalY); 128 128 129 129 /* xRight yBottom */ … … 137 137 } 138 138 139 DECLINLINE(GLint*) crBltVtRectTF(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff )139 DECLINLINE(GLint*) crBltVtRectTF(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, uint32_t height) 140 140 { 141 141 /* xLeft yTop */ 142 142 pBuff[0] = pRect->xLeft; 143 pBuff[1] = pRect->yTop;143 pBuff[1] = height ? height - pRect->yTop : pRect->yTop; 144 144 145 145 /* xLeft yBottom */ 146 146 pBuff[2] = pBuff[0]; 147 pBuff[3] = pRect->yBottom;147 pBuff[3] = height ? height - pRect->yBottom : pRect->yBottom; 148 148 149 149 /* xRight yBottom */ … … 169 169 pIndex[4] = iBase + 2; 170 170 pIndex[5] = iBase + 3; 171 *piBase = iBase + 6;171 *piBase = iBase + 4; 172 172 return pIndex + 6; 173 173 } 174 174 175 175 /* Indexed GL_TRIANGLES */ 176 DECLINLINE(GLfloat*) crBltVtRectITNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff )177 { 178 GLfloat* ret = crBltVtRectTFNormalized(pRect, normalX, normalY, pBuff );176 DECLINLINE(GLfloat*) crBltVtRectITNormalized(const RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, uint32_t height) 177 { 178 GLfloat* ret = crBltVtRectTFNormalized(pRect, normalX, normalY, pBuff, height); 179 179 return ret; 180 180 } 181 181 182 DECLINLINE(GLint*) crBltVtRectIT(RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, GLubyte **ppIndex, GLubyte *piBase )183 { 184 GLint* ret = crBltVtRectTF(pRect, normalX, normalY, pBuff );182 DECLINLINE(GLint*) crBltVtRectIT(RTRECT *pRect, uint32_t normalX, uint32_t normalY, GLint* pBuff, GLubyte **ppIndex, GLubyte *piBase, uint32_t height) 183 { 184 GLint* ret = crBltVtRectTF(pRect, normalX, normalY, pBuff, height); 185 185 186 186 if (ppIndex) … … 203 203 204 204 205 static GLfloat* crBltVtRectsITNormalized(const RTRECT *paRects, uint32_t cRects, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase )205 static GLfloat* crBltVtRectsITNormalized(const RTRECT *paRects, uint32_t cRects, uint32_t normalX, uint32_t normalY, GLfloat* pBuff, GLubyte **ppIndex, GLubyte *piBase, uint32_t height) 206 206 { 207 207 uint32_t i; 208 208 for (i = 0; i < cRects; ++i) 209 209 { 210 pBuff = crBltVtRectITNormalized(&paRects[i], normalX, normalY, pBuff );210 pBuff = crBltVtRectITNormalized(&paRects[i], normalX, normalY, pBuff, height); 211 211 } 212 212 … … 235 235 } 236 236 237 #ifndef DEBUG_misha 238 /* debugging: ensure we calculate proper buffer size */ 237 239 cbBuffer += 16; 240 #endif 238 241 239 242 pBuffer->pvBuffer = RTMemAlloc(cbBuffer); … … 291 294 { 292 295 GLuint normalX, normalY; 296 uint32_t height = (fFlags & CRBLT_F_OFFSCREEN) ? 0 : pDstSize->cy; 293 297 294 298 switch (pSrc->target) … … 329 333 { 330 334 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * sizeof (*pVerticies)); 331 crBltVtRectTFNormalized(paDstRect, normalX, normalY, pVerticies );335 crBltVtRectTFNormalized(paDstRect, normalX, normalY, pVerticies, height); 332 336 pTexCoords = pVerticies; 333 337 } … … 335 339 { 336 340 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies)); 337 pTexCoords = crBltVtRectTFNormalized(paDstRect, 1, 1, pVerticies );338 crBltVtRectTFNormalized(paSrcRect, normalX, normalY, pTexCoords );341 pTexCoords = crBltVtRectTFNormalized(paDstRect, 1, 1, pVerticies, height); 342 crBltVtRectTFNormalized(paSrcRect, normalX, normalY, pTexCoords, height); 339 343 } 340 344 … … 365 369 if (bUseSameVerticies) 366 370 { 367 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * sizeof (*pVerticies) );368 crBltVtRectsITNormalized(paDstRect, cRects, normalX, normalY, pVerticies, &pIndicies, &iIdxBase );371 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * sizeof (*pVerticies) + cIndicies * sizeof (*pIndicies)); 372 crBltVtRectsITNormalized(paDstRect, cRects, normalX, normalY, pVerticies, &pIndicies, &iIdxBase, height); 369 373 pTexCoords = pVerticies; 370 374 } 371 375 else 372 376 { 373 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies) );374 pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, 1, 1, pVerticies, &pIndicies, &iIdxBase );375 crBltVtRectsITNormalized(paSrcRect, cRects, normalX, normalY, pTexCoords, NULL, NULL );377 pVerticies = (GLfloat*)crBltBufGet(&pBlitter->Verticies, cElements * 2 * 2 * sizeof (*pVerticies) + cIndicies * sizeof (*pIndicies)); 378 pTexCoords = crBltVtRectsITNormalized(paDstRect, cRects, 1, 1, pVerticies, &pIndicies, &iIdxBase, height); 379 crBltVtRectsITNormalized(paSrcRect, cRects, normalX, normalY, pTexCoords, NULL, NULL, height); 376 380 } 377 381
Note:
See TracChangeset
for help on using the changeset viewer.