| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #pragma once |
| 6 | |
| 7 | #include <memory> |
| 8 | |
| 9 | #include "flutter/fml/macros.h" |
| 10 | #include "impeller/core/formats.h" |
| 11 | |
| 12 | namespace impeller { |
| 13 | |
| 14 | class Capabilities { |
| 15 | public: |
| 16 | virtual ~Capabilities(); |
| 17 | |
| 18 | virtual bool HasThreadingRestrictions() const = 0; |
| 19 | |
| 20 | virtual bool SupportsOffscreenMSAA() const = 0; |
| 21 | |
| 22 | virtual bool SupportsSSBO() const = 0; |
| 23 | |
| 24 | virtual bool SupportsBufferToTextureBlits() const = 0; |
| 25 | |
| 26 | virtual bool SupportsTextureToTextureBlits() const = 0; |
| 27 | |
| 28 | virtual bool SupportsFramebufferFetch() const = 0; |
| 29 | |
| 30 | virtual bool SupportsCompute() const = 0; |
| 31 | |
| 32 | virtual bool SupportsComputeSubgroups() const = 0; |
| 33 | |
| 34 | virtual bool SupportsReadFromOnscreenTexture() const = 0; |
| 35 | |
| 36 | virtual bool SupportsReadFromResolve() const = 0; |
| 37 | |
| 38 | virtual bool SupportsDecalTileMode() const = 0; |
| 39 | |
| 40 | virtual bool SupportsMemorylessTextures() const = 0; |
| 41 | |
| 42 | virtual PixelFormat GetDefaultColorFormat() const = 0; |
| 43 | |
| 44 | virtual PixelFormat GetDefaultStencilFormat() const = 0; |
| 45 | |
| 46 | protected: |
| 47 | Capabilities(); |
| 48 | |
| 49 | FML_DISALLOW_COPY_AND_ASSIGN(Capabilities); |
| 50 | }; |
| 51 | |
| 52 | class CapabilitiesBuilder { |
| 53 | public: |
| 54 | CapabilitiesBuilder(); |
| 55 | |
| 56 | ~CapabilitiesBuilder(); |
| 57 | |
| 58 | CapabilitiesBuilder& SetHasThreadingRestrictions(bool value); |
| 59 | |
| 60 | CapabilitiesBuilder& SetSupportsOffscreenMSAA(bool value); |
| 61 | |
| 62 | CapabilitiesBuilder& SetSupportsSSBO(bool value); |
| 63 | |
| 64 | CapabilitiesBuilder& SetSupportsBufferToTextureBlits(bool value); |
| 65 | |
| 66 | CapabilitiesBuilder& SetSupportsTextureToTextureBlits(bool value); |
| 67 | |
| 68 | CapabilitiesBuilder& SetSupportsFramebufferFetch(bool value); |
| 69 | |
| 70 | CapabilitiesBuilder& SetSupportsCompute(bool value); |
| 71 | |
| 72 | CapabilitiesBuilder& SetSupportsComputeSubgroups(bool value); |
| 73 | |
| 74 | CapabilitiesBuilder& SetSupportsReadFromOnscreenTexture(bool value); |
| 75 | |
| 76 | CapabilitiesBuilder& SetSupportsReadFromResolve(bool value); |
| 77 | |
| 78 | CapabilitiesBuilder& SetDefaultColorFormat(PixelFormat value); |
| 79 | |
| 80 | CapabilitiesBuilder& SetDefaultStencilFormat(PixelFormat value); |
| 81 | |
| 82 | CapabilitiesBuilder& SetSupportsDecalTileMode(bool value); |
| 83 | |
| 84 | CapabilitiesBuilder& SetSupportsMemorylessTextures(bool value); |
| 85 | |
| 86 | std::unique_ptr<Capabilities> Build(); |
| 87 | |
| 88 | private: |
| 89 | bool has_threading_restrictions_ = false; |
| 90 | bool supports_offscreen_msaa_ = false; |
| 91 | bool supports_ssbo_ = false; |
| 92 | bool supports_buffer_to_texture_blits_ = false; |
| 93 | bool supports_texture_to_texture_blits_ = false; |
| 94 | bool supports_framebuffer_fetch_ = false; |
| 95 | bool supports_compute_ = false; |
| 96 | bool supports_compute_subgroups_ = false; |
| 97 | bool supports_read_from_onscreen_texture_ = false; |
| 98 | bool supports_read_from_resolve_ = false; |
| 99 | bool supports_decal_tile_mode_ = false; |
| 100 | bool supports_memoryless_textures_ = false; |
| 101 | std::optional<PixelFormat> default_color_format_ = std::nullopt; |
| 102 | std::optional<PixelFormat> default_stencil_format_ = std::nullopt; |
| 103 | |
| 104 | FML_DISALLOW_COPY_AND_ASSIGN(CapabilitiesBuilder); |
| 105 | }; |
| 106 | |
| 107 | } // namespace impeller |
| 108 | |