- Timestamp:
- Mar 30, 2022 5:40:28 PM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-internal.h
r94377 r94401 884 884 885 885 #ifdef VMSVGA3D_INCL_STRUCTURE_DESCRIPTORS 886 /* Verify that constants did not change for the legacy context saved state data. */ 887 AssertCompile(SVGA3D_RS_MAX == 99); 888 AssertCompile(SVGA3D_TRANSFORM_MAX == 15); 889 AssertCompile(SVGA3D_FACE_MAX == 5); 890 AssertCompile(SVGA3D_CLIPPLANE_5 == (1 << 5)); 891 AssertCompile(SVGA3D_MAX_LIGHTS == 32); 892 AssertCompile(SVGA3D_RT_MAX == 10); 893 886 894 /** 887 895 * SSM descriptor table for the VMSVGA3DCONTEXT structure. -
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-savedstate.cpp
r94232 r94401 211 211 } 212 212 213 214 /* 215 * Load the legacy VMSVGA3DCONTEXT from saved state version VGA_SAVEDSTATE_VERSION_VMSVGA_MIPLEVELS (23) 216 * or earlier, i.e. 6.1 or old trunk. 217 * 218 * The saved state incompatibility has been introduced in two revisions: 219 * 220 * - r140506: which makes sure that VMSVGA structures are tightly packed (pragma pack(1)). 221 * This caused all structures which have a member from VMSVGA headers (like VMSVGALIGHTSTATE) to be packed too. 222 * For example the size of aLightData element (VMSVGALIGHTSTATE) is 2 bytes smaller on trunk (118) than on 6.1 (120), 223 * which happens because SVGA3dLightData member offset is 2 on trunk and 4 on 6.1. 224 * 225 * - r141385: new VMSVGA device headers. 226 * SVGA3D_RS_MAX is 99 with new VMSVGA headers, but it was 100 with old headers. 227 * 6.1 always saved 100 entries; trunk before r141385 saved 100 entries; trunk at r141385 saves 99 entries. 228 * 229 * 6.1 saved state version is VGA_SAVEDSTATE_VERSION_VMSVGA_SCREENS (21). 230 * Trunk r141287 introduced VGA_SAVEDSTATE_VERSION_VMSVGA_MIPLEVELS (23). 231 * 232 * Both issues has been solved by loading a compatible context structure for saved state 233 * version < VGA_SAVEDSTATE_VERSION_VMSVGA_MIPLEVELS. 234 * This means that trunk will not be able to load states created from r140506 to r141385. 235 */ 236 static int vmsvga3dLoadVMSVGA3DCONTEXT23(PPDMDEVINS pDevIns, PSSMHANDLE pSSM, VMSVGA3DCONTEXT *pContext) 237 { 238 #pragma pack(1) 239 struct VMSVGA3DCONTEXT23 240 { 241 uint32_t id; 242 #ifdef VMSVGA3D_OPENGL 243 uint32_t lastError; 244 #endif 245 uint32_t cPixelShaders; 246 uint32_t cVertexShaders; 247 struct 248 { 249 uint32_t u32UpdateFlags; 250 SVGA3dRenderState aRenderState[/*SVGA3D_RS_MAX=*/ 100]; 251 SVGA3dTextureState aTextureStates[/*SVGA3D_MAX_TEXTURE_STAGE=*/ 8][/*SVGA3D_TS_MAX=*/ 30]; 252 struct 253 { 254 bool fValid; 255 bool pad[3]; 256 float matrix[16]; 257 } aTransformState[SVGA3D_TRANSFORM_MAX]; 258 struct 259 { 260 bool fValid; 261 bool pad[3]; 262 SVGA3dMaterial material; 263 } aMaterial[SVGA3D_FACE_MAX]; 264 struct 265 { 266 bool fValid; 267 bool pad[3]; 268 float plane[4]; 269 } aClipPlane[SVGA3D_CLIPPLANE_5]; 270 struct 271 { 272 bool fEnabled; 273 bool fValidData; 274 bool pad[2]; 275 SVGA3dLightData data; 276 } aLightData[SVGA3D_MAX_LIGHTS]; 277 uint32_t aRenderTargets[SVGA3D_RT_MAX]; 278 SVGA3dRect RectScissor; 279 SVGA3dRect RectViewPort; 280 SVGA3dZRange zRange; 281 uint32_t shidPixel; 282 uint32_t shidVertex; 283 uint32_t cPixelShaderConst; 284 uint32_t cVertexShaderConst; 285 } state; 286 }; 287 #pragma pack() 288 289 static SSMFIELD const g_aVMSVGA3DCONTEXT23Fields[] = 290 { 291 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, id), 292 #ifdef VMSVGA3D_OPENGL 293 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, lastError), 294 #endif 295 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, cPixelShaders), 296 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, cVertexShaders), 297 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.u32UpdateFlags), 298 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.aRenderState), 299 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.aTextureStates), 300 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.aTransformState), 301 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.aMaterial), 302 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.aClipPlane), 303 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.aLightData), 304 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.aRenderTargets), 305 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.RectScissor), 306 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.RectViewPort), 307 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.zRange), 308 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.shidPixel), 309 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.shidVertex), 310 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.cPixelShaderConst), 311 SSMFIELD_ENTRY(VMSVGA3DCONTEXT23, state.cVertexShaderConst), 312 SSMFIELD_ENTRY_TERM() 313 }; 314 315 struct VMSVGA3DCONTEXT23 ctx; 316 int rc = pDevIns->pHlpR3->pfnSSMGetStructEx(pSSM, &ctx, sizeof(ctx), 0, g_aVMSVGA3DCONTEXT23Fields, NULL); 317 AssertRCReturn(rc, rc); 318 319 pContext->id = ctx.id; 320 #ifdef VMSVGA3D_OPENGL 321 pContext->lastError = (GLenum)ctx.lastError; 322 #endif 323 324 pContext->cPixelShaders = ctx.cPixelShaders; 325 pContext->cVertexShaders = ctx.cVertexShaders; 326 pContext->state.u32UpdateFlags = ctx.state.u32UpdateFlags; 327 328 AssertCompile(sizeof(SVGA3dRenderState) == 8); 329 AssertCompile(RT_ELEMENTS(pContext->state.aRenderState) == 99); 330 for (unsigned i = 0; i < RT_ELEMENTS(pContext->state.aRenderState); ++i) 331 pContext->state.aRenderState[i] = ctx.state.aRenderState[i]; 332 333 // Skip pContext->state.aTextureStates 334 AssertCompile(sizeof(SVGA3dTextureState) == 12); 335 336 AssertCompile(sizeof(VMSVGATRANSFORMSTATE) == 68); 337 AssertCompile(RT_ELEMENTS(pContext->state.aTransformState) == 15); 338 for (unsigned i = 0; i < RT_ELEMENTS(pContext->state.aTransformState); ++i) 339 { 340 pContext->state.aTransformState[i].fValid = ctx.state.aTransformState[i].fValid; 341 memcpy(pContext->state.aTransformState[i].matrix, ctx.state.aTransformState[i].matrix, sizeof(pContext->state.aTransformState[i].matrix)); 342 } 343 344 AssertCompile(sizeof(SVGA3dMaterial) == 68); 345 AssertCompile(RT_ELEMENTS(pContext->state.aMaterial) == 5); 346 for (unsigned i = 0; i < RT_ELEMENTS(pContext->state.aMaterial); ++i) 347 { 348 pContext->state.aMaterial[i].fValid = ctx.state.aMaterial[i].fValid; 349 pContext->state.aMaterial[i].material = ctx.state.aMaterial[i].material; 350 } 351 352 AssertCompile(sizeof(VMSVGACLIPPLANESTATE) == 20); 353 AssertCompile(RT_ELEMENTS(pContext->state.aClipPlane) == (1 << 5)); 354 for (unsigned i = 0; i < RT_ELEMENTS(pContext->state.aClipPlane); ++i) 355 { 356 pContext->state.aClipPlane[i].fValid = ctx.state.aClipPlane[i].fValid; 357 memcpy(pContext->state.aClipPlane[i].plane, ctx.state.aClipPlane[i].plane, sizeof(pContext->state.aClipPlane[i].plane)); 358 } 359 360 AssertCompile(sizeof(SVGA3dLightData) == 116); 361 AssertCompile(RT_ELEMENTS(pContext->state.aLightData) == 32); 362 for (unsigned i = 0; i < RT_ELEMENTS(pContext->state.aLightData); ++i) 363 { 364 pContext->state.aLightData[i].fEnabled = ctx.state.aLightData[i].fEnabled; 365 pContext->state.aLightData[i].fValidData = ctx.state.aLightData[i].fValidData; 366 pContext->state.aLightData[i].data = ctx.state.aLightData[i].data; 367 } 368 369 AssertCompile(RT_ELEMENTS(pContext->state.aRenderTargets) == 10); 370 memcpy(pContext->state.aRenderTargets, ctx.state.aRenderTargets, SVGA3D_RT_MAX * sizeof(uint32_t)); 371 372 AssertCompile(sizeof(SVGA3dRect) == 16); 373 pContext->state.RectScissor = ctx.state.RectScissor; 374 pContext->state.RectViewPort = ctx.state.RectViewPort; 375 376 AssertCompile(sizeof(SVGA3dZRange) == 8); 377 pContext->state.zRange = ctx.state.zRange; 378 379 pContext->state.shidPixel = ctx.state.shidPixel; 380 pContext->state.shidVertex = ctx.state.shidVertex; 381 pContext->state.cPixelShaderConst = ctx.state.cPixelShaderConst; 382 pContext->state.cVertexShaderConst = ctx.state.cVertexShaderConst; 383 384 return VINF_SUCCESS; 385 } 386 213 387 int vmsvga3dLoadExec(PPDMDEVINS pDevIns, PVGASTATE pThis, PVGASTATECC pThisCC, PSSMHANDLE pSSM, uint32_t uVersion, uint32_t uPass) 214 388 { … … 267 441 AssertReturn(pContext->id == cid, VERR_INTERNAL_ERROR); 268 442 269 rc = pHlp->pfnSSMGetStructEx(pSSM, pContext, sizeof(*pContext), 0, g_aVMSVGA3DCONTEXTFields, NULL); 443 if (uVersion >= VGA_SAVEDSTATE_VERSION_VMSVGA_MIPLEVELS) 444 rc = pHlp->pfnSSMGetStructEx(pSSM, pContext, sizeof(*pContext), 0, g_aVMSVGA3DCONTEXTFields, NULL); 445 else 446 rc = vmsvga3dLoadVMSVGA3DCONTEXT23(pDevIns, pSSM, pContext); 270 447 AssertRCReturn(rc, rc); 271 448
Note:
See TracChangeset
for help on using the changeset viewer.