Android-x86
Fork
Donation

  • R/O
  • HTTP
  • SSH
  • HTTPS

external-swiftshader: Commit

external/swiftshader


Commit MetaInfo

Revision9418b511c73bc2b079d8b8d8d6fcb5d40b814159 (tree)
Time2020-04-15 04:46:53
AuthorAntonio Maiorano <amaiorano@goog...>
CommiterAntonio Maiorano

Log Message

CMake: split out Vulkan sources into separate CMakeLists

Add CMakeLists.txt to the following folders under src that create the
following targets:

Device -> vk_device
Pipeline -> vk_pipeline
WSI -> vk_wsi
System -> vk_system
Vulkan -> vk_swiftshader

Dependencies (by folder):

System --> n/a
Pipeline --> System Device* Vulkan*
WSI --> System Pipeline Vulkan*
Device --> System Pipeline Vulkan*
Vulkan --> Device Pipeline WSI System

* = dependency by include directory only (should fix this in the future)

Also make system-unittests and system-benchmarks depend on vk_system
rather than build part of System source files.

Bug: b/145758253
Change-Id: I9cce59ca90d91601696f6195326b5fd7dde517d5
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/43690
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Tested-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>

Change Summary

Incremental Difference

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -18,16 +18,6 @@ set(CMAKE_CXX_STANDARD 14)
1818
1919 project(SwiftShader C CXX ASM)
2020
21-# On Windows we use custom solution and project files, except for certain third-
22-# party projects which use CMake-generated ones. They are manually (re)generated
23-# and made path relative using build/cmake.sh, so they can be checked into the
24-# repository. Therefore they should not be auto-regenerated and left using
25-# absolute paths by CMake's ZERO_CHECK.
26-if(WIN32)
27- # Disable automatically regenerating project files on CMakeLists.txt changes.
28- set(CMAKE_SUPPRESS_REGENERATION true)
29-endif()
30-
3121 ###########################################################
3222 # Detect system
3323 ###########################################################
@@ -311,9 +301,6 @@ endif()
311301 ###########################################################
312302
313303 set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
314-set(OPENGL_DIR ${SOURCE_DIR}/OpenGL)
315-set(OPENGL_COMPILER_DIR ${OPENGL_DIR}/compiler)
316-set(VULKAN_DIR ${SOURCE_DIR}/Vulkan)
317304 set(THIRD_PARTY_DIR ${CMAKE_CURRENT_SOURCE_DIR}/third_party)
318305 set(TESTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/tests)
319306 set(HELLO2_DIR ${THIRD_PARTY_DIR}/PowerVR_SDK/Examples/Beginner/01_HelloAPI/OGLES2)
@@ -571,6 +558,7 @@ if(NOT MSVC)
571558 list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-fno-exceptions")
572559 endif()
573560 endif()
561+unset(USE_EXCEPTIONS)
574562
575563 # Transform SWIFTSHADER_LINK_FLAGS from semicolon delimited to whitespace
576564 # delimited (what is expected by LINK_FLAGS)
@@ -634,110 +622,20 @@ endif()
634622 # Include Directories
635623 ###########################################################
636624
637-set(COMMON_INCLUDE_DIR
625+set(VULKAN_INCLUDE_DIR
638626 ${SOURCE_DIR}
639627 ${CMAKE_CURRENT_SOURCE_DIR}/include
640628 )
641-set(OPENGL_INCLUDE_DIR
642- ${OPENGL_DIR}
643- ${COMMON_INCLUDE_DIR}
644-)
645-
646-set(VULKAN_INCLUDE_DIR
647- ${COMMON_INCLUDE_DIR}
648-)
649629
650630 ###########################################################
651631 # File Lists
652632 ###########################################################
653633
654-
655-file(GLOB VULKAN_LIST
656- ${VULKAN_DIR}/*.cpp
657- ${VULKAN_DIR}/*.h
658- ${VULKAN_DIR}/*.hpp
659- ${SOURCE_DIR}/System/Build.cpp
660- ${SOURCE_DIR}/System/Build.hpp
661- ${SOURCE_DIR}/System/CPUID.cpp
662- ${SOURCE_DIR}/System/CPUID.hpp
663- ${SOURCE_DIR}/System/Configurator.cpp
664- ${SOURCE_DIR}/System/Configurator.hpp
665- ${SOURCE_DIR}/System/Debug.cpp
666- ${SOURCE_DIR}/System/Debug.hpp
667- ${SOURCE_DIR}/System/Half.cpp
668- ${SOURCE_DIR}/System/Half.hpp
669- ${SOURCE_DIR}/System/Math.cpp
670- ${SOURCE_DIR}/System/Math.hpp
671- ${SOURCE_DIR}/System/Memory.cpp
672- ${SOURCE_DIR}/System/Memory.hpp
673- ${SOURCE_DIR}/System/Socket.cpp
674- ${SOURCE_DIR}/System/Socket.hpp
675- ${SOURCE_DIR}/System/Synchronization.hpp
676- ${SOURCE_DIR}/System/Timer.cpp
677- ${SOURCE_DIR}/System/Timer.hpp
678- ${SOURCE_DIR}/Device/*.cpp
679- ${SOURCE_DIR}/Device/*.hpp
680- ${SOURCE_DIR}/Pipeline/*.cpp
681- ${SOURCE_DIR}/Pipeline/*.hpp
682- ${SOURCE_DIR}/WSI/VkSurfaceKHR.cpp
683- ${SOURCE_DIR}/WSI/VkSurfaceKHR.hpp
684- ${SOURCE_DIR}/WSI/VkSwapchainKHR.cpp
685- ${SOURCE_DIR}/WSI/VkSwapchainKHR.hpp
686- ${CMAKE_CURRENT_SOURCE_DIR}/include/vulkan/*.h
687-)
688-
689-if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
690- file(GLOB_RECURSE VULKAN_DEBUG_LIST
691- ${VULKAN_DIR}/Debug/*.cpp
692- ${VULKAN_DIR}/Debug/*.h
693- ${VULKAN_DIR}/Debug/*.hpp
694- )
695- list(APPEND VULKAN_LIST ${VULKAN_DEBUG_LIST})
696- list(APPEND SWIFTSHADER_COMPILE_OPTIONS "-DENABLE_VK_DEBUGGER")
697-endif()
698-
699-if(LINUX OR ANDROID)
700- list(APPEND VULKAN_LIST
701- ${SOURCE_DIR}/System/Linux/MemFd.cpp
702- ${SOURCE_DIR}/System/Linux/MemFd.hpp
703- )
704-endif()
705-
706634 ###########################################################
707635 # Append OS specific files to lists
708636 ###########################################################
709637
710638 if(WIN32)
711- list(APPEND VULKAN_LIST
712- ${VULKAN_DIR}/Vulkan.rc
713- ${SOURCE_DIR}/WSI/Win32SurfaceKHR.cpp
714- ${SOURCE_DIR}/WSI/Win32SurfaceKHR.hpp
715- )
716-elseif(LINUX)
717- if(X11)
718- list(APPEND VULKAN_LIST
719- ${SOURCE_DIR}/WSI/XlibSurfaceKHR.cpp
720- ${SOURCE_DIR}/WSI/XlibSurfaceKHR.hpp
721- ${SOURCE_DIR}/WSI/libX11.cpp
722- ${SOURCE_DIR}/WSI/libX11.hpp
723- )
724- endif()
725-
726- if(XCB)
727- list(APPEND VULKAN_LIST
728- ${SOURCE_DIR}/WSI/XcbSurfaceKHR.cpp
729- ${SOURCE_DIR}/WSI/XcbSurfaceKHR.hpp
730- )
731- endif()
732-
733-elseif(APPLE)
734- list(APPEND VULKAN_LIST
735- ${SOURCE_DIR}/WSI/MetalSurface.mm
736- ${SOURCE_DIR}/WSI/MetalSurface.h
737- )
738-endif()
739-
740-if(WIN32)
741639 set(OS_LIBS odbc32 odbccp32 WS2_32 dxguid)
742640 elseif(LINUX)
743641 set(OS_LIBS dl pthread)
@@ -796,119 +694,44 @@ if(SWIFTSHADER_BUILD_GLES_CM)
796694 endif(SWIFTSHADER_BUILD_GLES_CM)
797695
798696 if(SWIFTSHADER_BUILD_VULKAN)
799- add_library(vk_swiftshader SHARED ${VULKAN_LIST})
800-
801697 if (NOT TARGET SPIRV-Tools)
802698 # This variable is also used by SPIRV-Tools to locate SPIRV-Headers
803699 set(SPIRV-Headers_SOURCE_DIR "${THIRD_PARTY_DIR}/SPIRV-Headers")
804- list(APPEND VULKAN_INCLUDE_DIR "${SPIRV-Headers_SOURCE_DIR}/include")
805700 set(SPIRV_SKIP_TESTS TRUE CACHE BOOL "" FORCE)
806- add_subdirectory(third_party/SPIRV-Tools)
807-
808- set_target_properties(core_tables PROPERTIES FOLDER "SPIRV-Tools build")
809- set_target_properties(enum_string_mapping PROPERTIES FOLDER "SPIRV-Tools build")
810- set_target_properties(extinst_tables PROPERTIES FOLDER "SPIRV-Tools build")
811- set_target_properties(spirv-tools-pkg-config PROPERTIES FOLDER "SPIRV-Tools build")
812- set_target_properties(spirv-tools-shared-pkg-config PROPERTIES FOLDER "SPIRV-Tools build")
701+ add_subdirectory(third_party/SPIRV-Tools) # Add SPIRV-Tools target
813702 endif()
814703
815- # Copy the OpenCLDebugInfo100.h header that's generated by SPIRV-Tools
816- # out to a separate directory that can be added to the include path.
817- # Ideally, this header would just be pre-built and part of SPIRV-Headers.
818- # See: https://github.com/KhronosGroup/SPIRV-Headers/issues/137
819- set(SPIRV_TOOLS_EXT_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-ext/include)
820- add_custom_command(
821- OUTPUT "${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h"
822- DEPENDS spirv-tools-header-OpenCLDebugInfo100
823- COMMAND ${CMAKE_COMMAND} -E copy
824- "${spirv-tools_BINARY_DIR}/OpenCLDebugInfo100.h"
825- "${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h"
826- )
827- add_custom_target(spirv_tools_ext_includes
828- DEPENDS "${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h")
829- set_target_properties(spirv_tools_ext_includes PROPERTIES FOLDER "SPIRV-Tools build")
830- list(APPEND VULKAN_INCLUDE_DIR "${SPIRV_TOOLS_EXT_INC_DIR}")
831- add_dependencies(vk_swiftshader spirv_tools_ext_includes)
832-
833- set(VULKAN_COMPILE_OPTIONS ${SWIFTSHADER_COMPILE_OPTIONS})
834- if(FUCHSIA)
835- # At the moment, the Fuchsia build uses unofficial VK_STRUCTURE_TYPE_XX
836- # constants that are defined as macros in <vulkan/fuchsia_extras.h>. When
837- # these appear in switch() cases, the compiler complains that the values
838- # are not part of the VkStructureType enum. Silence this warning, until
839- # the constants are upstreamed to the official Vulkan headers.
840- list(APPEND VULKAN_COMPILE_OPTIONS "-Wno-switch")
704+ # Add a vk_base interface library for shared vulkan build options.
705+ # TODO: Create src/Base and make this a lib target, and move stuff from
706+ # src/Vulkan into it that is needed by vk_pipeline, vk_device, and vk_wsi.
707+ add_library(vk_base INTERFACE)
708+
709+ if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
710+ target_compile_definitions(vk_base INTERFACE "ENABLE_VK_DEBUGGER")
841711 endif()
842- set_target_properties(vk_swiftshader PROPERTIES
843- INCLUDE_DIRECTORIES "${VULKAN_INCLUDE_DIR}"
844- FOLDER "Vulkan"
845- COMPILE_OPTIONS "${VULKAN_COMPILE_OPTIONS};${WARNINGS_AS_ERRORS}"
846- COMPILE_DEFINITIONS "VK_EXPORT=;NO_SANITIZE_FUNCTION=;$<$<CONFIG:Debug>:DEBUGGER_WAIT_DIALOG>"
847- LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
848- )
712+
849713 if(WIN32)
850- set(VULKAN_API_LIBRARY_NAME "vulkan-1.dll")
851- set_property(TARGET vk_swiftshader APPEND
852- PROPERTY COMPILE_DEFINITIONS "VK_USE_PLATFORM_WIN32_KHR")
714+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_WIN32_KHR")
853715 elseif(LINUX)
854- set(VULKAN_API_LIBRARY_NAME "libvulkan.so.1")
855716 if(X11)
856- set_property(TARGET vk_swiftshader APPEND
857- PROPERTY COMPILE_DEFINITIONS "VK_USE_PLATFORM_XLIB_KHR")
717+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XLIB_KHR")
858718 endif()
859719 if(XCB)
860- set_property(TARGET vk_swiftshader APPEND
861- PROPERTY COMPILE_DEFINITIONS "VK_USE_PLATFORM_XCB_KHR")
720+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_XCB_KHR")
862721 endif()
863722 elseif(APPLE)
864- set(VULKAN_API_LIBRARY_NAME "libvulkan.dylib")
865- set_property(TARGET vk_swiftshader APPEND
866- PROPERTY COMPILE_DEFINITIONS "VK_USE_PLATFORM_MACOS_MVK")
723+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_MACOS_MVK")
867724 elseif(FUCHSIA)
868- set(VULKAN_API_LIBRARY_NAME "libvulkan.so")
869- set_property(TARGET vk_swiftshader APPEND
870- PROPERTY COMPILE_DEFINITIONS "VK_USE_PLATFORM_FUCHSIA")
871- # On Fuchsia, the Vulkan ICD is loaded into a process sandbox that doesn't
872- # have system libraries available, so ensure it does not depend on libc++.so.
873- set_property(TARGET vk_swiftshader APPEND
874- PROPERTY LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS} -static-libstdc++")
725+ target_compile_definitions(vk_base INTERFACE "VK_USE_PLATFORM_FUCHSIA")
875726 else()
876727 message(FATAL_ERROR "Platform does not support Vulkan yet")
877728 endif()
878729
879- set_shared_library_export_map(vk_swiftshader ${SOURCE_DIR}/Vulkan)
880-
881- set(VK_SWIFTSHADER_LIBS ${Reactor} marl ${OS_LIBS} SPIRV-Tools SPIRV-Tools-opt ${SWIFTSHADER_LIBS})
882- if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
883- list(APPEND VK_SWIFTSHADER_LIBS cppdap)
884- endif()
885- if(SWIFTSHADER_ENABLE_ASTC)
886- list(APPEND VK_SWIFTSHADER_LIBS astc-encoder)
887- endif()
888- target_link_libraries(vk_swiftshader ${VK_SWIFTSHADER_LIBS})
889-
890- add_custom_command(
891- TARGET vk_swiftshader
892- POST_BUILD
893- COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/
894- COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vk_swiftshader> ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/
895- COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vk_swiftshader> ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/${VULKAN_API_LIBRARY_NAME}
896- )
897-
898- # The vk_swiftshader_icd.json manifest file will point to ICD_LIBRARY_PATH.
899- # Set ICD_LIBRARY_PATH to be a relative path similar to "./libvk_swiftshader.so", so both files can be moved.
900- # A relative path is relative to the manifest file.
901- set(ICD_LIBRARY_PATH "${CMAKE_SHARED_LIBRARY_PREFIX}vk_swiftshader${CMAKE_SHARED_LIBRARY_SUFFIX}")
902- if(WIN32)
903- # The path is output to a JSON file, which requires backslashes to be escaped.
904- set(ICD_LIBRARY_PATH ".\\\\${ICD_LIBRARY_PATH}")
905- else()
906- set(ICD_LIBRARY_PATH "./${ICD_LIBRARY_PATH}")
907- endif()
908- configure_file(
909- "${VULKAN_DIR}/vk_swiftshader_icd.json.tmpl"
910- "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/vk_swiftshader_icd.json"
911- )
730+ add_subdirectory(src/System) # Add vk_system target
731+ add_subdirectory(src/Pipeline) # Add vk_pipeline target
732+ add_subdirectory(src/WSI) # Add vk_wsi target
733+ add_subdirectory(src/Device) # Add vk_device target
734+ add_subdirectory(src/Vulkan) # Add vk_swiftshader target
912735
913736 if(SWIFTSHADER_EMIT_COVERAGE)
914737 add_executable(turbo-cov ${TESTS_DIR}/regres/cov/turbo-cov/main.cpp)
@@ -996,18 +819,6 @@ if(SWIFTSHADER_BUILD_TESTS)
996819 ${TESTS_DIR}/SystemUnitTests/unittests.cpp
997820 )
998821
999- # TODO: Replace with dep on System static target
1000- list(APPEND SYSTEM_UNITTESTS_LIST
1001- ${SOURCE_DIR}/System/Debug.cpp
1002- ${SOURCE_DIR}/System/Memory.cpp
1003- )
1004- if(LINUX OR ANDROID)
1005- list(APPEND SYSTEM_UNITTESTS_LIST
1006- ${SOURCE_DIR}/System/Linux/MemFd.cpp
1007- ${SOURCE_DIR}/System/Linux/MemFd.hpp
1008- )
1009- endif()
1010-
1011822 set(SYSTEM_UNITTESTS_INCLUDE_DIR
1012823 ${CMAKE_CURRENT_SOURCE_DIR}/src/
1013824 )
@@ -1020,7 +831,7 @@ if(SWIFTSHADER_BUILD_TESTS)
1020831 LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
1021832 )
1022833
1023- target_link_libraries(system-unittests gtest gmock)
834+ target_link_libraries(system-unittests vk_system gtest gmock)
1024835 if(NOT WIN32)
1025836 target_link_libraries(system-unittests pthread ${SWIFTSHADER_LIBS})
1026837 endif()
@@ -1048,8 +859,6 @@ if(SWIFTSHADER_BUILD_BENCHMARKS)
1048859
1049860 # System benchmarks
1050861 set(SYSTEM_BENCHMARKS_LIST
1051- ${SOURCE_DIR}/System/Debug.cpp
1052-
1053862 ${TESTS_DIR}/SystemBenchmarks/main.cpp
1054863 ${TESTS_DIR}/SystemBenchmarks/LRUCacheBenchmarks.cpp
1055864 )
@@ -1067,7 +876,7 @@ if(SWIFTSHADER_BUILD_BENCHMARKS)
1067876 FOLDER "Benchmarks"
1068877 )
1069878
1070- target_link_libraries(system-benchmarks gtest gmock)
879+ target_link_libraries(system-benchmarks vk_system gtest gmock)
1071880 if(NOT WIN32)
1072881 target_link_libraries(system-benchmarks pthread ${SWIFTSHADER_LIBS})
1073882 endif()
--- /dev/null
+++ b/src/Device/CMakeLists.txt
@@ -0,0 +1,80 @@
1+# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2+#
3+# Licensed under the Apache License, Version 2.0 (the "License");
4+# you may not use this file except in compliance with the License.
5+# You may obtain a copy of the License at
6+#
7+# http://www.apache.org/licenses/LICENSE-2.0
8+#
9+# Unless required by applicable law or agreed to in writing, software
10+# distributed under the License is distributed on an "AS IS" BASIS,
11+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+# See the License for the specific language governing permissions and
13+# limitations under the License.
14+
15+set(ROOT_PROJECT_COMPILE_OPTIONS
16+ ${SWIFTSHADER_COMPILE_OPTIONS}
17+ ${WARNINGS_AS_ERRORS}
18+)
19+
20+set(DEVICE_SRC_FILES
21+ ASTC_Decoder.cpp
22+ ASTC_Decoder.hpp
23+ BC_Decoder.cpp
24+ BC_Decoder.hpp
25+ Blitter.cpp
26+ Blitter.hpp
27+ Clipper.cpp
28+ Clipper.hpp
29+ Config.hpp
30+ Context.cpp
31+ Context.hpp
32+ ETC_Decoder.cpp
33+ ETC_Decoder.hpp
34+ LRUCache.hpp
35+ Memset.hpp
36+ PixelProcessor.cpp
37+ PixelProcessor.hpp
38+ Polygon.hpp
39+ Primitive.hpp
40+ QuadRasterizer.cpp
41+ QuadRasterizer.hpp
42+ Rasterizer.hpp
43+ Renderer.cpp
44+ Renderer.hpp
45+ RoutineCache.hpp
46+ Sampler.hpp
47+ SetupProcessor.cpp
48+ SetupProcessor.hpp
49+ Stream.hpp
50+ Triangle.hpp
51+ Vertex.hpp
52+ VertexProcessor.cpp
53+ VertexProcessor.hpp
54+)
55+
56+add_library(vk_device EXCLUDE_FROM_ALL
57+ ${DEVICE_SRC_FILES}
58+)
59+
60+set_target_properties(vk_device PROPERTIES
61+ POSITION_INDEPENDENT_CODE 1
62+ FOLDER "SwiftShader VK"
63+ LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
64+)
65+
66+target_include_directories(vk_device
67+ PUBLIC
68+ ".."
69+ "${CMAKE_SOURCE_DIR}/include"
70+)
71+
72+target_compile_options(vk_device
73+ PUBLIC
74+ ${ROOT_PROJECT_COMPILE_OPTIONS}
75+)
76+
77+target_link_libraries(vk_device
78+ PUBLIC
79+ vk_pipeline
80+)
--- /dev/null
+++ b/src/Pipeline/CMakeLists.txt
@@ -0,0 +1,113 @@
1+# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2+#
3+# Licensed under the Apache License, Version 2.0 (the "License");
4+# you may not use this file except in compliance with the License.
5+# You may obtain a copy of the License at
6+#
7+# http://www.apache.org/licenses/LICENSE-2.0
8+#
9+# Unless required by applicable law or agreed to in writing, software
10+# distributed under the License is distributed on an "AS IS" BASIS,
11+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+# See the License for the specific language governing permissions and
13+# limitations under the License.
14+
15+set(ROOT_PROJECT_COMPILE_OPTIONS
16+ ${SWIFTSHADER_COMPILE_OPTIONS}
17+ ${WARNINGS_AS_ERRORS}
18+)
19+
20+set(PIPELINE_SRC_FILES
21+ ComputeProgram.cpp
22+ ComputeProgram.hpp
23+ Constants.cpp
24+ Constants.hpp
25+ PixelProgram.cpp
26+ PixelProgram.hpp
27+ PixelRoutine.cpp
28+ PixelRoutine.hpp
29+ SamplerCore.cpp
30+ SamplerCore.hpp
31+ SetupRoutine.cpp
32+ SetupRoutine.hpp
33+ ShaderCore.cpp
34+ ShaderCore.hpp
35+ SpirvID.hpp
36+ SpirvShader.cpp
37+ SpirvShader.hpp
38+ SpirvShaderArithmetic.cpp
39+ SpirvShaderControlFlow.cpp
40+ SpirvShaderDebugger.cpp
41+ SpirvShaderEnumNames.cpp
42+ SpirvShaderGLSLstd450.cpp
43+ SpirvShaderGroup.cpp
44+ SpirvShaderImage.cpp
45+ SpirvShaderInstructions.cpp
46+ SpirvShaderMemory.cpp
47+ SpirvShaderSampling.cpp
48+ SpirvShaderSpec.cpp
49+ VertexProgram.cpp
50+ VertexProgram.hpp
51+ VertexRoutine.cpp
52+ VertexRoutine.hpp
53+)
54+
55+add_library(vk_pipeline EXCLUDE_FROM_ALL
56+ ${PIPELINE_SRC_FILES}
57+)
58+
59+# Add SPIRV-Tools dep
60+if (NOT TARGET SPIRV-Tools)
61+ message(FATAL_ERROR "Missing required target: SPIRV-Tools")
62+endif()
63+
64+set_target_properties(core_tables PROPERTIES FOLDER "SPIRV-Tools build")
65+set_target_properties(enum_string_mapping PROPERTIES FOLDER "SPIRV-Tools build")
66+set_target_properties(extinst_tables PROPERTIES FOLDER "SPIRV-Tools build")
67+set_target_properties(spirv-tools-pkg-config PROPERTIES FOLDER "SPIRV-Tools build")
68+set_target_properties(spirv-tools-shared-pkg-config PROPERTIES FOLDER "SPIRV-Tools build")
69+
70+# Copy the OpenCLDebugInfo100.h header that's generated by SPIRV-Tools
71+# out to a separate directory that can be added to the include path.
72+# Ideally, this header would just be pre-built and part of SPIRV-Headers.
73+# See: https://github.com/KhronosGroup/SPIRV-Headers/issues/137
74+set(SPIRV_TOOLS_EXT_INC_DIR ${CMAKE_CURRENT_BINARY_DIR}/spirv-tools-ext/include)
75+add_custom_command(
76+ OUTPUT "${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h"
77+ DEPENDS spirv-tools-header-OpenCLDebugInfo100
78+ COMMAND ${CMAKE_COMMAND} -E copy
79+ "${spirv-tools_BINARY_DIR}/OpenCLDebugInfo100.h"
80+ "${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h"
81+)
82+add_custom_target(spirv_tools_ext_includes
83+ DEPENDS "${SPIRV_TOOLS_EXT_INC_DIR}/spirv-tools/ext/OpenCLDebugInfo100.h")
84+set_target_properties(spirv_tools_ext_includes PROPERTIES FOLDER "SPIRV-Tools build")
85+add_dependencies(vk_pipeline spirv_tools_ext_includes)
86+
87+set_target_properties(vk_pipeline PROPERTIES
88+ POSITION_INDEPENDENT_CODE 1
89+ FOLDER "SwiftShader VK"
90+ LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
91+)
92+
93+target_include_directories(vk_pipeline
94+ PUBLIC
95+ ".."
96+ "${CMAKE_SOURCE_DIR}/include"
97+ "${SPIRV-Headers_SOURCE_DIR}/include"
98+ "${SPIRV_TOOLS_EXT_INC_DIR}"
99+)
100+
101+target_compile_options(vk_pipeline
102+ PUBLIC
103+ ${ROOT_PROJECT_COMPILE_OPTIONS}
104+)
105+
106+target_link_libraries(vk_pipeline
107+ PUBLIC
108+ vk_base
109+ vk_system
110+ marl
111+ SPIRV-Tools
112+ SPIRV-Tools-opt
113+)
--- /dev/null
+++ b/src/System/CMakeLists.txt
@@ -0,0 +1,69 @@
1+# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2+#
3+# Licensed under the Apache License, Version 2.0 (the "License");
4+# you may not use this file except in compliance with the License.
5+# You may obtain a copy of the License at
6+#
7+# http://www.apache.org/licenses/LICENSE-2.0
8+#
9+# Unless required by applicable law or agreed to in writing, software
10+# distributed under the License is distributed on an "AS IS" BASIS,
11+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+# See the License for the specific language governing permissions and
13+# limitations under the License.
14+
15+set(ROOT_PROJECT_COMPILE_OPTIONS
16+ ${SWIFTSHADER_COMPILE_OPTIONS}
17+ ${WARNINGS_AS_ERRORS}
18+)
19+
20+set(SYSTEM_SRC_FILES
21+ Build.cpp
22+ Build.hpp
23+ Configurator.cpp
24+ Configurator.hpp
25+ CPUID.cpp
26+ CPUID.hpp
27+ Debug.cpp
28+ Debug.hpp
29+ Half.cpp
30+ Half.hpp
31+ Math.cpp
32+ Math.hpp
33+ Memory.cpp
34+ Memory.hpp
35+ SharedLibrary.hpp
36+ Socket.cpp
37+ Socket.hpp
38+ Synchronization.hpp
39+ Timer.cpp
40+ Timer.hpp
41+ Types.hpp
42+)
43+
44+if(LINUX OR ANDROID)
45+ list(APPEND SYSTEM_SRC_FILES
46+ Linux/MemFd.cpp
47+ Linux/MemFd.hpp
48+ )
49+endif()
50+
51+add_library(vk_system EXCLUDE_FROM_ALL
52+ ${SYSTEM_SRC_FILES}
53+)
54+
55+set_target_properties(vk_system PROPERTIES
56+ POSITION_INDEPENDENT_CODE 1
57+ FOLDER "SwiftShader VK"
58+ LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
59+)
60+
61+target_include_directories(vk_system
62+ PUBLIC
63+ ".."
64+)
65+
66+target_compile_options(vk_system
67+ PUBLIC
68+ ${ROOT_PROJECT_COMPILE_OPTIONS}
69+)
--- /dev/null
+++ b/src/Vulkan/CMakeLists.txt
@@ -0,0 +1,220 @@
1+# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2+#
3+# Licensed under the Apache License, Version 2.0 (the "License");
4+# you may not use this file except in compliance with the License.
5+# You may obtain a copy of the License at
6+#
7+# http://www.apache.org/licenses/LICENSE-2.0
8+#
9+# Unless required by applicable law or agreed to in writing, software
10+# distributed under the License is distributed on an "AS IS" BASIS,
11+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+# See the License for the specific language governing permissions and
13+# limitations under the License.
14+
15+set(ROOT_PROJECT_COMPILE_OPTIONS
16+ ${SWIFTSHADER_COMPILE_OPTIONS}
17+ ${WARNINGS_AS_ERRORS}
18+)
19+
20+set(VULKAN_SRC_FILES
21+ libVulkan.cpp
22+ main.cpp
23+ resource.h
24+ Version.h
25+ VkBuffer.cpp
26+ VkBuffer.hpp
27+ VkBufferView.cpp
28+ VkBufferView.hpp
29+ VkCommandBuffer.cpp
30+ VkCommandBuffer.hpp
31+ VkCommandPool.cpp
32+ VkCommandPool.hpp
33+ VkConfig.h
34+ VkDescriptorPool.cpp
35+ VkDescriptorPool.hpp
36+ VkDescriptorSet.hpp
37+ VkDescriptorSetLayout.cpp
38+ VkDescriptorSetLayout.hpp
39+ VkDescriptorUpdateTemplate.cpp
40+ VkDescriptorUpdateTemplate.hpp
41+ VkDestroy.h
42+ VkDevice.cpp
43+ VkDevice.hpp
44+ VkDeviceMemory.cpp
45+ VkDeviceMemory.hpp
46+ VkDeviceMemoryExternalAndroid.hpp
47+ VkDeviceMemoryExternalLinux.hpp
48+ VkEvent.hpp
49+ VkFence.hpp
50+ VkFormat.cpp
51+ VkFormat.h
52+ VkFramebuffer.cpp
53+ VkFramebuffer.hpp
54+ VkGetProcAddress.cpp
55+ VkGetProcAddress.h
56+ VkImage.cpp
57+ VkImage.hpp
58+ VkImageView.cpp
59+ VkImageView.hpp
60+ VkInstance.cpp
61+ VkInstance.hpp
62+ VkMemory.cpp
63+ VkMemory.h
64+ VkObject.hpp
65+ VkPhysicalDevice.cpp
66+ VkPhysicalDevice.hpp
67+ VkPipeline.cpp
68+ VkPipeline.hpp
69+ VkPipelineCache.cpp
70+ VkPipelineCache.hpp
71+ VkPipelineLayout.cpp
72+ VkPipelineLayout.hpp
73+ VkPromotedExtensions.cpp
74+ VkQueryPool.cpp
75+ VkQueryPool.hpp
76+ VkQueue.cpp
77+ VkQueue.hpp
78+ VkRenderPass.cpp
79+ VkRenderPass.hpp
80+ VkSampler.cpp
81+ VkSampler.hpp
82+ VkSemaphore.cpp
83+ VkSemaphore.hpp
84+ VkSemaphoreExternalFuchsia.hpp
85+ VkSemaphoreExternalLinux.hpp
86+ VkShaderModule.cpp
87+ VkShaderModule.hpp
88+ VkStringify.cpp
89+ VkStringify.hpp
90+ VulkanPlatform.h
91+)
92+
93+if(WIN32)
94+ list(APPEND VULKAN_SRC_FILES
95+ Vulkan.rc
96+ )
97+endif()
98+
99+if(SWIFTSHADER_ENABLE_VULKAN_DEBUGGER)
100+ list(APPEND VULKAN_SRC_FILES
101+ Context.cpp
102+ Context.hpp
103+ Debug.cpp
104+ EventListener.hpp
105+ File.cpp
106+ File.hpp
107+ ID.hpp
108+ Location.hpp
109+ Server.cpp
110+ Server.hpp
111+ Thread.cpp
112+ Thread.hpp
113+ Type.cpp
114+ Type.hpp
115+ Value.cpp
116+ Value.hpp
117+ Variable.hpp
118+ WeakMap.hpp
119+ )
120+endif()
121+
122+set(VULKAN_COMPILE_OPTIONS "")
123+if(FUCHSIA)
124+ # At the moment, the Fuchsia build uses unofficial VK_STRUCTURE_TYPE_XX
125+ # constants that are defined as macros in <vulkan/fuchsia_extras.h>. When
126+ # these appear in switch() cases, the compiler complains that the values
127+ # are not part of the VkStructureType enum. Silence this warning, until
128+ # the constants are upstreamed to the official Vulkan headers.
129+ list(APPEND VULKAN_COMPILE_OPTIONS "-Wno-switch")
130+endif()
131+
132+set(VULKAN_LINKER_FLAGS "")
133+if(FUCHSIA)
134+ # On Fuchsia, the Vulkan ICD is loaded into a process sandbox that doesn't
135+ # have system libraries available, so ensure it does not depend on libc++.so.
136+ list(APPEND VULKAN_LINKER_FLAGS "-static-libstdc++")
137+endif()
138+# Convert list to space-delimited string for LINK_FLAGS
139+string(REPLACE ";" " " VULKAN_LINKER_FLAGS "${VULKAN_LINKER_FLAGS}")
140+
141+add_library(vk_swiftshader SHARED
142+ ${VULKAN_SRC_FILES}
143+)
144+
145+set_target_properties(vk_swiftshader PROPERTIES
146+ POSITION_INDEPENDENT_CODE 1
147+ FOLDER "SwiftShader VK"
148+ LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS} ${VULKAN_LINKER_FLAGS}"
149+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
150+ LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
151+)
152+
153+target_include_directories(vk_swiftshader
154+ PRIVATE
155+ ".."
156+ # "${CMAKE_SOURCE_DIR}/include"
157+)
158+
159+target_compile_options(vk_swiftshader
160+ PRIVATE
161+ ${ROOT_PROJECT_COMPILE_OPTIONS}
162+ ${VULKAN_COMPILE_OPTIONS}
163+)
164+
165+target_compile_definitions(vk_swiftshader
166+ PRIVATE
167+ "VK_EXPORT="
168+ $<$<CONFIG:Debug>:"DEBUGGER_WAIT_DIALOG">
169+)
170+
171+target_link_libraries(vk_swiftshader
172+ PRIVATE
173+ vk_system
174+ vk_pipeline
175+ vk_device
176+ vk_wsi
177+ ${Reactor}
178+ marl
179+ ${OS_LIBS}
180+ ${SWIFTSHADER_LIBS}
181+ $<$<BOOL:${SWIFTSHADER_ENABLE_VULKAN_DEBUGGER}>:cppdap>
182+ $<$<BOOL:${SWIFTSHADER_ENABLE_ASTC}>:astc-encoder>
183+)
184+
185+set_shared_library_export_map(vk_swiftshader ${CMAKE_CURRENT_SOURCE_DIR})
186+
187+if(WIN32)
188+ set(VULKAN_API_LIBRARY_NAME "vulkan-1.dll")
189+elseif(LINUX)
190+ set(VULKAN_API_LIBRARY_NAME "libvulkan.so.1")
191+elseif(APPLE)
192+ set(VULKAN_API_LIBRARY_NAME "libvulkan.dylib")
193+elseif(FUCHSIA)
194+ set(VULKAN_API_LIBRARY_NAME "libvulkan.so")
195+else()
196+ message(FATAL_ERROR "Platform does not support Vulkan yet")
197+endif()
198+
199+add_custom_command(
200+ TARGET vk_swiftshader
201+ POST_BUILD
202+ COMMAND ${CMAKE_COMMAND} -E make_directory ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/
203+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vk_swiftshader> ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/
204+ COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:vk_swiftshader> ${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/${VULKAN_API_LIBRARY_NAME}
205+)
206+
207+# The vk_swiftshader_icd.json manifest file will point to ICD_LIBRARY_PATH.
208+# Set ICD_LIBRARY_PATH to be a relative path similar to "./libvk_swiftshader.so", so both files can be moved.
209+# A relative path is relative to the manifest file.
210+set(ICD_LIBRARY_PATH "${CMAKE_SHARED_LIBRARY_PREFIX}vk_swiftshader${CMAKE_SHARED_LIBRARY_SUFFIX}")
211+if(WIN32)
212+ # The path is output to a JSON file, which requires backslashes to be escaped.
213+ set(ICD_LIBRARY_PATH ".\\\\${ICD_LIBRARY_PATH}")
214+else()
215+ set(ICD_LIBRARY_PATH "./${ICD_LIBRARY_PATH}")
216+endif()
217+configure_file(
218+ "vk_swiftshader_icd.json.tmpl"
219+ "${CMAKE_BINARY_DIR}/${CMAKE_SYSTEM_NAME}/vk_swiftshader_icd.json"
220+)
--- /dev/null
+++ b/src/WSI/CMakeLists.txt
@@ -0,0 +1,80 @@
1+# Copyright 2020 The SwiftShader Authors. All Rights Reserved.
2+#
3+# Licensed under the Apache License, Version 2.0 (the "License");
4+# you may not use this file except in compliance with the License.
5+# You may obtain a copy of the License at
6+#
7+# http://www.apache.org/licenses/LICENSE-2.0
8+#
9+# Unless required by applicable law or agreed to in writing, software
10+# distributed under the License is distributed on an "AS IS" BASIS,
11+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+# See the License for the specific language governing permissions and
13+# limitations under the License.
14+
15+set(ROOT_PROJECT_COMPILE_OPTIONS
16+ ${SWIFTSHADER_COMPILE_OPTIONS}
17+ ${WARNINGS_AS_ERRORS}
18+)
19+
20+set(WSI_SRC_FILES
21+ VkSurfaceKHR.cpp
22+ VkSurfaceKHR.hpp
23+ VkSwapchainKHR.cpp
24+ VkSwapchainKHR.hpp
25+)
26+
27+if(WIN32)
28+ list(APPEND WSI_SRC_FILES
29+ Win32SurfaceKHR.cpp
30+ Win32SurfaceKHR.hpp
31+ )
32+elseif(LINUX)
33+ if(X11)
34+ list(APPEND WSI_SRC_FILES
35+ XlibSurfaceKHR.cpp
36+ XlibSurfaceKHR.hpp
37+ libX11.cpp
38+ libX11.hpp
39+ )
40+ endif()
41+
42+ if(XCB)
43+ list(APPEND WSI_SRC_FILES
44+ XcbSurfaceKHR.cpp
45+ XcbSurfaceKHR.hpp
46+ )
47+ endif()
48+
49+elseif(APPLE)
50+ list(APPEND WSI_SRC_FILES
51+ MetalSurface.mm
52+ MetalSurface.h
53+ )
54+endif()
55+
56+add_library(vk_wsi EXCLUDE_FROM_ALL
57+ ${WSI_SRC_FILES}
58+)
59+
60+set_target_properties(vk_wsi PROPERTIES
61+ POSITION_INDEPENDENT_CODE 1
62+ FOLDER "SwiftShader VK"
63+ LINK_FLAGS "${SWIFTSHADER_LINK_FLAGS}"
64+)
65+
66+target_include_directories(vk_wsi
67+ PUBLIC
68+ ".."
69+ "${CMAKE_SOURCE_DIR}/include"
70+)
71+
72+target_compile_options(vk_wsi
73+ PUBLIC
74+ ${ROOT_PROJECT_COMPILE_OPTIONS}
75+)
76+
77+target_link_libraries(vk_wsi
78+ PUBLIC
79+ vk_pipeline
80+)
Show on old repository browser