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

Rename function to transferFunction #482

Merged
merged 5 commits into from
Sep 16, 2021
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: 0 additions & 14 deletions include/ktx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1146,17 +1146,6 @@ typedef enum ktx_pack_astc_block_dimension_e {
/*!< Maximum supported blocks. */
} ktx_pack_astc_block_dimension_e;

/**
* @~English
* @brief Options specifiying ASTC encoder profile function
*/
typedef enum ktx_pack_astc_encoder_function_e {
KTX_PACK_ASTC_ENCODER_FUNCTION_UNKNOWN,
KTX_PACK_ASTC_ENCODER_FUNCTION_SRGB,
KTX_PACK_ASTC_ENCODER_FUNCTION_LINEAR,
KTX_PACK_ASTC_ENCODER_FUNCTION_MAX = KTX_PACK_ASTC_ENCODER_FUNCTION_LINEAR
} ktx_pack_astc_encoder_function_e;

/**
* @~English
* @brief Options specifying ASTC encoder profile mode
Expand Down Expand Up @@ -1197,9 +1186,6 @@ typedef struct ktxAstcParams {
/*!< Combinations of block dimensions that astcenc supports
i.e. 6x6, 8x8, 6x5 etc*/

ktx_uint32_t function;
/*!< Can be {linear/srgb} from astcenc*/

ktx_uint32_t mode;
/*!< Can be {ldr/hdr} from astcenc*/

Expand Down
37 changes: 10 additions & 27 deletions lib/astc_encode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,6 @@ astcDefaultOptions() {
params.verbose = false;
params.threadCount = 1;
params.blockDimension = KTX_PACK_ASTC_BLOCK_DIMENSION_6x6;
params.function = KTX_PACK_ASTC_ENCODER_FUNCTION_UNKNOWN;
params.mode = KTX_PACK_ASTC_ENCODER_MODE_LDR;
params.qualityLevel = KTX_PACK_ASTC_QUALITY_LEVEL_MEDIUM;
params.normalMap = false;
Expand Down Expand Up @@ -302,35 +301,19 @@ astcVkFormat(ktx_uint32_t block_size, bool sRGB) {
static astcenc_profile
astcEncoderAction(const ktxAstcParams &params, const uint32_t* bdb) {

if (params.function == KTX_PACK_ASTC_ENCODER_FUNCTION_SRGB &&
params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR) {
ktx_uint32_t transfer = KHR_DFDVAL(bdb, TRANSFER);

if (transfer == KHR_DF_TRANSFER_SRGB &&
params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR)
return ASTCENC_PRF_LDR_SRGB;
}
else if (params.function == KTX_PACK_ASTC_ENCODER_FUNCTION_LINEAR &&
params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR) {
return ASTCENC_PRF_LDR;
}
else if (params.function == KTX_PACK_ASTC_ENCODER_FUNCTION_LINEAR &&
params.mode == KTX_PACK_ASTC_ENCODER_MODE_HDR) {
return ASTCENC_PRF_HDR;
}
else if (params.function == KTX_PACK_ASTC_ENCODER_FUNCTION_UNKNOWN) {
// If no options provided assume the user wants to use
// color space info provided from the file

ktx_uint32_t transfer = KHR_DFDVAL(bdb, TRANSFER);
if (transfer == KHR_DF_TRANSFER_SRGB &&
params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR)
return ASTCENC_PRF_LDR_SRGB;
else if (transfer == KHR_DF_TRANSFER_LINEAR) {
if (params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR)
return ASTCENC_PRF_LDR;
else
return ASTCENC_PRF_HDR;
}
else if (transfer == KHR_DF_TRANSFER_LINEAR) {
if (params.mode == KTX_PACK_ASTC_ENCODER_MODE_LDR)
return ASTCENC_PRF_LDR;
else
return ASTCENC_PRF_HDR;
}
// TODO: Add support for the following
// KTX_PACK_ASTC_ENCODER_ACTION_COMP_HDR_RGB_LDR_ALPHA; not supported
// KTX_PACK_ASTC_ENCODER_ACTION_COMP_HDR_RGB_LDR_ALPHA; currently not supported

return ASTCENC_PRF_LDR_SRGB;
}
Expand Down
7 changes: 0 additions & 7 deletions tools/toktx/toktx.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1389,13 +1389,6 @@ toktxApp::main(int argc, _TCHAR *argv[])
}
}

if (chosenOETF == KHR_DF_TRANSFER_SRGB) {
astcopts.function = KTX_PACK_ASTC_ENCODER_FUNCTION_SRGB;
}
else {
astcopts.function = KTX_PACK_ASTC_ENCODER_FUNCTION_LINEAR;
}

astcopts.threadCount = options.threadCount;
astcopts.normalMap = options.normalMode;

Expand Down
5 changes: 0 additions & 5 deletions utils/scapp.h
Original file line number Diff line number Diff line change
Expand Up @@ -413,14 +413,12 @@ class scApp : public ktxApp {
struct astcOptions : public ktxAstcParams {
clampedOption<ktx_uint32_t> threadCount;
clampedOption<ktx_uint32_t> blockDimension;
clampedOption<ktx_uint32_t> function;
clampedOption<ktx_uint32_t> mode;
clampedOption<ktx_uint32_t> qualityLevel;

astcOptions() :
threadCount(ktxAstcParams::threadCount, 1, 10000),
blockDimension(ktxAstcParams::blockDimension, 0, KTX_PACK_ASTC_BLOCK_DIMENSION_MAX),
function(ktxAstcParams::function, 0, KTX_PACK_ASTC_ENCODER_FUNCTION_MAX),
mode(ktxAstcParams::mode, 0, KTX_PACK_ASTC_ENCODER_MODE_MAX),
qualityLevel(ktxAstcParams::qualityLevel, 0, KTX_PACK_ASTC_QUALITY_LEVEL_MAX)
{
Expand All @@ -432,9 +430,6 @@ class scApp : public ktxApp {
structSize = sizeof(ktxAstcParams);
blockDimension.clear();
blockDimension = KTX_PACK_ASTC_BLOCK_DIMENSION_6x6;
function.clear();
// Default to unknown to have a chance to use color space from file
function = KTX_PACK_ASTC_ENCODER_FUNCTION_UNKNOWN;
mode.clear();
qualityLevel.clear();
normalMap = false;
Expand Down