mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-22 22:00:39 -06:00
AbstractPipeline: Support returning "cache data"
"Cache data" can be used to assist a driver with creating pipelines by using previously-compiled shader ISA.
This commit is contained in:
@ -75,4 +75,10 @@ class AbstractPipeline
|
||||
public:
|
||||
AbstractPipeline() = default;
|
||||
virtual ~AbstractPipeline() = default;
|
||||
|
||||
// "Cache data" can be used to assist a driver with creating pipelines by using previously
|
||||
// compiled shader ISA. The abstract shaders and creation struct are still required to create
|
||||
// pipeline objects, the cache is optionally used by the driver to speed up compilation.
|
||||
using CacheData = std::vector<u8>;
|
||||
virtual CacheData GetCacheData() const { return {}; }
|
||||
};
|
||||
|
@ -25,9 +25,11 @@ public:
|
||||
virtual ~AbstractShader() = default;
|
||||
|
||||
ShaderStage GetStage() const { return m_stage; }
|
||||
|
||||
// Shader binaries represent the input source code in a lower-level form. e.g. SPIR-V or DXBC.
|
||||
// The shader source code is not required to create a shader object from the binary.
|
||||
using BinaryData = std::vector<u8>;
|
||||
virtual bool HasBinary() const = 0;
|
||||
virtual BinaryData GetBinary() const = 0;
|
||||
virtual BinaryData GetBinary() const { return {}; }
|
||||
|
||||
protected:
|
||||
ShaderStage m_stage;
|
||||
|
@ -130,8 +130,9 @@ public:
|
||||
CreateShaderFromBinary(ShaderStage stage, const void* data, size_t length) = 0;
|
||||
virtual std::unique_ptr<NativeVertexFormat>
|
||||
CreateNativeVertexFormat(const PortableVertexDeclaration& vtx_decl) = 0;
|
||||
virtual std::unique_ptr<AbstractPipeline>
|
||||
CreatePipeline(const AbstractPipelineConfig& config) = 0;
|
||||
virtual std::unique_ptr<AbstractPipeline> CreatePipeline(const AbstractPipelineConfig& config,
|
||||
const void* cache_data = nullptr,
|
||||
size_t cache_data_length = 0) = 0;
|
||||
std::unique_ptr<AbstractShader> CreateShaderFromSource(ShaderStage stage,
|
||||
const std::string& source);
|
||||
|
||||
|
@ -334,7 +334,7 @@ const AbstractShader* ShaderCache::InsertVertexShader(const VertexShaderUid& uid
|
||||
|
||||
if (shader && !entry.shader)
|
||||
{
|
||||
if (g_ActiveConfig.bShaderCache && shader->HasBinary())
|
||||
if (g_ActiveConfig.bShaderCache && g_ActiveConfig.backend_info.bSupportsShaderBinaries)
|
||||
{
|
||||
auto binary = shader->GetBinary();
|
||||
if (!binary.empty())
|
||||
@ -356,7 +356,7 @@ const AbstractShader* ShaderCache::InsertVertexUberShader(const UberShader::Vert
|
||||
|
||||
if (shader && !entry.shader)
|
||||
{
|
||||
if (g_ActiveConfig.bShaderCache && shader->HasBinary())
|
||||
if (g_ActiveConfig.bShaderCache && g_ActiveConfig.backend_info.bSupportsShaderBinaries)
|
||||
{
|
||||
auto binary = shader->GetBinary();
|
||||
if (!binary.empty())
|
||||
@ -378,7 +378,7 @@ const AbstractShader* ShaderCache::InsertPixelShader(const PixelShaderUid& uid,
|
||||
|
||||
if (shader && !entry.shader)
|
||||
{
|
||||
if (g_ActiveConfig.bShaderCache && shader->HasBinary())
|
||||
if (g_ActiveConfig.bShaderCache && g_ActiveConfig.backend_info.bSupportsShaderBinaries)
|
||||
{
|
||||
auto binary = shader->GetBinary();
|
||||
if (!binary.empty())
|
||||
@ -400,7 +400,7 @@ const AbstractShader* ShaderCache::InsertPixelUberShader(const UberShader::Pixel
|
||||
|
||||
if (shader && !entry.shader)
|
||||
{
|
||||
if (g_ActiveConfig.bShaderCache && shader->HasBinary())
|
||||
if (g_ActiveConfig.bShaderCache && g_ActiveConfig.backend_info.bSupportsShaderBinaries)
|
||||
{
|
||||
auto binary = shader->GetBinary();
|
||||
if (!binary.empty())
|
||||
@ -425,7 +425,7 @@ const AbstractShader* ShaderCache::CreateGeometryShader(const GeometryShaderUid&
|
||||
|
||||
if (shader && !entry.shader)
|
||||
{
|
||||
if (g_ActiveConfig.bShaderCache && shader->HasBinary())
|
||||
if (g_ActiveConfig.bShaderCache && g_ActiveConfig.backend_info.bSupportsShaderBinaries)
|
||||
{
|
||||
auto binary = shader->GetBinary();
|
||||
if (!binary.empty())
|
||||
|
@ -219,6 +219,8 @@ struct VideoConfig final
|
||||
bool bSupportsBackgroundCompiling;
|
||||
bool bSupportsLargePoints;
|
||||
bool bSupportsPartialDepthCopies;
|
||||
bool bSupportsShaderBinaries;
|
||||
bool bSupportsPipelineCacheData;
|
||||
} backend_info;
|
||||
|
||||
// Utility
|
||||
|
Reference in New Issue
Block a user