CMake: split out atsc-encoder into its own CMakeLists
Also remove dependency of third_party/astc-encoder on
src/System/Debug.hpp.
Bug: b/145758253
Change-Id: I329928d9221c99a416fcdb1b0dd44d2578a22cb8
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43269
Reviewed-by: Ben Clayton <bclayton@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
Kokoro-Presubmit: kokoro <noreply+kokoro@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5593fa4..f309bbc 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -311,7 +311,6 @@
set(OPENGL_COMPILER_DIR ${OPENGL_DIR}/compiler)
set(VULKAN_DIR ${SOURCE_DIR}/Vulkan)
set(THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
-set(ASTC_DIR ${THIRD_PARTY_DIR}/astc-encoder)
set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
set(HELLO2_DIR ${THIRD_PARTY_DIR}/PowerVR_SDK/Examples/Beginner/01_HelloAPI/OGLES2)
@@ -600,7 +599,6 @@
add_subdirectory(third_party/marl)
endif()
-
###########################################################
# cppdap
###########################################################
@@ -609,6 +607,12 @@
add_subdirectory(third_party/cppdap)
endif()
+###########################################################
+# astc-encoder
+###########################################################
+if(SWIFTSHADER_ENABLE_ASTC)
+ add_subdirectory(third_party/astc-encoder)
+endif()
###########################################################
# Include Directories
@@ -753,15 +757,6 @@
list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_VK_DEBUGGER")
endif()
-if(SWIFTSHADER_ENABLE_ASTC)
- file(GLOB_RECURSE VULKAN_ASTC_LIST
- ${ASTC_DIR}/Source/*.cpp
- ${ASTC_DIR}/Source/*.h
- )
- list(APPEND VULKAN_LIST ${VULKAN_ASTC_LIST})
- list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DSWIFTSHADER_ENABLE_ASTC")
-endif()
-
if(LINUX OR ANDROID)
list(APPEND VULKAN_LIST
${SOURCE_DIR}/System/Linux/MemFd.cpp
@@ -1050,6 +1045,9 @@
if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
list(APPEND VK_SWIFTSHADER_LIBS cppdap)
endif()
+ if(SWIFTSHADER_ENABLE_ASTC)
+ list(APPEND VK_SWIFTSHADER_LIBS astc-encoder)
+ endif()
target_link_libraries(vk_swiftshader ${VK_SWIFTSHADER_LIBS})
add_custom_command(
diff --git a/src/Device/ASTC_Decoder.cpp b/src/Device/ASTC_Decoder.cpp
index aef8795..7a289ad 100644
--- a/src/Device/ASTC_Decoder.cpp
+++ b/src/Device/ASTC_Decoder.cpp
@@ -17,7 +17,7 @@
#include "System/Math.hpp"
#ifdef SWIFTSHADER_ENABLE_ASTC
-# include "../third_party/astc-encoder/Source/astc_codec_internals.h"
+# include "astc_codec_internals.h"
#endif
#include <memory>
diff --git a/third_party/astc-encoder/CMakeLists.txt b/third_party/astc-encoder/CMakeLists.txt
new file mode 100644
index 0000000..300c08c
--- /dev/null
+++ b/third_party/astc-encoder/CMakeLists.txt
@@ -0,0 +1,60 @@
+# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set(ROOT_PROJECT_COMPILE_OPTIONS
+ ${SWIFTSHADER_COMPILE_OPTIONS}
+ ${WARNINGS_AS_ERRORS}
+)
+
+set(ASTC_ENCODER_SRC_FILES
+ Source/astc_block_sizes2.cpp
+ Source/astc_codec_internals.h
+ Source/astc_color_unquantize.cpp
+ Source/astc_decompress_symbolic.cpp
+ Source/astc_image_load_store.cpp
+ Source/astc_integer_sequence.cpp
+ Source/astc_mathlib.cpp
+ Source/astc_mathlib.h
+ Source/astc_mathlib_softfloat.cpp
+ Source/astc_partition_tables.cpp
+ Source/astc_percentile_tables.cpp
+ Source/astc_quantization.cpp
+ Source/astc_symbolic_physical.cpp
+ Source/astc_weight_quant_xfer_tables.cpp
+)
+
+add_library(astc-encoder STATIC EXCLUDE_FROM_ALL
+ ${ASTC_ENCODER_SRC_FILES}
+)
+
+set_target_properties(astc-encoder PROPERTIES
+ POSITION_INDEPENDENT_CODE 1
+ FOLDER "Core"
+)
+
+target_include_directories(astc-encoder
+ PUBLIC
+ "Source"
+)
+
+target_compile_definitions(astc-encoder
+ PUBLIC
+ # TODO: Remove SWIFTSHADER from the name
+ "SWIFTSHADER_ENABLE_ASTC"
+)
+
+target_compile_options(astc-encoder
+ PUBLIC
+ ${ROOT_PROJECT_COMPILE_OPTIONS}
+)
diff --git a/third_party/astc-encoder/Source/astc_color_unquantize.cpp b/third_party/astc-encoder/Source/astc_color_unquantize.cpp
index b510cef..32940ab 100644
--- a/third_party/astc-encoder/Source/astc_color_unquantize.cpp
+++ b/third_party/astc-encoder/Source/astc_color_unquantize.cpp
@@ -20,7 +20,8 @@
*/
#include "astc_codec_internals.h"
-#include "System/Debug.hpp"
+
+#include <cassert>
static int rgb_delta_unpack(
const int input[6],
@@ -907,7 +908,8 @@
break;
default:
- UNREACHABLE("endpoint_format %d", int(format));
+ assert(false && "Unreachable");
+ break;
}
if (*alpha_hdr == -1)