Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
43 changes: 29 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,24 @@
#
#######################################################################################################################

#
# CMake file for top level of LLPC repository.
#
# Some variables that the client might set for enabling components:
#
# - ICD_BUILD_LLPC: Enable LLPC on Vulkan and OGLP.
#
#
#
#
#

cmake_minimum_required(VERSION 3.21)

project(LLPCrepo LANGUAGES C CXX)

set(LLPC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

### Standalone LLPC build handling
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
include(cmake/CompilerStandalone.cmake)
Expand All @@ -38,6 +52,8 @@ endif()
include(cmake/llpc_version.cmake)
add_llpc_version_projects()

include(CMakeDependentOption)

### Cached Project Options #############################################################################################
option(LLPC_BUILD_TOOLS "LLPC build all tools" OFF)

Expand All @@ -51,6 +67,8 @@ option(LLPC_AMD_YUV_IMAGE "Build with AMD_YUV_IMAGE" OFF)
option(LLPC_AMD_LVR_INTEROP "Build with AMD_LVR_INTEROP" OFF)
#endif

cmake_dependent_option(LLPC_SHAREDME_XDL_BUILD_TEST "Build tests for xdl." ON "LLPC_BUILD_TOOLS" OFF)

### VKGC aspects ###################################################################
# For drivers that use VKGC, as the interface to the LLPC front-end
if (FALSE
Expand All @@ -59,11 +77,12 @@ if (FALSE
include("cmake/vkgc.cmake")
endif()

### LGC for LLPC ###################################################################
### LLPC dependencies ##############################################################
if (ICD_BUILD_LLPC)
# Add LGC and its dependencies as LLVM external projects for LLPC to use.
include("cmake/lgc.cmake")
add_lgc_projects()
# Add LLPC's dependencies (including LGC) as LLVM external projects. This needs
# to be done before LLVM, whereas LLPC itself needs to be done after LLVM.
include("cmake/llpcdeps.cmake")
add_llpcdeps_projects()
endif()

### LLVM ###########################################################################
Expand Down Expand Up @@ -153,23 +172,13 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_property(TARGET llvm-dialects-example PROPERTY FOLDER Misc)
endif()
if (NOT WIN32 AND LLVM_OPTIMIZED_TABLEGEN)
#if _WIN32
# These targets don't exist on Windows when CMake is first invoked.
# They are created later at build time, when the cross-compilation takes place.
#endif
set_property(TARGET llvm_nm_target PROPERTY FOLDER Misc)
set_property(TARGET llvm_readobj_target PROPERTY FOLDER Misc)
set_property(TARGET llvm-min-tblgen-host PROPERTY FOLDER Misc)
set_property(TARGET llvm-tblgen-host PROPERTY FOLDER Misc)
set_property(TARGET CONFIGURE_LLVM_NATIVE PROPERTY FOLDER Misc)
set_property(TARGET CREATE_LLVM_NATIVE PROPERTY FOLDER Misc)
endif()
#if _WIN32
if(MSVC)
# The 32-bit llvm-tblgen can easily run out of memory. Tell the linker to allow addresses larger than 2GB.
set_property(TARGET llvm-tblgen PROPERTY LINK_FLAGS "/LARGEADDRESSAWARE")
endif()
#endif
if (LLPC_BUILD_TESTS)
if(NOT LLPC_IS_STANDALONE)
set_property(TARGET check-amber PROPERTY FOLDER "LLPC Tests")
Expand All @@ -181,4 +190,10 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
set_property(TARGET check-lgc-units PROPERTY FOLDER "LGC Tests")
endif()
endif()

if (TARGET llvm-tblgen)
# The 32-bit llvm-tblgen can easily run out of memory. Tell the linker to allow addresses larger than 2GB.
set_property(TARGET llvm-tblgen PROPERTY LINK_FLAGS "/LARGEADDRESSAWARE")
endif()

endif()
14 changes: 12 additions & 2 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#######################################################################################################################
#
# Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved.
# Copyright (c) 2024-2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
Expand All @@ -23,14 +23,24 @@
#
#######################################################################################################################

function(set_compiler_options PROJECT_NAME ENABLE_WERROR)
option(LLPC_ENABLE_WERROR "Build LLPC with more errors" OFF)

# Function to set standard compiler options on the specified target.
# There is an optional second arg to specify whether to apply -Werror; if the arg is not given,
# then that is controlled by LLPC_ENABLE_WERROR.
function(set_compiler_options PROJECT_NAME)
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_20)
set_target_properties(${PROJECT_NAME} PROPERTIES
CXX_STANDARD 20
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
POSITION_INDEPENDENT_CODE ON)

set(ENABLE_WERROR "${ARGN}")
if("${ENABLE_WERROR}" STREQUAL "")
set(ENABLE_WERROR "${LLPC_ENABLE_WERROR}")
endif()

if(CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
if(ENABLE_WERROR)
target_compile_options("${PROJECT_NAME}" PRIVATE
Expand Down
74 changes: 40 additions & 34 deletions cmake/CompilerStandalone.cmake
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
##
#######################################################################################################################
#
# Copyright (c) 2021-2024 Advanced Micro Devices, Inc. All Rights Reserved.
# Copyright (c) 2021-2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
Expand Down Expand Up @@ -29,48 +29,54 @@ if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

set(ICD_BUILD_LLPC ON)
set(LLPC_BUILD_TESTS ON)
set(LLPC_BUILD_TOOLS ON)

set(XGL_VKGC_PATH ${CMAKE_CURRENT_SOURCE_DIR})

# This is so spvgen can find vfx in an LLPC standalone build.
set(XGL_LLPC_PATH ${CMAKE_CURRENT_SOURCE_DIR})

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../pal)
set(XGL_PAL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../pal)
else()
set(XGL_PAL_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../imported/pal)
set(PAL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../pal)
elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../../imported/pal)
set(PAL_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../imported/pal)
endif()

if(EXISTS ${PROJECT_SOURCE_DIR}/../third_party)
set(THIRD_PARTY ${PROJECT_SOURCE_DIR}/../third_party)
else()
elseif(EXISTS ${PROJECT_SOURCE_DIR}/../../../../third_party)
set(THIRD_PARTY ${PROJECT_SOURCE_DIR}/../../../../third_party)
endif()
set(XGL_METROHASH_PATH ${THIRD_PARTY}/metrohash CACHE PATH "The path of metrohash.")
set(XGL_CWPACK_PATH ${THIRD_PARTY}/cwpack CACHE PATH "The path of cwpack.")
add_subdirectory(${XGL_METROHASH_PATH} ${PROJECT_BINARY_DIR}/metrohash)
add_subdirectory(${XGL_CWPACK_PATH} ${PROJECT_BINARY_DIR}/cwpack)

# External Vulkan headers path
if(EXISTS ${PROJECT_SOURCE_DIR}/../Vulkan-Headers)
set(VULKAN_HEADERS_PATH ${PROJECT_SOURCE_DIR}/../Vulkan-Headers CACHE PATH "The path of Vulkan headers.")
if (THIRD_PARTY)
set(XGL_METROHASH_PATH ${THIRD_PARTY}/metrohash CACHE PATH "The path of metrohash.")
set(XGL_CWPACK_PATH ${THIRD_PARTY}/cwpack CACHE PATH "The path of cwpack.")
add_subdirectory(${XGL_METROHASH_PATH} ${PROJECT_BINARY_DIR}/metrohash)
add_subdirectory(${XGL_CWPACK_PATH} ${PROJECT_BINARY_DIR}/cwpack)
endif()

### Khronos Interface
add_library(khronos_vulkan_interface INTERFACE)
if(EXISTS ${VULKAN_HEADERS_PATH})
target_include_directories(khronos_vulkan_interface INTERFACE ${VULKAN_HEADERS_PATH}/include)
target_compile_definitions(khronos_vulkan_interface INTERFACE EXTERNAL_VULKAN_HEADERS=1)
# Enable LLPC if we found its prerequisites (and it is not explicitly disabled).
if (NOT DEFINED ICD_BUILD_LLPC)
if (THIRD_PARTY AND PAL_SOURCE_DIR)
set(ICD_BUILD_LLPC ON)
else()
message(STATUS "Vulkan-LLPC prerequisites not found; disabling")
endif()
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../xgl)
target_include_directories(khronos_vulkan_interface INTERFACE ../xgl/icd/api/include/khronos)
else()
target_include_directories(khronos_vulkan_interface INTERFACE ../../../icd/api/include/khronos)
if (ICD_BUILD_LLPC)
set(LLPC_BUILD_TESTS ON)
set(LLPC_BUILD_TOOLS ON)

# External Vulkan headers path
if(EXISTS ${PROJECT_SOURCE_DIR}/../Vulkan-Headers)
set(VULKAN_HEADERS_PATH ${PROJECT_SOURCE_DIR}/../Vulkan-Headers CACHE PATH "The path of Vulkan headers.")
endif()

### Khronos Interface
add_library(khronos_vulkan_interface INTERFACE)
if(EXISTS ${VULKAN_HEADERS_PATH})
target_include_directories(khronos_vulkan_interface INTERFACE ${VULKAN_HEADERS_PATH}/include)
target_compile_definitions(khronos_vulkan_interface INTERFACE EXTERNAL_VULKAN_HEADERS=1)
endif()
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../xgl)
target_include_directories(khronos_vulkan_interface INTERFACE ../xgl/icd/api/include/khronos)
else()
target_include_directories(khronos_vulkan_interface INTERFACE ../../../icd/api/include/khronos)
endif()
endif()

set(GPURT_CLIENT_INTERFACE_MAJOR_VERSION 9999 CACHE STRING "")
set(LLPC_CLIENT_INTERFACE_MAJOR_VERSION "LLPC_INTERFACE_MAJOR_VERSION")
set(PAL_CLIENT_INTERFACE_MAJOR_VERSION 9999 CACHE STRING "")
set(GPURT_CLIENT_INTERFACE_MAJOR_VERSION 999999)
set(LLPC_CLIENT_INTERFACE_MAJOR_VERSION 999999)
set(PAL_CLIENT_INTERFACE_MAJOR_VERSION 999999)
39 changes: 39 additions & 0 deletions cmake/DialectsTablegen.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
##
#######################################################################################################################
#
# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
#######################################################################################################################

# TableGen for dialects
macro(set_dialects_tablegen_exe DIALECTS)
set(${DIALECTS}_TABLEGEN_TARGET llvm-dialects-tblgen)
if (EXISTS ${LLVM_TOOLS_BINARY_PATH}/llvm-dialects-tblgen)
set(${DIALECTS}_TABLEGEN_EXE ${LLVM_TOOLS_BINARY_PATH}/llvm-dialects-tblgen)
else()
if(CMAKE_CROSSCOMPILING)
set(${DIALECTS}_TABLEGEN_TARGET ${LLVM_DIALECTS_TABLEGEN_TARGET_HOST})
set(${DIALECTS}_TABLEGEN_EXE ${LLVM_DIALECTS_TABLEGEN_EXE_HOST})
else()
set(${DIALECTS}_TABLEGEN_EXE $<TARGET_FILE:llvm-dialects-tblgen>)
endif()
endif()
endmacro()
49 changes: 49 additions & 0 deletions cmake/FindShaderDbg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
##
#######################################################################################################################
#
# Copyright (c) 2020-2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
#######################################################################################################################

include(FindPackageHandleStandardArgs)

set(_SDB_SEARCHES
$ENV{SHADERDBG_DEPTH}
${GLOBAL_ROOT_SRC_DIR}drivers/ShaderDbg
${LLPC_SOURCE_DIR}/imported/ShaderDbg
${LLPC_SOURCE_DIR}/../ShaderDbg
)

find_path(SHADERDBG_PATH inc/shaderDbg.h
PATHS ${_SDB_SEARCHES} ENV SHADERDBG_PATH
NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH)

find_package_handle_standard_args(ShaderDbg DEFAULT_MSG SHADERDBG_PATH)

if(SHADERDBG_FOUND)
set(SHADERDBG_INCLUDE_DIRS ${SHADERDBG_PATH}/inc)
set(SDL_BUILD_TOOLS FALSE)

# Only add the ShaderDbg subdirectory if we haven't already seen it.
if (NOT TARGET ShaderDbg)
add_subdirectory(${SHADERDBG_PATH} ${CMAKE_CURRENT_BINARY_DIR}/ShaderDbg)
endif()
endif()
2 changes: 1 addition & 1 deletion cmake/llpc_version.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ function(llpc_set_property target scope varName default propertyName)
endif()
# For an LLPC_ variable, cache it as an option so that GPURT can see it.
if ("${varName}" MATCHES "^LLPC_")
option(${varName} "Support ${varName}?" ${${varName}})
set(${varName} "${${varName}}" CACHE BOOL "Support ${varName}?" FORCE)
endif()
set(${varName} ${${varName}} PARENT_SCOPE)
endif()
Expand Down
38 changes: 38 additions & 0 deletions cmake/llpcdeps.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
##
#######################################################################################################################
#
# Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved.
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to
# deal in the Software without restriction, including without limitation the
# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
# sell copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
# IN THE SOFTWARE.
#
#######################################################################################################################

set(LLPC_SOURCE_DIR "${CMAKE_CURRENT_LIST_DIR}/..")

include("${LLPC_SOURCE_DIR}/cmake/lgc.cmake")
include("${LLPC_SOURCE_DIR}/cmake/sharedme/xdl.cmake")

# Macro to add LLPC's dependencies as LLVM external projects.
# The function appends the project names to LLVM_EXTERNAL_PROJECTS and sets each
# LLVM_EXTERNAL_*_SOURCE_DIR, all in the caller's scope.
# LLPC itself is not an LLVM external project, so is not added here.
macro(add_llpcdeps_projects)
add_lgc_projects()
add_sharedme_xdl_projects()
endmacro()
Loading
Loading