DX11 code maintenance, part 5:

Move shader and input layout management from EmuGfxState to Vertex/PixelShaderCache and D3DVertexFormat.


git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6906 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
NeoBrainX 2011-01-24 11:57:17 +00:00
parent e0c6092721
commit f33cd7cbbd
11 changed files with 40 additions and 89 deletions

View file

@ -27,16 +27,22 @@
#include "CPMemory.h"
#include "NativeVertexFormat.h"
#include "VertexManager.h"
#include "VertexShaderCache.h"
class D3DVertexFormat : public NativeVertexFormat
{
D3D11_INPUT_ELEMENT_DESC m_elems[32];
UINT m_num_elems;
D3DBlob* m_vs_bytecode;
ID3D11InputLayout* m_layout;
public:
D3DVertexFormat() : m_num_elems(0) {}
D3DVertexFormat() : m_num_elems(0), m_vs_bytecode(NULL), m_layout(NULL) {}
~D3DVertexFormat() { SAFE_RELEASE(m_vs_bytecode); SAFE_RELEASE(m_layout); }
void Initialize(const PortableVertexDeclaration &_vtx_decl);
void SetupVertexPointers() const;
void SetupVertexPointers();
};
namespace DX11
@ -140,7 +146,19 @@ void D3DVertexFormat::Initialize(const PortableVertexDeclaration &_vtx_decl)
}
}
void D3DVertexFormat::SetupVertexPointers() const
void D3DVertexFormat::SetupVertexPointers()
{
D3D::gfxstate->SetInputElements(m_elems, m_num_elems);
if (m_vs_bytecode != VertexShaderCache::GetActiveShaderBytecode())
{
SAFE_RELEASE(m_vs_bytecode);
SAFE_RELEASE(m_layout);
m_vs_bytecode = VertexShaderCache::GetActiveShaderBytecode();
m_vs_bytecode->AddRef();
HRESULT hr = D3D::device->CreateInputLayout(m_elems, m_num_elems, m_vs_bytecode->Data(), m_vs_bytecode->Size(), &m_layout);
if (FAILED(hr)) PanicAlert("Failed to create input layout, %s %d\n", __FILE__, __LINE__);
D3D::SetDebugObjectName((ID3D11DeviceChild*)m_layout, "input layout used to emulate the GX pipeline");
}
D3D::context->IASetInputLayout(m_layout);
}