gl_shader_cache: Fixes for async shaders

This commit is contained in:
ameerj 2021-07-01 20:32:30 -04:00
parent 57171b23f9
commit dbee32d302
2 changed files with 26 additions and 3 deletions

View File

@ -328,11 +328,32 @@ GraphicsPipeline* ShaderCache::CurrentGraphicsPipelineSlowPath() {
if (is_new) { if (is_new) {
pipeline = CreateGraphicsPipeline(); pipeline = CreateGraphicsPipeline();
} }
current_pipeline = pipeline.get(); if (!pipeline) {
if (!pipeline || !pipeline->IsBuilt()) {
return nullptr; return nullptr;
} }
return pipeline.get(); current_pipeline = pipeline.get();
return BuiltPipeline(current_pipeline);
}
GraphicsPipeline* ShaderCache::BuiltPipeline(GraphicsPipeline* pipeline) const noexcept {
if (pipeline->IsBuilt()) {
return pipeline;
}
if (!use_asynchronous_shaders) {
return pipeline;
}
// If something is using depth, we can assume that games are not rendering anything which
// will be used one time.
if (maxwell3d.regs.zeta_enable) {
return nullptr;
}
// If games are using a small index count, we can assume these are full screen quads.
// Usually these shaders are only used once for building textures so we can assume they
// can't be built async
if (maxwell3d.regs.index_array.count <= 6 || maxwell3d.regs.vertex_buffer.count <= 6) {
return pipeline;
}
return nullptr;
} }
ComputePipeline* ShaderCache::CurrentComputePipeline() { ComputePipeline* ShaderCache::CurrentComputePipeline() {

View File

@ -54,6 +54,8 @@ public:
private: private:
GraphicsPipeline* CurrentGraphicsPipelineSlowPath(); GraphicsPipeline* CurrentGraphicsPipelineSlowPath();
[[nodiscard]] GraphicsPipeline* BuiltPipeline(GraphicsPipeline* pipeline) const noexcept;
std::unique_ptr<GraphicsPipeline> CreateGraphicsPipeline(); std::unique_ptr<GraphicsPipeline> CreateGraphicsPipeline();
std::unique_ptr<GraphicsPipeline> CreateGraphicsPipeline( std::unique_ptr<GraphicsPipeline> CreateGraphicsPipeline(