Skip to content

Commit

Permalink
KTX compare tool - phase 1
Browse files Browse the repository at this point in the history
Draft implementation for the compare tool with no image comparison yet.
Basic test set covering the following:
  * Help
  * Command line errors
  * Use with invalid files without the "allow-invalid-input" flag
  * Use with invalid files with the "allow-invalid-input" flag
  * Unicode filename support
  • Loading branch information
aqnuep committed Dec 7, 2023
1 parent d3ef5ed commit 77c715c
Show file tree
Hide file tree
Showing 14 changed files with 3,208 additions and 67 deletions.
1 change: 1 addition & 0 deletions cmake/docs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ function( CreateDocTools )
doxygen_add_docs(
tools.doc
tools/ktx/ktx_main.cpp
tools/ktx/command_compare.cpp
tools/ktx/command_create.cpp
tools/ktx/command_encode.cpp
tools/ktx/command_extract.cpp
Expand Down
6 changes: 3 additions & 3 deletions lib/dfdutils/printdfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ const char* dfdToStringColorModel(khr_df_model_e value) {
return NULL;
}

const char* dfdToStringSampleDatatypeQualifiers(uint32_t bit_index, bool bit_value) {
const char* dfdToStringSampleDatatypeQualifiersBit(uint32_t bit_index, bool bit_value) {
if (!bit_value)
return NULL;

Expand Down Expand Up @@ -782,7 +782,7 @@ void printDFD(uint32_t *DFD, uint32_t dataSize)

khr_df_sample_datatype_qualifiers_e qualifiers = KHR_DFDSVAL(block, sample, QUALIFIERS);
printf(" Qualifiers: 0x%X (", qualifiers);
printFlagBits(qualifiers, dfdToStringSampleDatatypeQualifiers);
printFlagBits(qualifiers, dfdToStringSampleDatatypeQualifiersBit);
printf(")\n");
printf(" Channel Type: 0x%X", channelType);
{
Expand Down Expand Up @@ -960,7 +960,7 @@ void printDFDJSON(uint32_t* DFD, uint32_t dataSize, uint32_t base_indent, uint32

} else {
PRINT_INDENT(4, "\"qualifiers\":%s[%s", space, nl)
printFlagBitsJSON(LENGTH_OF_INDENT(5), nl, qualifiers, dfdToStringSampleDatatypeQualifiers);
printFlagBitsJSON(LENGTH_OF_INDENT(5), nl, qualifiers, dfdToStringSampleDatatypeQualifiersBit);
PRINT_INDENT(4, "],%s", nl)
}

Expand Down
3 changes: 3 additions & 0 deletions lib/internalexport_write.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ EXPORTS
dfdToStringColorModel
dfdToStringColorPrimaries
dfdToStringDescriptorType
dfdToStringFlagsBit
dfdToStringSampleDatatypeQualifiersBit
dfdToStringTransferFunction
dfdToStringVendorID
dfdToStringVersionNumber
ktxBUImageFlagsBitString
ktxTexture2_constructCopy
3 changes: 3 additions & 0 deletions lib/internalexport_write_mingw.def
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ EXPORTS
dfdToStringColorModel
dfdToStringColorPrimaries
dfdToStringDescriptorType
dfdToStringFlagsBit
dfdToStringSampleDatatypeQualifiersBit
dfdToStringTransferFunction
dfdToStringVendorID
dfdToStringVersionNumber
ktxBUImageFlagsBitString
ktxTexture2_constructCopy
2 changes: 1 addition & 1 deletion tests/cts
Submodule cts updated 300 files
1 change: 1 addition & 0 deletions tools/ktx/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
add_executable(ktxtools
command.cpp
command.h
command_compare.cpp
command_create.cpp
command_encode.cpp
command_extract.cpp
Expand Down
10 changes: 10 additions & 0 deletions tools/ktx/command.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ enum class ReturnCode {
DFD_FAILURE = RUNTIME_ERROR,
NOT_SUPPORTED = 5,
NOT_IMPLEMENTED = 6,
DIFFERENCE_FOUND = 7
};
using rc = ReturnCode;

Expand Down Expand Up @@ -358,6 +359,10 @@ class InputStream {
public:
InputStream(const std::string& filepath, Reporter& report);

const std::string& str() {
return filepath;
}

/*explicit(false)*/ operator std::istream&() {
return *activeStream;
}
Expand All @@ -380,6 +385,11 @@ class OutputStream {
public:
OutputStream(const std::string& filepath, Reporter& report);
~OutputStream();

const std::string& str() {
return filepath;
}

void writeKTX2(ktxTexture* texture, Reporter& report);
void write(const char* data, std::size_t size, Reporter& report);
};
Expand Down
Loading

0 comments on commit 77c715c

Please sign in to comment.