[graphite] Don't reset uniform bindings on pipeline change

This is pulled from https://skia-review.googlesource.com/c/skia/+/492400

I noticed this when trying to determine pipeline changes in graphite on
the motionmark SKPs. Resetting the uniform bindings to invalid when we
switched pipelines because of a stencil-only pass meant a lot of extra
re-binding. Additionally, with graphite splitting bindings between
geometry and shading, this potentially avoids a rebind when a program
has a compatible shading snippet, or a compatible RenderStep.

Cq-Include-Trybots: luci.skia.skia.primary:Test-Mac11-Clang-MacMini9.1-GPU-AppleM1-arm64-Release-All-Graphite,Test-Mac11-Clang-MacMini9.1-GPU-AppleM1-arm64-Debug-All-ASAN_Graphite,Build-Mac-Clang-arm64-Release-Graphite,Build-Mac-Clang-arm64-Release-iOS_Graphite,Build-Mac-Clang-arm64-Debug-iOS_Graphite,Build-Mac-Clang-arm64-Debug-Graphite_NoGpu,Build-Mac-Clang-arm64-Debug-Graphite,Build-Mac-Clang-arm64-Debug-ASAN_Graphite
Change-Id: I42e60194a09b30b717d814acb4584c3f1eb884d7
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/519079
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
This commit is contained in:
Michael Ludwig 2022-03-09 21:07:28 -05:00 committed by SkCQ
parent 4b3403e6c8
commit 841906a850

View File

@ -378,9 +378,16 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
const DrawList::Draw& draw = *key.draw();
const RenderStep& renderStep = key.renderStep();
const bool geometryUniformChange =
key.geometryUniforms() != PipelineDataCache::kInvalidUniformID &&
key.geometryUniforms() != lastGeometryUniforms;
const bool shadingUniformChange =
key.shadingUniforms() != PipelineDataCache::kInvalidUniformID &&
key.shadingUniforms() != lastShadingUniforms;
const bool pipelineChange = key.pipeline() != lastPipeline;
const bool stateChange = key.geometryUniforms() != lastGeometryUniforms ||
key.shadingUniforms() != lastShadingUniforms ||
const bool stateChange = geometryUniformChange ||
shadingUniformChange ||
draw.fClip.scissor() != lastScissor;
// Update DrawWriter *before* we actually change any state so that accumulated draws from
@ -397,24 +404,18 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
if (pipelineChange) {
drawPass->fCommands.emplace_back(BindGraphicsPipeline{key.pipeline()});
lastPipeline = key.pipeline();
lastShadingUniforms = PipelineDataCache::kInvalidUniformID;
lastGeometryUniforms = PipelineDataCache::kInvalidUniformID;
}
if (stateChange) {
if (key.geometryUniforms() != lastGeometryUniforms) {
if (key.geometryUniforms() != PipelineDataCache::kInvalidUniformID) {
auto binding = geometryUniformBindings.getBinding(key.geometryUniforms());
drawPass->fCommands.emplace_back(
BindUniformBuffer{binding, UniformSlot::kRenderStep});
}
if (geometryUniformChange) {
auto binding = geometryUniformBindings.getBinding(key.geometryUniforms());
drawPass->fCommands.emplace_back(
BindUniformBuffer{binding, UniformSlot::kRenderStep});
lastGeometryUniforms = key.geometryUniforms();
}
if (key.shadingUniforms() != lastShadingUniforms) {
if (key.shadingUniforms() != PipelineDataCache::kInvalidUniformID) {
auto binding = shadingUniformBindings.getBinding(key.shadingUniforms());
drawPass->fCommands.emplace_back(
BindUniformBuffer{binding, UniformSlot::kPaint});
}
if (shadingUniformChange) {
auto binding = shadingUniformBindings.getBinding(key.shadingUniforms());
drawPass->fCommands.emplace_back(
BindUniformBuffer{binding, UniformSlot::kPaint});
lastShadingUniforms = key.shadingUniforms();
}
if (draw.fClip.scissor() != lastScissor) {