1 /*
2 * Copyright 2021 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 "src/gpu/graphite/GraphicsPipeline.h"
9
10 #include "src/gpu/graphite/ContextUtils.h"
11 #include "src/gpu/graphite/Renderer.h"
12 #include "src/gpu/graphite/ShaderInfo.h"
13 #include "src/utils/SkShaderUtils.h"
14
15 namespace skgpu::graphite {
16
GraphicsPipeline(const SharedContext * sharedContext,const PipelineInfo & pipelineInfo)17 GraphicsPipeline::GraphicsPipeline(const SharedContext* sharedContext,
18 const PipelineInfo& pipelineInfo)
19 : Resource(sharedContext,
20 Ownership::kOwned,
21 skgpu::Budgeted::kYes,
22 /*gpuMemorySize=*/0)
23 , fPipelineInfo(pipelineInfo) {}
24
25 GraphicsPipeline::~GraphicsPipeline() = default;
26
PipelineInfo(const ShaderInfo & shaderInfo,SkEnumBitMask<PipelineCreationFlags> pipelineCreationFlags)27 GraphicsPipeline::PipelineInfo::PipelineInfo(
28 const ShaderInfo& shaderInfo,
29 SkEnumBitMask<PipelineCreationFlags> pipelineCreationFlags)
30 : fDstReadReq(shaderInfo.dstReadRequirement())
31 , fNumFragTexturesAndSamplers(shaderInfo.numFragmentTexturesAndSamplers())
32 , fHasPaintUniforms(shaderInfo.hasPaintUniforms())
33 , fHasStepUniforms(shaderInfo.hasStepUniforms())
34 , fHasGradientBuffer(shaderInfo.hasGradientBuffer()) {
35 #if defined(GPU_TEST_UTILS)
36 fSkSLVertexShader = SkShaderUtils::PrettyPrint(shaderInfo.vertexSkSL());
37 fSkSLFragmentShader = SkShaderUtils::PrettyPrint(shaderInfo.fragmentSkSL());
38 fLabel = shaderInfo.fsLabel();
39 #endif
40 #if SK_HISTOGRAMS_ENABLED
41 fFromPrecompile =
42 SkToBool(pipelineCreationFlags & PipelineCreationFlags::kForPrecompilation);
43 #endif
44 }
45
46 } // namespace skgpu::graphite
47