-
Notifications
You must be signed in to change notification settings - Fork 5
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
base: master
Are you sure you want to change the base?
Conversation
theKlaxon
commented
Aug 20, 2024
- 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.
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 |
You got it, I'll make the change! |
Just to note, IMAGE_FORMAT_BC6H is signed BC6H. |
There was a problem hiding this 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.
VTFLib/VTFFormat.h
Outdated
@@ -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 |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
VTFLib/VTFFile.cpp
Outdated
@@ -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}, |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
✔
VTFLib/VTFFile.cpp
Outdated
@@ -3031,7 +3032,7 @@ static SVTFImageFormatInfo VTFImageFormatInfo[] = | |||
{}, | |||
{}, | |||
{}, | |||
{}, | |||
{ "BC6H", 8, 0, 0, 0, 0, 0, vlTrue, vlTrue }, // IMAGE_FORMAT_BC6H |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
Would you like me to note it at the end of the format as IMAGE_FORMAT_BC6H_SF ? |
No, since there won't be an unsigned version. And we don't need to be weird with format naming like compressonator. |
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.
Co-authored-by: craftablescience <lauralewisdev@gmail.com>
Co-authored-by: craftablescience <lauralewisdev@gmail.com>
There was a problem hiding this 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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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 | |||
|
|||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: extra space