Patch up ColorBuffer for vk snapshot
Set the flags and properties properly when vk snapshot is enabled.
Bug: 340286132
Test: manual
Change-Id: I624fde4144a84689c80cbbc62285d1f0da8d7c63
GitOrigin-RevId: 430ed7099c43cf122db87d43c6f7db3c00600b87
diff --git a/host/ColorBuffer.cpp b/host/ColorBuffer.cpp
index b1acc92..55dd70b 100644
--- a/host/ColorBuffer.cpp
+++ b/host/ColorBuffer.cpp
@@ -58,6 +58,10 @@
std::shared_ptr<ColorBuffer> colorBuffer(
new ColorBuffer(handle, width, height, format, frameworkFormat));
+ if (stream) {
+ // When vk snapshot enabled, mNeedRestore will be touched and set to false immediately.
+ colorBuffer->mNeedRestore = true;
+ }
#if GFXSTREAM_ENABLE_HOST_GLES
if (emulationGl) {
if (stream) {
@@ -95,9 +99,11 @@
#if GFXSTREAM_ENABLE_HOST_GLES
bool b271028352Workaround = emulationGl && strstr(emulationGl->getGlesRenderer().c_str(), "Intel");
+ bool vkSnapshotEnabled = emulationVk && emulationVk->features.VulkanSnapshots.enabled;
- if (!stream && colorBuffer->mColorBufferGl && colorBuffer->mColorBufferVk &&
+ if ((!stream || vkSnapshotEnabled) && colorBuffer->mColorBufferGl && colorBuffer->mColorBufferVk &&
!b271028352Workaround && shouldAttemptExternalMemorySharing(frameworkFormat)) {
+ colorBuffer->touch();
auto memoryExport = vk::exportColorBufferMemory(handle);
if (memoryExport) {
if (colorBuffer->mColorBufferGl->importMemory(
@@ -127,8 +133,6 @@
std::shared_ptr<ColorBuffer> colorBuffer = ColorBuffer::create(
emulationGl, emulationVk, width, height, format, frameworkFormat, handle, stream);
- colorBuffer->mNeedRestore = true;
-
return colorBuffer;
}
diff --git a/host/gl/ColorBufferGl.cpp b/host/gl/ColorBufferGl.cpp
index 586de98..d0129b2 100644
--- a/host/gl/ColorBufferGl.cpp
+++ b/host/gl/ColorBufferGl.cpp
@@ -990,6 +990,10 @@
bool isBlob;
sGetFormatParameters(&cb->m_internalFormat, &texFormat, &pixelType, &bytesPerPixel,
&sizedInternalFormat, &isBlob);
+ cb->m_type = pixelType;
+ cb->m_format = texFormat;
+ cb->m_sizedInternalFormat = sizedInternalFormat;
+ // TODO: set m_BRSwizzle properly
cb->m_numBytes = ((unsigned long)bytesPerPixel) * width * height;
return cb;
}