2013-04-18 03:29:41 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include <map>
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoBackends/D3D/D3DBase.h"
|
|
|
|
#include "VideoBackends/D3D/D3DBlob.h"
|
2011-01-25 16:43:08 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VertexShaderGen.h"
|
2011-01-25 16:43:08 +00:00
|
|
|
|
2011-06-11 19:37:21 +00:00
|
|
|
namespace DX11 {
|
2011-01-29 20:16:51 +00:00
|
|
|
|
2010-06-13 19:50:06 +00:00
|
|
|
class VertexShaderCache
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static void Init();
|
|
|
|
static void Clear();
|
|
|
|
static void Shutdown();
|
2011-06-11 19:37:21 +00:00
|
|
|
static bool SetShader(u32 components); // TODO: Should be renamed to LoadShader
|
2011-01-24 11:57:17 +00:00
|
|
|
|
2011-06-11 19:37:21 +00:00
|
|
|
static ID3D11VertexShader* GetActiveShader() { return last_entry->shader; }
|
|
|
|
static D3DBlob* GetActiveShaderBytecode() { return last_entry->bytecode; }
|
|
|
|
static ID3D11Buffer* &GetConstantBuffer();
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
static ID3D11VertexShader* GetSimpleVertexShader();
|
|
|
|
static ID3D11VertexShader* GetClearVertexShader();
|
|
|
|
static ID3D11InputLayout* GetSimpleInputLayout();
|
|
|
|
static ID3D11InputLayout* GetClearInputLayout();
|
|
|
|
|
2013-03-26 22:35:14 +00:00
|
|
|
static bool VertexShaderCache::InsertByteCode(const VertexShaderUid &uid, D3DBlob* bcodeblob);
|
2010-06-13 19:50:06 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
struct VSCacheEntry
|
2013-10-29 05:23:17 +00:00
|
|
|
{
|
2011-06-11 19:37:21 +00:00
|
|
|
ID3D11VertexShader* shader;
|
|
|
|
D3DBlob* bytecode; // needed to initialize the input layout
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2011-09-08 22:32:04 +00:00
|
|
|
std::string code;
|
|
|
|
|
2011-09-29 20:54:52 +00:00
|
|
|
VSCacheEntry() : shader(NULL), bytecode(NULL) {}
|
2011-06-11 19:37:21 +00:00
|
|
|
void SetByteCode(D3DBlob* blob)
|
2010-06-13 19:50:06 +00:00
|
|
|
{
|
2011-06-11 19:37:21 +00:00
|
|
|
SAFE_RELEASE(bytecode);
|
2010-06-13 19:50:06 +00:00
|
|
|
bytecode = blob;
|
2011-06-11 19:37:21 +00:00
|
|
|
blob->AddRef();
|
|
|
|
}
|
|
|
|
void Destroy()
|
|
|
|
{
|
|
|
|
SAFE_RELEASE(shader);
|
|
|
|
SAFE_RELEASE(bytecode);
|
2010-06-13 19:50:06 +00:00
|
|
|
}
|
|
|
|
};
|
2013-03-26 22:35:14 +00:00
|
|
|
typedef std::map<VertexShaderUid, VSCacheEntry> VSCache;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-06-13 19:50:06 +00:00
|
|
|
static VSCache vshaders;
|
|
|
|
static const VSCacheEntry* last_entry;
|
2013-03-26 22:35:14 +00:00
|
|
|
static VertexShaderUid last_uid;
|
2013-04-29 19:00:39 +00:00
|
|
|
|
|
|
|
static UidChecker<VertexShaderUid,VertexShaderCode> vertex_uid_checker;
|
2010-06-13 19:50:06 +00:00
|
|
|
};
|
|
|
|
|
2011-01-29 20:16:51 +00:00
|
|
|
} // namespace DX11
|