@@ -126,10 +126,6 @@ static WICTranslate g_WICFormats[] =
126
126
{ GUID_WICPixelFormat8bppGray, DXGI_FORMAT_R8_UNORM },
127
127
128
128
{ GUID_WICPixelFormat8bppAlpha, DXGI_FORMAT_A8_UNORM },
129
-
130
- #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ )
131
- { GUID_WICPixelFormat96bppRGBFloat, DXGI_FORMAT_R32G32B32_FLOAT },
132
- #endif
133
129
};
134
130
135
131
// -------------------------------------------------------------------------------------
@@ -202,18 +198,17 @@ static WICConvert g_WICConvert[] =
202
198
{ GUID_WICPixelFormat40bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM
203
199
{ GUID_WICPixelFormat80bppCMYKAlpha, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM
204
200
205
- #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ )
201
+ #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ ) || defined (_WIN7_PLATFORM_UPDATE)
206
202
{ GUID_WICPixelFormat32bppRGB, GUID_WICPixelFormat32bppRGBA }, // DXGI_FORMAT_R8G8B8A8_UNORM
207
203
{ GUID_WICPixelFormat64bppRGB, GUID_WICPixelFormat64bppRGBA }, // DXGI_FORMAT_R16G16B16A16_UNORM
208
204
{ GUID_WICPixelFormat64bppPRGBAHalf, GUID_WICPixelFormat64bppRGBAHalf }, // DXGI_FORMAT_R16G16B16A16_FLOAT
209
- { GUID_WICPixelFormat96bppRGBFixedPoint, GUID_WICPixelFormat96bppRGBFloat }, // DXGI_FORMAT_R32G32B32_FLOAT
210
- #else
211
- { GUID_WICPixelFormat96bppRGBFixedPoint, GUID_WICPixelFormat128bppRGBAFloat }, // DXGI_FORMAT_R32G32B32A32_FLOAT
212
205
#endif
213
206
214
207
// We don't support n-channel formats
215
208
};
216
209
210
+ static bool g_WIC2 = false ;
211
+
217
212
// --------------------------------------------------------------------------------------
218
213
static IWICImagingFactory* _GetWIC ()
219
214
{
@@ -222,6 +217,37 @@ static IWICImagingFactory* _GetWIC()
222
217
if ( s_Factory )
223
218
return s_Factory;
224
219
220
+ #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ ) || defined (_WIN7_PLATFORM_UPDATE)
221
+ HRESULT hr = CoCreateInstance (
222
+ CLSID_WICImagingFactory2,
223
+ nullptr ,
224
+ CLSCTX_INPROC_SERVER,
225
+ __uuidof (IWICImagingFactory2),
226
+ (LPVOID*)&s_Factory
227
+ );
228
+
229
+ if ( SUCCEEDED (hr) )
230
+ {
231
+ // WIC2 is available on Windows 8 and Windows 7 SP1 with KB 2670838 installed
232
+ g_WIC2 = true ;
233
+ }
234
+ else
235
+ {
236
+ hr = CoCreateInstance (
237
+ CLSID_WICImagingFactory1,
238
+ nullptr ,
239
+ CLSCTX_INPROC_SERVER,
240
+ __uuidof (IWICImagingFactory),
241
+ (LPVOID*)&s_Factory
242
+ );
243
+
244
+ if ( FAILED (hr) )
245
+ {
246
+ s_Factory = nullptr ;
247
+ return nullptr ;
248
+ }
249
+ }
250
+ #else
225
251
HRESULT hr = CoCreateInstance (
226
252
CLSID_WICImagingFactory,
227
253
nullptr ,
@@ -235,6 +261,7 @@ static IWICImagingFactory* _GetWIC()
235
261
s_Factory = nullptr ;
236
262
return nullptr ;
237
263
}
264
+ #endif
238
265
239
266
return s_Factory;
240
267
}
@@ -248,6 +275,14 @@ static DXGI_FORMAT _WICToDXGI( const GUID& guid )
248
275
return g_WICFormats[i].format ;
249
276
}
250
277
278
+ #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ ) || defined (_WIN7_PLATFORM_UPDATE)
279
+ if ( g_WIC2 )
280
+ {
281
+ if ( memcmp ( &GUID_WICPixelFormat96bppRGBFloat, &guid, sizeof (GUID) ) == 0 )
282
+ return DXGI_FORMAT_R32G32B32_FLOAT;
283
+ }
284
+ #endif
285
+
251
286
return DXGI_FORMAT_UNKNOWN;
252
287
}
253
288
@@ -361,16 +396,34 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice,
361
396
DXGI_FORMAT format = _WICToDXGI ( pixelFormat );
362
397
if ( format == DXGI_FORMAT_UNKNOWN )
363
398
{
364
- for ( size_t i= 0 ; i < _countof (g_WICConvert); ++i )
399
+ if ( memcmp ( &GUID_WICPixelFormat96bppRGBFixedPoint, &pixelFormat, sizeof (WICPixelFormatGUID) ) == 0 )
365
400
{
366
- if ( memcmp ( &g_WICConvert[i].source , &pixelFormat, sizeof (WICPixelFormatGUID) ) == 0 )
401
+ #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ ) || defined (_WIN7_PLATFORM_UPDATE)
402
+ if ( g_WIC2 )
367
403
{
368
- memcpy ( &convertGUID, &g_WICConvert[i].target , sizeof (WICPixelFormatGUID) );
369
-
370
- format = _WICToDXGI ( g_WICConvert[i].target );
371
- assert ( format != DXGI_FORMAT_UNKNOWN );
372
- bpp = _WICBitsPerPixel ( convertGUID );
373
- break ;
404
+ memcpy ( &convertGUID, &GUID_WICPixelFormat96bppRGBFloat, sizeof (WICPixelFormatGUID) );
405
+ format = DXGI_FORMAT_R32G32B32_FLOAT;
406
+ }
407
+ else
408
+ #endif
409
+ {
410
+ memcpy ( &convertGUID, &GUID_WICPixelFormat128bppRGBAFloat, sizeof (WICPixelFormatGUID) );
411
+ format = DXGI_FORMAT_R32G32B32A32_FLOAT;
412
+ }
413
+ }
414
+ else
415
+ {
416
+ for ( size_t i=0 ; i < _countof (g_WICConvert); ++i )
417
+ {
418
+ if ( memcmp ( &g_WICConvert[i].source , &pixelFormat, sizeof (WICPixelFormatGUID) ) == 0 )
419
+ {
420
+ memcpy ( &convertGUID, &g_WICConvert[i].target , sizeof (WICPixelFormatGUID) );
421
+
422
+ format = _WICToDXGI ( g_WICConvert[i].target );
423
+ assert ( format != DXGI_FORMAT_UNKNOWN );
424
+ bpp = _WICBitsPerPixel ( convertGUID );
425
+ break ;
426
+ }
374
427
}
375
428
}
376
429
@@ -382,7 +435,7 @@ static HRESULT CreateTextureFromWIC( _In_ ID3D11Device* d3dDevice,
382
435
bpp = _WICBitsPerPixel ( pixelFormat );
383
436
}
384
437
385
- #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ )
438
+ #if (_WIN32_WINNT >= 0x0602 /* _WIN32_WINNT_WIN8*/ ) || defined (_WIN7_PLATFORM_UPDATE)
386
439
if ( (format == DXGI_FORMAT_R32G32B32_FLOAT) && d3dContext != 0 && textureView != 0 )
387
440
{
388
441
// Special case test for optional device support for autogen mipchains for R32G32B32_FLOAT
0 commit comments