diff --git a/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp b/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp index be29d9fbfe..b112ee1c04 100644 --- a/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/D3D/NativeVertexFormat.cpp @@ -2,6 +2,8 @@ // Licensed under GPLv2+ // Refer to the license.txt file included. +#include + #include "VideoBackends/D3D/D3DBase.h" #include "VideoBackends/D3D/D3DBlob.h" #include "VideoBackends/D3D/D3DState.h" @@ -14,16 +16,17 @@ namespace DX11 class D3DVertexFormat : public NativeVertexFormat { - D3D11_INPUT_ELEMENT_DESC m_elems[32]; - UINT m_num_elems; - - ID3D11InputLayout* m_layout; - public: D3DVertexFormat(const PortableVertexDeclaration& vtx_decl); ~D3DVertexFormat() { SAFE_RELEASE(m_layout); } void SetupVertexPointers(); + +private: + std::array m_elems{}; + UINT m_num_elems = 0; + + ID3D11InputLayout* m_layout = nullptr; }; 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) - : m_num_elems(0), m_layout(nullptr) { this->vtx_decl = _vtx_decl; - memset(m_elems, 0, sizeof(m_elems)); + const AttributeFormat* format = &_vtx_decl.position; if (format->enable) @@ -134,7 +136,7 @@ void D3DVertexFormat::SetupVertexPointers() // changes. 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__); DX11::D3D::SetDebugObjectName((ID3D11DeviceChild*)m_layout, "input layout used to emulate the GX pipeline"); } diff --git a/Source/Core/VideoBackends/D3D12/NativeVertexFormat.cpp b/Source/Core/VideoBackends/D3D12/NativeVertexFormat.cpp index fda4846367..d5a4cdd5a5 100644 --- a/Source/Core/VideoBackends/D3D12/NativeVertexFormat.cpp +++ b/Source/Core/VideoBackends/D3D12/NativeVertexFormat.cpp @@ -44,8 +44,7 @@ DXGI_FORMAT VarToD3D(VarType t, int size, bool integer) return retval; } -D3DVertexFormat::D3DVertexFormat(const PortableVertexDeclaration &vtx_decl) - : m_num_elems(0), m_layout12({}), m_elems() +D3DVertexFormat::D3DVertexFormat(const PortableVertexDeclaration& vtx_decl) { this->vtx_decl = vtx_decl; diff --git a/Source/Core/VideoBackends/D3D12/NativeVertexFormat.h b/Source/Core/VideoBackends/D3D12/NativeVertexFormat.h index 58a9fbb1e4..cccf233cc0 100644 --- a/Source/Core/VideoBackends/D3D12/NativeVertexFormat.h +++ b/Source/Core/VideoBackends/D3D12/NativeVertexFormat.h @@ -12,11 +12,6 @@ namespace DX12 class D3DVertexFormat final : public NativeVertexFormat { - std::array m_elems; - UINT m_num_elems; - - D3D12_INPUT_LAYOUT_DESC m_layout12; - public: D3DVertexFormat(const PortableVertexDeclaration& vtx_decl); ~D3DVertexFormat(); @@ -27,5 +22,10 @@ public: private: void AddInputElementDescFromAttributeFormatIfValid(const AttributeFormat* format, const char* semantic_name, unsigned int semantic_index); + + std::array m_elems{}; + UINT m_num_elems = 0; + + D3D12_INPUT_LAYOUT_DESC m_layout12{}; }; }