From ee870efb9ee55afcc0b07160b0b08b11c7785f50 Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Tue, 12 Aug 2014 15:01:09 -0700 Subject: [PATCH] Standalone DDSTextureLoader, WICTextureLoader, ScreenGrab sync'd; removed partial XBox One support --- DDSTextureLoader/DDSTextureLoader.cpp | 138 +++++++++++--------------- DDSTextureLoader/DDSTextureLoader.h | 6 -- ScreenGrab/ScreenGrab.cpp | 13 --- ScreenGrab/ScreenGrab.h | 6 -- WICTextureLoader/WICTextureLoader.h | 6 -- 5 files changed, 59 insertions(+), 110 deletions(-) diff --git a/DDSTextureLoader/DDSTextureLoader.cpp b/DDSTextureLoader/DDSTextureLoader.cpp index fed698c..86b606b 100644 --- a/DDSTextureLoader/DDSTextureLoader.cpp +++ b/DDSTextureLoader/DDSTextureLoader.cpp @@ -410,19 +410,6 @@ static size_t BitsPerPixel( _In_ DXGI_FORMAT fmt ) case DXGI_FORMAT_BC7_UNORM_SRGB: return 8; -#if defined(_XBOX_ONE) && defined(_TITLE) - - case DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - case DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - return 32; - - case DXGI_FORMAT_D16_UNORM_S8_UINT: - case DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X16_TYPELESS_G8_UINT: - return 24; - -#endif // _XBOX_ONE && _TITLE - default: return 0; } @@ -502,17 +489,6 @@ static void GetSurfaceInfo( _In_ size_t width, planar = true; bpe = 4; break; - -#if defined(_XBOX_ONE) && defined(_TITLE) - - case DXGI_FORMAT_D16_UNORM_S8_UINT: - case DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X16_TYPELESS_G8_UINT: - planar = true; - bpe = 4; - break; - -#endif } if (bc) @@ -1170,12 +1146,12 @@ static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice, { HRESULT hr = S_OK; - size_t width = header->width; - size_t height = header->height; - size_t depth = header->depth; + UINT width = header->width; + UINT height = header->height; + UINT depth = header->depth; uint32_t resDim = D3D11_RESOURCE_DIMENSION_UNKNOWN; - size_t arraySize = 1; + UINT arraySize = 1; DXGI_FORMAT format = DXGI_FORMAT_UNKNOWN; bool isCubeMap = false; @@ -1295,42 +1271,45 @@ static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice, switch ( resDim ) { - case D3D11_RESOURCE_DIMENSION_TEXTURE1D: - if ((arraySize > D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) || - (width > D3D11_REQ_TEXTURE1D_U_DIMENSION) ) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - break; + case D3D11_RESOURCE_DIMENSION_TEXTURE1D: + if ((arraySize > D3D11_REQ_TEXTURE1D_ARRAY_AXIS_DIMENSION) || + (width > D3D11_REQ_TEXTURE1D_U_DIMENSION) ) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + break; - case D3D11_RESOURCE_DIMENSION_TEXTURE2D: - if ( isCubeMap ) - { - // This is the right bound because we set arraySize to (NumCubes*6) above - if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D11_REQ_TEXTURECUBE_DIMENSION) || - (height > D3D11_REQ_TEXTURECUBE_DIMENSION)) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - } - else if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || - (width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION) || - (height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION)) + case D3D11_RESOURCE_DIMENSION_TEXTURE2D: + if ( isCubeMap ) + { + // This is the right bound because we set arraySize to (NumCubes*6) above + if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || + (width > D3D11_REQ_TEXTURECUBE_DIMENSION) || + (height > D3D11_REQ_TEXTURECUBE_DIMENSION)) { return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); } - break; + } + else if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) || + (width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION) || + (height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION)) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + break; - case D3D11_RESOURCE_DIMENSION_TEXTURE3D: - if ((arraySize > 1) || - (width > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (height > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || - (depth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) ) - { - return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); - } - break; + case D3D11_RESOURCE_DIMENSION_TEXTURE3D: + if ((arraySize > 1) || + (width > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || + (height > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) || + (depth > D3D11_REQ_TEXTURE3D_U_V_OR_W_DIMENSION) ) + { + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); + } + break; + + default: + return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED ); } bool autogen = false; @@ -1374,28 +1353,29 @@ static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice, return HRESULT_FROM_WIN32( ERROR_HANDLE_EOF ); } + D3D11_SHADER_RESOURCE_VIEW_DESC desc; + (*textureView)->GetDesc( &desc ); + + UINT mipLevels = 1; + + switch( desc.ViewDimension ) + { + case D3D_SRV_DIMENSION_TEXTURE1D: mipLevels = desc.Texture1D.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE1DARRAY: mipLevels = desc.Texture1DArray.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE2D: mipLevels = desc.Texture2D.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE2DARRAY: mipLevels = desc.Texture2DArray.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURECUBE: mipLevels = desc.TextureCube.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURECUBEARRAY:mipLevels = desc.TextureCubeArray.MipLevels; break; + case D3D_SRV_DIMENSION_TEXTURE3D: mipLevels = desc.Texture3D.MipLevels; break; + default: + (*textureView)->Release(); + *textureView = nullptr; + tex->Release(); + return E_UNEXPECTED; + } + if ( arraySize > 1 ) { - D3D11_SHADER_RESOURCE_VIEW_DESC desc; - (*textureView)->GetDesc( &desc ); - - UINT mipLevels = 1; - - switch( desc.ViewDimension ) - { - case D3D_SRV_DIMENSION_TEXTURE1D: mipLevels = desc.Texture1D.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURE1DARRAY: mipLevels = desc.Texture1DArray.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURE2D: mipLevels = desc.Texture2D.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURE2DARRAY: mipLevels = desc.Texture2DArray.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURECUBE: mipLevels = desc.TextureCube.MipLevels; break; - case D3D_SRV_DIMENSION_TEXTURECUBEARRAY:mipLevels = desc.TextureCubeArray.MipLevels; break; - default: - (*textureView)->Release(); - *textureView = nullptr; - tex->Release(); - return E_UNEXPECTED; - } - const uint8_t* pSrcBits = bitData; const uint8_t* pEndBits = bitData + bitSize; for( UINT item = 0; item < arraySize; ++item ) diff --git a/DDSTextureLoader/DDSTextureLoader.h b/DDSTextureLoader/DDSTextureLoader.h index bf9548b..3a7e21c 100644 --- a/DDSTextureLoader/DDSTextureLoader.h +++ b/DDSTextureLoader/DDSTextureLoader.h @@ -22,13 +22,7 @@ #pragma once #endif -#if defined(_XBOX_ONE) && defined(_TITLE) -#include -#define DCOMMON_H_INCLUDED -#define NO_D3D11_DEBUG_NAME -#else #include -#endif #pragma warning(push) #pragma warning(disable : 4005) diff --git a/ScreenGrab/ScreenGrab.cpp b/ScreenGrab/ScreenGrab.cpp index d33808d..685e2ff 100644 --- a/ScreenGrab/ScreenGrab.cpp +++ b/ScreenGrab/ScreenGrab.cpp @@ -340,19 +340,6 @@ static size_t BitsPerPixel( _In_ DXGI_FORMAT fmt ) case DXGI_FORMAT_BC7_UNORM_SRGB: return 8; -#if defined(_XBOX_ONE) && defined(_TITLE) - - case DXGI_FORMAT_R10G10B10_7E3_A2_FLOAT: - case DXGI_FORMAT_R10G10B10_6E4_A2_FLOAT: - return 32; - - case DXGI_FORMAT_D16_UNORM_S8_UINT: - case DXGI_FORMAT_R16_UNORM_X8_TYPELESS: - case DXGI_FORMAT_X16_TYPELESS_G8_UINT: - return 24; - -#endif // _XBOX_ONE && _TITLE - default: return 0; } diff --git a/ScreenGrab/ScreenGrab.h b/ScreenGrab/ScreenGrab.h index c228dd4..36b6bab 100644 --- a/ScreenGrab/ScreenGrab.h +++ b/ScreenGrab/ScreenGrab.h @@ -23,13 +23,7 @@ #pragma once #endif -#if defined(_XBOX_ONE) && defined(_TITLE) -#include -#define DCOMMON_H_INCLUDED -#define NO_D3D11_DEBUG_NAME -#else #include -#endif #include diff --git a/WICTextureLoader/WICTextureLoader.h b/WICTextureLoader/WICTextureLoader.h index 4114926..7df46b2 100644 --- a/WICTextureLoader/WICTextureLoader.h +++ b/WICTextureLoader/WICTextureLoader.h @@ -33,13 +33,7 @@ #error WIC is not supported on Windows Phone 8.0 #endif -#if defined(_XBOX_ONE) && defined(_TITLE) -#include -#define DCOMMON_H_INCLUDED -#define NO_D3D11_DEBUG_NAME -#else #include -#endif #pragma warning(push) #pragma warning(disable : 4005)