MCPcopy Create free account
hub / github.com/NVIDIA-RTX/Donut / GetBytecode

Method GetBytecode

src/engine/ShaderFactory.cpp:62–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

60}
61
62std::shared_ptr<IBlob> ShaderFactory::GetBytecode(const char* fileName, const char* entryName)
63{
64 if (!m_fs)
65 return nullptr;
66
67 if (!entryName)
68 entryName = "main";
69
70 string adjustedName = fileName;
71 {
72 size_t pos = adjustedName.find(".hlsl");
73 if (pos != string::npos)
74 adjustedName.erase(pos, 5);
75
76 if (entryName && strcmp(entryName, "main"))
77 adjustedName += "_" + string(entryName);
78 }
79
80 std::filesystem::path shaderFilePath = m_basePath / (adjustedName + ".bin");
81
82 std::shared_ptr<IBlob>& data = m_BytecodeCache[shaderFilePath.generic_string()];
83
84 if (data)
85 return data;
86
87 data = m_fs->readFile(shaderFilePath);
88
89 if (!data)
90 {
91 log::error("Couldn't read the binary file for shader %s from %s", fileName, shaderFilePath.generic_string().c_str());
92 return nullptr;
93 }
94
95 return data;
96}
97
98nvrhi::ShaderHandle ShaderFactory::CreateShader(const char* fileName, const char* entryName, const vector<ShaderMacro>* pDefines, const nvrhi::ShaderDesc& desc)
99{

Callers

nothing calls this directly

Calls 2

errorFunction · 0.85
readFileMethod · 0.45

Tested by

no test coverage detected