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