Code review feedback

This commit is contained in:
walbourn_cp
2013-03-28 00:14:06 -07:00
parent 9c9364490c
commit 991b325f10
8 changed files with 35 additions and 25 deletions

View File

@@ -1,7 +1,7 @@
//--------------------------------------------------------------------------------------
// File: DDSTextureLoader.cpp
//
// Function for loading a DDS texture and creating a Direct3D 11 runtime resource for it
// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it
//
// Note these functions are useful as a light-weight runtime loader for DDS files. For
// a full-featured DDS file reader, writer, and texture processing pipeline see
@@ -215,7 +215,7 @@ static HRESULT LoadTextureDataFromFile( _In_z_ const wchar_t* fileName,
// create enough space for the file data
ddsData.reset( new (std::nothrow) uint8_t[ FileSize.LowPart ] );
if (!ddsData )
if (!ddsData)
{
return E_OUTOFMEMORY;
}
@@ -720,7 +720,6 @@ static DXGI_FORMAT GetDXGIFormat( const DDS_PIXELFORMAT& ddpf )
}
//--------------------------------------------------------------------------------------
static DXGI_FORMAT MakeSRGB( _In_ DXGI_FORMAT format )
{
@@ -865,8 +864,8 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice,
_In_ bool forceSRGB,
_In_ bool isCubeMap,
_In_reads_(mipCount*arraySize) D3D11_SUBRESOURCE_DATA* initData,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView )
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView )
{
if ( !d3dDevice || !initData )
return E_POINTER;
@@ -955,9 +954,13 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice,
desc.BindFlags = bindFlags;
desc.CPUAccessFlags = cpuAccessFlags;
if ( isCubeMap )
{
desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE;
}
else
{
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
}
ID3D11Texture2D* tex = nullptr;
hr = d3dDevice->CreateTexture2D( &desc,
@@ -972,7 +975,7 @@ static HRESULT CreateD3DResources( _In_ ID3D11Device* d3dDevice,
memset( &SRVDesc, 0, sizeof( SRVDesc ) );
SRVDesc.Format = format;
if (isCubeMap)
if ( isCubeMap )
{
if (arraySize > 6)
{
@@ -1093,8 +1096,8 @@ static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice,
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
_In_ bool forceSRGB,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView )
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView )
{
HRESULT hr = S_OK;
@@ -1222,7 +1225,7 @@ static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice,
break;
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
if (isCubeMap)
if ( isCubeMap )
{
// This is the right bound because we set arraySize to (NumCubes*6) above
if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) ||
@@ -1278,7 +1281,7 @@ static HRESULT CreateTextureFromDDS( _In_ ID3D11Device* d3dDevice,
{
case D3D_FEATURE_LEVEL_9_1:
case D3D_FEATURE_LEVEL_9_2:
if (isCubeMap)
if ( isCubeMap )
{
maxsize = 512 /*D3D_FL9_1_REQ_TEXTURECUBE_DIMENSION*/;
}

View File

@@ -1,7 +1,7 @@
//--------------------------------------------------------------------------------------
// File: DDSTextureLoader.h
//
// Function for loading a DDS texture and creating a Direct3D 11 runtime resource for it
// Functions for loading a DDS texture and creating a Direct3D 11 runtime resource for it
//
// Note these functions are useful as a light-weight runtime loader for DDS files. For
// a full-featured DDS file reader, writer, and texture processing pipeline see
@@ -33,6 +33,7 @@
#define _In_reads_(exp)
#define _Out_writes_(exp)
#define _In_reads_bytes_(exp)
#define _Outptr_opt_
#endif
#ifndef _Use_decl_annotations_
@@ -52,16 +53,16 @@ namespace DirectX
HRESULT CreateDDSTextureFromMemory( _In_ ID3D11Device* d3dDevice,
_In_reads_bytes_(ddsDataSize) const uint8_t* ddsData,
_In_ size_t ddsDataSize,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize = 0,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
);
HRESULT CreateDDSTextureFromFile( _In_ ID3D11Device* d3dDevice,
_In_z_ const wchar_t* szFileName,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_In_ size_t maxsize = 0,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
);
@@ -75,8 +76,8 @@ namespace DirectX
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
_In_ bool forceSRGB,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
);
@@ -88,8 +89,8 @@ namespace DirectX
_In_ unsigned int cpuAccessFlags,
_In_ unsigned int miscFlags,
_In_ bool forceSRGB,
_Out_opt_ ID3D11Resource** texture,
_Out_opt_ ID3D11ShaderResourceView** textureView,
_Outptr_opt_ ID3D11Resource** texture,
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
_Out_opt_ DDS_ALPHA_MODE* alphaMode = nullptr
);
}