Reland^2: Use "gfxstream" namespace
This reverts commit d37d7c8c0cdf6b84d453cb41e358094880a8f3b5.
Reland adds in aosp/2516595 which was only built on the "full"
target and removes namespace around window methods to satisfy
MacOS build.
Bug: b/271464937
Test: android build
Test: cmake build
Test: ATP MacOS build
Change-Id: Ida36ac16f9c3b98aedd744d21c9b27e9063a8eea
diff --git a/stream-servers/BorrowedImage.h b/stream-servers/BorrowedImage.h
index 16079e9..ed28905 100644
--- a/stream-servers/BorrowedImage.h
+++ b/stream-servers/BorrowedImage.h
@@ -14,6 +14,8 @@
#pragma once
+namespace gfxstream {
+
// Common base struct representing images (Gl/Vk) that are borrowed
// by server components (e.g. CompositorGl, CompositorVk, DisplayVk)
// from the underlying server image owner (GlEmulation/VkEmulation).
@@ -24,3 +26,5 @@
uint32_t width = 0;
uint32_t height = 0;
};
+
+} // namespace gfxstream
diff --git a/stream-servers/Buffer.cpp b/stream-servers/Buffer.cpp
index a65d6ec..1858924 100644
--- a/stream-servers/Buffer.cpp
+++ b/stream-servers/Buffer.cpp
@@ -27,9 +27,8 @@
Buffer::Buffer(HandleType handle, uint64_t size) : mHandle(handle), mSize(size) {}
/*static*/
-std::shared_ptr<Buffer> Buffer::create(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation* emulationVk, uint64_t size,
- HandleType handle) {
+std::shared_ptr<Buffer> Buffer::create(gl::EmulationGl* emulationGl, vk::VkEmulation* emulationVk,
+ uint64_t size, HandleType handle) {
std::shared_ptr<Buffer> buffer(new Buffer(handle, size));
if (emulationGl) {
@@ -43,7 +42,7 @@
if (emulationVk && emulationVk->live) {
const bool vulkanOnly = emulationGl == nullptr;
- buffer->mBufferVk = BufferVk::create(handle, size, vulkanOnly);
+ buffer->mBufferVk = vk::BufferVk::create(handle, size, vulkanOnly);
if (!buffer->mBufferVk) {
ERR("Failed to initialize BufferVk.");
return nullptr;
@@ -62,8 +61,8 @@
}
/*static*/
-std::shared_ptr<Buffer> Buffer::onLoad(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation*, android::base::Stream* stream) {
+std::shared_ptr<Buffer> Buffer::onLoad(gl::EmulationGl* emulationGl, vk::VkEmulation*,
+ android::base::Stream* stream) {
const auto handle = static_cast<HandleType>(stream->getBe32());
const auto size = static_cast<uint64_t>(stream->getBe64());
diff --git a/stream-servers/Buffer.h b/stream-servers/Buffer.h
index 9a48700..5db0db3 100644
--- a/stream-servers/Buffer.h
+++ b/stream-servers/Buffer.h
@@ -22,23 +22,28 @@
#include "snapshot/LazySnapshotObj.h"
namespace gfxstream {
-class BufferVk;
+namespace gl {
class EmulationGl;
+} // namespace gl
} // namespace gfxstream
-namespace goldfish_vk {
+
+namespace gfxstream {
+namespace vk {
+class BufferVk;
struct VkEmulation;
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
namespace gfxstream {
class Buffer : public android::snapshot::LazySnapshotObj<Buffer> {
public:
- static std::shared_ptr<Buffer> create(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation* emulationVk, uint64_t size,
+ static std::shared_ptr<Buffer> create(gl::EmulationGl* emulationGl,
+ vk::VkEmulation* emulationVk, uint64_t size,
HandleType handle);
- static std::shared_ptr<Buffer> onLoad(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation* emulationVk,
+ static std::shared_ptr<Buffer> onLoad(gl::EmulationGl* emulationGl,
+ vk::VkEmulation* emulationVk,
android::base::Stream* stream);
void onSave(android::base::Stream* stream);
@@ -57,10 +62,10 @@
const HandleType mHandle;
// If GL emulation is enabled.
- std::unique_ptr<gfxstream::BufferGl> mBufferGl;
+ std::unique_ptr<gl::BufferGl> mBufferGl;
// If Vk emulation is enabled.
- std::unique_ptr<BufferVk> mBufferVk;
+ std::unique_ptr<vk::BufferVk> mBufferVk;
};
typedef std::shared_ptr<Buffer> BufferPtr;
diff --git a/stream-servers/ChannelStream.cpp b/stream-servers/ChannelStream.cpp
index 88846ba..3e9f413 100644
--- a/stream-servers/ChannelStream.cpp
+++ b/stream-servers/ChannelStream.cpp
@@ -23,7 +23,7 @@
#include <assert.h>
#include <memory.h>
-namespace emugl {
+namespace gfxstream {
using IoResult = RenderChannel::IoResult;
using emugl::ABORT_REASON_OTHER;
@@ -90,12 +90,10 @@
}
void* ChannelStream::getDmaForReading(uint64_t guest_paddr) {
- return g_emugl_dma_get_host_addr(guest_paddr);
+ return emugl::g_emugl_dma_get_host_addr(guest_paddr);
}
-void ChannelStream::unlockDma(uint64_t guest_paddr) {
- g_emugl_dma_unlock(guest_paddr);
-}
+void ChannelStream::unlockDma(uint64_t guest_paddr) { emugl::g_emugl_dma_unlock(guest_paddr); }
void ChannelStream::forceStop() {
mChannel->stopFromHost();
@@ -129,4 +127,4 @@
return reinterpret_cast<unsigned char*>(mWriteBuffer.data());
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/ChannelStream.h b/stream-servers/ChannelStream.h
index fa65657..43b92fa 100644
--- a/stream-servers/ChannelStream.h
+++ b/stream-servers/ChannelStream.h
@@ -18,7 +18,7 @@
#include <memory>
-namespace emugl {
+namespace gfxstream {
// An IOStream instance that can be used by the host RenderThread to
// wrap a RenderChannelImpl channel.
@@ -48,4 +48,4 @@
size_t mReadBufferLeft = 0;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/ColorBuffer.cpp b/stream-servers/ColorBuffer.cpp
index eb1dbe5..9346138 100644
--- a/stream-servers/ColorBuffer.cpp
+++ b/stream-servers/ColorBuffer.cpp
@@ -24,6 +24,7 @@
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
+namespace gfxstream {
namespace {
// ColorBufferVk natively supports YUV images. However, ColorBufferGl
@@ -46,9 +47,9 @@
mFrameworkFormat(frameworkFormat) {}
/*static*/
-std::shared_ptr<ColorBuffer> ColorBuffer::create(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation* emulationVk,
- uint32_t width, uint32_t height, GLenum format,
+std::shared_ptr<ColorBuffer> ColorBuffer::create(gl::EmulationGl* emulationGl,
+ vk::VkEmulation* emulationVk, uint32_t width,
+ uint32_t height, GLenum format,
FrameworkFormat frameworkFormat,
HandleType handle) {
std::shared_ptr<ColorBuffer> colorBuffer(
@@ -67,8 +68,8 @@
const bool vulkanOnly = colorBuffer->mColorBufferGl == nullptr;
colorBuffer->mColorBufferVk =
- gfxstream::ColorBufferVk::create(handle, width, height, format, frameworkFormat,
- vulkanOnly, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
+ vk::ColorBufferVk::create(handle, width, height, format, frameworkFormat, vulkanOnly,
+ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
if (!colorBuffer->mColorBufferVk) {
if (emulationGl) {
// Historically, ColorBufferVk setup was deferred until the first actual Vulkan
@@ -84,7 +85,7 @@
if (colorBuffer->mColorBufferGl && colorBuffer->mColorBufferVk &&
!b271028352Workaround && shouldAttemptExternalMemorySharing(frameworkFormat)) {
- auto memoryExport = goldfish_vk::exportColorBufferMemory(handle);
+ auto memoryExport = vk::exportColorBufferMemory(handle);
if (memoryExport) {
if (colorBuffer->mColorBufferGl->importMemory(
std::move(memoryExport->descriptor), memoryExport->size,
@@ -101,8 +102,7 @@
}
/*static*/
-std::shared_ptr<ColorBuffer> ColorBuffer::onLoad(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation*,
+std::shared_ptr<ColorBuffer> ColorBuffer::onLoad(gl::EmulationGl* emulationGl, vk::VkEmulation*,
android::base::Stream* stream) {
const auto handle = static_cast<HandleType>(stream->getBe32());
const auto width = static_cast<uint32_t>(stream->getBe32());
@@ -161,7 +161,7 @@
}
void ColorBuffer::readToBytesScaled(int pixelsWidth, int pixelsHeight, GLenum pixelsFormat,
- GLenum pixelsType, int pixelsRotation, emugl::Rect rect,
+ GLenum pixelsType, int pixelsRotation, Rect rect,
void* outPixels) {
touch();
@@ -245,7 +245,7 @@
if (!mColorBufferVk) {
GFXSTREAM_ABORT(FatalError(ABORT_REASON_OTHER)) << "ColorBufferGl not available.";
}
- return goldfish_vk::borrowColorBufferForComposition(getHndl(), isTarget);
+ return vk::borrowColorBufferForComposition(getHndl(), isTarget);
}
}
GFXSTREAM_ABORT(FatalError(ABORT_REASON_OTHER)) << "Unimplemented";
@@ -264,7 +264,7 @@
if (!mColorBufferVk) {
GFXSTREAM_ABORT(FatalError(ABORT_REASON_OTHER)) << "ColorBufferGl not available.";
}
- return goldfish_vk::borrowColorBufferForDisplay(getHndl());
+ return vk::borrowColorBufferForDisplay(getHndl());
}
}
GFXSTREAM_ABORT(FatalError(ABORT_REASON_OTHER)) << "Unimplemented";
@@ -295,7 +295,7 @@
}
std::vector<uint8_t> contents;
- if (!goldfish_vk::readColorBufferToBytes(mHandle, &contents)) {
+ if (!vk::readColorBufferToBytes(mHandle, &contents)) {
ERR("Failed to get VK contents for ColorBuffer:%d", mHandle);
return false;
}
@@ -505,3 +505,5 @@
mColorBufferGl->postViewportScaledWithOverlay(rotation, dx, dy);
}
+
+} // namespace gfxstream
diff --git a/stream-servers/ColorBuffer.h b/stream-servers/ColorBuffer.h
index 77f91ee..92cd03c 100644
--- a/stream-servers/ColorBuffer.h
+++ b/stream-servers/ColorBuffer.h
@@ -26,22 +26,29 @@
#include "snapshot/LazySnapshotObj.h"
namespace gfxstream {
+namespace gl {
class EmulationGl;
-class ColorBufferVk;
+} // namespace gl
} // namespace gfxstream
-namespace goldfish_vk {
+
+namespace gfxstream {
+namespace vk {
+class ColorBufferVk;
struct VkEmulation;
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
+
+namespace gfxstream {
class ColorBuffer : public android::snapshot::LazySnapshotObj<ColorBuffer> {
public:
- static std::shared_ptr<ColorBuffer> create(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation* emulationVk,
- uint32_t width, uint32_t height, GLenum format,
+ static std::shared_ptr<ColorBuffer> create(gl::EmulationGl* emulationGl,
+ vk::VkEmulation* emulationVk, uint32_t width,
+ uint32_t height, GLenum format,
FrameworkFormat frameworkFormat, HandleType handle);
- static std::shared_ptr<ColorBuffer> onLoad(gfxstream::EmulationGl* emulationGl,
- goldfish_vk::VkEmulation* emulationVk,
+ static std::shared_ptr<ColorBuffer> onLoad(gl::EmulationGl* emulationGl,
+ vk::VkEmulation* emulationVk,
android::base::Stream* stream);
void onSave(android::base::Stream* stream);
void restore();
@@ -55,8 +62,7 @@
void readToBytes(int x, int y, int width, int height, GLenum pixelsFormat, GLenum pixelsType,
void* outPixels);
void readToBytesScaled(int pixelsWidth, int pixelsHeight, GLenum pixelsFormat,
- GLenum pixelsType, int pixelsRotation, emugl::Rect rect,
- void* outPixels);
+ GLenum pixelsType, int pixelsRotation, Rect rect, void* outPixels);
void readYuvToBytes(int x, int y, int width, int height, void* outPixels, uint32_t pixelsSize);
bool updateFromBytes(int x, int y, int width, int height, GLenum pixelsFormat,
@@ -105,10 +111,10 @@
const FrameworkFormat mFrameworkFormat;
// If GL emulation is enabled.
- std::unique_ptr<gfxstream::ColorBufferGl> mColorBufferGl;
+ std::unique_ptr<gl::ColorBufferGl> mColorBufferGl;
// If Vk emulation is enabled.
- std::unique_ptr<gfxstream::ColorBufferVk> mColorBufferVk;
+ std::unique_ptr<vk::ColorBufferVk> mColorBufferVk;
bool mGlAndVkAreSharingExternalMemory = false;
};
@@ -130,4 +136,6 @@
};
typedef std::unordered_map<HandleType, ColorBufferRef> ColorBufferMap;
-typedef std::unordered_multiset<HandleType> ColorBufferSet;
\ No newline at end of file
+typedef std::unordered_multiset<HandleType> ColorBufferSet;
+
+} // namespace gfxstream
diff --git a/stream-servers/Compositor.h b/stream-servers/Compositor.h
index c9ed16f..cccd693 100644
--- a/stream-servers/Compositor.h
+++ b/stream-servers/Compositor.h
@@ -21,6 +21,8 @@
#include "BorrowedImage.h"
#include "Hwc2.h"
+namespace gfxstream {
+
// Thread hostile and should only be called from the same single thread.
class Compositor {
public:
@@ -42,3 +44,5 @@
virtual void onImageDestroyed(uint32_t imageId) {}
};
+
+} // namespace gfxstream
diff --git a/stream-servers/ContextHelper.h b/stream-servers/ContextHelper.h
index b4d0a22..a15503b 100644
--- a/stream-servers/ContextHelper.h
+++ b/stream-servers/ContextHelper.h
@@ -14,7 +14,13 @@
#pragma once
+namespace gfxstream {
+namespace gl {
class TextureDraw;
+} // namespace gl
+} // namespace gfxstream
+
+namespace gfxstream {
// ContextHelper interface class used during Buffer and ColorBuffer
// operations. This is introduced to remove coupling from the FrameBuffer
@@ -66,3 +72,5 @@
ContextHelper* mHelper;
bool mNeedUnbind = false;
};
+
+} // namespace gfxstream
diff --git a/stream-servers/FrameBuffer.cpp b/stream-servers/FrameBuffer.cpp
index 3a7baa1..43f2ff1 100644
--- a/stream-servers/FrameBuffer.cpp
+++ b/stream-servers/FrameBuffer.cpp
@@ -56,6 +56,8 @@
#include "vulkan/VkCommonOperations.h"
#include "vulkan/VkDecoderGlobalState.h"
+namespace gfxstream {
+
using android::base::AutoLock;
using android::base::ManagedDescriptor;
using android::base::MetricEventVulkanOutOfMemory;
@@ -65,19 +67,31 @@
using emugl::CreateHealthMonitor;
using emugl::FatalError;
using emugl::GfxApiLogger;
-using gfxstream::EmulatedEglContext;
-using gfxstream::EmulatedEglContextMap;
-using gfxstream::EmulatedEglContextPtr;
-using gfxstream::EmulatedEglFenceSync;
-using gfxstream::EmulatedEglWindowSurface;
-using gfxstream::EmulatedEglWindowSurfaceMap;
-using gfxstream::EmulatedEglWindowSurfacePtr;
-using gfxstream::GLESApi;
-using gfxstream::GLESApi_CM;
-using gfxstream::GLESApi_2;
-using gfxstream::ReadbackWorker;
-using goldfish_vk::VkEmulationFeatures;
-using goldfish_vk::AstcEmulationMode;
+using gl::DisplaySurfaceGl;
+using gl::EmulatedEglConfig;
+using gl::EmulatedEglConfigList;
+using gl::EmulatedEglContext;
+using gl::EmulatedEglContextMap;
+using gl::EmulatedEglContextPtr;
+using gl::EmulatedEglFenceSync;
+using gl::EmulatedEglWindowSurface;
+using gl::EmulatedEglWindowSurfaceMap;
+using gl::EmulatedEglWindowSurfacePtr;
+using gl::EmulationGl;
+using gl::GLES_DISPATCH_MAX_VERSION_2;
+using gl::GLESApi;
+using gl::GLESApi_2;
+using gl::GLESApi_CM;
+using gl::GLESDispatchMaxVersion;
+using gl::RenderThreadInfoGl;
+using gl::s_egl;
+using gl::s_gles2;
+using gl::TextureDraw;
+using gl::YUVConverter;
+using gl::YUVPlane;
+
+using vk::AstcEmulationMode;
+using vk::VkEmulationFeatures;
// static std::string getTimeStampString() {
// const time_t timestamp = android::base::getUnixTimeUs();
@@ -223,11 +237,11 @@
// used by underlying EGL driver might become invalid,
// preventing new contexts from being created that share
// against those contexts.
- goldfish_vk::VkEmulation* vkEmu = nullptr;
- goldfish_vk::VulkanDispatch* vkDispatch = nullptr;
+ vk::VkEmulation* vkEmu = nullptr;
+ vk::VulkanDispatch* vkDispatch = nullptr;
if (feature_is_enabled(kFeature_Vulkan)) {
- vkDispatch = emugl::vkDispatch(false /* not for testing */);
- vkEmu = goldfish_vk::createGlobalVkEmulation(vkDispatch);
+ vkDispatch = vk::vkDispatch(false /* not for testing */);
+ vkEmu = vk::createGlobalVkEmulation(vkDispatch);
if (!vkEmu) {
ERR("Failed to initialize global Vulkan emulation. Disable the Vulkan support.");
}
@@ -259,7 +273,7 @@
// Do not initialize GL emulation if the guest is using ANGLE.
if (!feature_is_enabled(kFeature_GuestUsesAngle)) {
- fb->m_emulationGl = gfxstream::EmulationGl::create(width, height, useSubWindow);
+ fb->m_emulationGl = EmulationGl::create(width, height, useSubWindow);
if (!fb->m_emulationGl) {
ERR("Failed to initialize GL emulation.");
return false;
@@ -388,7 +402,7 @@
GL_LOG("glvk interop final: %d", fb->m_vulkanInteropSupported);
vkEmulationFeatures->glInteropSupported = fb->m_vulkanInteropSupported;
if (feature_is_enabled(kFeature_Vulkan)) {
- goldfish_vk::initVkEmulationFeatures(std::move(vkEmulationFeatures));
+ vk::initVkEmulationFeatures(std::move(vkEmulationFeatures));
if (vkEmu && vkEmu->displayVk) {
fb->m_displayVk = vkEmu->displayVk.get();
fb->m_displaySurfaceUsers.push_back(fb->m_displayVk);
@@ -526,7 +540,7 @@
destroySharedTrivialContext(it.second.context, it.second.surface);
}
- goldfish_vk::teardownGlobalVkEmulation();
+ vk::teardownGlobalVkEmulation();
sInitialized.store(false, std::memory_order_relaxed);
}
@@ -632,17 +646,15 @@
}
std::future<void> FrameBuffer::sendPostWorkerCmd(Post post) {
- bool postOnlyOnMainThread = ::postOnlyOnMainThread();
+ bool shouldPostOnlyOnMainThread = postOnlyOnMainThread();
bool expectedPostThreadStarted = false;
if (m_postThreadStarted.compare_exchange_strong(expectedPostThreadStarted, true)) {
if (m_emulationGl) {
m_emulationGl->setUseBoundSurfaceContextForDisplay(true);
}
- m_postWorker.reset(new PostWorker(postOnlyOnMainThread,
- m_compositor,
- m_displayGl,
- m_displayVk));
+ m_postWorker.reset(
+ new PostWorker(shouldPostOnlyOnMainThread, m_compositor, m_displayGl, m_displayVk));
m_postThread.start();
}
@@ -654,7 +666,7 @@
// For now, this fixes a screenshot issue on macOS.
std::future<void> res = std::async(std::launch::deferred, [] {});
res.wait();
- if (postOnlyOnMainThread && (PostCmd::Screenshot == post.cmd) &&
+ if (shouldPostOnlyOnMainThread && (PostCmd::Screenshot == post.cmd) &&
emugl::get_emugl_window_operations().isRunningInUiThread()) {
post.cb->readToBytesScaled(post.screenshot.screenwidth, post.screenshot.screenheight,
post.screenshot.format, post.screenshot.type,
@@ -663,7 +675,7 @@
} else {
std::future<void> completeFuture =
m_postThread.enqueue(Post(std::move(post)));
- if (!postOnlyOnMainThread ||
+ if (!shouldPostOnlyOnMainThread ||
(PostCmd::Screenshot == post.cmd &&
!emugl::get_emugl_window_operations().isRunningInUiThread())) {
res = std::move(completeFuture);
@@ -672,11 +684,8 @@
return res;
}
-void FrameBuffer::setPostCallback(
- emugl::Renderer::OnPostCallback onPost,
- void* onPostContext,
- uint32_t displayId,
- bool useBgraReadback) {
+void FrameBuffer::setPostCallback(Renderer::OnPostCallback onPost, void* onPostContext,
+ uint32_t displayId, bool useBgraReadback) {
AutoLock lock(m_lock);
if (onPost) {
uint32_t w, h;
@@ -744,7 +753,7 @@
// Do a quick check before even taking the lock - maybe we don't need to
// do anything here.
- const bool createSubWindow = !m_subWin || deleteExisting;
+ const bool shouldCreateSubWindow = !m_subWin || deleteExisting;
// On Mac, since window coordinates are Y-up and not Y-down, the
// subwindow may not change dimensions, but because the main window
@@ -754,17 +763,17 @@
// because the functions used to resize a native window on those hosts
// will block if the shape doesn't actually change, freezing the
// emulator.
- const bool moveSubWindow =
- !createSubWindow && !(m_x == wx && m_y == wy &&
- m_windowWidth == ww && m_windowHeight == wh
+ const bool shouldMoveSubWindow =
+ !shouldCreateSubWindow &&
+ !(m_x == wx && m_y == wy && m_windowWidth == ww && m_windowHeight == wh
#if defined(__APPLE__)
- && m_zRot == zRot
+ && m_zRot == zRot
#endif
- );
+ );
const bool redrawSubwindow =
- createSubWindow || moveSubWindow || m_zRot != zRot || m_dpr != dpr;
- if (!createSubWindow && !moveSubWindow && !redrawSubwindow) {
+ shouldCreateSubWindow || shouldMoveSubWindow || m_zRot != zRot || m_dpr != dpr;
+ if (!shouldCreateSubWindow && !shouldMoveSubWindow && !redrawSubwindow) {
assert(sInitialized.load(std::memory_order_relaxed));
GL_LOG("Exit setupSubWindow (nothing to do)");
#if SNAPSHOT_PROFILE > 1
@@ -843,9 +852,8 @@
m_windowHeight = wh;
if (!hideWindow) {
- m_subWin = ::createSubWindow(p_window, m_x, m_y, m_windowWidth,
- m_windowHeight, dpr, subWindowRepaint, this,
- hideWindow);
+ m_subWin = createSubWindow(p_window, m_x, m_y, m_windowWidth, m_windowHeight, dpr,
+ subWindowRepaint, this, hideWindow);
}
if (m_subWin) {
m_nativeWindow = p_window;
@@ -853,9 +861,8 @@
if (m_displayVk) {
- m_displaySurface = goldfish_vk::createDisplaySurface(m_subWin,
- m_windowWidth,
- m_windowHeight);
+ m_displaySurface =
+ vk::createDisplaySurface(m_subWin, m_windowWidth, m_windowHeight);
} else if (m_emulationGl) {
m_displaySurface = m_emulationGl->createWindowSurface(m_windowWidth,
m_windowHeight,
@@ -906,7 +913,7 @@
// couldn't be created
// in the first place or the EGLSurface couldn't be created.
if (m_subWin) {
- if (!moveSubWindow) {
+ if (!shouldMoveSubWindow) {
// Ensure that at least viewport parameters are properly updated.
success = true;
} else {
@@ -919,8 +926,8 @@
{
auto watchdog = WATCHDOG_BUILDER(m_healthMonitor.get(), "Moving subwindow").build();
- success = ::moveSubWindow(m_nativeWindow, m_subWin, m_x, m_y, m_windowWidth,
- m_windowHeight);
+ success = moveSubWindow(m_nativeWindow, m_subWin, m_x, m_y, m_windowWidth,
+ m_windowHeight);
}
m_displaySurface->updateSize(m_windowWidth, m_windowHeight);
}
@@ -1125,8 +1132,7 @@
<< "Buffer already exists with handle " << handle;
}
- gfxstream::BufferPtr buffer(
- gfxstream::Buffer::create(m_emulationGl.get(), m_emulationVk, p_size, handle));
+ BufferPtr buffer(Buffer::create(m_emulationGl.get(), m_emulationVk, p_size, handle));
if (!buffer) {
ERR("Create buffer failed.\n");
return 0;
@@ -1266,7 +1272,7 @@
mutex.unlock();
for (auto handle : colorBuffersToCleanup) {
- goldfish_vk::teardownVkColorBuffer(handle);
+ vk::teardownVkColorBuffer(handle);
}
}
@@ -1430,7 +1436,7 @@
m_lock.unlock();
for (auto handle: colorBuffersToCleanup) {
- goldfish_vk::teardownVkColorBuffer(handle);
+ vk::teardownVkColorBuffer(handle);
}
}
@@ -1497,7 +1503,7 @@
mutex.unlock();
for (auto handle : toCleanup) {
- goldfish_vk::teardownVkColorBuffer(handle);
+ vk::teardownVkColorBuffer(handle);
}
}
@@ -1679,7 +1685,7 @@
mutex.unlock();
for (auto handle : colorBuffersToCleanup) {
- goldfish_vk::teardownVkColorBuffer(handle);
+ vk::teardownVkColorBuffer(handle);
}
for (auto cb : callbacks) {
@@ -1844,7 +1850,7 @@
void FrameBuffer::readBuffer(HandleType handle, uint64_t offset, uint64_t size, void* bytes) {
AutoLock mutex(m_lock);
- gfxstream::BufferPtr buffer = findBuffer(handle);
+ BufferPtr buffer = findBuffer(handle);
if (!buffer) {
ERR("Failed to read buffer: buffer %d not found.", handle);
return;
@@ -1974,7 +1980,7 @@
bool FrameBuffer::updateBuffer(HandleType p_buffer, uint64_t offset, uint64_t size, void* bytes) {
AutoLock mutex(m_lock);
- gfxstream::BufferPtr buffer = findBuffer(p_buffer);
+ BufferPtr buffer = findBuffer(p_buffer);
if (!buffer) {
ERR("Failed to update buffer: buffer %d not found.", p_buffer);
return false;
@@ -2559,12 +2565,11 @@
return m_emulationGl && m_emulationGl->isAsyncReadbackSupported();
}
-emugl::Renderer::ReadPixelsCallback
-FrameBuffer::getReadPixelsCallback() {
+Renderer::ReadPixelsCallback FrameBuffer::getReadPixelsCallback() {
return sFrameBuffer_ReadPixelsCallback;
}
-emugl::Renderer::FlushReadPixelPipeline FrameBuffer::getFlushReadPixelPipeline() {
+Renderer::FlushReadPixelPipeline FrameBuffer::getFlushReadPixelPipeline() {
return sFrameBuffer_FlushReadPixelPipeline;
}
@@ -2620,7 +2625,7 @@
int FrameBuffer::getScreenshot(unsigned int nChannels, unsigned int* width, unsigned int* height,
uint8_t* pixels, size_t* cPixels, int displayId, int desiredWidth,
- int desiredHeight, int desiredRotation, emugl::Rect rect) {
+ int desiredHeight, int desiredRotation, Rect rect) {
AutoLock mutex(m_lock);
uint32_t w, h, cb, screenWidth, screenHeight;
if (!emugl::get_emugl_multi_display_operations().getMultiDisplay(displayId,
@@ -2936,9 +2941,8 @@
saveProcOwnedCollection(stream, m_procOwnedEmulatedEglContexts);
// Save Vulkan state
- if (feature_is_enabled(kFeature_VulkanSnapshots) &&
- goldfish_vk::VkDecoderGlobalState::get()) {
- goldfish_vk::VkDecoderGlobalState::get()->save(stream);
+ if (feature_is_enabled(kFeature_VulkanSnapshots) && vk::VkDecoderGlobalState::get()) {
+ vk::VkDecoderGlobalState::get()->save(stream);
}
if (m_emulationGl) {
@@ -3039,7 +3043,7 @@
lock.unlock();
for (auto colorBufferHandle : colorBuffersToCleanup) {
- goldfish_vk::teardownVkColorBuffer(colorBufferHandle);
+ vk::teardownVkColorBuffer(colorBufferHandle);
}
for (auto cb : cleanupCallbacks) {
@@ -3182,14 +3186,11 @@
}
// Restore Vulkan state
- if (feature_is_enabled(kFeature_VulkanSnapshots) &&
- goldfish_vk::VkDecoderGlobalState::get()) {
-
+ if (feature_is_enabled(kFeature_VulkanSnapshots) && vk::VkDecoderGlobalState::get()) {
lock.unlock();
GfxApiLogger gfxLogger;
- goldfish_vk::VkDecoderGlobalState::get()->load(stream, gfxLogger, m_healthMonitor.get());
+ vk::VkDecoderGlobalState::get()->load(stream, gfxLogger, m_healthMonitor.get());
lock.lock();
-
}
repost(false);
@@ -3228,7 +3229,7 @@
}
}
-gfxstream::BufferPtr FrameBuffer::findBuffer(HandleType p_buffer) {
+BufferPtr FrameBuffer::findBuffer(HandleType p_buffer) {
AutoLock colorBufferMapLock(m_colorBufferMapLock);
BufferMap::iterator b(m_buffers.find(p_buffer));
if (b == m_buffers.end()) {
@@ -3323,7 +3324,7 @@
bool needCleanup = decColorBufferRefCountLocked(handleToDestroy);
if (needCleanup) {
m_lock.unlock();
- goldfish_vk::teardownVkColorBuffer(handleToDestroy);
+ vk::teardownVkColorBuffer(handleToDestroy);
m_lock.lock();
}
}
@@ -3498,7 +3499,7 @@
return colorBufferPtr->borrowForDisplay(api);
}
-gfxstream::EmulationGl& FrameBuffer::getEmulationGl() {
+EmulationGl& FrameBuffer::getEmulationGl() {
if (!m_emulationGl) {
GFXSTREAM_ABORT(FatalError(ABORT_REASON_OTHER))
<< "GL/EGL emulation not enabled.";
@@ -3757,3 +3758,5 @@
}
return colorBuffer->invalidateForVk();
}
+
+} // namespace gfxstream
diff --git a/stream-servers/FrameBuffer.h b/stream-servers/FrameBuffer.h
index 563a6c3..f000948 100644
--- a/stream-servers/FrameBuffer.h
+++ b/stream-servers/FrameBuffer.h
@@ -66,14 +66,20 @@
#include "utils/RenderDoc.h"
#include "vulkan/vk_util.h"
+namespace gfxstream {
+namespace vk {
+class DisplayVk;
+} // namespace vk
+} // namespace gfxstream
+
+namespace gfxstream {
+
using android::base::CreateMetricsLogger;
using emugl::HealthMonitor;
using emugl::MetricsLogger;
-class DisplayVk;
-
struct BufferRef {
- gfxstream::BufferPtr buffer;
+ BufferPtr buffer;
};
class ProcessResources {
@@ -95,11 +101,10 @@
mutable std::atomic<uint32_t> mSequenceNumber;
};
-typedef std::unordered_map<uint64_t, gfxstream::EmulatedEglWindowSurfaceSet>
+typedef std::unordered_map<uint64_t, gl::EmulatedEglWindowSurfaceSet>
ProcOwnedEmulatedEglWindowSurfaces;
-typedef std::unordered_map<uint64_t, gfxstream::EmulatedEglContextSet>
- ProcOwnedEmulatedEglContexts;
+typedef std::unordered_map<uint64_t, gl::EmulatedEglContextSet> ProcOwnedEmulatedEglContexts;
typedef std::unordered_map<uint64_t, ColorBufferSet> ProcOwnedColorBuffers;
@@ -107,8 +112,7 @@
typedef std::unordered_multiset<HandleType> BufferSet;
typedef std::unordered_map<uint64_t, BufferSet> ProcOwnedBuffers;
-typedef std::unordered_map<uint64_t, gfxstream::EmulatedEglImageSet>
- ProcOwnedEmulatedEGLImages;
+typedef std::unordered_map<uint64_t, gl::EmulatedEglImageSet> ProcOwnedEmulatedEGLImages;
typedef std::unordered_map<void*, std::function<void()>> CallbackMap;
typedef std::unordered_map<uint64_t, CallbackMap> ProcOwnedCleanupCallbacks;
@@ -120,7 +124,7 @@
// There is only one global instance, that can be retrieved with getFB(),
// and which must be previously setup by calling initialize().
//
-class FrameBuffer : public android::base::EventNotificationSupport<emugl::FrameBufferChangeEvent> {
+class FrameBuffer : public android::base::EventNotificationSupport<FrameBufferChangeEvent> {
public:
// Initialize the global instance.
// |width| and |height| are the dimensions of the emulator GPU display
@@ -177,13 +181,12 @@
int getHeight() const { return m_framebufferHeight; }
// Return the list of configs available from this display.
- const EmulatedEglConfigList* getConfigs() const;
+ const gl::EmulatedEglConfigList* getConfigs() const;
// Set a callback that will be called each time the emulated GPU content
// is updated. This can be relatively slow with host-based GPU emulation,
// so only do this when you need to.
- void setPostCallback(emugl::Renderer::OnPostCallback onPost,
- void* onPostContext, uint32_t displayId,
+ void setPostCallback(Renderer::OnPostCallback onPost, void* onPostContext, uint32_t displayId,
bool useBgraReadback = false);
// Retrieve the GL strings of the underlying EGL/GLES implementation.
@@ -202,7 +205,7 @@
// |version| specifies the GLES version as a GLESApi enum.
// Return a new handle value, which will be 0 in case of error.
HandleType createEmulatedEglContext(int p_config, HandleType p_share,
- gfxstream::GLESApi version = gfxstream::GLESApi_CM);
+ gl::GLESApi version = gl::GLESApi_CM);
// Destroy a given EmulatedEglContext instance. |p_context| is its handle
// value as returned by createEmulatedEglContext().
@@ -304,10 +307,10 @@
HandleType p_readSurface);
// Return a render context pointer from its handle
- gfxstream::EmulatedEglContextPtr getContext_locked(HandleType p_context);
+ gl::EmulatedEglContextPtr getContext_locked(HandleType p_context);
// Return a color buffer pointer from its handle
- gfxstream::EmulatedEglWindowSurfacePtr getWindowSurface_locked(HandleType p_windowsurface);
+ gl::EmulatedEglWindowSurfacePtr getWindowSurface_locked(HandleType p_windowsurface);
// Attach a ColorBuffer to a EmulatedEglWindowSurface instance.
// See the documentation for EmulatedEglWindowSurface::setColorBuffer().
@@ -452,15 +455,15 @@
void ensureReadbackWorker();
bool asyncReadbackSupported();
- emugl::Renderer::ReadPixelsCallback getReadPixelsCallback();
- emugl::Renderer::FlushReadPixelPipeline getFlushReadPixelPipeline();
+ Renderer::ReadPixelsCallback getReadPixelsCallback();
+ Renderer::FlushReadPixelPipeline getFlushReadPixelPipeline();
// Re-post the last ColorBuffer that was displayed through post().
// This is useful if you detect that the sub-window content needs to
// be re-displayed for any reason.
bool repost(bool needLockAndBind = true);
- gfxstream::EmulationGl& getEmulationGl();
+ gl::EmulationGl& getEmulationGl();
bool hasEmulationGl() const { return m_emulationGl != nullptr; }
// Return the host EGLDisplay used by this instance.
@@ -497,7 +500,7 @@
// Return a TextureDraw instance that can be used with this surfaces
// and windows created by this instance.
- TextureDraw* getTextureDraw() const;
+ gl::TextureDraw* getTextureDraw() const;
// Create an eglImage and return its handle. Reference:
// https://www.khronos.org/registry/egl/extensions/KHR/EGL_KHR_image_base.txt
@@ -542,7 +545,7 @@
void lock();
void unlock();
- GLESDispatchMaxVersion getMaxGLESVersion();
+ gl::GLESDispatchMaxVersion getMaxGLESVersion();
float getDpr() const { return m_dpr; }
int windowWidth() const { return m_windowWidth; }
@@ -581,11 +584,11 @@
// desiredWidth and desiredHeight.
int getScreenshot(unsigned int nChannels, unsigned int* width, unsigned int* height,
uint8_t* pixels, size_t* cPixels, int displayId, int desiredWidth,
- int desiredHeight, int desiredRotation, emugl::Rect rect = {{0, 0}, {0, 0}});
+ int desiredHeight, int desiredRotation, Rect rect = {{0, 0}, {0, 0}});
void onLastColorBufferRef(uint32_t handle);
ColorBufferPtr findColorBuffer(HandleType p_colorbuffer);
- gfxstream::BufferPtr findBuffer(HandleType p_buffer);
+ BufferPtr findBuffer(HandleType p_buffer);
void registerProcessCleanupCallback(void* key,
std::function<void()> callback);
@@ -693,7 +696,7 @@
bool postImplSync(HandleType p_colorbuffer, bool needLockAndBind = true, bool repaint = false);
void setGuestPostedAFrame() {
m_guestPostedAFrame = true;
- fireEvent({emugl::FrameBufferChange::FrameReady, mFrameNumber++});
+ fireEvent({FrameBufferChange::FrameReady, mFrameNumber++});
}
HandleType createColorBufferWithHandleLocked(int p_width, int p_height, GLenum p_internalFormat,
FrameworkFormat p_frameworkFormat,
@@ -731,9 +734,9 @@
android::base::Lock m_colorBufferMapLock;
uint64_t mFrameNumber;
FBNativeWindowType m_nativeWindow = 0;
- gfxstream::EmulatedEglContextMap m_contexts;
- gfxstream::EmulatedEglImageMap m_images;
- gfxstream::EmulatedEglWindowSurfaceMap m_windows;
+ gl::EmulatedEglContextMap m_contexts;
+ gl::EmulatedEglImageMap m_images;
+ gl::EmulatedEglWindowSurfaceMap m_windows;
ColorBufferMap m_colorbuffers;
BufferMap m_buffers;
std::unordered_map<HandleType, HandleType> m_EmulatedEglWindowSurfaceToColorBuffer;
@@ -782,7 +785,7 @@
bool m_guestPostedAFrame = false;
struct onPost {
- emugl::Renderer::OnPostCallback cb;
+ Renderer::OnPostCallback cb;
void* context;
uint32_t displayId;
uint32_t width;
@@ -797,7 +800,7 @@
}
};
std::map<uint32_t, onPost> m_onPost;
- gfxstream::ReadbackWorker* m_readbackWorker = nullptr;
+ ReadbackWorker* m_readbackWorker = nullptr;
android::base::WorkerThread<Readback> m_readbackThread;
std::atomic_bool m_readbackThreadStarted = false;
@@ -850,28 +853,27 @@
android::base::MessageChannel<HandleType, 1024>
mOutstandingColorBufferDestroys;
- std::unique_ptr<gfxstream::EmulationGl> m_emulationGl;
- DisplayGl* m_displayGl = nullptr;
+ std::unique_ptr<gl::EmulationGl> m_emulationGl;
+ gl::DisplayGl* m_displayGl = nullptr;
Compositor* m_compositor = nullptr;
bool m_useVulkanComposition = false;
- goldfish_vk::VkEmulation* m_emulationVk = nullptr;
+ vk::VkEmulation* m_emulationVk = nullptr;
// The implementation for Vulkan native swapchain. Only initialized when useVulkan is set when
// calling FrameBuffer::initialize(). DisplayVk is actually owned by VkEmulation.
- DisplayVk *m_displayVk = nullptr;
+ vk::DisplayVk* m_displayVk = nullptr;
VkInstance m_vkInstance = VK_NULL_HANDLE;
std::unique_ptr<emugl::RenderDoc> m_renderDoc = nullptr;
// TODO(b/233939967): Refactor to create DisplayGl and DisplaySurfaceGl
// and remove usage of non-generic DisplayVk.
- gfxstream::Display* m_display;
- std::unique_ptr<gfxstream::DisplaySurface> m_displaySurface;
+ Display* m_display;
+ std::unique_ptr<DisplaySurface> m_displaySurface;
// CompositorGl.
// TODO: update RenderDoc to be a DisplaySurfaceUser.
- std::vector<gfxstream::DisplaySurfaceUser*> m_displaySurfaceUsers;
-
+ std::vector<DisplaySurfaceUser*> m_displaySurfaceUsers;
// UUIDs of physical devices for Vulkan and GLES, respectively. In most
// cases, this determines whether we can support zero-copy interop.
@@ -907,4 +909,7 @@
std::map<int, DisplayConfig> mDisplayConfigs;
int mDisplayActiveConfigId = -1;
};
+
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/FrameworkFormats.h b/stream-servers/FrameworkFormats.h
index d6ca5f7..ba1e457 100644
--- a/stream-servers/FrameworkFormats.h
+++ b/stream-servers/FrameworkFormats.h
@@ -1,5 +1,7 @@
#pragma once
+namespace gfxstream {
+
// Android system might want to allocate some color buffers with formats
// that are not compatible with most OpenGL implementations,
// such as YV12.
@@ -19,3 +21,5 @@
FRAMEWORK_FORMAT_NV12 = 3,
FRAMEWORK_FORMAT_P010 = 4,
};
+
+} // namespace gfxstream
diff --git a/stream-servers/Handle.h b/stream-servers/Handle.h
index 873e874..c2fd6c0 100644
--- a/stream-servers/Handle.h
+++ b/stream-servers/Handle.h
@@ -17,6 +17,10 @@
#include <cstdint>
#include <unordered_set>
-typedef uint32_t HandleType;
-typedef std::unordered_set<HandleType> ThreadContextSet;
-typedef std::unordered_set<HandleType> WindowSurfaceSet;
\ No newline at end of file
+namespace gfxstream {
+
+using HandleType = uint32_t;
+using ThreadContextSet = std::unordered_set<HandleType>;
+using WindowSurfaceSet = std::unordered_set<HandleType>;
+
+} // namespace gfxstream
diff --git a/stream-servers/Hwc2.cpp b/stream-servers/Hwc2.cpp
index bf82ef1..b4629bd 100644
--- a/stream-servers/Hwc2.cpp
+++ b/stream-servers/Hwc2.cpp
@@ -14,6 +14,8 @@
#include "Hwc2.h"
+namespace gfxstream {
+
std::unique_ptr<FlatComposeRequest> ToFlatComposeRequest(
const ComposeDevice* composeRequest) {
auto flatComposeRequest = std::make_unique<FlatComposeRequest>();
@@ -35,3 +37,5 @@
}
return flatComposeRequest;
}
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/Hwc2.h b/stream-servers/Hwc2.h
index 90c7f4b..6b5e004 100644
--- a/stream-servers/Hwc2.h
+++ b/stream-servers/Hwc2.h
@@ -20,6 +20,8 @@
#include <stdint.h>
#include <vector>
+namespace gfxstream {
+
/* Copied from Android source */
// Should be identical to graphics-base-v1.0.h
@@ -120,4 +122,6 @@
std::unique_ptr<FlatComposeRequest> ToFlatComposeRequest(const ComposeDevice* in);
std::unique_ptr<FlatComposeRequest> ToFlatComposeRequest(const ComposeDevice_v2* in);
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/IOStream.h b/stream-servers/IOStream.h
index bb71454..6538dcb 100644
--- a/stream-servers/IOStream.h
+++ b/stream-servers/IOStream.h
@@ -23,6 +23,8 @@
#include <stdlib.h>
#include <stdio.h>
+namespace gfxstream {
+
class IOStream {
protected:
explicit IOStream(size_t bufSize) : m_bufsize(bufSize) {}
@@ -110,3 +112,5 @@
size_t m_bufsize;
size_t m_free = 0;
};
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/NativeSubWindow_x11.cpp b/stream-servers/NativeSubWindow_x11.cpp
index 0b57425..58f96fd 100644
--- a/stream-servers/NativeSubWindow_x11.cpp
+++ b/stream-servers/NativeSubWindow_x11.cpp
@@ -18,6 +18,8 @@
#include <stdio.h>
+namespace {
+
static Bool WaitForMapNotify(Display *d, XEvent *e, char *arg) {
if (e->type == MapNotify && e->xmap.window == (Window)arg) {
return 1;
@@ -34,6 +36,8 @@
static Display *s_display = NULL;
+} // namespace
+
EGLNativeWindowType createSubWindow(FBNativeWindowType p_window,
int x,
int y,
diff --git a/stream-servers/PostCommands.h b/stream-servers/PostCommands.h
index 27dd680..697f695 100644
--- a/stream-servers/PostCommands.h
+++ b/stream-servers/PostCommands.h
@@ -10,6 +10,8 @@
#include "Handle.h"
#include "render-utils/Renderer.h"
+namespace gfxstream {
+
class ColorBuffer;
// Posting
@@ -52,7 +54,9 @@
GLenum type;
int rotation;
void* pixels;
- emugl::Rect rect;
+ Rect rect;
} screenshot;
};
};
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/PostWorker.cpp b/stream-servers/PostWorker.cpp
index 1e83767..2e740dd 100644
--- a/stream-servers/PostWorker.cpp
+++ b/stream-servers/PostWorker.cpp
@@ -30,9 +30,6 @@
#include "vulkan/DisplayVk.h"
#include "vulkan/VkCommonOperations.h"
-using emugl::ABORT_REASON_OTHER;
-using emugl::FatalError;
-
#define POST_DEBUG 0
#if POST_DEBUG >= 1
#define DD(fmt, ...) \
@@ -54,8 +51,14 @@
(void)wait;
}
+namespace gfxstream {
namespace {
+using emugl::ABORT_REASON_OTHER;
+using emugl::FatalError;
+using gl::DisplayGl;
+using vk::DisplayVk;
+
hwc_transform_t getTransformFromRotation(int rotation) {
switch (static_cast<int>(rotation / 90)) {
case 1:
@@ -327,7 +330,7 @@
}
void PostWorker::screenshot(ColorBuffer* cb, int width, int height, GLenum format, GLenum type,
- int rotation, void* pixels, emugl::Rect rect) {
+ int rotation, void* pixels, Rect rect) {
if (m_displayVk) {
GFXSTREAM_ABORT(FatalError(ABORT_REASON_OTHER)) <<
"Screenshot not supported with native Vulkan swapchain enabled.";
@@ -420,3 +423,5 @@
}
return false;
}
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/PostWorker.h b/stream-servers/PostWorker.h
index 614e4f1..a8d0b13 100644
--- a/stream-servers/PostWorker.h
+++ b/stream-servers/PostWorker.h
@@ -31,16 +31,27 @@
#include "gl/DisplayGl.h"
#include "host-common/window_agent.h"
-class ColorBuffer;
+namespace gfxstream {
+namespace gl {
class DisplayGl;
+} // namespace gl
+} // namespace gfxstream
+
+namespace gfxstream {
+namespace vk {
class DisplayVk;
+} // namespace vk
+} // namespace gfxstream
+
+namespace gfxstream {
+class ColorBuffer;
class FrameBuffer;
struct RenderThreadInfo;
class PostWorker {
public:
- PostWorker(bool mainThreadPostingOnly, Compositor* compositor,
- DisplayGl* displayGl, DisplayVk* displayVk);
+ PostWorker(bool mainThreadPostingOnly, Compositor* compositor, gl::DisplayGl* displayGl,
+ vk::DisplayVk* displayVk);
~PostWorker();
// post: posts the next color buffer.
@@ -64,7 +75,7 @@
void clear();
void screenshot(ColorBuffer* cb, int screenwidth, int screenheight, GLenum format, GLenum type,
- int skinRotation, void* pixels, emugl::Rect rect);
+ int skinRotation, void* pixels, Rect rect);
// The block task will set the scheduledSignal promise when the task is scheduled, and wait
// until continueSignal is ready before completes.
@@ -73,7 +84,7 @@
private:
// Impl versions of the above, so we can run it from separate threads
std::shared_future<void> postImpl(ColorBuffer* cb);
- DisplayGl::PostLayer postWithOverlay(ColorBuffer* cb);
+ gl::DisplayGl::PostLayer postWithOverlay(ColorBuffer* cb);
void viewportImpl(int width, int height);
std::shared_future<void> composeImpl(const FlatComposeRequest& composeRequest);
void clearImpl();
@@ -97,14 +108,16 @@
// TODO(b/233939967): conslidate DisplayGl and DisplayVk into
// `Display* const m_display`.
- DisplayGl* const m_displayGl;
+ gl::DisplayGl* const m_displayGl;
// The implementation for Vulkan native swapchain. Only initialized when
// useVulkan is set when calling FrameBuffer::initialize(). PostWorker
// doesn't take the ownership of this DisplayVk object.
- DisplayVk* const m_displayVk;
+ vk::DisplayVk* const m_displayVk;
std::unordered_map<uint32_t, std::shared_future<void>> m_composeTargetToComposeFuture;
bool isComposeTargetReady(uint32_t targetHandle);
DISALLOW_COPY_AND_ASSIGN(PostWorker);
};
+
+} // namespace gfxstream
diff --git a/stream-servers/ReadBuffer.cpp b/stream-servers/ReadBuffer.cpp
index 5e0ef71..32382eb 100644
--- a/stream-servers/ReadBuffer.cpp
+++ b/stream-servers/ReadBuffer.cpp
@@ -23,7 +23,7 @@
#include <string.h>
#include <limits.h>
-namespace emugl {
+namespace gfxstream {
ReadBuffer::ReadBuffer(size_t bufsize) {
m_size = bufsize;
@@ -135,4 +135,4 @@
(float)m_tailMoveTimeUs / 1000.0f);
m_tailMoveTimeUs = 0;
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/ReadBuffer.h b/stream-servers/ReadBuffer.h
index 039923f..3858a10 100644
--- a/stream-servers/ReadBuffer.h
+++ b/stream-servers/ReadBuffer.h
@@ -17,7 +17,7 @@
#include "aemu/base/files/Stream.h"
#include "IOStream.h"
-namespace emugl {
+namespace gfxstream {
class ReadBuffer {
public:
@@ -44,4 +44,4 @@
size_t m_neededFreeTailSize = 0;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/ReadbackWorker.h b/stream-servers/ReadbackWorker.h
index 25a4d72..369a3be 100644
--- a/stream-servers/ReadbackWorker.h
+++ b/stream-servers/ReadbackWorker.h
@@ -15,10 +15,10 @@
*/
#pragma once
-class ColorBuffer;
-
namespace gfxstream {
+class ColorBuffer;
+
// This class implements async readback of ColorBuffers on both the FrameBuffer
// posting thread and a separate worker thread.
class ReadbackWorker {
diff --git a/stream-servers/RenderChannelImpl.cpp b/stream-servers/RenderChannelImpl.cpp
index b3a62d4..7feef24 100644
--- a/stream-servers/RenderChannelImpl.cpp
+++ b/stream-servers/RenderChannelImpl.cpp
@@ -25,7 +25,7 @@
#define EMUGL_DEBUG_LEVEL 0
#include "host-common/debug.h"
-namespace emugl {
+namespace gfxstream {
using Buffer = RenderChannel::Buffer;
using IoResult = android::base::BufferQueueResult;
@@ -221,4 +221,4 @@
mRenderThread->save(stream);
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RenderChannelImpl.h b/stream-servers/RenderChannelImpl.h
index 1e1cb14..b512dee 100644
--- a/stream-servers/RenderChannelImpl.h
+++ b/stream-servers/RenderChannelImpl.h
@@ -17,7 +17,7 @@
#include "render-utils/RenderChannel.h"
#include "RendererImpl.h"
-namespace emugl {
+namespace gfxstream {
class RenderThread;
@@ -113,4 +113,4 @@
BufferQueue<RenderChannel::Buffer> mToGuest;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RenderControl.cpp b/stream-servers/RenderControl.cpp
index eccf73e..902cdbf 100644
--- a/stream-servers/RenderControl.cpp
+++ b/stream-servers/RenderControl.cpp
@@ -40,13 +40,20 @@
#include "vulkan/VkCommonOperations.h"
#include "vulkan/VkDecoderGlobalState.h"
+namespace gfxstream {
+
using android::base::AutoLock;
using android::base::Lock;
using emugl::emugl_sync_device_exists;
using emugl::emugl_sync_register_trigger_wait;
-using gfxstream::GLESApi;
-using gfxstream::GLESApi_CM;
-using gfxstream::EmulatedEglFenceSync;
+using gl::EmulatedEglFenceSync;
+using gl::GLES_DISPATCH_MAX_VERSION_2;
+using gl::GLES_DISPATCH_MAX_VERSION_3_0;
+using gl::GLES_DISPATCH_MAX_VERSION_3_1;
+using gl::GLESApi;
+using gl::GLESApi_CM;
+using gl::GLESDispatchMaxVersion;
+using gl::RenderThreadInfoGl;
#define DEBUG 0
#define DEBUG_GRALLOC_SYNC 0
@@ -282,7 +289,7 @@
return 0;
}
- const char *str = s_egl.eglQueryString(fb->getDisplay(), name);
+ const char* str = gl::s_egl.eglQueryString(fb->getDisplay(), name);
if (!str) {
return 0;
}
@@ -322,22 +329,18 @@
static bool shouldEnableVulkan() {
// TODO: Restrict further to devices supporting external memory.
- return feature_is_enabled(kFeature_Vulkan) && goldfish_vk::getGlobalVkEmulation() &&
- goldfish_vk::VkDecoderGlobalState::get()->getHostFeatureSupport().supportsVulkan;
+ return feature_is_enabled(kFeature_Vulkan) && vk::getGlobalVkEmulation() &&
+ vk::VkDecoderGlobalState::get()->getHostFeatureSupport().supportsVulkan;
}
static bool shouldEnableDeferredVulkanCommands() {
- auto supportInfo =
- goldfish_vk::VkDecoderGlobalState::get()->
- getHostFeatureSupport();
+ auto supportInfo = vk::VkDecoderGlobalState::get()->getHostFeatureSupport();
return supportInfo.supportsVulkan &&
supportInfo.useDeferredCommands;
}
static bool shouldEnableCreateResourcesWithRequirements() {
- auto supportInfo =
- goldfish_vk::VkDecoderGlobalState::get()->
- getHostFeatureSupport();
+ auto supportInfo = vk::VkDecoderGlobalState::get()->getHostFeatureSupport();
return supportInfo.supportsVulkan &&
supportInfo.useCreateResourcesWithRequirements;
}
@@ -445,10 +448,10 @@
if (tInfo && tInfo->currContext.get()) {
const char *str = nullptr;
if (tInfo->currContext->clientVersion() > GLESApi_CM) {
- str = (const char *)s_gles2.glGetString(name);
+ str = (const char*)gl::s_gles2.glGetString(name);
}
else {
- str = (const char *)s_gles1.glGetString(name);
+ str = (const char*)gl::s_gles1.glGetString(name);
}
if (str) {
glStr += str;
@@ -460,7 +463,7 @@
// filter extensions by name to match guest-side support
GLESDispatchMaxVersion maxVersion = FrameBuffer::getFB()->getMaxGLESVersion();
if (name == GL_EXTENSIONS) {
- glStr = filterExtensionsBasedOnMaxVersion(maxVersion, glStr);
+ glStr = gl::filterExtensionsBasedOnMaxVersion(maxVersion, glStr);
}
bool isChecksumEnabled =
@@ -669,7 +672,7 @@
: "<no GL emulation>";
const bool hasNativeAstc =
glExtensions.find("GL_KHR_texture_compression_astc_ldr") != std::string::npos;
- const bool hasAstcDecompressor = goldfish_vk::AstcCpuDecompressor::get().available();
+ const bool hasAstcDecompressor = vk::AstcCpuDecompressor::get().available();
if (hasNativeAstc || hasAstcDecompressor) {
glStr += "GL_KHR_texture_compression_astc_ldr ";
} else {
@@ -1406,7 +1409,7 @@
bool modeIsVulkanOnly = mode == VULKAN_MODE_VULKAN_ONLY;
- if (!goldfish_vk::setColorBufferVulkanMode(colorBuffer, mode)) {
+ if (!vk::setColorBufferVulkanMode(colorBuffer, mode)) {
fprintf(stderr,
"%s: error: failed to set Vulkan mode for colorBuffer 0x%x\n",
__func__, colorBuffer);
@@ -1422,7 +1425,7 @@
}
static int32_t rcMapGpaToBufferHandle(uint32_t bufferHandle, uint64_t gpa) {
- int32_t result = goldfish_vk::mapGpaToBufferHandle(bufferHandle, gpa);
+ int32_t result = vk::mapGpaToBufferHandle(bufferHandle, gpa);
if (result < 0) {
fprintf(stderr,
"%s: error: failed to map gpa %" PRIx64 " to buffer handle 0x%x: %d\n",
@@ -1434,7 +1437,7 @@
static int32_t rcMapGpaToBufferHandle2(uint32_t bufferHandle,
uint64_t gpa,
uint64_t size) {
- int32_t result = goldfish_vk::mapGpaToBufferHandle(bufferHandle, gpa, size);
+ int32_t result = vk::mapGpaToBufferHandle(bufferHandle, gpa, size);
if (result < 0) {
fprintf(stderr,
"%s: error: failed to map gpa %" PRIx64 " to buffer handle 0x%x: %d\n",
@@ -1617,3 +1620,5 @@
dec->rcSetProcessMetadata = rcSetProcessMetadata;
dec->rcGetHostExtensionsString = rcGetHostExtensionsString;
}
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/RenderControl.h b/stream-servers/RenderControl.h
index 625549e..d7a622d 100644
--- a/stream-servers/RenderControl.h
+++ b/stream-servers/RenderControl.h
@@ -18,7 +18,11 @@
#include "renderControl_dec/renderControl_dec.h"
+namespace gfxstream {
+
void initRenderControlContext(renderControl_decoder_context_t *dec);
void registerTriggerWait();
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/RenderLibImpl.cpp b/stream-servers/RenderLibImpl.cpp
index b944140..600feff 100644
--- a/stream-servers/RenderLibImpl.cpp
+++ b/stream-servers/RenderLibImpl.cpp
@@ -27,7 +27,7 @@
#include "host-common/opengl/misc.h"
#include "host-common/sync_device.h"
-namespace emugl {
+namespace gfxstream {
void RenderLibImpl::setRenderer(SelectedRenderer renderer) {
emugl::setRenderer(renderer);
@@ -66,17 +66,17 @@
emugl_sync_destroy_timeline_t destroy_timeline,
emugl_sync_register_trigger_wait_t register_trigger_wait,
emugl_sync_device_exists_t device_exists) {
- set_emugl_sync_create_timeline(create_timeline);
- set_emugl_sync_create_fence(create_fence);
- set_emugl_sync_timeline_inc(timeline_inc);
- set_emugl_sync_destroy_timeline(destroy_timeline);
- set_emugl_sync_register_trigger_wait(register_trigger_wait);
- set_emugl_sync_device_exists(device_exists);
+ emugl::set_emugl_sync_create_timeline(create_timeline);
+ emugl::set_emugl_sync_create_fence(create_fence);
+ emugl::set_emugl_sync_timeline_inc(timeline_inc);
+ emugl::set_emugl_sync_destroy_timeline(destroy_timeline);
+ emugl::set_emugl_sync_register_trigger_wait(register_trigger_wait);
+ emugl::set_emugl_sync_device_exists(device_exists);
}
void RenderLibImpl::setDmaOps(emugl_dma_ops ops) {
- set_emugl_dma_get_host_addr(ops.get_host_addr);
- set_emugl_dma_unlock(ops.unlock);
+ emugl::set_emugl_dma_get_host_addr(ops.get_host_addr);
+ emugl::set_emugl_dma_unlock(ops.unlock);
}
void RenderLibImpl::setVmOps(const QAndroidVmOperations &vm_operations) {
@@ -89,8 +89,8 @@
void RenderLibImpl::setWindowOps(const QAndroidEmulatorWindowAgent &window_operations,
const QAndroidMultiDisplayAgent &multi_display_operations) {
- set_emugl_window_operations(window_operations);
- set_emugl_multi_display_operations(multi_display_operations);
+ emugl::set_emugl_window_operations(window_operations);
+ emugl::set_emugl_multi_display_operations(multi_display_operations);
}
void RenderLibImpl::setUsageTracker(android::base::CpuUsage* cpuUsage,
@@ -104,13 +104,9 @@
(void) gralloc;
}
-void* RenderLibImpl::getGLESv2Dispatch(void) {
- return &s_gles2;
-}
+void* RenderLibImpl::getGLESv2Dispatch(void) { return &gl::s_gles2; }
-void* RenderLibImpl::getEGLDispatch(void) {
- return &s_egl;
-}
+void* RenderLibImpl::getEGLDispatch(void) { return &gl::s_egl; }
bool RenderLibImpl::getOpt(RenderOpt* opt) {
FrameBuffer* fb = FrameBuffer::getFB();
@@ -149,4 +145,4 @@
return (OnLastColorBufferRef)impl_onLastCbRef;
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RenderLibImpl.h b/stream-servers/RenderLibImpl.h
index 7c54e7e..eaa2d84 100644
--- a/stream-servers/RenderLibImpl.h
+++ b/stream-servers/RenderLibImpl.h
@@ -21,7 +21,7 @@
#include <memory>
-namespace emugl {
+namespace gfxstream {
class RenderLibImpl final : public RenderLib {
public:
@@ -74,4 +74,4 @@
std::weak_ptr<Renderer> mRenderer;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RenderThread.cpp b/stream-servers/RenderThread.cpp
index b9b93db..c90a382 100644
--- a/stream-servers/RenderThread.cpp
+++ b/stream-servers/RenderThread.cpp
@@ -46,11 +46,13 @@
#include <unordered_map>
+namespace gfxstream {
+
using android::base::AutoLock;
using android::base::EventHangMetadata;
using android::base::MessageChannel;
-
-namespace emugl {
+using emugl::GfxApiLogger;
+using vk::VkDecoderContext;
struct RenderThread::SnapshotObjects {
RenderThreadInfo* threadInfo;
@@ -292,7 +294,7 @@
// Framebuffer initialization is asynchronous, so we need to make sure
// it's completely initialized before running any GL commands.
FrameBuffer::waitUntilInitialized();
- if (goldfish_vk::getGlobalVkEmulation()) {
+ if (vk::getGlobalVkEmulation()) {
tInfo.m_vkInfo.emplace();
}
@@ -568,4 +570,4 @@
return 0;
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RenderThread.h b/stream-servers/RenderThread.h
index dd376ad..1bcc096 100644
--- a/stream-servers/RenderThread.h
+++ b/stream-servers/RenderThread.h
@@ -25,7 +25,7 @@
#include <atomic>
#include <memory>
-namespace emugl {
+namespace gfxstream {
class RenderChannelImpl;
class RendererImpl;
@@ -104,4 +104,4 @@
uint32_t mContextId = 0;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RenderThreadInfo.cpp b/stream-servers/RenderThreadInfo.cpp
index 0b0d62d..3cabf04 100644
--- a/stream-servers/RenderThreadInfo.cpp
+++ b/stream-servers/RenderThreadInfo.cpp
@@ -21,6 +21,8 @@
#include <unordered_map>
#include <unordered_set>
+namespace gfxstream {
+
using android::base::AutoLock;
using android::base::Stream;
using android::base::Lock;
@@ -73,3 +75,5 @@
void RenderThreadInfo::postLoadRefreshCurrentContextSurfacePtrs() {
return m_glInfo->postLoadRefreshCurrentContextSurfacePtrs();
}
+
+} // namespace gfxstream
diff --git a/stream-servers/RenderThreadInfo.h b/stream-servers/RenderThreadInfo.h
index ee97a65..95c8444 100644
--- a/stream-servers/RenderThreadInfo.h
+++ b/stream-servers/RenderThreadInfo.h
@@ -26,6 +26,8 @@
#include "RenderThreadInfoMagma.h"
#include "RenderThreadInfoVk.h"
+namespace gfxstream {
+
// A class used to model the state of each RenderThread related
struct RenderThreadInfo {
// Create new instance. Only call this once per thread.
@@ -50,8 +52,8 @@
uint64_t m_puid = 0;
std::optional<std::string> m_processName;
- std::optional<RenderThreadInfoGl> m_glInfo;
- std::optional<goldfish_vk::RenderThreadInfoVk> m_vkInfo;
+ std::optional<gl::RenderThreadInfoGl> m_glInfo;
+ std::optional<vk::RenderThreadInfoVk> m_vkInfo;
std::optional<RenderThreadInfoMagma> m_magmaInfo;
// Whether this thread was used to perform composition.
@@ -67,4 +69,6 @@
void postLoadRefreshCurrentContextSurfacePtrs();
};
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/RenderThreadInfoGl.cpp b/stream-servers/RenderThreadInfoGl.cpp
index efcf991..5bd191f 100644
--- a/stream-servers/RenderThreadInfoGl.cpp
+++ b/stream-servers/RenderThreadInfoGl.cpp
@@ -25,6 +25,9 @@
#include "aemu/base/files/StreamSerializing.h"
#include "host-common/GfxstreamFatalError.h"
+namespace gfxstream {
+namespace gl {
+
using android::base::AutoLock;
using android::base::Lock;
using android::base::Stream;
@@ -129,3 +132,6 @@
const HandleType read = currReadSurf ? currReadSurf->getHndl() : 0;
fb->bindContext(ctx, draw, read);
}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/RenderThreadInfoGl.h b/stream-servers/RenderThreadInfoGl.h
index bac97fb..f6c0255 100644
--- a/stream-servers/RenderThreadInfoGl.h
+++ b/stream-servers/RenderThreadInfoGl.h
@@ -25,6 +25,9 @@
#include "gl/gles1_dec/GLESv1Decoder.h"
#include "gl/gles2_dec/GLESv2Decoder.h"
+namespace gfxstream {
+namespace gl {
+
struct RenderThreadInfoGl {
// Create new instance. Only call this once per thread.
// Future calls to get() will return this instance until
@@ -62,11 +65,14 @@
HandleType currDrawSurfHandleFromLoad;
HandleType currReadSurfHandleFromLoad;
- gfxstream::EmulatedEglContextPtr currContext;
- gfxstream::EmulatedEglWindowSurfacePtr currDrawSurf;
- gfxstream::EmulatedEglWindowSurfacePtr currReadSurf;
+ EmulatedEglContextPtr currContext;
+ EmulatedEglWindowSurfacePtr currDrawSurf;
+ EmulatedEglWindowSurfacePtr currReadSurf;
// Decoder states.
GLESv1Decoder m_glDec;
GLESv2Decoder m_gl2Dec;
};
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/RenderWindow.cpp b/stream-servers/RenderWindow.cpp
index 433d8e2..0dd824c 100644
--- a/stream-servers/RenderWindow.cpp
+++ b/stream-servers/RenderWindow.cpp
@@ -27,6 +27,8 @@
#include <pthread.h>
#endif
+namespace gfxstream {
+
#define DEBUG 0
#if DEBUG
@@ -85,7 +87,7 @@
// CMD_SET_POST_CALLBACK
struct {
- emugl::Renderer::OnPostCallback on_post;
+ Renderer::OnPostCallback on_post;
void* on_post_context;
uint32_t on_post_displayId;
bool use_bgra_readback;
@@ -504,10 +506,8 @@
return true;
}
-void RenderWindow::setPostCallback(emugl::Renderer::OnPostCallback onPost,
- void* onPostContext,
- uint32_t displayId,
- bool useBgraReadback) {
+void RenderWindow::setPostCallback(Renderer::OnPostCallback onPost, void* onPostContext,
+ uint32_t displayId, bool useBgraReadback) {
D("Entering\n");
RenderWindowMessage msg = {};
msg.cmd = CMD_SET_POST_CALLBACK;
@@ -524,21 +524,20 @@
return FrameBuffer::getFB()->asyncReadbackSupported();
}
-emugl::Renderer::ReadPixelsCallback RenderWindow::getReadPixelsCallback() {
+Renderer::ReadPixelsCallback RenderWindow::getReadPixelsCallback() {
D("Entering\n");
return FrameBuffer::getFB()->getReadPixelsCallback();
}
-void RenderWindow::addListener(emugl::Renderer::FrameBufferChangeEventListener* listener) {
+void RenderWindow::addListener(Renderer::FrameBufferChangeEventListener* listener) {
FrameBuffer::getFB()->addListener(listener);
}
-void RenderWindow::removeListener(emugl::Renderer::FrameBufferChangeEventListener* listener) {
+void RenderWindow::removeListener(Renderer::FrameBufferChangeEventListener* listener) {
FrameBuffer::getFB()->removeListener(listener);
}
-emugl::Renderer::FlushReadPixelPipeline
-RenderWindow::getFlushReadPixelPipeline() {
+Renderer::FlushReadPixelPipeline RenderWindow::getFlushReadPixelPipeline() {
return FrameBuffer::getFB()->getFlushReadPixelPipeline();
}
bool RenderWindow::setupSubWindow(FBNativeWindowType window,
@@ -691,3 +690,5 @@
return msg.process();
}
}
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/RenderWindow.h b/stream-servers/RenderWindow.h
index 68e7ca1..5a21302 100644
--- a/stream-servers/RenderWindow.h
+++ b/stream-servers/RenderWindow.h
@@ -21,6 +21,8 @@
#include "aemu/base/threads/FunctorThread.h"
#include "aemu/base/threads/Thread.h"
+namespace gfxstream {
+
class RenderWindowChannel;
struct RenderWindowMessage;
@@ -79,14 +81,12 @@
// Specify a function that will be called everytime a new frame is
// displayed. This is relatively slow but allows one to capture the
// output.
- void setPostCallback(emugl::Renderer::OnPostCallback onPost,
- void* onPostContext,
- uint32_t displayId,
+ void setPostCallback(Renderer::OnPostCallback onPost, void* onPostContext, uint32_t displayId,
bool useBgraReadback = false);
bool asyncReadbackSupported();
- emugl::Renderer::ReadPixelsCallback getReadPixelsCallback();
- emugl::Renderer::FlushReadPixelPipeline getFlushReadPixelPipeline();
+ Renderer::ReadPixelsCallback getReadPixelsCallback();
+ Renderer::FlushReadPixelPipeline getFlushReadPixelPipeline();
// Start displaying the emulated framebuffer using a sub-window of a
// parent |window| id. |wx|, |wy|, |ww| and |wh| are the position
@@ -144,8 +144,8 @@
void setPaused(bool paused);
- void addListener(emugl::Renderer::FrameBufferChangeEventListener* listener);
- void removeListener(emugl::Renderer::FrameBufferChangeEventListener* listener);
+ void addListener(Renderer::FrameBufferChangeEventListener* listener);
+ void removeListener(Renderer::FrameBufferChangeEventListener* listener);
void setVsyncHz(int vsyncHz);
void setDisplayConfigs(int configId, int w, int h, int dpiX, int dpiY);
@@ -169,4 +169,6 @@
bool mPaused = false;
};
+} // namespace gfxstream
+
#endif // ANDROID_EMUGL_LIBRENDER_RENDER_WINDOW_H
diff --git a/stream-servers/RendererImpl.cpp b/stream-servers/RendererImpl.cpp
index 602dea9..4967967 100644
--- a/stream-servers/RendererImpl.cpp
+++ b/stream-servers/RendererImpl.cpp
@@ -28,7 +28,7 @@
#include "host-common/logging.h"
#include "snapshot/common.h"
-namespace emugl {
+namespace gfxstream {
// kUseSubwindowThread is used to determine whether the RenderWindow should use
// a separate thread to manage its subwindow GL/GLES context.
@@ -368,7 +368,7 @@
bool res = true;
res = fb->onLoad(stream, textureLoader);
- gfxstream::EmulatedEglFenceSync::onLoad(stream);
+ gl::EmulatedEglFenceSync::onLoad(stream);
return res;
}
@@ -688,4 +688,4 @@
}
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RendererImpl.h b/stream-servers/RendererImpl.h
index a48fa9f..17cb886 100644
--- a/stream-servers/RendererImpl.h
+++ b/stream-servers/RendererImpl.h
@@ -33,7 +33,7 @@
class EmulatorGLESUsages;
}
-namespace emugl {
+namespace gfxstream {
class RendererImpl final : public Renderer {
public:
@@ -148,4 +148,4 @@
std::vector<RenderThread*> mAdditionalPostLoadRenderThreads;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RingStream.cpp b/stream-servers/RingStream.cpp
index b0709d6..5f3018a 100644
--- a/stream-servers/RingStream.cpp
+++ b/stream-servers/RingStream.cpp
@@ -28,7 +28,7 @@
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
-namespace emugl {
+namespace gfxstream {
RingStream::RingStream(
struct asg_context context,
@@ -334,12 +334,10 @@
}
void* RingStream::getDmaForReading(uint64_t guest_paddr) {
- return g_emugl_dma_get_host_addr(guest_paddr);
+ return emugl::g_emugl_dma_get_host_addr(guest_paddr);
}
-void RingStream::unlockDma(uint64_t guest_paddr) {
- g_emugl_dma_unlock(guest_paddr);
-}
+void RingStream::unlockDma(uint64_t guest_paddr) { emugl::g_emugl_dma_unlock(guest_paddr); }
int RingStream::writeFully(const void* buf, size_t len) {
void* dstBuf = alloc(len);
@@ -366,4 +364,4 @@
return reinterpret_cast<unsigned char*>(mWriteBuffer.data());
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/RingStream.h b/stream-servers/RingStream.h
index 96cd37a..90d0c5a 100644
--- a/stream-servers/RingStream.h
+++ b/stream-servers/RingStream.h
@@ -22,7 +22,7 @@
#include <functional>
#include <vector>
-namespace emugl {
+namespace gfxstream {
// An IOStream instance that can be used by the host RenderThread to process
// messages from a pair of ring buffers (to host and from host). It also takes
@@ -91,4 +91,4 @@
bool mInSnapshotOperation = false;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/StalePtrRegistry.h b/stream-servers/StalePtrRegistry.h
index b4b8fd8..6a9656f 100644
--- a/stream-servers/StalePtrRegistry.h
+++ b/stream-servers/StalePtrRegistry.h
@@ -25,6 +25,8 @@
#include <cstdint>
#include <unordered_map>
+namespace gfxstream {
+
// The purpose of StalePtrRegistry is to track integers corresponding to
// host-side pointers that may be invalidated after snapshots.
template <class T>
@@ -140,3 +142,5 @@
DISALLOW_COPY_AND_ASSIGN(StalePtrRegistry);
};
+
+} // namespace gfxstream
diff --git a/stream-servers/SyncThread.cpp b/stream-servers/SyncThread.cpp
index 23a56c5..a4d85b7 100644
--- a/stream-servers/SyncThread.cpp
+++ b/stream-servers/SyncThread.cpp
@@ -30,10 +30,13 @@
#endif
#include <memory>
+namespace gfxstream {
+
using android::base::EventHangMetadata;
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
-using gfxstream::EmulatedEglFenceSync;
+using gl::EGLDispatch;
+using gl::EmulatedEglFenceSync;
#define DEBUG 0
@@ -183,7 +186,7 @@
<< reinterpret_cast<uintptr_t>(vkImage);
sendAsync(
[vkImage, cb = std::move(cb)](WorkerId) {
- auto decoder = goldfish_vk::VkDecoderGlobalState::get();
+ auto decoder = vk::VkDecoderGlobalState::get();
auto res = decoder->registerQsriCallback(vkImage, cb);
// If registerQsriCallback does not schedule the callback, we still need to complete
// the task, otherwise we may hit deadlocks on tasks on the same ring.
@@ -204,7 +207,7 @@
sendAndWaitForResult(
[this](WorkerId workerId) {
if (mHasGl) {
- const EGLDispatch* egl = emugl::LazyLoadedEGLDispatch::get();
+ const EGLDispatch* egl = gl::LazyLoadedEGLDispatch::get();
egl->eglMakeCurrent(mDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
@@ -289,7 +292,7 @@
// without GL enabled.
SYNC_THREAD_CHECK(mHasGl);
- const EGLDispatch* egl = emugl::LazyLoadedEGLDispatch::get();
+ const EGLDispatch* egl = gl::LazyLoadedEGLDispatch::get();
mDisplay = egl->eglGetDisplay(EGL_DEFAULT_DISPLAY);
int eglMaj, eglMin;
@@ -357,7 +360,7 @@
wait_result);
if (wait_result != EGL_CONDITION_SATISFIED_KHR) {
- EGLint error = s_egl.eglGetError();
+ EGLint error = gl::s_egl.eglGetError();
DPRINT("error: eglClientWaitSync abnormal exit 0x%x. sync handle 0x%llx. egl error = %#x\n",
wait_result, (unsigned long long)fenceSync, error);
(void)error;
@@ -402,7 +405,7 @@
int SyncThread::doSyncWaitVk(VkFence vkFence, std::function<void()> onComplete) {
DPRINT("enter");
- auto decoder = goldfish_vk::VkDecoderGlobalState::get();
+ auto decoder = vk::VkDecoderGlobalState::get();
auto result = decoder->waitForFence(vkFence, kDefaultTimeoutNsecs);
if (result == VK_TIMEOUT) {
DPRINT("SYNC_WAIT_VK timeout: vkFence=%p", vkFence);
@@ -437,3 +440,5 @@
}
void SyncThread::destroy() { sGlobalSyncThread()->destroy(); }
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/SyncThread.h b/stream-servers/SyncThread.h
index ccee40d..c1e33f7 100644
--- a/stream-servers/SyncThread.h
+++ b/stream-servers/SyncThread.h
@@ -36,6 +36,8 @@
#include "render-utils/virtio_gpu_ops.h"
#include "vulkan/VkDecoderGlobalState.h"
+namespace gfxstream {
+
using emugl::HealthMonitor;
using emugl::HealthWatchdog;
@@ -58,7 +60,7 @@
// which should signal the guest-side fence FD.
// This method is how the goldfish sync virtual device
// knows when to increment timelines / signal native fence FD's.
- void triggerWait(gfxstream::EmulatedEglFenceSync* fenceSync, uint64_t timeline);
+ void triggerWait(gl::EmulatedEglFenceSync* fenceSync, uint64_t timeline);
// |triggerWaitVk|: async wait with a given VkFence object.
// The |vkFence| argument is a *boxed* host Vulkan handle of the fence.
@@ -72,11 +74,11 @@
// for use with the virtio-gpu path; is meant to have a current context
// while waiting.
- void triggerBlockedWaitNoTimeline(gfxstream::EmulatedEglFenceSync* fenceSync);
+ void triggerBlockedWaitNoTimeline(gl::EmulatedEglFenceSync* fenceSync);
// For use with virtio-gpu and async fence completion callback. This is async like triggerWait,
// but takes a fence completion callback instead of incrementing some timeline directly.
- void triggerWaitWithCompletionCallback(gfxstream::EmulatedEglFenceSync* fenceSync,
+ void triggerWaitWithCompletionCallback(gl::EmulatedEglFenceSync* fenceSync,
FenceCompletionCallback);
void triggerWaitVkWithCompletionCallback(VkFence fenceHandle, FenceCompletionCallback);
void triggerWaitVkQsriWithCompletionCallback(VkImage image, FenceCompletionCallback);
@@ -127,8 +129,7 @@
// |doSyncThreadCmd| execute the actual task. These run on the sync thread.
void doSyncThreadCmd(Command&& command, ThreadPool::WorkerId);
- void doSyncWait(gfxstream::EmulatedEglFenceSync* fenceSync,
- std::function<void()> onComplete);
+ void doSyncWait(gl::EmulatedEglFenceSync* fenceSync, std::function<void()> onComplete);
static int doSyncWaitVk(VkFence, std::function<void()> onComplete);
// EGL objects / object handles specific to
@@ -147,3 +148,5 @@
HealthMonitor<>* mHealthMonitor;
};
+
+} // namespace gfxstream
diff --git a/stream-servers/VsyncThread.cpp b/stream-servers/VsyncThread.cpp
index 034ca92..414ef46 100644
--- a/stream-servers/VsyncThread.cpp
+++ b/stream-servers/VsyncThread.cpp
@@ -15,6 +15,8 @@
#include "aemu/base/system/System.h"
+namespace gfxstream {
+
VsyncThread::VsyncThread(uint64_t vsyncPeriodNs) :
mPeriodNs(vsyncPeriodNs),
mThread([this] { threadFunc(); }) {
@@ -76,3 +78,5 @@
++mCount;
}
}
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/VsyncThread.h b/stream-servers/VsyncThread.h
index 90cbf1b..5cbfb57 100644
--- a/stream-servers/VsyncThread.h
+++ b/stream-servers/VsyncThread.h
@@ -19,6 +19,8 @@
#include <inttypes.h>
#include <functional>
+namespace gfxstream {
+
// A thread that regularly processes tasks that need to happen at some vsync
// interval (initialized from FrameBuffer).
//
@@ -73,3 +75,5 @@
android::base::MessageChannel<VsyncThreadCommand, 128> mChannel;
android::base::FunctorThread mThread;
};
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/apigen-codec-common/ProtocolUtils.h b/stream-servers/apigen-codec-common/ProtocolUtils.h
index 5db7515..b03db3c 100644
--- a/stream-servers/apigen-codec-common/ProtocolUtils.h
+++ b/stream-servers/apigen-codec-common/ProtocolUtils.h
@@ -8,7 +8,7 @@
#include <stdlib.h>
#include <string.h>
-namespace emugl {
+namespace gfxstream {
// A helper template to extract values form the wire protocol stream
// and convert them to appropriate host values.
@@ -178,4 +178,4 @@
using InputBuffer = GenericInputBuffer<>;
using OutputBuffer = GenericOutputBuffer<>;
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/compressedTextureFormats/AstcCpuDecompressor.h b/stream-servers/compressedTextureFormats/AstcCpuDecompressor.h
index 2f4faab..4823ee2 100644
--- a/stream-servers/compressedTextureFormats/AstcCpuDecompressor.h
+++ b/stream-servers/compressedTextureFormats/AstcCpuDecompressor.h
@@ -16,7 +16,8 @@
#include <memory>
#include <string>
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
// This class is responsible for decompressing ASTC textures on the CPU.
// This class is thread-safe and all its methods can be called by any thread.
@@ -52,4 +53,5 @@
virtual const char* getStatusString(int32_t statusCode) const = 0;
};
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/compressedTextureFormats/AstcCpuDecompressorNoOp.cpp b/stream-servers/compressedTextureFormats/AstcCpuDecompressorNoOp.cpp
index 8c7de46..f0e4f32 100644
--- a/stream-servers/compressedTextureFormats/AstcCpuDecompressorNoOp.cpp
+++ b/stream-servers/compressedTextureFormats/AstcCpuDecompressorNoOp.cpp
@@ -14,8 +14,8 @@
#include "AstcCpuDecompressor.h"
-namespace goldfish_vk {
-
+namespace gfxstream {
+namespace vk {
namespace {
class AstcCpuDecompressorNoOp : public AstcCpuDecompressor {
@@ -40,4 +40,5 @@
return instance;
}
-} // namespace goldfish_vk
\ No newline at end of file
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/compressedTextureFormats/AstcCpuDecompressor_unittest.cpp b/stream-servers/compressedTextureFormats/AstcCpuDecompressor_unittest.cpp
index 3fa80aa..319fe11 100644
--- a/stream-servers/compressedTextureFormats/AstcCpuDecompressor_unittest.cpp
+++ b/stream-servers/compressedTextureFormats/AstcCpuDecompressor_unittest.cpp
@@ -16,7 +16,8 @@
#include "AstcCpuDecompressor.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
namespace {
using ::testing::ElementsAreArray;
@@ -73,4 +74,5 @@
}
} // namespace
-} // namespace goldfish_vk
\ No newline at end of file
+} // namespace vk
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/BorrowedImageGl.h b/stream-servers/gl/BorrowedImageGl.h
index 1500b7e..eae5b90 100644
--- a/stream-servers/gl/BorrowedImageGl.h
+++ b/stream-servers/gl/BorrowedImageGl.h
@@ -23,6 +23,9 @@
#include "BorrowedImage.h"
+namespace gfxstream {
+namespace gl {
+
struct BorrowedImageInfoGl : public BorrowedImageInfo {
GLuint texture = 0;
@@ -30,3 +33,6 @@
// issued (useful for setting a GL sync).
std::function<void()> onCommandsIssued;
};
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/BufferGl.cpp b/stream-servers/gl/BufferGl.cpp
index 1f03fd8..69449e4 100644
--- a/stream-servers/gl/BufferGl.cpp
+++ b/stream-servers/gl/BufferGl.cpp
@@ -15,6 +15,7 @@
#include "BufferGl.h"
namespace gfxstream {
+namespace gl {
BufferGl::BufferGl(uint64_t size, HandleType handle, ContextHelper* helper)
: mSize(size), mHandle(handle), mContextHelper(helper) {}
@@ -100,4 +101,5 @@
stream->putBe32(mHandle);
}
-} // namespace gfxstream
\ No newline at end of file
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/BufferGl.h b/stream-servers/gl/BufferGl.h
index 9f396c6..fd1429b 100644
--- a/stream-servers/gl/BufferGl.h
+++ b/stream-servers/gl/BufferGl.h
@@ -26,6 +26,7 @@
#include "aemu/base/files/Stream.h"
namespace gfxstream {
+namespace gl {
class BufferGl {
public:
@@ -58,4 +59,5 @@
ContextHelper* mContextHelper = nullptr;
};
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/ColorBufferGl.cpp b/stream-servers/gl/ColorBufferGl.cpp
index ad87a78..f3957bf 100644
--- a/stream-servers/gl/ColorBufferGl.cpp
+++ b/stream-servers/gl/ColorBufferGl.cpp
@@ -36,11 +36,9 @@
using android::base::ManagedDescriptor;
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
-using gfxstream::GLESApi;
-using gfxstream::GLESApi_CM;
-using gfxstream::GLESApi_2;
namespace gfxstream {
+namespace gl {
namespace {
// Lazily create and bind a framebuffer object to the current host context.
@@ -393,7 +391,7 @@
}
void ColorBufferGl::readPixelsScaled(int width, int height, GLenum p_format, GLenum p_type,
- int rotation, emugl::Rect rect, void* pixels) {
+ int rotation, Rect rect, void* pixels) {
RecursiveScopedContextBind context(m_helper);
if (!context.isOk()) {
return;
@@ -1161,4 +1159,5 @@
return info;
}
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/ColorBufferGl.h b/stream-servers/gl/ColorBufferGl.h
index bc6d021..f72fdcf 100644
--- a/stream-servers/gl/ColorBufferGl.h
+++ b/stream-servers/gl/ColorBufferGl.h
@@ -37,10 +37,6 @@
// From ANGLE "src/common/angleutils.h"
#define GL_BGR10_A2_ANGLEX 0x6AF9
-class TextureDraw;
-class TextureResize;
-class YUVConverter;
-
// A class used to model a guest color buffer, and used to implement several
// related things:
//
@@ -70,6 +66,11 @@
// As an additional twist.
namespace gfxstream {
+namespace gl {
+
+class TextureDraw;
+class TextureResize;
+class YUVConverter;
class ColorBufferGl {
public:
@@ -119,7 +120,7 @@
// to the size of width x height, then clipping a |rect| from the
// screen defined by width x height.
void readPixelsScaled(int width, int height, GLenum p_format, GLenum p_type, int skinRotation,
- emugl::Rect rect, void* pixels);
+ Rect rect, void* pixels);
// Read cached YUV pixel values into host memory.
void readPixelsYUVCached(int x,
@@ -291,4 +292,5 @@
typedef std::shared_ptr<ColorBufferGl> ColorBufferGlPtr;
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/CompositorGl.cpp b/stream-servers/gl/CompositorGl.cpp
index 3fe95b3..a215f6e 100644
--- a/stream-servers/gl/CompositorGl.cpp
+++ b/stream-servers/gl/CompositorGl.cpp
@@ -22,6 +22,8 @@
#include "host-common/GfxstreamFatalError.h"
#include "host-common/misc.h"
+namespace gfxstream {
+namespace gl {
namespace {
const BorrowedImageInfoGl* getInfoOrAbort(const std::unique_ptr<BorrowedImageInfo>& info) {
@@ -141,3 +143,6 @@
// passes along a GL fence or VK fence.
return getCompletedFuture();
}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/CompositorGl.h b/stream-servers/gl/CompositorGl.h
index a471df3..cba58a6 100644
--- a/stream-servers/gl/CompositorGl.h
+++ b/stream-servers/gl/CompositorGl.h
@@ -25,6 +25,9 @@
#include "DisplaySurfaceUser.h"
#include "TextureDraw.h"
+namespace gfxstream {
+namespace gl {
+
class CompositorGl : public Compositor, public gfxstream::DisplaySurfaceUser {
public:
CompositorGl(TextureDraw* textureDraw);
@@ -42,9 +45,12 @@
private:
GLuint m_composeFbo = 0;
-
+
// Owned by FrameBuffer.
TextureDraw* m_textureDraw = nullptr;
std::atomic_bool mUseBoundSurfaceContext{true};
};
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/DebugGl.cpp b/stream-servers/gl/DebugGl.cpp
index 5158744..3e8eaed 100644
--- a/stream-servers/gl/DebugGl.cpp
+++ b/stream-servers/gl/DebugGl.cpp
@@ -20,6 +20,9 @@
#include "OpenGLESDispatch/DispatchTables.h"
+namespace gfxstream {
+namespace gl {
+
std::string formatString(const char* format, ...) {
char buf[1024];
va_list args;
@@ -57,4 +60,7 @@
s_gles2.glPopDebugGroup();
groupPopped = s_gles2.glGetError() == GL_NO_ERROR;
}
-}
\ No newline at end of file
+}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/DebugGl.h b/stream-servers/gl/DebugGl.h
index 2e5c21a..bcf3338 100644
--- a/stream-servers/gl/DebugGl.h
+++ b/stream-servers/gl/DebugGl.h
@@ -19,6 +19,9 @@
#include "host-common/logging.h"
+namespace gfxstream {
+namespace gl {
+
std::string formatString(const char* format, ...);
class ScopedDebugGroup {
@@ -32,3 +35,6 @@
#else
#define GL_SCOPED_DEBUG_GROUP(...) (void(0))
#endif
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/DisplayGl.cpp b/stream-servers/gl/DisplayGl.cpp
index 915394f..9ed9301 100644
--- a/stream-servers/gl/DisplayGl.cpp
+++ b/stream-servers/gl/DisplayGl.cpp
@@ -20,6 +20,8 @@
#include "TextureDraw.h"
#include "host-common/logging.h"
+namespace gfxstream {
+namespace gl {
namespace {
std::shared_future<void> getCompletedFuture() {
@@ -113,3 +115,6 @@
s_egl.eglSwapBuffers(surfaceGl->mDisplay, surfaceGl->mSurface);
#endif
}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/DisplayGl.h b/stream-servers/gl/DisplayGl.h
index a82f520..59eab5e 100644
--- a/stream-servers/gl/DisplayGl.h
+++ b/stream-servers/gl/DisplayGl.h
@@ -26,6 +26,9 @@
#include "Display.h"
#include "Hwc2.h"
+namespace gfxstream {
+namespace gl {
+
class DisplayGl : public gfxstream::Display {
public:
DisplayGl(TextureDraw* textureDraw): mTextureDraw(textureDraw) {}
@@ -76,3 +79,6 @@
std::atomic_bool mUseBoundSurfaceContext{true};
TextureDraw* mTextureDraw = nullptr;
};
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/DisplaySurfaceGl.cpp b/stream-servers/gl/DisplaySurfaceGl.cpp
index 70b0695..763eae9 100644
--- a/stream-servers/gl/DisplaySurfaceGl.cpp
+++ b/stream-servers/gl/DisplaySurfaceGl.cpp
@@ -19,6 +19,8 @@
#include "host-common/GfxstreamFatalError.h"
#include "host-common/logging.h"
+namespace gfxstream {
+namespace gl {
namespace {
using emugl::ABORT_REASON_OTHER;
@@ -176,3 +178,6 @@
}
}
}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/DisplaySurfaceGl.h b/stream-servers/gl/DisplaySurfaceGl.h
index e682053..9cc2340 100644
--- a/stream-servers/gl/DisplaySurfaceGl.h
+++ b/stream-servers/gl/DisplaySurfaceGl.h
@@ -26,6 +26,9 @@
#include "DisplaySurface.h"
#include "render-utils/render_api_platform_types.h"
+namespace gfxstream {
+namespace gl {
+
class DisplaySurfaceGl : public gfxstream::DisplaySurfaceImpl {
public:
static std::unique_ptr<DisplaySurfaceGl> createPbufferSurface(EGLDisplay display,
@@ -62,3 +65,6 @@
std::unique_ptr<ContextHelper> mContextHelper;
};
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglConfig.cpp b/stream-servers/gl/EmulatedEglConfig.cpp
index cc32889..cd14156 100644
--- a/stream-servers/gl/EmulatedEglConfig.cpp
+++ b/stream-servers/gl/EmulatedEglConfig.cpp
@@ -24,6 +24,8 @@
#include <stdio.h>
#include <string.h>
+namespace gfxstream {
+namespace gl {
namespace {
#ifndef EGL_PRESERVED_RESOURCES
@@ -289,3 +291,6 @@
}
return mConfigs.size();
}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/EmulatedEglConfig.h b/stream-servers/gl/EmulatedEglConfig.h
index 74c4e59..87264ef 100644
--- a/stream-servers/gl/EmulatedEglConfig.h
+++ b/stream-servers/gl/EmulatedEglConfig.h
@@ -23,6 +23,9 @@
#include "OpenGLESDispatch/GLESv2Dispatch.h"
+namespace gfxstream {
+namespace gl {
+
// A class used to model an EGL config that is exposed to the guest.
//
// This really wraps a host EGLConfig handle, and provides a few cached
@@ -161,3 +164,6 @@
EGLDisplay mDisplay = 0;
GLESDispatchMaxVersion mGlesDispatchMaxVersion;
};
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglContext.cpp b/stream-servers/gl/EmulatedEglContext.cpp
index 5311f5e..61b9732 100644
--- a/stream-servers/gl/EmulatedEglContext.cpp
+++ b/stream-servers/gl/EmulatedEglContext.cpp
@@ -26,6 +26,7 @@
#include "host-common/misc.h"
namespace gfxstream {
+namespace gl {
std::unique_ptr<EmulatedEglContext> EmulatedEglContext::create(
EGLDisplay display,
@@ -123,4 +124,5 @@
return mVersion;
}
-}
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglContext.h b/stream-servers/gl/EmulatedEglContext.h
index c46f3fb..c23b548 100644
--- a/stream-servers/gl/EmulatedEglContext.h
+++ b/stream-servers/gl/EmulatedEglContext.h
@@ -27,6 +27,7 @@
#include "aemu/base/files/Stream.h"
namespace gfxstream {
+namespace gl {
// Tracks all the possible OpenGL ES API versions.
enum GLESApi {
@@ -101,4 +102,5 @@
typedef std::unordered_map<HandleType, EmulatedEglContextPtr> EmulatedEglContextMap;
typedef std::unordered_set<HandleType> EmulatedEglContextSet;
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglFenceSync.cpp b/stream-servers/gl/EmulatedEglFenceSync.cpp
index 8ac94da..8a63580 100644
--- a/stream-servers/gl/EmulatedEglFenceSync.cpp
+++ b/stream-servers/gl/EmulatedEglFenceSync.cpp
@@ -28,6 +28,7 @@
#include "aemu/base/synchronization/Lock.h"
namespace gfxstream {
+namespace gl {
namespace {
using android::base::AutoLock;
@@ -212,4 +213,5 @@
return sFenceRegistry()->getPtr(handle);
}
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglFenceSync.h b/stream-servers/gl/EmulatedEglFenceSync.h
index 6cef8f5..4cccd0f 100644
--- a/stream-servers/gl/EmulatedEglFenceSync.h
+++ b/stream-servers/gl/EmulatedEglFenceSync.h
@@ -27,6 +27,7 @@
#include "aemu/base/synchronization/Lock.h"
namespace gfxstream {
+namespace gl {
// The EmulatedEglFenceSync class wraps actual EGLSyncKHR objects
// and issues calls to eglCreateSyncKHR, eglClientWaitSyncKHR,
@@ -162,4 +163,5 @@
DISALLOW_COPY_AND_ASSIGN(EmulatedEglFenceSync);
};
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglImage.cpp b/stream-servers/gl/EmulatedEglImage.cpp
index 15305c0..56d1e2e 100644
--- a/stream-servers/gl/EmulatedEglImage.cpp
+++ b/stream-servers/gl/EmulatedEglImage.cpp
@@ -21,6 +21,7 @@
#include "host-common/logging.h"
namespace gfxstream {
+namespace gl {
/*static*/
std::unique_ptr<EmulatedEglImage> EmulatedEglImage::create(EGLDisplay display,
@@ -65,4 +66,5 @@
return EGL_TRUE;
}
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglImage.h b/stream-servers/gl/EmulatedEglImage.h
index 9b10e90..8b2e46c 100644
--- a/stream-servers/gl/EmulatedEglImage.h
+++ b/stream-servers/gl/EmulatedEglImage.h
@@ -26,6 +26,7 @@
#include "Handle.h"
namespace gfxstream {
+namespace gl {
class EmulatedEglImage {
public:
@@ -54,4 +55,5 @@
typedef std::unordered_map<HandleType, EmulatedEglImagePtr> EmulatedEglImageMap;
typedef std::unordered_set<HandleType> EmulatedEglImageSet;
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglWindowSurface.cpp b/stream-servers/gl/EmulatedEglWindowSurface.cpp
index b9c1baa..64d2c8e 100644
--- a/stream-servers/gl/EmulatedEglWindowSurface.cpp
+++ b/stream-servers/gl/EmulatedEglWindowSurface.cpp
@@ -32,6 +32,7 @@
using emugl::FatalError;
namespace gfxstream {
+namespace gl {
EmulatedEglWindowSurface::EmulatedEglWindowSurface(EGLDisplay display,
EGLConfig config,
@@ -257,4 +258,5 @@
return surface;
}
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/EmulatedEglWindowSurface.h b/stream-servers/gl/EmulatedEglWindowSurface.h
index a3a0108..b5c4690 100644
--- a/stream-servers/gl/EmulatedEglWindowSurface.h
+++ b/stream-servers/gl/EmulatedEglWindowSurface.h
@@ -29,6 +29,7 @@
#include "gl/EmulatedEglContext.h"
namespace gfxstream {
+namespace gl {
// A class used to model a guest-side window surface. The implementation
// uses a host Pbuffer to act as the EGL rendering surface instead.
@@ -126,4 +127,5 @@
typedef std::unordered_map<HandleType, std::pair<EmulatedEglWindowSurfacePtr, HandleType>> EmulatedEglWindowSurfaceMap;
typedef std::unordered_set<HandleType> EmulatedEglWindowSurfaceSet;
-}
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/EmulationGl.cpp b/stream-servers/gl/EmulationGl.cpp
index 825ba73..972f8fa 100644
--- a/stream-servers/gl/EmulationGl.cpp
+++ b/stream-servers/gl/EmulationGl.cpp
@@ -32,6 +32,7 @@
#include "host-common/opengl/misc.h"
namespace gfxstream {
+namespace gl {
namespace {
static void EGLAPIENTRY EglDebugCallback(EGLenum error,
@@ -700,4 +701,5 @@
return EmulatedEglWindowSurface::onLoad(stream, mEglDisplay, colorBuffers, contexts);
}
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/EmulationGl.h b/stream-servers/gl/EmulationGl.h
index 506cb66..80a9d15 100644
--- a/stream-servers/gl/EmulationGl.h
+++ b/stream-servers/gl/EmulationGl.h
@@ -45,9 +45,12 @@
#define EGL_NO_CONFIG ((EGLConfig)0)
+namespace gfxstream {
class FrameBuffer;
+} // namespace gfxstream
namespace gfxstream {
+namespace gl {
class EmulationGl {
public:
@@ -136,48 +139,49 @@
private:
// TODO(b/233939967): Remove this after fully transitioning to EmulationGl.
- friend class ::FrameBuffer;
+ friend class gfxstream::FrameBuffer;
- EmulationGl() = default;
+ EmulationGl() = default;
- ContextHelper* getColorBufferContextHelper();
+ ContextHelper* getColorBufferContextHelper();
- EGLDisplay mEglDisplay = EGL_NO_DISPLAY;
- EGLint mEglVersionMajor = 0;
- EGLint mEglVersionMinor = 0;
- std::string mEglVendor;
- std::unordered_set<std::string> mEglExtensions;
- EGLConfig mEglConfig = EGL_NO_CONFIG;
+ EGLDisplay mEglDisplay = EGL_NO_DISPLAY;
+ EGLint mEglVersionMajor = 0;
+ EGLint mEglVersionMinor = 0;
+ std::string mEglVendor;
+ std::unordered_set<std::string> mEglExtensions;
+ EGLConfig mEglConfig = EGL_NO_CONFIG;
- // The "global" context that all other contexts are shared with.
- EGLContext mEglContext = EGL_NO_CONTEXT;
+ // The "global" context that all other contexts are shared with.
+ EGLContext mEglContext = EGL_NO_CONTEXT;
- // Used for ColorBuffer ops.
- std::unique_ptr<gfxstream::DisplaySurface> mPbufferSurface;
+ // Used for ColorBuffer ops.
+ std::unique_ptr<gfxstream::DisplaySurface> mPbufferSurface;
- // Used for Composition and Display ops.
- std::unique_ptr<gfxstream::DisplaySurface> mWindowSurface;
- std::unique_ptr<gfxstream::DisplaySurface> mFakeWindowSurface;
+ // Used for Composition and Display ops.
+ std::unique_ptr<gfxstream::DisplaySurface> mWindowSurface;
+ std::unique_ptr<gfxstream::DisplaySurface> mFakeWindowSurface;
- GLint mGlesVersionMajor = 0;
- GLint mGlesVersionMinor = 0;
- GLESDispatchMaxVersion mGlesDispatchMaxVersion = GLES_DISPATCH_MAX_VERSION_2;
- std::string mGlesVendor;
- std::string mGlesRenderer;
- std::string mGlesVersion;
- std::string mGlesExtensions;
- std::optional<GlesUuid> mGlesDeviceUuid;
- bool mGlesVulkanInteropSupported = false;
+ GLint mGlesVersionMajor = 0;
+ GLint mGlesVersionMinor = 0;
+ GLESDispatchMaxVersion mGlesDispatchMaxVersion = GLES_DISPATCH_MAX_VERSION_2;
+ std::string mGlesVendor;
+ std::string mGlesRenderer;
+ std::string mGlesVersion;
+ std::string mGlesExtensions;
+ std::optional<GlesUuid> mGlesDeviceUuid;
+ bool mGlesVulkanInteropSupported = false;
- std::unique_ptr<EmulatedEglConfigList> mEmulatedEglConfigs;
+ std::unique_ptr<EmulatedEglConfigList> mEmulatedEglConfigs;
- bool mFastBlitSupported = false;
+ bool mFastBlitSupported = false;
- std::unique_ptr<CompositorGl> mCompositorGl;
- std::unique_ptr<DisplayGl> mDisplayGl;
- std::unique_ptr<ReadbackWorkerGl> mReadbackWorkerGl;
+ std::unique_ptr<CompositorGl> mCompositorGl;
+ std::unique_ptr<DisplayGl> mDisplayGl;
+ std::unique_ptr<ReadbackWorkerGl> mReadbackWorkerGl;
- std::unique_ptr<TextureDraw> mTextureDraw;
+ std::unique_ptr<TextureDraw> mTextureDraw;
};
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/GLESVersionDetector.cpp b/stream-servers/gl/GLESVersionDetector.cpp
index 14ed649..bb2bdff 100644
--- a/stream-servers/gl/GLESVersionDetector.cpp
+++ b/stream-servers/gl/GLESVersionDetector.cpp
@@ -25,6 +25,9 @@
#include <algorithm>
+namespace gfxstream {
+namespace gl {
+
// Config + context attributes to query the underlying OpenGL if it is
// a OpenGL ES backend. Only try for OpenGL ES 3, and assume OpenGL ES 2
// exists (if it doesn't, this is the least of our problems).
@@ -247,3 +250,6 @@
return filteredExtensions;
}
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/GLESVersionDetector.h b/stream-servers/gl/GLESVersionDetector.h
index b3d4dba..dcaa2f2 100644
--- a/stream-servers/gl/GLESVersionDetector.h
+++ b/stream-servers/gl/GLESVersionDetector.h
@@ -21,6 +21,10 @@
#include <EGL/eglext.h>
#include <string>
+
+namespace gfxstream {
+namespace gl {
+
// Used to determine maximum supported GLES version.
GLESDispatchMaxVersion calcMaxVersionFromDispatch(EGLDisplay dpy);
@@ -29,3 +33,5 @@
std::string filterExtensionsBasedOnMaxVersion(GLESDispatchMaxVersion ver, const std::string& exts);
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/OpenGLESDispatch/EGLDispatch.cpp b/stream-servers/gl/OpenGLESDispatch/EGLDispatch.cpp
index 46a1fab..45444a8 100644
--- a/stream-servers/gl/OpenGLESDispatch/EGLDispatch.cpp
+++ b/stream-servers/gl/OpenGLESDispatch/EGLDispatch.cpp
@@ -18,10 +18,13 @@
#include <stdio.h>
#include <stdlib.h>
+namespace gfxstream {
+namespace gl {
+
EGLDispatch s_egl;
#define RENDER_EGL_LOAD_FIELD_STATIC(return_type, function_name, signature) \
- s_egl. function_name = (function_name ## _t) (translator::egl::function_name); \
+ s_egl.function_name = (function_name##_t)(::translator::egl::function_name);
#define RENDER_EGL_LOAD_FIELD_WITH_EGL(return_type, function_name, signature) \
if ((!s_egl. function_name) && s_egl.eglGetProcAddress) s_egl. function_name = \
@@ -44,3 +47,6 @@
s_egl.initialized = true;
return true;
}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/OpenGLESDispatch/GLESv1Dispatch.cpp b/stream-servers/gl/OpenGLESDispatch/GLESv1Dispatch.cpp
index 40c2656..82e6a99 100644
--- a/stream-servers/gl/OpenGLESDispatch/GLESv1Dispatch.cpp
+++ b/stream-servers/gl/OpenGLESDispatch/GLESv1Dispatch.cpp
@@ -22,6 +22,9 @@
#include <stdlib.h>
#include <string.h>
+namespace gfxstream {
+namespace gl {
+
#define DEBUG 0
#if DEBUG
@@ -99,12 +102,12 @@
//
// macro to assign from static library
-#define ASSIGN_GLES1_STATIC(return_type,function_name,signature,callargs)\
- dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
- translator::gles1::function_name); \
- if ((!dispatch_table-> function_name) && s_egl.eglGetProcAddress) \
- dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
- s_egl.eglGetProcAddress(#function_name)); \
+#define ASSIGN_GLES1_STATIC(return_type, function_name, signature, callargs) \
+ dispatch_table->function_name = \
+ reinterpret_cast<function_name##_t>(::translator::gles1::function_name); \
+ if ((!dispatch_table->function_name) && s_egl.eglGetProcAddress) \
+ dispatch_table->function_name = \
+ reinterpret_cast<function_name##_t>(s_egl.eglGetProcAddress(#function_name));
bool gles1_dispatch_init(GLESv1Dispatch* dispatch_table) {
if (dispatch_table->initialized) return true;
@@ -127,3 +130,6 @@
}
return func;
}
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/OpenGLESDispatch/GLESv2Dispatch.cpp b/stream-servers/gl/OpenGLESDispatch/GLESv2Dispatch.cpp
index 68bbafa..48207a5 100644
--- a/stream-servers/gl/OpenGLESDispatch/GLESv2Dispatch.cpp
+++ b/stream-servers/gl/OpenGLESDispatch/GLESv2Dispatch.cpp
@@ -24,6 +24,9 @@
#define DEFAULT_GLES_V2_LIB EMUGL_LIBNAME("GLES_V2_translator")
+namespace gfxstream {
+namespace gl {
+
// An unimplemented function which prints out an error message.
// To make it consistent with the guest, all GLES2 functions not supported by
// the driver should be redirected to this function.
@@ -32,18 +35,18 @@
fprintf(stderr, "Called unimplemented GLES API\n");
}
-#define LOOKUP_SYMBOL_STATIC(return_type,function_name,signature,callargs) \
- dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
- translator::gles2::function_name); \
- if ((!dispatch_table-> function_name) && s_egl.eglGetProcAddress) \
- dispatch_table-> function_name = reinterpret_cast< function_name ## _t >( \
- s_egl.eglGetProcAddress(#function_name)); \
+#define LOOKUP_SYMBOL_STATIC(return_type, function_name, signature, callargs) \
+ dispatch_table->function_name = \
+ reinterpret_cast<function_name##_t>(::translator::gles2::function_name); \
+ if ((!dispatch_table->function_name) && s_egl.eglGetProcAddress) \
+ dispatch_table->function_name = \
+ reinterpret_cast<function_name##_t>(s_egl.eglGetProcAddress(#function_name));
bool gles2_dispatch_init(GLESv2Dispatch* dispatch_table) {
if (dispatch_table->initialized) return true;
LIST_GLES2_FUNCTIONS(LOOKUP_SYMBOL_STATIC,LOOKUP_SYMBOL_STATIC)
-
+
dispatch_table->initialized = true;
return true;
}
@@ -61,3 +64,6 @@
}
return func;
}
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/OpenGLESDispatch/OpenGLDispatchLoader.cpp b/stream-servers/gl/OpenGLESDispatch/OpenGLDispatchLoader.cpp
index 405c4a4..d728621 100644
--- a/stream-servers/gl/OpenGLESDispatch/OpenGLDispatchLoader.cpp
+++ b/stream-servers/gl/OpenGLESDispatch/OpenGLDispatchLoader.cpp
@@ -16,13 +16,12 @@
#include "OpenGLESDispatch/DispatchTables.h"
+namespace gfxstream {
+namespace gl {
+
GLESv1Dispatch s_gles1;
GLESv2Dispatch s_gles2;
-using emugl::LazyLoadedGLESv1Dispatch;
-using emugl::LazyLoadedGLESv2Dispatch;
-using emugl::LazyLoadedEGLDispatch;
-
// Must be declared outside of LazyLoaded*Dispatch scope due to the use of
// sizeof(T) within the template definition.
static LazyLoadedGLESv1Dispatch* sGLESv1Dispatch() {
@@ -79,3 +78,6 @@
}
LazyLoadedEGLDispatch::LazyLoadedEGLDispatch() { mValid = init_egl_dispatch(); }
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/OpenGLESDispatch/StaticDispatch.cpp b/stream-servers/gl/OpenGLESDispatch/StaticDispatch.cpp
index 9fe669b..c56a862 100644
--- a/stream-servers/gl/OpenGLESDispatch/StaticDispatch.cpp
+++ b/stream-servers/gl/OpenGLESDispatch/StaticDispatch.cpp
@@ -22,6 +22,9 @@
#include <string.h>
+namespace gfxstream {
+namespace gl {
+
// Returns functions from s_gles2/s_gles1, for use with static Translator.
void* gles1_dispatch_get_proc_func_static(const char* name) {
@@ -45,3 +48,6 @@
return func;
}
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/ReadbackWorkerGl.cpp b/stream-servers/gl/ReadbackWorkerGl.cpp
index 426f86b..98bc9d4 100644
--- a/stream-servers/gl/ReadbackWorkerGl.cpp
+++ b/stream-servers/gl/ReadbackWorkerGl.cpp
@@ -27,6 +27,7 @@
#include "host-common/misc.h"
namespace gfxstream {
+namespace gl {
ReadbackWorkerGl::TrackedDisplay::TrackedDisplay(uint32_t displayId, uint32_t w, uint32_t h)
: mBufferSize(4 * w * h /* RGBA8 (4 bpp) */),
@@ -243,4 +244,5 @@
lock.unlock();
}
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/ReadbackWorkerGl.h b/stream-servers/gl/ReadbackWorkerGl.h
index a5ec3ce..23882df 100644
--- a/stream-servers/gl/ReadbackWorkerGl.h
+++ b/stream-servers/gl/ReadbackWorkerGl.h
@@ -27,9 +27,12 @@
#include "DisplaySurfaceGl.h"
#include "ReadbackWorker.h"
+namespace gfxstream {
class ColorBuffer;
+} // namespace gfxstream
namespace gfxstream {
+namespace gl {
// This class implements async readback of emugl ColorBuffers.
// It is meant to run on both the emugl framebuffer posting thread
@@ -105,4 +108,5 @@
DISALLOW_COPY_AND_ASSIGN(ReadbackWorkerGl);
};
+} // namespace gl
} // namespace gfxstream
diff --git a/stream-servers/gl/TextureDraw.cpp b/stream-servers/gl/TextureDraw.cpp
index e9f9f67..b57936b 100644
--- a/stream-servers/gl/TextureDraw.cpp
+++ b/stream-servers/gl/TextureDraw.cpp
@@ -25,6 +25,8 @@
#include <stdio.h>
#define ERR(...) fprintf(stderr, __VA_ARGS__)
+namespace gfxstream {
+namespace gl {
namespace {
// Helper function to create a new shader.
@@ -686,3 +688,6 @@
s_gles2.glUniform2f(mCoordTranslation, 0.0, 0.0);
s_gles2.glUniform2f(mCoordScale, 1.0, 1.0);
}
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/TextureDraw.h b/stream-servers/gl/TextureDraw.h
index a5ade18..f970764 100644
--- a/stream-servers/gl/TextureDraw.h
+++ b/stream-servers/gl/TextureDraw.h
@@ -23,6 +23,9 @@
#include <vector>
+namespace gfxstream {
+namespace gl {
+
// Helper class used to draw a simple texture to the current framebuffer.
// Usage is pretty simple:
//
@@ -95,4 +98,7 @@
bool mBlendResetNeeded = false;
};
+} // namespace gl
+} // namespace gfxstream
+
#endif // TEXTURE_DRAW_H
diff --git a/stream-servers/gl/TextureResize.cpp b/stream-servers/gl/TextureResize.cpp
index 761405b..e523101 100644
--- a/stream-servers/gl/TextureResize.cpp
+++ b/stream-servers/gl/TextureResize.cpp
@@ -31,6 +31,9 @@
#include "host-common/misc.h"
#include "host-common/opengl/misc.h"
+namespace gfxstream {
+namespace gl {
+
// #define V(...) VERBOSE_PRINT(gles,__VA_ARGS__)
#define V(...)
#define MAX_FACTOR_POWER 4
@@ -614,4 +617,5 @@
s_gles2.glDeleteBuffers(1, &mIndexBuffer);
}
-
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/TextureResize.h b/stream-servers/gl/TextureResize.h
index c1df6d6..d083998 100644
--- a/stream-servers/gl/TextureResize.h
+++ b/stream-servers/gl/TextureResize.h
@@ -19,6 +19,9 @@
#include <GLES2/gl2.h>
#include <memory>
+namespace gfxstream {
+namespace gl {
+
class TextureResize {
public:
TextureResize(GLuint width, GLuint height);
@@ -74,4 +77,7 @@
std::unique_ptr<GenericResizer> mGenericResizer;
};
+} // namespace gl
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/gl/YUVConverter.cpp b/stream-servers/gl/YUVConverter.cpp
index d06f768..457e7c3 100644
--- a/stream-servers/gl/YUVConverter.cpp
+++ b/stream-servers/gl/YUVConverter.cpp
@@ -24,6 +24,8 @@
#include "host-common/feature_control.h"
#include "host-common/opengl/misc.h"
+namespace gfxstream {
+namespace gl {
#define FATAL(fmt,...) do { \
fprintf(stderr, "%s: FATAL: " fmt "\n", __func__, ##__VA_ARGS__); \
@@ -1025,3 +1027,6 @@
YUVConverter::~YUVConverter() {
reset();
}
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/YUVConverter.h b/stream-servers/gl/YUVConverter.h
index 23dde61..f00edb7 100644
--- a/stream-servers/gl/YUVConverter.h
+++ b/stream-servers/gl/YUVConverter.h
@@ -25,6 +25,9 @@
#include <cstring>
#include <vector>
+namespace gfxstream {
+namespace gl {
+
enum class YUVPlane {
Y = 0,
U = 1,
@@ -133,3 +136,6 @@
GLint mCurrVbo = 0;
GLint mCurrIbo = 0;
};
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/gles1_dec/GLESv1Decoder.cpp b/stream-servers/gl/gles1_dec/GLESv1Decoder.cpp
index 8d9f234..f1d918f 100644
--- a/stream-servers/gl/gles1_dec/GLESv1Decoder.cpp
+++ b/stream-servers/gl/gles1_dec/GLESv1Decoder.cpp
@@ -31,6 +31,9 @@
using android::base::AutoLock;
using android::base::StaticLock;
+namespace gfxstream {
+namespace gl {
+
static inline void* SafePointerFromUInt(GLuint value) {
return (void*)(uintptr_t)value;
}
@@ -382,3 +385,6 @@
}
return func;
}
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/gles1_dec/GLESv1Decoder.h b/stream-servers/gl/gles1_dec/GLESv1Decoder.h
index 6369ff5..7497e99 100644
--- a/stream-servers/gl/gles1_dec/GLESv1Decoder.h
+++ b/stream-servers/gl/gles1_dec/GLESv1Decoder.h
@@ -21,6 +21,9 @@
#include "GLDecoderContextData.h"
#include "aemu/base/SharedLibrary.h"
+namespace gfxstream {
+namespace gl {
+
typedef void (gles1_APIENTRY *glColorPointerWithDataSize_server_proc_t) (GLint, GLenum, GLsizei, const GLvoid*, GLsizei);
typedef void (gles1_APIENTRY *glNormalPointerWithDataSize_server_proc_t) (GLenum, GLsizei, const GLvoid*, GLsizei);
typedef void (gles1_APIENTRY *glTexCoordPointerWithDataSize_server_proc_t) (GLint, GLenum, GLsizei, const GLvoid*, GLsizei);
@@ -92,4 +95,7 @@
android::base::SharedLibrary* m_glesDso;
};
+} // namespace gl
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/gl/gles1_dec/gles1_dec.cpp b/stream-servers/gl/gles1_dec/gles1_dec.cpp
index 5a57803..5a4c6b2 100644
--- a/stream-servers/gl/gles1_dec/gles1_dec.cpp
+++ b/stream-servers/gl/gles1_dec/gles1_dec.cpp
@@ -16,6 +16,8 @@
#include <stdio.h>
+namespace gfxstream {
+
typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
#ifdef CHECK_GL_ERRORS
@@ -23,8 +25,6 @@
#else
# define SET_LASTCALL(name)
#endif
-using namespace emugl;
-
size_t gles1_decoder_context_t::decode(void *buf, size_t len, IOStream *stream, ChecksumCalculator* checksumCalc) {
if (len < 8) return 0;
#ifdef CHECK_GL_ERRORS
@@ -6185,3 +6185,4 @@
} // while
return ptr - (unsigned char*)buf;
}
+} // namespace gfxstream
diff --git a/stream-servers/gl/gles1_dec/gles1_dec.h b/stream-servers/gl/gles1_dec/gles1_dec.h
index 767c01c..4425a4f 100644
--- a/stream-servers/gl/gles1_dec/gles1_dec.h
+++ b/stream-servers/gl/gles1_dec/gles1_dec.h
@@ -8,7 +8,7 @@
#include "ChecksumCalculator.h"
#include "gles1_server_context.h"
-
+namespace gfxstream {
struct gles1_decoder_context_t : public gles1_server_context_t {
@@ -16,4 +16,6 @@
};
+} // namespace gfxstream
+
#endif // GUARD_gles1_decoder_context_t
diff --git a/stream-servers/gl/gles2_dec/GLESv2Decoder.cpp b/stream-servers/gl/gles2_dec/GLESv2Decoder.cpp
index a7cbad2..2876492 100644
--- a/stream-servers/gl/gles2_dec/GLESv2Decoder.cpp
+++ b/stream-servers/gl/gles2_dec/GLESv2Decoder.cpp
@@ -34,6 +34,9 @@
#include <string.h>
+namespace gfxstream {
+namespace gl {
+
using android::base::AutoLock;
using android::base::StaticLock;
@@ -713,7 +716,7 @@
GLuint GLESv2Decoder::s_glCreateShader(void* self, GLenum shaderType) {
GLESv2Decoder *ctx = (GLESv2Decoder *)self;
GLuint shader = ctx->glCreateShader(shaderType);
-
+
if (ctx->m_snapshot) {
GLuint emuName = ctx->m_snapshot->createShader(shader, shaderType);
return emuName;
@@ -1065,3 +1068,6 @@
SNAPSHOT_PROGRAM_CALL_RET(GLuint, glGetProgramResourceIndex, (void* self, GLuint program, GLenum programInterface, const char * name), (program, programInterface, name))
SNAPSHOT_PROGRAM_CALL_RET(GLint, glGetProgramResourceLocation, (void* self, GLuint program, GLenum programInterface, const char * name), (program, programInterface, name))
SNAPSHOT_PROGRAM_CALL(glGetProgramResourceName, (void* self, GLuint program, GLenum programInterface, GLuint index, GLsizei bufSize, GLsizei* length, char* name), (program, programInterface, index, bufSize, length, name))
+
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/gl/gles2_dec/GLESv2Decoder.h b/stream-servers/gl/gles2_dec/GLESv2Decoder.h
index 8aa7ff7..17f0a03 100644
--- a/stream-servers/gl/gles2_dec/GLESv2Decoder.h
+++ b/stream-servers/gl/gles2_dec/GLESv2Decoder.h
@@ -23,6 +23,9 @@
#include "GLSnapshot.h"
+namespace gfxstream {
+namespace gl {
+
typedef void (gles2_APIENTRY *glVertexAttribPointerWithDataSize_server_proc_t) (GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*, GLsizei);
typedef void (gles2_APIENTRY *glVertexAttribIPointerWithDataSize_server_proc_t) (GLuint, GLint, GLenum, GLsizei, const GLvoid*, GLsizei);
@@ -45,7 +48,8 @@
int initGL(get_proc_func_t getProcFunc, void *getProcFuncData);
void setContextData(GLDecoderContextData *contextData) { m_contextData = contextData; }
protected:
- GLSnapshot::GLSnapshotState *m_snapshot;
+ snapshot::GLSnapshotState* m_snapshot;
+
private:
GLDecoderContextData *m_contextData;
android::base::SharedLibrary* m_GL2library;
@@ -113,7 +117,7 @@
//============================================================
// All generations============================================
-
+
static GLuint gles2_APIENTRY s_glCreateShader(void* self, GLenum shaderType);
static GLuint gles2_APIENTRY s_glCreateProgram(void* self);
@@ -269,4 +273,8 @@
GLboolean blue, GLboolean alpha);
static GLboolean gles2_APIENTRY s_glIsEnablediEXT(void* self, GLenum cap, GLuint index);
};
+
+} // namespace gl
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/gl/gles2_dec/gles2_dec.cpp b/stream-servers/gl/gles2_dec/gles2_dec.cpp
index d8be92e..6041816 100644
--- a/stream-servers/gl/gles2_dec/gles2_dec.cpp
+++ b/stream-servers/gl/gles2_dec/gles2_dec.cpp
@@ -16,6 +16,8 @@
#include <stdio.h>
+namespace gfxstream {
+
typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
#ifdef CHECK_GL_ERRORS
@@ -23,8 +25,6 @@
#else
# define SET_LASTCALL(name)
#endif
-using namespace emugl;
-
size_t gles2_decoder_context_t::decode(void *buf, size_t len, IOStream *stream, ChecksumCalculator* checksumCalc) {
if (len < 8) return 0;
#ifdef CHECK_GL_ERRORS
@@ -9755,3 +9755,4 @@
} // while
return ptr - (unsigned char*)buf;
}
+} // namespace gfxstream
diff --git a/stream-servers/gl/gles2_dec/gles2_dec.h b/stream-servers/gl/gles2_dec/gles2_dec.h
index df07867..9f25164 100644
--- a/stream-servers/gl/gles2_dec/gles2_dec.h
+++ b/stream-servers/gl/gles2_dec/gles2_dec.h
@@ -8,7 +8,7 @@
#include "ChecksumCalculator.h"
#include "gles2_server_context.h"
-
+namespace gfxstream {
struct gles2_decoder_context_t : public gles2_server_context_t {
@@ -16,4 +16,6 @@
};
+} // namespace gfxstream
+
#endif // GUARD_gles2_decoder_context_t
diff --git a/stream-servers/gl/glestranslator/GLcommon/TextureUtils.cpp b/stream-servers/gl/glestranslator/GLcommon/TextureUtils.cpp
index bce04ec..bd6e8df 100644
--- a/stream-servers/gl/glestranslator/GLcommon/TextureUtils.cpp
+++ b/stream-servers/gl/glestranslator/GLcommon/TextureUtils.cpp
@@ -25,7 +25,7 @@
#include "compressedTextureFormats/AstcCpuDecompressor.h"
using android::AlignedBuf;
-using goldfish_vk::AstcCpuDecompressor;
+using gfxstream::vk::AstcCpuDecompressor;
#define GL_R16 0x822A
#define GL_RG16 0x822C
diff --git a/stream-servers/gl/glsnapshot/GLSnapshot.cpp b/stream-servers/gl/glsnapshot/GLSnapshot.cpp
index 6959654..27fe79f 100644
--- a/stream-servers/gl/glsnapshot/GLSnapshot.cpp
+++ b/stream-servers/gl/glsnapshot/GLSnapshot.cpp
@@ -17,7 +17,9 @@
#define D(...)
#endif
-namespace GLSnapshot {
+namespace gfxstream {
+namespace gl {
+namespace snapshot {
GLSnapshotState::GLSnapshotState(const GLESv2Dispatch* gl) : mGL(gl) {
D("init snapshot state");
@@ -116,7 +118,6 @@
void GLSnapshotState::shaderString(GLuint shader, const GLchar* string) {
mShaderState[mProgramNamesBack[shader]].source = std::string(string);
-
}
void GLSnapshotState::genBuffers(GLsizei n, GLuint* buffers) {
@@ -127,4 +128,6 @@
return mProgramNames[name];
}
-} // namespace GLSnapshot
+} // namespace snapshot
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/gl/glsnapshot/GLSnapshot.h b/stream-servers/gl/glsnapshot/GLSnapshot.h
index 308573e..fd072c7 100644
--- a/stream-servers/gl/glsnapshot/GLSnapshot.h
+++ b/stream-servers/gl/glsnapshot/GLSnapshot.h
@@ -10,7 +10,9 @@
#include <GLES2/gl2.h>
-namespace GLSnapshot {
+namespace gfxstream {
+namespace gl {
+namespace snapshot {
struct GLValue {
std::vector<GLenum> enums;
@@ -70,4 +72,6 @@
};
-} // namespace GLSnapshot
+} // namespace snapshot
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/magma/magma_dec/magma_dec.cpp b/stream-servers/magma/magma_dec/magma_dec.cpp
index 57c50e2..c067c7a 100644
--- a/stream-servers/magma/magma_dec/magma_dec.cpp
+++ b/stream-servers/magma/magma_dec/magma_dec.cpp
@@ -16,6 +16,8 @@
#include <stdio.h>
+namespace gfxstream {
+
typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
#ifdef CHECK_GL_ERRORS
@@ -23,8 +25,6 @@
#else
# define SET_LASTCALL(name)
#endif
-using namespace emugl;
-
size_t magma_decoder_context_t::decode(void *buf, size_t len, IOStream *stream, ChecksumCalculator* checksumCalc) {
if (len < 8) return 0;
#ifdef CHECK_GL_ERRORS
@@ -1150,3 +1150,4 @@
} // while
return ptr - (unsigned char*)buf;
}
+} // namespace gfxstream
diff --git a/stream-servers/magma/magma_dec/magma_dec.h b/stream-servers/magma/magma_dec/magma_dec.h
index eb7a1d9..cabbe4d 100644
--- a/stream-servers/magma/magma_dec/magma_dec.h
+++ b/stream-servers/magma/magma_dec/magma_dec.h
@@ -8,7 +8,7 @@
#include "ChecksumCalculator.h"
#include "magma_server_context.h"
-
+namespace gfxstream {
struct magma_decoder_context_t : public magma_server_context_t {
@@ -16,4 +16,6 @@
};
+} // namespace gfxstream
+
#endif // GUARD_magma_decoder_context_t
diff --git a/stream-servers/renderControl_dec/renderControl_dec.cpp b/stream-servers/renderControl_dec/renderControl_dec.cpp
index 7a3a902..96e5b38 100644
--- a/stream-servers/renderControl_dec/renderControl_dec.cpp
+++ b/stream-servers/renderControl_dec/renderControl_dec.cpp
@@ -16,6 +16,8 @@
#include <stdio.h>
+namespace gfxstream {
+
typedef unsigned int tsize_t; // Target "size_t", which is 32-bit for now. It may or may not be the same as host's size_t when emugen is compiled.
#ifdef CHECK_GL_ERRORS
@@ -23,8 +25,6 @@
#else
# define SET_LASTCALL(name)
#endif
-using namespace emugl;
-
size_t renderControl_decoder_context_t::decode(void *buf, size_t len, IOStream *stream, ChecksumCalculator* checksumCalc) {
if (len < 8) return 0;
#ifdef CHECK_GL_ERRORS
@@ -1469,3 +1469,4 @@
} // while
return ptr - (unsigned char*)buf;
}
+} // namespace gfxstream
diff --git a/stream-servers/renderControl_dec/renderControl_dec.h b/stream-servers/renderControl_dec/renderControl_dec.h
index 334f6ba..ac97dda 100644
--- a/stream-servers/renderControl_dec/renderControl_dec.h
+++ b/stream-servers/renderControl_dec/renderControl_dec.h
@@ -8,7 +8,7 @@
#include "ChecksumCalculator.h"
#include "renderControl_server_context.h"
-
+namespace gfxstream {
struct renderControl_decoder_context_t : public renderControl_server_context_t {
@@ -16,4 +16,6 @@
};
+} // namespace gfxstream
+
#endif // GUARD_renderControl_decoder_context_t
diff --git a/stream-servers/render_api.cpp b/stream-servers/render_api.cpp
index bd3e04a..75b770a 100644
--- a/stream-servers/render_api.cpp
+++ b/stream-servers/render_api.cpp
@@ -23,11 +23,13 @@
#include <memory>
-RENDER_APICALL emugl::RenderLibPtr RENDER_APIENTRY initLibrary() {
+namespace gfxstream {
+
+RENDER_APICALL RenderLibPtr RENDER_APIENTRY initLibrary() {
//
// Load EGL Plugin
//
- if (!emugl::LazyLoadedEGLDispatch::get()) {
+ if (!gl::LazyLoadedEGLDispatch::get()) {
// Failed to load EGL
printf("Failed to init_egl_dispatch\n");
return nullptr;
@@ -36,17 +38,19 @@
//
// Load GLES Plugin
//
- if (!emugl::LazyLoadedGLESv1Dispatch::get()) {
+ if (!gl::LazyLoadedGLESv1Dispatch::get()) {
// Failed to load GLES
ERR("Failed to gles1_dispatch_init\n");
return nullptr;
}
/* failure to init the GLES2 dispatch table is not fatal */
- if (!emugl::LazyLoadedGLESv2Dispatch::get()) {
+ if (!gl::LazyLoadedGLESv2Dispatch::get()) {
ERR("Failed to gles2_dispatch_init\n");
return nullptr;
}
- return emugl::RenderLibPtr(new emugl::RenderLibImpl());
+ return RenderLibPtr(new RenderLibImpl());
}
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/render_api.h b/stream-servers/render_api.h
index a3b66af..653d0cc 100644
--- a/stream-servers/render_api.h
+++ b/stream-servers/render_api.h
@@ -28,6 +28,8 @@
ANDROID_BEGIN_HEADER
#endif
+namespace gfxstream {
+
// Use KHRONOS_APICALL to control visibility, but do not use KHRONOS_APIENTRY
// because we don't need the functions to be __stdcall on Win32.
#define RENDER_APICALL KHRONOS_APICALL
@@ -39,7 +41,9 @@
LIST_RENDER_API_FUNCTIONS(RENDER_API_DECLARE)
-RENDER_APICALL emugl::RenderLibPtr RENDER_APIENTRY initLibrary();
+RENDER_APICALL RenderLibPtr RENDER_APIENTRY initLibrary();
+
+} // namespace gfxstream
#ifndef USING_ANDROID_BP
ANDROID_END_HEADER
diff --git a/stream-servers/tests/CompositorVk_unittest.cpp b/stream-servers/tests/CompositorVk_unittest.cpp
index 3e02b2a..0288264 100644
--- a/stream-servers/tests/CompositorVk_unittest.cpp
+++ b/stream-servers/tests/CompositorVk_unittest.cpp
@@ -16,6 +16,8 @@
#include "vulkan/VulkanDispatch.h"
#include "vulkan/vk_util.h"
+namespace gfxstream {
+namespace vk {
namespace {
static constexpr const bool kDefaultSaveImageIfComparisonFailed = false;
@@ -33,13 +35,11 @@
class CompositorVkTest : public ::testing::Test {
protected:
- using TargetImage = emugl::RenderResourceVk<VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
- VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT>;
- using SourceImage = emugl::RenderTextureVk;
+ using TargetImage = RenderResourceVk<VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL,
+ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT>;
+ using SourceImage = RenderTextureVk;
- static void SetUpTestCase() {
- k_vk = emugl::vkDispatch(false);
- }
+ static void SetUpTestCase() { k_vk = vkDispatch(false); }
void SetUp() override {
#if defined(__APPLE__) && defined(__arm64__)
@@ -258,7 +258,7 @@
checkImageFilledWith(image, color);
}
- static const goldfish_vk::VulkanDispatch *k_vk;
+ static const VulkanDispatch* k_vk;
VkInstance m_vkInstance = VK_NULL_HANDLE;
VkPhysicalDevice m_vkPhysicalDevice = VK_NULL_HANDLE;
uint32_t m_compositorQueueFamilyIndex = 0;
@@ -355,7 +355,7 @@
}
};
-const goldfish_vk::VulkanDispatch *CompositorVkTest::k_vk = nullptr;
+const VulkanDispatch* CompositorVkTest::k_vk = nullptr;
TEST_F(CompositorVkTest, QueueSupportsComposition) {
VkQueueFamilyProperties properties = {};
@@ -820,3 +820,5 @@
}
} // namespace
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/tests/DefaultFramebufferBlit_unittest.cpp b/stream-servers/tests/DefaultFramebufferBlit_unittest.cpp
index 398c642..7952f55 100644
--- a/stream-servers/tests/DefaultFramebufferBlit_unittest.cpp
+++ b/stream-servers/tests/DefaultFramebufferBlit_unittest.cpp
@@ -19,14 +19,17 @@
#include <memory>
-using gfxstream::GLESApi;
-using gfxstream::GLESApi_2;
-using gfxstream::GLESApi_3_0;
-using gfxstream::GLESApi_3_1;
-using gfxstream::GLESApi_3_2;
-using gfxstream::GLESApi_CM;
+namespace gfxstream {
+namespace {
-namespace emugl {
+using gl::GLESApi;
+using gl::GLESApi_2;
+using gl::GLESApi_3_0;
+using gl::GLESApi_3_1;
+using gl::GLESApi_3_2;
+using gl::GLESApi_CM;
+using gl::LazyLoadedEGLDispatch;
+using gl::LazyLoadedGLESv2Dispatch;
struct ClearColorParam {
const GLESApi glVersion;
@@ -275,5 +278,5 @@
testing::Values(
ClearColorParam(GLESApi_3_0, true)));
-
-} // namespace emugl
+} // namespace
+} // namespace gfxstream
diff --git a/stream-servers/tests/DisplayVk_unittest.cpp b/stream-servers/tests/DisplayVk_unittest.cpp
index cda4937..2842873 100644
--- a/stream-servers/tests/DisplayVk_unittest.cpp
+++ b/stream-servers/tests/DisplayVk_unittest.cpp
@@ -12,22 +12,26 @@
using gfxstream::DisplaySurface;
+namespace gfxstream {
+namespace vk {
+namespace {
+
class DisplayVkTest : public ::testing::Test {
protected:
- using RenderTexture = emugl::RenderTextureVk;
+ using RenderTexture = RenderTextureVk;
- static void SetUpTestCase() { k_vk = emugl::vkDispatch(false); }
+ static void SetUpTestCase() { k_vk = vkDispatch(false); }
void SetUp() override {
// skip the test when testing without a window
- if (!emugl::shouldUseWindow()) {
+ if (!shouldUseWindow()) {
GTEST_SKIP();
}
ASSERT_NE(k_vk, nullptr);
createInstance();
createWindowAndSurface();
- m_window = emugl::createOrGetTestWindow(0, 0, k_width, k_height);
+ m_window = createOrGetTestWindow(0, 0, k_width, k_height);
pickPhysicalDevice();
createLogicalDevice();
k_vk->vkGetDeviceQueue(m_vkDevice, m_compositorQueueFamilyIndex, 0, &m_compositorVkQueue);
@@ -51,7 +55,7 @@
}
void TearDown() override {
- if (emugl::shouldUseWindow()) {
+ if (shouldUseWindow()) {
ASSERT_EQ(k_vk->vkQueueWaitIdle(m_compositorVkQueue), VK_SUCCESS);
ASSERT_EQ(k_vk->vkQueueWaitIdle(m_swapChainVkQueue), VK_SUCCESS);
@@ -80,7 +84,7 @@
return info;
}
- static const goldfish_vk::VulkanDispatch *k_vk;
+ static const VulkanDispatch* k_vk;
static constexpr uint32_t k_width = 0x100;
static constexpr uint32_t k_height = 0x100;
@@ -119,7 +123,7 @@
}
void createWindowAndSurface() {
- m_window = emugl::createOrGetTestWindow(0, 0, k_width, k_height);
+ m_window = createOrGetTestWindow(0, 0, k_width, k_height);
ASSERT_NE(m_window, nullptr);
// TODO(kaiyili, b/179477624): add support for other platforms
#ifdef _WIN32
@@ -205,7 +209,7 @@
}
};
-const goldfish_vk::VulkanDispatch *DisplayVkTest::k_vk = nullptr;
+const VulkanDispatch* DisplayVkTest::k_vk = nullptr;
TEST_F(DisplayVkTest, Init) {}
@@ -282,3 +286,7 @@
waitForGpuFuture.wait();
}
}
+
+} // namespace
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/tests/FrameBuffer_unittest.cpp b/stream-servers/tests/FrameBuffer_unittest.cpp
index dc79ad0..6bca587 100644
--- a/stream-servers/tests/FrameBuffer_unittest.cpp
+++ b/stream-servers/tests/FrameBuffer_unittest.cpp
@@ -43,12 +43,17 @@
#include "X11TestingSupport.h"
#endif
+namespace gfxstream {
+namespace {
+
using android::base::StdioStream;
using android::snapshot::TextureLoader;
using android::snapshot::TextureSaver;
-using gfxstream::GLESApi_3_0;
-
-namespace emugl {
+using gl::EGLDispatch;
+using gl::EmulatedEglConfigList;
+using gl::GLESApi_3_0;
+using gl::LazyLoadedEGLDispatch;
+using gl::LazyLoadedGLESv2Dispatch;
class FrameBufferTest : public ::testing::Test {
public:
@@ -981,4 +986,6 @@
freeNativePixmap(pixmap);
}
#endif
-} // namespace emugl
+
+} // namespace
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLES1Dispatch_unittest.cpp b/stream-servers/tests/GLES1Dispatch_unittest.cpp
index ec6f1ed..174ccf2 100644
--- a/stream-servers/tests/GLES1Dispatch_unittest.cpp
+++ b/stream-servers/tests/GLES1Dispatch_unittest.cpp
@@ -18,7 +18,10 @@
#include "GLTestUtils.h"
#include "OpenGLTestContext.h"
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
+
// b/233094475: GLES1 frustumf crash on cmcontext should not crash when
// core profile is not enabled.
TEST_F(GLTest, TestGlFrustumNoCoreProfile) {
@@ -32,4 +35,6 @@
context.frustumf(0, 0, 0, 0, 0, 0);
}
-} // namespace emugl
\ No newline at end of file
+} // namespace
+} // namespace gl
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/tests/GLSnapshotBuffers_unittest.cpp b/stream-servers/tests/GLSnapshotBuffers_unittest.cpp
index d246d90..2dc4318 100644
--- a/stream-servers/tests/GLSnapshotBuffers_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotBuffers_unittest.cpp
@@ -20,7 +20,9 @@
#include <map>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
static const GLenum kGLES2GlobalBufferBindings[] = {
GL_ARRAY_BUFFER_BINDING, GL_ELEMENT_ARRAY_BUFFER_BINDING};
@@ -143,4 +145,6 @@
doCheckedSnapshot();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotFramebufferControl_unittest.cpp b/stream-servers/tests/GLSnapshotFramebufferControl_unittest.cpp
index fb12829..39f523a 100644
--- a/stream-servers/tests/GLSnapshotFramebufferControl_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotFramebufferControl_unittest.cpp
@@ -16,7 +16,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
class SnapshotGlColorMaskTest
: public SnapshotSetValueTest<std::vector<GLboolean>> {
@@ -106,4 +108,6 @@
doCheckedSnapshot();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotFramebuffers_unittest.cpp b/stream-servers/tests/GLSnapshotFramebuffers_unittest.cpp
index 397061d..05c3c6e 100644
--- a/stream-servers/tests/GLSnapshotFramebuffers_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotFramebuffers_unittest.cpp
@@ -19,7 +19,9 @@
#include <map>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
struct GlFramebufferAttachment {
GLenum type;
@@ -154,4 +156,6 @@
doCheckedSnapshot();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotMultisampling_unittest.cpp b/stream-servers/tests/GLSnapshotMultisampling_unittest.cpp
index 76ff56f..5e1a530 100644
--- a/stream-servers/tests/GLSnapshotMultisampling_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotMultisampling_unittest.cpp
@@ -17,7 +17,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
struct GlSampleCoverage {
GLclampf value;
@@ -52,4 +54,6 @@
SnapshotGlSampleCoverageTest,
::testing::ValuesIn(kGLES2TestSampleCoverages));
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotPixelOperations_unittest.cpp b/stream-servers/tests/GLSnapshotPixelOperations_unittest.cpp
index 347db33..6ace67f 100644
--- a/stream-servers/tests/GLSnapshotPixelOperations_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotPixelOperations_unittest.cpp
@@ -18,7 +18,9 @@
#include <gtest/gtest.h>
#include <array>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
struct GlStencilFunc {
GLenum func;
@@ -410,4 +412,6 @@
INSTANTIATE_TEST_SUITE_P(GLES2SnapshotPixelOps, SnapshotGlBlendFunciTest,
::testing::Values(kGLES2TestBlendFunci));
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotPixels_unittest.cpp b/stream-servers/tests/GLSnapshotPixels_unittest.cpp
index d75599b..98fc452 100644
--- a/stream-servers/tests/GLSnapshotPixels_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotPixels_unittest.cpp
@@ -16,7 +16,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
class SnapshotGlUnpackAlignmentTest
: public SnapshotSetValueTest<GLuint>,
@@ -58,4 +60,6 @@
SnapshotGlPackAlignmentTest,
::testing::Values(1, 2, 4, 8));
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotPrograms_unittest.cpp b/stream-servers/tests/GLSnapshotPrograms_unittest.cpp
index d73ebc2..d23ded1 100644
--- a/stream-servers/tests/GLSnapshotPrograms_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotPrograms_unittest.cpp
@@ -20,7 +20,9 @@
#include <map>
#include <string>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
static const char kTestVertexShader[] = R"(
attribute vec4 position;
@@ -414,4 +416,6 @@
doCheckedSnapshot();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotRasterization_unittest.cpp b/stream-servers/tests/GLSnapshotRasterization_unittest.cpp
index 3f016af..89c369e 100644
--- a/stream-servers/tests/GLSnapshotRasterization_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotRasterization_unittest.cpp
@@ -17,7 +17,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
// Line width settings to attempt
static const GLfloat kGLES2TestLineWidths[] = {2.0f};
@@ -101,5 +103,6 @@
doCheckedSnapshot();
}
-
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotRenderbuffers_unittest.cpp b/stream-servers/tests/GLSnapshotRenderbuffers_unittest.cpp
index a0ad642..b9593b6 100644
--- a/stream-servers/tests/GLSnapshotRenderbuffers_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotRenderbuffers_unittest.cpp
@@ -16,7 +16,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
struct GlRenderbufferFormat {
GLenum name;
@@ -205,4 +207,6 @@
SnapshotGlRenderbufferFormatTest,
::testing::ValuesIn(kGLES2TestRenderbufferStates));
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotRendering_unittest.cpp b/stream-servers/tests/GLSnapshotRendering_unittest.cpp
index e6df544..3b8bb4b 100644
--- a/stream-servers/tests/GLSnapshotRendering_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotRendering_unittest.cpp
@@ -21,10 +21,9 @@
#include <gtest/gtest.h>
-
-namespace emugl {
-
-
+namespace gfxstream {
+namespace gl {
+namespace {
TEST(SnapshotGlRenderingSampleTest, OverrideDispatch) {
const GLESv2Dispatch* gl = LazyLoadedGLESv2Dispatch::get();
@@ -73,7 +72,7 @@
emugl::set_emugl_window_operations(*getGraphicsAgents()->emu);
//const EGLDispatch* egl = LazyLoadedEGLDispatch::get();
- LazyLoadedGLESv2Dispatch::get();
+ gl::LazyLoadedGLESv2Dispatch::get();
getSnapshotTestDispatch();
mApp.reset(new T());
@@ -104,4 +103,6 @@
this->mApp->drawLoop();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotShaders_unittest.cpp b/stream-servers/tests/GLSnapshotShaders_unittest.cpp
index 37a68e6..8e304a2 100644
--- a/stream-servers/tests/GLSnapshotShaders_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotShaders_unittest.cpp
@@ -18,7 +18,9 @@
#include <string>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
static const char kTestVertexShaderSource[] = R"(
attribute vec4 position;
@@ -242,4 +244,6 @@
doCheckedSnapshot();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTestDispatch.cpp b/stream-servers/tests/GLSnapshotTestDispatch.cpp
index 258d218..9660e8e 100644
--- a/stream-servers/tests/GLSnapshotTestDispatch.cpp
+++ b/stream-servers/tests/GLSnapshotTestDispatch.cpp
@@ -12,7 +12,8 @@
#include "snapshot/TextureLoader.h"
#include "snapshot/TextureSaver.h"
-namespace emugl {
+namespace gfxstream {
+namespace gl {
using android::base::StdioStream;
using android::snapshot::TextureLoader;
@@ -169,4 +170,5 @@
prePixels.data(), postPixels.data()));
}
-} // namespace emugl
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTestDispatch.h b/stream-servers/tests/GLSnapshotTestDispatch.h
index 736e0fa..3a8d62b 100644
--- a/stream-servers/tests/GLSnapshotTestDispatch.h
+++ b/stream-servers/tests/GLSnapshotTestDispatch.h
@@ -18,7 +18,8 @@
#include "aemu/base/testing/TestSystem.h"
-namespace emugl {
+namespace gfxstream {
+namespace gl {
// Global dispatch object with functions overridden for snapshot testing
const GLESv2Dispatch* getSnapshotTestDispatch();
@@ -68,4 +69,5 @@
std::string mTextureFile = {};
};
-} // namespace emugl
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTestStateUtils.cpp b/stream-servers/tests/GLSnapshotTestStateUtils.cpp
index 8549d31..46b0af3 100644
--- a/stream-servers/tests/GLSnapshotTestStateUtils.cpp
+++ b/stream-servers/tests/GLSnapshotTestStateUtils.cpp
@@ -22,7 +22,8 @@
#include <GLES2/gl2.h>
#include <GLES3/gl31.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
GLuint createBuffer(const GLESv2Dispatch* gl, GlBufferData data) {
// We bind to GL_ARRAY_BUFFER in order to set up buffer data,
@@ -107,4 +108,5 @@
return out;
}
-} // namespace emugl
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTestStateUtils.h b/stream-servers/tests/GLSnapshotTestStateUtils.h
index d1cf385..311a8cc 100644
--- a/stream-servers/tests/GLSnapshotTestStateUtils.h
+++ b/stream-servers/tests/GLSnapshotTestStateUtils.h
@@ -18,7 +18,8 @@
#include <GLES2/gl2.h>
#include <GLES3/gl31.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
GLuint createBuffer(const GLESv2Dispatch* gl, GlBufferData data);
@@ -37,4 +38,5 @@
GLenum format,
GLenum type);
-} // namespace emugl
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTesting.cpp b/stream-servers/tests/GLSnapshotTesting.cpp
index 5b27eab..8ea3945 100644
--- a/stream-servers/tests/GLSnapshotTesting.cpp
+++ b/stream-servers/tests/GLSnapshotTesting.cpp
@@ -29,7 +29,8 @@
#include <GLES2/gl2.h>
#include <GLES3/gl31.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
using android::base::StdioStream;
using android::snapshot::TextureLoader;
@@ -344,4 +345,5 @@
}
}
-} // namespace emugl
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTesting.h b/stream-servers/tests/GLSnapshotTesting.h
index 5e6b7f4..ac979d6 100644
--- a/stream-servers/tests/GLSnapshotTesting.h
+++ b/stream-servers/tests/GLSnapshotTesting.h
@@ -25,7 +25,8 @@
#include <memory>
#include <vector>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
struct GlValues {
std::vector<GLint> ints;
@@ -192,8 +193,8 @@
// EXPECT_FALSE(fooBarState()); // Snapshot preserved the state change
// }
//
-class SnapshotTest : public emugl::GLTest {
-public:
+class SnapshotTest : public gfxstream::gl::GLTest {
+ public:
SnapshotTest() = default;
void SetUp() override;
@@ -320,4 +321,5 @@
std::unique_ptr<T> m_changed_value;
};
-} // namespace emugl
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTextures_unittest.cpp b/stream-servers/tests/GLSnapshotTextures_unittest.cpp
index c450b60..e2818bd 100644
--- a/stream-servers/tests/GLSnapshotTextures_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotTextures_unittest.cpp
@@ -18,7 +18,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
struct GlTextureUnitState {
GLuint binding2D;
@@ -478,4 +480,6 @@
doCheckedSnapshot();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotTransformation_unittest.cpp b/stream-servers/tests/GLSnapshotTransformation_unittest.cpp
index 394af70..7d23ab5 100644
--- a/stream-servers/tests/GLSnapshotTransformation_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotTransformation_unittest.cpp
@@ -17,7 +17,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
// Viewport settings to attempt
static const std::vector<GLint> kGLES2TestViewport = {10, 10, 100, 100};
@@ -74,4 +76,6 @@
SnapshotGlDepthRangeTest,
::testing::Values(kGLES2TestDepthRange));
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshotVertexAttributes_unittest.cpp b/stream-servers/tests/GLSnapshotVertexAttributes_unittest.cpp
index f8438dd..3fbcce1 100644
--- a/stream-servers/tests/GLSnapshotVertexAttributes_unittest.cpp
+++ b/stream-servers/tests/GLSnapshotVertexAttributes_unittest.cpp
@@ -20,7 +20,9 @@
#include <algorithm>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
enum class GlVertexAttribMode { SingleValue = 0, Array = 1, Buffer = 2 };
@@ -302,4 +304,6 @@
doCheckedSnapshot();
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLSnapshot_unittest.cpp b/stream-servers/tests/GLSnapshot_unittest.cpp
index fce7999..f963905 100644
--- a/stream-servers/tests/GLSnapshot_unittest.cpp
+++ b/stream-servers/tests/GLSnapshot_unittest.cpp
@@ -17,7 +17,9 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
+namespace {
TEST_F(SnapshotTest, InitDestroy) {}
@@ -78,4 +80,6 @@
SnapshotGlMipmapHintTest,
::testing::ValuesIn(kGLES2GenerateMipmapHints));
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLTestUtils.cpp b/stream-servers/tests/GLTestUtils.cpp
index 8e1fc63..d2b9af9 100644
--- a/stream-servers/tests/GLTestUtils.cpp
+++ b/stream-servers/tests/GLTestUtils.cpp
@@ -16,7 +16,7 @@
using android::AlignedBuf;
-namespace emugl {
+namespace gfxstream {
testing::AssertionResult RowMatches(int rowIndex, size_t rowBytes,
unsigned char* expected, unsigned char* actual) {
@@ -624,4 +624,4 @@
}
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/GLTestUtils.h b/stream-servers/tests/GLTestUtils.h
index 9e9b5cf..1cc0e90 100644
--- a/stream-servers/tests/GLTestUtils.h
+++ b/stream-servers/tests/GLTestUtils.h
@@ -21,7 +21,7 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
using TestTexture = android::AlignedBuf<uint8_t, 4>;
@@ -45,4 +45,4 @@
// Return the name associated with |v| as a string.
const char* getEnumString(GLenum v);
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/HelloTriangle.cpp b/stream-servers/tests/HelloTriangle.cpp
index a65bfb5..0ec71b7 100644
--- a/stream-servers/tests/HelloTriangle.cpp
+++ b/stream-servers/tests/HelloTriangle.cpp
@@ -17,7 +17,7 @@
// Implementation is in HelloTriangleImp.cpp
int main(int argc, char** argv) {
- emugl::HelloTriangle app;
+ gfxstream::HelloTriangle app;
app.drawLoop();
return 0;
}
diff --git a/stream-servers/tests/HelloTriangle.h b/stream-servers/tests/HelloTriangle.h
index fda9432..4d1d067 100644
--- a/stream-servers/tests/HelloTriangle.h
+++ b/stream-servers/tests/HelloTriangle.h
@@ -23,7 +23,7 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
-namespace emugl {
+namespace gfxstream {
class HelloTriangle : public SampleApplication {
protected:
@@ -40,4 +40,4 @@
float mTime = 0.0f;
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/HelloTriangleImp.cpp b/stream-servers/tests/HelloTriangleImp.cpp
index cbe0249..a08d683 100644
--- a/stream-servers/tests/HelloTriangleImp.cpp
+++ b/stream-servers/tests/HelloTriangleImp.cpp
@@ -23,7 +23,7 @@
#include <glm/gtc/matrix_transform.hpp>
#include <glm/gtc/type_ptr.hpp>
-namespace emugl {
+namespace gfxstream {
void HelloTriangle::initialize() {
constexpr char vshaderSrc[] = R"(#version 300 es
@@ -53,7 +53,7 @@
}
)";
- GLint program = emugl::compileAndLinkShaderProgram(vshaderSrc, fshaderSrc);
+ GLint program = compileAndLinkShaderProgram(vshaderSrc, fshaderSrc);
auto gl = getGlDispatch();
@@ -97,4 +97,4 @@
mTime += 0.05f;
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/ImageUtils.cpp b/stream-servers/tests/ImageUtils.cpp
index f9de13f..25269c5 100644
--- a/stream-servers/tests/ImageUtils.cpp
+++ b/stream-servers/tests/ImageUtils.cpp
@@ -19,6 +19,8 @@
#include <cstring>
+namespace gfxstream {
+
bool LoadRGBAFromPng(const std::string& filename, uint32_t* outWidth, uint32_t* outHeight,
std::vector<uint32_t>* outPixels) {
*outWidth = 0;
@@ -56,3 +58,5 @@
}
return true;
}
+
+} // namespace gfxstream
diff --git a/stream-servers/tests/ImageUtils.h b/stream-servers/tests/ImageUtils.h
index 567741b..3ff83fc 100644
--- a/stream-servers/tests/ImageUtils.h
+++ b/stream-servers/tests/ImageUtils.h
@@ -18,8 +18,12 @@
#include <string>
#include <vector>
+namespace gfxstream {
+
bool LoadRGBAFromPng(const std::string& filename, uint32_t* outWidth, uint32_t* outHeight,
std::vector<uint32_t>* outPixels);
bool SaveRGBAToPng(uint32_t width, uint32_t height, const uint32_t* pixels,
const std::string& filename);
+
+} // namespace gfxstream
diff --git a/stream-servers/tests/OpenGLTestContext.cpp b/stream-servers/tests/OpenGLTestContext.cpp
index d0babb9..0c6117a 100644
--- a/stream-servers/tests/OpenGLTestContext.cpp
+++ b/stream-servers/tests/OpenGLTestContext.cpp
@@ -18,7 +18,8 @@
#include "host-common/testing/MockGraphicsAgentFactory.h"
#include "Standalone.h"
-namespace emugl {
+namespace gfxstream {
+namespace gl {
static bool sDisplayNeedsInit = true;
@@ -152,4 +153,5 @@
<< "GLTest TearDown found EGL error";
}
-} // namespace emugl
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/OpenGLTestContext.h b/stream-servers/tests/OpenGLTestContext.h
index 756307a..7b8ca6a 100644
--- a/stream-servers/tests/OpenGLTestContext.h
+++ b/stream-servers/tests/OpenGLTestContext.h
@@ -28,7 +28,8 @@
#include <GLES2/gl2.h>
#include <GLES3/gl31.h>
-namespace emugl {
+namespace gfxstream {
+namespace gl {
// Dimensions for test surface
static const int kTestSurfaceSize[] = {32, 32};
@@ -65,4 +66,6 @@
return; \
} \
} while (0)
-} // namespace emugl
+
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/OpenGL_unittest.cpp b/stream-servers/tests/OpenGL_unittest.cpp
index 0cf2e2b..22d738e 100644
--- a/stream-servers/tests/OpenGL_unittest.cpp
+++ b/stream-servers/tests/OpenGL_unittest.cpp
@@ -16,7 +16,8 @@
#include <gtest/gtest.h>
-namespace emugl {
+namespace gfxstream {
+namespace {
TEST_F(GLTest, InitDestroy) {}
@@ -41,4 +42,5 @@
EXPECT_EQ(EGL_SUCCESS, egl->eglGetError());
}
-} // namespace emugl
+} // namespace
+} // namespace gfxstream
diff --git a/stream-servers/tests/SampleApplication.cpp b/stream-servers/tests/SampleApplication.cpp
index 7ea34f0..c8b9747 100644
--- a/stream-servers/tests/SampleApplication.cpp
+++ b/stream-servers/tests/SampleApplication.cpp
@@ -30,18 +30,18 @@
#include <EGL/eglext.h>
#include <GLES3/gl3.h>
+namespace gfxstream {
+
using android::base::AutoLock;
using android::base::ConditionVariable;
using android::base::FunctorThread;
using android::base::Lock;
using android::base::MessageChannel;
using android::base::TestSystem;
-using gfxstream::EmulatedEglFenceSync;
-using gfxstream::GLESApi;
-using gfxstream::GLESApi_3_0;
-using gfxstream::GLESApi_CM;
-
-namespace emugl {
+using gl::EmulatedEglFenceSync;
+using gl::GLESApi;
+using gl::GLESApi_3_0;
+using gl::GLESApi_CM;
// Class holding the persistent test window.
class TestWindow {
@@ -244,9 +244,9 @@
emugl::setGLObjectCounter(android::base::GLObjectCounter::get());
emugl::set_emugl_window_operations(*getGraphicsAgents()->emu);;
emugl::set_emugl_multi_display_operations(*getGraphicsAgents()->multi_display);
- LazyLoadedEGLDispatch::get();
- if (glVersion == GLESApi_CM) LazyLoadedGLESv1Dispatch::get();
- LazyLoadedGLESv2Dispatch::get();
+ gl::LazyLoadedEGLDispatch::get();
+ if (glVersion == GLESApi_CM) gl::LazyLoadedGLESv1Dispatch::get();
+ gl::LazyLoadedGLESv2Dispatch::get();
bool useHostGpu = shouldUseHostGpu();
mWindow = createOrGetTestWindow(mXOffset, mYOffset, mWidth, mHeight);
@@ -556,8 +556,8 @@
}
}
-const GLESv2Dispatch* SampleApplication::getGlDispatch() {
- return LazyLoadedGLESv2Dispatch::get();
+const gl::GLESv2Dispatch* SampleApplication::getGlDispatch() {
+ return gl::LazyLoadedGLESv2Dispatch::get();
}
bool SampleApplication::isSwANGLE() {
@@ -568,4 +568,4 @@
return strstr(renderer, "ANGLE") && strstr(renderer, "SwiftShader");
}
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/SampleApplication.h b/stream-servers/tests/SampleApplication.h
index 09c49a6..2bdf8b5 100644
--- a/stream-servers/tests/SampleApplication.h
+++ b/stream-servers/tests/SampleApplication.h
@@ -24,11 +24,12 @@
#include "gl/EmulatedEglContext.h"
#include "gl/EmulatedEglFenceSync.h"
-class FrameBuffer;
class OSWindow;
-struct RenderThreadInfo;
-namespace emugl {
+namespace gfxstream {
+
+class FrameBuffer;
+struct RenderThreadInfo;
// Determines whether the host GPU should be used.
bool shouldUseHostGpu();
@@ -46,51 +47,49 @@
// Creates a window (or runs headless) to be used in a sample app.
class SampleApplication {
public:
- SampleApplication(int windowWidth = 256, int windowHeight = 256,
- int refreshRate = 60,
- gfxstream::GLESApi glVersion = gfxstream::GLESApi_3_0,
- bool compose = false);
- virtual ~SampleApplication();
+ SampleApplication(int windowWidth = 256, int windowHeight = 256, int refreshRate = 60,
+ gl::GLESApi glVersion = gl::GLESApi_3_0, bool compose = false);
+ virtual ~SampleApplication();
- // A basic draw loop that works similar to most simple
- // GL apps that run on desktop.
- //
- // Per frame:
- //
- // a single GL context for drawing,
- // a color buffer to blit,
- // and a call to post that color buffer.
- void rebind();
- void drawLoop();
+ // A basic draw loop that works similar to most simple
+ // GL apps that run on desktop.
+ //
+ // Per frame:
+ //
+ // a single GL context for drawing,
+ // a color buffer to blit,
+ // and a call to post that color buffer.
+ void rebind();
+ void drawLoop();
- // A more complex loop that uses 3 separate contexts
- // to simulate what goes on in Android:
- //
- // Per frame
- //
- // a GL 'app' context for drawing,
- // a SurfaceFlinger context for rendering the "Layer",
- // and a HWC context for posting.
- void surfaceFlingerComposerLoop();
+ // A more complex loop that uses 3 separate contexts
+ // to simulate what goes on in Android:
+ //
+ // Per frame
+ //
+ // a GL 'app' context for drawing,
+ // a SurfaceFlinger context for rendering the "Layer",
+ // and a HWC context for posting.
+ void surfaceFlingerComposerLoop();
- // TODO:
- // void HWC2Loop();
+ // TODO:
+ // void HWC2Loop();
- // Just initialize, draw, and swap buffers once.
- void drawOnce();
+ // Just initialize, draw, and swap buffers once.
+ void drawOnce();
- bool isSwANGLE();
+ bool isSwANGLE();
private:
void drawWorkerWithCompose(ColorBufferQueue& app2sfQueue, ColorBufferQueue& sf2appQueue);
void drawWorker(ColorBufferQueue& app2sfQueue, ColorBufferQueue& sf2appQueue,
ColorBufferQueue& sf2hwcQueue, ColorBufferQueue& hwc2sfQueue);
- gfxstream::EmulatedEglFenceSync* getFenceSync();
+ gl::EmulatedEglFenceSync* getFenceSync();
-protected:
+ protected:
virtual void initialize() = 0;
virtual void draw() = 0;
- virtual const GLESv2Dispatch* getGlDispatch();
+ virtual const gl::GLESv2Dispatch* getGlDispatch();
int mWidth = 256;
int mHeight = 256;
@@ -114,4 +113,4 @@
DISALLOW_COPY_ASSIGN_AND_MOVE(SampleApplication);
};
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/ShaderUtils.cpp b/stream-servers/tests/ShaderUtils.cpp
index 4d73dbc..fb038ab 100644
--- a/stream-servers/tests/ShaderUtils.cpp
+++ b/stream-servers/tests/ShaderUtils.cpp
@@ -39,10 +39,10 @@
#define E(fmt,...) fprintf(stderr, "%s: " fmt "\n", __func__, ##__VA_ARGS__);
-namespace emugl {
+namespace gfxstream {
GLuint compileShader(GLenum shaderType, const char* src) {
- auto gl = LazyLoadedGLESv2Dispatch::get();
+ auto gl = gl::LazyLoadedGLESv2Dispatch::get();
GLuint shader = gl->glCreateShader(shaderType);
gl->glShaderSource(shader, 1, (const GLchar* const*)&src, nullptr);
@@ -63,7 +63,7 @@
}
GLint compileAndLinkShaderProgram(const char* vshaderSrc, const char* fshaderSrc) {
- auto gl = LazyLoadedGLESv2Dispatch::get();
+ auto gl = gl::LazyLoadedGLESv2Dispatch::get();
GLuint vshader = compileShader(GL_VERTEX_SHADER, vshaderSrc);
GLuint fshader = compileShader(GL_FRAGMENT_SHADER, fshaderSrc);
@@ -96,23 +96,23 @@
// #else
// std::string programName = "glslangValidator";
// #endif
-//
+//
// auto programDirRelativePath =
// pj(android::base::getProgramDirectory(),
// "lib64", "vulkan", "tools", programName);
-//
+//
// if (path_exists(programDirRelativePath.c_str())) {
// return programDirRelativePath;
// }
-//
+//
// auto launcherDirRelativePath =
// pj(android::base::getLauncherDirectory(),
// "lib64", "vulkan", programName);
-//
+//
// if (path_exists(launcherDirRelativePath.c_str())) {
// return launcherDirRelativePath;
// }
-//
+//
// E("spirv compiler does not exist");
// return {};
// }
@@ -120,62 +120,62 @@
// Optional<std::string> compileSpirvFromGLSL(const std::string& shaderType,
// const std::string& src) {
// auto spvCompilerPath = getSpirvCompilerPath();
-//
+//
// if (!spvCompilerPath) return {};
-//
+//
// const auto glslFile = android::base::makeCustomScopedPtr(
// tempfile_create(), tempfile_unref_and_close_file);
-//
+//
// const auto spvFile = android::base::makeCustomScopedPtr(
// tempfile_create(), tempfile_unref_and_close_file);
-//
+//
// auto glslPath = tempfile_path(glslFile.get());
// auto spvPath = tempfile_path(spvFile.get());
-//
+//
// auto glslFd = android::base::ScopedFd(open(glslPath, O_RDWR));
// if (!glslFd.valid()) { return {}; }
-//
+//
// android::writeStringToFile(glslFd.get(), src);
// glslFd.close();
-//
+//
// std::vector<std::string> args =
// { *spvCompilerPath, glslPath, "-V", "-S", shaderType, "-o", spvPath };
-//
+//
// auto runRes = System::get()->runCommandWithResult(args);
-//
+//
// if (!runRes) {
// E("failed to compile SPIRV from GLSL. args: %s %s -V -S %s -o %s",
// spvCompilerPath->c_str(), glslPath, shaderType.c_str(), spvPath);
// return {};
// }
-//
+//
// D("Result of compiling SPIRV from GLSL. res: %s args: %s %s -V -S %s -o %s",
// runRes->c_str(), spvCompilerPath->c_str(), glslPath, shaderType.c_str(),
// spvPath);
-//
+//
// auto res = android::readFileIntoString(spvPath);
-//
+//
// if (res) {
// D("got %zu bytes:", res->size());
// } else {
// E("failed to read SPIRV file %s into string", spvPath);
// }
-//
+//
// return res;
// }
-//
+//
// Optional<std::vector<char> > readSpirv(const char* path) {
// std::ifstream in(path, std::ios::ate | std::ios::binary);
-//
+//
// if (!in) return {};
-//
+//
// size_t fileSize = (size_t)in.tellg();
// std::vector<char> buffer(fileSize);
-//
+//
// in.seekg(0);
// in.read(buffer.data(), fileSize);
-//
+//
// return buffer;
// }
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/ShaderUtils.h b/stream-servers/tests/ShaderUtils.h
index ea81a19..0851e0d 100644
--- a/stream-servers/tests/ShaderUtils.h
+++ b/stream-servers/tests/ShaderUtils.h
@@ -20,7 +20,7 @@
#include <string>
#include <vector>
-namespace emugl {
+namespace gfxstream {
GLuint compileShader(GLenum shaderType, const char* src);
GLint compileAndLinkShaderProgram(const char* vshaderSrc, const char* fshaderSrc);
@@ -31,4 +31,4 @@
android::base::Optional<std::vector<char>> readSpirv(const char* path);
-} // namespace emugl
+} // namespace gfxstream
diff --git a/stream-servers/tests/StalePtrRegistry_unittest.cpp b/stream-servers/tests/StalePtrRegistry_unittest.cpp
index 8ec9dfb..9ab9d96 100644
--- a/stream-servers/tests/StalePtrRegistry_unittest.cpp
+++ b/stream-servers/tests/StalePtrRegistry_unittest.cpp
@@ -16,6 +16,9 @@
#include <gtest/gtest.h>
+namespace gfxstream {
+namespace {
+
TEST(StalePtrRegistry, Constructor) {
StalePtrRegistry<void> reg;
}
@@ -199,3 +202,6 @@
EXPECT_EQ(reg.getPtr(handle1), ptr1);
EXPECT_EQ(reg.getPtr(handle2), ptr2);
}
+
+} // namespace
+} // namespace gfxstream
diff --git a/stream-servers/tests/SwapChainStateVk_unittest.cpp b/stream-servers/tests/SwapChainStateVk_unittest.cpp
index 826c0cc..46372e4 100644
--- a/stream-servers/tests/SwapChainStateVk_unittest.cpp
+++ b/stream-servers/tests/SwapChainStateVk_unittest.cpp
@@ -5,13 +5,17 @@
#include "Standalone.h"
#include "vulkan/VulkanDispatch.h"
+namespace gfxstream {
+namespace vk {
+namespace {
+
class SwapChainStateVkTest : public ::testing::Test {
protected:
- static void SetUpTestCase() { k_vk = emugl::vkDispatch(false); }
+ static void SetUpTestCase() { k_vk = vkDispatch(false); }
void SetUp() override {
// skip the test when testing without a window
- if (!emugl::shouldUseWindow()) {
+ if (!shouldUseWindow()) {
GTEST_SKIP();
}
ASSERT_NE(k_vk, nullptr);
@@ -23,14 +27,14 @@
}
void TearDown() override {
- if (emugl::shouldUseWindow()) {
+ if (shouldUseWindow()) {
k_vk->vkDestroyDevice(m_vkDevice, nullptr);
k_vk->vkDestroySurfaceKHR(m_vkInstance, m_vkSurface, nullptr);
k_vk->vkDestroyInstance(m_vkInstance, nullptr);
}
}
- static goldfish_vk::VulkanDispatch *k_vk;
+ static VulkanDispatch* k_vk;
static const uint32_t k_width = 0x100;
static const uint32_t k_height = 0x100;
@@ -63,7 +67,7 @@
}
void createWindowAndSurface() {
- m_window = emugl::createOrGetTestWindow(0, 0, k_width, k_height);
+ m_window = createOrGetTestWindow(0, 0, k_width, k_height);
ASSERT_NE(m_window, nullptr);
#ifdef _WIN32
VkWin32SurfaceCreateInfoKHR surfaceCi = {
@@ -162,7 +166,7 @@
}
};
-goldfish_vk::VulkanDispatch *SwapChainStateVkTest::k_vk = nullptr;
+VulkanDispatch* SwapChainStateVkTest::k_vk = nullptr;
TEST_F(SwapChainStateVkTest, init) {
auto swapChainCi = SwapChainStateVk::createSwapChainCi(
@@ -171,4 +175,8 @@
ASSERT_NE(swapChainCi, std::nullopt);
std::unique_ptr<SwapChainStateVk> swapChainState =
SwapChainStateVk::createSwapChainVk(*k_vk, m_vkDevice, swapChainCi->mCreateInfo);
-}
\ No newline at end of file
+}
+
+} // namespace
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/tests/TextureDraw_unittest.cpp b/stream-servers/tests/TextureDraw_unittest.cpp
index 01e1d94..32fdd46 100644
--- a/stream-servers/tests/TextureDraw_unittest.cpp
+++ b/stream-servers/tests/TextureDraw_unittest.cpp
@@ -18,8 +18,8 @@
#include "OpenGLTestContext.h"
#include "TextureDraw.h"
-namespace emugl {
-
+namespace gfxstream {
+namespace gl {
namespace {
void TestTextureDrawBasic(const GLESv2Dispatch* gl, GLenum internalformat,
@@ -205,8 +205,6 @@
}
-} // namespace
-
#define GL_BGRA_EXT 0x80E1
TEST_F(GLTest, TextureDrawBasic) {
@@ -218,4 +216,6 @@
TestTextureDrawLayer(gl);
}
-} // namespace emugl
+} // namespace
+} // namespace gl
+} // namespace gfxstream
diff --git a/stream-servers/tests/VirtioGpuTimelines_unittest.cpp b/stream-servers/tests/VirtioGpuTimelines_unittest.cpp
index f0abc28..5e7dbc0 100644
--- a/stream-servers/tests/VirtioGpuTimelines_unittest.cpp
+++ b/stream-servers/tests/VirtioGpuTimelines_unittest.cpp
@@ -18,6 +18,9 @@
#include <memory>
+namespace gfxstream {
+namespace {
+
using RingGlobal = VirtioGpuRingGlobal;
using RingContextSpecific = VirtioGpuRingContextSpecific;
@@ -239,3 +242,6 @@
check.Call(3);
virtioGpuTimelines->notifyTaskCompletion(taskId3);
}
+
+} // namespace
+} // namespace gfxstream
diff --git a/stream-servers/tests/VkTestUtils.h b/stream-servers/tests/VkTestUtils.h
index 484c8a9..4c0b131 100644
--- a/stream-servers/tests/VkTestUtils.h
+++ b/stream-servers/tests/VkTestUtils.h
@@ -5,7 +5,8 @@
#include "vulkan/VulkanDispatch.h"
#include "vulkan/vk_util.h"
-namespace emugl {
+namespace gfxstream {
+namespace vk {
inline std::string libDir() {
using android::base::pj;
@@ -37,7 +38,7 @@
vk_util::FindMemoryType, //
vk_util::RecordImageLayoutTransformCommands, //
vk_util::RunSingleTimeCommand> {
- const goldfish_vk::VulkanDispatch &m_vk;
+ const VulkanDispatch& m_vk;
VkDevice m_vkDevice;
VkPhysicalDevice m_vkPhysicalDevice;
VkQueue m_vkQueue;
@@ -57,7 +58,7 @@
VkCommandBuffer m_readCommandBuffer;
VkCommandBuffer m_writeCommandBuffer;
- explicit RenderResourceVkBase(const goldfish_vk::VulkanDispatch &vk)
+ explicit RenderResourceVkBase(const VulkanDispatch& vk)
: m_vk(vk),
m_vkImageCreateInfo({}),
m_vkImage(VK_NULL_HANDLE),
@@ -77,10 +78,9 @@
static constexpr uint32_t k_bpp = 4;
static constexpr VkImageLayout k_vkImageLayout = imageLayout;
- static std::unique_ptr<const RenderResourceVk<imageLayout, imageUsage>>
- create(const goldfish_vk::VulkanDispatch &vk, VkDevice device,
- VkPhysicalDevice physicalDevice, VkQueue queue,
- VkCommandPool commandPool, uint32_t width, uint32_t height) {
+ static std::unique_ptr<const RenderResourceVk<imageLayout, imageUsage>> create(
+ const VulkanDispatch& vk, VkDevice device, VkPhysicalDevice physicalDevice, VkQueue queue,
+ VkCommandPool commandPool, uint32_t width, uint32_t height) {
std::unique_ptr<RenderResourceVk<imageLayout, imageUsage>> res(
new RenderResourceVk<imageLayout, imageUsage>(vk));
res->m_vkDevice = device;
@@ -145,8 +145,7 @@
}
private:
- RenderResourceVk(const goldfish_vk::VulkanDispatch &vk)
- : RenderResourceVkBase(vk) {}
+ RenderResourceVk(const VulkanDispatch& vk) : RenderResourceVkBase(vk) {}
bool setUpImage() {
VkImageCreateInfo imageCi{
@@ -339,12 +338,12 @@
}
return true;
}
-}; // namespace emugl
+};
using RenderTextureVk =
- emugl::RenderResourceVk<VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL,
- VK_IMAGE_USAGE_SAMPLED_BIT>;
+ RenderResourceVk<VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT>;
-} // namespace emugl
+} // namespace vk
+} // namespace gfxstream
#endif
\ No newline at end of file
diff --git a/stream-servers/tests/VsyncThread_unittest.cpp b/stream-servers/tests/VsyncThread_unittest.cpp
index f5d1cb5..0635a5c 100644
--- a/stream-servers/tests/VsyncThread_unittest.cpp
+++ b/stream-servers/tests/VsyncThread_unittest.cpp
@@ -19,6 +19,9 @@
#include <unistd.h>
#endif
+namespace gfxstream {
+namespace {
+
// Tests scheduling some basic task, and that they are processed
// before the thread completely exits.
TEST(VsyncThread, Basic) {
@@ -66,3 +69,6 @@
EXPECT_EQ(2, count);
}
}
+
+} // namespace
+} // namespace gfxstream
diff --git a/stream-servers/tests/Vulkan_unittest.cpp b/stream-servers/tests/Vulkan_unittest.cpp
index 93cc56c..b40255a 100644
--- a/stream-servers/tests/Vulkan_unittest.cpp
+++ b/stream-servers/tests/Vulkan_unittest.cpp
@@ -47,7 +47,9 @@
using android::base::pj;
using android::base::TestSystem;
-namespace emugl {
+namespace gfxstream {
+namespace vk {
+namespace {
static constexpr const HandleType kArbitraryColorBufferHandle = 5;
@@ -95,11 +97,9 @@
return ss.str();
}
-static std::string getPhysicalDevicePropertiesString(
- const goldfish_vk::VulkanDispatch* vk,
- VkPhysicalDevice physicalDevice,
- const VkPhysicalDeviceProperties& props) {
-
+static std::string getPhysicalDevicePropertiesString(const VulkanDispatch* vk,
+ VkPhysicalDevice physicalDevice,
+ const VkPhysicalDeviceProperties& props) {
std::stringstream ss;
uint16_t apiMaj = (uint16_t)(props.apiVersion >> 22);
@@ -397,7 +397,7 @@
static void TearDownTestSuite() { }
void SetUp() override {
- auto dispatch = emugl::vkDispatch(false);
+ auto dispatch = vkDispatch(false);
ASSERT_NE(dispatch, nullptr);
mVk = *dispatch;
@@ -425,8 +425,7 @@
mVk.vkGetPhysicalDeviceMemoryProperties(mPhysicalDevice, &memProps);
- EXPECT_TRUE(goldfish_vk::getStagingMemoryTypeIndex(
- &mVk, mDevice, &memProps, &typeIndex));
+ EXPECT_TRUE(getStagingMemoryTypeIndex(&mVk, mDevice, &memProps, &typeIndex));
}
#ifndef _WIN32 // TODO: Get this working w/ Swiftshader vk on Windows
@@ -447,9 +446,8 @@
emugl::setGLObjectCounter(android::base::GLObjectCounter::get());
emugl::set_emugl_window_operations(*getGraphicsAgents()->emu);
emugl::set_emugl_multi_display_operations(*getGraphicsAgents()->multi_display);
- const EGLDispatch* egl = LazyLoadedEGLDispatch::get();
- ASSERT_NE(nullptr, egl);
- ASSERT_NE(nullptr, LazyLoadedGLESv2Dispatch::get());
+ ASSERT_NE(nullptr, gl::LazyLoadedEGLDispatch::get());
+ ASSERT_NE(nullptr, gl::LazyLoadedGLESv2Dispatch::get());
bool useHostGpu = false;
EXPECT_TRUE(FrameBuffer::initialize(mWidth, mHeight, false,
@@ -474,16 +472,15 @@
TEST_F(VulkanFrameBufferTest, VkColorBufferWithoutMemoryProperties) {
// Create a color buffer without any memory properties restriction.
- EXPECT_TRUE(goldfish_vk::setupVkColorBuffer(mWidth, mHeight, GL_RGBA,
- FRAMEWORK_FORMAT_GL_COMPATIBLE,
- kArbitraryColorBufferHandle, true, /* vulkanOnly */
- 0 /* memoryProperty */
- ));
- EXPECT_TRUE(goldfish_vk::teardownVkColorBuffer(kArbitraryColorBufferHandle));
+ EXPECT_TRUE(setupVkColorBuffer(mWidth, mHeight, GL_RGBA, FRAMEWORK_FORMAT_GL_COMPATIBLE,
+ kArbitraryColorBufferHandle, true, /* vulkanOnly */
+ 0 /* memoryProperty */
+ ));
+ EXPECT_TRUE(teardownVkColorBuffer(kArbitraryColorBufferHandle));
}
TEST_F(VulkanFrameBufferTest, VkColorBufferWithMemoryPropertyFlags) {
- auto* vkEmulation = goldfish_vk::getGlobalVkEmulation();
+ auto* vkEmulation = getGlobalVkEmulation();
VkMemoryPropertyFlags kTargetMemoryPropertyFlags =
VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT;
@@ -540,22 +537,23 @@
}
// Create a color buffer with the target memory property flags.
- EXPECT_TRUE(goldfish_vk::setupVkColorBuffer(mWidth, mHeight, GL_RGBA,
- FRAMEWORK_FORMAT_GL_COMPATIBLE,
- kArbitraryColorBufferHandle, true, /* vulkanOnly */
- static_cast<uint32_t>(kTargetMemoryPropertyFlags)));
+ EXPECT_TRUE(setupVkColorBuffer(mWidth, mHeight, GL_RGBA, FRAMEWORK_FORMAT_GL_COMPATIBLE,
+ kArbitraryColorBufferHandle, true, /* vulkanOnly */
+ static_cast<uint32_t>(kTargetMemoryPropertyFlags)));
uint32_t allocatedTypeIndex = 0u;
- EXPECT_TRUE(goldfish_vk::getColorBufferAllocationInfo(kArbitraryColorBufferHandle, nullptr,
- &allocatedTypeIndex, nullptr, nullptr));
+ EXPECT_TRUE(getColorBufferAllocationInfo(kArbitraryColorBufferHandle, nullptr,
+ &allocatedTypeIndex, nullptr, nullptr));
EXPECT_TRUE(vkEmulation->deviceInfo.memProps.memoryTypes[allocatedTypeIndex]
.propertyFlags &
kTargetMemoryPropertyFlags);
- EXPECT_TRUE(goldfish_vk::teardownVkColorBuffer(kArbitraryColorBufferHandle));
+ EXPECT_TRUE(teardownVkColorBuffer(kArbitraryColorBufferHandle));
}
#endif // !_WIN32
-} // namespace emugl
+} // namespace
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/tests/X11TestingSupport.cpp b/stream-servers/tests/X11TestingSupport.cpp
index 59cf8e7..22905f8 100644
--- a/stream-servers/tests/X11TestingSupport.cpp
+++ b/stream-servers/tests/X11TestingSupport.cpp
@@ -11,9 +11,13 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
-#include "../apigen-codec-common/X11Support.h"
+
#include <stdio.h>
+#include "../apigen-codec-common/X11Support.h"
+
+namespace gfxstream {
+
struct X11State {
X11State() :
threadsInitResult(XInitThreads()),
@@ -47,3 +51,5 @@
}
void freeNativePixmap(void* pixmap) { XFreePixmap(x11()->display, (Pixmap)pixmap); }
+
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/tests/X11TestingSupport.h b/stream-servers/tests/X11TestingSupport.h
index e146b0f..fdf1456 100644
--- a/stream-servers/tests/X11TestingSupport.h
+++ b/stream-servers/tests/X11TestingSupport.h
@@ -13,5 +13,9 @@
// limitations under the License.
#pragma once
+namespace gfxstream {
+
void* createNativePixmap(int width, int height, int bytesPerPixel);
void freeNativePixmap(void* pixmap);
+
+} // namespace gfxstream
diff --git a/stream-servers/virtgpu_gfxstream_protocol.h b/stream-servers/virtgpu_gfxstream_protocol.h
index 325fa9c..8d4a312 100644
--- a/stream-servers/virtgpu_gfxstream_protocol.h
+++ b/stream-servers/virtgpu_gfxstream_protocol.h
@@ -17,6 +17,8 @@
#include <stdint.h>
+namespace gfxstream {
+
// Address Space Graphics contexts
#define GFXSTREAM_CONTEXT_CREATE 0x1001
#define GFXSTREAM_CONTEXT_PING 0x1002
@@ -75,4 +77,6 @@
uint32_t pad;
};
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/virtio-gpu-gfxstream-renderer.cpp b/stream-servers/virtio-gpu-gfxstream-renderer.cpp
index fe649b9..66951d5 100644
--- a/stream-servers/virtio-gpu-gfxstream-renderer.cpp
+++ b/stream-servers/virtio-gpu-gfxstream-renderer.cpp
@@ -693,15 +693,15 @@
}
#define DECODE(variable, type, input) \
- struct type variable = {}; \
+ type variable = {}; \
memcpy(&variable, input, sizeof(type));
void addressSpaceProcessCmd(VirtioGpuCtxId ctxId, uint32_t* dwords, int dwordCount) {
- DECODE(header, gfxstreamHeader, dwords)
+ DECODE(header, gfxstream::gfxstreamHeader, dwords)
switch (header.opCode) {
case GFXSTREAM_CONTEXT_CREATE: {
- DECODE(contextCreate, gfxstreamContextCreate, dwords)
+ DECODE(contextCreate, gfxstream::gfxstreamContextCreate, dwords)
auto resEntryIt = mResources.find(contextCreate.resourceId);
if (resEntryIt == mResources.end()) {
@@ -739,7 +739,7 @@
break;
}
case GFXSTREAM_CONTEXT_PING: {
- DECODE(contextPing, gfxstreamContextPing, dwords)
+ DECODE(contextPing, gfxstream::gfxstreamContextPing, dwords)
AutoLock lock(mLock);
@@ -772,7 +772,7 @@
return -1;
}
- DECODE(header, gfxstreamHeader, buffer);
+ DECODE(header, gfxstream::gfxstreamHeader, buffer);
switch (header.opCode) {
case GFXSTREAM_CONTEXT_CREATE:
case GFXSTREAM_CONTEXT_PING:
@@ -780,7 +780,7 @@
addressSpaceProcessCmd(ctxId, (uint32_t*)buffer, dwordCount);
break;
case GFXSTREAM_CREATE_EXPORT_SYNC: {
- DECODE(exportSync, gfxstreamCreateExportSync, buffer)
+ DECODE(exportSync, gfxstream::gfxstreamCreateExportSync, buffer)
uint64_t sync_handle =
convert32to64(exportSync.syncHandleLo, exportSync.syncHandleHi);
@@ -794,7 +794,7 @@
}
case GFXSTREAM_CREATE_EXPORT_SYNC_VK:
case GFXSTREAM_CREATE_IMPORT_SYNC_VK: {
- DECODE(exportSyncVK, gfxstreamCreateExportSyncVK, buffer)
+ DECODE(exportSyncVK, gfxstream::gfxstreamCreateExportSyncVK, buffer)
uint64_t device_handle =
convert32to64(exportSyncVK.deviceHandleLo, exportSyncVK.deviceHandleHi);
@@ -819,7 +819,7 @@
.mRingIdx = 0,
};
- DECODE(exportQSRI, gfxstreamCreateQSRIExportVK, buffer)
+ DECODE(exportQSRI, gfxstream::gfxstreamCreateQSRIExportVK, buffer)
uint64_t image_handle =
convert32to64(exportQSRI.imageHandleLo, exportQSRI.imageHandleHi);
@@ -1312,11 +1312,12 @@
void getCapset(uint32_t set, uint32_t *max_size) {
// Only one capset right not
- *max_size = sizeof(struct gfxstreamCapset);
+ *max_size = sizeof(struct gfxstream::gfxstreamCapset);
}
void fillCaps(uint32_t set, void* caps) {
- struct gfxstreamCapset *capset = reinterpret_cast<struct gfxstreamCapset*>(caps);
+ struct gfxstream::gfxstreamCapset *capset =
+ reinterpret_cast<struct gfxstream::gfxstreamCapset*>(caps);
if (capset) {
memset(capset, 0, sizeof(*capset));
@@ -2199,27 +2200,28 @@
}
// Set non product-specific callbacks
- vk_util::setVkCheckCallbacks(
- std::make_unique<vk_util::VkCheckCallbacks>(vk_util::VkCheckCallbacks{
- .onVkErrorOutOfMemory =
- [](VkResult result, const char* function, int line) {
- auto fb = FrameBuffer::getFB();
- if (!fb) {
- ERR("FrameBuffer not yet initialized. Dropping out of memory event");
- return;
- }
- fb->logVulkanOutOfMemory(result, function, line);
- },
- .onVkErrorOutOfMemoryOnAllocation =
- [](VkResult result, const char* function, int line,
- std::optional<uint64_t> allocationSize) {
- auto fb = FrameBuffer::getFB();
- if (!fb) {
- ERR("FrameBuffer not yet initialized. Dropping out of memory event");
- return;
- }
- fb->logVulkanOutOfMemory(result, function, line, allocationSize);
- }}));
+ gfxstream::vk::vk_util::setVkCheckCallbacks(
+ std::make_unique<gfxstream::vk::vk_util::VkCheckCallbacks>(
+ gfxstream::vk::vk_util::VkCheckCallbacks{
+ .onVkErrorOutOfMemory =
+ [](VkResult result, const char* function, int line) {
+ auto fb = gfxstream::FrameBuffer::getFB();
+ if (!fb) {
+ ERR("FrameBuffer not yet initialized. Dropping out of memory event");
+ return;
+ }
+ fb->logVulkanOutOfMemory(result, function, line);
+ },
+ .onVkErrorOutOfMemoryOnAllocation =
+ [](VkResult result, const char* function, int line,
+ std::optional<uint64_t> allocationSize) {
+ auto fb = gfxstream::FrameBuffer::getFB();
+ if (!fb) {
+ ERR("FrameBuffer not yet initialized. Dropping out of memory event");
+ return;
+ }
+ fb->logVulkanOutOfMemory(result, function, line, allocationSize);
+ }}));
gfxstream_backend_init_product_override();
// First we make some agents available.
@@ -2326,7 +2328,7 @@
<< "can't enable vulkan native swapchain, Vulkan is disabled";
}
- emugl::vkDispatch(false /* don't use test ICD */);
+ gfxstream::vk::vkDispatch(false /* don't use test ICD */);
auto androidHw = aemu_get_android_hw();
@@ -2352,7 +2354,7 @@
android_prepareOpenglesEmulation();
{
- static emugl::RenderLibPtr renderLibPtr = initLibrary();
+ static gfxstream::RenderLibPtr renderLibPtr = gfxstream::initLibrary();
void* egldispatch = renderLibPtr->getEGLDispatch();
void* glesv2Dispatch = renderLibPtr->getGLESv2Dispatch();
android_setOpenglesEmulation(renderLibPtr.get(), egldispatch, glesv2Dispatch);
@@ -2478,7 +2480,7 @@
VG_EXPORT void gfxstream_backend_getrender(char* buf, size_t bufSize, size_t* size) {
const char* render = "";
- FrameBuffer* pFB = FrameBuffer::getFB();
+ auto* pFB = gfxstream::FrameBuffer::getFB();
if (pFB) {
const char* vendor = nullptr;
const char* version = nullptr;
diff --git a/stream-servers/vulkan/BorrowedImageVk.cpp b/stream-servers/vulkan/BorrowedImageVk.cpp
index 13c169c..9d11a7c 100644
--- a/stream-servers/vulkan/BorrowedImageVk.cpp
+++ b/stream-servers/vulkan/BorrowedImageVk.cpp
@@ -14,6 +14,9 @@
#include "BorrowedImageVk.h"
+namespace gfxstream {
+namespace vk {
+
void addNeededBarriersToUseBorrowedImage(
const BorrowedImageInfoVk& borrowedImageInfo, uint32_t usedQueueFamilyIndex,
VkImageLayout usedInitialImageLayout, VkImageLayout usedFinalImageLayout,
@@ -111,3 +114,6 @@
postUseQueueTransferBarriers->emplace_back(queueTransferBarrier);
}
}
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/BorrowedImageVk.h b/stream-servers/vulkan/BorrowedImageVk.h
index 26ebd98..4df04ea 100644
--- a/stream-servers/vulkan/BorrowedImageVk.h
+++ b/stream-servers/vulkan/BorrowedImageVk.h
@@ -20,6 +20,9 @@
#include "BorrowedImage.h"
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
+namespace gfxstream {
+namespace vk {
+
struct BorrowedImageInfoVk : public BorrowedImageInfo {
VkImage image = VK_NULL_HANDLE;
VkImageView imageView = VK_NULL_HANDLE;
@@ -58,3 +61,6 @@
std::vector<VkImageMemoryBarrier>* preUseLayoutTransitionBarriers,
std::vector<VkImageMemoryBarrier>* postUseLayoutTransitionBarriers,
std::vector<VkImageMemoryBarrier>* postUseQueueTransferBarriers);
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/BufferVk.cpp b/stream-servers/vulkan/BufferVk.cpp
index 9de53c2..46f4540 100644
--- a/stream-servers/vulkan/BufferVk.cpp
+++ b/stream-servers/vulkan/BufferVk.cpp
@@ -17,11 +17,11 @@
#include "VkCommonOperations.h"
namespace gfxstream {
+namespace vk {
/*static*/
std::unique_ptr<BufferVk> BufferVk::create(uint32_t handle, uint64_t size, bool vulkanOnly) {
- if (!goldfish_vk::setupVkBuffer(size, handle, vulkanOnly,
- VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
+ if (!setupVkBuffer(size, handle, vulkanOnly, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT)) {
ERR("Failed to create BufferVk:%d", handle);
return nullptr;
}
@@ -32,17 +32,18 @@
BufferVk::BufferVk(uint32_t handle) : mHandle(handle) {}
BufferVk::~BufferVk() {
- if (!goldfish_vk::teardownVkBuffer(mHandle)) {
+ if (!teardownVkBuffer(mHandle)) {
ERR("Failed to destroy BufferVk:%d", mHandle);
}
}
void BufferVk::readToBytes(uint64_t offset, uint64_t size, void* outBytes) {
- goldfish_vk::readBufferToBytes(mHandle, offset, size, outBytes);
+ readBufferToBytes(mHandle, offset, size, outBytes);
}
bool BufferVk::updateFromBytes(uint64_t offset, uint64_t size, const void* bytes) {
- return goldfish_vk::updateBufferFromBytes(mHandle, offset, size, bytes);
+ return updateBufferFromBytes(mHandle, offset, size, bytes);
}
+} // namespace vk
} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/vulkan/BufferVk.h b/stream-servers/vulkan/BufferVk.h
index ac7b4b9..9016fd7 100644
--- a/stream-servers/vulkan/BufferVk.h
+++ b/stream-servers/vulkan/BufferVk.h
@@ -16,6 +16,7 @@
#include <vector>
namespace gfxstream {
+namespace vk {
class BufferVk {
public:
@@ -33,4 +34,5 @@
const uint32_t mHandle;
};
+} // namespace vk
} // namespace gfxstream
diff --git a/stream-servers/vulkan/ColorBufferVk.cpp b/stream-servers/vulkan/ColorBufferVk.cpp
index f4e13a6..72860c4 100644
--- a/stream-servers/vulkan/ColorBufferVk.cpp
+++ b/stream-servers/vulkan/ColorBufferVk.cpp
@@ -17,14 +17,15 @@
#include "VkCommonOperations.h"
namespace gfxstream {
+namespace vk {
/*static*/
std::unique_ptr<ColorBufferVk> ColorBufferVk::create(uint32_t handle, uint32_t width,
uint32_t height, GLenum format,
FrameworkFormat frameworkFormat,
bool vulkanOnly, uint32_t memoryProperty) {
- if (!goldfish_vk::setupVkColorBuffer(width, height, format, frameworkFormat, handle, vulkanOnly,
- memoryProperty)) {
+ if (!setupVkColorBuffer(width, height, format, frameworkFormat, handle, vulkanOnly,
+ memoryProperty)) {
GL_LOG("Failed to create ColorBufferVk:%d", handle);
return nullptr;
}
@@ -35,26 +36,27 @@
ColorBufferVk::ColorBufferVk(uint32_t handle) : mHandle(handle) {}
ColorBufferVk::~ColorBufferVk() {
- if (!goldfish_vk::teardownVkColorBuffer(mHandle)) {
+ if (!teardownVkColorBuffer(mHandle)) {
ERR("Failed to destroy ColorBufferVk:%d", mHandle);
}
}
bool ColorBufferVk::readToBytes(std::vector<uint8_t>* outBytes) {
- return goldfish_vk::readColorBufferToBytes(mHandle, outBytes);
+ return readColorBufferToBytes(mHandle, outBytes);
}
bool ColorBufferVk::readToBytes(uint32_t x, uint32_t y, uint32_t w, uint32_t h, void* outBytes) {
- return goldfish_vk::readColorBufferToBytes(mHandle, x, y, w, h, outBytes);
+ return readColorBufferToBytes(mHandle, x, y, w, h, outBytes);
}
bool ColorBufferVk::updateFromBytes(const std::vector<uint8_t>& bytes) {
- return goldfish_vk::updateColorBufferFromBytes(mHandle, bytes);
+ return updateColorBufferFromBytes(mHandle, bytes);
}
bool ColorBufferVk::updateFromBytes(uint32_t x, uint32_t y, uint32_t w, uint32_t h,
const void* bytes) {
- return goldfish_vk::updateColorBufferFromBytes(mHandle, x, y, w, h, bytes);
+ return updateColorBufferFromBytes(mHandle, x, y, w, h, bytes);
}
-} // namespace gfxstream
\ No newline at end of file
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/ColorBufferVk.h b/stream-servers/vulkan/ColorBufferVk.h
index a5016c0..c049bf3 100644
--- a/stream-servers/vulkan/ColorBufferVk.h
+++ b/stream-servers/vulkan/ColorBufferVk.h
@@ -20,6 +20,7 @@
#include "FrameworkFormats.h"
namespace gfxstream {
+namespace vk {
class ColorBufferVk {
public:
@@ -41,4 +42,5 @@
const uint32_t mHandle;
};
-} // namespace gfxstream
\ No newline at end of file
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/CompositorVk.cpp b/stream-servers/vulkan/CompositorVk.cpp
index 01fe90d..08cf00d 100644
--- a/stream-servers/vulkan/CompositorVk.cpp
+++ b/stream-servers/vulkan/CompositorVk.cpp
@@ -10,6 +10,9 @@
#include "vulkan/vk_enum_string_helper.h"
#include "vulkan/vk_util.h"
+namespace gfxstream {
+namespace vk {
+
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
@@ -79,7 +82,7 @@
static const std::vector<uint16_t> k_indices = {0, 1, 2, 2, 3, 0};
-static VkShaderModule createShaderModule(const goldfish_vk::VulkanDispatch& vk, VkDevice device,
+static VkShaderModule createShaderModule(const VulkanDispatch& vk, VkDevice device,
const std::vector<uint32_t>& code) {
const VkShaderModuleCreateInfo shaderModuleCi = {
.sType = VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO,
@@ -93,7 +96,7 @@
} // namespace
-CompositorVk::RenderTarget::RenderTarget(const goldfish_vk::VulkanDispatch& vk, VkDevice vkDevice,
+CompositorVk::RenderTarget::RenderTarget(const VulkanDispatch& vk, VkDevice vkDevice,
VkImage vkImage, VkImageView vkImageView, uint32_t width,
uint32_t height, VkRenderPass vkRenderPass)
: m_vk(vk),
@@ -126,10 +129,12 @@
}
}
-std::unique_ptr<CompositorVk> CompositorVk::create(
- const goldfish_vk::VulkanDispatch& vk, VkDevice vkDevice, VkPhysicalDevice vkPhysicalDevice,
- VkQueue vkQueue, std::shared_ptr<android::base::Lock> queueLock, uint32_t queueFamilyIndex,
- uint32_t maxFramesInFlight) {
+std::unique_ptr<CompositorVk> CompositorVk::create(const VulkanDispatch& vk, VkDevice vkDevice,
+ VkPhysicalDevice vkPhysicalDevice,
+ VkQueue vkQueue,
+ std::shared_ptr<android::base::Lock> queueLock,
+ uint32_t queueFamilyIndex,
+ uint32_t maxFramesInFlight) {
auto res = std::unique_ptr<CompositorVk>(new CompositorVk(
vk, vkDevice, vkPhysicalDevice, vkQueue, queueLock, queueFamilyIndex, maxFramesInFlight));
res->setUpCommandPool();
@@ -143,7 +148,7 @@
return res;
}
-CompositorVk::CompositorVk(const goldfish_vk::VulkanDispatch& vk, VkDevice vkDevice,
+CompositorVk::CompositorVk(const VulkanDispatch& vk, VkDevice vkDevice,
VkPhysicalDevice vkPhysicalDevice, VkQueue vkQueue,
std::shared_ptr<android::base::Lock> queueLock,
uint32_t queueFamilyIndex, uint32_t maxFramesInFlight)
@@ -1110,3 +1115,6 @@
frameResources->m_vkDescriptorSetsContents = descriptorSetsContents;
}
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/CompositorVk.h b/stream-servers/vulkan/CompositorVk.h
index 6265e3c..b8aa131 100644
--- a/stream-servers/vulkan/CompositorVk.h
+++ b/stream-servers/vulkan/CompositorVk.h
@@ -21,6 +21,9 @@
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
#include "vulkan/vk_util.h"
+namespace gfxstream {
+namespace vk {
+
// We do see a composition requests with 12 layers. (b/222700096)
// Inside hwc2, we will ask for surfaceflinger to
// do the composition, if the layers more than 16.
@@ -33,7 +36,7 @@
struct CompositorVkBase : public vk_util::MultiCrtp<CompositorVkBase, //
vk_util::FindMemoryType, //
vk_util::RunSingleTimeCommand> {
- const goldfish_vk::VulkanDispatch& m_vk;
+ const VulkanDispatch& m_vk;
const VkDevice m_vkDevice;
const VkPhysicalDevice m_vkPhysicalDevice;
const VkQueue m_vkQueue;
@@ -98,7 +101,7 @@
std::vector<PerFrameResources> m_frameResources;
std::deque<std::shared_future<PerFrameResources*>> m_availableFrameResources;
- explicit CompositorVkBase(const goldfish_vk::VulkanDispatch& vk, VkDevice device,
+ explicit CompositorVkBase(const VulkanDispatch& vk, VkDevice device,
VkPhysicalDevice physicalDevice, VkQueue queue,
std::shared_ptr<android::base::Lock> queueLock,
uint32_t queueFamilyIndex, uint32_t maxFramesInFlight)
@@ -124,8 +127,7 @@
class CompositorVk : protected CompositorVkBase, public Compositor {
public:
- static std::unique_ptr<CompositorVk> create(const goldfish_vk::VulkanDispatch& vk,
- VkDevice vkDevice,
+ static std::unique_ptr<CompositorVk> create(const VulkanDispatch& vk, VkDevice vkDevice,
VkPhysicalDevice vkPhysicalDevice, VkQueue vkQueue,
std::shared_ptr<android::base::Lock> queueLock,
uint32_t queueFamilyIndex,
@@ -142,7 +144,7 @@
}
private:
- explicit CompositorVk(const goldfish_vk::VulkanDispatch&, VkDevice, VkPhysicalDevice, VkQueue,
+ explicit CompositorVk(const VulkanDispatch&, VkDevice, VkPhysicalDevice, VkQueue,
std::shared_ptr<android::base::Lock> queueLock, uint32_t queueFamilyIndex,
uint32_t maxFramesInFlight);
@@ -203,11 +205,11 @@
private:
friend class CompositorVk;
- RenderTarget(const goldfish_vk::VulkanDispatch& vk, VkDevice vkDevice, VkImage vkImage,
+ RenderTarget(const VulkanDispatch& vk, VkDevice vkDevice, VkImage vkImage,
VkImageView vkImageView, uint32_t width, uint32_t height,
VkRenderPass vkRenderPass);
- const goldfish_vk::VulkanDispatch& m_vk;
+ const VulkanDispatch& m_vk;
VkDevice m_vkDevice;
VkImage m_vkImage;
VkFramebuffer m_vkFramebuffer;
@@ -231,4 +233,7 @@
android::base::LruCache<uint32_t, std::unique_ptr<RenderTarget>> m_renderTargetCache;
};
+} // namespace vk
+} // namespace gfxstream
+
#endif /* COMPOSITOR_VK_H */
diff --git a/stream-servers/vulkan/DebugUtilsHelper.cpp b/stream-servers/vulkan/DebugUtilsHelper.cpp
index e719c86..0c2269a 100644
--- a/stream-servers/vulkan/DebugUtilsHelper.cpp
+++ b/stream-servers/vulkan/DebugUtilsHelper.cpp
@@ -21,7 +21,8 @@
#include "host-common/logging.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
/*static*/ DebugUtilsHelper DebugUtilsHelper::withUtilsDisabled() {
return DebugUtilsHelper(false, VK_NULL_HANDLE, nullptr);
@@ -91,4 +92,5 @@
m_vk->vkCmdEndDebugUtilsLabelEXT(commandBuffer);
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/DebugUtilsHelper.h b/stream-servers/vulkan/DebugUtilsHelper.h
index d93efb5..f1dad84 100644
--- a/stream-servers/vulkan/DebugUtilsHelper.h
+++ b/stream-servers/vulkan/DebugUtilsHelper.h
@@ -18,7 +18,8 @@
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
class DebugUtilsHelper {
public:
@@ -73,4 +74,5 @@
const VulkanDispatch* m_vk = nullptr;
};
-} // namespace goldfish_vk
\ No newline at end of file
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/DisplaySurfaceVk.cpp b/stream-servers/vulkan/DisplaySurfaceVk.cpp
index 7a61a9c..4228b3e 100644
--- a/stream-servers/vulkan/DisplaySurfaceVk.cpp
+++ b/stream-servers/vulkan/DisplaySurfaceVk.cpp
@@ -18,13 +18,15 @@
#include "host-common/logging.h"
#include "vk_util.h"
+namespace gfxstream {
+namespace vk {
+
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
-std::unique_ptr<DisplaySurfaceVk> DisplaySurfaceVk::create(
- const goldfish_vk::VulkanDispatch& vk,
- VkInstance instance,
- FBNativeWindowType window) {
+std::unique_ptr<DisplaySurfaceVk> DisplaySurfaceVk::create(const VulkanDispatch& vk,
+ VkInstance instance,
+ FBNativeWindowType window) {
VkSurfaceKHR surface = VK_NULL_HANDLE;
#ifdef _WIN32
const VkWin32SurfaceCreateInfoKHR surfaceCi = {
@@ -47,15 +49,15 @@
return std::unique_ptr<DisplaySurfaceVk>(new DisplaySurfaceVk(vk, instance, surface));
}
-DisplaySurfaceVk::DisplaySurfaceVk(const goldfish_vk::VulkanDispatch& vk,
- VkInstance instance,
+DisplaySurfaceVk::DisplaySurfaceVk(const VulkanDispatch& vk, VkInstance instance,
VkSurfaceKHR surface)
- : mVk(vk),
- mInstance(instance),
- mSurface(surface) {}
+ : mVk(vk), mInstance(instance), mSurface(surface) {}
DisplaySurfaceVk::~DisplaySurfaceVk() {
if (mSurface != VK_NULL_HANDLE) {
mVk.vkDestroySurfaceKHR(mInstance, mSurface, nullptr);
}
}
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/DisplaySurfaceVk.h b/stream-servers/vulkan/DisplaySurfaceVk.h
index 2ff8ff7..b31318f 100644
--- a/stream-servers/vulkan/DisplaySurfaceVk.h
+++ b/stream-servers/vulkan/DisplaySurfaceVk.h
@@ -21,23 +21,25 @@
#include "render-utils/render_api_platform_types.h"
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
+namespace gfxstream {
+namespace vk {
+
class DisplaySurfaceVk : public gfxstream::DisplaySurfaceImpl {
public:
- static std::unique_ptr<DisplaySurfaceVk> create(
- const goldfish_vk::VulkanDispatch& vk,
- VkInstance vkInstance,
- FBNativeWindowType window);
+ static std::unique_ptr<DisplaySurfaceVk> create(const VulkanDispatch& vk, VkInstance vkInstance,
+ FBNativeWindowType window);
- ~DisplaySurfaceVk();
+ ~DisplaySurfaceVk();
- VkSurfaceKHR getSurface() const { return mSurface; }
+ VkSurfaceKHR getSurface() const { return mSurface; }
private:
- DisplaySurfaceVk(const goldfish_vk::VulkanDispatch& vk,
- VkInstance vkInstance,
- VkSurfaceKHR vkSurface);
+ DisplaySurfaceVk(const VulkanDispatch& vk, VkInstance vkInstance, VkSurfaceKHR vkSurface);
- const goldfish_vk::VulkanDispatch& mVk;
- VkInstance mInstance = VK_NULL_HANDLE;
- VkSurfaceKHR mSurface = VK_NULL_HANDLE;
+ const VulkanDispatch& mVk;
+ VkInstance mInstance = VK_NULL_HANDLE;
+ VkSurfaceKHR mSurface = VK_NULL_HANDLE;
};
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/DisplayVk.cpp b/stream-servers/vulkan/DisplayVk.cpp
index 97e7e80..1d646fa 100644
--- a/stream-servers/vulkan/DisplayVk.cpp
+++ b/stream-servers/vulkan/DisplayVk.cpp
@@ -9,6 +9,9 @@
#include "vulkan/VkFormatUtils.h"
#include "vulkan/vk_enum_string_helper.h"
+namespace gfxstream {
+namespace vk {
+
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
@@ -45,7 +48,7 @@
} // namespace
-DisplayVk::DisplayVk(const goldfish_vk::VulkanDispatch& vk, VkPhysicalDevice vkPhysicalDevice,
+DisplayVk::DisplayVk(const VulkanDispatch& vk, VkPhysicalDevice vkPhysicalDevice,
uint32_t swapChainQueueFamilyIndex, uint32_t compositorQueueFamilyIndex,
VkDevice vkDevice, VkQueue compositorVkQueue,
std::shared_ptr<android::base::Lock> compositorVkQueueLock,
@@ -235,7 +238,7 @@
// borrowed image.
const auto* sourceImageInfoVk = static_cast<const BorrowedImageInfoVk*>(sourceImageInfo);
struct ImageBorrower {
- ImageBorrower(const goldfish_vk::VulkanDispatch& vk, VkQueue queue,
+ ImageBorrower(const VulkanDispatch& vk, VkQueue queue,
std::shared_ptr<android::base::Lock> queueLock, uint32_t usedQueueFamilyIndex,
const BorrowedImageInfoVk& image, const ImageBorrowResource& acquireResource,
const ImageBorrowResource& releaseResource)
@@ -322,7 +325,7 @@
}
}
- const goldfish_vk::VulkanDispatch& m_vk;
+ const VulkanDispatch& m_vk;
const VkQueue m_vkQueue;
std::shared_ptr<android::base::Lock> m_queueLock;
const ImageBorrowResource& m_releaseResource;
@@ -678,7 +681,7 @@
}
std::shared_ptr<DisplayVk::PostResource> DisplayVk::PostResource::create(
- const goldfish_vk::VulkanDispatch& vk, VkDevice vkDevice, VkCommandPool vkCommandPool) {
+ const VulkanDispatch& vk, VkDevice vkDevice, VkCommandPool vkCommandPool) {
VkFenceCreateInfo fenceCi = {
.sType = VK_STRUCTURE_TYPE_FENCE_CREATE_INFO,
};
@@ -710,7 +713,7 @@
m_vk.vkDestroySemaphore(m_vkDevice, m_swapchainImageReleaseSemaphore, nullptr);
}
-DisplayVk::PostResource::PostResource(const goldfish_vk::VulkanDispatch& vk, VkDevice vkDevice,
+DisplayVk::PostResource::PostResource(const VulkanDispatch& vk, VkDevice vkDevice,
VkCommandPool vkCommandPool,
VkFence swapchainImageReleaseFence,
VkSemaphore swapchainImageAcquireSemaphore,
@@ -725,7 +728,7 @@
m_vkCommandPool(vkCommandPool) {}
std::unique_ptr<DisplayVk::ImageBorrowResource> DisplayVk::ImageBorrowResource::create(
- const goldfish_vk::VulkanDispatch& vk, VkDevice device, VkCommandPool commandPool) {
+ const VulkanDispatch& vk, VkDevice device, VkCommandPool commandPool) {
const VkCommandBufferAllocateInfo allocInfo = {
.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO,
.pNext = nullptr,
@@ -750,11 +753,14 @@
m_vk.vkFreeCommandBuffers(m_vkDevice, m_vkCommandPool, 1, &m_vkCommandBuffer);
}
-DisplayVk::ImageBorrowResource::ImageBorrowResource(const goldfish_vk::VulkanDispatch& vk,
- VkDevice device, VkCommandPool commandPool,
- VkFence fence, VkCommandBuffer commandBuffer)
+DisplayVk::ImageBorrowResource::ImageBorrowResource(const VulkanDispatch& vk, VkDevice device,
+ VkCommandPool commandPool, VkFence fence,
+ VkCommandBuffer commandBuffer)
: m_completeFence(fence),
m_vkCommandBuffer(commandBuffer),
m_vk(vk),
m_vkDevice(device),
m_vkCommandPool(commandPool) {}
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/DisplayVk.h b/stream-servers/vulkan/DisplayVk.h
index cd649ba..e137134 100644
--- a/stream-servers/vulkan/DisplayVk.h
+++ b/stream-servers/vulkan/DisplayVk.h
@@ -22,12 +22,15 @@
// The DisplayVk class holds the Vulkan and other states required to draw a
// frame in a host window.
+namespace gfxstream {
+namespace vk {
+
class DisplayVk : public gfxstream::Display {
public:
- DisplayVk(const goldfish_vk::VulkanDispatch&, VkPhysicalDevice,
- uint32_t swapChainQueueFamilyIndex, uint32_t compositorQueueFamilyIndex, VkDevice,
- VkQueue compositorVkQueue, std::shared_ptr<android::base::Lock> compositorVkQueueLock,
- VkQueue swapChainVkQueue, std::shared_ptr<android::base::Lock> swapChainVkQueueLock);
+ DisplayVk(const VulkanDispatch&, VkPhysicalDevice, uint32_t swapChainQueueFamilyIndex,
+ uint32_t compositorQueueFamilyIndex, VkDevice, VkQueue compositorVkQueue,
+ std::shared_ptr<android::base::Lock> compositorVkQueueLock, VkQueue swapChainVkQueue,
+ std::shared_ptr<android::base::Lock> swapChainVkQueueLock);
~DisplayVk();
PostResult post(const BorrowedImageInfo* info);
@@ -53,7 +56,7 @@
VkFormatFeatureFlags getFormatFeatures(VkFormat, VkImageTiling);
bool canPost(const VkImageCreateInfo&);
- const goldfish_vk::VulkanDispatch& m_vk;
+ const VulkanDispatch& m_vk;
VkPhysicalDevice m_vkPhysicalDevice;
uint32_t m_swapChainQueueFamilyIndex;
uint32_t m_compositorQueueFamilyIndex;
@@ -70,16 +73,15 @@
const VkSemaphore m_swapchainImageAcquireSemaphore;
const VkSemaphore m_swapchainImageReleaseSemaphore;
const VkCommandBuffer m_vkCommandBuffer;
- static std::shared_ptr<PostResource> create(const goldfish_vk::VulkanDispatch&, VkDevice,
- VkCommandPool);
+ static std::shared_ptr<PostResource> create(const VulkanDispatch&, VkDevice, VkCommandPool);
~PostResource();
DISALLOW_COPY_ASSIGN_AND_MOVE(PostResource);
private:
- PostResource(const goldfish_vk::VulkanDispatch&, VkDevice, VkCommandPool,
+ PostResource(const VulkanDispatch&, VkDevice, VkCommandPool,
VkFence swapchainImageReleaseFence, VkSemaphore swapchainImageAcquireSemaphore,
VkSemaphore swapchainImageReleaseSemaphore, VkCommandBuffer);
- const goldfish_vk::VulkanDispatch& m_vk;
+ const VulkanDispatch& m_vk;
const VkDevice m_vkDevice;
const VkCommandPool m_vkCommandPool;
};
@@ -93,15 +95,15 @@
public:
const VkFence m_completeFence;
const VkCommandBuffer m_vkCommandBuffer;
- static std::unique_ptr<ImageBorrowResource> create(const goldfish_vk::VulkanDispatch&,
- VkDevice, VkCommandPool);
+ static std::unique_ptr<ImageBorrowResource> create(const VulkanDispatch&, VkDevice,
+ VkCommandPool);
~ImageBorrowResource();
DISALLOW_COPY_ASSIGN_AND_MOVE(ImageBorrowResource);
private:
- ImageBorrowResource(const goldfish_vk::VulkanDispatch&, VkDevice, VkCommandPool, VkFence,
+ ImageBorrowResource(const VulkanDispatch&, VkDevice, VkCommandPool, VkFence,
VkCommandBuffer);
- const goldfish_vk::VulkanDispatch& m_vk;
+ const VulkanDispatch& m_vk;
const VkDevice m_vkDevice;
const VkCommandPool m_vkCommandPool;
};
@@ -112,4 +114,8 @@
std::unordered_map<VkFormat, VkFormatProperties> m_vkFormatProperties;
};
+
+} // namespace vk
+} // namespace gfxstream
+
#endif
diff --git a/stream-servers/vulkan/RenderThreadInfoVk.h b/stream-servers/vulkan/RenderThreadInfoVk.h
index bbacebf..578b962 100644
--- a/stream-servers/vulkan/RenderThreadInfoVk.h
+++ b/stream-servers/vulkan/RenderThreadInfoVk.h
@@ -19,10 +19,12 @@
#include "VkDecoder.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
struct RenderThreadInfoVk {
VkDecoder m_vkDec;
};
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/SwapChainStateVk.cpp b/stream-servers/vulkan/SwapChainStateVk.cpp
index 8ad0097..1090f25 100644
--- a/stream-servers/vulkan/SwapChainStateVk.cpp
+++ b/stream-servers/vulkan/SwapChainStateVk.cpp
@@ -8,6 +8,9 @@
#include "vulkan/vk_enum_string_helper.h"
#include "vulkan/vk_util.h"
+namespace gfxstream {
+namespace vk {
+
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
@@ -72,11 +75,8 @@
}
}
-
-
std::unique_ptr<SwapChainStateVk> SwapChainStateVk::createSwapChainVk(
- const goldfish_vk::VulkanDispatch& vk,
- VkDevice vkDevice, const VkSwapchainCreateInfoKHR& swapChainCi) {
+ const VulkanDispatch& vk, VkDevice vkDevice, const VkSwapchainCreateInfoKHR& swapChainCi) {
std::unique_ptr<SwapChainStateVk> swapChainVk(new SwapChainStateVk(vk, vkDevice));
if (swapChainVk->initSwapChainStateVk(swapChainCi) != VK_SUCCESS) {
return nullptr;
@@ -84,13 +84,12 @@
return swapChainVk;
}
-SwapChainStateVk::SwapChainStateVk(const goldfish_vk::VulkanDispatch& vk, VkDevice vkDevice)
+SwapChainStateVk::SwapChainStateVk(const VulkanDispatch& vk, VkDevice vkDevice)
: m_vk(vk),
m_vkDevice(vkDevice),
m_vkSwapChain(VK_NULL_HANDLE),
m_vkImages(0),
- m_vkImageViews(0) {
-}
+ m_vkImageViews(0) {}
VkResult SwapChainStateVk::initSwapChainStateVk(const VkSwapchainCreateInfoKHR& swapChainCi) {
VkResult res = m_vk.vkCreateSwapchainKHR(m_vkDevice, &swapChainCi, nullptr, &m_vkSwapChain);
@@ -154,7 +153,7 @@
};
}
-bool SwapChainStateVk::validateQueueFamilyProperties(const goldfish_vk::VulkanDispatch& vk,
+bool SwapChainStateVk::validateQueueFamilyProperties(const VulkanDispatch& vk,
VkPhysicalDevice physicalDevice,
VkSurfaceKHR surface,
uint32_t queueFamilyIndex) {
@@ -165,8 +164,8 @@
}
std::optional<SwapchainCreateInfoWrapper> SwapChainStateVk::createSwapChainCi(
- const goldfish_vk::VulkanDispatch& vk, VkSurfaceKHR surface, VkPhysicalDevice physicalDevice,
- uint32_t width, uint32_t height, const std::unordered_set<uint32_t>& queueFamilyIndices) {
+ const VulkanDispatch& vk, VkSurfaceKHR surface, VkPhysicalDevice physicalDevice, uint32_t width,
+ uint32_t height, const std::unordered_set<uint32_t>& queueFamilyIndices) {
uint32_t formatCount = 0;
VK_CHECK(
vk.vkGetPhysicalDeviceSurfaceFormatsKHR(physicalDevice, surface, &formatCount, nullptr));
@@ -305,3 +304,6 @@
const std::vector<VkImageView>& SwapChainStateVk::getVkImageViews() const { return m_vkImageViews; }
VkSwapchainKHR SwapChainStateVk::getSwapChain() const { return m_vkSwapChain; }
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/SwapChainStateVk.h b/stream-servers/vulkan/SwapChainStateVk.h
index 6734272..49ad577 100644
--- a/stream-servers/vulkan/SwapChainStateVk.h
+++ b/stream-servers/vulkan/SwapChainStateVk.h
@@ -10,6 +10,9 @@
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
+namespace gfxstream {
+namespace vk {
+
struct SwapchainCreateInfoWrapper {
VkSwapchainCreateInfoKHR mCreateInfo;
std::vector<uint32_t> mQueueFamilyIndices;
@@ -34,18 +37,18 @@
public:
static std::vector<const char*> getRequiredInstanceExtensions();
static std::vector<const char*> getRequiredDeviceExtensions();
- static bool validateQueueFamilyProperties(const goldfish_vk::VulkanDispatch&, VkPhysicalDevice,
- VkSurfaceKHR, uint32_t queueFamilyIndex);
+ static bool validateQueueFamilyProperties(const VulkanDispatch&, VkPhysicalDevice, VkSurfaceKHR,
+ uint32_t queueFamilyIndex);
static std::optional<SwapchainCreateInfoWrapper> createSwapChainCi(
- const goldfish_vk::VulkanDispatch&, VkSurfaceKHR, VkPhysicalDevice, uint32_t width,
- uint32_t height, const std::unordered_set<uint32_t>& queueFamilyIndices);
+ const VulkanDispatch&, VkSurfaceKHR, VkPhysicalDevice, uint32_t width, uint32_t height,
+ const std::unordered_set<uint32_t>& queueFamilyIndices);
SwapChainStateVk() = delete;
SwapChainStateVk(const SwapChainStateVk&) = delete;
SwapChainStateVk& operator = (const SwapChainStateVk&) = delete;
- static std::unique_ptr<SwapChainStateVk> createSwapChainVk(const goldfish_vk::VulkanDispatch&,
- VkDevice, const VkSwapchainCreateInfoKHR&);
+ static std::unique_ptr<SwapChainStateVk> createSwapChainVk(const VulkanDispatch&, VkDevice,
+ const VkSwapchainCreateInfoKHR&);
~SwapChainStateVk();
VkFormat getFormat();
@@ -55,13 +58,13 @@
VkSwapchainKHR getSwapChain() const;
private:
- explicit SwapChainStateVk(const goldfish_vk::VulkanDispatch&, VkDevice);
+ explicit SwapChainStateVk(const VulkanDispatch&, VkDevice);
VkResult initSwapChainStateVk(const VkSwapchainCreateInfoKHR& swapChainCi);
const static VkFormat k_vkFormat = VK_FORMAT_B8G8R8A8_UNORM;
const static VkColorSpaceKHR k_vkColorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
- const goldfish_vk::VulkanDispatch& m_vk;
+ const VulkanDispatch& m_vk;
VkDevice m_vkDevice;
VkSwapchainKHR m_vkSwapChain;
VkExtent2D m_vkImageExtent;
@@ -69,4 +72,7 @@
std::vector<VkImageView> m_vkImageViews;
};
+} // namespace vk
+} // namespace gfxstream
+
#endif
\ No newline at end of file
diff --git a/stream-servers/vulkan/VkAndroidNativeBuffer.cpp b/stream-servers/vulkan/VkAndroidNativeBuffer.cpp
index ca8fb1d..be28d76 100644
--- a/stream-servers/vulkan/VkAndroidNativeBuffer.cpp
+++ b/stream-servers/vulkan/VkAndroidNativeBuffer.cpp
@@ -27,6 +27,9 @@
#include "stream-servers/FrameBuffer.h"
#include "vulkan/vk_enum_string_helper.h"
+namespace gfxstream {
+namespace vk {
+
#define VK_ANB_ERR(fmt, ...) fprintf(stderr, "%s:%d " fmt "\n", __func__, __LINE__, ##__VA_ARGS__);
#define ENABLE_VK_ANB_DEBUG 0
@@ -46,8 +49,6 @@
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
-namespace goldfish_vk {
-
AndroidNativeBufferInfo::QsriWaitFencePool::QsriWaitFencePool(VulkanDispatch* vk, VkDevice device)
: mVk(vk), mDevice(device) {}
@@ -814,4 +815,5 @@
return VK_SUCCESS;
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkAndroidNativeBuffer.h b/stream-servers/vulkan/VkAndroidNativeBuffer.h
index 4cfb714..d43bfd0 100644
--- a/stream-servers/vulkan/VkAndroidNativeBuffer.h
+++ b/stream-servers/vulkan/VkAndroidNativeBuffer.h
@@ -28,7 +28,8 @@
#include "aemu/base/synchronization/Lock.h"
#include "cereal/common/goldfish_vk_private_defs.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
struct AndroidNativeBufferInfo;
struct VulkanDispatch;
@@ -167,4 +168,5 @@
const VkSemaphore* pWaitSemaphores, int* pNativeFenceFd,
std::shared_ptr<AndroidNativeBufferInfo> anbInfo);
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkCommonOperations.cpp b/stream-servers/vulkan/VkCommonOperations.cpp
index b5032c5..32795d3 100644
--- a/stream-servers/vulkan/VkCommonOperations.cpp
+++ b/stream-servers/vulkan/VkCommonOperations.cpp
@@ -49,6 +49,10 @@
#include <CoreFoundation/CoreFoundation.h>
#endif
+namespace gfxstream {
+namespace vk {
+namespace {
+
#define VK_COMMON_ERROR(fmt, ...) \
fprintf(stderr, "%s:%d " fmt "\n", __func__, __LINE__, ##__VA_ARGS__);
#define VK_COMMON_LOG(fmt, ...) \
@@ -58,19 +62,14 @@
fprintf(stderr, "%s:%d " fmt "\n", __func__, __LINE__, ##__VA_ARGS__);
using android::base::AutoLock;
+using android::base::kNullopt;
using android::base::ManagedDescriptor;
using android::base::Optional;
using android::base::StaticLock;
using android::base::StaticMap;
-
-using android::base::kNullopt;
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
-namespace goldfish_vk {
-
-namespace {
-
constexpr size_t kPageBits = 12;
constexpr size_t kPageSize = 1u << kPageBits;
@@ -509,7 +508,7 @@
if (sVkEmulation) return sVkEmulation;
- if (!emugl::vkDispatchValid(vk)) {
+ if (!vkDispatchValid(vk)) {
VK_EMU_INIT_RETURN_OR_ABORT_ON_ERROR(ABORT_REASON_OTHER, "Dispatch is invalid.");
}
@@ -3226,4 +3225,5 @@
return compositorInfo;
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkCommonOperations.h b/stream-servers/vulkan/VkCommonOperations.h
index 9017f22..f8415df 100644
--- a/stream-servers/vulkan/VkCommonOperations.h
+++ b/stream-servers/vulkan/VkCommonOperations.h
@@ -34,7 +34,8 @@
#include "utils/GfxApiLogger.h"
#include "utils/RenderDoc.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
struct VulkanDispatch;
@@ -491,4 +492,5 @@
bool colorBufferIsTarget);
std::unique_ptr<BorrowedImageInfoVk> borrowColorBufferForDisplay(uint32_t colorBufferHandle);
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkDecoder.cpp b/stream-servers/vulkan/VkDecoder.cpp
index 93791a5..72f6fa4 100644
--- a/stream-servers/vulkan/VkDecoder.cpp
+++ b/stream-servers/vulkan/VkDecoder.cpp
@@ -55,11 +55,11 @@
#define MAX_PACKET_LENGTH (400 * 1024 * 1024) // 400MB
+namespace gfxstream {
+namespace vk {
+
using android::base::MetricEventBadPacketLength;
using android::base::MetricEventDuplicateSequenceNum;
-using emugl::vkDispatch;
-
-using namespace goldfish_vk;
class VkDecoder::Impl {
public:
@@ -34543,3 +34543,6 @@
return ptr - (unsigned char*)buf;
;
}
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkDecoder.h b/stream-servers/vulkan/VkDecoder.h
index f661d65..ebc9dfe 100644
--- a/stream-servers/vulkan/VkDecoder.h
+++ b/stream-servers/vulkan/VkDecoder.h
@@ -43,8 +43,13 @@
} // namespace base
} // namespace android
-class ProcessResources;
+namespace gfxstream {
class IOStream;
+class ProcessResources;
+} // namespace gfxstream
+
+namespace gfxstream {
+namespace vk {
class VkDecoder {
public:
@@ -58,6 +63,10 @@
class Impl;
std::unique_ptr<Impl> mImpl;
};
+
+} // namespace vk
+} // namespace gfxstream
+
#ifdef VK_VERSION_1_0
#endif
#ifdef VK_VERSION_1_1
diff --git a/stream-servers/vulkan/VkDecoderContext.h b/stream-servers/vulkan/VkDecoderContext.h
index 096c32e..4a997cf 100644
--- a/stream-servers/vulkan/VkDecoderContext.h
+++ b/stream-servers/vulkan/VkDecoderContext.h
@@ -21,9 +21,15 @@
#include "aemu/base/Metrics.h"
#include "utils/GfxApiLogger.h"
+namespace gfxstream {
+namespace vk {
+
struct VkDecoderContext {
const char* processName = nullptr;
emugl::GfxApiLogger* gfxApiLogger = nullptr;
emugl::HealthMonitor<>* healthMonitor = nullptr;
emugl::MetricsLogger* metricsLogger = nullptr;
-};
\ No newline at end of file
+};
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkDecoderGlobalState.cpp b/stream-servers/vulkan/VkDecoderGlobalState.cpp
index e798a9e..914be22 100644
--- a/stream-servers/vulkan/VkDecoderGlobalState.cpp
+++ b/stream-servers/vulkan/VkDecoderGlobalState.cpp
@@ -66,6 +66,9 @@
#include <climits>
+namespace gfxstream {
+namespace vk {
+
using android::base::AutoLock;
using android::base::ConditionVariable;
using android::base::DescriptorType;
@@ -109,8 +112,6 @@
}
}
-namespace goldfish_vk {
-
// A list of device extensions that should not be passed to the host driver.
// These will mainly include Vulkan features that we emulate ourselves.
static constexpr const char* const kEmulatedDeviceExtensions[] = {
@@ -294,7 +295,7 @@
class VkDecoderGlobalState::Impl {
public:
Impl()
- : m_vk(emugl::vkDispatch()),
+ : m_vk(vkDispatch()),
m_emu(getGlobalVkEmulation()),
mRenderDocWithMultipleVkInstances(m_emu->guestRenderDoc.get()) {
mSnapshotsEnabled = feature_is_enabled(kFeature_VulkanSnapshots);
@@ -4955,14 +4956,13 @@
// For AHardwareBufferImage binding, we can't know which ColorBuffer this
// to-be-created VkImage will bind to, so we try our best to infer the creation
// parameters.
- colorBufferVkImageCi = goldfish_vk::generateColorBufferVkImageCreateInfo(
+ colorBufferVkImageCi = generateColorBufferVkImageCreateInfo(
resolvedFormat, imageCreateInfo.extent.width, imageCreateInfo.extent.height,
imageCreateInfo.tiling);
importSource = "AHardwareBuffer";
} else if (pNativeBufferANDROID) {
// For native buffer binding, we can query the creation parameters from handle.
- auto colorBufferInfo =
- goldfish_vk::getColorBufferInfo(*pNativeBufferANDROID->handle);
+ auto colorBufferInfo = getColorBufferInfo(*pNativeBufferANDROID->handle);
if (colorBufferInfo.handle == *pNativeBufferANDROID->handle) {
colorBufferVkImageCi =
std::make_unique<VkImageCreateInfo>(colorBufferInfo.imageCreateInfoShallow);
@@ -5383,7 +5383,7 @@
}
// Whether the VkInstance associated with this physical device was created by ANGLE
- bool isAngleInstance(VkPhysicalDevice physicalDevice, goldfish_vk::VulkanDispatch* vk) {
+ bool isAngleInstance(VkPhysicalDevice physicalDevice, VulkanDispatch* vk) {
std::lock_guard<std::recursive_mutex> lock(mLock);
VkInstance* instance = android::base::find(mPhysicalDeviceToInstance, physicalDevice);
if (!instance) return false;
@@ -5392,14 +5392,14 @@
return instanceInfo->isAngle;
}
- bool enableEmulatedEtc2(VkPhysicalDevice physicalDevice, goldfish_vk::VulkanDispatch* vk) {
+ bool enableEmulatedEtc2(VkPhysicalDevice physicalDevice, VulkanDispatch* vk) {
if (!m_emu->enableEtc2Emulation) return false;
// Don't enable ETC2 emulation for ANGLE, let it do its own emulation.
return !isAngleInstance(physicalDevice, vk);
}
- bool enableEmulatedAstc(VkPhysicalDevice physicalDevice, goldfish_vk::VulkanDispatch* vk) {
+ bool enableEmulatedAstc(VkPhysicalDevice physicalDevice, VulkanDispatch* vk) {
if (m_emu->astcLdrEmulationMode == AstcEmulationMode::Disabled) {
return false;
}
@@ -5408,7 +5408,7 @@
return !isAngleInstance(physicalDevice, vk);
}
- bool needEmulatedEtc2(VkPhysicalDevice physicalDevice, goldfish_vk::VulkanDispatch* vk) {
+ bool needEmulatedEtc2(VkPhysicalDevice physicalDevice, VulkanDispatch* vk) {
if (!enableEmulatedEtc2(physicalDevice, vk)) {
return false;
}
@@ -5417,7 +5417,7 @@
return !feature.textureCompressionETC2;
}
- bool needEmulatedAstc(VkPhysicalDevice physicalDevice, goldfish_vk::VulkanDispatch* vk) {
+ bool needEmulatedAstc(VkPhysicalDevice physicalDevice, VulkanDispatch* vk) {
if (!enableEmulatedAstc(physicalDevice, vk)) {
return false;
}
@@ -5427,7 +5427,7 @@
}
bool isEmulatedCompressedTexture(VkFormat format, VkPhysicalDevice physicalDevice,
- goldfish_vk::VulkanDispatch* vk) {
+ VulkanDispatch* vk) {
return (CompressedImageInfo::isEtc2(format) && needEmulatedEtc2(physicalDevice, vk)) ||
(CompressedImageInfo::isAstc(format) && needEmulatedAstc(physicalDevice, vk));
}
@@ -5462,7 +5462,7 @@
void getPhysicalDeviceFormatPropertiesCore(
std::function<void(VkPhysicalDevice, VkFormat, VkFormatProperties1or2*)>
getPhysicalDeviceFormatPropertiesFunc,
- goldfish_vk::VulkanDispatch* vk, VkPhysicalDevice physicalDevice, VkFormat format,
+ VulkanDispatch* vk, VkPhysicalDevice physicalDevice, VkFormat format,
VkFormatProperties1or2* pFormatProperties) {
if (isEmulatedCompressedTexture(format, physicalDevice, vk)) {
getPhysicalDeviceFormatPropertiesFunc(
@@ -7415,4 +7415,5 @@
GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES(
BOXED_NON_DISPATCHABLE_HANDLE_UNWRAP_AND_DELETE_PRESERVE_BOXED_IMPL)
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkDecoderGlobalState.h b/stream-servers/vulkan/VkDecoderGlobalState.h
index 2a3e304..5c1f6a3 100644
--- a/stream-servers/vulkan/VkDecoderGlobalState.h
+++ b/stream-servers/vulkan/VkDecoderGlobalState.h
@@ -49,7 +49,8 @@
} // namespace base
} // namespace android
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
// Class for tracking host-side state. Currently we only care about
// tracking VkDeviceMemory to make it easier to pass the right data
@@ -951,4 +952,5 @@
int mMaxSize;
};
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkDecoderGlobalState_unittest.cpp b/stream-servers/vulkan/VkDecoderGlobalState_unittest.cpp
index 44935e4..7126869 100644
--- a/stream-servers/vulkan/VkDecoderGlobalState_unittest.cpp
+++ b/stream-servers/vulkan/VkDecoderGlobalState_unittest.cpp
@@ -19,7 +19,8 @@
#include "aemu/base/testing/TestUtils.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
namespace {
using ::testing::_;
using ::testing::InSequence;
@@ -143,4 +144,5 @@
}
} // namespace
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkDecoderSnapshot.cpp b/stream-servers/vulkan/VkDecoderSnapshot.cpp
index c5f545d..add885e 100644
--- a/stream-servers/vulkan/VkDecoderSnapshot.cpp
+++ b/stream-servers/vulkan/VkDecoderSnapshot.cpp
@@ -36,7 +36,7 @@
#include "VulkanHandleMapping.h"
#include "aemu/base/synchronization/Lock.h"
-using namespace goldfish_vk;
+using namespace gfxstream::vk;
using emugl::GfxApiLogger;
using emugl::HealthMonitor;
diff --git a/stream-servers/vulkan/VkFormatUtils.cpp b/stream-servers/vulkan/VkFormatUtils.cpp
index 7685ea6..a51f1a6 100644
--- a/stream-servers/vulkan/VkFormatUtils.cpp
+++ b/stream-servers/vulkan/VkFormatUtils.cpp
@@ -16,6 +16,8 @@
#include <unordered_map>
+namespace gfxstream {
+namespace vk {
namespace {
struct FormatPlaneLayout {
@@ -191,3 +193,6 @@
return true;
}
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkFormatUtils.h b/stream-servers/vulkan/VkFormatUtils.h
index 323146d..5728f7e 100644
--- a/stream-servers/vulkan/VkFormatUtils.h
+++ b/stream-servers/vulkan/VkFormatUtils.h
@@ -20,6 +20,9 @@
#include "host-common/logging.h"
#include "vulkan/vk_enum_string_helper.h"
+namespace gfxstream {
+namespace vk {
+
// Header library that captures common patterns when working with
// Vulkan formats:
// - Macros to iterate over categories of formats
@@ -655,3 +658,6 @@
bool getFormatTransferInfo(VkFormat format, uint32_t width, uint32_t height,
VkDeviceSize* outStagingBufferCopySize,
std::vector<VkBufferImageCopy>* outBufferImageCopies);
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkFormatUtils_unittest.cpp b/stream-servers/vulkan/VkFormatUtils_unittest.cpp
index 3cdb76a..db724a5 100644
--- a/stream-servers/vulkan/VkFormatUtils_unittest.cpp
+++ b/stream-servers/vulkan/VkFormatUtils_unittest.cpp
@@ -17,6 +17,8 @@
#include "VkFormatUtils.h"
+namespace gfxstream {
+namespace vk {
namespace {
using ::testing::AllOf;
@@ -256,4 +258,6 @@
})));
}
-} // namespace
\ No newline at end of file
+} // namespace
+} // namespace vk
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/vulkan/VkQsriTimeline.h b/stream-servers/vulkan/VkQsriTimeline.h
index 19e8ea0..e8a9526 100644
--- a/stream-servers/vulkan/VkQsriTimeline.h
+++ b/stream-servers/vulkan/VkQsriTimeline.h
@@ -9,7 +9,9 @@
#include "host-common/logging.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
class VkQsriTimeline {
public:
using Callback = std::function<void()>;
@@ -60,6 +62,8 @@
mPendingCallbacks.erase(mPendingCallbacks.begin(), firstPendingCallback);
}
};
-} // namespace goldfish_vk
+
+} // namespace vk
+} // namespace gfxstream
#endif // VK_QSRI_TIMELINE_H
\ No newline at end of file
diff --git a/stream-servers/vulkan/VkQsriTimeline_unittest.cpp b/stream-servers/vulkan/VkQsriTimeline_unittest.cpp
index d5d7af7..3516c6a 100644
--- a/stream-servers/vulkan/VkQsriTimeline_unittest.cpp
+++ b/stream-servers/vulkan/VkQsriTimeline_unittest.cpp
@@ -3,7 +3,8 @@
#include "VkQsriTimeline.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
namespace {
using ::testing::InSequence;
using ::testing::MockFunction;
@@ -39,4 +40,5 @@
}
} // namespace
-} // namespace goldfish_vk
\ No newline at end of file
+} // namespace vk
+} // namespace gfxstream
\ No newline at end of file
diff --git a/stream-servers/vulkan/VkReconstruction.cpp b/stream-servers/vulkan/VkReconstruction.cpp
index 3926dc7..8de635b 100644
--- a/stream-servers/vulkan/VkReconstruction.cpp
+++ b/stream-servers/vulkan/VkReconstruction.cpp
@@ -22,6 +22,9 @@
#include "VkDecoder.h"
#include "aemu/base/containers/EntityManager.h"
+namespace gfxstream {
+namespace vk {
+
#define DEBUG_RECONSTRUCTION 0
#if DEBUG_RECONSTRUCTION
@@ -299,7 +302,7 @@
mApiTrace.forEachLiveEntry_const(
[&traceBytesTotal](bool live, uint64_t handle, const ApiInfo& info) {
fprintf(stderr, "VkReconstruction::%s: api handle 0x%llx: %s\n", __func__,
- (unsigned long long)handle, goldfish_vk::api_opcode_to_string(info.opCode));
+ (unsigned long long)handle, api_opcode_to_string(info.opCode));
traceBytesTotal += info.traceBytes;
});
@@ -310,8 +313,7 @@
(unsigned long long)entityHandle);
for (auto apiHandle : reconstruction.apiRefs) {
auto apiInfo = mApiTrace.get(apiHandle);
- const char* apiName =
- apiInfo ? goldfish_vk::api_opcode_to_string(apiInfo->opCode) : "unalloced";
+ const char* apiName = apiInfo ? api_opcode_to_string(apiInfo->opCode) : "unalloced";
fprintf(stderr, "VkReconstruction::%s: 0x%llx: %s\n", __func__,
(unsigned long long)apiHandle, apiName);
for (auto createdHandle : apiInfo->createdHandles) {
@@ -328,8 +330,7 @@
(unsigned long long)entityHandle);
for (auto apiHandle : modification.apiRefs) {
auto apiInfo = mApiTrace.get(apiHandle);
- const char* apiName =
- apiInfo ? goldfish_vk::api_opcode_to_string(apiInfo->opCode) : "unalloced";
+ const char* apiName = apiInfo ? api_opcode_to_string(apiInfo->opCode) : "unalloced";
fprintf(stderr, "VkReconstruction::%s: mod: 0x%llx: %s\n", __func__,
(unsigned long long)apiHandle, apiName);
}
@@ -473,3 +474,6 @@
return orderedUniqueModifyApis;
}
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VkReconstruction.h b/stream-servers/vulkan/VkReconstruction.h
index 863c249..beb5816 100644
--- a/stream-servers/vulkan/VkReconstruction.h
+++ b/stream-servers/vulkan/VkReconstruction.h
@@ -21,6 +21,9 @@
#include "common/goldfish_vk_marshaling.h"
#include "utils/GfxApiLogger.h"
+namespace gfxstream {
+namespace vk {
+
// A class that captures all important data structures for
// reconstructing a Vulkan system state via trimmed API record and replay.
class VkReconstruction {
@@ -93,3 +96,6 @@
std::vector<uint8_t> mLoadedTrace;
};
+
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VulkanDispatch.cpp b/stream-servers/vulkan/VulkanDispatch.cpp
index c018428..9c87278 100644
--- a/stream-servers/vulkan/VulkanDispatch.cpp
+++ b/stream-servers/vulkan/VulkanDispatch.cpp
@@ -24,7 +24,8 @@
using android::base::Lock;
using android::base::pj;
-namespace emugl {
+namespace gfxstream {
+namespace vk {
static void setIcdPath(const std::string& path) {
if (android::base::pathExists(path.c_str())) {
@@ -276,7 +277,7 @@
}
void* dlsym(void* lib, const char* name) {
- return (void*)((emugl::SharedLibraries*)(lib))->dlsym(name);
+ return (void*)((SharedLibraries*)(lib))->dlsym(name);
}
VulkanDispatch* dispatch() { return &mDispatch; }
@@ -310,8 +311,8 @@
mForTesting = forTesting;
initIcdPaths(mForTesting);
- goldfish_vk::init_vulkan_dispatch_from_system_loader(sVulkanDispatchDlOpen,
- sVulkanDispatchDlSym, &mDispatch);
+ init_vulkan_dispatch_from_system_loader(sVulkanDispatchDlOpen, sVulkanDispatchDlSym,
+ &mDispatch);
mInitialized = true;
}
@@ -326,4 +327,5 @@
vk->vkGetInstanceProcAddr != nullptr || vk->vkGetDeviceProcAddr != nullptr;
}
-} // namespace emugl
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VulkanDispatch.h b/stream-servers/vulkan/VulkanDispatch.h
index f238fb8..a717548 100644
--- a/stream-servers/vulkan/VulkanDispatch.h
+++ b/stream-servers/vulkan/VulkanDispatch.h
@@ -15,11 +15,11 @@
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
-using goldfish_vk::VulkanDispatch;
-
-namespace emugl {
+namespace gfxstream {
+namespace vk {
VulkanDispatch* vkDispatch(bool forTesting = false);
bool vkDispatchValid(const VulkanDispatch* vk);
-} // namespace emugl
\ No newline at end of file
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VulkanHandleMapping.cpp b/stream-servers/vulkan/VulkanHandleMapping.cpp
index a91f5ed..1b5c6a6 100644
--- a/stream-servers/vulkan/VulkanHandleMapping.cpp
+++ b/stream-servers/vulkan/VulkanHandleMapping.cpp
@@ -16,7 +16,8 @@
#include <vulkan/vulkan.h>
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
#define DEFAULT_HANDLE_MAP_DEFINE(type) \
void DefaultHandleMapping::mapHandles_##type(type*, size_t) { return; } \
@@ -35,4 +36,5 @@
GOLDFISH_VK_LIST_HANDLE_TYPES(DEFAULT_HANDLE_MAP_DEFINE)
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VulkanHandleMapping.h b/stream-servers/vulkan/VulkanHandleMapping.h
index 490c6e6..2ea379f 100644
--- a/stream-servers/vulkan/VulkanHandleMapping.h
+++ b/stream-servers/vulkan/VulkanHandleMapping.h
@@ -21,7 +21,8 @@
#include "VulkanDispatch.h"
#include "VulkanHandles.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
class VkDecoderGlobalState;
@@ -74,4 +75,5 @@
GOLDFISH_VK_LIST_NON_DISPATCHABLE_HANDLE_TYPES(DEFINE_BOXED_NON_DISPATCHABLE_HANDLE_GLOBAL_API_DECL)
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VulkanStream.cpp b/stream-servers/vulkan/VulkanStream.cpp
index 60b4a87..aab3de1 100644
--- a/stream-servers/vulkan/VulkanStream.cpp
+++ b/stream-servers/vulkan/VulkanStream.cpp
@@ -22,13 +22,14 @@
#include "host-common/GfxstreamFatalError.h"
#include "host-common/feature_control.h"
+namespace gfxstream {
+namespace vk {
+
#define E(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
using emugl::ABORT_REASON_OTHER;
using emugl::FatalError;
-namespace goldfish_vk {
-
VulkanStream::VulkanStream(IOStream* stream) : mStream(stream) {
unsetHandleMapping();
@@ -219,4 +220,5 @@
void VulkanMemReadingStream::resetTrace() { mTraceStart = mStart + mReadPos; }
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VulkanStream.h b/stream-servers/vulkan/VulkanStream.h
index 854650d..ee18476 100644
--- a/stream-servers/vulkan/VulkanStream.h
+++ b/stream-servers/vulkan/VulkanStream.h
@@ -26,15 +26,18 @@
#define E(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)
-class IOStream;
-
namespace android {
namespace base {
class BumpPool;
} // namespace base
} // namespace android
-namespace goldfish_vk {
+namespace gfxstream {
+class IOStream;
+} // namespace gfxstream
+
+namespace gfxstream {
+namespace vk {
class VulkanStream : public android::base::Stream {
public:
@@ -109,4 +112,5 @@
uintptr_t mReadPos = 0;
};
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/VulkanStream_unittest.cpp b/stream-servers/vulkan/VulkanStream_unittest.cpp
index eb38747..6198e56 100644
--- a/stream-servers/vulkan/VulkanStream_unittest.cpp
+++ b/stream-servers/vulkan/VulkanStream_unittest.cpp
@@ -27,9 +27,11 @@
#include "common/goldfish_vk_reserved_marshaling.h"
#include "common/goldfish_vk_testing.h"
-using android::base::arraySize;
+namespace gfxstream {
+namespace vk {
+namespace {
-namespace goldfish_vk {
+using android::base::arraySize;
class TestStream : public IOStream {
public:
@@ -707,4 +709,6 @@
}
}
-} // namespace goldfish_vk
+} // namespace
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.cpp
index 47d7fe0..98410e6 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.cpp
@@ -37,7 +37,8 @@
#include "goldfish_vk_private_defs.h"
#include "vk_util.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
void deepcopy_extension_struct(Allocator* alloc, VkStructureType rootType,
const void* structExtension, void* structExtension_out);
@@ -21021,4 +21022,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.h b/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.h
index db290f9..eb14ba8 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_deepcopy.h
@@ -38,7 +38,9 @@
using android::base::Allocator;
using android::base::BumpPool;
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
#ifdef VK_VERSION_1_0
void deepcopy_VkExtent2D(Allocator* alloc, VkStructureType rootType, const VkExtent2D* from,
VkExtent2D* to);
@@ -3945,4 +3947,5 @@
#endif
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.cpp
index 7b00124..6244a7b 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.cpp
@@ -35,7 +35,8 @@
#include <stdlib.h>
#include <string.h>
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
#ifdef VK_VERSION_1_0
#endif
@@ -5524,4 +5525,5 @@
return good;
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.h b/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.h
index afbf14b..546d961 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.h
@@ -34,15 +34,18 @@
#include "goldfish_vk_private_defs.h"
#include "vk_android_native_buffer.h"
#include "vulkan_gfxstream.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
struct VulkanDispatch;
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
using DlOpenFunc = void*(void);
using DlSymFunc = void*(void*, const char*);
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
void init_vulkan_dispatch_from_system_loader(DlOpenFunc dlOpenFunc, DlSymFunc dlSymFunc,
VulkanDispatch* dispatch_out);
@@ -1163,4 +1166,5 @@
#endif
};
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.cpp
index 4895f05..310a340 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.cpp
@@ -31,7 +31,8 @@
#include "goldfish_vk_extension_structs.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
#ifdef VK_VERSION_1_0
#endif
@@ -3424,4 +3425,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.h b/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.h
index 261cefb..fd0296b 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_extension_structs.h
@@ -35,7 +35,9 @@
#include "vk_android_native_buffer.h"
#include "vulkan_gfxstream.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
uint32_t goldfish_vk_struct_type(const void* structExtension);
size_t goldfish_vk_extension_struct_size(VkStructureType rootType, const void* structExtension);
@@ -587,4 +589,5 @@
#ifdef VK_KHR_ray_query
#endif
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.cpp
index b523f18..813046c 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.cpp
@@ -36,7 +36,8 @@
#include "goldfish_vk_extension_structs.h"
#include "goldfish_vk_private_defs.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
void handlemap_extension_struct(VulkanHandleMapping* handlemap, void* structExtension_out);
@@ -10574,4 +10575,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.h b/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.h
index bc2d79c..65f2989 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_handlemap.h
@@ -36,7 +36,9 @@
#include "vk_android_native_buffer.h"
#include "vulkan_gfxstream.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
#ifdef VK_VERSION_1_0
void handlemap_VkExtent2D(VulkanHandleMapping* handlemap, VkExtent2D* toMap);
@@ -2999,4 +3001,5 @@
#endif
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.cpp
index 982106d..e1a2247 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.cpp
@@ -36,7 +36,8 @@
#include "goldfish_vk_extension_structs.h"
#include "goldfish_vk_private_defs.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
void marshal_extension_struct(VulkanStream* vkStream, VkStructureType rootType,
const void* structExtension);
@@ -40942,4 +40943,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.h b/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.h
index a6f4827..e390da2 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_marshaling.h
@@ -37,7 +37,9 @@
#include "vk_android_native_buffer.h"
#include "vulkan_gfxstream.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
#ifdef VK_VERSION_1_0
void marshal_VkExtent2D(VulkanStream* vkStream, VkStructureType rootType,
const VkExtent2D* forMarshaling);
@@ -6947,4 +6949,5 @@
#define OP_vkFirst 200000000
#define OP_vkLast 300000000
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.cpp
index ff4364e..87d4904 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.cpp
@@ -36,7 +36,8 @@
#include "goldfish_vk_extension_structs.h"
#include "goldfish_vk_private_defs.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
void reservedmarshal_extension_struct(VulkanStream* vkStream, VkStructureType rootType,
const void* structExtension, uint8_t** ptr);
@@ -28919,4 +28920,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.h b/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.h
index 0f44245..e8c04bb 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_reserved_marshaling.h
@@ -37,7 +37,9 @@
#include "vk_android_native_buffer.h"
#include "vulkan_gfxstream.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
#ifdef VK_VERSION_1_0
void reservedunmarshal_VkExtent2D(VulkanStream* vkStream, VkStructureType rootType,
VkExtent2D* forUnmarshaling, uint8_t** ptr);
@@ -3799,4 +3801,5 @@
#endif
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_testing.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_testing.cpp
index 64ac323..0f6c7dc 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_testing.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_testing.cpp
@@ -36,7 +36,8 @@
#include "goldfish_vk_extension_structs.h"
#include "goldfish_vk_private_defs.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
void checkEqual_extension_struct(const void* structExtension, const void* structExtension2,
OnFailCompareFunc onFail);
@@ -21015,4 +21016,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_testing.h b/stream-servers/vulkan/cereal/common/goldfish_vk_testing.h
index cb352af..b0cf026 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_testing.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_testing.h
@@ -39,7 +39,9 @@
#include "vulkan_gfxstream.h"
using OnFailCompareFunc = std::function<void(const char*)>;
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
#ifdef VK_VERSION_1_0
void checkEqual_VkExtent2D(const VkExtent2D* a, const VkExtent2D* b, OnFailCompareFunc onFail);
@@ -3687,4 +3689,5 @@
#endif
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_transform.cpp b/stream-servers/vulkan/cereal/common/goldfish_vk_transform.cpp
index 85c07c7..c251329 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_transform.cpp
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_transform.cpp
@@ -33,7 +33,8 @@
#include "VkDecoderGlobalState.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
void transform_tohost_extension_struct(VkDecoderGlobalState* resourceTracker,
void* structExtension_out);
@@ -21206,4 +21207,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/cereal/common/goldfish_vk_transform.h b/stream-servers/vulkan/cereal/common/goldfish_vk_transform.h
index b8584cd..4f27087 100644
--- a/stream-servers/vulkan/cereal/common/goldfish_vk_transform.h
+++ b/stream-servers/vulkan/cereal/common/goldfish_vk_transform.h
@@ -36,7 +36,9 @@
#include "vk_android_native_buffer.h"
#include "vulkan_gfxstream.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
+
class VkDecoderGlobalState;
#define LIST_TRIVIAL_TRANSFORMED_TYPES(f) \
f(VkPhysicalDeviceExternalImageFormatInfo) \
@@ -6032,4 +6034,5 @@
#endif
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/emulated_textures/AstcTexture.cpp b/stream-servers/vulkan/emulated_textures/AstcTexture.cpp
index a942958..5057ad7 100644
--- a/stream-servers/vulkan/emulated_textures/AstcTexture.cpp
+++ b/stream-servers/vulkan/emulated_textures/AstcTexture.cpp
@@ -24,7 +24,8 @@
#include "host-common/logging.h"
#include "stream-servers/vulkan/vk_util.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
namespace {
using std::chrono::milliseconds;
@@ -257,4 +258,5 @@
}
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/emulated_textures/AstcTexture.h b/stream-servers/vulkan/emulated_textures/AstcTexture.h
index 4af34f4..6b491a7 100644
--- a/stream-servers/vulkan/emulated_textures/AstcTexture.h
+++ b/stream-servers/vulkan/emulated_textures/AstcTexture.h
@@ -18,7 +18,8 @@
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
#include "vulkan/vulkan.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
// Holds the resources necessary to perform CPU ASTC decompression of a single texture.
class AstcTexture {
@@ -58,4 +59,5 @@
AstcCpuDecompressor* mDecompressor;
};
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/emulated_textures/CompressedImageInfo.cpp b/stream-servers/vulkan/emulated_textures/CompressedImageInfo.cpp
index 4b398eb..0110103 100644
--- a/stream-servers/vulkan/emulated_textures/CompressedImageInfo.cpp
+++ b/stream-servers/vulkan/emulated_textures/CompressedImageInfo.cpp
@@ -18,8 +18,8 @@
#include "stream-servers/vulkan/VkFormatUtils.h"
#include "stream-servers/vulkan/emulated_textures/shaders/DecompressionShaders.h"
-namespace goldfish_vk {
-
+namespace gfxstream {
+namespace vk {
namespace {
#define _RETURN_ON_FAILURE(cmd) \
@@ -157,7 +157,7 @@
// Note the potential integer overflow for large numbers.
inline constexpr uint32_t ceil_div(uint32_t x, uint32_t y) { return (x + y - 1) / y; }
-VkImageView createDefaultImageView(goldfish_vk::VulkanDispatch* vk, VkDevice device, VkImage image,
+VkImageView createDefaultImageView(VulkanDispatch* vk, VkDevice device, VkImage image,
VkFormat format, VkImageType imageType, uint32_t mipLevel,
uint32_t layerCount) {
VkImageViewCreateInfo imageViewInfo = {};
@@ -462,7 +462,7 @@
return result;
}
-void CompressedImageInfo::createCompressedMipmapImages(goldfish_vk::VulkanDispatch* vk,
+void CompressedImageInfo::createCompressedMipmapImages(VulkanDispatch* vk,
const VkImageCreateInfo& createInfo) {
if (!mCompressedMipmaps.empty()) {
return;
@@ -505,8 +505,7 @@
mBlock.height, &AstcCpuDecompressor::get());
}
-bool CompressedImageInfo::decompressIfNeeded(goldfish_vk::VulkanDispatch* vk,
- VkCommandBuffer commandBuffer,
+bool CompressedImageInfo::decompressIfNeeded(VulkanDispatch* vk, VkCommandBuffer commandBuffer,
VkPipelineStageFlags srcStageMask,
VkPipelineStageFlags dstStageMask,
const VkImageMemoryBarrier& targetBarrier,
@@ -578,8 +577,7 @@
};
}
-VkResult CompressedImageInfo::bindCompressedMipmapsMemory(goldfish_vk::VulkanDispatch* vk,
- VkDeviceMemory memory,
+VkResult CompressedImageInfo::bindCompressedMipmapsMemory(VulkanDispatch* vk, VkDeviceMemory memory,
VkDeviceSize memoryOffset) {
VkResult result = VK_SUCCESS;
for (size_t i = 0; i < mCompressedMipmaps.size(); i++) {
@@ -643,7 +641,7 @@
vk->vkDestroyImage(mDevice, mDecompressedImage, nullptr);
}
-VkDeviceSize CompressedImageInfo::getImageSize(goldfish_vk::VulkanDispatch* vk, VkImage image) {
+VkDeviceSize CompressedImageInfo::getImageSize(VulkanDispatch* vk, VkImage image) {
VkMemoryRequirements memRequirements;
vk->vkGetImageMemoryRequirements(mDevice, image, &memRequirements);
mAlignment = std::max(mAlignment, memRequirements.alignment);
@@ -685,8 +683,7 @@
return result;
}
-VkResult CompressedImageInfo::initializeDecompressionPipeline(goldfish_vk::VulkanDispatch* vk,
- VkDevice device) {
+VkResult CompressedImageInfo::initializeDecompressionPipeline(VulkanDispatch* vk, VkDevice device) {
if (mDecompPipeline != nullptr) {
return VK_SUCCESS;
}
@@ -829,7 +826,7 @@
return VK_SUCCESS;
}
-void CompressedImageInfo::decompress(goldfish_vk::VulkanDispatch* vk, VkCommandBuffer commandBuffer,
+void CompressedImageInfo::decompress(VulkanDispatch* vk, VkCommandBuffer commandBuffer,
const VkImageSubresourceRange& range) {
vk->vkCmdBindPipeline(commandBuffer, VK_PIPELINE_BIND_POINT_COMPUTE, mDecompPipeline);
uint32_t dispatchZ = mExtent.depth == 1 ? range.layerCount : mExtent.depth;
@@ -897,4 +894,5 @@
};
}
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/emulated_textures/CompressedImageInfo.h b/stream-servers/vulkan/emulated_textures/CompressedImageInfo.h
index ac9ea1a..88e3c7b 100644
--- a/stream-servers/vulkan/emulated_textures/CompressedImageInfo.h
+++ b/stream-servers/vulkan/emulated_textures/CompressedImageInfo.h
@@ -23,7 +23,8 @@
#include "vulkan/cereal/common/goldfish_vk_dispatch.h"
#include "vulkan/vulkan.h"
-namespace goldfish_vk {
+namespace gfxstream {
+namespace vk {
class CompressedImageInfo {
public:
@@ -60,8 +61,7 @@
VkImageCreateInfo getDecompressedCreateInfo(const VkImageCreateInfo& createInfo) const;
// Creates the compressed mipmap images, that is the VkImages holding the compressed data
- void createCompressedMipmapImages(goldfish_vk::VulkanDispatch* vk,
- const VkImageCreateInfo& createInfo);
+ void createCompressedMipmapImages(VulkanDispatch* vk, const VkImageCreateInfo& createInfo);
// Initializes the resources needed to perform CPU decompression of ASTC textures
void initAstcCpuDecompression(VulkanDispatch* vk, VkPhysicalDevice physicalDevice);
@@ -73,7 +73,7 @@
// outputBarriers: any barrier that needs to be passed to the vkCmdPipelineBarrier call will be
// added to this vector.
// Returns whether image decompression happened.
- bool decompressIfNeeded(goldfish_vk::VulkanDispatch* vk, VkCommandBuffer commandBuffer,
+ bool decompressIfNeeded(VulkanDispatch* vk, VkCommandBuffer commandBuffer,
VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask,
const VkImageMemoryBarrier& targetBarrier,
std::vector<VkImageMemoryBarrier>& outputBarriers);
@@ -84,7 +84,7 @@
VkMemoryRequirements getMemoryRequirements() const;
- VkResult bindCompressedMipmapsMemory(goldfish_vk::VulkanDispatch* vk, VkDeviceMemory memory,
+ VkResult bindCompressedMipmapsMemory(VulkanDispatch* vk, VkDeviceMemory memory,
VkDeviceSize memoryOffset);
// Given a VkBufferImageCopy object for the original image, returns a new
@@ -110,7 +110,7 @@
private:
// Returns the size in bytes needed for the storage of a given image.
// Also updates the alignment field of this class.
- VkDeviceSize getImageSize(goldfish_vk::VulkanDispatch* vk, VkImage image);
+ VkDeviceSize getImageSize(VulkanDispatch* vk, VkImage image);
// Returns a vector of image barriers for the compressed mipmap images and the decompressed
// image.
@@ -120,10 +120,10 @@
// Initializes the compute shader pipeline to decompress the image.
// No-op if this was already called successfully.
- VkResult initializeDecompressionPipeline(goldfish_vk::VulkanDispatch* vk, VkDevice device);
+ VkResult initializeDecompressionPipeline(VulkanDispatch* vk, VkDevice device);
// Runs the decompression shader
- void decompress(goldfish_vk::VulkanDispatch* vk, VkCommandBuffer commandBuffer,
+ void decompress(VulkanDispatch* vk, VkCommandBuffer commandBuffer,
const VkImageSubresourceRange& range);
// Returns the size of the image at a given mip level
@@ -175,4 +175,5 @@
std::vector<VkImageView> mDecompImageViews;
};
-} // namespace goldfish_vk
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/emulated_textures/shaders/DecompressionShaders.h b/stream-servers/vulkan/emulated_textures/shaders/DecompressionShaders.h
index a96e56f..f720f40 100644
--- a/stream-servers/vulkan/emulated_textures/shaders/DecompressionShaders.h
+++ b/stream-servers/vulkan/emulated_textures/shaders/DecompressionShaders.h
@@ -12,7 +12,9 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-namespace goldfish_vk::decompression_shaders {
+namespace gfxstream {
+namespace vk {
+namespace decompression_shaders {
// Compiled code of the image decompression shaders
//
@@ -83,4 +85,6 @@
#include "compiled/Etc2RGBA8_3D.inl"
};
-} // namespace goldfish_vk::decompression_shaders
+} // namespace decompression_shaders
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/testing/VkDecoderTestDispatch.h b/stream-servers/vulkan/testing/VkDecoderTestDispatch.h
index 72419f6..a38ff8d 100644
--- a/stream-servers/vulkan/testing/VkDecoderTestDispatch.h
+++ b/stream-servers/vulkan/testing/VkDecoderTestDispatch.h
@@ -18,7 +18,9 @@
#include "stream-servers/vulkan/cereal/common/goldfish_vk_dispatch.h"
#include "vulkan/vulkan.h"
-namespace goldfish_vk::testing {
+namespace gfxstream {
+namespace vk {
+namespace testing {
// TODO(gregschlom): This class should be auto-generated
class VkDecoderTestDispatch {
@@ -288,4 +290,6 @@
VkDecoderContext* mDecoderContext;
};
-} // namespace goldfish_vk::testing
\ No newline at end of file
+} // namespace testing
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/testing/VulkanTestHelper.cpp b/stream-servers/vulkan/testing/VulkanTestHelper.cpp
index 96582d4..c210cd4 100644
--- a/stream-servers/vulkan/testing/VulkanTestHelper.cpp
+++ b/stream-servers/vulkan/testing/VulkanTestHelper.cpp
@@ -19,7 +19,9 @@
#include "host-common/logging.h"
#include "host-common/vm_operations.h"
-namespace goldfish_vk::testing {
+namespace gfxstream {
+namespace vk {
+namespace testing {
namespace {
using ::android::base::BumpPool;
@@ -43,7 +45,7 @@
VulkanTestHelper::VulkanTestHelper()
: mLock(mMutex),
- mVk(emugl::vkDispatch(/*forTesting=*/true)),
+ mVk(vkDispatch(/*forTesting=*/true)),
mLogger(),
mMetricsLogger(android::base::CreateMetricsLogger()),
mHealthMonitor(*mMetricsLogger),
@@ -340,4 +342,6 @@
&barrier);
}
-} // namespace goldfish_vk::testing
+} // namespace testing
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/testing/VulkanTestHelper.h b/stream-servers/vulkan/testing/VulkanTestHelper.h
index 6606cb3..d3c3edc 100644
--- a/stream-servers/vulkan/testing/VulkanTestHelper.h
+++ b/stream-servers/vulkan/testing/VulkanTestHelper.h
@@ -24,7 +24,9 @@
#include "stream-servers/vulkan/testing/VkDecoderTestDispatch.h"
#include "utils/include/utils/GfxApiLogger.h"
-namespace goldfish_vk::testing {
+namespace gfxstream {
+namespace vk {
+namespace testing {
// This class provides facilities to write tests that call into the Vulkan API through VkDecoder and
// VkDecoderGlobalState.
@@ -115,4 +117,6 @@
VkDebugUtilsMessengerEXT mDebugMessenger = VK_NULL_HANDLE;
};
-} // namespace goldfish_vk::testing
+} // namespace testing
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/vk_fn_info.h b/stream-servers/vulkan/vk_fn_info.h
index 11c61b9..a44fb8d 100644
--- a/stream-servers/vulkan/vk_fn_info.h
+++ b/stream-servers/vulkan/vk_fn_info.h
@@ -20,6 +20,8 @@
#include <initializer_list>
#include <tuple>
+namespace gfxstream {
+namespace vk {
namespace vk_util {
namespace vk_fn_info {
template <class T>
@@ -40,7 +42,10 @@
"vkGetPhysicalDeviceImageFormatProperties2"))
REGISTER_VK_FN_INFO(GetPhysicalDeviceFeatures2,
("vkGetPhysicalDeviceFeatures2", "vkGetPhysicalDeviceFeatures2KHR"));
+
} // namespace vk_fn_info
} // namespace vk_util
+} // namespace vk
+} // namespace gfxstream
#endif /* VK_FN_INFO_H */
diff --git a/stream-servers/vulkan/vk_format_info.h b/stream-servers/vulkan/vk_format_info.h
index e9b41ba..ad10df2 100644
--- a/stream-servers/vulkan/vk_format_info.h
+++ b/stream-servers/vulkan/vk_format_info.h
@@ -30,6 +30,9 @@
#include <vndk/hardware_buffer.h>
#include <vulkan/vulkan.h>
+namespace gfxstream {
+namespace vk {
+
/* See i915_private_android_types.h in minigbm. */
#define HAL_PIXEL_FORMAT_NV12_Y_TILED_INTEL 0x100
@@ -135,4 +138,7 @@
return aspects & VK_IMAGE_ASPECT_DEPTH_BIT;
}
+} // namespace vk
+} // namespace gfxstream
+
#endif /* VK_FORMAT_INFO_H */
\ No newline at end of file
diff --git a/stream-servers/vulkan/vk_util.cpp b/stream-servers/vulkan/vk_util.cpp
index 0e715f5..096f03a 100644
--- a/stream-servers/vulkan/vk_util.cpp
+++ b/stream-servers/vulkan/vk_util.cpp
@@ -16,6 +16,8 @@
#include "vk_util.h"
+namespace gfxstream {
+namespace vk {
namespace vk_util {
namespace {
@@ -45,3 +47,5 @@
}
} // namespace vk_util
+} // namespace vk
+} // namespace gfxstream
diff --git a/stream-servers/vulkan/vk_util.h b/stream-servers/vulkan/vk_util.h
index 312a8eb..ba7f9ea 100644
--- a/stream-servers/vulkan/vk_util.h
+++ b/stream-servers/vulkan/vk_util.h
@@ -48,6 +48,9 @@
#include "vk_fn_info.h"
#include "vulkan/cereal/common/vk_struct_id.h"
+namespace gfxstream {
+namespace vk {
+
struct vk_struct_common {
VkStructureType sType;
struct vk_struct_common* pNext;
@@ -274,34 +277,34 @@
}
}
-#define VK_CHECK(x) \
- do { \
- VkResult err = x; \
- if (err != VK_SUCCESS) { \
- if (err == VK_ERROR_DEVICE_LOST) { \
- ::vk_util::getVkCheckCallbacks().callIfExists( \
- &::vk_util::VkCheckCallbacks::onVkErrorDeviceLost); \
- } \
- if (err == VK_ERROR_OUT_OF_HOST_MEMORY || err == VK_ERROR_OUT_OF_DEVICE_MEMORY || \
- err == VK_ERROR_OUT_OF_POOL_MEMORY) { \
- ::vk_util::getVkCheckCallbacks().callIfExists( \
- &::vk_util::VkCheckCallbacks::onVkErrorOutOfMemory, err, __func__, __LINE__); \
- } \
- GFXSTREAM_ABORT(::emugl::FatalError(err)); \
- } \
+#define VK_CHECK(x) \
+ do { \
+ VkResult err = x; \
+ if (err != VK_SUCCESS) { \
+ if (err == VK_ERROR_DEVICE_LOST) { \
+ vk_util::getVkCheckCallbacks().callIfExists( \
+ &vk_util::VkCheckCallbacks::onVkErrorDeviceLost); \
+ } \
+ if (err == VK_ERROR_OUT_OF_HOST_MEMORY || err == VK_ERROR_OUT_OF_DEVICE_MEMORY || \
+ err == VK_ERROR_OUT_OF_POOL_MEMORY) { \
+ vk_util::getVkCheckCallbacks().callIfExists( \
+ &vk_util::VkCheckCallbacks::onVkErrorOutOfMemory, err, __func__, __LINE__); \
+ } \
+ GFXSTREAM_ABORT(::emugl::FatalError(err)); \
+ } \
} while (0)
-#define VK_CHECK_MEMALLOC(x, allocateInfo) \
- do { \
- VkResult err = x; \
- if (err != VK_SUCCESS) { \
- if (err == VK_ERROR_OUT_OF_HOST_MEMORY || err == VK_ERROR_OUT_OF_DEVICE_MEMORY) { \
- ::vk_util::getVkCheckCallbacks().callIfExists( \
- &::vk_util::VkCheckCallbacks::onVkErrorOutOfMemoryOnAllocation, err, __func__, \
- __LINE__, allocateInfo.allocationSize); \
- } \
- GFXSTREAM_ABORT(::emugl::FatalError(err)); \
- } \
+#define VK_CHECK_MEMALLOC(x, allocateInfo) \
+ do { \
+ VkResult err = x; \
+ if (err != VK_SUCCESS) { \
+ if (err == VK_ERROR_OUT_OF_HOST_MEMORY || err == VK_ERROR_OUT_OF_DEVICE_MEMORY) { \
+ vk_util::getVkCheckCallbacks().callIfExists( \
+ &vk_util::VkCheckCallbacks::onVkErrorOutOfMemoryOnAllocation, err, __func__, \
+ __LINE__, allocateInfo.allocationSize); \
+ } \
+ GFXSTREAM_ABORT(::emugl::FatalError(err)); \
+ } \
} while (0)
typedef void* MTLTextureRef;
@@ -494,6 +497,9 @@
}
return nullptr;
}
+
} // namespace vk_util
+} // namespace vk
+} // namespace gfxstream
#endif /* VK_UTIL_H */
diff --git a/stream-servers/vulkan/vk_util_unittest.cpp b/stream-servers/vulkan/vk_util_unittest.cpp
index 3d6105a..d723872 100644
--- a/stream-servers/vulkan/vk_util_unittest.cpp
+++ b/stream-servers/vulkan/vk_util_unittest.cpp
@@ -21,6 +21,8 @@
#include <tuple>
+namespace gfxstream {
+namespace vk {
namespace vk_util {
namespace vk_fn_info {
@@ -261,3 +263,5 @@
} // namespace
} // namespace vk_fn_info
} // namespace vk_util
+} // namespace vk
+} // namespace gfxstream