aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/mtl/GrMtlCaps.h
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2017-07-31 10:45:52 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-07-31 15:03:22 +0000
commitcebcb84739c261e729a054ff097adca32a1b537f (patch)
tree6b936450dc9b90357152c94e32d4c77bdba66042 /src/gpu/mtl/GrMtlCaps.h
parent6bd729d8ebc98548fd92e081e1d1163bbc2ec815 (diff)
Add caps files for metal
Bug: skia: Change-Id: I8e7488320d4237cf67d6ebeaad319d3de75b67e6 Reviewed-on: https://skia-review.googlesource.com/27741 Commit-Queue: Greg Daniel <egdaniel@google.com> Reviewed-by: Brian Salomon <bsalomon@google.com> Reviewed-by: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/gpu/mtl/GrMtlCaps.h')
-rw-r--r--src/gpu/mtl/GrMtlCaps.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/gpu/mtl/GrMtlCaps.h b/src/gpu/mtl/GrMtlCaps.h
new file mode 100644
index 0000000000..9590bb9e12
--- /dev/null
+++ b/src/gpu/mtl/GrMtlCaps.h
@@ -0,0 +1,97 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#ifndef GrMtlCaps_DEFINED
+#define GrMtlCaps_DEFINED
+
+#include "GrCaps.h"
+
+#include "SkTDArray.h"
+
+#import <Metal/Metal.h>
+
+class GrShaderCaps;
+
+/**
+ * Stores some capabilities of a Mtl backend.
+ */
+class GrMtlCaps : public GrCaps {
+public:
+ GrMtlCaps(const GrContextOptions& contextOptions, id<MTLDevice> device,
+ MTLFeatureSet featureSet);
+
+ int getSampleCount(int requestedCount, GrPixelConfig config) const override;
+
+ bool isConfigTexturable(GrPixelConfig config) const override {
+ return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kTextureable_Flag);
+ }
+
+ bool isConfigRenderable(GrPixelConfig config, bool withMSAA) const override {
+ if (withMSAA) {
+ return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag) &&
+ SkToBool(fConfigTable[config].fFlags & ConfigInfo::kMSAA_Flag);
+ } else {
+ return SkToBool(fConfigTable[config].fFlags & ConfigInfo::kRenderable_Flag);
+ }
+ }
+
+ bool canConfigBeImageStorage(GrPixelConfig) const override { return false; }
+
+#if 0
+ /**
+ * Returns both a supported and most prefered stencil format to use in draws.
+ */
+ const StencilFormat& preferedStencilFormat() const {
+ return fPreferedStencilFormat;
+ }
+#endif
+ bool initDescForDstCopy(const GrRenderTargetProxy* src, GrSurfaceDesc* desc,
+ bool* rectsMustMatch, bool* disallowSubrect) const override {
+ return false;
+ }
+
+private:
+ void initFeatureSet(MTLFeatureSet featureSet);
+
+ void initGrCaps(const id<MTLDevice> device);
+ void initShaderCaps();
+ void initSampleCount();
+ void initConfigTable();
+
+ struct ConfigInfo {
+ ConfigInfo() : fFlags(0) {}
+
+ enum {
+ kTextureable_Flag = 0x1,
+ kRenderable_Flag = 0x2, // Color attachment and blendable
+ kMSAA_Flag = 0x4,
+ kResolve_Flag = 0x8,
+ };
+ static const uint16_t kAllFlags = kTextureable_Flag | kRenderable_Flag |
+ kMSAA_Flag | kResolve_Flag;
+
+ uint16_t fFlags;
+ };
+ ConfigInfo fConfigTable[kGrPixelConfigCnt];
+
+ enum class Platform {
+ kMac,
+ kIOS
+ };
+ bool isMac() { return Platform::kMac == fPlatform; }
+ bool isIOS() { return Platform::kIOS == fPlatform; }
+
+ Platform fPlatform;
+ int fFamilyGroup;
+ int fVersion;
+
+ SkTDArray<int> fSampleCounts;
+
+ typedef GrCaps INHERITED;
+};
+
+#endif