mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-26 07:39:45 -06:00
D3D: Uber shader support
This commit is contained in:
@ -9,10 +9,14 @@
|
||||
#include "VideoBackends/D3D/D3DBase.h"
|
||||
#include "VideoBackends/D3D/D3DBlob.h"
|
||||
|
||||
#include "VideoCommon/AsyncShaderCompiler.h"
|
||||
#include "VideoCommon/UberShaderVertex.h"
|
||||
#include "VideoCommon/VertexShaderGen.h"
|
||||
|
||||
namespace DX11
|
||||
{
|
||||
class D3DVertexFormat;
|
||||
|
||||
class VertexShaderCache
|
||||
{
|
||||
public:
|
||||
@ -20,10 +24,11 @@ public:
|
||||
static void Reload();
|
||||
static void Clear();
|
||||
static void Shutdown();
|
||||
static bool SetShader(); // TODO: Should be renamed to LoadShader
|
||||
static bool SetShader(D3DVertexFormat* vertex_format);
|
||||
static bool SetUberShader(D3DVertexFormat* vertex_format);
|
||||
static void RetreiveAsyncShaders();
|
||||
static void PrecompileUberShaders();
|
||||
|
||||
static ID3D11VertexShader* GetActiveShader() { return last_entry->shader; }
|
||||
static D3DBlob* GetActiveShaderBytecode() { return last_entry->bytecode; }
|
||||
static ID3D11Buffer*& GetConstantBuffer();
|
||||
|
||||
static ID3D11VertexShader* GetSimpleVertexShader();
|
||||
@ -31,15 +36,20 @@ public:
|
||||
static ID3D11InputLayout* GetSimpleInputLayout();
|
||||
static ID3D11InputLayout* GetClearInputLayout();
|
||||
|
||||
static bool InsertByteCode(const VertexShaderUid& uid, D3DBlob* bcodeblob);
|
||||
static bool InsertByteCode(const VertexShaderUid& uid, D3DBlob* blob);
|
||||
static bool InsertByteCode(const UberShader::VertexShaderUid& uid, D3DBlob* blob);
|
||||
static bool InsertShader(const VertexShaderUid& uid, ID3D11VertexShader* shader, D3DBlob* blob);
|
||||
static bool InsertShader(const UberShader::VertexShaderUid& uid, ID3D11VertexShader* shader,
|
||||
D3DBlob* blob);
|
||||
|
||||
private:
|
||||
struct VSCacheEntry
|
||||
{
|
||||
ID3D11VertexShader* shader;
|
||||
D3DBlob* bytecode; // needed to initialize the input layout
|
||||
bool pending;
|
||||
|
||||
VSCacheEntry() : shader(nullptr), bytecode(nullptr) {}
|
||||
VSCacheEntry() : shader(nullptr), bytecode(nullptr), pending(false) {}
|
||||
void SetByteCode(D3DBlob* blob)
|
||||
{
|
||||
SAFE_RELEASE(bytecode);
|
||||
@ -52,13 +62,49 @@ private:
|
||||
SAFE_RELEASE(bytecode);
|
||||
}
|
||||
};
|
||||
|
||||
class VertexShaderCompilerWorkItem : public VideoCommon::AsyncShaderCompiler::WorkItem
|
||||
{
|
||||
public:
|
||||
VertexShaderCompilerWorkItem(const VertexShaderUid& uid);
|
||||
~VertexShaderCompilerWorkItem() override;
|
||||
|
||||
bool Compile() override;
|
||||
void Retrieve() override;
|
||||
|
||||
private:
|
||||
VertexShaderUid m_uid;
|
||||
D3DBlob* m_bytecode = nullptr;
|
||||
ID3D11VertexShader* m_vs = nullptr;
|
||||
};
|
||||
|
||||
class UberVertexShaderCompilerWorkItem : public VideoCommon::AsyncShaderCompiler::WorkItem
|
||||
{
|
||||
public:
|
||||
UberVertexShaderCompilerWorkItem(const UberShader::VertexShaderUid& uid);
|
||||
~UberVertexShaderCompilerWorkItem() override;
|
||||
|
||||
bool Compile() override;
|
||||
void Retrieve() override;
|
||||
|
||||
private:
|
||||
UberShader::VertexShaderUid m_uid;
|
||||
D3DBlob* m_bytecode = nullptr;
|
||||
ID3D11VertexShader* m_vs = nullptr;
|
||||
};
|
||||
|
||||
typedef std::map<VertexShaderUid, VSCacheEntry> VSCache;
|
||||
typedef std::map<UberShader::VertexShaderUid, VSCacheEntry> UberVSCache;
|
||||
|
||||
static void LoadShaderCache();
|
||||
static void SetInputLayout();
|
||||
|
||||
static VSCache vshaders;
|
||||
static UberVSCache ubervshaders;
|
||||
static const VSCacheEntry* last_entry;
|
||||
static const VSCacheEntry* last_uber_entry;
|
||||
static VertexShaderUid last_uid;
|
||||
static UberShader::VertexShaderUid last_uber_uid;
|
||||
};
|
||||
|
||||
} // namespace DX11
|
||||
|
Reference in New Issue
Block a user