Implement VkPipelineCache for host pipeline caching

To allow for caching of pipelines on the host a `VkPipelineCache` has been added, it is entirely in-memory and is not flushed to the disk which'll be done in the future alongside caching guest shaders to further avoid translation where possible.
This commit is contained in:
PixelyIon 2021-12-07 03:20:50 +05:30
parent 4dcf12c4c0
commit 7a63ad7d3d

View File

@ -44,7 +44,7 @@ namespace skyline::gpu::interconnect {
static_assert(sizeof(IOVA) == sizeof(u64)); static_assert(sizeof(IOVA) == sizeof(u64));
public: public:
GraphicsContext(GPU &gpu, soc::gm20b::ChannelContext &channelCtx, gpu::interconnect::CommandExecutor &executor) : gpu(gpu), channelCtx(channelCtx), executor(executor) { GraphicsContext(GPU &gpu, soc::gm20b::ChannelContext &channelCtx, gpu::interconnect::CommandExecutor &executor) : gpu(gpu), channelCtx(channelCtx), executor(executor), pipelineCache(gpu.vkDevice, vk::PipelineCacheCreateInfo{}) {
scissors.fill(DefaultScissor); scissors.fill(DefaultScissor);
if (!gpu.quirks.supportsMultipleViewports) { if (!gpu.quirks.supportsMultipleViewports) {
viewportState.viewportCount = 1; viewportState.viewportCount = 1;
@ -1126,6 +1126,7 @@ namespace skyline::gpu::interconnect {
.pColorBlendState = &blendState, .pColorBlendState = &blendState,
.pDynamicState = nullptr, .pDynamicState = nullptr,
}; };
vk::raii::PipelineCache pipelineCache;
public: public:
void Draw(u32 vertexCount, u32 firstVertex) { void Draw(u32 vertexCount, u32 firstVertex) {
@ -1191,7 +1192,7 @@ namespace skyline::gpu::interconnect {
pipelineCreateInfo.renderPass = renderPass; pipelineCreateInfo.renderPass = renderPass;
pipelineCreateInfo.subpass = subpassIndex; pipelineCreateInfo.subpass = subpassIndex;
auto pipeline{(*vkDevice).createGraphicsPipeline(nullptr, pipelineCreateInfo, nullptr, *vkDevice.getDispatcher())}; auto pipeline{(*vkDevice).createGraphicsPipeline(pipelineCache, pipelineCreateInfo, nullptr, *vkDevice.getDispatcher())};
if (pipeline.result != vk::Result::eSuccess) if (pipeline.result != vk::Result::eSuccess)
vk::throwResultException(pipeline.result, __builtin_FUNCTION()); vk::throwResultException(pipeline.result, __builtin_FUNCTION());