SpiecsEngine
 
Loading...
Searching...
No Matches
NsightAftermathShaderDatabase.h
Go to the documentation of this file.
1/**
2* @file NsightAftermathShaderDataBase.h
3* @brief The ShaderDataBase Class Definitions.
4* @author NVIDIA
5* @see https://github.com/NVIDIA/nsight-aftermath-samples
6*/
7
8#pragma once
9
10#include <vector>
11#include <map>
12#include <mutex>
13
15
16namespace Spices {
17
18 /**
19 * @brief Implements a very simple shader database to help demonstrate
20 * how to use the Nsight Aftermath GPU crash dump decoder API.
21 *
22 * In a real world scenario this would be part of an offline
23 * analysis tool. This is for demonstration purposes only!
24 */
26 {
27 public:
28
29 /**
30 * @brief Constructor Function.
31 */
33
34 /**
35 * @brief Destructor Function.
36 */
37 virtual ~ShaderDataBase() = default;
38
39 /**
40 * @brief Find a shader bytecode binary by shader hash.
41 * @param[in] shaderHash GFSDK_Aftermath_ShaderBinaryHash.
42 * @param[in] shader .
43 */
45 const GFSDK_Aftermath_ShaderBinaryHash& shaderHash ,
46 std::vector<uint8_t>& shader
47 ) const;
48
49 /**
50 * @brief Find a source shader debug info by shader debug name generated by the DXC compiler.
51 * @param[in] shaderDebugName GFSDK_Aftermath_ShaderDebugName.
52 * @param[in] shader .
53 */
55 const GFSDK_Aftermath_ShaderDebugName& shaderDebugName ,
56 std::vector<uint8_t>& shader
57 ) const;
58
59 /**
60 * @brief Add a shader binary to m_ShaderBinaries.
61 * @param[in] shaderFilePath .
62 */
63 void AddShaderBinary(const char* shaderFilePath);
64
65 /**
66 * @brief Add a shader source to m_ShaderBinaries.
67 * @param[in] spirv Spirv Code .
68 */
69 void AddShaderSource(std::vector<uint8_t> spirv);
70
71 /**
72 * @brief Add a shader binary with debug info to m_ShaderBinariesWithDebugInfo.
73 * @param[in] strippedShaderFilePath .
74 * @param[in] shaderFilePath .
75 */
76 void AddShaderBinaryWithDebugInfo(const char* strippedShaderFilePath, const char* shaderFilePath);
77
78 /**
79 * @brief Add a shader Source with debug info to m_ShaderBinariesWithDebugInfo.
80 * @param[in] strippedSpirv .
81 * @param[in] spirv .
82 */
83 void AddShaderSourceWithDebugInfo(std::vector<uint8_t> strippedSpirv, std::vector<uint8_t> spirv);
84
85 private:
86
87 /**
88 * @brief Read a file.
89 * @param[in] filename .
90 * @param[in] data File data.
91 * @return Returns true if read successfully.
92 */
93 static bool ReadFile(const char* filename, std::vector<uint8_t>& data);
94
95 /**
96 * @brief List of shader binaries by ShaderBinaryHash.
97 */
99
100 /**
101 * @brief List of available shader binaries with source debug information by ShaderDebugName.
102 */
104 };
105
106}
#define AFTERMATH_CHECK_ERROR(FC)
Helper macro for checking Nsight Aftermath results and throwing exception in case of a failure.
#define SPICES_PROFILE_ZONE
virtual ~ShaderDataBase()=default
Destructor Function.
void AddShaderSource(std::vector< uint8_t > spirv)
Add a shader source to m_ShaderBinaries.
static bool ReadFile(const char *filename, std::vector< uint8_t > &data)
Read a file.
bool FindShaderBinaryWithDebugData(const GFSDK_Aftermath_ShaderDebugName &shaderDebugName, std::vector< uint8_t > &shader) const
Find a source shader debug info by shader debug name generated by the DXC compiler.
void AddShaderBinary(const char *shaderFilePath)
Add a shader binary to m_ShaderBinaries.
void AddShaderBinaryWithDebugInfo(const char *strippedShaderFilePath, const char *shaderFilePath)
Add a shader binary with debug info to m_ShaderBinariesWithDebugInfo.
bool FindShaderBinary(const GFSDK_Aftermath_ShaderBinaryHash &shaderHash, std::vector< uint8_t > &shader) const
Find a shader bytecode binary by shader hash.
void AddShaderSourceWithDebugInfo(std::vector< uint8_t > strippedSpirv, std::vector< uint8_t > spirv)
Add a shader Source with debug info to m_ShaderBinariesWithDebugInfo.
Implements a very simple shader database to help demonstrate how to use the Nsight Aftermath GPU cras...