Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit b7faaf4

Browse files
committed
[Impeller] Fix SupportsReadFromOnscreenTexture capability check
1 parent a858ced commit b7faaf4

File tree

6 files changed

+53
-11
lines changed

6 files changed

+53
-11
lines changed

impeller/renderer/BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ impeller_component("renderer_unittests") {
119119
testonly = true
120120

121121
sources = [
122+
"capabilities_unittests.cc",
122123
"device_buffer_unittests.cc",
123124
"host_buffer_unittests.cc",
124125
"pipeline_descriptor_unittests.cc",

impeller/renderer/backend/gles/context_gles.cc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,8 @@ ContextGLES::ContextGLES(std::unique_ptr<ProcTableGLES> gl,
7171
.SetSupportsFramebufferFetch(false)
7272
.SetDefaultColorFormat(PixelFormat::kR8G8B8A8UNormInt)
7373
.SetDefaultStencilFormat(PixelFormat::kS8UInt)
74-
.SetSupportsCompute(false, false)
74+
.SetSupportsCompute(false)
75+
.SetSupportsComputeSubgroups(false)
7576
.SetSupportsReadFromResolve(false)
7677
.SetSupportsReadFromOnscreenTexture(false)
7778
.Build();

impeller/renderer/backend/metal/context_mtl.mm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ static bool DeviceSupportsComputeSubgroups(id<MTLDevice> device) {
5858
.SetSupportsFramebufferFetch(DeviceSupportsFramebufferFetch(device))
5959
.SetDefaultColorFormat(color_format)
6060
.SetDefaultStencilFormat(PixelFormat::kS8UInt)
61-
.SetSupportsCompute(true, DeviceSupportsComputeSubgroups(device))
61+
.SetSupportsCompute(true)
62+
.SetSupportsComputeSubgroups(DeviceSupportsComputeSubgroups(device))
6263
.SetSupportsReadFromResolve(true)
6364
.SetSupportsReadFromOnscreenTexture(true)
6465
.Build();

impeller/renderer/capabilities.cc

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,16 +162,20 @@ CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsFramebufferFetch(
162162
return *this;
163163
}
164164

165-
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool compute,
166-
bool subgroups) {
167-
supports_compute_ = compute;
168-
supports_compute_subgroups_ = subgroups;
165+
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsCompute(bool value) {
166+
supports_compute_ = value;
167+
return *this;
168+
}
169+
170+
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsComputeSubgroups(
171+
bool value) {
172+
supports_compute_subgroups_ = value;
169173
return *this;
170174
}
171175

172176
CapabilitiesBuilder& CapabilitiesBuilder::SetSupportsReadFromOnscreenTexture(
173177
bool read_from_onscreen_texture) {
174-
supports_read_from_resolve_ = read_from_onscreen_texture;
178+
supports_read_from_onscreen_texture_ = read_from_onscreen_texture;
175179
return *this;
176180
}
177181

impeller/renderer/capabilities.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,13 @@ class CapabilitiesBuilder {
6565

6666
CapabilitiesBuilder& SetSupportsFramebufferFetch(bool value);
6767

68-
CapabilitiesBuilder& SetSupportsCompute(bool compute, bool subgroups);
68+
CapabilitiesBuilder& SetSupportsCompute(bool value);
6969

70-
CapabilitiesBuilder& SetSupportsReadFromOnscreenTexture(
71-
bool read_from_onscreen_texture);
70+
CapabilitiesBuilder& SetSupportsComputeSubgroups(bool value);
7271

73-
CapabilitiesBuilder& SetSupportsReadFromResolve(bool read_from_resolve);
72+
CapabilitiesBuilder& SetSupportsReadFromOnscreenTexture(bool value);
73+
74+
CapabilitiesBuilder& SetSupportsReadFromResolve(bool value);
7475

7576
CapabilitiesBuilder& SetDefaultColorFormat(PixelFormat value);
7677

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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+
#include "flutter/testing/testing.h"
6+
#include "impeller/renderer/capabilities.h"
7+
8+
#include "gtest/gtest.h"
9+
10+
namespace impeller {
11+
namespace testing {
12+
13+
#define CAPABILITY_TEST(name, default_value) \
14+
TEST(CapabilitiesTest, name) { \
15+
auto defaults = CapabilitiesBuilder().Build(); \
16+
ASSERT_EQ(defaults->name(), default_value); \
17+
auto opposite = CapabilitiesBuilder().Set##name(!default_value).Build(); \
18+
ASSERT_EQ(opposite->name(), !default_value); \
19+
}
20+
21+
CAPABILITY_TEST(HasThreadingRestrictions, false);
22+
CAPABILITY_TEST(SupportsOffscreenMSAA, false);
23+
CAPABILITY_TEST(SupportsSSBO, false);
24+
CAPABILITY_TEST(SupportsBufferToTextureBlits, false);
25+
CAPABILITY_TEST(SupportsTextureToTextureBlits, false);
26+
CAPABILITY_TEST(SupportsFramebufferFetch, false);
27+
CAPABILITY_TEST(SupportsCompute, false);
28+
CAPABILITY_TEST(SupportsComputeSubgroups, false);
29+
CAPABILITY_TEST(SupportsReadFromOnscreenTexture, false);
30+
CAPABILITY_TEST(SupportsReadFromResolve, false);
31+
CAPABILITY_TEST(SupportsDecalTileMode, false);
32+
33+
} // namespace testing
34+
} // namespace impeller

0 commit comments

Comments
 (0)