mirror of
https://github.com/microsoft/DirectXTex.git
synced 2026-02-04 04:16:12 +01:00
Resync DDSTextureLoader, WICTextureLoader
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: WICTextureLoader.h
|
||||
//
|
||||
// Function for loading a WIC image and creating a Direct3D 11 runtime texture for it
|
||||
// Function for loading a WIC image and creating a Direct3D runtime texture for it
|
||||
// (auto-generating mipmaps if possible)
|
||||
//
|
||||
// Note: Assumes application has already called CoInitializeEx
|
||||
@@ -33,23 +33,28 @@
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
enum WIC_LOADER_FLAGS
|
||||
{
|
||||
WIC_LOADER_DEFAULT = 0,
|
||||
WIC_LOADER_FORCE_SRGB = 0x1,
|
||||
WIC_LOADER_IGNORE_SRGB = 0x2,
|
||||
};
|
||||
|
||||
// Standard version
|
||||
HRESULT CreateWICTextureFromMemory(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
HRESULT CreateWICTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
// Standard version with optional auto-gen mipmap support
|
||||
HRESULT CreateWICTextureFromMemory(
|
||||
@@ -57,19 +62,17 @@ namespace DirectX
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
HRESULT CreateWICTextureFromFile(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
_In_opt_ ID3D11DeviceContext* d3dContext,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0
|
||||
);
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView,
|
||||
_In_ size_t maxsize = 0);
|
||||
|
||||
// Extended version
|
||||
HRESULT CreateWICTextureFromMemoryEx(
|
||||
@@ -77,14 +80,13 @@ namespace DirectX
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
_In_ size_t wicDataSize,
|
||||
_In_ size_t maxsize,
|
||||
D3D11_USAGE usage,
|
||||
_In_ D3D11_USAGE usage,
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
|
||||
HRESULT CreateWICTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
@@ -94,10 +96,9 @@ namespace DirectX
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
|
||||
// Extended version with optional auto-gen mipmap support
|
||||
HRESULT CreateWICTextureFromMemoryEx(
|
||||
@@ -110,10 +111,9 @@ namespace DirectX
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
|
||||
HRESULT CreateWICTextureFromFileEx(
|
||||
_In_ ID3D11Device* d3dDevice,
|
||||
@@ -124,8 +124,7 @@ namespace DirectX
|
||||
_In_ unsigned int bindFlags,
|
||||
_In_ unsigned int cpuAccessFlags,
|
||||
_In_ unsigned int miscFlags,
|
||||
_In_ bool forceSRGB,
|
||||
_Out_opt_ ID3D11Resource** texture,
|
||||
_Out_opt_ ID3D11ShaderResourceView** textureView
|
||||
);
|
||||
_In_ unsigned int loadFlags,
|
||||
_Outptr_opt_ ID3D11Resource** texture,
|
||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||
}
|
||||
@@ -269,9 +269,8 @@ namespace
|
||||
HRESULT CreateTextureFromWIC(_In_ ID3D12Device* d3dDevice,
|
||||
_In_ IWICBitmapFrameDecode *frame,
|
||||
size_t maxsize,
|
||||
D3D12_RESOURCE_FLAGS flags,
|
||||
bool forceSRGB,
|
||||
bool reserveFullMipChain,
|
||||
D3D12_RESOURCE_FLAGS resFlags,
|
||||
unsigned int loadFlags,
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource)
|
||||
@@ -351,11 +350,11 @@ namespace
|
||||
return E_FAIL;
|
||||
|
||||
// Handle sRGB formats
|
||||
if (forceSRGB)
|
||||
if (loadFlags & WIC_LOADER_FORCE_SRGB)
|
||||
{
|
||||
format = MakeSRGB(format);
|
||||
}
|
||||
else
|
||||
else if (!(loadFlags & WIC_LOADER_IGNORE_SRGB))
|
||||
{
|
||||
ComPtr<IWICMetadataQueryReader> metareader;
|
||||
if (SUCCEEDED(frame->GetMetadataQueryReader(metareader.GetAddressOf())))
|
||||
@@ -488,7 +487,7 @@ namespace
|
||||
}
|
||||
|
||||
// Count the number of mips
|
||||
uint32_t mipCount = (reserveFullMipChain) ? CountMips(twidth, theight) : 1;
|
||||
uint32_t mipCount = (loadFlags & (WIC_LOADER_MIP_AUTOGEN | WIC_LOADER_MIP_RESERVE)) ? CountMips(twidth, theight) : 1;
|
||||
|
||||
// Create texture
|
||||
D3D12_RESOURCE_DESC desc = {};
|
||||
@@ -499,7 +498,7 @@ namespace
|
||||
desc.Format = format;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.SampleDesc.Quality = 0;
|
||||
desc.Flags = flags;
|
||||
desc.Flags = resFlags;
|
||||
desc.Dimension = D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
|
||||
CD3DX12_HEAP_PROPERTIES defaultHeapProperties(D3D12_HEAP_TYPE_DEFAULT);
|
||||
@@ -547,8 +546,7 @@ HRESULT DirectX::LoadWICTextureFromMemory(
|
||||
wicDataSize,
|
||||
maxsize,
|
||||
D3D12_RESOURCE_FLAG_NONE,
|
||||
false,
|
||||
false,
|
||||
WIC_LOADER_DEFAULT,
|
||||
texture,
|
||||
decodedData,
|
||||
subresource);
|
||||
@@ -562,9 +560,8 @@ HRESULT DirectX::LoadWICTextureFromMemoryEx(
|
||||
const uint8_t* wicData,
|
||||
size_t wicDataSize,
|
||||
size_t maxsize,
|
||||
D3D12_RESOURCE_FLAGS flags,
|
||||
bool forceSRGB,
|
||||
bool reserveFullMipChain,
|
||||
D3D12_RESOURCE_FLAGS resFlags,
|
||||
unsigned int loadFlags,
|
||||
ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource)
|
||||
@@ -610,7 +607,7 @@ HRESULT DirectX::LoadWICTextureFromMemoryEx(
|
||||
|
||||
hr = CreateTextureFromWIC( d3dDevice,
|
||||
frame.Get(), maxsize,
|
||||
flags, forceSRGB, reserveFullMipChain,
|
||||
resFlags, loadFlags,
|
||||
texture, decodedData, subresource);
|
||||
if ( FAILED(hr))
|
||||
return hr;
|
||||
@@ -637,8 +634,7 @@ HRESULT DirectX::LoadWICTextureFromFile(
|
||||
fileName,
|
||||
maxsize,
|
||||
D3D12_RESOURCE_FLAG_NONE,
|
||||
false,
|
||||
false,
|
||||
WIC_LOADER_DEFAULT,
|
||||
texture,
|
||||
wicData,
|
||||
subresource);
|
||||
@@ -651,9 +647,8 @@ HRESULT DirectX::LoadWICTextureFromFileEx(
|
||||
ID3D12Device* d3dDevice,
|
||||
const wchar_t* fileName,
|
||||
size_t maxsize,
|
||||
D3D12_RESOURCE_FLAGS flags,
|
||||
bool forceSRGB,
|
||||
bool reserveFullMipChain,
|
||||
D3D12_RESOURCE_FLAGS resFlags,
|
||||
unsigned int loadFlags,
|
||||
ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource)
|
||||
@@ -682,7 +677,7 @@ HRESULT DirectX::LoadWICTextureFromFileEx(
|
||||
return hr;
|
||||
|
||||
hr = CreateTextureFromWIC( d3dDevice, frame.Get(), maxsize,
|
||||
flags, forceSRGB, reserveFullMipChain,
|
||||
resFlags, loadFlags,
|
||||
texture, decodedData, subresource );
|
||||
|
||||
#if !defined(NO_D3D12_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//--------------------------------------------------------------------------------------
|
||||
// File: WICTextureLoader12.h
|
||||
//
|
||||
// Function for loading a WIC image and creating a Direct3D 12 runtime texture for it
|
||||
// Function for loading a WIC image and creating a Direct3D runtime texture for it
|
||||
// (auto-generating mipmaps if possible)
|
||||
//
|
||||
// Note: Assumes application has already called CoInitializeEx
|
||||
@@ -31,6 +31,15 @@
|
||||
|
||||
namespace DirectX
|
||||
{
|
||||
enum WIC_LOADER_FLAGS
|
||||
{
|
||||
WIC_LOADER_DEFAULT = 0,
|
||||
WIC_LOADER_FORCE_SRGB = 0x1,
|
||||
WIC_LOADER_IGNORE_SRGB = 0x2,
|
||||
WIC_LOADER_MIP_AUTOGEN = 0x4,
|
||||
WIC_LOADER_MIP_RESERVE = 0x8,
|
||||
};
|
||||
|
||||
// Standard version
|
||||
HRESULT __cdecl LoadWICTextureFromMemory(
|
||||
_In_ ID3D12Device* d3dDevice,
|
||||
@@ -55,9 +64,8 @@ namespace DirectX
|
||||
_In_reads_bytes_(wicDataSize) const uint8_t* wicData,
|
||||
size_t wicDataSize,
|
||||
size_t maxsize,
|
||||
D3D12_RESOURCE_FLAGS flags,
|
||||
bool forceSRGB,
|
||||
bool reserveFullMipChain,
|
||||
D3D12_RESOURCE_FLAGS resFlags,
|
||||
unsigned int loadFlags,
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource);
|
||||
@@ -66,9 +74,8 @@ namespace DirectX
|
||||
_In_ ID3D12Device* d3dDevice,
|
||||
_In_z_ const wchar_t* szFileName,
|
||||
size_t maxsize,
|
||||
D3D12_RESOURCE_FLAGS flags,
|
||||
bool forceSRGB,
|
||||
bool reserveFullMipChain,
|
||||
D3D12_RESOURCE_FLAGS resFlags,
|
||||
unsigned int loadFlags,
|
||||
_Outptr_ ID3D12Resource** texture,
|
||||
std::unique_ptr<uint8_t[]>& decodedData,
|
||||
D3D12_SUBRESOURCE_DATA& subresource);
|
||||
|
||||
Reference in New Issue
Block a user