Enable ASTC on supported builds only
To temporarily work around build issues related to Google3 integration,
make ASTC support optional and only enable it for CMake, Chromium, and
Android builds.
Bug: b/150600814
Change-Id: Iac6a404322c65a6f2727807ea8af2edfb219a5a2
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/41828
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Sean Risser <srisser@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Android.bp b/src/Android.bp
index a400a4c..2f8683a 100644
--- a/src/Android.bp
+++ b/src/Android.bp
@@ -617,6 +617,7 @@
cflags: [
"-DLOG_TAG=\"swiftshader\"",
"-DSWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER",
+ "-DSWIFTSHADER_ENABLE_ASTC", // TODO(b/150130101)
],
srcs: [
diff --git a/src/Device/ASTC_Decoder.cpp b/src/Device/ASTC_Decoder.cpp
index 344988d..aef8795 100644
--- a/src/Device/ASTC_Decoder.cpp
+++ b/src/Device/ASTC_Decoder.cpp
@@ -13,14 +13,19 @@
// limitations under the License.
#include "ASTC_Decoder.hpp"
-#include "../third_party/astc-encoder/Source/astc_codec_internals.h"
+
#include "System/Math.hpp"
+#ifdef SWIFTSHADER_ENABLE_ASTC
+# include "../third_party/astc-encoder/Source/astc_codec_internals.h"
+#endif
+
#include <memory>
#include <unordered_map>
namespace {
+#ifdef SWIFTSHADER_ENABLE_ASTC
void write_imageblock(unsigned char *img,
// picture-block to initialize with image data. We assume that orig_data is valid
const imageblock *pb,
@@ -91,6 +96,7 @@
}
}
}
+#endif
} // namespace
@@ -100,6 +106,7 @@
int xBlockSize, int yBlockSize, int zBlockSize,
int xblocks, int yblocks, int zblocks, bool isUnsignedByte)
{
+#ifdef SWIFTSHADER_ENABLE_ASTC
build_quantization_mode_table();
astc_decode_mode decode_mode = isUnsignedByte ? DECODE_LDR : DECODE_HDR;
@@ -124,4 +131,5 @@
}
term_block_size_descriptor(bsd.get());
+#endif
}
diff --git a/src/Vulkan/BUILD.gn b/src/Vulkan/BUILD.gn
index 063704e..b167c68 100644
--- a/src/Vulkan/BUILD.gn
+++ b/src/Vulkan/BUILD.gn
@@ -50,6 +50,10 @@
"-Wno-switch",
]
}
+
+ defines += [
+ "SWIFTSHADER_ENABLE_ASTC", # TODO(b/150130101)
+ ]
}
swiftshader_source_set("swiftshader_libvulkan_headers") {
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index a85b301..7c2872a 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -13,19 +13,21 @@
// limitations under the License.
#include "VkImage.hpp"
+
#include "VkBuffer.hpp"
#include "VkDevice.hpp"
#include "VkDeviceMemory.hpp"
-#include "Device/ASTC_Decoder.hpp"
#include "Device/BC_Decoder.hpp"
#include "Device/Blitter.hpp"
#include "Device/ETC_Decoder.hpp"
-#include <cstring>
+#include "Device/ASTC_Decoder.hpp"
#ifdef __ANDROID__
# include "System/GrallocAndroid.hpp"
#endif
+#include <cstring>
+
namespace {
ETC_Decoder::InputType GetInputType(const vk::Format &format)
diff --git a/src/Vulkan/VkPhysicalDevice.cpp b/src/Vulkan/VkPhysicalDevice.cpp
index 03df1e5..ba22551 100644
--- a/src/Vulkan/VkPhysicalDevice.cpp
+++ b/src/Vulkan/VkPhysicalDevice.cpp
@@ -76,7 +76,11 @@
VK_FALSE, // multiViewport
VK_TRUE, // samplerAnisotropy
VK_TRUE, // textureCompressionETC2
- VK_TRUE, // textureCompressionASTC_LDR
+#ifdef SWIFTSHADER_ENABLE_ASTC
+ VK_TRUE, // textureCompressionASTC_LDR
+#else
+ VK_FALSE, // textureCompressionASTC_LDR
+#endif
VK_FALSE, // textureCompressionBC
VK_FALSE, // occlusionQueryPrecise
VK_FALSE, // pipelineStatisticsQuery
@@ -527,6 +531,7 @@
case VK_FORMAT_EAC_R11_SNORM_BLOCK:
case VK_FORMAT_EAC_R11G11_UNORM_BLOCK:
case VK_FORMAT_EAC_R11G11_SNORM_BLOCK:
+#ifdef SWIFTSHADER_ENABLE_ASTC
case VK_FORMAT_ASTC_4x4_UNORM_BLOCK:
case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
@@ -555,6 +560,7 @@
case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
+#endif
case VK_FORMAT_D16_UNORM:
case VK_FORMAT_D32_SFLOAT:
case VK_FORMAT_D32_SFLOAT_S8_UINT: