2015-05-24 07:32:32 +03:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
2014-02-10 20:54:46 +02:00
|
|
|
#pragma once
|
2010-11-18 04:21:26 +02:00
|
|
|
|
2017-09-08 12:42:56 +03:00
|
|
|
#include <d3d11.h>
|
2014-03-12 21:33:41 +02:00
|
|
|
#include <string>
|
2017-09-30 09:19:16 +03:00
|
|
|
#include "VideoBackends/D3D/D3DState.h"
|
2014-02-17 12:18:15 +02:00
|
|
|
#include "VideoCommon/RenderBase.h"
|
2010-11-18 04:21:26 +02:00
|
|
|
|
|
|
|
namespace DX11
|
|
|
|
{
|
2019-03-09 15:31:36 +02:00
|
|
|
class SwapChain;
|
2019-02-15 03:59:50 +02:00
|
|
|
class DXTexture;
|
|
|
|
class DXFramebuffer;
|
2017-01-23 18:20:20 +02:00
|
|
|
|
2010-11-18 04:21:26 +02:00
|
|
|
class Renderer : public ::Renderer
|
|
|
|
{
|
|
|
|
public:
|
2019-03-09 15:31:36 +02:00
|
|
|
Renderer(std::unique_ptr<SwapChain> swap_chain, float backbuffer_scale);
|
2017-03-04 08:40:08 +02:00
|
|
|
~Renderer() override;
|
2010-11-18 04:21:26 +02:00
|
|
|
|
2017-09-30 09:19:16 +03:00
|
|
|
StateCache& GetStateCache() { return m_state_cache; }
|
2018-10-03 16:03:13 +03:00
|
|
|
|
|
|
|
bool IsHeadless() const override;
|
|
|
|
|
2017-09-30 09:25:36 +03:00
|
|
|
std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config) override;
|
2017-10-21 17:49:40 +03:00
|
|
|
std::unique_ptr<AbstractStagingTexture>
|
|
|
|
CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
|
2017-09-08 12:42:56 +03:00
|
|
|
std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage, const char* source,
|
|
|
|
size_t length) override;
|
|
|
|
std::unique_ptr<AbstractShader> CreateShaderFromBinary(ShaderStage stage, const void* data,
|
|
|
|
size_t length) override;
|
2019-02-15 03:59:50 +02:00
|
|
|
std::unique_ptr<NativeVertexFormat>
|
|
|
|
CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override;
|
2019-04-15 14:55:26 +03:00
|
|
|
std::unique_ptr<AbstractPipeline> CreatePipeline(const AbstractPipelineConfig& config,
|
|
|
|
const void* cache_data = nullptr,
|
|
|
|
size_t cache_data_length = 0) override;
|
2018-01-21 12:22:45 +02:00
|
|
|
std::unique_ptr<AbstractFramebuffer>
|
2019-02-15 03:59:50 +02:00
|
|
|
CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment) override;
|
2017-09-30 09:25:36 +03:00
|
|
|
|
2017-09-08 12:42:56 +03:00
|
|
|
void SetPipeline(const AbstractPipeline* pipeline) override;
|
2019-02-15 03:59:50 +02:00
|
|
|
void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
|
|
|
|
void SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) override;
|
|
|
|
void SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value = {},
|
2018-01-21 12:22:45 +02:00
|
|
|
float depth_value = 0.0f) override;
|
2018-01-21 14:12:32 +02:00
|
|
|
void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
|
2018-01-21 15:13:25 +02:00
|
|
|
void SetTexture(u32 index, const AbstractTexture* texture) override;
|
2017-09-09 11:30:15 +03:00
|
|
|
void SetSamplerState(u32 index, const SamplerState& state) override;
|
2019-02-15 03:59:50 +02:00
|
|
|
void SetComputeImageTexture(AbstractTexture* texture, bool read, bool write) override;
|
2018-01-21 15:13:25 +02:00
|
|
|
void UnbindTexture(const AbstractTexture* texture) override;
|
2018-01-21 14:04:15 +02:00
|
|
|
void SetViewport(float x, float y, float width, float height, float near_depth,
|
|
|
|
float far_depth) override;
|
2018-11-27 09:16:53 +02:00
|
|
|
void Draw(u32 base_vertex, u32 num_vertices) override;
|
|
|
|
void DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex) override;
|
2019-02-15 03:59:50 +02:00
|
|
|
void DispatchComputeShader(const AbstractShader* shader, u32 groups_x, u32 groups_y,
|
|
|
|
u32 groups_z) override;
|
2018-11-28 06:30:47 +02:00
|
|
|
void BindBackbuffer(const ClearColor& clear_color = {}) override;
|
|
|
|
void PresentBackbuffer() override;
|
2016-11-09 02:07:56 +02:00
|
|
|
void SetFullscreen(bool enable_fullscreen) override;
|
2016-11-13 23:16:29 +02:00
|
|
|
bool IsFullscreen() const override;
|
2010-11-18 04:21:26 +02:00
|
|
|
|
2016-06-24 11:43:46 +03:00
|
|
|
u16 BBoxRead(int index) override;
|
|
|
|
void BBoxWrite(int index, u16 value) override;
|
2010-11-18 04:21:26 +02:00
|
|
|
|
2019-02-15 03:59:50 +02:00
|
|
|
void Flush() override;
|
|
|
|
void WaitForGPUIdle() override;
|
2010-11-18 04:21:26 +02:00
|
|
|
|
2019-04-15 17:47:46 +03:00
|
|
|
void RenderXFBToScreen(const AbstractTexture* texture,
|
|
|
|
const MathUtil::Rectangle<int>& rc) override;
|
2018-11-28 06:30:47 +02:00
|
|
|
void OnConfigChanged(u32 bits) override;
|
2010-11-18 04:21:26 +02:00
|
|
|
|
2014-12-20 19:20:49 +02:00
|
|
|
private:
|
2017-11-21 11:53:38 +02:00
|
|
|
void Create3DVisionTexture(int width, int height);
|
2019-03-09 15:31:36 +02:00
|
|
|
void CheckForSwapChainChanges();
|
2017-11-21 11:53:38 +02:00
|
|
|
|
2017-09-30 09:19:16 +03:00
|
|
|
StateCache m_state_cache;
|
2017-11-21 11:53:38 +02:00
|
|
|
|
2019-03-09 15:31:36 +02:00
|
|
|
std::unique_ptr<SwapChain> m_swap_chain;
|
2019-02-15 03:59:50 +02:00
|
|
|
std::unique_ptr<DXTexture> m_3d_vision_texture;
|
|
|
|
std::unique_ptr<DXFramebuffer> m_3d_vision_framebuffer;
|
2010-11-18 04:21:26 +02:00
|
|
|
};
|
2019-02-15 03:59:50 +02:00
|
|
|
} // namespace DX11
|