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

Add astc support #433

Merged
merged 73 commits into from
Jul 29, 2021
Merged

Add astc support #433

merged 73 commits into from
Jul 29, 2021

Conversation

wasimabbas-arm
Copy link
Contributor

This is the start of astc support. First the cli options required are provided.

Since ktx-software now supports multiple encoders this patch extracts
out the common options into '--encode ' and removes redundant options.
Also add enums for astc compressor into ktx.h.

This is the start of astc support. First cli options are provided.
Since ktx-software now supports multiple encoder this patch extracts
out the common options into '--encode <encoding>' and removes redundant options.
Also adds enums for astc compressor into ktx.h.
@wasimabbas-arm
Copy link
Contributor Author

I am aware of the tabs introduced that needs fixing.

include/ktx.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
Add default options for transfer function and fix typos.
Includes build system changes, command line arguments plumbing support
Whitespace changes 'tabs->spaces'
astc compression support for 2D images including 'layers, mip-levels, cubefaces'
Multi-threaded compresssion support using pthreads and pthreads style api on windows
Copy link
Collaborator

@MarkCallow MarkCallow left a comment

Choose a reason for hiding this comment

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

Thanks. This is close. A few things need changing. Note my review comments do not include the need to add back the existing options as deprecated since we covered that in email.

CMakeLists.txt Show resolved Hide resolved
include/ktx.h Outdated Show resolved Hide resolved
tests/toktx-tests Outdated Show resolved Hide resolved
tools/toktx/toktx.cc Outdated Show resolved Hide resolved
include/ktx.h Outdated Show resolved Hide resolved
lib/astc_encode.cpp Outdated Show resolved Hide resolved
lib/astc_encode.cpp Outdated Show resolved Hide resolved
lib/astc_encode.cpp Show resolved Hide resolved
lib/astc_encode.cpp Outdated Show resolved Hide resolved
lib/astc_encode.cpp Outdated Show resolved Hide resolved
Copy link
Contributor Author

@wasimabbas-arm wasimabbas-arm left a comment

Choose a reason for hiding this comment

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

Some comments answered in c01d05d.

lib/astc_encode.cpp Show resolved Hide resolved
tests/toktx-tests Outdated Show resolved Hide resolved
utils/scapp.h Show resolved Hide resolved
utils/scapp.h Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
lib/astc_encode.cpp Outdated Show resolved Hide resolved
lib/astc_encode.cpp Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
Copy link
Contributor Author

@wasimabbas-arm wasimabbas-arm left a comment

Choose a reason for hiding this comment

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

This should to complete answering all the review comments except the following:

  1. create a prototype texture of the correct VkFormat
  2. Re-add all deprecated options

tools/toktx/toktx.cc Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Show resolved Hide resolved
tools/toktx/toktx.cc Outdated Show resolved Hide resolved
Copy link
Collaborator

@MarkCallow MarkCallow left a comment

Choose a reason for hiding this comment

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

If the wrong indentation is because of the tabs vs spaces you noted, then I apologize for the noise.

I'm having a hard time with GitHub here. It seems difficult to see just the changes since my last review and even some review comments I made before are missing.

utils/scapp.h Outdated Show resolved Hide resolved
include/ktx.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
lib/basis_encode.cpp Outdated Show resolved Hide resolved
tools/toktx/toktx.cc Outdated Show resolved Hide resolved
tools/toktx/toktx.cc Outdated Show resolved Hide resolved
tools/toktx/toktx.cc Outdated Show resolved Hide resolved
ci_scripts/build_android.sh Outdated Show resolved Hide resolved
ci_scripts/build_android_debug.sh Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
lib/astc_encode.cpp Outdated Show resolved Hide resolved
Add common '--normal_mode', common 'threadCount' option, replaced delete with free
@wasimabbas-arm
Copy link
Contributor Author

"to ASTC, transcodable ETC1S / BasisLZ or high-quality transcodable UASTC format."

EDIT: This is in the usage message for --encode. I guess I didn't select the line when I wrote the comment.

Fixed in 18af498

@wasimabbas-arm
Copy link
Contributor Author

It is still not clear if you can enter a number or only the listed strings.

EDIT: This is in the usage message for astc_quality.

So should we leave it there or you want me to implement my prosal #433 (comment)

@wasimabbas-arm
Copy link
Contributor Author

I have also extracted out the --nomal_mode option that is used by both encoders, just like threads into variable in "options". d440dd1

@wasimabbas-arm
Copy link
Contributor Author

Regarding #433 (comment) we could do one internal to KTX-Software. Not possible for astc-encoder though. There is strict requirement to be able to build all the different binaries for testing/benchmarking purposes from single configure.

@MarkCallow
Copy link
Collaborator

Regarding #433 (comment) we could do one internal to KTX-Software. Not possible for astc-encoder though. There is strict requirement to be able to build all the different binaries for testing/benchmarking purposes from single configure.

How is this possible? A CMake configure includes the target processor. Is there some sort of universal binary for ARM? Even if there is, the encoder still needs to support Intel processors.

@wasimabbas-arm
Copy link
Contributor Author

How is this possible?

The encoder cmake script has a for loop to generate different executables based on what ISA options are set from the same configure.

@MarkCallow
Copy link
Collaborator

The encoder cmake script has a for loop to generate different executables

That loop builds for each possible ISA. What are the global config options that are applied to each of these ISA builds?

What are the "native" and "none" builds?

@wasimabbas-arm
Copy link
Contributor Author

wasimabbas-arm commented Jul 26, 2021

The encoder cmake script has a for loop to generate different executables

That loop builds for each possible ISA. What are the global config options that are applied to each of these ISA builds?

What are the "native" and "none" builds?

So set(CONFIGS ${ISA_NATIVE} ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2}) and

if(${CONFIG})
     set(ISA_SIMD ${ARTEFACT})
     include(cmake_core.cmake)
endif()

Makes sure it only builds for globally set ISA options.

The native build uses -march=native compiler option which sets "default" options for the compiler. And none is just plan C/C++ code all SIMD code stripped off.

@MarkCallow
Copy link
Collaborator

So set(CONFIGS ${ISA_NATIVE} ${ISA_NONE} ${ISA_NEON} ${ISA_AVX2} ${ISA_SSE41} ${ISA_SSE2}) and

if(${CONFIG})
     set(ISA_SIMD ${ARTEFACT})
     include(cmake_core.cmake)
endif()

Makes sure it only builds for globally set ISA options.

If the global settings are only which ISAs to build for then why

There is strict requirement to be able to build all the different binaries for testing/benchmarking purposes from single configure.

? Presumably you can configure to build for a single ISA so I still don't understand what this requirement really means. Hopefully astc-encoder will be modified to do compile time detection of the ISA as we've previously discussed. In that case the only configure option should be whether to use SIMD instructions or not and this discussion will be irrevelant. Does -march=native do compile-time detection or which SIMD instructions to use?

@wasimabbas-arm
Copy link
Contributor Author

wasimabbas-arm commented Jul 27, 2021

If the global settings are only which ISAs to build for then why

There is strict requirement to be able to build all the different binaries for testing/benchmarking purposes from single configure.

? Presumably you can configure to build for a single ISA so I still don't understand what this requirement really means.

You can indeed build for a single ISA, which is how KTX-Software is using it. This requirement means the maintainer didn't want to cmake configure multiple times for multiple SIMD and non-SIMD options. Instead do cmake configure -DISA_NEON=ON -DISA_SIMD=ON -DISA_AVX=ON. This was a strict requirement when I was proposing other build system changes to make it work with ktx-software. I also proposed SIMD detection but it doesn't work when you are building multiple variants from the same configure command. Not easily anyways.
The encoder does all of this because it build different variants and runs performance tests on it in CI. Of course it can be done differently like a for loop on all SIMD variants via a shell script in the CI but the maintainer chose to use cmake loop instead.

Does -march=native do compile-time detection or which SIMD instructions to use?

I don't know much about this to be honest. This is just another option that the encoder tests against. IIRC I think clang doesn't support native but I didn't bother testing that. We don't use it in ktx-software. The GCC docs says

‘native’

    This selects the CPU to generate code for at compilation time by determining the processor type of the compiling machine. Using -march=native enables all instruction subsets supported by the local machine (hence the result might not run on different machines). Using -mtune=native produces code optimized for the local machine under the constraints of the selected instruction set.

Also not sure where this conversation is going. We have previously decide to leave this where it is. Unfortunately I don't maintain the encoder and I have same push back when I try to propose changes there. Its something thats used by other clients as well and maintaining backwards compatibility is important. As I have already proposed quite a few changes to the build system to make it work with ktx-software. Some like detect SIMD didn't go well. Either way I think for this PR thats kind of out of scope. We have a way to use its provided options to make it work with ktx-software. I think we should leave it there for the first version.

Copy link
Collaborator

@MarkCallow MarkCallow left a comment

Choose a reason for hiding this comment

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

Please answer the various questions and make the small changes requested. They're mostly minor but I did find one bug.

Where are the readers for the .hdr and .exr formats? Are they going to be in a subsequent PR? I'm planning to try using Open ImageIO which supports both of these, but I have so much else to do it will be a while before I can get to it.

CMakeLists.txt Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
utils/scapp.h Outdated Show resolved Hide resolved
lib/basis_encode.cpp Show resolved Hide resolved
tools/toktx/toktx.cc Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
lib/astc_encode.cpp Show resolved Hide resolved
@MarkCallow
Copy link
Collaborator

You can indeed build for a single ISA, which is how KTX-Software is using it. This requirement means the maintainer didn't want to cmake configure multiple times for multiple SIMD and non-SIMD options. Instead do cmake configure -DISA_NEON=ON -DISA_SIMD=ON -DISA_AVX=ON.

Got it. Makes perfect sense.

I also proposed SIMD detection but it doesn't work when you are building multiple variants from the same configure command. Not easily anyways.

Why not? The configure command would pick which compilers and targets to use. The SIMD detection can be completely unaware of this. It just looks at whatever pre-defined macros it is presented with.

Does -march=native do compile-time detection or which SIMD instructions to use?

...

‘native’

    This selects the CPU to generate code for at compilation time by determining the processor type of the compiling machine. Using -march=native enables all instruction subsets supported by the local machine (hence the result might not run on different machines). Using -mtune=native produces code optimized for the local machine under the constraints of the selected instruction set.

It sounds like it would be up to the code being compiled to decide whether to invoke SIMD or not.

Also not sure where this conversation is going. We have previously decide to leave this where it is. Unfortunately I don't maintain the encoder and I have same push back when I try to propose changes there. Its something thats used by other clients as well and maintaining backwards compatibility is important. As I have already proposed quite a few changes to the build system to make it work with ktx-software. Some like detect SIMD didn't go well. Either way I think for this PR thats kind of out of scope. We have a way to use its provided options to make it work with ktx-software. I think we should leave it there for the first version.

I agree for the first version we should leave it there. I fully understand the need for compatibility with other encoder clients. I was hoping compile-time detection would simplify things for everybody and we could investigate more deeply for a future version.

@MarkCallow MarkCallow merged commit da435de into KhronosGroup:master Jul 29, 2021
@wasimabbas-arm wasimabbas-arm deleted the astc_support branch July 30, 2021 14:13
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 21, 2024
This is the start of astc support using `lib/astc-encoder`, a `git subrepo` clone of ARM's ASTC encoder. 

Since ktx-software now supports multiple encoders this patch extracts
out the common options into '--encode <encoding>' and removes redundant options.
Also adds enums for astc compressor into ktx.h.

Similarly the `--threads` option has been moved from the BasisU options to the
common options so it can be used for any encoder.

The `--bcmp` option has been renamed to `--etc1s` to reflect its actual use.

A common '--normal_mode' option has been added replacing the ETC1S encoder's `--normal_map`.
The new option is recognized by the ASTC and ETC1S encoders.

A very useful feature of uploading the output files of broken toktx-tests to a cloud storage service has been added to `.travis.yml`.
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
This is the start of astc support using `lib/astc-encoder`, a `git subrepo` clone of ARM's ASTC encoder. 

Since ktx-software now supports multiple encoders this patch extracts
out the common options into '--encode <encoding>' and removes redundant options.
Also adds enums for astc compressor into ktx.h.

Similarly the `--threads` option has been moved from the BasisU options to the
common options so it can be used for any encoder.

The `--bcmp` option has been renamed to `--etc1s` to reflect its actual use.

A common '--normal_mode' option has been added replacing the ETC1S encoder's `--normal_map`.
The new option is recognized by the ASTC and ETC1S encoders.

A very useful feature of uploading the output files of broken toktx-tests to a cloud storage service has been added to `.travis.yml`.
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
This is the start of astc support using `lib/astc-encoder`, a `git subrepo` clone of ARM's ASTC encoder. 

Since ktx-software now supports multiple encoders this patch extracts
out the common options into '--encode <encoding>' and removes redundant options.
Also adds enums for astc compressor into ktx.h.

Similarly the `--threads` option has been moved from the BasisU options to the
common options so it can be used for any encoder.

The `--bcmp` option has been renamed to `--etc1s` to reflect its actual use.

A common '--normal_mode' option has been added replacing the ETC1S encoder's `--normal_map`.
The new option is recognized by the ASTC and ETC1S encoders.

A very useful feature of uploading the output files of broken toktx-tests to a cloud storage service has been added to `.travis.yml`.
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
This is the start of astc support using `lib/astc-encoder`, a `git subrepo` clone of ARM's ASTC encoder. 

Since ktx-software now supports multiple encoders this patch extracts
out the common options into '--encode <encoding>' and removes redundant options.
Also adds enums for astc compressor into ktx.h.

Similarly the `--threads` option has been moved from the BasisU options to the
common options so it can be used for any encoder.

The `--bcmp` option has been renamed to `--etc1s` to reflect its actual use.

A common '--normal_mode' option has been added replacing the ETC1S encoder's `--normal_map`.
The new option is recognized by the ASTC and ETC1S encoders.

A very useful feature of uploading the output files of broken toktx-tests to a cloud storage service has been added to `.travis.yml`.
KaperD pushed a commit to KaperD/KTX-Software that referenced this pull request Feb 22, 2024
This is the start of astc support using `lib/astc-encoder`, a `git subrepo` clone of ARM's ASTC encoder. 

Since ktx-software now supports multiple encoders this patch extracts
out the common options into '--encode <encoding>' and removes redundant options.
Also adds enums for astc compressor into ktx.h.

Similarly the `--threads` option has been moved from the BasisU options to the
common options so it can be used for any encoder.

The `--bcmp` option has been renamed to `--etc1s` to reflect its actual use.

A common '--normal_mode' option has been added replacing the ETC1S encoder's `--normal_map`.
The new option is recognized by the ASTC and ETC1S encoders.

A very useful feature of uploading the output files of broken toktx-tests to a cloud storage service has been added to `.travis.yml`.
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.

3 participants