• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# vk - Vulkan utilites
2# Split into two libraries - one that depends on spirv/glslang libraries
3# which have long build times, and one that can build in parallel with those.
4
5include(CheckIncludeFileCXX)
6check_include_file_cxx(
7	${CMAKE_SOURCE_DIR}/external/renderdoc/src/renderdoc_app.h
8	HAVE_RENDERDOC_APP_H)
9if(HAVE_RENDERDOC_APP_H)
10	set(VKRENDERDOC_SRC vkRenderDocUtil.cpp)
11else()
12	set(VKRENDERDOC_SRC vkNoRenderDocUtil.cpp)
13endif(HAVE_RENDERDOC_APP_H)
14
15# Build inl files
16set(DEQP_VULKAN_INL_GEN_INPUT ${PROJECT_SOURCE_DIR}/external/vulkan-docs/src/xml/vk.xml)
17set(DEQP_VULKAN_INL_GEN_OUTPUTS_DIR ${PROJECT_BINARY_DIR}/external/vulkancts/framework/vulkan)
18set(DEQP_VULKAN_INL_GEN_OUTPUTS
19	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkApiExtensionDependencyInfo.inl
20	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkBasicTypes.inl
21	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkConcreteDeviceInterface.inl
22	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkConcreteInstanceInterface.inl
23	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkConcretePlatformInterface.inl
24	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkCoreFunctionalities.inl
25	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceDriverImpl.inl
26	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceExtensions.inl
27	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeatures.inl
28	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeatures2.inl
29	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeaturesForContextDecl.inl
30	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeaturesForContextDefs.inl
31	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeaturesForDefaultDeviceDefs.inl
32	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFunctionPointers.inl
33	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceProperties.inl
34	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDevicePropertiesForContextDecl.inl
35	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDevicePropertiesForContextDefs.inl
36	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDevicePropertiesForDefaultDeviceDefs.inl
37	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkExtensionFunctions.inl
38	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkFunctionPointerTypes.inl
39	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkGetStructureTypeImpl.inl
40	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkHandleType.inl
41	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInitDeviceFunctionPointers.inl
42	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInitInstanceFunctionPointers.inl
43	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInitPlatformFunctionPointers.inl
44	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInstanceDriverImpl.inl
45	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInstanceExtensions.inl
46	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInstanceFunctionPointers.inl
47	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkKnownDriverIds.inl
48	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkMandatoryFeatures.inl
49	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkNullDriverImpl.inl
50	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkObjTypeImpl.inl
51	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkPlatformDriverImpl.inl
52	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkPlatformFunctionPointers.inl
53	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkRefUtil.inl
54	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkRefUtilImpl.inl
55	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkStrUtil.inl
56	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkStrUtilImpl.inl
57	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkStructTypes.inl
58	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkSupportedExtensions.inl
59	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkTypeUtil.inl
60	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVirtualDeviceInterface.inl
61	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVirtualInstanceInterface.inl
62	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVirtualPlatformInterface.inl
63	# NOTE: when new file is generated by gen_framework it should be added to this list.
64	${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVulkan_c.inl)
65
66add_custom_command(
67	# Remove all outputs to help detect missing outputs.
68	COMMAND cmake -E remove ${DEQP_VULKAN_INL_GEN_OUTPUTS}
69
70	# Generate all inl files.
71	COMMAND ${PYTHON_EXECUTABLE} ARGS ${PROJECT_SOURCE_DIR}/external/vulkancts/scripts/gen_ext_deps.py ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}
72	COMMAND ${PYTHON_EXECUTABLE} ARGS ${PROJECT_SOURCE_DIR}/external/vulkancts/scripts/gen_framework.py ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}
73	COMMAND ${PYTHON_EXECUTABLE} ARGS ${PROJECT_SOURCE_DIR}/external/vulkancts/scripts/gen_framework_c.py ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}
74
75	# Check all outputs exist, as CMake does not do this.
76	COMMAND cmake -E md5sum ${DEQP_VULKAN_INL_GEN_OUTPUTS}
77
78	DEPENDS ${DEQP_VULKAN_INL_GEN_INPUT}
79	OUTPUT ${DEQP_VULKAN_INL_GEN_OUTPUTS})
80
81add_custom_target(
82	deqp-vk-inl ALL
83	DEPENDS ${DEQP_VULKAN_INL_GEN_OUTPUTS})
84
85set(VKUTILNOSHADER_SRCS
86	vkApiVersion.cpp
87	vkApiVersion.hpp
88	vkBuilderUtil.cpp
89	vkBuilderUtil.hpp
90	vkBarrierUtil.cpp
91	vkBarrierUtil.hpp
92	vkCmdUtil.cpp
93	vkCmdUtil.hpp
94	vkDefs.cpp
95	vkDefs.hpp
96	vkRef.cpp
97	vkRef.hpp
98	vkRefUtil.cpp
99	vkRefUtil.hpp
100	vkPlatform.cpp
101	vkPlatform.hpp
102	vkStrUtil.cpp
103	vkStrUtil.hpp
104	vkQueryUtil.cpp
105	vkQueryUtil.hpp
106	vkMemUtil.cpp
107	vkMemUtil.hpp
108	vkDeviceUtil.cpp
109	vkDeviceUtil.hpp
110	vkBinaryRegistry.cpp
111	vkBinaryRegistry.hpp
112	vkNullDriver.cpp
113	vkNullDriver.hpp
114	vkImageUtil.cpp
115	vkImageUtil.hpp
116	vkTypeUtil.cpp
117	vkTypeUtil.hpp
118	vkAllocationCallbackUtil.cpp
119	vkAllocationCallbackUtil.hpp
120	vkWsiPlatform.cpp
121	vkWsiPlatform.hpp
122	vkWsiUtil.cpp
123	vkWsiUtil.hpp
124	vkDebugReportUtil.cpp
125	vkDebugReportUtil.hpp
126	vkBufferWithMemory.cpp
127	vkBufferWithMemory.hpp
128	vkImageWithMemory.cpp
129	vkImageWithMemory.hpp
130	vkImageWithMemory.cpp
131	vkImageWithMemory.hpp
132	vkShaderProgram.cpp
133	vkShaderProgram.hpp
134	vkValidatorOptions.hpp
135	vkYCbCrImageWithMemory.cpp
136	vkYCbCrImageWithMemory.hpp
137	vkObjUtil.cpp
138	vkObjUtil.hpp
139	${VKRENDERDOC_SRC}
140	vkRenderDocUtil.hpp
141	vkDeviceFeatures.hpp
142	vkDeviceFeatures.cpp
143	vkDeviceProperties.hpp
144	vkDeviceProperties.cpp
145	vkRayTracingUtil.hpp
146	vkRayTracingUtil.cpp
147	)
148
149set(VKUTIL_SRCS
150	vkPrograms.cpp
151	vkPrograms.hpp
152	vkShaderToSpirV.cpp
153	vkShaderToSpirV.hpp
154	vkSpirVAsm.hpp
155	vkSpirVAsm.cpp
156	vkSpirVProgram.hpp
157	vkSpirVProgram.cpp
158	)
159
160set(VKUTILNOSHADER_LIBS
161	glutil
162	tcutil
163	)
164
165set(VKUTIL_LIBS
166	glutil
167	tcutil
168	vkutilnoshader
169	)
170
171include_directories(${GLSLANG_INCLUDE_PATH})
172include_directories(${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR})
173
174# \note Code interfacing with glslang needs to include third-party headers
175#       that cause all sorts of warnings to appear.
176if (DE_COMPILER_IS_GCC OR DE_COMPILER_IS_CLANG)
177	set_source_files_properties(
178		FILES vkShaderToSpirV.cpp
179		PROPERTIES COMPILE_FLAGS "${DE_3RD_PARTY_CXX_FLAGS}")
180endif ()
181
182set(VKUTIL_LIBS ${VKUTIL_LIBS} ${GLSLANG_LIBRARIES})
183
184include_directories(${spirv-tools_SOURCE_DIR}/include)
185include_directories(${spirv-tools_SOURCE_DIR}/external/include)
186
187# \note Code interfacing with spirv-opt needs to include third-party headers
188#       that cause all sorts of warnings to appear.
189if (DE_COMPILER_IS_GCC OR DE_COMPILER_IS_CLANG)
190	set_source_files_properties(
191		FILES vkPrograms.cpp
192		PROPERTIES COMPILE_FLAGS "${DE_3RD_PARTY_CXX_FLAGS}")
193endif ()
194
195set(VKUTIL_LIBS ${VKUTIL_LIBS} spirv-tools spirv-tools-opt)
196
197if(DEQP_HAVE_RENDERDOC_HEADER)
198	add_definitions(-DDEQP_HAVE_RENDERDOC_HEADER=1)
199endif()
200
201PCH(VKUTILNOSHADER_SRCS ../../modules/vulkan/pch.cpp)
202PCH(VKUTIL_SRCS ../../modules/vulkan/pch.cpp)
203
204add_library(vkutilnoshader STATIC ${VKUTILNOSHADER_SRCS})
205target_link_libraries(vkutilnoshader ${VKUTILNOSHADER_LIBS})
206add_dependencies(vkutilnoshader deqp-vk-inl)
207
208if (DEQP_USE_X11)
209	find_package(X11 REQUIRED)
210	target_link_libraries(vkutilnoshader ${X11_LIBRARIES})
211	add_definitions(-DDEQP_SUPPORT_X11=1)
212	if (DEQP_USE_XCB)
213		find_package(XCB REQUIRED)
214		target_link_libraries(vkutilnoshader ${XCB_LIBRARIES})
215		add_definitions(-DDEQP_SUPPORT_XCB=1)
216	endif ()
217endif()
218
219add_library(vkutil STATIC ${VKUTIL_SRCS})
220target_link_libraries(vkutil ${VKUTIL_LIBS})
221