From 4cebdfc8d3e8be9e5ad450b6e96b883fc8bfead3 Mon Sep 17 00:00:00 2001 From: Billy Laws Date: Sun, 9 Oct 2022 14:01:48 +0100 Subject: [PATCH] Pass texture and cbuf state into pipeline manager for hades callbacks --- .../skyline/gpu/interconnect/maxwell_3d/active_state.cpp | 5 ++--- .../skyline/gpu/interconnect/maxwell_3d/active_state.h | 2 +- .../skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp | 4 ++-- .../gpu/interconnect/maxwell_3d/pipeline_manager.cpp | 6 +++--- .../gpu/interconnect/maxwell_3d/pipeline_manager.h | 8 ++++---- .../gpu/interconnect/maxwell_3d/pipeline_state.cpp | 6 +++--- .../skyline/gpu/interconnect/maxwell_3d/pipeline_state.h | 2 +- 7 files changed, 16 insertions(+), 17 deletions(-) diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp index cac6dce4..aeb02618 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.cpp @@ -386,7 +386,7 @@ namespace skyline::gpu::interconnect::maxwell3d { dirtyFunc(stencilValues); } - void ActiveState::Update(InterconnectContext &ctx, StateUpdateBuilder &builder, bool indexed, engine::DrawTopology topology, u32 drawElementCount) { + void ActiveState::Update(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, StateUpdateBuilder &builder, bool indexed, engine::DrawTopology topology, u32 drawElementCount) { if (topology != directState.inputAssembly.GetPrimitiveTopology()) { directState.inputAssembly.SetPrimitiveTopology(topology); pipeline.MarkDirty(false); @@ -394,7 +394,7 @@ namespace skyline::gpu::interconnect::maxwell3d { // TODO non-indexed quads auto updateFunc{[&](auto &stateElem, auto &&... args) { stateElem.Update(ctx, builder, args...); }}; - updateFunc(pipeline); + pipeline.Update(ctx, textures, constantBuffers, builder); ranges::for_each(vertexBuffers, updateFunc); if (indexed) updateFunc(indexBuffer, directState.inputAssembly.NeedsQuadConversion(), drawElementCount); @@ -412,7 +412,6 @@ namespace skyline::gpu::interconnect::maxwell3d { return pipeline.Get().pipeline; } - span ActiveState::GetColorAttachments() { return pipeline.Get().colorAttachments; } diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.h index 5dc9068c..f622e725 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/active_state.h @@ -256,7 +256,7 @@ namespace skyline::gpu::interconnect::maxwell3d { /** * @brief Updates the active state for a given draw operation, removing the dirtiness of all member states */ - void Update(InterconnectContext &ctx, StateUpdateBuilder &builder, bool indexed, engine::DrawTopology topology, u32 drawElementCount); + void Update(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, StateUpdateBuilder &builder, bool indexed, engine::DrawTopology topology, u32 drawElementCount); Pipeline *GetPipeline(); diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp index 5c2b17eb..723e25a2 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/maxwell_3d.cpp @@ -202,11 +202,11 @@ namespace skyline::gpu::interconnect::maxwell3d { }, renderArea, {}, colorView ? colorAttachments : span{}, depthStencilView ? &*depthStencilView : nullptr); } - void Maxwell3D::Draw(engine::DrawTopology topology, bool indexed, u32 count, u32 first, u32 instanceCount, u32 vertexOffset, u32 firstInstance) { + void Maxwell3D::Draw(engine::DrawTopology topology, bool transformFeedbackEnable, bool indexed, u32 count, u32 first, u32 instanceCount, u32 vertexOffset, u32 firstInstance) { StateUpdateBuilder builder{*ctx.executor.allocator}; Pipeline *oldPipeline{activeState.GetPipeline()}; - activeState.Update(ctx, builder, indexed, topology, count); + activeState.Update(ctx, textures, constantBuffers.boundConstantBuffers, builder, indexed, topology, count); if (directState.inputAssembly.NeedsQuadConversion()) { count = conversion::quads::GetIndexCount(count); first = 0; 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 799038fb..03db8941 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 @@ -170,7 +170,7 @@ namespace skyline::gpu::interconnect::maxwell3d { return info; } - static std::array MakePipelineShaders(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array &shaderBinaries) { + static std::array MakePipelineShaders(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array &shaderBinaries) { ctx.gpu.shader.ResetPools(); using PipelineStage = engine::Pipeline::Shader::Type; @@ -564,8 +564,8 @@ namespace skyline::gpu::interconnect::maxwell3d { }, layoutBindings); } - Pipeline::Pipeline(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array &shaderBinaries, span colorAttachments, TextureView *depthAttachment) - : shaderStages{MakePipelineShaders(ctx, packedState, shaderBinaries)}, + Pipeline::Pipeline(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array &shaderBinaries, span colorAttachments, TextureView *depthAttachment) + : shaderStages{MakePipelineShaders(ctx, textures, constantBuffers, packedState, shaderBinaries)}, descriptorInfo{MakePipelineDescriptorInfo(shaderStages, ctx.gpu.traits.quirks.needsIndividualTextureBindingWrites)}, compiledPipeline{MakeCompiledPipeline(ctx, packedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings, colorAttachments, depthAttachment)}, sourcePackedState{packedState} { 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 44467437..c1320abf 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 @@ -103,7 +103,7 @@ namespace skyline::gpu::interconnect::maxwell3d { PackedPipelineState sourcePackedState; - Pipeline(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array &shaderBinaries, span colorAttachments, TextureView *depthAttachment); + Pipeline(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array &shaderBinaries, span colorAttachments, TextureView *depthAttachment); Pipeline *LookupNext(const PackedPipelineState &packedState); @@ -118,15 +118,15 @@ namespace skyline::gpu::interconnect::maxwell3d { class PipelineManager { private: - tsl::robin_map, util::ObjectHash> map; + tsl::robin_map, PackedPipelineStateHash> map; public: - Pipeline *FindOrCreate(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array &shaderBinaries, span colorAttachments, TextureView *depthAttachment) { + Pipeline *FindOrCreate(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array &shaderBinaries, span colorAttachments, TextureView *depthAttachment) { auto it{map.find(packedState)}; if (it != map.end()) return it->second.get(); - return map.emplace(packedState, std::make_unique(ctx, packedState, shaderBinaries, colorAttachments, depthAttachment)).first->second.get(); + return map.emplace(packedState, std::make_unique(ctx, textures, constantBuffers, packedState, shaderBinaries, colorAttachments, depthAttachment)).first->second.get(); } }; } diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp index 2419cf55..4df38e1e 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.cpp @@ -544,7 +544,7 @@ namespace skyline::gpu::interconnect::maxwell3d { globalShaderConfig{engine.globalShaderConfigRegisters}, ctSelect{engine.ctSelect} {} - void PipelineState::Flush(InterconnectContext &ctx, StateUpdateBuilder &builder) { + void PipelineState::Flush(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, StateUpdateBuilder &builder) { std::array shaderBinaries; for (size_t i{}; i < engine::PipelineCount; i++) { const auto &stage{pipelineStages[i].UpdateGet(ctx)}; @@ -581,9 +581,9 @@ namespace skyline::gpu::interconnect::maxwell3d { pipeline = newPipeline; return; } - } + } - auto newPipeline{pipelineManager.FindOrCreate(ctx, packedState, shaderBinaries, colorAttachments, depthAttachment)}; + auto newPipeline{pipelineManager.FindOrCreate(ctx, textures, constantBuffers, packedState, shaderBinaries, colorAttachments, depthAttachment)}; if (pipeline) pipeline->AddTransition(newPipeline); pipeline = newPipeline; diff --git a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h index 7f33262b..d239f8d9 100644 --- a/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h +++ b/app/src/main/cpp/skyline/gpu/interconnect/maxwell_3d/pipeline_state.h @@ -343,7 +343,7 @@ namespace skyline::gpu::interconnect::maxwell3d { PipelineState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine); - void Flush(InterconnectContext &ctx, StateUpdateBuilder &builder); + void Flush(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, StateUpdateBuilder &builder); void PurgeCaches();