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);
}
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<TextureView *> ActiveState::GetColorAttachments() {
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
*/
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();

View File

@ -202,11 +202,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
}, 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};
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;

View File

@ -170,7 +170,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
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();
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<ShaderBinary, engine::PipelineCount> &shaderBinaries, span<TextureView *> colorAttachments, TextureView *depthAttachment)
: shaderStages{MakePipelineShaders(ctx, packedState, shaderBinaries)},
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, textures, constantBuffers, packedState, shaderBinaries)},
descriptorInfo{MakePipelineDescriptorInfo(shaderStages, ctx.gpu.traits.quirks.needsIndividualTextureBindingWrites)},
compiledPipeline{MakeCompiledPipeline(ctx, packedState, shaderStages, descriptorInfo.descriptorSetLayoutBindings, colorAttachments, depthAttachment)},
sourcePackedState{packedState} {

View File

@ -103,7 +103,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
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);
@ -118,15 +118,15 @@ namespace skyline::gpu::interconnect::maxwell3d {
class PipelineManager {
private:
tsl::robin_map<PackedPipelineState, std::unique_ptr<Pipeline>, util::ObjectHash<PackedPipelineState>> map;
tsl::robin_map<PackedPipelineState, std::unique_ptr<Pipeline>, PackedPipelineStateHash> map;
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)};
if (it != map.end())
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},
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;
for (size_t i{}; i < engine::PipelineCount; i++) {
const auto &stage{pipelineStages[i].UpdateGet(ctx)};
@ -583,7 +583,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
}
}
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;

View File

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