.edtiorconfig driven reformat of source (#271)

This commit is contained in:
Chuck Walbourn
2022-04-04 15:03:02 -07:00
committed by GitHub
parent 091835fa86
commit b1001d15b3
48 changed files with 5645 additions and 5531 deletions

View File

@@ -43,7 +43,7 @@ using namespace DirectX;
// Macros
//--------------------------------------------------------------------------------------
#ifndef MAKEFOURCC
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
#define MAKEFOURCC(ch0, ch1, ch2, ch3) \
((uint32_t)(uint8_t)(ch0) | ((uint32_t)(uint8_t)(ch1) << 8) | \
((uint32_t)(uint8_t)(ch2) << 16) | ((uint32_t)(uint8_t)(ch3) << 24 ))
#endif /* defined(MAKEFOURCC) */
@@ -136,7 +136,7 @@ namespace
inline HANDLE safe_handle(HANDLE h) noexcept { return (h == INVALID_HANDLE_VALUE) ? nullptr : h; }
template<UINT TNameLength>
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char (&name)[TNameLength]) noexcept
inline void SetDebugObjectName(_In_ ID3D11DeviceChild* resource, _In_ const char(&name)[TNameLength]) noexcept
{
#if defined(_DEBUG) || defined(PROFILE)
resource->SetPrivateData(WKPDID_D3DDebugObjectName, TNameLength - 1, name);
@@ -229,13 +229,13 @@ namespace
*bitSize = 0;
// open the file
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
ScopedHandle hFile(safe_handle(CreateFile2(fileName,
GENERIC_READ,
FILE_SHARE_READ,
OPEN_EXISTING,
nullptr)));
#else
#else
ScopedHandle hFile(safe_handle(CreateFileW(fileName,
GENERIC_READ,
FILE_SHARE_READ,
@@ -243,7 +243,7 @@ namespace
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
nullptr)));
#endif
#endif
if (!hFile)
{
@@ -611,13 +611,13 @@ namespace
numBytes = rowBytes * height;
}
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
#if defined(_M_IX86) || defined(_M_ARM) || defined(_M_HYBRID_X86_ARM64)
static_assert(sizeof(size_t) == 4, "Not a 32-bit platform!");
if (numBytes > UINT32_MAX || rowBytes > UINT32_MAX || numRows > UINT32_MAX)
return HRESULT_FROM_WIN32(ERROR_ARITHMETIC_OVERFLOW);
#else
#else
static_assert(sizeof(size_t) == 8, "Not a 64-bit platform!");
#endif
#endif
if (outNumBytes)
{
@@ -637,7 +637,7 @@ namespace
//--------------------------------------------------------------------------------------
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
#define ISBITMASK( r,g,b,a ) ( ddpf.RBitMask == r && ddpf.GBitMask == g && ddpf.BBitMask == b && ddpf.ABitMask == a )
DXGI_FORMAT GetDXGIFormat(const DDS_PIXELFORMAT& ddpf) noexcept
{
@@ -904,10 +904,10 @@ namespace
return DXGI_FORMAT_UNKNOWN;
}
#undef ISBITMASK
#undef ISBITMASK
//--------------------------------------------------------------------------------------
//--------------------------------------------------------------------------------------
DXGI_FORMAT MakeSRGB(_In_ DXGI_FORMAT format) noexcept
{
switch (format)
@@ -1070,202 +1070,202 @@ namespace
switch (resDim)
{
case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
{
D3D11_TEXTURE1D_DESC desc;
desc.Width = static_cast<UINT>(width);
desc.MipLevels = static_cast<UINT>(mipCount);
desc.ArraySize = static_cast<UINT>(arraySize);
desc.Format = format;
desc.Usage = usage;
desc.BindFlags = bindFlags;
desc.CPUAccessFlags = cpuAccessFlags;
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
ID3D11Texture1D* tex = nullptr;
hr = d3dDevice->CreateTexture1D(&desc,
initData,
&tex
);
if (SUCCEEDED(hr) && tex)
{
if (textureView)
{
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = format;
if (arraySize > 1)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
SRVDesc.Texture1DArray.ArraySize = static_cast<UINT>(arraySize);
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
SRVDesc.Texture1D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
}
hr = d3dDevice->CreateShaderResourceView(tex,
&SRVDesc,
textureView
);
if (FAILED(hr))
{
tex->Release();
return hr;
}
}
if (texture)
{
*texture = tex;
}
else
{
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
}
}
}
break;
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
D3D11_TEXTURE2D_DESC desc;
desc.Width = static_cast<UINT>(width);
desc.Height = static_cast<UINT>(height);
desc.MipLevels = static_cast<UINT>(mipCount);
desc.ArraySize = static_cast<UINT>(arraySize);
desc.Format = format;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = usage;
desc.BindFlags = bindFlags;
desc.CPUAccessFlags = cpuAccessFlags;
if (isCubeMap)
{
desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE;
}
else
{
D3D11_TEXTURE1D_DESC desc;
desc.Width = static_cast<UINT>(width);
desc.MipLevels = static_cast<UINT>(mipCount);
desc.ArraySize = static_cast<UINT>(arraySize);
desc.Format = format;
desc.Usage = usage;
desc.BindFlags = bindFlags;
desc.CPUAccessFlags = cpuAccessFlags;
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
}
ID3D11Texture2D* tex = nullptr;
hr = d3dDevice->CreateTexture2D(&desc,
initData,
&tex
);
if (SUCCEEDED(hr) && tex)
{
if (textureView)
ID3D11Texture1D* tex = nullptr;
hr = d3dDevice->CreateTexture1D(&desc,
initData,
&tex
);
if (SUCCEEDED(hr) && tex)
{
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = format;
if (isCubeMap)
if (textureView)
{
if (arraySize > 6)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = format;
// Earlier we set arraySize to (NumCubes * 6)
SRVDesc.TextureCubeArray.NumCubes = static_cast<UINT>(arraySize / 6);
if (arraySize > 1)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1DARRAY;
SRVDesc.Texture1DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
SRVDesc.Texture1DArray.ArraySize = static_cast<UINT>(arraySize);
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
SRVDesc.TextureCube.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE1D;
SRVDesc.Texture1D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
}
hr = d3dDevice->CreateShaderResourceView(tex,
&SRVDesc,
textureView
);
if (FAILED(hr))
{
tex->Release();
return hr;
}
}
else if (arraySize > 1)
if (texture)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
SRVDesc.Texture2DArray.ArraySize = static_cast<UINT>(arraySize);
*texture = tex;
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
}
hr = d3dDevice->CreateShaderResourceView(tex,
&SRVDesc,
textureView
);
if (FAILED(hr))
{
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
return hr;
}
}
}
break;
if (texture)
case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
{
D3D11_TEXTURE2D_DESC desc;
desc.Width = static_cast<UINT>(width);
desc.Height = static_cast<UINT>(height);
desc.MipLevels = static_cast<UINT>(mipCount);
desc.ArraySize = static_cast<UINT>(arraySize);
desc.Format = format;
desc.SampleDesc.Count = 1;
desc.SampleDesc.Quality = 0;
desc.Usage = usage;
desc.BindFlags = bindFlags;
desc.CPUAccessFlags = cpuAccessFlags;
if (isCubeMap)
{
*texture = tex;
desc.MiscFlags = miscFlags | D3D11_RESOURCE_MISC_TEXTURECUBE;
}
else
{
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
}
ID3D11Texture2D* tex = nullptr;
hr = d3dDevice->CreateTexture2D(&desc,
initData,
&tex
);
if (SUCCEEDED(hr) && tex)
{
if (textureView)
{
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = format;
if (isCubeMap)
{
if (arraySize > 6)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBEARRAY;
SRVDesc.TextureCubeArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
// Earlier we set arraySize to (NumCubes * 6)
SRVDesc.TextureCubeArray.NumCubes = static_cast<UINT>(arraySize / 6);
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
SRVDesc.TextureCube.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
}
}
else if (arraySize > 1)
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DARRAY;
SRVDesc.Texture2DArray.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
SRVDesc.Texture2DArray.ArraySize = static_cast<UINT>(arraySize);
}
else
{
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
SRVDesc.Texture2D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
}
hr = d3dDevice->CreateShaderResourceView(tex,
&SRVDesc,
textureView
);
if (FAILED(hr))
{
tex->Release();
return hr;
}
}
if (texture)
{
*texture = tex;
}
else
{
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
}
}
}
}
break;
break;
case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
{
D3D11_TEXTURE3D_DESC desc;
desc.Width = static_cast<UINT>(width);
desc.Height = static_cast<UINT>(height);
desc.Depth = static_cast<UINT>(depth);
desc.MipLevels = static_cast<UINT>(mipCount);
desc.Format = format;
desc.Usage = usage;
desc.BindFlags = bindFlags;
desc.CPUAccessFlags = cpuAccessFlags;
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
ID3D11Texture3D* tex = nullptr;
hr = d3dDevice->CreateTexture3D(&desc,
initData,
&tex
);
if (SUCCEEDED(hr) && tex)
{
if (textureView)
D3D11_TEXTURE3D_DESC desc;
desc.Width = static_cast<UINT>(width);
desc.Height = static_cast<UINT>(height);
desc.Depth = static_cast<UINT>(depth);
desc.MipLevels = static_cast<UINT>(mipCount);
desc.Format = format;
desc.Usage = usage;
desc.BindFlags = bindFlags;
desc.CPUAccessFlags = cpuAccessFlags;
desc.MiscFlags = miscFlags & ~static_cast<unsigned int>(D3D11_RESOURCE_MISC_TEXTURECUBE);
ID3D11Texture3D* tex = nullptr;
hr = d3dDevice->CreateTexture3D(&desc,
initData,
&tex
);
if (SUCCEEDED(hr) && tex)
{
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = format;
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
SRVDesc.Texture3D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
hr = d3dDevice->CreateShaderResourceView(tex,
&SRVDesc,
textureView
);
if (FAILED(hr))
if (textureView)
{
D3D11_SHADER_RESOURCE_VIEW_DESC SRVDesc = {};
SRVDesc.Format = format;
SRVDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE3D;
SRVDesc.Texture3D.MipLevels = (!mipCount) ? UINT(-1) : desc.MipLevels;
hr = d3dDevice->CreateShaderResourceView(tex,
&SRVDesc,
textureView
);
if (FAILED(hr))
{
tex->Release();
return hr;
}
}
if (texture)
{
*texture = tex;
}
else
{
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
return hr;
}
}
if (texture)
{
*texture = tex;
}
else
{
SetDebugObjectName(tex, "DDSTextureLoader");
tex->Release();
}
}
}
break;
break;
}
return hr;
@@ -1434,8 +1434,8 @@ namespace
}
}
else if ((arraySize > D3D11_REQ_TEXTURE2D_ARRAY_AXIS_DIMENSION) ||
(width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION) ||
(height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION))
(width > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION) ||
(height > D3D11_REQ_TEXTURE2D_U_OR_V_DIMENSION))
{
return HRESULT_FROM_WIN32(ERROR_NOT_SUPPORTED);
}
@@ -1682,7 +1682,7 @@ namespace
_In_opt_ ID3D11Resource** texture,
_In_opt_ ID3D11ShaderResourceView** textureView) noexcept
{
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
#if !defined(NO_D3D11_DEBUG_NAME) && ( defined(_DEBUG) || defined(PROFILE) )
if (texture || textureView)
{
CHAR strFileA[MAX_PATH];
@@ -1724,11 +1724,11 @@ namespace
}
}
}
#else
#else
UNREFERENCED_PARAMETER(fileName);
UNREFERENCED_PARAMETER(texture);
UNREFERENCED_PARAMETER(textureView);
#endif
#endif
}
} // anonymous namespace