// SPDX-FileCopyrightText: 2019-2023 Connor McLaughlin // SPDX-License-Identifier: (GPL-3.0 OR CC-BY-NC-ND-4.0) #pragma once #include "gpu_device.h" #include "common/windows_headers.h" #include #include #include #include #include #include class D3D11Device; class D3D11Shader final : public GPUShader { friend D3D11Device; public: ~D3D11Shader() override; ID3D11VertexShader* GetVertexShader() const; ID3D11PixelShader* GetPixelShader() const; ID3D11ComputeShader* GetComputeShader() const; ALWAYS_INLINE const std::vector& GetBytecode() const { return m_bytecode; } void SetDebugName(const std::string_view& name) override; private: D3D11Shader(GPUShaderStage stage, Microsoft::WRL::ComPtr shader, std::vector bytecode); Microsoft::WRL::ComPtr m_shader; std::vector m_bytecode; // only for VS }; class D3D11Pipeline final : public GPUPipeline { friend D3D11Device; template using ComPtr = Microsoft::WRL::ComPtr; public: ~D3D11Pipeline() override; void SetDebugName(const std::string_view& name) override; ALWAYS_INLINE ID3D11RasterizerState* GetRasterizerState() const { return m_rs.Get(); } ALWAYS_INLINE ID3D11DepthStencilState* GetDepthStencilState() const { return m_ds.Get(); } ALWAYS_INLINE ID3D11BlendState* GetBlendState() const { return m_bs.Get(); } ALWAYS_INLINE ID3D11InputLayout* GetInputLayout() const { return m_il.Get(); } ALWAYS_INLINE ID3D11VertexShader* GetVertexShader() const { return m_vs.Get(); } ALWAYS_INLINE ID3D11PixelShader* GetPixelShader() const { return m_ps.Get(); } ALWAYS_INLINE D3D11_PRIMITIVE_TOPOLOGY GetPrimitiveTopology() const { return m_topology; } ALWAYS_INLINE u32 GetVertexStride() const { return m_vertex_stride; } ALWAYS_INLINE u32 GetBlendFactor() const { return m_blend_factor; } ALWAYS_INLINE const std::array& GetBlendFactorFloat() const { return m_blend_factor_float; } private: D3D11Pipeline(ComPtr rs, ComPtr ds, ComPtr bs, ComPtr il, ComPtr vs, ComPtr ps, D3D11_PRIMITIVE_TOPOLOGY topology, u32 vertex_stride, u32 blend_factor); ComPtr m_rs; ComPtr m_ds; ComPtr m_bs; ComPtr m_il; ComPtr m_vs; ComPtr m_ps; D3D11_PRIMITIVE_TOPOLOGY m_topology; u32 m_vertex_stride; u32 m_blend_factor; std::array m_blend_factor_float; };