modifications for v2.5
diff --git a/encoder/3rdparty/tinydds.h b/encoder/3rdparty/tinydds.h index 6b4712a..829c56b 100644 --- a/encoder/3rdparty/tinydds.h +++ b/encoder/3rdparty/tinydds.h
@@ -1368,27 +1368,51 @@ return false; } - // correct for dodgy mipmap levels counts + // rg: The original tinydds mipmap-count "correction" below is WRONG and is + // disabled. For COMPRESSED formats it stopped counting at the 4x4 block size + // (w <= 4 || h <= 4) and truncated mipMapCount there, which drops the perfectly + // valid sub-block mip levels (e.g. 2x2 and 1x1) -- those levels are legal and are + // simply stored padded to a single 4x4 block. ANY DDS file, block-compressed or + // uncompressed, can carry a full mip chain down to 1x1. + // + // Original (incorrect) code: + // + // if(ctx->header.mipMapCount > 1) { + // uint32_t w = ctx->header.width; + // uint32_t h = ctx->header.height; + // + // for(uint32_t i = 0; i < ctx->header.mipMapCount;++i) { + // if (TinyDDS_IsCompressed(ctx->format)) { + // if (w <= 4 || h <= 4) { + // ctx->header.mipMapCount = i + 1; + // break; + // } + // } else if (w <= 1 || h <= 1) { + // ctx->header.mipMapCount = i + 1; + // break; + // } + // + // w = w / 2; + // h = h / 2; + // } + // } + // + // Replacement: count the true maximum number of mip levels for these dimensions + // (halving each axis down to 1x1, for every format) and clamp the header's count + // to it ONLY if the file claims MORE levels than are dimensionally possible. if(ctx->header.mipMapCount > 1) { uint32_t w = ctx->header.width; uint32_t h = ctx->header.height; - for(uint32_t i = 0; i < ctx->header.mipMapCount;++i) { - if (TinyDDS_IsCompressed(ctx->format)) { - if (w <= 4 || h <= 4) { - ctx->header.mipMapCount = i + 1; - break; - } - } else if (w <= 1 || h <= 1) { - ctx->header.mipMapCount = i + 1; - break; - } - - - w = w / 2; - h = h / 2; + uint32_t maxMipMapCount = 1; + while ((w > 1) || (h > 1)) { + w = (w > 1) ? (w >> 1) : 1; + h = (h > 1) ? (h >> 1) : 1; + maxMipMapCount++; } + if (ctx->header.mipMapCount > maxMipMapCount) + ctx->header.mipMapCount = maxMipMapCount; } if (TinyDDS_IsCompressed(ctx->format)) {
diff --git a/encoder_lib/encoder_lib.vcxproj b/encoder_lib/encoder_lib.vcxproj index 9d4c1b9..19a67ec 100644 --- a/encoder_lib/encoder_lib.vcxproj +++ b/encoder_lib/encoder_lib.vcxproj
@@ -32,12 +32,16 @@ <ClCompile Include="..\encoder\basisu_astc_hdr_common.cpp" /> <ClCompile Include="..\encoder\basisu_astc_ldr_common.cpp" /> <ClCompile Include="..\encoder\basisu_astc_ldr_encode.cpp" /> + <ClCompile Include="..\encoder\basisu_xbc7_encode.cpp" /> + <ClCompile Include="..\encoder\basisu_astc_ldr_fencode.cpp" /> <ClCompile Include="..\encoder\basisu_tinyexr.cpp" /> <ClCompile Include="..\encoder\basisu_uastc_hdr_4x4_enc.cpp" /> <ClCompile Include="..\encoder\basisu_backend.cpp" /> <ClCompile Include="..\encoder\basisu_basis_file.cpp" /> <ClCompile Include="..\encoder\basisu_bc7enc.cpp" /> <ClCompile Include="..\encoder\basisu_comp.cpp" /> + <ClCompile Include="..\encoder\basisu_bc15_spmd.cpp" /> + <ClCompile Include="..\encoder\basisu_bc15_spmd_sse.cpp" /> <ClCompile Include="..\encoder\basisu_enc.cpp" /> <ClCompile Include="..\encoder\basisu_etc.cpp" /> <ClCompile Include="..\encoder\basisu_frontend.cpp" /> @@ -49,6 +53,8 @@ <ClCompile Include="..\encoder\basisu_resample_filters.cpp" /> <ClCompile Include="..\encoder\basisu_ssim.cpp" /> <ClCompile Include="..\encoder\basisu_uastc_enc.cpp" /> + <ClCompile Include="..\encoder\basisu_bc7e_scalar.cpp" /> + <ClCompile Include="..\encoder\basisu_dds_export.cpp" /> <ClCompile Include="..\encoder\jpgd.cpp" /> <ClCompile Include="..\encoder\pvpngreader.cpp" /> <ClCompile Include="..\transcoder\basisu_transcoder.cpp" /> @@ -62,9 +68,13 @@ <ClInclude Include="..\encoder\basisu_astc_hdr_common.h" /> <ClInclude Include="..\encoder\basisu_astc_ldr_common.h" /> <ClInclude Include="..\encoder\basisu_astc_ldr_encode.h" /> + <ClInclude Include="..\encoder\basisu_xbc7_encode.h" /> + <ClInclude Include="..\encoder\basisu_astc_ldr_fencode.h" /> <ClInclude Include="..\encoder\basisu_uastc_hdr_4x4_enc.h" /> <ClInclude Include="..\encoder\basisu_backend.h" /> <ClInclude Include="..\encoder\basisu_basis_file.h" /> + <ClInclude Include="..\encoder\basisu_bc15_spmd.h" /> + <ClInclude Include="..\encoder\basisu_bc15_spmd_kernels.inl" /> <ClInclude Include="..\encoder\basisu_bc7enc.h" /> <ClInclude Include="..\encoder\basisu_comp.h" /> <ClInclude Include="..\encoder\basisu_enc.h" /> @@ -82,6 +92,8 @@ <ClInclude Include="..\encoder\basisu_resampler_filters.h" /> <ClInclude Include="..\encoder\basisu_ssim.h" /> <ClInclude Include="..\encoder\basisu_uastc_enc.h" /> + <ClInclude Include="..\encoder\basisu_bc7e_scalar.h" /> + <ClInclude Include="..\encoder\basisu_dds_export.h" /> <ClInclude Include="..\encoder\cppspmd_flow.h" /> <ClInclude Include="..\encoder\cppspmd_math.h" /> <ClInclude Include="..\encoder\cppspmd_math_declares.h" /> @@ -99,6 +111,7 @@ <ClInclude Include="..\transcoder\basisu_transcoder.h" /> <ClInclude Include="..\transcoder\basisu_transcoder_internal.h" /> <ClInclude Include="..\transcoder\basisu_transcoder_uastc.h" /> + <ClInclude Include="..\transcoder\basisu_xbc7_decoder.h" /> </ItemGroup> <ItemGroup> <None Include="..\bin\ocl_kernels.cl" /> @@ -111,6 +124,8 @@ <None Include="..\transcoder\basisu_transcoder_tables_bc7_m5_color.inc" /> <None Include="..\transcoder\basisu_transcoder_tables_dxt1_5.inc" /> <None Include="..\transcoder\basisu_transcoder_tables_dxt1_6.inc" /> + <None Include="..\transcoder\basisu_xbc7_decoder.inl" /> + <None Include="..\transcoder\basisu_dds_transcoder.inl" /> </ItemGroup> <PropertyGroup Label="Globals"> <VCProjectVersion>17.0</VCProjectVersion> @@ -228,7 +243,7 @@ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> <SDLCheck>false</SDLCheck> - <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=1;BASISU_SUPPORT_OPENCL=1;</PreprocessorDefinitions> + <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=1;BASISU_SUPPORT_OPENCL=1;_HAS_EXCEPTIONS=0</PreprocessorDefinitions> <ConformanceMode>true</ConformanceMode> <PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> @@ -246,7 +261,7 @@ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|ARM64EC'"> <ClCompile> <SDLCheck>false</SDLCheck> - <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=0;BASISU_SUPPORT_OPENCL=1;</PreprocessorDefinitions> + <PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=0;BASISU_SUPPORT_OPENCL=1;_HAS_EXCEPTIONS=0</PreprocessorDefinitions> <ConformanceMode>true</ConformanceMode> <PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> @@ -266,7 +281,7 @@ <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <SDLCheck>false</SDLCheck> - <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=1;BASISU_SUPPORT_OPENCL=1;</PreprocessorDefinitions> + <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=1;BASISU_SUPPORT_OPENCL=1;_HAS_EXCEPTIONS=0</PreprocessorDefinitions> <ConformanceMode>true</ConformanceMode> <PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile> @@ -294,7 +309,7 @@ <FunctionLevelLinking>true</FunctionLevelLinking> <IntrinsicFunctions>true</IntrinsicFunctions> <SDLCheck>false</SDLCheck> - <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=0;BASISU_SUPPORT_OPENCL=1;</PreprocessorDefinitions> + <PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions);BASISU_SUPPORT_SSE=0;BASISU_SUPPORT_OPENCL=1;_HAS_EXCEPTIONS=0</PreprocessorDefinitions> <ConformanceMode>true</ConformanceMode> <PrecompiledHeader>NotUsing</PrecompiledHeader> <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
diff --git a/encoder_lib/encoder_lib.vcxproj.filters b/encoder_lib/encoder_lib.vcxproj.filters index 8d0ad48..fc2a011 100644 --- a/encoder_lib/encoder_lib.vcxproj.filters +++ b/encoder_lib/encoder_lib.vcxproj.filters
@@ -45,6 +45,12 @@ <ClCompile Include="..\encoder\basisu_comp.cpp"> <Filter>Source Files\encoder</Filter> </ClCompile> + <ClCompile Include="..\encoder\basisu_bc15_spmd.cpp"> + <Filter>Source Files\encoder</Filter> + </ClCompile> + <ClCompile Include="..\encoder\basisu_bc15_spmd_sse.cpp"> + <Filter>Source Files\encoder</Filter> + </ClCompile> <ClCompile Include="..\encoder\basisu_enc.cpp"> <Filter>Source Files\encoder</Filter> </ClCompile> @@ -78,6 +84,12 @@ <ClCompile Include="..\encoder\basisu_uastc_enc.cpp"> <Filter>Source Files\encoder</Filter> </ClCompile> + <ClCompile Include="..\encoder\basisu_bc7e_scalar.cpp"> + <Filter>Source Files\encoder</Filter> + </ClCompile> + <ClCompile Include="..\encoder\basisu_dds_export.cpp"> + <Filter>Source Files\encoder</Filter> + </ClCompile> <ClCompile Include="..\encoder\jpgd.cpp"> <Filter>Source Files\encoder</Filter> </ClCompile> @@ -102,9 +114,15 @@ <ClCompile Include="..\encoder\basisu_astc_ldr_encode.cpp"> <Filter>Source Files\encoder</Filter> </ClCompile> + <ClCompile Include="..\encoder\basisu_xbc7_encode.cpp"> + <Filter>Source Files\encoder</Filter> + </ClCompile> <ClCompile Include="..\encoder\basisu_tinyexr.cpp"> <Filter>Source Files\encoder</Filter> </ClCompile> + <ClCompile Include="..\encoder\basisu_astc_ldr_fencode.cpp"> + <Filter>Source Files\encoder</Filter> + </ClCompile> </ItemGroup> <ItemGroup> <ClInclude Include="..\transcoder\basisu_astc_helpers.h"> @@ -158,6 +176,12 @@ <ClInclude Include="..\encoder\basisu_basis_file.h"> <Filter>Source Files\encoder</Filter> </ClInclude> + <ClInclude Include="..\encoder\basisu_bc15_spmd.h"> + <Filter>Source Files\encoder</Filter> + </ClInclude> + <ClInclude Include="..\encoder\basisu_bc15_spmd_kernels.inl"> + <Filter>Source Files\encoder</Filter> + </ClInclude> <ClInclude Include="..\encoder\basisu_bc7enc.h"> <Filter>Source Files\encoder</Filter> </ClInclude> @@ -206,6 +230,12 @@ <ClInclude Include="..\encoder\basisu_uastc_enc.h"> <Filter>Source Files\encoder</Filter> </ClInclude> + <ClInclude Include="..\encoder\basisu_bc7e_scalar.h"> + <Filter>Source Files\encoder</Filter> + </ClInclude> + <ClInclude Include="..\encoder\basisu_dds_export.h"> + <Filter>Source Files\encoder</Filter> + </ClInclude> <ClInclude Include="..\encoder\jpgd.h"> <Filter>Source Files\encoder</Filter> </ClInclude> @@ -236,9 +266,18 @@ <ClInclude Include="..\encoder\basisu_astc_ldr_encode.h"> <Filter>Source Files\encoder</Filter> </ClInclude> + <ClInclude Include="..\encoder\basisu_xbc7_encode.h"> + <Filter>Source Files\encoder</Filter> + </ClInclude> <ClInclude Include="..\transcoder\basisu_idct.h"> <Filter>Source Files\transcoder</Filter> </ClInclude> + <ClInclude Include="..\encoder\basisu_astc_ldr_fencode.h"> + <Filter>Source Files\encoder</Filter> + </ClInclude> + <ClInclude Include="..\transcoder\basisu_xbc7_decoder.h"> + <Filter>Source Files\transcoder</Filter> + </ClInclude> </ItemGroup> <ItemGroup> <None Include="..\transcoder\basisu_transcoder_tables_astc.inc"> @@ -271,5 +310,11 @@ <None Include="..\transcoder\basisu_astc_cfgs.inl"> <Filter>Source Files\transcoder</Filter> </None> + <None Include="..\transcoder\basisu_xbc7_decoder.inl"> + <Filter>Source Files\transcoder</Filter> + </None> + <None Include="..\transcoder\basisu_dds_transcoder.inl"> + <Filter>Source Files\transcoder</Filter> + </None> </ItemGroup> </Project> \ No newline at end of file