2013-04-18 03:29:41 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// Refer to the license.txt file included.
|
2009-02-23 06:17:57 +00:00
|
|
|
|
2011-01-29 20:16:51 +00:00
|
|
|
#pragma once
|
2009-02-23 06:17:57 +00:00
|
|
|
|
|
|
|
#include "D3DBase.h"
|
|
|
|
|
|
|
|
#include <map>
|
2009-09-01 19:48:45 +00:00
|
|
|
#include <string>
|
2009-02-23 06:17:57 +00:00
|
|
|
|
2009-02-28 22:10:38 +00:00
|
|
|
#include "D3DBase.h"
|
|
|
|
#include "VertexShaderGen.h"
|
2009-02-23 06:17:57 +00:00
|
|
|
|
2011-01-29 20:16:51 +00:00
|
|
|
namespace DX9
|
|
|
|
{
|
|
|
|
|
2009-02-28 22:10:38 +00:00
|
|
|
class VertexShaderCache
|
2009-02-23 06:17:57 +00:00
|
|
|
{
|
2009-09-01 19:48:45 +00:00
|
|
|
private:
|
2009-02-23 06:17:57 +00:00
|
|
|
struct VSCacheEntry
|
|
|
|
{
|
2009-03-01 10:38:04 +00:00
|
|
|
LPDIRECT3DVERTEXSHADER9 shader;
|
2011-09-29 20:54:52 +00:00
|
|
|
|
2009-09-01 19:48:45 +00:00
|
|
|
std::string code;
|
2011-09-29 20:54:52 +00:00
|
|
|
|
|
|
|
VSCacheEntry() : shader(NULL) {}
|
2009-02-23 06:17:57 +00:00
|
|
|
void Destroy()
|
|
|
|
{
|
2009-03-01 10:38:04 +00:00
|
|
|
if (shader)
|
|
|
|
shader->Release();
|
2009-09-13 17:46:33 +00:00
|
|
|
shader = NULL;
|
2009-02-23 06:17:57 +00:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2013-03-26 22:35:14 +00:00
|
|
|
typedef std::map<VertexShaderUid, VSCacheEntry> VSCache;
|
2009-02-23 06:17:57 +00:00
|
|
|
|
|
|
|
static VSCache vshaders;
|
2009-09-01 19:48:45 +00:00
|
|
|
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-19 16:22:24 +00:00
|
|
|
static void Clear();
|
2009-02-23 06:17:57 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
static void Init();
|
|
|
|
static void Shutdown();
|
2009-09-02 21:19:35 +00:00
|
|
|
static bool SetShader(u32 components);
|
2010-06-05 00:01:18 +00:00
|
|
|
static LPDIRECT3DVERTEXSHADER9 GetSimpleVertexShader(int level);
|
|
|
|
static LPDIRECT3DVERTEXSHADER9 GetClearVertexShader();
|
2013-03-26 22:35:14 +00:00
|
|
|
static bool InsertByteCode(const VertexShaderUid &uid, const u8 *bytecode, int bytecodelen, bool activate);
|
2010-11-29 16:16:48 +00:00
|
|
|
|
2009-09-01 19:48:45 +00:00
|
|
|
static std::string GetCurrentShaderCode();
|
2009-02-23 06:17:57 +00:00
|
|
|
};
|
|
|
|
|
2011-01-29 20:16:51 +00:00
|
|
|
} // namespace DX9
|