2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2013-04-18 03:29:41 +00:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2017-07-20 05:25:31 +00:00
|
|
|
#include <d3d11.h>
|
2017-12-03 01:06:25 +00:00
|
|
|
|
|
|
|
#include <array>
|
2018-02-24 14:23:24 +00:00
|
|
|
#include <atomic>
|
2017-02-18 08:14:30 +00:00
|
|
|
#include <memory>
|
2017-12-03 01:06:25 +00:00
|
|
|
#include <vector>
|
|
|
|
|
2017-07-20 05:25:31 +00:00
|
|
|
#include "VideoCommon/NativeVertexFormat.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "VideoCommon/VertexManagerBase.h"
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2017-02-01 04:29:29 +00:00
|
|
|
struct ID3D11Buffer;
|
|
|
|
|
2010-10-03 00:41:06 +00:00
|
|
|
namespace DX11
|
|
|
|
{
|
2017-07-20 05:25:31 +00:00
|
|
|
class D3DBlob;
|
|
|
|
class D3DVertexFormat : public NativeVertexFormat
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
D3DVertexFormat(const PortableVertexDeclaration& vtx_decl);
|
|
|
|
~D3DVertexFormat();
|
2017-09-08 09:42:56 +00:00
|
|
|
ID3D11InputLayout* GetInputLayout(D3DBlob* vs_bytecode);
|
2017-07-20 05:25:31 +00:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::array<D3D11_INPUT_ELEMENT_DESC, 32> m_elems{};
|
|
|
|
UINT m_num_elems = 0;
|
|
|
|
|
2018-02-24 14:23:24 +00:00
|
|
|
std::atomic<ID3D11InputLayout*> m_layout{nullptr};
|
2017-07-20 05:25:31 +00:00
|
|
|
};
|
|
|
|
|
2015-11-01 21:54:41 +00:00
|
|
|
class VertexManager : public VertexManagerBase
|
2010-10-03 00:41:06 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-06-24 08:43:46 +00:00
|
|
|
VertexManager();
|
|
|
|
~VertexManager();
|
2010-10-03 00:41:06 +00:00
|
|
|
|
2017-02-18 08:14:30 +00:00
|
|
|
std::unique_ptr<NativeVertexFormat>
|
|
|
|
CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override;
|
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
void UploadUtilityUniforms(const void* uniforms, u32 uniforms_size) override;
|
2012-10-20 13:22:15 +00:00
|
|
|
|
2014-01-23 14:27:18 +00:00
|
|
|
protected:
|
2018-11-27 07:16:53 +00:00
|
|
|
void CreateDeviceObjects() override;
|
|
|
|
void DestroyDeviceObjects() override;
|
|
|
|
void ResetBuffer(u32 vertex_stride, bool cull_all) override;
|
|
|
|
void CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_indices, u32* out_base_vertex,
|
|
|
|
u32* out_base_index) override;
|
|
|
|
void UploadConstants() override;
|
|
|
|
void DrawCurrentBatch(u32 base_index, u32 num_indices, u32 base_vertex) override;
|
2018-04-12 12:18:04 +00:00
|
|
|
|
2012-10-20 13:22:15 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
enum
|
|
|
|
{
|
|
|
|
MAX_BUFFER_COUNT = 2
|
|
|
|
};
|
2018-11-27 07:16:53 +00:00
|
|
|
ID3D11Buffer* m_buffers[MAX_BUFFER_COUNT] = {};
|
|
|
|
u32 m_current_buffer = 0;
|
|
|
|
u32 m_buffer_cursor = 0;
|
|
|
|
|
|
|
|
std::vector<u8> m_staging_vertex_buffer;
|
|
|
|
std::vector<u16> m_staging_index_buffer;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
ID3D11Buffer* m_vertex_constant_buffer = nullptr;
|
|
|
|
ID3D11Buffer* m_geometry_constant_buffer = nullptr;
|
|
|
|
ID3D11Buffer* m_pixel_constant_buffer = nullptr;
|
2010-10-03 00:41:06 +00:00
|
|
|
};
|
2010-06-13 19:50:06 +00:00
|
|
|
|
2018-11-27 07:16:53 +00:00
|
|
|
} // namespace DX11
|