Zero out blend state when disabled to avoid creating redundant pipelines

This commit is contained in:
Billy Laws 2022-10-09 13:46:10 +01:00
parent 4052a93051
commit 7ad2d94345
3 changed files with 20 additions and 9 deletions

View File

@ -71,7 +71,6 @@ namespace skyline::gpu::interconnect::maxwell3d {
} }
} }
static u8 ConvertCompareFunc(engine::CompareFunc func) { static u8 ConvertCompareFunc(engine::CompareFunc func) {
if (func < engine::CompareFunc::D3DNever || func > engine::CompareFunc::OglAlways || (func > engine::CompareFunc::D3DAlways && func < engine::CompareFunc::OglNever)) if (func < engine::CompareFunc::D3DNever || func > engine::CompareFunc::OglAlways || (func > engine::CompareFunc::D3DAlways && func < engine::CompareFunc::OglNever))
throw exception("Invalid comparision function: 0x{:X}", static_cast<u32>(func)); throw exception("Invalid comparision function: 0x{:X}", static_cast<u32>(func));
@ -253,12 +252,12 @@ namespace skyline::gpu::interconnect::maxwell3d {
static PackedPipelineState::AttachmentBlendState PackAttachmentBlendState(bool enable, engine::CtWrite writeMask, auto blend) { static PackedPipelineState::AttachmentBlendState PackAttachmentBlendState(bool enable, engine::CtWrite writeMask, auto blend) {
return { return {
.colorWriteMask = ConvertColorWriteMask(writeMask), .colorWriteMask = ConvertColorWriteMask(writeMask),
.colorBlendOp = ConvertBlendOp(blend.colorOp), .colorBlendOp = enable ? ConvertBlendOp(blend.colorOp) : u8{0},
.srcColorBlendFactor = ConvertBlendFactor(blend.colorSourceCoeff), .srcColorBlendFactor = enable ? ConvertBlendFactor(blend.colorSourceCoeff) : u8{0},
.dstColorBlendFactor = ConvertBlendFactor(blend.colorDestCoeff), .dstColorBlendFactor = enable ? ConvertBlendFactor(blend.colorDestCoeff) : u8{0},
.alphaBlendOp = ConvertBlendOp(blend.alphaOp), .alphaBlendOp = enable ? ConvertBlendOp(blend.alphaOp) : u8{0},
.srcAlphaBlendFactor = ConvertBlendFactor(blend.alphaSourceCoeff), .srcAlphaBlendFactor = enable ? ConvertBlendFactor(blend.alphaSourceCoeff) : u8{0},
.dstAlphaBlendFactor = ConvertBlendFactor(blend.alphaDestCoeff), .dstAlphaBlendFactor = enable ? ConvertBlendFactor(blend.alphaDestCoeff) : u8{0},
.blendEnable = enable .blendEnable = enable
}; };
} }

View File

@ -59,6 +59,7 @@ namespace skyline::gpu::interconnect::maxwell3d {
float pointSize; float pointSize;
std::array<engine::VertexAttribute, engine::VertexAttributeCount> vertexAttributes; std::array<engine::VertexAttribute, engine::VertexAttributeCount> vertexAttributes;
std::array<u8, engine::ColorTargetCount> colorRenderTargetFormats; //!< Use {Set, Get}ColorRenderTargetFormat std::array<u8, engine::ColorTargetCount> colorRenderTargetFormats; //!< Use {Set, Get}ColorRenderTargetFormat
std::bitset<8> activeColorTargets;
std::array<u32, 8> postVtgShaderAttributeSkipMask; std::array<u32, 8> postVtgShaderAttributeSkipMask;
struct VertexBinding { struct VertexBinding {

View File

@ -439,8 +439,17 @@ namespace skyline::gpu::interconnect::maxwell3d {
packedState.SetLogicOp(engine->logicOp.func); packedState.SetLogicOp(engine->logicOp.func);
for (u32 i{}; i < engine::ColorTargetCount; i++) { for (u32 i{}; i < engine::ColorTargetCount; i++) {
auto ctWrite{engine->singleCtWriteControl ? engine->ctWrites[0] : engine->ctWrites[i]}; auto ctWrite{[&]() {
bool enable{engine->blend.enable[i] != 0}; if (!packedState.activeColorTargets.test(i))
return engine::CtWrite{};
if (engine->singleCtWriteControl)
return engine->ctWrites[0];
else
return engine->ctWrites[i];
}()};
bool enable{engine->blend.enable[i] != 0 && packedState.activeColorTargets.test(i)};
if (engine->blendStatePerTargetEnable) if (engine->blendStatePerTargetEnable)
packedState.SetAttachmentBlendState(i, enable, ctWrite, engine->blendPerTargets[i]); packedState.SetAttachmentBlendState(i, enable, ctWrite, engine->blendPerTargets[i]);
@ -502,9 +511,11 @@ namespace skyline::gpu::interconnect::maxwell3d {
} }
colorAttachments.clear(); colorAttachments.clear();
packedState.activeColorTargets.reset();
for (size_t i{}; i < ctSelect.count; i++) { for (size_t i{}; i < ctSelect.count; i++) {
const auto &view{colorRenderTargets[ctSelect[i]].UpdateGet(ctx, packedState).view.get()}; const auto &view{colorRenderTargets[ctSelect[i]].UpdateGet(ctx, packedState).view.get()};
colorAttachments.push_back(view); colorAttachments.push_back(view);
packedState.activeColorTargets.set(i);
if (view) if (view)
ctx.executor.AttachTexture(view); ctx.executor.AttachTexture(view);