From b645215f5917a573c022dcb2698c02decae0a729 Mon Sep 17 00:00:00 2001 From: Nikita Krupitskas Date: Mon, 25 Nov 2024 20:54:18 +0100 Subject: [PATCH] Initial aftermath addition --- .gitattributes | 2 + .gitignore | 3 +- Vendor/nvidia-aftermath/LICENSE | 601 ++++++++ Vendor/nvidia-aftermath/Readme.md | 1206 ++++++++++++++++ .../include/GFSDK_Aftermath.h | 639 ++++++++ .../include/GFSDK_Aftermath_Defines.h | 288 ++++ .../include/GFSDK_Aftermath_GpuCrashDump.h | 477 ++++++ .../GFSDK_Aftermath_GpuCrashDumpDecoding.h | 1284 +++++++++++++++++ .../lib/x64/GFSDK_Aftermath_Lib.x64.dll | 3 + .../lib/x64/GFSDK_Aftermath_Lib.x64.lib | 3 + .../nsight-aftermath-usage-guidelines.txt | 22 + 11 files changed, 4526 insertions(+), 2 deletions(-) create mode 100644 Vendor/nvidia-aftermath/LICENSE create mode 100644 Vendor/nvidia-aftermath/Readme.md create mode 100644 Vendor/nvidia-aftermath/include/GFSDK_Aftermath.h create mode 100644 Vendor/nvidia-aftermath/include/GFSDK_Aftermath_Defines.h create mode 100644 Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDump.h create mode 100644 Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDumpDecoding.h create mode 100644 Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.dll create mode 100644 Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.lib create mode 100644 Vendor/nvidia-aftermath/nsight-aftermath-usage-guidelines.txt diff --git a/.gitattributes b/.gitattributes index d815ea0..47c3297 100644 --- a/.gitattributes +++ b/.gitattributes @@ -3,3 +3,5 @@ *.gltf filter=lfs diff=lfs merge=lfs -text *.jpg filter=lfs diff=lfs merge=lfs -text *.hdr filter=lfs diff=lfs merge=lfs -text +*.dll filter=lfs diff=lfs merge=lfs -text +*.lib filter=lfs diff=lfs merge=lfs -text diff --git a/.gitignore b/.gitignore index 26d6edf..671fe58 100644 --- a/.gitignore +++ b/.gitignore @@ -14,8 +14,6 @@ mono_crash.* [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ -x64/ -x86/ [Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ @@ -376,3 +374,4 @@ FodyWeavers.xsd *.sln.iml .idea/ +!Vendor/ \ No newline at end of file diff --git a/Vendor/nvidia-aftermath/LICENSE b/Vendor/nvidia-aftermath/LICENSE new file mode 100644 index 0000000..45c6adf --- /dev/null +++ b/Vendor/nvidia-aftermath/LICENSE @@ -0,0 +1,601 @@ +Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved. + +NVIDIA CORPORATION and its licensors retain all intellectual property and proprietary +rights in and to this software, related documentation and any modifications thereto. Any +use, reproduction, disclosure or distribution of this software and related documentation +without an express license agreement from NVIDIA CORPORATION is strictly prohibited. + +LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT KITS + +This license agreement, including exhibits attached ("Agreement") is a legal agreement +between you and NVIDIA Corporation ("NVIDIA") and governs your use of a NVIDIA software +development kit ("SDK"). + +Each SDK has its own set of software and materials, but here is a description of the types +of items that may be included in a SDK: source code, header files, APIs, data sets and +assets (examples include images, textures, models, scenes, videos, native API input/output +files), binary software, sample code, libraries, utility programs, programming code and +documentation. + +This Agreement can be accepted only by an adult of legal age of majority in the country in +which the SDK is used. + +If you are entering into this Agreement on behalf of a company or other legal entity, you +represent that you have the legal authority to bind the entity to this Agreement, in which +case "you" will mean the entity you represent. + +If you don't have the required age or authority to accept this Agreement, or if you don't +accept all the terms and conditions of this Agreement, do not download, install or use the +SDK. + +You agree to use the SDK only for purposes that are permitted by (a) this Agreement, and +(b) any applicable law, regulation or generally accepted practices or guidelines in the +relevant jurisdictions. + +1. License. + +1.1 Grant + +Subject to the terms of this Agreement, NVIDIA hereby grants you a non-exclusive, +non-transferable license, without the right to sublicense (except as expressly provided in +this Agreement) to: + +(i) Install and use the SDK, and + +(ii) Distribute those portions of the SDK that are identified in this Agreement as +distributable, as incorporated in object code format into a software application that +meets the distribution requirements indicated in this Agreement. + +1.2 Distribution Requirements + +These are the distribution requirements for you to exercise the distribution grant: + +(i) Your application must have material additional functionality, beyond the included +portions of the SDK. + +(ii) The distributable portions of the SDK shall only be accessed by your application. + +(iii) The following notice shall be included in modifications and derivative works of +sample source code distributed: "This software contains source code provided by NVIDIA +Corporation." + +(iv) Unless a developer tool is identified in this Agreement as distributable, it is +delivered for your internal use only. + +(v) The terms under which you distribute your application must be consistent with the +terms of this Agreement, including (without limitation) terms relating to the license +grant and license restrictions and protection of NVIDIA's intellectual property rights. +Additionally, you agree that you will protect the privacy, security and legal rights of +your application users. + +(vi) You agree to notify NVIDIA in writing of any known or suspected distribution or use +of the SDK not in compliance with the requirements of this Agreement, and to enforce the +terms of your agreements with respect to distributed SDK. + +1.3 Authorized Users + +You may allow employees and contractors of your entity or of your subsidiary(ies) to +access and use the SDK from your secure network to perform work on your behalf. + +If you are an academic institution you may allow users enrolled or employed by the +academic institution to access and use the SDK from your secure network. + +You are responsible for the compliance with the terms of this Agreement by your authorized +users. If you become aware that your authorized users didn't follow the terms of this +Agreement, you agree to take reasonable steps to resolve the non-compliance and prevent +new occurrences. + +1.4 Pre-Release SDK + +The SDK versions identified as alpha, beta, preview or otherwise as pre-release, may not +be fully functional, may contain errors or design flaws, and may have reduced or different +security, privacy, accessibility, availability, and reliability standards relative to +commercial versions of NVIDIA software and materials. Use of a pre-release SDK may result +in unexpected results, loss of data, project delays or other unpredictable damage or loss. +You may use a pre-release SDK at your own risk, understanding that pre-release SDKs are +not intended for use in production or business-critical systems. NVIDIA may choose not to +make available a commercial version of any pre-release SDK. NVIDIA may also choose to +abandon development and terminate the availability of a pre-release SDK at any time +without liability. + +1.5 Updates + +NVIDIA may, at its option, make available patches, workarounds or other updates to this +SDK. Unless the updates are provided with their separate governing terms, they are deemed +part of the SDK licensed to you as provided in this Agreement. + +You agree that the form and content of the SDK that NVIDIA provides may change without +prior notice to you. While NVIDIA generally maintains compatibility between versions, +NVIDIA may in some cases make changes that introduce incompatibilities in future versions +of the SDK. + +1.6 Third Party Licenses + +The SDK may come bundled with, or otherwise include or be distributed with, third party +software licensed by a NVIDIA supplier and/or open source software provided under an open +source license. Use of third-party software is subject to the third-party license terms, +or in the absence of third party terms, the terms of this Agreement. Copyright to +third-party software is held by the copyright holders indicated in the third-party +software or license. + +1.7 Reservation of Rights + +NVIDIA reserves all rights, title and interest in and to the SDK not expressly granted to +you under this Agreement. + +2. Limitations. + +The following license limitations apply to your use of the SDK: + +2.1 You may not reverse engineer, decompile or disassemble, or remove copyright or other +proprietary notices from any portion of the SDK or copies of the SDK. + +2.2 Except as expressly provided in this Agreement, you may not copy, sell, rent, +sublicense, transfer, distribute, modify, or create derivative works of any portion of the +SDK. + +2.3 Unless you have an agreement with NVIDIA for this purpose, you may not indicate that +an application created with the SDK is sponsored or endorsed by NVIDIA. + +2.4 You may not bypass, disable, or circumvent any encryption, security, digital rights +management or authentication mechanism in the SDK. + +2.5 You may not use the SDK in any manner that would cause it to become subject to an open +source software license. As examples, licenses that require as a condition of use, +modification, and/or distribution that the SDK be (i) disclosed or distributed in source +code form; (ii) licensed for the purpose of making derivative works; or (iii) +redistributable at no charge. + +2.6 Unless you have an agreement with NVIDIA for this purpose, you may not use the SDK +with any system or application where the use or failure of the system or application can +reasonably be expected to threaten or result in personal injury, death, or catastrophic +loss. Examples include use in nuclear, avionics, navigation, military, medical, life +support or other life critical applications. NVIDIA does not design, test or manufacture +the SDK for these critical uses and NVIDIA shall not be liable to you or any third party, +in whole or in part, for any claims or damages arising from such uses. + +2.7 You agree to defend, indemnify and hold harmless NVIDIA and its affiliates, and their +respective employees, contractors, agents, officers and directors, from and against any +and all claims, damages, obligations, losses, liabilities, costs or debt, fines, +restitutions and expenses (including but not limited to attorney's fees and costs incident +to establishing the right of indemnification) arising out of or related to your use of the +SDK outside of the scope of this Agreement, or not in compliance with its terms. + +3. Ownership. + +3.1 NVIDIA or its licensors hold all rights, title and interest in and to the SDK and its +modifications and derivative works, including their respective intellectual property +rights. This SDK may include software and materials from NVIDIA's licensors, and these +licensors are intended third party beneficiaries that may enforce this Agreement with +respect to their intellectual property rights. + +3.2 You may, but don't have to, provide to NVIDIA suggestions, feature requests or other +feedback regarding the SDK, including possible enhancements or modifications to the SDK. +For any feedback that you voluntarily provide, you hereby grant NVIDIA and its affiliates +a perpetual, non-exclusive, worldwide, irrevocable license to use, reproduce, modify, +license, sublicense (through multiple tiers of sublicensees), and distribute (through +multiple tiers of distributors) it without the payment of any royalties or fees to you. +NVIDIA will use feedback at its choice. NVIDIA is constantly looking for ways to improve +its products, so you may send feedback to NVIDIA through the developer portal at +https://developer.nvidia.com. + +4. No Warranties. + +THE SDK IS PROVIDED BY NVIDIA "AS IS" AND "WITH ALL FAULTS." TO THE MAXIMUM EXTENT +PERMITTED BY LAW, NVIDIA AND ITS AFFILIATES EXPRESSLY DISCLAIM ALL WARRANTIES OF ANY KIND +OR NATURE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, ANY +WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE, NON-INFRINGEMENT, +OR THE ABSENCE OF ANY DEFECTS THEREIN, WHETHER LATENT OR PATENT. NO WARRANTY IS MADE ON +THE BASIS OF TRADE USAGE, COURSE OF DEALING OR COURSE OF TRADE. + +5. Limitations of Liability. + +TO THE MAXIMUM EXTENT PERMITTED BY LAW, NVIDIA AND ITS AFFILIATES SHALL NOT BE LIABLE FOR +ANY SPECIAL, INCIDENTAL, PUNITIVE OR CONSEQUENTIAL DAMAGES, OR ANY LOST PROFITS, LOSS OF +USE, LOSS OF DATA OR LOSS OF GOODWILL, OR THE COSTS OF PROCURING SUBSTITUTE PRODUCTS, +ARISING OUT OF OR IN CONNECTION WITH THIS AGREEMENT OR THE USE OR PERFORMANCE OF THE SDK, +WHETHER SUCH LIABILITY ARISES FROM ANY CLAIM BASED UPON BREACH OF CONTRACT, BREACH OF +WARRANTY, TORT (INCLUDING NEGLIGENCE), PRODUCT LIABILITY OR ANY OTHER CAUSE OF ACTION OR +THEORY OF LIABILITY. IN NO EVENT WILL NVIDIA'S AND ITS AFFILIATES TOTAL CUMULATIVE +LIABILITY UNDER OR ARISING OUT OF THIS AGREEMENT EXCEED US$10.00. THE NATURE OF THE +LIABILITY OR THE NUMBER OF CLAIMS OR SUITS SHALL NOT ENLARGE OR EXTEND THIS LIMIT. + +These exclusions and limitations of liability shall apply regardless if NVIDIA or its +affiliates have been advised of the possibility of such damages, and regardless of whether +a remedy fails its essential purpose. These exclusions and limitations of liability form +an essential basis of the bargain between the parties, and, absent any of these exclusions +or limitations of liability, the provisions of this Agreement, including, without +limitation, the economic terms, would be substantially different. + +6. Termination. + +6.1 This Agreement will continue to apply until terminated by either you or NVIDIA as +described below. + +6.2 If you want to terminate this Agreement, you may do so by stopping to use the SDK. + +6.3 NVIDIA may, at any time, terminate this Agreement if: (i) you fail to comply with any +term of this Agreement and the non-compliance is not fixed within thirty (30) days +following notice from NVIDIA (or immediately if you violate NVIDIA's intellectual property +rights); (ii) you commence or participate in any legal proceeding against NVIDIA with +respect to the SDK; or (iii) NVIDIA decides to no longer provide the SDK in a country or, +in NVIDIA's sole discretion, the continued use of it is no longer commercially viable. + +6.4 Upon any termination of this Agreement, you agree to promptly discontinue use of the +SDK and destroy all copies in your possession or control. Your prior distributions in +accordance with this Agreement are not affected by the termination of this Agreement. Upon +written request, you will certify in writing that you have complied with your commitments +under this section. Upon any termination of this Agreement all provisions survive except +for the licenses granted to you. + +7. General. + +If you wish to assign this Agreement or your rights and obligations, including by merger, +consolidation, dissolution or operation of law, contact NVIDIA to ask for permission. Any +attempted assignment not approved by NVIDIA in writing shall be void and of no effect. +NVIDIA may assign, delegate or transfer this Agreement and its rights and obligations, and +if to a non-affiliate you will be notified. + +You agree to cooperate with NVIDIA and provide reasonably requested information to verify +your compliance with this Agreement. + +This Agreement will be governed in all respects by the laws of the United States and of +the State of Delaware as those laws are applied to contracts entered into and performed +entirely within Delaware by Delaware residents, without regard to the conflicts of laws +principles. The United Nations Convention on Contracts for the International Sale of Goods +is specifically disclaimed. You agree to all terms of this Agreement in the English +language. + +The state or federal courts residing in Santa Clara County, California shall have +exclusive jurisdiction over any dispute or claim arising out of this Agreement. +Notwithstanding this, you agree that NVIDIA shall still be allowed to apply for injunctive +remedies or an equivalent type of urgent legal relief in any jurisdiction. + +If any court of competent jurisdiction determines that any provision of this Agreement is +illegal, invalid or unenforceable, such provision will be construed as limited to the +extent necessary to be consistent with and fully enforceable under the law and the +remaining provisions will remain in full force and effect. Unless otherwise specified, +remedies are cumulative. + +Each party acknowledges and agrees that the other is an independent contractor in the +performance of this Agreement. + +The SDK has been developed entirely at private expense and is "commercial items" +consisting of "commercial computer software" and "commercial computer software +documentation" provided with RESTRICTED RIGHTS. Use, duplication or disclosure by the U.S. +Government or a U.S. Government subcontractor is subject to the restrictions in this +Agreement pursuant to DFARS 227.7202-3(a) or as set forth in subparagraphs (b)(1) and (2) +of the Commercial Computer Software - Restricted Rights clause at FAR 52.227-19, as +applicable. Contractor/manufacturer is NVIDIA, 2788 San Tomas Expressway, Santa Clara, CA +95051. + +The SDK is subject to United States export laws and regulations. You agree that you will +not ship, transfer or export the SDK into any country, or use the SDK in any manner, +prohibited by the United States Bureau of Industry and Security or economic sanctions +regulations administered by the U.S. Department of Treasury's Office of Foreign Assets +Control (OFAC), or any applicable export laws, restrictions or regulations. These laws +include restrictions on destinations, end users and end use. By accepting this Agreement, +you confirm that you are not a resident or citizen of any country currently embargoed by +the U.S. and that you are not otherwise prohibited from receiving the SDK. + +Any notice delivered by NVIDIA to you under this Agreement will be delivered via mail, +email or fax. You agree that any notices that NVIDIA sends you electronically will satisfy +any legal communication requirements. Please direct your legal notices or other +correspondence to NVIDIA Corporation, 2788 San Tomas Expressway, Santa Clara, California +95051, United States of America, Attention: Legal Department. + +This Agreement and any exhibits incorporated into this Agreement constitute the entire +agreement of the parties with respect to the subject matter of this Agreement and +supersede all prior negotiations or documentation exchanged between the parties relating +to this SDK license. Any additional and/or conflicting terms on documents issued by you +are null, void, and invalid. Any amendment or waiver under this Agreement shall be in +writing and signed by representatives of both parties. + +(v. July 22, 2019) + +NSIGHT AFTERMATH SUPPLEMENT TO SOFTWARE LICENSE AGREEMENT FOR NVIDIA SOFTWARE DEVELOPMENT +KITS + +The terms in this supplement govern your use of the NVIDIA Nsight Aftermath SDK under the +terms of your license agreement ("Agreement") as modified by this supplement. Capitalized +terms used but not defined below have the meaning assigned to them in the Agreement. + +This supplement is an exhibit to the Agreement and is incorporated as an integral part of +the Agreement. In the event of conflict between the terms in this supplement and the terms +in the Agreement, the terms in this supplement govern. + +1. Distribution. + +The following portions of the SDK are distributable under the Agreement: the .dll / .so files. + +2. Usage. + +Please read the accompanying usage guidelines document (nsight-aftermath-usage-guidelines.txt) +for information on how Nsight Aftermath is intended to be used. + +(v. October 30, 2019) + + +------------------------------------------------------------------------------------------ +------------------------------------------------------------------------------------------ + +The Nsight Aftermath SDK makes use of third-party libraries. The licensee's use of the +SDK is subject to the following additional terms and conditions: + +JSON for Modern C++ (https://nlohmann.github.io/json/) + + The class is licensed under the MIT License: + + Copyright (c) 2013-2019 Niels Lohmann + + 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. + + The class contains the UTF-8 Decoder from Bjoern Hoehrmann which is licensed under the + MIT License (see above). Copyright (c) 2008-2009 Björn Hoehrmann bjoern@hoehrmann.de + + The class contains a slightly modified version of the Grisu2 algorithm from Florian + Loitsch which is licensed under the MIT License (see above). Copyright (c) 2009 + Florian Loitsch + + +FlatBuffers: Memory Efficient Serialization Library (http://google.github.io/flatbuffers/) + + Apache License Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, and distribution + as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by the copyright owner + that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all other entities that + control, are controlled by, or are under common control with that entity. For the + purposes of this definition, "control" means (i) the power, direct or indirect, to + cause the direction or management of such entity, whether by contract or otherwise, or + (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) + beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity exercising permissions + granted by this License. + + "Source" form shall mean the preferred form for making modifications, including but + not limited to software source code, documentation source, and configuration files. + + "Object" form shall mean any form resulting from mechanical transformation or + translation of a Source form, including but not limited to compiled object code, + generated documentation, and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or Object form, made + available under the License, as indicated by a copyright notice that is included in or + attached to the work (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object form, that is + based on (or derived from) the Work and for which the editorial revisions, + annotations, elaborations, or other modifications represent, as a whole, an original + work of authorship. For the purposes of this License, Derivative Works shall not + include works that remain separable from, or merely link (or bind by name) to the + interfaces of, the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including the original version of + the Work and any modifications or additions to that Work or Derivative Works thereof, + that is intentionally submitted to Licensor for inclusion in the Work by the copyright + owner or by an individual or Legal Entity authorized to submit on behalf of the + copyright owner. For the purposes of this definition, "submitted" means any form of + electronic, verbal, or written communication sent to the Licensor or its + representatives, including but not limited to communication on electronic mailing + lists, source code control systems, and issue tracking systems that are managed by, or + on behalf of, the Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise designated in + writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom + a Contribution has been received by Licensor and subsequently incorporated within the + Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of this License, + each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, + no-charge, royalty-free, irrevocable copyright license to reproduce, prepare + Derivative Works of, publicly display, publicly perform, sublicense, and distribute + the Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of this License, each + Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, + royalty-free, irrevocable (except as stated in this section) patent license to make, + have made, use, offer to sell, sell, import, and otherwise transfer the Work, where + such license applies only to those patent claims licensable by such Contributor that + are necessarily infringed by their Contribution(s) alone or by combination of their + Contribution(s) with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a cross-claim or + counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated + within the Work constitutes direct or contributory patent infringement, then any + patent licenses granted to You under this License for that Work shall terminate as of + the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative + Works thereof in any medium, with or without modifications, and in Source or Object + form, provided that You meet the following conditions: + + (a) You must give any other recipients of the Work or Derivative Works a copy of this + License; and + + (b) You must cause any modified files to carry prominent notices stating that You + changed the files; and + + (c) You must retain, in the Source form of any Derivative Works that You distribute, + all copyright, patent, trademark, and attribution notices from the Source form of the + Work, excluding those notices that do not pertain to any part of the Derivative Works; + and + + (d) If the Work includes a "NOTICE" text file as part of its distribution, then any + Derivative Works that You distribute must include a readable copy of the attribution + notices contained within such NOTICE file, excluding those notices that do not pertain + to any part of the Derivative Works, in at least one of the following places: within a + NOTICE text file distributed as part of the Derivative Works; within the Source form + or documentation, if provided along with the Derivative Works; or, within a display + generated by the Derivative Works, if and wherever such third-party notices normally + appear. The contents of the NOTICE file are for informational purposes only and do not + modify the License. You may add Your own attribution notices within Derivative Works + that You distribute, alongside or as an addendum to the NOTICE text from the Work, + provided that such additional attribution notices cannot be construed as modifying the + License. + + You may add Your own copyright statement to Your modifications and may provide + additional or different license terms and conditions for use, reproduction, or + distribution of Your modifications, or for any such Derivative Works as a whole, + provided Your use, reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, any + Contribution intentionally submitted for inclusion in the Work by You to the Licensor + shall be under the terms and conditions of this License, without any additional terms + or conditions. Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed with Licensor + regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade names, + trademarks, service marks, or product names of the Licensor, except as required for + reasonable and customary use in describing the origin of the Work and reproducing the + content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, + Licensor provides the Work (and each Contributor provides its Contributions) on an "AS + IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, + including, without limitation, any warranties or conditions of TITLE, + NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely + responsible for determining the appropriateness of using or redistributing the Work + and assume any risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, whether in tort + (including negligence), contract, or otherwise, unless required by applicable law + (such as deliberate and grossly negligent acts) or agreed to in writing, shall any + Contributor be liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a result of this + License or out of the use or inability to use the Work (including but not limited to + damages for loss of goodwill, work stoppage, computer failure or malfunction, or any + and all other commercial damages or losses), even if such Contributor has been advised + of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing the Work or + Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of + support, warranty, indemnity, or other liability obligations and/or rights consistent + with this License. However, in accepting such obligations, You may act only on Your + own behalf and on Your sole responsibility, not on behalf of any other Contributor, + and only if You agree to indemnify, defend, and hold each Contributor harmless for any + liability incurred by, or claims asserted against, such Contributor by reason of your + accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following boilerplate notice, + with the fields enclosed by brackets "[]" replaced with your own identifying + information. (Don't include the brackets!) The text should be enclosed in the + appropriate comment syntax for the file format. We also recommend that a file or class + name and description of purpose be included on the same "printed page" as the + copyright notice for easier identification within third-party archives. + + Copyright 2014 Google Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); you may not use this + file except in compliance with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software distributed under + the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF + ANY KIND, either express or implied. See the License for the specific language + governing permissions and limitations under the License. + + +The LLVM Compiler Infrastructure (http://llvm.org/) + + ============================================================================== + LLVM Release License + ============================================================================== + University of Illinois/NCSA + Open Source License + + Copyright (c) 2003-2018 University of Illinois at Urbana-Champaign. + All rights reserved. + + Developed by: + + LLVM Team + + University of Illinois at Urbana-Champaign + + http://llvm.org + + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal with + 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: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimers. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimers in the + documentation and/or other materials provided with the distribution. + + * Neither the names of the LLVM Team, University of Illinois at + Urbana-Champaign, nor the names of its contributors may be used to + endorse or promote products derived from this Software without specific + prior written permission. + + 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 + CONTRIBUTORS 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 WITH THE + SOFTWARE. + + ============================================================================== + Copyrights and Licenses for Third Party Software Distributed with LLVM: + ============================================================================== + The LLVM software contains code written by third parties. Such software will + have its own individual LICENSE.TXT file in the directory in which it appears. + This file will describe the copyrights, license, and restrictions which apply + to that code. + + The disclaimer of warranty in the University of Illinois Open Source License + applies to all code in the LLVM Distribution, and nothing in any of the + other licenses gives permission to use the names of the LLVM Team or the + University of Illinois to endorse or promote products derived from this + Software. + + The following pieces of software have additional or alternate copyrights, + licenses, and/or restrictions: + + Program Directory + ------- --------- + Google Test llvm/utils/unittest/googletest + OpenBSD regex llvm/lib/Support/{reg*, COPYRIGHT.regex} + pyyaml tests llvm/test/YAMLParser/{*.data, LICENSE.TXT} + ARM contributions llvm/lib/Target/ARM/LICENSE.TXT + md5 contributions llvm/lib/Support/MD5.cpp llvm/include/llvm/Support/MD5.h + diff --git a/Vendor/nvidia-aftermath/Readme.md b/Vendor/nvidia-aftermath/Readme.md new file mode 100644 index 0000000..0d832c8 --- /dev/null +++ b/Vendor/nvidia-aftermath/Readme.md @@ -0,0 +1,1206 @@ +# Nsight Aftermath SDK + +Aftermath is a compact, easy to use C/C++ library aimed at developers of D3D12 +or Vulkan based applications on Microsoft Windows or Linux, enabling post-mortem +GPU crash analysis on NVIDIA GeForce based GPUs. + +## Key Features + +The Nsight Aftermath SDK is an easy to use C/C++ API (shared libraries + header +files), which provides support for three major use cases: + +* GPU crash dump creation + +* GPU crash dump analysis + +* Application instrumentation with light-weight GPU event markers + +Nsight Aftermath's GPU crash dump collection performance footprint is low +enough to include in a shipping application - allowing developers to mine +details on why the GPU crashed in the wild, and gather GPU crash dumps for +further analysis (should the required cloud infrastructure already exist). + +## Application Instrumentation with Event Markers + +In its basic form, this works by allowing programmers to insert markers into +the GPU pipeline, which can be read post-TDR, to determine what work item the +GPU was processing at the point of failure. Nsight Aftermath also includes a +facility to query the current device state, much like the conventional graphics +APIs, but reporting a finer grained reason. + +One of the key principles of Aftermath is for the marker insertion to be as +unobtrusive as possible. Avoiding situations common with other similar +debuggers, where their associated performance cost changes timing enough to +make a bug repro vanish: a "Heisenbug". Aftermath avoids this problem by using +a very light-weight event marker design. + +Nevertheless, there is still considerable performance overhead associated with +event markers and they should be used only for debugging purposes on development +or QA systems. Therefore, on some versions of NVIDIA graphics drivers, +Aftermath event marker tracking on D3D11 and D3D12 is only available if the +Nsight Aftermath GPU Crash Dump Monitor is running on the system. This requirement +applies to R495 to R530 drivers for D3D12 and R495+ drivers for D3D11. No Aftermath +configuration needs to be made in the Monitor. It serves only as a dongle to +ensure Aftermath event markers do not impact application performance on end user +systems. + +For Vulkan the Aftermath event marker functionality is exposed as a Vulkan +extension: `NV_device_diagnostic_checkpoints`. + +## GPU Crash Dump Creation +In addition to event marker-based GPU work tracking and device state queries, +Nsight Aftermath also supports the creation of GPU crash dumps for in-depth +post-mortem GPU crash analysis. + +Integrating GPU crash dump creation into a graphics application allows it to +collect and process the GPU crash dumps by already established crash handling +workflows and infrastructure. + +## GPU Crash Dump Inspection and Analysis + +There are two possibilities for a developer to inspect and analyze GPU crash +dumps collected from an application enabled with Nsight Aftermath's GPU crash +dump creation feature: + +* Load the GPU crash dump into Nsight Graphics and use the graphical GPU crash + dump inspector. This option allows for quick and easy access to the data + stored in the GPU crash dump for visual inspection. + +* Use the Nsight Aftermath GPU crash dump decoding functions to + programmatically access the data stored in the GPU crash dump. This allows + for automatic processing and binning of GPU crash dumps in a user-defined + fashion. + +## Distribution + +The following portions of the SDK are distributable: all .dll / .so files in the +`lib` directory. + +NOTE: Redistribution of the files is subject to the terms and conditions listed +in the LICENSE file, including the terms and conditions inherited from any +third-party component used within this product. + +## Support + +* Microsoft Windows 10 or newer + +* Linux (kernel 4.15.0 or newer) + +* D3D12, DXR, D3D11 (basic support), Vulkan + +* NVIDIA Turing GPU + +* NVIDIA Display Driver R440 or newer (for D3D) + +* NVIDIA Display Driver R445 or newer (for Vulkan on Windows) + +* NVIDIA Display Driver R455 or newer (for Vulkan on Linux) + +# Usage Examples + +In this section some code snippets can be found that show how to use the Nsight +Aftermath API for collecting and decoding crash dumps for a D3D12 or Vulkan +application. + +The code samples cover the following commonly required tasks: + +1. Enable GPU crash dump collection in an application + +2. Configure what data to include in GPU crash dumps + +3. Instrument an application with Aftermath event markers + +4. Handle GPU crash dump callback events + +5. Handle device removed/lost + +6. Disable GPU crash dump collection + +7. Use the GPU crash dump decoding API + +## Enabling GPU Crash Dumps + +An application enables GPU crash dump creation by calling +`GFSDK_Aftermath_EnableGpuCrashDumps`. To use the Nsight Aftermath API +functions related to GPU crash dump collection include the +`GFSDK_Aftermath_GpuCrashDump.h` header file. + +GPU crash dump collection should be enabled before the application creates any +D3D12, D3D11, or Vulkan device. No GPU crash dumps will be generated for GPU +crashes or hangs related to devices that were created before the +`GFSDK_Aftermath_EnableGpuCrashDumps` call. + +Besides enabling the GPU crash dump feature, this call allows the application +to register a few callback functions. First, a callback function that will be +invoked once a GPU crash is detected and crash dump data is available. This +callback is required. In addition, the application can also provide two +optional callback functions that will be invoked if debug information for +shaders is available or the application intends to provide additional +description or context for the exception, such as the current state of the +application at the time of the crash, to be included with the GPU crash dump. + +Note: The shader debug information callback will only be invoked if the shader +debug information feature is enabled; see the description of +`GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo` and +`VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV` in the +'Configuring GPU Crash Dumps' section of this document. + +The following code snippet shows an example of how to enable GPU crash dumps +and how to setup the callbacks for crash dump notifications, for shader debug +information notifications, for providing additional crash dump description +data, and for resolving application-managed markers. Only the crash dump +callback is mandatory. The other three callbacks are optional and can be +omitted by passing a NULL pointer if the corresponding functionality is not +needed. In this example, GPU cash dumps are only enabled for D3D12 and D3D11 +devices. For watching Vulkan devices the `GFSDK_Aftermath_EnableGpuCrashDumps` +functions must be called with `GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_Vulkan`. +It is also possible to combine both flags, if an application uses both the D3D and +the Vulkan API. + +```C++ + void MyApp::InitDevice() + { + [...] + + // Enable GPU crash dumps and register callbacks. + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_EnableGpuCrashDumps( + GFSDK_Aftermath_Version_API, + GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_DX, + GFSDK_Aftermath_GpuCrashDumpFeatureFlags_Default, // Default behavior. + GpuCrashDumpCallback, // Register callback for GPU crash dumps. + ShaderDebugInfoCallback, // Register callback for shader debug information. + CrashDumpDescriptionCallback, // Register callback for GPU crash dump description. + ResolveMarkerCallback, // Register callback for marker resolution (R495 or later NVIDIA graphics driver). + &m_gpuCrashDumpTracker)); // Set the GpuCrashTracker object as user data passed back by the above callbacks. + + [...] + } + + // Static wrapper for the GPU crash dump handler. See the 'Handling GPU crash dump Callbacks' section for details. + void MyApp::GpuCrashDumpCallback(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, void* pUserData) + { + GpuCrashTracker* pGpuCrashTracker = reinterpret_cast(pUserData); + pGpuCrashTracker->OnCrashDump(pGpuCrashDump, gpuCrashDumpSize); + } + + // Static wrapper for the shader debug information handler. See the 'Handling Shader Debug Information callbacks' section for details. + void MyApp::ShaderDebugInfoCallback(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize, void* pUserData) + { + GpuCrashTracker* pGpuCrashTracker = reinterpret_cast(pUserData); + pGpuCrashTracker->OnShaderDebugInfo(pShaderDebugInfo, shaderDebugInfoSize); + } + + // Static wrapper for the GPU crash dump description handler. See the 'Handling GPU Crash Dump Description Callbacks' section for details. + void MyApp::CrashDumpDescriptionCallback(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription, void* pUserData) + { + GpuCrashTracker* pGpuCrashTracker = reinterpret_cast(pUserData); + pGpuCrashTracker->OnDescription(addDescription); + } + + // Static wrapper for the resolve marker handler. See the 'Handling Marker Resolve Callbacks' section for details. + void MyApp::ResolveMarkerCallback(const void* pMarkerData, const uint32_t markerDataSize, void* pUserData, void** ppResolvedMarkerData, uint32_t* pResolvedMarkerDataSize) + { + GpuCrashTracker* pGpuCrashTracker = reinterpret_cast(pUserData); + pGpuCrashTracker->OnResolveMarker(pMarkerData, markerDataSize, ppResolvedMarkerData, pResolvedMarkerDataSize); + } +``` + +Enabling GPU crash dumps in an application with +`GFSDK_Aftermath_EnableGpuCrashDumps` will override any settings from an +already active Nsight Aftermath GPU crash dump monitor for this application. +That means the GPU crash dump monitor will not be notified of any GPU crash +related to this process nor will it create any GPU crash dumps or shader debug +information files for D3D or Vulkan devices that are created after the function +was called. Also, all configuration settings made in the GPU crash dump monitor +will be ignored. + +## Configuring GPU Crash Dumps + +Which data will be included in GPU crash dumps is configured by the Aftermath +per-device feature flags. How to configure Aftermath feature flags differs +between D3D and Vulkan. + +For D3D, the application must call the appropriate +`GFSDK_Aftermath_DX*_Initialize` functions to initialize the desired Aftermath +feature flags. + +The features supported for DX Aftermath by this release of the Aftermath SDK +are the following: + +* `GFSDK_Aftermath_FeatureFlags_EnableMarkers` - this enables support for DX + Aftermath event markers, including both the support for user markers that are + explicitly added by the application via `GFSDK_Aftermath_SetEventMarker` and + automatic call stack markers described in more detail below. + + Overhead Note: Using event markers (checkpoints) should be considered + carefully. Injecting markers in high-frequency code paths can introduce high + CPU overhead. Therefore, on some versions of NVIDIA graphics drivers, + the DX event marker feature is only available if the Nsight Aftermath + GPU Crash Dump Monitor is running on the system. This requirement applies + to R495 to R530 drivers for D3D12 and R495+ drivers for D3D11. No Aftermath + configuration needs to be made in the Monitor. It serves only as a dongle to + ensure Aftermath event markers do not impact application performance on end + user systems. + +* `GFSDK_Aftermath_FeatureFlags_CallStackCapturing` - this will instruct the + NVIDIA graphics driver to automatically generate Aftermath event markers for + all draw calls, compute and ray tracing dispatches, ray tracing acceleration + structure build operations, or resource copies initiated by the application. + The automatic event markers are added into the command lists right after the + corresponding commands with the CPU call stacks of the functions recording the + commands as their data payload. This may help narrowing down the commands that + were issued nearest to that causing the crash. This feature is only available + if the event marker feature is enabled, too. + + Overhead Note: Enabling this feature will cause very high CPU overhead during + command list recording. Due to the inherent overhead, call stack capturing + should only be used for debugging purposes on development or QA systems and + should not be enabled in applications shipped to customers. Therefore, on + R495+ NVIDIA graphics drivers, the DX call stack capturing feature is only + available if the Nsight Aftermath GPU Crash Dump Monitor is running on the + system. No Aftermath configuration needs to be made in the Monitor. It serves + only as a dongle to ensure Aftermath call stack capturing does not impact + application performance on end user systems. + + Note: When enabling this feature, Aftermath GPU crash dumps will include file + paths to the crashing application's executable as well as all DLLs it has + loaded. + +* `GFSDK_Aftermath_FeatureFlags_EnableResourceTracking` - this feature will + enable graphics driver-level tracking of live and recently destroyed + resources. This helps the user to identify resources related to a GPU virtual + address seen in the case of a crash due to a GPU page fault. Since the + tracking happens on the driver-level, it will provide only basic resource + information, such as the size of the resource, the format, and the current + deletion status of the resource object. Developers may also want to register + the D3D12 resources created by their application using the + `GFSDK_Aftermath_DX12_RegisterResource` function, which will allow Aftermath + to track additional information, such as the resource's debug name. + +* `GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo` - this instructs the + shader compiler to generate debug information (line tables for mapping from + the shader DXIL passed to the NVIDIA graphics driver to the shader microcode) + for all shaders. + + Overhead Note: Using this option should be considered carefully. It may cause + considerable shader compilation overhead and additional overhead for handling + the corresponding shader debug information callbacks. + +* `GFSDK_Aftermath_FeatureFlags_EnableShaderErrorReporting` - this puts the GPU + in a special mode that allows it to report more runtime shader errors. The + additional information may help in debugging rendering corruption crashes due + to errors in shader execution. + + Note: Enabling this feature does not cause any performance overhead, but it + may result in additional crashes being reported for shaders that exhibit + undefined behavior, which so far went unnoticed. Examples of situations that + would be silently ignored without enabling this feature are: + + * Accessing memory using misaligned addresses, such as reading or writing a + byte address that is not a multiple of the access size. + + * Accessing memory out-of-bounds, such as reading or writing beyond the + declared bounds of group shared or thread local memory or reading from + an out-of-bounds constant buffer address. + + * Hitting call stack limits. + + Note: This feature is only supported on R515 and later NVIDIA graphics + drivers. The feature flag will be ignored if the application is running on a + system using an earlier driver version. + +The following code snippet shows how to use those flags with +`GFSDK_Aftermath_DX12_Initialize` to enable all available Aftermath features for +a D3D12 device. Note, enabling all features, as in this simple example, may not +always be the right choice. Which subset of features to enable should be +considered based on requirements and acceptable overhead. + +``` C++ + void MyApp::InitDevice() + { + [...] + + D3D12CreateDevice(hardwareAdapter.Get(), D3D_FEATURE_LEVEL_11_0, IID_PPV_ARGS(&m_device))); + + // Initialize Nsight Aftermath for this device. + const uint32_t aftermathFlags = + GFSDK_Aftermath_FeatureFlags_EnableMarkers | // Enable event marker tracking. + GFSDK_Aftermath_FeatureFlags_CallStackCapturing | // Enable automatic call stack event markers. + GFSDK_Aftermath_FeatureFlags_EnableResourceTracking | // Enable tracking of resources. + GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo | // Generate debug information for shaders. + GFSDK_Aftermath_FeatureFlags_EnableShaderErrorReporting; // Enable additional runtime shader error reporting. + + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_DX12_Initialize( + GFSDK_Aftermath_Version_API, + aftermathFlags, + m_device.Get())); + + [...] + } +``` + +For Vulkan, Aftermath feature flags are configured at logical device creation time +via the `VK_NV_device_diagnostics_config` extension. + +The supported configuration flag bits are: + +* `VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV` - this flag + will instruct the NVIDIA graphics driver to automatically generate diagnostic + checkpoints for all draw calls, compute and ray tracing dispatches, ray + tracing acceleration structure build operations, or resource copies initiated + by the application. The automatic checkpoints are added into the command + buffers right after the corresponding commands with the CPU call stacks of the + functions recording the commands as their data payload. This may help narrow + down the commands that were issued nearest to the one that caused the crash. + This configuration flag is only effective if the application has also enabled + the `NV_device_diagnostic_checkpoints` extension. + + Overhead Note: Using this flag should be considered carefully. Enabling call + stack capturing can cause considerable CPU overhead during command buffer + recording. + + Note: When enabling this feature, Aftermath GPU crash dumps will include file paths + to the crashing application's executable as well as all DLLs or DSOs it has loaded. + +* `VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV` - this flag + will enable graphics driver-level tracking of live and recently destroyed + resources. This helps the user to identify resources related to a GPU virtual + address seen in the case of a crash due to a GPU page fault. The information + being tracked includes the size of the resource, the format, and the current + deletion status of the resource object, as well as the resource's debug name + set via `vkSetDebugUtilsObjectNameEXT`. + +* `VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV` - this instructs the + shader compiler to generate debug information (line tables). Whether a mapping + from the SPIR-V code to the shader microcode or a mapping from the shader's + source code to the shader microcode is generated depends on whether the SPIR-V + sent to the NVIDIA graphics driver was compiled with debug information or not. + + Overhead Note: Using this option should be considered carefully. It may cause + considerable shader compilation overhead and additional overhead for handling + the corresponding shader debug information callbacks. + +* `VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV` - this + flag puts the GPU in a special mode that allows it to report more runtime + shader errors. The additional information may help in debugging rendering + corruption or crashes due to errors in shader execution. + + Note: Enabling this feature does not cause any performance overhead, but it may result + in additional crashes being reported for shaders that exhibit undefined behavior, which + so far went unnoticed. Examples of situations that would be silently ignored without + enabling this feature are: + + * Accessing memory using misaligned addresses, such as reading or writing a + byte address that is not a multiple of the access size. + + * Accessing memory out-of-bounds, such as reading or writing beyond the + bounds of shared or thread local memory or reading from an out-of-bounds + constant buffer address. + + * Accessing a texture with incompatible format or memory layout. + + * Hitting call stack limits. + + Note: This feature is only supported on R515 and later NVIDIA graphics + drivers. The feature flag will be ignored if the application is running on a + system using an earlier driver version. + +The Aftermath feature selection for a Vulkan device could look like the code +below. Note, enabling all features, as in this simple example, may not always +be the right choice. Which subset of features to enable should be considered +based on requirements and acceptable overhead. + +``` C++ + void MyApp::InitDevice() + { + std::vector extensionNames; + + [...] + + // Enable NV_device_diagnostic_checkpoints extension to be able to + // use Aftermath event markers. + extensionNames.push_back(VK_NV_DEVICE_DIAGNOSTIC_CHECKPOINTS_EXTENSION_NAME); + + // Enable NV_device_diagnostics_config extension to configure Aftermath + // features. + extensionNames.push_back(VK_NV_DEVICE_DIAGNOSTICS_CONFIG_EXTENSION_NAME); + + // Set up device creation info for Aftermath feature flag configuration. + VkDeviceDiagnosticsConfigFlagsNV aftermathFlags = + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV | // Enable automatic call stack checkpoints. + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV | // Enable tracking of resources. + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV | // Generate debug information for shaders. + VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV; // Enable additional runtime shader error reporting. + + VkDeviceDiagnosticsConfigCreateInfoNV aftermathInfo = {}; + aftermathInfo.sType = VK_STRUCTURE_TYPE_DEVICE_DIAGNOSTICS_CONFIG_CREATE_INFO_NV; + aftermathInfo.flags = aftermathFlags; + + // Set up device creation info. + VkDeviceCreateInfo deviceInfo = {}; + deviceInfo.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; + deviceInfo.pNext = &aftermathInfo; + deviceInfo.queueCreateInfoCount = 1; + deviceInfo.pQueueCreateInfos = &queueInfo; + deviceInfo.enabledExtensionCount = extensionNames.size(); + deviceInfo.ppEnabledExtensionNames = extensionNames.data(); + + // Create the logical device. + VkDevice device; + vkCreateDevice(physicalDevice, &deviceInfo, NULL, &device); + + [...] + } +``` + +## Inserting Event Markers + +The Aftermath API provides a simple and light-weight solution for inserting +event markers on the GPU timeline. + +Here is some D3D12 example code that shows how to create the necessary command +context handle with `GFSDK_Aftermath_DX12_CreateContextHandle` and how to +call `GFSDK_Aftermath_SetEventMarker` to set a simple event marker with a +character string as payload. + +Note: The command list passed into `GFSDK_Aftermath_DX12_CreateContextHandle` +must be in the recording state for the returned context handle to be valid. +The context handle will remain valid even if the command list is subsequently +closed and reset, but the command list also must be in the recording state +when its context handle is passed into `GFSDK_Aftermath_SetEventMarker`. + +Note: Calls of `GFSDK_Aftermath_SetEventMarker` are only effective if the +`GFSDK_Aftermath_FeatureFlags_EnableMarkers` option was provided to +`GFSDK_Aftermath_DX12_Initialize` and the Nsight Aftermath GPU Crash Dump +Monitor is running on the system. This Monitor requirement applies to +R495 to R530 drivers for D3D12 and R495+ drivers for D3D11. + +```C++ + void MyApp::PopulateCommandList() + { + // Create the command list. + m_device->CreateCommandList(0, D3D12_COMMAND_LIST_TYPE_DIRECT, m_commandAllocator.Get(), m_pipelineState.Get(), IID_PPV_ARGS(&m_commandList))); + + // Create an Nsight Aftermath context handle for setting Aftermath event markers in this command list. + // Note that the command list must be in the recording state for this function, so if it is closed it must be reset first + // (e.g. if it was created above with ID3D12Device4::CreateCommandList1 instead of ID3D12Device::CreateCommandList). + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_DX12_CreateContextHandle(m_commandList.Get(), &m_hAftermathCommandListContext)); + + [...] + + // Add an Aftermath event marker with a 0-terminated string as payload. + std::string eventMarker = "Draw Triangle"; + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_SetEventMarker(m_hAftermathCommandListContext, (void*)eventMarker.c_str(), (unsigned int)eventMarker.size() + 1)); + m_commandList->DrawInstanced(3, 1, 0, 0); + + [...] + } +``` + +Overhead Note: For reduced CPU overhead, use `GFSDK_Aftermath_SetEventMarker` +with `dataSize=0`. This instructs Aftermath not to allocate and copy off memory +internally, relying on the application to manage marker pointers itself. +Markers managed this way may later be resolved using the Aftermath SDK resolve +marker callback `PFN_GFSDK_Aftermath_ResolveMarkerCb`. + +For Vulkan, similar functionality is provided via the +`NV_device_diagnostic_checkpoints` extension. When this extension is enabled +for a Vulkan device, event markers can be inserted in a command buffer with the +`vkCmdSetCheckpointNV` function. The application is responsible for managing +the marker pointers/tokens, which may later be resolved using the Aftermath SDK +resolve marker callback `PFN_GFSDK_Aftermath_ResolveMarkerCb`. + +```C++ + std::map appManagedMarkers; + + void MyApp::RecordCommandBuffer() + { + [...] + size_t markerId = appManagedMarkers.size() + 1; + appManagedMarkers[markerId] = "Draw Cube"; + // Add an Aftermath event marker ID, which requires resolution later via callback. + vkCmdSetCheckpointNV(commandBuffer, (const void*)markerId); + [...] + } +``` + +## Handling GPU Crash Dump Callbacks + +When Nsight Aftermath GPU crash dumps are enabled, and a GPU crash or hang is +detected, the necessary data is gathered, and a GPU crash dump is created from +it. Then the GPU crash dump callback function that was registered with the +`GFSDK_Aftermath_EnableGpuCrashDumps` will be invoked to notify the +application. In the callback the application can either decode the GPU crash +dump data using the GPU crash dump decoding API or forward it to the crash +handling infrastructure. + +In the simple example implementation of a GPU crash dump callback handler is +shown below the GPU crash dump data is simply stored to a file. This file could +then be opened for analysis with Nsight Graphics. + +```C++ + // Handler for GPU crash dump callbacks (called by GpuCrashDumpCallback). + void GpuCrashTracker::OnCrashDump(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize) + { + // Make sure only one thread at a time... + std::lock_guard lock(m_mutex); + + // Write to file for later in-depth analysis. + WriteGpuCrashDumpToFile(pGpuCrashDump, gpuCrashDumpSize); + } +``` + +Note: All callback functions are free-threaded, and that the application is +responsible for providing thread-safe callback handlers. + +It is important to note that the device removed/lost notification of the +graphics API used by the application is asynchronous to the NVIDIA graphics +driver's GPU crash handling. That means applications should check the return +value of `IDXGISwapChain::Present` for `DXGI_ERROR_DEVICE_REMOVED` or +`DXGI_ERROR_DEVICE_RESET` and the return codes of their Vulkan calls for +`VK_ERROR_DEVICE_LOST`, and give the Nsight Aftermath GPU crash dump processing +thread some time to do its work before releasing the D3D or Vulkan device or +terminating the process. See the 'Handling Device Removed/Lost' section of this +document for further details. + +## Handling GPU Crash Dump Description Callbacks + +An application can register an optional callback function that allows it to +provide supplemental information about a crash. This callback is called after +the GPU crash happened, but before the actual GPU crash dump callback. This +presents the opportunity for the application to provide information such as +application name, application version, or user defined data, for example, +current engine state. The data provided will be stored in the GPU crash dump. + +Here is an example of a basic GPU crash dump description handler. Data is added +to the crash dump by calling the `addDescription` function provided by the +callback. + +```C++ + // Handler for GPU crash dump description callbacks (called by CrashDumpDescriptionCallback). + void GpuCrashTracker::OnDescription(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addDescription) + { + // Add some basic description about the crash. + addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName, "Hello Nsight Aftermath"); + addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationVersion, "v1.0"); + addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined, "This is a GPU crash dump example"); + addDescription(GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined + 1, "Engine State: Rendering"); + } +``` + +Note: All callback functions are free-threaded; the application is +responsible for providing thread-safe callback handlers. + +## Handling Shader Debug Information Callbacks + +If the device was configured with the `GenerateShaderDebugInfo` feature flag, +the generated shader debug information will be communicated to the application +through the (optional) shader debug information callback function that was +registered when the `GFSDK_Aftermath_EnableGpuCrashDumps` was called. This debug +information will be required to map from shader instruction addresses to +intermediate assembly language (IL) instructions or high-level source lines when +analyzing a crash dump in Nsight Graphics or when using the GPU crash dump to +JSON decoding functions of the Nsight Aftermath API. If this functionality is +not required, an application can omit the `GenerateShaderDebugInfo` flag when +configuring the device and pass `nullptr` for the shader debug information +callback. This might be desirable, because generating shader debug information +incurs overhead in shader compilation and for handling the callback. + +Here is a simple example implementation of a callback handler that writes +the data to disk using the unique shader debug info identifier queried from the +opaque shader debug information blob. + +```C++ +// Handler for shader debug information callbacks (called by ShaderDebugInfoCallback) +void GpuCrashTracker::OnShaderDebugInfo(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize) +{ + // Make sure only one thread at a time... + std::lock_guard lock(m_mutex); + + // Get shader debug information identifier. + GFSDK_Aftermath_ShaderDebugInfoIdentifier identifier = {}; + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetShaderDebugInfoIdentifier(GFSDK_Aftermath_Version_API, pShaderDebugInfo, shaderDebugInfoSize, &identifier)); + + // Write to file for later in-depth analysis of crash dumps with Nsight Graphics. + WriteShaderDebugInformationToFile(identifier, pShaderDebugInfo, shaderDebugInfoSize); +} +``` + +By default, the shader debug information callback will be invoked for every +shader that is compiled by the NVIDIA graphics driver. It is the responsibility +of the implementation to handle those callbacks and store the data in case a GPU +crash occurs. To simplify the process the Nsight Aftermath library can handle +the caching of the debug information and only invoke the callback in case of a +GPU crash and only for the shaders referenced in the corresponding GPU crash +dump. This behavior is enabled by passing the +`GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks` flag to +`GFSDK_Aftermath_EnableGpuCrashDumps` when enabling GPU crash dumps. + +Note: All callback functions are free-threaded; the application is responsible +for providing thread-safe callback handlers. + +## Handling Marker Resolve Callbacks + +Note, this Aftermath feature is only supported on R495 and later NVIDIA graphics +drivers. + +For D3D applications which call `GFSDK_Aftermath_SetEventMarker` with a +`markerSize` of zero, or for all Vulkan applications, the application passes +a unique token (such as a pointer) identifying the marker to Aftermath, +and is responsible for tracking the meaning of that token internally. +When generating the crash dump, if a marker of interest has a size of zero, +the crash dump process will invoke this callback, passing back the marker's +token, expecting the application to resolve the token to the actual marker +data (such as a string) and pass the data back. + +The association of token to marker data is completely up to the application. +Pointers to the application-managed marker data is usually a viable token, +since if the application is keeping all marker data in memory, different +markers will have unique pointer values by definition. + +The pointer to the marker data passed back to the crash dump process from the +application must be valid until the next call of ResolveMarkerCallback or for +the duration crash dump generation. Crash dump generation is complete when the +GPU crash dump callback is called. + +If the application does not implement this callback, or does not pass the +resolved marker data and size back, then the original marker payload (or only +the marker's address for zero-size/Vulkan marker) will be added to the crash +dump. The same will happen if the NVIDIA graphics driver does not support the +feature, i.e, if the driver release version is less than R495. + +If the marker is still considered valid, but the application does not have an +associated payload (payloads lifetime expired, marker is the payload, etc.), +you may consider returning a string representation of the marker in the callback +implementation. + +```C++ +// Simple data structure used to store marker tokens. This is managed by the application. +// It could be stored within the callbacks pUserData or in some other scope. +std::map appManagedMarkers; + +// Example handler for resolving markers (called by ResolveMarkerCallback) +void GpuCrashTracker::OnResolveMarker(const void* pMarkerData, const uint32_t markerDataSize, void** ppResolvedMarkerData, uint32_t* pResolvedMarkerDataSize) +{ + // In this example, we set the (uint64_t) key of the 'appManagedMarkers' to the 'markerData' + // and set the 'markerDataSize' to zero when we call the 'GFSDK_Aftermath_SetEventMarker'. + // So we are only interested in zero size markers here. + if (markerDataSize == 0) + { + // Important: the pointer passed back via ppResolvedMarkerData must remain valid after this function returns. + // Using references for all of the appManagedMarkers accesses ensures that the pointers refer to the persistent data + const auto& foundMarker = appManagedMarkers->find((uint64_t)pMarkerData); + if (foundMarker != appManagedMarkers->end()) + { + const std::string& markerString = foundMarker->second; + // std::string::data() will return a valid pointer until the string is next modified + // we don't modify the string after calling data() here, so the pointer should remain valid + *ppResolvedMarkerData = (void*)markerString.data(); + *pResolvedMarkerDataSize = (uint32_t)markerString.length(); + return; + } + } + // Marker was not found or we are not interested in it. So we return without setting any resolved + // marker data or size. The marker's original payload (or the marker's pointer/token for zero-size + // marker) will be stored in the Aftermath crash dump. + // When capturing lots of markers, it may be unfeasible to to maintain the lifetime of all markers. + // It may be desirable to maintain only markers recorded in the most recent render calls. +} +``` + +## Handling Device Removed/Lost + +After a GPU crash happens (e.g., after seeing device removed/lost in the application), +call `GFSDK_Aftermath_GetCrashDumpStatus` to check the GPU crash dump status. +The Application should wait until Aftermath has finished processing the crash dump +before exiting/terminating the application. Here is an example of how an application may +handle the device removed event if it is setup for collecting Aftermath GPU crash dumps. + +```C++ +void Graphics::Present(void) +{ + [...] + + HRESULT hr = s_SwapChain1->Present(PresentInterval, 0); + + if (hr == DXGI_ERROR_DEVICE_REMOVED || hr == DXGI_ERROR_DEVICE_RESET) + { + [...] + + GFSDK_Aftermath_CrashDump_Status status = GFSDK_Aftermath_CrashDump_Status_Unknown; + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetCrashDumpStatus(&status)); + + auto tStart = std::chrono::steady_clock::now(); + auto tElapsed = std::chrono::milliseconds::zero(); + + // Loop while Aftermath crash dump data collection has not finished or + // the application is still processing the crash dump data. + while (status != GFSDK_Aftermath_CrashDump_Status_CollectingDataFailed && + status != GFSDK_Aftermath_CrashDump_Status_Finished && + tElapsed.count() < deviceLostTimeout) + { + // Sleep a couple of milliseconds and poll the status again. + std::this_thread::sleep_for(std::chrono::milliseconds(50)); + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetCrashDumpStatus(&status)); + + tElapsed = std::chrono::duration_cast(std::chrono::steady_clock::now() - tStart); + } + + if (status == GFSDK_Aftermath_CrashDump_Status_Finished) + { + Utility::Print("Aftermath finished processing the crash dump.\n"); + } + else + { + Utility::Printf("Unexpected crash dump status after timeout: %d\n", status); + } + + exit(-1); + } + + [...] +} +``` + +## Disable GPU Crash Dumps + +To disable GPU crash dumps simply call `GFSDK_Aftermath_DisableGpuCrashDumps`. + +```C++ + MyApp::~MyApp() + { + [...] + + // Disable GPU crash dump creation. + GFSDK_Aftermath_DisableGpuCrashDumps(); + + [...] + } +``` + +Disabling GPU crash dumps in an application with +`GFSDK_Aftermath_DisableGpuCrashDumps` will re-enable any Nsight Aftermath GPU +crash dump monitor settings for this application if it is running on the +system. After this, the GPU crash dump monitor will be notified of any GPU +crash related to this process and will create GPU crash dumps and shader debug +information files for all active devices. + +## Reading GPU Crash Dumps + +The Nsight Aftermath library provides several functions for decoding GPU crash +dumps and for querying data from the crash dumps. To use these functions +include the `GFSD_Aftermath_GpuCrashDumpDecoding.h` header file. + +The first step in decoding a GPU crash dump is to create a decoder object for +it by calling `GFSDK_Aftermath_GpuCrashDump_CreateDecoder`: + +```C++ + // Create a GPU crash dump decoder object for the GPU crash dump. + GFSDK_Aftermath_GpuCrashDump_Decoder decoder = {}; + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_CreateDecoder( + GFSDK_Aftermath_Version_API, + pGpuCrashDump, + gpuCrashDumpSize, + &decoder)); +``` +Then one or more decoder functions can be used to read data from a GPU crash +dump. The data in the GPU crash dumps varies depending on the type of GPU crash +and the feature flags used when initializing Aftermath. For example, if the +application does not use Aftermath event markers, querying Aftermath event +marker information will fail. The decoder will return +`GFSDK_Aftermath_Result_NotAvailable` if the requested data is not available. +An implementation should be aware of that and handle the situation accordingly. + +Here is an example of how to query GPU page fault information from a GPU crash +dump using a previously created decoder object: + +```C++ + // Query GPU page fault information. + GFSDK_Aftermath_GpuCrashDump_PageFaultInfo pageFaultInfo = {}; + GFSDK_Aftermath_Result result = GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo(decoder, &pageFaultInfo); + + if (GFSDK_Aftermath_SUCCEED(result) && result != GFSDK_Aftermath_Result_NotAvailable) + { + // Print information about the GPU page fault. + Utility::Printf("GPU page fault at 0x%016llx", pageFaultInfo.faultingGpuVA); + Utility::Printf("Fault Type: %u", pageFaultInfo.faultType); + Utility::Printf("Access Type: %u", pageFaultInfo.accessType); + Utility::Printf("Engine: %u", pageFaultInfo.engine); + Utility::Printf("Client: %u", pageFaultInfo.client); + if (pageFaultInfo.resourceInfoCount > 0) + { + std::vector resourceInfos(pageFaultInfo.resourceInfoCount); + GFSDK_Aftermath_GpuCrashDump_GetPageFaultResourceInfo(decoder, pageFaultInfo.resourceInfoCount, resourceInfos.data()); + + int index = 0; + for (auto resourceInfo : resourceInfos) + { + Utility::Printf("Resource[%d]", index); + Utility::Printf("\tFault in resource starting at 0x%016llx", resourceInfo.gpuVa); + Utility::Printf("\tSize of resource: (w x h x d x ml) = {%u, %u, %u, %u} = %llu bytes", + resourceInfo.width, + resourceInfo.height, + resourceInfo.depth, + resourceInfo.mipLevels, + resourceInfo.size); + Utility::Printf("\tFormat of resource: %u", resourceInfo.format); + Utility::Printf("\tResource was destroyed: %d", resourceInfo.bWasDestroyed); + index++; + } + } + } +``` + +Some decoding functions require the caller to provide an appropriately sized +buffer for the data they return. Those come with an additional function to +query the size of the buffer. For example, querying all the active shaders at +the time of the GPU crash or hang could look like this: + +```C++ + // First query active shaders count. + uint32_t shaderCount = 0; + GFSDK_Aftermath_Result result = GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount(decoder, &shaderCount); + + if (GFSDK_Aftermath_SUCCEED(result) && result != GFSDK_Aftermath_Result_NotAvailable) + { + // Allocate buffer for results. + std::vector shaderInfos(shaderCount); + + // Query active shaders information. + result = GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo(decoder, shaderCount, shaderInfos.data()); + + if (GFSDK_Aftermath_SUCCEED(result)) + { + // Print information for each active shader + for (const GFSDK_Aftermath_GpuCrashDump_ShaderInfo& shaderInfo : shaderInfos) + { + Utility::Printf("Active shader: ShaderHash = 0x%016llx ShaderInstance = 0x%016llx Shadertype = %u", + shaderInfo.shaderHash, + shaderInfo.shaderInstance, + shaderInfo.shaderType); + } + } + } +``` + +Finally, the GPU crash dump decoder also provides functions for converting a GPU +crash dump into JSON format. Here is a code example for creating JSON from a GPU +crash dump, including information about all the shaders active at the time of +the GPU crash or hang. The information also includes the corresponding active +shader warps, including their mapping back to intermediate assembly language +(IL) instructions or source, if available. The later requires the caller to also +provide a couple of callback functions the decoder will invoke to query shader +debug information and shader binaries (dxc shader object outputs or SPIR-V +shader files). These are optional and implementations not interested in mapping +shader instruction addresses to IL or source lines can simply pass +`nullptr`. However, if shader instruction mapping is desired, the implementation +needs to ensure that it can provide the necessary information to the decoder. + +```C++ + // Flags controlling what to include in the JSON data + const uint32_t jsonDecoderFlags = + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_INFO | // Include information about active shaders. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_WARP_STATE_INFO | // Include information about active shader warps. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO; // Try to map shader instruction addresses to shader lines. + + // Query the size of the required results buffer + uint32_t jsonSize = 0; + GFSDK_Aftermath_Result result = GFSDK_Aftermath_GpuCrashDump_GenerateJSON( + decoder, + jsonDecoderFlags, // The flags controlling what information to include in the JSON. + GFSDK_Aftermath_GpuCrashDumpFormatterFlags_CONDENSED_OUTPUT, // Generate condensed output, i.e., omit all unnecessary whitespace. + ShaderDebugInfoLookupCallback, // Callback function invoked to find shader debug information data. + ShaderLookupCallback, // Callback function invoked to find shader binary data by shader hash. + ShaderSourceDebugDataLookupCallback, // Callback function invoked to find shader source debug data by shader DebugName. + &m_gpuCrashDumpTracker, // User data that will be provided to the above callback functions. + &jsonSize); // Result of the call: size in bytes of the generated JSON data. + + if (GFSDK_Aftermath_SUCCEED(result) && result != GFSDK_Aftermath_Result_NotAvailable) + { + // Allocate buffer for results. + std::vector json(jsonSize); + + // Query the generated JSON data taht si cached inside the decoder object. + result = GFSDK_Aftermath_GpuCrashDump_GetJSON( + decoder, + json.size(), + json.data()); + if (GFSDK_Aftermath_SUCCEED(result)) + { + Utility::Printf("JSON: %s", json.data()); + } + } +``` + +Possible implementations for the shader debug information and shader binary +lookup callbacks: + +```C++ + + // Static callback wrapper for OnShaderDebugInfoLookup + void MyApp::ShaderDebugInfoLookupCallback( + const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier, + PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, + void* pUserData) + { + GpuCrashTracker* pGpuCrashTracker = reinterpret_cast(pUserData); + pGpuCrashTracker->OnShaderDebugInfoLookup(*pIdentifier, setShaderDebugInfo); + } + + // Static callback wrapper for OnShaderLookup + void MyApp::ShaderLookupCallback( + const GFSDK_Aftermath_ShaderBinaryHash* pShaderHash, + PFN_GFSDK_Aftermath_SetData setShaderBinary, + void* pUserData) + { + GpuCrashTracker* pGpuCrashTracker = reinterpret_cast(pUserData); + pGpuCrashTracker->OnShaderLookup(*pShaderHash, setShaderBinary); + } + + // Static callback wrapper for OnShaderSourceDebugInfoLookup + void MyApp::ShaderSourceDebugInfoLookupCallback( + const GFSDK_Aftermath_ShaderDebugName* pShaderDebugName, + PFN_GFSDK_Aftermath_SetData setShaderBinary, + void* pUserData) + { + GpuCrashTracker* pGpuCrashTracker = reinterpret_cast(pUserData); + pGpuCrashTracker->OnShaderSourceDebugInfoLookup(*pShaderDebugName, setShaderBinary); + } + + // Handler for shader debug information lookup callbacks. + // This is used by the JSON decoder for mapping shader instruction + // addresses to IL lines or source lines. + void GpuCrashTracker::OnShaderDebugInfoLookup( + const GFSDK_Aftermath_ShaderDebugInfoIdentifier& identifier, + PFN_GFSDK_Aftermath_SetData setShaderDebugInfo) const + { + // Search the list of shader debug information blobs received earlier. + auto i_debugInfo = m_shaderDebugInfo.find(identifier); + if (i_debugInfo == m_shaderDebugInfo.end()) + { + // Early exit, nothing found. No need to call setShaderDebugInfo. + return; + } + + // Let the GPU crash dump decoder know about the shader debug information + // that was found. + setShaderDebugInfo(i_debugInfo->second.data(), i_debugInfo->second.size()); + } + + // Handler for shader lookup callbacks. + // This is used by the JSON decoder for mapping shader instruction + // addresses to IL lines or source lines. + // NOTE: If the application loads stripped shader binaries, Aftermath + // will require access to both the stripped and the non-stripped + // shader binaries. + void GpuCrashTracker::OnShaderLookup( + const GFSDK_Aftermath_ShaderBinaryHash& shaderHash, + PFN_GFSDK_Aftermath_SetData setShaderBinary) const + { + // Find shader binary data for the shader hash in the shader database. + std::vector shaderBinary; + if (!m_shaderDatabase.FindShaderBinary(shaderHash, shaderBinary)) + { + // Early exit, nothing found. No need to call setShaderBinary. + return; + } + + // Let the GPU crash dump decoder know about the shader data + // that was found. + setShaderBinary(shaderBinary.data(), shaderBinary.size()); + } + + // Handler for shader source debug info lookup callbacks. + // This is used by the JSON decoder for mapping shader instruction addresses to + // source lines if the shaders used by the application were compiled with + // separate debug info data files. + void GpuCrashTracker::OnShaderSourceDebugInfoLookup( + const GFSDK_Aftermath_ShaderDebugName& shaderDebugName, + PFN_GFSDK_Aftermath_SetData setShaderBinary) const + { + // Find source debug info for the shader DebugName in the shader database. + std::vector sourceDebugInfo; + if (!m_shaderDatabase.FindSourceShaderDebugData(shaderDebugName, sourceDebugInfo)) + { + // Early exit, nothing found. No need to call setShaderBinary. + return; + } + + // Let the GPU crash dump decoder know about the shader debug data that + // was found. + setShaderBinary(sourceDebugInfo.data(), sourceDebugInfo.size()); + } + +``` + +Last, the decoder object should be destroyed, if no longer needed, to free up +all memory allocated for it: + +```C++ + // Destroy the GPU crash dump decoder object. + AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GpuCrashDump_DestroyDecoder(decoder)); +``` + +# Shader Compilation for Source Mapping + +## D3D12 + +The following variants of generating source shader debug information for HLSL +shaders using the Microsoft DirectX Shader Compiler are supported: + +1. Compile and use full shader blobs + + Compile the shaders with the debug information. Use the full (i.e., not + stripped) shader binary when running the application and make it accessible + through `ShaderLookupCallback`. In this case there is no need to provide a + `ShaderSourceDebugDataLookupCallback`. + + Compilation example: + ``` + dxc -Zi [..] -Fo shader.bin shader.hlsl + ``` + +2. Compile and strip + + Compile the shaders with debug information and then strip off the debug + information. Use the stripped shader binary data when running the + application. Make the stripped shader binary data accessible through + `ShaderLookupCallback`. In addition, make the non-stripped shader binary + data accessible through `ShaderSourceDebugDataLookupCallback`. + + Compilation example: + ``` + dxc -Zi [..] -Fo full_shader.bin shader.hlsl + dxc -dumpbin -Qstrip_debug -Fo shader.bin full_shader.bin + ``` + + The shader's DebugName required for implementing the + ShaderSourceDebugDataLookupCallback may be extracted from the stripped or + the non-stripped shader binary data with + `GFSDK_Aftermath_GetShaderDebugName`. + +3. Compile with separate debug information (and auto-generated debug data file name) + + Compile the shaders with debug information and instruct the compiler to store + the debug meta data in a separate shader debug information file. The name of + the file generated by the compiler will match the DebugName of the shader. + Make the shader binary data accessible through `ShaderLookupCallback`. + In addition, make the data from the compiler generated shader debug data file + accessible through `ShaderSourceDebugDataLookupCallback`. + + Compilation example: + ``` + dxc -Zi [..] -Fo shader.bin -Fd debugInfo\ shader.hlsl + ``` + + The debug data file generated by the compiler does not contain any reference + to the shader's DebugName. It is the responsibility of the user providing + the `ShaderSourceDebugDataLookupCallback` callback to implement a solution to + lookup the debug data based on the name of the generated debug data file. + +4. Compile with separate debug information (and user-defined debug data file name) + + Compile the shaders with debug information and instruct the compiler to + store the debug meta data in a separate shader debug information file. The + name of the file is freely chosen by the user. Make the shader binary data + accessible through `ShaderLookupCallback`. In addition, make the data from + the compiler generated shader debug data file accessible through + `ShaderSourceDebugDataLookupCallback`. + + Compilation example: + ``` + dxc -Zi [..] -Fo shader.bin -Fd debugInfo\shader.dbg shader.hlsl + ``` + + The debug data file generated by the compiler does not contain any reference + to the shader's DebugName. It is the responsibility of the user providing + the `ShaderSourceDebugDataLookupCallback` callback to implement a solution + that performs the lookup of the debug data based on a mapping between the + shader's DebugName the debug data file's name that was chosen for the + compilation. The shader's DebugName may be extracted from the shader binary + data with `GFSDK_Aftermath_GetShaderDebugName`. + +## Vulkan (SPIR-V) + +For SPIR-V shaders, the Aftermath SDK provides support for the following variants +of generating source shader debug information: + +1. Compile and use a full shader blob + + Compile the shaders with the debug information. Use the full (i.e., not + stripped) shader binary when running the application and make it accessible + through `ShaderLookupCallback`. In this case there is no need to provide + `ShaderSourceDebugInfoLookupCallback`. + + Compilation example using the Vulkan SDK toolchain: + ``` + glslangValidator -V -g -o shader.spv shader.vert + ``` + + Compilation example using the DirectX Shader Compiler: + ``` + dxc -spirv -Zi [..] -Fo shader.spv shader.hlsl + ``` + +2. Compile and strip + + Compile the shaders with debug information and then strip off the debug + information. Use the stripped shader binary data when running the + application. Make the stripped shader binary data accessible through + shaderLookupCb. In addition, make the non-stripped shader binary data + accessible through `ShaderSourceDebugInfoLookupCallback`. + + Compilation example using the Vulkan SDK toolchain: + ``` + glslangValidator -V -g -o ./full/shader.spv shader.vert + spirv-remap --map all --strip-all --input full/shader.spv --output ./stripped/ + ```` + + Compilation example using the Microsoft DirectX Shader Compiler: + ``` + dxc -spirv -Zi [..] -Fo ./full/shader.spv shader.hlsl + spirv-remap --map all --strip-all --input full/shader.spv --output ./stripped/ + ``` + + The (crash dump decoder) application then needs to pass the contents of the + `full/shader.spv` and `stripped/shader.spv` pair to + `GFSDK_Aftermath_GetDebugNameSpirv` to generate the shader DebugName to use + with `ShaderSourceDebugInfoLookupCallback`. + +# Limitations and Known Issues + +* Nsight Aftermath covers only GPU crashes. CPU crashes in the NVIDIA graphics + driver, the D3D runtime, the Vulkan loader, or the application cannot be + captured. + +* Nsight Aftermath is only fully supported on Turing or later GPUs. + +## D3D + +* Nsight Aftermath is only fully supported for D3D12 devices. Only basic support + with a reduced feature set (no API resource tracking and no shader address + mapping) is available for D3D11 devices. + +* Nsight Aftermath is fully supported on Windows 10 and newer, with limited support on + Windows 7. + +* Nsight Aftermath event markers and resource tracking is incompatible with the + D3D debug layer and tools using D3D API interception, such as Microsoft PIX + or Nsight Graphics. + +* Shader line mappings are only supported for DXIL shaders, i.e., Shader Model 6 or + above. Line mappings for shaders in DXBC shader byte code format are unsupported. + +* Shader line mappings are not yet supported for shaders compiled with the DirectX + Shader Compiler's `-Zs` option for generating "slim PDBs". + +## Vulkan + +* Shader line mappings are not yet supported for SPIR-V shaders compiled with the + NonSemantic.Shader.DebugInfo.100 extended instruction set, i.e., shaders compiled + with the `-gVS` option of `glslangValidator` or the `-fspv-debug=vulkan-with-source` + option of the DirectX Shader Compiler. + +# Copyright and Licenses + +See LICENSE file. diff --git a/Vendor/nvidia-aftermath/include/GFSDK_Aftermath.h b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath.h new file mode 100644 index 0000000..544b115 --- /dev/null +++ b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath.h @@ -0,0 +1,639 @@ +/* + * Copyright (c) 2017-2023, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +/* + * █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER + * ██ ██ + * ████████████████████████████████████████████████████████ ██ █ ██ ████████████ + * + * + * HOW TO USE AFTERMATH for DX11 and DX12 + * -------------------------------------- + * + * NOTE: Some of the Aftermath 1.x functionality will go away in a future release. + * The functions and structures to be removed are indicated with a DEPRECATED + * comment. The supported method for accessing this data is provided via the + * GPU crash dump functionality. Please refer to the + * 'GFSDK_Aftermath_GpuCrashDump.h' header file for more details. + * + * NOTE: Aftermath does not support UWP applications. + * + * Call 'GFSDK_Aftermath_DXxx_Initialize', to initialize the library and to enable + * the desired Aftermath feature set. See 'GFSDK_Aftermath_FeatureFlags' below for + * the list of supported features. + * This must be done before any other library calls are made, and the method must + * return 'GFSDK_Aftermath_Result_Success' for initialization to be complete. + * + * Initialization of Aftermath may fail for a variety of reasons, including: + * + * o) The initialization function was already called for the device: + * 'GFSDK_Aftermath_Result_FAIL_AlreadyInitialized'. + * + * + * o) Aftermath isn't supported on the GPU associated with the device or the NVIDIA + * display driver version installed: + * 'GFSDK_Aftermath_Result_FAIL_InvalidAdapter' + * 'GFSDK_Aftermath_Result_FAIL_DriverInitFailed', + * 'GFSDK_Aftermath_Result_FAIL_DriverVersionNotSupported', + * 'GFSDK_Aftermath_Result_FAIL_NvApiIncompatible'. + * + * + * o) A D3D API debug layer, such as PIX or other graphics debuggers, was detected + * that is incompatible with Aftermath: + * 'GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported' + * + * + * o) Aftermath was disabled on the system by the current user setting the + * 'HKEY_CURRENT_USER\Software\NVIDIA Corporation\Nsight Aftermath\ForceOff' + * Windows registry key: 'GFSDK_Aftermath_Result_FAIL_Disabled' + * + * + * After detecting D3D device lost (TDR): + * + * o) To query the fault reason after TDR, use the 'GFSDK_Aftermath_GetDeviceStatus' + * call. See 'GFSDK_Aftermath_Device_Status', for the full list of possible + * status. + * + * + * o) In the event of a GPU page fault, use the 'GFSDK_Aftermath_GetPageFaultInformation' + * method to return more information about what might of gone wrong. A GPU + * virtual address (VA) is returned, along with the resource descriptor of the + * resource that VA lands in. + * NOTE: It's not 100% certain that this is the resource is related to the fault, + * only that the faulting VA lands within this resource in memory. It is always + * possible that due to a bug or due to faulty dependency a random GPU VA is + * accessed by a shader. + * + * + * Optionally, instrument the application with Aftermath event markers: + * + * 1) For each DX12 command list or DX11 device context you expect to use with + * Aftermath, initialize them using the 'GFSDK_Aftermath_DXxx_CreateContextHandle' + * function. DX12 command lists must be in the recording state when this function + * is called, but the returned context handle will remain valid through subsequent + * command list closes and resets. + * + * + * 2) Call 'GFSDK_Aftermath_SetEventMarker' to inject an event marker directly into + * the command stream at that point. DX12 command lists must be in the recording + * state when this function is called. + * + * PERFORMANCE TIP: + * + * Do not use 'GFSDK_Aftermath_SetEventMarker' in high frequency code paths. + * Injecting event markers introduces considerable CPU overhead. For reduced + * CPU overhead, use 'GFSDK_Aftermath_SetEventMarker' with 'markerDataSize = 0'. + * This instructs Aftermath not to allocate and copy off memory internally, + * relying on the application to manage marker pointers itself. + * + * + * 3) Once TDR/hang occurs, call the 'GFSDK_Aftermath_GetData' API to fetch the + * event marker last processed by the GPU for each context. This API also + * supports fetching the current execution state for each the GPU. + * + * + * 4) Before the app shuts down, each Aftermath context handle must be cleaned + * up, this is done with the 'GFSDK_Aftermath_ReleaseContextHandle' call. + * + * + * + * HOW TO USE AFTERMATH for Vulkan + * ------------------------------- + * + * For Vulkan use the 'VK_NV_device_diagnostics_config' extension to initialize and + * configure the Aftermath feature set to use. The meaning of the flag bits + * defined by 'VkDeviceDiagnosticsConfigFlagBitsNV' correspond to the features + * defined by 'GFSDK_Aftermath_FeatureFlags' for DX11/DX12 below. + * + * Use the 'VK_NV_device_diagnostic_checkpoints' extension to add event markers into + * the command stream. + * + */ + +#ifndef GFSDK_Aftermath_H +#define GFSDK_Aftermath_H + +#include "GFSDK_Aftermath_Defines.h" + +#pragma pack(push, 8) + +#ifdef __cplusplus +extern "C" { +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_FeatureFlags +// --------------------------------- +// +// Feature flags that can be used to enabled various features when initializing DX +// Aftermath via the 'GFSDK_Aftermath_DX11_Initialize' and +// 'GFSDK_Aftermath_DX12_Initialize' functions. +// +// For Vulkan, the same set of features can be controlled through the +// 'VkDeviceDiagnosticsConfigFlagBitsNV' defined by the +// 'VK_NV_device_diagnostics_config' extension. See also the description of the +// configuration flag bits in the 'Readme.md' file. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(FeatureFlags){ + // The minimal flag only allows use of the 'GFSDK_Aftermath_GetDeviceStatus' + // entry point and GPU crash dump generation with basic information about the + // GPU fault. + GFSDK_Aftermath_FeatureFlags_Minimum = 0x00000000, + + // This flag enables support for DX Aftermath event markers, including both + // the support for user markers that are explicitly added by the application + // via 'GFSDK_Aftermath_SetEventMarker' and automatic call stack markers + // controlled by 'GFSDK_Aftermath_FeatureFlags_CallStackCapturing'. + // + // For Vulkan, the event marker (checkpoints) feature is enabled through the + // 'VK_NV_device_diagnostic_checkpoints' extension. + // + // NOTE: Using event markers should be considered carefully as they can cause + // very high CPU overhead when used in high frequency code paths. Due to the + // inherent overhead, event markers should be used only for debugging purposes on + // development or QA systems. Therefore, on some driver versions, Aftermath + // event marker tracking on DX11 and DX12 is only available if the Nsight + // Aftermath GPU Crash Dump Monitor is running on the system. This requirement + // applies to R495 to R530 drivers for DX12 and R495+ drivers for DX11. No Aftermath + // configuration needs to be made in the Monitor. It serves only as a dongle to + // ensure Aftermath event markers do not impact application performance on end + // user systems. That means this flag will be ignored if the monitor process is + // not detected. + GFSDK_Aftermath_FeatureFlags_EnableMarkers = 0x00000001, + + // With this flag set, live and recently destroyed resources are tracked by the + // display driver. In case of a page fault that information will be used to + // identify possible candidates of deleted resources that correspond to the fault + // address. Information about the most likely resource related to the fault will + // be included in the page fault data, including, for example, information about + // the size of the resource, its format, and the epoch time stamp when it was + // deleted. + // + // The corresponding feature configuration flag for Vulkan is + // 'VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_RESOURCE_TRACKING_BIT_NV'. + // + // NOTE: Enabling this feature will incur memory overhead due to the additional + // tracking data managed by the display driver as well as CPU overhead for each + // resource creation and destruction. + GFSDK_Aftermath_FeatureFlags_EnableResourceTracking = 0x00000002, + + // With this flag set, event markers are automatically set for all draw calls, + // compute dispatches and copy operations to capture the CPU call stack for the + // corresponding API call as the event marker payload. + // + // The corresponding feature configuration flag for Vulkan is + // 'VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_AUTOMATIC_CHECKPOINTS_BIT_NV'. + // + // NOTE: Requires also 'GFSDK_Aftermath_FeatureFlags_EnableMarkers' to be set. + // + // NOTE: Enabling this feature will cause very high CPU overhead during command + // list recording. Due to the inherent overhead, call stack capturing should only + // be used for debugging purposes on development or QA systems and should not be + // enabled in applications shipped to customers. Therefore, on R495+ drivers, + // call stack capturing on DX11 and DX12 is only available if the Nsight Aftermath + // GPU Crash Dump Monitor is running on the system. No Aftermath configuration + // needs to be made in the Monitor. It serves only as a dongle to ensure call + // stack capturing does not impact application performance on end user systems. + // That means this flag will be ignored if the monitor process is not detected. + // + // NOTE: When enabling this feature, Aftermath GPU crash dumps will include file + // paths to the crashing application's executable as well as all DLLs it has loaded. + GFSDK_Aftermath_FeatureFlags_CallStackCapturing = 0x40000000, + + // With this flag set, debug information (line tables for mapping from the shader + // IL passed to the driver to the shader microcode) for all shaders is generated + // by the display driver. + // + // The corresponding feature configuration flag for Vulkan is + // 'VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_DEBUG_INFO_BIT_NV'. + // + // NOTE: Using this feature should be considered carefully. It may cause + // considerable shader compilation overhead and additional overhead for handling + // the corresponding shader debug information callbacks (if provided to + // 'GFSDK_Aftermath_EnableGpuCrashDumps'). + // + // NOTE: shader debug information is only supported for DX12 applications using + // shaders compiled as DXIL. This flag has no effect on DX11 applications. + GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo = 0x00000008, + + // If this flag is set, the GPU will run in a mode that allows to capture runtime + // errors in shaders that are not caught with default driver settings. This may + // provide additional information for debugging GPU hangs, GPU crashes or other + // unexpected behavior related to shader execution. + // + // The corresponding feature configuration flag for Vulkan is + // 'VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV'. + // + // NOTE: Enabling this feature does not cause any performance overhead, but it + // may result in additional crash dumps being generated to report issues in + // shaders that exhibit undefined behavior or have hidden bugs, which so far went + // unnoticed, because with default driver settings the HW silently ignores them. + // + // NOTE: This feature is only supported on R515 or later drivers. The feature + // flag will be ignored on earlier driver versions. + // + // Examples for problems that are caught when this feature is enabled: + // + // o) Accessing memory using misaligned addresses, such as reading or + // writing a byte address that is not a multiple of the access size. + // + // o) Accessing memory out-of-bounds, such as reading or writing beyond the + // declared bounds of (group) shared or thread local memory or reading from an + // out-of-bounds constant buffer address. + // + // o) Hitting call stack limits. + GFSDK_Aftermath_FeatureFlags_EnableShaderErrorReporting = 0x00000010, +}; + +#if defined(__d3d11_h__) || defined(__d3d12_h__) + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ContextHandle +// --------------------------------- +// +// Used with Aftermath entry points to reference an API object. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_HANDLE(GFSDK_Aftermath_ContextHandle); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ResourceHandle +// --------------------------------- +// +// Used with the 'GFSDK_Aftermath_DX12_RegisterResource' and +// 'GFSDK_Aftermath_DX12_UnregisterResource' entry points to reference an API +// resource object. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_HANDLE(GFSDK_Aftermath_ResourceHandle); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ContextData +// --------------------------------- +// +// DEPRECATED - this functionality will go away in a future release. Do not use! +// +// Used with, 'GFSDK_Aftermath_GetData'. Filled with information, about each +// requested context. +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_ContextData +{ + GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(void*, markerData); + uint32_t markerSize; + GFSDK_Aftermath_Context_Status status; +} GFSDK_Aftermath_ContextData; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ResourceDescriptor +// --------------------------------- +// +// DEPRECATED - this functionality will go away in a future release. Do not use! +// +// Minimal description of a graphics resource. +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_ResourceDescriptor +{ + // This is available in DX12 only and only if the application registers the + // resource pointers using 'GFSDK_Aftermath_DX12_RegisterResource'. +#ifdef __d3d12_h__ + GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(ID3D12Resource*, pAppResource); +#else + GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(void*, pAppResource); +#endif + + uint64_t size; + + uint32_t width; + uint32_t height; + uint32_t depth; + + uint32_t mipLevels; + + uint32_t format; // DXGI_FORMAT + + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsBufferHeap); + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsStaticTextureHeap); + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsRtvDsvTextureHeap); + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bPlacedResource); + + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bWasDestroyed); +} GFSDK_Aftermath_ResourceDescriptor; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_PageFaultInformation +// --------------------------------- +// +// DEPRECATED - this functionality will go away in a future release. Do not use! +// +// Used with GFSDK_Aftermath_GetPageFaultInformation +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_PageFaultInformation +{ + uint64_t faultingGpuVA; + GFSDK_Aftermath_ResourceDescriptor resourceDesc; + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bHasPageFaultOccured); +} GFSDK_Aftermath_PageFaultInformation; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_DX11_Initialize +// GFSDK_Aftermath_DX12_Initialize +// --------------------------------- +// +// [pDx11Device]; DX11-Only +// The current dx11 device pointer. +// +// [pDx12Device]; DX12-Only +// The current dx12 device pointer. +// +// flags; +// The set of features to enable when initializing Aftermath. +// +// version; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against library +// version. +// +//// DESCRIPTION; +// Library must be initialized before any other call is made. This should be +// done after device creation. Aftermath currently only supports one D3D +// device, the first one that is initialized. +// +///////////////////////////////////////////////////////////////////////// +#ifdef __d3d11_h__ +GFSDK_Aftermath_API GFSDK_Aftermath_DX11_Initialize(GFSDK_Aftermath_Version version, uint32_t flags, ID3D11Device* const pDx11Device); +#endif +#ifdef __d3d12_h__ +GFSDK_Aftermath_API GFSDK_Aftermath_DX12_Initialize(GFSDK_Aftermath_Version version, uint32_t flags, ID3D12Device* const pDx12Device); +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_DX11_CreateContextHandle +// GFSDK_Aftermath_DX12_CreateContextHandle +// --------------------------------- +// +// (pDx11DeviceContext); DX11-Only +// Device context to use with Aftermath. +// +// (pDx12Unknown); DX12-Only +// Command list, Command Queue, or Device to use with Aftermath. If a device, +// must be the same device given to 'GFSDK_Aftermath_DX12_Initialize'. If a +// command list, it must be in the recording state. +// +// pOutContextHandle; +// The context handle for the specified context/command list/command +// queue/device to be used with future Aftermath calls. +// +//// DESCRIPTION; +// Before Aftermath event markers can be inserted into the command stream of a +// DX12 command list or a DX11 device context, a context handle must first be +// fetched. A context handle is also required for querying the event marker +// status with 'GFSDK_Aftermath_GetData'. +// +///////////////////////////////////////////////////////////////////////// +#ifdef __d3d11_h__ +GFSDK_Aftermath_API GFSDK_Aftermath_DX11_CreateContextHandle(ID3D11DeviceContext* const pDx11DeviceContext, GFSDK_Aftermath_ContextHandle* pOutContextHandle); +#endif +#ifdef __d3d12_h__ +GFSDK_Aftermath_API GFSDK_Aftermath_DX12_CreateContextHandle(IUnknown* const pDx12Unknown, GFSDK_Aftermath_ContextHandle* pOutContextHandle); +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_API GFSDK_Aftermath_ReleaseContextHandle +// ------------------------------------- +// +// contextHandle; +// Context to release +// +// DESCRIPTION; +// Cleans up any resources associated with an Aftermath context. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_ReleaseContextHandle(const GFSDK_Aftermath_ContextHandle contextHandle); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_SetEventMarker +// ------------------------------------- +// +// contextHandle; +// Command list currently being populated, which must be in the recording state. +// +// markerData; +// Pointer to data used for event marker. +// +// NOTE: If 'markerDataSize' is also provided, an internal copy will be made of this +// data. In that case there is no need to keep it around after this call - stack +// allocation of the data is safe. +// +// markerDataSize; +// Size of event marker data in bytes. +// +// NOTE: Passing a 0 for this parameter is valid, and will instruct Aftermath to +// only copy off the pointer supplied by 'markerData', rather than internally +// making a copy. In this case, additional work is required to include the +// marker data into Aftermath crash dumps. The application needs to keep track +// of the 'markerData' pointer and resolve it to the actual marker data via the +// 'resolveMarkerCb' provided to 'GFSDK_Aftermath_EnableGpuCrashDumps'. +// +// NOTE: Aftermath will internally truncate marker data to a maximum size of +// 1024 bytes. Use 'markerDataSize = 0' and manually manage memory for markers if +// the application requires larger ones. +// +// DESCRIPTION; +// Drops an event into the command stream with a payload that can be linked back +// to the data given here, 'markerData'. It's safe to call from multiple threads +// simultaneously, normal D3D API threading restrictions apply. +// +// NOTE: Using event markers should be considered carefully as they can cause +// considerable CPU overhead when used in high frequency code paths. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_SetEventMarker(const GFSDK_Aftermath_ContextHandle contextHandle, const void* pMarkerData, const uint32_t markerDataSize); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetData +// ------------------------------ +// +// DEPRECATED - this functionality will go away in a future release. Do not use! +// +// numContexts; +// Number of contexts to fetch information for. +// +// pContextHandles; +// Array of contexts containing Aftermath event markers. +// +// pOutContextData; +// OUTPUT: context data for each context requested. Contains event last reached +// on the GPU, and status of context if applicable (DX12-Only). +// +// NOTE: must allocate enough space for 'numContexts' worth of structures. +// Stack allocation is fine. +// +// DESCRIPTION; +// Once a TDR/crash/hang has occurred (or whenever you like), call this API to +// retrieve the events last processed by the GPU on the given contexts. The +// context handles may refer to DX12 command lists, queues, or DX11 device +// contexts. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GetData(const uint32_t numContexts, const GFSDK_Aftermath_ContextHandle* pContextHandles, GFSDK_Aftermath_ContextData* pOutContextData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetContextError +// ------------------------------ +// +// DEPRECATED - this functionality will go away in a future release. Do not use! +// +// pContextData; +// Context data for which to determine error status. +// +// DESCRIPTION; +// Call this to determine the detailed failure reason for +// GFSDK_Aftermath_ContextData with 'status == GFSDK_Aftermath_Context_Status_Invalid'. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GetContextError(const GFSDK_Aftermath_ContextData* pContextData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetDeviceStatus +// --------------------------------- +// +// pOutStatus; +// OUTPUT: Device status. +// +//// DESCRIPTION; +// Return the status of a D3D device. See 'GFSDK_Aftermath_Device_Status'. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GetDeviceStatus(GFSDK_Aftermath_Device_Status* pOutStatus); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetPageFaultInformation +// --------------------------------- +// +// DEPRECATED - this functionality will go away in a future release. Do not use! +// +// pOutPageFaultInformation; +// OUTPUT: Information about a page fault which may have occurred. +// +//// DESCRIPTION; +// Return any information available about a recent page fault which may have +// occurred, causing a device removed scenario. See +// 'GFSDK_Aftermath_PageFaultInformation'. +// +// Requires WDDMv2 (Windows 10) or later +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GetPageFaultInformation(GFSDK_Aftermath_PageFaultInformation* pOutPageFaultInformation); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_DX12_RegisterResource +// --------------------------------- +// +// pResource; +// ID3D12Resource to register. +// +// pOutResourceHandle; +// OUTPUT: Aftermath resource handle for the resource that was registered. +// +//// DESCRIPTION; +// Registers an 'ID3D12Resource' with Aftermath. This allows Aftermath to map +// the GPU virtual address of a page fault to the corresponding 'ID3D12Resource' +// pointer and the driver level resource tracking data (enabled via +// 'GFSDK_Aftermath_FeatureFlags_EnableResourceTracking'). If called after +// 'ID3D12Object::SetName', it will also allow tracking of the debug object name +// assigned to the resource (requires R530 driver). +// +// NOTE: This function is only supported on Windows 10 RS4 and later. It will +// return 'GFSDK_Aftermath_Result_FAIL_D3dDllNotSupported', if the version of the +// D3D DLL loaded by the application is not supported. +// +// NOTE: This function is not compatible with graphics debuggers, such as Nsight +// Graphics, PIX, or the Visual Studio Graphics Debugger. It may fail with +// 'GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported' when called, if +// such a debugger is active. +// +// NOTE: This is a BETA FEATURE and may not work with all versions of Windows. +// +///////////////////////////////////////////////////////////////////////// +#if defined(__d3d12_h__) +GFSDK_Aftermath_API GFSDK_Aftermath_DX12_RegisterResource(ID3D12Resource* const pApiResource, GFSDK_Aftermath_ResourceHandle* pOutResourceHandle); +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_DX12_UnregisterResource +// --------------------------------- +// +// resourceHandle; +// Aftermath resource handle for a resource that was registered earlier with +// 'GFSDK_Aftermath_DX12_RegisterResource'. +// +//// DESCRIPTION; +// Unregisters a previously registered resource. This will tell Aftermath +// that the resource tracking data that was allocated for this resource +// may be reused in LRU order for new resources being registered via +// 'GFSDK_Aftermath_DX12_RegisterResource'. Aftermath will guarantee a +// look-back of the least recently unregistered 1024 resources before +// reusing the corresponding tracking data. +// +// NOTE: This is a BETA FEATURE and may not work with all versions of Windows. +// +///////////////////////////////////////////////////////////////////////// +#if defined(__d3d12_h__) +GFSDK_Aftermath_API GFSDK_Aftermath_DX12_UnregisterResource(const GFSDK_Aftermath_ResourceHandle resourceHandle); +#endif + +///////////////////////////////////////////////////////////////////////// +// +// Function pointer definitions - if dynamic loading is preferred. +// +///////////////////////////////////////////////////////////////////////// +#if defined(__d3d11_h__) +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_DX11_Initialize)(GFSDK_Aftermath_Version version, uint32_t flags, ID3D11Device* const pDx11Device); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_DX11_CreateContextHandle)(ID3D11DeviceContext* const pDx11DeviceContext, GFSDK_Aftermath_ContextHandle* pOutContextHandle); +#endif + +#if defined(__d3d12_h__) +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_DX12_Initialize)(GFSDK_Aftermath_Version version, uint32_t flags, ID3D12Device* const pDx12Device); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_DX12_CreateContextHandle)(IUnknown* const pDx12CommandList, GFSDK_Aftermath_ContextHandle* pOutContextHandle); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_DX12_RegisterResource)(ID3D12Resource* const pApiResource, GFSDK_Aftermath_ResourceHandle* pOutResourceHandle); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_DX12_UnregisterResource)(const GFSDK_Aftermath_ResourceHandle resourceHandle); +#endif + +#if defined(__d3d11_h__) || defined(__d3d12_h__) +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_ReleaseContextHandle)(const GFSDK_Aftermath_ContextHandle contextHandle); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_SetEventMarker)(const GFSDK_Aftermath_ContextHandle contextHandle, const void* markerData, const uint32_t markerDataSize); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetData)(const uint32_t numContexts, const GFSDK_Aftermath_ContextHandle* ppContextHandles, GFSDK_Aftermath_ContextData* pOutContextData); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetContextError)(const GFSDK_Aftermath_ContextData* pContextData); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetDeviceStatus)(GFSDK_Aftermath_Device_Status* pOutStatus); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetPageFaultInformation)(GFSDK_Aftermath_PageFaultInformation* pOutPageFaultInformation); +#endif + +#endif // defined(__d3d11_h__) || defined(__d3d12_h__) + +#if defined(VULKAN_H_) +// See VK_NV_device_diagnostics_config +// See VK_NV_device_diagnostic_checkpoints +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#pragma pack(pop) + +#endif // GFSDK_Aftermath_H diff --git a/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_Defines.h b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_Defines.h new file mode 100644 index 0000000..4fff944 --- /dev/null +++ b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_Defines.h @@ -0,0 +1,288 @@ +/* + * Copyright (c) 2016-2024, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +/* + * █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER + * ██ ██ + * ████████████████████████████████████████████████████████ ██ █ ██ ████████████ + */ + +#ifndef GFSDK_Aftermath_Defines_H +#define GFSDK_Aftermath_Defines_H + +#if defined(_MSC_VER) +#if defined(_M_X86) +#define GFSDK_AFTERMATH_CALL __cdecl +#else +#define GFSDK_AFTERMATH_CALL +#endif +#elif defined(__clang__) || defined(__GNUC__) +#if defined(__i386__) +#define GFSDK_AFTERMATH_CALL __attribute__((cdecl)) +#else +#define GFSDK_AFTERMATH_CALL +#endif +#else +#error "Unsupported compiler" +#endif + +#ifdef __cplusplus +#include +#else +#include +#include +#endif + +// Library stuff... +#define GFSDK_Aftermath_PFN typedef GFSDK_Aftermath_Result + +#if defined(_MSC_VER) +#ifdef EXPORTS +#define GFSDK_Aftermath_DLLSPEC __declspec(dllexport) +#else +#define GFSDK_Aftermath_DLLSPEC +#endif +#elif defined(__clang__) || defined(__GNUC__) +#define GFSDK_Aftermath_DLLSPEC __attribute__((visibility("default"))) +#endif + +#ifdef __cplusplus +#define GFSDK_Aftermath_API extern "C" GFSDK_Aftermath_DLLSPEC GFSDK_Aftermath_Result GFSDK_AFTERMATH_CALL +#else +#define GFSDK_Aftermath_API GFSDK_Aftermath_DLLSPEC GFSDK_Aftermath_Result GFSDK_AFTERMATH_CALL +#endif + +#pragma pack(push, 8) + +///////////////////////////////////////////////////////////////////////// +// +// Helper macros for declaring struct members and types with guaranteed properties. +// +///////////////////////////////////////////////////////////////////////// +#define GFSDK_AFTERMATH_DECLARE_HANDLE(name) \ + struct name##__ \ + { \ + int32_t ID; \ + }; \ + typedef struct name##__* name +#ifdef __cplusplus +#define GFSDK_AFTERMATH_DECLARE_ENUM(name) enum GFSDK_Aftermath_##name : uint32_t +#else +#define GFSDK_AFTERMATH_DECLARE_ENUM(name) \ + typedef uint32_t GFSDK_Aftermath_##name; \ + enum GFSDK_Aftermath_##name +#endif +#define GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(type, name) \ + union \ + { \ + type name; \ + uint64_t ptr_align_##name; \ + } +#define GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(name) \ + union \ + { \ + bool name; \ + uint32_t bool_align_##name; \ + } + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_Version +// --------------------------------- +// +// Aftermath API version +// +// NOTE: The Aftermath SDK does not guarantee compatibility between different +// API versions. Therefore, the API version of the header files used for +// building the application needs to match the API version of the Aftermath +// library loaded by the application. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(Version){ + GFSDK_Aftermath_Version_API = 0x0000217 // Version 2.23 +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_Result +// --------------------------------- +// +// Result codes returned by Aftermath API functions +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(Result){ + // The call was successful. + GFSDK_Aftermath_Result_Success = 0x1, + + // The requested functionality is not available. + GFSDK_Aftermath_Result_NotAvailable = 0x2, + + // The call failed with an unspecified failure. + GFSDK_Aftermath_Result_Fail = 0xBAD00000, + + // The callee tries to use a library version which does not match the built + // binary. + GFSDK_Aftermath_Result_FAIL_VersionMismatch = GFSDK_Aftermath_Result_Fail | 1, + + // The library hasn't been initialized, see 'GFSDK_Aftermath_DX*_Initialize'. + GFSDK_Aftermath_Result_FAIL_NotInitialized = GFSDK_Aftermath_Result_Fail | 2, + + // The callee tries to use the library with a non-supported GPU. Only NVIDIA GPUs + // are supported. + GFSDK_Aftermath_Result_FAIL_InvalidAdapter = GFSDK_Aftermath_Result_Fail | 3, + + // The callee passed an invalid parameter to the library, likely a null pointer + // or a bad handle. + GFSDK_Aftermath_Result_FAIL_InvalidParameter = GFSDK_Aftermath_Result_Fail | 4, + + // Something weird happened that caused the library to fail for an unknown + // reason. + GFSDK_Aftermath_Result_FAIL_Unknown = GFSDK_Aftermath_Result_Fail | 5, + + // Got a failure from the graphics API. + GFSDK_Aftermath_Result_FAIL_ApiError = GFSDK_Aftermath_Result_Fail | 6, + + // Make sure that the NvAPI DLL is up to date. + GFSDK_Aftermath_Result_FAIL_NvApiIncompatible = GFSDK_Aftermath_Result_Fail | 7, + + // It would appear as though a call has been made to fetch the Aftermath data for + // a context that hasn't yet been used with the event marker API. + GFSDK_Aftermath_Result_FAIL_GettingContextDataWithNewCommandList = GFSDK_Aftermath_Result_Fail | 8, + + // Looks like the library has already been initialized. + GFSDK_Aftermath_Result_FAIL_AlreadyInitialized = GFSDK_Aftermath_Result_Fail | 9, + + // A debug layer not compatible with Aftermath has been detected. + GFSDK_Aftermath_Result_FAIL_D3DDebugLayerNotCompatible = GFSDK_Aftermath_Result_Fail | 10, + + // Aftermath failed to initialize in the graphics driver. + GFSDK_Aftermath_Result_FAIL_DriverInitFailed = GFSDK_Aftermath_Result_Fail | 11, + + // Aftermath v2.x requires NVIDIA graphics driver version 387.xx or beyond. + GFSDK_Aftermath_Result_FAIL_DriverVersionNotSupported = GFSDK_Aftermath_Result_Fail | 12, + + // The system ran out of memory for allocations. + GFSDK_Aftermath_Result_FAIL_OutOfMemory = GFSDK_Aftermath_Result_Fail | 13, + + // No need to get data on bundles, as markers execute on the command list. + GFSDK_Aftermath_Result_FAIL_GetDataOnBundle = GFSDK_Aftermath_Result_Fail | 14, + + // No need to get data on deferred contexts, as markers execute on the immediate + // context. + GFSDK_Aftermath_Result_FAIL_GetDataOnDeferredContext = GFSDK_Aftermath_Result_Fail | 15, + + // This feature hasn't been enabled at initialization - see 'GFSDK_Aftermath_FeatureFlags'. + GFSDK_Aftermath_Result_FAIL_FeatureNotEnabled = GFSDK_Aftermath_Result_Fail | 16, + + // No resources have ever been registered. + GFSDK_Aftermath_Result_FAIL_NoResourcesRegistered = GFSDK_Aftermath_Result_Fail | 17, + + // This resource has never been registered. + GFSDK_Aftermath_Result_FAIL_ThisResourceNeverRegistered = GFSDK_Aftermath_Result_Fail | 18, + + // The functionality is not supported for UWP applications. + GFSDK_Aftermath_Result_FAIL_NotSupportedInUWP = GFSDK_Aftermath_Result_Fail | 19, + + // The version of the D3D DLL is not compatible with Aftermath. + GFSDK_Aftermath_Result_FAIL_D3dDllNotSupported = GFSDK_Aftermath_Result_Fail | 20, + + // D3D DLL interception is not compatible with Aftermath. + GFSDK_Aftermath_Result_FAIL_D3dDllInterceptionNotSupported = GFSDK_Aftermath_Result_Fail | 21, + + // Aftermath is disabled on the system by the current user. + // On Windows, this is controlled by a Windows registry key: + // KeyPath : HKEY_CURRENT_USER\Software\NVIDIA Corporation\Nsight Aftermath + // KeyValue : ForceOff + // ValueType : REG_DWORD + // ValueData : Any value != 0 will force the functionality of the Aftermath + // SDK off on the system. + // + // On Linux, this is controlled by an environment variable: + // Name : NV_AFTERMATH_FORCE_OFF + // Value : Any value != "0" will force the functionality of the Aftermath SDK + // off. + GFSDK_Aftermath_Result_FAIL_Disabled = GFSDK_Aftermath_Result_Fail | 22, + + // Markers cannot be set on queue or device contexts. + GFSDK_Aftermath_Result_FAIL_NotSupportedOnContext = GFSDK_Aftermath_Result_Fail | 23, +}; + +///////////////////////////////////////////////////////////////////////// +// +// Macro for simplified checking of API call result code. +// +///////////////////////////////////////////////////////////////////////// +#define GFSDK_Aftermath_SUCCEED(value) (((value) & 0xFFF00000) != GFSDK_Aftermath_Result_Fail) + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_Context_Status +// --------------------------------- +// +// Status of an Aftermath context. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(Context_Status){ + // The GPU has not started processing this command list yet. + GFSDK_Aftermath_Context_Status_NotStarted = 0, + + // This command list has begun execution on the GPU. + GFSDK_Aftermath_Context_Status_Executing, + + // This command list has finished execution on the GPU. + GFSDK_Aftermath_Context_Status_Finished, + + // This context has an invalid state, which could be caused by an error. + GFSDK_Aftermath_Context_Status_Invalid, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_Device_Status +// --------------------------------- +// +// Status of a D3D device. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(Device_Status){ + // The device is still active and hasn't gone down. + GFSDK_Aftermath_Device_Status_Active = 0, + + // A long running shader/operation has caused a GPU timeout. Reconfiguring the + // timeout length might help tease out the problem. + GFSDK_Aftermath_Device_Status_Timeout, + + // Run out of memory to complete operations. + GFSDK_Aftermath_Device_Status_OutOfMemory, + + // An invalid VA access has caused a fault. + GFSDK_Aftermath_Device_Status_PageFault, + + // The GPU has stopped executing. + GFSDK_Aftermath_Device_Status_Stopped, + + // The device has been reset. + GFSDK_Aftermath_Device_Status_Reset, + + // Unknown problem - likely using an older driver incompatible with this + // Aftermath feature. + GFSDK_Aftermath_Device_Status_Unknown, + + // An invalid rendering call has percolated through the driver. + GFSDK_Aftermath_Device_Status_DmaFault, + + // The device was removed but no GPU fault was detected. + GFSDK_Aftermath_Device_Status_DeviceRemovedNoGpuFault, +}; + +#pragma pack(pop) + +#endif // GFSDK_Aftermath_Defines_H diff --git a/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDump.h b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDump.h new file mode 100644 index 0000000..0da0a16 --- /dev/null +++ b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDump.h @@ -0,0 +1,477 @@ +/* + * Copyright (c) 2019-2023, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +/* + * █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER + * ██ ██ + * ████████████████████████████████████████████████████████ ██ █ ██ ████████████ + * + * + * HOW TO USE AFTERMATH GPU CRASH DUMP COLLECTION: + * ----------------------------------------------- + * + * 1) Call 'GFSDK_Aftermath_EnableGpuCrashDumps', to enable GPU crash dump collection. + * This must be done before any other library calls are made and before any D3D + * device is created by the application. + * + * With this call the application can register a callback function that is invoked + * with the GPU crash dump data once a TDR/hang occurs. In addition, it is also + * possible to provide optional callback functions for collecting shader debug + * information and for providing additional descriptive data from the application to + * include in the crash dump. + * + * Enabling GPU crash dumps will also override any settings from an also active + * Nsight Graphics GPU crash dump monitor for the calling process. + * + * + * 2) On DX11/DX12, call 'GFSDK_Aftermath_DXxx_Initialize', to initialize the library and + * to enable additional Aftermath features that will affect the data captured in + * the GPU crash dumps, such as Aftermath event markers, automatic call stack + * markers, resource tracking, shader debug information, or additional shader + * error reporting. See 'GFSDK_Aftermath.h' for more details. + * + * On Vulkan use the 'VK_NV_device_diagnostics_config' extension to enable + * additional Aftermath features, such as automatic call stack markers, resource + * tracking, shader debug information, or additional shader error reporting. See + * 'Readme.md' for more details. + * + * + * 4) Before the application shuts down, call 'GFSDK_Aftermath_DisableGpuCrashDumps' to + * disable GPU crash dump collection. + * + * Disabling GPU crash dumps will also re-establish any settings from an also active + * Nsight Graphics GPU crash dump monitor for the calling process. + * + * + * 5) If the application detects a potential GPU crash, i.e., device removed/lost, + * call 'GFSDK_Aftermath_GetCrashDumpStatus' to check the GPU crash dump status. + * The application should then wait until Aftermath has finished processing the + * crash dump before releasing the device or exiting. + * + * The recommended process for handling device removed/lost events is as follows: + * + * a) Call 'GFSDK_Aftermath_GetCrashDumpStatus' to check the GPU crash dump status. + * + * b) If the status is "Unknown", this means the graphics driver does not support + * the crash dump status query feature. But it is still possible to receive the + * "Finished" or "Failed" status. The application should continue to poll the + * status as described in step d) below. + * + * c) If the status is not "Unknown" and not "NotStarted", this means Aftermath + * has detected the GPU crash. + * + * d) The application should wait for a few seconds to allow the Aftermath + * graphics driver thread to collect the GPU crash dump data. Start polling the + * status until the crash dump data has been collected and the notification + * callback has been processed by the application, or a timeout of a couple of + * seconds has expired. + * + * e) If the timeout expires or the status returns "Finished" or "Failed" you + * should continue handling the device lost event as normal (e.g., release + * the device and/or terminate the application). + * + * Pseudo code implementing the above steps: + * + * if (deviceLost) + * { + * // Check Aftermath crash dump status + * GFSDK_Aftermath_CrashDump_Status status = GFSDK_Aftermath_CrashDump_Status_Unknown; + * AFTERMATH_CHECK_ERROR(GFSDK_Aftermath_GetCrashDumpStatus(&status)); + * + * // Loop while Aftermath crash dump data collection has not finished or + * // the application is still processing the crash dump data. + * while (status != GFSDK_Aftermath_CrashDump_Status_CollectingDataFailed && + * status != GFSDK_Aftermath_CrashDump_Status_Finished && + * !timeout) + * { + * // Wait for a couple of milliseconds, and poll the crash dump status again. + * Sleep(50); + * GFSDK_Aftermath_GetCrashDumpStatus(&status); + * } + * + * HandleDeviceLost(); + * } + * + * + * OPTIONAL: + * + * o) (Optional) Instrument the application with event markers as described in + * 'GFSDK_Aftermath.h'. + * + * o) (Optional, DX12-Only) Register DX12 resource pointers with Aftermath as + * described in 'GFSDK_Aftermath.h'. + * + * + * PERFORMANCE TIPS: + * + * o) Enabling shader debug information creation will introduce shader compile + * time overhead as well as memory overhead for handling the debug information. + * + * o) User event markers cause considerable overhead and should be used very + * carefully. + * + * o) Automatic call stack markers for draw calls, compute and ray tracing + * dispatches, acceleration structure building, and copy operations provide a + * less intrusive alternative to manually injecting event markers for every + * command. However, they are in general even more expensive in terms of CPU + * overhead and should be avoided in shipping applications. + * + */ + +#ifndef GFSDK_Aftermath_GpuCrashDump_H +#define GFSDK_Aftermath_GpuCrashDump_H + +#include "GFSDK_Aftermath_Defines.h" + +#pragma pack(push, 8) + +#ifdef __cplusplus +extern "C" { +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags +// --------------------------------- +// +// Flags to configure for which graphics APIs to enable GPU crash dumps. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpWatchedApiFlags){ + // Default setting - GPU crash dump tracking disabled. + GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_None = 0x0, + + // Enable GPU crash dump tracking for the DX API. + GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_DX = 0x1, + + // Enable GPU crash dump tracking for the Vulkan API. + GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags_Vulkan = 0x2, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDumpFeatureFlags +// --------------------------------- +// +// Flags to configure GPU crash dump-specific Aftermath features. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpFeatureFlags){ + // Default settings + GFSDK_Aftermath_GpuCrashDumpFeatureFlags_Default = 0x0, + + // Defer shader debug information callbacks until an actual GPU crash dump + // is generated and execute shader debug information callbacks only for the + // shaders related to the crash dump. + // + // NOTE: Using this option will increase the memory footprint of the + // application. + GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks = 0x1, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDumpDescriptionKey +// --------------------------------- +// +// Key definitions for user-defined GPU crash dump description. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpDescriptionKey){ + // Predefined key for application name. + GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationName = 0x1, + + // Predefined key for application version. + GFSDK_Aftermath_GpuCrashDumpDescriptionKey_ApplicationVersion = 0x2, + + // Base key for creating user-defined key-value pairs. Any value greater or equal + // to 'GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined' will create a + // user-defined key-value pair. + GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined = 0x10000, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_CrashDump_Status +// --------------------------------- +// +// Aftermath GPU crash dump generation progress status. +// +// Applications are expected to check the status of the Aftermath crash dump +// generation progress if they detect a potential GPU crash, i.e., device +// removed/lost. For more details, see the description on how to set up an application +// for GPU crash dump collection at the beginning of this file. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(CrashDump_Status){ + // No GPU crash has been detected by Aftermath, so far. + GFSDK_Aftermath_CrashDump_Status_NotStarted = 0, + + // A GPU crash happened and was detected by Aftermath. Aftermath started to + // collect crash dump data. + GFSDK_Aftermath_CrashDump_Status_CollectingData, + + // Aftermath failed to collect crash dump data. No further callback will be + // invoked. + GFSDK_Aftermath_CrashDump_Status_CollectingDataFailed, + + // Aftermath is invoking the 'gpuCrashDumpCb' callback after collecting the crash + // dump data successfully. + GFSDK_Aftermath_CrashDump_Status_InvokingCallback, + + // The 'gpuCrashDumpCb' callback returned and Aftermath finished processing the + // GPU crash. The application should now continue with handling the device + // removed/lost situation. + GFSDK_Aftermath_CrashDump_Status_Finished, + + // Unknown problem - likely using an older driver incompatible with this + // Aftermath feature. + GFSDK_Aftermath_CrashDump_Status_Unknown, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_AddGpuCrashDumpDescription +// --------------------------------- +// +// Function for adding user-defined description key-value pairs used by +// 'GFSDK_Aftermath_GpuCrashDumpDescriptionCb'. +// +// Key must be one of the predefined keys of +// 'GFSDK_Aftermath_GpuCrashDumpDescriptionKey' or a user-defined key based on +// 'GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined'. All keys greater than +// the last predefined key in 'GFSDK_Aftermath_GpuCrashDumpDescriptionKey' and +// smaller than 'GFSDK_Aftermath_GpuCrashDumpDescriptionKey_UserDefined' are +// considered illegal and ignored. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription)(uint32_t key, const char* value); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDumpCb +// --------------------------------- +// +// GPU crash dump callback. +// +// If registered via 'GFSDK_Aftermath_EnableGpuCrashDumps' it will be called with the +// crash dump data when a GPU crash is detected by Aftermath. See the description of +// 'GFSDK_Aftermath_EnableGpuCrashDumps' for more details. +// +// NOTE: Except for the 'pUserData' pointer, all pointer values passed to the +// callbacks are only valid for the duration of the call! An implementation +// must make copies of the data if it intends to store it beyond that. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDumpCb)(const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, void* pUserData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderDebugInfoCb +// --------------------------------- +// +// Shader debug information callback. +// +// If registered via 'GFSDK_Aftermath_EnableGpuCrashDumps' it will be called with +// shader debug information (line tables for mapping from the shader IL passed to the +// driver to the shader microcode) if the shader debug information generation feature +// is enabled: 'GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo' or +// 'VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV'. Also see the +// description of 'GFSDK_Aftermath_EnableGpuCrashDumps' for more details. +// +// NOTE: Except for the 'pUserData' pointer, all pointer values passed to the +// callbacks are only valid for the duration of the call! An implementation +// must make copies of the data if it intends to store it beyond that. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_ShaderDebugInfoCb)(const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize, void* pUserData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDumpDescriptionCb +// --------------------------------- +// +// Crash dump description callback. +// +// If registered via 'GFSDK_Aftermath_EnableGpuCrashDumps' it will be called during +// GPU crash dump generation, i.e., before 'GFSDK_Aftermath_GpuCrashDumpCb' is called, +// and allows the application to provide additional information to be captured in the +// crash dump by calling the provided 'addValue' function. See the description of +// 'GFSDK_Aftermath_EnableGpuCrashDumps' for more details. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDumpDescriptionCb)(PFN_GFSDK_Aftermath_AddGpuCrashDumpDescription addValue, void* pUserData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ResolveMarkerCb +// --------------------------------- +// +// Marker data resolution callback. +// +// If registered via 'GFSDK_Aftermath_EnableGpuCrashDumps' it will be called during +// GPU crash dump data generation, i.e., before 'GFSDK_Aftermath_GpuCrashDumpCb' is +// called, when a DX event marker or a Vulkan checkpoint will be recorded into the +// crash dump. See the description of 'GFSDK_Aftermath_EnableGpuCrashDumps' for more details. +// +// NOTE: Except for the 'pUserData' pointer, all pointer values passed to the +// callbacks are only valid for the duration of the call! The application must ensure +// that the pointer returned through 'ppResolvedMarkerData' is valid after returning +// from the callback. Then, the GPU crash dump data collection process will make an +// internal copy of it. So, it's safe to reuse the memory in the next call, i.e., it's +// OK to store the memory blob where the 'ppResolvedMarkerData' is pointed to in static memory. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_ResolveMarkerCb)(const void* pMarkerData, const uint32_t markerDataSize, void* pUserData, void** ppResolvedMarkerData, uint32_t* pResolvedMarkerDataSize); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_EnableGpuCrashDumps +// --------------------------------- +// +// apiVersion; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against +// library version. +// +// watchedApis; +// Controls which graphics APIs to watch for crashes. A combination of +// 'GFSDK_Aftermath_GpuCrashDumpWatchedApiFlags'. +// +// flags; +// Controls GPU crash dump specific behavior. A combination of +// 'GFSDK_Aftermath_GpuCrashDumpFeatureFlags'. +// +// gpuCrashDumpCb; +// Callback function to be called when new GPU crash dump data is available. +// +// NOTE: This callback is free-threaded, ensure the provided function is +// thread-safe. +// +// shaderDebugInfoCb; +// Optional, can be NULL. +// +// Callback function to be called when new shader debug information data is +// available. Shader debug information generation needs to be enabled by +// setting the corresponding feature flags: +// * For DX: 'GFSDK_Aftermath_FeatureFlags_GenerateShaderDebugInfo' +// * For Vulkan: 'VK_DEVICE_DIAGNOSTICS_CONFIG_ENABLE_SHADER_ERROR_REPORTING_BIT_NV' +// +// NOTE: Shader debug information is only supported for DX12 (DXIL) and Vulkan +// (SPIR-V) shaders. +// +// NOTE: If not using 'GFSDK_Aftermath_GpuCrashDumpFeatureFlags_DeferDebugInfoCallbacks', +// 'shaderDebugInfoCb' will be invoked for every shader compilation by the +// graphics driver, even if there will be never an invocation of 'gpuCrashDumpCb'. +// +// NOTE: This callback is free-threaded, ensure the provided function is +// thread-safe. +// +// descriptionCb; +// Optional, can be NULL. +// +// Callback function that allows the application to provide additional +// descriptive values to be include in crash dumps. This will be called before +// 'gpuCrashDumpCb'. +// +// NOTE: This callback is free-threaded, ensure the provided function is +// thread-safe. +// +// resolveMarkerCb; +// Optional, can be NULL. +// +// Callback function to be called when the crash dump data generation encounters +// an event marker with a size of zero. This means that +// 'GFSDK_Aftermath_SetEventMarker' was called with 'markerDataSize = 0', meaning +// that the marker payload itself is managed by the application rather than +// copied by Aftermath internally. All Vulkan markers set using the +// 'NV_device_diagnostic_checkpoints' extension are application-managed as well. +// This callback allows the application to pass the marker's associated data +// back to the crash dump generation process to be included in the crash dump +// data. The application should set the value of 'ppResolvedMarkerData' to the +// pointer of the marker's data, and set the value of 'markerSize' to the size +// of the marker's data in bytes. +// +// NOTE: Applications must ensure that the marker data memory passed back via +// 'ppResolvedMarkerData' will remain valid for the entirety of the crash dump +// generation process, i.e., until 'gpuCrashDumpCb' is called. +// +// NOTE: This callback is only supported on R495 or later NVIDIA graphics drivers. If +// the application is running on a system using an earlier driver version, it will +// be ignored. +// +// NOTE: This callback is free-threaded, ensure the provided function is +// thread-safe. +// +// pUserData; +// Optional, can be NULL. +// +// User data pointer passed to the callbacks. +// +//// DESCRIPTION; +// Device independent initialization call to enable Aftermath GPU crash dump +// creation. This function must be called before any D3D or Vulkan device is +// created by the application. +// +// NOTE: This overrides any settings from an also active GPU crash dump monitor +// for this process! +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_EnableGpuCrashDumps( + GFSDK_Aftermath_Version apiVersion, + uint32_t watchedApis, + uint32_t flags, + PFN_GFSDK_Aftermath_GpuCrashDumpCb gpuCrashDumpCb, + PFN_GFSDK_Aftermath_ShaderDebugInfoCb shaderDebugInfoCb, + PFN_GFSDK_Aftermath_GpuCrashDumpDescriptionCb descriptionCb, + PFN_GFSDK_Aftermath_ResolveMarkerCb resolveMarkerCb, + void* pUserData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_DisableGpuCrashDumps +// --------------------------------- +// +//// DESCRIPTION; +// Device independent call to disable Aftermath GPU crash dump creation. +// Re-enables settings from an also active GPU crash dump monitor for the +// current process! +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_DisableGpuCrashDumps(); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetCrashDumpStatus +// --------------------------------- +// +// pOutStatus; +// OUTPUT: Crash dump status. +// +//// DESCRIPTION; +// If the application detects a potential crash (i.e., device +// removed/lost event), applications are expected to check the status of +// the Aftermath crash dump generation progress. This function allows to +// query the status of the GPU crash detection and the crash dump data +// collection. For more details, see 'GFSDK_Aftermath_CrashDump_Status' +// and the description of how to set up an application for GPU crash dump +// collection at the beginning of this file. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GetCrashDumpStatus(GFSDK_Aftermath_CrashDump_Status* pOutStatus); + +///////////////////////////////////////////////////////////////////////// +// +// Function pointer definitions - if dynamic loading is preferred. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_EnableGpuCrashDumps)(GFSDK_Aftermath_Version apiVersion, uint32_t watchedApis, uint32_t flags, PFN_GFSDK_Aftermath_GpuCrashDumpCb gpuCrashDumpCb, PFN_GFSDK_Aftermath_ShaderDebugInfoCb shaderDebugInfoCb, PFN_GFSDK_Aftermath_GpuCrashDumpDescriptionCb descriptionCb, PFN_GFSDK_Aftermath_ResolveMarkerCb resolveMarkerCb, void* pUserData); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_DisableGpuCrashDumps)(); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetCrashDumpStatus)(GFSDK_Aftermath_CrashDump_Status* pOutStatus); + +#ifdef __cplusplus +} // extern "C" +#endif + +#pragma pack(pop) + +#endif // GFSDK_Aftermath_GpuCrashDump_H diff --git a/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDumpDecoding.h b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDumpDecoding.h new file mode 100644 index 0000000..3ef36db --- /dev/null +++ b/Vendor/nvidia-aftermath/include/GFSDK_Aftermath_GpuCrashDumpDecoding.h @@ -0,0 +1,1284 @@ +/* + * Copyright (c) 2019-2024, NVIDIA CORPORATION. All rights reserved. + * + * NVIDIA CORPORATION and its licensors retain all intellectual property + * and proprietary rights in and to this software, related documentation + * and any modifications thereto. Any use, reproduction, disclosure or + * distribution of this software and related documentation without an express + * license agreement from NVIDIA CORPORATION is strictly prohibited. + */ + +/* + * █████ █████ ██████ ████ ████ ███████ ████ ██████ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██████ ████ ██ ████ █████ ██ ██ ██ ██████ ██ ███████ + * ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ + * ██ ██ ██ ██ █████ ██ ██ ██ ██ ██ ██ ██ ██ ██ DEBUGGER + * ██ ██ + * ████████████████████████████████████████████████████████ ██ █ ██ ████████████ + * + * + * HOW TO DECODE AFTERMATH GPU CRASH DUMPS: + * ---------------------------------------- + * + * 1) Call 'GFSDK_Aftermath_GpuCrashDump_CreateDecoder', to create a decoder object for + * a GPU crash dump. + * + * + * 2) Call one or more of the 'GFSDK_Aftermath_GpuCrashDump_Get*' functions with this + * decoder, to query information from the GPU crash dump. + * + * Some of the functions require caller allocated buffers to return the data. Those + * are accompanied with a corresponding 'GFSDK_Aftermath_GpuCrashDump_Get*Count' + * function to query the element count the caller has to reserve for these buffers. + * + * If the requested data is not available in the GPU crash dump, the functions + * will return with 'GFSDK_Aftermath_Result_NotAvailable'. + * + * + * 3) Call 'GFSDK_Aftermath_GpuCrashDump_DestroyDecoder', to destroy the decoder object + * and cleanup all related memory. + * + */ + +#ifndef GFSDK_Aftermath_CrashDumpDecoding_H +#define GFSDK_Aftermath_CrashDumpDecoding_H + +#include "GFSDK_Aftermath_Defines.h" + +#pragma pack(push, 8) + +#ifdef __cplusplus +extern "C" { +#endif + +///////////////////////////////////////////////////////////////////////// +// +// Constants used in GPU crash dump decoding functions. +// +///////////////////////////////////////////////////////////////////////// +enum +{ + GFSDK_Aftermath_MAX_STRING_LENGTH = 127, +}; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderDebugInfoIdentifier +// --------------------------------- +// +// Unique identifier for shader debug information. +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_ShaderDebugInfoIdentifier +{ + uint64_t id[2]; +} GFSDK_Aftermath_ShaderDebugInfoIdentifier; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderBinaryHash +// --------------------------------- +// +// Unique identifier for shader binaries. +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_ShaderBinaryHash +{ + uint64_t hash; +} GFSDK_Aftermath_ShaderBinaryHash; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderDebugName +// --------------------------------- +// +// Shader DebugName, i.e., a unique identifier for shader source debug information. +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_ShaderDebugName +{ + char name[GFSDK_Aftermath_MAX_STRING_LENGTH + 1]; +} GFSDK_Aftermath_ShaderDebugName; + +#if defined(VULKAN_H_) +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_SpirvCode +// --------------------------------- +// +// SPIR-V shader code. +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_SpirvCode +{ + GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(const void*, pData); + uint32_t size; +} GFSDK_Aftermath_SpirvCode; +#endif + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GraphicsApi +// --------------------------------- +// +// Graphics API +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(GraphicsApi){ + GFSDK_Aftermath_GraphicsApi_Unknown = 0, + GFSDK_Aftermath_GraphicsApi_D3D_10_0 = 1, + GFSDK_Aftermath_GraphicsApi_D3D_10_1 = 2, + GFSDK_Aftermath_GraphicsApi_D3D_11_0 = 3, + GFSDK_Aftermath_GraphicsApi_D3D_11_1 = 4, + GFSDK_Aftermath_GraphicsApi_D3D_11_2 = 5, + GFSDK_Aftermath_GraphicsApi_D3D_12_0 = 6, + GFSDK_Aftermath_GraphicsApi_Vulkan = 7, +}; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_BaseInfo +// --------------------------------- +// +// GPU crash dump - base information +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_GpuCrashDump_BaseInfo +{ + char applicationName[GFSDK_Aftermath_MAX_STRING_LENGTH + 1]; + char creationDate[GFSDK_Aftermath_MAX_STRING_LENGTH + 1]; + uint32_t creationTickCount; + uint32_t pid; + GFSDK_Aftermath_GraphicsApi graphicsApi; +} GFSDK_Aftermath_GpuCrashDump_BaseInfo; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_DeviceInfo +// --------------------------------- +// +// GPU crash dump - device information +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_GpuCrashDump_DeviceInfo +{ + GFSDK_Aftermath_Device_Status status; + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(adapterReset); + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(engineReset); +} GFSDK_Aftermath_GpuCrashDump_DeviceInfo; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_SystemInfo +// --------------------------------- +// +// GPU crash dump - system information +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_GpuCrashDump_SystemInfo +{ + char osVersion[GFSDK_Aftermath_MAX_STRING_LENGTH + 1]; + struct DisplayDriverVersion + { + uint32_t major; + uint32_t minor; + } displayDriver; +} GFSDK_Aftermath_GpuCrashDump_SystemInfo; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GpuInfo +// --------------------------------- +// +// GPU crash dump - GPU information +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_GpuCrashDump_GpuInfo +{ + char adapterName[GFSDK_Aftermath_MAX_STRING_LENGTH + 1]; + char generationName[GFSDK_Aftermath_MAX_STRING_LENGTH + 1]; + uint64_t adapterLUID; +} GFSDK_Aftermath_GpuCrashDump_GpuInfo; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_FaultType +// --------------------------------- +// +// GPU crash dump - page fault type +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(FaultType){ + GFSDK_Aftermath_FaultType_Unknown = 0, + GFSDK_Aftermath_FaultType_AddressTranslationError, + GFSDK_Aftermath_FaultType_IllegalAccessError, +}; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_AccessType +// --------------------------------- +// +// GPU crash dump - page fault access type +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(AccessType){ + GFSDK_Aftermath_AccessType_Unknown = 0, + GFSDK_Aftermath_AccessType_Read, + GFSDK_Aftermath_AccessType_Write, + GFSDK_Aftermath_AccessType_Atomic, +}; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_Engine +// --------------------------------- +// +// GPU crash dump - page fault GPU engine +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(Engine){ + GFSDK_Aftermath_Engine_Unknown = 0, + GFSDK_Aftermath_Engine_Graphics, + GFSDK_Aftermath_Engine_GraphicsCompute, + GFSDK_Aftermath_Engine_Display, + GFSDK_Aftermath_Engine_CopyEngine, + GFSDK_Aftermath_Engine_VideoDecoder, + GFSDK_Aftermath_Engine_VideoEncoder, + GFSDK_Aftermath_Engine_Other, +}; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_Client +// --------------------------------- +// +// GPU crash dump - page fault GPU client +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(Client){ + GFSDK_Aftermath_Client_Unknown = 0, + GFSDK_Aftermath_Client_HostInterface, + GFSDK_Aftermath_Client_FrontEnd, + GFSDK_Aftermath_Client_PrimitiveDistributor, + GFSDK_Aftermath_Client_GraphicsProcessingCluster, + GFSDK_Aftermath_Client_PolymorphEngine, + GFSDK_Aftermath_Client_RasterEngine, + GFSDK_Aftermath_Client_Rasterizer2D, + GFSDK_Aftermath_Client_RenderOutputUnit, + GFSDK_Aftermath_Client_TextureProcessingCluster, + GFSDK_Aftermath_Client_CopyEngine, + GFSDK_Aftermath_Client_VideoDecoder, + GFSDK_Aftermath_Client_VideoEncoder, + GFSDK_Aftermath_Client_Other, +}; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_PageFaultInfo +// --------------------------------- +// +// GPU crash dump - page fault information +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_GpuCrashDump_PageFaultInfo +{ + uint64_t faultingGpuVA; + GFSDK_Aftermath_FaultType faultType; + GFSDK_Aftermath_AccessType accessType; + GFSDK_Aftermath_Engine engine; + GFSDK_Aftermath_Client client; + uint32_t resourceInfoCount; +} GFSDK_Aftermath_GpuCrashDump_PageFaultInfo; + +typedef struct GFSDK_Aftermath_GpuCrashDump_ResourceInfo +{ + uint64_t gpuVa; + uint64_t size; + + uint32_t width; + uint32_t height; + uint32_t depth; + uint32_t mipLevels; + + uint32_t format; // DXGI_Format for DX, VkFormat for Vulkan + + // For DX12, and only if the application registers the resource pointers using + // 'GFSDK_Aftermath_DX12_RegisterResource', this is the 'ID3D12Resource' pointer + // that was registered and cast to 'uint64_t'. + // Note, if the resource was destroyed, this is a dangling pointer. + // For DX11, this is unsupported and will always be 0. + // For Vulkan, this is the VkImage or VkBuffer handle cast to 'uint64_t'. + // Note, if the resource was destroyed, this is a stale handle. + uint64_t apiResource; + + char debugName[GFSDK_Aftermath_MAX_STRING_LENGTH + 1]; + + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsBufferHeap); + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsStaticTextureHeap); + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bIsRenderTargetOrDepthStencilViewHeap); + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bPlacedResource); + + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(bWasDestroyed); + uint32_t createDestroyTickCount; +} GFSDK_Aftermath_GpuCrashDump_ResourceInfo; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderType +// --------------------------------- +// +// GPU crash dump - shader types +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(ShaderType){ + GFSDK_Aftermath_ShaderType_Unknown = 0, + GFSDK_Aftermath_ShaderType_Vertex, + GFSDK_Aftermath_ShaderType_Tessellation_Control, + GFSDK_Aftermath_ShaderType_Hull = GFSDK_Aftermath_ShaderType_Tessellation_Control, + GFSDK_Aftermath_ShaderType_Tessellation_Evaluation, + GFSDK_Aftermath_ShaderType_Domain = GFSDK_Aftermath_ShaderType_Tessellation_Evaluation, + GFSDK_Aftermath_ShaderType_Geometry, + GFSDK_Aftermath_ShaderType_Fragment, + GFSDK_Aftermath_ShaderType_Pixel = GFSDK_Aftermath_ShaderType_Fragment, + GFSDK_Aftermath_ShaderType_Compute, + GFSDK_Aftermath_ShaderType_RayTracing_RayGeneration, + GFSDK_Aftermath_ShaderType_RayTracing_Miss, + GFSDK_Aftermath_ShaderType_RayTracing_Intersection, + GFSDK_Aftermath_ShaderType_RayTracing_AnyHit, + GFSDK_Aftermath_ShaderType_RayTracing_ClosestHit, + GFSDK_Aftermath_ShaderType_RayTracing_Callable, + GFSDK_Aftermath_ShaderType_RayTracing_Internal, + GFSDK_Aftermath_ShaderType_Mesh, + GFSDK_Aftermath_ShaderType_Task, +}; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_ShaderInfo +// --------------------------------- +// +// GPU crash dump - shader information +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_GpuCrashDump_ShaderInfo +{ + // NOTE: This shader hash value is not necessarily the same as the GFSDK_Aftermath_ShaderBinaryHash + // value for this shader info, which must be calculated with GFSDK_Aftermath_GetShaderHashForShaderInfo. + uint64_t shaderHash; + uint64_t shaderInstance; + GFSDK_AFTERMATH_DECLARE_BOOLEAN_MEMBER(isInternal); + GFSDK_Aftermath_ShaderType shaderType; +} GFSDK_Aftermath_GpuCrashDump_ShaderInfo; + +//////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_Context_Type +// --------------------------------- +// +// GPU crash dump - event marker context type +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(Context_Type){ + GFSDK_Aftermath_Context_Type_Invalid = 0, + GFSDK_Aftermath_Context_Type_Immediate, + GFSDK_Aftermath_Context_Type_CommandList, + GFSDK_Aftermath_Context_Type_Bundle, + GFSDK_Aftermath_Context_Type_CommandQueue}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_EventMarkerDataOwnership +// --------------------------------- +// +// GPU crash dump - Event marker data ownership. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(EventMarkerDataOwnership){ + // Data is owned by the user application. + GFSDK_Aftermath_EventMarkerDataOwnership_User = 0, + + // Data is part of the GPU crash dump and is owned by the decoder. + GFSDK_Aftermath_EventMarkerDataOwnership_Decoder, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo +// --------------------------------- +// +// GPU crash dump - Aftermath event marker information. +// +// NOTE: If 'GFSDK_Aftermath_SetEventMarker' was called with 'markerDataSize=0', +// 'markerDataOwnership' will be set to 'GFSDK_Aftermath_EventMarkerDataOwnership_User' +// and the 'markerData' pointer will be only valid within the context of the process +// setting the marker and if the application properly manages the lifetime of the +// pointed to data. It is the responsibility of the caller to ensure that the pointer +// is valid before accessing the pointed to data. +// +///////////////////////////////////////////////////////////////////////// +typedef struct GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo +{ + uint64_t contextId; + GFSDK_Aftermath_Context_Status contextStatus; + GFSDK_Aftermath_Context_Type contextType; + GFSDK_AFTERMATH_DECLARE_POINTER_MEMBER(const void*, markerData); + GFSDK_Aftermath_EventMarkerDataOwnership markerDataOwnership; + uint32_t markerDataSize; +} GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDumpDecoderFlags +// --------------------------------- +// +// Flags that allow to specify the data to be included in the JSON generated by +// 'GFSDK_Aftermath_GpuCrashDump_GenerateJSON'. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpDecoderFlags){ + // Include basic information about the GPU crash dump. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_BASE_INFO = 0x1, + + // Include information about the device state. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_DEVICE_INFO = 0x2, + + // Include information about the OS. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_OS_INFO = 0x4, + + // Include information about the display driver. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_DISPLAY_DRIVER_INFO = 0x8, + + // Include information about the GPU. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_GPU_INFO = 0x10, + + // Include information about page faults (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_PAGE_FAULT_INFO = 0x20, + + // Include information about shaders (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_INFO = 0x40, + + // Include information about active warps (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_WARP_STATE_INFO = 0x80, + + // Try to map shader addresses to source or intermediate assembly lines using + // additional information provided through 'shaderDebugInfoLookupCb', + // 'shaderLookupCb', and 'shaderSourceDebugInfoLookupCb', if provided. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO = 0x100, + + // Include Aftermath event marker data (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_EVENT_MARKER_INFO = 0x200, + + // Include automatic event marker call stack data (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_CALL_STACK_INFO = 0x400, + + // Include user provided GPU crash dump description values (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_DESCRIPTION_INFO = 0x800, + + // Include information about faulted warps (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_FAULTED_WARP_INFO = 0x1000, + + // Include information about the fingerprint of the GPU crash dump (if available). + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_FINGERPRINT_INFO = 0x2000, + + // Include all available information. + GFSDK_Aftermath_GpuCrashDumpDecoderFlags_ALL_INFO = 0x3FFF, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDumpFormatterFlags +// --------------------------------- +// +// Flags controlling the formatting of the JSON generated by +// 'GFSDK_Aftermath_GpuCrashDump_GenerateJSON'. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_ENUM(GpuCrashDumpFormatterFlags){ + // No special formatting + GFSDK_Aftermath_GpuCrashDumpFormatterFlags_NONE = 0x0, + + // Remove all unnecessary whitespace from formatted string. + GFSDK_Aftermath_GpuCrashDumpFormatterFlags_CONDENSED_OUTPUT = 0x1, + + // Use UTF8 encoding. + GFSDK_Aftermath_GpuCrashDumpFormatterFlags_UTF8_OUTPUT = 0x2, +}; + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_Decoder +// --------------------------------- +// +// GPU crash dump decoder handle. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_AFTERMATH_DECLARE_HANDLE(GFSDK_Aftermath_GpuCrashDump_Decoder); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_SetData +// --------------------------------- +// +// Callback function for providing shader debug information and shader binary data to +// the GPU crash dump decoder. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_SetData)(const void* pData, uint32_t size); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderDebugInfoLookupCb +// --------------------------------- +// +// Callback used by the GPU crash dump decoder to query shader debug information. See +// the description of 'GFSDK_Aftermath_GpuCrashDump_GenerateJSON' for more details. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_ShaderDebugInfoLookupCb)(const GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier, PFN_GFSDK_Aftermath_SetData setShaderDebugInfo, void* pUserData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderLookupCb +// --------------------------------- +// +// Callback used by the GPU crash dump decoder to query shader binary information. +// See the description of 'GFSDK_Aftermath_GpuCrashDump_GenerateJSON' for more +// details. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_ShaderLookupCb)(const GFSDK_Aftermath_ShaderBinaryHash* pShaderHash, PFN_GFSDK_Aftermath_SetData setShaderBinary, void* pUserData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb +// --------------------------------- +// +// Callback used by the GPU crash dump decoder to query source shader debug +// information. See the description of 'GFSDK_Aftermath_GpuCrashDump_GenerateJSON' +// for more details. +// +///////////////////////////////////////////////////////////////////////// +typedef void(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb)(const GFSDK_Aftermath_ShaderDebugName* pShaderDebugName, PFN_GFSDK_Aftermath_SetData setShaderBinary, void* pUserData); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_CreateDecoder +// --------------------------------- +// +// apiVersion; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against +// library version. +// +// pGpuCrashDump; +// Pointer to GPU crash dump data captured in a 'GFSDK_Aftermath_GpuCrashDumpCb' +// callback. +// +// gpuCrashDumpSize; +// Size of GPU crash dump data in bytes. +// +// pDecoder; +// Pointer to a decoder object owned by the caller that is initialized. +// +//// DESCRIPTION; +// Create a decoder object that can be used to query information about the +// provided GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_CreateDecoder( + GFSDK_Aftermath_Version apiVersion, + const void* pGpuCrashDump, + const uint32_t gpuCrashDumpSize, + GFSDK_Aftermath_GpuCrashDump_Decoder* pDecoder); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_DestroyDecoder +// --------------------------------- +// +// decoder; +// A valid GPU crash dump decoder object. +// +//// DESCRIPTION; +// Free any data related to the passed in GPU crash dump decoder object. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_DestroyDecoder( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetBaseInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pBaseInfo; +// Pointer to data structure owned by the caller that is filled in with +// information from the GPU crash dump. +// +//// DESCRIPTION; +// Query basic information from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetBaseInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + GFSDK_Aftermath_GpuCrashDump_BaseInfo* pBaseInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// key; +// What value to query from the description section. +// +// pValueSize; +// Populated with the size of the value in bytes (including 0-termination +// of the string). +// +//// DESCRIPTION; +// Query the size of a description value from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const uint32_t key, + uint32_t* pValueSize); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetDescription +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// key; +// What value to query from the description section. +// +// valueBufferSize; +// Size in bytes of the caller allocated results buffer 'pValue'. +// +// pValue; +// Caller allocated results buffer. +// +//// DESCRIPTION; +// Query description value from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetDescription( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const uint32_t key, + const uint32_t valueBufferSize, + char* pValue); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pDeviceInfo; +// Pointer to data structure owned by the caller that is filled in with +// information from the GPU crash dump. +// +//// DESCRIPTION; +// Query device state information from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + GFSDK_Aftermath_GpuCrashDump_DeviceInfo* pDeviceInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetSystemInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pSystemInfo; +// Pointer to data structure owned by the caller that is filled in with +// information from the GPU crash dump. +// +//// DESCRIPTION; +// Query system information (OS, display driver) from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetSystemInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + GFSDK_Aftermath_GpuCrashDump_SystemInfo* pSystemInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetGpuInfoCount +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pGpuCount; +// Populated with the number of GPU entries from the GPU crash dump. +// +//// DESCRIPTION; +// Query number of GPU entries from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetGpuInfoCount( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + uint32_t* pGpuCount); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetGpuInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// gpuInfoBufferCount; +// Number of elements in caller allocated array passed in 'pGpuInfo'. +// +// pGpuInfo; +// Pointer to caller allocated array of 'GFSDK_Aftermath_GpuCrashDump_GpuInfo' +// that is filled in with information from the GPU crash dump. +// +//// DESCRIPTION; +// Query information about the GPUs from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetGpuInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const uint32_t gpuInfoBufferCount, + GFSDK_Aftermath_GpuCrashDump_GpuInfo* pGpuInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pPageFaultInfo; +// Pointer to data structure owned by the caller that is filled in with +// information from the GPU crash dump. +// +//// DESCRIPTION; +// Query page fault information from a GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + GFSDK_Aftermath_GpuCrashDump_PageFaultInfo* pPageFaultInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetPageFaultResourceInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// resourceInfoCount; +// Number of elements in caller allocated array passed in 'pResourceInfo'. +// +// pResourceInfo; +// Pointer to caller allocated array of 'GFSDK_Aftermath_GpuCrashDump_ResourceInfo' +// that is filled in with information from the GPU crash dump. +// +//// DESCRIPTION; +// Query resource information about the page fault from the GPU crash dump. +// The resource info count can be queried by calling 'GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo'. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetPageFaultResourceInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const uint32_t resourceInfoCount, + GFSDK_Aftermath_GpuCrashDump_ResourceInfo* pResourceInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pShaderCount; +// Populated with the number of active shaders from the GPU crash dump. +// +//// DESCRIPTION; +// Query the number of active shaders from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + uint32_t* pShaderCount); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// shaderInfoBufferCount; +// Number of elements in caller allocated array passed in 'pShaderInfo'. +// +// pShaderInfo; +// Pointer to caller allocated array of'GFSDK_Aftermath_GpuCrashDump_ShaderInfo' +// that is filled in with information from the GPU crash dump. +// +//// DESCRIPTION; +// Query information about active shaders from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const uint32_t shaderInfoBufferCount, + GFSDK_Aftermath_GpuCrashDump_ShaderInfo* pShaderInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfoCount +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pMarkerCount; +// Populated with the number of event markers from the GPU crash dump. +// +//// DESCRIPTION; +// Query the number of DX event markers or Vulkan checkpoint markers from +// the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfoCount( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + uint32_t* pMarkerCount); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// markerInfoBufferCount; +// Number of elements in caller allocated array passed in 'pMarkerInfo'. +// +// pMarkerInfo; +// Pointer to caller allocated array of +// 'GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo' that is filled in with +// information from the GPU crash dump. +// +//// DESCRIPTION; +// Query information about DX event markers or Vulkan checkpoint markers +// from the GPU crash dump. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const uint32_t markerInfoBufferCount, + GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo* pMarkerInfo); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GenerateJSON +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// decoderFlags; +// Flags that define what information to include in the decoding. Bitwise OR of +// any of the flags defined in 'GFSDK_Aftermath_GpuCrashDumpDecoderFlags'. +// +// formatFlags; +// Flags controlling the formatting. Bitwise OR of any of the flags defined in +// 'GFSDK_Aftermath_GpuCrashDumpFormatterFlags'. +// +// shaderDebugInfoLookupCb; +// Callback used by the decoder to query shader debug information for mapping +// shader addresses to source or intermediate assembly line. +// +// Optional, can be NULL. +// +// Used when 'GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO' is +// set in 'decoderFlags'. +// +// shaderLookupCb; +// Callback used by the decoder to query shader information for mapping shader +// addresses to shader intermediate assembly (DXIL/SPIR-V) or source. +// +// Optional, can be NULL. +// +// Used when 'GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO' is +// set in 'decoderFlags'. +// +// shaderSourceDebugInfoLookupCb; +// Callback used by the decoder to query high-level shader debug information for +// mapping shader addresses to shader source, if the shaders used by the +// application are stripped of debug information. This lookup is done by the +// shader's DebugName, a unique identifier of the source debug information. +// +// Optional, can be NULL. +// +// Used when 'GFSDK_Aftermath_GpuCrashDumpDecoderFlags_SHADER_MAPPING_INFO' is +// set in 'decoderFlags'. +// +// For DXIL shaders DebugName is generated by the dxc compiler and is defined here: +// https://github.com/microsoft/DirectXShaderCompiler/blob/master/docs/SourceLevelDebuggingHLSL.rst#using-debug-names. +// +// The following variants of generating source shader debug information for DXIL shaders +// are supported: +// +// 1) Compile and use a full shader blob +// +// Compile the shaders with the debug information. Use the full (i.e., +// not stripped) shader binary when running the application and make it +// accessible through shaderLookupCb. In this case there is no need to +// provide 'shaderSourceDebugInfoLookupCb'. +// +// Compilation example: +// +// dxc -Zi [..] -Fo shader.bin shader.hlsl +// +// 2) Compile and strip +// +// Compile the shaders with debug information and then strip off the debug +// information. Use the stripped shader binary data when running the +// application. Make the stripped shader binary data accessible through +// shaderLookupCb. In addition, make the non-stripped shader binary data +// accessible through 'shaderSourceDebugInfoLookupCb'. +// +// Compilation example: +// +// dxc -Zi [..] -Fo full_shader.bin shader.hlsl +// dxc -dumpbin -Qstrip_debug -Fo shader.bin full_shader.bin +// +// The shader's DebugName required for implementing the +// 'shaderSourceDebugInfoLookupCb' may be extracted from the stripped or the +// non-stripped shader binary data with 'GFSDK_Aftermath_GetShaderDebugName'. +// +// 3) Compile with separate debug information (and auto-generated debug data file name) +// +// Compile the shaders with debug information and instruct the compiler to store +// the debug meta data in a separate shader debug information file. The name of +// the file generated by the compiler will match the DebugName of the shader. +// Make the shader binary data accessible through 'shaderLookupCb'. In addition, make +// the data from the compiler generated shader debug data file accessible through +// 'shaderSourceDebugInfoLookupCb'. +// +// Compilation example: +// +// dxc -Zi [..] -Fo shader.bin -Fd debugInfo\ shader.hlsl +// +// The debug data file generated by the compiler does not contain any reference to +// the shader's DebugName. It is the responsibility of the user providing the +// 'shaderSourceDebugInfoLookupCb' callback to implement a solution to lookup the +// debug data based on the name of the generated debug data file. +// +// 4) Compile with separate debug information (and user-defined debug data file name) +// +// Compile the shaders with debug information and instruct the compiler to +// store the debug meta data in a separate shader debug information file. The +// name of the file is freely chosen by the user. Make the shader binary +// data accessible through 'shaderLookupCb'. In addition, make the data from +// the compiler generated shader debug data file accessible through +// 'shaderSourceDebugInfoLookupCb'. +// +// Compilation example: +// +// dxc -Zi [..] -Fo shader.bin -Fd debugInfo\shader.dbg shader.hlsl +// +// The debug data file generated by the compiler does not contain any +// reference to the shader's DebugName. It is the responsibility of the +// user providing the 'shaderSourceDebugInfoLookupCb' callback to +// implement a solution that performs the lookup of the debug data +// based on a mapping between the shader's DebugName and the debug data +// file's name that was chosen for the compilation. The shader's +// DebugName may be extracted from the shader binary data with +// 'GFSDK_Aftermath_GetShaderDebugName'. +// +// For SPIR-V shaders the Aftermath SDK provides support for the following variants of +// generating source shader debug information: +// +// 1) Compile and use a full shader blob +// +// Compile the shaders with debug information. Use the full (i.e., not +// stripped) shader binary when running the application and make it +// accessible through 'shaderLookupCb'. In this case there is no need +// to provide 'shaderSourceDebugInfoLookupCb'. +// +// Compilation example using Vulkan SDK toolchain: +// +// glslangValidator -V -g -o ./full/shader.spv shader.vert +// +// Compilation example using the DirectX Shader Compiler: +// +// dxc -spirv -Zi [..] -Fo shader.spv shader.hlsl +// +// 2) Compile and strip +// +// Compile the shaders with debug information and then strip off the debug +// information. Use the stripped shader binary data when running the +// application. Make the stripped shader binary data accessible through +// 'shaderLookupCb'. In addition, make the non-stripped shader binary data +// accessible through 'shaderSourceDebugInfoLookupCb'. +// +// Compilation example using Vulkan SDK toolchain: +// +// glslangValidator -V -g -o ./full/shader.spv shader.vert +// spirv-remap --map all --strip-all --input full/shader.spv --output ./stripped/ +// +// Compilation example using the DirectX Shader Compiler: +// +// dxc -spirv -Zi [..] -Fo ./full/shader.spv shader.hlsl +// spirv-remap --map all --strip-all --input full/shader.spv --output ./stripped/ +// +// Then pass the content of ./full/shader.spv and ./stripped/shader.spv to +// 'GFSDK_Aftermath_GetDebugNameSpirv' to generate the debug name to use with +// 'shaderSourceDebugInfoLookupCb'. +// +// pUserData; +// User data made available in callbacks. +// +// pJsonSize; +// Populated with the size of the generated JSON data in bytes. +// +//// DESCRIPTION; +// Decode the GPU crash dump to JSON format. The decoded JSON can be later +// queried by calling 'GFSDK_Aftermath_GpuCrashDump_GetJSON'. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GenerateJSON( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + uint32_t decoderFlags, + uint32_t formatFlags, + PFN_GFSDK_Aftermath_ShaderDebugInfoLookupCb shaderDebugInfoLookupCb, + PFN_GFSDK_Aftermath_ShaderLookupCb shaderLookupCb, + PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb shaderSourceDebugInfoLookupCb, + void* pUserData, + uint32_t* pJsonSize); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GpuCrashDump_GetJSON +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// jsonBufferSize; +// The size of the caller allocated buffer for the JSON data in bytes. +// +// pJson; +// Caller allocated buffer populated with the JSON data (0-terminated string). +// +//// DESCRIPTION; +// Copy the JSON generated by the last call to 'GFSDK_Aftermath_GpuCrashDump_GenerateJSON' +// into a caller provided buffer. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GpuCrashDump_GetJSON( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const uint32_t jsonBufferSize, + char* pJson); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetShaderDebugInfoIdentifier +// --------------------------------- +// +// apiVersion; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against +// library version. +// +// pShaderDebugInfo; +// Pointer to shader debug information data captured in a +// 'GFSDK_Aftermath_ShaderDebugInfoCb' callback. +// +// shaderDebugInfoSize; +// Size in bytes of the shader debug information data. +// +// pIdentifier; +// Pointer to a 'GFSDK_Aftermath_ShaderDebugInfoIdentifier' structure that will +// receive the result. +// +//// DESCRIPTION; +// Read the shader debug information identifier from shader debug information. +// The shader debug information identifier is required when implementing the +// 'GFSDK_Aftermath_ShaderDebugInfoLookupCb' callback. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderDebugInfoIdentifier( + GFSDK_Aftermath_Version apiVersion, + const void* pShaderDebugInfo, + const uint32_t shaderDebugInfoSize, + GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier); + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetShaderHash +// --------------------------------- +// +// apiVersion; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against +// library version. +// +// pShader; +// The binary shader blob for which to compute the identifier. +// +// pShaderHash; +// Pointer to a 'GFSDK_Aftermath_ShaderBinaryHash' structure that will receive +// the computed shader hash. +// +//// DESCRIPTION; +// Computes a shader hash uniquely identifying the provided DXBC shader binary. +// This is, for example, required for comparison in the shader binary lookup by +// 'GFSDK_Aftermath_ShaderLookupCb' or for matching a +// 'GFSDK_Aftermath_GpuCrashDump_ShaderInfo' with a shader binary using +// 'GFSDK_Aftermath_GetShaderHashForShaderInfo'. +// +///////////////////////////////////////////////////////////////////////// +#if defined(__d3d12_h__) +GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderHash( + GFSDK_Aftermath_Version apiVersion, + const D3D12_SHADER_BYTECODE* pShader, + GFSDK_Aftermath_ShaderBinaryHash* pShaderHash); +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetShaderHashSpirv +// --------------------------------- +// +// apiVersion; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against +// library version. +// +// pShader; +// The SPIR-V shader binary for which to compute the identifier. +// +// pShaderHash; +// Pointer to a 'GFSDK_Aftermath_ShaderBinaryHash' structure that will receive +// the computed shader hash. +// +//// DESCRIPTION; +// Computes a shader hash uniquely identifying the provided SPIR-V shader +// binary. This is, for example, required for comparison in the shader binary +// lookup by 'GFSDK_Aftermath_ShaderLookupCb' or for matching a +// 'GFSDK_Aftermath_GpuCrashDump_ShaderInfo' with a shader binary using +// 'GFSDK_Aftermath_GetShaderHashForShaderInfo'. +// +///////////////////////////////////////////////////////////////////////// +#if defined(VULKAN_H_) +GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderHashSpirv( + GFSDK_Aftermath_Version apiVersion, + const GFSDK_Aftermath_SpirvCode* pShader, + GFSDK_Aftermath_ShaderBinaryHash* pShaderHash); +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetShaderDebugName +// --------------------------------- +// +// apiVersion; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against +// library version. +// +// pShader; +// The binary shader data blob from which to extract the DebugName. +// +// pShaderDebugName; +// Pointer to a 'GFSDK_Aftermath_ShaderDebugName' structure that will receive +// the generated DebugName. +// +//// DESCRIPTION; +// Extracts the shader's DebugName (if available) from the provided DXBC shader +// binary. This is, for example, required for comparison in the shader debug +// data lookup by 'GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb'. For more +// information about shader debug names please read: +// https://github.com/microsoft/DirectXShaderCompiler/blob/master/docs/SourceLevelDebuggingHLSL.rst#using-debug-names. +// +///////////////////////////////////////////////////////////////////////// +#if defined(__d3d12_h__) +GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderDebugName( + GFSDK_Aftermath_Version apiVersion, + const D3D12_SHADER_BYTECODE* pShader, + GFSDK_Aftermath_ShaderDebugName* pShaderDebugName); +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetShaderDebugNameSpirv +// --------------------------------- +// +// apiVersion; +// Must be set to 'GFSDK_Aftermath_Version_API'. Used for checking against +// library version. +// +// pShader; +// The not-stripped SPIR-V binary shader data of the shader pair for which to +// generate the DebugName. +// +// pStrippedShader; +// The stripped SPIR-V binary shader data of the shader pair for which to +// generate the DebugName. +// +// pShaderDebugName; +// Pointer to a 'GFSDK_Aftermath_ShaderDebugName' structure that will receive +// the generated DebugName. +// +//// DESCRIPTION; +// Generates a shader DebugName from the provided pair of SPIR-V shader binary +// data. This is, for example, required for comparison in the shader debug data +// lookup by 'GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb'. For more +// information about how to generate the pair of shader binaries, see the +// description of 'GFSDK_Aftermath_GpuCrashDump_GenerateJSON'. +// +///////////////////////////////////////////////////////////////////////// +#if defined(VULKAN_H_) +GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderDebugNameSpirv( + GFSDK_Aftermath_Version apiVersion, + const GFSDK_Aftermath_SpirvCode* pShader, + const GFSDK_Aftermath_SpirvCode* pStrippedShader, + GFSDK_Aftermath_ShaderDebugName* pShaderDebugName); +#endif + +///////////////////////////////////////////////////////////////////////// +// GFSDK_Aftermath_GetShaderHashForShaderInfo +// --------------------------------- +// +// decoder; +// A valid decoder object. +// +// pShaderInfo; +// Pointer to 'GFSDK_Aftermath_GpuCrashDump_ShaderInfo' for which to generate +// the 'GFSDK_Aftermath_ShaderBinaryHash'. +// +// pShaderHash; +// Pointer to a 'GFSDK_Aftermath_ShaderBinaryHash' structure that will receive +// the computed shader hash. +// +//// DESCRIPTION; +// Computes a shader hash for the provided shader info. This is, for example, +// useful for matching against the 'GFSDK_Aftermath_ShaderBinaryHash' values +// calculated for shader binaries using 'GFSDK_Aftermath_GetShaderHash' or +// 'GFSDK_Aftermath_GetShaderHashSpirv'. +// +///////////////////////////////////////////////////////////////////////// +GFSDK_Aftermath_API GFSDK_Aftermath_GetShaderHashForShaderInfo( + const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, + const GFSDK_Aftermath_GpuCrashDump_ShaderInfo* pShaderInfo, + GFSDK_Aftermath_ShaderBinaryHash* pShaderHash); + +///////////////////////////////////////////////////////////////////////// +// +// Function pointer definitions - if dynamic loading is preferred. +// +///////////////////////////////////////////////////////////////////////// + +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_CreateDecoder)(GFSDK_Aftermath_Version apiVersion, const void* pGpuCrashDump, const uint32_t gpuCrashDumpSize, GFSDK_Aftermath_GpuCrashDump_Decoder* pDecoder); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_DestroyDecoder)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetBaseInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_BaseInfo* pBaseInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetDescriptionSize)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t key, uint32_t* pValueSize); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetDescription)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t key, const uint32_t valueBufferSize, char* pValue); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetDeviceInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_DeviceInfo* pDeviceInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetSystemInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_SystemInfo* pSystemInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetGpuInfoCount)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, uint32_t* pGpuCount); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetGpuInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t gpuInfoBufferCount, GFSDK_Aftermath_GpuCrashDump_GpuInfo* pGpuInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetPageFaultInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, GFSDK_Aftermath_GpuCrashDump_PageFaultInfo* pPageFaultInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetPageFaultResourceInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t resourceInfoCount, GFSDK_Aftermath_GpuCrashDump_ResourceInfo* pResourceInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfoCount)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, uint32_t* pShaderCount); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetActiveShadersInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t shaderInfoBufferCount, GFSDK_Aftermath_GpuCrashDump_ShaderInfo* pShaderInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfoCount)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t markerInfoBufferCount); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetEventMarkersInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t markerInfoBufferCount, GFSDK_Aftermath_GpuCrashDump_EventMarkerInfo* pMarkerInfo); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GenerateJSON)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, uint32_t decoderFlags, uint32_t formatFlags, PFN_GFSDK_Aftermath_ShaderDebugInfoLookupCb shaderDebugInfoLookupCb, PFN_GFSDK_Aftermath_ShaderLookupCb shaderLookupCb, PFN_GFSDK_Aftermath_ShaderSourceDebugInfoLookupCb shaderSourceDebugInfoLookupCb, void* pUserData, uint32_t* pJsonSize); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GpuCrashDump_GetJSON)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const uint32_t jsonBufferSize, char* pJson); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetShaderDebugInfoIdentifier)(GFSDK_Aftermath_Version apiVersion, const void* pShaderDebugInfo, const uint32_t shaderDebugInfoSize, GFSDK_Aftermath_ShaderDebugInfoIdentifier* pIdentifier); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetShaderHashForShaderInfo)(const GFSDK_Aftermath_GpuCrashDump_Decoder decoder, const GFSDK_Aftermath_GpuCrashDump_ShaderInfo* pShaderInfo, GFSDK_Aftermath_ShaderBinaryHash* pShaderHash); +#if defined(__d3d12_h__) +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetShaderHash)(GFSDK_Aftermath_Version apiVersion, const D3D12_SHADER_BYTECODE* pShader, GFSDK_Aftermath_ShaderBinaryHash* pShaderHash); +GFSDK_Aftermath_PFN (*GPFN_GFSDK_Aftermath_GetShaderDebugName)(GFSDK_Aftermath_Version apiVersion, const D3D12_SHADER_BYTECODE* pShader, GFSDK_Aftermath_ShaderDebugName* pShaderDebugName); +#endif +#if defined(VULKAN_H_) +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetShaderHashSpirv)(GFSDK_Aftermath_Version apiVersion, const GFSDK_Aftermath_SpirvCode* pShader, GFSDK_Aftermath_ShaderBinaryHash* pShaderHash); +GFSDK_Aftermath_PFN(GFSDK_AFTERMATH_CALL* PFN_GFSDK_Aftermath_GetShaderDebugNameSpirv)(GFSDK_Aftermath_Version apiVersion, const GFSDK_Aftermath_SpirvCode* pShader, const GFSDK_Aftermath_SpirvCode* pStrippedShader, GFSDK_Aftermath_ShaderDebugName* pShaderDebugName); +#endif + +#ifdef __cplusplus +} // extern "C" +#endif + +#pragma pack(pop) + +#endif // GFSDK_Aftermath_CrashDumpDecoding_H diff --git a/Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.dll b/Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.dll new file mode 100644 index 0000000..15ed813 --- /dev/null +++ b/Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.dll @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:072d085f523bc244cf4df401dee5c5d2e0c19b7e0cb5f62e55b3da5f674a8cfa +size 5431880 diff --git a/Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.lib b/Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.lib new file mode 100644 index 0000000..bbfcf87 --- /dev/null +++ b/Vendor/nvidia-aftermath/lib/x64/GFSDK_Aftermath_Lib.x64.lib @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4983ad0569052c8ac32c0d65920c9f8bda296fb8a977fdcd16bc7a087836960e +size 15850 diff --git a/Vendor/nvidia-aftermath/nsight-aftermath-usage-guidelines.txt b/Vendor/nvidia-aftermath/nsight-aftermath-usage-guidelines.txt new file mode 100644 index 0000000..77dc5f3 --- /dev/null +++ b/Vendor/nvidia-aftermath/nsight-aftermath-usage-guidelines.txt @@ -0,0 +1,22 @@ +Nsight Aftermath is primarily a development tool and is intended to be used +with minimal side effects to the user application. Despite this, there may be +overhead when it is enabled resulting in performance degradation. The +application should only fully enable Nsight Aftermath when in an application +controlled 'diagnostics mode', e.g. enabled after the user has experienced a +GPU crash and exhaustive data collection is required. + +Your users should also be able to easily disable Nsight Aftermath in situations +where performance is critical, such as when benchmarking or during competitive +play. + +To override the behavior of applications that do not follow the above guidelines +a user may force off all Aftermath functionality in the application: + +on Windows, set a Windows registry key: +HKEY_CURRENT_USER\Software\NVIDIA Corporation\Nsight Aftermath\ForceOff=1 + +on Linux, set an environment variable: +export NV_AFTERMATH_FORCE_OFF=1 + +For questions regarding these guidelines or Nsight Aftermath in general, please +email NsightAftermath@nvidia.com