mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
VideoBackends:Metal: Cache pipelines
Metal pipelines hold less stuff than Dolphin pipelines, so duplicates will appear
This commit is contained in:
@ -14,24 +14,34 @@
|
||||
|
||||
namespace Metal
|
||||
{
|
||||
struct PipelineReflection
|
||||
{
|
||||
u32 textures = 0;
|
||||
u32 samplers = 0;
|
||||
u32 vertex_buffers = 0;
|
||||
u32 fragment_buffers = 0;
|
||||
PipelineReflection() = default;
|
||||
explicit PipelineReflection(MTLRenderPipelineReflection* reflection);
|
||||
};
|
||||
|
||||
class Pipeline final : public AbstractPipeline
|
||||
{
|
||||
public:
|
||||
explicit Pipeline(MRCOwned<id<MTLRenderPipelineState>> pipeline,
|
||||
MTLRenderPipelineReflection* reflection, MTLPrimitiveType prim,
|
||||
MTLCullMode cull, DepthState depth, AbstractPipelineUsage usage);
|
||||
const PipelineReflection& reflection, MTLPrimitiveType prim, MTLCullMode cull,
|
||||
DepthState depth, AbstractPipelineUsage usage);
|
||||
|
||||
id<MTLRenderPipelineState> Get() const { return m_pipeline; }
|
||||
MTLPrimitiveType Prim() const { return m_prim; }
|
||||
MTLCullMode Cull() const { return m_cull; }
|
||||
DepthStencilSelector DepthStencil() const { return m_depth_stencil; }
|
||||
AbstractPipelineUsage Usage() const { return m_usage; }
|
||||
u32 GetTextures() const { return m_textures; }
|
||||
u32 GetSamplers() const { return m_samplers; }
|
||||
u32 GetVertexBuffers() const { return m_vertex_buffers; }
|
||||
u32 GetFragmentBuffers() const { return m_fragment_buffers; }
|
||||
bool UsesVertexBuffer(u32 index) const { return m_vertex_buffers & (1 << index); }
|
||||
bool UsesFragmentBuffer(u32 index) const { return m_fragment_buffers & (1 << index); }
|
||||
u32 GetTextures() const { return m_reflection.textures; }
|
||||
u32 GetSamplers() const { return m_reflection.samplers; }
|
||||
u32 GetVertexBuffers() const { return m_reflection.vertex_buffers; }
|
||||
u32 GetFragmentBuffers() const { return m_reflection.fragment_buffers; }
|
||||
bool UsesVertexBuffer(u32 index) const { return m_reflection.vertex_buffers & (1 << index); }
|
||||
bool UsesFragmentBuffer(u32 index) const { return m_reflection.fragment_buffers & (1 << index); }
|
||||
|
||||
private:
|
||||
MRCOwned<id<MTLRenderPipelineState>> m_pipeline;
|
||||
@ -39,10 +49,7 @@ private:
|
||||
MTLCullMode m_cull;
|
||||
DepthStencilSelector m_depth_stencil;
|
||||
AbstractPipelineUsage m_usage;
|
||||
u32 m_textures = 0;
|
||||
u32 m_samplers = 0;
|
||||
u32 m_vertex_buffers = 0;
|
||||
u32 m_fragment_buffers = 0;
|
||||
PipelineReflection m_reflection;
|
||||
};
|
||||
|
||||
class ComputePipeline : public Shader
|
||||
|
Reference in New Issue
Block a user