aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <android-test-infra-autosubmit@system.gserviceaccount.com>2024-04-30 01:03:42 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2024-04-30 01:03:42 +0000
commitcc1924d2b148a38927ebdcbb78d1611d80977320 (patch)
tree27ac3cf2a8d18aa869ba59e05770fd2bf3cd93d6
parent24e20f84e120777ea16d8b26737ace0a989363fc (diff)
parent234a263b042af215fefb8213624eafa7b0420b77 (diff)
downloadgfxstream-cc1924d2b148a38927ebdcbb78d1611d80977320.tar.gz
Merge changes Iea8d7c0f,I2636bcf0 into main
* changes: gfxstream: add missing DeviceOpTracker.cpp to meson build gfxstream: Fix createResource call for Linux-guest VirtGpu layer
-rw-r--r--guest/vulkan_enc/ResourceTracker.cpp48
-rw-r--r--host/vulkan/meson.build1
2 files changed, 43 insertions, 6 deletions
diff --git a/guest/vulkan_enc/ResourceTracker.cpp b/guest/vulkan_enc/ResourceTracker.cpp
index 164ddc35..030b9f6a 100644
--- a/guest/vulkan_enc/ResourceTracker.cpp
+++ b/guest/vulkan_enc/ResourceTracker.cpp
@@ -2892,6 +2892,24 @@ static uint32_t getVirglFormat(VkFormat vkFormat) {
return virglFormat;
}
+static bool getVirtGpuFormatParams(const VkFormat vkFormat, uint32_t* virglFormat, uint32_t* target,
+ uint32_t* bind, uint32_t* bpp) {
+ *virglFormat = getVirglFormat(vkFormat);
+ switch (*virglFormat) {
+ case VIRGL_FORMAT_R8G8B8A8_UNORM:
+ case VIRGL_FORMAT_B8G8R8A8_UNORM:
+ *target = PIPE_TEXTURE_2D;
+ *bind = VIRGL_BIND_RENDER_TARGET;
+ *bpp = 4;
+ break;
+ default:
+ /* Format not recognized */
+ return false;
+ }
+
+ return true;
+}
+
CoherentMemoryPtr ResourceTracker::createCoherentMemory(
VkDevice device, VkDeviceMemory mem, const VkMemoryAllocateInfo& hostAllocationInfo,
VkEncoder* enc, VkResult& res) {
@@ -3770,14 +3788,20 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
imageCreateInfo = imageInfo.createInfo;
}
- uint32_t virglFormat = gfxstream::vk::getVirglFormat(imageCreateInfo.format);
- if (virglFormat < 0) {
- ALOGE("%s: Unsupported VK format for colorBuffer, vkFormat: 0x%x", __func__,
+
+ uint32_t virglFormat = 0;
+ uint32_t target = 0;
+ uint32_t bind = 0;
+ uint32_t bpp = 0;
+ if (!gfxstream::vk::getVirtGpuFormatParams(imageCreateInfo.format, &virglFormat,
+ &target, &bind, &bpp)) {
+ ALOGE("%s: Unsupported VK format for VirtGpu resource, vkFormat: 0x%x", __func__,
imageCreateInfo.format);
return VK_ERROR_FORMAT_NOT_SUPPORTED;
}
colorBufferBlob = instance->createResource(imageCreateInfo.extent.width,
- imageCreateInfo.extent.height, virglFormat);
+ imageCreateInfo.extent.height, virglFormat,
+ target, bind, bpp);
if (!colorBufferBlob) {
ALOGE("%s: Failed to create colorBuffer resource for Image memory\n", __func__);
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
@@ -3798,8 +3822,20 @@ VkResult ResourceTracker::on_vkAllocateMemory(void* context, VkResult input_resu
const auto& bufferInfo = it->second;
bufferCreateInfo = bufferInfo.createInfo;
}
- colorBufferBlob =
- instance->createResource(bufferCreateInfo.size / 4, 1, VIRGL_FORMAT_R8G8B8A8_UNORM);
+ const VkFormat vkFormat = VK_FORMAT_R8G8B8A8_UNORM;
+ uint32_t virglFormat = 0;
+ uint32_t target = 0;
+ uint32_t bind = 0;
+ uint32_t bpp = 0;
+ if (!gfxstream::vk::getVirtGpuFormatParams(vkFormat, &virglFormat, &target, &bind,
+ &bpp)) {
+ ALOGE("%s: Unexpected error getting VirtGpu format params for vkFormat: 0x%x",
+ __func__, vkFormat);
+ return VK_ERROR_FORMAT_NOT_SUPPORTED;
+ }
+
+ colorBufferBlob = instance->createResource(bufferCreateInfo.size / bpp, 1, virglFormat,
+ target, bind, bpp);
if (!colorBufferBlob) {
ALOGE("%s: Failed to create colorBuffer resource for Buffer memory\n", __func__);
return VK_ERROR_OUT_OF_DEVICE_MEMORY;
diff --git a/host/vulkan/meson.build b/host/vulkan/meson.build
index 4ffd3308..ae7e03a4 100644
--- a/host/vulkan/meson.build
+++ b/host/vulkan/meson.build
@@ -13,6 +13,7 @@ files_lib_vulkan_server = files(
'BufferVk.cpp',
'ColorBufferVk.cpp',
'CompositorVk.cpp',
+ 'DeviceOpTracker.cpp',
'DisplayVk.cpp',
'DisplaySurfaceVk.cpp',
'PostWorkerVk.cpp',