[Impeller] Fix SupportsReadFromOnscreenTexture capability check (flutter/engine#41386)

This commit is contained in:
Brandon DeRosier
2023-04-21 01:45:35 -07:00
committed by GitHub
parent b98bc7c360
commit c222cc4715
7 changed files with 54 additions and 11 deletions

View File

@@ -144,6 +144,7 @@
../../../flutter/impeller/golden_tests_harvester/test
../../../flutter/impeller/image/README.md
../../../flutter/impeller/playground
../../../flutter/impeller/renderer/capabilities_unittests.cc
../../../flutter/impeller/renderer/compute_subgroup_unittests.cc
../../../flutter/impeller/renderer/compute_unittests.cc
../../../flutter/impeller/renderer/device_buffer_unittests.cc

View File

@@ -119,6 +119,7 @@ impeller_component("renderer_unittests") {
testonly = true
sources = [
"capabilities_unittests.cc",
"device_buffer_unittests.cc",
"host_buffer_unittests.cc",
"pipeline_descriptor_unittests.cc",

View File

@@ -71,7 +71,8 @@ ContextGLES::ContextGLES(std::unique_ptr<ProcTableGLES> gl,
.SetSupportsFramebufferFetch(false)
.SetDefaultColorFormat(PixelFormat::kR8G8B8A8UNormInt)
.SetDefaultStencilFormat(PixelFormat::kS8UInt)
.SetSupportsCompute(false, false)
.SetSupportsCompute(false)
.SetSupportsComputeSubgroups(false)
.SetSupportsReadFromResolve(false)
.SetSupportsReadFromOnscreenTexture(false)
.Build();

View File

@@ -58,7 +58,8 @@ static std::unique_ptr<Capabilities> InferMetalCapabilities(
.SetSupportsFramebufferFetch(DeviceSupportsFramebufferFetch(device))
.SetDefaultColorFormat(color_format)
.SetDefaultStencilFormat(PixelFormat::kS8UInt)
.SetSupportsCompute(true, DeviceSupportsComputeSubgroups(device))
.SetSupportsCompute(true)
.SetSupportsComputeSubgroups(DeviceSupportsComputeSubgroups(device))
.SetSupportsReadFromResolve(true)
.SetSupportsReadFromOnscreenTexture(true)
.Build();

View File

@@ -162,16 +162,20 @@ CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsFramebufferFetch(
return *this;
}
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool compute,
bool subgroups) {
supports_compute_ = compute;
supports_compute_subgroups_ = subgroups;
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool value) {
supports_compute_ = value;
return *this;
}
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsComputeSubgroups(
bool value) {
supports_compute_subgroups_ = value;
return *this;
}
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromOnscreenTexture(
bool read_from_onscreen_texture) {
supports_read_from_resolve_ = read_from_onscreen_texture;
supports_read_from_onscreen_texture_ = read_from_onscreen_texture;
return *this;
}

View File

@@ -65,12 +65,13 @@ class CapabilitiesBuilder {
CapabilitiesBuilder& SetSupportsFramebufferFetch(bool value);
CapabilitiesBuilder& SetSupportsCompute(bool compute, bool subgroups);
CapabilitiesBuilder& SetSupportsCompute(bool value);
CapabilitiesBuilder& SetSupportsReadFromOnscreenTexture(
bool read_from_onscreen_texture);
CapabilitiesBuilder& SetSupportsComputeSubgroups(bool value);
CapabilitiesBuilder& SetSupportsReadFromResolve(bool read_from_resolve);
CapabilitiesBuilder& SetSupportsReadFromOnscreenTexture(bool value);
CapabilitiesBuilder& SetSupportsReadFromResolve(bool value);
CapabilitiesBuilder& SetDefaultColorFormat(PixelFormat value);

View File

@@ -0,0 +1,34 @@
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "flutter/testing/testing.h"
#include "impeller/renderer/capabilities.h"
#include "gtest/gtest.h"
namespace impeller {
namespace testing {
#define CAPABILITY_TEST(name, default_value) \
TEST(CapabilitiesTest, name) { \
auto defaults = CapabilitiesBuilder().Build(); \
ASSERT_EQ(defaults->name(), default_value); \
auto opposite = CapabilitiesBuilder().Set##name(!default_value).Build(); \
ASSERT_EQ(opposite->name(), !default_value); \
}
CAPABILITY_TEST(HasThreadingRestrictions, false);
CAPABILITY_TEST(SupportsOffscreenMSAA, false);
CAPABILITY_TEST(SupportsSSBO, false);
CAPABILITY_TEST(SupportsBufferToTextureBlits, false);
CAPABILITY_TEST(SupportsTextureToTextureBlits, false);
CAPABILITY_TEST(SupportsFramebufferFetch, false);
CAPABILITY_TEST(SupportsCompute, false);
CAPABILITY_TEST(SupportsComputeSubgroups, false);
CAPABILITY_TEST(SupportsReadFromOnscreenTexture, false);
CAPABILITY_TEST(SupportsReadFromResolve, false);
CAPABILITY_TEST(SupportsDecalTileMode, false);
} // namespace testing
} // namespace impeller