mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-04 04:16:12 +01:00
Code review feedback for standalone texture loaders
This commit is contained in:
@@ -48,7 +48,7 @@ namespace
|
||||
{
|
||||
//--------------------------------------------------------------------------------------
|
||||
template<UINT TNameLength>
|
||||
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength])
|
||||
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept
|
||||
{
|
||||
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
|
||||
@@ -203,12 +203,13 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
IWICImagingFactory* _GetWIC()
|
||||
IWICImagingFactory* _GetWIC() noexcept
|
||||
{
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
IWICImagingFactory* factory = nullptr;
|
||||
if (!InitOnceExecuteOnce(&s_initOnce,
|
||||
if (!InitOnceExecuteOnce(
|
||||
&s_initOnce,
|
||||
InitializeWICFactory,
|
||||
nullptr,
|
||||
reinterpret_cast<LPVOID*>(&factory)))
|
||||
@@ -220,7 +221,7 @@ namespace
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
DXGI_FORMAT _WICToDXGI(const GUID& guid)
|
||||
DXGI_FORMAT _WICToDXGI(const GUID& guid) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
{
|
||||
@@ -240,7 +241,7 @@ namespace
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
size_t _WICBitsPerPixel(REFGUID targetGuid)
|
||||
size_t _WICBitsPerPixel(REFGUID targetGuid) noexcept
|
||||
{
|
||||
auto pWIC = _GetWIC();
|
||||
if (!pWIC)
|
||||
@@ -270,7 +271,7 @@ namespace
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format)
|
||||
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
@@ -312,7 +313,7 @@ namespace
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView)
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept
|
||||
{
|
||||
UINT width, height;
|
||||
HRESULT hr = frame->GetSize(&width, &height);
|
||||
@@ -334,20 +335,20 @@ namespace
|
||||
{
|
||||
case D3D_FEATURE_LEVEL_9_1:
|
||||
case D3D_FEATURE_LEVEL_9_2:
|
||||
maxsize = 2048 /*D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION*/;
|
||||
maxsize = 2048u /*D3D_FL9_1_REQ_TEXTURE2D_U_OR_V_DIMENSION*/;
|
||||
break;
|
||||
|
||||
case D3D_FEATURE_LEVEL_9_3:
|
||||
maxsize = 4096 /*D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION*/;
|
||||
maxsize = 4096u /*D3D_FL9_3_REQ_TEXTURE2D_U_OR_V_DIMENSION*/;
|
||||
break;
|
||||
|
||||
case D3D_FEATURE_LEVEL_10_0:
|
||||
case D3D_FEATURE_LEVEL_10_1:
|
||||
maxsize = 8192 /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/;
|
||||
maxsize = 8192u /*D3D10_REQ_TEXTURE2D_U_OR_V_DIMENSION*/;
|
||||
break;
|
||||
|
||||
default:
|
||||
maxsize = D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION;
|
||||
maxsize = size_t(D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -618,10 +619,10 @@ namespace
|
||||
}
|
||||
|
||||
// Create texture
|
||||
D3D11_TEXTURE2D_DESC desc;
|
||||
D3D11_TEXTURE2D_DESC desc = {};
|
||||
desc.Width = twidth;
|
||||
desc.Height = theight;
|
||||
desc.MipLevels = (autogen) ? 0 : 1;
|
||||
desc.MipLevels = (autogen) ? 0u : 1u;
|
||||
desc.ArraySize = 1;
|
||||
desc.Format = format;
|
||||
desc.SampleDesc.Count = 1;
|
||||
@@ -655,7 +656,7 @@ namespace
|
||||
SRVDesc.Format = desc.Format;
|
||||
|
||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||
SRVDesc.Texture2D.MipLevels = (autogen) ? UINT(-1) : 1;
|
||||
SRVDesc.Texture2D.MipLevels = (autogen) ? unsigned(-1) : 1u;
|
||||
|
||||
hr = d3dDevice->CreateShaderResourceView(tex, &SRVDesc, textureView);
|
||||
if (FAILED(hr))
|
||||
@@ -691,7 +692,7 @@ namespace
|
||||
void SetDebugTextureInfo(
|
||||
_In_z_ const wchar_t* fileName,
|
||||
_In_opt_ ID3D11Resource** texture,
|
||||
_In_opt_ ID3D11ShaderResourceView** textureView)
|
||||
_In_opt_ ID3D11ShaderResourceView** textureView) noexcept
|
||||
{
|
||||
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||
if (texture || textureView)
|
||||
@@ -751,7 +752,7 @@ HRESULT DirectX::CreateWICTextureFromMemory(
|
||||
size_t wicDataSize,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView,
|
||||
size_t maxsize)
|
||||
size_t maxsize) noexcept
|
||||
{
|
||||
return CreateWICTextureFromMemoryEx(d3dDevice, nullptr,
|
||||
wicData, wicDataSize,
|
||||
@@ -769,7 +770,7 @@ HRESULT DirectX::CreateWICTextureFromMemory(
|
||||
size_t wicDataSize,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView,
|
||||
size_t maxsize)
|
||||
size_t maxsize) noexcept
|
||||
{
|
||||
return CreateWICTextureFromMemoryEx(d3dDevice, d3dContext,
|
||||
wicData, wicDataSize,
|
||||
@@ -791,7 +792,7 @@ HRESULT DirectX::CreateWICTextureFromMemoryEx(
|
||||
unsigned int miscFlags,
|
||||
unsigned int loadFlags,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView)
|
||||
ID3D11ShaderResourceView** textureView) noexcept
|
||||
{
|
||||
return CreateWICTextureFromMemoryEx(d3dDevice, nullptr,
|
||||
wicData, wicDataSize,
|
||||
@@ -814,7 +815,7 @@ HRESULT DirectX::CreateWICTextureFromMemoryEx(
|
||||
unsigned int miscFlags,
|
||||
unsigned int loadFlags,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView)
|
||||
ID3D11ShaderResourceView** textureView) noexcept
|
||||
{
|
||||
if (texture)
|
||||
{
|
||||
@@ -895,7 +896,7 @@ HRESULT DirectX::CreateWICTextureFromFile(
|
||||
const wchar_t* fileName,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView,
|
||||
size_t maxsize)
|
||||
size_t maxsize) noexcept
|
||||
{
|
||||
return CreateWICTextureFromFileEx(d3dDevice, nullptr,
|
||||
fileName, maxsize,
|
||||
@@ -911,7 +912,7 @@ HRESULT DirectX::CreateWICTextureFromFile(
|
||||
const wchar_t* fileName,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView,
|
||||
size_t maxsize)
|
||||
size_t maxsize) noexcept
|
||||
{
|
||||
return CreateWICTextureFromFileEx(d3dDevice, d3dContext,
|
||||
fileName,
|
||||
@@ -932,7 +933,7 @@ HRESULT DirectX::CreateWICTextureFromFileEx(
|
||||
unsigned int miscFlags,
|
||||
unsigned int loadFlags,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView)
|
||||
ID3D11ShaderResourceView** textureView) noexcept
|
||||
{
|
||||
return CreateWICTextureFromFileEx(d3dDevice, nullptr,
|
||||
fileName,
|
||||
@@ -954,7 +955,7 @@ HRESULT DirectX::CreateWICTextureFromFileEx(
|
||||
unsigned int miscFlags,
|
||||
unsigned int loadFlags,
|
||||
ID3D11Resource** texture,
|
||||
ID3D11ShaderResourceView** textureView)
|
||||
ID3D11ShaderResourceView** textureView) noexcept
|
||||
{
|
||||
if (texture)
|
||||
{
|
||||
|
||||
@@ -24,14 +24,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d11_1.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
#ifndef WIC_LOADER_FLAGS_DEFINED
|
||||
#define WIC_LOADER_FLAGS_DEFINED
|
||||
enum WIC_LOADER_FLAGS
|
||||
enum WIC_LOADER_FLAGS : uint32_t
|
||||
{
|
||||
WIC_LOADER_DEFAULT = 0,
|
||||
WIC_LOADER_FORCE_SRGB = 0x1,
|
||||
@@ -46,14 +46,14 @@ namespace DirectX
|
||||
_In_ size_t wicDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
_In_ size_t maxsize = 0) noexcept;
|
||||
|
||||
HRESULT CreateWICTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
_In_ size_t maxsize = 0) noexcept;
|
||||
|
||||
// Standard version with optional auto-gen mipmap support
|
||||
HRESULT CreateWICTextureFromMemory(
|
||||
@@ -63,7 +63,7 @@ namespace DirectX
|
||||
_In_ size_t wicDataSize,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
_In_ size_t maxsize = 0) noexcept;
|
||||
|
||||
HRESULT CreateWICTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
@@ -71,7 +71,7 @@ namespace DirectX
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
_In_ size_t maxsize = 0) noexcept;
|
||||
|
||||
// Extended version
|
||||
HRESULT CreateWICTextureFromMemoryEx(
|
||||
@@ -85,7 +85,7 @@ namespace DirectX
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
||||
|
||||
HRESULT CreateWICTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
@@ -97,7 +97,7 @@ namespace DirectX
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
||||
|
||||
// Extended version with optional auto-gen mipmap support
|
||||
HRESULT CreateWICTextureFromMemoryEx(
|
||||
@@ -112,7 +112,7 @@ namespace DirectX
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
||||
|
||||
HRESULT CreateWICTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
@@ -125,6 +125,5 @@ namespace DirectX
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView) noexcept;
|
||||
}
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ namespace
|
||||
ifactory)) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
IWICImagingFactory2* _GetWIC()
|
||||
IWICImagingFactory2* _GetWIC() noexcept
|
||||
{
|
||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
template<UINT TNameLength>
|
||||
inline void SetDebugObjectName(_In_ ID3D12DeviceChild* resource, _In_z_ const wchar_t(&name)[TNameLength])
|
||||
inline void SetDebugObjectName(_In_ ID3D12DeviceChild* resource, _In_z_ const wchar_t(&name)[TNameLength]) noexcept
|
||||
{
|
||||
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||
resource->SetName(name);
|
||||
@@ -189,7 +189,7 @@ namespace
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint32_t CountMips(uint32_t width, uint32_t height)
|
||||
inline uint32_t CountMips(uint32_t width, uint32_t height) noexcept
|
||||
{
|
||||
if (width == 0 || height == 0)
|
||||
return 0;
|
||||
@@ -205,7 +205,7 @@ namespace
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------
|
||||
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format)
|
||||
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept
|
||||
{
|
||||
switch (format)
|
||||
{
|
||||
@@ -236,7 +236,7 @@ namespace
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
DXGI_FORMAT _WICToDXGI(const GUID& guid)
|
||||
DXGI_FORMAT _WICToDXGI(const GUID& guid) noexcept
|
||||
{
|
||||
for (size_t i = 0; i < _countof(g_WICFormats); ++i)
|
||||
{
|
||||
@@ -248,7 +248,7 @@ namespace
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------
|
||||
size_t _WICBitsPerPixel(REFGUID targetGuid)
|
||||
size_t _WICBitsPerPixel(REFGUID targetGuid) noexcept
|
||||
{
|
||||
auto pWIC = _GetWIC();
|
||||
if (!pWIC)
|
||||
@@ -284,7 +284,7 @@ namespace
|
||||
unsigned int loadFlags,
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource)
|
||||
D3D12_SUBRESOURCE_DATA& subresource) noexcept
|
||||
{
|
||||
UINT width, height;
|
||||
HRESULT hr = frame->GetSize(&width, &height);
|
||||
@@ -549,7 +549,7 @@ namespace
|
||||
//--------------------------------------------------------------------------------------
|
||||
void SetDebugTextureInfo(
|
||||
_In_z_ const wchar_t* fileName,
|
||||
_In_ ID3D12Resource** texture)
|
||||
_In_ ID3D12Resource** texture) noexcept
|
||||
{
|
||||
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||
if (texture)
|
||||
@@ -586,7 +586,7 @@ HRESULT DirectX::LoadWICTextureFromMemory(
|
||||
ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource,
|
||||
size_t maxsize)
|
||||
size_t maxsize) noexcept
|
||||
{
|
||||
return LoadWICTextureFromMemoryEx(
|
||||
d3dDevice,
|
||||
@@ -612,7 +612,7 @@ HRESULT DirectX::LoadWICTextureFromMemoryEx(
|
||||
unsigned int loadFlags,
|
||||
ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource)
|
||||
D3D12_SUBRESOURCE_DATA& subresource) noexcept
|
||||
{
|
||||
if (texture)
|
||||
{
|
||||
@@ -675,7 +675,7 @@ HRESULT DirectX::LoadWICTextureFromFile(
|
||||
ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& wicData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource,
|
||||
size_t maxsize)
|
||||
size_t maxsize) noexcept
|
||||
{
|
||||
return LoadWICTextureFromFileEx(
|
||||
d3dDevice,
|
||||
@@ -699,7 +699,7 @@ HRESULT DirectX::LoadWICTextureFromFileEx(
|
||||
unsigned int loadFlags,
|
||||
ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource)
|
||||
D3D12_SUBRESOURCE_DATA& subresource) noexcept
|
||||
{
|
||||
if (texture)
|
||||
{
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <d3d12.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <cstdint>
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -29,7 +30,7 @@ namespace DirectX
|
||||
{
|
||||
#ifndef WIC_LOADER_FLAGS_DEFINED
|
||||
#define WIC_LOADER_FLAGS_DEFINED
|
||||
enum WIC_LOADER_FLAGS
|
||||
enum WIC_LOADER_FLAGS : uint32_t
|
||||
{
|
||||
WIC_LOADER_DEFAULT = 0,
|
||||
WIC_LOADER_FORCE_SRGB = 0x1,
|
||||
@@ -47,7 +48,7 @@ namespace DirectX
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource,
|
||||
size_t maxsize = 0);
|
||||
size_t maxsize = 0) noexcept;
|
||||
|
||||
HRESULT __cdecl LoadWICTextureFromFile(
|
||||
_In_ ID3D12Device* d3dDevice,
|
||||
@@ -55,7 +56,7 @@ namespace DirectX
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource,
|
||||
size_t maxsize = 0);
|
||||
size_t maxsize = 0) noexcept;
|
||||
|
||||
// Extended version
|
||||
HRESULT __cdecl LoadWICTextureFromMemoryEx(
|
||||
@@ -67,7 +68,7 @@ namespace DirectX
|
||||
unsigned int loadFlags,
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource);
|
||||
D3D12_SUBRESOURCE_DATA& subresource) noexcept;
|
||||
|
||||
HRESULT __cdecl LoadWICTextureFromFileEx(
|
||||
_In_ ID3D12Device* d3dDevice,
|
||||
@@ -77,5 +78,5 @@ namespace DirectX
|
||||
unsigned int loadFlags,
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource);
|
||||
D3D12_SUBRESOURCE_DATA& subresource) noexcept;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user