Skip to content

Commit

Permalink
KtxImporter: oops
Browse files Browse the repository at this point in the history
  • Loading branch information
pezcode committed Jul 23, 2021
1 parent b4cdfe3 commit d1bdcab
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 17 deletions.
4 changes: 2 additions & 2 deletions package/debian/rules
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ override_dh_auto_configure:
-DWITH_ICOIMPORTER=ON \
-DWITH_JPEGIMAGECONVERTER=ON \
-DWITH_JPEGIMPORTER=ON \
-DWITH_KTXIMAGECONVERTER=ON \
-DWITH_KTXIMPORTER=ON \
-DWITH_KTXIMAGECONVERTER=ON \
-DWITH_KTXIMPORTER=ON \
-DWITH_MESHOPTIMIZERSCENECONVERTER=OFF \
-DWITH_MINIEXRIMAGECONVERTER=ON \
-DWITH_OPENEXRIMAGECONVERTER=ON \
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ src_configure() {
-DWITH_ICOIMPORTER=ON
-DWITH_JPEGIMAGECONVERTER=ON
-DWITH_JPEGIMPORTER=ON
-DWITH_KTXIMAGECONVERTER=ON
-DWITH_KTXIMPORTER=ON
-DWITH_KTXIMAGECONVERTER=ON
-DWITH_KTXIMPORTER=ON
-DWITH_MESHOPTIMIZERSCENECONVERTER=OFF
-DWITH_MINIEXRIMAGECONVERTER=ON
-DWITH_OPENEXRIMAGECONVERTER=ON
Expand Down
6 changes: 3 additions & 3 deletions src/MagnumPlugins/KtxImageConverter/KtxImageConverter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
#include "KtxImageConverter.h"

#include <Corrade/Containers/Array.h>
#include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/Pair.h>
#include <Corrade/Containers/StaticArray.h>
#include <Corrade/Containers/StringView.h>
#include <Corrade/Utility/Algorithms.h>
#include <Corrade/Utility/Endianness.h>
Expand Down Expand Up @@ -172,7 +172,7 @@ UnsignedByte channelFormat(Implementation::VkFormatSuffix suffix, Implementation
: Implementation::KdfBasicBlockSample::ChannelFormat{};
}

CORRADE_ASSERT_UNREACHABLE("channelFormat(): invalid format suffix" << suffix, {});
CORRADE_ASSERT_UNREACHABLE("channelFormat(): invalid format suffix" << UnsignedInt(suffix), {});
}

Containers::Array2<UnsignedInt> channelMapping(Implementation::VkFormatSuffix suffix, UnsignedByte typeSize) {
Expand Down Expand Up @@ -214,7 +214,7 @@ Containers::Array2<UnsignedInt> channelMapping(Implementation::VkFormatSuffix su
return {Corrade::Utility::bitCast<UnsignedInt>(-1.0f), Corrade::Utility::bitCast<UnsignedInt>(1.0f)};
}

CORRADE_ASSERT_UNREACHABLE("channelLimits(): invalid format suffix" << suffix, {});
CORRADE_ASSERT_UNREACHABLE("channelLimits(): invalid format suffix" << UnsignedInt(suffix), {});
}

bool isSrgb(PixelFormat format) {
Expand Down
2 changes: 1 addition & 1 deletion src/MagnumPlugins/KtxImageConverter/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/configure.h
INPUT ${CMAKE_CURRENT_BINARY_DIR}/configure.h.in)

corrade_add_test(KtxImageConverterTest KtxImageConverterTest.cpp
LIBRARIES MagnumTrade)
LIBRARIES Magnum::Trade)
target_include_directories(KtxImageConverterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>)
if(MAGNUM_KTXIMAGECONVERTER_BUILD_STATIC)
target_link_libraries(KtxImageConverterTest PRIVATE KtxImageConverter)
Expand Down
3 changes: 1 addition & 2 deletions src/MagnumPlugins/KtxImporter/KtxImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
#include <Magnum/Math/Vector4.h>
#include <Magnum/Trade/ImageData.h>
#include <Magnum/Trade/TextureData.h>
#include <Magnum/Vk/PixelFormat.h>
#include "MagnumPlugins/KtxImporter/KtxHeader.h"

namespace Magnum { namespace Trade {
Expand Down Expand Up @@ -613,7 +612,7 @@ void KtxImporter::doOpenData(const Containers::ArrayView<const char> data) {
if(f->pixelFormat.isCompressed) {
/* Block size */
const Vector4i expected = Vector4i::pad(compressedBlockSize(f->pixelFormat.compressed), 1);
const Vector4i actual{Math::max(Vector4ub::from(block.texelBlockDimension), {1})};
const Vector4i actual{Math::max(Vector4ub::from(block.texelBlockDimension), UnsignedByte(1))};
valid = valid && actual == expected;
} else {
/* Pixel size. For supercompressed data, bytePlanes is all
Expand Down
19 changes: 17 additions & 2 deletions src/MagnumPlugins/KtxImporter/Test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,23 @@ file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>/configure.h
INPUT ${CMAKE_CURRENT_BINARY_DIR}/configure.h.in)

corrade_add_test(KtxImporterTest KtxImporterTest.cpp
LIBRARIES MagnumTrade
FILES file.tga)
LIBRARIES Magnum::Trade
FILES
1d.ktx2
1d-mipmaps.ktx2
bgr.ktx2
bgra.ktx2
bgra-swizzle-bgra.ktx2
bgr-swizzle-bgr.ktx2
orientation-empty.ktx2
rgb.ktx2
rgba.ktx2
rgb-mipmaps.ktx2
swizzle-bgr.ktx2
swizzle-bgra.ktx2
swizzle-identity.ktx2
swizzle-unsupported.ktx2
version1.ktx)
target_include_directories(KtxImporterTest PRIVATE
${CMAKE_CURRENT_BINARY_DIR}/$<CONFIG>
${PROJECT_SOURCE_DIR}/src)
Expand Down
10 changes: 5 additions & 5 deletions src/MagnumPlugins/KtxImporter/Test/KtxImporterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,14 @@ constexpr Color3ub Black{0};
constexpr Color3ub White{0xff};
constexpr Color3ub Purple{0x7f, 0, 0x7f};

constexpr Color3ub PatternRgb2DData[3][4]{
const Color3ub PatternRgb2DData[3][4]{
/* Origin bottom-left */
{Color3ub::red(), White, Black, Color3ub::green()},
{White, Color3ub::red(), Black, Color3ub::green()},
{Color3ub::blue(), Color3ub::green(), Purple, Purple}
};

constexpr Color4ub PatternRgba2DData[3][4]{
const Color4ub PatternRgba2DData[3][4] = {
{PatternRgb2DData[0][0], PatternRgb2DData[0][1], PatternRgb2DData[0][2], PatternRgb2DData[0][3]},
{PatternRgb2DData[1][0], PatternRgb2DData[1][1], PatternRgb2DData[1][2], PatternRgb2DData[1][3]},
{PatternRgb2DData[2][0], PatternRgb2DData[2][1], PatternRgb2DData[2][2], PatternRgb2DData[2][3]}
Expand Down Expand Up @@ -252,12 +252,12 @@ const struct {
{"BGRA8 format", "bgra.ktx2",
PixelFormat::RGBA8Srgb, Implementation::VK_FORMAT_B8G8R8A8_SRGB,
"format requires conversion from BGRA to RGBA", Containers::arrayCast<const char>(PatternRgba2DData)},
{"BGR8 format+header cancel", "swizzle-bgr.ktx2",
PixelFormat::RGB8Srgb, Implementation::VK_FORMAT_B8G8R8_SRGB,
nullptr, Containers::arrayCast<const char>(PatternRgb2DData)},
{"BGRA8 format+header cancel", "swizzle-bgra.ktx2",
PixelFormat::RGBA8Srgb, Implementation::VK_FORMAT_B8G8R8A8_SRGB,
nullptr, Containers::arrayCast<const char>(PatternRgba2DData)},
{"BGR8 format+header cancel", "swizzle-bgr.ktx2",
PixelFormat::RGB8Srgb, Implementation::VK_FORMAT_B8G8R8_SRGB,
nullptr, Containers::arrayCast<const char>(PatternRgb2DData)}
/** @todo Check swizzle of larger formats */
};

Expand Down

0 comments on commit d1bdcab

Please sign in to comment.