[graphite] Make CreateKey work more like ExtractPaintData
ExtractPaintData currently returns: std::tuple<SkUniquePaintParamsID, std::unique_ptr<SkPipelineData>> SkShaderCodeDictionary::findOrCreate is going to change in an upcoming CL and this sets up to better isolate those changes. Bug: skia:12701 Change-Id: I8d077b3d342e6ea16ac99227eb145d92e8247ea4 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/517736 Reviewed-by: Jim Van Verth <jvanverth@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
0843ef6ded
commit
88f90513a9
@ -81,15 +81,14 @@ void Context::preCompile(const PaintCombo& paintCombo) {
|
||||
for (auto& shaderCombo: paintCombo.fShaders) {
|
||||
for (auto shaderType: shaderCombo.fTypes) {
|
||||
for (auto tm: shaderCombo.fTileModes) {
|
||||
SkPaintParamsKey key = CreateKey(dict, &builder, shaderType, tm, bm);
|
||||
auto entry = dict->findOrCreate(std::move(key));
|
||||
auto uniqueID = CreateKey(dict, &builder, shaderType, tm, bm);
|
||||
|
||||
GraphicsPipelineDesc desc;
|
||||
|
||||
for (const Renderer* r : kRenderers) {
|
||||
for (auto&& s : r->steps()) {
|
||||
if (s->performsShading()) {
|
||||
desc.setProgram(s, entry->uniqueID());
|
||||
desc.setProgram(s, uniqueID);
|
||||
}
|
||||
// TODO: Combine with renderpass description set to generate full
|
||||
// GraphicsPipeline and MSL program. Cache that compiled pipeline on
|
||||
|
@ -301,9 +301,9 @@ std::unique_ptr<DrawPass> DrawPass::Make(Recorder* recorder,
|
||||
// bound independently of those used by the rest of the RenderStep, then we can upload now
|
||||
// and remember the location for re-use on any RenderStep that does shading.
|
||||
SkUniquePaintParamsID shaderID;
|
||||
std::unique_ptr<SkPipelineData> pipelineData;
|
||||
uint32_t shadingIndex = PipelineDataCache::kInvalidUniformID;
|
||||
if (draw.fPaintParams.has_value()) {
|
||||
std::unique_ptr<SkPipelineData> pipelineData;
|
||||
std::tie(shaderID, pipelineData) = ExtractPaintData(dict, &builder,
|
||||
draw.fPaintParams.value());
|
||||
shadingIndex = shadingUniformBindings.addUniforms(std::move(pipelineData));
|
||||
|
@ -502,11 +502,11 @@ void AddToKey(SkShaderCodeDictionary* dict,
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
SkPaintParamsKey CreateKey(SkShaderCodeDictionary* dict,
|
||||
SkPaintParamsKeyBuilder* builder,
|
||||
skgpu::ShaderCombo::ShaderType s,
|
||||
SkTileMode tm,
|
||||
SkBlendMode bm) {
|
||||
SkUniquePaintParamsID CreateKey(SkShaderCodeDictionary* dict,
|
||||
SkPaintParamsKeyBuilder* builder,
|
||||
skgpu::ShaderCombo::ShaderType s,
|
||||
SkTileMode tm,
|
||||
SkBlendMode bm) {
|
||||
SkDEBUGCODE(builder->checkReset());
|
||||
|
||||
switch (s) {
|
||||
@ -535,6 +535,10 @@ SkPaintParamsKey CreateKey(SkShaderCodeDictionary* dict,
|
||||
}
|
||||
|
||||
BlendModeBlock::AddToKey(dict, builder, nullptr, bm);
|
||||
return builder->lockAsKey();
|
||||
SkPaintParamsKey key = builder->lockAsKey();
|
||||
|
||||
const SkShaderCodeDictionary::Entry* entry = dict->findOrCreate(key);
|
||||
|
||||
return entry->uniqueID();
|
||||
}
|
||||
#endif
|
||||
|
@ -17,10 +17,10 @@
|
||||
#include "include/core/SkTileMode.h"
|
||||
|
||||
enum class SkBackend : uint8_t;
|
||||
class SkPaintParamsKey;
|
||||
class SkPaintParamsKeyBuilder;
|
||||
class SkShaderCodeDictionary;
|
||||
class SkPipelineData;
|
||||
class SkUniquePaintParamsID;
|
||||
|
||||
// The KeyHelpers can be used to manually construct an SkPaintParamsKey
|
||||
|
||||
@ -142,11 +142,11 @@ namespace BlendModeBlock {
|
||||
|
||||
#ifdef SK_GRAPHITE_ENABLED
|
||||
// Bridge between the combinations system and the SkPaintParamsKey
|
||||
SkPaintParamsKey CreateKey(SkShaderCodeDictionary*,
|
||||
SkPaintParamsKeyBuilder*,
|
||||
skgpu::ShaderCombo::ShaderType,
|
||||
SkTileMode,
|
||||
SkBlendMode);
|
||||
SkUniquePaintParamsID CreateKey(SkShaderCodeDictionary*,
|
||||
SkPaintParamsKeyBuilder*,
|
||||
skgpu::ShaderCombo::ShaderType,
|
||||
SkTileMode,
|
||||
SkBlendMode);
|
||||
#endif
|
||||
|
||||
#endif // SkKeyHelpers_DEFINED
|
||||
|
@ -254,18 +254,15 @@ DEF_GRAPHITE_TEST_FOR_CONTEXTS(CommandBufferTest, reporter, context) {
|
||||
TextureInfo textureInfo;
|
||||
#endif
|
||||
|
||||
const SkShaderCodeDictionary::Entry* entry;
|
||||
|
||||
SkUniquePaintParamsID uniqueID;
|
||||
{
|
||||
SkPaintParamsKeyBuilder builder(dict, SkBackend::kGraphite);
|
||||
|
||||
SkPaintParamsKey key = CreateKey(dict,
|
||||
&builder,
|
||||
ShaderCombo::ShaderType::kSolidColor,
|
||||
SkTileMode::kClamp,
|
||||
SkBlendMode::kSrc);
|
||||
|
||||
entry = dict->findOrCreate(key);
|
||||
uniqueID = CreateKey(dict,
|
||||
&builder,
|
||||
ShaderCombo::ShaderType::kSolidColor,
|
||||
SkTileMode::kClamp,
|
||||
SkBlendMode::kSrc);
|
||||
}
|
||||
|
||||
auto target = sk_sp<TextureProxy>(new TextureProxy(textureSize, textureInfo));
|
||||
@ -309,7 +306,7 @@ DEF_GRAPHITE_TEST_FOR_CONTEXTS(CommandBufferTest, reporter, context) {
|
||||
|
||||
auto draw = [&](const RenderStep* step, std::vector<RectAndColor> draws) {
|
||||
GraphicsPipelineDesc pipelineDesc;
|
||||
pipelineDesc.setProgram(step, entry->uniqueID());
|
||||
pipelineDesc.setProgram(step, uniqueID);
|
||||
drawWriter.newPipelineState(step->primitiveType(),
|
||||
step->vertexStride(),
|
||||
step->instanceStride());
|
||||
|
@ -95,14 +95,13 @@ DEF_GRAPHITE_TEST_FOR_CONTEXTS(UniformTest, reporter, context) {
|
||||
|
||||
for (auto bm : { SkBlendMode::kSrc, SkBlendMode::kSrcOver }) {
|
||||
auto [ p, expectedNumUniforms ] = create_paint(s, tm, bm);
|
||||
auto [ actualID, uniformBlock] = ExtractPaintData(dict, &builder, PaintParams(p));
|
||||
auto [ uniqueID1, uniformBlock] = ExtractPaintData(dict, &builder, PaintParams(p));
|
||||
int actualNumUniforms = uniformBlock->count();
|
||||
|
||||
auto entry = dict->lookup(actualID);
|
||||
SkUniquePaintParamsID uniqueID2 = CreateKey(dict, &builder, s, tm, bm);
|
||||
|
||||
SkPaintParamsKey expected = CreateKey(dict, &builder, s, tm, bm);
|
||||
|
||||
REPORTER_ASSERT(reporter, expected == entry->paintParamsKey());
|
||||
// ExtractPaintData and CreateKey agree
|
||||
REPORTER_ASSERT(reporter, uniqueID1 == uniqueID2);
|
||||
REPORTER_ASSERT(reporter, expectedNumUniforms == actualNumUniforms);
|
||||
for (auto& u : *uniformBlock) {
|
||||
for (int i = 0; i < u->count(); ++i) {
|
||||
|
Loading…
Reference in New Issue
Block a user