Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement internal ktxdiff tool for comparing test output files
Browse files Browse the repository at this point in the history
Mátyás Császár committed Jul 26, 2023

Verified

This commit was signed with the committer’s verified signature.
djhi Gildas Garcia
1 parent 1ae04f8 commit 34ca929
Showing 7 changed files with 503 additions and 5 deletions.
16 changes: 14 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -71,6 +71,16 @@ CMAKE_DEPENDENT_OPTION( BASISU_SUPPORT_OPENCL
OFF
)

# To improve deterministic outputs enable precise floating point operations
if(MSVC)
add_compile_options(/fp:precise)
else()
add_compile_options(-ffp-contract=off)
if(${CMAKE_CXX_COMPILER_ID} MATCHES "Clang")
add_compile_options(-ffp-model=precise)
endif()
endif()

if(BASISU_SUPPORT_OPENCL)
find_package(OpenCL)
endif()
@@ -356,10 +366,11 @@ if(WIN32)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${KTX_BUILD_DIR}/$<CONFIG>>)
elseif(APPLE)
if(NOT IOS)
# Set a common RUNTIME_OUTPUT_DIR for all targets, so that
# INSTALL RPATH is functional in build directory as well.
# Set a common RUNTIME_OUTPUT_DIR and LIBRARY_OUTPUT_DIR for all targets,
# so that INSTALL RPATH is functional in build directory as well.
# BUILD_WITH_INSTALL_RPATH is necessary for working code signing.
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY $<1:${KTX_BUILD_DIR}/$<CONFIG>>)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY $<1:${KTX_BUILD_DIR}/$<CONFIG>>)
endif()
endif()

@@ -955,6 +966,7 @@ else()
endif()

# Other external projects
set(FMT_SYSTEM_HEADERS ON)
add_subdirectory(other_projects/fmt)
add_subdirectory(other_projects/cxxopts)

2 changes: 2 additions & 0 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -28,7 +28,9 @@ if(KTX_FEATURE_TOOLS)

# ktx cli tool tests
if(KTX_FEATURE_TOOLS_CTS)
add_subdirectory(ktxdiff)
set(KTX_TOOLS_PATH $<TARGET_FILE:ktxtools>)
set(KTX_DIFF_PATH $<TARGET_FILE:ktxdiff>)
add_subdirectory(cts/clitests)
endif()
endif()
2 changes: 1 addition & 1 deletion tests/cts
Submodule cts updated 398 files
44 changes: 44 additions & 0 deletions tests/ktxdiff/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# Copyright 2022-2023 The Khronos Group Inc.
# Copyright 2022-2023 RasterGrid Kft.
# SPDX-License-Identifier: Apache-2.0


add_executable(ktxdiff
ktxdiff_main.cpp
)

set_target_properties(
ktxdiff
PROPERTIES
CXX_STANDARD 17
CXX_STANDARD_REQUIRED YES
)

target_include_directories(
ktxdiff
PRIVATE
.
$<TARGET_PROPERTY:ktx,INCLUDE_DIRECTORIES>
)

target_include_directories(
ktxdiff
SYSTEM
PRIVATE
${PROJECT_SOURCE_DIR}/lib
${PROJECT_SOURCE_DIR}/other_include
)

target_link_libraries(
ktxdiff
PRIVATE
ktx
${ASTCENC_LIB_TARGET}
fmt::fmt
)

target_compile_definitions(
ktxdiff
PRIVATE
$<TARGET_PROPERTY:ktx,INTERFACE_COMPILE_DEFINITIONS>
)
438 changes: 438 additions & 0 deletions tests/ktxdiff/ktxdiff_main.cpp

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion tools/ktx/encode_utils.h
Original file line number Diff line number Diff line change
@@ -107,7 +107,7 @@ enum class EncodeCodec {
<tr><td>4 </td><td> Very slow </td><td> 48.24dB</td></tr>
</table>
You are strongly encouraged to also specify @b --zcmp to
You are strongly encouraged to also specify @b --zstd to
losslessly compress the UASTC data. This and any LZ-style
compression can be made more effective by conditioning the
UASTC texture data using the Rate Distortion Optimization (RDO)
4 changes: 3 additions & 1 deletion tools/ktx/image.hpp
Original file line number Diff line number Diff line change
@@ -1248,7 +1248,9 @@ class ImageT : public Image {
// Encode destination transfer function
for (uint32_t comp = 0; comp < components; comp++) {
brightness[comp] = encode.encode(intensity[comp]);
c.set(comp, roundf(brightness[comp] * static_cast<float>(Color::one())));
// max(0, value) is required as static_cast from negative float to integrals has platform-specific behaviors
// and on certian platforms it can incorrectly wrap around
c.set(comp, std::max(0.f, roundf(brightness[comp] * static_cast<float>(Color::one()))));
}
}
return *this;

0 comments on commit 34ca929

Please sign in to comment.