D3DGfx.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // Copyright 2010 Dolphin Emulator Project
  2. // SPDX-License-Identifier: GPL-2.0-or-later
  3. #pragma once
  4. #include <d3d11.h>
  5. #include <string_view>
  6. #include "VideoBackends/D3D/D3DState.h"
  7. #include "VideoCommon/AbstractGfx.h"
  8. class BoundingBox;
  9. namespace DX11
  10. {
  11. class SwapChain;
  12. class DXTexture;
  13. class DXFramebuffer;
  14. class Gfx final : public ::AbstractGfx
  15. {
  16. public:
  17. Gfx(std::unique_ptr<SwapChain> swap_chain, float backbuffer_scale);
  18. ~Gfx() override;
  19. StateCache& GetStateCache() { return m_state_cache; }
  20. bool IsHeadless() const override;
  21. std::unique_ptr<AbstractTexture> CreateTexture(const TextureConfig& config,
  22. std::string_view name) override;
  23. std::unique_ptr<AbstractStagingTexture>
  24. CreateStagingTexture(StagingTextureType type, const TextureConfig& config) override;
  25. std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage, std::string_view source,
  26. std::string_view name) override;
  27. std::unique_ptr<AbstractShader> CreateShaderFromBinary(ShaderStage stage, const void* data,
  28. size_t length,
  29. std::string_view name) override;
  30. std::unique_ptr<NativeVertexFormat>
  31. CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) override;
  32. std::unique_ptr<AbstractPipeline> CreatePipeline(const AbstractPipelineConfig& config,
  33. const void* cache_data = nullptr,
  34. size_t cache_data_length = 0) override;
  35. std::unique_ptr<AbstractFramebuffer>
  36. CreateFramebuffer(AbstractTexture* color_attachment, AbstractTexture* depth_attachment,
  37. std::vector<AbstractTexture*> additional_color_attachments) override;
  38. void SetPipeline(const AbstractPipeline* pipeline) override;
  39. void SetFramebuffer(AbstractFramebuffer* framebuffer) override;
  40. void SetAndDiscardFramebuffer(AbstractFramebuffer* framebuffer) override;
  41. void SetAndClearFramebuffer(AbstractFramebuffer* framebuffer, const ClearColor& color_value = {},
  42. float depth_value = 0.0f) override;
  43. void SetScissorRect(const MathUtil::Rectangle<int>& rc) override;
  44. void SetTexture(u32 index, const AbstractTexture* texture) override;
  45. void SetSamplerState(u32 index, const SamplerState& state) override;
  46. void SetComputeImageTexture(u32 index, AbstractTexture* texture, bool read, bool write) override;
  47. void UnbindTexture(const AbstractTexture* texture) override;
  48. void SetViewport(float x, float y, float width, float height, float near_depth,
  49. float far_depth) override;
  50. void Draw(u32 base_vertex, u32 num_vertices) override;
  51. void DrawIndexed(u32 base_index, u32 num_indices, u32 base_vertex) override;
  52. void DispatchComputeShader(const AbstractShader* shader, u32 groupsize_x, u32 groupsize_y,
  53. u32 groupsize_z, u32 groups_x, u32 groups_y, u32 groups_z) override;
  54. bool BindBackbuffer(const ClearColor& clear_color = {}) override;
  55. void PresentBackbuffer() override;
  56. void SetFullscreen(bool enable_fullscreen) override;
  57. bool IsFullscreen() const override;
  58. void Flush() override;
  59. void WaitForGPUIdle() override;
  60. void OnConfigChanged(u32 bits) override;
  61. SurfaceInfo GetSurfaceInfo() const override;
  62. private:
  63. void CheckForSwapChainChanges();
  64. StateCache m_state_cache;
  65. float m_backbuffer_scale;
  66. std::unique_ptr<SwapChain> m_swap_chain;
  67. };
  68. } // namespace DX11