Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor code review change for PPM/PFM code #548

Merged
merged 3 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion DDSTextureLoader/DDSTextureLoader11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ namespace
_In_ size_t width,
_In_ size_t height,
_In_ DXGI_FORMAT fmt,
size_t* outNumBytes,
_Out_opt_ size_t* outNumBytes,
_Out_opt_ size_t* outRowBytes,
_Out_opt_ size_t* outNumRows) noexcept
{
Expand All @@ -516,6 +516,9 @@ namespace
size_t bpe = 0;
switch (fmt)
{
case DXGI_FORMAT_UNKNOWN:
return E_INVALIDARG;

case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
Expand Down Expand Up @@ -569,6 +572,15 @@ namespace
bpe = 2;
break;

#if (_WIN32_WINNT >= _WIN32_WINNT_WIN10)

case DXGI_FORMAT_P208:
planar = true;
bpe = 2;
break;

#endif

case DXGI_FORMAT_P010:
case DXGI_FORMAT_P016:
if ((height % 2) != 0)
Expand Down
5 changes: 4 additions & 1 deletion DDSTextureLoader/DDSTextureLoader12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ namespace
_In_ size_t width,
_In_ size_t height,
_In_ DXGI_FORMAT fmt,
size_t* outNumBytes,
_Out_opt_ size_t* outNumBytes,
_Out_opt_ size_t* outRowBytes,
_Out_opt_ size_t* outNumRows) noexcept
{
Expand All @@ -595,6 +595,9 @@ namespace
size_t bpe = 0;
switch (fmt)
{
case DXGI_FORMAT_UNKNOWN:
return E_INVALIDARG;

case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
Expand Down
5 changes: 4 additions & 1 deletion DDSTextureLoader/DDSTextureLoader9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ namespace
_In_ size_t width,
_In_ size_t height,
_In_ D3DFORMAT fmt,
size_t* outNumBytes,
_Out_opt_ size_t* outNumBytes,
_Out_opt_ size_t* outRowBytes,
_Out_opt_ size_t* outNumRows) noexcept
{
Expand All @@ -429,6 +429,9 @@ namespace
size_t bpe = 0;
switch (static_cast<int>(fmt))
{
case D3DFMT_UNKNOWN:
return E_INVALIDARG;

case D3DFMT_DXT1:
bc = true;
bpe = 8;
Expand Down
3 changes: 3 additions & 0 deletions DirectXTex/DirectXTexCompressGPU.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,9 @@ HRESULT DirectX::CompressEx(
|| IsTypeless(srcImage.format) || IsPlanar(srcImage.format) || IsPalettized(srcImage.format))
return HRESULT_E_NOT_SUPPORTED;

if (!srcImage.pixels)
return E_POINTER;

// Setup GPU compressor
std::unique_ptr<GPUCompressBC> gpubc(new (std::nothrow) GPUCompressBC);
if (!gpubc)
Expand Down
6 changes: 6 additions & 0 deletions DirectXTex/DirectXTexUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -972,6 +972,9 @@ HRESULT DirectX::ComputePitch(DXGI_FORMAT fmt, size_t width, size_t height,

switch (static_cast<int>(fmt))
{
case DXGI_FORMAT_UNKNOWN:
return E_INVALIDARG;

case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
Expand Down Expand Up @@ -1192,6 +1195,9 @@ size_t DirectX::ComputeScanlines(DXGI_FORMAT fmt, size_t height) noexcept
{
switch (static_cast<int>(fmt))
{
case DXGI_FORMAT_UNKNOWN:
return 0;

case DXGI_FORMAT_BC1_TYPELESS:
case DXGI_FORMAT_BC1_UNORM:
case DXGI_FORMAT_BC1_UNORM_SRGB:
Expand Down
9 changes: 9 additions & 0 deletions Texconv/PortablePixMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ namespace

HRESULT ReadData(_In_z_ const wchar_t* szFile, std::unique_ptr<uint8_t[]>& blob, size_t& blobSize)
{
if (!szFile)
return E_INVALIDARG;

blob.reset();

#if (_WIN32_WINNT >= _WIN32_WINNT_WIN8)
Expand Down Expand Up @@ -361,6 +364,9 @@ HRESULT __cdecl SaveToPortablePixMap(
_In_ const Image& image,
_In_z_ const wchar_t* szFile) noexcept
{
if (!szFile)
return E_INVALIDARG;

switch (image.format)
{
case DXGI_FORMAT_R8G8B8A8_UNORM:
Expand Down Expand Up @@ -688,6 +694,9 @@ HRESULT __cdecl SaveToPortablePixMapHDR(
_In_ const Image& image,
_In_z_ const wchar_t* szFile) noexcept
{
if (!szFile)
return E_INVALIDARG;

switch (image.format)
{
case DXGI_FORMAT_R32G32B32A32_FLOAT:
Expand Down
Loading