@@ -1245,7 +1245,30 @@ static HRESULT _Generate2DMipsTriangleFilter( _In_ size_t levels, _In_ DWORD fil
1245
1245
1246
1246
if ( !rowAcc->remaining )
1247
1247
{
1248
- if ( !_StoreScanlineLinear ( pDest + (dest->rowPitch * v), dest->rowPitch , dest->format , rowAcc->scanline .get (), dest->width , filter ) )
1248
+ XMVECTOR* pAccSrc = rowAcc->scanline .get ();
1249
+ if ( !pAccSrc )
1250
+ return E_POINTER;
1251
+
1252
+ switch ( dest->format )
1253
+ {
1254
+ case DXGI_FORMAT_R10G10B10A2_UNORM:
1255
+ case DXGI_FORMAT_R10G10B10A2_UINT:
1256
+ {
1257
+ // Need to slightly bias results for floating-point error accumulation which can
1258
+ // be visible with harshly quantized values
1259
+ static const XMVECTORF32 Bias = { 0 .f , 0 .f , 0 .f , 0 .1f };
1260
+
1261
+ XMVECTOR* ptr = pAccSrc;
1262
+ for ( size_t i=0 ; i < dest->width ; ++i, ++ptr )
1263
+ {
1264
+ *ptr = XMVectorAdd ( *ptr, Bias );
1265
+ }
1266
+ }
1267
+ break ;
1268
+ }
1269
+
1270
+ // This performs any required clamping
1271
+ if ( !_StoreScanlineLinear ( pDest + (dest->rowPitch * v), dest->rowPitch , dest->format , pAccSrc, dest->width , filter ) )
1249
1272
return E_FAIL;
1250
1273
1251
1274
// Put row on freelist to reuse it's allocated scanline
@@ -2402,6 +2425,25 @@ static HRESULT _Generate3DMipsTriangleFilter( _In_ size_t depth, _In_ size_t lev
2402
2425
2403
2426
for ( size_t h = 0 ; h < nheight; ++h )
2404
2427
{
2428
+ switch ( dest->format )
2429
+ {
2430
+ case DXGI_FORMAT_R10G10B10A2_UNORM:
2431
+ case DXGI_FORMAT_R10G10B10A2_UINT:
2432
+ {
2433
+ // Need to slightly bias results for floating-point error accumulation which can
2434
+ // be visible with harshly quantized values
2435
+ static const XMVECTORF32 Bias = { 0 .f , 0 .f , 0 .f , 0 .1f };
2436
+
2437
+ XMVECTOR* ptr = pAccSrc;
2438
+ for ( size_t i=0 ; i < dest->width ; ++i, ++ptr )
2439
+ {
2440
+ *ptr = XMVectorAdd ( *ptr, Bias );
2441
+ }
2442
+ }
2443
+ break ;
2444
+ }
2445
+
2446
+ // This performs any required clamping
2405
2447
if ( !_StoreScanlineLinear ( pDest, dest->rowPitch , dest->format , pAccSrc, dest->width , filter ) )
2406
2448
return E_FAIL;
2407
2449
@@ -2845,7 +2887,7 @@ HRESULT GenerateMipMaps3D( const Image* baseImages, size_t depth, DWORD filter,
2845
2887
if ( !filter_select )
2846
2888
{
2847
2889
// Default filter choice
2848
- filter_select = ( ispow2 (width) && ispow2 (height) && ispow2 (depth) ) ? TEX_FILTER_BOX : TEX_FILTER_LINEAR ;
2890
+ filter_select = ( ispow2 (width) && ispow2 (height) && ispow2 (depth) ) ? TEX_FILTER_BOX : TEX_FILTER_TRIANGLE ;
2849
2891
}
2850
2892
2851
2893
switch ( filter_select )
@@ -2953,7 +2995,7 @@ HRESULT GenerateMipMaps3D( const Image* srcImages, size_t nimages, const TexMeta
2953
2995
if ( !filter_select )
2954
2996
{
2955
2997
// Default filter choice
2956
- filter_select = ( ispow2 (metadata.width ) && ispow2 (metadata.height ) && ispow2 (metadata.depth ) ) ? TEX_FILTER_BOX : TEX_FILTER_LINEAR ;
2998
+ filter_select = ( ispow2 (metadata.width ) && ispow2 (metadata.height ) && ispow2 (metadata.depth ) ) ? TEX_FILTER_BOX : TEX_FILTER_TRIANGLE ;
2957
2999
}
2958
3000
2959
3001
switch ( filter_select )
0 commit comments