Pass texture and cbuf state into pipeline manager for hades callbacks

This commit is contained in:
Billy Laws 2022-10-09 14:01:48 +01:00
parent 9ce848d4e0
commit 4cebdfc8d3
7 changed files with 16 additions and 17 deletions

View File

@ -386,7 +386,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
dirtyFunc(stencilValues); 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()) { if (topology != directState.inputAssembly.GetPrimitiveTopology()) {
directState.inputAssembly.SetPrimitiveTopology(topology); directState.inputAssembly.SetPrimitiveTopology(topology);
pipeline.MarkDirty(false); pipeline.MarkDirty(false);
@ -394,7 +394,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
// TODO non-indexed quads // TODO non-indexed quads
auto updateFunc{[&](auto &stateElem, auto &&... args) { stateElem.Update(ctx, builder, args...); }}; auto updateFunc{[&](auto &stateElem, auto &&... args) { stateElem.Update(ctx, builder, args...); }};
updateFunc(pipeline); pipeline.Update(ctx, textures, constantBuffers, builder);
ranges::for_each(vertexBuffers, updateFunc); ranges::for_each(vertexBuffers, updateFunc);
if (indexed) if (indexed)
updateFunc(indexBuffer, directState.inputAssembly.NeedsQuadConversion(), drawElementCount); updateFunc(indexBuffer, directState.inputAssembly.NeedsQuadConversion(), drawElementCount);
@ -412,7 +412,6 @@ namespace skyline::gpu::interconnect::maxwell3d {
return pipeline.Get().pipeline; return pipeline.Get().pipeline;
} }
span<TextureView *> ActiveState::GetColorAttachments() { span<TextureView *> ActiveState::GetColorAttachments() {
return pipeline.Get().colorAttachments; return pipeline.Get().colorAttachments;
} }

View File

@ -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 * @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(); Pipeline *GetPipeline();

View File

@ -202,11 +202,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
}, renderArea, {}, colorView ? colorAttachments : span<TextureView *>{}, depthStencilView ? &*depthStencilView : nullptr); }, renderArea, {}, colorView ? colorAttachments : span<TextureView *>{}, 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}; StateUpdateBuilder builder{*ctx.executor.allocator};
Pipeline *oldPipeline{activeState.GetPipeline()}; 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()) { if (directState.inputAssembly.NeedsQuadConversion()) {
count = conversion::quads::GetIndexCount(count); count = conversion::quads::GetIndexCount(count);
first = 0; first = 0;

View File

@ -170,7 +170,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
return info; return info;
} }
static std::array<Pipeline::ShaderStage, engine::ShaderStageCount> MakePipelineShaders(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries) { static std::array<Pipeline::ShaderStage, engine::ShaderStageCount> MakePipelineShaders(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries) {
ctx.gpu.shader.ResetPools(); ctx.gpu.shader.ResetPools();
using PipelineStage = engine::Pipeline::Shader::Type; using PipelineStage = engine::Pipeline::Shader::Type;
@ -564,8 +564,8 @@ namespace skyline::gpu::interconnect::maxwell3d {
}, layoutBindings); }, layoutBindings);
} }
Pipeline::Pipeline(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries, span<TextureView *> colorAttachments, TextureView *depthAttachment) Pipeline::Pipeline(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries, span<TextureView *> colorAttachments, TextureView *depthAttachment)
: shaderStages{MakePipelineShaders(ctx, packedState, shaderBinaries)}, : shaderStages{MakePipelineShaders(ctx, textures, constantBuffers, packedState, shaderBinaries)},
descriptorInfo{MakePipelineDescriptorInfo(shaderStages, ctx.gpu.traits.quirks.needsIndividualTextureBindingWrites)}, descriptorInfo{MakePipelineDescriptorInfo(shaderStages, ctx.gpu.traits.quirks.needsIndividualTextureBindingWrites)},
compiledPipeline{MakeCompiledPipeline(ctx, packedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings, colorAttachments, depthAttachment)}, compiledPipeline{MakeCompiledPipeline(ctx, packedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings, colorAttachments, depthAttachment)},
sourcePackedState{packedState} { sourcePackedState{packedState} {

View File

@ -103,7 +103,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
PackedPipelineState sourcePackedState; PackedPipelineState sourcePackedState;
Pipeline(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries, span<TextureView *> colorAttachments, TextureView *depthAttachment); Pipeline(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries, span<TextureView *> colorAttachments, TextureView *depthAttachment);
Pipeline *LookupNext(const PackedPipelineState &packedState); Pipeline *LookupNext(const PackedPipelineState &packedState);
@ -118,15 +118,15 @@ namespace skyline::gpu::interconnect::maxwell3d {
class PipelineManager { class PipelineManager {
private: private:
tsl::robin_map<PackedPipelineState, std::unique_ptr<Pipeline>, util::ObjectHash<PackedPipelineState>> map; tsl::robin_map<PackedPipelineState, std::unique_ptr<Pipeline>, PackedPipelineStateHash> map;
public: public:
Pipeline *FindOrCreate(InterconnectContext &ctx, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries, span<TextureView *> colorAttachments, TextureView *depthAttachment) { Pipeline *FindOrCreate(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, const PackedPipelineState &packedState, const std::array<ShaderBinary, engine::PipelineCount> &shaderBinaries, span<TextureView *> colorAttachments, TextureView *depthAttachment) {
auto it{map.find(packedState)}; auto it{map.find(packedState)};
if (it != map.end()) if (it != map.end())
return it->second.get(); return it->second.get();
return map.emplace(packedState, std::make_unique<Pipeline>(ctx, packedState, shaderBinaries, colorAttachments, depthAttachment)).first->second.get(); return map.emplace(packedState, std::make_unique<Pipeline>(ctx, textures, constantBuffers, packedState, shaderBinaries, colorAttachments, depthAttachment)).first->second.get();
} }
}; };
} }

View File

@ -544,7 +544,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
globalShaderConfig{engine.globalShaderConfigRegisters}, globalShaderConfig{engine.globalShaderConfigRegisters},
ctSelect{engine.ctSelect} {} ctSelect{engine.ctSelect} {}
void PipelineState::Flush(InterconnectContext &ctx, StateUpdateBuilder &builder) { void PipelineState::Flush(InterconnectContext &ctx, Textures &textures, ConstantBufferSet &constantBuffers, StateUpdateBuilder &builder) {
std::array<ShaderBinary, engine::PipelineCount> shaderBinaries; std::array<ShaderBinary, engine::PipelineCount> shaderBinaries;
for (size_t i{}; i < engine::PipelineCount; i++) { for (size_t i{}; i < engine::PipelineCount; i++) {
const auto &stage{pipelineStages[i].UpdateGet(ctx)}; const auto &stage{pipelineStages[i].UpdateGet(ctx)};
@ -581,9 +581,9 @@ namespace skyline::gpu::interconnect::maxwell3d {
pipeline = newPipeline; pipeline = newPipeline;
return; return;
} }
} }
auto newPipeline{pipelineManager.FindOrCreate(ctx, packedState, shaderBinaries, colorAttachments, depthAttachment)}; auto newPipeline{pipelineManager.FindOrCreate(ctx, textures, constantBuffers, packedState, shaderBinaries, colorAttachments, depthAttachment)};
if (pipeline) if (pipeline)
pipeline->AddTransition(newPipeline); pipeline->AddTransition(newPipeline);
pipeline = newPipeline; pipeline = newPipeline;

View File

@ -343,7 +343,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
PipelineState(dirty::Handle dirtyHandle, DirtyManager &manager, const EngineRegisters &engine); 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(); void PurgeCaches();