#ifndef RENDERER_PIPELINECACHE_H_ #define RENDERER_PIPELINECACHE_H_ struct PipelineKey { uint64 state; int program; bool mirrored; int depthBias; float slopeBias; Framebuffer* framebuffer; }; inline bool operator==( const PipelineKey& lhs, const PipelineKey& rhs ) { return lhs.state == rhs.state && lhs.program == rhs.program && lhs.mirrored == rhs.mirrored && lhs.framebuffer == rhs.framebuffer && lhs.depthBias == rhs.depthBias && lhs.slopeBias == rhs.slopeBias; } template<> struct std::hash { std::size_t operator()( const PipelineKey& key ) const noexcept { std::size_t h = 0; nvrhi::hash_combine( h, key.state ); nvrhi::hash_combine( h, key.program ); nvrhi::hash_combine( h, key.mirrored ); nvrhi::hash_combine( h, key.framebuffer ); nvrhi::hash_combine( h, key.depthBias ); nvrhi::hash_combine( h, key.slopeBias ); return h; } }; class PipelineCache { public: PipelineCache(); void Init( nvrhi::DeviceHandle deviceHandle ); void Clear(); nvrhi::GraphicsPipelineHandle GetOrCreatePipeline( const PipelineKey& key ); private: nvrhi::DeviceHandle device; idHashIndex pipelineHash; idList> pipelines; }; #endif