/src/skia/tools/graphite/UniqueKeyUtils.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright 2024 Google LLC |
3 | | * |
4 | | * Use of this source code is governed by a BSD-style license that can be |
5 | | * found in the LICENSE file. |
6 | | */ |
7 | | |
8 | | #include "tools/graphite/UniqueKeyUtils.h" |
9 | | |
10 | | #include "src/gpu/ResourceKey.h" |
11 | | #include "src/gpu/graphite/Caps.h" |
12 | | #include "src/gpu/graphite/ContextPriv.h" |
13 | | #include "src/gpu/graphite/GraphicsPipelineDesc.h" |
14 | | #include "src/gpu/graphite/RenderPassDesc.h" |
15 | | #include "src/gpu/graphite/RendererProvider.h" |
16 | | |
17 | | using namespace skgpu::graphite; |
18 | | using namespace skgpu; |
19 | | |
20 | | |
21 | | namespace UniqueKeyUtils { |
22 | | |
23 | | void FetchUniqueKeys(GlobalCache* globalCache, |
24 | 0 | std::vector<UniqueKey>* keys) { |
25 | 0 | keys->reserve(globalCache->numGraphicsPipelines()); |
26 | 0 | globalCache->forEachGraphicsPipeline([keys](const UniqueKey& key, |
27 | 0 | const GraphicsPipeline* pipeline) { |
28 | 0 | keys->push_back(key); |
29 | 0 | }); |
30 | 0 | } |
31 | | |
32 | | #ifdef SK_DEBUG |
33 | | void DumpDescs(const RendererProvider* rendererProvider, |
34 | | const ShaderCodeDictionary* dict, |
35 | | const GraphicsPipelineDesc& pipelineDesc, |
36 | 0 | const RenderPassDesc& rpd) { |
37 | 0 | const RenderStep* rs = rendererProvider->lookup(pipelineDesc.renderStepID()); |
38 | 0 | SkDebugf("GraphicsPipelineDesc: %u %s\n", pipelineDesc.paintParamsID().asUInt(), rs->name()); |
39 | |
|
40 | 0 | dict->lookup(pipelineDesc.paintParamsID()).dump(dict); |
41 | |
|
42 | 0 | SkDebugf("RenderPassDesc:\n"); |
43 | 0 | SkDebugf(" colorAttach: %s\n", rpd.fColorAttachment.toString().c_str()); |
44 | 0 | SkDebugf(" colorResolveAttach: %s\n", rpd.fColorResolveAttachment.toString().c_str()); |
45 | 0 | SkDebugf(" depthStencilAttach: %s\n", rpd.fDepthStencilAttachment.toString().c_str()); |
46 | 0 | SkDebugf(" clearColor: %.2f %.2f %.2f %.2f\n" |
47 | 0 | " clearDepth: %.2f\n" |
48 | 0 | " stencilClear: %u\n" |
49 | 0 | " writeSwizzle: %s\n" |
50 | 0 | " sampleCount: %u\n", |
51 | 0 | rpd.fClearColor[0], rpd.fClearColor[1], rpd.fClearColor[2], rpd.fClearColor[3], |
52 | 0 | rpd.fClearDepth, |
53 | 0 | rpd.fClearStencil, |
54 | 0 | rpd.fWriteSwizzle.asString().c_str(), |
55 | 0 | rpd.fSampleCount); |
56 | |
|
57 | 0 | } |
58 | | #endif // SK_DEBUG |
59 | | |
60 | | bool ExtractKeyDescs(Context* context, |
61 | | const UniqueKey& origKey, |
62 | | GraphicsPipelineDesc* pipelineDesc, |
63 | 0 | RenderPassDesc* renderPassDesc) { |
64 | 0 | const Caps* caps = context->priv().caps(); |
65 | 0 | const RendererProvider* rendererProvider = context->priv().rendererProvider(); |
66 | |
|
67 | 0 | bool extracted = caps->extractGraphicsDescs(origKey, pipelineDesc, renderPassDesc, |
68 | 0 | rendererProvider); |
69 | 0 | if (!extracted) { |
70 | 0 | SkASSERT(0); |
71 | 0 | return false; |
72 | 0 | } |
73 | | |
74 | | #ifdef SK_DEBUG |
75 | 0 | const ShaderCodeDictionary* dict = context->priv().shaderCodeDictionary(); |
76 | |
|
77 | 0 | UniqueKey newKey = caps->makeGraphicsPipelineKey(*pipelineDesc, *renderPassDesc); |
78 | 0 | if (origKey != newKey) { |
79 | 0 | SkDebugf("------- The UniqueKey didn't round trip!\n"); |
80 | 0 | origKey.dump("original key:"); |
81 | 0 | newKey.dump("reassembled key:"); |
82 | 0 | DumpDescs(rendererProvider, dict, *pipelineDesc, *renderPassDesc); |
83 | 0 | SkDebugf("------------------------\n"); |
84 | 0 | } |
85 | 0 | SkASSERT(origKey == newKey); |
86 | | #endif |
87 | |
|
88 | 0 | return true; |
89 | 0 | } Unexecuted instantiation: UniqueKeyUtils::ExtractKeyDescs(skgpu::graphite::Context*, skgpu::UniqueKey const&, skgpu::graphite::GraphicsPipelineDesc*, skgpu::graphite::RenderPassDesc*) Unexecuted instantiation: UniqueKeyUtils::ExtractKeyDescs(skgpu::graphite::Context*, skgpu::UniqueKey const&, skgpu::graphite::GraphicsPipelineDesc*, skgpu::graphite::RenderPassDesc*) |
90 | | |
91 | | } // namespace UniqueKeyUtils |