mirror of
https://github.com/doitsujin/dxvk.git
synced 2024-12-13 07:08:50 +01:00
[dxvk] Compile pipeline libraries in registerShader if supported
This commit is contained in:
parent
a49333cd87
commit
5019ce4b9c
@ -268,6 +268,11 @@ namespace dxvk {
|
|||||||
|
|
||||||
void DxvkPipelineManager::registerShader(
|
void DxvkPipelineManager::registerShader(
|
||||||
const Rc<DxvkShader>& shader) {
|
const Rc<DxvkShader>& shader) {
|
||||||
|
if (m_device->canUseGraphicsPipelineLibrary() && shader->canUsePipelineLibrary()) {
|
||||||
|
auto library = createPipelineLibrary(shader);
|
||||||
|
m_workers.compilePipelineLibrary(library);
|
||||||
|
}
|
||||||
|
|
||||||
m_stateCache.registerShader(shader);
|
m_stateCache.registerShader(shader);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -321,4 +326,20 @@ namespace dxvk {
|
|||||||
return &iter.first->second;
|
return &iter.first->second;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
DxvkShaderPipelineLibrary* DxvkPipelineManager::createPipelineLibrary(
|
||||||
|
const Rc<DxvkShader>& shader) {
|
||||||
|
std::lock_guard<dxvk::mutex> lock(m_mutex);
|
||||||
|
auto layout = createPipelineLayout(shader->getBindings());
|
||||||
|
|
||||||
|
DxvkShaderPipelineLibraryKey key;
|
||||||
|
key.shader = shader;
|
||||||
|
|
||||||
|
auto iter = m_shaderLibraries.emplace(
|
||||||
|
std::piecewise_construct,
|
||||||
|
std::tuple(key),
|
||||||
|
std::tuple(m_device, shader.ptr(), layout));
|
||||||
|
return &iter.first->second;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -257,12 +257,20 @@ namespace dxvk {
|
|||||||
DxvkGraphicsPipelineFragmentOutputLibrary,
|
DxvkGraphicsPipelineFragmentOutputLibrary,
|
||||||
DxvkHash, DxvkEq> m_fragmentOutputLibraries;
|
DxvkHash, DxvkEq> m_fragmentOutputLibraries;
|
||||||
|
|
||||||
|
std::unordered_map<
|
||||||
|
DxvkShaderPipelineLibraryKey,
|
||||||
|
DxvkShaderPipelineLibrary,
|
||||||
|
DxvkHash, DxvkEq> m_shaderLibraries;
|
||||||
|
|
||||||
DxvkBindingSetLayout* createDescriptorSetLayout(
|
DxvkBindingSetLayout* createDescriptorSetLayout(
|
||||||
const DxvkBindingSetLayoutKey& key);
|
const DxvkBindingSetLayoutKey& key);
|
||||||
|
|
||||||
DxvkBindingLayoutObjects* createPipelineLayout(
|
DxvkBindingLayoutObjects* createPipelineLayout(
|
||||||
const DxvkBindingLayout& layout);
|
const DxvkBindingLayout& layout);
|
||||||
|
|
||||||
|
DxvkShaderPipelineLibrary* createPipelineLibrary(
|
||||||
|
const Rc<DxvkShader>& shader);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
@ -202,6 +202,20 @@ namespace dxvk {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool DxvkShader::canUsePipelineLibrary() const {
|
||||||
|
// Pipeline libraries are unsupported for geometry and
|
||||||
|
// tessellation stages since we'd need to compile them
|
||||||
|
// all into one library
|
||||||
|
if (m_info.stage != VK_SHADER_STAGE_VERTEX_BIT
|
||||||
|
&& m_info.stage != VK_SHADER_STAGE_FRAGMENT_BIT
|
||||||
|
&& m_info.stage != VK_SHADER_STAGE_COMPUTE_BIT)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Ignore shaders that have user-defined spec constants
|
||||||
|
return !m_flags.test(DxvkShaderFlag::HasSpecConstants);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void DxvkShader::dump(std::ostream& outputStream) const {
|
void DxvkShader::dump(std::ostream& outputStream) const {
|
||||||
m_code.decompress().store(outputStream);
|
m_code.decompress().store(outputStream);
|
||||||
}
|
}
|
||||||
|
@ -150,6 +150,15 @@ namespace dxvk {
|
|||||||
const DxvkBindingLayoutObjects* layout,
|
const DxvkBindingLayoutObjects* layout,
|
||||||
const DxvkShaderModuleCreateInfo& info);
|
const DxvkShaderModuleCreateInfo& info);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Tests whether this shader supports pipeline libraries
|
||||||
|
*
|
||||||
|
* This is true for any vertex, fragment, or compute shader that does not
|
||||||
|
* require additional pipeline state to be compiled into something useful.
|
||||||
|
* \returns \c true if this shader can be used with pipeline libraries
|
||||||
|
*/
|
||||||
|
bool canUsePipelineLibrary() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Dumps SPIR-V shader
|
* \brief Dumps SPIR-V shader
|
||||||
*
|
*
|
||||||
@ -305,6 +314,22 @@ namespace dxvk {
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* \brief Shader pipeline library key
|
||||||
|
*/
|
||||||
|
struct DxvkShaderPipelineLibraryKey {
|
||||||
|
Rc<DxvkShader> shader;
|
||||||
|
|
||||||
|
bool eq(const DxvkShaderPipelineLibraryKey& other) const {
|
||||||
|
return shader == other.shader;
|
||||||
|
}
|
||||||
|
|
||||||
|
size_t hash() const {
|
||||||
|
return DxvkShader::getHash(shader);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Shader pipeline library
|
* \brief Shader pipeline library
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user