diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp index 4579a8af..e9cdf064 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.cpp @@ -173,8 +173,8 @@ namespace skyline::gpu::interconnect::maxwell3d { return info; } - static std::array MakePipelineShaders(InterconnectContext &ctx, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState) { - ctx.gpu.shader.ResetPools(); + static std::array MakePipelineShaders(GPU &gpu, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState) { + gpu.shader.ResetPools(); using PipelineStage = engine::Pipeline::Shader::Type; auto pipelineStage{[](u32 i) { return static_cast(i); }}; @@ -188,7 +188,7 @@ namespace skyline::gpu::interconnect::maxwell3d { continue; auto binary{accessor.GetShaderBinary(i)}; - auto program{ctx.gpu.shader.ParseGraphicsShader( + auto program{gpu.shader.ParseGraphicsShader( packedState.postVtgShaderAttributeSkipMask, ConvertCompilerShaderStage(static_cast(i)), binary.binary, binary.baseOffset, @@ -202,7 +202,7 @@ namespace skyline::gpu::interconnect::maxwell3d { })}; if (i == stageIdx(PipelineStage::Vertex) && packedState.shaderHashes[stageIdx(PipelineStage::VertexCullBeforeFetch)]) { ignoreVertexCullBeforeFetch = true; - programs[i] = ctx.gpu.shader.CombineVertexShaders(programs[stageIdx(PipelineStage::VertexCullBeforeFetch)], program, binary.binary); + programs[i] = gpu.shader.CombineVertexShaders(programs[stageIdx(PipelineStage::VertexCullBeforeFetch)], program, binary.binary); } else { programs[i] = program; } @@ -219,7 +219,7 @@ namespace skyline::gpu::interconnect::maxwell3d { continue; auto runtimeInfo{MakeRuntimeInfo(packedState, programs[i], lastProgram, hasGeometry)}; - shaderStages[i - (i >= 1 ? 1 : 0)] = {ConvertVkShaderStage(pipelineStage(i)), ctx.gpu.shader.CompileShader(runtimeInfo, programs[i], bindings), programs[i].info}; + shaderStages[i - (i >= 1 ? 1 : 0)] = {ConvertVkShaderStage(pipelineStage(i)), gpu.shader.CompileShader(runtimeInfo, programs[i], bindings), programs[i].info}; lastProgram = &programs[i]; } @@ -422,7 +422,7 @@ namespace skyline::gpu::interconnect::maxwell3d { } } - static cache::GraphicsPipelineCache::CompiledPipeline MakeCompiledPipeline(InterconnectContext &ctx, + static cache::GraphicsPipelineCache::CompiledPipeline MakeCompiledPipeline(GPU &gpu, const PackedPipelineState &packedState, const std::array &shaderStages, span layoutBindings) { @@ -448,10 +448,10 @@ namespace skyline::gpu::interconnect::maxwell3d { }); if (binding.GetInputRate() == vk::VertexInputRate::eInstance) { - if (!ctx.gpu.traits.supportsVertexAttributeDivisor) + if (!gpu.traits.supportsVertexAttributeDivisor) [[unlikely]] Logger::Warn("Vertex attribute divisor used on guest without host support"); - else if (!ctx.gpu.traits.supportsVertexAttributeZeroDivisor && binding.divisor == 0) + else if (!gpu.traits.supportsVertexAttributeZeroDivisor && binding.divisor == 0) [[unlikely]] Logger::Warn("Vertex attribute zero divisor used on guest without host support"); else @@ -507,7 +507,7 @@ namespace skyline::gpu::interconnect::maxwell3d { rasterizationCreateInfo.frontFace = packedState.frontFaceClockwise ? vk::FrontFace::eClockwise : vk::FrontFace::eCounterClockwise; rasterizationCreateInfo.depthBiasEnable = packedState.depthBiasEnable; rasterizationCreateInfo.depthClampEnable = packedState.depthClampEnable; - if (!ctx.gpu.traits.supportsDepthClamp) + if (!gpu.traits.supportsDepthClamp) Logger::Warn("Depth clamp used on guest without host support"); rasterizationState.get().provokingVertexMode = ConvertProvokingVertex(packedState.provokingVertex); @@ -560,7 +560,7 @@ namespace skyline::gpu::interconnect::maxwell3d { }; vk::PipelineDynamicStateCreateInfo dynamicState{ - .dynamicStateCount = ctx.gpu.traits.supportsExtendedDynamicState ? ExtendedDynamicStateCount : BaseDynamicStateCount, + .dynamicStateCount = gpu.traits.supportsExtendedDynamicState ? ExtendedDynamicStateCount : BaseDynamicStateCount, .pDynamicStates = dynamicStates.data() }; @@ -569,15 +569,15 @@ namespace skyline::gpu::interconnect::maxwell3d { std::array emptyViewports{}; vk::PipelineViewportStateCreateInfo viewportState{ - .viewportCount = static_cast(ctx.gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1), + .viewportCount = static_cast(gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1), .pViewports = emptyViewports.data(), - .scissorCount = static_cast(ctx.gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1), + .scissorCount = static_cast(gpu.traits.supportsMultipleViewports ? engine::ViewportCount : 1), .pScissors = emptyScissors.data(), }; texture::Format depthStencilFormat{packedState.GetDepthRenderTargetFormat()}; - return ctx.gpu.graphicsPipelineCache.GetCompiledPipeline(cache::GraphicsPipelineCache::PipelineState{ + return gpu.graphicsPipelineCache.GetCompiledPipeline(cache::GraphicsPipelineCache::PipelineState{ .shaderStages = shaderStageInfos, .vertexState = vertexInputState, .inputAssemblyState = inputAssemblyState, @@ -594,20 +594,21 @@ namespace skyline::gpu::interconnect::maxwell3d { }, layoutBindings); } - Pipeline::Pipeline(InterconnectContext &ctx, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState) + Pipeline::Pipeline(GPU &gpu, PipelineStateAccessor &accessor, const PackedPipelineState &packedState) : sourcePackedState{packedState}, - shaderStages{MakePipelineShaders(ctx, accessor, sourcePackedState)}, - descriptorInfo{MakePipelineDescriptorInfo(shaderStages, ctx.gpu.traits.quirks.needsIndividualTextureBindingWrites)}, - compiledPipeline{MakeCompiledPipeline(ctx, sourcePackedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings)} { + shaderStages{MakePipelineShaders(gpu, accessor, sourcePackedState)}, + descriptorInfo{MakePipelineDescriptorInfo(shaderStages, gpu.traits.quirks.needsIndividualTextureBindingWrites)}, + compiledPipeline{MakeCompiledPipeline(gpu, sourcePackedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings)} { storageBufferViews.resize(descriptorInfo.totalStorageBufferCount); + accessor.MarkComplete(); } - void Pipeline::SyncCachedStorageBufferViews(u32 executionNumber) { - if (lastExecutionNumber != executionNumber) { + void Pipeline::SyncCachedStorageBufferViews(ContextTag executionTag) { + if (lastExecutionTag != executionTag) { for (auto &view : storageBufferViews) view.PurgeCaches(); - lastExecutionNumber = executionNumber; + lastExecutionTag = executionTag; } } diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h index 559f66e4..5727bdfc 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_manager.h @@ -8,10 +8,10 @@ #include #include #include +#include #include "common.h" #include "packed_pipeline_state.h" #include "constant_buffers.h" -#include "graphics_pipeline_state_accessor.h" namespace skyline::gpu { class TextureView; @@ -95,13 +95,13 @@ namespace skyline::gpu::interconnect::maxwell3d { tsl::robin_map bindingMatchCache; //!< Cache of which pipelines have bindings that match this pipeline - void SyncCachedStorageBufferViews(u32 executionNumber); + void SyncCachedStorageBufferViews(ContextTag executionTag); public: cache::GraphicsPipelineCache::CompiledPipeline compiledPipeline; size_t sampledImageCount{}; - Pipeline(InterconnectContext &ctx, const PipelineStateAccessor &accessor, const PackedPipelineState &packedState); + Pipeline(GPU &gpu, PipelineStateAccessor &accessor, const PackedPipelineState &packedState); Pipeline *LookupNext(const PackedPipelineState &packedState);