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 16# Build inl files 17set(DEQP_VULKAN_INL_GEN_INPUT ${PROJECT_SOURCE_DIR}/external/vulkan-docs/src/xml/vk.xml) 18set(DEQP_VULKAN_INL_GEN_OUTPUTS_DIR ${PROJECT_SOURCE_DIR}/external/vulkancts/framework/vulkan) 19set(DEQP_VULKAN_INL_GEN_OUTPUTS 20 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkApiExtensionDependencyInfo.inl 21 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkBasicTypes.inl 22 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkConcreteDeviceInterface.inl 23 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkConcreteInstanceInterface.inl 24 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkConcretePlatformInterface.inl 25 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkCoreFunctionalities.inl 26 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceDriverImpl.inl 27 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceExtensions.inl 28 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeatures.inl 29 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeatures2.inl 30 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeaturesForContextDecl.inl 31 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeaturesForContextDefs.inl 32 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFeaturesForDefaultDeviceDefs.inl 33 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceFunctionPointers.inl 34 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDeviceProperties.inl 35 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDevicePropertiesForContextDecl.inl 36 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDevicePropertiesForContextDefs.inl 37 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkDevicePropertiesForDefaultDeviceDefs.inl 38 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkExtensionFunctions.inl 39 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkFunctionPointerTypes.inl 40 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkGetStructureTypeImpl.inl 41 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkHandleType.inl 42 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInitDeviceFunctionPointers.inl 43 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInitInstanceFunctionPointers.inl 44 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInitPlatformFunctionPointers.inl 45 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInstanceDriverImpl.inl 46 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInstanceExtensions.inl 47 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkInstanceFunctionPointers.inl 48 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkKnownDriverIds.inl 49 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkMandatoryFeatures.inl 50 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkNullDriverImpl.inl 51 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkObjTypeImpl.inl 52 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkPlatformDriverImpl.inl 53 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkPlatformFunctionPointers.inl 54 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkRefUtil.inl 55 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkRefUtilImpl.inl 56 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkStrUtil.inl 57 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkStrUtilImpl.inl 58 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkStructTypes.inl 59 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkSupportedExtensions.inl 60 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkTypeUtil.inl 61 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVirtualDeviceInterface.inl 62 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVirtualInstanceInterface.inl 63 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVirtualPlatformInterface.inl 64 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkEntryPointValidation.inl 65 # NOTE: when new file is generated by gen_framework it should be added to this list. 66 ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}/vkVulkan_c.inl) 67 68# If .inl files are generated to build directory add custom command that will build them. 69if (DEQP_VULKAN_INL_GEN_OUTPUTS_DIR MATCHES ^${PROJECT_BINARY_DIR}) 70 add_custom_command( 71 # Remove all outputs to help detect missing outputs. 72 COMMAND cmake -E remove ${DEQP_VULKAN_INL_GEN_OUTPUTS} 73 74 # Generate all inl files. 75 COMMAND ${PYTHON_EXECUTABLE} ARGS ${PROJECT_SOURCE_DIR}/external/vulkancts/scripts/gen_framework.py -o ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR} 76 COMMAND ${PYTHON_EXECUTABLE} ARGS ${PROJECT_SOURCE_DIR}/external/vulkancts/scripts/gen_framework_c.py -o ${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR} 77 78 # Check all outputs exist, as CMake does not do this. 79 COMMAND cmake -E md5sum ${DEQP_VULKAN_INL_GEN_OUTPUTS} 80 81 DEPENDS ${DEQP_VULKAN_INL_GEN_INPUT} 82 OUTPUT ${DEQP_VULKAN_INL_GEN_OUTPUTS}) 83 84 add_custom_target( 85 deqp-vk-inl ALL 86 DEPENDS ${DEQP_VULKAN_INL_GEN_OUTPUTS}) 87else() 88 add_custom_target(deqp-vk-inl) 89endif() 90 91set(VKUTILNOSHADER_SRCS 92 vkApiVersion.cpp 93 vkApiVersion.hpp 94 vkAppParamsUtil.cpp 95 vkAppParamsUtil.hpp 96 vkBuilderUtil.cpp 97 vkBuilderUtil.hpp 98 vkBarrierUtil.cpp 99 vkBarrierUtil.hpp 100 vkCmdUtil.cpp 101 vkCmdUtil.hpp 102 vkDefs.cpp 103 vkDefs.hpp 104 vkRef.cpp 105 vkRef.hpp 106 vkRefUtil.cpp 107 vkRefUtil.hpp 108 vkPlatform.cpp 109 vkPlatform.hpp 110 vkStrUtil.cpp 111 vkStrUtil.hpp 112 vkQueryUtil.cpp 113 vkQueryUtil.hpp 114 vkMemUtil.cpp 115 vkMemUtil.hpp 116 vkDeviceUtil.cpp 117 vkDeviceUtil.hpp 118 vkBinaryRegistry.cpp 119 vkBinaryRegistry.hpp 120 vkNullDriver.cpp 121 vkNullDriver.hpp 122 vkImageUtil.cpp 123 vkImageUtil.hpp 124 vkTypeUtil.cpp 125 vkTypeUtil.hpp 126 vkAllocationCallbackUtil.cpp 127 vkAllocationCallbackUtil.hpp 128 vkWsiPlatform.cpp 129 vkWsiPlatform.hpp 130 vkWsiUtil.cpp 131 vkWsiUtil.hpp 132 vkDebugReportUtil.cpp 133 vkDebugReportUtil.hpp 134 vkBufferWithMemory.cpp 135 vkBufferWithMemory.hpp 136 vkImageWithMemory.cpp 137 vkImageWithMemory.hpp 138 vkImageWithMemory.cpp 139 vkImageWithMemory.hpp 140 vkShaderProgram.cpp 141 vkShaderProgram.hpp 142 vkValidatorOptions.hpp 143 vkYCbCrImageWithMemory.cpp 144 vkYCbCrImageWithMemory.hpp 145 vkObjUtil.cpp 146 vkObjUtil.hpp 147 ${VKRENDERDOC_SRC} 148 vkRenderDocUtil.hpp 149 vkDeviceFeatures.hpp 150 vkDeviceFeatures.cpp 151 vkDeviceProperties.hpp 152 vkDeviceProperties.cpp 153 vkRayTracingUtil.hpp 154 vkRayTracingUtil.cpp 155 vkPipelineConstructionUtil.hpp 156 vkPipelineConstructionUtil.cpp 157 vkSafetyCriticalUtil.hpp 158 vkSafetyCriticalUtil.cpp 159 vkResourceInterface.hpp 160 vkResourceInterface.cpp 161 ) 162 163set(VKUTILNOSHADER_INLS 164 generated/vulkan/vkDeviceFeatures.inl 165 generated/vulkan/vkDeviceFeatureTest.inl 166 generated/vulkan/vkDeviceProperties.inl 167 ) 168 169set(VKSCUTILNOSHADER_INLS 170 generated/vulkansc/vkDeviceFeatures.inl 171 generated/vulkansc/vkDeviceFeatureTest.inl 172 generated/vulkansc/vkDeviceProperties.inl 173 generated/vulkansc/vulkan_json_data.hpp 174 generated/vulkansc/vulkan_json_parser.hpp 175 generated/vulkansc/tlsWrapper.hpp 176 ) 177 178set(VKUTIL_SRCS 179 vkPrograms.cpp 180 vkPrograms.hpp 181 vkShaderToSpirV.cpp 182 vkShaderToSpirV.hpp 183 vkSpirVAsm.hpp 184 vkSpirVAsm.cpp 185 vkSpirVProgram.hpp 186 vkSpirVProgram.cpp 187 ) 188 189set(VKUTILNOSHADER_LIBS 190 glutil 191 tcutil 192 ) 193 194set(VKUTIL_LIBS 195 glutil 196 tcutil 197 vkutilnoshader 198 ) 199 200include_directories(${GLSLANG_INCLUDE_PATH}) 201include_directories(${DEQP_VULKAN_INL_GEN_OUTPUTS_DIR}) 202 203# \note Code interfacing with glslang needs to include third-party headers 204# that cause all sorts of warnings to appear. 205if (DE_COMPILER_IS_GCC OR DE_COMPILER_IS_CLANG) 206 set_source_files_properties( 207 FILES vkShaderToSpirV.cpp 208 PROPERTIES COMPILE_FLAGS "${DE_3RD_PARTY_CXX_FLAGS}") 209endif () 210 211 212# \note Code interfacing with spirv-opt needs to include third-party headers 213# that cause all sorts of warnings to appear. 214if (DE_COMPILER_IS_GCC OR DE_COMPILER_IS_CLANG) 215 set_source_files_properties( 216 FILES vkPrograms.cpp 217 PROPERTIES COMPILE_FLAGS "${DE_3RD_PARTY_CXX_FLAGS}") 218endif () 219 220if(DEQP_HAVE_RENDERDOC_HEADER) 221 add_definitions(-DDEQP_HAVE_RENDERDOC_HEADER=1) 222endif() 223 224add_definitions(-DDISABLE_SHADERCACHE_IPC) 225 226PCH(VKUTILNOSHADER_SRCS ../../modules/vulkan/pch.cpp) 227PCH(VKUTIL_SRCS ../../modules/vulkan/pch.cpp) 228PCH(VKUTILNOSHADER_INLS ../../modules/vulkan/pch.cpp) 229PCH(VKSCUTILNOSHADER_INLS ../../modules/vulkan/pch.cpp) 230 231add_library(vkutilnoshader STATIC ${VKUTILNOSHADER_SRCS} ${VKUTILNOSHADER_INLS}) 232 233 234target_compile_definitions(vkutilnoshader PUBLIC CTS_USES_VULKAN) 235target_link_libraries(vkutilnoshader PUBLIC ${VKUTILNOSHADER_LIBS}) 236add_dependencies(vkutilnoshader deqp-vk-inl) 237 238add_library(vkscutilnoshader STATIC ${VKUTILNOSHADER_SRCS} ${VKSCUTILNOSHADER_INLS}) 239target_include_directories(vkscutilnoshader BEFORE PUBLIC generated/vulkansc) 240target_include_directories(vkscutilnoshader BEFORE PUBLIC ${CMAKE_SOURCE_DIR}/external/vulkancts/vkscserver) 241target_compile_definitions(vkscutilnoshader PUBLIC CTS_USES_VULKANSC) 242target_link_libraries(vkscutilnoshader PUBLIC ${VKUTILNOSHADER_LIBS} jsoncpp_static vksc-server-util) 243 244if (DEQP_USE_X11) 245 find_package(X11 REQUIRED) 246 247 target_compile_definitions(vkutilnoshader PUBLIC DEQP_SUPPORT_X11=1) 248 target_link_libraries(vkutilnoshader PUBLIC ${X11_LIBRARIES}) 249 250 target_compile_definitions(vkscutilnoshader PUBLIC DEQP_SUPPORT_X11=1) 251 target_link_libraries(vkscutilnoshader PUBLIC ${X11_LIBRARIES}) 252 253 if (DEQP_USE_XCB) 254 find_package(XCB REQUIRED) 255 256 target_compile_definitions(vkutilnoshader PUBLIC DEQP_SUPPORT_XCB=1) 257 target_link_libraries(vkutilnoshader PUBLIC ${XCB_LIBRARIES}) 258 259 target_compile_definitions(vkscutilnoshader PUBLIC DEQP_SUPPORT_XCB=1) 260 target_link_libraries(vkscutilnoshader PUBLIC ${XCB_LIBRARIES}) 261 262 endif () 263endif() 264 265add_library(vkutil STATIC ${VKUTIL_SRCS}) 266target_include_directories(vkutil PUBLIC ${GLSLANG_INCLUDE_PATH} ${spirv-tools_SOURCE_DIR}/include ${spirv-tools_SOURCE_DIR}/external/include ) 267target_link_libraries(vkutil PUBLIC vkutilnoshader ${GLSLANG_LIBRARIES} SPIRV-Tools SPIRV-Tools-opt) 268 269add_library(vkscutil STATIC ${VKUTIL_SRCS}) 270target_include_directories(vkscutil BEFORE PUBLIC generated/vulkansc) 271target_include_directories(vkscutil PUBLIC ${GLSLANG_INCLUDE_PATH} ${spirv-tools_SOURCE_DIR}/include ${spirv-tools_SOURCE_DIR}/external/include ) 272target_link_libraries(vkscutil PUBLIC vkscutilnoshader ${GLSLANG_LIBRARIES} SPIRV-Tools SPIRV-Tools-opt) 273 274