Commit a4347a94 by Nicolas Capens Committed by Nicolas Capens

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/+/41828Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarSean Risser <srisser@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 416d3745
......@@ -30,7 +30,7 @@ cc_defaults {
cppflags: [
"-Woverloaded-virtual",
"-DVK_USE_PLATFORM_ANDROID_KHR",
"-DVK_EXPORT= ",
"-DVK_EXPORT= ",
],
cpp_std: "c++14",
......
......@@ -123,7 +123,8 @@ option_if_not_defined(REACTOR_EMIT_PRINT_LOCATION "Emit printing of location inf
option_if_not_defined(REACTOR_ENABLE_PRINT "Enable RR_PRINT macros" 0)
option_if_not_defined(REACTOR_VERIFY_LLVM_IR "Check reactor-generated LLVM IR is valid even in release builds" 0)
option_if_not_defined(SWIFTSHADER_LESS_DEBUG_INFO "Generate less debug info to reduce file size" 0)
option_if_not_defined(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER "Enable vulkan debugger support" 0)
option_if_not_defined(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER "Enable Vulkan debugger support" 0)
option_if_not_defined(SWIFTSHADER_ENABLE_ASTC "Enable ASTC compressed textures support" 1) # TODO(b/150130101)
set(BUILD_MARL ${SWIFTSHADER_BUILD_VULKAN})
......@@ -1866,8 +1867,6 @@ file(GLOB VULKAN_LIST
${SOURCE_DIR}/WSI/VkSurfaceKHR.hpp
${SOURCE_DIR}/WSI/VkSwapchainKHR.cpp
${SOURCE_DIR}/WSI/VkSwapchainKHR.hpp
${ASTC_DIR}/Source/*.cpp
${ASTC_DIR}/Source/*.h
${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan/*.h}
)
......@@ -1881,6 +1880,15 @@ if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
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
......
......@@ -617,6 +617,7 @@ cc_defaults {
cflags: [
"-DLOG_TAG=\"swiftshader\"",
"-DSWIFTSHADER_EXTERNAL_MEMORY_ANDROID_HARDWARE_BUFFER",
"-DSWIFTSHADER_ENABLE_ASTC", // TODO(b/150130101)
],
srcs: [
......
......@@ -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 @@ void write_imageblock(unsigned char *img,
}
}
}
#endif
} // namespace
......@@ -100,6 +106,7 @@ void ASTC_Decoder::Decode(const unsigned char *source, unsigned char *dest,
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 @@ void ASTC_Decoder::Decode(const unsigned char *source, unsigned char *dest,
}
term_block_size_descriptor(bsd.get());
#endif
}
......@@ -50,6 +50,10 @@ config("swiftshader_libvulkan_private_config") {
"-Wno-switch",
]
}
defines += [
"SWIFTSHADER_ENABLE_ASTC", # TODO(b/150130101)
]
}
swiftshader_source_set("swiftshader_libvulkan_headers") {
......
......@@ -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)
......
......@@ -76,7 +76,11 @@ const VkPhysicalDeviceFeatures &PhysicalDevice::getFeatures() const
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 @@ void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFor
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 @@ void PhysicalDevice::getFormatProperties(Format format, VkFormatProperties *pFor
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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment