#pragma once #include "common/d3d11/stream_buffer.h" #include "common/d3d11/texture.h" #include "common/windows_headers.h" #include "core/host_display.h" #include #include #include #include class D3D11HostDisplay final : public HostDisplay { public: template using ComPtr = Microsoft::WRL::ComPtr; D3D11HostDisplay(SDL_Window* window); ~D3D11HostDisplay(); static std::unique_ptr Create(SDL_Window* window, bool debug_device); RenderAPI GetRenderAPI() const override; void* GetRenderDevice() const override; void* GetRenderContext() const override; void* GetRenderWindow() const override; void ChangeRenderWindow(void* new_window) override; std::unique_ptr CreateTexture(u32 width, u32 height, const void* data, u32 data_stride, bool dynamic) override; void UpdateTexture(HostDisplayTexture* texture, u32 x, u32 y, u32 width, u32 height, const void* data, u32 data_stride) override; void SetVSync(bool enabled) override; std::tuple GetWindowSize() const override; void WindowResized() override; private: static constexpr u32 DISPLAY_UNIFORM_BUFFER_SIZE = 16; bool CreateD3DDevice(bool debug_device); bool CreateD3DResources(); bool CreateSwapChainRTV(); bool CreateImGuiContext(); void Render(); void RenderDisplay(); SDL_Window* m_window = nullptr; SDL_GLContext m_gl_context = nullptr; int m_window_width = 0; int m_window_height = 0; ComPtr m_device; ComPtr m_context; ComPtr m_swap_chain; ComPtr m_swap_chain_rtv; ComPtr m_display_rasterizer_state; ComPtr m_display_depth_stencil_state; ComPtr m_display_blend_state; ComPtr m_display_vertex_shader; ComPtr m_display_pixel_shader; ComPtr m_point_sampler; ComPtr m_linear_sampler; D3D11::Texture m_display_pixels_texture; D3D11::StreamBuffer m_display_uniform_buffer; bool m_allow_tearing_supported = false; bool m_vsync = false; };