Add RenderThreadInfoVk ... and move VkDecoder into a RenderThreadInfoVk to have an object to package VK info into to parallel RenderThreadInfoGl in aosp/2167843. This is useful for upcoming changes to avoid a circular dependency between `libgfxstream_backend` and `gfxstream_vulkan_server` when wanting to have thread info in VkDecoderGlobalState. Bug: b/233939967 Test: cvd start --gpu_mode=gfxstream --enable_gpu_angle=true Change-Id: I6cb73a122253e0e897100ba95c1bff32c0234310
diff --git a/stream-servers/RenderThread.cpp b/stream-servers/RenderThread.cpp index 5310e2b..88eb3b8 100644 --- a/stream-servers/RenderThread.cpp +++ b/stream-servers/RenderThread.cpp
@@ -295,7 +295,7 @@ // it's completely initialized before running any GL commands. FrameBuffer::waitUntilInitialized(); if (goldfish_vk::getGlobalVkEmulation()) { - tInfo.m_vkDec = std::make_unique<VkDecoder>(); + tInfo.m_vkInfo.emplace(); } // This is the only place where we try loading from snapshot. @@ -451,9 +451,9 @@ // // Note: It's risky to limit Vulkan decoding to one thread, // so we do it outside the limiter - if (tInfo.m_vkDec) { - last = tInfo.m_vkDec->decode(readBuf.buf(), readBuf.validData(), ioStream, seqnoPtr, - gfxLogger); + if (tInfo.m_vkInfo) { + last = tInfo.m_vkInfo->m_vkDec.decode(readBuf.buf(), readBuf.validData(), ioStream, + seqnoPtr, gfxLogger); if (last > 0) { readBuf.consume(last); progress = true;
diff --git a/stream-servers/RenderThreadInfo.h b/stream-servers/RenderThreadInfo.h index 1da5591..b291c17 100644 --- a/stream-servers/RenderThreadInfo.h +++ b/stream-servers/RenderThreadInfo.h
@@ -23,7 +23,7 @@ #include "RenderContext.h" #include "StalePtrRegistry.h" #include "SyncThread.h" -#include "VkDecoder.h" +#include "RenderThreadInfoVk.h" #include "WindowSurface.h" #include "base/Stream.h" #include "gles1_dec/GLESv1Decoder.h" @@ -63,7 +63,6 @@ GLESv1Decoder m_glDec; GLESv2Decoder m_gl2Dec; renderControl_decoder_context_t m_rcDec; - std::unique_ptr<VkDecoder> m_vkDec; // All the contexts that are created by this render thread. // New emulator manages contexts in guest process level, @@ -77,6 +76,8 @@ uint64_t m_puid = 0; std::optional<std::string> m_processName; + std::optional<goldfish_vk::RenderThreadInfoVk> m_vkInfo; + // Functions to save / load a snapshot // They must be called after Framebuffer snapshot void onSave(android::base::Stream* stream);
diff --git a/stream-servers/vulkan/RenderThreadInfoVk.h b/stream-servers/vulkan/RenderThreadInfoVk.h new file mode 100644 index 0000000..bbacebf --- /dev/null +++ b/stream-servers/vulkan/RenderThreadInfoVk.h
@@ -0,0 +1,28 @@ +// Copyright 2022 The Android Open Source Project +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either expresso or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +#pragma once + +#include <optional> +#include <string> + +#include "VkDecoder.h" + +namespace goldfish_vk { + +struct RenderThreadInfoVk { + VkDecoder m_vkDec; +}; + +} // namespace goldfish_vk