Extend D3D12 GetShaderBlob() to allow passing arbitrary compile options

Pass via ShaderCompileFlag with name "@compile_option" and value is the compile option to add

Added helper to return D3D12 Shader Cache m_CompileFlags
This commit is contained in:
Jake Turner
2024-12-11 14:34:40 +00:00
parent cfa392e279
commit daa0392170
2 changed files with 7 additions and 0 deletions
@@ -495,6 +495,11 @@ rdcstr D3D12ShaderCache::GetShaderBlob(const char *source, const char *entry,
uint32_t flags = DXBC::DecodeFlags(compileFlags) & ~D3DCOMPILE_NO_PRESHADER;
rdcarray<rdcwstr> argsData;
DXBC::EncodeDXCFlags(flags, argsData);
for(const ShaderCompileFlag &flag : compileFlags.flags)
{
if(flag.name == "@compile_option")
argsData.push_back(StringFormat::UTF82Wide(flag.value));
}
argsData.push_back(L"-select-validator internal");
rdcarray<LPCWSTR> arguments;
for(const rdcwstr &arg : argsData)
@@ -57,6 +57,8 @@ public:
void LoadDXC();
void SetCaching(bool enabled) { m_CacheShaders = enabled; }
uint32_t GetCompileFlags() const { return m_CompileFlags; }
private:
static const uint32_t m_ShaderCacheMagic = 0xf000baba;
static const uint32_t m_ShaderCacheVersion = 3;