2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2008 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2013-04-17 21:29:41 -06:00
|
|
|
// Refer to the license.txt file included.
|
2010-06-13 13:50:06 -06:00
|
|
|
|
2014-02-10 11:54:46 -07:00
|
|
|
#pragma once
|
2010-06-13 13:50:06 -06:00
|
|
|
|
2017-12-02 18:06:25 -07:00
|
|
|
#include <array>
|
2018-02-24 07:23:24 -07:00
|
|
|
#include <atomic>
|
2017-02-18 01:14:30 -07:00
|
|
|
#include <memory>
|
2017-12-02 18:06:25 -07:00
|
|
|
#include <vector>
|
|
|
|
|
2019-03-09 06:31:37 -07:00
|
|
|
#include "VideoBackends/D3D/D3DBase.h"
|
2017-07-19 23:25:31 -06:00
|
|
|
#include "VideoCommon/NativeVertexFormat.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "VideoCommon/VertexManagerBase.h"
|
2010-06-13 13:50:06 -06:00
|
|
|
|
2010-10-02 18:41:06 -06:00
|
|
|
namespace DX11
|
|
|
|
{
|
2017-07-19 23:25:31 -06:00
|
|
|
class D3DVertexFormat : public NativeVertexFormat
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
D3DVertexFormat(const PortableVertexDeclaration& vtx_decl);
|
|
|
|
~D3DVertexFormat();
|
2019-02-14 18:59:50 -07:00
|
|
|
ID3D11InputLayout* GetInputLayout(const void* vs_bytecode, size_t vs_bytecode_size);
|
2017-07-19 23:25:31 -06:00
|
|
|
|
|
|
|
private:
|
|
|
|
std::array<D3D11_INPUT_ELEMENT_DESC, 32> m_elems{};
|
|
|
|
UINT m_num_elems = 0;
|
|
|
|
|
2018-02-24 07:23:24 -07:00
|
|
|
std::atomic<ID3D11InputLayout*> m_layout{nullptr};
|
2017-07-19 23:25:31 -06:00
|
|
|
};
|
|
|
|
|
2015-11-01 14:54:41 -07:00
|
|
|
class VertexManager : public VertexManagerBase
|
2010-10-02 18:41:06 -06:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
VertexManager();
|
2011-06-11 13:37:21 -06:00
|
|
|
~VertexManager();
|
2010-10-02 18:41:06 -06:00
|
|
|
|
2019-02-14 18:59:50 -07:00
|
|
|
bool Initialize();
|
2017-02-18 01:14:30 -07:00
|
|
|
|
2018-11-27 00:16:53 -07:00
|
|
|
void UploadUtilityUniforms(const void* uniforms, u32 uniforms_size) override;
|
2019-02-14 18:59:50 -07:00
|
|
|
bool UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format,
|
|
|
|
u32* out_offset) override;
|
|
|
|
bool UploadTexelBuffer(const void* data, u32 data_size, TexelBufferFormat format, u32* out_offset,
|
|
|
|
const void* palette_data, u32 palette_size,
|
|
|
|
TexelBufferFormat palette_format, u32* out_palette_offset) override;
|
2012-10-20 07:22:15 -06:00
|
|
|
|
2014-01-23 07:27:18 -07:00
|
|
|
protected:
|
2019-02-14 18:59:50 -07:00
|
|
|
void ResetBuffer(u32 vertex_stride) override;
|
2018-11-27 00:16:53 -07:00
|
|
|
void CommitBuffer(u32 num_vertices, u32 vertex_stride, u32 num_indices, u32* out_base_vertex,
|
|
|
|
u32* out_base_index) override;
|
2019-02-14 18:59:50 -07:00
|
|
|
void UploadUniforms() override;
|
2018-04-12 06:18:04 -06:00
|
|
|
|
2012-10-20 07:22:15 -06:00
|
|
|
private:
|
2019-02-14 18:59:50 -07:00
|
|
|
static constexpr u32 BUFFER_COUNT = 2;
|
|
|
|
static constexpr u32 BUFFER_SIZE =
|
|
|
|
(VERTEX_STREAM_BUFFER_SIZE + INDEX_STREAM_BUFFER_SIZE) / BUFFER_COUNT;
|
|
|
|
|
|
|
|
bool MapTexelBuffer(u32 required_size, D3D11_MAPPED_SUBRESOURCE& sr);
|
|
|
|
|
2019-03-09 06:31:37 -07:00
|
|
|
ComPtr<ID3D11Buffer> m_buffers[BUFFER_COUNT] = {};
|
2018-11-27 00:16:53 -07:00
|
|
|
u32 m_current_buffer = 0;
|
|
|
|
u32 m_buffer_cursor = 0;
|
|
|
|
|
2019-03-09 06:31:37 -07:00
|
|
|
ComPtr<ID3D11Buffer> m_vertex_constant_buffer = nullptr;
|
|
|
|
ComPtr<ID3D11Buffer> m_geometry_constant_buffer = nullptr;
|
|
|
|
ComPtr<ID3D11Buffer> m_pixel_constant_buffer = nullptr;
|
2019-02-14 18:59:50 -07:00
|
|
|
|
2019-03-09 06:31:37 -07:00
|
|
|
ComPtr<ID3D11Buffer> m_texel_buffer = nullptr;
|
|
|
|
std::array<ComPtr<ID3D11ShaderResourceView>, NUM_TEXEL_BUFFER_FORMATS> m_texel_buffer_views;
|
2019-02-14 18:59:50 -07:00
|
|
|
u32 m_texel_buffer_offset = 0;
|
2010-10-02 18:41:06 -06:00
|
|
|
};
|
2010-06-13 13:50:06 -06:00
|
|
|
|
2018-11-27 00:16:53 -07:00
|
|
|
} // namespace DX11
|