mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-13 13:30:44 +00:00
Fetch D3DCompiler on demand rather than at dll init
* This incurs a bit of a load-time hit that might not be needed until later.
This commit is contained in:
@@ -34,25 +34,34 @@ typedef HRESULT(WINAPI *pD3DCreateBlob)(SIZE_T Size, ID3DBlob **ppBlob);
|
||||
|
||||
struct D3DBlobShaderCallbacks
|
||||
{
|
||||
D3DBlobShaderCallbacks()
|
||||
pD3DCreateBlob GetCreateBlob() const
|
||||
{
|
||||
HMODULE d3dcompiler = GetD3DCompiler();
|
||||
static pD3DCreateBlob blobCreate = NULL;
|
||||
|
||||
if(d3dcompiler == NULL)
|
||||
RDCFATAL("Can't get handle to d3dcompiler_??.dll");
|
||||
if(!blobCreate)
|
||||
{
|
||||
HMODULE d3dcompiler = GetD3DCompiler();
|
||||
|
||||
m_BlobCreate = (pD3DCreateBlob)GetProcAddress(d3dcompiler, "D3DCreateBlob");
|
||||
if(d3dcompiler == NULL)
|
||||
RDCFATAL("Can't get handle to d3dcompiler_??.dll");
|
||||
|
||||
if(m_BlobCreate == NULL)
|
||||
RDCFATAL("d3dcompiler.dll doesn't contain D3DCreateBlob");
|
||||
blobCreate = (pD3DCreateBlob)GetProcAddress(d3dcompiler, "D3DCreateBlob");
|
||||
|
||||
if(blobCreate == NULL)
|
||||
RDCFATAL("d3dcompiler.dll doesn't contain D3DCreateBlob");
|
||||
}
|
||||
|
||||
return blobCreate;
|
||||
}
|
||||
|
||||
bool Create(uint32_t size, byte *data, ID3DBlob **ret) const
|
||||
{
|
||||
RDCASSERT(ret);
|
||||
|
||||
pD3DCreateBlob blobCreate = GetCreateBlob();
|
||||
|
||||
*ret = NULL;
|
||||
HRESULT hr = m_BlobCreate((SIZE_T)size, ret);
|
||||
HRESULT hr = blobCreate((SIZE_T)size, ret);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
@@ -68,7 +77,7 @@ struct D3DBlobShaderCallbacks
|
||||
void Destroy(ID3DBlob *blob) const { blob->Release(); }
|
||||
uint32_t GetSize(ID3DBlob *blob) const { return (uint32_t)blob->GetBufferSize(); }
|
||||
const byte *GetData(ID3DBlob *blob) const { return (const byte *)blob->GetBufferPointer(); }
|
||||
pD3DCreateBlob m_BlobCreate;
|
||||
pD3DCreateBlob m_BlobCreate = NULL;
|
||||
} D3D11ShaderCacheCallbacks;
|
||||
|
||||
struct EmbeddedD3D11Includer : public ID3DInclude
|
||||
|
||||
@@ -32,25 +32,34 @@ typedef HRESULT(WINAPI *pD3DCreateBlob)(SIZE_T Size, ID3DBlob **ppBlob);
|
||||
|
||||
struct D3D12BlobShaderCallbacks
|
||||
{
|
||||
D3D12BlobShaderCallbacks()
|
||||
pD3DCreateBlob GetCreateBlob() const
|
||||
{
|
||||
HMODULE d3dcompiler = GetD3DCompiler();
|
||||
static pD3DCreateBlob blobCreate = NULL;
|
||||
|
||||
if(d3dcompiler == NULL)
|
||||
RDCFATAL("Can't get handle to d3dcompiler_??.dll");
|
||||
if(!blobCreate)
|
||||
{
|
||||
HMODULE d3dcompiler = GetD3DCompiler();
|
||||
|
||||
m_BlobCreate = (pD3DCreateBlob)GetProcAddress(d3dcompiler, "D3DCreateBlob");
|
||||
if(d3dcompiler == NULL)
|
||||
RDCFATAL("Can't get handle to d3dcompiler_??.dll");
|
||||
|
||||
if(m_BlobCreate == NULL)
|
||||
RDCFATAL("d3dcompiler.dll doesn't contain D3DCreateBlob");
|
||||
blobCreate = (pD3DCreateBlob)GetProcAddress(d3dcompiler, "D3DCreateBlob");
|
||||
|
||||
if(blobCreate == NULL)
|
||||
RDCFATAL("d3dcompiler.dll doesn't contain D3DCreateBlob");
|
||||
}
|
||||
|
||||
return blobCreate;
|
||||
}
|
||||
|
||||
bool Create(uint32_t size, byte *data, ID3DBlob **ret) const
|
||||
{
|
||||
RDCASSERT(ret);
|
||||
|
||||
pD3DCreateBlob blobCreate = GetCreateBlob();
|
||||
|
||||
*ret = NULL;
|
||||
HRESULT hr = m_BlobCreate((SIZE_T)size, ret);
|
||||
HRESULT hr = blobCreate((SIZE_T)size, ret);
|
||||
|
||||
if(FAILED(hr))
|
||||
{
|
||||
@@ -67,7 +76,6 @@ struct D3D12BlobShaderCallbacks
|
||||
void Destroy(ID3DBlob *blob) const { blob->Release(); }
|
||||
uint32_t GetSize(ID3DBlob *blob) const { return (uint32_t)blob->GetBufferSize(); }
|
||||
const byte *GetData(ID3DBlob *blob) const { return (const byte *)blob->GetBufferPointer(); }
|
||||
pD3DCreateBlob m_BlobCreate;
|
||||
} D3D12ShaderCacheCallbacks;
|
||||
|
||||
struct EmbeddedD3D12Includer : public ID3DInclude
|
||||
|
||||
Reference in New Issue
Block a user