diff --git a/renderdoc.sln b/renderdoc.sln
index b04e93701..4997e4305 100644
--- a/renderdoc.sln
+++ b/renderdoc.sln
@@ -79,6 +79,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "renderdocui_stub", "qrender
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "NV", "renderdoc\driver\ihv\nv\NV.vcxproj", "{40349AD9-5558-4DF4-84E2-11934DE90A11}"
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "AMD_RGP", "renderdoc\driver\ihv\amd\AMD_RGP.vcxproj", "{B33F8FFD-3C04-4779-9C3B-E2858387971B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Development|x64 = Development|x64
@@ -263,6 +265,14 @@ Global
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Release|x64.Build.0 = Release|x64
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Release|x86.ActiveCfg = Release|Win32
{40349AD9-5558-4DF4-84E2-11934DE90A11}.Release|x86.Build.0 = Release|Win32
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Development|x64.ActiveCfg = Development|x64
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Development|x64.Build.0 = Development|x64
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Development|x86.ActiveCfg = Development|Win32
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Development|x86.Build.0 = Development|Win32
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Release|x64.ActiveCfg = Release|x64
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Release|x64.Build.0 = Release|x64
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Release|x86.ActiveCfg = Release|Win32
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -296,5 +306,6 @@ Global
{257FD75C-4D17-4A23-A754-23BFD85887A0} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C}
{37955C79-D91D-423F-8C6C-8F5BCF4F28D4} = {B5A783D9-AEB9-420D-8E77-D4D930F8D88C}
{40349AD9-5558-4DF4-84E2-11934DE90A11} = {4DA2F3E3-9A65-45DD-A69B-82C7757D4904}
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B} = {4DA2F3E3-9A65-45DD-A69B-82C7757D4904}
EndGlobalSection
EndGlobal
diff --git a/renderdoc/driver/ihv/amd/AMD_RGP.vcxproj b/renderdoc/driver/ihv/amd/AMD_RGP.vcxproj
new file mode 100644
index 000000000..0c8f2645f
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/AMD_RGP.vcxproj
@@ -0,0 +1,234 @@
+
+
+
+
+ Development
+ Win32
+
+
+ Development
+ x64
+
+
+ Release
+ Win32
+
+
+ Release
+ x64
+
+
+
+ {B33F8FFD-3C04-4779-9C3B-E2858387971B}
+ AMD_RGP
+ 8.1
+
+
+
+ StaticLibrary
+ true
+ MultiByte
+ v140
+
+
+ true
+
+
+
+
+
+
+ $(SolutionDir)$(Platform)\$(Configuration)\
+ $(ExecutablePath)
+ $(SolutionDir)\breakpad;$(IncludePath)
+ $(LibraryPath)
+ $(ExcludePath)
+ driver_$(ProjectName)
+
+
+ $(SolutionDir)$(Platform)\$(Configuration)\obj\$(ProjectName)\
+
+
+
+ WIN64;%(PreprocessorDefinitions)
+
+
+
+
+ RELEASE;%(PreprocessorDefinitions)
+
+
+
+
+ $(ProjectDir)official\RGP\ADL\include;$(ProjectDir)official\RGP\DevDriverComponents\inc;$(SolutionDir)renderdoc\;$(SolutionDir)renderdoc\3rdparty\
+ GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION=27;RENDERDOC_EXPORTS;RENDERDOC_PLATFORM_WIN32;WIN32;NDEBUG;_WINDOWS;_USRDLL;AGS;%(PreprocessorDefinitions)
+ Level4
+ MultiThreadedDLL
+ false
+ true
+ true
+ false
+ ProgramDatabase
+ 4100;4201;4324;4189;4127;4996
+
+
+ Windows
+ true
+
+
+
+
+ Disabled
+
+
+
+
+ MaxSpeed
+ Default
+ true
+ true
+
+
+ true
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ true
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/renderdoc/driver/ihv/amd/AMD_RGP.vcxproj.filters b/renderdoc/driver/ihv/amd/AMD_RGP.vcxproj.filters
new file mode 100644
index 000000000..ae18532f6
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/AMD_RGP.vcxproj.filters
@@ -0,0 +1,431 @@
+
+
+
+
+ {e8f4dcfb-b6d9-4fb8-aa7b-c7ad46b29f83}
+
+
+ {7f0cc2e2-a45e-4957-a1c5-9ec2ae66396b}
+
+
+ {29abae8a-3a0f-4f0b-8092-d88ab3d9a1a4}
+
+
+ {d97a3063-2945-4ad3-a616-0eda2e187f23}
+
+
+ {ec03dc9f-8299-40a4-a6b4-004e85687996}
+
+
+ {ec3413de-c35d-4612-95ad-c48adbd42355}
+
+
+ {793454d9-d39b-41a2-9c57-61bdc79a2553}
+
+
+ {295905ef-9b24-4585-8a52-d43804268cd5}
+
+
+ {8749e3f4-7d31-434d-8ef2-1bbc47f94507}
+
+
+ {8a4afd3f-72db-4f2a-88da-222e6665577a}
+
+
+ {26f16d97-2b0c-4333-a1e4-8877e79ce5d0}
+
+
+ {5af13bf5-c069-4995-ba85-adf7ec337eed}
+
+
+ {8d594f6c-17a7-42e8-a89c-0d41552283de}
+
+
+ {09408f6a-a584-4caf-941f-9f442edd2214}
+
+
+ {7c0f2f8e-70c5-4d99-8396-0311df7e9f75}
+
+
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener\transports
+
+
+ DevDriverComponents\listener\transports
+
+
+ DevDriverComponents\listener\transports
+
+
+ DevDriverComponents\listener\transports
+
+
+ DevDriverComponents\listener\clientmanagers
+
+
+ DevDriverComponents\listener\clientmanagers
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc\posix
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\util
+
+
+ DevDriverComponents\inc\win
+
+
+ Common
+
+
+ Common
+
+
+ DevDriverComponents\inc
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\inc\protocols
+
+
+ DevDriverComponents\src
+
+
+ DevDriverAPI
+
+
+ DevDriverAPI
+
+
+ DevDriverAPI
+
+
+
+
+ DevDriverComponents\src\posix
+
+
+ DevDriverComponents\src\posix
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\protocols
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src\win
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\src
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener
+
+
+ DevDriverComponents\listener\transports
+
+
+ DevDriverComponents\listener\transports
+
+
+ DevDriverComponents\listener\transports
+
+
+ DevDriverComponents\listener\clientmanagers
+
+
+ DevDriverAPI
+
+
+ DevDriverAPI
+
+
+ DevDriverAPI
+
+
+
+
+ DevDriverComponents\src
+
+
+
\ No newline at end of file
diff --git a/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_defines.h b/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_defines.h
new file mode 100644
index 000000000..442908b12
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_defines.h
@@ -0,0 +1,1526 @@
+//
+// Copyright (c) 2008 - 2013 Advanced Micro Devices, Inc.
+
+// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
+// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
+
+/// \file adl_defines.h
+/// \brief Contains all definitions exposed by ADL for \ALL platforms.\n Included in ADL SDK
+///
+/// This file contains all definitions used by ADL.
+/// The ADL definitions include the following:
+/// \li ADL error codes
+/// \li Enumerations for the ADLDisplayInfo structure
+/// \li Maximum limits
+///
+
+#ifndef ADL_DEFINES_H_
+#define ADL_DEFINES_H_
+
+/// \defgroup DEFINES Constants and Definitions
+// @{
+
+/// \defgroup define_misc Miscellaneous Constant Definitions
+// @{
+
+/// \name General Definitions
+// @{
+
+/// Defines ADL_TRUE
+#define ADL_TRUE 1
+/// Defines ADL_FALSE
+#define ADL_FALSE 0
+
+/// Defines the maximum string length
+#define ADL_MAX_CHAR 4096
+/// Defines the maximum string length
+#define ADL_MAX_PATH 256
+/// Defines the maximum number of supported adapters
+#define ADL_MAX_ADAPTERS 250
+/// Defines the maxumum number of supported displays
+#define ADL_MAX_DISPLAYS 150
+/// Defines the maxumum string length for device name
+#define ADL_MAX_DEVICENAME 32
+/// Defines for all adapters
+#define ADL_ADAPTER_INDEX_ALL -1
+/// Defines APIs with iOption none
+#define ADL_MAIN_API_OPTION_NONE 0
+// @}
+
+/// \name Definitions for iOption parameter used by
+/// ADL_Display_DDCBlockAccess_Get()
+// @{
+
+/// Switch to DDC line 2 before sending the command to the display.
+#define ADL_DDC_OPTION_SWITCHDDC2 0x00000001
+/// Save command in the registry under a unique key, corresponding to parameter \b iCommandIndex
+#define ADL_DDC_OPTION_RESTORECOMMAND 0x00000002
+/// Combine write-read DDC block access command.
+#define ADL_DDC_OPTION_COMBOWRITEREAD 0x00000010
+/// Direct DDC access to the immediate device connected to graphics card.
+/// MST with this option set: DDC command is sent to first branch.
+/// MST with this option not set: DDC command is sent to the end node sink device.
+#define ADL_DDC_OPTION_SENDTOIMMEDIATEDEVICE 0x00000020
+// @}
+
+/// \name Values for
+/// ADLI2C.iAction used with ADL_Display_WriteAndReadI2C()
+// @{
+
+#define ADL_DL_I2C_ACTIONREAD 0x00000001
+#define ADL_DL_I2C_ACTIONWRITE 0x00000002
+#define ADL_DL_I2C_ACTIONREAD_REPEATEDSTART 0x00000003
+// @}
+
+
+// @} //Misc
+
+/// \defgroup define_adl_results Result Codes
+/// This group of definitions are the various results returned by all ADL functions \n
+// @{
+/// All OK, but need to wait
+#define ADL_OK_WAIT 4
+/// All OK, but need restart
+#define ADL_OK_RESTART 3
+/// All OK but need mode change
+#define ADL_OK_MODE_CHANGE 2
+/// All OK, but with warning
+#define ADL_OK_WARNING 1
+/// ADL function completed successfully
+#define ADL_OK 0
+/// Generic Error. Most likely one or more of the Escape calls to the driver failed!
+#define ADL_ERR -1
+/// ADL not initialized
+#define ADL_ERR_NOT_INIT -2
+/// One of the parameter passed is invalid
+#define ADL_ERR_INVALID_PARAM -3
+/// One of the parameter size is invalid
+#define ADL_ERR_INVALID_PARAM_SIZE -4
+/// Invalid ADL index passed
+#define ADL_ERR_INVALID_ADL_IDX -5
+/// Invalid controller index passed
+#define ADL_ERR_INVALID_CONTROLLER_IDX -6
+/// Invalid display index passed
+#define ADL_ERR_INVALID_DIPLAY_IDX -7
+/// Function not supported by the driver
+#define ADL_ERR_NOT_SUPPORTED -8
+/// Null Pointer error
+#define ADL_ERR_NULL_POINTER -9
+/// Call can't be made due to disabled adapter
+#define ADL_ERR_DISABLED_ADAPTER -10
+/// Invalid Callback
+#define ADL_ERR_INVALID_CALLBACK -11
+/// Display Resource conflict
+#define ADL_ERR_RESOURCE_CONFLICT -12
+//Failed to update some of the values. Can be returned by set request that include multiple values if not all values were successfully committed.
+#define ADL_ERR_SET_INCOMPLETE -20
+
+// @}
+///
+
+/// \defgroup define_display_type Display Type
+/// Define Monitor/CRT display type
+// @{
+/// Define Monitor display type
+#define ADL_DT_MONITOR 0
+/// Define TV display type
+#define ADL_DT_TELEVISION 1
+/// Define LCD display type
+#define ADL_DT_LCD_PANEL 2
+/// Define DFP display type
+#define ADL_DT_DIGITAL_FLAT_PANEL 3
+/// Define Componment Video display type
+#define ADL_DT_COMPONENT_VIDEO 4
+/// Define Projector display type
+#define ADL_DT_PROJECTOR 5
+// @}
+
+/// \defgroup define_display_connection_type Display Connection Type
+// @{
+/// Define unknown display output type
+#define ADL_DOT_UNKNOWN 0
+/// Define composite display output type
+#define ADL_DOT_COMPOSITE 1
+/// Define SVideo display output type
+#define ADL_DOT_SVIDEO 2
+/// Define analog display output type
+#define ADL_DOT_ANALOG 3
+/// Define digital display output type
+#define ADL_DOT_DIGITAL 4
+// @}
+
+/// \defgroup define_color_type Display Color Type and Source
+/// Define Display Color Type and Source
+// @{
+#define ADL_DISPLAY_COLOR_BRIGHTNESS (1 << 0)
+#define ADL_DISPLAY_COLOR_CONTRAST (1 << 1)
+#define ADL_DISPLAY_COLOR_SATURATION (1 << 2)
+#define ADL_DISPLAY_COLOR_HUE (1 << 3)
+#define ADL_DISPLAY_COLOR_TEMPERATURE (1 << 4)
+
+/// Color Temperature Source is EDID
+#define ADL_DISPLAY_COLOR_TEMPERATURE_SOURCE_EDID (1 << 5)
+/// Color Temperature Source is User
+#define ADL_DISPLAY_COLOR_TEMPERATURE_SOURCE_USER (1 << 6)
+// @}
+
+/// \defgroup define_adjustment_capabilities Display Adjustment Capabilities
+/// Display adjustment capabilities values. Returned by ADL_Display_AdjustCaps_Get
+// @{
+#define ADL_DISPLAY_ADJUST_OVERSCAN (1 << 0)
+#define ADL_DISPLAY_ADJUST_VERT_POS (1 << 1)
+#define ADL_DISPLAY_ADJUST_HOR_POS (1 << 2)
+#define ADL_DISPLAY_ADJUST_VERT_SIZE (1 << 3)
+#define ADL_DISPLAY_ADJUST_HOR_SIZE (1 << 4)
+#define ADL_DISPLAY_ADJUST_SIZEPOS (ADL_DISPLAY_ADJUST_VERT_POS | ADL_DISPLAY_ADJUST_HOR_POS | ADL_DISPLAY_ADJUST_VERT_SIZE | ADL_DISPLAY_ADJUST_HOR_SIZE)
+#define ADL_DISPLAY_CUSTOMMODES (1<<5)
+#define ADL_DISPLAY_ADJUST_UNDERSCAN (1<<6)
+// @}
+
+
+/// \defgroup define_desktop_config Desktop Configuration Flags
+/// These flags are used by ADL_DesktopConfig_xxx
+/// \deprecated This API has been deprecated because it was only used for RandR 1.1 (Red Hat 5.x) distributions which is now not supported.
+// @{
+#define ADL_DESKTOPCONFIG_UNKNOWN 0 /* UNKNOWN desktop config */
+#define ADL_DESKTOPCONFIG_SINGLE (1 << 0) /* Single */
+#define ADL_DESKTOPCONFIG_CLONE (1 << 2) /* Clone */
+#define ADL_DESKTOPCONFIG_BIGDESK_H (1 << 4) /* Big Desktop Horizontal */
+#define ADL_DESKTOPCONFIG_BIGDESK_V (1 << 5) /* Big Desktop Vertical */
+#define ADL_DESKTOPCONFIG_BIGDESK_HR (1 << 6) /* Big Desktop Reverse Horz */
+#define ADL_DESKTOPCONFIG_BIGDESK_VR (1 << 7) /* Big Desktop Reverse Vert */
+#define ADL_DESKTOPCONFIG_RANDR12 (1 << 8) /* RandR 1.2 Multi-display */
+// @}
+
+/// needed for ADLDDCInfo structure
+#define ADL_MAX_DISPLAY_NAME 256
+
+/// \defgroup define_edid_flags Values for ulDDCInfoFlag
+/// defines for ulDDCInfoFlag EDID flag
+// @{
+#define ADL_DISPLAYDDCINFOEX_FLAG_PROJECTORDEVICE (1 << 0)
+#define ADL_DISPLAYDDCINFOEX_FLAG_EDIDEXTENSION (1 << 1)
+#define ADL_DISPLAYDDCINFOEX_FLAG_DIGITALDEVICE (1 << 2)
+#define ADL_DISPLAYDDCINFOEX_FLAG_HDMIAUDIODEVICE (1 << 3)
+#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORTS_AI (1 << 4)
+#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC601 (1 << 5)
+#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC709 (1 << 6)
+// @}
+
+/// \defgroup define_displayinfo_connector Display Connector Type
+/// defines for ADLDisplayInfo.iDisplayConnector
+// @{
+#define ADL_DISPLAY_CONTYPE_UNKNOWN 0
+#define ADL_DISPLAY_CONTYPE_VGA 1
+#define ADL_DISPLAY_CONTYPE_DVI_D 2
+#define ADL_DISPLAY_CONTYPE_DVI_I 3
+#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_NTSC 4
+#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_JPN 5
+#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_JPN 6
+#define ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_NTSC 7
+#define ADL_DISPLAY_CONTYPE_PROPRIETARY 8
+#define ADL_DISPLAY_CONTYPE_HDMI_TYPE_A 10
+#define ADL_DISPLAY_CONTYPE_HDMI_TYPE_B 11
+#define ADL_DISPLAY_CONTYPE_SVIDEO 12
+#define ADL_DISPLAY_CONTYPE_COMPOSITE 13
+#define ADL_DISPLAY_CONTYPE_RCA_3COMPONENT 14
+#define ADL_DISPLAY_CONTYPE_DISPLAYPORT 15
+#define ADL_DISPLAY_CONTYPE_EDP 16
+#define ADL_DISPLAY_CONTYPE_WIRELESSDISPLAY 17
+// @}
+
+/// TV Capabilities and Standards
+/// \defgroup define_tv_caps TV Capabilities and Standards
+/// \deprecated Dropping support for TV displays
+// @{
+#define ADL_TV_STANDARDS (1 << 0)
+#define ADL_TV_SCART (1 << 1)
+
+/// TV Standards Definitions
+#define ADL_STANDARD_NTSC_M (1 << 0)
+#define ADL_STANDARD_NTSC_JPN (1 << 1)
+#define ADL_STANDARD_NTSC_N (1 << 2)
+#define ADL_STANDARD_PAL_B (1 << 3)
+#define ADL_STANDARD_PAL_COMB_N (1 << 4)
+#define ADL_STANDARD_PAL_D (1 << 5)
+#define ADL_STANDARD_PAL_G (1 << 6)
+#define ADL_STANDARD_PAL_H (1 << 7)
+#define ADL_STANDARD_PAL_I (1 << 8)
+#define ADL_STANDARD_PAL_K (1 << 9)
+#define ADL_STANDARD_PAL_K1 (1 << 10)
+#define ADL_STANDARD_PAL_L (1 << 11)
+#define ADL_STANDARD_PAL_M (1 << 12)
+#define ADL_STANDARD_PAL_N (1 << 13)
+#define ADL_STANDARD_PAL_SECAM_D (1 << 14)
+#define ADL_STANDARD_PAL_SECAM_K (1 << 15)
+#define ADL_STANDARD_PAL_SECAM_K1 (1 << 16)
+#define ADL_STANDARD_PAL_SECAM_L (1 << 17)
+// @}
+
+
+/// \defgroup define_video_custom_mode Video Custom Mode flags
+/// Component Video Custom Mode flags. This is used by the iFlags parameter in ADLCustomMode
+// @{
+#define ADL_CUSTOMIZEDMODEFLAG_MODESUPPORTED (1 << 0)
+#define ADL_CUSTOMIZEDMODEFLAG_NOTDELETETABLE (1 << 1)
+#define ADL_CUSTOMIZEDMODEFLAG_INSERTBYDRIVER (1 << 2)
+#define ADL_CUSTOMIZEDMODEFLAG_INTERLACED (1 << 3)
+#define ADL_CUSTOMIZEDMODEFLAG_BASEMODE (1 << 4)
+// @}
+
+/// \defgroup define_ddcinfoflag Values used for DDCInfoFlag
+/// ulDDCInfoFlag field values used by the ADLDDCInfo structure
+// @{
+#define ADL_DISPLAYDDCINFOEX_FLAG_PROJECTORDEVICE (1 << 0)
+#define ADL_DISPLAYDDCINFOEX_FLAG_EDIDEXTENSION (1 << 1)
+#define ADL_DISPLAYDDCINFOEX_FLAG_DIGITALDEVICE (1 << 2)
+#define ADL_DISPLAYDDCINFOEX_FLAG_HDMIAUDIODEVICE (1 << 3)
+#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORTS_AI (1 << 4)
+#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC601 (1 << 5)
+#define ADL_DISPLAYDDCINFOEX_FLAG_SUPPORT_xvYCC709 (1 << 6)
+// @}
+
+/// \defgroup define_cv_dongle Values used by ADL_CV_DongleSettings_xxx
+/// The following is applicable to ADL_DISPLAY_CONTYPE_ATICVDONGLE_JP and ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C_D only
+/// \deprecated Dropping support for Component Video displays
+// @{
+#define ADL_DISPLAY_CV_DONGLE_D1 (1 << 0)
+#define ADL_DISPLAY_CV_DONGLE_D2 (1 << 1)
+#define ADL_DISPLAY_CV_DONGLE_D3 (1 << 2)
+#define ADL_DISPLAY_CV_DONGLE_D4 (1 << 3)
+#define ADL_DISPLAY_CV_DONGLE_D5 (1 << 4)
+
+/// The following is applicable to ADL_DISPLAY_CONTYPE_ATICVDONGLE_NA and ADL_DISPLAY_CONTYPE_ATICVDONGLE_NONI2C only
+
+#define ADL_DISPLAY_CV_DONGLE_480I (1 << 0)
+#define ADL_DISPLAY_CV_DONGLE_480P (1 << 1)
+#define ADL_DISPLAY_CV_DONGLE_540P (1 << 2)
+#define ADL_DISPLAY_CV_DONGLE_720P (1 << 3)
+#define ADL_DISPLAY_CV_DONGLE_1080I (1 << 4)
+#define ADL_DISPLAY_CV_DONGLE_1080P (1 << 5)
+#define ADL_DISPLAY_CV_DONGLE_16_9 (1 << 6)
+#define ADL_DISPLAY_CV_DONGLE_720P50 (1 << 7)
+#define ADL_DISPLAY_CV_DONGLE_1080I25 (1 << 8)
+#define ADL_DISPLAY_CV_DONGLE_576I25 (1 << 9)
+#define ADL_DISPLAY_CV_DONGLE_576P50 (1 << 10)
+#define ADL_DISPLAY_CV_DONGLE_1080P24 (1 << 11)
+#define ADL_DISPLAY_CV_DONGLE_1080P25 (1 << 12)
+#define ADL_DISPLAY_CV_DONGLE_1080P30 (1 << 13)
+#define ADL_DISPLAY_CV_DONGLE_1080P50 (1 << 14)
+// @}
+
+/// \defgroup define_formats_ovr Formats Override Settings
+/// Display force modes flags
+// @{
+///
+#define ADL_DISPLAY_FORMAT_FORCE_720P 0x00000001
+#define ADL_DISPLAY_FORMAT_FORCE_1080I 0x00000002
+#define ADL_DISPLAY_FORMAT_FORCE_1080P 0x00000004
+#define ADL_DISPLAY_FORMAT_FORCE_720P50 0x00000008
+#define ADL_DISPLAY_FORMAT_FORCE_1080I25 0x00000010
+#define ADL_DISPLAY_FORMAT_FORCE_576I25 0x00000020
+#define ADL_DISPLAY_FORMAT_FORCE_576P50 0x00000040
+#define ADL_DISPLAY_FORMAT_FORCE_1080P24 0x00000080
+#define ADL_DISPLAY_FORMAT_FORCE_1080P25 0x00000100
+#define ADL_DISPLAY_FORMAT_FORCE_1080P30 0x00000200
+#define ADL_DISPLAY_FORMAT_FORCE_1080P50 0x00000400
+
+///< Below are \b EXTENDED display mode flags
+
+#define ADL_DISPLAY_FORMAT_CVDONGLEOVERIDE 0x00000001
+#define ADL_DISPLAY_FORMAT_CVMODEUNDERSCAN 0x00000002
+#define ADL_DISPLAY_FORMAT_FORCECONNECT_SUPPORTED 0x00000004
+#define ADL_DISPLAY_FORMAT_RESTRICT_FORMAT_SELECTION 0x00000008
+#define ADL_DISPLAY_FORMAT_SETASPECRATIO 0x00000010
+#define ADL_DISPLAY_FORMAT_FORCEMODES 0x00000020
+#define ADL_DISPLAY_FORMAT_LCDRTCCOEFF 0x00000040
+// @}
+
+/// Defines used by OD5
+#define ADL_PM_PARAM_DONT_CHANGE 0
+
+/// The following defines Bus types
+// @{
+#define ADL_BUSTYPE_PCI 0 /* PCI bus */
+#define ADL_BUSTYPE_AGP 1 /* AGP bus */
+#define ADL_BUSTYPE_PCIE 2 /* PCI Express bus */
+#define ADL_BUSTYPE_PCIE_GEN2 3 /* PCI Express 2nd generation bus */
+#define ADL_BUSTYPE_PCIE_GEN3 4 /* PCI Express 3rd generation bus */
+// @}
+
+/// \defgroup define_ws_caps Workstation Capabilities
+/// Workstation values
+// @{
+
+/// This value indicates that the workstation card supports active stereo though stereo output connector
+#define ADL_STEREO_SUPPORTED (1 << 2)
+/// This value indicates that the workstation card supports active stereo via "blue-line"
+#define ADL_STEREO_BLUE_LINE (1 << 3)
+/// This value is used to turn off stereo mode.
+#define ADL_STEREO_OFF 0
+/// This value indicates that the workstation card supports active stereo. This is also used to set the stereo mode to active though the stereo output connector
+#define ADL_STEREO_ACTIVE (1 << 1)
+/// This value indicates that the workstation card supports auto-stereo monitors with horizontal interleave. This is also used to set the stereo mode to use the auto-stereo monitor with horizontal interleave
+#define ADL_STEREO_AUTO_HORIZONTAL (1 << 30)
+/// This value indicates that the workstation card supports auto-stereo monitors with vertical interleave. This is also used to set the stereo mode to use the auto-stereo monitor with vertical interleave
+#define ADL_STEREO_AUTO_VERTICAL (1 << 31)
+/// This value indicates that the workstation card supports passive stereo, ie. non stereo sync
+#define ADL_STEREO_PASSIVE (1 << 6)
+/// This value indicates that the workstation card supports auto-stereo monitors with vertical interleave. This is also used to set the stereo mode to use the auto-stereo monitor with vertical interleave
+#define ADL_STEREO_PASSIVE_HORIZ (1 << 7)
+/// This value indicates that the workstation card supports auto-stereo monitors with vertical interleave. This is also used to set the stereo mode to use the auto-stereo monitor with vertical interleave
+#define ADL_STEREO_PASSIVE_VERT (1 << 8)
+/// This value indicates that the workstation card supports auto-stereo monitors with Samsung.
+#define ADL_STEREO_AUTO_SAMSUNG (1 << 11)
+/// This value indicates that the workstation card supports auto-stereo monitors with Tridility.
+#define ADL_STEREO_AUTO_TSL (1 << 12)
+/// This value indicates that the workstation card supports DeepBitDepth (10 bpp)
+#define ADL_DEEPBITDEPTH_10BPP_SUPPORTED (1 << 5)
+
+/// This value indicates that the workstation supports 8-Bit Grayscale
+#define ADL_8BIT_GREYSCALE_SUPPORTED (1 << 9)
+/// This value indicates that the workstation supports CUSTOM TIMING
+#define ADL_CUSTOM_TIMING_SUPPORTED (1 << 10)
+
+/// Load balancing is supported.
+#define ADL_WORKSTATION_LOADBALANCING_SUPPORTED 0x00000001
+/// Load balancing is available.
+#define ADL_WORKSTATION_LOADBALANCING_AVAILABLE 0x00000002
+
+/// Load balancing is disabled.
+#define ADL_WORKSTATION_LOADBALANCING_DISABLED 0x00000000
+/// Load balancing is Enabled.
+#define ADL_WORKSTATION_LOADBALANCING_ENABLED 0x00000001
+
+
+
+// @}
+
+/// \defgroup define_adapterspeed speed setting from the adapter
+// @{
+#define ADL_CONTEXT_SPEED_UNFORCED 0 /* default asic running speed */
+#define ADL_CONTEXT_SPEED_FORCEHIGH 1 /* asic running speed is forced to high */
+#define ADL_CONTEXT_SPEED_FORCELOW 2 /* asic running speed is forced to low */
+
+#define ADL_ADAPTER_SPEEDCAPS_SUPPORTED (1 << 0) /* change asic running speed setting is supported */
+// @}
+
+/// \defgroup define_glsync Genlock related values
+/// GL-Sync port types (unique values)
+// @{
+/// Unknown port of GL-Sync module
+#define ADL_GLSYNC_PORT_UNKNOWN 0
+/// BNC port of of GL-Sync module
+#define ADL_GLSYNC_PORT_BNC 1
+/// RJ45(1) port of of GL-Sync module
+#define ADL_GLSYNC_PORT_RJ45PORT1 2
+/// RJ45(2) port of of GL-Sync module
+#define ADL_GLSYNC_PORT_RJ45PORT2 3
+
+// GL-Sync Genlock settings mask (bit-vector)
+
+/// None of the ADLGLSyncGenlockConfig members are valid
+#define ADL_GLSYNC_CONFIGMASK_NONE 0
+/// The ADLGLSyncGenlockConfig.lSignalSource member is valid
+#define ADL_GLSYNC_CONFIGMASK_SIGNALSOURCE (1 << 0)
+/// The ADLGLSyncGenlockConfig.iSyncField member is valid
+#define ADL_GLSYNC_CONFIGMASK_SYNCFIELD (1 << 1)
+/// The ADLGLSyncGenlockConfig.iSampleRate member is valid
+#define ADL_GLSYNC_CONFIGMASK_SAMPLERATE (1 << 2)
+/// The ADLGLSyncGenlockConfig.lSyncDelay member is valid
+#define ADL_GLSYNC_CONFIGMASK_SYNCDELAY (1 << 3)
+/// The ADLGLSyncGenlockConfig.iTriggerEdge member is valid
+#define ADL_GLSYNC_CONFIGMASK_TRIGGEREDGE (1 << 4)
+/// The ADLGLSyncGenlockConfig.iScanRateCoeff member is valid
+#define ADL_GLSYNC_CONFIGMASK_SCANRATECOEFF (1 << 5)
+/// The ADLGLSyncGenlockConfig.lFramelockCntlVector member is valid
+#define ADL_GLSYNC_CONFIGMASK_FRAMELOCKCNTL (1 << 6)
+
+
+// GL-Sync Framelock control mask (bit-vector)
+
+/// Framelock is disabled
+#define ADL_GLSYNC_FRAMELOCKCNTL_NONE 0
+/// Framelock is enabled
+#define ADL_GLSYNC_FRAMELOCKCNTL_ENABLE ( 1 << 0)
+
+#define ADL_GLSYNC_FRAMELOCKCNTL_DISABLE ( 1 << 1)
+#define ADL_GLSYNC_FRAMELOCKCNTL_SWAP_COUNTER_RESET ( 1 << 2)
+#define ADL_GLSYNC_FRAMELOCKCNTL_SWAP_COUNTER_ACK ( 1 << 3)
+#define ADL_GLSYNC_FRAMELOCKCNTL_VERSION_KMD (1 << 4)
+
+#define ADL_GLSYNC_FRAMELOCKCNTL_STATE_ENABLE ( 1 << 0)
+#define ADL_GLSYNC_FRAMELOCKCNTL_STATE_KMD (1 << 4)
+
+// GL-Sync Framelock counters mask (bit-vector)
+#define ADL_GLSYNC_COUNTER_SWAP ( 1 << 0 )
+
+// GL-Sync Signal Sources (unique values)
+
+/// GL-Sync signal source is undefined
+#define ADL_GLSYNC_SIGNALSOURCE_UNDEFINED 0x00000100
+/// GL-Sync signal source is Free Run
+#define ADL_GLSYNC_SIGNALSOURCE_FREERUN 0x00000101
+/// GL-Sync signal source is the BNC GL-Sync port
+#define ADL_GLSYNC_SIGNALSOURCE_BNCPORT 0x00000102
+/// GL-Sync signal source is the RJ45(1) GL-Sync port
+#define ADL_GLSYNC_SIGNALSOURCE_RJ45PORT1 0x00000103
+/// GL-Sync signal source is the RJ45(2) GL-Sync port
+#define ADL_GLSYNC_SIGNALSOURCE_RJ45PORT2 0x00000104
+
+
+// GL-Sync Signal Types (unique values)
+
+/// GL-Sync signal type is unknown
+#define ADL_GLSYNC_SIGNALTYPE_UNDEFINED 0
+/// GL-Sync signal type is 480I
+#define ADL_GLSYNC_SIGNALTYPE_480I 1
+/// GL-Sync signal type is 576I
+#define ADL_GLSYNC_SIGNALTYPE_576I 2
+/// GL-Sync signal type is 480P
+#define ADL_GLSYNC_SIGNALTYPE_480P 3
+/// GL-Sync signal type is 576P
+#define ADL_GLSYNC_SIGNALTYPE_576P 4
+/// GL-Sync signal type is 720P
+#define ADL_GLSYNC_SIGNALTYPE_720P 5
+/// GL-Sync signal type is 1080P
+#define ADL_GLSYNC_SIGNALTYPE_1080P 6
+/// GL-Sync signal type is 1080I
+#define ADL_GLSYNC_SIGNALTYPE_1080I 7
+/// GL-Sync signal type is SDI
+#define ADL_GLSYNC_SIGNALTYPE_SDI 8
+/// GL-Sync signal type is TTL
+#define ADL_GLSYNC_SIGNALTYPE_TTL 9
+/// GL_Sync signal type is Analog
+#define ADL_GLSYNC_SIGNALTYPE_ANALOG 10
+
+// GL-Sync Sync Field options (unique values)
+
+///GL-Sync sync field option is undefined
+#define ADL_GLSYNC_SYNCFIELD_UNDEFINED 0
+///GL-Sync sync field option is Sync to Field 1 (used for Interlaced signal types)
+#define ADL_GLSYNC_SYNCFIELD_BOTH 1
+///GL-Sync sync field option is Sync to Both fields (used for Interlaced signal types)
+#define ADL_GLSYNC_SYNCFIELD_1 2
+
+
+// GL-Sync trigger edge options (unique values)
+
+/// GL-Sync trigger edge is undefined
+#define ADL_GLSYNC_TRIGGEREDGE_UNDEFINED 0
+/// GL-Sync trigger edge is the rising edge
+#define ADL_GLSYNC_TRIGGEREDGE_RISING 1
+/// GL-Sync trigger edge is the falling edge
+#define ADL_GLSYNC_TRIGGEREDGE_FALLING 2
+/// GL-Sync trigger edge is both the rising and the falling edge
+#define ADL_GLSYNC_TRIGGEREDGE_BOTH 3
+
+
+// GL-Sync scan rate coefficient/multiplier options (unique values)
+
+/// GL-Sync scan rate coefficient/multiplier is undefined
+#define ADL_GLSYNC_SCANRATECOEFF_UNDEFINED 0
+/// GL-Sync scan rate coefficient/multiplier is 5
+#define ADL_GLSYNC_SCANRATECOEFF_x5 1
+/// GL-Sync scan rate coefficient/multiplier is 4
+#define ADL_GLSYNC_SCANRATECOEFF_x4 2
+/// GL-Sync scan rate coefficient/multiplier is 3
+#define ADL_GLSYNC_SCANRATECOEFF_x3 3
+/// GL-Sync scan rate coefficient/multiplier is 5:2 (SMPTE)
+#define ADL_GLSYNC_SCANRATECOEFF_x5_DIV_2 4
+/// GL-Sync scan rate coefficient/multiplier is 2
+#define ADL_GLSYNC_SCANRATECOEFF_x2 5
+/// GL-Sync scan rate coefficient/multiplier is 3 : 2
+#define ADL_GLSYNC_SCANRATECOEFF_x3_DIV_2 6
+/// GL-Sync scan rate coefficient/multiplier is 5 : 4
+#define ADL_GLSYNC_SCANRATECOEFF_x5_DIV_4 7
+/// GL-Sync scan rate coefficient/multiplier is 1 (default)
+#define ADL_GLSYNC_SCANRATECOEFF_x1 8
+/// GL-Sync scan rate coefficient/multiplier is 4 : 5
+#define ADL_GLSYNC_SCANRATECOEFF_x4_DIV_5 9
+/// GL-Sync scan rate coefficient/multiplier is 2 : 3
+#define ADL_GLSYNC_SCANRATECOEFF_x2_DIV_3 10
+/// GL-Sync scan rate coefficient/multiplier is 1 : 2
+#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_2 11
+/// GL-Sync scan rate coefficient/multiplier is 2 : 5 (SMPTE)
+#define ADL_GLSYNC_SCANRATECOEFF_x2_DIV_5 12
+/// GL-Sync scan rate coefficient/multiplier is 1 : 3
+#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_3 13
+/// GL-Sync scan rate coefficient/multiplier is 1 : 4
+#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_4 14
+/// GL-Sync scan rate coefficient/multiplier is 1 : 5
+#define ADL_GLSYNC_SCANRATECOEFF_x1_DIV_5 15
+
+
+// GL-Sync port (signal presence) states (unique values)
+
+/// GL-Sync port state is undefined
+#define ADL_GLSYNC_PORTSTATE_UNDEFINED 0
+/// GL-Sync port is not connected
+#define ADL_GLSYNC_PORTSTATE_NOCABLE 1
+/// GL-Sync port is Idle
+#define ADL_GLSYNC_PORTSTATE_IDLE 2
+/// GL-Sync port has an Input signal
+#define ADL_GLSYNC_PORTSTATE_INPUT 3
+/// GL-Sync port is Output
+#define ADL_GLSYNC_PORTSTATE_OUTPUT 4
+
+
+// GL-Sync LED types (used index within ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array) (unique values)
+
+/// Index into the ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array for the one LED of the BNC port
+#define ADL_GLSYNC_LEDTYPE_BNC 0
+/// Index into the ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array for the Left LED of the RJ45(1) or RJ45(2) port
+#define ADL_GLSYNC_LEDTYPE_RJ45_LEFT 0
+/// Index into the ADL_Workstation_GLSyncPortState_Get returned ppGlSyncLEDs array for the Right LED of the RJ45(1) or RJ45(2) port
+#define ADL_GLSYNC_LEDTYPE_RJ45_RIGHT 1
+
+
+// GL-Sync LED colors (unique values)
+
+/// GL-Sync LED undefined color
+#define ADL_GLSYNC_LEDCOLOR_UNDEFINED 0
+/// GL-Sync LED is unlit
+#define ADL_GLSYNC_LEDCOLOR_NOLIGHT 1
+/// GL-Sync LED is yellow
+#define ADL_GLSYNC_LEDCOLOR_YELLOW 2
+/// GL-Sync LED is red
+#define ADL_GLSYNC_LEDCOLOR_RED 3
+/// GL-Sync LED is green
+#define ADL_GLSYNC_LEDCOLOR_GREEN 4
+/// GL-Sync LED is flashing green
+#define ADL_GLSYNC_LEDCOLOR_FLASH_GREEN 5
+
+
+// GL-Sync Port Control (refers one GL-Sync Port) (unique values)
+
+/// Used to configure the RJ54(1) or RJ42(2) port of GL-Sync is as Idle
+#define ADL_GLSYNC_PORTCNTL_NONE 0x00000000
+/// Used to configure the RJ54(1) or RJ42(2) port of GL-Sync is as Output
+#define ADL_GLSYNC_PORTCNTL_OUTPUT 0x00000001
+
+
+// GL-Sync Mode Control (refers one Display/Controller) (bitfields)
+
+/// Used to configure the display to use internal timing (not genlocked)
+#define ADL_GLSYNC_MODECNTL_NONE 0x00000000
+/// Bitfield used to configure the display as genlocked (either as Timing Client or as Timing Server)
+#define ADL_GLSYNC_MODECNTL_GENLOCK 0x00000001
+/// Bitfield used to configure the display as Timing Server
+#define ADL_GLSYNC_MODECNTL_TIMINGSERVER 0x00000002
+
+// GL-Sync Mode Status
+/// Display is currently not genlocked
+#define ADL_GLSYNC_MODECNTL_STATUS_NONE 0x00000000
+/// Display is currently genlocked
+#define ADL_GLSYNC_MODECNTL_STATUS_GENLOCK 0x00000001
+/// Display requires a mode switch
+#define ADL_GLSYNC_MODECNTL_STATUS_SETMODE_REQUIRED 0x00000002
+/// Display is capable of being genlocked
+#define ADL_GLSYNC_MODECNTL_STATUS_GENLOCK_ALLOWED 0x00000004
+
+#define ADL_MAX_GLSYNC_PORTS 8
+#define ADL_MAX_GLSYNC_PORT_LEDS 8
+
+// @}
+
+/// \defgroup define_crossfirestate CrossfireX state of a particular adapter CrossfireX combination
+// @{
+#define ADL_XFIREX_STATE_NOINTERCONNECT ( 1 << 0 ) /* Dongle / cable is missing */
+#define ADL_XFIREX_STATE_DOWNGRADEPIPES ( 1 << 1 ) /* CrossfireX can be enabled if pipes are downgraded */
+#define ADL_XFIREX_STATE_DOWNGRADEMEM ( 1 << 2 ) /* CrossfireX cannot be enabled unless mem downgraded */
+#define ADL_XFIREX_STATE_REVERSERECOMMENDED ( 1 << 3 ) /* Card reversal recommended, CrossfireX cannot be enabled. */
+#define ADL_XFIREX_STATE_3DACTIVE ( 1 << 4 ) /* 3D client is active - CrossfireX cannot be safely enabled */
+#define ADL_XFIREX_STATE_MASTERONSLAVE ( 1 << 5 ) /* Dongle is OK but master is on slave */
+#define ADL_XFIREX_STATE_NODISPLAYCONNECT ( 1 << 6 ) /* No (valid) display connected to master card. */
+#define ADL_XFIREX_STATE_NOPRIMARYVIEW ( 1 << 7 ) /* CrossfireX is enabled but master is not current primary device */
+#define ADL_XFIREX_STATE_DOWNGRADEVISMEM ( 1 << 8 ) /* CrossfireX cannot be enabled unless visible mem downgraded */
+#define ADL_XFIREX_STATE_LESSTHAN8LANE_MASTER ( 1 << 9 ) /* CrossfireX can be enabled however performance not optimal due to <8 lanes */
+#define ADL_XFIREX_STATE_LESSTHAN8LANE_SLAVE ( 1 << 10 ) /* CrossfireX can be enabled however performance not optimal due to <8 lanes */
+#define ADL_XFIREX_STATE_PEERTOPEERFAILED ( 1 << 11 ) /* CrossfireX cannot be enabled due to failed peer to peer test */
+#define ADL_XFIREX_STATE_MEMISDOWNGRADED ( 1 << 16 ) /* Notification that memory is currently downgraded */
+#define ADL_XFIREX_STATE_PIPESDOWNGRADED ( 1 << 17 ) /* Notification that pipes are currently downgraded */
+#define ADL_XFIREX_STATE_XFIREXACTIVE ( 1 << 18 ) /* CrossfireX is enabled on current device */
+#define ADL_XFIREX_STATE_VISMEMISDOWNGRADED ( 1 << 19 ) /* Notification that visible FB memory is currently downgraded */
+#define ADL_XFIREX_STATE_INVALIDINTERCONNECTION ( 1 << 20 ) /* Cannot support current inter-connection configuration */
+#define ADL_XFIREX_STATE_NONP2PMODE ( 1 << 21 ) /* CrossfireX will only work with clients supporting non P2P mode */
+#define ADL_XFIREX_STATE_DOWNGRADEMEMBANKS ( 1 << 22 ) /* CrossfireX cannot be enabled unless memory banks downgraded */
+#define ADL_XFIREX_STATE_MEMBANKSDOWNGRADED ( 1 << 23 ) /* Notification that memory banks are currently downgraded */
+#define ADL_XFIREX_STATE_DUALDISPLAYSALLOWED ( 1 << 24 ) /* Extended desktop or clone mode is allowed. */
+#define ADL_XFIREX_STATE_P2P_APERTURE_MAPPING ( 1 << 25 ) /* P2P mapping was through peer aperture */
+#define ADL_XFIREX_STATE_P2PFLUSH_REQUIRED ADL_XFIREX_STATE_P2P_APERTURE_MAPPING /* For back compatible */
+#define ADL_XFIREX_STATE_XSP_CONNECTED ( 1 << 26 ) /* There is CrossfireX side port connection between GPUs */
+#define ADL_XFIREX_STATE_ENABLE_CF_REBOOT_REQUIRED ( 1 << 27 ) /* System needs a reboot bofore enable CrossfireX */
+#define ADL_XFIREX_STATE_DISABLE_CF_REBOOT_REQUIRED ( 1 << 28 ) /* System needs a reboot after disable CrossfireX */
+#define ADL_XFIREX_STATE_DRV_HANDLE_DOWNGRADE_KEY ( 1 << 29 ) /* Indicate base driver handles the downgrade key updating */
+#define ADL_XFIREX_STATE_CF_RECONFIG_REQUIRED ( 1 << 30 ) /* CrossfireX need to be reconfigured by CCC because of a LDA chain broken */
+#define ADL_XFIREX_STATE_ERRORGETTINGSTATUS ( 1 << 31 ) /* Could not obtain current status */
+// @}
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_DISPLAY_ADJUSTMENT_PIXELFORMAT adjustment values
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+/// \defgroup define_pixel_formats Pixel Formats values
+/// This group defines the various Pixel Formats that a particular digital display can support. \n
+/// Since a display can support multiple formats, these values can be bit-or'ed to indicate the various formats \n
+// @{
+#define ADL_DISPLAY_PIXELFORMAT_UNKNOWN 0
+#define ADL_DISPLAY_PIXELFORMAT_RGB (1 << 0)
+#define ADL_DISPLAY_PIXELFORMAT_YCRCB444 (1 << 1) //Limited range
+#define ADL_DISPLAY_PIXELFORMAT_YCRCB422 (1 << 2) //Limited range
+#define ADL_DISPLAY_PIXELFORMAT_RGB_LIMITED_RANGE (1 << 3)
+#define ADL_DISPLAY_PIXELFORMAT_RGB_FULL_RANGE ADL_DISPLAY_PIXELFORMAT_RGB //Full range
+// @}
+
+/// \defgroup define_contype Connector Type Values
+/// ADLDisplayConfig.ulConnectorType defines
+// @{
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_UNKNOWN 0
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_NONI2C_JP 1
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_JPN 2
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_NA 3
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_CV_NONI2C_NA 4
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_VGA 5
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_DVI_D 6
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_DVI_I 7
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_HDMI_TYPE_A 8
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_HDMI_TYPE_B 9
+#define ADL_DL_DISPLAYCONFIG_CONTYPE_DISPLAYPORT 10
+// @}
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_DISPLAY_DISPLAYINFO_ Definitions
+// for ADLDisplayInfo.iDisplayInfoMask and ADLDisplayInfo.iDisplayInfoValue
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+/// \defgroup define_displayinfomask Display Info Mask Values
+// @{
+#define ADL_DISPLAY_DISPLAYINFO_DISPLAYCONNECTED 0x00000001
+#define ADL_DISPLAY_DISPLAYINFO_DISPLAYMAPPED 0x00000002
+#define ADL_DISPLAY_DISPLAYINFO_NONLOCAL 0x00000004
+#define ADL_DISPLAY_DISPLAYINFO_FORCIBLESUPPORTED 0x00000008
+#define ADL_DISPLAY_DISPLAYINFO_GENLOCKSUPPORTED 0x00000010
+#define ADL_DISPLAY_DISPLAYINFO_MULTIVPU_SUPPORTED 0x00000020
+#define ADL_DISPLAY_DISPLAYINFO_LDA_DISPLAY 0x00000040
+#define ADL_DISPLAY_DISPLAYINFO_MODETIMING_OVERRIDESSUPPORTED 0x00000080
+
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_SINGLE 0x00000100
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_CLONE 0x00000200
+
+/// Legacy support for XP
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_2VSTRETCH 0x00000400
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_2HSTRETCH 0x00000800
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_EXTENDED 0x00001000
+
+/// More support manners
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_NSTRETCH1GPU 0x00010000
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_NSTRETCHNGPU 0x00020000
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_RESERVED2 0x00040000
+#define ADL_DISPLAY_DISPLAYINFO_MANNER_SUPPORTED_RESERVED3 0x00080000
+
+/// Projector display type
+#define ADL_DISPLAY_DISPLAYINFO_SHOWTYPE_PROJECTOR 0x00100000
+
+// @}
+
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_ADAPTER_DISPLAY_MANNER_SUPPORTED_ Definitions
+// for ADLAdapterDisplayCap of ADL_Adapter_Display_Cap()
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+/// \defgroup define_adaptermanner Adapter Manner Support Values
+// @{
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_NOTACTIVE 0x00000001
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_SINGLE 0x00000002
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_CLONE 0x00000004
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_NSTRETCH1GPU 0x00000008
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_NSTRETCHNGPU 0x00000010
+
+/// Legacy support for XP
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_2VSTRETCH 0x00000020
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_2HSTRETCH 0x00000040
+#define ADL_ADAPTER_DISPLAYCAP_MANNER_SUPPORTED_EXTENDED 0x00000080
+
+#define ADL_ADAPTER_DISPLAYCAP_PREFERDISPLAY_SUPPORTED 0x00000100
+#define ADL_ADAPTER_DISPLAYCAP_BEZEL_SUPPORTED 0x00000200
+
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_DISPLAY_DISPLAYMAP_MANNER_ Definitions
+// for ADLDisplayMap.iDisplayMapMask and ADLDisplayMap.iDisplayMapValue
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_RESERVED 0x00000001
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_NOTACTIVE 0x00000002
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_SINGLE 0x00000004
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_CLONE 0x00000008
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_RESERVED1 0x00000010 // Removed NSTRETCH
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_HSTRETCH 0x00000020
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_VSTRETCH 0x00000040
+#define ADL_DISPLAY_DISPLAYMAP_MANNER_VLD 0x00000080
+
+// @}
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_DISPLAY_DISPLAYMAP_OPTION_ Definitions
+// for iOption in function ADL_Display_DisplayMapConfig_Get
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+#define ADL_DISPLAY_DISPLAYMAP_OPTION_GPUINFO 0x00000001
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_DISPLAY_DISPLAYTARGET_ Definitions
+// for ADLDisplayTarget.iDisplayTargetMask and ADLDisplayTarget.iDisplayTargetValue
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+#define ADL_DISPLAY_DISPLAYTARGET_PREFERRED 0x00000001
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_DISPLAY_POSSIBLEMAPRESULT_VALID Definitions
+// for ADLPossibleMapResult.iPossibleMapResultMask and ADLPossibleMapResult.iPossibleMapResultValue
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+#define ADL_DISPLAY_POSSIBLEMAPRESULT_VALID 0x00000001
+#define ADL_DISPLAY_POSSIBLEMAPRESULT_BEZELSUPPORTED 0x00000002
+#define ADL_DISPLAY_POSSIBLEMAPRESULT_OVERLAPSUPPORTED 0x00000004
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_DISPLAY_MODE_ Definitions
+// for ADLMode.iModeMask, ADLMode.iModeValue, and ADLMode.iModeFlag
+// (bit-vector)
+///////////////////////////////////////////////////////////////////////////
+/// \defgroup define_displaymode Display Mode Values
+// @{
+#define ADL_DISPLAY_MODE_COLOURFORMAT_565 0x00000001
+#define ADL_DISPLAY_MODE_COLOURFORMAT_8888 0x00000002
+#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_000 0x00000004
+#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_090 0x00000008
+#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_180 0x00000010
+#define ADL_DISPLAY_MODE_ORIENTATION_SUPPORTED_270 0x00000020
+#define ADL_DISPLAY_MODE_REFRESHRATE_ROUNDED 0x00000040
+#define ADL_DISPLAY_MODE_REFRESHRATE_ONLY 0x00000080
+
+#define ADL_DISPLAY_MODE_PROGRESSIVE_FLAG 0
+#define ADL_DISPLAY_MODE_INTERLACED_FLAG 2
+// @}
+
+///////////////////////////////////////////////////////////////////////////
+// ADL_OSMODEINFO Definitions
+///////////////////////////////////////////////////////////////////////////
+/// \defgroup define_osmode OS Mode Values
+// @{
+#define ADL_OSMODEINFOXPOS_DEFAULT -640
+#define ADL_OSMODEINFOYPOS_DEFAULT 0
+#define ADL_OSMODEINFOXRES_DEFAULT 640
+#define ADL_OSMODEINFOYRES_DEFAULT 480
+#define ADL_OSMODEINFOXRES_DEFAULT800 800
+#define ADL_OSMODEINFOYRES_DEFAULT600 600
+#define ADL_OSMODEINFOREFRESHRATE_DEFAULT 60
+#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT 8
+#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT16 16
+#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT24 24
+#define ADL_OSMODEINFOCOLOURDEPTH_DEFAULT32 32
+#define ADL_OSMODEINFOORIENTATION_DEFAULT 0
+#define ADL_OSMODEINFOORIENTATION_DEFAULT_WIN7 DISPLAYCONFIG_ROTATION_FORCE_UINT32
+#define ADL_OSMODEFLAG_DEFAULT 0
+// @}
+
+
+///////////////////////////////////////////////////////////////////////////
+// ADLThreadingModel Enumeration
+///////////////////////////////////////////////////////////////////////////
+/// \defgroup thread_model
+/// Used with \ref ADL_Main_ControlX2_Create and \ref ADL2_Main_ControlX2_Create to specify how ADL handles API calls when executed by multiple threads concurrently.
+/// \brief Declares ADL threading behavior.
+// @{
+typedef enum ADLThreadingModel
+{
+ ADL_THREADING_UNLOCKED = 0, /*!< Default behavior. ADL will not enforce serialization of ADL API executions by multiple threads. Multiple threads will be allowed to enter to ADL at the same time. Note that ADL library is not guaranteed to be thread-safe. Client that calls ADL_Main_Control_Create have to provide its own mechanism for ADL calls serialization. */
+ ADL_THREADING_LOCKED /*!< ADL will enforce serialization of ADL API when called by multiple threads. Only single thread will be allowed to enter ADL API at the time. This option makes ADL calls thread-safe. You shouldn't use this option if ADL calls will be executed on Linux on x-server rendering thread. It can cause the application to hung. */
+}ADLThreadingModel;
+
+// @}
+///////////////////////////////////////////////////////////////////////////
+// ADLPurposeCode Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLPurposeCode
+{
+ ADL_PURPOSECODE_NORMAL = 0,
+ ADL_PURPOSECODE_HIDE_MODE_SWITCH,
+ ADL_PURPOSECODE_MODE_SWITCH,
+ ADL_PURPOSECODE_ATTATCH_DEVICE,
+ ADL_PURPOSECODE_DETACH_DEVICE,
+ ADL_PURPOSECODE_SETPRIMARY_DEVICE,
+ ADL_PURPOSECODE_GDI_ROTATION,
+ ADL_PURPOSECODE_ATI_ROTATION
+};
+///////////////////////////////////////////////////////////////////////////
+// ADLAngle Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLAngle
+{
+ ADL_ANGLE_LANDSCAPE = 0,
+ ADL_ANGLE_ROTATERIGHT = 90,
+ ADL_ANGLE_ROTATE180 = 180,
+ ADL_ANGLE_ROTATELEFT = 270,
+};
+
+///////////////////////////////////////////////////////////////////////////
+// ADLOrientationDataType Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLOrientationDataType
+{
+ ADL_ORIENTATIONTYPE_OSDATATYPE,
+ ADL_ORIENTATIONTYPE_NONOSDATATYPE
+};
+
+///////////////////////////////////////////////////////////////////////////
+// ADLPanningMode Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLPanningMode
+{
+ ADL_PANNINGMODE_NO_PANNING = 0,
+ ADL_PANNINGMODE_AT_LEAST_ONE_NO_PANNING = 1,
+ ADL_PANNINGMODE_ALLOW_PANNING = 2,
+};
+
+///////////////////////////////////////////////////////////////////////////
+// ADLLARGEDESKTOPTYPE Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLLARGEDESKTOPTYPE
+{
+ ADL_LARGEDESKTOPTYPE_NORMALDESKTOP = 0,
+ ADL_LARGEDESKTOPTYPE_PSEUDOLARGEDESKTOP = 1,
+ ADL_LARGEDESKTOPTYPE_VERYLARGEDESKTOP = 2
+};
+
+///////////////////////////////////////////////////////////////////////////
+// ADLPlatform Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLPlatForm
+{
+ GRAPHICS_PLATFORM_DESKTOP = 0,
+ GRAPHICS_PLATFORM_MOBILE = 1
+};
+// Other Definitions for internal use
+
+// Values for ADL_Display_WriteAndReadI2CRev_Get()
+
+#define ADL_I2C_MAJOR_API_REV 0x00000001
+#define ADL_I2C_MINOR_DEFAULT_API_REV 0x00000000
+#define ADL_I2C_MINOR_OEM_API_REV 0x00000001
+
+// Values for ADL_Display_WriteAndReadI2C()
+#define ADL_DL_I2C_LINE_OEM 0x00000001
+#define ADL_DL_I2C_LINE_OD_CONTROL 0x00000002
+#define ADL_DL_I2C_LINE_OEM2 0x00000003
+#define ADL_DL_I2C_LINE_OEM3 0x00000004
+#define ADL_DL_I2C_LINE_OEM4 0x00000005
+#define ADL_DL_I2C_LINE_OEM5 0x00000006
+#define ADL_DL_I2C_LINE_OEM6 0x00000007
+
+// Max size of I2C data buffer
+#define ADL_DL_I2C_MAXDATASIZE 0x00000040
+#define ADL_DL_I2C_MAXWRITEDATASIZE 0x0000000C
+#define ADL_DL_I2C_MAXADDRESSLENGTH 0x00000006
+#define ADL_DL_I2C_MAXOFFSETLENGTH 0x00000004
+
+
+/// Values for ADLDisplayProperty.iPropertyType
+#define ADL_DL_DISPLAYPROPERTY_TYPE_UNKNOWN 0
+#define ADL_DL_DISPLAYPROPERTY_TYPE_EXPANSIONMODE 1
+#define ADL_DL_DISPLAYPROPERTY_TYPE_USEUNDERSCANSCALING 2
+/// Enables ITC processing for HDMI panels that are capable of the feature
+#define ADL_DL_DISPLAYPROPERTY_TYPE_ITCFLAGENABLE 9
+
+
+/// Values for ADLDisplayContent.iContentType
+/// Certain HDMI panels that support ITC have support for a feature such that, the display on the panel
+/// can be adjusted to optimize the view of the content being displayed, depending on the type of content.
+#define ADL_DL_DISPLAYCONTENT_TYPE_GRAPHICS 1
+#define ADL_DL_DISPLAYCONTENT_TYPE_PHOTO 2
+#define ADL_DL_DISPLAYCONTENT_TYPE_CINEMA 4
+#define ADL_DL_DISPLAYCONTENT_TYPE_GAME 8
+
+
+
+
+
+//values for ADLDisplayProperty.iExpansionMode
+#define ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_CENTER 0
+#define ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_FULLSCREEN 1
+#define ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_ASPECTRATIO 2
+
+//values for ADL_Display_DitherState_Get
+#define ADL_DL_DISPLAY_DITHER_UNKNOWN 0
+#define ADL_DL_DISPLAY_DITHER_DISABLED 1
+#define ADL_DL_DISPLAY_DITHER_ENABLED 2
+
+/// Display Get Cached EDID flag
+#define ADL_MAX_EDIDDATA_SIZE 256 // number of UCHAR
+#define ADL_MAX_OVERRIDEEDID_SIZE 512 // number of UCHAR
+#define ADL_MAX_EDID_EXTENSION_BLOCKS 3
+
+#define ADL_DL_CONTROLLER_OVERLAY_ALPHA 0
+#define ADL_DL_CONTROLLER_OVERLAY_ALPHAPERPIX 1
+
+#define ADL_DL_DISPLAY_DATA_PACKET__INFO_PACKET_RESET 0x00000000
+#define ADL_DL_DISPLAY_DATA_PACKET__INFO_PACKET_SET 0x00000001
+#define ADL_DL_DISPLAY_DATA_PACKET__INFO_PACKET_SCAN 0x00000002
+
+///\defgroup define_display_packet Display Data Packet Types
+// @{
+#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__AVI 0x00000001
+#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__RESERVED 0x00000002
+#define ADL_DL_DISPLAY_DATA_PACKET__TYPE__VENDORINFO 0x00000004
+// @}
+
+// matrix types
+#define ADL_GAMUT_MATRIX_SD 1 // SD matrix i.e. BT601
+#define ADL_GAMUT_MATRIX_HD 2 // HD matrix i.e. BT709
+
+///\defgroup define_clockinfo_flags Clock flags
+/// Used by ADLAdapterODClockInfo.iFlag
+// @{
+#define ADL_DL_CLOCKINFO_FLAG_FULLSCREEN3DONLY 0x00000001
+#define ADL_DL_CLOCKINFO_FLAG_ALWAYSFULLSCREEN3D 0x00000002
+#define ADL_DL_CLOCKINFO_FLAG_VPURECOVERYREDUCED 0x00000004
+#define ADL_DL_CLOCKINFO_FLAG_THERMALPROTECTION 0x00000008
+// @}
+
+// Supported GPUs
+// ADL_Display_PowerXpressActiveGPU_Get()
+#define ADL_DL_POWERXPRESS_GPU_INTEGRATED 1
+#define ADL_DL_POWERXPRESS_GPU_DISCRETE 2
+
+// Possible values for lpOperationResult
+// ADL_Display_PowerXpressActiveGPU_Get()
+#define ADL_DL_POWERXPRESS_SWITCH_RESULT_STARTED 1 // Switch procedure has been started - Windows platform only
+#define ADL_DL_POWERXPRESS_SWITCH_RESULT_DECLINED 2 // Switch procedure cannot be started - All platforms
+#define ADL_DL_POWERXPRESS_SWITCH_RESULT_ALREADY 3 // System already has required status - All platforms
+#define ADL_DL_POWERXPRESS_SWITCH_RESULT_DEFERRED 5 // Switch was deferred and requires an X restart - Linux platform only
+
+// PowerXpress support version
+// ADL_Display_PowerXpressVersion_Get()
+#define ADL_DL_POWERXPRESS_VERSION_MAJOR 2 // Current PowerXpress support version 2.0
+#define ADL_DL_POWERXPRESS_VERSION_MINOR 0
+
+#define ADL_DL_POWERXPRESS_VERSION (((ADL_DL_POWERXPRESS_VERSION_MAJOR) << 16) | ADL_DL_POWERXPRESS_VERSION_MINOR)
+
+//values for ADLThermalControllerInfo.iThermalControllerDomain
+#define ADL_DL_THERMAL_DOMAIN_OTHER 0
+#define ADL_DL_THERMAL_DOMAIN_GPU 1
+
+//values for ADLThermalControllerInfo.iFlags
+#define ADL_DL_THERMAL_FLAG_INTERRUPT 1
+#define ADL_DL_THERMAL_FLAG_FANCONTROL 2
+
+///\defgroup define_fanctrl Fan speed cotrol
+/// Values for ADLFanSpeedInfo.iFlags
+// @{
+#define ADL_DL_FANCTRL_SUPPORTS_PERCENT_READ 1
+#define ADL_DL_FANCTRL_SUPPORTS_PERCENT_WRITE 2
+#define ADL_DL_FANCTRL_SUPPORTS_RPM_READ 4
+#define ADL_DL_FANCTRL_SUPPORTS_RPM_WRITE 8
+// @}
+
+//values for ADLFanSpeedValue.iSpeedType
+#define ADL_DL_FANCTRL_SPEED_TYPE_PERCENT 1
+#define ADL_DL_FANCTRL_SPEED_TYPE_RPM 2
+
+//values for ADLFanSpeedValue.iFlags
+#define ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED 1
+
+// MVPU interfaces
+#define ADL_DL_MAX_MVPU_ADAPTERS 4
+#define MVPU_ADAPTER_0 0x00000001
+#define MVPU_ADAPTER_1 0x00000002
+#define MVPU_ADAPTER_2 0x00000004
+#define MVPU_ADAPTER_3 0x00000008
+#define ADL_DL_MAX_REGISTRY_PATH 256
+
+//values for ADLMVPUStatus.iStatus
+#define ADL_DL_MVPU_STATUS_OFF 0
+#define ADL_DL_MVPU_STATUS_ON 1
+
+// values for ASIC family
+///\defgroup define_Asic_type Detailed asic types
+/// Defines for Adapter ASIC family type
+// @{
+#define ADL_ASIC_UNDEFINED 0
+#define ADL_ASIC_DISCRETE (1 << 0)
+#define ADL_ASIC_INTEGRATED (1 << 1)
+#define ADL_ASIC_FIREGL (1 << 2)
+#define ADL_ASIC_FIREMV (1 << 3)
+#define ADL_ASIC_XGP (1 << 4)
+#define ADL_ASIC_FUSION (1 << 5)
+#define ADL_ASIC_FIRESTREAM (1 << 6)
+// @}
+
+///\defgroup define_detailed_timing_flags Detailed Timimg Flags
+/// Defines for ADLDetailedTiming.sTimingFlags field
+// @{
+#define ADL_DL_TIMINGFLAG_DOUBLE_SCAN 0x0001
+//sTimingFlags is set when the mode is INTERLACED, if not PROGRESSIVE
+#define ADL_DL_TIMINGFLAG_INTERLACED 0x0002
+//sTimingFlags is set when the Horizontal Sync is POSITIVE, if not NEGATIVE
+#define ADL_DL_TIMINGFLAG_H_SYNC_POLARITY 0x0004
+//sTimingFlags is set when the Vertical Sync is POSITIVE, if not NEGATIVE
+#define ADL_DL_TIMINGFLAG_V_SYNC_POLARITY 0x0008
+// @}
+
+///\defgroup define_modetiming_standard Timing Standards
+/// Defines for ADLDisplayModeInfo.iTimingStandard field
+// @{
+#define ADL_DL_MODETIMING_STANDARD_CVT 0x00000001 // CVT Standard
+#define ADL_DL_MODETIMING_STANDARD_GTF 0x00000002 // GFT Standard
+#define ADL_DL_MODETIMING_STANDARD_DMT 0x00000004 // DMT Standard
+#define ADL_DL_MODETIMING_STANDARD_CUSTOM 0x00000008 // User-defined standard
+#define ADL_DL_MODETIMING_STANDARD_DRIVER_DEFAULT 0x00000010 // Remove Mode from overriden list
+#define ADL_DL_MODETIMING_STANDARD_CVT_RB 0x00000020 // CVT-RB Standard
+// @}
+
+// \defgroup define_xserverinfo driver x-server info
+/// These flags are used by ADL_XServerInfo_Get()
+// @
+
+/// Xinerama is active in the x-server, Xinerama extension may report it to be active but it
+/// may not be active in x-server
+#define ADL_XSERVERINFO_XINERAMAACTIVE (1<<0)
+
+/// RandR 1.2 is supported by driver, RandR extension may report version 1.2
+/// but driver may not support it
+#define ADL_XSERVERINFO_RANDR12SUPPORTED (1<<1)
+// @
+
+
+///\defgroup define_eyefinity_constants Eyefinity Definitions
+// @{
+
+#define ADL_CONTROLLERVECTOR_0 1 // ADL_CONTROLLERINDEX_0 = 0, (1 << ADL_CONTROLLERINDEX_0)
+#define ADL_CONTROLLERVECTOR_1 2 // ADL_CONTROLLERINDEX_1 = 1, (1 << ADL_CONTROLLERINDEX_1)
+
+#define ADL_DISPLAY_SLSGRID_ORIENTATION_000 0x00000001
+#define ADL_DISPLAY_SLSGRID_ORIENTATION_090 0x00000002
+#define ADL_DISPLAY_SLSGRID_ORIENTATION_180 0x00000004
+#define ADL_DISPLAY_SLSGRID_ORIENTATION_270 0x00000008
+#define ADL_DISPLAY_SLSGRID_CAP_OPTION_RELATIVETO_LANDSCAPE 0x00000001
+#define ADL_DISPLAY_SLSGRID_CAP_OPTION_RELATIVETO_CURRENTANGLE 0x00000002
+#define ADL_DISPLAY_SLSGRID_PORTAIT_MODE 0x00000004
+
+
+#define ADL_DISPLAY_SLSMAPCONFIG_GET_OPTION_RELATIVETO_LANDSCAPE 0x00000001
+#define ADL_DISPLAY_SLSMAPCONFIG_GET_OPTION_RELATIVETO_CURRENTANGLE 0x00000002
+
+#define ADL_DISPLAY_SLSMAPCONFIG_CREATE_OPTION_RELATIVETO_LANDSCAPE 0x00000001
+#define ADL_DISPLAY_SLSMAPCONFIG_CREATE_OPTION_RELATIVETO_CURRENTANGLE 0x00000002
+
+#define ADL_DISPLAY_SLSMAPCONFIG_REARRANGE_OPTION_RELATIVETO_LANDSCAPE 0x00000001
+#define ADL_DISPLAY_SLSMAPCONFIG_REARRANGE_OPTION_RELATIVETO_CURRENTANGLE 0x00000002
+
+
+#define ADL_DISPLAY_SLSGRID_RELATIVETO_LANDSCAPE 0x00000010
+#define ADL_DISPLAY_SLSGRID_RELATIVETO_CURRENTANGLE 0x00000020
+
+
+/// The bit mask identifies displays is currently in bezel mode.
+#define ADL_DISPLAY_SLSMAP_BEZELMODE 0x00000010
+/// The bit mask identifies displays from this map is arranged.
+#define ADL_DISPLAY_SLSMAP_DISPLAYARRANGED 0x00000002
+/// The bit mask identifies this map is currently in used for the current adapter.
+#define ADL_DISPLAY_SLSMAP_CURRENTCONFIG 0x00000004
+
+ ///For onlay active SLS map info
+#define ADL_DISPLAY_SLSMAPINDEXLIST_OPTION_ACTIVE 0x00000001
+
+///For Bezel
+#define ADL_DISPLAY_BEZELOFFSET_STEPBYSTEPSET 0x00000004
+#define ADL_DISPLAY_BEZELOFFSET_COMMIT 0x00000008
+
+// @}
+
+///\defgroup define_powerxpress_constants PowerXpress Definitions
+// @{
+
+/// The bit mask identifies PX caps for ADLPXConfigCaps.iPXConfigCapMask and ADLPXConfigCaps.iPXConfigCapValue
+#define ADL_PX_CONFIGCAPS_SPLASHSCREEN_SUPPORT 0x0001
+#define ADL_PX_CONFIGCAPS_CF_SUPPORT 0x0002
+#define ADL_PX_CONFIGCAPS_MUXLESS 0x0004
+#define ADL_PX_CONFIGCAPS_PROFILE_COMPLIANT 0x0008
+#define ADL_PX_CONFIGCAPS_NON_AMD_DRIVEN_DISPLAYS 0x0010
+#define ADL_PX_CONFIGCAPS_FIXED_SUPPORT 0x0020
+#define ADL_PX_CONFIGCAPS_DYNAMIC_SUPPORT 0x0040
+#define ADL_PX_CONFIGCAPS_HIDE_AUTO_SWITCH 0x0080
+
+/// The bit mask identifies PX schemes for ADLPXSchemeRange
+#define ADL_PX_SCHEMEMASK_FIXED 0x0001
+#define ADL_PX_SCHEMEMASK_DYNAMIC 0x0002
+
+/// PX Schemes
+typedef enum _ADLPXScheme
+{
+ ADL_PX_SCHEME_INVALID = 0,
+ ADL_PX_SCHEME_FIXED = ADL_PX_SCHEMEMASK_FIXED,
+ ADL_PX_SCHEME_DYNAMIC = ADL_PX_SCHEMEMASK_DYNAMIC
+}ADLPXScheme;
+
+/// Just keep the old definitions for compatibility, need to be removed later
+typedef enum PXScheme
+{
+ PX_SCHEME_INVALID = 0,
+ PX_SCHEME_FIXED = 1,
+ PX_SCHEME_DYNAMIC = 2
+} PXScheme;
+
+
+// @}
+
+///\defgroup define_appprofiles For Application Profiles
+// @{
+
+#define ADL_APP_PROFILE_FILENAME_LENGTH 64
+#define ADL_APP_PROFILE_TIMESTAMP_LENGTH 32
+#define ADL_APP_PROFILE_VERSION_LENGTH 32
+#define ADL_APP_PROFILE_PROPERTY_LENGTH 64
+
+enum ApplicationListType
+{
+ ADL_PX40_MRU,
+ ADL_PX40_MISSED,
+ ADL_PX40_DISCRETE,
+ ADL_PX40_INTEGRATED,
+
+ ADL_PX40_TOTAL
+};
+
+typedef enum _ADLProfilePropertyType
+{
+ ADL_PROFILEPROPERTY_TYPE_BINARY = 0,
+ ADL_PROFILEPROPERTY_TYPE_BOOLEAN,
+ ADL_PROFILEPROPERTY_TYPE_DWORD,
+ ADL_PROFILEPROPERTY_TYPE_QWORD,
+ ADL_PROFILEPROPERTY_TYPE_ENUMERATED,
+ ADL_PROFILEPROPERTY_TYPE_STRING
+}ADLProfilePropertyType;
+
+
+// @}
+
+///\defgroup define_dp12 For Display Port 1.2
+// @{
+
+/// Maximum Relative Address Link
+#define ADL_MAX_RAD_LINK_COUNT 15
+
+// @}
+
+///\defgroup defines_gamutspace Driver Supported Gamut Space
+// @{
+
+/// The flags desribes that gamut is related to source or to destination and to overlay or to graphics
+#define ADL_GAMUT_REFERENCE_SOURCE (1 << 0)
+#define ADL_GAMUT_GAMUT_VIDEO_CONTENT (1 << 1)
+
+/// The flags are used to describe the source of gamut and how read information from struct ADLGamutData
+#define ADL_CUSTOM_WHITE_POINT (1 << 0)
+#define ADL_CUSTOM_GAMUT (1 << 1)
+
+/// The define means the predefined gamut values .
+///Driver uses to find entry in the table and apply appropriate gamut space.
+#define ADL_GAMUT_SPACE_CCIR_709 (1 << 0)
+#define ADL_GAMUT_SPACE_CCIR_601 (1 << 1)
+#define ADL_GAMUT_SPACE_ADOBE_RGB (1 << 2)
+#define ADL_GAMUT_SPACE_CIE_RGB (1 << 3)
+#define ADL_GAMUT_SPACE_CUSTOM (1 << 4)
+
+/// Predefine white point values are structed similar to gamut .
+#define ADL_WHITE_POINT_5000K (1 << 0)
+#define ADL_WHITE_POINT_6500K (1 << 1)
+#define ADL_WHITE_POINT_7500K (1 << 2)
+#define ADL_WHITE_POINT_9300K (1 << 3)
+#define ADL_WHITE_POINT_CUSTOM (1 << 4)
+
+///gamut and white point coordinates are from 0.0 -1.0 and divider is used to find the real value .
+/// X float = X int /divider
+#define ADL_GAMUT_WHITEPOINT_DIVIDER 10000
+
+///gamma a0 coefficient uses the following divider:
+#define ADL_REGAMMA_COEFFICIENT_A0_DIVIDER 10000000
+///gamma a1 ,a2,a3 coefficients use the following divider:
+#define ADL_REGAMMA_COEFFICIENT_A1A2A3_DIVIDER 1000
+
+///describes whether the coefficients are from EDID or custom user values.
+#define ADL_EDID_REGAMMA_COEFFICIENTS (1 << 0)
+///Used for struct ADLRegamma. Feature if set use gamma ramp, if missing use regamma coefficents
+#define ADL_USE_GAMMA_RAMP (1 << 4)
+///Used for struct ADLRegamma. If the gamma ramp flag is used then the driver could apply de gamma corretion to the supplied curve and this depends on this flag
+#define ADL_APPLY_DEGAMMA (1 << 5)
+
+// @}
+
+/// \defgroup define_ddcinfo_pixelformats DDCInfo Pixel Formats
+// @{
+/// defines for iPanelPixelFormat in struct ADLDDCInfo2
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB656 0x00000001L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB666 0x00000002L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB888 0x00000004L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB101010 0x00000008L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB161616 0x00000010L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB_RESERVED1 0x00000020L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB_RESERVED2 0x00000040L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_RGB_RESERVED3 0x00000080L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_XRGB_BIAS101010 0x00000100L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR444_8BPCC 0x00000200L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR444_10BPCC 0x00000400L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR444_12BPCC 0x00000800L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR422_8BPCC 0x00001000L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR422_10BPCC 0x00002000L
+#define ADL_DISPLAY_DDCINFO_PIXEL_FORMAT_YCBCR422_12BPCC 0x00004000L
+// @}
+
+
+
+/// \defgroup define_dbd_state Deep Bit Depth
+// @{
+
+/// defines for ADL_Workstation_DeepBitDepth_Get and ADL_Workstation_DeepBitDepth_Set functions
+// This value indicates that the deep bit depth state is forced off
+#define ADL_DEEPBITDEPTH_FORCEOFF 0
+/// This value indicates that the deep bit depth state is set to auto, the driver will automatically enable the
+/// appropriate deep bit depth state depending on what connected display supports.
+#define ADL_DEEPBITDEPTH_10BPP_AUTO 1
+/// This value indicates that the deep bit depth state is forced on to 10 bits per pixel, this is regardless if the display
+/// supports 10 bpp.
+#define ADL_DEEPBITDEPTH_10BPP_FORCEON 2
+
+/// defines for ADLAdapterConfigMemory of ADL_Adapter_ConfigMemory_Get
+/// If this bit is set, it indicates that the Deep Bit Depth pixel is set on the display
+#define ADL_ADAPTER_CONFIGMEMORY_DBD (1 << 0)
+/// If this bit is set, it indicates that the display is rotated (90, 180 or 270)
+#define ADL_ADAPTER_CONFIGMEMORY_ROTATE (1 << 1)
+/// If this bit is set, it indicates that passive stereo is set on the display
+#define ADL_ADAPTER_CONFIGMEMORY_STEREO_PASSIVE (1 << 2)
+/// If this bit is set, it indicates that the active stereo is set on the display
+#define ADL_ADAPTER_CONFIGMEMORY_STEREO_ACTIVE (1 << 3)
+/// If this bit is set, it indicates that the tear free vsync is set on the display
+#define ADL_ADAPTER_CONFIGMEMORY_ENHANCEDVSYNC (1 << 4)
+#define ADL_ADAPTER_CONFIGMEMORY_TEARFREEVSYNC (1 << 4)
+/// @}
+
+/// \defgroup define_adl_validmemoryrequiredfields Memory Type
+/// @{
+
+/// This group defines memory types in ADLMemoryRequired struct \n
+/// Indicates that this is the visible memory
+#define ADL_MEMORYREQTYPE_VISIBLE (1 << 0)
+/// Indicates that this is the invisible memory.
+#define ADL_MEMORYREQTYPE_INVISIBLE (1 << 1)
+/// Indicates that this is amount of visible memory per GPU that should be reserved for all other allocations.
+#define ADL_MEMORYREQTYPE_GPURESERVEDVISIBLE (1 << 2)
+/// @}
+
+/// \defgroup define_adapter_tear_free_status
+/// Used in ADL_Adapter_TEAR_FREE_Set and ADL_Adapter_TFD_Get functions to indicate the tear free
+/// desktop status.
+/// @{
+/// Tear free desktop is enabled.
+#define ADL_ADAPTER_TEAR_FREE_ON 1
+/// Tear free desktop can't be enabled due to a lack of graphic adapter memory.
+#define ADL_ADAPTER_TEAR_FREE_NOTENOUGHMEM -1
+/// Tear free desktop can't be enabled due to quad buffer stereo being enabled.
+#define ADL_ADAPTER_TEAR_FREE_OFF_ERR_QUADBUFFERSTEREO -2
+/// Tear free desktop can't be enabled due to MGPU-SLS being enabled.
+#define ADL_ADAPTER_TEAR_FREE_OFF_ERR_MGPUSLD -3
+/// Tear free desktop is disabled.
+#define ADL_ADAPTER_TEAR_FREE_OFF 0
+/// @}
+
+/// \defgroup define_adapter_crossdisplay_platforminfo
+/// Used in ADL_Adapter_CrossDisplayPlatformInfo_Get function to indicate the Crossdisplay platform info.
+/// @{
+/// CROSSDISPLAY platform.
+#define ADL_CROSSDISPLAY_PLATFORM (1 << 0)
+/// CROSSDISPLAY platform for Lasso station.
+#define ADL_CROSSDISPLAY_PLATFORM_LASSO (1 << 1)
+/// CROSSDISPLAY platform for docking station.
+#define ADL_CROSSDISPLAY_PLATFORM_DOCKSTATION (1 << 2)
+/// @}
+
+/// \defgroup define_adapter_crossdisplay_option
+/// Used in ADL_Adapter_CrossdisplayInfoX2_Set function to indicate cross display options.
+/// @{
+/// Checking if 3D application is runnning. If yes, not to do switch, return ADL_OK_WAIT; otherwise do switch.
+#define ADL_CROSSDISPLAY_OPTION_NONE 0
+/// Force switching without checking for running 3D applications
+#define ADL_CROSSDISPLAY_OPTION_FORCESWITCH (1 << 0)
+/// @}
+
+/// \defgroup define_adapter_states Adapter Capabilities
+/// These defines the capabilities supported by an adapter. It is used by \ref ADL_Adapter_ConfigureState_Get
+/// @{
+/// Indicates that the adapter is headless (i.e. no displays can be connected to it)
+#define ADL_ADAPTERCONFIGSTATE_HEADLESS ( 1 << 2 )
+/// Indicates that the adapter is configured to define the main rendering capabilities. For example, adapters
+/// in Crossfire(TM) configuration, this bit would only be set on the adapter driving the display(s).
+#define ADL_ADAPTERCONFIGSTATE_REQUISITE_RENDER ( 1 << 0 )
+/// Indicates that the adapter is configured to be used to unload some of the rendering work for a particular
+/// requisite rendering adapter. For eample, for adapters in a Crossfire configuration, this bit would be set
+/// on all adapters that are currently not driving the display(s)
+#define ADL_ADAPTERCONFIGSTATE_ANCILLARY_RENDER ( 1 << 1 )
+/// @}
+
+/// \defgroup define_controllermode_ulModifiers
+/// These defines the detailed actions supported by set viewport. It is used by \ref ADL_Display_ViewPort_Set
+/// @{
+/// Indicate that the viewport set will change the view position
+#define ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_POSITION 0x00000001
+/// Indicate that the viewport set will change the view PanLock
+#define ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_PANLOCK 0x00000002
+/// Indicate that the viewport set will change the view size
+#define ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_SIZE 0x00000008
+/// @}
+
+/// \defgroup defines for Mirabilis
+/// These defines are used for the Mirabilis feature
+/// @{
+///
+/// Indicates the maximum number of audio sample rates
+#define ADL_MAX_AUDIO_SAMPLE_RATE_COUNT 16
+/// @}
+
+///////////////////////////////////////////////////////////////////////////
+// ADLMultiChannelSplitStateFlag Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLMultiChannelSplitStateFlag
+{
+ ADLMultiChannelSplit_Unitialized = 0,
+ ADLMultiChannelSplit_Disabled = 1,
+ ADLMultiChannelSplit_Enabled = 2,
+ ADLMultiChannelSplit_SaveProfile = 3
+};
+
+///////////////////////////////////////////////////////////////////////////
+// ADLSampleRate Enumeration
+///////////////////////////////////////////////////////////////////////////
+enum ADLSampleRate
+{
+ ADLSampleRate_32KHz =0,
+ ADLSampleRate_44P1KHz,
+ ADLSampleRate_48KHz,
+ ADLSampleRate_88P2KHz,
+ ADLSampleRate_96KHz,
+ ADLSampleRate_176P4KHz,
+ ADLSampleRate_192KHz,
+ ADLSampleRate_384KHz, //DP1.2
+ ADLSampleRate_768KHz, //DP1.2
+ ADLSampleRate_Undefined
+};
+
+/// \defgroup define_overdrive6_capabilities
+/// These defines the capabilities supported by Overdrive 6. It is used by \ref ADL_Overdrive6_Capabilities_Get
+// @{
+/// Indicate that core (engine) clock can be changed.
+#define ADL_OD6_CAPABILITY_SCLK_CUSTOMIZATION 0x00000001
+/// Indicate that memory clock can be changed.
+#define ADL_OD6_CAPABILITY_MCLK_CUSTOMIZATION 0x00000002
+/// Indicate that graphics activity reporting is supported.
+#define ADL_OD6_CAPABILITY_GPU_ACTIVITY_MONITOR 0x00000004
+/// Indicate that power limit can be customized.
+#define ADL_OD6_CAPABILITY_POWER_CONTROL 0x00000008
+/// Indicate that SVI2 Voltage Control is supported.
+#define ADL_OD6_CAPABILITY_VOLTAGE_CONTROL 0x00000010
+/// Indicate that OD6+ percentage adjustment is supported.
+#define ADL_OD6_CAPABILITY_PERCENT_ADJUSTMENT 0x00000020
+/// Indicate that Thermal Limit Unlock is supported.
+#define ADL_OD6_CAPABILITY_THERMAL_LIMIT_UNLOCK 0x00000040
+// @}
+
+/// \defgroup define_overdrive6_supported_states
+/// These defines the power states supported by Overdrive 6. It is used by \ref ADL_Overdrive6_Capabilities_Get
+// @{
+/// Indicate that overdrive is supported in the performance state. This is currently the only state supported.
+#define ADL_OD6_SUPPORTEDSTATE_PERFORMANCE 0x00000001
+/// Do not use. Reserved for future use.
+#define ADL_OD6_SUPPORTEDSTATE_POWER_SAVING 0x00000002
+// @}
+
+/// \defgroup define_overdrive6_getstateinfo
+/// These defines the power states to get information about. It is used by \ref ADL_Overdrive6_StateInfo_Get
+// @{
+/// Get default clocks for the performance state.
+#define ADL_OD6_GETSTATEINFO_DEFAULT_PERFORMANCE 0x00000001
+/// Do not use. Reserved for future use.
+#define ADL_OD6_GETSTATEINFO_DEFAULT_POWER_SAVING 0x00000002
+/// Get clocks for current state. Currently this is the same as \ref ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE
+/// since only performance state is supported.
+#define ADL_OD6_GETSTATEINFO_CURRENT 0x00000003
+/// Get the modified clocks (if any) for the performance state. If clocks were not modified
+/// through Overdrive 6, then this will return the same clocks as \ref ADL_OD6_GETSTATEINFO_DEFAULT_PERFORMANCE.
+#define ADL_OD6_GETSTATEINFO_CUSTOM_PERFORMANCE 0x00000004
+/// Do not use. Reserved for future use.
+#define ADL_OD6_GETSTATEINFO_CUSTOM_POWER_SAVING 0x00000005
+// @}
+
+/// \defgroup define_overdrive6_getstate and define_overdrive6_getmaxclockadjust
+/// These defines the power states to get information about. It is used by \ref ADL_Overdrive6_StateEx_Get and \ref ADL_Overdrive6_MaxClockAdjust_Get
+// @{
+/// Get default clocks for the performance state. Only performance state is currently supported.
+#define ADL_OD6_STATE_PERFORMANCE 0x00000001
+// @}
+
+/// \defgroup define_overdrive6_setstate
+/// These define which power state to set customized clocks on. It is used by \ref ADL_Overdrive6_State_Set
+// @{
+/// Set customized clocks for the performance state.
+#define ADL_OD6_SETSTATE_PERFORMANCE 0x00000001
+/// Do not use. Reserved for future use.
+#define ADL_OD6_SETSTATE_POWER_SAVING 0x00000002
+// @}
+
+/// \defgroup define_overdrive6_thermalcontroller_caps
+/// These defines the capabilities of the GPU thermal controller. It is used by \ref ADL_Overdrive6_ThermalController_Caps
+// @{
+/// GPU thermal controller is supported.
+#define ADL_OD6_TCCAPS_THERMAL_CONTROLLER 0x00000001
+/// GPU fan speed control is supported.
+#define ADL_OD6_TCCAPS_FANSPEED_CONTROL 0x00000002
+/// Fan speed percentage can be read.
+#define ADL_OD6_TCCAPS_FANSPEED_PERCENT_READ 0x00000100
+/// Fan speed can be set by specifying a percentage value.
+#define ADL_OD6_TCCAPS_FANSPEED_PERCENT_WRITE 0x00000200
+/// Fan speed RPM (revolutions-per-minute) can be read.
+#define ADL_OD6_TCCAPS_FANSPEED_RPM_READ 0x00000400
+/// Fan speed can be set by specifying an RPM value.
+#define ADL_OD6_TCCAPS_FANSPEED_RPM_WRITE 0x00000800
+// @}
+
+/// \defgroup define_overdrive6_fanspeed_type
+/// These defines the fan speed type being reported. It is used by \ref ADL_Overdrive6_FanSpeed_Get
+// @{
+/// Fan speed reported in percentage.
+#define ADL_OD6_FANSPEED_TYPE_PERCENT 0x00000001
+/// Fan speed reported in RPM.
+#define ADL_OD6_FANSPEED_TYPE_RPM 0x00000002
+/// Fan speed has been customized by the user, and fan is not running in automatic mode.
+#define ADL_OD6_FANSPEED_USER_DEFINED 0x00000100
+// @}
+
+/// \defgroup define_ecc_mode_states
+/// These defines the ECC(Error Correction Code) state. It is used by \ref ADL_Workstation_ECC_Get,ADL_Workstation_ECC_Set
+// @{
+/// Error Correction is disabled.
+#define ECC_MODE_OFF 0
+/// Error Correction is enabled.
+#define ECC_MODE_ON 2
+// @}
+
+// End Bracket for Constants and Definitions. Add new groups ABOVE this line!
+
+// @}
+
+#endif /* ADL_DEFINES_H_ */
+
+
diff --git a/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_sdk.h b/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_sdk.h
new file mode 100644
index 000000000..c0ad27e17
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_sdk.h
@@ -0,0 +1,29 @@
+///
+/// Copyright (c) 2008 - 2013 Advanced Micro Devices, Inc.
+
+/// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
+/// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+/// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
+
+/// \file adl_sdk.h
+/// \brief Contains the definition of the Memory Allocation Callback.\n Included in ADL SDK
+///
+/// \n\n
+/// This file contains the definition of the Memory Allocation Callback.\n
+/// It also includes definitions of the respective structures and constants.\n
+/// This is the only header file to be included in a C/C++ project using ADL
+
+#ifndef ADL_SDK_H_
+#define ADL_SDK_H_
+
+#include "adl_structures.h"
+
+#if defined (LINUX)
+#define __stdcall
+#endif /* (LINUX) */
+
+/// Memory Allocation Call back
+typedef void* ( __stdcall *ADL_MAIN_MALLOC_CALLBACK )( int );
+
+
+#endif /* ADL_SDK_H_ */
diff --git a/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_structures.h b/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_structures.h
new file mode 100644
index 000000000..1bfb57950
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/ADL/include/adl_structures.h
@@ -0,0 +1,2143 @@
+///
+/// Copyright (c) 2008 - 2013 Advanced Micro Devices, Inc.
+
+/// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
+/// EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+/// WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
+
+/// \file adl_structures.h
+///\brief This file contains the structure declarations that are used by the public ADL interfaces for \ALL platforms.\n Included in ADL SDK
+///
+/// All data structures used in AMD Display Library (ADL) public interfaces should be defined in this header file.
+///
+
+#ifndef ADL_STRUCTURES_H_
+#define ADL_STRUCTURES_H_
+
+#include "adl_defines.h"
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the graphics adapter.
+///
+/// This structure is used to store various information about the graphics adapter. This
+/// information can be returned to the user. Alternatively, it can be used to access various driver calls to set
+/// or fetch various settings upon the user's request.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct AdapterInfo
+{
+/// \ALL_STRUCT_MEM
+
+/// Size of the structure.
+ int iSize;
+/// The ADL index handle. One GPU may be associated with one or two index handles
+ int iAdapterIndex;
+/// The unique device ID associated with this adapter.
+ char strUDID[ADL_MAX_PATH];
+/// The BUS number associated with this adapter.
+ int iBusNumber;
+/// The driver number associated with this adapter.
+ int iDeviceNumber;
+/// The function number.
+ int iFunctionNumber;
+/// The vendor ID associated with this adapter.
+ int iVendorID;
+/// Adapter name.
+ char strAdapterName[ADL_MAX_PATH];
+/// Display name. For example, "\\Display0" for Windows or ":0:0" for Linux.
+ char strDisplayName[ADL_MAX_PATH];
+/// Present or not; 1 if present and 0 if not present.It the logical adapter is present, the display name such as \\.\Display1 can be found from OS
+ int iPresent;
+// @}
+
+#if defined (_WIN32) || defined (_WIN64)
+/// \WIN_STRUCT_MEM
+
+/// Exist or not; 1 is exist and 0 is not present.
+ int iExist;
+/// Driver registry path.
+ char strDriverPath[ADL_MAX_PATH];
+/// Driver registry path Ext for.
+ char strDriverPathExt[ADL_MAX_PATH];
+/// PNP string from Windows.
+ char strPNPString[ADL_MAX_PATH];
+/// It is generated from EnumDisplayDevices.
+ int iOSDisplayIndex;
+// @}
+#endif /* (_WIN32) || (_WIN64) */
+
+#if defined (LINUX)
+/// \LNX_STRUCT_MEM
+
+/// Internal X screen number from GPUMapInfo (DEPRICATED use XScreenInfo)
+ int iXScreenNum;
+/// Internal driver index from GPUMapInfo
+ int iDrvIndex;
+/// \deprecated Internal x config file screen identifier name. Use XScreenInfo instead.
+ char strXScreenConfigName[ADL_MAX_PATH];
+
+// @}
+#endif /* (LINUX) */
+} AdapterInfo, *LPAdapterInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the Linux X screen information.
+///
+/// This structure is used to store the current screen number and xorg.conf ID name assoicated with an adapter index.
+/// This structure is updated during ADL_Main_Control_Refresh or ADL_ScreenInfo_Update.
+/// Note: This structure should be used in place of iXScreenNum and strXScreenConfigName in AdapterInfo as they will be
+/// deprecated.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+#if defined (LINUX)
+typedef struct XScreenInfo
+{
+/// Internal X screen number from GPUMapInfo.
+ int iXScreenNum;
+/// Internal x config file screen identifier name.
+ char strXScreenConfigName[ADL_MAX_PATH];
+} XScreenInfo, *LPXScreenInfo;
+#endif /* (LINUX) */
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the ASIC memory.
+///
+/// This structure is used to store various information about the ASIC memory. This
+/// information can be returned to the user.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLMemoryInfo
+{
+/// Memory size in bytes.
+ long long iMemorySize;
+/// Memory type in string.
+ char strMemoryType[ADL_MAX_PATH];
+/// Memory bandwidth in Mbytes/s.
+ long long iMemoryBandwidth;
+} ADLMemoryInfo, *LPADLMemoryInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about memory required by type
+///
+/// This structure is returned by ADL_Adapter_ConfigMemory_Get, which given a desktop and display configuration
+/// will return the Memory used.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLMemoryRequired
+{
+ long long iMemoryReq; /// Memory in bytes required
+ int iType; /// Type of Memory \ref define_adl_validmemoryrequiredfields
+ int iDisplayFeatureValue; /// Display features \ref define_adl_visiblememoryfeatures that are using this type of memory
+} ADLMemoryRequired, *LPADLMemoryRequired;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the features associated with a display
+///
+/// This structure is a parameter to ADL_Adapter_ConfigMemory_Get, which given a desktop and display configuration
+/// will return the Memory used.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLMemoryDisplayFeatures
+{
+ int iDisplayIndex; /// ADL Display index
+ int iDisplayFeatureValue; /// features that the display is using \ref define_adl_visiblememoryfeatures
+} ADLMemoryDisplayFeatures, *LPADLMemoryDisplayFeatures;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing DDC information.
+///
+/// This structure is used to store various DDC information that can be returned to the user.
+/// Note that all fields of type int are actually defined as unsigned int types within the driver.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDDCInfo
+{
+/// Size of the structure
+ int ulSize;
+/// Indicates whether the attached display supports DDC. If this field is zero on return, no other DDC information fields will be used.
+ int ulSupportsDDC;
+/// Returns the manufacturer ID of the display device. Should be zeroed if this information is not available.
+ int ulManufacturerID;
+/// Returns the product ID of the display device. Should be zeroed if this information is not available.
+ int ulProductID;
+/// Returns the name of the display device. Should be zeroed if this information is not available.
+ char cDisplayName[ADL_MAX_DISPLAY_NAME];
+/// Returns the maximum Horizontal supported resolution. Should be zeroed if this information is not available.
+ int ulMaxHResolution;
+/// Returns the maximum Vertical supported resolution. Should be zeroed if this information is not available.
+ int ulMaxVResolution;
+/// Returns the maximum supported refresh rate. Should be zeroed if this information is not available.
+ int ulMaxRefresh;
+/// Returns the display device preferred timing mode's horizontal resolution.
+ int ulPTMCx;
+/// Returns the display device preferred timing mode's vertical resolution.
+ int ulPTMCy;
+/// Returns the display device preferred timing mode's refresh rate.
+ int ulPTMRefreshRate;
+/// Return EDID flags.
+ int ulDDCInfoFlag;
+} ADLDDCInfo, *LPADLDDCInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing DDC information.
+///
+/// This structure is used to store various DDC information that can be returned to the user.
+/// Note that all fields of type int are actually defined as unsigned int types within the driver.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDDCInfo2
+{
+/// Size of the structure
+ int ulSize;
+/// Indicates whether the attached display supports DDC. If this field is zero on return, no other DDC
+/// information fields will be used.
+ int ulSupportsDDC;
+/// Returns the manufacturer ID of the display device. Should be zeroed if this information is not available.
+ int ulManufacturerID;
+/// Returns the product ID of the display device. Should be zeroed if this information is not available.
+ int ulProductID;
+/// Returns the name of the display device. Should be zeroed if this information is not available.
+ char cDisplayName[ADL_MAX_DISPLAY_NAME];
+/// Returns the maximum Horizontal supported resolution. Should be zeroed if this information is not available.
+ int ulMaxHResolution;
+/// Returns the maximum Vertical supported resolution. Should be zeroed if this information is not available.
+ int ulMaxVResolution;
+/// Returns the maximum supported refresh rate. Should be zeroed if this information is not available.
+ int ulMaxRefresh;
+/// Returns the display device preferred timing mode's horizontal resolution.
+ int ulPTMCx;
+/// Returns the display device preferred timing mode's vertical resolution.
+ int ulPTMCy;
+/// Returns the display device preferred timing mode's refresh rate.
+ int ulPTMRefreshRate;
+/// Return EDID flags.
+ int ulDDCInfoFlag;
+// Returns 1 if the display supported packed pixel, 0 otherwise
+ int bPackedPixelSupported;
+// Returns the Pixel formats the display supports \ref define_ddcinfo_pixelformats
+ int iPanelPixelFormat;
+/// Return EDID serial ID.
+ int ulSerialID;
+// Reserved for future use
+ int iReserved[26];
+} ADLDDCInfo2, *LPADLDDCInfo2;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information controller Gamma settings.
+///
+/// This structure is used to store the red, green and blue color channel information for the.
+/// controller gamma setting. This information is returned by ADL, and it can also be used to
+/// set the controller gamma setting.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGamma
+{
+/// Red color channel gamma value.
+ float fRed;
+/// Green color channel gamma value.
+ float fGreen;
+/// Blue color channel gamma value.
+ float fBlue;
+} ADLGamma, *LPADLGamma;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about component video custom modes.
+///
+/// This structure is used to store the component video custom mode.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLCustomMode
+{
+/// Custom mode flags. They are returned by the ADL driver.
+ int iFlags;
+/// Custom mode width.
+ int iModeWidth;
+/// Custom mode height.
+ int iModeHeight;
+/// Custom mode base width.
+ int iBaseModeWidth;
+/// Custom mode base height.
+ int iBaseModeHeight;
+/// Custom mode refresh rate.
+ int iRefreshRate;
+} ADLCustomMode, *LPADLCustomMode;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing Clock information for OD5 calls.
+///
+/// This structure is used to retrieve clock information for OD5 calls.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGetClocksOUT
+{
+ long ulHighCoreClock;
+ long ulHighMemoryClock;
+ long ulHighVddc;
+ long ulCoreMin;
+ long ulCoreMax;
+ long ulMemoryMin;
+ long ulMemoryMax;
+ long ulActivityPercent;
+ long ulCurrentCoreClock;
+ long ulCurrentMemoryClock;
+ long ulReserved;
+} ADLGetClocksOUT;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing HDTV information for display calls.
+///
+/// This structure is used to retrieve HDTV information information for display calls.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayConfig
+{
+/// Size of the structure
+ long ulSize;
+/// HDTV connector type.
+ long ulConnectorType;
+/// HDTV capabilities.
+ long ulDeviceData;
+/// Overridden HDTV capabilities.
+ long ulOverridedDeviceData;
+/// Reserved field
+ long ulReserved;
+} ADLDisplayConfig;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display device.
+///
+/// This structure is used to store display device information
+/// such as display index, type, name, connection status, mapped adapter and controller indexes,
+/// whether or not multiple VPUs are supported, local display connections or not (through Lasso), etc.
+/// This information can be returned to the user. Alternatively, it can be used to access various driver calls to set
+/// or fetch various display device related settings upon the user's request.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayID
+{
+/// The logical display index belonging to this adapter.
+ int iDisplayLogicalIndex;
+
+///\brief The physical display index.
+/// For example, display index 2 from adapter 2 can be used by current adapter 1.\n
+/// So current adapter may enumerate this adapter as logical display 7 but the physical display
+/// index is still 2.
+ int iDisplayPhysicalIndex;
+
+/// The persistent logical adapter index for the display.
+ int iDisplayLogicalAdapterIndex;
+
+///\brief The persistent physical adapter index for the display.
+/// It can be the current adapter or a non-local adapter. \n
+/// If this adapter index is different than the current adapter,
+/// the Display Non Local flag is set inside DisplayInfoValue.
+ int iDisplayPhysicalAdapterIndex;
+} ADLDisplayID, *LPADLDisplayID;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display device.
+///
+/// This structure is used to store various information about the display device. This
+/// information can be returned to the user, or used to access various driver calls to set
+/// or fetch various display-device-related settings upon the user's request
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayInfo
+{
+/// The DisplayID structure
+ ADLDisplayID displayID;
+
+///\deprecated The controller index to which the display is mapped.\n Will not be used in the future\n
+ int iDisplayControllerIndex;
+
+/// The display's EDID name.
+ char strDisplayName[ADL_MAX_PATH];
+
+/// The display's manufacturer name.
+ char strDisplayManufacturerName[ADL_MAX_PATH];
+
+/// The Display type. For example: CRT, TV, CV, DFP.
+ int iDisplayType;
+
+/// The display output type. For example: HDMI, SVIDEO, COMPONMNET VIDEO.
+ int iDisplayOutputType;
+
+/// The connector type for the device.
+ int iDisplayConnector;
+
+///\brief The bit mask identifies the number of bits ADLDisplayInfo is currently using. \n
+/// It will be the sum all the bit definitions in ADL_DISPLAY_DISPLAYINFO_xxx.
+ int iDisplayInfoMask;
+
+/// The bit mask identifies the display status. \ref define_displayinfomask
+ int iDisplayInfoValue;
+} ADLDisplayInfo, *LPADLDisplayInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display port MST device.
+///
+/// This structure is used to store various MST information about the display port device. This
+/// information can be returned to the user, or used to access various driver calls to
+/// fetch various display-device-related settings upon the user's request
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayDPMSTInfo
+{
+ /// The ADLDisplayID structure
+ ADLDisplayID displayID;
+
+ /// total bandwidth available on the DP connector
+ int iTotalAvailableBandwidthInMpbs;
+ /// bandwidth allocated to this display
+ int iAllocatedBandwidthInMbps;
+
+ // info from DAL DpMstSinkInfo
+ /// string identifier for the display
+ char strGlobalUniqueIdentifier[ADL_MAX_PATH];
+
+ /// The link count of relative address, rad[0] upto rad[linkCount] are valid
+ int radLinkCount;
+ /// The physical connector ID, used to identify the physical DP port
+ int iPhysicalConnectorID;
+
+ /// Relative address, address scheme starts from source side
+ char rad[ADL_MAX_RAD_LINK_COUNT];
+} ADLDisplayDPMSTInfo, *LPADLDisplayDPMSTInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the display mode definition used per controller.
+///
+/// This structure is used to store the display mode definition used per controller.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayMode
+{
+/// Vertical resolution (in pixels).
+ int iPelsHeight;
+/// Horizontal resolution (in pixels).
+ int iPelsWidth;
+/// Color depth.
+ int iBitsPerPel;
+/// Refresh rate.
+ int iDisplayFrequency;
+} ADLDisplayMode;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing detailed timing parameters.
+///
+/// This structure is used to store the detailed timing parameters.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDetailedTiming
+{
+/// Size of the structure.
+ int iSize;
+/// Timing flags. \ref define_detailed_timing_flags
+ short sTimingFlags;
+/// Total width (columns).
+ short sHTotal;
+/// Displayed width.
+ short sHDisplay;
+/// Horizontal sync signal offset.
+ short sHSyncStart;
+/// Horizontal sync signal width.
+ short sHSyncWidth;
+/// Total height (rows).
+ short sVTotal;
+/// Displayed height.
+ short sVDisplay;
+/// Vertical sync signal offset.
+ short sVSyncStart;
+/// Vertical sync signal width.
+ short sVSyncWidth;
+/// Pixel clock value.
+ short sPixelClock;
+/// Overscan right.
+ short sHOverscanRight;
+/// Overscan left.
+ short sHOverscanLeft;
+/// Overscan bottom.
+ short sVOverscanBottom;
+/// Overscan top.
+ short sVOverscanTop;
+ short sOverscan8B;
+ short sOverscanGR;
+} ADLDetailedTiming;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing display mode information.
+///
+/// This structure is used to store the display mode information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayModeInfo
+{
+/// Timing standard of the current mode. \ref define_modetiming_standard
+ int iTimingStandard;
+/// Applicable timing standards for the current mode.
+ int iPossibleStandard;
+/// Refresh rate factor.
+ int iRefreshRate;
+/// Num of pixels in a row.
+ int iPelsWidth;
+/// Num of pixels in a column.
+ int iPelsHeight;
+/// Detailed timing parameters.
+ ADLDetailedTiming sDetailedTiming;
+} ADLDisplayModeInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about display property.
+///
+/// This structure is used to store the display property for the current adapter.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayProperty
+{
+/// Must be set to sizeof the structure
+ int iSize;
+/// Must be set to \ref ADL_DL_DISPLAYPROPERTY_TYPE_EXPANSIONMODE or \ref ADL_DL_DISPLAYPROPERTY_TYPE_USEUNDERSCANSCALING
+ int iPropertyType;
+/// Get or Set \ref ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_CENTER or \ref ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_FULLSCREEN or \ref ADL_DL_DISPLAYPROPERTY_EXPANSIONMODE_ASPECTRATIO or \ref ADL_DL_DISPLAYPROPERTY_TYPE_ITCFLAGENABLE
+ int iExpansionMode;
+/// Display Property supported? 1: Supported, 0: Not supported
+ int iSupport;
+/// Display Property current value
+ int iCurrent;
+/// Display Property Default value
+ int iDefault;
+} ADLDisplayProperty;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Clock.
+///
+/// This structure is used to store the clock information for the current adapter
+/// such as core clock and memory clock info.
+///\nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLClockInfo
+{
+/// Core clock in 10 KHz.
+ int iCoreClock;
+/// Memory clock in 10 KHz.
+ int iMemoryClock;
+} ADLClockInfo, *LPADLClockInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about I2C.
+///
+/// This structure is used to store the I2C information for the current adapter.
+/// This structure is used by the ADL_Display_WriteAndReadI2C() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLI2C
+{
+/// Size of the structure
+ int iSize;
+/// Numerical value representing hardware I2C.
+ int iLine;
+/// The 7-bit I2C slave device address, shifted one bit to the left.
+ int iAddress;
+/// The offset of the data from the address.
+ int iOffset;
+/// Read from or write to slave device. \ref ADL_DL_I2C_ACTIONREAD or \ref ADL_DL_I2C_ACTIONWRITE or \ref ADL_DL_I2C_ACTIONREAD_REPEATEDSTART
+ int iAction;
+/// I2C clock speed in KHz.
+ int iSpeed;
+/// A numerical value representing the number of bytes to be sent or received on the I2C bus.
+ int iDataSize;
+/// Address of the characters which are to be sent or received on the I2C bus.
+ char *pcData;
+} ADLI2C;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about EDID data.
+///
+/// This structure is used to store the information about EDID data for the adapter.
+/// This structure is used by the ADL_Display_EdidData_Get() and ADL_Display_EdidData_Set() functions.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayEDIDData
+{
+/// Size of the structure
+ int iSize;
+/// Set to 0
+ int iFlag;
+ /// Size of cEDIDData. Set by ADL_Display_EdidData_Get() upon return
+ int iEDIDSize;
+/// 0, 1 or 2. If set to 3 or above an error ADL_ERR_INVALID_PARAM is generated
+ int iBlockIndex;
+/// EDID data
+ char cEDIDData[ADL_MAX_EDIDDATA_SIZE];
+/// Reserved
+ int iReserved[4];
+}ADLDisplayEDIDData;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about input of controller overlay adjustment.
+///
+/// This structure is used to store the information about input of controller overlay adjustment for the adapter.
+/// This structure is used by the ADL_Display_ControllerOverlayAdjustmentCaps_Get, ADL_Display_ControllerOverlayAdjustmentData_Get, and
+/// ADL_Display_ControllerOverlayAdjustmentData_Set() functions.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLControllerOverlayInput
+{
+/// Should be set to the sizeof the structure
+ int iSize;
+///\ref ADL_DL_CONTROLLER_OVERLAY_ALPHA or \ref ADL_DL_CONTROLLER_OVERLAY_ALPHAPERPIX
+ int iOverlayAdjust;
+/// Data.
+ int iValue;
+/// Should be 0.
+ int iReserved;
+} ADLControllerOverlayInput;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about overlay adjustment.
+///
+/// This structure is used to store the information about overlay adjustment for the adapter.
+/// This structure is used by the ADLControllerOverlayInfo() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLAdjustmentinfo
+{
+/// Default value
+ int iDefault;
+/// Minimum value
+ int iMin;
+/// Maximum Value
+ int iMax;
+/// Step value
+ int iStep;
+} ADLAdjustmentinfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about controller overlay information.
+///
+/// This structure is used to store information about controller overlay info for the adapter.
+/// This structure is used by the ADL_Display_ControllerOverlayAdjustmentCaps_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLControllerOverlayInfo
+{
+/// Should be set to the sizeof the structure
+ int iSize;
+/// Data.
+ ADLAdjustmentinfo sOverlayInfo;
+/// Should be 0.
+ int iReserved[3];
+} ADLControllerOverlayInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing GL-Sync module information.
+///
+/// This structure is used to retrieve GL-Sync module information for
+/// Workstation Framelock/Genlock.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGLSyncModuleID
+{
+/// Unique GL-Sync module ID.
+ int iModuleID;
+/// GL-Sync GPU port index (to be passed into ADLGLSyncGenlockConfig.lSignalSource and ADLGlSyncPortControl.lSignalSource).
+ int iGlSyncGPUPort;
+/// GL-Sync module firmware version of Boot Sector.
+ int iFWBootSectorVersion;
+/// GL-Sync module firmware version of User Sector.
+ int iFWUserSectorVersion;
+} ADLGLSyncModuleID , *LPADLGLSyncModuleID;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing GL-Sync ports capabilities.
+///
+/// This structure is used to retrieve hardware capabilities for the ports of the GL-Sync module
+/// for Workstation Framelock/Genlock (such as port type and number of associated LEDs).
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGLSyncPortCaps
+{
+/// Port type. Bitfield of ADL_GLSYNC_PORTTYPE_* \ref define_glsync
+ int iPortType;
+/// Number of LEDs associated for this port.
+ int iNumOfLEDs;
+}ADLGLSyncPortCaps, *LPADLGLSyncPortCaps;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing GL-Sync Genlock settings.
+///
+/// This structure is used to get and set genlock settings for the GPU ports of the GL-Sync module
+/// for Workstation Framelock/Genlock.\n
+/// \see define_glsync
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGLSyncGenlockConfig
+{
+/// Specifies what fields in this structure are valid \ref define_glsync
+ int iValidMask;
+/// Delay (ms) generating a sync signal.
+ int iSyncDelay;
+/// Vector of framelock control bits. Bitfield of ADL_GLSYNC_FRAMELOCKCNTL_* \ref define_glsync
+ int iFramelockCntlVector;
+/// Source of the sync signal. Either GL_Sync GPU Port index or ADL_GLSYNC_SIGNALSOURCE_* \ref define_glsync
+ int iSignalSource;
+/// Use sampled sync signal. A value of 0 specifies no sampling.
+ int iSampleRate;
+/// For interlaced sync signals, the value can be ADL_GLSYNC_SYNCFIELD_1 or *_BOTH \ref define_glsync
+ int iSyncField;
+/// The signal edge that should trigger synchronization. ADL_GLSYNC_TRIGGEREDGE_* \ref define_glsync
+ int iTriggerEdge;
+/// Scan rate multiplier applied to the sync signal. ADL_GLSYNC_SCANRATECOEFF_* \ref define_glsync
+ int iScanRateCoeff;
+}ADLGLSyncGenlockConfig, *LPADLGLSyncGenlockConfig;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing GL-Sync port information.
+///
+/// This structure is used to get status of the GL-Sync ports (BNC or RJ45s)
+/// for Workstation Framelock/Genlock.
+/// \see define_glsync
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGlSyncPortInfo
+{
+/// Type of GL-Sync port (ADL_GLSYNC_PORT_*).
+ int iPortType;
+/// The number of LEDs for this port. It's also filled within ADLGLSyncPortCaps.
+ int iNumOfLEDs;
+/// Port state ADL_GLSYNC_PORTSTATE_* \ref define_glsync
+ int iPortState;
+/// Scanned frequency for this port (vertical refresh rate in milliHz; 60000 means 60 Hz).
+ int iFrequency;
+/// Used for ADL_GLSYNC_PORT_BNC. It is ADL_GLSYNC_SIGNALTYPE_* \ref define_glsync
+ int iSignalType;
+/// Used for ADL_GLSYNC_PORT_RJ45PORT*. It is GL_Sync GPU Port index or ADL_GLSYNC_SIGNALSOURCE_*. \ref define_glsync
+ int iSignalSource;
+
+} ADLGlSyncPortInfo, *LPADLGlSyncPortInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing GL-Sync port control settings.
+///
+/// This structure is used to configure the GL-Sync ports (RJ45s only)
+/// for Workstation Framelock/Genlock.
+/// \see define_glsync
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGlSyncPortControl
+{
+/// Port to control ADL_GLSYNC_PORT_RJ45PORT1 or ADL_GLSYNC_PORT_RJ45PORT2 \ref define_glsync
+ int iPortType;
+/// Port control data ADL_GLSYNC_PORTCNTL_* \ref define_glsync
+ int iControlVector;
+/// Source of the sync signal. Either GL_Sync GPU Port index or ADL_GLSYNC_SIGNALSOURCE_* \ref define_glsync
+ int iSignalSource;
+} ADLGlSyncPortControl;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing GL-Sync mode of a display.
+///
+/// This structure is used to get and set GL-Sync mode settings for a display connected to
+/// an adapter attached to a GL-Sync module for Workstation Framelock/Genlock.
+/// \see define_glsync
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGlSyncMode
+{
+/// Mode control vector. Bitfield of ADL_GLSYNC_MODECNTL_* \ref define_glsync
+ int iControlVector;
+/// Mode status vector. Bitfield of ADL_GLSYNC_MODECNTL_STATUS_* \ref define_glsync
+ int iStatusVector;
+/// Index of GL-Sync connector used to genlock the display/controller.
+ int iGLSyncConnectorIndex;
+} ADLGlSyncMode, *LPADLGlSyncMode;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing GL-Sync mode of a display.
+///
+/// This structure is used to get and set GL-Sync mode settings for a display connected to
+/// an adapter attached to a GL-Sync module for Workstation Framelock/Genlock.
+/// \see define_glsync
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLGlSyncMode2
+{
+/// Mode control vector. Bitfield of ADL_GLSYNC_MODECNTL_* \ref define_glsync
+ int iControlVector;
+/// Mode status vector. Bitfield of ADL_GLSYNC_MODECNTL_STATUS_* \ref define_glsync
+ int iStatusVector;
+/// Index of GL-Sync connector used to genlock the display/controller.
+ int iGLSyncConnectorIndex;
+/// Index of the display to which this GLSync applies to.
+ int iDisplayIndex;
+} ADLGlSyncMode2, *LPADLGlSyncMode2;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the packet info of a display.
+///
+/// This structure is used to get and set the packet information of a display.
+/// This structure is used by ADLDisplayDataPacket.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLInfoPacket
+{
+ char hb0;
+ char hb1;
+ char hb2;
+/// sb0~sb27
+ char sb[28];
+}ADLInfoPacket;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the AVI packet info of a display.
+///
+/// This structure is used to get and set AVI the packet info of a display.
+/// This structure is used by ADLDisplayDataPacket.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLAVIInfoPacket //Valid user defined data/
+{
+/// byte 3, bit 7
+ char bPB3_ITC;
+/// byte 5, bit [7:4].
+ char bPB5;
+}ADLAVIInfoPacket;
+
+// Overdrive clock setting structure definition.
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the Overdrive clock setting.
+///
+/// This structure is used to get the Overdrive clock setting.
+/// This structure is used by ADLAdapterODClockInfo.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLODClockSetting
+{
+/// Deafult clock
+ int iDefaultClock;
+/// Current clock
+ int iCurrentClock;
+/// Maximum clcok
+ int iMaxClock;
+/// Minimum clock
+ int iMinClock;
+/// Requested clcock
+ int iRequestedClock;
+/// Step
+ int iStepClock;
+} ADLODClockSetting;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the Overdrive clock information.
+///
+/// This structure is used to get the Overdrive clock information.
+/// This structure is used by the ADL_Display_ODClockInfo_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLAdapterODClockInfo
+{
+/// Size of the structure
+ int iSize;
+/// Flag \ref define_clockinfo_flags
+ int iFlags;
+/// Memory Clock
+ ADLODClockSetting sMemoryClock;
+/// Engine Clock
+ ADLODClockSetting sEngineClock;
+} ADLAdapterODClockInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the Overdrive clock configuration.
+///
+/// This structure is used to set the Overdrive clock configuration.
+/// This structure is used by the ADL_Display_ODClockConfig_Set() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLAdapterODClockConfig
+{
+/// Size of the structure
+ int iSize;
+/// Flag \ref define_clockinfo_flags
+ int iFlags;
+/// Memory Clock
+ int iMemoryClock;
+/// Engine Clock
+ int iEngineClock;
+} ADLAdapterODClockConfig;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about current power management related activity.
+///
+/// This structure is used to store information about current power management related activity.
+/// This structure (Overdrive 5 interfaces) is used by the ADL_PM_CurrentActivity_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLPMActivity
+{
+/// Must be set to the size of the structure
+ int iSize;
+/// Current engine clock.
+ int iEngineClock;
+/// Current memory clock.
+ int iMemoryClock;
+/// Current core voltage.
+ int iVddc;
+/// GPU utilization.
+ int iActivityPercent;
+/// Performance level index.
+ int iCurrentPerformanceLevel;
+/// Current PCIE bus speed.
+ int iCurrentBusSpeed;
+/// Number of PCIE bus lanes.
+ int iCurrentBusLanes;
+/// Maximum number of PCIE bus lanes.
+ int iMaximumBusLanes;
+/// Reserved for future purposes.
+ int iReserved;
+} ADLPMActivity;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about thermal controller.
+///
+/// This structure is used to store information about thermal controller.
+/// This structure is used by ADL_PM_ThermalDevices_Enum.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLThermalControllerInfo
+{
+/// Must be set to the size of the structure
+ int iSize;
+/// Possible valies: \ref ADL_DL_THERMAL_DOMAIN_OTHER or \ref ADL_DL_THERMAL_DOMAIN_GPU.
+ int iThermalDomain;
+/// GPU 0, 1, etc.
+ int iDomainIndex;
+/// Possible valies: \ref ADL_DL_THERMAL_FLAG_INTERRUPT or \ref ADL_DL_THERMAL_FLAG_FANCONTROL
+ int iFlags;
+} ADLThermalControllerInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about thermal controller temperature.
+///
+/// This structure is used to store information about thermal controller temperature.
+/// This structure is used by the ADL_PM_Temperature_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLTemperature
+{
+/// Must be set to the size of the structure
+ int iSize;
+/// Temperature in millidegrees Celsius.
+ int iTemperature;
+} ADLTemperature;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about thermal controller fan speed.
+///
+/// This structure is used to store information about thermal controller fan speed.
+/// This structure is used by the ADL_PM_FanSpeedInfo_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLFanSpeedInfo
+{
+/// Must be set to the size of the structure
+ int iSize;
+/// \ref define_fanctrl
+ int iFlags;
+/// Minimum possible fan speed value in percents.
+ int iMinPercent;
+/// Maximum possible fan speed value in percents.
+ int iMaxPercent;
+/// Minimum possible fan speed value in RPM.
+ int iMinRPM;
+/// Maximum possible fan speed value in RPM.
+ int iMaxRPM;
+} ADLFanSpeedInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about fan speed reported by thermal controller.
+///
+/// This structure is used to store information about fan speed reported by thermal controller.
+/// This structure is used by the ADL_Overdrive5_FanSpeed_Get() and ADL_Overdrive5_FanSpeed_Set() functions.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLFanSpeedValue
+{
+/// Must be set to the size of the structure
+ int iSize;
+/// Possible valies: \ref ADL_DL_FANCTRL_SPEED_TYPE_PERCENT or \ref ADL_DL_FANCTRL_SPEED_TYPE_RPM
+ int iSpeedType;
+/// Fan speed value
+ int iFanSpeed;
+/// The only flag for now is: \ref ADL_DL_FANCTRL_FLAG_USER_DEFINED_SPEED
+ int iFlags;
+} ADLFanSpeedValue;
+
+////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the range of Overdrive parameter.
+///
+/// This structure is used to store information about the range of Overdrive parameter.
+/// This structure is used by ADLODParameters.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLODParameterRange
+{
+/// Minimum parameter value.
+ int iMin;
+/// Maximum parameter value.
+ int iMax;
+/// Parameter step value.
+ int iStep;
+} ADLODParameterRange;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive parameters.
+///
+/// This structure is used to store information about Overdrive parameters.
+/// This structure is used by the ADL_Overdrive5_ODParameters_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLODParameters
+{
+/// Must be set to the size of the structure
+ int iSize;
+/// Number of standard performance states.
+ int iNumberOfPerformanceLevels;
+/// Indicates whether the GPU is capable to measure its activity.
+ int iActivityReportingSupported;
+/// Indicates whether the GPU supports discrete performance levels or performance range.
+ int iDiscretePerformanceLevels;
+/// Reserved for future use.
+ int iReserved;
+/// Engine clock range.
+ ADLODParameterRange sEngineClock;
+/// Memory clock range.
+ ADLODParameterRange sMemoryClock;
+/// Core voltage range.
+ ADLODParameterRange sVddc;
+} ADLODParameters;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive level.
+///
+/// This structure is used to store information about Overdrive level.
+/// This structure is used by ADLODPerformanceLevels.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLODPerformanceLevel
+{
+/// Engine clock.
+ int iEngineClock;
+/// Memory clock.
+ int iMemoryClock;
+/// Core voltage.
+ int iVddc;
+} ADLODPerformanceLevel;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive performance levels.
+///
+/// This structure is used to store information about Overdrive performance levels.
+/// This structure is used by the ADL_Overdrive5_ODPerformanceLevels_Get() and ADL_Overdrive5_ODPerformanceLevels_Set() functions.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLODPerformanceLevels
+{
+/// Must be set to sizeof( \ref ADLODPerformanceLevels ) + sizeof( \ref ADLODPerformanceLevel ) * (ADLODParameters.iNumberOfPerformanceLevels - 1)
+ int iSize;
+ int iReserved;
+/// Array of performance state descriptors. Must have ADLODParameters.iNumberOfPerformanceLevels elements.
+ ADLODPerformanceLevel aLevels [1];
+} ADLODPerformanceLevels;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the proper CrossfireX chains combinations.
+///
+/// This structure is used to store information about the CrossfireX chains combination for a particular adapter.
+/// This structure is used by the ADL_Adapter_Crossfire_Caps(), ADL_Adapter_Crossfire_Get(), and ADL_Adapter_Crossfire_Set() functions.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLCrossfireComb
+{
+/// Number of adapters in this combination.
+ int iNumLinkAdapter;
+/// A list of ADL indexes of the linked adapters in this combination.
+ int iAdaptLink[3];
+} ADLCrossfireComb;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing CrossfireX state and error information.
+///
+/// This structure is used to store state and error information about a particular adapter CrossfireX combination.
+/// This structure is used by the ADL_Adapter_Crossfire_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLCrossfireInfo
+{
+/// Current error code of this CrossfireX combination.
+ int iErrorCode;
+/// Current \ref define_crossfirestate
+ int iState;
+/// If CrossfireX is supported by this combination. The value is either \ref ADL_TRUE or \ref ADL_FALSE.
+ int iSupported;
+} ADLCrossfireInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about the BIOS.
+///
+/// This structure is used to store various information about the Chipset. This
+/// information can be returned to the user.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLBiosInfo
+{
+ char strPartNumber[ADL_MAX_PATH]; ///< Part number.
+ char strVersion[ADL_MAX_PATH]; ///< Version number.
+ char strDate[ADL_MAX_PATH]; ///< BIOS date in yyyy/mm/dd hh:mm format.
+} ADLBiosInfo, *LPADLBiosInfo;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about adapter location.
+///
+/// This structure is used to store information about adapter location.
+/// This structure is used by ADLMVPUStatus.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLAdapterLocation
+{
+/// PCI Bus number : 8 bits
+ int iBus;
+/// Device number : 5 bits
+ int iDevice;
+/// Function number : 3 bits
+ int iFunction;
+} ADLAdapterLocation,ADLBdf;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about MultiVPU capabilities.
+///
+/// This structure is used to store information about MultiVPU capabilities.
+/// This structure is used by the ADL_Display_MVPUCaps_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLMVPUCaps
+{
+/// Must be set to sizeof( ADLMVPUCaps ).
+ int iSize;
+/// Number of adapters.
+ int iAdapterCount;
+/// Bits set for all possible MVPU masters. \ref MVPU_ADAPTER_0 .. \ref MVPU_ADAPTER_3
+ int iPossibleMVPUMasters;
+/// Bits set for all possible MVPU slaves. \ref MVPU_ADAPTER_0 .. \ref MVPU_ADAPTER_3
+ int iPossibleMVPUSlaves;
+/// Registry path for each adapter.
+ char cAdapterPath[ADL_DL_MAX_MVPU_ADAPTERS][ADL_DL_MAX_REGISTRY_PATH];
+} ADLMVPUCaps;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about MultiVPU status.
+///
+/// This structure is used to store information about MultiVPU status.
+/// Ths structure is used by the ADL_Display_MVPUStatus_Get() function.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLMVPUStatus
+{
+/// Must be set to sizeof( ADLMVPUStatus ).
+ int iSize;
+/// Number of active adapters.
+ int iActiveAdapterCount;
+/// MVPU status.
+ int iStatus;
+/// PCI Bus/Device/Function for each active adapter participating in MVPU.
+ ADLAdapterLocation aAdapterLocation[ADL_DL_MAX_MVPU_ADAPTERS];
+} ADLMVPUStatus;
+
+// Displays Manager structures
+
+///////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about the activatable source.
+///
+/// This structure is used to store activatable source information
+/// This information can be returned to the user.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLActivatableSource
+{
+ /// The Persistent logical Adapter Index.
+ int iAdapterIndex;
+ /// The number of Activatable Sources.
+ int iNumActivatableSources;
+ /// The bit mask identifies the number of bits ActivatableSourceValue is using. (Not currnetly used)
+ int iActivatableSourceMask;
+ /// The bit mask identifies the status. (Not currnetly used)
+ int iActivatableSourceValue;
+} ADLActivatableSource, *LPADLActivatableSource;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about display mode.
+///
+/// This structure is used to store the display mode for the current adapter
+/// such as X, Y positions, screen resolutions, orientation,
+/// color depth, refresh rate, progressive or interlace mode, etc.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+
+typedef struct ADLMode
+{
+/// Adapter index.
+ int iAdapterIndex;
+/// Display IDs.
+ ADLDisplayID displayID;
+/// Screen position X coordinate.
+ int iXPos;
+/// Screen position Y coordinate.
+ int iYPos;
+/// Screen resolution Width.
+ int iXRes;
+/// Screen resolution Height.
+ int iYRes;
+/// Screen Color Depth. E.g., 16, 32.
+ int iColourDepth;
+/// Screen refresh rate. Could be fractional E.g. 59.97
+ float fRefreshRate;
+/// Screen orientation. E.g., 0, 90, 180, 270.
+ int iOrientation;
+/// Vista mode flag indicating Progressive or Interlaced mode.
+ int iModeFlag;
+/// The bit mask identifying the number of bits this Mode is currently using. It is the sum of all the bit definitions defined in \ref define_displaymode
+ int iModeMask;
+/// The bit mask identifying the display status. The detailed definition is in \ref define_displaymode
+ int iModeValue;
+} ADLMode, *LPADLMode;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about display target information.
+///
+/// This structure is used to store the display target information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayTarget
+{
+ /// The Display ID.
+ ADLDisplayID displayID;
+
+ /// The display map index identify this manner and the desktop surface.
+ int iDisplayMapIndex;
+
+ /// The bit mask identifies the number of bits DisplayTarget is currently using. It is the sum of all the bit definitions defined in \ref ADL_DISPLAY_DISPLAYTARGET_PREFERRED.
+ int iDisplayTargetMask;
+
+ /// The bit mask identifies the display status. The detailed definition is in \ref ADL_DISPLAY_DISPLAYTARGET_PREFERRED.
+ int iDisplayTargetValue;
+
+} ADLDisplayTarget, *LPADLDisplayTarget;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display SLS bezel Mode information.
+///
+/// This structure is used to store the display SLS bezel Mode information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct tagADLBezelTransientMode
+{
+ /// Adapter Index
+ int iAdapterIndex;
+
+ /// SLS Map Index
+ int iSLSMapIndex;
+
+ /// The mode index
+ int iSLSModeIndex;
+
+ /// The mode
+ ADLMode displayMode;
+
+ /// The number of bezel offsets belongs to this map
+ int iNumBezelOffset;
+
+ /// The first bezel offset array index in the native mode array
+ int iFirstBezelOffsetArrayIndex;
+
+ /// The bit mask identifies the bits this structure is currently using. It will be the total OR of all the bit definitions.
+ int iSLSBezelTransientModeMask;
+
+ /// The bit mask identifies the display status. The detail definition is defined below.
+ int iSLSBezelTransientModeValue;
+
+} ADLBezelTransientMode, *LPADLBezelTransientMode;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about the adapter display manner.
+///
+/// This structure is used to store adapter display manner information
+/// This information can be returned to the user. Alternatively, it can be used to access various driver calls to
+/// fetch various display device related display manner settings upon the user's request.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLAdapterDisplayCap
+{
+ /// The Persistent logical Adapter Index.
+ int iAdapterIndex;
+ /// The bit mask identifies the number of bits AdapterDisplayCap is currently using. Sum all the bits defined in ADL_ADAPTER_DISPLAYCAP_XXX
+ int iAdapterDisplayCapMask;
+ /// The bit mask identifies the status. Refer to ADL_ADAPTER_DISPLAYCAP_XXX
+ int iAdapterDisplayCapValue;
+} ADLAdapterDisplayCap, *LPADLAdapterDisplayCap;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about display mapping.
+///
+/// This structure is used to store the display mapping data such as display manner.
+/// For displays with horizontal or vertical stretch manner,
+/// this structure also stores the display order, display row, and column data.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayMap
+{
+/// The current display map index. It is the OS desktop index. For example, if the OS index 1 is showing clone mode, the display map will be 1.
+ int iDisplayMapIndex;
+
+/// The Display Mode for the current map
+ ADLMode displayMode;
+
+/// The number of display targets belongs to this map\n
+ int iNumDisplayTarget;
+
+/// The first target array index in the Target array\n
+ int iFirstDisplayTargetArrayIndex;
+
+/// The bit mask identifies the number of bits DisplayMap is currently using. It is the sum of all the bit definitions defined in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx.
+ int iDisplayMapMask;
+
+///The bit mask identifies the display status. The detailed definition is in ADL_DISPLAY_DISPLAYMAP_MANNER_xxx.
+ int iDisplayMapValue;
+
+} ADLDisplayMap, *LPADLDisplayMap;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about the display device possible map for one GPU
+///
+/// This structure is used to store the display device possible map
+/// This information can be returned to the user.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLPossibleMap
+{
+ /// The current PossibleMap index. Each PossibleMap is assigned an index
+ int iIndex;
+ /// The adapter index identifying the GPU for which to validate these Maps & Targets
+ int iAdapterIndex;
+ /// Number of display Maps for this GPU to be validated
+ int iNumDisplayMap;
+ /// The display Maps list to validate
+ ADLDisplayMap* displayMap;
+ /// the number of display Targets for these display Maps
+ int iNumDisplayTarget;
+ /// The display Targets list for these display Maps to be validated.
+ ADLDisplayTarget* displayTarget;
+} ADLPossibleMap, *LPADLPossibleMap;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about display possible mapping.
+///
+/// This structure is used to store the display possible mapping's controller index for the current display.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLPossibleMapping
+{
+ int iDisplayIndex; ///< The display index. Each display is assigned an index.
+ int iDisplayControllerIndex; ///< The controller index to which display is mapped.
+ int iDisplayMannerSupported; ///< The supported display manner.
+} ADLPossibleMapping, *LPADLPossibleMapping;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+/// \brief Structure containing information about the validated display device possible map result.
+///
+/// This structure is used to store the validated display device possible map result
+/// This information can be returned to the user.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLPossibleMapResult
+{
+ /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1.
+ int iIndex;
+ // The bit mask identifies the number of bits PossibleMapResult is currently using. It will be the sum all the bit definitions defined in ADL_DISPLAY_POSSIBLEMAPRESULT_VALID.
+ int iPossibleMapResultMask;
+ /// The bit mask identifies the possible map result. The detail definition is defined in ADL_DISPLAY_POSSIBLEMAPRESULT_XXX.
+ int iPossibleMapResultValue;
+} ADLPossibleMapResult, *LPADLPossibleMapResult;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display SLS Grid information.
+///
+/// This structure is used to store the display SLS Grid information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLSLSGrid
+{
+/// The Adapter index.
+ int iAdapterIndex;
+
+/// The grid index.
+ int iSLSGridIndex;
+
+/// The grid row.
+ int iSLSGridRow;
+
+/// The grid column.
+ int iSLSGridColumn;
+
+/// The grid bit mask identifies the number of bits DisplayMap is currently using. Sum of all bits defined in ADL_DISPLAY_SLSGRID_ORIENTATION_XXX
+ int iSLSGridMask;
+
+/// The grid bit value identifies the display status. Refer to ADL_DISPLAY_SLSGRID_ORIENTATION_XXX
+ int iSLSGridValue;
+
+} ADLSLSGrid, *LPADLSLSGrid;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display SLS Map information.
+///
+/// This structure is used to store the display SLS Map information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLSLSMap
+{
+ /// The Adapter Index
+ int iAdapterIndex;
+
+ /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1.
+ int iSLSMapIndex;
+
+ /// Indicate the current grid
+ ADLSLSGrid grid;
+
+ /// OS surface index
+ int iSurfaceMapIndex;
+
+ /// Screen orientation. E.g., 0, 90, 180, 270
+ int iOrientation;
+
+ /// The number of display targets belongs to this map
+ int iNumSLSTarget;
+
+ /// The first target array index in the Target array
+ int iFirstSLSTargetArrayIndex;
+
+ /// The number of native modes belongs to this map
+ int iNumNativeMode;
+
+ /// The first native mode array index in the native mode array
+ int iFirstNativeModeArrayIndex;
+
+ /// The number of bezel modes belongs to this map
+ int iNumBezelMode;
+
+ /// The first bezel mode array index in the native mode array
+ int iFirstBezelModeArrayIndex;
+
+ /// The number of bezel offsets belongs to this map
+ int iNumBezelOffset;
+
+ /// The first bezel offset array index in the
+ int iFirstBezelOffsetArrayIndex;
+
+ /// The bit mask identifies the number of bits DisplayMap is currently using. Sum all the bit definitions defined in ADL_DISPLAY_SLSMAP_XXX.
+ int iSLSMapMask;
+
+ /// The bit mask identifies the display map status. Refer to ADL_DISPLAY_SLSMAP_XXX
+ int iSLSMapValue;
+
+
+} ADLSLSMap, *LPADLSLSMap;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display SLS Offset information.
+///
+/// This structure is used to store the display SLS Offset information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLSLSOffset
+{
+ /// The Adapter Index
+ int iAdapterIndex;
+
+ /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1.
+ int iSLSMapIndex;
+
+ /// The Display ID.
+ ADLDisplayID displayID;
+
+ /// SLS Bezel Mode Index
+ int iBezelModeIndex;
+
+ /// SLS Bezel Offset X
+ int iBezelOffsetX;
+
+ /// SLS Bezel Offset Y
+ int iBezelOffsetY;
+
+ /// SLS Display Width
+ int iDisplayWidth;
+
+ /// SLS Display Height
+ int iDisplayHeight;
+
+ /// The bit mask identifies the number of bits Offset is currently using.
+ int iBezelOffsetMask;
+
+ /// The bit mask identifies the display status.
+ int iBezelffsetValue;
+} ADLSLSOffset, *LPADLSLSOffset;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display SLS Mode information.
+///
+/// This structure is used to store the display SLS Mode information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLSLSMode
+{
+ /// The Adapter Index
+ int iAdapterIndex;
+
+ /// The current display map index. It is the OS Desktop index. For example, OS Index 1 showing clone mode. The Display Map will be 1.
+ int iSLSMapIndex;
+
+ /// The mode index
+ int iSLSModeIndex;
+
+ /// The mode for this map.
+ ADLMode displayMode;
+
+ /// The bit mask identifies the number of bits Mode is currently using.
+ int iSLSNativeModeMask;
+
+ /// The bit mask identifies the display status.
+ int iSLSNativeModeValue;
+} ADLSLSMode, *LPADLSLSMode;
+
+
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the display Possible SLS Map information.
+///
+/// This structure is used to store the display Possible SLS Map information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLPossibleSLSMap
+{
+ /// The current display map index. It is the OS Desktop index.
+ /// For example, OS Index 1 showing clone mode. The Display Map will be 1.
+ int iSLSMapIndex;
+
+ /// Number of display map to be validated.
+ int iNumSLSMap;
+
+ /// The display map list for validation
+ ADLSLSMap* lpSLSMap;
+
+ /// the number of display map config to be validated.
+ int iNumSLSTarget;
+
+ /// The display target list for validation.
+ ADLDisplayTarget* lpDisplayTarget;
+} ADLPossibleSLSMap, *LPADLPossibleSLSMap;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the SLS targets.
+///
+/// This structure is used to store the SLS targets information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLSLSTarget
+{
+ /// the logic adapter index
+ int iAdapterIndex;
+
+ /// The SLS map index
+ int iSLSMapIndex;
+
+ /// The target ID
+ ADLDisplayTarget displayTarget;
+
+ /// Target postion X in SLS grid
+ int iSLSGridPositionX;
+
+ /// Target postion Y in SLS grid
+ int iSLSGridPositionY;
+
+ /// The view size width, height and rotation angle per SLS Target
+ ADLMode viewSize;
+
+ /// The bit mask identifies the bits in iSLSTargetValue are currently used
+ int iSLSTargetMask;
+
+ /// The bit mask identifies status info. It is for function extension purpose
+ int iSLSTargetValue;
+
+} ADLSLSTarget, *LPADLSLSTarget;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about the Adapter offset stepping size.
+///
+/// This structure is used to store the Adapter offset stepping size information.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLBezelOffsetSteppingSize
+{
+ /// the logic adapter index
+ int iAdapterIndex;
+
+ /// The SLS map index
+ int iSLSMapIndex;
+
+ /// Bezel X stepping size offset
+ int iBezelOffsetSteppingSizeX;
+
+ /// Bezel Y stepping size offset
+ int iBezelOffsetSteppingSizeY;
+
+ /// Identifies the bits this structure is currently using. It will be the total OR of all the bit definitions.
+ int iBezelOffsetSteppingSizeMask;
+
+ /// Bit mask identifies the display status.
+ int iBezelOffsetSteppingSizeValue;
+
+} ADLBezelOffsetSteppingSize, *LPADLBezelOffsetSteppingSize;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about driver supported PowerExpress Config Caps
+///
+/// This structure is used to store the driver supported PowerExpress Config Caps
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLPXConfigCaps
+{
+ /// The Persistent logical Adapter Index.
+ int iAdapterIndex;
+
+ /// The bit mask identifies the number of bits PowerExpress Config Caps is currently using. It is the sum of all the bit definitions defined in \ref ADL_PX_CONFIGCAPS_XXXX.
+ int iPXConfigCapMask;
+
+ /// The bit mask identifies the PowerExpress Config Caps value. The detailed definition is in \ref ADL_PX_CONFIGCAPS_XXXX.
+ int iPXConfigCapValue;
+
+} ADLPXConfigCaps, *LPADLPXConfigCaps;
+
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about an application
+///
+/// This structure is used to store basic information of an application
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLApplicationData
+{
+ /// Path Name
+ char strPathName[ADL_MAX_PATH];
+ /// File Name
+ char strFileName[ADL_APP_PROFILE_FILENAME_LENGTH];
+ /// Creation timestamp
+ char strTimeStamp[ADL_APP_PROFILE_TIMESTAMP_LENGTH];
+ /// Version
+ char strVersion[ADL_APP_PROFILE_VERSION_LENGTH];
+}ADLApplicationData;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about an application
+///
+/// This structure is used to store basic information of an application
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLApplicationDataX2
+{
+ /// Path Name
+ wchar_t strPathName[ADL_MAX_PATH];
+ /// File Name
+ wchar_t strFileName[ADL_APP_PROFILE_FILENAME_LENGTH];
+ /// Creation timestamp
+ wchar_t strTimeStamp[ADL_APP_PROFILE_TIMESTAMP_LENGTH];
+ /// Version
+ wchar_t strVersion[ADL_APP_PROFILE_VERSION_LENGTH];
+}ADLApplicationDataX2;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information of a property of an application profile
+///
+/// This structure is used to store property information of an application profile
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _PropertyRecord
+{
+ /// Property Name
+ char strName [ADL_APP_PROFILE_PROPERTY_LENGTH];
+ /// Property Type
+ ADLProfilePropertyType eType;
+ /// Data Size in bytes
+ int iDataSize;
+ /// Property Value, can be any data type
+ unsigned char uData[1];
+}PropertyRecord;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about an application profile
+///
+/// This structure is used to store information of an application profile
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLApplicationProfile
+{
+ /// Number of properties
+ int iCount;
+ /// Buffer to store all property records
+ PropertyRecord record[1];
+}ADLApplicationProfile;
+
+// @}
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about an OD5 Power Control feature
+///
+/// This structure is used to store information of an Power Control feature
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLPowerControlInfo
+{
+/// Minimum value.
+int iMinValue;
+/// Maximum value.
+int iMaxValue;
+/// The minimum change in between minValue and maxValue.
+int iStepValue;
+ } ADLPowerControlInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about an controller mode
+///
+/// This structure is used to store information of an controller mode
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLControllerMode
+{
+ /// This falg indicates actions that will be applied by set viewport
+ /// The value can be a combination of ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_POSITION,
+ /// ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_PANLOCK and ADL_CONTROLLERMODE_CM_MODIFIER_VIEW_SIZE
+ int iModifiers;
+
+ /// Horizontal view starting position
+ int iViewPositionCx;
+
+ /// Vertical view starting position
+ int iViewPositionCy;
+
+ /// Horizontal left panlock position
+ int iViewPanLockLeft;
+
+ /// Horizontal right panlock position
+ int iViewPanLockRight;
+
+ /// Vertical top panlock position
+ int iViewPanLockTop;
+
+ /// Vertical bottom panlock position
+ int iViewPanLockBottom;
+
+ /// View resolution in pixels (width)
+ int iViewResolutionCx;
+
+ /// View resolution in pixels (hight)
+ int iViewResolutionCy;
+}ADLControllerMode;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about a display
+///
+/// This structure is used to store information about a display
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayIdentifier
+{
+ /// ADL display index
+ long ulDisplayIndex;
+
+ /// manufacturer ID of the display
+ long ulManufacturerId;
+
+ /// product ID of the display
+ long ulProductId;
+
+ /// serial number of the display
+ long ulSerialNo;
+
+} ADLDisplayIdentifier;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 clock range
+///
+/// This structure is used to store information about Overdrive 6 clock range
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6ParameterRange
+{
+ /// The starting value of the clock range
+ int iMin;
+ /// The ending value of the clock range
+ int iMax;
+ /// The minimum increment between clock values
+ int iStep;
+
+} ADLOD6ParameterRange;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 capabilities
+///
+/// This structure is used to store information about Overdrive 6 capabilities
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6Capabilities
+{
+ /// Contains a bitmap of the OD6 capability flags. Possible values: \ref ADL_OD6_CAPABILITY_SCLK_CUSTOMIZATION,
+ /// \ref ADL_OD6_CAPABILITY_MCLK_CUSTOMIZATION, \ref ADL_OD6_CAPABILITY_GPU_ACTIVITY_MONITOR
+ int iCapabilities;
+ /// Contains a bitmap indicating the power states
+ /// supported by OD6. Currently only the performance state
+ /// is supported. Possible Values: \ref ADL_OD6_SUPPORTEDSTATE_PERFORMANCE
+ int iSupportedStates;
+ /// Number of levels. OD6 will always use 2 levels, which describe
+ /// the minimum to maximum clock ranges.
+ /// The 1st level indicates the minimum clocks, and the 2nd level
+ /// indicates the maximum clocks.
+ int iNumberOfPerformanceLevels;
+ /// Contains the hard limits of the sclk range. Overdrive
+ /// clocks cannot be set outside this range.
+ ADLOD6ParameterRange sEngineClockRange;
+ /// Contains the hard limits of the mclk range. Overdrive
+ /// clocks cannot be set outside this range.
+ ADLOD6ParameterRange sMemoryClockRange;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+} ADLOD6Capabilities;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 clock values.
+///
+/// This structure is used to store information about Overdrive 6 clock values.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6PerformanceLevel
+{
+ /// Engine (core) clock.
+ int iEngineClock;
+ /// Memory clock.
+ int iMemoryClock;
+
+} ADLOD6PerformanceLevel;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 clocks.
+///
+/// This structure is used to store information about Overdrive 6 clocks. This is a
+/// variable-sized structure. iNumberOfPerformanceLevels indicate how many elements
+/// are contained in the aLevels array.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6StateInfo
+{
+ /// Number of levels. OD6 uses clock ranges instead of discrete performance levels.
+ /// iNumberOfPerformanceLevels is always 2. The 1st level indicates the minimum clocks
+ /// in the range. The 2nd level indicates the maximum clocks in the range.
+ int iNumberOfPerformanceLevels;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+ /// Variable-sized array of levels.
+ /// The number of elements in the array is specified by iNumberofPerformanceLevels.
+ ADLOD6PerformanceLevel aLevels [1];
+
+} ADLOD6StateInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about current Overdrive 6 performance status.
+///
+/// This structure is used to store information about current Overdrive 6 performance status.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6CurrentStatus
+{
+ /// Current engine clock
+ int iEngineClock;
+ /// Current memory clock
+ int iMemoryClock;
+ /// Current GPU activity in percent. This
+ /// indicates how "busy" the GPU is.
+ int iActivityPercent;
+ /// Not used. Reserved for future use.
+ int iCurrentPerformanceLevel;
+ /// Current PCI-E bus speed
+ int iCurrentBusSpeed;
+ /// Current PCI-E bus # of lanes
+ int iCurrentBusLanes;
+ /// Maximum possible PCI-E bus # of lanes
+ int iMaximumBusLanes;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+} ADLOD6CurrentStatus;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 thermal contoller capabilities
+///
+/// This structure is used to store information about Overdrive 6 thermal controller capabilities
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6ThermalControllerCaps
+{
+ /// Contains a bitmap of thermal controller capability flags. Possible values: \ref ADL_OD6_TCCAPS_THERMAL_CONTROLLER, \ref ADL_OD6_TCCAPS_FANSPEED_CONTROL,
+ /// \ref ADL_OD6_TCCAPS_FANSPEED_PERCENT_READ, \ref ADL_OD6_TCCAPS_FANSPEED_PERCENT_WRITE, \ref ADL_OD6_TCCAPS_FANSPEED_RPM_READ, \ref ADL_OD6_TCCAPS_FANSPEED_RPM_WRITE
+ int iCapabilities;
+ /// Minimum fan speed expressed as a percentage
+ int iFanMinPercent;
+ /// Maximum fan speed expressed as a percentage
+ int iFanMaxPercent;
+ /// Minimum fan speed expressed in revolutions-per-minute
+ int iFanMinRPM;
+ /// Maximum fan speed expressed in revolutions-per-minute
+ int iFanMaxRPM;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+} ADLOD6ThermalControllerCaps;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 fan speed information
+///
+/// This structure is used to store information about Overdrive 6 fan speed information
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6FanSpeedInfo
+{
+ /// Contains a bitmap of the valid fan speed type flags. Possible values: \ref ADL_OD6_FANSPEED_TYPE_PERCENT, \ref ADL_OD6_FANSPEED_TYPE_RPM, \ref ADL_OD6_FANSPEED_USER_DEFINED
+ int iSpeedType;
+ /// Contains current fan speed in percent (if valid flag exists in iSpeedType)
+ int iFanSpeedPercent;
+ /// Contains current fan speed in RPM (if valid flag exists in iSpeedType)
+ int iFanSpeedRPM;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+} ADLOD6FanSpeedInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 fan speed value
+///
+/// This structure is used to store information about Overdrive 6 fan speed value
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6FanSpeedValue
+{
+ /// Indicates the units of the fan speed. Possible values: \ref ADL_OD6_FANSPEED_TYPE_PERCENT, \ref ADL_OD6_FANSPEED_TYPE_RPM
+ int iSpeedType;
+ /// Fan speed value (units as indicated above)
+ int iFanSpeed;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+} ADLOD6FanSpeedValue;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 PowerControl settings.
+///
+/// This structure is used to store information about Overdrive 6 PowerControl settings.
+/// PowerControl is the feature which allows the performance characteristics of the GPU
+/// to be adjusted by changing the PowerTune power limits.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6PowerControlInfo
+{
+ /// The minimum PowerControl adjustment value
+ int iMinValue;
+ /// The maximum PowerControl adjustment value
+ int iMaxValue;
+ /// The minimum difference between PowerControl adjustment values
+ int iStepValue;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+} ADLOD6PowerControlInfo;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 PowerControl settings.
+///
+/// This structure is used to store information about Overdrive 6 PowerControl settings.
+/// PowerControl is the feature which allows the performance characteristics of the GPU
+/// to be adjusted by changing the PowerTune power limits.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6VoltageControlInfo
+{
+ /// The minimum VoltageControl adjustment value
+ int iMinValue;
+ /// The maximum VoltageControl adjustment value
+ int iMaxValue;
+ /// The minimum difference between VoltageControl adjustment values
+ int iStepValue;
+
+ /// Value for future extension
+ int iExtValue;
+ /// Mask for future extension
+ int iExtMask;
+
+} ADLOD6VoltageControlInfo;
+
+////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing ECC statistics namely SEC counts and DED counts
+/// Single error count - count of errors that can be corrected
+/// Doubt Error Detect - count of errors that cannot be corrected
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLECCData
+{
+ // Single error count - count of errors that can be corrected
+ int iSec;
+ // Double error detect - count of errors that cannot be corrected
+ int iDed;
+
+} ADLECCData;
+
+
+/// \brief Handle to ADL client context.
+///
+/// ADL clients obtain context handle from initial call to \ref ADL2_Main_Control_Create.
+/// Clients have to pass the handle to each subsequent ADL call and finally destroy
+/// the context with call to \ref ADL2_Main_Control_Destroy
+/// \nosubgrouping
+typedef void *ADL_CONTEXT_HANDLE;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing the display mode definition used per controller.
+///
+/// This structure is used to store the display mode definition used per controller.
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct ADLDisplayModeX2
+{
+/// Horizontal resolution (in pixels).
+ int iWidth;
+/// Vertical resolution (in lines).
+ int iHeight;
+/// Interlaced/Progressive. The value will be set for Interlaced as ADL_DL_TIMINGFLAG_INTERLACED. If not set it is progressive. Refer define_detailed_timing_flags.
+ int iScanType;
+/// Refresh rate.
+ int iRefreshRate;
+/// Timing Standard. Refer define_modetiming_standard.
+ int iTimingStandard;
+} ADLDisplayModeX2;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 extension capabilities
+///
+/// This structure is used to store information about Overdrive 6 extension capabilities
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6CapabilitiesEx
+{
+ /// Contains a bitmap of the OD6 extension capability flags. Possible values: \ref ADL_OD6_CAPABILITY_SCLK_CUSTOMIZATION,
+ /// \ref ADL_OD6_CAPABILITY_MCLK_CUSTOMIZATION, \ref ADL_OD6_CAPABILITY_GPU_ACTIVITY_MONITOR,
+ /// \ref ADL_OD6_CAPABILITY_POWER_CONTROL, \ref ADL_OD6_CAPABILITY_VOLTAGE_CONTROL, \ref ADL_OD6_CAPABILITY_PERCENT_ADJUSTMENT,
+ //// \ref ADL_OD6_CAPABILITY_THERMAL_LIMIT_UNLOCK
+ int iCapabilities;
+ /// The Power states that support clock and power customization. Only performance state is currently supported.
+ /// Possible Values: \ref ADL_OD6_SUPPORTEDSTATE_PERFORMANCE
+ int iSupportedStates;
+ /// Returns the hard limits of the SCLK overdrive adjustment range. Overdrive clocks should not be adjusted outside of this range. The values are specified as +/- percentages.
+ ADLOD6ParameterRange sEngineClockPercent;
+ /// Returns the hard limits of the MCLK overdrive adjustment range. Overdrive clocks should not be adjusted outside of this range. The values are specified as +/- percentages.
+ ADLOD6ParameterRange sMemoryClockPercent;
+ /// Returns the hard limits of the Power Limit adjustment range. Power limit should not be adjusted outside this range. The values are specified as +/- percentages.
+ ADLOD6ParameterRange sPowerControlPercent;
+ /// Reserved for future expansion of the structure.
+ int iExtValue;
+ /// Reserved for future expansion of the structure.
+ int iExtMask;
+} ADLOD6CapabilitiesEx;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 extension state information
+///
+/// This structure is used to store information about Overdrive 6 extension state information
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6StateEx
+{
+ /// The current engine clock adjustment value, specified as a +/- percent.
+ int iEngineClockPercent;
+ /// The current memory clock adjustment value, specified as a +/- percent.
+ int iMemoryClockPercent;
+ /// The current power control adjustment value, specified as a +/- percent.
+ int iPowerControlPercent;
+ /// Reserved for future expansion of the structure.
+ int iExtValue;
+ /// Reserved for future expansion of the structure.
+ int iExtMask;
+} ADLOD6StateEx;
+
+/////////////////////////////////////////////////////////////////////////////////////////////
+///\brief Structure containing information about Overdrive 6 extension recommended maximum clock adjustment values
+///
+/// This structure is used to store information about Overdrive 6 extension recommended maximum clock adjustment values
+/// \nosubgrouping
+////////////////////////////////////////////////////////////////////////////////////////////
+typedef struct _ADLOD6MaxClockAdjust
+{
+ /// The recommended maximum engine clock adjustment in percent, for the specified power limit value.
+ int iEngineClockMax;
+ /// The recommended maximum memory clock adjustment in percent, for the specified power limit value.
+ /// Currently the memory is independent of the Power Limit setting, so iMemoryClockMax will always return the maximum
+ /// possible adjustment value. This field is here for future enhancement in case we add a dependency between Memory Clock
+ /// adjustment and Power Limit setting.
+ int iMemoryClockMax;
+ /// Reserved for future expansion of the structure.
+ int iExtValue;
+ /// Reserved for future expansion of the structure.
+ int iExtMask;
+} ADLOD6MaxClockAdjust;
+
+#endif /* ADL_STRUCTURES_H_ */
+
diff --git a/renderdoc/driver/ihv/amd/official/RGP/Common/DriverToolsDefinitions.h b/renderdoc/driver/ihv/amd/official/RGP/Common/DriverToolsDefinitions.h
new file mode 100644
index 000000000..8a411b777
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/Common/DriverToolsDefinitions.h
@@ -0,0 +1,66 @@
+//=============================================================================
+/// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief Shared definitions for the Developer Driver components.
+//=============================================================================
+
+#ifndef _DRIVER_TOOLS_DEFINITIONS_H_
+#define _DRIVER_TOOLS_DEFINITIONS_H_
+
+#include "Version.h"
+#include "../DevDriverComponents/inc/gpuopen.h"
+#include "../DevDriverComponents/inc/ddPlatform.h"
+
+#ifdef WIN32
+#include
+#endif
+
+#ifdef _DEBUG
+ #define SHOW_DEBUG_WINDOW 1
+#endif
+
+#define SAFE_DELETE(x) {if(x){delete (x); (x) = nullptr; }}
+#define SAFE_DELETE_ARRAY(x) {if(x){delete [] (x); x = nullptr; }}
+
+#ifdef HEADLESS
+#define HEADLESS_FILENAME_SUFFIX "CLI"
+#else
+#define HEADLESS_FILENAME_SUFFIX ""
+#endif // HEADLESS
+
+#define BUILD_FILENAME_SUFFIX ""
+
+static const char* gs_RDP_SETTINGS_DIRECTORY = "RadeonDeveloperDriver"; ///< RDP and RDS use this directory to write settings to.
+static const char* gs_RGP_EXECUTABLE_FILENAME = "RadeonGPUProfiler" BUILD_FILENAME_SUFFIX; ///< RGP's executable filename.
+static const char* gs_RDP_EXECUTABLE_FILENAME = "RadeonDeveloperPanel" BUILD_FILENAME_SUFFIX; ///< RDP's executable filename.
+static const char* gs_RDP_APPLICATION_GUID = "C9EB0587-F8F7-4B8C-B35A-F7C2862CFDA7"; ///< Unique identifier for the RDP application
+static const char* gs_RDS_EXECUTABLE_FILENAME = "RadeonDeveloperService" HEADLESS_FILENAME_SUFFIX BUILD_FILENAME_SUFFIX; ///< RDS's executable filename.
+static const char* gs_RDS_APPLICATION_GUID = "D0939873-BA4B-4C4E-9729-D82DED85BC41"; ///< Unique identifier for the RDS service
+static const char* gs_RGP_TRACE_EXTENSION = ".rgp"; ///< The extension used when saving RGP trace files.
+
+// Help for Command line options
+#ifdef WIN32
+static const char* gs_RDS_CLI_USAGE_DESCRIPTION = " [--help] | [--port ] | [--enableUWP]\n\n";
+#else
+static const char* gs_RDS_CLI_USAGE_DESCRIPTION = " [--help] | [--port ]\n\n";
+#endif // WIN32
+static const char* gs_RDS_CLI_HELP_OPTION_DESCRIPTION = "--help This help message."; ///< Command line help for --help
+static const char* gs_RDS_CLI_PORT_OPTION_DESCRIPTION = "--port The listener port. Where is a value between 1 and 65535."; ///< Command line help for --port
+static const char* gs_RDS_CLI_UWPENABLE_OPTION_DESCRIPTION = "--enableUWP Enable UWP support."; ///< Command line help for --enableUWP
+
+// Default RDS connection info.
+static const char* gs_DEFAULT_HOST_ADDRESS = "0.0.0.0"; ///< The default address to listen on for incoming connections.
+static const unsigned int gs_DEFAULT_CONNECTION_PORT = 27300; ///< The default port used to connect the Developer Panel to the Developer Service.
+static const unsigned short gs_MAX_LISTEN_PORT = 65535; ///< The highest port that the Developer Service can listen on.
+
+// Control window sizes.
+static const int gs_DESKTOP_MARGIN = 25;
+static const int gs_OS_TITLE_BAR_HEIGHT = 35;
+static const float gs_DESKTOP_AVAIL_WIDTH_PCT = 99.0f;
+static const float gs_DESKTOP_AVAIL_HEIGHT_PCT = 95.0f;
+static const float gs_MAIN_WINDOW_DESKTOP_WIDTH_PCT = 100.0f;
+static const float gs_MAIN_WINDOW_DESKTOP_HEIGHT_PCT = 85.0f;
+static const float gs_DBG_WINDOW_DESKTOP_WIDTH_PCT = 35.0f;
+
+#endif // _DRIVER_TOOLS_DEFINITIONS_H_
diff --git a/renderdoc/driver/ihv/amd/official/RGP/Common/Version.h b/renderdoc/driver/ihv/amd/official/RGP/Common/Version.h
new file mode 100644
index 000000000..08313d2f1
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/Common/Version.h
@@ -0,0 +1,32 @@
+//=============================================================================
+/// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief Version number info for the Developer Driver tools.
+//=============================================================================
+
+#ifndef _VERSION_H_
+#define _VERSION_H_
+
+#define STRINGIFY_VALUE(x) STRINGIFY(x)
+#define STRINGIFY(x) #x
+
+#define DEV_DRIVER_TOOLS_MAJOR_VERSION 1 ///< Major version number.
+#define DEV_DRIVER_TOOLS_MINOR_VERSION 2 ///< Minor version number.
+#define DEV_DRIVER_TOOLS_BUGFIX_NUMBER 0 ///< Bugfix number.
+#define DEV_DRIVER_TOOLS_BUILD_NUMBER 0 ///< Build number.
+
+#ifdef HEADLESS
+#define DEV_DRIVER_TOOLS_BUILD_SUFFIX "- CLI" ///< The build suffix to apply to the product name for headess build.
+#else
+#define DEV_DRIVER_TOOLS_BUILD_SUFFIX "" ///< The build suffix to apply to the product name.
+#endif // HEADLESS
+
+#define DEV_DRIVER_TOOLS_BUILD_DATE_STRING "4/10/2018" ///< Build date string.
+
+#define DEV_DRIVER_TOOLS_VERSION_STRING STRINGIFY_VALUE(DEV_DRIVER_TOOLS_MAJOR_VERSION) "." \
+ STRINGIFY_VALUE(DEV_DRIVER_TOOLS_MINOR_VERSION) "." \
+ STRINGIFY_VALUE(DEV_DRIVER_TOOLS_BUGFIX_NUMBER) "." \
+ STRINGIFY_VALUE(DEV_DRIVER_TOOLS_BUILD_NUMBER) ///< The full revision string.
+
+#endif // _VERSION_H_
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/ADLGetDriverVersion.cpp b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/ADLGetDriverVersion.cpp
new file mode 100644
index 000000000..20978e799
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/ADLGetDriverVersion.cpp
@@ -0,0 +1,218 @@
+//=============================================================================
+/// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief Retrieve driver version information for AMD Radeon Drivers on Windows using ADL
+//=============================================================================
+
+// To compile from the windows CMD prompt into a standalone command-line executable for test
+// - use the following commands with Visual Studio 2017
+//
+// > "c:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\Tools\vsvars32.bat"
+// > cl ADLGetDriverVersion.cpp -I -D COMMAND_LINE_TEST /EHsc
+
+#ifdef _WIN32
+#include
+#include
+#include "adl_sdk.h"
+
+#include "ADLGetDriverVersion.h"
+
+/// Structure used to query driver version info
+typedef struct ADLVersionsInfo
+{
+ /// Driver Release (Packaging) Version (e.g. 8.71-100128n-094835E-ATI)
+ char strDriverVer[ADL_MAX_PATH];
+ /// Catalyst Version(e.g. "10.1").
+ char strCatalystVersion[ADL_MAX_PATH];
+ /// Web link to an XML file with information about the latest AMD drivers and locations (e.g. "http://www.amd.com/us/driverxml" )
+ char strCatalystWebLink[ADL_MAX_PATH];
+
+} ADLVersionsInfo, *LPADLVersionsInfo;
+
+// Definitions of the used ADL function pointers.
+typedef int(*ADL2_MAIN_CONTROL_CREATE)(ADL_MAIN_MALLOC_CALLBACK, int, ADL_CONTEXT_HANDLE*);
+typedef int(*ADL2_MAIN_CONTROL_DESTROY)(ADL_CONTEXT_HANDLE);
+typedef int(*ADL2_GRAPHICS_VERSION_GET)(ADL_CONTEXT_HANDLE context, ADLVersionsInfo * lpVersionsInfo);
+
+// Memory allocation function for use with ADL
+static void* __stdcall ADL_Main_Memory_Alloc(int iSize)
+{
+ void* lpBuffer = malloc(iSize);
+ return lpBuffer;
+}
+
+//-----------------------------------------------------------------------------
+/// Parse version string returned by the driver via ADL to extract version info
+/// \param versionString The string returned from the driver via ADL
+/// \param major The major version number
+/// \param minor The minor version number
+/// \param subminor The subminor version number
+/// \return true if successful, or false on error
+//-----------------------------------------------------------------------------
+static bool parseDriverVersionString(char *versionString, unsigned int &major, unsigned int &minor, unsigned int &subminor)
+{
+ major = minor = subminor = 0;
+ std::string strDriverVersion(versionString);
+
+#ifdef COMMAND_LINE_TEST
+ printf("\nVersion string from driver: %s\n", versionString);
+#endif
+
+ // driver version looks like: 13.35.1005-140131a-167669E-ATI or 14.10-140115n-021649E-ATI, etc...
+ // truncate at the first dash
+ strDriverVersion = strDriverVersion.substr(0, strDriverVersion.find("-", 0));
+
+ size_t pos = 0;
+ std::string strToken;
+ std::string strDelimiter = ".";
+ std::stringstream ss;
+
+ // parse the major driver version (start of string to first ".")
+ pos = strDriverVersion.find(strDelimiter);
+
+ if (pos == std::string::npos)
+ {
+ // delimiter not found
+ return false;
+ }
+
+ strToken = strDriverVersion.substr(0, pos);
+ ss.str(strToken);
+
+ if ((ss >> major).fail())
+ {
+ major = 0;
+ return false;
+ }
+
+ strDriverVersion.erase(0, pos + strDelimiter.length()); // Delete section of string already parsed
+
+ // parse the minor driver version
+ bool subminorAvailable = false;
+
+ pos = strDriverVersion.find(strDelimiter);
+
+ if (pos != std::string::npos)
+ {
+ // Delimiter found
+ strToken = strDriverVersion.substr(0, pos);
+ strDriverVersion.erase(0, pos + strDelimiter.length());
+ subminorAvailable = true;
+ }
+ else
+ {
+ // No delimeter - use entire string
+ strToken = strDriverVersion;
+ }
+
+ ss.clear();
+ ss.str(strToken);
+
+ if ((ss >> minor).fail())
+ {
+ major = 0;
+ minor = 0;
+ return false;
+ }
+
+ // parse the sub-minor driver version
+ if (subminorAvailable)
+ {
+ pos = strDriverVersion.find(strDelimiter);
+
+ if (pos != std::string::npos)
+ {
+ // Delimiter found
+ strToken = strDriverVersion.substr(0, pos);
+ }
+ else
+ {
+ strToken = strDriverVersion;
+ }
+ ss.clear();
+ ss.str(strToken);
+
+ if ((ss >> subminor).fail())
+ {
+ major = 0;
+ minor = 0;
+ subminor = 0;
+ return false;
+ }
+ }
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+/// Use ADL on Windows to retrieve the driver version number
+/// \param majorVar The major version number
+/// \param minorVer The minor version number
+/// \param subminorVer The subminor version number
+/// \return true if successful, or false on error
+//-----------------------------------------------------------------------------
+bool ADLGetDriverVersion(unsigned int& majorVer, unsigned int& minorVer, unsigned int& subminorVer)
+{
+ bool retStatus = false;
+
+ HINSTANCE hDLL = LoadLibrary(TEXT("atiadlxx.dll"));
+
+ if (NULL == hDLL)
+ {
+ // A 32 bit calling application on 64 bit OS will fail to LoadLIbrary.
+ // Try to load the 32 bit library (atiadlxy.dll) instead
+ hDLL = LoadLibrary(TEXT("atiadlxy.dll"));
+ }
+
+ if (NULL != hDLL)
+ {
+ ADL2_MAIN_CONTROL_CREATE ADL2_Main_Control_Create = (ADL2_MAIN_CONTROL_CREATE)GetProcAddress(hDLL, "ADL2_Main_Control_Create");;
+ ADL2_MAIN_CONTROL_DESTROY ADL2_Main_Control_Destroy = (ADL2_MAIN_CONTROL_DESTROY)GetProcAddress(hDLL, "ADL2_Main_Control_Destroy");
+ ADL2_GRAPHICS_VERSION_GET ADL2_Graphics_Versions_Get = (ADL2_GRAPHICS_VERSION_GET)GetProcAddress(hDLL, "ADL2_Graphics_Versions_Get");
+
+ if (NULL != ADL2_Main_Control_Create &&
+ NULL != ADL2_Main_Control_Destroy &&
+ NULL != ADL2_Graphics_Versions_Get
+ )
+ {
+ ADL_CONTEXT_HANDLE adlContext = NULL;
+ if (ADL_OK == ADL2_Main_Control_Create(ADL_Main_Memory_Alloc, 1, &adlContext))
+ {
+ ADLVersionsInfo versionsInfo;
+ int ADLResult = ADL2_Graphics_Versions_Get(adlContext, &versionsInfo);
+ if (ADL_OK == ADLResult || ADL_OK_WARNING == ADLResult)
+ {
+ retStatus = parseDriverVersionString(versionsInfo.strDriverVer, majorVer, minorVer, subminorVer);
+ }
+ ADL2_Main_Control_Destroy(adlContext);
+ }
+ }
+ FreeLibrary(hDLL);
+ }
+ return retStatus;
+}
+
+#endif // _WIN32
+
+#ifdef COMMAND_LINE_TEST
+int main()
+{
+ unsigned int major, minor, subminor;
+
+ if (ADLGetDriverVersion(major, minor, subminor) == true)
+ {
+ printf("\nDriver Major Version: %d", major);
+ printf("\nDriver Minor Version: %d", minor);
+ if (subminor != 0)
+ {
+ printf("\nDriver SubMinor Version: %d", subminor);
+ }
+ }
+ else
+ {
+ printf("\nUnable to retrieve driver version information");
+ }
+ printf("\n");
+
+}
+#endif
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/ADLGetDriverVersion.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/ADLGetDriverVersion.h
new file mode 100644
index 000000000..e2af360e9
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/ADLGetDriverVersion.h
@@ -0,0 +1,21 @@
+//=============================================================================
+/// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief Retrieve driver version information for AMD Radeon Drivers on Windows using ADL
+//=============================================================================
+#ifndef ADL_GET_DRIVER_VERSION_H_
+#define ADL_GET_DRIVER_VERSION_H_
+
+#ifdef _WIN32
+//-----------------------------------------------------------------------------
+/// Use ADL on Windows to retrieve the driver version number
+/// \param majorVar The major version number
+/// \param minorVer The minor version number
+/// \param subminorVer The subminor version number
+/// \return true if successful, or false on error
+//-----------------------------------------------------------------------------
+bool ADLGetDriverVersion(unsigned int& majorVer, unsigned int& minorVer, unsigned int& subminorVer);
+#endif // _WIN32
+
+#endif // ADL_GET_DRIVER_VERSION_H_
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/DevDriverAPI.cpp b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/DevDriverAPI.cpp
new file mode 100644
index 000000000..33c769d30
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/DevDriverAPI.cpp
@@ -0,0 +1,345 @@
+//=============================================================================
+/// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief An API for the developer mode driver to initialize driver protocols.
+/// Can be used by applications to take RGP profiles of themselves
+//=============================================================================
+
+#ifdef _WIN32
+#include "ADLGetDriverVersion.h"
+#else
+#include
+#include
+#include
+#endif
+
+#include
+
+#include "DevDriverAPI.h"
+#include "RGPClientInProcessModel.h"
+
+// C wrapper functions
+
+//-----------------------------------------------------------------------------
+/// Initialization function. To be called before initializing the device.
+/// \param featureList An array of DevDriverFeatures structures containing
+/// a list of features to be enabled
+/// \param featureCount The number of features in the list
+/// \param pOutHandle A returned handle to the DevDriverAPI context.
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not. If this function fails, pOutHandle will be unchanged.
+//-----------------------------------------------------------------------------
+static DevDriverStatus DEV_DRIVER_API_CALL
+Init(const DevDriverFeatures featureList[], uint32_t featureCount, DevDriverAPIContext* pOutHandle)
+{
+ bool rgpEnabled = false;
+
+ for (uint32_t loop = 0; loop < featureCount; loop++)
+ {
+ DevDriverFeature feature = featureList[loop].m_option;
+ switch (feature)
+ {
+ case DEV_DRIVER_FEATURE_ENABLE_RGP:
+ rgpEnabled = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+
+ RGPClientInProcessModel* pHandle = new(std::nothrow) RGPClientInProcessModel();
+
+ if (pHandle != nullptr)
+ {
+ if (pHandle->Init(rgpEnabled) == true)
+ {
+ *pOutHandle = reinterpret_cast(pHandle);
+ return DEV_DRIVER_STATUS_SUCCESS;
+ }
+ else
+ {
+ delete pHandle;
+ return DEV_DRIVER_STATUS_FAILED;
+ }
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_BAD_ALLOC;
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Cleanup function. To be called at application shutdown.
+/// \param context The DevDriverAPI context
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not.
+//-----------------------------------------------------------------------------
+static DevDriverStatus DEV_DRIVER_API_CALL
+Finish(DevDriverAPIContext handle)
+{
+ if (handle != nullptr)
+ {
+ RGPClientInProcessModel* pObj = reinterpret_cast(handle);
+ pObj->Finish();
+ delete pObj;
+ return DEV_DRIVER_STATUS_SUCCESS;
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_NULL_POINTER;
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Start triggering a profile. The actual profiling is done in a separate thread.
+/// The calling function will need to call IsRGPProfileCaptured() to determine
+/// if the profile has finished.
+/// \param context The DevDriverAPI context
+/// \param profileOptions A structure of type RGPProfileOptions containing the
+/// profile options
+/// \return DEV_DRIVER_STATUS_SUCCESS if a capture was successfully started, or
+/// a DevDriverStatus error code if not.
+//-----------------------------------------------------------------------------
+static DevDriverStatus DEV_DRIVER_API_CALL
+TriggerCapture(DevDriverAPIContext handle, const RGPProfileOptions* const profileOptions)
+{
+ if (handle != nullptr)
+ {
+ RGPClientInProcessModel* pObj = reinterpret_cast(handle);
+ bool requestingFrameTerminators = pObj->SetTriggerMarkerParams(profileOptions->m_beginFrameTerminatorTag, profileOptions->m_endFrameTerminatorTag,
+ profileOptions->m_pBeginFrameTerminatorString, profileOptions->m_pEndFrameTerminatorString);
+
+ bool captureAllowed = pObj->IsCaptureAllowed(requestingFrameTerminators);
+ if (captureAllowed == false)
+ {
+ return DEV_DRIVER_STATUS_INVALID_PARAMETERS;
+ }
+
+ bool triggered = pObj->TriggerCapture(profileOptions->m_pProfileFilePath);
+ if (triggered == true)
+ {
+ return DEV_DRIVER_STATUS_SUCCESS;
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_CAPTURE_FAILED;
+ }
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_NULL_POINTER;
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Has an RGP profile been taken?
+/// \param context The DevDriverAPI context
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not.
+//-----------------------------------------------------------------------------
+static DevDriverStatus DEV_DRIVER_API_CALL
+IsProfileCaptured(DevDriverAPIContext handle)
+{
+ if (handle != nullptr)
+ {
+ bool captured = reinterpret_cast(handle)->IsProfileCaptured();
+ if (captured == true)
+ {
+ return DEV_DRIVER_STATUS_SUCCESS;
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_NOT_CAPTURED;
+ }
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_NULL_POINTER;
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Get the name of the last captured RGP profile. Call this after taking a
+/// profile.
+/// \param context The DevDriverAPI context
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not.
+//-----------------------------------------------------------------------------
+static DevDriverStatus DEV_DRIVER_API_CALL
+GetProfileName(DevDriverAPIContext handle, const char** ppOutProfileName)
+{
+ if (handle != nullptr)
+ {
+ const char* pProfileName = reinterpret_cast(handle)->GetProfileName();
+ *ppOutProfileName = pProfileName;
+ return DEV_DRIVER_STATUS_SUCCESS;
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_NULL_POINTER;
+ }
+}
+
+#ifndef _WIN32
+//-----------------------------------------------------------------------------
+/// Convert a string to an int. Continue parsing the string until an non-digit
+/// is found.
+/// \param pString Reference to a pointer to a string to parse. The new value
+/// of the pointer is modified in the calling function
+/// \return The integer value found in the string. If no integer value is found
+/// 0 is returned.
+//-----------------------------------------------------------------------------
+static unsigned int ToInt(const char* &pString)
+{
+ unsigned int value = 0;
+ while (*pString >= '0' && *pString <= '9')
+ {
+ value *= 10;
+ value += *pString++ - '0';
+ }
+ return value;
+}
+#endif
+
+//-----------------------------------------------------------------------------
+/// Get the video driver version number.
+/// indirectly returns the major and minor version numbers in the parameters
+/// \param outMajorVersion The major version number returned
+/// \param outMinorVersion The minor version number returned
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not. If an error is returned, the version nunbers passed in are
+/// unmodified.
+//-----------------------------------------------------------------------------
+static DevDriverStatus DEV_DRIVER_API_CALL
+GetDriverVersion(DevDriverAPIContext handle, unsigned int& outMajorVersion, unsigned int& outMinorVersion)
+{
+ if (handle == nullptr)
+ {
+ return DEV_DRIVER_STATUS_NULL_POINTER;
+ }
+
+ bool result = false;
+ unsigned int subMinorVer = 0;
+#ifdef _WIN32
+ result = ADLGetDriverVersion(outMajorVersion, outMinorVersion, subMinorVer);
+#else
+ const int sysret = system("modinfo amdgpu | grep version > version.txt");
+ if (sysret != 0)
+ {
+ return DEV_DRIVER_STATUS_ERROR;
+ }
+
+ std::string lineString;
+ std::ifstream inFile;
+ const char* versionFile = "version.txt";
+ inFile.open(versionFile);
+ if (inFile.is_open())
+ {
+ do
+ {
+ getline(inFile, lineString);
+ size_t pos = 0;
+ const char* searchString = "version:";
+ const size_t searchStringLength = strlen(searchString);
+
+ // look for all instances of the search string and only consider ones which are longer than
+ // the search string. These strings should have a version number on the end. The complete version
+ // string should look something like:
+ // version: 18.10.0.1
+ pos = lineString.find(searchString, pos);
+ if (pos == 0)
+ {
+ const char* pVersion = lineString.c_str();
+ pVersion += searchStringLength;
+
+ // skip spaces
+ while (*pVersion == ' ')
+ {
+ pVersion++;
+ }
+
+ int majVer = 0;
+ int minVer = 0;
+
+ // get the major version number
+ majVer = ToInt(pVersion);
+
+ DD_ASSERT(pVersion[0] == '.');
+
+ // skip the delimiter
+ pVersion++;
+
+ // get the minor version
+ minVer = ToInt(pVersion);
+
+ outMajorVersion = majVer;
+ outMinorVersion = minVer;
+ result = true;
+ }
+ }
+ while (lineString.length() > 0 && result == false);
+ inFile.close();
+ }
+
+ // remove the file
+ remove(versionFile);
+
+#endif
+
+ if (result == true)
+ {
+ return DEV_DRIVER_STATUS_SUCCESS;
+ }
+ else
+ {
+ return DEV_DRIVER_STATUS_ERROR;
+ }
+}
+
+//-----------------------------------------------------------------------------
+/// Get the function table
+/// \param pAprTableOut Pointer to an array to receive the list of function
+/// pointers. Should be initialized to be at least the size of a DevDriverAPI
+/// structure.
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not.
+//-----------------------------------------------------------------------------
+DEV_DRIVER_API_EXPORT DevDriverStatus DEV_DRIVER_API_CALL
+DevDriverGetFuncTable(void* pApiTableOut)
+{
+ if (pApiTableOut == nullptr)
+ {
+ return DEV_DRIVER_STATUS_NULL_POINTER;
+ }
+
+ DevDriverAPI* pApiTable = reinterpret_cast(pApiTableOut);
+
+ if (pApiTable->majorVersion != DEV_DRIVER_API_MAJOR_VERSION)
+ {
+ // only support the exact major version match for now
+ return DEV_DRIVER_STATUS_INVALID_MAJOR_VERSION;
+ }
+
+ uint32_t suppliedMinorVersion = pApiTable->minorVersion;
+
+ // build the dispatch table containing all supported functions in this library
+ DevDriverAPI apiTable;
+
+ apiTable.majorVersion = DEV_DRIVER_API_MAJOR_VERSION;
+ apiTable.minorVersion = std::min(suppliedMinorVersion, DEV_DRIVER_API_MINOR_VERSION);
+
+ apiTable.DevDriverInit = Init;
+ apiTable.DevDriverFinish = Finish;
+
+ apiTable.TriggerRgpProfile = TriggerCapture;
+ apiTable.IsRgpProfileCaptured = IsProfileCaptured;
+ apiTable.GetRgpProfileName = GetProfileName;
+
+ apiTable.GetDriverVersion = GetDriverVersion;
+
+ // only copy the functions supported by the incoming requested library
+ memcpy(pApiTable, &apiTable, apiTable.minorVersion);
+ return DEV_DRIVER_STATUS_SUCCESS;
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/DevDriverAPI.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/DevDriverAPI.h
new file mode 100644
index 000000000..746dc323e
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/DevDriverAPI.h
@@ -0,0 +1,170 @@
+//=============================================================================
+/// Copyright (c) 2018 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief An API for the developer mode driver to initialize driver protocols.
+/// Can be used by applications to take RGP profiles of themselves
+//=============================================================================
+#ifndef DEV_DRIVER_API_H_
+#define DEV_DRIVER_API_H_
+
+#include
+
+#if defined(_WIN32) || defined(__CYGWIN__)
+ /// The API calling convention on windows.
+ #define DEV_DRIVER_API_CALL __cdecl
+ #ifdef BUILD_DLL
+ #define DEV_DRIVER_API_EXPORT __declspec(dllexport)
+ #elif defined(IMPORT_DLL)
+ #define DEV_DRIVER_API_EXPORT __declspec(dllimport)
+ #else
+ #define DEV_DRIVER_API_EXPORT
+ #endif // BUILD_DLL
+#else
+ /// The API calling convention on linux.
+ #define DEV_DRIVER_API_CALL
+ #define DEV_DRIVER_API_EXPORT
+#endif
+
+#define DEV_DRIVER_API_MAJOR_VERSION 1
+#define DEV_DRIVER_API_MINOR_VERSION (sizeof(DevDriverAPI))
+
+#ifdef __cplusplus
+extern "C" {
+#endif // #ifdef __cplusplus
+
+typedef void* DevDriverAPIContext;
+
+// An enum of status codes returned from the API
+typedef enum
+{
+ DEV_DRIVER_STATUS_SUCCESS = 0,
+ DEV_DRIVER_STATUS_ERROR = -1,
+ DEV_DRIVER_STATUS_FAILED = -2,
+ DEV_DRIVER_STATUS_NULL_POINTER = -3,
+ DEV_DRIVER_STATUS_BAD_ALLOC = -4,
+ DEV_DRIVER_STATUS_CAPTURE_FAILED = -5,
+ DEV_DRIVER_STATUS_NOT_CAPTURED = -6,
+ DEV_DRIVER_STATUS_INVALID_MAJOR_VERSION = -7,
+ DEV_DRIVER_STATUS_INVALID_PARAMETERS = -8,
+} DevDriverStatus;
+
+// An enum of options to pass into the DevDriverAPI
+typedef enum
+{
+ DEV_DRIVER_FEATURE_ENABLE_RGP = 1,
+} DevDriverFeature;
+
+// structure containing any features relating to RGP
+typedef struct DevDriverFeatureRGP
+{
+ // presently nothing needed for RGP initialization
+ uint32_t reserved; ///< ensure a specific size struct for C/C++
+} DevDriverFeatureRGP;
+
+// structure containing a developer driver feature. Specific
+// feature structures can be added to the union as needed
+typedef struct DevDriverFeatures
+{
+ DevDriverFeature m_option;
+ uint32_t m_size;
+ union
+ {
+ DevDriverFeatureRGP m_featureRGP;
+ };
+} DevDriverFeatures;
+
+// structure containing any options required for taking an RGP profile
+typedef struct RGPProfileOptions
+{
+ const char* m_pProfileFilePath; ///< The file (and path) used to save the captured profile to. If the
+ ///< path is omitted, the file will be saved to the default folder.
+ ///< If nullptr is specified, then a filename will be generated based
+ ///< on the process name and a date/time timestamp
+
+ // frame terminator values
+ uint64_t m_beginFrameTerminatorTag; ///< frame terminator begin tag (vulkan). Should be non-zero if being used
+ uint64_t m_endFrameTerminatorTag; ///< frame terminator end tag (vulkan). Should be non-zero if being used
+ const char* m_pBeginFrameTerminatorString; ///< frame terminator begin string (D3D12). Should be non-null/non-empty if being used
+ const char* m_pEndFrameTerminatorString; ///< frame terminator end string (D3D12). Should be non-null/non-empty if being used
+} RGPProfileOptions;
+
+// function typedefs
+
+/// Initialization function. To be called before initializing the device.
+/// \param featureList An array of DevDriverFeatures structures containing
+/// a list of features to be enabled
+/// \param featureCount The number of features in the list
+/// \param pOutHandle A returned handle to the DevDriverAPI context.
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not. If this function fails, pOutHandle will be unchanged.
+typedef DevDriverStatus(DEV_DRIVER_API_CALL*
+ DevDriverFnInit)(const DevDriverFeatures featureList[], uint32_t featureCount, DevDriverAPIContext* pOutHandle);
+
+/// Cleanup function. To be called at application shutdown.
+/// \param context The DevDriverAPI context
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not.
+typedef DevDriverStatus(DEV_DRIVER_API_CALL*
+ DevDriverFnFinish)(DevDriverAPIContext context);
+
+/// Start triggering a profile. The actual profiling is done in a separate thread.
+/// The calling function will need to call IsRGPProfileCaptured() to determine
+/// if the profile has finished.
+/// \param context The DevDriverAPI context
+/// \param profileOptions A structure of type RGPProfileOptions containing the
+/// profile options
+/// \return DEV_DRIVER_STATUS_SUCCESS if a capture was successfully started, or
+/// a DevDriverStatus error code if not.
+typedef DevDriverStatus(DEV_DRIVER_API_CALL*
+ DevDriverFnTriggerRGPProfile)(DevDriverAPIContext context, const RGPProfileOptions* const profileOptions);
+
+/// Has an RGP profile been taken?
+/// \param context The DevDriverAPI context
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not.
+typedef DevDriverStatus(DEV_DRIVER_API_CALL*
+ DevDriverFnIsRGPProfileCaptured)(DevDriverAPIContext context);
+
+/// Get the name of the last captured RGP profile. Call this after taking a
+/// profile.
+/// \param context The DevDriverAPI context
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not.
+typedef DevDriverStatus(DEV_DRIVER_API_CALL*
+ DevDriverFnGetRGPProfileName)(DevDriverAPIContext context, const char** ppOutProfileName);
+
+/// Get the video driver version number.
+/// indirectly returns the major and minor version numbers in the parameters
+/// \param outMajorVersion The major version number returned
+/// \param outMinorVersion The minor version number returned
+/// \return DEV_DRIVER_STATUS_SUCCESS if successful, or a DevDriverStatus error
+/// code if not. If an error is returned, the version nunbers passed in are
+/// unmodified.
+typedef DevDriverStatus(DEV_DRIVER_API_CALL*
+ DevDriverFnGetDriverVersion)(DevDriverAPIContext context, unsigned int& outMajorVersion, unsigned int& outMinorVersion);
+
+// structure containing the list of functions supported by this version of the API.
+// Also contains major and minor version numbers
+typedef struct DevDriverAPI
+{
+ uint32_t majorVersion;
+ uint32_t minorVersion;
+
+ DevDriverFnInit DevDriverInit;
+ DevDriverFnFinish DevDriverFinish;
+
+ DevDriverFnTriggerRGPProfile TriggerRgpProfile;
+ DevDriverFnIsRGPProfileCaptured IsRgpProfileCaptured;
+ DevDriverFnGetRGPProfileName GetRgpProfileName;
+ DevDriverFnGetDriverVersion GetDriverVersion;
+} DevDriverAPI;
+
+/// Get the function table
+DEV_DRIVER_API_EXPORT DevDriverStatus DEV_DRIVER_API_CALL DevDriverGetFuncTable(void* pApiTableOut);
+
+#ifdef __cplusplus
+}
+#endif // #ifdef __cplusplus
+
+#endif // DEV_DRIVER_API_H_
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/RGPClientInProcessModel.cpp b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/RGPClientInProcessModel.cpp
new file mode 100644
index 000000000..ec2adff19
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/RGPClientInProcessModel.cpp
@@ -0,0 +1,835 @@
+//=============================================================================
+/// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief a class to provide service to initialize dev driver protocols to
+/// capture rgp trace from within the profiled application.
+//=============================================================================
+#include
+#include
+#include
+#include
+#include "RGPClientInProcessModel.h"
+
+#include
+#include
+
+#include
+
+#include "../../Common/DriverToolsDefinitions.h"
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+#ifdef _LINUX
+int sprintf_s(char* _DstBuf, size_t _SizeInBytes, const char* _Format, ...)
+{
+ int retVal;
+ va_list arg_ptr;
+
+ va_start(arg_ptr, _Format);
+ retVal = vsnprintf(_DstBuf, _SizeInBytes, _Format, arg_ptr);
+ va_end(arg_ptr);
+ return retVal;
+}
+
+char* strncpy_s(char* _DstBuf, const char* _SrcBuf, size_t num)
+{
+ return strncpy(_DstBuf, _SrcBuf, num);
+}
+#endif
+
+void* GenericAlloc(void* pUserdata, size_t size, size_t alignment, bool zero)
+{
+ DD_UNUSED(pUserdata);
+
+ return DevDriver::Platform::AllocateMemory(size, alignment, zero);
+}
+
+void GenericFree(void* pUserdata, void* pMemory)
+{
+ DD_UNUSED(pUserdata);
+
+ DevDriver::Platform::FreeMemory(pMemory);
+}
+
+DevDriver::AllocCb GenericAllocCb =
+{
+ nullptr,
+ &GenericAlloc,
+ &GenericFree
+};
+
+void DbgMsg(const std::string& strMsg)
+{
+#ifdef _DEBUG
+ std::cout << strMsg << std::endl;
+ char buf[1024];
+ sprintf_s(buf, 1024, "%s\n", strMsg.c_str());
+ #ifdef _LINUX
+ printf(buf);
+ #else
+ OutputDebugStringA(buf);
+ #endif
+#else
+ DD_UNUSED(strMsg);
+#endif // def _DEBUG
+}
+
+// Worker thread states
+enum WorkerThreadState
+{
+ STATE_INIT,
+ STATE_CAPTURING,
+ STATE_IDLE,
+ STATE_FINISHED,
+ STATE_DONE,
+};
+
+// The global worker thread state
+static std::atomic g_workerState(STATE_INIT);
+
+// The global worker thread mutex
+static std::mutex g_workerThreadMutex;
+
+RGPClientInProcessModel::RGPClientInProcessModel() :
+ m_pClient(nullptr),
+ m_profileCaptured(false),
+ m_finished(false),
+ m_requestingShutdown(false),
+ m_beginTag(0),
+ m_endTag(0)
+{
+ m_beginMarker.clear();
+ m_endMarker.clear();
+}
+
+RGPClientInProcessModel::~RGPClientInProcessModel()
+{
+ Finish();
+}
+
+bool RGPClientInProcessModel::Init(bool rgpEnabled)
+{
+ InitDriverProtocols();
+ if (rgpEnabled)
+ {
+ CreateWorkerThreadToResumeDriverAndCollectRgpTrace();
+ }
+
+ return true;
+}
+
+void RGPClientInProcessModel::Finish()
+{
+ m_requestingShutdown = true;
+ if (m_finished == false)
+ {
+ g_workerThreadMutex.lock();
+ while (g_workerState != STATE_DONE)
+ {
+ g_workerThreadMutex.unlock();
+ DevDriver::Platform::Sleep(10);
+ g_workerThreadMutex.lock();
+ if (g_workerState == STATE_IDLE)
+ {
+ g_workerState = STATE_FINISHED;
+ }
+ }
+ g_workerThreadMutex.unlock();
+ DeInitDriverProtocols();
+ m_finished = true;
+ }
+}
+
+bool RGPClientInProcessModel::InitDriverProtocols()
+{
+ DevDriver::ListenerCreateInfo createInfo = {};
+ const char* kListenerDescription = "Radeon Developer Service [RGPClientInProcess]";
+ DevDriver::Platform::Strncpy(createInfo.description, kListenerDescription, sizeof(createInfo.description));
+ createInfo.flags.enableServer = 1;
+ createInfo.serverCreateInfo.enabledProtocols.etw = true;
+
+ createInfo.allocCb = GenericAllocCb;
+
+ DevDriver::Result result = m_listenerCore.Initialize(createInfo);
+ if (DevDriver::Result::Success != result)
+ {
+ DbgMsg("Failed to initialize listener core");
+ return false;
+ }
+ DbgMsg("Listener core initialized successfully");
+
+ DevDriver::DevDriverClientCreateInfo clientCreateInfo = {};
+ clientCreateInfo.transportCreateInfo.type = DevDriver::TransportType::Local;
+
+ DevDriver::Platform::Strncpy(clientCreateInfo.transportCreateInfo.clientDescription, "RGPClientInProcess", sizeof(clientCreateInfo.transportCreateInfo.clientDescription));
+
+ clientCreateInfo.transportCreateInfo.componentType = DevDriver::Component::Tool;
+
+ clientCreateInfo.transportCreateInfo.createUpdateThread = true;
+ clientCreateInfo.transportCreateInfo.initialFlags = static_cast(DevDriver::ClientStatusFlags::DeveloperModeEnabled) |
+ static_cast(DevDriver::ClientStatusFlags::HaltOnConnect);
+
+ clientCreateInfo.transportCreateInfo.allocCb = createInfo.allocCb;
+
+ m_pClient = new(std::nothrow) DevDriver::DevDriverClient(clientCreateInfo);
+ if (nullptr == m_pClient)
+ {
+ DbgMsg("Failed to allocate memory for client");
+ return false;
+ }
+
+ DevDriver::Result initResult = m_pClient->Initialize();
+ if (DevDriver::Result::Success != initResult)
+ {
+ DbgMsg("Failed to initialize client");
+ return false;
+ }
+ DbgMsg("Client initialized successfully");
+
+ return true;
+}
+
+void RGPClientInProcessModel::DeInitDriverProtocols()
+{
+#if 1
+ if (m_thread.Join() != DevDriver::Result::Success)
+ {
+ DbgMsg("Failed to join rgp client thread");
+ }
+#endif
+
+ if (m_pClient != nullptr)
+ {
+ m_pClient->Destroy();
+ delete m_pClient;
+ m_pClient = nullptr;
+ }
+
+ m_listenerCore.Destroy();
+}
+
+//-----------------------------------------------------------------------------
+/// Generate the name of the profile to be saved. This is obtained from the
+/// process name and a generated time stamp, in much the same way that the
+/// panel does things.
+/// \param profileName A string to accept the generated profile name string
+//-----------------------------------------------------------------------------
+void RGPClientInProcessModel::GenerateProfileName(std::string& profileName)
+{
+ char processName[1024];
+ DevDriver::Platform::GetProcessName(&processName[0], sizeof(processName));
+
+ // calculate the timestamp as yyyymmdd-hhmmss
+ const int BUFFER_SIZE = 32;
+ char timeStamp[BUFFER_SIZE];
+
+ time_t t = time(nullptr);
+ tm* timePtr = localtime(&t);
+ sprintf_s(timeStamp, BUFFER_SIZE, "-%04d%02d%02d-%02d%02d%02d", timePtr->tm_year + 1900, timePtr->tm_mon + 1, timePtr->tm_mday, timePtr->tm_hour, timePtr->tm_min, timePtr->tm_sec);
+
+ // build the filename, consisting of exe name, timestamp and rgp extension. Rip off the '.exe' from the executable name if it exists
+ std::string delimiter = ".exe";
+ size_t pos = 0;
+ std::string executableName = processName;
+
+ if ((pos = executableName.find(delimiter)) != std::string::npos)
+ {
+ executableName = executableName.substr(0, pos);
+ }
+
+ profileName = executableName + timeStamp + gs_RGP_TRACE_EXTENSION;
+}
+
+//-----------------------------------------------------------------------------
+/// Set the GPU clock mode to be used when collecting an RGP trace.
+/// \returns Result::Success if the clock mode was set correctly, and an error code if it failed.
+//-----------------------------------------------------------------------------
+DevDriver::Result RGPClientInProcessModel::SetGPUClockMode(
+ DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient,
+ DevDriver::DriverControlProtocol::DeviceClockMode kTraceClockMode)
+{
+ using namespace DevDriver;
+
+ Result setClockResult = Result::Error;
+
+ if (pDriverControlClient != nullptr && pDriverControlClient->IsConnected())
+ {
+ // RDP explicitly sets the GPU's clock mode to ensure timing accuracy while collecting a trace.
+ static const int kGPUIndex = 0;
+ setClockResult = pDriverControlClient->SetDeviceClockMode(kGPUIndex, kTraceClockMode);
+ if (setClockResult == Result::Success)
+ {
+ DbgMsg("Set/Reset clock mode for profiling.");
+ }
+ }
+ else
+ {
+ DbgMsg("Didn't set/reset clock for profiling because DriverControlClient wasn't connected.");
+ }
+
+ if (setClockResult != Result::Success)
+ {
+ DbgMsg("Failed to set/reset GPU clocks for profiling.");
+ }
+
+ return setClockResult;
+}
+
+struct RGPTraceContext
+{
+ std::ofstream* pRgpFile;
+ DevDriver::uint64 numChunks; ///< The number of chunks received for the trace file.
+ size_t totalTraceSizeInBytes; ///< The final total size of the RGP trace file in bytes.
+};
+
+void RGPChunkFunc(const DevDriver::RGPProtocol::TraceDataChunk* pChunk, void* pUserdata)
+{
+ RGPTraceContext* pTraceContext = reinterpret_cast(pUserdata);
+ std::ofstream* pRgpFile = pTraceContext->pRgpFile;
+
+ pRgpFile->write(reinterpret_cast(pChunk->data), pChunk->dataSize);
+
+ pTraceContext->numChunks++;
+ pTraceContext->totalTraceSizeInBytes += pChunk->dataSize;
+}
+
+bool RGPClientInProcessModel::CollectRgpTrace(
+ DevDriver::RGPProtocol::RGPClient* pRgpClient,
+ DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient,
+ const RGPProfileParameters& profileParameters)
+{
+ using namespace DevDriver;
+
+ std::ofstream rgpFile;
+ RGPTraceContext clientTraceContext = {};
+ clientTraceContext.pRgpFile = &rgpFile;
+
+ DevDriver::RGPProtocol::BeginTraceInfo traceInfo = {};
+ traceInfo.callbackInfo.chunkCallback = &RGPChunkFunc;
+ traceInfo.callbackInfo.pUserdata = &clientTraceContext;
+ traceInfo.parameters.numPreparationFrames = 4;
+ traceInfo.parameters.flags.enableInstructionTokens = false;
+ traceInfo.parameters.flags.allowComputePresents = false;
+
+#ifdef GPUOPEN_SESSION_INTERFACE_CLEANUP_VERSION
+ traceInfo.parameters.beginTag = profileParameters.beginTag;
+ traceInfo.parameters.endTag = profileParameters.endTag;
+ if (profileParameters.pBeginMarker != nullptr)
+ {
+ DevDriver::Platform::Strncpy(traceInfo.parameters.beginMarker, profileParameters.pBeginMarker, sizeof(traceInfo.parameters.beginMarker));
+ }
+ if (profileParameters.pEndMarker)
+ {
+ DevDriver::Platform::Strncpy(traceInfo.parameters.endMarker, profileParameters.pEndMarker, sizeof(traceInfo.parameters.endMarker));
+ }
+#endif
+
+ // Set the GPU clock mode before starting a trace.
+ Result setClocks = SetGPUClockMode(pDriverControlClient, DevDriver::DriverControlProtocol::DeviceClockMode::Peak);
+
+ Result requestResult = pRgpClient->BeginTrace(traceInfo);
+
+ Result restoredClocks = Result::Error;
+
+ if (requestResult == Result::Success)
+ {
+ DbgMsg("Profiling began successfully.");
+
+ uint32 numChunks = 0;
+ uint64 traceSizeInBytes = 0;
+
+ requestResult = pRgpClient->EndTrace(&numChunks, &traceSizeInBytes);
+
+ // Revert the clock mode to the RDP default after tracing.
+ if (setClocks == Result::Success)
+ {
+ restoredClocks = SetGPUClockMode(pDriverControlClient, DevDriver::DriverControlProtocol::DeviceClockMode::Default);
+ }
+
+ if (requestResult == Result::Success || requestResult == Result::Unavailable)
+ {
+ // Only try to write the trace file if the trace executed correctly.
+ if (m_profileName.empty())
+ {
+ GenerateProfileName(m_profileName);
+ }
+ rgpFile.open(m_profileName.c_str(), std::ios::out | std::ios::binary);
+
+ // Read chunks until we hit the end of the stream.
+ do
+ {
+ requestResult = pRgpClient->ReadTraceDataChunk();
+ } while (requestResult == Result::Success);
+
+ if (requestResult == Result::EndOfStream)
+ {
+ // If the result is EndOfStream, it means that all of the trace chunks were transferred.
+ // Just return Success to better indicate that the trace was successful.
+ requestResult = Result::Success;
+
+ if (rgpFile.is_open())
+ {
+ rgpFile.close();
+ }
+ DbgMsg("RGP trace file captured.");
+ SetProfileCaptured(true);
+ }
+ }
+
+ return true;
+ }
+ else
+ {
+ DbgMsg("Failed to begin profile");
+
+ // Looks like tracing failed- Attempt to revert the clock state to what it was originally.
+ restoredClocks = SetGPUClockMode(pDriverControlClient, DevDriver::DriverControlProtocol::DeviceClockMode::Default);
+ if (restoredClocks != Result::Success)
+ {
+ DbgMsg("Failed to restore GPU clocks to default after profiling.");
+ }
+
+ return false;
+ }
+}
+
+bool RGPClientInProcessModel::ConnectProtocolClients(
+ DevDriver::DevDriverClient* pClient,
+ DevDriver::ClientId clientId,
+ DevDriver::RGPProtocol::RGPClient*& pRgpClientOut,
+ DevDriver::DriverControlProtocol::DriverControlClient*& pDriverControlClientOut)
+{
+ using namespace DevDriver;
+ using namespace RGPProtocol;
+ using namespace DriverControlProtocol;
+
+ bool bReturn = true;
+
+ // Connect Driver Control Client
+ pDriverControlClientOut = pClient->AcquireProtocolClient();
+ if (nullptr == pDriverControlClientOut)
+ {
+ DbgMsg("Driver control client not available");
+ bReturn = false;
+ }
+ else
+ {
+ DbgMsg("Driver control client is available");
+ }
+
+ if (pDriverControlClientOut->Connect(clientId) != Result::Success)
+ {
+ DbgMsg("Failed to connect DriverControlClient");
+ bReturn = false;
+ }
+ else
+ {
+ DbgMsg("Driver control client is connected");
+ }
+
+ // Connect RGP Client
+ pRgpClientOut = pClient->AcquireProtocolClient();
+ if (nullptr == pRgpClientOut)
+ {
+ DbgMsg("RGP client not available");
+ bReturn = false;
+ }
+ else
+ {
+ DbgMsg("RGP client is available");
+ }
+
+ if (pRgpClientOut->Connect(clientId) != DevDriver::Result::Success)
+ {
+ DbgMsg("Failed to connect rgp client");
+ bReturn = false;
+ }
+ else
+ {
+ DbgMsg("RGP client connected");
+ }
+
+ return bReturn;
+}
+
+void RGPClientInProcessModel::DisconnectProtocolClients(
+ DevDriver::DevDriverClient* pClient,
+ DevDriver::RGPProtocol::RGPClient* pRgpClient,
+ DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient)
+{
+ if (pClient == nullptr)
+ {
+ return;
+ }
+
+ if (pRgpClient != nullptr && pRgpClient->IsConnected())
+ {
+ pRgpClient->Disconnect();
+ pClient->ReleaseProtocolClient(pRgpClient);
+ }
+
+ if (pDriverControlClient != nullptr && pDriverControlClient->IsConnected())
+ {
+ pDriverControlClient->Disconnect();
+ pClient->ReleaseProtocolClient(pDriverControlClient);
+ }
+}
+
+bool RGPClientInProcessModel::EnableRgpProfiling(DevDriver::RGPProtocol::RGPClient* pRgpClient)
+{
+ using namespace DevDriver;
+ using namespace RGPProtocol;
+
+ // Make sure profiling status starts as Available
+ ProfilingStatus profilingStatus = ProfilingStatus::NotAvailable;
+ if (pRgpClient->QueryProfilingStatus(&profilingStatus) != Result::Success)
+ {
+ DbgMsg("Failed to query rgp profiling status on client");
+ }
+ else
+ {
+ DbgMsg("Successfull to query rgp profiling status on client");
+ }
+
+ if (profilingStatus != ProfilingStatus::Available)
+ {
+ DbgMsg("RGP profiling status is not available");
+ }
+ else
+ {
+ DbgMsg("RGP profiling status is available");
+ }
+
+ Result result = pRgpClient->EnableProfiling();
+
+ if (result == Result::Success)
+ {
+ DbgMsg("RGP profiling enabled");
+ return true;
+ }
+ else
+ {
+ DbgMsg("Failed to enable RGP profiling");
+ return false;
+ }
+}
+
+bool RGPClientInProcessModel::ResumeDriverAndWaitForDriverInitilization(DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient)
+{
+ using namespace DevDriver;
+ bool bReturn = true;
+
+ if (pDriverControlClient->ResumeDriver() != Result::Success)
+ {
+ DbgMsg("Failed to resume driver");
+ bReturn = false;
+ }
+ else
+ {
+ DbgMsg("Driver resumed");
+ }
+
+ DbgMsg("Waiting for driver initialization on client");
+ Result result = pDriverControlClient->WaitForDriverInitialization(8000);
+ if (result == Result::Success)
+ {
+ DbgMsg("Wait for driver initialization successful on client");
+ }
+ else if (result == Result::Unavailable)
+ {
+ DbgMsg("Wait for driver initialization not available on client");
+ bReturn = false;
+ }
+ else if (result == Result::NotReady)
+ {
+ DbgMsg("Wait for driver initialization timed out on client");
+ bReturn = false;
+ }
+ else
+ {
+ DbgMsg("Wait for driver initialization failed on client\n");
+ bReturn = false;
+ }
+
+ return bReturn;
+}
+
+bool ProcessHaltedMessage(RGPClientInProcessModel* pContext, DevDriver::ClientId clientId)
+{
+ return pContext->ProcessHaltedMessage(clientId);
+}
+
+bool RGPClientInProcessModel::ProcessHaltedMessage(DevDriver::ClientId clientId)
+{
+ if (m_pClient->IsConnected())
+ {
+ bool resumed = false;
+
+ using namespace DevDriver;
+ using namespace RGPProtocol;
+ using namespace DriverControlProtocol;
+
+ RGPClient* pRgpClient = nullptr;
+ DriverControlClient* pDriverControlClient = nullptr;
+
+ ConnectProtocolClients(m_pClient, clientId, pRgpClient, pDriverControlClient);
+ m_clientId = clientId;
+
+ if (pRgpClient != nullptr)
+ {
+ EnableRgpProfiling(pRgpClient);
+ }
+
+ if (pDriverControlClient != nullptr)
+ {
+ resumed = ResumeDriverAndWaitForDriverInitilization(pDriverControlClient);
+ }
+ DisconnectProtocolClients(m_pClient, pRgpClient, pDriverControlClient);
+
+ return resumed;
+ }
+ return false;
+}
+
+//-----------------------------------------------------------------------------
+/// Validate if a capture is possible. Checks various capture parameters and
+/// sees if the requested capture features are enabled in the driver or
+/// interface.
+/// If the user requests a particular feature and that feature isn't available
+/// then a capture isn't possible since it doesn't do exactly what the user
+/// wants, even though it may be possible to perform a capture without the
+/// requested feature.
+/// \param requestingFrameTerminators Is the user requesting frame terminators
+/// \return true if a capture is possible, false otherwise
+//-----------------------------------------------------------------------------
+bool RGPClientInProcessModel::IsCaptureAllowed(bool requestingFrameTerminators)
+{
+ using namespace DevDriver;
+ using namespace RGPProtocol;
+ using namespace DriverControlProtocol;
+
+ RGPClient* pRgpClient = nullptr;
+ DriverControlClient* pDriverControlClient = nullptr;
+
+ ConnectProtocolClients(m_pClient, m_clientId, pRgpClient, pDriverControlClient);
+
+ bool userMarkerVersion = false;
+
+ // check the protocol trigger marker version. Need to fail if the user has chosen to use
+ // trigger markers but the DevDriverTools don't support it
+#ifdef RGP_TRIGGER_MARKERS_VERSION
+ if (pRgpClient->GetSessionVersion() >= RGP_TRIGGER_MARKERS_VERSION)
+ {
+ userMarkerVersion = true;
+ }
+#endif
+
+ DisconnectProtocolClients(m_pClient, pRgpClient, pDriverControlClient);
+
+ if (requestingFrameTerminators == true && userMarkerVersion == false)
+ {
+ return false;
+ }
+
+ return true;
+}
+
+//-----------------------------------------------------------------------------
+/// Collect a trace. This function is run in the worker thread to do the
+/// actual frame capture.
+//-----------------------------------------------------------------------------
+void RGPClientInProcessModel::CollectTrace()
+{
+ using namespace DevDriver;
+ using namespace RGPProtocol;
+ using namespace DriverControlProtocol;
+
+ RGPClient* pRgpClient = nullptr;
+ DriverControlClient* pDriverControlClient = nullptr;
+
+ ConnectProtocolClients(m_pClient, m_clientId, pRgpClient, pDriverControlClient);
+
+ if (pRgpClient != nullptr && pDriverControlClient != nullptr)
+ {
+ RGPProfileParameters profileParameters = {};
+ profileParameters.beginTag = m_beginTag;
+ profileParameters.endTag = m_endTag;
+ profileParameters.pBeginMarker = m_beginMarker.c_str();
+ profileParameters.pEndMarker = m_endMarker.c_str();
+ CollectRgpTrace(pRgpClient, pDriverControlClient, profileParameters);
+ }
+
+ DisconnectProtocolClients(m_pClient, pRgpClient, pDriverControlClient);
+}
+
+//-----------------------------------------------------------------------------
+/// Worker thread to wait until the driver halted message has been received
+/// and resume the application
+//-----------------------------------------------------------------------------
+static void WorkerInit(void* pThreadParam)
+{
+ bool result = false;
+ using namespace DevDriver;
+ RGPWorkerThreadContext* pThreadContext = reinterpret_cast(pThreadParam);
+ RGPClientInProcessModel* pContext = pThreadContext->m_pContext;
+ DevDriverClient* pClient = pThreadContext->m_pClient;
+
+ MessageBuffer message = {};
+ IMsgChannel* pMsgChannel = pClient->GetMessageChannel();
+ const uint32 kLogDelayInMs = 100;
+
+ while (pMsgChannel->IsConnected() && result == false && pContext->IsRequestingShutdown() == false)
+ {
+ DevDriver::Result status = pMsgChannel->Receive(message, kLogDelayInMs);
+ while (status == DevDriver::Result::Success && !pContext->IsProfileCaptured())
+ {
+ if (message.header.protocolId == Protocol::System)
+ {
+ using namespace SystemProtocol;
+ DevDriver::SystemProtocol::SystemMessage msg = static_cast(message.header.messageId);
+ switch (msg)
+ {
+ case SystemMessage::Halted:
+ result = ProcessHaltedMessage(pContext, message.header.srcClientId);
+ break;
+ default:
+ break;
+ }
+ }
+ status = pMsgChannel->Receive(message, 0);
+ }
+ }
+ g_workerThreadMutex.lock();
+ g_workerState = STATE_IDLE;
+ g_workerThreadMutex.unlock();
+}
+
+static void WorkerCapture(void* pThreadParam)
+{
+ using namespace DevDriver;
+ RGPWorkerThreadContext* pThreadContext = reinterpret_cast(pThreadParam);
+ RGPClientInProcessModel* pContext = pThreadContext->m_pContext;
+
+ pContext->CollectTrace();
+ g_workerThreadMutex.lock();
+ g_workerState = STATE_IDLE;
+ g_workerThreadMutex.unlock();
+}
+
+// Worker thread function. This is set up at init time, and WorkerInit is called then. Once a capture is triggered,
+// the WorkerCapture() function is called
+void RGPWorkerThreadFunc(void* pThreadParam)
+{
+ g_workerThreadMutex.lock();
+ WorkerThreadState state = g_workerState;
+ g_workerThreadMutex.unlock();
+
+ while (state != STATE_FINISHED)
+ {
+ switch (state)
+ {
+ case STATE_INIT:
+ WorkerInit(pThreadParam);
+ break;
+
+ case STATE_CAPTURING:
+ WorkerCapture(pThreadParam);
+ break;
+
+ default:
+ break;
+ }
+ g_workerThreadMutex.lock();
+ state = g_workerState;
+ g_workerThreadMutex.unlock();
+ }
+ g_workerThreadMutex.lock();
+ g_workerState = STATE_DONE;
+ g_workerThreadMutex.unlock();
+}
+
+bool RGPClientInProcessModel::SetTriggerMarkerParams(uint64_t beginTag, uint64_t endTag, const char* beginMarker, const char* endMarker)
+{
+ bool requestingFrameTerminators = false;
+
+ if (beginTag != 0 && endTag != 0)
+ {
+ m_beginTag = beginTag;
+ m_endTag = endTag;
+ requestingFrameTerminators = true;
+ }
+ if (beginMarker != nullptr && endMarker != nullptr)
+ {
+ m_beginMarker = beginMarker;
+ m_endMarker = endMarker;
+ requestingFrameTerminators = true;
+ }
+ return requestingFrameTerminators;
+}
+
+bool RGPClientInProcessModel::TriggerCapture(const char* pszCaptureFileName)
+{
+ g_workerThreadMutex.lock();
+ if (g_workerState == STATE_IDLE)
+ {
+ g_workerState = STATE_CAPTURING;
+ g_workerThreadMutex.unlock();
+ SetProfileCaptured(false);
+ m_profileName = "";
+ if (pszCaptureFileName != nullptr)
+ {
+ m_profileName = pszCaptureFileName;
+ }
+ return true;
+ }
+ g_workerThreadMutex.unlock();
+ return false;
+}
+
+bool RGPClientInProcessModel::CreateWorkerThreadToResumeDriverAndCollectRgpTrace()
+{
+ m_threadContext.m_pContext = this;
+ m_threadContext.m_pClient = m_pClient;
+
+ // reset the initial state
+ g_workerThreadMutex.lock();
+ g_workerState = STATE_INIT;
+ g_workerThreadMutex.unlock();
+
+ if (m_thread.Start(RGPWorkerThreadFunc, (void *)&m_threadContext) != DevDriver::Result::Success)
+ {
+ DbgMsg("Failed to create rgp worker thread");
+ return false;
+ }
+ DbgMsg("Successfull to create rgp worker thread");
+
+ if (!m_thread.IsJoinable())
+ {
+ DbgMsg("Rgp worker thread is not joinable");
+ return false;
+ }
+
+#if 0
+ if (m_thread.Join() != DevDriver::Result::Success)
+ {
+ DbgMsg("Failed to join rgp worker thread");
+ }
+#endif
+
+ return true;
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/RGPClientInProcessModel.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/RGPClientInProcessModel.h
new file mode 100644
index 000000000..0afc6f052
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverAPI/RGPClientInProcessModel.h
@@ -0,0 +1,108 @@
+//=============================================================================
+/// Copyright (c) 2017 Advanced Micro Devices, Inc. All rights reserved.
+/// \author AMD Developer Tools Team
+/// \file
+/// \brief a class to provide service to initialize dev driver protocols to
+/// capture rgp trace from within the profiled application.
+//=============================================================================
+#ifndef RGP_CLIENT_IN_PROCESS_MODEL_H_
+#define RGP_CLIENT_IN_PROCESS_MODEL_H_
+
+#include <../listener/listenerCore.h>
+#include
+#include
+#include
+
+class RGPClientInProcessModel;
+
+typedef struct
+{
+ RGPClientInProcessModel* m_pContext;
+ DevDriver::DevDriverClient* m_pClient;
+} RGPWorkerThreadContext;
+
+struct RGPProfileParameters
+{
+ uint64_t beginTag;
+ uint64_t endTag;
+ const char* pBeginMarker;
+ const char* pEndMarker;
+};
+
+class RGPClientInProcessModel
+{
+public:
+ RGPClientInProcessModel();
+ ~RGPClientInProcessModel();
+
+ bool Init(bool rgpEnabled);
+ void Finish();
+
+ bool IsProfileCaptured() const { return m_profileCaptured; }
+ bool IsRequestingShutdown() const { return m_requestingShutdown; }
+ const char* GetProfileName() const { return m_profileName.c_str(); }
+
+ bool SetTriggerMarkerParams(uint64_t beginTag, uint64_t endTag, const char* beginMarker, const char* endMarker);
+
+ bool TriggerCapture(const char* pszCaptureFileName);
+ bool IsCaptureAllowed(bool requestingFrameTerminators);
+ void CollectTrace();
+
+ bool ProcessHaltedMessage(DevDriver::ClientId clientId);
+
+private:
+ RGPClientInProcessModel(const RGPClientInProcessModel& c); // disable
+ RGPClientInProcessModel& operator=(const RGPClientInProcessModel& c); // disable
+
+ bool InitDriverProtocols();
+ void DeInitDriverProtocols();
+
+ bool CreateWorkerThreadToResumeDriverAndCollectRgpTrace();
+
+ void GenerateProfileName(std::string& profileName);
+ void SetProfileCaptured(bool bCaptured) { m_profileCaptured = bCaptured; }
+
+ bool ConnectProtocolClients(
+ DevDriver::DevDriverClient* pClient,
+ DevDriver::ClientId clientId,
+ DevDriver::RGPProtocol::RGPClient*& pRgpClientOut,
+ DevDriver::DriverControlProtocol::DriverControlClient*& pDriverControlClientOut);
+
+ void DisconnectProtocolClients(
+ DevDriver::DevDriverClient* pClient,
+ DevDriver::RGPProtocol::RGPClient* pRgpClient,
+ DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient);
+
+ DevDriver::Result SetGPUClockMode(
+ DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient,
+ DevDriver::DriverControlProtocol::DeviceClockMode kTraceClockMode);
+
+ bool EnableRgpProfiling(DevDriver::RGPProtocol::RGPClient* pRgpClient);
+
+ bool ResumeDriverAndWaitForDriverInitilization(DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient);
+
+ bool CollectRgpTrace(
+ DevDriver::RGPProtocol::RGPClient* pRgpClient,
+ DevDriver::DriverControlProtocol::DriverControlClient* pDriverControlClient,
+ const RGPProfileParameters& profileParameters);
+
+ DevDriver::ListenerCore m_listenerCore;
+ DevDriver::DevDriverClient* m_pClient;
+
+ DevDriver::Platform::Thread m_thread;
+ RGPWorkerThreadContext m_threadContext;
+
+ std::string m_profileName; ///< The name of the last saved profile
+
+ DevDriver::ClientId m_clientId; ///< The current client Id
+ bool m_profileCaptured; ///< Has a profile been captured
+ bool m_finished; ///< Has Finished() been called. Ensure it's only called once
+ std::atomic m_requestingShutdown; ///< The application is requesting shutdown, so exit worker thread loops
+
+ uint64_t m_beginTag; ///< The begin tag name
+ uint64_t m_endTag; ///< The end tag name
+ std::string m_beginMarker; ///< The begin marker name
+ std::string m_endMarker; ///< The end marker name
+};
+
+#endif // RGP_CLIENT_IN_PROCESS_MODEL_H_
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/baseProtocolClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/baseProtocolClient.h
new file mode 100644
index 000000000..9993b938c
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/baseProtocolClient.h
@@ -0,0 +1,211 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file baseProtocolClient.h
+* @brief Class declaration for BaseProtocolClient.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "protocolClient.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ enum class ClientState : uint32
+ {
+ Disconnected = 0,
+ Connecting,
+ Connected
+ };
+
+ class BaseProtocolClient : public IProtocolClient
+ {
+ public:
+ virtual ~BaseProtocolClient();
+
+ // query constant properties of the protocol client
+ Protocol GetProtocol() const override final { return m_protocol; };
+ SessionType GetType() const override final { return SessionType::Client; };
+ Version GetMinVersion() const override final { return m_minVersion; };
+ Version GetMaxVersion() const override final { return m_maxVersion; };
+
+ // connection management/tracking
+ Result Connect(ClientId clientId) override final;
+ void Disconnect() override final;
+ bool IsConnected() const override final;
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_SESSION_INTERFACE_CLEANUP_VERSION)
+ // Orphans the current session associated with the client object and moves to the disconnected state
+ void Orphan() override final;
+#endif
+
+ // properties that are only valid in a connected session
+ ClientId GetRemoteClientId() const override final;
+ Version GetSessionVersion() const override final;
+
+ // asychronous callbacks used by the SessionManager - should never be called directly
+ virtual void SessionEstablished(const SharedPointer& pSession) override;
+ virtual void UpdateSession(const SharedPointer& pSession) override;
+ virtual void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+
+ protected:
+ BaseProtocolClient(IMsgChannel* pMsgChannel, Protocol protocol, Version minVersion, Version maxVersion);
+
+ // Default implementation of ResetState that does nothing
+ virtual void ResetState() {};
+
+ IMsgChannel* const m_pMsgChannel;
+ const Protocol m_protocol;
+ const Version m_minVersion;
+ const Version m_maxVersion;
+
+ SharedPointer m_pSession;
+
+ DD_STATIC_CONST uint32 kDefaultRetryTimeoutInMs = 50;
+ DD_STATIC_CONST uint32 kDefaultCommunicationTimeoutInMs = 5000;
+
+ // Attempts to receive a payload into a fixed size buffer.
+ // Returns the result and the size of the payload if it was received successfully.
+ Result ReceiveSizedPayload(void* pPayloadBuffer,
+ uint32 payloadBufferSize,
+ uint32* pBytesReceived,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs)
+ {
+ uint32 timeElapsed = 0;
+ // Blocking wait on the message.
+ Result result = Result::Error;
+
+ SharedPointer pSession = m_pSession;
+ if (!pSession.IsNull())
+ {
+ do
+ {
+ result = pSession->Receive(payloadBufferSize, pPayloadBuffer, pBytesReceived, retryInMs);
+ timeElapsed += retryInMs;
+ }
+ while ((result == Result::NotReady) & (timeElapsed <= timeoutInMs));
+ }
+
+ return result;
+ }
+
+ // Templated wrapper around ReceiveSizedPayload
+ template
+ Result ReceivePayload(T& payload,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs)
+ {
+ uint32 bytesReceived = 0;
+ Result result = ReceiveSizedPayload(&payload, sizeof(T), &bytesReceived, timeoutInMs, retryInMs);
+
+ // Return an error if we don't get back the size we were expecting.
+ if ((result == Result::Success) & (bytesReceived != sizeof(T)))
+ {
+ result = Result::Error;
+ }
+
+ return result;
+ }
+
+ // Attempts to send a payload
+ Result SendSizedPayload(const void* pPayload,
+ uint32 payloadSize,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs)
+ {
+ Result result = Result::Error;
+ uint32 timeElapsed = 0;
+ SharedPointer pSession = m_pSession;
+ if (!pSession.IsNull())
+ {
+ do
+ {
+ result = pSession->Send(payloadSize, pPayload, retryInMs);
+ timeElapsed += retryInMs;
+ } while ((result == Result::NotReady) & (timeElapsed <= timeoutInMs));
+ }
+ return result;
+ }
+
+ // Templated wrapper around SendSizedPayload
+ template
+ Result SendPayload(T& payload,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs)
+ {
+ return SendSizedPayload(&payload, sizeof(T), timeoutInMs, retryInMs);
+ }
+
+ // Attempts to perform a payload "transaction" which is defined as sending one payload out, and receiving one in response.
+ Result TransactSized(const void* pSendPayload,
+ uint32 sendSize,
+ void* pReceivePayload,
+ uint32 receiveSize,
+ uint32* pBytesReceived,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs)
+ {
+ Result result = Result::Error;
+ if (IsConnected())
+ {
+ result = SendSizedPayload(pSendPayload, sendSize, timeoutInMs, retryInMs);
+ if (result == Result::Success)
+ {
+ result = ReceiveSizedPayload(pReceivePayload, receiveSize, pBytesReceived, timeoutInMs, retryInMs);
+ }
+ }
+ return result;
+ }
+
+ // Templated wrapper around TransactSized
+ template
+ Result Transact(const T& sendPayload,
+ U& receivePayload,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs)
+ {
+ Result result = Result::Error;
+ if (IsConnected())
+ {
+ result = SendPayload(sendPayload, timeoutInMs, retryInMs);
+ if (result == Result::Success)
+ {
+ result = ReceivePayload(receivePayload, timeoutInMs, retryInMs);
+ }
+ }
+ return result;
+ }
+
+ private:
+ Platform::Event m_pendingOperationEvent;
+ Result m_connectResult;
+ ClientState m_state;
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/baseProtocolServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/baseProtocolServer.h
new file mode 100644
index 000000000..eb4eacab5
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/baseProtocolServer.h
@@ -0,0 +1,67 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file baseProtocolServer.h
+* @brief Class declaration for BaseProtocolServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "protocolServer.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ class BaseProtocolServer : public IProtocolServer
+ {
+ public:
+ virtual ~BaseProtocolServer();
+
+ Protocol GetProtocol() const override final { return m_protocol; };
+ SessionType GetType() const override final { return SessionType::Server; };
+ Version GetMinVersion() const override final { return m_minVersion; };
+ Version GetMaxVersion() const override final { return m_maxVersion; };
+
+ bool GetSupportedVersion(Version minVersion, Version maxVersion, Version * version) const override final;
+
+ virtual void Finalize() override;
+ protected:
+ BaseProtocolServer(IMsgChannel* pMsgChannel, Protocol protocol, Version minVersion, Version maxVersion);
+
+ // Helper functions for working with SizedPayloadContainers
+ Result SendPayload(ISession* pSession, const SizedPayloadContainer* pPayload, uint32 timeoutInMs);
+ Result ReceivePayload(ISession* pSession, SizedPayloadContainer* pPayload, uint32 timeoutInMs);
+
+ IMsgChannel* const m_pMsgChannel;
+ const Protocol m_protocol;
+ const Version m_minVersion;
+ const Version m_maxVersion;
+
+ bool m_isFinalized;
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddPlatform.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddPlatform.h
new file mode 100644
index 000000000..47b702f27
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddPlatform.h
@@ -0,0 +1,328 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file platform.h
+* @brief GPUOpen Platform Abstraction Layer
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+
+#if !defined(NDEBUG)
+#if !defined(DEVDRIVER_FORCE_ASSERT)
+#define DEVDRIVER_FORCE_ASSERT
+#endif
+#if !defined(DEVDRIVER_HARD_ASSERT)
+#define DEVDRIVER_HARD_ASSERT
+#endif
+#endif
+
+#if defined(_WIN32)
+#include "win/ddWinPlatform.h"
+#elif defined(__APPLE__) || defined(__linux__)
+#include "posix/ddPosixPlatform.h"
+#endif
+
+#if defined(__x86_64__) || defined(_M_X64)
+#define DD_ARCH_STRING "x86-64"
+#elif defined(__i386__) || defined(_M_IX86)
+#define DD_ARCH_STRING "x86"
+#else
+#define DD_ARCH_STRING "Unk"
+#endif
+
+#if defined(DD_WINDOWS)
+#define DD_OS_STRING "Windows"
+#elif defined(DD_LINUX)
+#define DD_OS_STRING "Linux"
+#else
+#define DD_OS_STRING "Unknown"
+#endif
+
+#include "util/template.h"
+#include "util/memory.h"
+#include
+
+// TODO: remove this and make kDebugLogLevel DD_STATIC_CONST when we use a version of visual studio that supports it
+#ifdef DEVDRIVER_LOG_LEVEL
+ #define DEVDRIVER_LOG_LEVEL_VALUE static_cast(DEVDRIVER_LOG_LEVEL)
+#else
+ #if defined(NDEBUG)
+ #define DEVDRIVER_LOG_LEVEL_VALUE LogLevel::Always
+ #else
+ #define DEVDRIVER_LOG_LEVEL_VALUE LogLevel::Verbose
+ #endif
+#endif
+
+#define DD_WILL_PRINT(lvl) ((lvl >= DEVDRIVER_LOG_LEVEL_VALUE) & (lvl < DevDriver::LogLevel::Count))
+#define DD_PRINT(lvl, ...) DevDriver::LogString(__VA_ARGS__)
+
+#if !defined(DEVDRIVER_FORCE_ASSERT)
+
+#define DD_ALERT(statement) (DD_UNUSED(0))
+#define DD_ASSERT(statement) (DD_UNUSED(0))
+#define DD_ASSERT_REASON(reason) (DD_UNUSED(0))
+#define DD_ALERT_REASON(reason) (DD_UNUSED(0))
+
+#else
+
+#define DD_STRINGIFY(str) #str
+#define DD_STRINGIFY_(x) DD_STRINGIFY(x)
+#define DD_ALERT(statement) \
+{ \
+ if (!(statement)) \
+ { \
+ DD_PRINT(DevDriver::LogLevel::Alert, "%s (%d): Alert triggered in %s: %s\n", \
+ __FILE__, __LINE__, __func__, DD_STRINGIFY(statement)); \
+ } \
+}
+
+#define DD_ASSERT(statement) \
+{ \
+ if (!(statement)) \
+ { \
+ DD_PRINT(DevDriver::LogLevel::Error, "%s (%d): Assertion failed in %s: %s\n", \
+ __FILE__, __LINE__, __func__, DD_STRINGIFY(statement)); \
+ DevDriver::Platform::DebugBreak(__FILE__, __LINE__, __func__, DD_STRINGIFY(statement)); \
+ } \
+}
+
+#define DD_ALERT_REASON(reason) \
+{ \
+ DD_PRINT(DevDriver::LogLevel::Alert, "%s (%d): Alert triggered in %s: %s\n", \
+ __FILE__, __LINE__, __func__, reason); \
+}
+
+#define DD_ASSERT_REASON(reason) \
+{ \
+ DD_PRINT(DevDriver::LogLevel::Error, "%s (%d): Assertion failed in %s: %s\n", \
+ __FILE__, __LINE__, __func__, reason); \
+ DevDriver::Platform::DebugBreak(__FILE__, __LINE__, __func__, reason); \
+}
+
+#endif
+
+#if !defined(DD_RESTRICT)
+#define DD_RESTRICT
+#endif
+
+/// Convenience macro that always asserts.
+#define DD_ASSERT_ALWAYS() DD_ASSERT_REASON("Unconditional Assert")
+
+/// Convenience macro that always alerts.
+#define DD_ALERT_ALWAYS() DD_ALERT_REASON("Unconditional Alert")
+
+/// Convenience macro that asserts if something has not been implemented.
+#define DD_NOT_IMPLEMENTED() DD_ASSERT_REASON("Code not implemented!")
+
+/// Convenience macro that asserts if an area of code that shouldn't be executed is reached.
+#define DD_UNREACHABLE() DD_ASSERT_REASON("Unreachable code has been reached!")
+
+namespace DevDriver
+{
+ namespace Platform
+ {
+
+ void DebugPrint(LogLevel lvl, const char* format, ...);
+
+ /* platform functions for performing atomic operations */
+
+ int32 AtomicIncrement(Atomic *variable);
+ int32 AtomicDecrement(Atomic *variable);
+ int32 AtomicAdd(Atomic *variable, int32 num);
+ int32 AtomicSubtract(Atomic *variable, int32 num);
+
+ class Thread
+ {
+ public:
+ Thread();
+ ~Thread();
+ Result Start(void(*threadCallback)(void *), void *threadParameter);
+ Result Join();
+ bool IsJoinable() const;
+
+ private:
+ ThreadStorage m_thread;
+ };
+
+ void* AllocateMemory(size_t size, size_t alignment, bool zero);
+ void FreeMemory(void* pMemory);
+
+ /* fast locks */
+ class AtomicLock
+ {
+ public:
+ AtomicLock() : m_lock(0) {};
+ ~AtomicLock() {};
+ void Lock();
+ void Unlock();
+ bool IsLocked() { return m_lock != 0; };
+ private:
+ Atomic m_lock;
+ };
+
+ class Mutex
+ {
+ public:
+ Mutex();
+ ~Mutex();
+ void Lock();
+ void Unlock();
+ private:
+ MutexStorage m_mutex;
+ };
+
+ class Semaphore
+ {
+ public:
+ explicit Semaphore(uint32 initialCount, uint32 maxCount);
+ ~Semaphore();
+ Result Signal();
+ Result Wait(uint32 millisecTimeout);
+ private:
+ SemaphoreStorage m_semaphore;
+ };
+
+ class Event
+ {
+ public:
+ explicit Event(bool signaled);
+ ~Event();
+ void Clear();
+ void Signal();
+ Result Wait(uint32 timeoutInMs);
+ private:
+ EventStorage m_event;
+ };
+
+ class Random
+ {
+ public:
+ Random();
+ ~Random();
+ uint32 Generate();
+ static uint32 Max();
+
+ private:
+ RandomStorage m_randState;
+ };
+
+ ProcessId GetProcessId();
+
+ uint64 GetCurrentTimeInMs();
+
+ // Todo: Remove Sleep() entirely from our platform API. It cannot be used in the KMD and should not be used
+ // anywhere else either.
+ void Sleep(uint32 millisecTimeout);
+
+ void GetProcessName(char* buffer, size_t bufferSize);
+
+ void Strncpy(char* pDst, const char* pSrc, size_t dstSize);
+
+ void Snprintf(char* pDst, size_t dstSize, const char* format, ...);
+ void Vsnprintf(char* pDst, size_t dstSize, const char* format, va_list args);
+ }
+
+#ifndef DD_PRINT_FUNC
+#define DD_PRINT_FUNC Platform::DebugPrint
+#else
+ void DD_PRINT_FUNC(LogLevel logLevel, const char* format, ...);
+#endif
+
+ template
+ inline void LogString(const char *format, Ts&&... args)
+ {
+ if (DD_WILL_PRINT(logLevel))
+ {
+ DD_PRINT_FUNC(logLevel, format, Platform::Forward(args)...);
+ }
+ }
+
+ //---------------------------------------------------------------------
+ // CRC32
+ //
+ // Calculate a 32bit crc using a the Sarwate look up table method. The original algorithm was created by
+ // Dilip V. Sarwate, and is based off of Stephan Brumme's implementation. See also:
+ // https://dl.acm.org/citation.cfm?doid=63030.63037
+ // http://create.stephan-brumme.com/crc32/#sarwate
+ //
+ // Copyright (c) 2004-2006 Intel Corporation - All Rights Reserved
+ //
+ //
+ //
+ // This software program is licensed subject to the BSD License,
+ // available at http://www.opensource.org/licenses/bsd-license.html.
+ //
+ // Abstract:
+ //
+ // Tables for software CRC generation
+ //
+ static inline uint32 CRC32(const void *pData, size_t length, uint32 lastCRC = 0)
+ {
+ DD_STATIC_CONST uint32_t lookupTable[256] =
+ {
+ 0x00000000,0x77073096,0xEE0E612C,0x990951BA,0x076DC419,0x706AF48F,0xE963A535,0x9E6495A3,
+ 0x0EDB8832,0x79DCB8A4,0xE0D5E91E,0x97D2D988,0x09B64C2B,0x7EB17CBD,0xE7B82D07,0x90BF1D91,
+ 0x1DB71064,0x6AB020F2,0xF3B97148,0x84BE41DE,0x1ADAD47D,0x6DDDE4EB,0xF4D4B551,0x83D385C7,
+ 0x136C9856,0x646BA8C0,0xFD62F97A,0x8A65C9EC,0x14015C4F,0x63066CD9,0xFA0F3D63,0x8D080DF5,
+ 0x3B6E20C8,0x4C69105E,0xD56041E4,0xA2677172,0x3C03E4D1,0x4B04D447,0xD20D85FD,0xA50AB56B,
+ 0x35B5A8FA,0x42B2986C,0xDBBBC9D6,0xACBCF940,0x32D86CE3,0x45DF5C75,0xDCD60DCF,0xABD13D59,
+ 0x26D930AC,0x51DE003A,0xC8D75180,0xBFD06116,0x21B4F4B5,0x56B3C423,0xCFBA9599,0xB8BDA50F,
+ 0x2802B89E,0x5F058808,0xC60CD9B2,0xB10BE924,0x2F6F7C87,0x58684C11,0xC1611DAB,0xB6662D3D,
+ 0x76DC4190,0x01DB7106,0x98D220BC,0xEFD5102A,0x71B18589,0x06B6B51F,0x9FBFE4A5,0xE8B8D433,
+ 0x7807C9A2,0x0F00F934,0x9609A88E,0xE10E9818,0x7F6A0DBB,0x086D3D2D,0x91646C97,0xE6635C01,
+ 0x6B6B51F4,0x1C6C6162,0x856530D8,0xF262004E,0x6C0695ED,0x1B01A57B,0x8208F4C1,0xF50FC457,
+ 0x65B0D9C6,0x12B7E950,0x8BBEB8EA,0xFCB9887C,0x62DD1DDF,0x15DA2D49,0x8CD37CF3,0xFBD44C65,
+ 0x4DB26158,0x3AB551CE,0xA3BC0074,0xD4BB30E2,0x4ADFA541,0x3DD895D7,0xA4D1C46D,0xD3D6F4FB,
+ 0x4369E96A,0x346ED9FC,0xAD678846,0xDA60B8D0,0x44042D73,0x33031DE5,0xAA0A4C5F,0xDD0D7CC9,
+ 0x5005713C,0x270241AA,0xBE0B1010,0xC90C2086,0x5768B525,0x206F85B3,0xB966D409,0xCE61E49F,
+ 0x5EDEF90E,0x29D9C998,0xB0D09822,0xC7D7A8B4,0x59B33D17,0x2EB40D81,0xB7BD5C3B,0xC0BA6CAD,
+ 0xEDB88320,0x9ABFB3B6,0x03B6E20C,0x74B1D29A,0xEAD54739,0x9DD277AF,0x04DB2615,0x73DC1683,
+ 0xE3630B12,0x94643B84,0x0D6D6A3E,0x7A6A5AA8,0xE40ECF0B,0x9309FF9D,0x0A00AE27,0x7D079EB1,
+ 0xF00F9344,0x8708A3D2,0x1E01F268,0x6906C2FE,0xF762575D,0x806567CB,0x196C3671,0x6E6B06E7,
+ 0xFED41B76,0x89D32BE0,0x10DA7A5A,0x67DD4ACC,0xF9B9DF6F,0x8EBEEFF9,0x17B7BE43,0x60B08ED5,
+ 0xD6D6A3E8,0xA1D1937E,0x38D8C2C4,0x4FDFF252,0xD1BB67F1,0xA6BC5767,0x3FB506DD,0x48B2364B,
+ 0xD80D2BDA,0xAF0A1B4C,0x36034AF6,0x41047A60,0xDF60EFC3,0xA867DF55,0x316E8EEF,0x4669BE79,
+ 0xCB61B38C,0xBC66831A,0x256FD2A0,0x5268E236,0xCC0C7795,0xBB0B4703,0x220216B9,0x5505262F,
+ 0xC5BA3BBE,0xB2BD0B28,0x2BB45A92,0x5CB36A04,0xC2D7FFA7,0xB5D0CF31,0x2CD99E8B,0x5BDEAE1D,
+ 0x9B64C2B0,0xEC63F226,0x756AA39C,0x026D930A,0x9C0906A9,0xEB0E363F,0x72076785,0x05005713,
+ 0x95BF4A82,0xE2B87A14,0x7BB12BAE,0x0CB61B38,0x92D28E9B,0xE5D5BE0D,0x7CDCEFB7,0x0BDBDF21,
+ 0x86D3D2D4,0xF1D4E242,0x68DDB3F8,0x1FDA836E,0x81BE16CD,0xF6B9265B,0x6FB077E1,0x18B74777,
+ 0x88085AE6,0xFF0F6A70,0x66063BCA,0x11010B5C,0x8F659EFF,0xF862AE69,0x616BFFD3,0x166CCF45,
+ 0xA00AE278,0xD70DD2EE,0x4E048354,0x3903B3C2,0xA7672661,0xD06016F7,0x4969474D,0x3E6E77DB,
+ 0xAED16A4A,0xD9D65ADC,0x40DF0B66,0x37D83BF0,0xA9BCAE53,0xDEBB9EC5,0x47B2CF7F,0x30B5FFE9,
+ 0xBDBDF21C,0xCABAC28A,0x53B39330,0x24B4A3A6,0xBAD03605,0xCDD70693,0x54DE5729,0x23D967BF,
+ 0xB3667A2E,0xC4614AB8,0x5D681B02,0x2A6F2B94,0xB40BBE37,0xC30C8EA1,0x5A05DF1B,0x2D02EF8D,
+ };
+
+ uint32 crc = ~lastCRC; // same as lastCRC ^ 0xFFFFFFFF
+ const unsigned char* DD_RESTRICT pCurrent = (const unsigned char*)pData;
+ while (length--)
+ crc = (crc >> 8) ^ lookupTable[(crc & 0xFF) ^ *pCurrent++];
+ return ~crc;
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddTransferManager.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddTransferManager.h
new file mode 100644
index 000000000..1c39b96ca
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddTransferManager.h
@@ -0,0 +1,247 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2017-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddTransferManager.h
+* @brief Class declaration for TransferManager
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "util/sharedptr.h"
+#include "util/vector.h"
+#include "util/hashMap.h"
+#include "protocols/systemProtocols.h"
+#include "protocols/ddTransferClient.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+ class SessionManager;
+
+ namespace TransferProtocol
+ {
+ class TransferManager;
+ class TransferServer;
+
+ // Size of an individual "chunk" within a transfer operation.
+ static const size_t kTransferChunkSizeInBytes = 4096;
+
+ // A struct that represents a single transfer chunk
+ struct TransferChunk
+ {
+ uint8 Data[kTransferChunkSizeInBytes];
+ };
+
+ // Base class for transfer blocks.
+ // A "block" is a binary blob of data associated with a unique id. Blocks can be created locally via the
+ // transfer manager's OpenServerBlock function. Once a server block is closed, it can be accessed remotely
+ // by other clients on the message bus. Remote clients can simply use their own transfer manager to open
+ // the desired block over the bus via OpenPullBlock.
+ class TransferBlock
+ {
+ public:
+ explicit TransferBlock(BlockId blockId)
+ : m_blockDataSize(0)
+ , m_blockId(blockId) {}
+
+ // Returns the unique id associated with this block
+ BlockId GetBlockId() const { return m_blockId; }
+
+ // Returns the size of the data contained within this block in bytes
+ size_t GetBlockDataSize() const { return m_blockDataSize; }
+
+ protected:
+ size_t m_blockDataSize; // The size of the data held by the block
+ BlockId m_blockId; // The id associated with this block
+ };
+
+ // A server transfer block.
+ // Only supports writes and must be closed before the data can be accessed.
+ // Writes can only be performed on blocks that have not been closed.
+ class ServerBlock final : public TransferBlock
+ {
+ friend class TransferServer;
+ public:
+ explicit ServerBlock(const AllocCb& allocCb, BlockId blockId)
+ : TransferBlock(blockId)
+ , m_isClosed(false)
+ , m_chunks(allocCb)
+ , m_numPendingTransfers(0)
+ , m_transfersCompletedEvent(true)
+ , m_crc32(0)
+ {}
+
+ // Writes numBytes bytes from pSrcBuffer into the block.
+ void Write(const uint8* pSrcBuffer, size_t numBytes);
+
+ // Closes the block which exposes it to external clients and prevents further writes.
+ void Close();
+
+ // Resets the block to its initial state. Does not return allocated memory.
+ void Reset();
+
+ // Returns true if this block has been closed.
+ bool IsClosed() const { return m_isClosed; }
+
+ // Returns a const pointer to the underlying data contained within the block, or null if it contains
+ // no data.
+ const uint8* GetBlockData() const {
+ return (m_blockDataSize > 0) ? reinterpret_cast(m_chunks.Data()) : nullptr;
+ }
+
+ // Waits for all pending transfers to complete or for the timeout to expire.
+ Result WaitForPendingTransfers(uint32 timeoutInMs);
+
+ // Returns a CRC32 for the current block
+ uint32 GetCrc32() const { return m_crc32; };
+
+ // Reserves at least the specified number of bytes in the internal storage.
+ void Reserve(size_t bytes);
+
+ private:
+ // Notifies the block that a new transfer has begun.
+ void BeginTransfer();
+
+ // Notifies the block that an existing transfer has ended.
+ void EndTransfer();
+
+ bool m_isClosed; // A bool that indicates if the block is closed
+ Vector m_chunks; // A list of transfer chunks used to store data
+ Platform::Mutex m_pendingTransfersMutex; // A mutex used to control access to the pending transfers counter
+ uint32 m_numPendingTransfers; // A counter used to track the number of pending transfers
+ Platform::Event m_transfersCompletedEvent; // An event that is signaled when all pendings transfers are completed
+ uint32 m_crc32; // CRC covering all data stored in this block
+ };
+
+ // Backwards compatibility type alias. This will be removed with a future interface version change.
+ using LocalBlock = ServerBlock;
+
+ // A transfer block for reading data from a remote client.
+ class PullBlock final : public TransferBlock
+ {
+ friend class TransferManager;
+ public:
+ // Reads up to bufferSize bytes into pDstBuffer from the block.
+ // Returns the number of bytes read in pBytesRead.
+ Result Read(uint8* pDstBuffer, size_t bufferSize, size_t* pBytesRead);
+
+ private:
+ explicit PullBlock(IMsgChannel* pMsgChannel, BlockId blockId)
+ : TransferBlock(blockId)
+ , m_transferClient(pMsgChannel)
+ {}
+
+ TransferClient m_transferClient;
+ };
+
+ // A transfer block for sending data to a remote server block
+ class PushBlock final : public TransferBlock
+ {
+ friend class TransferManager;
+ public:
+ // Reads up to bufferSize bytes from pDstBuffer and writes it into the remote block.
+ Result Write(const uint8* pDstBuffer, size_t bufferSize);
+
+ // Closes the block, telling the server to save the data already transfered.
+ Result Finalize();
+
+ // Closes the block, telling the server to discard any data already transfered.
+ Result Discard();
+ private:
+ explicit PushBlock(IMsgChannel* pMsgChannel, BlockId blockId)
+ : TransferBlock(blockId)
+ , m_transferClient(pMsgChannel)
+ {}
+
+ TransferClient m_transferClient;
+ };
+
+ // Transfer manager class.
+ // Manages interactions with server/remote transfer blocks.
+ class TransferManager
+ {
+ public:
+ explicit TransferManager(const AllocCb& allocCb);
+ ~TransferManager();
+
+ Result Init(IMsgChannel* pMsgChannel, SessionManager* pSessionManager);
+ void Destroy();
+
+ // Returns a shared pointer to a server block or nullptr in the case of an error.
+ // Shared pointers are always used with server blocks to make sure they aren't destroyed
+ // while a remote download is in progress.
+ SharedPointer OpenServerBlock();
+
+ // Returns a shared pointer to a server block matching the requested block ID, or nullptr if it does
+ // not exist.
+ SharedPointer GetServerBlock(BlockId serverBlockId);
+
+ // Releases a server block. This prevents new remote transfer requests from succeeding.
+ // This will clear the server block pointer inside the shared pointer object.
+ void CloseServerBlock(SharedPointer& pBlock);
+
+ // Attempts to open a block exposed by a remote client over the message bus.
+ // Returns a valid PullBlock pointer on success and nullptr on failure.
+ PullBlock* OpenPullBlock(ClientId clientId, BlockId blockId);
+
+ // Closes a pull block and deletes the underlying resources.
+ // This will null out the pull block pointer that is passed in as ppBlock.
+ void ClosePullBlock(PullBlock** ppBlock);
+
+ // Attempts to open a block exposed by a remote client over the message bus.
+ // Returns a valid PushBlock pointer on success and nullptr on failure.
+ PushBlock* OpenPushBlock(ClientId clientId, BlockId blockId, size_t blockSize);
+
+ // Closes a push block and deletes the underlying resources.
+ // This will null out the push block pointer that is passed in as ppBlock.
+ void ClosePushBlock(PushBlock** ppBlock);
+
+ // Backwards compatibility - replaced by OpenServerBlock()
+ SharedPointer AcquireLocalBlock()
+ {
+ return OpenServerBlock();
+ }
+
+ // Backwards compatibility - replaced by CloseServerBlock()
+ void ReleaseLocalBlock(SharedPointer& pBlock)
+ {
+ CloseServerBlock(pBlock);
+ }
+
+ private:
+ IMsgChannel* m_pMessageChannel;
+ SessionManager* m_pSessionManager;
+ TransferServer* m_pTransferServer;
+ AllocCb m_allocCb;
+ Platform::Random m_rng;
+ Platform::Mutex m_mutex;
+
+ // A list of all the server blocks that are currently available to the TransferManager.
+ HashMap, 16> m_registeredServerBlocks;
+ };
+ } // TransferProtocol
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddUriInterface.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddUriInterface.h
new file mode 100644
index 000000000..0bede48ee
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/ddUriInterface.h
@@ -0,0 +1,116 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddUriInterface.h
+* @brief Declaration for public URI interfaces.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "ddPlatform.h"
+#include "util/sharedptr.h"
+
+namespace DevDriver
+{
+ namespace TransferProtocol
+ {
+ class ServerBlock;
+ }
+
+ enum struct URIDataFormat : uint32
+ {
+ Unknown = 0,
+ Text,
+ Binary,
+ Count
+ };
+
+ // A struct that represents a unique URI request
+ struct URIRequestContext
+ {
+ // Mutable arguments passed to the request
+ char* pRequestArguments;
+
+ // A server block to write the response data into.
+ SharedPointer pResponseBlock;
+
+ // The format of the data written into the response block.
+ URIDataFormat responseDataFormat;
+ };
+
+ struct URIResponseHeader
+ {
+ // The size of the response data in bytes
+ size_t responseDataSizeInBytes;
+
+ // The format of the response data
+ URIDataFormat responseDataFormat;
+ };
+
+ // Base class for URI services
+ class IService
+ {
+ public:
+ virtual ~IService() {}
+
+ // Returns the name of the service
+ virtual const char* GetName() const = 0;
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_URI_RESPONSE_FORMATS_VERSION)
+ // Attempts to handle a request from a client
+ // Deprecated
+ virtual Result HandleRequest(char* pArguments,
+ SharedPointer pBlock)
+ {
+ DD_UNUSED(pArguments);
+ DD_UNUSED(pBlock);
+ DD_NOT_IMPLEMENTED();
+ return Result::Error;
+ }
+
+ // Attempts to handle a request from a client
+ virtual Result HandleRequest(URIRequestContext* pContext)
+ {
+ DD_ASSERT(pContext != nullptr);
+
+ const Result result = HandleRequest(pContext->pRequestArguments,
+ pContext->pResponseBlock);
+ if (result == Result::Success)
+ {
+ pContext->responseDataFormat = URIDataFormat::Text;
+ }
+
+ return result;
+ }
+#else
+ // Attempts to handle a request from a client
+ virtual Result HandleRequest(URIRequestContext* pContext) = 0;
+#endif
+ protected:
+ IService() {};
+ };
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/devDriverClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/devDriverClient.h
new file mode 100644
index 000000000..7b4290f34
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/devDriverClient.h
@@ -0,0 +1,136 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file devDriverClient.h
+* @brief Class declaration for DevDriverClient.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "ddPlatform.h"
+#include "msgChannel.h"
+#include "msgTransport.h"
+#include "protocols/systemProtocols.h"
+#include "protocols/typemap.h"
+#include "util/vector.h"
+#include "protocolClient.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+ class IProtocolClient;
+
+ // Client Creation Info
+ // This struct extends the MessageChannelCreateInfo struct and adds information about the destination host
+ // the client will connect to. See msgChannel.h for a full list of members.
+ struct ClientCreateInfo : public MessageChannelCreateInfo
+ {
+ HostInfo connectionInfo; // Connection information describing how the Server should connect
+ // to the message bus.
+ };
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_CREATE_INFO_CLEANUP_VERSION)
+ struct DevDriverClientCreateInfo
+ {
+ struct TransportCreateInfo : public MessageChannelCreateInfo
+ {
+ AllocCb allocCb;
+ HostInfo hostInfo;
+ TransportType type;
+ } transportCreateInfo;
+ };
+#endif
+
+ class DevDriverClient
+ {
+ public:
+#if !DD_VERSION_SUPPORTS(GPUOPEN_CREATE_INFO_CLEANUP_VERSION)
+ explicit DevDriverClient(const DevDriverClientCreateInfo& createInfo);
+#endif
+ explicit DevDriverClient(const AllocCb& allocCb,
+ const ClientCreateInfo& createInfo);
+ ~DevDriverClient();
+
+ Result Initialize();
+ void Destroy();
+
+ bool IsConnected() const;
+ IMsgChannel* GetMessageChannel() const;
+
+ template
+ ProtocolClientType* AcquireProtocolClient()
+ {
+ using T = ProtocolClientType;
+ T* pProtocolClient = nullptr;
+
+ Platform::LockGuard lock(m_clientLock);
+
+ for (size_t index = 0; index < m_pUnusedClients.Size(); index++)
+ {
+ if (m_pUnusedClients[index]->GetProtocol() == protocol)
+ {
+ pProtocolClient = static_cast(m_pUnusedClients[index]);
+ DD_ASSERT(pProtocolClient->GetProtocol() == protocol);
+ m_pUnusedClients.Remove(index);
+ m_pClients.PushBack(pProtocolClient);
+ return pProtocolClient;
+ }
+ }
+
+ pProtocolClient = DD_NEW(T, m_allocCb)(m_pMsgChannel);
+ if (pProtocolClient != nullptr)
+ {
+ m_pClients.PushBack(pProtocolClient);
+ }
+
+ return pProtocolClient;
+ }
+
+ void ReleaseProtocolClient(IProtocolClient* pProtocolClient)
+ {
+ Platform::LockGuard lock(m_clientLock);
+ if (pProtocolClient != nullptr && (m_pClients.Remove(pProtocolClient) > 0))
+ {
+ pProtocolClient->Disconnect();
+ m_pUnusedClients.PushBack(pProtocolClient);
+ }
+ }
+
+ private:
+ DD_STATIC_CONST uint32 kRegistrationTimeoutInMs = 1000;
+ IMsgChannel* m_pMsgChannel;
+
+ Platform::AtomicLock m_clientLock;
+ Vector m_pClients;
+ Vector m_pUnusedClients;
+
+ // Allocator and create info are stored at the end of the struct since they will be used infrequently
+ AllocCb m_allocCb;
+ ClientCreateInfo m_createInfo;
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/devDriverServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/devDriverServer.h
new file mode 100644
index 000000000..599138f2e
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/devDriverServer.h
@@ -0,0 +1,117 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file devDriverServer.h
+* @brief Class declaration for DevDriverServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "msgChannel.h"
+#include "msgTransport.h"
+#include "protocols/systemProtocols.h"
+#include "protocols/typemap.h"
+
+namespace DevDriver
+{
+ class IProtocolServer;
+
+ // Server Creation Info
+ // This struct extends the MessageChannelCreateInfo struct and adds information about the destination host
+ // the client will connect to. It additionally allows specifying protocol servers to enable during initialization.
+ // See msgChannel.h for a full list of members.
+ struct ServerCreateInfo : public MessageChannelCreateInfo
+ {
+ HostInfo connectionInfo; // Connection information describing how the Server should connect
+ // to the message bus.
+ ProtocolFlags servers; // Set of boolean values indicating which servers should be created
+ // during initialization.
+ };
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_CREATE_INFO_CLEANUP_VERSION)
+ struct DevDriverServerCreateInfo
+ {
+ struct TransportCreateInfo : public MessageChannelCreateInfo
+ {
+ AllocCb allocCb;
+ HostInfo hostInfo;
+ TransportType type;
+ } transportCreateInfo;
+ ProtocolFlags enabledProtocols;
+ };
+#endif
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_DISTRIBUTED_STATUS_FLAGS_VERSION)
+ Result QueryDevDriverStatus(const TransportType type, StatusFlags* pFlags, HostInfo *pHostInfo = nullptr);
+#endif
+
+ DD_STATIC_CONST uint32 kQueryStatusTimeoutInMs = 50;
+
+ class DevDriverServer
+ {
+ public:
+ static bool IsConnectionAvailable(const HostInfo& hostInfo, uint32 timeout = kQueryStatusTimeoutInMs);
+
+ explicit DevDriverServer(const AllocCb& allocCb, const ServerCreateInfo& createInfo);
+ ~DevDriverServer();
+
+ Result Initialize();
+ void Finalize();
+ void Destroy();
+
+ bool IsConnected() const;
+ IMsgChannel* GetMessageChannel() const;
+
+ LoggingProtocol::LoggingServer* GetLoggingServer();
+ SettingsProtocol::SettingsServer* GetSettingsServer();
+ DriverControlProtocol::DriverControlServer* GetDriverControlServer();
+ RGPProtocol::RGPServer* GetRGPServer();
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_CREATE_INFO_CLEANUP_VERSION)
+ static bool IsConnectionAvailable(const TransportType type, uint32 timeout = kQueryStatusTimeoutInMs);
+ explicit DevDriverServer(const DevDriverServerCreateInfo& createInfo);
+#endif
+ private:
+ Result InitializeProtocols();
+ void DestroyProtocols();
+
+ Result RegisterProtocol(Protocol protocol);
+ void UnregisterProtocol(Protocol protocol);
+ void FinalizeProtocol(Protocol protocol);
+
+ IMsgChannel* m_pMsgChannel;
+ AllocCb m_allocCb;
+ ServerCreateInfo m_createInfo;
+
+ template
+ inline Result RegisterProtocol(Args... args);
+
+ template
+ inline ProtocolServerType* GetServer();
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/gpuopen.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/gpuopen.h
new file mode 100644
index 000000000..4929edf65
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/gpuopen.h
@@ -0,0 +1,531 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+
+#pragma once
+
+#define GPUOPEN_INTERFACE_MAJOR_VERSION 31
+#define GPUOPEN_INTERFACE_MINOR_VERSION 0
+
+#define GPUOPEN_INTERFACE_VERSION ((GPUOPEN_INTERFACE_MAJOR_VERSION << 16) | GPUOPEN_INTERFACE_MINOR_VERSION)
+
+#define GPUOPEN_MINIMUM_INTERFACE_MAJOR_VERSION 26
+
+#ifndef GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION
+static_assert(false, "Client must define GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION.");
+#else
+static_assert((GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION >= GPUOPEN_MINIMUM_INTERFACE_MAJOR_VERSION) &&
+ (GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION <= GPUOPEN_INTERFACE_MAJOR_VERSION),
+ "The specified GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION is not supported.");
+#endif
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 31.0 | Clean up DevDriverClient and DevDriverServer create info structs. Replace TransportCreateInfo |
+*| | struct with MessageChannelCreateInfo and HostInfo structs. |
+*| 30.2 | Added support for RGP v6 protocol which supports trace trigger markers. |
+*| 30.1 | Add Push transfer support to the transfer protocol. Added PushBlock class, added v2 of the |
+*| | TransferProtocol, and did a lot of internal cleanup. Legacy interfaces will be deprecated in a future |
+*| | interface version change alongside URI changes. |
+*| 30.0 | Remove CloseSession and OrphanSession from the public ISession object interface, and move the |
+*| | functionality into the Session class. |
+*| 29.0 | Added a ResponseDataFormat enum to the URI protocol to distinguish between binary and text responses. |
+*| 28.0 | Formally deprecate legacy KMD client manager support in the Listener. |
+*| 27.2 | Updated FindFirstClient to support returning the matching ClientMetadata struct. |
+*| 27.1 | Added PipelineDumpsEnabled status flag. |
+*| 27.0 | Deprecate global client status flags + replace it with client metadata. |
+*| 26.0 | Add new trace parameters in the RGP protocol. |
+*| 25.0 | Initial refactor of LoggingProtocol. Removes Subcategories, being able to set/clear filter outside of a |
+*| | trace, and significantly reduces the complexity that is involved in using it. |
+*| 24.0 | Expanded driver initialization concept in driver control protocol. |
+*| 23.0 | Modified RGP client API usage pattern to be uniform across protocol versions. |
+*| 22.0 | Refactor RGP client interface to support calculating transfer progress. |
+*| 21.1 | Added backwards compatible workaround for the session termination bug until we get the fix in mainline. |
+*| 21.0 | Enable link disconnection detection for socket based transports. |
+*| 20.0 | Added support for specifying the clock mode used during RGP profiling. |
+*| 19.0 | Refactor platform thread functions so that they are contained in a class. This is the last part of the |
+*| | platform library that needed to be refactored, so future work will be focused on migrating the message |
+*| | bus components to use the main platform library again. |
+*| 18.0 | Consolidate DevDriver::DebugLevel and DevDriver::Message::DebugLevel into DevDriver::LogLevel. |
+*| 17.0 | Rename DD_VERSION_IS_SUPPORTED macro to DD_VERSION_SUPPORTS for conciseness. |
+*| 16.1 | Rework session version negotiation to allow clients to support multiple server versions. |
+*| 16.0 | Change semantics of CreateProtocolClient to AcquireProtocolClient. This aligns better with |
+*| | ReleaseProtoclClient in terms of semantics. |
+*| 15.0 | Added support for memory allocator callbacks via AllocCb. |
+*| 14.1 | Added DisableTrace call in RGP server to allow drivers to disable future traces if necessary. |
+*| 14.0 | Add TraceParameters to the RGP protocol to allow for configuration of trace behavior. |
+*| 13.0 | Deprecate DevDriverClient::CreateProtocolClient() in favor of typesafe templated version. |
+*| 12.0 | Deprecate API features tied to legacy network protocol versions: |
+*| | * Replace ConnectToRemoteClient with Connect, which now returns more detailed errors on failure |
+*| | * Eliminate Send and ReceiveSessionMessage functions in IMsgChannel and SessionManager |
+*| | * Rename AuthenticationFailed to VersionMismatch since it is more semantically accurate |
+*| | * Update IMsgChannel::Update so that it takes a default timeout value, get rid of m_receiveTimeoutInMs |
+*| 11.5 | Updated server to remove GetVersion() call and pass version into AcceptSession() instead. This allows |
+*| | servers to potentially implement backwards compatibility for older client versions. Additionally, |
+*| | completely eliminate SessionTermination type in favor of expanding Result type. This allows propagating |
+*| | more information on connection failures back to clients, as well as streamlines some code. |
+*| 11.4 | Implement per-protocol versioning. Client protocol is sent as part of session request, server decides |
+*| | whether or not to accept session both from client and from version. Also rearrange how certain network |
+*| | operations work: Syn now stores the initial session ID in the sessionId field of the message, Rst now |
+*| | includes a result code, and closing a session now implicitly flushes both the client/server. Rst |
+*| | Is also sent on just about every unknown session packet received, allowing faster error detection and |
+*| | recovery. Bump network version number |
+*| 11.3 | Change ProcessId type from 64bit to 32bit integer and bump network protocol version. |
+*| 11.2 | Update the network protocol to give external protocols values from 0-223 and system protocols 224-255. |
+*| | Also clean up + deprecate some of the constants associated with protocols. |
+*| 11.1 | Force alignment of all network transmitted structs, as well as pad. This is a breaking change for the |
+*| | network protocol, but is otherwise API compatible. |
+*| 11.0 | Deprecate the Protocol::ClientManangement enum, as well as ReadMessageBuffer and SendMessageBuffer in |
+*| | message.lib. |
+*| 10.0 | Remove callback from MessageChannel to prevent usage that can cause deadlocking. |
+*| 9.0 | Formalized support for selective discard of non-session messages based on right in the message. |
+*| | Implementation is that the sequence field of a message can be populated with the contents of a |
+*| | ClientMetadata struct, which is then used by the receiving message channel to determine if it should |
+*| | respond. Decision is based on whether or not the metadata matches the metadata of the receiving client. |
+*| 8.0 | Added support for default settings values in the settings protocol. Removed support for min and max |
+*| | settings values since the scripts don't actually support those anyways. |
+*| 7.0 | Added a Finalize function to DevDriverServer and all protocol server objects. This function now handles |
+*| | the wait on start functionality for drivers internally. Finalize should now be called instead of the old |
+*| | wait on start logic in client drivers. |
+*| 6.0 | Update client protocol management so that DevDriverClient no longer caches a single instance of each |
+*| | client protocol, and add ability for clients to directly create more than one client protocol instance. |
+*| | Additionally, make changes to underlying message channel/transport API that is not backwards compatible, |
+*| | as well as rename QueryClientInfoResponse to ClientInfoResponse and QueryClientInfoResponsePayload to |
+*| | ClientInfoStruct. |
+*| 5.0 | Update network protocol to allow specifying status flags at registration time, and add system message. |
+*| | to indicate when a driver has been halted. Additionally, this changes the format of the client |
+*| | registration packets so as to better detect version mismatch. It also fixes the ClientManangement typo. |
+*| 4.0 | Refactor interface so as to better delineate between system protcols/client protocols, as well as add |
+*| | ability to query protocol availability. Requires version bump, so also formally deprecated |
+*| | Result::Timeout and ClientStatusFlags::ProfilingEnabled, as well as moved entire SessionProtocol |
+*| | namespace out of the public headers. |
+*| 3.1 | Introduce kNumberClientProtocols to replace usage of Protocol::Count |
+*| 3.0 | Rename SettingsProtocol::SettingType::Bool to Boolean to avoid conflict with Xlib macro. Additionally |
+*| | formally deprecate Result::Timeout. |
+*| 2.2 | Added None (0) to ClientStatusFlags enum. |
+*| 2.1 | Added kNamedPipeName to global namespace. |
+*| 2.0 | Added functionality for enabling and disabling traces in RGPServer. Traces must now be explicitly |
+*| | enabled before remote trace requests will succeed. |
+*| 1.2 | Added AbortTrace() function to RGPServer. |
+*| 1.1 | Added support for RGP protocol. |
+*| 1.0 | Initial versioned release. |
+***********************************************************************************************************************
+*/
+
+#define GPUOPEN_CREATE_INFO_CLEANUP_VERSION 31
+#define GPUOPEN_SESSION_INTERFACE_CLEANUP_VERSION 30
+#define GPUOPEN_URI_RESPONSE_FORMATS_VERSION 29
+#define GPUOPEN_DEPRECATE_LEGACY_KMD_VERSION 28
+#define GPUOPEN_DISTRIBUTED_STATUS_FLAGS_VERSION 27
+#define GPUOPEN_RGP_TRACE_PARAMETERS_V3_VERSION 26
+#define GPUOPEN_LOGGING_SIMPLIFICATION_VERSION 25
+#define GPUOPEN_DRIVERCONTROL_INITIALIZATION_VERSION 24
+#define GPUOPEN_RGP_UNIFORM_API_VERSION 23
+#define GPUOPEN_RGP_PROGRESS_VERSION 22
+#define GPUOPEN_KEEPALIVE_VERSION 21
+#define GPUOPEN_PROFILING_CLOCK_MODES_VERSION 20
+#define GPUOPEN_THREAD_REFACTOR_VERSION 19
+#define GPUOPEN_LOGLEVEL_CLEANUP_VERSION 18
+#define GPUOPEN_RENAME_MACRO_VERSION 17
+#define GPUOPEN_PROTOCOL_CLIENT_REUSE_VERSION 16
+#define GPUOPEN_MEMORY_ALLOCATORS_VERSION 15
+#define GPUOPEN_RGP_TRACE_PARAMETERS_VERSION 14
+#define GPUOPEN_DEPRECATE_CREATEPROTOCOLCLIENT_VERSION 13
+#define GPUOPEN_DEPRECATE_LEGACY_NETAPI_VERSION 12
+#define GPUOPEN_POST_GDC_CLEANUP_VERSION 11
+#define GPUOPEN_DEPRECATE_EXTERNAL_CALLBACK_VERSION 10
+#define GPUOPEN_SELECTIVE_RESPOND_VERSION 9
+#define GPUOPEN_DEFAULT_SETTINGS_VERSION 8
+#define GPUOPEN_SERVER_FINALIZE_VERSION 7
+#define GPUOPEN_DEPRECATE_LEGACY_VERSION 6
+#define GPUOPEN_CLIENT_REGISTRATION_VERSION 5
+#define GPUOPEN_PROTOCOL_CLEANUP_VERSION 4
+#define GPUOPEN_LINUX_BUILD_VERSION 3
+#define GPUOPEN_EXPLICIT_ENABLE_RGP_VERSION 2
+#define GPUOPEN_INITIAL_VERSION 1
+
+#include
+#include
+
+#if defined(_MSC_VER)
+#define DD_ALIGNAS(x)__declspec(align(x))
+#if _MSC_VER < 1900
+#define DD_STATIC_CONST static const
+#else
+#define DD_STATIC_CONST static constexpr
+#endif
+#endif
+
+#if !defined(DD_STATIC_CONST)
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define DD_STATIC_CONST static constexpr
+#else
+#define DD_STATIC_CONST static const
+#endif
+#endif
+
+#if !defined(DD_ALIGNAS)
+#if defined(__cplusplus) && __cplusplus >= 201103L
+#define DD_ALIGNAS(x) alignas(x)
+#else
+static_assert(false, "Error: unsupported compiler detected. Support is required to build.");
+#endif
+#endif
+
+// Creates a structure with the specified name and alignment.
+#define DD_ALIGNED_STRUCT(name, alignment) struct DD_ALIGNAS(alignment) name
+
+// Creates a structure with the specified alignment, and mark it as final to ensure it cannot be used as a parent class
+#define DD_NETWORK_STRUCT(name, alignment) struct DD_ALIGNAS(alignment) name final
+
+#define DD_CHECK_SIZE(x, size) static_assert(sizeof(x) == size_t(size), #x " size has changed unexpectedly")
+
+#define DD_VERSION_SUPPORTS(x) (GPUOPEN_CLIENT_INTERFACE_MAJOR_VERSION >= x)
+
+#define DD_PTR_TO_HANDLE(x) ((DevDriver::Handle)(uintptr_t)(x))
+
+#define DD_UNUSED(x) (static_cast(x))
+
+#define DD_SANITIZE_RESULT(x) ((x != Result::Success) ? Result::Error : x)
+
+namespace DevDriver
+{
+ typedef int8_t int8; ///< 8-bit integer.
+ typedef int16_t int16; ///< 16-bit integer.
+ typedef int32_t int32; ///< 32-bit integer.
+ typedef int64_t int64; ///< 64-bit integer.
+ typedef uint8_t uint8; ///< Unsigned 8-bit integer.
+ typedef uint16_t uint16; ///< Unsigned 16-bit integer.
+ typedef uint32_t uint32; ///< Unsigned 32-bit integer.
+ typedef uint64_t uint64; ///< Unsigned 64-bit integer.
+
+ typedef uint64_t Handle;
+
+ typedef uint16_t ClientId;
+ typedef uint32_t SessionId;
+ typedef uint32_t ProcessId;
+ typedef uint8_t MessageCode;
+ typedef uint16_t WindowSize;
+ typedef uint32_t Size;
+ typedef uint64_t Sequence;
+ typedef uint16_t Version;
+ typedef uint16_t StatusFlags;
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_DISTRIBUTED_STATUS_FLAGS_VERSION)
+ typedef StatusFlags ClientFlags;
+#endif
+
+ DD_STATIC_CONST Handle kNullPtr = DD_PTR_TO_HANDLE(NULL);
+ DD_STATIC_CONST uint32 kInfiniteTimeout = ~(0u);
+ DD_STATIC_CONST uint32 kNoWait = (0u);
+
+ ////////////////////////////
+ // Common result codes
+ enum struct Result : uint32
+ {
+ Success = 0,
+ Error = 1,
+ NotReady = 2,
+ VersionMismatch = 3,
+ Unavailable = 4,
+ Rejected = 5,
+ EndOfStream = 6,
+ Aborted = 7,
+ InsufficientMemory = 8
+ };
+
+ ////////////////////////////
+ // Common logging levels
+ enum struct LogLevel : uint8
+ {
+ Debug = 0,
+ Verbose,
+ Info,
+ Alert,
+ Error,
+ Always,
+ Count,
+ Never = 0xFF
+ };
+
+ ////////////////////////////
+ // Client status codes
+ enum struct ClientStatusFlags : StatusFlags
+ {
+ None = 0,
+ DeveloperModeEnabled = (1 << 0),
+ HaltOnConnect = (1 << 1),
+ GpuCrashDumpsEnabled = (1 << 2),
+ PipelineDumpsEnabled = (1 << 3)
+ };
+
+ DD_CHECK_SIZE(ClientId, 2);
+ DD_STATIC_CONST int16 kRouterPrefixWidth = 3;
+ DD_STATIC_CONST int16 kRouterPrefixShift = (int16)(16 - kRouterPrefixWidth);
+ DD_STATIC_CONST ClientId kClientIdMask = (1 << kRouterPrefixShift) - 1;
+ DD_STATIC_CONST ClientId kRouterPrefixMask = static_cast(~(kClientIdMask));
+
+ union ProtocolFlags
+ {
+ struct DD_ALIGNAS(4)
+ {
+ uint32 logging : 1;
+ uint32 settings : 1;
+ uint32 driverControl : 1;
+ uint32 rgp : 1;
+ uint32 etw : 1;
+ uint32 gpuCrashDump : 1;
+ uint32 reserved : 26;
+ };
+ uint32 value;
+ };
+
+ DD_CHECK_SIZE(ProtocolFlags, 4);
+
+ ////////////////////////////
+ // Component definitions
+ enum struct Component : uint8
+ {
+ Unknown = 0,
+ Server,
+ Tool,
+ Driver,
+ Count
+ };
+
+ union ClientMetadata
+ {
+ struct DD_ALIGNAS(8)
+ {
+ ProtocolFlags protocols;
+ Component clientType;
+ uint8 reserved;
+ StatusFlags status;
+ };
+ uint64 value;
+
+ // Test if all non-zero fields in the ClientMetadata value are contained in the function parameter
+ bool Matches(const ClientMetadata &right) const
+ {
+ bool result = true;
+ if (value != 0)
+ {
+ // Component is an enum, so the comparison needs to be equality
+ const bool clientTypeMatches =
+ (clientType != Component::Unknown)
+ ? (clientType == right.clientType)
+ : true;
+
+ // ProtocolFlags is a bit field, so we can do a bitwise comparison
+ const bool protocolMatches =
+ (protocols.value != 0)
+ ? (protocols.value & right.protocols.value) == protocols.value
+ : true;
+ // StatusFlags is a bit field, so we can do a bitwise comparison
+ const bool statusMatches =
+ (status != 0)
+ ? (status & right.status) == status
+ : true;
+ result = clientTypeMatches & protocolMatches & statusMatches;
+ }
+ return result;
+ }
+
+ // Test if any non-zero fields in the ClientMetadata value are contained in the function parameter
+ bool MatchesAny(const ClientMetadata &right) const
+ {
+ bool result = true;
+ if (value != 0)
+ {
+ // Component is an enum, so the comparison needs to be equality
+ const bool clientTypeMatches = (clientType == right.clientType);
+ // ProtocolFlags is a bit field, so we can do a bitwise comparison
+ const bool protocolMatches = (protocols.value & right.protocols.value) != 0;
+ // StatusFlags is a bit field, so we can do a bitwise comparison
+ const bool statusMatches = (status & right.status) != 0;
+ result = clientTypeMatches | protocolMatches | statusMatches;
+ }
+ return result;
+ }
+ };
+
+ DD_CHECK_SIZE(ClientMetadata, 8);
+
+ ////////////////////////////
+ // Protocol definitions
+ enum struct Protocol : uint8
+ {
+ DriverControl = 0,
+ Logging,
+ Settings,
+ RGP,
+ ETW,
+ GpuCrashDump,
+ DefinedProtocolCount,
+
+ // System enumerations
+ MaxUserProtocol = 223,
+ /* RESERVED FOR SYSTEM USE */
+ Transfer = 251,
+ URI = 252,
+ Session = 253,
+ ClientManagement = 254,
+ System = 255,
+ };
+
+ // this gives you the number of pre-defined user protocols that exist
+ DD_STATIC_CONST uint32 kNumberClientProtocols = static_cast(Protocol::DefinedProtocolCount);
+
+ // this gives you the maximum number of client protocols you can reserve.
+ DD_STATIC_CONST uint32 kMaxClientProtocolId = static_cast(Protocol::MaxUserProtocol);
+
+ static_assert(kNumberClientProtocols <= (kMaxClientProtocolId + 1), "Invalid protocol definitions specified");
+
+ ///////////////////////
+ // General definitions
+ DD_STATIC_CONST uint32 kMessageVersion = 1011;
+
+ // Max string size for names and messages
+ DD_STATIC_CONST Size kMaxStringLength = 128;
+
+ // Broadcast client ID
+ DD_STATIC_CONST ClientId kBroadcastClientId = 0;
+
+ // Invalid Session ID
+ DD_STATIC_CONST SessionId kInvalidSessionId = 0;
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_CREATE_INFO_CLEANUP_VERSION)
+ // Default named pipe name
+ DD_STATIC_CONST char kNamedPipeName[] = "\\\\.\\pipe\\AMD-Developer-Service";
+
+#endif
+ // Default network port number
+ DD_STATIC_CONST uint32 kDefaultNetworkPort = 27300;
+
+ // Transport type enumeration
+ enum class TransportType : uint32
+ {
+ Local = 0,
+ Remote,
+ };
+
+ // Struct used to designate a transport type, port number, and hostname
+ struct HostInfo
+ {
+ TransportType type; // Transport type, as defined above
+ uint32 port; // Port number if applicable
+ char hostname[kMaxStringLength]; // Host address, address, or path
+ };
+
+ // Default local host information
+ DD_STATIC_CONST HostInfo kDefaultLocalHost =
+ {
+ TransportType::Remote,
+ kDefaultNetworkPort,
+ "127.0.0.1"
+ };
+
+ // Default named pipe information
+ DD_STATIC_CONST HostInfo kDefaultNamedPipe =
+ {
+ TransportType::Local,
+ 0,
+#if defined(__APPLE__)
+ "/tmp/com.amd.AMD-Developer-Service"
+#else
+ "\\\\.\\pipe\\AMD-Developer-Service"
+#endif
+
+ };
+
+ ////////////////////////////
+ // Common definition of a message header
+ //
+ // todo: better packing of these values
+ // - payloadSize needs to be moved to where windowSize is currently
+ // - windowSize, sessionId, and sequence need to be moved into protocol specific payloads
+ // - minimum alignment could then be reduced to 2 bytes, and min packet size would be 8 bytes
+ // - downside is that pretty much every protocol would need to define some extra data
+
+ DD_NETWORK_STRUCT(MessageHeader, 8)
+ {
+ // source and destination client ids
+ ClientId srcClientId; // 0 - 15
+ ClientId dstClientId; // 16 - 31
+
+ // protocol and command
+ Protocol protocolId; // 31 - 38
+ MessageCode messageId; // 39 - 47
+ WindowSize windowSize; // 48 - 63
+
+ // payload size + current session ID
+ Size payloadSize; // 64 - 91
+ SessionId sessionId; // 92 - 127
+
+ // sequence number when using a session
+ Sequence sequence; // 128 - 191
+ };
+
+ DD_CHECK_SIZE(MessageHeader, 24);
+
+ DD_STATIC_CONST Size kMaxMessageSizeInBytes = 1408;
+ DD_STATIC_CONST Size kMaxPayloadSizeInBytes = (kMaxMessageSizeInBytes - sizeof(MessageHeader));
+
+ DD_NETWORK_STRUCT(MessageBuffer, 8)
+ {
+ MessageHeader header;
+ char payload[kMaxPayloadSizeInBytes];
+ };
+
+ DD_CHECK_SIZE(MessageBuffer, sizeof(MessageHeader) + kMaxPayloadSizeInBytes);
+
+ // tripwire - this intentionally will break if the message version changes. Since these are breaking changes already, we need to address
+ // this problem when it happens.
+ static_assert(kMessageVersion == 1011, "ClientInfoStruct needs to be updated so that clientName is long enough to support a full path");
+ // todo: shorten clientDescription to 64bytes and make clientName 320bytes to support full path
+ DD_NETWORK_STRUCT(ClientInfoStruct, 8)
+ {
+ char clientName[kMaxStringLength];
+ char clientDescription[kMaxStringLength];
+ // reserve 128bytes in case we need another string in the future
+ char reserved[kMaxStringLength];
+ ClientMetadata metadata;
+ ProcessId processId;
+ // pad this out to 512 bytes for future expansion
+ char padding[116];
+ };
+
+ DD_CHECK_SIZE(ClientInfoStruct, 512);
+
+ typedef void*(*AllocFunc)(void* pUserdata, size_t size, size_t alignment, bool zero);
+ typedef void(*FreeFunc)(void* pUserdata, void* pMemory);
+
+ struct AllocCb
+ {
+ void* pUserdata;
+ AllocFunc pfnAlloc;
+ FreeFunc pfnFree;
+ };
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/msgChannel.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/msgChannel.h
new file mode 100644
index 000000000..a337f5086
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/msgChannel.h
@@ -0,0 +1,164 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file msgChannel.h
+* @brief Interface declaration for IMsgChannel
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "protocolClient.h"
+#include "protocolServer.h"
+#include "msgTransport.h"
+
+namespace DevDriver
+{
+ class IService;
+
+ namespace TransferProtocol
+ {
+ class TransferManager;
+ }
+
+ DD_STATIC_CONST uint32 kDefaultUpdateTimeoutInMs = 10;
+ DD_STATIC_CONST uint32 kFindClientTimeout = 500;
+
+ // Struct of information required to initialize an IMsgChannel instance
+ struct MessageChannelCreateInfo
+ {
+ StatusFlags initialFlags; // Initial client status flags.
+ Component componentType; // Type of component the message channel represents.
+ bool createUpdateThread; // Create a background processing thread for the message
+ // channel. This should only be set to false if the
+ // owning object is able to call IMsgChannel::Update()
+ // at least once per frame.
+ char clientDescription[kMaxStringLength]; // Description of the client provided to other clients on
+ // the message bus.
+ };
+
+ class IMsgChannel
+ {
+ public:
+ virtual ~IMsgChannel() {}
+
+ // Register, unregister, or check connected status.
+ virtual Result Register(uint32 timeoutInMs = ~(0u)) = 0;
+ virtual Result Unregister() = 0;
+ virtual bool IsConnected() = 0;
+
+ // Send, receive, and forward messages
+ virtual Result Send(ClientId dstClientId,
+ Protocol protocol,
+ MessageCode message,
+ const ClientMetadata& metadata,
+ uint32 payloadSizeInBytes,
+ const void* pPayload) = 0;
+ virtual Result Receive(MessageBuffer& message, uint32 timeoutInMs) = 0;
+ virtual Result Forward(const MessageBuffer& messageBuffer) = 0;
+
+ // Register, unregister, and retrieve IProtocolServer objects
+ virtual Result RegisterProtocolServer(IProtocolServer* pServer) = 0;
+ virtual Result UnregisterProtocolServer(IProtocolServer* pServer) = 0;
+ virtual IProtocolServer* GetProtocolServer(Protocol protocol) = 0;
+
+ // Initiates a connection using the provided protocol client to the specified destionation client id
+ virtual Result ConnectProtocolClient(IProtocolClient* pProtocolClient, ClientId dstClientId) = 0;
+
+ // Register or Unregister an IService object
+ virtual Result RegisterService(IService* pService) = 0;
+ virtual Result UnregisterService(IService* pService) = 0;
+
+ // Get the allocator used to create this message channel
+ virtual const AllocCb& GetAllocCb() const = 0;
+
+ // Returns client information for the first client to respond that matches the specified filter
+ virtual Result FindFirstClient(const ClientMetadata& filter,
+ ClientId* pClientId,
+ uint32 timeoutInMs = kFindClientTimeout,
+ ClientMetadata* pClientMetadata = nullptr) = 0;
+
+ // Get the client ID, or returns kBroadcastClientId if disconnected.
+ virtual ClientId GetClientId() const = 0;
+
+ // Get the client information struct for the message channel.
+ virtual const ClientInfoStruct& GetClientInfo() const = 0;
+
+ // Get a human-readable string describing the connection type.
+ virtual const char* GetTransportName() const = 0;
+
+ // Set and get all client status flags.
+ virtual Result SetStatusFlags(StatusFlags flags) = 0;
+ virtual StatusFlags GetStatusFlags() const = 0;
+
+ // Set the specified client status flag.
+ template
+ Result SetStatusFlag(bool enable)
+ {
+ Result toggleResult = Result::Success;
+ StatusFlags oldFlags = GetStatusFlags();
+ StatusFlags newFlags;
+
+ if (enable)
+ {
+ // Toggle developer mode
+ newFlags = oldFlags | static_cast(flag);
+ }
+ else
+ {
+ // Toggle developer mode
+ newFlags = oldFlags & ~static_cast(flag);
+ }
+
+ if (newFlags != oldFlags)
+ {
+ toggleResult = SetStatusFlags(newFlags);
+ }
+ return toggleResult;
+ }
+
+ // Get the specified client status flag.
+ template
+ bool GetStatusFlag() const
+ {
+ return ((GetStatusFlags() & static_cast(flag)) != 0);
+ }
+
+ // Utility functions that should probably not be publicly exposed.
+ // TODO: Refactor surrounding code to eliminate these.
+ virtual TransferProtocol::TransferManager& GetTransferManager() = 0;
+ virtual void Update(uint32 timeoutInMs = kDefaultUpdateTimeoutInMs) = 0;
+
+ // Backwards compatibility
+ Result EstablishSession(ClientId dstClientId, IProtocolClient* pProtocolClient)
+ {
+ return ConnectProtocolClient(pProtocolClient, dstClientId);
+ }
+ protected:
+ IMsgChannel() {};
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/msgTransport.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/msgTransport.h
new file mode 100644
index 000000000..4a154c200
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/msgTransport.h
@@ -0,0 +1,79 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file msgChannel.h
+* @brief Interface declaration for IMsgChannel
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+
+namespace DevDriver
+{
+ class IMsgTransport
+ {
+ public:
+ virtual ~IMsgTransport() {}
+
+ // Connect and disconnect from the transport.
+ virtual Result Connect(ClientId* pClientId, uint32 timeoutInMs) = 0;
+ virtual Result Disconnect() = 0;
+
+ // Read and Write messages from a connected transport
+ virtual Result WriteMessage(const MessageBuffer &messageBuffer) = 0;
+ virtual Result ReadMessage(MessageBuffer &messageBuffer, uint32 timeoutInMs) = 0;
+
+ // Get a human-readable string describing the connection type.
+ virtual const char* GetTransportName() const = 0;
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_DISTRIBUTED_STATUS_FLAGS_VERSION)
+ virtual Result UpdateClientStatus(ClientId clientId, StatusFlags flags) = 0;
+#endif
+
+ // Static method to be implemented by individual transports
+ // true indicates that the transport is incapable of detecting
+ // dropped connections and some form of keep-alive is required
+ // false indicates that the transport can properly detect dropped
+ // connections
+ DD_STATIC_CONST bool RequiresKeepAlive()
+ {
+ return false;
+ }
+
+ // Static method to be implemented by individual transports
+ // true indicates that Connect is expected to also negotiate a client ID
+ // false indicates that the MessageChannel needs to do it's own client ID
+ // negotiation, e.g. in the case of network connections
+ DD_STATIC_CONST bool RequiresClientRegistration()
+ {
+ return false;
+ }
+ protected:
+ IMsgTransport() {}
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/posix/ddPosixPlatform.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/posix/ddPosixPlatform.h
new file mode 100644
index 000000000..9385dbb51
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/posix/ddPosixPlatform.h
@@ -0,0 +1,126 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddPosixPlatform.h
+* @brief POSIX Platform layer definition
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include
+#include
+#include
+#include
+#include
+
+#if defined(__APPLE__)
+#include
+#define DD_DARWIN
+#elif defined(__linux__)
+#include
+#define DD_LINUX
+#else
+static_assert(false, "Unknown platform detected")
+#endif
+
+#define DD_RESTRICT __restrict__
+
+namespace DevDriver
+{
+ namespace Platform
+ {
+ template
+ int RetryTemporaryFailure(T& func, Args&&... args)
+ {
+ int retval;
+ do
+ {
+ retval = func(args...);
+ } while (retval == -1 && errno == EINTR);
+ return retval;
+ }
+
+ typedef volatile int32 Atomic;
+
+ struct EmptyStruct
+ {
+ };
+
+ struct EventStorage
+ {
+ pthread_mutex_t mutex;
+ pthread_cond_t condition;
+ volatile bool isSet;
+ };
+
+ typedef pthread_mutex_t MutexStorage;
+
+#if defined(DD_LINUX)
+ typedef sem_t SemaphoreStorage;
+ typedef drand48_data RandomStorage;
+#endif
+
+ struct ThreadStorage
+ {
+ void(*callback)(void *);
+ void *parameter;
+ pthread_t handle;
+ };
+
+ inline static void DebugBreak(
+ const char* pFile,
+ unsigned int line,
+ const char* pFunction,
+ const char* pAssertion) __attribute__((noreturn));
+
+ static void DebugBreak(
+ const char* pFile,
+ unsigned int line,
+ const char* pFunction,
+ const char* pAssertion)
+ {
+ DD_UNUSED(pFile);
+ DD_UNUSED(line);
+ DD_UNUSED(pFunction);
+ DD_UNUSED(pAssertion);
+
+#if defined(DEVDRIVER_HARD_ASSERT)
+#if !defined(NDEBUG)
+#if defined(DD_LINUX)
+ __assert_fail(pAssertion, pFile, line, pFunction);
+#endif
+#else
+#if defined(SIGTRAP)
+ raise(SIGTRAP);
+#else
+ raise(SIGINT);
+#endif
+#endif
+#endif
+ __builtin_unreachable();
+ }
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolClient.h
new file mode 100644
index 000000000..446cb8ef2
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolClient.h
@@ -0,0 +1,59 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file gpuopenProtocolClient.h
+* @brief Interface declaration for IProtocolClient.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "protocolSession.h"
+
+namespace DevDriver
+{
+ class Session;
+
+ class IProtocolClient : public IProtocolSession
+ {
+ public:
+ virtual ~IProtocolClient() {}
+
+ virtual Version GetSessionVersion() const = 0;
+
+ virtual Result Connect(ClientId clientId) = 0;
+ virtual void Disconnect() = 0;
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_SESSION_INTERFACE_CLEANUP_VERSION)
+ virtual void Orphan() = 0;
+#endif
+ virtual bool IsConnected() const = 0;
+ virtual ClientId GetRemoteClientId() const = 0;
+ protected:
+ IProtocolClient() {}
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolServer.h
new file mode 100644
index 000000000..afc04df86
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolServer.h
@@ -0,0 +1,54 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file protocolServer.h
+* @brief Interface declaration for IProtocolServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "protocolSession.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+ class Session;
+
+ class IProtocolServer : public IProtocolSession
+ {
+ public:
+ virtual ~IProtocolServer() {}
+
+ virtual void Finalize() = 0;
+
+ virtual bool GetSupportedVersion(Version minVersion, Version maxVersion, Version *version) const = 0;
+ virtual bool AcceptSession(const SharedPointer& pSession) = 0;
+ protected:
+ IProtocolServer() {}
+ };
+
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolSession.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolSession.h
new file mode 100644
index 000000000..f8fdb6584
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocolSession.h
@@ -0,0 +1,185 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file protocolSession.h
+* @brief Interface declaration for IProtocolSession.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "ddPlatform.h"
+#include "util/template.h"
+#include "util/sharedptr.h"
+
+namespace DevDriver
+{
+ // A container struct that can hold any protocol's payload and keep track of its size.
+ // Not intended for network transport. This struct is intended to help simplify code that works with variably sized payloads.
+ // The struct is 8 byte aligned because the internal payload field requires 8 byte alignment.
+ DD_ALIGNED_STRUCT(SizedPayloadContainer, 8)
+ {
+ uint32 payloadSize;
+ uint32 _padding;
+ char payload[kMaxPayloadSizeInBytes];
+
+ // For safety purposes we limit the CreatePayload and GetPayload methods to types that:
+ //
+ // 1. Have a standard layout, to ensure that the contents are safe to transmit across the network
+ // 2. Are trivially destructible, to ensure that a user doesn't construct an object and then overwrite it
+ // without destroying it
+ // 3. Small enough to fit inside the payload field of this struct
+ template
+ struct CanUseAsPayload
+ {
+ static_assert(Platform::IsStandardLayout::Value, "Type provided does not meet standard layout requirements");
+ static_assert(Platform::IsTriviallyDestructible::Value, "Type provided is not trivially destructible");
+ static_assert((sizeof(T) <= kMaxPayloadSizeInBytes), "Type provided is too large to fit in the container");
+
+ DD_STATIC_CONST bool Value = Platform::IsStandardLayout::Value &&
+ Platform::IsTriviallyDestructible::Value &&
+ (sizeof(T) <= kMaxPayloadSizeInBytes);
+ };
+
+ // We additionally only allow creation of a payload if the type is constructible using the arguments specified
+ template
+ struct CanCreatePayload
+ {
+ static_assert(CanUseAsPayload::Value, "Type specified cannot be used as a payload");
+ static_assert(Platform::IsConstructible::Value, "Type provided cannot be constructed with the provided arguments");
+
+ DD_STATIC_CONST bool Value = CanUseAsPayload::Value &&
+ Platform::IsConstructible::Value;
+ };
+
+ // Convenience function to allow in-place construction of a payload object using placement new.
+ template::Value>::Type>
+ void CreatePayload(Args&&... args)
+ {
+ // This is tremendously unsafe, but we use placement new to construct an object inside the buffer.
+ // Why do we do this? The big benefit is that it lets us skip having to create a temporary object
+ // and then copy it into this buffer.
+ //
+ // There are a couple of other ancillary benefits that are useful. The biggest is that if an object has
+ // a constexpr constructor it can initialize the memory using a memcpy/move instead of having to actually
+ // call the constructor. The other benefit is that if the constructor omits initializing memory (e.g.,
+ // a giant data buffer) it will also skip re-initializing the memory here. This is not the case with
+ // when you create another instance of the object and copy it - the temporary object is almost certainly
+ // zero initialized, and the copy/move will result in the entire struct being copied.
+
+ static_assert(alignof(T) <= alignof(SizedPayloadContainer), "Type provided cannot be aligned in the container");
+
+ new(reinterpret_cast(&payload[0])) T(Platform::Forward(args)...);
+ payloadSize = sizeof(T);
+ }
+
+ // Convenience function to allow accessing the payload as if it was the specified type.
+ template::Value>::Type>
+ T& GetPayload()
+ {
+ return *GetPayloadPointer(&payload[0]);
+ }
+
+ private:
+ // Convenience function to allow accessing the payload as if it was the specified type.
+ template::Value>::Type>
+ static constexpr T* GetPayloadPointer(char* DD_RESTRICT pPointer)
+ {
+ static_assert(alignof(T) <= alignof(SizedPayloadContainer), "Type provided cannot be aligned in the container");
+ return (T*)(pPointer);
+ }
+ };
+
+ DD_CHECK_SIZE(SizedPayloadContainer, 8 + kMaxPayloadSizeInBytes);
+
+ class IMsgChannel;
+ class Session;
+
+ enum struct SessionType
+ {
+ Unknown = 0,
+ Client,
+ Server
+ };
+
+ class ISession
+ {
+ public:
+ virtual ~ISession() {};
+
+ virtual Result Send(uint32 payloadSizeInBytes, const void* pPayload, uint32 timeoutInMs) = 0;
+ virtual Result Receive(uint32 payloadSizeInBytes, void *pPayload, uint32 *pBytesReceived, uint32 timeoutInMs) = 0;
+ virtual void Shutdown(Result reason) = 0;
+ virtual void Close(Result reason) = 0;
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_SESSION_INTERFACE_CLEANUP_VERSION)
+ virtual void CloseSession(Result reason = Result::Error) = 0;
+ virtual void OrphanSession() = 0;
+#endif
+
+ virtual void* SetUserData(void *) = 0;
+ virtual void* GetUserData() const = 0;
+ virtual SessionId GetSessionId() const = 0;
+ virtual ClientId GetDestinationClientId() const = 0;
+ virtual Version GetVersion() const = 0;
+
+ // Helper functions for working with SizedPayloadContainers and managing back-compat.
+ Result SendPayload(const SizedPayloadContainer& payload, uint32 timeoutInMs)
+ {
+ return Send(payload.payloadSize, payload.payload, timeoutInMs);
+ }
+
+ Result ReceivePayload(SizedPayloadContainer* pPayload, uint32 timeoutInMs)
+ {
+ DD_ASSERT(pPayload != nullptr);
+ return Receive(sizeof(pPayload->payload), pPayload->payload, &pPayload->payloadSize, timeoutInMs);
+ }
+
+ protected:
+ ISession() {}
+ };
+
+ class IProtocolSession
+ {
+ public:
+ virtual ~IProtocolSession() {}
+
+ virtual Protocol GetProtocol() const = 0;
+ virtual SessionType GetType() const = 0;
+ virtual Version GetMinVersion() const = 0;
+ virtual Version GetMaxVersion() const = 0;
+
+ virtual void SessionEstablished(const SharedPointer &pSession) = 0;
+ virtual void UpdateSession(const SharedPointer &pSession) = 0;
+ virtual void SessionTerminated(const SharedPointer &pSession, Result terminationReason) = 0;
+ protected:
+ IProtocolSession() {}
+ };
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpClient.h
new file mode 100644
index 000000000..bc643f7fb
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpClient.h
@@ -0,0 +1,69 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2017-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddGpuCrashDumpClient.h
+* @brief Class declaration for the gpu crash dump client
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolClient.h"
+#include "protocols/ddGpuCrashDumpProtocol.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ namespace TransferProtocol
+ {
+ class ServerBlock;
+ }
+
+ namespace GpuCrashDumpProtocol
+ {
+ class GpuCrashDumpClient : public BaseProtocolClient
+ {
+ public:
+ explicit GpuCrashDumpClient(IMsgChannel* pMsgChannel);
+ ~GpuCrashDumpClient();
+
+ // Begins the gpu crash dumping process. Sends a notification to the server and starts
+ // transferring crash data.
+ // Returns Success if the process starts successfully, Rejected if the server rejects
+ // the crash dump and Error otherwise.
+ Result BeginGpuCrashDump(const void* pCrashDump, size_t crashDumpSize);
+
+ // Ends the gpu crash dumping process. Waits for the crash dump transfer to finish.
+ // Returns Success if the transfer completes successfully, and Error otherwise.
+ Result EndGpuCrashDump();
+
+ private:
+ uint8* m_pCrashDump;
+ uint32 m_crashDumpSize;
+ uint32 m_crashDumpBytesSent;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpProtocol.h
new file mode 100644
index 000000000..d833bb706
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpProtocol.h
@@ -0,0 +1,123 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2017-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddGpuCrashDumpProtocol.h
+* @brief Header file for the gpu crash dump protocol
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "systemProtocols.h"
+
+#define GPUCRASHDUMP_PROTOCOL_MAJOR_VERSION 1
+#define GPUCRASHDUMP_PROTOCOL_MINOR_VERSION 0
+
+#define GPUCRASHDUMP_INTERFACE_VERSION ((GPUCRASHDUMP_INTERFACE_MAJOR_VERSION << 16) | GPUCRASHDUMP_INTERFACE_MINOR_VERSION)
+
+#define GPUCRASHDUMP_PROTOCOL_MINIMUM_MAJOR_VERSION 1
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 1.0 | Initial version |
+***********************************************************************************************************************
+*/
+
+#define GPUCRASHDUMP_INITIAL_VERSION 1
+
+namespace DevDriver
+{
+ namespace GpuCrashDumpProtocol
+ {
+ ///////////////////////
+ // GpuCrashDump Protocol
+ enum struct GpuCrashDumpMessage : MessageCode
+ {
+ Unknown = 0,
+ GpuCrashNotify,
+ GpuCrashAcknowledge,
+ GpuCrashDataChunk,
+ GpuCrashDataSentinel,
+ Count
+ };
+
+ ///////////////////////
+ // GpuCrashDump Constants
+ // @note: We currently subtract sizeof(uint32) instead of sizeof(GpuCrashDumpMessage) to work around struct packing issues.
+ // The compiler pads out GpuCrashDumpMessage to 4 bytes when it's included in the payload struct.
+ DD_STATIC_CONST Size kMaxGpuCrashDumpDataChunkSize = (kMaxPayloadSizeInBytes - sizeof(uint32));
+
+ ///////////////////////
+ // GpuCrashDump Payloads
+ DD_NETWORK_STRUCT(GpuCrashNotifyPayload, 4)
+ {
+ uint32 sizeInBytes;
+ };
+
+ DD_CHECK_SIZE(GpuCrashNotifyPayload, 4);
+
+ DD_NETWORK_STRUCT(GpuCrashAcknowledgePayload, 4)
+ {
+ bool acceptedCrashDump;
+ char padding[3];
+ };
+
+ DD_CHECK_SIZE(GpuCrashAcknowledgePayload, 4);
+
+ DD_NETWORK_STRUCT(GpuCrashDataChunkPayload, 4)
+ {
+ uint8 data[kMaxGpuCrashDumpDataChunkSize];
+ };
+
+ DD_CHECK_SIZE(GpuCrashDataChunkPayload, kMaxGpuCrashDumpDataChunkSize);
+
+ DD_NETWORK_STRUCT(GpuCrashDataSentinelPayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(GpuCrashDataSentinelPayload, 4);
+
+ DD_NETWORK_STRUCT(GpuCrashDumpPayload, 4)
+ {
+ GpuCrashDumpMessage command;
+ // pad out to 4 bytes for alignment requirements
+ char padding[3];
+
+ union
+ {
+ GpuCrashNotifyPayload notify;
+ GpuCrashAcknowledgePayload acknowledge;
+ GpuCrashDataChunkPayload dataChunk;
+ GpuCrashDataSentinelPayload sentinel;
+ };
+ };
+
+ DD_CHECK_SIZE(GpuCrashDumpPayload, kMaxPayloadSizeInBytes);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpServer.h
new file mode 100644
index 000000000..50927ea9a
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddGpuCrashDumpServer.h
@@ -0,0 +1,85 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2017-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddGpuCrashDumpServer.h
+* @brief Class declaration for GpuCrashDumpServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolServer.h"
+#include "ddGpuCrashDumpProtocol.h"
+#include "util/vector.h"
+#include "util/sharedptr.h"
+
+namespace DevDriver
+{
+ namespace GpuCrashDumpProtocol
+ {
+ // Abstract interface for handling crash notifications
+ class ICrashDumpHandler
+ {
+ public:
+ virtual ~ICrashDumpHandler() {}
+
+ // Accepts or rejects a crash dump notification from an external client.
+ virtual bool AcceptCrashDump(size_t crashDumpSizeInBytes, ClientId clientId, void** ppUserdata) = 0;
+
+ // Handles incoming crash dump data. Returns false if we should abort the transfer.
+ virtual void ReceiveCrashDumpData(const uint8* pCrashDumpData, size_t crashDumpDataSize, void* pUserdata) = 0;
+
+ // Performs any work that should be done at the end of the transfer.
+ virtual void FinishCrashDumpTransfer(bool transferSuccessful, void* pUserdata) = 0;
+
+ protected:
+ ICrashDumpHandler() {}
+ };
+
+ class GpuCrashDumpServer : public BaseProtocolServer
+ {
+ public:
+ explicit GpuCrashDumpServer(IMsgChannel* pMsgChannel);
+ ~GpuCrashDumpServer();
+
+ bool AcceptSession(const SharedPointer& pSession) override;
+ void SessionEstablished(const SharedPointer& pSession) override;
+ void UpdateSession(const SharedPointer& pSession) override;
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+
+ // Sets the current crash dump handler.
+ // Returns Error if the crash handler cannot currently be changed due to active sessions.
+ Result SetCrashDumpHandler(ICrashDumpHandler* pHandler);
+
+ // Gets the current crash dump handler.
+ ICrashDumpHandler* GetCrashDumpHandler();
+
+ private:
+ Platform::Mutex m_mutex;
+ ICrashDumpHandler* m_pCrashDumpHandler;
+ uint32 m_numSessions;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferClient.h
new file mode 100644
index 000000000..841328295
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferClient.h
@@ -0,0 +1,126 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddTransferClient.h
+* @brief Class declaration for TransferClient.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolClient.h"
+#include "protocols/ddTransferProtocol.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ namespace TransferProtocol
+ {
+ class TransferClient final : public BaseProtocolClient
+ {
+ public:
+ explicit TransferClient(IMsgChannel* pMsgChannel);
+ ~TransferClient();
+
+ // Requests a transfer on the remote client. Returns Success if the request was successful and data
+ // is being sent to the client. Returns the size in bytes of the data being transferred in
+ // pTransferSizeInBytes.
+ Result RequestPullTransfer(BlockId blockId, size_t* pTransferSizeInBytes);
+
+ // Reads transfer data from a previous transfer that completed successfully.
+ Result ReadPullTransferData(uint8* pDstBuffer, size_t bufferSize, size_t* pBytesRead);
+
+ // Aborts a pull transfer in progress.
+ Result AbortPullTransfer();
+
+ // Requests a transfer on the remote client. Returns Success if the request was successful and data
+ // can be written to the server.
+ Result RequestPushTransfer(BlockId blockId, size_t transferSizeInBytes);
+
+ // Writes transfer data to the remote server.
+ Result WritePushTransferData(const uint8* pSrcBuffer, size_t bufferSize);
+
+ // Closes the push transfer session, optionally discarding any data already transmitted
+ Result ClosePushTransfer(bool discard = false);
+
+ // Returns true if there's currently a transfer in progress.
+ bool IsTransferInProgress() const
+ {
+ return IsConnected() && (m_transferContext.state == TransferState::TransferInProgress);
+ }
+
+ // Backwards compatibility
+ Result RequestTransfer(BlockId blockId, size_t* pTransferSizeInBytes)
+ {
+ return RequestPullTransfer(blockId, pTransferSizeInBytes);
+ }
+
+ Result ReadTransferData(uint8* pDstBuffer, size_t bufferSize, size_t* pBytesRead)
+ {
+ return ReadPullTransferData(pDstBuffer, bufferSize, pBytesRead);
+ }
+
+ private:
+ void ResetState() override;
+
+ // Helper method to send a payload, handling backwards compatibility and retrying.
+ Result SendTransferPayload(const SizedPayloadContainer& container,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs);
+ // Helper method to handle sending a payload from a SizedPayloadContainer, including retrying if busy.
+ Result ReceiveTransferPayload(SizedPayloadContainer* pContainer,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs);
+ // Helper method to send and then receive using a SizedPayloadContainer object.
+ Result TransactTransferPayload(SizedPayloadContainer* pContainer,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs);
+
+ enum class TransferState : uint32
+ {
+ Idle = 0,
+ TransferInProgress,
+ Error
+ };
+
+ // Context structure for tracking all state specific to a transfer.
+ struct ClientTransferContext
+ {
+ TransferState state;
+ TransferType type;
+ uint32 totalBytes;
+ uint32 crc32;
+ size_t dataChunkSizeInBytes;
+ size_t dataChunkBytesTransfered;
+ SizedPayloadContainer scratchPayload;
+ };
+
+ ClientTransferContext m_transferContext;
+
+ DD_STATIC_CONST uint32 kTransferChunkTimeoutInMs = 3000;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferProtocol.h
new file mode 100644
index 000000000..d18301990
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferProtocol.h
@@ -0,0 +1,205 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddTransferProtocol.h
+* @brief Protocol header for the block transfer protocol.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "protocolSession.h"
+#include
+
+/*
+***********************************************************************************************************************
+* Transfer Protocol
+***********************************************************************************************************************
+*/
+
+#define TRANSFER_PROTOCOL_MAJOR_VERSION 2
+#define TRANSFER_PROTOCOL_MINOR_VERSION 0
+
+#define TRANSFER_INTERFACE_VERSION ((TRANSFER_INTERFACE_MAJOR_VERSION << 16) | TRANSFER_INTERFACE_MINOR_VERSION)
+
+#define TRANSFER_PROTOCOL_MINIMUM_MAJOR_VERSION 1
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 2.0 | Refactor for variably sized messages + push transfers |
+*| 1.0 | Initial version |
+***********************************************************************************************************************
+*/
+
+#define TRANSFER_REFACTOR_VERSION 2
+#define TRANSFER_INITIAL_VERSION 1
+
+namespace DevDriver
+{
+ namespace TransferProtocol
+ {
+ ///////////////////////
+ // GPU Open Transfer Protocol
+ enum struct TransferMessage : uint32
+ {
+ Unknown = 0,
+ TransferRequest,
+ TransferDataHeader,
+ TransferDataChunk,
+ TransferDataSentinel,
+ TransferStatus,
+ Count,
+ };
+
+ enum struct TransferType : uint32
+ {
+ Pull = 0,
+ Push,
+ Count,
+ };
+
+ // @note: We currently subtract sizeof(uint32) instead of sizeof(TransferMessage) to work around struct packing issues.
+ // The compiler pads out TransferMessage to 4 bytes when it's included in the payload struct.
+ DD_STATIC_CONST size_t kMaxTransferDataChunkSize = (kMaxPayloadSizeInBytes - sizeof(uint32));
+
+ ///////////////////////
+ // Transfer Types
+ typedef uint32 BlockId;
+ DD_STATIC_CONST BlockId kInvalidBlockId = 0;
+
+ ///////////////////////
+ // Transfer Payloads
+
+ DD_NETWORK_STRUCT(TransferHeader, 4)
+ {
+ TransferMessage command;
+ constexpr TransferHeader(TransferMessage message = TransferMessage::Unknown)
+ : command(message)
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(TransferHeader, 4);
+
+ DD_NETWORK_STRUCT(TransferRequest, 4)
+ {
+ TransferMessage command;
+ BlockId blockId;
+ TransferType type;
+ uint32 sizeInBytes;
+
+ constexpr TransferRequest(BlockId blockId, TransferType type, uint32 size)
+ : command(TransferMessage::TransferRequest)
+ , blockId(blockId)
+ , type(type)
+ , sizeInBytes(size)
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(TransferRequest, 16);
+
+ DD_NETWORK_STRUCT(TransferDataHeader, 4)
+ {
+ TransferMessage command;
+ Result result;
+ uint32 sizeInBytes;
+
+ constexpr TransferDataHeader(Result result, uint32 size)
+ : command(TransferMessage::TransferDataHeader)
+ , result(result)
+ , sizeInBytes(size)
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(TransferDataHeader, 12);
+
+ DD_NETWORK_STRUCT(TransferDataHeaderV2, 4)
+ {
+ TransferMessage command;
+ uint32 sizeInBytes;
+
+ constexpr TransferDataHeaderV2(uint32 size)
+ : command(TransferMessage::TransferDataHeader)
+ , sizeInBytes(size)
+ {}
+ };
+
+ DD_CHECK_SIZE(TransferDataHeaderV2, 8);
+
+ DD_NETWORK_STRUCT(TransferDataChunk, 4)
+ {
+ TransferMessage command;
+ uint8 data[kMaxTransferDataChunkSize];
+
+ static void WritePayload(
+ const void *pData,
+ size_t bytesToSend,
+ SizedPayloadContainer* pContainer)
+ {
+ pContainer->payloadSize = static_cast(bytesToSend + offsetof(TransferDataChunk, data));
+ DD_ASSERT(pContainer->payloadSize <= kMaxPayloadSizeInBytes);
+ TransferDataChunk& payload = pContainer->GetPayload();
+ payload.command = TransferMessage::TransferDataChunk;
+ memcpy(&payload.data[0], pData, bytesToSend);
+ }
+ };
+
+ DD_CHECK_SIZE(TransferDataChunk, kMaxPayloadSizeInBytes);
+
+ DD_NETWORK_STRUCT(TransferDataSentinel, 4)
+ {
+ TransferMessage command;
+ Result result;
+ uint32 crc32;
+
+ constexpr TransferDataSentinel(Result result, uint32 crc32)
+ : command(TransferMessage::TransferDataSentinel)
+ , result(result)
+ , crc32(crc32)
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(TransferDataSentinel, 12);
+
+ DD_NETWORK_STRUCT(TransferStatus, 4)
+ {
+ TransferMessage command;
+ Result result;
+
+ constexpr TransferStatus(Result result)
+ : command(TransferMessage::TransferStatus)
+ , result(result)
+ {}
+ };
+
+ DD_CHECK_SIZE(TransferStatus, 8);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferServer.h
new file mode 100644
index 000000000..1113bbf52
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddTransferServer.h
@@ -0,0 +1,61 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddTransferServer.h
+* @brief Class declaration for TransferServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolServer.h"
+#include "protocols/ddTransferProtocol.h"
+
+namespace DevDriver
+{
+ namespace TransferProtocol
+ {
+ class TransferManager;
+
+ // The protocol server implementation for the transfer protocol.
+ class TransferServer final : public BaseProtocolServer
+ {
+ public:
+ explicit TransferServer(IMsgChannel* pMsgChannel, TransferManager* pTransferManager);
+ ~TransferServer();
+
+ void Finalize() override;
+
+ bool AcceptSession(const SharedPointer& pSession) override;
+ void SessionEstablished(const SharedPointer& pSession) override;
+ void UpdateSession(const SharedPointer& pSession) override;
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+ private:
+ TransferManager* m_pTransferManager;
+
+ class TransferSession;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIClient.h
new file mode 100644
index 000000000..a9e25bdf7
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIClient.h
@@ -0,0 +1,90 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddURIClient.h
+* @brief Class declaration for URIClient.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolClient.h"
+#include "ddUriInterface.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ namespace TransferProtocol
+ {
+ class PullBlock;
+ }
+
+ namespace URIProtocol
+ {
+ // We alias these types for backwards compatibility
+ using ResponseHeader = DevDriver::URIResponseHeader;
+
+ class URIClient final : public BaseProtocolClient
+ {
+ public:
+ explicit URIClient(IMsgChannel* pMsgChannel);
+ ~URIClient();
+
+ // Sends a URI request to the connected server.
+ Result RequestURI(const char* pRequestString, ResponseHeader* pResponseHeader = nullptr);
+
+#if !DD_VERSION_SUPPORTS(GPUOPEN_URI_RESPONSE_FORMATS_VERSION)
+ // Sends a URI request to the connected server.
+ // Deprecated
+ Result RequestURI(const char* pRequestString, size_t* pResponseSizeInBytes);
+#endif
+
+ // Reads response data that was returned by a prior request.
+ Result ReadResponse(uint8* pDstBuffer, size_t bufferSize, size_t* pBytesRead);
+
+ // Aborts the currently active request.
+ Result AbortRequest();
+
+ private:
+ void ResetState() override;
+
+ enum class State : uint32
+ {
+ Idle = 0,
+ ReadResponse
+ };
+
+ // Context structure for tracking all state specific to a request.
+ struct Context
+ {
+ State state;
+ TransferProtocol::PullBlock* pBlock;
+ };
+
+ Context m_context;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIProtocol.h
new file mode 100644
index 000000000..ba75a79e4
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIProtocol.h
@@ -0,0 +1,122 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddURIProtocol.h
+* @brief Protocol header for the URI protocol.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "ddTransferProtocol.h"
+
+/*
+***********************************************************************************************************************
+* URI Protocol
+***********************************************************************************************************************
+*/
+
+#define URI_PROTOCOL_MAJOR_VERSION 2
+#define URI_PROTOCOL_MINOR_VERSION 0
+
+#define URI_INTERFACE_VERSION ((URI_INTERFACE_MAJOR_VERSION << 16) | URI_INTERFACE_MINOR_VERSION)
+
+#define URI_PROTOCOL_MINIMUM_MAJOR_VERSION 1
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 2.0 | Added support for response data formats. |
+*| 1.0 | Initial version |
+***********************************************************************************************************************
+*/
+
+#define URI_RESPONSE_FORMATS_VERSION 2
+#define URI_INITIAL_VERSION 1
+
+namespace DevDriver
+{
+ namespace URIProtocol
+ {
+ ///////////////////////
+ // GPU Open URI Protocol
+ enum struct URIMessage : MessageCode
+ {
+ Unknown = 0,
+ URIRequest,
+ URIResponse,
+ Count,
+ };
+
+ ///////////////////////
+ // URI Types
+ enum struct ResponseDataFormat : uint32
+ {
+ Unknown = 0,
+ Text,
+ Binary,
+ Count
+ };
+
+ ///////////////////////
+ // URI Constants
+ DD_STATIC_CONST uint32 kURIStringSize = 256;
+
+ ///////////////////////
+ // URI Payloads
+
+ DD_NETWORK_STRUCT(URIRequestPayload, 4)
+ {
+ char uriString[kURIStringSize];
+ };
+
+ DD_CHECK_SIZE(URIRequestPayload, kURIStringSize);
+
+ DD_NETWORK_STRUCT(URIResponsePayload, 4)
+ {
+ Result result;
+ TransferProtocol::BlockId blockId;
+ ResponseDataFormat format; // format is only valid in v2 sessions or higher.
+ };
+
+ DD_CHECK_SIZE(URIResponsePayload, 12);
+
+ DD_NETWORK_STRUCT(URIPayload, 4)
+ {
+ URIMessage command;
+ // pad out to 4 bytes for alignment requirements
+ char padding[3];
+ union
+ {
+ URIRequestPayload uriRequest;
+ URIResponsePayload uriResponse;
+ };
+ };
+
+ DD_CHECK_SIZE(URIPayload, 260);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIService.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIService.h
new file mode 100644
index 000000000..ac669f5fa
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/ddURIService.h
@@ -0,0 +1,69 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file ddURIService.h
+* @brief Class declaration for URIService.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+#include "ddPlatform.h"
+#include "ddUriInterface.h"
+#include "util/sharedptr.h"
+#include "ddTransferManager.h"
+
+namespace DevDriver
+{
+ namespace URIProtocol
+ {
+ // We alias these types for backwards compatibility
+ using URIRequestContext = DevDriver::URIRequestContext;
+ using ResponseDataFormat = DevDriver::URIDataFormat;
+
+ // Base class for URI services
+ class URIService : public IService
+ {
+ public:
+ virtual ~URIService() {}
+
+ // Returns the name of the service
+ const char* GetName() const override final { return m_name; }
+
+ protected:
+ URIService(const char* pName)
+ {
+ // Copy the service name into a member variable for later use.
+ Platform::Strncpy(m_name, pName, sizeof(m_name));
+ }
+
+ DD_STATIC_CONST uint32 kServiceNameSize = 64;
+
+ // The name of the service
+ char m_name[kServiceNameSize];
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlClient.h
new file mode 100644
index 000000000..469025faf
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlClient.h
@@ -0,0 +1,80 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file driverControlClient.h
+* @brief Developer Driver Control Client Interface
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolClient.h"
+#include "protocols/driverControlProtocol.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ namespace DriverControlProtocol
+ {
+ class DriverControlClient : public BaseProtocolClient
+ {
+ public:
+ explicit DriverControlClient(IMsgChannel* pMsgChannel);
+ ~DriverControlClient();
+
+ // Pauses execution inside the driver
+ Result PauseDriver();
+
+ // Resumes execution inside the driver
+ Result ResumeDriver();
+
+ Result StepDriver(uint32 numSteps);
+
+ // Returns the number of gpus the driver is managing.
+ Result QueryNumGpus(uint32* pNumGpus);
+
+ // Returns the current device clock mode
+ Result QueryDeviceClockMode(uint32 gpuIndex, DeviceClockMode* pClockMode);
+
+ // Sets the current device clock mode
+ Result SetDeviceClockMode(uint32 gpuIndex, DeviceClockMode clockMode);
+
+ // Returns the current device clock values in MHz
+ Result QueryDeviceClock(uint32 gpuIndex, float* pGpuClock, float* pMemClock);
+
+ // Returns the max device clock values in MHz
+ Result QueryMaxDeviceClock(uint32 gpuIndex, float* pMaxGpuClock, float* pMaxMemClock);
+
+ // Returns the current status of the driver.
+ Result QueryDriverStatus(DriverStatus* pDriverStatus);
+
+ // Waits until the driver finishes initialization.
+ Result WaitForDriverInitialization(uint32 timeoutInMs);
+
+ private:
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlProtocol.h
new file mode 100644
index 000000000..e0e75f48a
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlProtocol.h
@@ -0,0 +1,235 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2018 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.
+ ******************************************************************************/
+
+#pragma once
+
+#include "gpuopen.h"
+
+#define DRIVERCONTROL_PROTOCOL_MAJOR_VERSION 2
+#define DRIVERCONTROL_PROTOCOL_MINOR_VERSION 0
+
+#define DRIVERCONTROL_INTERFACE_VERSION ((DRIVERCONTROL_INTERFACE_MAJOR_VERSION << 16) | DRIVERCONTROL_INTERFACE_MINOR_VERSION)
+
+#define DRIVERCONTROL_PROTOCOL_MINIMUM_MAJOR_VERSION 1
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 2.0 | Added initialization time driver status values and a terminate driver command. |
+*| 1.0 | Initial version |
+***********************************************************************************************************************
+*/
+
+#define DRIVERCONTROL_INITIALIZATION_STATUS_VERSION 2
+#define DRIVERCONTROL_INITIAL_VERSION 1
+
+namespace DevDriver
+{
+ namespace DriverControlProtocol
+ {
+ ///////////////////////
+ // DriverControl Protocol
+ enum struct DriverControlMessage : MessageCode
+ {
+ Unknown = 0,
+ PauseDriverRequest,
+ PauseDriverResponse,
+ ResumeDriverRequest,
+ ResumeDriverResponse,
+ QueryNumGpusRequest,
+ QueryNumGpusResponse,
+ QueryDeviceClockModeRequest,
+ QueryDeviceClockModeResponse,
+ SetDeviceClockModeRequest,
+ SetDeviceClockModeResponse,
+ QueryDeviceClockRequest,
+ QueryDeviceClockResponse,
+ QueryMaxDeviceClockRequest,
+ QueryMaxDeviceClockResponse,
+ QueryDriverStatusRequest,
+ QueryDriverStatusResponse,
+ StepDriverRequest,
+ StepDriverResponse,
+ Count
+ };
+
+ ///////////////////////
+ // DriverControl Types
+ enum struct DeviceClockMode : uint32
+ {
+ Unknown = 0,
+ Default,
+ Profiling,
+ MinimumMemory,
+ MinimumEngine,
+ Peak,
+ Count
+ };
+
+ enum struct DriverStatus : uint32
+ {
+ Running = 0,
+ Paused,
+ HaltedOnStart,
+ EarlyInit,
+ LateInit,
+ Count
+ };
+
+ ///////////////////////
+ // DriverControl Payloads
+ DD_NETWORK_STRUCT(PauseDriverResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(PauseDriverResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(ResumeDriverResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(ResumeDriverResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QueryNumGpusResponsePayload, 4)
+ {
+ Result result;
+ uint32 numGpus;
+ };
+
+ DD_CHECK_SIZE(QueryNumGpusResponsePayload, 8);
+
+ DD_NETWORK_STRUCT(QueryDeviceClockModeRequestPayload, 4)
+ {
+ uint32 gpuIndex;
+ };
+
+ DD_CHECK_SIZE(QueryDeviceClockModeRequestPayload, 4);
+
+ DD_NETWORK_STRUCT(QueryDeviceClockModeResponsePayload, 4)
+ {
+ Result result;
+ DeviceClockMode mode;
+ };
+
+ DD_CHECK_SIZE(QueryDeviceClockModeResponsePayload, 8);
+
+ DD_NETWORK_STRUCT(SetDeviceClockModeRequestPayload, 4)
+ {
+ uint32 gpuIndex;
+ DeviceClockMode mode;
+ };
+
+ DD_CHECK_SIZE(SetDeviceClockModeRequestPayload, 8);
+
+ DD_NETWORK_STRUCT(SetDeviceClockModeResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(SetDeviceClockModeResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QueryDeviceClockRequestPayload, 4)
+ {
+ uint32 gpuIndex;
+ };
+
+ DD_CHECK_SIZE(QueryDeviceClockRequestPayload, 4);
+
+ DD_NETWORK_STRUCT(QueryDeviceClockResponsePayload, 4)
+ {
+ Result result;
+ float gpuClock;
+ float memClock;
+ };
+
+ DD_CHECK_SIZE(QueryDeviceClockResponsePayload, 12);
+
+ DD_NETWORK_STRUCT(QueryMaxDeviceClockRequestPayload, 4)
+ {
+ uint32 gpuIndex;
+ };
+
+ DD_CHECK_SIZE(QueryMaxDeviceClockRequestPayload, 4);
+
+ DD_NETWORK_STRUCT(QueryMaxDeviceClockResponsePayload, 4)
+ {
+ Result result;
+ float maxGpuClock;
+ float maxMemClock;
+ };
+
+ DD_CHECK_SIZE(QueryMaxDeviceClockResponsePayload, 12);
+
+ DD_NETWORK_STRUCT(QueryDriverStatusResponsePayload, 4)
+ {
+ DriverStatus status;
+ };
+
+ DD_CHECK_SIZE(QueryDriverStatusResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(StepDriverRequestPayload, 4)
+ {
+ uint32 count;
+ };
+
+ DD_CHECK_SIZE(StepDriverRequestPayload, 4);
+
+ DD_NETWORK_STRUCT(StepDriverResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(StepDriverResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(DriverControlPayload, 4)
+ {
+ DriverControlMessage command;
+ // pad out to 4 bytes for alignment requirements
+ char padding[3];
+
+ union
+ {
+ PauseDriverResponsePayload pauseDriverResponse;
+ ResumeDriverResponsePayload resumeDriverResponse;
+ QueryNumGpusResponsePayload queryNumGpusResponse;
+ QueryDeviceClockModeRequestPayload queryDeviceClockModeRequest;
+ QueryDeviceClockModeResponsePayload queryDeviceClockModeResponse;
+ SetDeviceClockModeRequestPayload setDeviceClockModeRequest;
+ SetDeviceClockModeResponsePayload setDeviceClockModeResponse;
+ QueryDeviceClockRequestPayload queryDeviceClockRequest;
+ QueryDeviceClockResponsePayload queryDeviceClockResponse;
+ QueryMaxDeviceClockResponsePayload queryMaxDeviceClockResponse;
+ QueryMaxDeviceClockRequestPayload queryMaxDeviceClockRequest;
+ QueryDriverStatusResponsePayload queryDriverStatusResponse;
+ StepDriverRequestPayload stepDriverRequest;
+ StepDriverResponsePayload stepDriverResponse;
+ };
+ };
+
+ DD_CHECK_SIZE(DriverControlPayload, 16);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlServer.h
new file mode 100644
index 000000000..1188ee218
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/driverControlServer.h
@@ -0,0 +1,101 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file driverControlServer.h
+* @brief Class declaration for DriverControlServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolServer.h"
+#include "driverControlProtocol.h"
+
+namespace DevDriver
+{
+ namespace DriverControlProtocol
+ {
+ DD_STATIC_CONST uint32 kMaxNumGpus = 16;
+
+ typedef Result(*QueryDeviceClockCallback)(uint32 gpuIndex, float* pGpuClock, float* pMemClock, void* pUserdata);
+ typedef Result(*QueryMaxDeviceClockCallback)(uint32 gpuIndex, float* pMaxGpuClock, float* pMaxMemClock, void* pUserdata);
+ typedef Result(*SetDeviceClockModeCallback)(uint32 gpuIndex, DeviceClockMode clockMode, void* pUserdata);
+
+ struct DeviceClockCallbackInfo
+ {
+ QueryDeviceClockCallback queryClockCallback;
+ QueryMaxDeviceClockCallback queryMaxClockCallback;
+ SetDeviceClockModeCallback setCallback;
+ void* pUserdata;
+ };
+
+ class DriverControlServer : public BaseProtocolServer
+ {
+ public:
+ explicit DriverControlServer(IMsgChannel* pMsgChannel);
+ ~DriverControlServer();
+
+ void Finalize() override;
+
+ bool AcceptSession(const SharedPointer& pSession) override;
+ void SessionEstablished(const SharedPointer& pSession) override;
+ void UpdateSession(const SharedPointer& pSession) override;
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+
+ void WaitForDriverResume();
+
+ bool IsDriverInitialized() const;
+ void FinishDriverInitialization();
+
+ DriverStatus QueryDriverStatus();
+
+ void PauseDriver();
+ void ResumeDriver();
+
+ void SetNumGpus(uint32 numGpus);
+ void SetDeviceClockCallback(const DeviceClockCallbackInfo& deviceClockCallbackInfo);
+
+ uint32 GetNumGpus();
+ DeviceClockMode GetDeviceClockMode(uint32 gpuIndex);
+
+ private:
+ void LockData();
+ void UnlockData();
+ void WaitForDriverStart(uint64 timeoutInMs);
+
+ Platform::Mutex m_mutex;
+ DriverStatus m_driverStatus;
+ Platform::Event m_driverResumedEvent;
+
+ uint32 m_numGpus;
+ DeviceClockMode m_deviceClockModes[kMaxNumGpus];
+ DeviceClockCallbackInfo m_deviceClockCallbackInfo;
+ Platform::Atomic m_numSessions;
+ Platform::Atomic m_stepCounter;
+
+ DD_STATIC_CONST uint32 kBroadcastIntervalInMs = 100;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwClient.h
new file mode 100644
index 000000000..46692689d
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwClient.h
@@ -0,0 +1,63 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file etwClient.h
+* @brief Class declaration for ETWClient.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolClient.h"
+#include "protocols/etwProtocol.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ namespace ETWProtocol
+ {
+ enum class SessionState
+ {
+ Idle = 0,
+ Tracing,
+ Waiting,
+ Receiving,
+ };
+
+ class ETWClient : public BaseProtocolClient
+ {
+ public:
+ explicit ETWClient(IMsgChannel* pMsgChannel);
+ ~ETWClient();
+ Result EnableTracing(ProcessId processId);
+ Result DisableTracing(size_t *pNumEvents);
+ Result GetTraceData(GpuEvent *buffer, size_t numEvents);
+ private:
+ SessionState m_sessionState;
+ };
+
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwProtocol.h
new file mode 100644
index 000000000..bbe0c290d
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwProtocol.h
@@ -0,0 +1,175 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file etwProtcol.h
+* @brief Common interface for ETW Protocol.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+
+namespace DevDriver
+{
+ enum struct GpuEventType : uint16
+ {
+ Unknown = 0,
+ QueueSignal,
+ QueueWait,
+ Count
+ };
+
+ DD_NETWORK_STRUCT(GpuEvent, 8)
+ {
+ uint64 submissionTime;
+ uint64 completionTime;
+ GpuEventType type;
+ uint8 reserved[6];
+ union
+ {
+ struct
+ {
+ uint64 contextIdentifier;
+ uint64 fenceObject;
+ uint64 fenceValue;
+ } queue;
+ };
+ };
+
+ DD_CHECK_SIZE(GpuEvent, 48);
+
+ namespace ETWProtocol
+ {
+ ///////////////////////
+ // ETW Protocol
+ enum struct ETWMessage : MessageCode
+ {
+ Unknown = 0,
+ BeginTrace,
+ BeginResponse,
+ EndTrace,
+ EndResponse,
+ TraceDataChunk,
+ TraceDataSentinel,
+ Count
+ };
+
+ ///////////////////////
+ // ETW Constants
+ DD_STATIC_CONST Version kVersion = 3;
+
+ // @note: We currently subtract sizeof(uint32) instead of sizeof(ETWMessage) to work around struct packing issues.
+ // The compiler pads out ETWMessage to 4 bytes when it's included in the payload struct. It also pads out
+ // the TraceDataChunk data field to 1000 bytes. This causes the total payload size to be 1004 bytes which is
+ // 4 bytes larger than the maximum size allowed.
+ static const Size kMaxTraceDataChunkSize = (kMaxPayloadSizeInBytes - sizeof(uint32) - sizeof(uint32));
+
+ ///////////////////////
+ // ETW Types
+ DD_NETWORK_STRUCT(StartTraceRequestPayload, 4)
+ {
+ ProcessId processId;
+ };
+
+ DD_CHECK_SIZE(StartTraceRequestPayload, 4);
+
+ DD_NETWORK_STRUCT(StartTraceResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(StartTraceResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(StopTraceRequestPayload, 4)
+ {
+ uint8 discard;
+ uint8 reserved[3];
+ };
+
+ DD_CHECK_SIZE(StopTraceRequestPayload, 4);
+
+ DD_NETWORK_STRUCT(StopTraceResponsePayload, 4)
+ {
+ Result result;
+ uint32 numEventsCaptured;
+ };
+
+ DD_CHECK_SIZE(StopTraceResponsePayload, 8);
+
+ DD_NETWORK_STRUCT(TraceDataChunk, 4)
+ {
+ uint32 dataSize;
+ uint8 data[kMaxTraceDataChunkSize];
+ };
+
+ DD_STATIC_CONST uint32 kTraceChunkAlignmentSize = 8;
+ DD_STATIC_CONST uint32 kMaxEventsPerChunk = (kMaxPayloadSizeInBytes - kTraceChunkAlignmentSize * 2)/sizeof(GpuEvent);
+
+ DD_NETWORK_STRUCT(TraceDataChunkPayload, kTraceChunkAlignmentSize)
+ {
+ uint16 numEvents;
+ uint8 reserved[kTraceChunkAlignmentSize - sizeof(uint16)];
+ GpuEvent events[kMaxEventsPerChunk];
+ };
+
+ DD_CHECK_SIZE(TraceDataChunkPayload, (sizeof(GpuEvent) * kMaxEventsPerChunk) + offsetof(TraceDataChunkPayload, events));
+
+ DD_NETWORK_STRUCT(TraceDataSentinelPayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(TraceDataSentinelPayload, 4);
+
+ enum struct ProfilingStatus : uint32
+ {
+ NotAvailable = 0,
+ Available,
+ Enabled,
+ Count
+ };
+
+ ///////////////////////
+ // ETW Payloads
+ DD_NETWORK_STRUCT(ETWPayload, 8)
+ {
+ ETWMessage command;
+ // pad out to 4 bytes for alignment requirements
+ char padding[7];
+ union
+ {
+ StartTraceRequestPayload startTrace;
+ StartTraceResponsePayload startTraceResponse;
+ StopTraceRequestPayload stopTrace;
+ StopTraceResponsePayload stopTraceResponse;
+ TraceDataChunkPayload traceDataChunk;
+ TraceDataSentinelPayload traceDataSentinel;
+ };
+ };
+
+ DD_CHECK_SIZE(ETWPayload, 1360);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwServer.h
new file mode 100644
index 000000000..feb783aaa
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/etwServer.h
@@ -0,0 +1,54 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file etwServer.h
+* @brief Class declaration for ETWServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolServer.h"
+#include "etwProtocol.h"
+
+namespace DevDriver
+{
+ namespace ETWProtocol
+ {
+ class ETWServer : public BaseProtocolServer
+ {
+ public:
+ explicit ETWServer(IMsgChannel* pMsgChannel);
+ ~ETWServer();
+
+ void Finalize() override;
+ bool AcceptSession(const SharedPointer& pSession) override;
+ void SessionEstablished(const SharedPointer& pSession) override;
+ void UpdateSession(const SharedPointer& pSession) override;
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+ private:
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingClient.h
new file mode 100644
index 000000000..648121f86
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingClient.h
@@ -0,0 +1,94 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2018 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.
+ ******************************************************************************/
+
+#pragma once
+
+#include "baseProtocolClient.h"
+#include "loggingProtocol.h"
+#include "util/queue.h"
+#include "util/vector.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ namespace LoggingProtocol
+ {
+ enum class LoggingClientState : uint32
+ {
+ Idle = 0,
+ Logging,
+ LoggingFinished
+ };
+
+ class LoggingClient : public BaseProtocolClient
+ {
+ public:
+ explicit LoggingClient(IMsgChannel* pMsgChannel);
+ ~LoggingClient();
+
+ // Overrides the base client's update session functionality
+ void UpdateSession(const SharedPointer& pSession) override final;
+
+ // Overrides the base client's session termination callback to ensure state gets reset
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override final;
+
+ // Sends an enable logging message to the UMD
+ Result EnableLogging(LogLevel priority, LoggingCategory categoryMask);
+
+ // Sends a disable logging message to the UMD
+ Result DisableLogging();
+
+ // Queries available categories and populates the provided vector
+ Result QueryCategories(Vector &categories);
+
+ // Reads the log messages stored on the remote server into the provided vector
+ Result ReadLogMessages(Vector &logMessages);
+
+ // Returns true if the client currently contains log messages that have not been received.
+ bool HasLogMessages();
+
+ private:
+ void ResetState() override;
+
+ bool IsIdle() const;
+ bool IsLogging() const;
+
+ Result SendLoggingPayload(const SizedPayloadContainer& container,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs);
+ Result ReceiveLoggingPayload(SizedPayloadContainer* pContainer,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs);
+ Result TransactLoggingPayload(SizedPayloadContainer* pContainer,
+ uint32 timeoutInMs = kDefaultCommunicationTimeoutInMs,
+ uint32 retryInMs = kDefaultRetryTimeoutInMs);
+
+ LoggingClientState m_loggingState;
+ Queue m_logMessages;
+ Platform::Mutex m_mutex;
+ Platform::Event m_loggingFinishedEvent;
+ };
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingProtocol.h
new file mode 100644
index 000000000..64aceee3c
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingProtocol.h
@@ -0,0 +1,303 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2018 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.
+ ******************************************************************************/
+
+#pragma once
+
+#include "gpuopen.h"
+#include
+
+#define LOGGING_PROTOCOL_MAJOR_VERSION 3
+#define LOGGING_PROTOCOL_MINOR_VERSION 0
+
+#define LOGGING_INTERFACE_VERSION ((LOGGING_INTERFACE_MAJOR_VERSION << 16) | LOGGING_INTERFACE_MINOR_VERSION)
+
+#define LOGGING_PROTOCOL_MINIMUM_MAJOR_VERSION 1
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 3.0 | Variably sized log message support |
+*| 2.0 | Refactor to simplify protocol + API semantics |
+*| 1.0 | Initial version |
+***********************************************************************************************************************
+*/
+
+#define LOGGING_LARGE_MESSAGES_VERSION 3
+#define LOGGING_REFACTOR_VERSION 2
+#define LOGGING_INITIAL_VERSION 1
+
+namespace DevDriver
+{
+
+ namespace LoggingProtocol
+ {
+ ///////////////////////
+ // Logging Constants
+ DD_STATIC_CONST uint32 kLegacyLoggingPayloadSize = 152;
+
+ // Subtract the logging header size from the max payload size to get the max size for any logging payload.
+ DD_STATIC_CONST uint32 kLoggingHeaderSize = sizeof(uint64);
+ DD_STATIC_CONST uint32 kMaxLoggingPayloadSize = (kMaxPayloadSizeInBytes - kLoggingHeaderSize);
+
+ ///////////////////////
+ // Logging Protocol
+ enum struct LoggingMessage : uint32
+ {
+ Unknown = 0,
+ EnableLoggingRequest,
+ EnableLoggingResponse,
+ DisableLogging,
+ QueryCategoriesRequest,
+ QueryCategoriesNumResponse,
+ QueryCategoriesDataResponse,
+ LogMessage,
+ LogMessageSentinel,
+ Count
+ };
+
+ ///////////////////////
+ // Logging Types
+ typedef uint64 LoggingCategory;
+
+ // WARNING: Do not increase this without also changing the payload size.
+ DD_STATIC_CONST uint32 kMaxCategoryCount = 64;
+ DD_STATIC_CONST uint32 kMaxCategoryIndex = (kMaxCategoryCount - 1);
+ DD_STATIC_CONST LoggingCategory kAllLoggingCategories = static_cast(-1);
+
+ // offset definition for the default categories.
+ // we are reserving a total of four, giving us two we can use in the future
+ enum DefaultCategories : LoggingCategory
+ {
+ kGeneralCategoryOffset,
+ kSystemCategoryOffset,
+ kReservedOffset1,
+ kReservedOffset2,
+ kReservedCategoryCount
+ };
+
+ // define categories that are available to client applications
+ DD_STATIC_CONST uint32 kDefinableCategoryCount = kMaxCategoryCount - kReservedCategoryCount;
+ DD_STATIC_CONST LoggingCategory kDefinableCategoryMask = ((LoggingCategory)1 << kDefinableCategoryCount) - 1;
+
+ static_assert(kDefinableCategoryCount <= kMaxCategoryCount, "Invalid kReservedCategoryCount");
+ // ensure that the available logging category mask is wholly contained inside the all category mask
+ static_assert((kDefinableCategoryMask & kAllLoggingCategories) == kDefinableCategoryMask,
+ "Invalid category masks defined");
+
+ // define the default category masks start so that the first mask is outside of the kDefinableCategoryMask
+ enum BaseCategoryMasks : LoggingCategory
+ {
+ kGeneralCategoryMask = ((LoggingCategory)1 << (kDefinableCategoryCount + kGeneralCategoryOffset)),
+ kSystemCategoryMask = ((LoggingCategory)1 << (kDefinableCategoryCount + kSystemCategoryOffset))
+ };
+
+ // test to make sure that the base logging category bitmasks are contained inside the all logging category mask
+ static_assert((kAllLoggingCategories & kGeneralCategoryMask) == kGeneralCategoryMask,
+ "Invalid category masks defined");
+ static_assert((kAllLoggingCategories & kSystemCategoryMask) == kSystemCategoryMask,
+ "Invalid category masks defined");
+
+ // ensure that the base logging categories do not overlap with the available logging category mask
+ static_assert((kDefinableCategoryMask & kGeneralCategoryMask) == 0, "Invalid category masks defined");
+ static_assert((kDefinableCategoryMask & kSystemCategoryMask) == 0, "Invalid category masks defined");
+
+ // A logging category is defined as both a bitmask + a name
+ DD_NETWORK_STRUCT(NamedLoggingCategory, 8)
+ {
+ LoggingCategory category;
+ char name[kMaxLoggingPayloadSize - sizeof(LoggingCategory)];
+ };
+
+ DD_CHECK_SIZE(NamedLoggingCategory, kMaxLoggingPayloadSize);
+
+ // ensure that we cannot define more categories than we have bits more
+ static_assert(kMaxCategoryCount <= 64, "kMaxCategoryCount is too big to fit inside the payload.");
+
+ // logging filter definition
+ // TODO: consider replacing this with manual bitshifting
+ DD_NETWORK_STRUCT(LoggingFilter, 8)
+ {
+ LoggingCategory category;
+ uint8 reserved[7];
+ LogLevel priority;
+ };
+
+ DD_CHECK_SIZE(LoggingFilter, 16);
+
+ // logging message definition. Filter is included so the client can identify the message.
+ DD_NETWORK_STRUCT(LogMessage, 8)
+ {
+ LoggingFilter filter;
+ char message[kMaxLoggingPayloadSize - sizeof(LoggingFilter)];
+ };
+
+ DD_CHECK_SIZE(LogMessage, kMaxLoggingPayloadSize);
+
+ ///////////////////////
+ // Logging Payloads
+ DD_NETWORK_STRUCT(LoggingHeader, 4)
+ {
+ LoggingMessage command;
+ // Padding for backwards compatibility. Initial protocol defined struct as 8 byte aligned, so first 8 bytes
+ // were always used for the header. We mark this as char to prevent the compiler from initializing this.
+ char _padding[4];
+
+ constexpr LoggingHeader(LoggingMessage message)
+ : command(message)
+ , _padding()
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(LoggingHeader, 8);
+
+ static_assert(sizeof(LoggingHeader) == kLoggingHeaderSize, "Logging header size mismatch!");
+
+ DD_NETWORK_STRUCT(EnableLoggingRequestPayload, 8)
+ {
+ LoggingHeader header;
+ LoggingFilter filter;
+
+ constexpr EnableLoggingRequestPayload(const LoggingFilter& initialFilter)
+ : header(LoggingMessage::EnableLoggingRequest)
+ , filter(initialFilter)
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(EnableLoggingRequestPayload, sizeof(LoggingHeader) + sizeof(LoggingFilter));
+
+ DD_NETWORK_STRUCT(EnableLoggingResponsePayload, 4)
+ {
+ LoggingHeader header;
+ Result result;
+ // Padding for backwards compatibility. Should remove on version bump.
+ char _padding[4];
+
+ constexpr EnableLoggingResponsePayload(Result response)
+ : header(LoggingMessage::EnableLoggingResponse)
+ , result(response)
+ , _padding()
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(EnableLoggingResponsePayload, sizeof(LoggingHeader) + 8);
+
+ DD_NETWORK_STRUCT(QueryCategoriesNumResponsePayload, 4)
+ {
+ LoggingHeader header;
+ uint32 numCategories;
+ // Padding for backwards compatibility. Should remove on version bump.
+ char _padding[4];
+
+ constexpr QueryCategoriesNumResponsePayload(uint32 categories)
+ : header(LoggingMessage::QueryCategoriesNumResponse)
+ , numCategories(categories)
+ , _padding()
+ {
+ }
+ };
+
+ DD_CHECK_SIZE(QueryCategoriesNumResponsePayload, sizeof(LoggingHeader) + 8);
+
+ DD_NETWORK_STRUCT(QueryCategoriesDataResponsePayload, 8)
+ {
+ LoggingHeader header;
+ NamedLoggingCategory category;
+
+ static void WritePayload(
+ const NamedLoggingCategory& category,
+ Version sessionVersion,
+ size_t categoryNameSize,
+ SizedPayloadContainer* pContainer)
+ {
+ DD_ASSERT(pContainer != nullptr);
+ const size_t maxNameSize =
+ (sessionVersion >= LOGGING_LARGE_MESSAGES_VERSION) ? sizeof(category.name) : kMaxStringLength;
+ const size_t finalNameSize = Platform::Min(categoryNameSize, maxNameSize);
+ const uint32 payloadSize =
+ static_cast(offsetof(QueryCategoriesDataResponsePayload, category.name) + finalNameSize);
+
+ pContainer->payloadSize = payloadSize;
+
+ QueryCategoriesDataResponsePayload& payload =
+ pContainer->GetPayload();
+ payload.header = LoggingHeader(LoggingMessage::QueryCategoriesDataResponse);
+
+ memcpy(&payload.category,
+ &category,
+ payloadSize);
+
+ // If we had to truncate the string to fit in the payload, we want to overwrite the final character
+ // with null.
+ if (categoryNameSize > finalNameSize)
+ {
+ payload.category.name[finalNameSize - 1] = '\0';
+ }
+ }
+ };
+
+ DD_CHECK_SIZE(QueryCategoriesDataResponsePayload, sizeof(LoggingHeader) + sizeof(NamedLoggingCategory));
+
+ DD_NETWORK_STRUCT(LogMessagePayload, 8)
+ {
+ LoggingHeader header;
+ LogMessage message;
+
+ static void WritePayload(
+ const LogMessage& message,
+ Version sessionVersion,
+ size_t messageSize,
+ SizedPayloadContainer* pContainer)
+ {
+ DD_ASSERT(pContainer != nullptr);
+ const size_t maxStringSize =
+ (sessionVersion >= LOGGING_LARGE_MESSAGES_VERSION) ? sizeof(message.message) : kMaxStringLength;
+ const size_t finalMessageSize = Platform::Min(messageSize, maxStringSize);
+ const uint32 payloadSize =
+ static_cast(offsetof(LogMessagePayload, message.message) + finalMessageSize);
+
+ pContainer->payloadSize = payloadSize;
+
+ LogMessagePayload& payload = pContainer->GetPayload();
+ payload.header = LoggingHeader(LoggingMessage::LogMessage);
+
+ memcpy(&payload.message,
+ &message,
+ payloadSize);
+
+ // If we had to truncate the string to fit in the payload, we want to overwrite the final character
+ // with null.
+ if (messageSize > finalMessageSize)
+ {
+ payload.message.message[finalMessageSize - 1] = '\0';
+ }
+ }
+ };
+
+ DD_CHECK_SIZE(LogMessagePayload, sizeof(LoggingHeader) + sizeof(LogMessage));
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingServer.h
new file mode 100644
index 000000000..515d9272d
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/loggingServer.h
@@ -0,0 +1,126 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file loggingServer.h
+* @brief Class declaration for LoggingServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+#include "baseProtocolServer.h"
+#include "loggingProtocol.h"
+#include "util/vector.h"
+#include "util/queue.h"
+#include "ddPlatform.h"
+
+#ifdef DEVDRIVER_LOG_CATEGORY_MASK
+#define LOGGING_CATEGORY_MASK static_cast(DEVDRIVER_LOG_CATEGORY_MASK)
+#else
+#if defined(NDEBUG)
+#define LOGGING_CATEGORY_MASK DevDriver::LoggingProtocol::kAllLoggingCategories
+#else
+#define LOGGING_CATEGORY_MASK DevDriver::LoggingProtocol::kAllLoggingCategories
+#endif
+#endif
+
+namespace DevDriver
+{
+ namespace LoggingProtocol
+ {
+ enum class SessionState
+ {
+ ReceivePayload = 0,
+ ProcessPayload,
+ SendPayload,
+ SendCategoriesNumResponse,
+ SendCategoriesDataResponse,
+ FinishLogging
+ };
+
+ struct LoggingSession
+ {
+ SizedPayloadContainer scratchPayload;
+ SharedPointer pSession;
+ Queue messages;
+ uint32 itemIndex;
+ uint32 numItems;
+ LoggingFilter filter;
+ SessionState state;
+ bool loggingEnabled;
+
+ explicit LoggingSession(const AllocCb& allocCb, const SharedPointer& pSession)
+ : scratchPayload()
+ , pSession(pSession)
+ , messages(allocCb)
+ , itemIndex(0)
+ , numItems(0)
+ , filter()
+ , state(SessionState::ReceivePayload)
+ , loggingEnabled(false)
+ {
+ memset(&scratchPayload, 0, sizeof(scratchPayload));
+ // Default to all messages enabled.
+
+ filter.priority = LogLevel::Error;
+ filter.category = kAllLoggingCategories;
+ }
+
+ // Helper functions for working with SizedPayloadContainers and managing back-compat.
+ Result SendPayload(const SizedPayloadContainer* pPayload, uint32 timeoutInMs);
+ };
+
+ class LoggingServer : public BaseProtocolServer
+ {
+ public:
+ explicit LoggingServer(IMsgChannel* pMsgChannel);
+ ~LoggingServer();
+
+ bool AcceptSession(const SharedPointer& pSession) override;
+ void SessionEstablished(const SharedPointer& pSession) override;
+ void UpdateSession(const SharedPointer& pSession) override;
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+
+ Result AddCategoryTable(uint32 offset, uint32 count, const char **pCategoryTable);
+
+ void Log(LogLevel priority, LoggingCategory category, const char* pFormat, va_list args);
+ void Log(LogLevel priority, LoggingCategory category, const char* pFormat, ...)
+ {
+ va_list args;
+ va_start(args, pFormat);
+ Log(priority, category, pFormat, args);
+ va_end(args);
+ }
+
+ private:
+ void LockData();
+ void UnlockData();
+
+ NamedLoggingCategory m_categories[kMaxCategoryCount];
+ Vector m_activeSessions;
+ Platform::Mutex m_mutex;
+ uint32 m_numCategories;
+ };
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpClient.h
new file mode 100644
index 000000000..30ead029b
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpClient.h
@@ -0,0 +1,132 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file rgpClient.h
+* @brief Class declaration for RGPClient.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolClient.h"
+
+#include "protocols/rgpProtocol.h"
+
+namespace DevDriver
+{
+ class IMsgChannel;
+
+ namespace RGPProtocol
+ {
+ typedef void(*TraceDataChunkReceived)(const TraceDataChunk* pChunk, void* pUserdata);
+
+ struct ChunkCallbackInfo
+ {
+ TraceDataChunkReceived chunkCallback;
+ void* pUserdata;
+ };
+
+ struct ClientTraceParametersInfo
+ {
+ uint32 gpuMemoryLimitInMb;
+ uint32 numPreparationFrames;
+
+ union
+ {
+ struct
+ {
+ uint32 enableInstructionTokens : 1;
+ uint32 allowComputePresents : 1;
+ uint32 reserved : 30;
+ };
+ uint32 u32All;
+ } flags;
+
+ uint64 beginTag;
+ uint64 endTag;
+
+ char beginMarker[kMarkerStringLength];
+ char endMarker[kMarkerStringLength];
+ };
+
+ struct BeginTraceInfo
+ {
+ ClientTraceParametersInfo parameters; // Parameters for the trace
+ ChunkCallbackInfo callbackInfo; // Callback used to return trace data
+ };
+
+ class RGPClient : public BaseProtocolClient
+ {
+ public:
+ explicit RGPClient(IMsgChannel* pMsgChannel);
+ ~RGPClient();
+
+ // Requests an RGP trace in the driver. Returns Success if the request was successfully delivered.
+ Result BeginTrace(const BeginTraceInfo& traceInfo);
+
+ // Waits until a previously requested trace completes in the driver and returns the result of the trace.
+ // If the trace was successful, the number of chunks generated is returned in pNumChunks and the size in
+ // bytes of the trace data is returned in pTraceSizeInBytes.
+ Result EndTrace(uint32* pNumChunks, uint64* pTraceSizeInBytes);
+
+ // Reads a chunk of trace data from a previous trace that completed successfully. Returns chunk data
+ // via the callback provided earlier in BeginTraceInfo.
+ Result ReadTraceDataChunk();
+
+ // Aborts a trace in progress.
+ Result AbortTrace();
+
+ // Queries the current profiling status of the driver.
+ Result QueryProfilingStatus(ProfilingStatus* pStatus);
+
+ // Enables profiling support inside the driver. ExecuteTrace will only succeed if the connected driver
+ // has profiling enabled.
+ Result EnableProfiling();
+
+ private:
+ void ResetState() override;
+
+ enum class TraceState : uint32
+ {
+ Idle = 0,
+ TraceRequested,
+ TraceCompleted,
+ Error
+ };
+
+ struct ClientTraceContext
+ {
+ TraceState state;
+ BeginTraceInfo traceInfo;
+ uint32 numChunksReceived;
+ uint32 numChunks;
+ };
+
+ ClientTraceContext m_traceContext;
+
+ DD_STATIC_CONST uint32 kRGPChunkTimeoutInMs = 3000;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpProtocol.h
new file mode 100644
index 000000000..7c13ab4e6
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpProtocol.h
@@ -0,0 +1,301 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file rgpProtcol.h
+* @brief Common interface for RGP Protocol.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#pragma pack(push)
+
+#include "gpuopen.h"
+
+#define RGP_PROTOCOL_MAJOR_VERSION 6
+#define RGP_PROTOCOL_MINOR_VERSION 0
+
+#define RGP_INTERFACE_VERSION ((RGP_INTERFACE_MAJOR_VERSION << 16) | RGP_INTERFACE_MINOR_VERSION)
+
+#define RGP_PROTOCOL_MINIMUM_MAJOR_VERSION 2
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 6.0 | Added support for trace trigger markers. |
+*| 5.0 | Added support for allow compute presents trace parameter and removed unused clock mode parameter. |
+*| 4.0 | Added support for reporting trace transfer progress. |
+*| 3.0 | Updated TraceParameters struct to allow for specifying profiling clock mode. |
+*| 2.0 | Add TraceParameters struct and ExecuteTraceRequestPayload so a client can specify trace options. |
+*| 1.0 | Initial version |
+***********************************************************************************************************************
+*/
+
+#define RGP_TRIGGER_MARKERS_VERSION 6
+#define RGP_COMPUTE_PRESENTS_VERSION 5
+#define RGP_TRACE_PROGRESS_VERSION 4
+#define RGP_PROFILING_CLOCK_MODES_VERSION 3
+#define RGP_TRACE_PARAMETERS_VERSION 2
+#define RGP_INITIAL_VERSION 1
+
+namespace DevDriver
+{
+ namespace RGPProtocol
+ {
+ ///////////////////////
+ // RGP Protocol
+ enum struct RGPMessage : MessageCode
+ {
+ Unknown = 0,
+ ExecuteTraceRequest,
+ TraceDataChunk,
+ TraceDataSentinel,
+ QueryProfilingStatusRequest,
+ QueryProfilingStatusResponse,
+ EnableProfilingRequest,
+ EnableProfilingResponse,
+ TraceDataHeader,
+ AbortTrace,
+ Count
+ };
+
+ // @note: We currently subtract sizeof(uint32) instead of sizeof(RGPMessage) to work around struct packing issues.
+ // The compiler pads out RGPMessage to 4 bytes when it's included in the payload struct. It also pads out
+ // the TraceDataChunk data field to 1000 bytes. This causes the total payload size to be 1004 bytes which is
+ // 4 bytes larger than the maximum size allowed.
+ DD_STATIC_CONST Size kMaxTraceDataChunkSize = (kMaxPayloadSizeInBytes - sizeof(uint32) - sizeof(uint32));
+
+ ///////////////////////
+ // RGP Constants
+ const uint32 kMarkerStringLength = 256;
+
+ ///////////////////////
+ // RGP Types
+ DD_NETWORK_STRUCT(TraceDataChunk, 4)
+ {
+ uint32 dataSize;
+ uint8 data[kMaxTraceDataChunkSize];
+ };
+
+ DD_CHECK_SIZE(TraceDataChunk, kMaxTraceDataChunkSize + sizeof(int32));
+
+ DD_NETWORK_STRUCT(TraceParameters, 4)
+ {
+ uint32 gpuMemoryLimitInMb;
+ uint32 numPreparationFrames;
+ union
+ {
+ struct
+ {
+ uint32 enableInstructionTokens : 1;
+ uint32 reserved : 31;
+ };
+ uint32 u32All;
+ } flags;
+ };
+
+ DD_CHECK_SIZE(TraceParameters, 12);
+
+ enum struct ProfilingClockMode : uint32
+ {
+ Stable = 0,
+ Max,
+ Normal,
+ Count
+ };
+
+ DD_NETWORK_STRUCT(TraceParametersV2, 4)
+ {
+ uint32 gpuMemoryLimitInMb;
+ uint32 numPreparationFrames;
+ ProfilingClockMode clockMode;
+ union
+ {
+ struct
+ {
+ uint32 enableInstructionTokens : 1;
+ uint32 reserved : 31;
+ };
+ uint32 u32All;
+ } flags;
+ };
+
+ DD_CHECK_SIZE(TraceParametersV2, 16);
+
+ DD_NETWORK_STRUCT(TraceParametersV3, 4)
+ {
+ uint32 gpuMemoryLimitInMb;
+ uint32 numPreparationFrames;
+ union
+ {
+ struct
+ {
+ uint32 enableInstructionTokens : 1;
+ uint32 allowComputePresents : 1;
+ uint32 reserved : 30;
+ };
+ uint32 u32All;
+ } flags;
+ };
+
+ DD_CHECK_SIZE(TraceParametersV3, 12);
+
+ DD_NETWORK_STRUCT(TraceParametersV4, 4)
+ {
+ uint32 gpuMemoryLimitInMb;
+ uint32 numPreparationFrames;
+ union
+ {
+ struct
+ {
+ uint32 enableInstructionTokens : 1;
+ uint32 allowComputePresents : 1;
+ uint32 reserved : 30;
+ };
+ uint32 u32All;
+ } flags;
+
+ // Begin Tag
+ uint32 beginTagHigh;
+ uint32 beginTagLow;
+
+ // End Tag
+ uint32 endTagHigh;
+ uint32 endTagLow;
+
+ // Begin/End Marker Strings
+ char beginMarker[kMarkerStringLength];
+ char endMarker[kMarkerStringLength];
+ };
+
+ DD_CHECK_SIZE(TraceParametersV4, 540);
+
+ enum struct ProfilingStatus : uint32
+ {
+ NotAvailable = 0,
+ Available,
+ Enabled,
+ Count
+ };
+
+ ///////////////////////
+ // RGP Payloads
+
+ DD_NETWORK_STRUCT(ExecuteTraceRequestPayload, 4)
+ {
+ TraceParameters parameters;
+ };
+
+ DD_CHECK_SIZE(ExecuteTraceRequestPayload, 12);
+
+ DD_NETWORK_STRUCT(ExecuteTraceRequestPayloadV2, 4)
+ {
+ TraceParametersV2 parameters;
+ };
+
+ DD_CHECK_SIZE(ExecuteTraceRequestPayloadV2, 16);
+
+ DD_NETWORK_STRUCT(ExecuteTraceRequestPayloadV3, 4)
+ {
+ TraceParametersV3 parameters;
+ };
+
+ DD_CHECK_SIZE(ExecuteTraceRequestPayloadV3, 12);
+
+ DD_NETWORK_STRUCT(ExecuteTraceRequestPayloadV4, 4)
+ {
+ TraceParametersV4 parameters;
+ };
+
+ DD_CHECK_SIZE(ExecuteTraceRequestPayloadV4, 540);
+
+ DD_NETWORK_STRUCT(ExecuteTraceResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(ExecuteTraceResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(TraceDataChunkPayload, 4)
+ {
+ TraceDataChunk chunk;
+ };
+
+ DD_CHECK_SIZE(TraceDataChunkPayload, kMaxTraceDataChunkSize + sizeof(int32));
+
+ DD_NETWORK_STRUCT(TraceDataSentinelPayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(TraceDataSentinelPayload, 4);
+
+ DD_NETWORK_STRUCT(TraceDataHeaderPayload, 4)
+ {
+ Result result;
+ uint32 numChunks;
+ uint32 sizeInBytes;
+ };
+
+ DD_CHECK_SIZE(TraceDataHeaderPayload, 12);
+
+ DD_NETWORK_STRUCT(QueryProfilingStatusResponsePayload, 4)
+ {
+ ProfilingStatus status;
+ };
+
+ DD_CHECK_SIZE(QueryProfilingStatusResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(EnableProfilingResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(EnableProfilingResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(RGPPayload, 4)
+ {
+ RGPMessage command;
+ // pad out to 4 bytes for alignment requirements
+ char padding[3];
+ union
+ {
+ ExecuteTraceRequestPayload executeTraceRequest;
+ ExecuteTraceRequestPayloadV2 executeTraceRequestV2;
+ ExecuteTraceRequestPayloadV3 executeTraceRequestV3;
+ ExecuteTraceRequestPayloadV4 executeTraceRequestV4;
+ ExecuteTraceResponsePayload executeTraceResponse;
+ TraceDataChunkPayload traceDataChunk;
+ TraceDataSentinelPayload traceDataSentinel;
+ TraceDataHeaderPayload traceDataHeader;
+ QueryProfilingStatusResponsePayload queryProfilingStatusResponse;
+ EnableProfilingResponsePayload enableProfilingStatusResponse;
+ };
+ };
+
+ DD_CHECK_SIZE(RGPPayload, kMaxPayloadSizeInBytes);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpServer.h
new file mode 100644
index 000000000..7fe68d6b0
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/rgpServer.h
@@ -0,0 +1,133 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file rgpServer.h
+* @brief Class declaration for RGPServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "baseProtocolServer.h"
+
+#include "rgpProtocol.h"
+
+namespace DevDriver
+{
+ namespace RGPProtocol
+ {
+ enum class TraceStatus : uint32
+ {
+ Idle = 0,
+ Pending,
+ Running,
+ Finishing,
+ Aborting
+ };
+
+ struct ServerTraceParametersInfo
+ {
+ uint32 gpuMemoryLimitInMb;
+ uint32 numPreparationFrames;
+
+ union
+ {
+ struct
+ {
+ uint32 enableInstructionTokens : 1;
+ uint32 allowComputePresents : 1;
+ uint32 reserved : 30;
+ };
+ uint32 u32All;
+ } flags;
+
+ uint64 beginTag;
+ uint64 endTag;
+
+ char beginMarker[kMarkerStringLength];
+ char endMarker[kMarkerStringLength];
+ };
+
+ struct RGPSession;
+
+ class RGPServer : public BaseProtocolServer
+ {
+ public:
+ explicit RGPServer(IMsgChannel* pMsgChannel);
+ ~RGPServer();
+
+ void Finalize() override;
+
+ bool AcceptSession(const SharedPointer& pSession) override;
+ void SessionEstablished(const SharedPointer& pSession) override;
+ void UpdateSession(const SharedPointer& pSession) override;
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+
+ // Returns true if traces are currently enabled.
+ bool TracesEnabled();
+
+ // Allows remote clients to request traces.
+ Result EnableTraces();
+
+ // Disable support for traces.
+ Result DisableTraces();
+
+ // Returns true if a client has requested a trace and it has not been started yet.
+ bool IsTracePending();
+
+ // Returns true if a client has requested a trace and it is currently running.
+ bool IsTraceRunning();
+
+ // Starts a new trace. This will only succeed if a trace was previously pending.
+ Result BeginTrace();
+
+ // Ends a trace. This will only succeed if a trace was previously in progress.
+ Result EndTrace();
+
+ // Aborts a trace. This will only succeed if a trace was previously in progress.
+ Result AbortTrace();
+
+ // Writes data into the current trace. This can only be performed when there is a trace in progress.
+ Result WriteTraceData(const uint8* pTraceData, size_t traceDataSize);
+
+ // Returns the current profiling status on the rgp server.
+ ProfilingStatus QueryProfilingStatus();
+
+ // Returns the current trace parameters on the rgp server.
+ ServerTraceParametersInfo QueryTraceParameters();
+
+ private:
+ void LockData();
+ void UnlockData();
+ void ClearCurrentSession();
+
+ Platform::Mutex m_mutex;
+ TraceStatus m_traceStatus;
+ RGPSession* m_pCurrentSessionData;
+ ProfilingStatus m_profilingStatus;
+ ServerTraceParametersInfo m_traceParameters;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsClient.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsClient.h
new file mode 100644
index 000000000..7533805fa
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsClient.h
@@ -0,0 +1,62 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file settingsClient.h
+* @brief Protocol Client for the Settings Protocol
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#define SETTINGS_CLIENT_MIN_MAJOR_VERSION 1
+#define SETTINGS_CLIENT_MAX_MAJOR_VERSION 2
+
+#include "settingsProtocol.h"
+#include "baseProtocolClient.h"
+
+namespace DevDriver
+{
+ namespace SettingsProtocol
+ {
+ class SettingsClient : public BaseProtocolClient
+ {
+ public:
+ explicit SettingsClient(IMsgChannel* pMsgChannel);
+ ~SettingsClient();
+
+ Result QueryNumCategories(uint32* pNumCategories);
+ Result QueryCategories(SettingCategory* pCategoriesBuffer, uint32 bufferSizeInCategories);
+
+ Result QueryNumSettings(uint32* pNumSettings);
+ Result QuerySettings(Setting* pSettingsBuffer, uint32 bufferSizeInSettings);
+
+ Result QuerySetting(const char* pName, Setting* pSetting);
+
+ Result SetSetting(const char* pName, const SettingValue* pValue);
+
+ private:
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsProtocol.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsProtocol.h
new file mode 100644
index 000000000..6496f1036
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsProtocol.h
@@ -0,0 +1,264 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file settingsProtocol.h
+* @brief Protocol header for the Settings Protocol
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+
+#define SETTINGS_PROTOCOL_MAJOR_VERSION 2
+#define SETTINGS_PROTOCOL_MINOR_VERSION 0
+
+#define SETTINGS_INTERFACE_VERSION ((GPUOPEN_INTERFACE_MAJOR_VERSION << 16) | GPUOPEN_INTERFACE_MINOR_VERSION)
+
+#define SETTINGS_PROTOCOL_MINIMUM_MAJOR_VERSION 1
+
+#ifndef SETTINGS_CLIENT_MIN_MAJOR_VERSION
+static_assert(false, "Client must define SETTINGS_CLIENT_MIN_MAJOR_VERSION.");
+#else
+static_assert((SETTINGS_CLIENT_MIN_MAJOR_VERSION >= SETTINGS_PROTOCOL_MINIMUM_MAJOR_VERSION) &&
+(SETTINGS_CLIENT_MIN_MAJOR_VERSION <= SETTINGS_PROTOCOL_MAJOR_VERSION),
+"The specified SETTINGS_CLIENT_MIN_MAJOR_VERSION is not supported.");
+#endif
+
+#ifndef SETTINGS_CLIENT_MAX_MAJOR_VERSION
+static_assert(false, "Client must define SETTINGS_CLIENT_MAX_MAJOR_VERSION.");
+#else
+static_assert((SETTINGS_CLIENT_MAX_MAJOR_VERSION >= SETTINGS_PROTOCOL_MINIMUM_MAJOR_VERSION) &&
+(SETTINGS_CLIENT_MAX_MAJOR_VERSION <= SETTINGS_PROTOCOL_MAJOR_VERSION),
+"The specified SETTINGS_CLIENT_MAX_MAJOR_VERSION is not supported.");
+#endif
+
+/*
+***********************************************************************************************************************
+*| Version | Change Description |
+*| ------- | ---------------------------------------------------------------------------------------------------------|
+*| 2.0 | Add hex setting type to protocol. |
+*| 1.0 | Initial version. |
+***********************************************************************************************************************
+*/
+
+#define SETTINGS_HEX_VERSION 2
+#define SETTINGS_INITIAL_VERSION 1
+
+#define SETTINGS_PROTOCOL_SUPPORTS(x) ((SETTINGS_CLIENT_MAX_MAJOR_VERSION >= x) && (x >= SETTINGS_CLIENT_MIN_MAJOR_VERSION))
+
+namespace DevDriver
+{
+
+ namespace SettingsProtocol
+ {
+ ///////////////////////
+ // Settings Constants
+ DD_STATIC_CONST uint32 kSmallStringSize = 64;
+ DD_STATIC_CONST uint32 kLargeStringSize = 256;
+
+ ///////////////////////
+ // Settings Protocol
+ enum struct SettingsMessage : MessageCode
+ {
+ Unknown = 0,
+ QueryNumSettingsRequest,
+ QueryNumSettingsResponse,
+ QuerySettingsRequest,
+ QuerySettingsNumResponse,
+ QuerySettingsDataResponse,
+ QuerySettingRequest,
+ QuerySettingResponse,
+ SetSettingRequest,
+ SetSettingResponse,
+ QueryNumCategoriesRequest,
+ QueryNumCategoriesResponse,
+ QueryCategoriesRequest,
+ QueryCategoriesNumResponse,
+ QueryCategoriesDataResponse,
+ Count
+ };
+
+ ///////////////////////
+ // Setting Types
+ enum struct SettingType : uint32
+ {
+ Unknown = 0,
+ Boolean,
+ Integer,
+ UnsignedInteger,
+ Float,
+ String,
+#if SETTINGS_PROTOCOL_SUPPORTS(SETTINGS_HEX_VERSION)
+ Hex,
+#endif
+ Count
+ };
+
+ ///////////////////////
+ // Setting Value Structure
+ DD_NETWORK_STRUCT(SettingValue, 4)
+ {
+ union
+ {
+ bool boolValue;
+ int32 integerValue;
+ uint32 unsignedIntegerValue;
+#if SETTINGS_PROTOCOL_SUPPORTS(SETTINGS_HEX_VERSION)
+ uint32 hexValue;
+#endif
+ float floatValue;
+ char stringValue[kSmallStringSize];
+ };
+ };
+
+ DD_CHECK_SIZE(SettingValue, 64);
+
+ ///////////////////////
+ // Setting Structure
+ DD_NETWORK_STRUCT(Setting, 4)
+ {
+ char description[kLargeStringSize];
+ char name[kSmallStringSize];
+ SettingValue value;
+ SettingValue defaultValue;
+ SettingType type;
+ uint32 categoryIndex;
+ };
+
+ DD_CHECK_SIZE(Setting, 456);
+
+ ///////////////////////
+ // Category Structure
+ DD_NETWORK_STRUCT(SettingCategory, 4)
+ {
+ char name[kSmallStringSize];
+ int32 parentIndex;
+ };
+
+ DD_CHECK_SIZE(SettingCategory, 68);
+
+ ///////////////////////
+ // Payloads
+ DD_NETWORK_STRUCT(QueryNumSettingsResponsePayload, 4)
+ {
+ uint32 numSettings;
+ };
+ DD_CHECK_SIZE(QueryNumSettingsResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QuerySettingsNumResponsePayload, 4)
+ {
+ uint32 numSettings;
+ };
+ DD_CHECK_SIZE(QuerySettingsNumResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QuerySettingsDataResponsePayload, 4)
+ {
+ Setting setting;
+ };
+
+ DD_CHECK_SIZE(QuerySettingsDataResponsePayload, 456);
+
+ DD_NETWORK_STRUCT(QuerySettingRequestPayload, 4)
+ {
+ char name[kSmallStringSize];
+ };
+ DD_CHECK_SIZE(QuerySettingRequestPayload, 64);
+
+ DD_NETWORK_STRUCT(QuerySettingResponsePayload, 4)
+ {
+ Setting setting;
+ // todo: replace this with something that is more verbose at a later date
+ // avoided for the time being as it would cause a breaking API change
+ uint8 success;
+ // pad out for alignment requirements
+ uint8 padding[3];
+ };
+
+ DD_CHECK_SIZE(QuerySettingResponsePayload, 460);
+
+ DD_NETWORK_STRUCT(SetSettingRequestPayload, 4)
+ {
+ char name[kSmallStringSize];
+ SettingValue value;
+ };
+
+ DD_CHECK_SIZE(SetSettingRequestPayload, 128);
+
+ DD_NETWORK_STRUCT(SetSettingResponsePayload, 4)
+ {
+ // todo: replace this with something that is more verbose at a later date
+ // avoided for the time being as it would cause a breaking API change
+ uint8 success;
+ // pad out to 4 bytes for alignment requirements
+ uint8 padding[3];
+ };
+
+ DD_CHECK_SIZE(SetSettingResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QueryNumCategoriesResponsePayload, 4)
+ {
+ uint32 numCategories;
+ };
+
+ DD_CHECK_SIZE(QueryNumCategoriesResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QueryCategoriesNumResponsePayload, 4)
+ {
+ uint32 numCategories;
+ };
+
+ DD_CHECK_SIZE(QueryCategoriesNumResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QueryCategoriesDataResponsePayload, 4)
+ {
+ SettingCategory category;
+ };
+
+ DD_CHECK_SIZE(QueryCategoriesDataResponsePayload, 68);
+
+ DD_NETWORK_STRUCT(SettingsPayload, 4)
+ {
+ SettingsMessage command;
+ // pad out to 4 bytes for alignment requirements
+ char padding[3];
+ union
+ {
+ QueryNumSettingsResponsePayload queryNumSettingsResponse;
+ QuerySettingsNumResponsePayload querySettingsNumResponse;
+ QuerySettingsDataResponsePayload querySettingsDataResponse;
+ QuerySettingRequestPayload querySettingRequest;
+ QuerySettingResponsePayload querySettingResponse;
+ SetSettingRequestPayload setSettingRequest;
+ SetSettingResponsePayload setSettingResponse;
+ QueryNumCategoriesResponsePayload queryNumCategoriesResponse;
+ QueryCategoriesNumResponsePayload queryCategoriesNumResponse;
+ QueryCategoriesDataResponsePayload queryCategoriesDataResponse;
+ };
+ };
+
+ DD_CHECK_SIZE(SettingsPayload, 464);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsServer.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsServer.h
new file mode 100644
index 000000000..14d9232bf
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/settingsServer.h
@@ -0,0 +1,81 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file settingsServer.h
+* @brief Class declaration for SettingServer.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#define SETTINGS_CLIENT_MIN_MAJOR_VERSION 1
+#define SETTINGS_CLIENT_MAX_MAJOR_VERSION 2
+
+#include "settingsProtocol.h"
+#include "baseProtocolServer.h"
+#include "util/vector.h"
+
+namespace DevDriver
+{
+ namespace SettingsProtocol
+ {
+ class SettingsServer : public BaseProtocolServer
+ {
+ public:
+ explicit SettingsServer(IMsgChannel* pMsgChannel);
+ ~SettingsServer();
+
+ void Finalize() override;
+
+ bool AcceptSession(const SharedPointer& pSession) override;
+ void SessionEstablished(const SharedPointer& pSession) override;
+ void UpdateSession(const SharedPointer& pSession) override;
+ void SessionTerminated(const SharedPointer& pSession, Result terminationReason) override;
+
+ void AddCategory(const char* pName, const char* pParentName);
+ int32 QueryCategoryIndex(const char* pName) const;
+
+ void AddSetting(const Setting* pSetting);
+ bool QuerySetting(const char* pName, Setting* pSetting);
+ bool QuerySettingByIndex(uint32 settingIndex, Setting* pSetting);
+ bool UpdateSetting(const char* pName, const SettingValue* pValue);
+ bool UpdateSettingByIndex(uint32 settingIndex, const SettingValue* pValue);
+
+ uint32 GetNumSettings();
+ uint32 GetNumCategories();
+
+ private:
+ void LockData();
+ void UnlockData();
+
+ int32 FindCategory(const char* pCategoryName) const;
+ int32 FindSetting(const char* pSettingName) const;
+
+ Vector m_settings;
+ Vector m_categories;
+ Platform::Mutex m_mutex;
+ };
+ }
+} // DevDriver
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/systemProtocols.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/systemProtocols.h
new file mode 100644
index 000000000..5ee322fe5
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/systemProtocols.h
@@ -0,0 +1,222 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file systemProtocols.h
+* @brief Protocol header for all system protocols
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+#include "gpuopen.h"
+
+namespace DevDriver
+{
+ namespace SystemProtocol
+ {
+ ///////////////////////
+ // GPU Open System Protocol
+ enum struct SystemMessage : MessageCode
+ {
+ Unknown = 0,
+ ClientConnected,
+ ClientDisconnected,
+ Ping,
+ Pong,
+ QueryClientInfo,
+ ClientInfo,
+ Halted,
+ Count,
+ };
+ }
+
+ namespace SessionProtocol
+ {
+ ///////////////////////
+ // GPU Open Session Protocol
+ enum struct SessionMessage : MessageCode
+ {
+ Unknown = 0,
+ Syn,
+ SynAck,
+ Fin,
+ Data,
+ Ack,
+ Rst,
+ Count
+ };
+
+ typedef uint8 SessionVersion;
+ // Session protocol 2 lets session servers return session version as part of the synack
+ DD_STATIC_CONST SessionVersion kSessionProtocolVersionSynAckVersion = 2;
+ // Session protocol 1 lets session clients specify a max range supported as part of the syn
+ DD_STATIC_CONST SessionVersion kSessionProtocolRangeVersion = 1;
+ // current version is 2
+ DD_STATIC_CONST SessionVersion kSessionProtocolVersion = kSessionProtocolVersionSynAckVersion;
+ // not mentioned is session version 0. It only supported min version in SynAck, servers reporting it cannot
+ // cleanly terminate in response to a Fin packet.
+
+ // tripwire - this intentionally will break if the message version changes. Since that implies a breaking change, we need to address
+ // to re-baseline this as version 0 and update the SynPayload struct at the same time
+ static_assert(kMessageVersion == 1011, "Session packets need to be cleaned up as part of the next protocol version");
+
+ DD_NETWORK_STRUCT(SynPayload, 4)
+ {
+ Version minVersion;
+ Protocol protocol;
+ // pad out to 4 bytes
+ SessionVersion sessionVersion;
+
+ // New fields read if sessionVersion != 0
+ Version maxVersion;
+ // pad out to 8 bytes
+ uint8 reserved[2];
+ };
+
+ DD_CHECK_SIZE(SynPayload, 8);
+
+ //
+ // SynPayloadV2 is here so that we can use it with the next breaking message bus change.
+ //
+ //DD_NETWORK_STRUCT(SynPayloadV2, 4)
+ //{
+ // Protocol protocol;
+ // SessionVersion sessionVersion;
+ // Version minVersion;
+ // Version maxVersion;
+ // // pad out to 8 bytes
+ // uint8 reserved[2];
+ //};
+
+ //DD_CHECK_SIZE(SynPayloadV2, 8);
+
+ DD_NETWORK_STRUCT(SynAckPayload, 8)
+ {
+ Sequence sequence;
+ SessionId initialSessionId;
+ Version version;
+ SessionVersion sessionVersion;
+ uint8 reserved[1];
+ };
+
+ DD_CHECK_SIZE(SynAckPayload, 16);
+ }
+
+ namespace ClientManagementProtocol
+ {
+
+ ///////////////////////
+ // GPU Open ClientManagement Protocol
+ enum struct ManagementMessage : MessageCode
+ {
+ Unknown = 0,
+ ConnectRequest,
+ ConnectResponse,
+ DisconnectNotification,
+ DisconnectResponse,
+ SetClientFlags,
+ SetClientFlagsResponse,
+ QueryStatus,
+ QueryStatusResponse,
+ KeepAlive,
+ Count
+ };
+
+ DD_STATIC_CONST MessageBuffer kOutOfBandMessage =
+ {
+ { // header
+ kBroadcastClientId, //srcClientId
+ kBroadcastClientId, //dstClientId
+ Protocol::ClientManagement, //protocolId
+ 0, //messageId
+ 0, //windowSize
+ 0, //payloadSize
+ 0, //sessionId
+ kMessageVersion //sequence
+ },
+ {} // payload
+ };
+
+ inline bool IsOutOfBandMessage(const MessageBuffer &message)
+ {
+ // an out of band message is denoted by both the dstClientId and srcClientId
+ // being initialized to kBroadcastClientId.
+ static_assert(kBroadcastClientId == 0, "Error, kBroadcastClientId is non-zero. IsOutOfBandMessage needs to be fixed");
+ return ((message.header.dstClientId | message.header.srcClientId) == kBroadcastClientId);
+ }
+
+ inline bool IsValidOutOfBandMessage(const MessageBuffer &message)
+ {
+ // an out of band message is only valid if the sequence field is initialized with the correct version
+ // and the protocolId is equal to the receiving client's Protocol::ClientManagement value
+ return ((message.header.sequence == kMessageVersion) &
+ (message.header.protocolId == Protocol::ClientManagement));
+ }
+
+ DD_NETWORK_STRUCT(ConnectRequestPayload, 4)
+ {
+ StatusFlags initialClientFlags;
+ uint8 padding[2];
+ Component componentType;
+ uint8 reserved[3];
+ };
+
+ DD_CHECK_SIZE(ConnectRequestPayload, 8);
+
+ DD_NETWORK_STRUCT(ConnectResponsePayload, 4)
+ {
+ Result result;
+ ClientId clientId;
+ // pad this out to 8 bytes for future expansion
+ uint8 padding[2];
+ };
+
+ DD_CHECK_SIZE(ConnectResponsePayload, 8);
+
+ DD_NETWORK_STRUCT(SetClientFlagsPayload, 4)
+ {
+ StatusFlags flags;
+ uint8 padding[2];
+ };
+
+ DD_CHECK_SIZE(SetClientFlagsPayload, 4);
+
+ DD_NETWORK_STRUCT(SetClientFlagsResponsePayload, 4)
+ {
+ Result result;
+ };
+
+ DD_CHECK_SIZE(SetClientFlagsResponsePayload, 4);
+
+ DD_NETWORK_STRUCT(QueryStatusResponsePayload, 4)
+ {
+ Result result;
+ StatusFlags flags;
+ uint8 reserved[2];
+ };
+
+ DD_CHECK_SIZE(QueryStatusResponsePayload, 8);
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/typemap.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/typemap.h
new file mode 100644
index 000000000..beb8311bc
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/protocols/typemap.h
@@ -0,0 +1,198 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2016-2018 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.
+ ******************************************************************************/
+/**
+***********************************************************************************************************************
+* @file map.h
+* @brief Type mappings between protocol enum and client/server types.
+***********************************************************************************************************************
+*/
+
+#pragma once
+
+namespace DevDriver
+{
+ class IProtocolServer;
+ class IProtocolClient;
+
+ template
+ struct ProtocolServerMap
+ {
+ typedef IProtocolServer type;
+ };
+
+ template
+ struct ProtocolClientMap
+ {
+ typedef IProtocolClient type;
+ };
+
+ template
+ using ProtocolServerType = typename ProtocolServerMap::type;
+
+ template
+ using ProtocolClientType = typename ProtocolClientMap::type;
+
+ namespace LoggingProtocol
+ {
+ class LoggingServer;
+ class LoggingClient;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef LoggingProtocol::LoggingServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef LoggingProtocol::LoggingClient type;
+ };
+
+ namespace SettingsProtocol
+ {
+ class SettingsServer;
+ class SettingsClient;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef SettingsProtocol::SettingsServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef SettingsProtocol::SettingsClient type;
+ };
+
+ namespace DriverControlProtocol
+ {
+ class DriverControlServer;
+ class DriverControlClient;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef DriverControlProtocol::DriverControlServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef DriverControlProtocol::DriverControlClient type;
+ };
+
+ namespace RGPProtocol
+ {
+ class RGPServer;
+ class RGPClient;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef RGPProtocol::RGPServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef RGPProtocol::RGPClient type;
+ };
+
+ namespace ETWProtocol
+ {
+ class ETWServer;
+ class ETWClient;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef ETWProtocol::ETWServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef ETWProtocol::ETWClient type;
+ };
+
+ namespace GpuCrashDumpProtocol
+ {
+ class GpuCrashDumpClient;
+ class GpuCrashDumpServer;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef GpuCrashDumpProtocol::GpuCrashDumpServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef GpuCrashDumpProtocol::GpuCrashDumpClient type;
+ };
+ namespace TransferProtocol
+ {
+ class TransferServer;
+ class TransferClient;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef TransferProtocol::TransferServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef TransferProtocol::TransferClient type;
+ };
+
+ namespace URIProtocol
+ {
+ class URIServer;
+ class URIClient;
+ }
+
+ template <>
+ struct ProtocolServerMap
+ {
+ typedef URIProtocol::URIServer type;
+ };
+
+ template <>
+ struct ProtocolClientMap
+ {
+ typedef URIProtocol::URIClient type;
+ };
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashBase.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashBase.h
new file mode 100644
index 000000000..23027f187
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashBase.h
@@ -0,0 +1,813 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2017-2018 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.
+ ******************************************************************************/
+ /**
+ ***********************************************************************************************************************
+ * @file hashBase.h
+ * @brief Templated class to support common hash table functions.
+ ***********************************************************************************************************************
+ */
+
+#pragma once
+
+#include "gpuopen.h"
+#include "ddPlatform.h"
+#include "memory.h"
+#include "hashFunc.h"
+#include
+
+namespace DevDriver
+{
+ // For the i-th block, it will hold Pow(2,i) groups, the whole array could have 4G groups.
+ DD_STATIC_CONST int32 kNumHashBlocks = 32; // Maximum number of blocks the container can implement
+
+ /**
+ ***********************************************************************************************************************
+ * @brief Templated base class for HashMap and HashSet, supporting the ability to store, find, and remove entries.
+ *
+ * The hash container has a fixed number of buckets. These buckets contain a growable number of entry groups. Each
+ * entry group contains a fixed number of entries and a pointer to the next entry group in the bucket.
+ *
+ * This class aims to be very efficient when looking up the key and storing small attached items is the primary concern.
+ * It's therefore not desired to have the key associated with a pointer to the attached data, because the attached data
+ * may be of similar or smaller size than the pointer anyway, it would also introduce much unnecessary memory
+ * management, and it would imply a minimum of two cache misses in the typical lookup case.
+ *
+ * The idea is that these enty groups can be exactly the size of a cache line, so an entry group can be scanned with
+ * only a single cache miss. This extends the load factor that the hash-map can manage before performance begins to
+ * degrade. For the very small items that we expect, this should be a significant advantage; we expect one cache miss
+ * pretty much always, so packing the items together would not be a significant gain, and the cost in memory usage is
+ * (relatively) small.
+ ***********************************************************************************************************************
+ */
+ template<
+ typename Key,
+ typename Entry,
+ typename HashFunc,
+ typename EqualFunc,
+ size_t NumBuckets,
+ size_t MinimumBucketSize = DD_CACHE_LINE_BYTES * 2>
+ class HashBase
+ {
+ public:
+ /// Returns number of entries in the container.
+ size_t Size() const { return m_numEntries; }
+
+ /// Empty the hash container without freeing the underlying allocations.
+ void Reset()
+ {
+ if (m_curBlock >= 0)
+ {
+ // Reset the bucket head pointers
+ memset(&m_buckets[0], 0, sizeof(m_buckets));
+
+ // We need to destroy all object instances inside the hash map, so we iterate over all blocks
+ for (int32 i = 0; i <= m_curBlock; ++i)
+ {
+ MemBlock& block = m_blocks[i];
+
+ DD_ASSERT(block.pMemory != nullptr);
+
+ // The number of buckets depends on which block it is
+ for (int32 j = 0; j < Platform::Pow2(i); j++)
+ {
+ // For every bucket in the block we need to destroy all object instances
+ Bucket& currentBucket = block.pMemory[j];
+ if (!Platform::IsPod::Value)
+ {
+ for (uint32 k = 0; k < currentBucket.footer.numEntries; k++)
+ {
+ currentBucket.entries[k].~Entry();
+ }
+ }
+
+ // We then overwrite the footer
+ currentBucket.footer = Footer();
+
+ // Ensure that the footer was correctly zero initialized
+ DD_ASSERT(currentBucket.footer.pNextBucket == nullptr);
+ DD_ASSERT(currentBucket.footer.numEntries == 0);
+ }
+
+ block.curBucket = 0;
+ }
+
+ // Reset the object count
+ m_numEntries = 0;
+ m_curBlock = -1;
+ }
+ }
+
+ /// Empty the hash container and dispose of all underlying allocations.
+ void Clear()
+ {
+ if (m_curBlock >= 0)
+ {
+ // Reset the bucket head pointers
+ memset(&m_buckets[0], 0, sizeof(m_buckets));
+
+ // Deallocate all blocks that have been allocated
+ for (int32 i = 0; i <= m_curBlock; ++i)
+ {
+ MemBlock& block = m_blocks[i];
+ if (block.pMemory != nullptr)
+ {
+ // If this was not a POD type we want to explicitly destroy the object
+ if (!Platform::IsPod::Value)
+ {
+ for (int32 j = 0; j < Platform::Pow2(i); j++)
+ {
+ Bucket& currentBucket = block.pMemory[j];
+ for (uint32 k = 0; k < currentBucket.footer.numEntries; k++)
+ {
+ currentBucket.entries[k].~Entry();
+ }
+ }
+ }
+
+ DD_FREE(block.pMemory, m_allocCb);
+ block.pMemory = nullptr;
+ block.curBucket = 0;
+ }
+ }
+
+ // Reset the object count
+ m_numEntries = 0;
+ m_curBlock = -1;
+ }
+ }
+
+ /// Returns true if the specified key exists in the set.
+ ///
+ /// @param [in] key Key to search for.
+ ///
+ /// @returns True if the specified key exists in the set.
+ bool Contains(const Key& key) const
+ {
+ // Get the bucket base address.
+ const Bucket* pBucket = FindBucket(key);
+ const Entry* pMatchingEntry = nullptr;
+
+ while ((pBucket != nullptr) && (pMatchingEntry == nullptr))
+ {
+ const Bucket& currentBucket = *pBucket;
+
+ // Search this entry group.
+ for (uint32 i = 0; i < currentBucket.footer.numEntries; i++)
+ {
+ const Entry& entry = currentBucket.entries[i];
+ if (this->m_equalFunc(entry.key, key))
+ {
+ // We've found the entry.
+ pMatchingEntry = &entry;
+ break;
+ }
+ }
+
+ // Chain to the next entry group.
+ pBucket = pBucket->footer.pNextBucket;
+ }
+
+ return (pMatchingEntry != nullptr);
+ }
+
+ /// Removes an entry that matches the specified key.
+ ///
+ /// @param [in] key Key of the entry to erase.
+ ///
+ /// @returns True if the erase completed successfully, false if an entry for this key did not exist.
+ Result Erase(const Key& key)
+ {
+ // Get the bucket base address.
+ Bucket* pBucket = this->FindBucket(key);
+ Entry* pFoundEntry = nullptr;
+
+ // Find the entry to delete
+ while (pBucket != nullptr && (pBucket->footer.numEntries > 0))
+ {
+ Bucket& currentBucket = *pBucket;
+
+ // Search each group
+ for (uint32 i = 0; i < currentBucket.footer.numEntries; i++)
+ {
+ Entry& entry = currentBucket.entries[i];
+ if (this->m_equalFunc(entry.key, key) == true)
+ {
+ // We shouldn't find the same key twice.
+ DD_ASSERT(pFoundEntry == nullptr);
+
+ pFoundEntry = &entry;
+ break;
+ }
+ }
+
+ if (pFoundEntry != nullptr)
+ break;
+
+ // Chain to the next entry group.
+ pBucket = currentBucket.footer.pNextBucket;
+ }
+
+ // Copy the last entry's data into the entry that we are removing and invalidate the last entry as it now appears
+ // earlier in the list. This also handles the case where the entry to be removed is the last entry.
+
+ if (pFoundEntry != nullptr)
+ {
+ Entry* pLastEntry = nullptr;
+ Bucket* pLastBucket = nullptr;
+
+ while (pBucket != nullptr && (pBucket->footer.numEntries > 0))
+ {
+ Bucket& currentBucket = *pBucket;
+
+ // keep track of last entry of all groups in bucket
+ pLastEntry = &(currentBucket.entries[currentBucket.footer.numEntries - 1]);
+ pLastBucket = pBucket;
+
+ // Chain to the next entry group.
+ pBucket = currentBucket.footer.pNextBucket;
+ }
+
+ DD_ASSERT(pLastEntry != nullptr);
+
+ // If this item isn't the last entry, then we move the last entry into it.
+ if (pFoundEntry != pLastEntry)
+ {
+ *pFoundEntry = Platform::Move(*pLastEntry);
+ }
+
+ // If it wasn't a POD type we need to explicitly invoke the destructor on the last entry
+ if (!Platform::IsPod::Value)
+ {
+ pLastEntry->~Entry();
+ }
+
+ DD_ASSERT(this->m_numEntries > 0);
+ this->m_numEntries--;
+ pLastBucket->footer.numEntries--;
+ }
+ return (pFoundEntry != nullptr) ? Result::Success : Result::Error;
+ }
+ protected:
+ class BaseIterator;
+
+ /// @internal Constructor
+ ///
+ /// @param [in] numBuckets Number of buckets to allocate for this hash container. The initial hash container
+ /// will take (buckets * DD_CACHE_LINE_BYTES) bytes.
+ /// @param [in] pAllocator The allocator that will allocate memory if required.
+ explicit HashBase(const AllocCb& allocCb) :
+ m_hashFunc(HashFunc(Platform::ConstLog2(kPaddedNumBuckets))),
+ m_equalFunc(EqualFunc()),
+ m_allocCb(allocCb),
+ m_numEntries(0),
+ m_blocks(),
+ m_curBlock(-1),
+ m_buckets()
+ {
+ }
+
+ ///// @internal Constructor
+ /////
+ ///// @param [in] numBuckets Number of buckets to allocate for this hash container. The initial hash container
+ ///// will take (buckets * DD_CACHE_LINE_BYTES) bytes.
+ ///// @param [in] pAllocator The allocator that will allocate memory if required.
+ HashBase(HashBase&& rhs) :
+ m_hashFunc(HashFunc(Platform::ConstLog2(kPaddedNumBuckets))),
+ m_equalFunc(EqualFunc()),
+ m_allocCb(rhs.m_allocCb),
+ m_numEntries(Platform::Exchange(rhs.m_numEntries, 0)),
+ m_curBlock(Platform::Exchange(rhs.m_curBlock, -1))
+ {
+ // Copy pointers to allocations made by the other container
+ memcpy(m_blocks, rhs.m_blocks, sizeof(m_blocks));
+ // Reset the object on the right hand side
+ memset(rhs.m_blocks, 0, sizeof(m_blocks));
+
+ // Copy the pointers from the right hand container
+ memcpy(m_buckets, rhs.m_buckets, sizeof(m_buckets));
+ // Reset the object on the right hand side
+ memset(rhs.m_buckets, 0, sizeof(m_buckets));
+ }
+
+ virtual ~HashBase()
+ {
+ Clear();
+ }
+
+ // ============================================================================================================
+ // Gets a pointer to the value that matches the key. Returns null if no entry is present matching the
+ // specified key.
+ Entry* FindEntry(const Key& key) const
+ {
+ // Get the bucket base address.
+ Bucket* pBucket = this->FindBucket(key);
+ Entry* pMatchingEntry = nullptr;
+
+ while (pBucket != nullptr)
+ {
+ Bucket& currentBucket = *pBucket;
+
+ // Search this entry group
+ for (uint32 i = 0; i < currentBucket.footer.numEntries; i++)
+ {
+ Entry& entry = currentBucket.entries[i];
+
+ if (this->m_equalFunc(entry.key, key))
+ {
+ // We've found the entry.
+ pMatchingEntry = &entry;
+ break;
+ }
+ }
+
+ if (pMatchingEntry != nullptr)
+ {
+ break;
+ }
+
+ // Chain to the next entry group.
+ pBucket = currentBucket.footer.pNextBucket;
+ }
+
+ return pMatchingEntry;
+ }
+
+ // ============================================================================================================
+ // Gets a BaseIterator to the value that matches the key. Returns invalid Iterator if the value is not found
+ BaseIterator FindIterator(const Key& key) const
+ {
+ // Get the bucket base address.
+ const uint32 bucket = m_hashFunc(&key) & (kPaddedNumBuckets - 1);
+ Bucket* pBucket = m_buckets[bucket];
+
+ while (pBucket != nullptr)
+ {
+ Bucket& currentBucket = *pBucket;
+
+ // Search this entry group
+ for (uint32 i = 0; i < currentBucket.footer.numEntries; i++)
+ {
+ if (this->m_equalFunc(currentBucket.entries[i].key, key))
+ {
+ // We've found the entry.
+ return BaseIterator(this, bucket, bucket, pBucket, i);
+ }
+ }
+
+ // Chain to the next entry group.
+ pBucket = currentBucket.footer.pNextBucket;
+ }
+
+ return BaseIterator(this, static_cast(kPaddedNumBuckets));
+ }
+
+ /// Finds a given entry; if no entry was found, allocate it.
+ ///
+ /// @param [in] key Key to search for.
+ /// @param [out] pExisted True if an entry for the specified key existed before this call was made. False
+ /// indicates that a new entry was allocated as a result of this call.
+ /// @returns @ref Readable/writeable value in the hash map corresponding to the specified key.
+ Entry* FindOrAllocate(const Key& key,
+ bool* pExisted = nullptr) // [out] True if a matching key was found.
+ {
+ // Get the bucket base address.
+ const uint32 bucket = m_hashFunc(&key) & (kPaddedNumBuckets - 1);
+ Bucket** ppBucket = &m_buckets[bucket];
+ bool existed = false;
+
+ Entry* pMatchingEntry = nullptr;
+
+ while (pMatchingEntry == nullptr)
+ {
+ Bucket* pBucket = *ppBucket;
+
+ if (pBucket == nullptr)
+ {
+ pBucket = AllocateBucket();
+ DD_ASSERT(pBucket != nullptr);
+
+ *ppBucket = pBucket;
+ }
+
+ Bucket& currentBucket = *pBucket;
+
+ // Search this entry group.
+ for (uint32 i = 0; i < currentBucket.footer.numEntries; i++)
+ {
+ Entry& entry = currentBucket.entries[i];
+ if (this->m_equalFunc(entry.key, key))
+ {
+ // We've found the entry.
+ pMatchingEntry = &entry;
+ existed = true;
+ break;
+ }
+ }
+
+ if ((pMatchingEntry == nullptr) & (currentBucket.footer.numEntries < kEntriesInBucket))
+ {
+ // We've reached the end of the bucket and the entry was not found. Allocate this entry for the key.
+ Entry& entry = currentBucket.entries[currentBucket.footer.numEntries];
+ new(&entry.key) Key(key);
+ pMatchingEntry = &entry;
+ currentBucket.footer.numEntries++;
+ this->m_numEntries++;
+ }
+
+ if (pMatchingEntry != nullptr)
+ {
+ break;
+ }
+
+ ppBucket = ¤tBucket.footer.pNextBucket;
+ }
+
+ if (pExisted != nullptr)
+ {
+ *pExisted = existed;
+ }
+ return pMatchingEntry;
+ }
+
+ /// Returns the bucket index containing the first element or an invalid bucket index if no buckets have been
+ /// allocated yet.
+ uint32 GetFirstBucket() const
+ {
+ uint32 bucket = 0;
+
+ if (m_numEntries != 0)
+ {
+ for (; bucket < kPaddedNumBuckets; ++bucket)
+ {
+ if ((m_buckets[bucket] != nullptr) && (m_buckets[bucket]->footer.numEntries > 0))
+ {
+ break;
+ }
+ }
+ }
+ else
+ {
+ // If the backing memory does not exist we should return an invalid bucket.
+ // This can be done by setting the start bucket such that it is off the end of the bucket list.
+ bucket = kPaddedNumBuckets;
+ }
+
+ return bucket;
+ }
+
+ /// Swaps the contents of this object with those of the object specified as a parameter.
+ void Swap(HashBase& other)
+ {
+ // exchange the stateful information
+ m_allocCb = Platform::Exchange(other.m_allocCb, m_allocCb);
+ m_numEntries = Platform::Exchange(other.m_numEntries, m_numEntries);
+ m_curBlock = Platform::Exchange(other.m_curBlock, m_curBlock);
+
+ // calculate how many blocks need to be swapped
+ const int32 numBlocks = Platform::Min(Platform::Max(m_curBlock, other.m_curBlock) + 1, kNumHashBlocks);
+
+ // exchange block pointers
+ for (int32 i = 0; i < numBlocks; i++)
+ {
+ m_blocks[i] = Platform::Exchange(other.m_blocks[i], m_blocks[i]);
+ }
+
+ // exchange bucket pointers
+ for (size_t i = 0; i < kPaddedNumBuckets; i++)
+ {
+ m_buckets[i] = Platform::Exchange(other.m_buckets[i], m_buckets[i]);
+ }
+ }
+
+ /// Removes an entry associated with the provided iterator
+ ///
+ /// @param [in] iterator BaseIterator created by the current object
+ ///
+ /// @returns True if the erase completed successfully, false if the iterator was invalid.
+ bool RemoveIterator(BaseIterator& iterator)
+ {
+ Entry* pFoundEntry = nullptr;
+ if ((iterator.m_pCurrentBucket != nullptr) & (iterator.m_pContainer == this))
+ {
+ // Get the bucket base address.
+ Bucket* pBucket = iterator.m_pCurrentBucket;
+
+ DD_ASSERT(this->m_numEntries > 0);
+
+ pFoundEntry = iterator.Get();
+
+ DD_ASSERT(pFoundEntry != nullptr);
+
+ // We need to look for the last entry in the current chain. We will then either swap this entry with
+ // last entry and destroy the object
+ Entry* pLastEntry = nullptr;
+ Bucket* pLastBucket = nullptr;
+
+ while (pBucket != nullptr && (pBucket->footer.numEntries > 0))
+ {
+ Bucket& currentBucket = *pBucket;
+
+ // keep track of last entry of all groups in bucket
+ pLastEntry = &(currentBucket.entries[currentBucket.footer.numEntries - 1]);
+ pLastBucket = pBucket;
+
+ // Chain to the next entry group.
+ pBucket = currentBucket.footer.pNextBucket;
+ }
+
+ DD_ASSERT(pLastEntry != nullptr);
+ DD_ASSERT(pLastBucket != nullptr);
+
+ this->m_numEntries--;
+ pLastBucket->footer.numEntries--;
+
+ if (pFoundEntry != pLastEntry)
+ {
+ *pFoundEntry = Platform::Move(*pLastEntry);
+ }
+ else
+ {
+ // This was the last entry in the current bucket, so we need to advance the iterator
+ iterator.Next();
+ }
+
+ // If the element we removed wasn't a POD type we need to explicitly invoke the destructor
+ if (!Platform::IsPod::Value)
+ {
+ pLastEntry->~Entry();
+ }
+
+ }
+ return (pFoundEntry != nullptr);
+ }
+
+ DD_STATIC_CONST size_t kPaddedNumBuckets = Platform::ConstPow2Pad(NumBuckets);
+ private:
+ struct Bucket;
+ struct Footer
+ {
+ Bucket* pNextBucket;
+ uint32 numEntries;
+ };
+
+ /// The native bucket size is going to be, at minimum, the size of an entry + footer,
+ /// aligned to the cache line.
+ DD_STATIC_CONST size_t kAlignedBucketSize =
+ Platform::Pow2Align(sizeof(Entry) + sizeof(Footer), DD_CACHE_LINE_BYTES);
+
+ /// We pick the larger of the native bucket size and the minimum bucket size to ensure
+ /// that we always have enough room for at least one object.
+ DD_STATIC_CONST size_t kBucketSize = Platform::Max(kAlignedBucketSize, MinimumBucketSize);
+
+ /// Number of entries in a single group.
+ DD_STATIC_CONST uint32 kEntriesInBucket = ((kBucketSize - sizeof(Footer)) / sizeof(Entry));
+
+ /// There must be at least one entry in each group.
+ static_assert((kEntriesInBucket >= 1), "Hash container entry is too big.");
+
+ struct Bucket
+ {
+ Entry entries[kEntriesInBucket];
+ Footer footer;
+ };
+
+ static_assert(sizeof(Bucket) <= kBucketSize, "Hash container entry is too big.");
+
+ struct MemBlock
+ {
+ Bucket* pMemory = nullptr; // Pointer to the memory allocated for this block.
+ int32 curBucket = 0; // Current group index to be allocated.
+ };
+
+ const HashFunc m_hashFunc; ///< @internal Hash functor object.
+ const EqualFunc m_equalFunc; ///< @internal Key compare function object.
+ AllocCb m_allocCb; ///< @internal Allocator for this hash allocation function.
+
+ uint32 m_numEntries; ///< @internal Entries in the table.
+
+ MemBlock m_blocks[kNumHashBlocks]; ///< @internal Memory blocks for memory allocations.
+ int32 m_curBlock; ///< @internal Current block index buckets can be allocated
+ ///< from. -1 indicates no memory has been allocated yet
+
+ Bucket* m_buckets[kPaddedNumBuckets]; ///< @internal Base address as allocated
+ ///< (before alignment).
+
+ /// @internal Finds the bucket that matches the specified key
+ ///
+ /// @param [in] key Key to find matching bucket for.
+ ///
+ /// @returns Pointer to the bucket corresponding to the specified key.
+ Bucket* FindBucket(const Key& key) const
+ {
+ const uint32 bucket = m_hashFunc(&key) & (kPaddedNumBuckets - 1);
+ return m_buckets[bucket];
+ }
+
+ /// Allocates a new block of memory.
+ ///
+ /// No size parameter, the size of allocation is fixed to the groupSize parameter specified in the constructor.
+ ///
+ /// @returns A pointer to the allocate memory, or null if the allocation failed.
+ Bucket* AllocateBucket()
+ {
+ Bucket* pMemory = nullptr;
+
+ // Leave pBlock null if this is the first allocation made with this object.
+ MemBlock* pBlock = (m_curBlock >= 0) ? &m_blocks[m_curBlock] : nullptr;
+
+ // If current block is used up (or we haven't allocated one yet), go to next.
+ if ((pBlock == nullptr) || (pBlock->curBucket >= Platform::Pow2(m_curBlock)))
+ {
+ // Only advance to the next block if the current one had memory allocated to it (which implies that it's
+ // full).
+ int32 nextBlock = m_curBlock;
+
+ if ((pBlock == nullptr) || (pBlock->pMemory != nullptr))
+ {
+ nextBlock++;
+ }
+
+ DD_ASSERT(nextBlock < kNumHashBlocks);
+
+ pBlock = &m_blocks[nextBlock];
+
+ DD_ASSERT(pBlock->curBucket == 0);
+
+ // Allocate memory if needed (note that this may rarely fail)
+ if (pBlock->pMemory == nullptr)
+ {
+ const size_t numBuckets = static_cast(Platform::Pow2(nextBlock));
+ const size_t allocSize = sizeof(Bucket) * numBuckets;
+ pBlock->pMemory = reinterpret_cast(DD_CALLOC(allocSize, alignof(Bucket), m_allocCb));
+ }
+
+ // If we successfully allocated memory (or the block already had some), make it current
+ if (pBlock->pMemory != nullptr)
+ {
+ m_curBlock = nextBlock;
+ }
+ }
+
+ if (pBlock->pMemory != nullptr)
+ {
+ pMemory = &pBlock->pMemory[pBlock->curBucket++];
+ }
+
+ return pMemory;
+ }
+ };
+
+ /**
+ ***********************************************************************************************************************
+ * @brief BaseIterator for traversal of elements in a Hash container.
+ *
+ * Backward iterating is not supported since there is no "footer" or "header" for a hash container.
+ ***********************************************************************************************************************
+ */
+ template<
+ typename Key,
+ typename Entry,
+ typename HashFunc,
+ typename EqualFunc,
+ size_t NumBuckets,
+ size_t MinimumBucketSize>
+ class HashBase::BaseIterator
+ {
+ protected:
+ /// Returns a pointer to current entry. Will return null if the iterator has been advanced off the end of the
+ /// container.
+ Entry* Get() const { return &m_pCurrentBucket->entries[m_indexInBucket]; }
+
+ // In order for an iterator to be considered equal it has to have the same:
+ // 1) Container
+ // 2) Current bucket
+ // 3) Index inside the bucket
+ // Note: this is not publicly exposed to prevent HashMap and HashSet from ever being directly comparable
+ bool Equals(const BaseIterator& rhs) const
+ {
+ return ((m_pContainer == rhs.m_pContainer) &
+ (m_currentBucket == rhs.m_currentBucket) &
+ (m_indexInBucket == rhs.m_indexInBucket));
+ }
+
+ /// Advances the iterator to the next position (move forward).
+ void Next()
+ {
+ if (m_pCurrentBucket != nullptr)
+ {
+ Bucket* pNextBucket = m_pCurrentBucket->footer.pNextBucket;
+
+ // We're in the middle of a group.
+ if ((m_indexInBucket < kEntriesInBucket) &&
+ (m_indexInBucket + 1 < m_pCurrentBucket->footer.numEntries))
+ {
+ m_indexInBucket++;
+ }
+ // We're in the last entry of a group.
+ // Considering that the next chained group could be an empty group already, it is better to check the
+ // next group's footer->numEntries before jump to the next group. If the numEntry of the next chained
+ // group is 0 (invalid), we need to jump to the next bucket directly to avoid returning invalid entry.
+ else if ((pNextBucket != nullptr) &&
+ (m_indexInBucket == m_pCurrentBucket->footer.numEntries - 1) &&
+ (pNextBucket->footer.numEntries > 0))
+ {
+ m_pCurrentBucket = pNextBucket;
+ m_indexInBucket = 0;
+ }
+ // The current bucket is done, step to the next.
+ else
+ {
+ do
+ {
+ m_currentBucket = (m_currentBucket + 1) % kPaddedNumBuckets;
+
+ pNextBucket = m_pContainer->m_buckets[m_currentBucket];
+
+ if (pNextBucket != nullptr && pNextBucket->footer.numEntries > 0)
+ {
+ m_indexInBucket = 0;
+ break;
+ }
+ } while (m_currentBucket != m_startBucket);
+
+ if (m_currentBucket != m_startBucket)
+ {
+ m_pCurrentBucket = pNextBucket;
+ m_indexInBucket = 0;
+ }
+ else
+ {
+ m_currentBucket = kPaddedNumBuckets;
+ m_pCurrentBucket = nullptr;
+ m_indexInBucket = 0;
+ }
+ }
+ }
+ }
+
+ // Constructor. BaseIterator objects should never be directly created by anything.
+ BaseIterator(
+ const HashBase* pContainer, ///< [retained] The hash container to iterate over
+ uint32 startBucket) ///< The beginning bucket
+ :
+ m_pContainer(pContainer),
+ m_startBucket(startBucket),
+ m_currentBucket(startBucket),
+ m_pCurrentBucket(nullptr),
+ m_indexInBucket(0)
+ {
+ if (startBucket < kPaddedNumBuckets)
+ {
+ m_pCurrentBucket = m_pContainer->m_buckets[m_startBucket];
+ }
+ }
+
+ // Constructor that allows returning an Iterator to a specific object.
+ // BaseIterator objects should never be directly created by anything.
+ constexpr BaseIterator(
+ const HashBase* pContainer, ///< [retained] The hash container to iterate over
+ uint32 startBucket,
+ uint32 currentBucket,
+ Bucket* pCurrentBucket,
+ uint32 bucketIndex) ///< The beginning bucket
+ :
+ m_pContainer(pContainer),
+ m_startBucket(startBucket),
+ m_currentBucket(currentBucket),
+ m_pCurrentBucket(pCurrentBucket),
+ m_indexInBucket(bucketIndex)
+ {
+ }
+
+ const HashBase* m_pContainer; // Hash container that we're iterating over.
+ uint32 m_startBucket; // Bucket where we start iterating.
+ uint32 m_currentBucket; // Current bucket we're iterating.
+ Bucket* m_pCurrentBucket; // Current group we're iterating (belongs to the current bucket).
+ uint32 m_indexInBucket; // Index of current entry in the group.
+
+ // Although this is a transgression of coding standards, it means that Container does not need to have a public
+ // interface specifically to implement this class. The added encapsulation this provides is worthwhile.
+ friend HashBase;
+ };
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashFunc.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashFunc.h
new file mode 100644
index 000000000..6d3276a25
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashFunc.h
@@ -0,0 +1,359 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2017-2018 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.
+ ******************************************************************************/
+ /**
+ ***********************************************************************************************************************
+ * @file hashFunc.h
+ * @brief Hashing and comparison functors used by HashMap and HashSet
+ ***********************************************************************************************************************
+ */
+
+#pragma once
+
+#include "gpuopen.h"
+#include "ddPlatform.h"
+#include "memory.h"
+#include
+
+namespace DevDriver
+{
+ /// Default hash functor.
+ ///
+ /// Just directly returns bits 31-6 of the key's first dword. This is a decent hash if the key is a pointer.
+ template
+ struct DefaultHashFunc
+ {
+ /// Shifts the key to the right and use the resulting bits as a uint hash.
+ ///
+ /// @param [in] pKey Pointer to the key to be hashed. If the key is a pointer, which is the best use case for
+ /// this hash function, then this is really a pointer to a pointer.
+ /// @returns 32-bit uint hash value.
+ uint32 operator()(const Key* pKey) const;
+
+ DefaultHashFunc(uint32 minNumBits) {
+ // Calculate how many bits of precision are left over after accounting for the number of buckets.
+ const uint32 remainingPrecision = (uint32)Platform::Max(((kLength * 8) - (size_t)minNumBits), (size_t)0);
+ // We are going to shift by either how much precision is remaining, or the default shift value of 6 bits.
+ DD_STATIC_CONST uint32 kDefaultShiftNum = 6; ///< Right shift bit number
+ m_shiftNum = Platform::Min(remainingPrecision, kDefaultShiftNum);
+ };
+
+ private:
+ uint32 m_shiftNum;
+ DD_STATIC_CONST size_t kLength = Platform::Min(sizeof(Key), sizeof(uint32)); ///< How many bytes we read.
+ };
+
+ /// Null hash functor.
+ ///
+ /// Simply returns up to the first 4 bytes of the key. This works well for small, consecutive values (e.g., uint8)
+ template
+ struct NullHashFunc
+ {
+ /// Returns up to the first 4 bytes of the key
+ ///
+ /// @param [in] pKey Pointer to the key to be hashed. If the key is a pointer, which is the best use case for
+ /// this hash function, then this is really a pointer to a pointer.
+ /// @returns 32-bit uint hash value.
+ uint32 operator()(const Key* pKey) const;
+
+ NullHashFunc(uint32 minNumBits)
+ {
+ DD_UNUSED(minNumBits);
+ };
+
+ private:
+ DD_STATIC_CONST size_t kLength = Platform::Min(sizeof(Key), sizeof(uint32)); ///< How many bytes we read.
+ };
+
+ /// Jenkins hash functor.
+ ///
+ /// Compute hash value according to the Jenkins algorithm. A description of the algorithm is found here:
+ /// http://burtleburtle.net/bob/hash/doobs.html
+ /// By Bob Jenkins, 1996. bob_jenkins@compuserve.com. You may use this
+ /// code any way you wish, private, educational, or commercial. It's free.
+ /// See http:\\ourworld.compuserve.com\homepages\bob_jenkins\evahash.htm
+ /// Use for hash table lookup, or anything where one collision in 2^^32 is
+ /// acceptable. Do NOT use for cryptographic purposes.
+ ///
+ template
+ struct JenkinsHashFunc
+ {
+ /// Hashes the specified key value via the Jenkins hash algorithm.
+ ///
+ /// @param [in] pKey Pointer to the key to be hashed.
+ /// @param [in] keyLen Amount of data at pVoidKey to hash, in bytes.
+ ///
+ /// @returns 32-bit uint hash value.
+ uint32 operator()(const Key* pKey, uint32 len = sizeof(Key)) const;
+
+ /// Initialize local state. Does nothing for Jenkins
+ JenkinsHashFunc(uint32 minNumBits)
+ {
+ DD_UNUSED(minNumBits);
+ };
+ };
+
+ /// Jenkins hash functor for C-style strings.
+ ///
+ /// Compute hash value according to the Jenkins algorithm. A description of the algorithm is found here:
+ /// http://burtleburtle.net/bob/hash/doobs.html
+ /// By Bob Jenkins, 1996. bob_jenkins@compuserve.com. You may use this
+ /// code any way you wish, private, educational, or commercial. It's free.
+ /// See http:\\ourworld.compuserve.com\homepages\bob_jenkins\evahash.htm
+ /// Use for hash table lookup, or anything where one collision in 2^^32 is
+ /// acceptable. Do NOT use for cryptographic purposes.
+ ///
+ /// @note This hash function is for char* keys only, since the regular JenkinsHashFunc will attempt to do a hash on the
+ /// address of the pointer, as opposed to the actual string.
+ template
+ struct StringJenkinsHashFunc : JenkinsHashFunc
+ {
+ /// Hashes the specified C-style string key via the Jenkins hash algorithm.
+ ///
+ /// @param [in] ppKey Pointer to the key string (i.e., this is a char**) to be hashed.
+ /// @param [in] keyLen Amount of data at pVoidKey to hash, in bytes. Should always be sizeof(char*).
+ ///
+ /// @returns 32-bit uint hash value.
+ uint32 operator()(const char** ppKey) const;
+
+ /// Initialize local state. Does nothing.
+ StringJenkinsHashFunc(uint32 minNumBits)
+ {
+ DD_UNUSED(minNumBits);
+ };
+ };
+
+ /// Generic compare functor for types that have defined the comparison operator
+ ///
+ /// Used by @ref HashBase to prevent defining compare functions for each type.
+ template
+ struct DefaultEqualFunc
+ {
+ /// Returns true if key1 and key2 are equal according to the equality operator
+ bool operator()(const Key& key1, const Key& key2) const
+ {
+ return (key1 == key2);
+ }
+ };
+
+ /// Generic compare functor for types with arbitrary size.
+ ///
+ /// Used by @ref HashBase to prevent defining compare functions for each type.
+ template
+ struct BitwiseEqualFunc
+ {
+ /// Returns true if key1 and key2 are equal (have identical memory contents).
+ bool operator()(const Key& key1, const Key& key2) const
+ {
+ return (memcmp(&key1, &key2, sizeof(Key)) == 0);
+ }
+ };
+
+ /// String compare functor for use with C-style strings. memcmp doesn't work well for strings, so this uses strcmp.
+ template
+ struct StringEqualFunc
+ {
+ /// Returns true if the strings in key1 and key2 are equal.
+ bool operator()(const Key& key1, const Key& key2) const;
+ };
+
+ // =====================================================================================================================
+ // Reads up to 4 bytes of the object passed as a value
+ template
+ inline uint32 ReadAsUint32(Key* pKey)
+ {
+ uint32 key = *reinterpret_cast(pKey);
+
+ switch (Platform::Min(sizeof(Key), sizeof(uint32)))
+ {
+ case 1:
+ key &= 0x000000FF;
+ break;
+ case 2:
+ key &= 0x0000FFFF;
+ break;
+ case 3:
+ key &= 0x00FFFFFF;
+ break;
+ default:
+ break;
+ }
+ return key;
+ }
+
+ // =====================================================================================================================
+ // Default hash function implementation. Simply shift the key to the right and use the resulting bits as the hash.
+ template
+ uint32 DefaultHashFunc::operator()(
+ const Key* pKey
+ ) const
+ {
+ return (ReadAsUint32(pKey) >> m_shiftNum);
+ }
+
+ // =====================================================================================================================
+ // Null hash function implementation. Simply returns up to the first 4 bytes of the key.
+ template
+ uint32 NullHashFunc::operator()(
+ const Key* pKey
+ ) const
+ {
+ return ReadAsUint32(pKey);
+ }
+
+ // =====================================================================================================================
+ // Hashes the specified key value with the Jenkins hash algorithm. Implementation based on the algorithm description
+ // found here: http://burtleburtle.net/bob/hash/doobs.html.
+ // By Bob Jenkins, 1996. bob_jenkins@compuserve.com. You may use this
+ // code any way you wish, private, educational, or commercial. It's free.
+ // See http:\\ourworld.compuserve.com\homepages\bob_jenkins\evahash.htm
+ // Use for hash table lookup, or anything where one collision in 2^^32 is
+ // acceptable. Do NOT use for cryptographic purposes.
+ template
+ uint32 JenkinsHashFunc::operator()(
+ const Key* pKey,
+ uint32 len
+ ) const
+ {
+ // Mixing table.
+ DD_STATIC_CONST uint8 MixTable[256] =
+ {
+ 251, 175, 119, 215, 81, 14, 79, 191, 103, 49, 181, 143, 186, 157, 0, 232,
+ 31, 32, 55, 60, 152, 58, 17, 237, 174, 70, 160, 144, 220, 90, 57, 223,
+ 59, 3, 18, 140, 111, 166, 203, 196, 134, 243, 124, 95, 222, 179, 197, 65,
+ 180, 48, 36, 15, 107, 46, 233, 130, 165, 30, 123, 161, 209, 23, 97, 16,
+ 40, 91, 219, 61, 100, 10, 210, 109, 250, 127, 22, 138, 29, 108, 244, 67,
+ 207, 9, 178, 204, 74, 98, 126, 249, 167, 116, 34, 77, 193, 200, 121, 5,
+ 20, 113, 71, 35, 128, 13, 182, 94, 25, 226, 227, 199, 75, 27, 41, 245,
+ 230, 224, 43, 225, 177, 26, 155, 150, 212, 142, 218, 115, 241, 73, 88, 105,
+ 39, 114, 62, 255, 192, 201, 145, 214, 168, 158, 221, 148, 154, 122, 12, 84,
+ 82, 163, 44, 139, 228, 236, 205, 242, 217, 11, 187, 146, 159, 64, 86, 239,
+ 195, 42, 106, 198, 118, 112, 184, 172, 87, 2, 173, 117, 176, 229, 247, 253,
+ 137, 185, 99, 164, 102, 147, 45, 66, 231, 52, 141, 211, 194, 206, 246, 238,
+ 56, 110, 78, 248, 63, 240, 189, 93, 92, 51, 53, 183, 19, 171, 72, 50,
+ 33, 104, 101, 69, 8, 252, 83, 120, 76, 135, 85, 54, 202, 125, 188, 213,
+ 96, 235, 136, 208, 162, 129, 190, 132, 156, 38, 47, 1, 7, 254, 24, 4,
+ 216, 131, 89, 21, 28, 133, 37, 153, 149, 80, 170, 68, 6, 169, 234, 151
+ };
+
+ const uint8* pByteKey = static_cast(pKey);
+
+ uint32 a = 0x9e3779b9; // The golden ratio; an arbitrary value.
+ uint32 b = a;
+ uint32 c = MixTable[pByteKey[0]]; // Arbitrary value.
+
+ // Handle most of the key.
+ while (len >= 12)
+ {
+ a = a + (pByteKey[0] + (static_cast(pByteKey[1]) << 8) +
+ (static_cast(pByteKey[2]) << 16) +
+ (static_cast(pByteKey[3]) << 24));
+ b = b + (pByteKey[4] + (static_cast(pByteKey[5]) << 8) +
+ (static_cast(pByteKey[6]) << 16) +
+ (static_cast(pByteKey[7]) << 24));
+ c = c + (pByteKey[8] + (static_cast(pByteKey[9]) << 8) +
+ (static_cast(pByteKey[10]) << 16) +
+ (static_cast(pByteKey[11]) << 24));
+
+ a = a - b; a = a - c; a = a ^ (c >> 13);
+ b = b - c; b = b - a; b = b ^ (a << 8);
+ c = c - a; c = c - b; c = c ^ (b >> 13);
+ a = a - b; a = a - c; a = a ^ (c >> 12);
+ b = b - c; b = b - a; b = b ^ (a << 16);
+ c = c - a; c = c - b; c = c ^ (b >> 5);
+ a = a - b; a = a - c; a = a ^ (c >> 3);
+ b = b - c; b = b - a; b = b ^ (a << 10);
+ c = c - a; c = c - b; c = c ^ (b >> 15);
+
+ pByteKey = pByteKey + 12;
+ len = len - 12;
+ }
+
+ // Handle last 11 bytes.
+ c = c + sizeof(Key);
+ switch (len)
+ {
+ case 11: c = c + (static_cast(pByteKey[10]) << 24); // fall through
+ case 10: c = c + (static_cast(pByteKey[9]) << 16); // fall through
+ case 9: c = c + (static_cast(pByteKey[8]) << 8); // fall through
+ // the first byte of c is reserved for the length
+ case 8: b = b + (static_cast(pByteKey[7]) << 24); // fall through
+ case 7: b = b + (static_cast(pByteKey[6]) << 16); // fall through
+ case 6: b = b + (static_cast(pByteKey[5]) << 8); // fall through
+ case 5: b = b + pByteKey[4]; // fall through
+ case 4: a = a + (static_cast(pByteKey[3]) << 24); // fall through
+ case 3: a = a + (static_cast(pByteKey[2]) << 16); // fall through
+ case 2: a = a + (static_cast(pByteKey[1]) << 8); // fall through
+ case 1: a = a + pByteKey[0]; // fall through
+ // case 0: nothing left to add
+ }
+
+ a = a - b; a = a - c; a = a ^ (c >> 13);
+ b = b - c; b = b - a; b = b ^ (a << 8);
+ c = c - a; c = c - b; c = c ^ (b >> 13);
+ a = a - b; a = a - c; a = a ^ (c >> 12);
+ b = b - c; b = b - a; b = b ^ (a << 16);
+ c = c - a; c = c - b; c = c ^ (b >> 5);
+ a = a - b; a = a - c; a = a ^ (c >> 3);
+ b = b - c; b = b - a; b = b ^ (a << 10);
+ c = c - a; c = c - b; c = c ^ (b >> 15);
+
+ return c;
+ }
+
+ // =====================================================================================================================
+ // Hashes the specified C-style string key with the Jenkins hash algorithm.
+ template
+ uint32 StringJenkinsHashFunc::operator()(
+ const char** ppKey
+ ) const
+ {
+ const char* pKey = *ppKey;
+ const uint32 keyLen = static_cast(strlen(pKey));
+
+ return JenkinsHashFunc::operator()(pKey, keyLen);
+ }
+
+ // =====================================================================================================================
+ // Returns true if the strings in key1 and key2 are the same.
+ template
+ bool StringEqualFunc::operator()(
+ const Key& key1,
+ const Key& key2
+ ) const
+ {
+ bool ret = false;
+
+ // Can't do strcmp on null.
+ if ((key1 != nullptr) & (key2 != nullptr))
+ {
+ ret = (strcmp(key1, key2) == 0);
+ }
+ else if ((key1 == nullptr) & (key2 == nullptr))
+ {
+ ret = true;
+ }
+
+ return ret;
+ }
+}
diff --git a/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashMap.h b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashMap.h
new file mode 100644
index 000000000..e0622c1c8
--- /dev/null
+++ b/renderdoc/driver/ihv/amd/official/RGP/DevDriverComponents/inc/util/hashMap.h
@@ -0,0 +1,393 @@
+/*
+ *******************************************************************************
+ *
+ * Copyright (c) 2017-2018 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.
+ ******************************************************************************/
+ /**
+ ***********************************************************************************************************************
+ * @file hashMap.h
+ * @brief Templated class implementing key/value map semantics
+ ***********************************************************************************************************************
+ */
+
+#pragma once
+
+#include "hashBase.h"
+
+namespace DevDriver
+{
+
+ /// Encapsulates one key/value pair in a hash map.
+ template
+ struct HashMapEntry
+ {
+ Key key; ///< Hash map entry key.
+ Value value; ///< Hash map entry value.
+ };
+
+ /**
+ ***********************************************************************************************************************
+ * @brief Templated hash map container.
+ *
+ * This container is meant for storing elements of an arbitrary (but uniform) key/value type. Supported operations:
+ *
+ * - Searching
+ * - Insertion
+ * - Deletion
+ * - Iteration
+ *
+ * HashFunc is a functor for hashing keys. Built-in choices for HashFunc are:
+ *
+ * - DefaultHashFunc: Good choice when the key is a pointer.
+ * - JenkinsHashFunc: Good choice when the key is arbitrary binary data.
+ * - StringJenkinsHashFunc: Good choice when the key is a C-style string.
+ *
+ * EqualFunc is a functor for comparing keys. Built-in choices for EqualFunc are:
+ *
+ * - DefaultEqualFunc: Determines keys are equal using teh equality operator.
+ * - BitwiseEqualFunc: Determines keys are equal by bitwise comparison.
+ * - StringEqualFunc: Treats keys as a char* and compares them as C-style strings.
+ *
+ * @warning This class is not thread-safe for Insert, FindAllocate, Erase, or iteration!
+ * @warning Init() must be called before using this container. Begin() and Reset() can be safely called before
+ * initialization and Begin() will always return an iterator that points to null.
+ *
+ * For more details please refer to @ref HashBase.
+ ***********************************************************************************************************************
+ */
+ template class HashFunc = DefaultHashFunc,
+ template