NativeVertexFormat: Use in-class initialization
This commit is contained in:
parent
2c5fcad5f5
commit
69c82f32ff
|
@ -2,6 +2,8 @@
|
||||||
// Licensed under GPLv2+
|
// Licensed under GPLv2+
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "VideoBackends/D3D/D3DBase.h"
|
#include "VideoBackends/D3D/D3DBase.h"
|
||||||
#include "VideoBackends/D3D/D3DBlob.h"
|
#include "VideoBackends/D3D/D3DBlob.h"
|
||||||
#include "VideoBackends/D3D/D3DState.h"
|
#include "VideoBackends/D3D/D3DState.h"
|
||||||
|
@ -14,16 +16,17 @@ namespace DX11
|
||||||
|
|
||||||
class D3DVertexFormat : public NativeVertexFormat
|
class D3DVertexFormat : public NativeVertexFormat
|
||||||
{
|
{
|
||||||
D3D11_INPUT_ELEMENT_DESC m_elems[32];
|
|
||||||
UINT m_num_elems;
|
|
||||||
|
|
||||||
ID3D11InputLayout* m_layout;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
D3DVertexFormat(const PortableVertexDeclaration& vtx_decl);
|
D3DVertexFormat(const PortableVertexDeclaration& vtx_decl);
|
||||||
~D3DVertexFormat() { SAFE_RELEASE(m_layout); }
|
~D3DVertexFormat() { SAFE_RELEASE(m_layout); }
|
||||||
|
|
||||||
void SetupVertexPointers();
|
void SetupVertexPointers();
|
||||||
|
|
||||||
|
private:
|
||||||
|
std::array<D3D11_INPUT_ELEMENT_DESC, 32> m_elems{};
|
||||||
|
UINT m_num_elems = 0;
|
||||||
|
|
||||||
|
ID3D11InputLayout* m_layout = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
NativeVertexFormat* VertexManager::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
|
NativeVertexFormat* VertexManager::CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl)
|
||||||
|
@ -57,10 +60,9 @@ DXGI_FORMAT VarToD3D(VarType t, int size, bool integer)
|
||||||
}
|
}
|
||||||
|
|
||||||
D3DVertexFormat::D3DVertexFormat(const PortableVertexDeclaration& _vtx_decl)
|
D3DVertexFormat::D3DVertexFormat(const PortableVertexDeclaration& _vtx_decl)
|
||||||
: m_num_elems(0), m_layout(nullptr)
|
|
||||||
{
|
{
|
||||||
this->vtx_decl = _vtx_decl;
|
this->vtx_decl = _vtx_decl;
|
||||||
memset(m_elems, 0, sizeof(m_elems));
|
|
||||||
const AttributeFormat* format = &_vtx_decl.position;
|
const AttributeFormat* format = &_vtx_decl.position;
|
||||||
|
|
||||||
if (format->enable)
|
if (format->enable)
|
||||||
|
@ -134,7 +136,7 @@ void D3DVertexFormat::SetupVertexPointers()
|
||||||
// changes.
|
// changes.
|
||||||
D3DBlob* vs_bytecode = DX11::VertexShaderCache::GetActiveShaderBytecode();
|
D3DBlob* vs_bytecode = DX11::VertexShaderCache::GetActiveShaderBytecode();
|
||||||
|
|
||||||
HRESULT hr = DX11::D3D::device->CreateInputLayout(m_elems, m_num_elems, vs_bytecode->Data(), vs_bytecode->Size(), &m_layout);
|
HRESULT hr = DX11::D3D::device->CreateInputLayout(m_elems.data(), m_num_elems, vs_bytecode->Data(), vs_bytecode->Size(), &m_layout);
|
||||||
if (FAILED(hr)) PanicAlert("Failed to create input layout, %s %d\n", __FILE__, __LINE__);
|
if (FAILED(hr)) PanicAlert("Failed to create input layout, %s %d\n", __FILE__, __LINE__);
|
||||||
DX11::D3D::SetDebugObjectName((ID3D11DeviceChild*)m_layout, "input layout used to emulate the GX pipeline");
|
DX11::D3D::SetDebugObjectName((ID3D11DeviceChild*)m_layout, "input layout used to emulate the GX pipeline");
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,8 +44,7 @@ DXGI_FORMAT VarToD3D(VarType t, int size, bool integer)
|
||||||
return retval;
|
return retval;
|
||||||
}
|
}
|
||||||
|
|
||||||
D3DVertexFormat::D3DVertexFormat(const PortableVertexDeclaration &vtx_decl)
|
D3DVertexFormat::D3DVertexFormat(const PortableVertexDeclaration& vtx_decl)
|
||||||
: m_num_elems(0), m_layout12({}), m_elems()
|
|
||||||
{
|
{
|
||||||
this->vtx_decl = vtx_decl;
|
this->vtx_decl = vtx_decl;
|
||||||
|
|
||||||
|
|
|
@ -12,11 +12,6 @@ namespace DX12
|
||||||
|
|
||||||
class D3DVertexFormat final : public NativeVertexFormat
|
class D3DVertexFormat final : public NativeVertexFormat
|
||||||
{
|
{
|
||||||
std::array<D3D12_INPUT_ELEMENT_DESC, 15> m_elems;
|
|
||||||
UINT m_num_elems;
|
|
||||||
|
|
||||||
D3D12_INPUT_LAYOUT_DESC m_layout12;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
D3DVertexFormat(const PortableVertexDeclaration& vtx_decl);
|
D3DVertexFormat(const PortableVertexDeclaration& vtx_decl);
|
||||||
~D3DVertexFormat();
|
~D3DVertexFormat();
|
||||||
|
@ -27,5 +22,10 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void AddInputElementDescFromAttributeFormatIfValid(const AttributeFormat* format, const char* semantic_name, unsigned int semantic_index);
|
void AddInputElementDescFromAttributeFormatIfValid(const AttributeFormat* format, const char* semantic_name, unsigned int semantic_index);
|
||||||
|
|
||||||
|
std::array<D3D12_INPUT_ELEMENT_DESC, 15> m_elems{};
|
||||||
|
UINT m_num_elems = 0;
|
||||||
|
|
||||||
|
D3D12_INPUT_LAYOUT_DESC m_layout12{};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue