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