Changeset 54658 in vbox for trunk/src/VBox
- Timestamp:
- Mar 5, 2015 8:04:05 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/DevVGA-SVGA3d-ogl.cpp
r54641 r54658 20 20 * Header Files * 21 21 *******************************************************************************/ 22 #ifdef DEBUG_bird 23 # define RTMEM_WRAP_TO_EF_APIS 24 #endif 22 25 #define LOG_GROUP LOG_GROUP_DEV_VMSVGA 23 26 #include <VBox/vmm/pdmdev.h> … … 275 278 * @param a_pState The 3D state structure. 276 279 * @param a_pContext The context that holds the first error. 280 * @param a_LogRelDetails Argument list for LogRel or similar that describes 281 * the operation in greater detail. 277 282 * 278 283 * @sa VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN … … 283 288 VMSVGA3D_GL_COMPLAIN(a_pState, a_pContext, a_LogRelDetails); \ 284 289 } while (0) 290 291 /** @def VMSVGA3D_GL_ASSERT_SUCCESS 292 * Asserts that VMSVGA3D_GL_IS_SUCCESS is true, complains if not. 293 * 294 * Uses VMSVGA3D_GL_COMPLAIN for complaining, so check it out wrt to release 295 * logging in non-strict builds. 296 * 297 * @param a_pState The 3D state structure. 298 * @param a_pContext The context that holds the first error. 299 * @param a_LogRelDetails Argument list for LogRel or similar that describes 300 * the operation in greater detail. 301 * 302 * @sa VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN 303 */ 304 #define VMSVGA3D_GL_ASSERT_SUCCESS(a_pState, a_pContext, a_LogRelDetails) \ 305 if (VMSVGA3D_GL_IS_SUCCESS(a_pContext)) \ 306 { /* likely */ } \ 307 else do { \ 308 VMSVGA3D_GET_GL_ERROR(a_pContext); \ 309 VMSVGA3D_GL_COMPLAIN(a_pState, a_pContext, a_LogRelDetails); \ 310 } while (0) 311 312 /** @def VMSVGA3D_ASSERT_GL_CALL_EX 313 * Executes the specified OpenGL API call and asserts that it succeeded, variant 314 * with extra logging flexibility. 315 * 316 * ASSUMES no GL errors pending prior to invocation - caller should use 317 * VMSVGA3D_CLEAR_GL_ERRORS if uncertain. 318 * 319 * Uses VMSVGA3D_GL_COMPLAIN for complaining, so check it out wrt to release 320 * logging in non-strict builds. 321 * 322 * @param a_GlCall Expression making an OpenGL call. 323 * @param a_pState The 3D state structure. 324 * @param a_pContext The context that holds the first error. 325 * @param a_LogRelDetails Argument list for LogRel or similar that describes 326 * the operation in greater detail. 327 * 328 * @sa VMSVGA3D_ASSERT_GL_CALL, VMSVGA3D_GL_ASSERT_SUCCESS, 329 * VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN 330 */ 331 #define VMSVGA3D_ASSERT_GL_CALL_EX(a_GlCall, a_pState, a_pContext, a_LogRelDetails) \ 332 do { \ 333 (a_GlCall); \ 334 VMSVGA3D_GL_ASSERT_SUCCESS(a_pState, a_pContext, a_LogRelDetails); \ 335 } while (0) 336 337 /** @def VMSVGA3D_ASSERT_GL_CALL 338 * Executes the specified OpenGL API call and asserts that it succeeded. 339 * 340 * ASSUMES no GL errors pending prior to invocation - caller should use 341 * VMSVGA3D_CLEAR_GL_ERRORS if uncertain. 342 * 343 * Uses VMSVGA3D_GL_COMPLAIN for complaining, so check it out wrt to release 344 * logging in non-strict builds. 345 * 346 * @param a_GlCall Expression making an OpenGL call. 347 * @param a_pState The 3D state structure. 348 * @param a_pContext The context that holds the first error. 349 * 350 * @sa VMSVGA3D_ASSERT_GL_CALL_EX, VMSVGA3D_GL_ASSERT_SUCCESS, 351 * VMSVGA3D_GET_GL_ERROR, VMSVGA3D_GL_IS_SUCCESS, VMSVGA3D_GL_COMPLAIN 352 */ 353 #define VMSVGA3D_ASSERT_GL_CALL(a_GlCall, a_pState, a_pContext) \ 354 VMSVGA3D_ASSERT_GL_CALL_EX(a_GlCall, a_pState, a_pContext, ("%s\n", #a_GlCall)) 285 355 286 356 … … 789 859 790 860 861 /** Save and setup everything. */ 862 #define VMSVGA3D_PARANOID_TEXTURE_PACKING 863 864 /** 865 * Saved texture packing parameters (shared by both pack and unpack). 866 */ 867 typedef struct VMSVGAPACKPARAMS 868 { 869 GLint iAlignment; 870 GLint cxRow; 871 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING 872 GLint cyImage; 873 GLboolean fSwapBytes; 874 GLboolean fLsbFirst; 875 GLint cSkipRows; 876 GLint cSkipPixels; 877 GLint cSkipImages; 878 #endif 879 } VMSVGAPACKPARAMS; 880 /** Pointer to saved texture packing parameters. */ 881 typedef VMSVGAPACKPARAMS *PVMSVGAPACKPARAMS; 882 /** Pointer to const saved texture packing parameters. */ 883 typedef VMSVGAPACKPARAMS const *PCVMSVGAPACKPARAMS; 884 885 886 /******************************************************************************* 887 * Global Variables * 888 *******************************************************************************/ 791 889 /* Define the default light parameters as specified by MSDN. */ 792 890 /* @todo move out; fetched from Wine */ … … 807 905 }; 808 906 907 908 /******************************************************************************* 909 * Internal Functions * 910 *******************************************************************************/ 809 911 RT_C_DECLS_BEGIN 810 912 static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, PVMSVGA3DSURFACE pSurface); … … 2123 2225 /** 2124 2226 * Convert SVGA format value to its OpenGL equivalent 2227 * 2228 * @remarks Clues to be had in format_texture_info table (wined3d/utils.c) with 2229 * help from wined3dformat_from_d3dformat(). 2125 2230 */ 2126 2231 static void vmsvga3dSurfaceFormat2OGL(PVMSVGA3DSURFACE pSurface, SVGA3dSurfaceFormat format) … … 2128 2233 switch (format) 2129 2234 { 2130 case SVGA3D_X8R8G8B8: 2235 case SVGA3D_X8R8G8B8: /* D3DFMT_X8R8G8B8 - WINED3DFMT_B8G8R8X8_UNORM */ 2131 2236 pSurface->internalFormatGL = GL_RGB8; 2132 2237 pSurface->formatGL = GL_BGRA; 2133 2238 pSurface->typeGL = GL_UNSIGNED_INT_8_8_8_8_REV; 2134 2239 break; 2135 case SVGA3D_A8R8G8B8: 2240 case SVGA3D_A8R8G8B8: /* D3DFMT_A8R8G8B8 - WINED3DFMT_B8G8R8A8_UNORM */ 2136 2241 pSurface->internalFormatGL = GL_RGBA8; 2137 2242 pSurface->formatGL = GL_BGRA; 2138 2243 pSurface->typeGL = GL_UNSIGNED_INT_8_8_8_8_REV; 2139 2244 break; 2140 case SVGA3D_R5G6B5: 2141 pSurface->internalFormatGL = GL_RGB ;2245 case SVGA3D_R5G6B5: /* D3DFMT_R5G6B5 - WINED3DFMT_B5G6R5_UNORM */ 2246 pSurface->internalFormatGL = GL_RGB5; 2142 2247 pSurface->formatGL = GL_RGB; 2143 2248 pSurface->typeGL = GL_UNSIGNED_SHORT_5_6_5; 2144 break; 2145 case SVGA3D_X1R5G5B5: 2146 pSurface->internalFormatGL = GL_RGB; 2147 pSurface->formatGL = GL_RGB; 2249 AssertMsgFailed(("Test me - SVGA3D_R5G6B5\n")); 2250 break; 2251 case SVGA3D_X1R5G5B5: /* D3DFMT_X1R5G5B5 - WINED3DFMT_B5G5R5X1_UNORM */ 2252 pSurface->internalFormatGL = GL_RGB5; 2253 pSurface->formatGL = GL_BGRA; 2148 2254 pSurface->typeGL = GL_UNSIGNED_SHORT_1_5_5_5_REV; 2149 break; 2150 case SVGA3D_A1R5G5B5: 2151 pSurface->internalFormatGL = GL_RGBA; 2152 pSurface->formatGL = GL_RGB; 2255 AssertMsgFailed(("Test me - SVGA3D_X1R5G5B5\n")); 2256 break; 2257 case SVGA3D_A1R5G5B5: /* D3DFMT_A1R5G5B5 - WINED3DFMT_B5G5R5A1_UNORM */ 2258 pSurface->internalFormatGL = GL_RGB5_A1; 2259 pSurface->formatGL = GL_BGRA; 2153 2260 pSurface->typeGL = GL_UNSIGNED_SHORT_1_5_5_5_REV; 2154 break; 2155 case SVGA3D_A4R4G4B4: 2156 pSurface->internalFormatGL = GL_RGBA; 2157 pSurface->formatGL = GL_RGBA; 2158 pSurface->typeGL = GL_UNSIGNED_SHORT_4_4_4_4; 2159 break; 2160 2161 case SVGA3D_Z_D32: 2261 AssertMsgFailed(("Test me - SVGA3D_A1R5G5B5\n")); 2262 break; 2263 case SVGA3D_A4R4G4B4: /* D3DFMT_A4R4G4B4 - WINED3DFMT_B4G4R4A4_UNORM */ 2264 pSurface->internalFormatGL = GL_RGBA4; 2265 pSurface->formatGL = GL_BGRA; 2266 pSurface->typeGL = GL_UNSIGNED_SHORT_4_4_4_4_REV; 2267 AssertMsgFailed(("Test me - SVGA3D_A4R4G4B4\n")); 2268 break; 2269 2270 case SVGA3D_Z_D32: /* D3DFMT_D32 - WINED3DFMT_D32_UNORM */ 2162 2271 pSurface->internalFormatGL = GL_DEPTH_COMPONENT32; 2163 2272 pSurface->formatGL = GL_DEPTH_COMPONENT; 2164 2273 pSurface->typeGL = GL_UNSIGNED_INT; 2165 2274 break; 2166 case SVGA3D_Z_D16: 2167 pSurface->internalFormatGL = GL_DEPTH_COMPONENT16; 2275 case SVGA3D_Z_D16: /* D3DFMT_D16 - WINED3DFMT_D16_UNORM */ 2276 pSurface->internalFormatGL = GL_DEPTH_COMPONENT16; /** @todo Wine suggests GL_DEPTH_COMPONENT24. */ 2168 2277 pSurface->formatGL = GL_DEPTH_COMPONENT; 2169 2278 pSurface->typeGL = GL_UNSIGNED_SHORT; 2170 break; 2171 case SVGA3D_Z_D24S8: 2279 AssertMsgFailed(("Test me - SVGA3D_Z_D16\n")); 2280 break; 2281 case SVGA3D_Z_D24S8: /* D3DFMT_D24S8 - WINED3DFMT_D24_UNORM_S8_UINT */ 2172 2282 pSurface->internalFormatGL = GL_DEPTH24_STENCIL8; 2173 2283 pSurface->formatGL = GL_DEPTH_STENCIL; 2174 2284 pSurface->typeGL = GL_UNSIGNED_INT; 2175 2285 break; 2176 case SVGA3D_Z_D15S1: 2286 case SVGA3D_Z_D15S1: /* D3DFMT_D15S1 - WINED3DFMT_S1_UINT_D15_UNORM */ 2177 2287 pSurface->internalFormatGL = GL_DEPTH_COMPONENT16; /* @todo ??? */ 2178 2288 pSurface->formatGL = GL_DEPTH_STENCIL; 2179 2289 pSurface->typeGL = GL_UNSIGNED_SHORT; 2180 break; 2181 case SVGA3D_Z_D24X8: 2290 /** @todo Wine sources hints at no hw support for this, so test this one! */ 2291 AssertMsgFailed(("Test me - SVGA3D_Z_D15S1\n")); 2292 break; 2293 case SVGA3D_Z_D24X8: /* D3DFMT_D24X8 - WINED3DFMT_X8D24_UNORM */ 2182 2294 pSurface->internalFormatGL = GL_DEPTH_COMPONENT24; 2183 2295 pSurface->formatGL = GL_DEPTH_COMPONENT; … … 2186 2298 2187 2299 /* Advanced D3D9 depth formats. */ 2188 case SVGA3D_Z_DF16: 2300 case SVGA3D_Z_DF16: /* D3DFMT_DF16? - not supported */ 2189 2301 pSurface->internalFormatGL = GL_DEPTH_COMPONENT16; 2190 2302 pSurface->formatGL = GL_DEPTH_COMPONENT; … … 2192 2304 break; 2193 2305 2194 case SVGA3D_Z_DF24: 2306 case SVGA3D_Z_DF24: /* D3DFMT_DF24? - not supported */ 2195 2307 pSurface->internalFormatGL = GL_DEPTH_COMPONENT24; 2196 2308 pSurface->formatGL = GL_DEPTH_COMPONENT; … … 2198 2310 break; 2199 2311 2200 case SVGA3D_Z_D24S8_INT: 2312 case SVGA3D_Z_D24S8_INT: /* D3DFMT_??? - not supported */ 2201 2313 pSurface->internalFormatGL = GL_DEPTH24_STENCIL8; 2202 2314 pSurface->formatGL = GL_DEPTH_STENCIL; … … 2204 2316 break; 2205 2317 2206 case SVGA3D_DXT1: 2318 case SVGA3D_DXT1: /* D3DFMT_DXT1 - WINED3DFMT_DXT1 */ 2207 2319 pSurface->internalFormatGL = GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; 2320 #if 0 2208 2321 pSurface->formatGL = GL_RGBA_S3TC; /* ??? */ 2209 2322 pSurface->typeGL = GL_UNSIGNED_INT; /* ??? */ 2210 break; 2211 2212 case SVGA3D_DXT3: 2323 #else /* wine suggests: */ 2324 pSurface->formatGL = GL_RGBA; 2325 pSurface->typeGL = GL_UNSIGNED_BYTE; 2326 AssertMsgFailed(("Test me - SVGA3D_DXT1\n")); 2327 #endif 2328 break; 2329 2330 case SVGA3D_DXT3: /* D3DFMT_DXT3 - WINED3DFMT_DXT3 */ 2213 2331 pSurface->internalFormatGL = GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; 2332 #if 0 /** @todo this needs testing... */ 2214 2333 pSurface->formatGL = GL_RGBA_S3TC; /* ??? */ 2215 2334 pSurface->typeGL = GL_UNSIGNED_INT; /* ??? */ 2216 break; 2217 2218 case SVGA3D_DXT5: 2335 #else /* wine suggests: */ 2336 pSurface->formatGL = GL_RGBA; 2337 pSurface->typeGL = GL_UNSIGNED_BYTE; 2338 AssertMsgFailed(("Test me - SVGA3D_DXT3\n")); 2339 #endif 2340 break; 2341 2342 case SVGA3D_DXT5: /* D3DFMT_DXT5 - WINED3DFMT_DXT5 */ 2219 2343 pSurface->internalFormatGL = GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; 2344 #if 0 /** @todo this needs testing... */ 2220 2345 pSurface->formatGL = GL_RGBA_S3TC; 2221 2346 pSurface->typeGL = GL_UNSIGNED_INT; 2222 break; 2223 2224 case SVGA3D_LUMINANCE8: 2347 #else /* wine suggests: */ 2348 pSurface->formatGL = GL_RGBA; 2349 pSurface->typeGL = GL_UNSIGNED_BYTE; 2350 AssertMsgFailed(("Test me - SVGA3D_DXT5\n")); 2351 #endif 2352 break; 2353 2354 case SVGA3D_LUMINANCE8: /* D3DFMT_? - ? */ 2225 2355 pSurface->internalFormatGL = GL_LUMINANCE8_EXT; 2226 2356 pSurface->formatGL = GL_LUMINANCE; … … 2228 2358 break; 2229 2359 2230 case SVGA3D_LUMINANCE16: 2360 case SVGA3D_LUMINANCE16: /* D3DFMT_? - ? */ 2231 2361 pSurface->internalFormatGL = GL_LUMINANCE16_EXT; 2232 2362 pSurface->formatGL = GL_LUMINANCE; … … 2234 2364 break; 2235 2365 2236 case SVGA3D_LUMINANCE4_ALPHA4: 2366 case SVGA3D_LUMINANCE4_ALPHA4: /* D3DFMT_? - ? */ 2237 2367 pSurface->internalFormatGL = GL_LUMINANCE4_ALPHA4_EXT; 2238 2368 pSurface->formatGL = GL_LUMINANCE_ALPHA; … … 2240 2370 break; 2241 2371 2242 case SVGA3D_LUMINANCE8_ALPHA8: 2372 case SVGA3D_LUMINANCE8_ALPHA8: /* D3DFMT_? - ? */ 2243 2373 pSurface->internalFormatGL = GL_LUMINANCE8_ALPHA8_EXT; 2244 2374 pSurface->formatGL = GL_LUMINANCE_ALPHA; … … 2246 2376 break; 2247 2377 2248 case SVGA3D_ALPHA8: 2378 case SVGA3D_ALPHA8: /* D3DFMT_A8? - WINED3DFMT_A8_UNORM? */ 2249 2379 pSurface->internalFormatGL = GL_ALPHA8_EXT; 2250 2380 pSurface->formatGL = GL_ALPHA; … … 2278 2408 #endif 2279 2409 2280 case SVGA3D_ARGB_S10E5: /* 16-bit floating-point ARGB */ 2410 case SVGA3D_ARGB_S10E5: /* 16-bit floating-point ARGB */ /* D3DFMT_A16B16G16R16F - WINED3DFMT_R16G16B16A16_FLOAT */ 2281 2411 pSurface->internalFormatGL = GL_RGBA16F; 2282 2412 pSurface->formatGL = GL_RGBA; 2413 #if 0 /* bird: wine uses half float, sounds correct to me... */ 2283 2414 pSurface->typeGL = GL_FLOAT; 2284 break; 2285 2286 case SVGA3D_ARGB_S23E8: /* 32-bit floating-point ARGB */ 2415 #else 2416 pSurface->typeGL = GL_HALF_FLOAT; 2417 AssertMsgFailed(("Test me - SVGA3D_ARGB_S10E5\n")); 2418 #endif 2419 break; 2420 2421 case SVGA3D_ARGB_S23E8: /* 32-bit floating-point ARGB */ /* D3DFMT_A32B32G32R32F - WINED3DFMT_R32G32B32A32_FLOAT */ 2287 2422 pSurface->internalFormatGL = GL_RGBA32F; 2288 2423 pSurface->formatGL = GL_RGBA; 2289 pSurface->typeGL = GL_FLOAT; /* ?? */ 2290 break; 2291 2292 case SVGA3D_A2R10G10B10: 2293 pSurface->internalFormatGL = GL_RGB10_A2; /* ?? */ 2424 pSurface->typeGL = GL_FLOAT; /* ?? - same as wine, so probably correct */ 2425 break; 2426 2427 case SVGA3D_A2R10G10B10: /* D3DFMT_A2R10G10B10 - WINED3DFMT_B10G10R10A2_UNORM */ 2428 pSurface->internalFormatGL = GL_RGB10_A2; /* ?? - same as wine, so probably correct */ 2429 #if 0 /* bird: Wine uses GL_BGRA instead of GL_RGBA. */ 2294 2430 pSurface->formatGL = GL_RGBA; 2431 #else 2432 pSurface->formatGL = GL_BGRA; 2433 #endif 2295 2434 pSurface->typeGL = GL_UNSIGNED_INT; 2435 AssertMsgFailed(("Test me - SVGA3D_A2R10G10B10\n")); 2296 2436 break; 2297 2437 2298 2438 2299 2439 /* Single- and dual-component floating point formats */ 2300 case SVGA3D_R_S10E5: 2440 case SVGA3D_R_S10E5: /* D3DFMT_R16F - WINED3DFMT_R16_FLOAT */ 2301 2441 pSurface->internalFormatGL = GL_R16F; 2302 2442 pSurface->formatGL = GL_RED; 2443 #if 0 /* bird: wine uses half float, sounds correct to me... */ 2303 2444 pSurface->typeGL = GL_FLOAT; 2304 break; 2305 case SVGA3D_R_S23E8: 2445 #else 2446 pSurface->typeGL = GL_HALF_FLOAT; 2447 AssertMsgFailed(("Test me - SVGA3D_R_S10E5\n")); 2448 #endif 2449 break; 2450 case SVGA3D_R_S23E8: /* D3DFMT_R32F - WINED3DFMT_R32_FLOAT */ 2306 2451 pSurface->internalFormatGL = GL_R32F; 2307 2452 pSurface->formatGL = GL_RG; 2308 2453 pSurface->typeGL = GL_FLOAT; 2309 2454 break; 2310 case SVGA3D_RG_S10E5: 2455 case SVGA3D_RG_S10E5: /* D3DFMT_G16R16F - WINED3DFMT_R16G16_FLOAT */ 2311 2456 pSurface->internalFormatGL = GL_RG16F; 2312 2457 pSurface->formatGL = GL_RG; 2458 #if 0 /* bird: wine uses half float, sounds correct to me... */ 2313 2459 pSurface->typeGL = GL_FLOAT; 2314 break; 2315 case SVGA3D_RG_S23E8: 2460 #else 2461 pSurface->typeGL = GL_HALF_FLOAT; 2462 AssertMsgFailed(("Test me - SVGA3D_RG_S10E5\n")); 2463 #endif 2464 break; 2465 case SVGA3D_RG_S23E8: /* D3DFMT_G32R32F - WINED3DFMT_R32G32_FLOAT */ 2316 2466 pSurface->internalFormatGL = GL_RG32F; 2317 2467 pSurface->formatGL = GL_RG; … … 2337 2487 #endif 2338 2488 2339 case SVGA3D_G16R16: 2489 case SVGA3D_G16R16: /* D3DFMT_G16R16 - WINED3DFMT_R16G16_UNORM */ 2340 2490 pSurface->internalFormatGL = GL_RG16; 2341 2491 pSurface->formatGL = GL_RG; 2492 #if 0 /* bird: Wine uses GL_UNSIGNED_SHORT here. */ 2342 2493 pSurface->typeGL = GL_UNSIGNED_INT; 2343 break; 2344 2345 case SVGA3D_A16B16G16R16: 2494 #else 2495 pSurface->typeGL = GL_UNSIGNED_SHORT; 2496 AssertMsgFailed(("test me - SVGA3D_G16R16\n")); 2497 #endif 2498 break; 2499 2500 case SVGA3D_A16B16G16R16: /* D3DFMT_A16B16G16R16 - WINED3DFMT_R16G16B16A16_UNORM */ 2346 2501 pSurface->internalFormatGL = GL_RGBA16; 2347 pSurface->formatGL = GL_RG; 2502 pSurface->formatGL = GL_RGBA; 2503 #if 0 /* bird: Wine uses GL_UNSIGNED_SHORT here. */ 2348 2504 pSurface->typeGL = GL_UNSIGNED_INT; /* ??? */ 2505 #else 2506 pSurface->typeGL = GL_UNSIGNED_SHORT; 2507 AssertMsgFailed(("Test me - SVGA3D_A16B16G16R16\n")); 2508 #endif 2349 2509 break; 2350 2510 … … 2587 2747 { 2588 2748 PVMSVGA3DSURFACE pSurface = &pState->paSurface[sid]; 2589 PVMSVGA3DCONTEXT pContext = NULL;2749 PVMSVGA3DCONTEXT pContext; 2590 2750 2591 2751 Log(("vmsvga3dSurfaceDestroy id %x\n", sid)); … … 2595 2755 for (uint32_t cid = 0; cid < pState->cContexts; cid++) 2596 2756 { 2597 PVMSVGA3DCONTEXTpContext = &pState->paContext[cid];2757 pContext = &pState->paContext[cid]; 2598 2758 if (pContext->id == cid) 2599 2759 { … … 2729 2889 } 2730 2890 2891 2892 /** 2893 * Save texture unpacking parameters and loads those appropriate for the given 2894 * surface. 2895 * 2896 * @param pState The VMSVGA3D state structure. 2897 * @param pContext The active context. 2898 * @param pSurface The surface. 2899 * @param pSave Where to save stuff. 2900 */ 2901 static void vmsvga3dSetUnpackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface, 2902 PVMSVGAPACKPARAMS pSave) 2903 { 2904 /* 2905 * Save (ignore errors, setting the defaults we want and avoids restore). 2906 */ 2907 pSave->iAlignment = 1; 2908 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ALIGNMENT, &pSave->iAlignment), pState, pContext); 2909 pSave->cxRow = 0; 2910 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &pSave->cxRow), pState, pContext); 2911 2912 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING 2913 pSave->cyImage = 0; 2914 glGetIntegerv(GL_UNPACK_IMAGE_HEIGHT, &pSave->cyImage); 2915 Assert(pSave->cyImage == 0); 2916 2917 pSave->fSwapBytes = GL_FALSE; 2918 glGetBooleanv(GL_UNPACK_SWAP_BYTES, &pSave->fSwapBytes); 2919 Assert(pSave->fSwapBytes == GL_FALSE); 2920 2921 pSave->fLsbFirst = GL_FALSE; 2922 glGetBooleanv(GL_UNPACK_LSB_FIRST, &pSave->fLsbFirst); 2923 Assert(pSave->fLsbFirst == GL_FALSE); 2924 2925 pSave->cSkipRows = 0; 2926 glGetIntegerv(GL_UNPACK_SKIP_ROWS, &pSave->cSkipRows); 2927 Assert(pSave->cSkipRows == 0); 2928 2929 pSave->cSkipPixels = 0; 2930 glGetIntegerv(GL_UNPACK_SKIP_PIXELS, &pSave->cSkipPixels); 2931 Assert(pSave->cSkipPixels == 0); 2932 2933 pSave->cSkipImages = 0; 2934 glGetIntegerv(GL_UNPACK_SKIP_IMAGES, &pSave->cSkipImages); 2935 Assert(pSave->cSkipImages == 0); 2936 2937 VMSVGA3D_CLEAR_GL_ERRORS(); 2938 #endif 2939 2940 /* 2941 * Setup unpack. 2942 * 2943 * Note! We use 1 as alignment here because we currently don't do any 2944 * aligning of line pitches anywhere. 2945 */ 2946 NOREF(pSurface); 2947 if (pSave->iAlignment != 1) 2948 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, 1), pState, pContext); 2949 if (pSave->cxRow != 0) 2950 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, 0), pState, pContext); 2951 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING 2952 if (pSave->cyImage != 0) 2953 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, 0), pState, pContext); 2954 if (pSave->fSwapBytes != 0) 2955 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SWAP_BYTES, GL_FALSE), pState, pContext); 2956 if (pSave->fLsbFirst != 0) 2957 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_LSB_FIRST, GL_FALSE), pState, pContext); 2958 if (pSave->cSkipRows != 0) 2959 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_ROWS, 0), pState, pContext); 2960 if (pSave->cSkipPixels != 0) 2961 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS, 0), pState, pContext); 2962 if (pSave->cSkipImages != 0) 2963 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_IMAGES, 0), pState, pContext); 2964 #endif 2965 } 2966 2967 2968 /** 2969 * Restores texture unpacking parameters. 2970 * 2971 * @param pState The VMSVGA3D state structure. 2972 * @param pContext The active context. 2973 * @param pSurface The surface. 2974 * @param pSave Where stuff was saved. 2975 */ 2976 static void vmsvga3dRestoreUnpackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface, 2977 PCVMSVGAPACKPARAMS pSave) 2978 { 2979 NOREF(pSurface); 2980 if (pSave->iAlignment != 1) 2981 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ALIGNMENT, pSave->iAlignment), pState, pContext); 2982 if (pSave->cxRow != 0) 2983 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_ROW_LENGTH, pSave->cxRow), pState, pContext); 2984 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING 2985 if (pSave->cyImage != 0) 2986 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_IMAGE_HEIGHT, pSave->cyImage), pState, pContext); 2987 if (pSave->fSwapBytes != 0) 2988 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SWAP_BYTES, pSave->fSwapBytes), pState, pContext); 2989 if (pSave->fLsbFirst != 0) 2990 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_LSB_FIRST, pSave->fLsbFirst), pState, pContext); 2991 if (pSave->cSkipRows != 0) 2992 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_ROWS, pSave->cSkipRows), pState, pContext); 2993 if (pSave->cSkipPixels != 0) 2994 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_PIXELS, pSave->cSkipPixels), pState, pContext); 2995 if (pSave->cSkipImages != 0) 2996 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_UNPACK_SKIP_IMAGES, pSave->cSkipImages), pState, pContext); 2997 #endif 2998 } 2999 3000 2731 3001 /* Create D3D texture object for the specified surface. */ 2732 3002 static int vmsvga3dCreateTexture(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, uint32_t idAssociatedContext, … … 2748 3018 if (pSurface->fDirty) 2749 3019 { 3020 /* Set the unacpking parameters. */ 3021 VMSVGAPACKPARAMS SavedParams; 3022 vmsvga3dSetUnpackParams(pState, pContext, pSurface, &SavedParams); 3023 2750 3024 Log(("vmsvga3dCreateTexture: sync dirty texture\n")); 2751 3025 for (uint32_t i = 0; i < pSurface->faces[0].numMipLevels; i++) … … 2771 3045 } 2772 3046 pSurface->fDirty = false; 3047 3048 /* Restore packing parameters. */ 3049 vmsvga3dRestoreUnpackParams(pState, pContext, pSurface, &SavedParams); 2773 3050 } 2774 3051 else … … 2908 3185 } 2909 3186 3187 /** 3188 * Save texture packing parameters and loads those appropriate for the given 3189 * surface. 3190 * 3191 * @param pState The VMSVGA3D state structure. 3192 * @param pContext The active context. 3193 * @param pSurface The surface. 3194 * @param pSave Where to save stuff. 3195 */ 3196 static void vmsvga3dSetPackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface, 3197 PVMSVGAPACKPARAMS pSave) 3198 { 3199 /* 3200 * Save (ignore errors, setting the defaults we want and avoids restore). 3201 */ 3202 pSave->iAlignment = 1; 3203 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ALIGNMENT, &pSave->iAlignment), pState, pContext); 3204 pSave->cxRow = 0; 3205 VMSVGA3D_ASSERT_GL_CALL(glGetIntegerv(GL_UNPACK_ROW_LENGTH, &pSave->cxRow), pState, pContext); 3206 3207 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING 3208 pSave->cyImage = 0; 3209 glGetIntegerv(GL_PACK_IMAGE_HEIGHT, &pSave->cyImage); 3210 Assert(pSave->cyImage == 0); 3211 3212 pSave->fSwapBytes = GL_FALSE; 3213 glGetBooleanv(GL_PACK_SWAP_BYTES, &pSave->fSwapBytes); 3214 Assert(pSave->fSwapBytes == GL_FALSE); 3215 3216 pSave->fLsbFirst = GL_FALSE; 3217 glGetBooleanv(GL_PACK_LSB_FIRST, &pSave->fLsbFirst); 3218 Assert(pSave->fLsbFirst == GL_FALSE); 3219 3220 pSave->cSkipRows = 0; 3221 glGetIntegerv(GL_PACK_SKIP_ROWS, &pSave->cSkipRows); 3222 Assert(pSave->cSkipRows == 0); 3223 3224 pSave->cSkipPixels = 0; 3225 glGetIntegerv(GL_PACK_SKIP_PIXELS, &pSave->cSkipPixels); 3226 Assert(pSave->cSkipPixels == 0); 3227 3228 pSave->cSkipImages = 0; 3229 glGetIntegerv(GL_PACK_SKIP_IMAGES, &pSave->cSkipImages); 3230 Assert(pSave->cSkipImages == 0); 3231 3232 VMSVGA3D_CLEAR_GL_ERRORS(); 3233 #endif 3234 3235 /* 3236 * Setup unpack. 3237 * 3238 * Note! We use 1 as alignment here because we currently don't do any 3239 * aligning of line pitches anywhere. 3240 */ 3241 NOREF(pSurface); 3242 if (pSave->iAlignment != 1) 3243 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ALIGNMENT, 1), pState, pContext); 3244 if (pSave->cxRow != 0) 3245 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ROW_LENGTH, 0), pState, pContext); 3246 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING 3247 if (pSave->cyImage != 0) 3248 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_IMAGE_HEIGHT, 0), pState, pContext); 3249 if (pSave->fSwapBytes != 0) 3250 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SWAP_BYTES, GL_FALSE), pState, pContext); 3251 if (pSave->fLsbFirst != 0) 3252 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_LSB_FIRST, GL_FALSE), pState, pContext); 3253 if (pSave->cSkipRows != 0) 3254 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_ROWS, 0), pState, pContext); 3255 if (pSave->cSkipPixels != 0) 3256 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_PIXELS, 0), pState, pContext); 3257 if (pSave->cSkipImages != 0) 3258 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_IMAGES, 0), pState, pContext); 3259 #endif 3260 } 3261 3262 3263 /** 3264 * Restores texture packing parameters. 3265 * 3266 * @param pState The VMSVGA3D state structure. 3267 * @param pContext The active context. 3268 * @param pSurface The surface. 3269 * @param pSave Where stuff was saved. 3270 */ 3271 static void vmsvga3dRestorePackParams(PVMSVGA3DSTATE pState, PVMSVGA3DCONTEXT pContext, PVMSVGA3DSURFACE pSurface, 3272 PCVMSVGAPACKPARAMS pSave) 3273 { 3274 NOREF(pSurface); 3275 if (pSave->iAlignment != 1) 3276 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ALIGNMENT, pSave->iAlignment), pState, pContext); 3277 if (pSave->cxRow != 0) 3278 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_ROW_LENGTH, pSave->cxRow), pState, pContext); 3279 #ifdef VMSVGA3D_PARANOID_TEXTURE_PACKING 3280 if (pSave->cyImage != 0) 3281 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_IMAGE_HEIGHT, pSave->cyImage), pState, pContext); 3282 if (pSave->fSwapBytes != 0) 3283 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SWAP_BYTES, pSave->fSwapBytes), pState, pContext); 3284 if (pSave->fLsbFirst != 0) 3285 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_LSB_FIRST, pSave->fLsbFirst), pState, pContext); 3286 if (pSave->cSkipRows != 0) 3287 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_ROWS, pSave->cSkipRows), pState, pContext); 3288 if (pSave->cSkipPixels != 0) 3289 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_PIXELS, pSave->cSkipPixels), pState, pContext); 3290 if (pSave->cSkipImages != 0) 3291 VMSVGA3D_ASSERT_GL_CALL(glPixelStorei(GL_PACK_SKIP_IMAGES, pSave->cSkipImages), pState, pContext); 3292 #endif 3293 } 3294 3295 2910 3296 int vmsvga3dSurfaceDMA(PVGASTATE pThis, SVGA3dGuestImage guest, SVGA3dSurfaceImageId host, SVGA3dTransferType transfer, 2911 3297 uint32_t cCopyBoxes, SVGA3dCopyBox *pBoxes) … … 3051 3437 GLint activeTexture; 3052 3438 3439 /* Must bind texture to the current context in order to read it. */ 3053 3440 glGetIntegerv(GL_TEXTURE_BINDING_2D, &activeTexture); 3054 3441 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); … … 3056 3443 glBindTexture(GL_TEXTURE_2D, pSurface->oglId.texture); 3057 3444 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 3445 3446 /* Set row length and alignment of the input data. */ 3447 VMSVGAPACKPARAMS SavedParams; 3448 vmsvga3dSetPackParams(pState, pContext, pSurface, &SavedParams); 3058 3449 3059 3450 glGetTexImage(GL_TEXTURE_2D, … … 3063 3454 pDoubleBuffer); 3064 3455 VMSVGA3D_CHECK_LAST_ERROR_WARN(pState, pContext); 3456 3457 vmsvga3dRestorePackParams(pState, pContext, pSurface, &SavedParams); 3065 3458 3066 3459 /* Restore the old active texture. */ … … 3114 3507 { 3115 3508 GLint activeTexture = 0; 3116 GLint alignment;3117 3509 3118 3510 glGetIntegerv(GL_TEXTURE_BINDING_2D, &activeTexture); … … 3126 3518 3127 3519 /* Set row length and alignment of the input data. */ 3128 glGetIntegerv(GL_UNPACK_ALIGNMENT, &alignment); 3129 glPixelStorei(GL_UNPACK_ROW_LENGTH, pBoxes[i].w); 3130 glPixelStorei(GL_UNPACK_ALIGNMENT, pSurface->cbBlock); 3520 VMSVGAPACKPARAMS SavedParams; 3521 vmsvga3dSetUnpackParams(pState, pContext, pSurface, &SavedParams); /** @todo do we need to set ROW_LENGTH to w here? */ 3131 3522 3132 3523 glTexSubImage2D(GL_TEXTURE_2D, … … 3143 3534 3144 3535 /* Restore old values. */ 3145 glPixelStorei(GL_UNPACK_ROW_LENGTH, 0); 3146 glPixelStorei(GL_UNPACK_ALIGNMENT, alignment); 3536 vmsvga3dRestoreUnpackParams(pState, pContext, pSurface, &SavedParams); 3147 3537 3148 3538 /* Restore the old active texture. */
Note:
See TracChangeset
for help on using the changeset viewer.