mirror of
https://github.com/microsoft/DirectXTex.git
synced 2025-07-09 11:40:14 +02:00
Cleaned up clang warnings in DDSTextureLoader, ScreenGrab, WICTextureLoader
This commit is contained in:
parent
5dcfb90b9e
commit
bc0325b806
@ -20,8 +20,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
#ifdef __clang__
|
||||||
#pragma comment(lib,"dxguid.lib")
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
@ -65,7 +66,6 @@ struct DDS_PIXELFORMAT
|
|||||||
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
||||||
|
|
||||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
||||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
|
||||||
|
|
||||||
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
||||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
||||||
@ -189,7 +189,7 @@ namespace
|
|||||||
|
|
||||||
// setup the pointers in the process request
|
// setup the pointers in the process request
|
||||||
*header = hdr;
|
*header = hdr;
|
||||||
ptrdiff_t offset = sizeof(uint32_t)
|
auto offset = sizeof(uint32_t)
|
||||||
+ sizeof(DDS_HEADER)
|
+ sizeof(DDS_HEADER)
|
||||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||||
*bitData = ddsData + offset;
|
*bitData = ddsData + offset;
|
||||||
@ -309,7 +309,7 @@ namespace
|
|||||||
|
|
||||||
// setup the pointers in the process request
|
// setup the pointers in the process request
|
||||||
*header = hdr;
|
*header = hdr;
|
||||||
ptrdiff_t offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
||||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||||
*bitData = ddsData.get() + offset;
|
*bitData = ddsData.get() + offset;
|
||||||
*bitSize = fileInfo.EndOfFile.LowPart - offset;
|
*bitSize = fileInfo.EndOfFile.LowPart - offset;
|
||||||
@ -950,7 +950,7 @@ namespace
|
|||||||
|
|
||||||
assert(index < mipCount * arraySize);
|
assert(index < mipCount * arraySize);
|
||||||
_Analysis_assume_(index < mipCount * arraySize);
|
_Analysis_assume_(index < mipCount * arraySize);
|
||||||
initData[index].pSysMem = (const void*)pSrcBits;
|
initData[index].pSysMem = pSrcBits;
|
||||||
initData[index].SysMemPitch = static_cast<UINT>(RowBytes);
|
initData[index].SysMemPitch = static_cast<UINT>(RowBytes);
|
||||||
initData[index].SysMemSlicePitch = static_cast<UINT>(NumBytes);
|
initData[index].SysMemSlicePitch = static_cast<UINT>(NumBytes);
|
||||||
++index;
|
++index;
|
||||||
@ -1032,7 +1032,7 @@ namespace
|
|||||||
desc.Usage = usage;
|
desc.Usage = usage;
|
||||||
desc.BindFlags = bindFlags;
|
desc.BindFlags = bindFlags;
|
||||||
desc.CPUAccessFlags = cpuAccessFlags;
|
desc.CPUAccessFlags = cpuAccessFlags;
|
||||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||||
|
|
||||||
ID3D11Texture1D* tex = nullptr;
|
ID3D11Texture1D* tex = nullptr;
|
||||||
hr = d3dDevice->CreateTexture1D(&desc,
|
hr = d3dDevice->CreateTexture1D(&desc,
|
||||||
@ -1049,13 +1049,13 @@ namespace
|
|||||||
if (arraySize > 1)
|
if (arraySize > 1)
|
||||||
{
|
{
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
|
||||||
SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||||
SRVDesc.Texture1DArray.ArraySize = static_cast<UINT>(arraySize);
|
SRVDesc.Texture1DArray.ArraySize = static_cast<UINT>(arraySize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
|
||||||
SRVDesc.Texture1D.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
SRVDesc.Texture1D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = d3dDevice->CreateShaderResourceView(tex,
|
hr = d3dDevice->CreateShaderResourceView(tex,
|
||||||
@ -1101,7 +1101,7 @@ namespace
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3D11Texture2D* tex = nullptr;
|
ID3D11Texture2D* tex = nullptr;
|
||||||
@ -1121,7 +1121,7 @@ namespace
|
|||||||
if (arraySize > 6)
|
if (arraySize > 6)
|
||||||
{
|
{
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
|
||||||
SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||||
|
|
||||||
// Earlier we set arraySize to (NumCubes * 6)
|
// Earlier we set arraySize to (NumCubes * 6)
|
||||||
SRVDesc.TextureCubeArray.NumCubes = static_cast<UINT>(arraySize / 6);
|
SRVDesc.TextureCubeArray.NumCubes = static_cast<UINT>(arraySize / 6);
|
||||||
@ -1129,19 +1129,19 @@ namespace
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
|
||||||
SRVDesc.TextureCube.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
SRVDesc.TextureCube.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (arraySize > 1)
|
else if (arraySize > 1)
|
||||||
{
|
{
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
|
||||||
SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||||
SRVDesc.Texture2DArray.ArraySize = static_cast<UINT>(arraySize);
|
SRVDesc.Texture2DArray.ArraySize = static_cast<UINT>(arraySize);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
SRVDesc.Texture2D.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
SRVDesc.Texture2D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||||
}
|
}
|
||||||
|
|
||||||
hr = d3dDevice->CreateShaderResourceView(tex,
|
hr = d3dDevice->CreateShaderResourceView(tex,
|
||||||
@ -1179,7 +1179,7 @@ namespace
|
|||||||
desc.Usage = usage;
|
desc.Usage = usage;
|
||||||
desc.BindFlags = bindFlags;
|
desc.BindFlags = bindFlags;
|
||||||
desc.CPUAccessFlags = cpuAccessFlags;
|
desc.CPUAccessFlags = cpuAccessFlags;
|
||||||
desc.MiscFlags = miscFlags & ~D3D11_RESOURCE_MISC_TEXTURECUBE;
|
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
|
||||||
|
|
||||||
ID3D11Texture3D* tex = nullptr;
|
ID3D11Texture3D* tex = nullptr;
|
||||||
hr = d3dDevice->CreateTexture3D(&desc,
|
hr = d3dDevice->CreateTexture3D(&desc,
|
||||||
@ -1194,7 +1194,7 @@ namespace
|
|||||||
SRVDesc.Format = format;
|
SRVDesc.Format = format;
|
||||||
|
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
|
||||||
SRVDesc.Texture3D.MipLevels = (!mipCount) ? -1 : desc.MipLevels;
|
SRVDesc.Texture3D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
|
||||||
|
|
||||||
hr = d3dDevice->CreateShaderResourceView(tex,
|
hr = d3dDevice->CreateShaderResourceView(tex,
|
||||||
&SRVDesc,
|
&SRVDesc,
|
||||||
@ -1260,7 +1260,7 @@ namespace
|
|||||||
if ((header->ddspf.flags & DDS_FOURCC) &&
|
if ((header->ddspf.flags & DDS_FOURCC) &&
|
||||||
(MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC))
|
(MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC))
|
||||||
{
|
{
|
||||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>((const char*)header + sizeof(DDS_HEADER));
|
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||||
|
|
||||||
arraySize = d3d10ext->arraySize;
|
arraySize = d3d10ext->arraySize;
|
||||||
if (arraySize == 0)
|
if (arraySize == 0)
|
||||||
@ -1604,7 +1604,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC)
|
if (MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC)
|
||||||
{
|
{
|
||||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>((const char*)header + sizeof(DDS_HEADER));
|
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||||
auto mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
|
auto mode = static_cast<DDS_ALPHA_MODE>(d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK);
|
||||||
switch (mode)
|
switch (mode)
|
||||||
{
|
{
|
||||||
@ -1613,6 +1613,10 @@ namespace
|
|||||||
case DDS_ALPHA_MODE_OPAQUE:
|
case DDS_ALPHA_MODE_OPAQUE:
|
||||||
case DDS_ALPHA_MODE_CUSTOM:
|
case DDS_ALPHA_MODE_CUSTOM:
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
|
case DDS_ALPHA_MODE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC)
|
else if ((MAKEFOURCC('D', 'X', 'T', '2') == header->ddspf.fourCC)
|
||||||
|
@ -20,6 +20,14 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wtautological-type-limit-compare"
|
||||||
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define D3DX12_NO_STATE_OBJECT_HELPERS
|
||||||
#include "d3dx12.h"
|
#include "d3dx12.h"
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
@ -63,7 +71,6 @@ struct DDS_PIXELFORMAT
|
|||||||
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
#define DDS_HEADER_FLAGS_VOLUME 0x00800000 // DDSD_DEPTH
|
||||||
|
|
||||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
||||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
|
||||||
|
|
||||||
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
#define DDS_CUBEMAP_POSITIVEX 0x00000600 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_POSITIVEX
|
||||||
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
#define DDS_CUBEMAP_NEGATIVEX 0x00000a00 // DDSCAPS2_CUBEMAP | DDSCAPS2_CUBEMAP_NEGATIVEX
|
||||||
@ -203,7 +210,7 @@ namespace
|
|||||||
|
|
||||||
// setup the pointers in the process request
|
// setup the pointers in the process request
|
||||||
*header = hdr;
|
*header = hdr;
|
||||||
ptrdiff_t offset = sizeof(uint32_t)
|
auto offset = sizeof(uint32_t)
|
||||||
+ sizeof(DDS_HEADER)
|
+ sizeof(DDS_HEADER)
|
||||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||||
*bitData = ddsData + offset;
|
*bitData = ddsData + offset;
|
||||||
@ -313,7 +320,7 @@ namespace
|
|||||||
|
|
||||||
// setup the pointers in the process request
|
// setup the pointers in the process request
|
||||||
*header = hdr;
|
*header = hdr;
|
||||||
ptrdiff_t offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
auto offset = sizeof(uint32_t) + sizeof(DDS_HEADER)
|
||||||
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
+ (bDXT10Header ? sizeof(DDS_HEADER_DXT10) : 0);
|
||||||
*bitData = ddsData.get() + offset;
|
*bitData = ddsData.get() + offset;
|
||||||
*bitSize = fileInfo.EndOfFile.LowPart - offset;
|
*bitSize = fileInfo.EndOfFile.LowPart - offset;
|
||||||
@ -938,13 +945,13 @@ namespace
|
|||||||
if (!slicePlane)
|
if (!slicePlane)
|
||||||
{
|
{
|
||||||
// Plane 0
|
// Plane 0
|
||||||
res.SlicePitch = res.RowPitch * height;
|
res.SlicePitch = res.RowPitch * static_cast<LONG>(height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Plane 1
|
// Plane 1
|
||||||
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * height;
|
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + uintptr_t(res.RowPitch) * height;
|
||||||
res.SlicePitch = res.RowPitch * ((height + 1) >> 1);
|
res.SlicePitch = res.RowPitch * ((static_cast<LONG>(height) + 1) >> 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -952,14 +959,14 @@ namespace
|
|||||||
if (!slicePlane)
|
if (!slicePlane)
|
||||||
{
|
{
|
||||||
// Plane 0
|
// Plane 0
|
||||||
res.SlicePitch = res.RowPitch * height;
|
res.SlicePitch = res.RowPitch * static_cast<LONG>(height);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Plane 1
|
// Plane 1
|
||||||
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + res.RowPitch * height;
|
res.pData = reinterpret_cast<const uint8_t*>(res.pData) + uintptr_t(res.RowPitch) * height;
|
||||||
res.RowPitch = (res.RowPitch >> 1);
|
res.RowPitch = (res.RowPitch >> 1);
|
||||||
res.SlicePitch = res.RowPitch * height;
|
res.SlicePitch = res.RowPitch * static_cast<LONG>(height);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1116,7 +1123,7 @@ namespace
|
|||||||
&desc,
|
&desc,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(texture));
|
IID_ID3D12Resource, reinterpret_cast<void**>(texture));
|
||||||
if (SUCCEEDED(hr))
|
if (SUCCEEDED(hr))
|
||||||
{
|
{
|
||||||
_Analysis_assume_(*texture != nullptr);
|
_Analysis_assume_(*texture != nullptr);
|
||||||
@ -1159,7 +1166,7 @@ namespace
|
|||||||
if ((header->ddspf.flags & DDS_FOURCC) &&
|
if ((header->ddspf.flags & DDS_FOURCC) &&
|
||||||
(MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC))
|
(MAKEFOURCC('D', 'X', '1', '0') == header->ddspf.fourCC))
|
||||||
{
|
{
|
||||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>((const char*)header + sizeof(DDS_HEADER));
|
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||||
|
|
||||||
arraySize = d3d10ext->arraySize;
|
arraySize = d3d10ext->arraySize;
|
||||||
if (arraySize == 0)
|
if (arraySize == 0)
|
||||||
@ -1388,7 +1395,7 @@ namespace
|
|||||||
{
|
{
|
||||||
if ( MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC )
|
if ( MAKEFOURCC( 'D', 'X', '1', '0' ) == header->ddspf.fourCC )
|
||||||
{
|
{
|
||||||
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>( (const char*)header + sizeof(DDS_HEADER) );
|
auto d3d10ext = reinterpret_cast<const DDS_HEADER_DXT10*>(reinterpret_cast<const uint8_t*>(header) + sizeof(DDS_HEADER));
|
||||||
auto mode = static_cast<DDS_ALPHA_MODE>( d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK );
|
auto mode = static_cast<DDS_ALPHA_MODE>( d3d10ext->miscFlags2 & DDS_MISC_FLAGS2_ALPHA_MODE_MASK );
|
||||||
switch( mode )
|
switch( mode )
|
||||||
{
|
{
|
||||||
@ -1397,6 +1404,10 @@ namespace
|
|||||||
case DDS_ALPHA_MODE_OPAQUE:
|
case DDS_ALPHA_MODE_OPAQUE:
|
||||||
case DDS_ALPHA_MODE_CUSTOM:
|
case DDS_ALPHA_MODE_CUSTOM:
|
||||||
return mode;
|
return mode;
|
||||||
|
|
||||||
|
case DDS_ALPHA_MODE_UNKNOWN:
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if ( ( MAKEFOURCC( 'D', 'X', 'T', '2' ) == header->ddspf.fourCC )
|
else if ( ( MAKEFOURCC( 'D', 'X', 'T', '2' ) == header->ddspf.fourCC )
|
||||||
|
@ -80,9 +80,6 @@ namespace
|
|||||||
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
||||||
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
||||||
|
|
||||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
|
||||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
|
||||||
|
|
||||||
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -213,7 +210,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() { m_handle = 0; }
|
void clear() { m_handle = nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HANDLE m_handle;
|
HANDLE m_handle;
|
||||||
@ -225,7 +222,7 @@ namespace
|
|||||||
class auto_delete_file_wic
|
class auto_delete_file_wic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, const wchar_t* szFile) : m_handle(hFile), m_filename(szFile) {}
|
auto_delete_file_wic(ComPtr<IWICStream>& hFile, const wchar_t* szFile) : m_filename(szFile), m_handle(hFile) {}
|
||||||
~auto_delete_file_wic()
|
~auto_delete_file_wic()
|
||||||
{
|
{
|
||||||
if (m_filename)
|
if (m_filename)
|
||||||
@ -235,7 +232,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() { m_filename = 0; }
|
void clear() { m_filename = nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const wchar_t* m_filename;
|
const wchar_t* m_filename;
|
||||||
@ -627,7 +624,7 @@ namespace
|
|||||||
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
return HRESULT_FROM_WIN32( ERROR_NOT_SUPPORTED );
|
||||||
|
|
||||||
ComPtr<ID3D11Texture2D> pTexture;
|
ComPtr<ID3D11Texture2D> pTexture;
|
||||||
HRESULT hr = pSource->QueryInterface(IID_PPV_ARGS(pTexture.GetAddressOf()));
|
HRESULT hr = pSource->QueryInterface(IID_ID3D11Texture2D, reinterpret_cast<void**>(pTexture.GetAddressOf()));
|
||||||
if ( FAILED(hr) )
|
if ( FAILED(hr) )
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -711,13 +708,7 @@ namespace
|
|||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
bool g_WIC2 = false;
|
bool g_WIC2 = false;
|
||||||
|
|
||||||
IWICImagingFactory* _GetWIC()
|
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
|
||||||
{
|
|
||||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
|
||||||
|
|
||||||
IWICImagingFactory* factory = nullptr;
|
|
||||||
InitOnceExecuteOnce(&s_initOnce,
|
|
||||||
[](PINIT_ONCE, PVOID, LPVOID *ifactory) -> BOOL
|
|
||||||
{
|
{
|
||||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
HRESULT hr = CoCreateInstance(
|
HRESULT hr = CoCreateInstance(
|
||||||
@ -753,7 +744,17 @@ namespace
|
|||||||
__uuidof(IWICImagingFactory),
|
__uuidof(IWICImagingFactory),
|
||||||
ifactory)) ? TRUE : FALSE;
|
ifactory)) ? TRUE : FALSE;
|
||||||
#endif
|
#endif
|
||||||
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
|
}
|
||||||
|
|
||||||
|
IWICImagingFactory* _GetWIC()
|
||||||
|
{
|
||||||
|
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||||
|
|
||||||
|
IWICImagingFactory* factory = nullptr;
|
||||||
|
InitOnceExecuteOnce(&s_initOnce,
|
||||||
|
InitializeWICFactory,
|
||||||
|
nullptr,
|
||||||
|
reinterpret_cast<LPVOID*>(&factory));
|
||||||
|
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <d3d11_1.h>
|
#include <d3d11_1.h>
|
||||||
|
|
||||||
#include <ocidl.h>
|
#include <OCIdl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
@ -31,6 +31,14 @@
|
|||||||
|
|
||||||
#include <wrl\client.h>
|
#include <wrl\client.h>
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wtautological-type-limit-compare"
|
||||||
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define D3DX12_NO_STATE_OBJECT_HELPERS
|
||||||
#include "d3dx12.h"
|
#include "d3dx12.h"
|
||||||
|
|
||||||
using Microsoft::WRL::ComPtr;
|
using Microsoft::WRL::ComPtr;
|
||||||
@ -80,9 +88,6 @@ namespace
|
|||||||
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
#define DDS_HEADER_FLAGS_PITCH 0x00000008 // DDSD_PITCH
|
||||||
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
#define DDS_HEADER_FLAGS_LINEARSIZE 0x00080000 // DDSD_LINEARSIZE
|
||||||
|
|
||||||
#define DDS_HEIGHT 0x00000002 // DDSD_HEIGHT
|
|
||||||
#define DDS_WIDTH 0x00000004 // DDSD_WIDTH
|
|
||||||
|
|
||||||
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
#define DDS_SURFACE_FLAGS_TEXTURE 0x00001000 // DDSCAPS_TEXTURE
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
@ -213,7 +218,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() { m_handle = 0; }
|
void clear() { m_handle = nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
HANDLE m_handle;
|
HANDLE m_handle;
|
||||||
@ -225,7 +230,7 @@ namespace
|
|||||||
class auto_delete_file_wic
|
class auto_delete_file_wic
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
auto_delete_file_wic(ComPtr<IWICStream>& hFile, LPCWSTR szFile) : m_handle(hFile), m_filename(szFile) {}
|
auto_delete_file_wic(ComPtr<IWICStream>& hFile, LPCWSTR szFile) : m_filename(szFile), m_handle(hFile) {}
|
||||||
~auto_delete_file_wic()
|
~auto_delete_file_wic()
|
||||||
{
|
{
|
||||||
if (m_filename)
|
if (m_filename)
|
||||||
@ -235,7 +240,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() { m_filename = 0; }
|
void clear() { m_filename = nullptr; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LPCWSTR m_filename;
|
LPCWSTR m_filename;
|
||||||
@ -676,19 +681,19 @@ namespace
|
|||||||
|
|
||||||
// Create a command allocator
|
// Create a command allocator
|
||||||
ComPtr<ID3D12CommandAllocator> commandAlloc;
|
ComPtr<ID3D12CommandAllocator> commandAlloc;
|
||||||
hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_PPV_ARGS(commandAlloc.GetAddressOf()));
|
hr = device->CreateCommandAllocator(D3D12_COMMAND_LIST_TYPE_DIRECT, IID_ID3D12CommandAllocator, reinterpret_cast<void**>(commandAlloc.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
// Spin up a new command list
|
// Spin up a new command list
|
||||||
ComPtr<ID3D12GraphicsCommandList> commandList;
|
ComPtr<ID3D12GraphicsCommandList> commandList;
|
||||||
hr = device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAlloc.Get(), nullptr, IID_PPV_ARGS(commandList.GetAddressOf()));
|
hr = device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, commandAlloc.Get(), nullptr, IID_ID3D12GraphicsCommandList, reinterpret_cast<void**>(commandList.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
// Create a fence
|
// Create a fence
|
||||||
ComPtr<ID3D12Fence> fence;
|
ComPtr<ID3D12Fence> fence;
|
||||||
hr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_PPV_ARGS(fence.GetAddressOf()));
|
hr = device->CreateFence(0, D3D12_FENCE_FLAG_NONE, IID_ID3D12Fence, reinterpret_cast<void**>(fence.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -726,7 +731,8 @@ namespace
|
|||||||
&descCopy,
|
&descCopy,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(pTemp.GetAddressOf()));
|
IID_ID3D12Resource,
|
||||||
|
reinterpret_cast<void**>(pTemp.GetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -761,7 +767,8 @@ namespace
|
|||||||
&bufferDesc,
|
&bufferDesc,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(pStaging.ReleaseAndGetAddressOf()));
|
IID_ID3D12Resource,
|
||||||
|
reinterpret_cast<void**>(pStaging.ReleaseAndGetAddressOf()));
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
return hr;
|
return hr;
|
||||||
|
|
||||||
@ -806,13 +813,7 @@ namespace
|
|||||||
return S_OK;
|
return S_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
IWICImagingFactory2* _GetWIC()
|
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
|
||||||
{
|
|
||||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
|
||||||
|
|
||||||
IWICImagingFactory2* factory = nullptr;
|
|
||||||
(void)InitOnceExecuteOnce(&s_initOnce,
|
|
||||||
[](PINIT_ONCE, PVOID, PVOID *ifactory) -> BOOL
|
|
||||||
{
|
{
|
||||||
return SUCCEEDED(CoCreateInstance(
|
return SUCCEEDED(CoCreateInstance(
|
||||||
CLSID_WICImagingFactory2,
|
CLSID_WICImagingFactory2,
|
||||||
@ -820,7 +821,17 @@ namespace
|
|||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
__uuidof(IWICImagingFactory2),
|
__uuidof(IWICImagingFactory2),
|
||||||
ifactory)) ? TRUE : FALSE;
|
ifactory)) ? TRUE : FALSE;
|
||||||
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
|
}
|
||||||
|
|
||||||
|
IWICImagingFactory2* _GetWIC()
|
||||||
|
{
|
||||||
|
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||||
|
|
||||||
|
IWICImagingFactory2* factory = nullptr;
|
||||||
|
(void)InitOnceExecuteOnce(&s_initOnce,
|
||||||
|
InitializeWICFactory,
|
||||||
|
nullptr,
|
||||||
|
reinterpret_cast<LPVOID*>(&factory));
|
||||||
|
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
@ -840,7 +851,7 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
ComPtr<ID3D12Device> device;
|
ComPtr<ID3D12Device> device;
|
||||||
pCommandQ->GetDevice(IID_PPV_ARGS(device.GetAddressOf()));
|
pCommandQ->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(device.GetAddressOf()));
|
||||||
|
|
||||||
// Get the size of the image
|
// Get the size of the image
|
||||||
const auto desc = pSource->GetDesc();
|
const auto desc = pSource->GetDesc();
|
||||||
@ -863,7 +874,7 @@ HRESULT DirectX::SaveDDSTextureToFile(
|
|||||||
&totalResourceSize);
|
&totalResourceSize);
|
||||||
|
|
||||||
// Round up the srcPitch to multiples of 256
|
// Round up the srcPitch to multiples of 256
|
||||||
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFF;
|
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFFu;
|
||||||
|
|
||||||
if (dstRowPitch > UINT32_MAX)
|
if (dstRowPitch > UINT32_MAX)
|
||||||
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
||||||
@ -1045,7 +1056,7 @@ HRESULT DirectX::SaveWICTextureToFile(
|
|||||||
return E_INVALIDARG;
|
return E_INVALIDARG;
|
||||||
|
|
||||||
ComPtr<ID3D12Device> device;
|
ComPtr<ID3D12Device> device;
|
||||||
pCommandQ->GetDevice(IID_PPV_ARGS(device.GetAddressOf()));
|
pCommandQ->GetDevice(IID_ID3D12Device, reinterpret_cast<void**>(device.GetAddressOf()));
|
||||||
|
|
||||||
// Get the size of the image
|
// Get the size of the image
|
||||||
const auto desc = pSource->GetDesc();
|
const auto desc = pSource->GetDesc();
|
||||||
@ -1068,7 +1079,7 @@ HRESULT DirectX::SaveWICTextureToFile(
|
|||||||
&totalResourceSize);
|
&totalResourceSize);
|
||||||
|
|
||||||
// Round up the srcPitch to multiples of 256
|
// Round up the srcPitch to multiples of 256
|
||||||
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFF;
|
UINT64 dstRowPitch = (fpRowPitch + 255) & ~0xFFu;
|
||||||
|
|
||||||
if (dstRowPitch > UINT32_MAX)
|
if (dstRowPitch > UINT32_MAX)
|
||||||
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include <d3d12.h>
|
#include <d3d12.h>
|
||||||
|
|
||||||
#include <ocidl.h>
|
#include <OCIdl.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
|
|
||||||
|
@ -36,8 +36,9 @@
|
|||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
|
#ifdef __clang__
|
||||||
#pragma comment(lib,"dxguid.lib")
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
@ -164,13 +165,7 @@ namespace
|
|||||||
bool g_WIC2 = false;
|
bool g_WIC2 = false;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
IWICImagingFactory* _GetWIC()
|
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
|
||||||
{
|
|
||||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
|
||||||
|
|
||||||
IWICImagingFactory* factory = nullptr;
|
|
||||||
InitOnceExecuteOnce(&s_initOnce,
|
|
||||||
[](PINIT_ONCE, PVOID, PVOID *ifactory) -> BOOL
|
|
||||||
{
|
{
|
||||||
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8) || defined(_WIN7_PLATFORM_UPDATE)
|
||||||
HRESULT hr = CoCreateInstance(
|
HRESULT hr = CoCreateInstance(
|
||||||
@ -206,7 +201,17 @@ namespace
|
|||||||
__uuidof(IWICImagingFactory),
|
__uuidof(IWICImagingFactory),
|
||||||
ifactory)) ? TRUE : FALSE;
|
ifactory)) ? TRUE : FALSE;
|
||||||
#endif
|
#endif
|
||||||
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
|
}
|
||||||
|
|
||||||
|
IWICImagingFactory* _GetWIC()
|
||||||
|
{
|
||||||
|
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||||
|
|
||||||
|
IWICImagingFactory* factory = nullptr;
|
||||||
|
(void)InitOnceExecuteOnce(&s_initOnce,
|
||||||
|
InitializeWICFactory,
|
||||||
|
nullptr,
|
||||||
|
reinterpret_cast<LPVOID*>(&factory));
|
||||||
|
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
@ -647,7 +652,7 @@ namespace
|
|||||||
SRVDesc.Format = desc.Format;
|
SRVDesc.Format = desc.Format;
|
||||||
|
|
||||||
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
|
||||||
SRVDesc.Texture2D.MipLevels = (autogen) ? -1 : 1;
|
SRVDesc.Texture2D.MipLevels = (autogen) ? UINT(-1) : 1;
|
||||||
|
|
||||||
hr = d3dDevice->CreateShaderResourceView(tex, &SRVDesc, textureView);
|
hr = d3dDevice->CreateShaderResourceView(tex, &SRVDesc, textureView);
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
|
@ -124,3 +124,4 @@ namespace DirectX
|
|||||||
_Outptr_opt_ ID3D11Resource** texture,
|
_Outptr_opt_ ID3D11Resource** texture,
|
||||||
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
_Outptr_opt_ ID3D11ShaderResourceView** textureView);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -30,6 +30,14 @@
|
|||||||
|
|
||||||
#include <wrl\client.h>
|
#include <wrl\client.h>
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic ignored "-Wtautological-type-limit-compare"
|
||||||
|
#pragma clang diagnostic ignored "-Wcovered-switch-default"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch"
|
||||||
|
#pragma clang diagnostic ignored "-Wswitch-enum"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define D3DX12_NO_STATE_OBJECT_HELPERS
|
||||||
#include "d3dx12.h"
|
#include "d3dx12.h"
|
||||||
|
|
||||||
using namespace DirectX;
|
using namespace DirectX;
|
||||||
@ -143,13 +151,7 @@ namespace
|
|||||||
// We don't support n-channel formats
|
// We don't support n-channel formats
|
||||||
};
|
};
|
||||||
|
|
||||||
IWICImagingFactory2* _GetWIC()
|
BOOL WINAPI InitializeWICFactory(PINIT_ONCE, PVOID, PVOID* ifactory) noexcept
|
||||||
{
|
|
||||||
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
|
||||||
|
|
||||||
IWICImagingFactory2* factory = nullptr;
|
|
||||||
(void)InitOnceExecuteOnce(&s_initOnce,
|
|
||||||
[](PINIT_ONCE, PVOID, PVOID *ifactory) -> BOOL
|
|
||||||
{
|
{
|
||||||
return SUCCEEDED(CoCreateInstance(
|
return SUCCEEDED(CoCreateInstance(
|
||||||
CLSID_WICImagingFactory2,
|
CLSID_WICImagingFactory2,
|
||||||
@ -157,7 +159,17 @@ namespace
|
|||||||
CLSCTX_INPROC_SERVER,
|
CLSCTX_INPROC_SERVER,
|
||||||
__uuidof(IWICImagingFactory2),
|
__uuidof(IWICImagingFactory2),
|
||||||
ifactory)) ? TRUE : FALSE;
|
ifactory)) ? TRUE : FALSE;
|
||||||
}, nullptr, reinterpret_cast<LPVOID*>(&factory));
|
}
|
||||||
|
|
||||||
|
IWICImagingFactory2* _GetWIC()
|
||||||
|
{
|
||||||
|
static INIT_ONCE s_initOnce = INIT_ONCE_STATIC_INIT;
|
||||||
|
|
||||||
|
IWICImagingFactory2* factory = nullptr;
|
||||||
|
(void)InitOnceExecuteOnce(&s_initOnce,
|
||||||
|
InitializeWICFactory,
|
||||||
|
nullptr,
|
||||||
|
reinterpret_cast<LPVOID*>(&factory));
|
||||||
|
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
@ -513,7 +525,8 @@ namespace
|
|||||||
&desc,
|
&desc,
|
||||||
D3D12_RESOURCE_STATE_COPY_DEST,
|
D3D12_RESOURCE_STATE_COPY_DEST,
|
||||||
nullptr,
|
nullptr,
|
||||||
IID_PPV_ARGS(&tex));
|
IID_ID3D12Resource,
|
||||||
|
reinterpret_cast<void**>(&tex));
|
||||||
|
|
||||||
if (FAILED(hr))
|
if (FAILED(hr))
|
||||||
{
|
{
|
||||||
@ -523,8 +536,8 @@ namespace
|
|||||||
_Analysis_assume_(tex != nullptr);
|
_Analysis_assume_(tex != nullptr);
|
||||||
|
|
||||||
subresource.pData = decodedData.get();
|
subresource.pData = decodedData.get();
|
||||||
subresource.RowPitch = rowPitch;
|
subresource.RowPitch = static_cast<LONG>(rowPitch);
|
||||||
subresource.SlicePitch = imageSize;
|
subresource.SlicePitch = static_cast<LONG>(imageSize);
|
||||||
|
|
||||||
*texture = tex;
|
*texture = tex;
|
||||||
return hr;
|
return hr;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user