Adds feature for using an emulated memory type for AHBs
Adds a phyiscal device memory helper for organizing all of the
various physical memory changes and moves some of the existing
changes into the helper to avoid duplication.
Adds some tests for some of the existing physical memory changes.
Bug: b/283005889
Test: gfxstream_vkemulatedphysicaldevicememory_tests
Test: cvd start --gpu_mode=gfxstream_guest_angle_host_swiftshader
cts -m CtsNativeHardwareTestCases
Test: GfxstreamEnd2EndTests
Test: GfxstreamEnd2EndTests on SwiftShader
Change-Id: Ieb45fad253df27e483b8a04444bd3abb5c87d1ab
diff --git a/common/end2end/Android.bp b/common/end2end/Android.bp
index 60da42d..568f173 100644
--- a/common/end2end/Android.bp
+++ b/common/end2end/Android.bp
@@ -43,6 +43,7 @@
static_libs: [
"libc++fs",
"libgfxstream_common_image",
+ "libgfxstream_common_utils",
"libgfxstream_guest_android_with_host",
"libgfxstream_platform_rutabaga",
"libgfxstream_thirdparty_stb",
diff --git a/common/end2end/GfxstreamEnd2EndTests.cpp b/common/end2end/GfxstreamEnd2EndTests.cpp
index 5d15b9d..bead0e7 100644
--- a/common/end2end/GfxstreamEnd2EndTests.cpp
+++ b/common/end2end/GfxstreamEnd2EndTests.cpp
@@ -27,6 +27,7 @@
#include "aemu/base/Path.h"
#include "gfxstream/ImageUtils.h"
#include "gfxstream/RutabagaLayerTestUtils.h"
+#include "gfxstream/Strings.h"
VULKAN_HPP_DEFAULT_DISPATCH_LOADER_DYNAMIC_STORAGE
@@ -77,8 +78,11 @@
ret += "Gl";
ret += (with_vk ? "With" : "Without");
ret += "Vk";
- ret += (with_vk_snapshot ? "With" : "Without");
- ret += "Snapshot";
+ if (!with_features.empty()) {
+ ret += "WithFeatures_";
+ ret += Join(with_features, "_");
+ ret += "_";
+ }
ret += "Over";
ret += GfxstreamTransportToString(with_transport);
return ret;
@@ -92,6 +96,23 @@
return info.param.ToString();
}
+std::vector<TestParams> WithAndWithoutFeatures(const std::vector<TestParams>& params,
+ const std::vector<std::string>& features) {
+ std::vector<TestParams> output;
+ output.reserve(params.size() * 2);
+
+ // Copy of all of the existing test params:
+ output.insert(output.end(), params.begin(), params.end());
+
+ // Copy of all of the existing test params with the new features:
+ for (TestParams copy : params) {
+ copy.with_features.insert(features.begin(), features.end());
+ output.push_back(copy);
+ }
+
+ return output;
+}
+
std::unique_ptr<GuestGlDispatchTable> GfxstreamEnd2EndTest::SetupGuestGl() {
const std::filesystem::path testDirectory = gfxstream::guest::getProgramDirectory();
const std::string eglLibPath = (testDirectory / "libEGL_emulation_with_host.so").string();
@@ -198,11 +219,17 @@
ASSERT_THAT(setenv("GFXSTREAM_EMULATED_VIRTIO_GPU_WITH_VK", params.with_vk ? "Y" : "N",
/*overwrite=*/1),
Eq(0));
- ASSERT_THAT(setenv("GFXSTREAM_EMULATED_VIRTIO_GPU_WITH_VK_SNAPSHOTS",
- params.with_vk_snapshot ? "Y" : "N",
- /*overwrite=*/1),
+
+ std::vector<std::string> featureEnables;
+ for (const std::string& feature : params.with_features) {
+ featureEnables.push_back(feature + ":enabled");
+ }
+ const std::string features = Join(featureEnables, ",");
+ ASSERT_THAT(setenv("GFXSTREAM_EMULATED_VIRTIO_GPU_RENDERER_FEATURES", features.c_str(),
+ /*overwrite=*/1),
Eq(0));
+
if (params.with_gl) {
mGl = SetupGuestGl();
ASSERT_THAT(mGl, NotNull());
diff --git a/common/end2end/GfxstreamEnd2EndTests.h b/common/end2end/GfxstreamEnd2EndTests.h
index c543647..783bc3c 100644
--- a/common/end2end/GfxstreamEnd2EndTests.h
+++ b/common/end2end/GfxstreamEnd2EndTests.h
@@ -22,6 +22,7 @@
#include <memory>
#include <string>
#include <thread>
+#include <unordered_set>
#include <variant>
// clang-format off
@@ -440,7 +441,7 @@
struct TestParams {
bool with_gl;
bool with_vk;
- bool with_vk_snapshot = false;
+ std::unordered_set<std::string> with_features;
GfxstreamTransport with_transport = GfxstreamTransport::kVirtioGpuAsg;
std::string ToString() const;
@@ -449,6 +450,10 @@
std::string GetTestName(const ::testing::TestParamInfo<TestParams>& info);
+// Generates the cartesian product of params with and without the given features.
+std::vector<TestParams> WithAndWithoutFeatures(const std::vector<TestParams>& params,
+ const std::vector<std::string>& features);
+
class GfxstreamEnd2EndTest : public ::testing::TestWithParam<TestParams> {
public:
std::unique_ptr<GuestGlDispatchTable> SetupGuestGl();
diff --git a/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp b/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp
index 544aa13..edfef72 100644
--- a/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp
+++ b/common/end2end/GfxstreamEnd2EndVkSnapshotBasicTests.cpp
@@ -33,7 +33,7 @@
TestParams{
.with_gl = false,
.with_vk = true,
- .with_vk_snapshot = true,
+ .with_features = {"VulkanSnapshots"},
},
}),
&GetTestName);
diff --git a/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp b/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp
index 87b2611..643ff2d 100644
--- a/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp
+++ b/common/end2end/GfxstreamEnd2EndVkSnapshotImageTests.cpp
@@ -401,7 +401,7 @@
TestParams{
.with_gl = false,
.with_vk = true,
- .with_vk_snapshot = true,
+ .with_features = {"VulkanSnapshots"},
},
}),
&GetTestName);
diff --git a/common/end2end/GfxstreamEnd2EndVkSnapshotPipelineTests.cpp b/common/end2end/GfxstreamEnd2EndVkSnapshotPipelineTests.cpp
index 374333d..e3052e3 100644
--- a/common/end2end/GfxstreamEnd2EndVkSnapshotPipelineTests.cpp
+++ b/common/end2end/GfxstreamEnd2EndVkSnapshotPipelineTests.cpp
@@ -235,7 +235,7 @@
TestParams{
.with_gl = false,
.with_vk = true,
- .with_vk_snapshot = true,
+ .with_features = {"VulkanSnapshots"},
},
}),
&GetTestName);
diff --git a/common/end2end/GfxstreamEnd2EndVkTests.cpp b/common/end2end/GfxstreamEnd2EndVkTests.cpp
index 6004948..1acea55 100644
--- a/common/end2end/GfxstreamEnd2EndVkTests.cpp
+++ b/common/end2end/GfxstreamEnd2EndVkTests.cpp
@@ -232,7 +232,12 @@
TEST_P(GfxstreamEnd2EndVkTest, BlobAHBIsNotMapable) {
if (GetParam().with_gl) {
- GTEST_SKIP() << "Data buffers are currently only supported in Vulkan only mode.";
+ GTEST_SKIP()
+ << "Skipping test, data buffers are currently only supported in Vulkan only mode.";
+ }
+ if (GetParam().with_features.count("VulkanUseDedicatedAhbMemoryType") == 0) {
+ GTEST_SKIP()
+ << "Skipping test, AHB test only makes sense with VulkanUseDedicatedAhbMemoryType.";
}
auto [instance, physicalDevice, device, queue, queueFamilyIndex] =
@@ -625,30 +630,34 @@
}
}
+std::vector<TestParams> GenerateTestCases() {
+ std::vector<TestParams> cases = {TestParams{
+ .with_gl = false,
+ .with_vk = true,
+ .with_transport = GfxstreamTransport::kVirtioGpuAsg,
+ },
+ TestParams{
+ .with_gl = true,
+ .with_vk = true,
+ .with_transport = GfxstreamTransport::kVirtioGpuAsg,
+ },
+ TestParams{
+ .with_gl = false,
+ .with_vk = true,
+ .with_transport = GfxstreamTransport::kVirtioGpuPipe,
+ },
+ TestParams{
+ .with_gl = true,
+ .with_vk = true,
+ .with_transport = GfxstreamTransport::kVirtioGpuPipe,
+ }};
+ cases = WithAndWithoutFeatures(cases, {"VulkanSnapshots"});
+ cases = WithAndWithoutFeatures(cases, {"VulkanUseDedicatedAhbMemoryType"});
+ return cases;
+}
+
INSTANTIATE_TEST_CASE_P(GfxstreamEnd2EndTests, GfxstreamEnd2EndVkTest,
- ::testing::ValuesIn({
- TestParams{
- .with_gl = false,
- .with_vk = true,
- .with_transport = GfxstreamTransport::kVirtioGpuAsg,
- },
- TestParams{
- .with_gl = true,
- .with_vk = true,
- .with_transport = GfxstreamTransport::kVirtioGpuAsg,
- },
- TestParams{
- .with_gl = false,
- .with_vk = true,
- .with_transport = GfxstreamTransport::kVirtioGpuPipe,
- },
- TestParams{
- .with_gl = true,
- .with_vk = true,
- .with_transport = GfxstreamTransport::kVirtioGpuPipe,
- },
- }),
- &GetTestName);
+ ::testing::ValuesIn(GenerateTestCases()), &GetTestName);
} // namespace
} // namespace tests
diff --git a/common/utils/include/gfxstream/Strings.h b/common/utils/include/gfxstream/Strings.h
index f7a017e..7ea92b2 100644
--- a/common/utils/include/gfxstream/Strings.h
+++ b/common/utils/include/gfxstream/Strings.h
@@ -14,6 +14,7 @@
#pragma once
+#include <sstream>
#include <string>
#include <vector>
@@ -21,4 +22,18 @@
std::vector<std::string> Split(const std::string& s, const std::string& delimiters);
+template <typename ContainerT, typename SeparatorT>
+std::string Join(const ContainerT& things, SeparatorT separator) {
+ if (things.empty()) {
+ return "";
+ }
+
+ std::ostringstream result;
+ result << *things.begin();
+ for (auto it = std::next(things.begin()); it != things.end(); ++it) {
+ result << separator << *it;
+ }
+ return result.str();
+}
+
} // namespace gfxstream