update uint2float convert

This commit is contained in:
hyzboy 2019-09-05 20:49:53 +08:00
parent c691fce56b
commit fd02d2f4ee
2 changed files with 8 additions and 7 deletions

View File

@ -109,8 +109,11 @@ namespace
}
template<typename T,typename S>
void UInteger2Float(T *tar,S *src,uint size,const T max_value)
void UInteger2Float(void *ptr,uint size,const T max_value)
{
T *tar=(T *)ptr;
S *src=(S *)ptr;
for(uint i=0;i<size;i++)
*tar++=T(*src++)/max_value;
}
@ -240,7 +243,7 @@ Texture2D *LoadTGATexture(const OSString &filename,Device *device)
fis->Read(pixel_data,total_bytes);
if(header.image_type==tga::ImageType::Grayscale&&header.bit==32)
UInteger2Float<float,uint32>((float *)pixel_data,(uint32 *)pixel_data,pixel_count,(float)HGL_U32_MAX);
UInteger2Float<float,uint32>(pixel_data,pixel_count,(float)HGL_U32_MAX);
if(image_desc.vertical_direction==tga::VerticalDirection::BottomToTop)
SwapRow((uint8 *)pixel_data,line_bytes,header.height);

View File

@ -174,9 +174,9 @@ namespace
const VulkanFormat *vulkan_yuv_format_list=vulkan_color_format_list+FMT_RANGE_SIZE;
const VulkanFormat *vulkan_pvrtc_format_list=vulkan_color_format_list+FMT_RANGE_SIZE+FMT_YUV_RANGE_SIZE;
#ifdef _DEBUG
constexpr size_t TEXTURE_FORMAT_COUNT=sizeof(vulkan_color_format_list)/sizeof(VulkanFormat);
#ifdef _DEBUG
uint32_t GetStrideBytesByFormat(const VkFormat &format)
{
if(format<=VK_FORMAT_UNDEFINED)
@ -225,8 +225,6 @@ namespace
return(0);
}
#else
constexpr uint32_t STRIDE_FORMAT_COUNT=sizeof(stride_list)/sizeof(uint32);
#endif//_DEBUG
}//namespace