Merge branch 'master' of https://github.com/hyzboy/TexConv into HEAD

This commit is contained in:
hyzboy 2024-03-19 13:06:30 +08:00
commit fd108ac73b
7 changed files with 57 additions and 55 deletions

View File

@ -4,7 +4,6 @@
#include<hgl/type/DataType.h>
#include<hgl/util/cmd/CmdParse.h>
#include<hgl/type/Smart.h>
#include<hgl/graph/ColorSpace.h>
using namespace hgl;
using namespace hgl::util;

View File

@ -1,4 +1,5 @@
#include"ParamParse.h"
#include<hgl/log/LogInfo.h>
const PixelFormat *ParseParamFormat(const CmdParse &cmd,const os_char *flag,const PixelFormat *default_format)
{

View File

@ -1,11 +1,12 @@
#include"TextureFileCreater.h"
#include<hgl/filesystem/FileSystem.h>
#include<hgl/log/LogInfo.h>
using namespace hgl::filesystem;
bool ToILType(ILuint &type,const uint8 bits,const VulkanNumberType cdt)
bool ToILType(ILuint &type,const uint8 bits,const VulkanBaseType cdt)
{
constexpr ILuint target_type[3][(uint)VulkanNumberType::END_RANGE-1]=
constexpr ILuint target_type[3][(uint)VulkanBaseType::END_RANGE-1]=
{
//UINT SINT, UNORM SNORM USCALE,SSCALE, UFLOAT SFLOAT
/* 8 */{IL_UNSIGNED_BYTE, IL_BYTE, IL_UNSIGNED_BYTE, IL_BYTE, 0,0, 0, 0},

View File

@ -8,7 +8,7 @@
using namespace hgl;
bool ToILType(ILuint &type,const uint8 bits,const hgl::graph::VulkanNumberType cdt);
bool ToILType(ILuint &type,const uint8 bits,const hgl::graph::VulkanBaseType cdt);
class TextureFileCreater
{

View File

@ -1,5 +1,6 @@
#include<iostream>
#include<IL/il.h>
#include<hgl/log/LogInfo.h>
#include<hgl/util/cmd/CmdParse.h>
#include<hgl/Time.h>
#include<hgl/filesystem/FileSystem.h>
@ -99,7 +100,7 @@ int os_main(int argc,os_char **argv)
const double time_gap=(end_time-start_time)/1000000;
const OSString time_gap_str=OSString::numberOf(time_gap);
const OSString time_gap_str=OSString::floatOf(time_gap,2);
LOG_INFO(OS_TEXT("Total converted ")+OSString::numberOf(eci.GetConvertCount())
+OS_TEXT(" textures for ")+time_gap_str.c_str()+OS_TEXT(" seconds."));

View File

@ -23,56 +23,56 @@ namespace hgl
constexpr PixelFormat pf_list[]=
{
{ColorFormat::RGBA4, "RGBA4", 4,{'R','G','B','A'},{ 4, 4, 4, 4}, 16,VulkanNumberType::UNORM},
{ColorFormat::BGRA4, "BGRA4", 4,{'B','G','R','A'},{ 4, 4, 4, 4}, 16,VulkanNumberType::UNORM},
{ColorFormat::RGB565, "RGB565", 3,{'R','G','B', 0 },{ 5, 6, 5, 0}, 16,VulkanNumberType::UNORM},
{ColorFormat::A1RGB5, "A1RGB5", 4,{'A','R','G','B'},{ 1, 5, 5, 5}, 16,VulkanNumberType::UNORM},
{ColorFormat::R8, "R8", 1,{'R', 0 , 0 , 0 },{ 8, 0, 0, 0}, 8,VulkanNumberType::UNORM},
{ColorFormat::RG8, "RG8", 2,{'R','G', 0 , 0 },{ 8, 8, 0, 0}, 16,VulkanNumberType::UNORM},
{ColorFormat::RGBA8, "RGBA8", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanNumberType::UNORM},
{ColorFormat::RGBA8SN, "RGBA8S", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanNumberType::SNORM},
{ColorFormat::RGBA8U, "RGBA8U", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanNumberType::UINT},
{ColorFormat::RGBA8I, "RGBA8I", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanNumberType::SINT},
{ColorFormat::ABGR8, "ABGR8", 4,{'A','B','G','R'},{ 8, 8, 8, 8}, 32,VulkanNumberType::UNORM},
{ColorFormat::A2BGR10, "A2BGR10", 4,{'A','B','G','R'},{ 2,10,10,10}, 32,VulkanNumberType::UNORM},
{ColorFormat::R16, "R16", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanNumberType::UNORM},
{ColorFormat::R16U, "R16U", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanNumberType::UINT},
{ColorFormat::R16I, "R16I", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanNumberType::SINT},
{ColorFormat::R16F, "R16F", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanNumberType::SFLOAT},
{ColorFormat::RG16, "RG16", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanNumberType::UNORM},
{ColorFormat::RG16U, "RG16U", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanNumberType::UINT},
{ColorFormat::RG16I, "RG16I", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanNumberType::SINT},
{ColorFormat::RG16F, "RG16F", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanNumberType::SFLOAT},
{ColorFormat::RGBA16, "RGBA16", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanNumberType::UNORM},
{ColorFormat::RGBA16SN, "RGBA16S", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanNumberType::SNORM},
{ColorFormat::RGBA16U, "RGBA16U", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanNumberType::UINT},
{ColorFormat::RGBA16I, "RGBA16I", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanNumberType::SINT},
{ColorFormat::RGBA16F, "RGBA16F", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanNumberType::SFLOAT},
{ColorFormat::R32U, "R32U", 1,{'R', 0 , 0 , 0 },{32, 0, 0, 0}, 32,VulkanNumberType::UINT},
{ColorFormat::R32I, "R32I", 1,{'R', 0 , 0 , 0 },{32, 0, 0, 0}, 32,VulkanNumberType::SINT},
{ColorFormat::R32F, "R32F", 1,{'R', 0 , 0 , 0 },{32, 0, 0, 0}, 32,VulkanNumberType::SFLOAT},
{ColorFormat::RG32U, "RG32U", 2,{'R','G', 0 , 0 },{32,32, 0, 0}, 64,VulkanNumberType::UINT},
{ColorFormat::RG32I, "RG32I", 2,{'R','G', 0 , 0 },{32,32, 0, 0}, 64,VulkanNumberType::SINT},
{ColorFormat::RG32F, "RG32F", 2,{'R','G', 0 , 0 },{32,32, 0, 0}, 64,VulkanNumberType::SFLOAT},
{ColorFormat::RGB32U, "RGB32U", 3,{'R','G','B', 0 },{32,32,32, 0}, 96,VulkanNumberType::UINT},
{ColorFormat::RGB32I, "RGB32I", 3,{'R','G','B', 0 },{32,32,32, 0}, 96,VulkanNumberType::SINT},
{ColorFormat::RGB32F, "RGB32F", 3,{'R','G','B', 0 },{32,32,32, 0}, 96,VulkanNumberType::SFLOAT},
{ColorFormat::RGBA32U, "RGBA32U", 4,{'R','G','B','A'},{32,32,32,32},128,VulkanNumberType::UINT},
{ColorFormat::RGBA32I, "RGBA32I", 4,{'R','G','B','A'},{32,32,32,32},128,VulkanNumberType::SINT},
{ColorFormat::RGBA32F, "RGBA32F", 4,{'R','G','B','A'},{32,32,32,32},128,VulkanNumberType::SFLOAT},
{ColorFormat::B10GR11UF,"B10GR11UF",3,{'B','G','R', 0 },{10,11,11, 0}, 32,VulkanNumberType::UFLOAT},
{ColorFormat::RGBA4, "RGBA4", 4,{'R','G','B','A'},{ 4, 4, 4, 4}, 16,VulkanBaseType::UNORM},
{ColorFormat::BGRA4, "BGRA4", 4,{'B','G','R','A'},{ 4, 4, 4, 4}, 16,VulkanBaseType::UNORM},
{ColorFormat::RGB565, "RGB565", 3,{'R','G','B', 0 },{ 5, 6, 5, 0}, 16,VulkanBaseType::UNORM},
{ColorFormat::A1RGB5, "A1RGB5", 4,{'A','R','G','B'},{ 1, 5, 5, 5}, 16,VulkanBaseType::UNORM},
{ColorFormat::R8, "R8", 1,{'R', 0 , 0 , 0 },{ 8, 0, 0, 0}, 8,VulkanBaseType::UNORM},
{ColorFormat::RG8, "RG8", 2,{'R','G', 0 , 0 },{ 8, 8, 0, 0}, 16,VulkanBaseType::UNORM},
{ColorFormat::RGBA8, "RGBA8", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanBaseType::UNORM},
{ColorFormat::RGBA8SN, "RGBA8S", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanBaseType::SNORM},
{ColorFormat::RGBA8U, "RGBA8U", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanBaseType::UINT},
{ColorFormat::RGBA8I, "RGBA8I", 4,{'R','G','B','A'},{ 8, 8, 8, 8}, 32,VulkanBaseType::SINT},
{ColorFormat::ABGR8, "ABGR8", 4,{'A','B','G','R'},{ 8, 8, 8, 8}, 32,VulkanBaseType::UNORM},
{ColorFormat::A2BGR10, "A2BGR10", 4,{'A','B','G','R'},{ 2,10,10,10}, 32,VulkanBaseType::UNORM},
{ColorFormat::R16, "R16", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanBaseType::UNORM},
{ColorFormat::R16U, "R16U", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanBaseType::UINT},
{ColorFormat::R16I, "R16I", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanBaseType::SINT},
{ColorFormat::R16F, "R16F", 1,{'R', 0 , 0 , 0 },{16, 0, 0, 0}, 16,VulkanBaseType::SFLOAT},
{ColorFormat::RG16, "RG16", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanBaseType::UNORM},
{ColorFormat::RG16U, "RG16U", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanBaseType::UINT},
{ColorFormat::RG16I, "RG16I", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanBaseType::SINT},
{ColorFormat::RG16F, "RG16F", 2,{'R','G', 0 , 0 },{16,16, 0, 0}, 32,VulkanBaseType::SFLOAT},
{ColorFormat::RGBA16, "RGBA16", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanBaseType::UNORM},
{ColorFormat::RGBA16SN, "RGBA16S", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanBaseType::SNORM},
{ColorFormat::RGBA16U, "RGBA16U", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanBaseType::UINT},
{ColorFormat::RGBA16I, "RGBA16I", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanBaseType::SINT},
{ColorFormat::RGBA16F, "RGBA16F", 4,{'R','G','B','A'},{16,16,16,16}, 64,VulkanBaseType::SFLOAT},
{ColorFormat::R32U, "R32U", 1,{'R', 0 , 0 , 0 },{32, 0, 0, 0}, 32,VulkanBaseType::UINT},
{ColorFormat::R32I, "R32I", 1,{'R', 0 , 0 , 0 },{32, 0, 0, 0}, 32,VulkanBaseType::SINT},
{ColorFormat::R32F, "R32F", 1,{'R', 0 , 0 , 0 },{32, 0, 0, 0}, 32,VulkanBaseType::SFLOAT},
{ColorFormat::RG32U, "RG32U", 2,{'R','G', 0 , 0 },{32,32, 0, 0}, 64,VulkanBaseType::UINT},
{ColorFormat::RG32I, "RG32I", 2,{'R','G', 0 , 0 },{32,32, 0, 0}, 64,VulkanBaseType::SINT},
{ColorFormat::RG32F, "RG32F", 2,{'R','G', 0 , 0 },{32,32, 0, 0}, 64,VulkanBaseType::SFLOAT},
{ColorFormat::RGB32U, "RGB32U", 3,{'R','G','B', 0 },{32,32,32, 0}, 96,VulkanBaseType::UINT},
{ColorFormat::RGB32I, "RGB32I", 3,{'R','G','B', 0 },{32,32,32, 0}, 96,VulkanBaseType::SINT},
{ColorFormat::RGB32F, "RGB32F", 3,{'R','G','B', 0 },{32,32,32, 0}, 96,VulkanBaseType::SFLOAT},
{ColorFormat::RGBA32U, "RGBA32U", 4,{'R','G','B','A'},{32,32,32,32},128,VulkanBaseType::UINT},
{ColorFormat::RGBA32I, "RGBA32I", 4,{'R','G','B','A'},{32,32,32,32},128,VulkanBaseType::SINT},
{ColorFormat::RGBA32F, "RGBA32F", 4,{'R','G','B','A'},{32,32,32,32},128,VulkanBaseType::SFLOAT},
{ColorFormat::B10GR11UF,"B10GR11UF",3,{'B','G','R', 0 },{10,11,11, 0}, 32,VulkanBaseType::UFLOAT},
{ColorFormat::COMPRESS, "COMPRESS", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 0,VulkanNumberType::NONE},
{ColorFormat::COMPRESS, "COMPRESS", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 0,VulkanBaseType::NONE},
{ColorFormat::BC1RGB, "BC1RGB", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 4,VulkanNumberType::NONE},
{ColorFormat::BC1RGBA, "BC1RGBA", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 4,VulkanNumberType::NONE},
{ColorFormat::BC2, "BC2", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanNumberType::NONE},
{ColorFormat::BC3, "BC3", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanNumberType::NONE},
{ColorFormat::BC4, "BC4", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 4,VulkanNumberType::NONE},
{ColorFormat::BC5, "BC5", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanNumberType::NONE},
{ColorFormat::BC6H, "BC6H", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanNumberType::NONE},
{ColorFormat::BC6H_SF, "BC6H_SF", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanNumberType::NONE},
{ColorFormat::BC7, "BC7", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanNumberType::NONE}
{ColorFormat::BC1RGB, "BC1RGB", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 4,VulkanBaseType::NONE},
{ColorFormat::BC1RGBA, "BC1RGBA", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 4,VulkanBaseType::NONE},
{ColorFormat::BC2, "BC2", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanBaseType::NONE},
{ColorFormat::BC3, "BC3", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanBaseType::NONE},
{ColorFormat::BC4, "BC4", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 4,VulkanBaseType::NONE},
{ColorFormat::BC5, "BC5", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanBaseType::NONE},
{ColorFormat::BC6H, "BC6H", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanBaseType::NONE},
{ColorFormat::BC6H_SF, "BC6H_SF", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanBaseType::NONE},
{ColorFormat::BC7, "BC7", 0,{ 0 , 0 , 0 , 0 },{ 0, 0, 0, 0}, 8,VulkanBaseType::NONE}
};
constexpr uint PixelFormatCount=sizeof(pf_list)/sizeof(PixelFormat);

View File

@ -67,7 +67,7 @@ enum class ColorFormat
struct ColorDataFormat
{
char color; //颜色成份 R/G/B/A/D等
VulkanNumberType type; //UNORM/SNORM等
VulkanBaseType type; //UNORM/SNORM等
uint8 bits; //位数
};//
@ -80,7 +80,7 @@ struct PixelFormat
char color[4];
uint8 bits[4];
uint total_bits; //每象素总位数
VulkanNumberType type;
VulkanBaseType type;
};//struct PixelFormat
const PixelFormat *GetPixelFormat(ColorFormat); ///<根据获取获取象素格式类型