[dxvk] Track pipeline library compile for each shader

This commit is contained in:
Philip Rebohle 2022-08-11 02:05:52 +02:00
parent b5b74116fa
commit f09f11aad0
No known key found for this signature in database
GPG Key ID: C8CC613427A31C99
2 changed files with 33 additions and 3 deletions

View File

@ -152,6 +152,10 @@ namespace dxvk {
if (info.bindingOffset)
m_bindingOffsets.push_back(info);
}
// Don't set pipeline library flag if the shader
// doesn't actually support pipeline libraries
m_needsLibraryCompile = canUsePipelineLibrary();
}
@ -879,7 +883,7 @@ namespace dxvk {
DxvkShaderPipelineLibrary::DxvkShaderPipelineLibrary(
const DxvkDevice* device,
DxvkPipelineManager* manager,
const DxvkShader* shader,
DxvkShader* shader,
const DxvkBindingLayoutObjects* layout)
: m_device (device),
m_stats (&manager->m_stats),
@ -981,6 +985,9 @@ namespace dxvk {
VkShaderStageFlagBits stage = getShaderStage();
VkPipeline pipeline = VK_NULL_HANDLE;
if (m_shader)
m_shader->notifyLibraryCompile();
// If this is not the first time we're compiling the pipeline,
// try to get a cache hit using the shader module identifier
// so that we don't have to decompress our SPIR-V shader again.

View File

@ -127,6 +127,28 @@ namespace dxvk {
return m_specConstantMask;
}
/**
* \brief Tests whether this shader needs to be compiled
*
* If pipeline libraries are supported, this will return
* \c false once the pipeline library is being compiled.
* \returns \c true if compilation is still needed
*/
bool needsLibraryCompile() const {
return m_needsLibraryCompile.load();
}
/**
* \brief Notifies library compile
*
* Called automatically when pipeline compilation begins.
* Subsequent calls to \ref needsLibraryCompile will return
* \c false.
*/
void notifyLibraryCompile() {
m_needsLibraryCompile.store(false);
}
/**
* \brief Patches code using given info
*
@ -225,6 +247,7 @@ namespace dxvk {
size_t m_o1LocOffset = 0;
uint32_t m_specConstantMask = 0;
std::atomic<bool> m_needsLibraryCompile = { true };
std::vector<char> m_uniformData;
std::vector<BindingOffsets> m_bindingOffsets;
@ -380,7 +403,7 @@ namespace dxvk {
DxvkShaderPipelineLibrary(
const DxvkDevice* device,
DxvkPipelineManager* manager,
const DxvkShader* shader,
DxvkShader* shader,
const DxvkBindingLayoutObjects* layout);
~DxvkShaderPipelineLibrary();
@ -429,7 +452,7 @@ namespace dxvk {
const DxvkDevice* m_device;
DxvkPipelineStats* m_stats;
const DxvkShader* m_shader;
DxvkShader* m_shader;
const DxvkBindingLayoutObjects* m_layout;
dxvk::mutex m_mutex;