mirror of
https://github.com/skyline-emu/skyline.git
synced 2024-12-23 16:01:52 +01:00
Populate graphics pipeline manager from cache at launch-time
This commit is contained in:
parent
e9bcdd06eb
commit
4a3cd69257
@ -849,5 +849,37 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
.descriptorSetIndex = 0,
|
.descriptorSetIndex = 0,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PipelineManager::PipelineManager(GPU &gpu) {
|
||||||
|
std::ifstream stream{gpu.graphicsPipelineCacheManager->OpenReadStream()};
|
||||||
|
i64 lastKnownGoodOffset{stream.tellg()};
|
||||||
|
try {
|
||||||
|
auto startTime{util::GetTimeNs()};
|
||||||
|
PipelineStateBundle bundle;
|
||||||
|
|
||||||
|
while (bundle.Deserialise(stream)) {
|
||||||
|
lastKnownGoodOffset = stream.tellg();
|
||||||
|
auto accessor{FilePipelineStateAccessor{bundle}};
|
||||||
|
map.emplace(bundle.GetKey<PackedPipelineState>(), std::make_unique<Pipeline>(gpu, accessor, bundle.GetKey<PackedPipelineState>()));
|
||||||
|
}
|
||||||
|
|
||||||
|
Logger::Info("Loaded {} graphics pipelines in {}ms", map.size(), (util::GetTimeNs() - startTime) / constant::NsInMillisecond);
|
||||||
|
} catch (const exception &e) {
|
||||||
|
Logger::Warn("Pipeline cache corrupted at: 0x{:X}, error: {}", lastKnownGoodOffset, e.what());
|
||||||
|
gpu.graphicsPipelineCacheManager->InvalidateAllAfter(static_cast<u64>(lastKnownGoodOffset));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Pipeline *PipelineManager::FindOrCreate(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries) {
|
||||||
|
auto it{map.find(packedState)};
|
||||||
|
if (it != map.end())
|
||||||
|
return it->second.get();
|
||||||
|
|
||||||
|
auto bundle{std::make_unique<PipelineStateBundle>()};
|
||||||
|
bundle->Reset(packedState);
|
||||||
|
auto accessor{RuntimeGraphicsPipelineStateAccessor{std::move(bundle), ctx, textures, constantBuffers, shaderBinaries}};
|
||||||
|
return map.emplace(packedState, std::make_unique<Pipeline>(ctx.gpu, accessor, packedState)).first->second.get();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,18 +129,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
|
|||||||
*/
|
*/
|
||||||
class PipelineManager {
|
class PipelineManager {
|
||||||
private:
|
private:
|
||||||
PipelineStateBundle bundle;
|
|
||||||
tsl::robin_map<PackedPipelineState, std::unique_ptr<Pipeline>, PackedPipelineStateHash> map;
|
tsl::robin_map<PackedPipelineState, std::unique_ptr<Pipeline>, PackedPipelineStateHash> map;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Pipeline *FindOrCreate(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries) {
|
PipelineManager(GPU &gpu);
|
||||||
auto it{map.find(packedState)};
|
|
||||||
if (it != map.end())
|
|
||||||
return it->second.get();
|
|
||||||
|
|
||||||
bundle.Reset(packedState);
|
Pipeline *FindOrCreate(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries);
|
||||||
auto accessor{RuntimeGraphicsPipelineStateAccessor{bundle, ctx, textures, constantBuffers, shaderBinaries}};
|
|
||||||
return map.emplace(packedState, std::make_unique<Pipeline>(ctx, accessor, packedState)).first->second.get();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user