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

Added support for bc6h format #14

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

theKlaxon
Copy link

  • Added bc6h compression function.
  • Added bc6h to all enums + lists.
  • Updated Compressonator to 4.5.52 for proper bc6h support.

- Added bc6h compression function.
- Added bc6h to all enums + lists.
- Updated Compressonator to 4.5.52 for proper bc6h support.
@craftablescience
Copy link
Member

The prebuilt static library for Linux will need to be updated as well, I have builds of the latest version at https://github.com/craftablescience/compressonator-compiler/releases/tag/v4.5-f4b53d7-2 if you need it

@theKlaxon
Copy link
Author

You got it, I'll make the change!

@SCell555
Copy link
Member

Just to note, IMAGE_FORMAT_BC6H is signed BC6H.

Copy link
Member

@JJL772 JJL772 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this work! I have a couple small comments/questions.

@@ -95,6 +95,7 @@ typedef enum tagVTFImageFormat
IMAGE_FORMAT_ATI2N, //!< = Red, Green BC5 compressed format - 8 bpp
IMAGE_FORMAT_ATI1N, //!< = Red BC4 compressed format - 4 bpp

IMAGE_FORMAT_BC6H = 69, //!< = Red, Green, Blue, BC6H compressed format - 8 bpp
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMAGE_FORMAT_BC6H should be 71

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, I'll change the rest of the enums / lists to reflect that also.

@@ -3556,7 +3629,7 @@ static SVTFImageConvertInfo VTFImageConvertInfo[IMAGE_FORMAT_COUNT] =
{},
{},
{},
{},
{ 8, 0, 0, 0, 0, 0, -1, -1, -1, -1, vlTrue, vlTrue, NULL, NULL, IMAGE_FORMAT_BC6H},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to get moved to after IMAGE_FORMAT_BC7 when you update the enum (see the later comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -3031,7 +3032,7 @@ static SVTFImageFormatInfo VTFImageFormatInfo[] =
{},
{},
{},
{},
{ "BC6H", 8, 0, 0, 0, 0, 0, vlTrue, vlTrue }, // IMAGE_FORMAT_BC6H
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will need to get moved to after IMAGE_FORMAT_BC7 when you update the enum (see the later comment)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

srcTexture.dwWidth = uiWidth;
srcTexture.dwHeight = uiHeight;
srcTexture.dwPitch = 4 * uiWidth;
srcTexture.format = CMP_FORMAT_RGBA_8888;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the input to this function always assumed to be RGBA8888?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah, it was while i was testing things out. ill go ahead and add the SourceFormat param back to make sure an edge case isn't hit.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My issue with this code is less about assuming lpSource is always RGBA8888 and more about the potential data loss. If textures are getting squished down to RGBA8888 before being turned into BC6H, what's the point of using BC6H at all

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still blocking merge, basically what JJ said

@theKlaxon
Copy link
Author

Just to note, IMAGE_FORMAT_BC6H is signed BC6H.

Would you like me to note it at the end of the format as IMAGE_FORMAT_BC6H_SF ?

@SCell555
Copy link
Member

SCell555 commented Aug 21, 2024

No, since there won't be an unsigned version. And we don't need to be weird with format naming like compressonator.

@theKlaxon
Copy link
Author

Alright, I'll at least add a note that it's signed in the format note in the code.

- Moved BC6H format to 71
- Fixed incorrect dwDataSize given to midTexture in VTFFile.cpp
- Updated CMakeLists.txt to reflect new dependencies.
CMakeLists.txt Outdated Show resolved Hide resolved
CMakeLists.txt Outdated Show resolved Hide resolved
theKlaxon and others added 4 commits August 22, 2024 20:17
Co-authored-by: craftablescience <lauralewisdev@gmail.com>
Co-authored-by: craftablescience <lauralewisdev@gmail.com>
Copy link
Member

@craftablescience craftablescience left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mostly just have a few nitpicks, once JJ's comment and pthread stuff gets resolved this is good for merge

CMP_Core_AVX
CMP_Core_AVX512
CMP_Core_SSE
pthread
Copy link
Member

@craftablescience craftablescience Sep 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use cmake's Threads::Threads target instead of pthread

from stackoverflow:

set(CMAKE_THREAD_PREFER_PTHREAD ON)
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)

add_executable(test test.cpp)
target_link_libraries(test Threads::Threads)

also, is this actually required? i cant remember any vtflib code that uses pthreads or any threading stuff in std

CMP_Core_AVX
CMP_Core_AVX512
CMP_Core_SSE
pthread
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@@ -440,6 +440,7 @@ static CMP_FORMAT GetCMPFormat( VTFImageFormat imageFormat, bool bDXT5GA )
// Swizzle is technically wrong for below but we reverse it in the shader!
case IMAGE_FORMAT_ATI2N: return CMP_FORMAT_ATI2N;

case IMAGE_FORMAT_BC6H: return CMP_FORMAT_BC6H;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should come after BC7

@@ -3066,6 +3068,7 @@ vlUInt CVTFFile::ComputeImageSize(vlUInt uiWidth, vlUInt uiHeight, vlUInt uiDept
case IMAGE_FORMAT_DXT3:
case IMAGE_FORMAT_DXT5:
case IMAGE_FORMAT_ATI2N:
case IMAGE_FORMAT_BC6H:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be after BC7

srcTexture.dwWidth = uiWidth;
srcTexture.dwHeight = uiHeight;
srcTexture.dwPitch = 4 * uiWidth;
srcTexture.format = CMP_FORMAT_RGBA_8888;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is still blocking merge, basically what JJ said

@@ -3857,6 +3932,7 @@ vlBool CVTFFile::Convert(const vlByte *lpSource, vlByte *lpDest, vlUInt uiWidth,
case IMAGE_FORMAT_DXT5:
case IMAGE_FORMAT_ATI2N:
case IMAGE_FORMAT_ATI1N:
case IMAGE_FORMAT_BC6H:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should be below.. yeah you get the idea

@@ -94,8 +94,9 @@ typedef enum tagVTFImageFormat

IMAGE_FORMAT_ATI2N, //!< = Red, Green BC5 compressed format - 8 bpp
IMAGE_FORMAT_ATI1N, //!< = Red BC4 compressed format - 4 bpp

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: extra space

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants