From c43555b2f910f3e8cbc2d2597fec260fdff4e168 Mon Sep 17 00:00:00 2001 From: Michael Ludwig Date: Fri, 20 May 2022 13:45:57 -0400 Subject: [PATCH] [graphite] Delete unused/refrenced cpp file Change-Id: I4ea10bd1354d6f68a6940fd48782bfa00bb3b343 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/542417 Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips Commit-Queue: Michael Ludwig Auto-Submit: Michael Ludwig --- src/gpu/graphite/BUILD.bazel | 7 -- src/gpu/graphite/ProgramCache.cpp | 105 ------------------------------ 2 files changed, 112 deletions(-) delete mode 100644 src/gpu/graphite/ProgramCache.cpp diff --git a/src/gpu/graphite/BUILD.bazel b/src/gpu/graphite/BUILD.bazel index c2d3b95605..9c398b6e8d 100644 --- a/src/gpu/graphite/BUILD.bazel +++ b/src/gpu/graphite/BUILD.bazel @@ -516,13 +516,6 @@ generated_cc_atom( ], ) -generated_cc_atom( - name = "ProgramCache_src", - srcs = ["ProgramCache.cpp"], - visibility = ["//:__subpackages__"], - deps = ["//experimental/graphite/src:ProgramCache_hdr"], -) - generated_cc_atom( name = "Recorder_src", srcs = ["Recorder.cpp"], diff --git a/src/gpu/graphite/ProgramCache.cpp b/src/gpu/graphite/ProgramCache.cpp deleted file mode 100644 index 5e2960d45f..0000000000 --- a/src/gpu/graphite/ProgramCache.cpp +++ /dev/null @@ -1,105 +0,0 @@ -/* - * Copyright 2021 Google LLC - * - * Use of this source code is governed by a BSD-style license that can be - * found in the LICENSE file. - */ - -#include "experimental/graphite/src/ProgramCache.h" - -namespace skgpu::graphite { - -//////////////////////////////////////////////////////////////////////////////////////////////////// -ProgramCache::ProgramInfo::ProgramInfo(uint32_t uniqueID, Combination c) - : fID(uniqueID) - , fCombination(c) { -} - -ProgramCache::ProgramInfo::~ProgramInfo() {} - -std::string ProgramCache::ProgramInfo::getMSL() const { - std::string msl = GetMSLUniformStruct(fCombination.fShaderType); - - switch (fCombination.fShaderType) { - case ShaderCombo::ShaderType::kLinearGradient: - // TODO: this MSL uses a 'rtSize' uniform that, presumably, we'll be getting from the - // vertex shader side of things (still somewhat TBD) - msl += std::string( - "fragment float4 fragmentShader(VertexOut interpolated [[stage_in]],\n" - " constant FragmentUniforms &uniforms [[buffer(0)]])\n" - "{" - "float2 screenPos = float2(2*interpolated.pos.x/uniforms.rtSize[0] - 1,\n" - " 2*interpolated.pos.y/uniforms.rtSize[1] - 1);\n" - "float2 delta = uniforms.point1 - uniforms.point0;\n" - "float2 pt = screenPos - uniforms.point0;\n" - "float t = dot(pt, delta) / dot(delta, delta);\n" - "float4 result = uniforms.colors[0];\n" - "result = mix(result, uniforms.colors[1],\n" - " clamp((t-uniforms.offsets[0])/(uniforms.offsets[1]-uniforms.offsets[0]),\n" - " 0, 1));\n" - "result = mix(result, uniforms.colors[2],\n" - " clamp((t-uniforms.offsets[1])/(uniforms.offsets[2]-uniforms.offsets[1]),\n" - " 0, 1));\n" - "result = mix(result, uniforms.colors[3],\n" - " clamp((t-uniforms.offsets[2])/(uniforms.offsets[3]-uniforms.offsets[2]),\n" - " 0, 1));\n" - "return result;\n" - "}\n"); - break; - case ShaderCombo::ShaderType::kNone: - // TODO: kNone is for depth-only draws, so should actually have a fragment output type - // that only defines a [[depth]] attribute but no color calculation. - msl += - "fragment float4 fragmentMain(VertexOutput interpolated [[stage_in]]) {\n" - " return float4(0.0, 0.0, 1.0, 1.0);\n" - "}\n"; - break; - case ShaderCombo::ShaderType::kRadialGradient: - case ShaderCombo::ShaderType::kSweepGradient: - case ShaderCombo::ShaderType::kConicalGradient: - case ShaderCombo::ShaderType::kSolidColor: - default: - msl += std::string( - "fragment float4 fragmentShader(VertexOut interpolated [[stage_in]],\n" - " constant FragmentUniforms &uniforms [[buffer(0)]])\n" - "{\n" - "return float4(uniforms.color);\n" - "}\n"); - break; - } - - return msl; -} - -//////////////////////////////////////////////////////////////////////////////////////////////////// -ProgramCache::ProgramCache() { - // kInvalidProgramID (aka 0) is reserved - fProgramVector.push_back(nullptr); -} - -size_t ProgramCache::Hash::operator()(Combination c) const { - return static_cast(c.fShaderType) + - static_cast(c.fTileMode) + - static_cast(c.fBlendMode); -} - -sk_sp ProgramCache::findOrCreateProgram(Combination c) { - auto iter = fProgramHash.find(c); - if (iter != fProgramHash.end()) { - SkASSERT(iter->second->id() != kInvalidProgramID); - return iter->second; - } - - sk_sp pi(new ProgramInfo(fNextUniqueID++, c)); - fProgramHash.insert(std::make_pair(c, pi)); - fProgramVector.push_back(pi); - SkASSERT(fProgramVector[pi->id()] == pi); - return pi; -} - -sk_sp ProgramCache::lookup(uint32_t uniqueID) { - SkASSERT(uniqueID < fProgramVector.size()); - return fProgramVector[uniqueID]; -} - -} // namespace skgpu::graphite