Skip to content

Commit dc99f22

Browse files
committed
Initial Drop of PAL: 6234c0c
1 parent 27d9c3c commit dc99f22

File tree

880 files changed

+947297
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

880 files changed

+947297
-0
lines changed

CMakeLists.txt

+127
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,127 @@
1+
cmake_minimum_required(VERSION 3.5)
2+
project(PAL LANGUAGES C CXX)
3+
4+
### CMake Includes #####################################################################################################
5+
include(CMakeDependentOption)
6+
include(AmdCmakeHelper)
7+
8+
### Cached Project Options #############################################################################################
9+
# CMAKE-TODO: To support multiple configurations for Visual Studio we can't use CMAKE_BUILD_TYPE
10+
# We would have to override the options using cmake generator expressions and possibly include an
11+
# option to disable overrides such as PAL_DISABLE_INTERNAL_OPTION_OVERRIDES
12+
13+
option(PAL_CLOSED_SOURCE "Build closed source PAL?" OFF)
14+
15+
option(PAL_BUILD_GPUOPEN "Build GPUOpen developer driver support?" OFF)
16+
17+
option(PAL_DBG_COMMAND_COMMENTS "Command with comments" OFF)
18+
19+
option(PAL_DEVELOPER_BUILD "Enable developer build" OFF)
20+
21+
option(PAL_ENABLE_PRINTS_ASSERTS "Enable print assertions?" ${CMAKE_BUILD_TYPE_DEBUG})
22+
cmake_dependent_option(PAL_MEMTRACK "Enable PAL memory tracker?" ${CMAKE_BUILD_TYPE_DEBUG} "PAL_ENABLE_PRINTS_ASSERTS" OFF)
23+
24+
option(PAL_BUILD_JEMALLOC "Use jemalloc as the default PAL allocator?" ON)
25+
cmake_dependent_option(PAL_JEMALLOC_STATS "Enable jemalloc statistice reporting?" OFF "PAL_BUILD_JEMALLOC" OFF)
26+
cmake_dependent_option(PAL_JEMALLOC_DEBUG "Build jemalloc in debug mode?" OFF "PAL_BUILD_JEMALLOC" OFF)
27+
28+
option(PAL_BUILD_CORE "Build PAL Core?" ON)
29+
option(PAL_BUILD_GPUUTIL "Build PAL GPU Util?" ON)
30+
cmake_dependent_option(PAL_BUILD_LAYERS "Build PAL Layers?" ON "PAL_BUILD_GPUUTIL" OFF)
31+
32+
option(PAL_BUILD_DBG_OVERLAY "Build PAL Debug Overlay?" ON)
33+
34+
option(PAL_BUILD_GPU_PROFILER "Build PAL GPU Profiler?" ON)
35+
36+
option(PAL_BUILD_CMD_BUFFER_LOGGER "Build PAL Command Buffer Logger?" ${CMAKE_BUILD_TYPE_DEBUG})
37+
option(PAL_BUILD_INTERFACE_LOGGER "Build PAL Interface Logger?" ${CMAKE_BUILD_TYPE_DEBUG})
38+
39+
option(PAL_BUILD_GFX "Build PAL with Graphics support?" ON)
40+
cmake_dependent_option(PAL_BUILD_GFX6 "Build PAL with GFX6 support?" ON "PAL_BUILD_GFX" OFF)
41+
cmake_dependent_option(PAL_BUILD_GFX9 "Build PAL with GFX9 support?" ON "PAL_BUILD_GFX" OFF)
42+
43+
option(PAL_BUILD_OSS "Build PAL with Operating System support?" ON)
44+
cmake_dependent_option(PAL_BUILD_OSS1 "Build PAL with OSS1?" ON "PAL_BUILD_OSS" OFF)
45+
cmake_dependent_option(PAL_BUILD_OSS2 "Build PAL with OSS2?" ON "PAL_BUILD_OSS" OFF)
46+
cmake_dependent_option(PAL_BUILD_OSS2_4 "Build PAL with OSS2_4?" ON "PAL_BUILD_OSS" OFF)
47+
cmake_dependent_option(PAL_BUILD_OSS4 "Build PAL with OSS4?" ON "PAL_BUILD_OSS" OFF)
48+
49+
option(PAL_BUILD_DTIF "Build PAL with Driver-to-TCore2 InterFace support?" OFF)
50+
51+
# PAL Client Options ###############################################################################
52+
# Use Vulkan as the default client.
53+
set(PAL_CLIENT "VULKAN" CACHE STRING "Client interfacing with PAL.")
54+
55+
# Read the latest version from palLib.h
56+
if(DEFINED PAL_CLIENT_INTERFACE_MAJOR_VERSION)
57+
message(STATUS "Client configured PAL_INTERFACE_MAJOR_VERSION as " ${PAL_CLIENT_INTERFACE_MAJOR_VERSION})
58+
else()
59+
file(STRINGS inc/core/palLib.h PAL_MAJOR_VERSION REGEX "^#define PAL_INTERFACE_MAJOR_VERSION [0-9]+")
60+
61+
if(PAL_MAJOR_VERSION STREQUAL "")
62+
message(STATUS "Failed to find PAL_INTERFACE_MAJOR_VERSION")
63+
else()
64+
string(REGEX REPLACE "^#define PAL_INTERFACE_MAJOR_VERSION " "" PAL_MAJOR_VERSION ${PAL_MAJOR_VERSION})
65+
message(STATUS "Detected PAL_INTERFACE_MAJOR_VERSION is " ${PAL_MAJOR_VERSION})
66+
endif()
67+
set(PAL_CLIENT_INTERFACE_MAJOR_VERSION ${PAL_MAJOR_VERSION})
68+
endif()
69+
70+
# Option Overrides #################################################################################
71+
# These are options that override PAL subproject options. As these overrides are managed and force
72+
# set by PAL, mark_as_advanced is used to hide them from the CMake GUI.
73+
74+
# ADDRLIB
75+
set(PAL_ADDR_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/addrlib CACHE PATH "Specify the path to the ADDRLIB project.")
76+
set(ADDR_OPTIONS_MARK_ADVANCED ON)
77+
78+
set(ADDR_SI_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with SI support." FORCE)
79+
set(ADDR_CI_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with CI support." FORCE)
80+
set(ADDR_VI_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with VI support." FORCE)
81+
82+
set(ADDR_SI_CHIP_DIR ${PROJECT_SOURCE_DIR}/src/core/hw/gfxip/gfx6/chip CACHE PATH "PAL override for ADDRLIB SI/CI/VI register chip headers." FORCE)
83+
84+
if(PAL_BUILD_GFX9)
85+
set(ADDR_GFX9_BUILD ON CACHE BOOL "PAL override to build ADDRLIB with GFX9 support." FORCE)
86+
set(ADDR_GFX9_CHIP_DIR ${PROJECT_SOURCE_DIR}/src/core/hw/gfxip/gfx9/chip CACHE PATH "PAL override for ADDRLIB GFX9 register chip headers." FORCE)
87+
endif()
88+
89+
# JEMALLOC
90+
if(PAL_BUILD_JEMALLOC)
91+
set(PAL_JEMALLOC_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/jemalloc CACHE PATH "Specify the path to the jemalloc project.")
92+
set(JEMALLOC_OPTIONS_MARK_ADVANCED ON)
93+
94+
set(JEMALLOC_STATS ${PAL_JEMALLOC_STATS} CACHE BOOL "PAL override." FORCE)
95+
set(JEMALLOC_DEBUG ${PAL_JEMALLOC_DEBUG} CACHE BOOL "PAL override." FORCE)
96+
endif()
97+
98+
# METROHASH
99+
set(PAL_METROHASH_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/metrohash CACHE PATH "Specify the path to the MetroHash project.")
100+
101+
# VAM
102+
set(PAL_VAM_PATH ${PROJECT_SOURCE_DIR}/src/core/imported/vam CACHE PATH "Specify the path to the VAM project.")
103+
104+
# GPUOPEN
105+
if(PAL_BUILD_GPUOPEN)
106+
set(PAL_GPUOPEN_PATH ${PROJECT_SOURCE_DIR}/shared/gpuopen CACHE PATH "Specify the path to the GPUOPEN_PATH project.")
107+
endif()
108+
109+
### Generator Dependencies #############################################################################################
110+
find_package(PythonInterp 3)
111+
if(NOT PYTHONINTERP_FOUND)
112+
if(UNIX)
113+
message(FATAL_ERROR "Python 3 is needed to generate some source files.")
114+
endif()
115+
endif()
116+
set(PYTHON_CMD ${PYTHON_EXECUTABLE})
117+
118+
find_package(Perl 5)
119+
if(NOT PERL_FOUND)
120+
if(UNIX)
121+
message(FATAL_ERROR "Perl 5 is needed to generate some source files.")
122+
endif()
123+
endif()
124+
set(PERL_CMD ${PERL_EXECUTABLE})
125+
126+
### Add Subdirectories #################################################################################################
127+
add_subdirectory(src)

LICENSE.txt

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2017 Advanced Micro Devices, Inc.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# PAL
2+
Platform Abstraction Library

cmake/Modules/AmdCmakeHelper.cmake

+102
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
# Build Type Helper ################################################################################
2+
set(CMAKE_BUILD_TYPE_DEBUG OFF)
3+
set(CMAKE_BUILD_TYPE_RELEASE OFF)
4+
set(CMAKE_BUILD_TYPE_RELWITHDEBINFO OFF)
5+
6+
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
7+
set(CMAKE_BUILD_TYPE_DEBUG ON)
8+
elseif((CMAKE_BUILD_TYPE STREQUAL "Release"))
9+
set(CMAKE_BUILD_TYPE_RELEASE ON)
10+
elseif((CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo"))
11+
set(CMAKE_BUILD_TYPE_RELWITHDEBINFO ON)
12+
endif()
13+
14+
# Options Helpers ##################################################################################
15+
macro(dropdown_option _option _options)
16+
set_property(CACHE ${_option} PROPERTY STRINGS ${${_options}})
17+
18+
list(FIND ${_options} ${${_option}} ${_option}_INDEX)
19+
if(${${_option}_INDEX} EQUAL -1)
20+
message(FATAL_ERROR "Option ${${_option}} not supported, valid entries are ${${_options}}")
21+
endif()
22+
endmacro()
23+
24+
macro(mark_grouped_as_advanced _group)
25+
get_cmake_property(_groupVariables CACHE_VARIABLES)
26+
foreach(_groupVariable ${_groupVariables})
27+
if(_groupVariable MATCHES "^${_group}_.*")
28+
mark_as_advanced(FORCE ${_groupVariable})
29+
endif()
30+
endforeach()
31+
endmacro()
32+
33+
# System Architecture Helpers ######################################################################
34+
include(TestBigEndian)
35+
36+
function(get_system_architecture_endianess endianess)
37+
test_big_endian(architectureIsBigEndian)
38+
if (architectureIsBigEndian)
39+
set(${endianess} "BIG" PARENT_SCOPE)
40+
else()
41+
set(${endianess} "LITTLE" PARENT_SCOPE)
42+
endif()
43+
endfunction()
44+
45+
function(get_system_architecture_bits bits)
46+
math(EXPR ${bits} "8*${CMAKE_SIZEOF_VOID_P}")
47+
set(${bits} ${${bits}} PARENT_SCOPE)
48+
endfunction()
49+
50+
# Architecture Endianness ##########################################################################
51+
if(NOT DEFINED TARGET_ARCHITECTURE_ENDIANESS)
52+
get_system_architecture_endianess(TARGET_ARCHITECTURE_ENDIANESS)
53+
set(TARGET_ARCHITECTURE_ENDIANESS ${TARGET_ARCHITECTURE_ENDIANESS} CACHE STRING "Specify the target architecture endianess.")
54+
set(TARGET_ARCHITECTURE_ENDIANESS_OPTIONS "BIG" "LITTLE")
55+
dropdown_option(TARGET_ARCHITECTURE_ENDIANESS TARGET_ARCHITECTURE_ENDIANESS_OPTIONS)
56+
endif()
57+
58+
# Architecture Bits ################################################################################
59+
if(NOT DEFINED TARGET_ARCHITECTURE_BITS)
60+
get_system_architecture_bits(TARGET_ARCHITECTURE_BITS)
61+
set(TARGET_ARCHITECTURE_BITS ${TARGET_ARCHITECTURE_BITS} CACHE STRING "Specify the target architecture bits.")
62+
set(TARGET_ARCHITECTURE_BITS_OPTIONS "32" "64")
63+
dropdown_option(TARGET_ARCHITECTURE_BITS TARGET_ARCHITECTURE_BITS_OPTIONS)
64+
endif()
65+
66+
# Visual Studio Filter Helper ######################################################################
67+
macro(target_vs_filters _target)
68+
if(MSVC)
69+
get_target_property(${_target}_SOURCES ${_target} SOURCES)
70+
get_target_property(${_target}_INCLUDES_DIRS ${_target} INTERFACE_INCLUDE_DIRECTORIES)
71+
72+
if(${_target}_INCLUDES_DIRS)
73+
foreach(_include_dir IN ITEMS ${${_target}_INCLUDES_DIRS})
74+
file(GLOB _include_files
75+
LIST_DIRECTORIES false
76+
"${_include_dir}/*.h*"
77+
)
78+
79+
list(APPEND ${_target}_INCLUDES ${_include_files})
80+
endforeach()
81+
82+
target_sources(${_target} PRIVATE ${${_target}_INCLUDES})
83+
endif()
84+
85+
set(${_target}_FILES ${${_target}_SOURCES} ${${_target}_INCLUDES})
86+
87+
foreach(_source IN ITEMS ${${_target}_FILES})
88+
set(_source ${_source})
89+
get_filename_component(_source_path "${_source}" ABSOLUTE)
90+
file(RELATIVE_PATH _source_path_rel "${PROJECT_SOURCE_DIR}" "${_source_path}")
91+
get_filename_component(_source_path_rel "${_source_path_rel}" DIRECTORY)
92+
string(REPLACE "/" "\\" _group_path "${_source_path_rel}")
93+
source_group("${_group_path}" FILES "${_source}")
94+
endforeach()
95+
endif()
96+
endmacro()
97+
98+
# Install Helper ###################################################################################
99+
macro(target_install _target _destination)
100+
install(TARGET ${_target} DESTINATION ${_destination}/${CMAKE_BUILD_TYPE}${TARGET_ARCHITECTURE_BITS})
101+
endmacro()
102+

cmake/Modules/FindDRM.cmake

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
set(_DRM_SEARCHES
2+
/opt/amdgpu-pro/include
3+
/opt/amdgpu-pro/include/libdrm
4+
)
5+
6+
find_path(XF86_INCLUDE_PATH xf86drm.h ${_DRM_SEARCHES})
7+
find_path(AMDGPU_INCLUDE_PATH amdgpu.h ${_DRM_SEARCHES})
8+
9+
if(XF86_INCLUDE_PATH AND AMDGPU_INCLUDE_PATH)
10+
set(DRM_FOUND 1)
11+
set(DRM_INCLUDE_DIRS ${XF86_INCLUDE_PATH} ${AMDGPU_INCLUDE_PATH})
12+
message(STATUS "Found DRM: ${DRM_INCLUDE_DIRS}")
13+
endif ()

cmake/Modules/FindXCB.cmake

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
set(_XCB_SEARCHES)
2+
3+
# Search XCB_ROOT first if it is set.
4+
if(XCB_ROOT)
5+
set(_XCB_SEARCH_ROOT PATHS ${XCB_ROOT} NO_DEFAULT_PATH)
6+
list(APPEND _XCB_SEARCHES _XCB_SEARCH_ROOT)
7+
endif()
8+
9+
list(APPEND _XCB_SEARCHES _XCB_SEARCH_NORMAL)
10+
11+
find_path(XCB_INCLUDE_PATH xcb/xcb.h ${_XCB_SEARCHES})
12+
find_path(XCB_DRI3_INCLUDE_PATH xcb/dri3.h ${_XCB_SEARCHES})
13+
find_path(XCB_DRI2_INCLUDE_PATH xcb/dri2.h ${_XCB_SEARCHES})
14+
find_path(XCB_PRESENT_INCLUDE_PATH xcb/present.h ${_XCB_SEARCHES})
15+
16+
if(XCB_INCLUDE_PATH AND XCB_DRI3_INCLUDE_PATH AND XCB_DRI2_INCLUDE_PATH AND XCB_PRESENT_INCLUDE_PATH)
17+
set(XCB_FOUND 1)
18+
set(XCB_INCLUDE_DIRS ${XCB_INCLUDE_PATH} ${XCB_DRI3_INCLUDE_PATH} ${XCB_DRI2_INCLUDE_PATH} ${XCB_PRESENT_INCLUDE_PATH})
19+
message(STATUS "Found XCB: ${XCB_INCLUDE_DIRS}")
20+
endif ()
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#find_depth
2+
if(NOT DEFINED GLOBAL_ROOT_SRC_DIR)
3+
execute_process(
4+
COMMAND find_depth
5+
OUTPUT_VARIABLE GLOBAL_ROOT_SRC_DIR
6+
OUTPUT_STRIP_TRAILING_WHITESPACE
7+
)
8+
set(GLOBAL_ROOT_SRC_DIR ${CMAKE_SOURCE_DIR}/${GLOBAL_ROOT_SRC_DIR} CACHE PATH "Global root source directory..")
9+
endif()

0 commit comments

Comments
 (0)