mirror of
https://github.com/rt64/rt64.git
synced 2024-12-26 03:15:44 +00:00
Pipeline strategy (#72)
* Attempt to aid the driver when creating ubershader pipelines. * Second attempt. * Missing include. * Change the index in the condition.
This commit is contained in:
parent
b91d6a7441
commit
8e8588df56
@ -531,9 +531,28 @@ namespace RT64 {
|
||||
}
|
||||
|
||||
void RasterShaderUber::threadCreatePipelines(uint32_t threadIndex) {
|
||||
// Delay the creation of all other pipelines until the first pipeline is created. This can help the
|
||||
// driver reuse its shader cache between pipelines and achieve a much lower creation time than if
|
||||
// all threads started at the same time.
|
||||
if (threadIndex > 0) {
|
||||
std::unique_lock<std::mutex> lock(firstPipelineMutex);
|
||||
firstPipelineCondition.wait(lock, [this]() {
|
||||
return (pipelines[0] != nullptr);
|
||||
});
|
||||
}
|
||||
|
||||
for (const PipelineCreation &creation : pipelineThreadCreations[threadIndex]) {
|
||||
uint32_t pipelineIndex = pipelineStateIndex(creation.zCmp, creation.zUpd, creation.cvgAdd);
|
||||
pipelines[pipelineIndex] = RasterShader::createPipeline(creation);
|
||||
|
||||
if (pipelineIndex == 0) {
|
||||
firstPipelineMutex.lock();
|
||||
pipelines[pipelineIndex] = RasterShader::createPipeline(creation);
|
||||
firstPipelineMutex.unlock();
|
||||
firstPipelineCondition.notify_all();
|
||||
}
|
||||
else {
|
||||
pipelines[pipelineIndex] = RasterShader::createPipeline(creation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6,6 +6,7 @@
|
||||
|
||||
#include "rt64_shader_common.h"
|
||||
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
|
||||
@ -78,7 +79,8 @@ namespace RT64 {
|
||||
std::unique_ptr<RenderPipeline> pipelines[8];
|
||||
std::unique_ptr<RenderPipeline> postBlendDitherNoiseAddPipeline;
|
||||
std::unique_ptr<RenderPipeline> postBlendDitherNoiseSubPipeline;
|
||||
std::mutex pipelinesMutex;
|
||||
std::mutex firstPipelineMutex;
|
||||
std::condition_variable firstPipelineCondition;
|
||||
bool pipelinesCreated = false;
|
||||
std::unique_ptr<RenderPipelineLayout> pipelineLayout;
|
||||
std::vector<std::vector<PipelineCreation>> pipelineThreadCreations;
|
||||
@ -88,6 +90,7 @@ namespace RT64 {
|
||||
|
||||
RasterShaderUber(RenderDevice *device, RenderShaderFormat shaderFormat, const RenderMultisampling &multisampling, const ShaderLibrary *shaderLibrary, uint32_t threadCount);
|
||||
~RasterShaderUber();
|
||||
void threadCreatePipeline(const PipelineCreation &creation);
|
||||
void threadCreatePipelines(uint32_t threadIndex);
|
||||
void waitForPipelineCreation();
|
||||
uint32_t pipelineStateIndex(bool zCmp, bool zUpd, bool cvgAdd) const;
|
||||
|
Loading…
Reference in New Issue
Block a user