Code review feedback
This commit is contained in:
parent
685a69ad1b
commit
b47a7d13d9
@ -26,6 +26,10 @@
|
||||
using namespace DirectX;
|
||||
using Microsoft::WRL::ComPtr;
|
||||
|
||||
static_assert(TEX_DIMENSION_TEXTURE1D == D3D11_RESOURCE_DIMENSION_TEXTURE1D, "header enum mismatch");
|
||||
static_assert(TEX_DIMENSION_TEXTURE2D == D3D11_RESOURCE_DIMENSION_TEXTURE2D, "header enum mismatch");
|
||||
static_assert(TEX_DIMENSION_TEXTURE3D == D3D11_RESOURCE_DIMENSION_TEXTURE3D, "header enum mismatch");
|
||||
|
||||
namespace
|
||||
{
|
||||
HRESULT Capture(
|
||||
@ -425,7 +429,7 @@ HRESULT DirectX::CreateTextureEx(
|
||||
return E_INVALIDARG;
|
||||
|
||||
if ((metadata.width > UINT32_MAX) || (metadata.height > UINT32_MAX)
|
||||
|| (metadata.mipLevels > UINT32_MAX) || (metadata.arraySize > UINT32_MAX))
|
||||
|| (metadata.mipLevels > UINT16_MAX) || (metadata.arraySize > UINT16_MAX))
|
||||
return E_INVALIDARG;
|
||||
|
||||
std::unique_ptr<D3D11_SUBRESOURCE_DATA[]> initData(new (std::nothrow) D3D11_SUBRESOURCE_DATA[metadata.mipLevels * metadata.arraySize]);
|
||||
@ -439,7 +443,7 @@ HRESULT DirectX::CreateTextureEx(
|
||||
if (!metadata.depth)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (metadata.depth > UINT32_MAX)
|
||||
if (metadata.depth > UINT16_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (metadata.arraySize > 1)
|
||||
@ -537,7 +541,7 @@ HRESULT DirectX::CreateTextureEx(
|
||||
{
|
||||
case TEX_DIMENSION_TEXTURE1D:
|
||||
{
|
||||
D3D11_TEXTURE1D_DESC desc;
|
||||
D3D11_TEXTURE1D_DESC desc = {};
|
||||
desc.Width = static_cast<UINT>(metadata.width);
|
||||
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
|
||||
desc.ArraySize = static_cast<UINT>(metadata.arraySize);
|
||||
@ -553,7 +557,7 @@ HRESULT DirectX::CreateTextureEx(
|
||||
|
||||
case TEX_DIMENSION_TEXTURE2D:
|
||||
{
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
D3D11_TEXTURE2D_DESC desc = {};
|
||||
desc.Width = static_cast<UINT>(metadata.width);
|
||||
desc.Height = static_cast<UINT>(metadata.height);
|
||||
desc.MipLevels = static_cast<UINT>(metadata.mipLevels);
|
||||
@ -575,7 +579,7 @@ HRESULT DirectX::CreateTextureEx(
|
||||
|
||||
case TEX_DIMENSION_TEXTURE3D:
|
||||
{
|
||||
D3D11_TEXTURE3D_DESC desc;
|
||||
D3D11_TEXTURE3D_DESC desc = {};
|
||||
desc.Width = static_cast<UINT>(metadata.width);
|
||||
desc.Height = static_cast<UINT>(metadata.height);
|
||||
desc.Depth = static_cast<UINT>(metadata.depth);
|
||||
@ -711,7 +715,7 @@ HRESULT DirectX::CreateShaderResourceViewEx(
|
||||
|
||||
|
||||
//-------------------------------------------------------------------------------------
|
||||
// Save a texture resource to a DDS file in memory/on disk
|
||||
// Save a texture resource
|
||||
//-------------------------------------------------------------------------------------
|
||||
_Use_decl_annotations_
|
||||
HRESULT DirectX::CaptureTexture(
|
||||
|
@ -19,6 +19,10 @@
|
||||
|
||||
using namespace DirectX;
|
||||
|
||||
static_assert(TEX_DIMENSION_TEXTURE1D == DDS_DIMENSION_TEXTURE1D, "header enum mismatch");
|
||||
static_assert(TEX_DIMENSION_TEXTURE2D == DDS_DIMENSION_TEXTURE2D, "header enum mismatch");
|
||||
static_assert(TEX_DIMENSION_TEXTURE3D == DDS_DIMENSION_TEXTURE3D, "header enum mismatch");
|
||||
|
||||
namespace
|
||||
{
|
||||
//-------------------------------------------------------------------------------------
|
||||
@ -607,7 +611,7 @@ HRESULT DirectX::_EncodeDDSHeader(
|
||||
{
|
||||
header->dwFlags |= DDS_HEADER_FLAGS_MIPMAP;
|
||||
|
||||
if (metadata.mipLevels > UINT32_MAX)
|
||||
if (metadata.mipLevels > UINT16_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
header->dwMipMapCount = static_cast<uint32_t>(metadata.mipLevels);
|
||||
@ -645,7 +649,7 @@ HRESULT DirectX::_EncodeDDSHeader(
|
||||
case TEX_DIMENSION_TEXTURE3D:
|
||||
if (metadata.height > UINT32_MAX
|
||||
|| metadata.width > UINT32_MAX
|
||||
|| metadata.depth > UINT32_MAX)
|
||||
|| metadata.depth > UINT16_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
header->dwFlags |= DDS_HEADER_FLAGS_VOLUME;
|
||||
@ -688,7 +692,7 @@ HRESULT DirectX::_EncodeDDSHeader(
|
||||
ext->dxgiFormat = metadata.format;
|
||||
ext->resourceDimension = metadata.dimension;
|
||||
|
||||
if (metadata.arraySize > UINT32_MAX)
|
||||
if (metadata.arraySize > UINT16_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
static_assert(TEX_MISC_TEXTURECUBE == DDS_RESOURCE_MISC_TEXTURECUBE, "DDS header mismatch");
|
||||
|
@ -517,7 +517,7 @@ HRESULT DirectX::EvaluateImage(
|
||||
|| metadata.height > UINT32_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (metadata.IsVolumemap() && metadata.depth > UINT32_MAX)
|
||||
if (metadata.IsVolumemap() && metadata.depth > UINT16_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
ScratchImage temp;
|
||||
@ -645,7 +645,7 @@ HRESULT DirectX::TransformImage(
|
||||
|| metadata.height > UINT32_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
if (metadata.IsVolumemap() && metadata.depth > UINT32_MAX)
|
||||
if (metadata.IsVolumemap() && metadata.depth > UINT16_MAX)
|
||||
return E_INVALIDARG;
|
||||
|
||||
HRESULT hr = result.Initialize(metadata);
|
||||
|
@ -37,6 +37,7 @@
|
||||
|
||||
#include <wrl\client.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <memory>
|
||||
|
||||
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||
|
Loading…
Reference in New Issue
Block a user