Commit 1552d4d6 by Emircan Uysaler Committed by Commit Bot

Move to NewCreateImagePipe2Cmd

Bug: angleproject:3905 Change-Id: Id237c049848077acee8eaf491f7aada636764290 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1802535Reviewed-by: 's avatarMichael Spang <spang@chromium.org> Commit-Queue: Michael Spang <spang@chromium.org>
parent b1580a27
......@@ -1111,6 +1111,7 @@ foreach(is_shared_library,
if (is_fuchsia) {
sources += util_fuchsia_sources
public_deps += [
":angle_vulkan",
"$angle_root/src/common/fuchsia_egl",
"//third_party/fuchsia-sdk/sdk:async_loop_cpp",
"//third_party/fuchsia-sdk/sdk:async_loop_default",
......
......@@ -18,6 +18,7 @@
#include <lib/fidl/cpp/interface_request.h>
#include <lib/ui/scenic/cpp/view_token_pair.h>
#include <lib/zx/channel.h>
#include <vulkan/vulkan.h>
#include <zircon/status.h>
#include "common/debug.h"
......@@ -25,6 +26,36 @@
namespace
{
uint32_t GetImagePipeSwapchainLayerImplementationVersion()
{
uint32_t numInstanceLayers = 0;
VkResult result = vkEnumerateInstanceLayerProperties(&numInstanceLayers, nullptr);
if (result != VK_SUCCESS)
{
return 0u;
}
std::vector<VkLayerProperties> instanceLayers(numInstanceLayers);
result = vkEnumerateInstanceLayerProperties(&numInstanceLayers, instanceLayers.data());
if (result != VK_SUCCESS)
{
return 0u;
}
uint32_t imagePipeSwapchainImplementationVersion = 0;
const std::string layerName = "VK_LAYER_FUCHSIA_imagepipe_swapchain";
for (const VkLayerProperties &layerProperty : instanceLayers)
{
if (layerName.compare(layerProperty.layerName) != 0)
continue;
imagePipeSwapchainImplementationVersion = layerProperty.implementationVersion;
break;
}
ASSERT(imagePipeSwapchainImplementationVersion > 0u);
return imagePipeSwapchainImplementationVersion;
}
async::Loop *GetDefaultLoop()
{
static async::Loop *defaultLoop = new async::Loop(&kAsyncLoopConfigAttachToCurrentThread);
......@@ -107,15 +138,25 @@ void ScenicWindow::destroy()
void ScenicWindow::resetNativeWindow()
{
fuchsia::images::ImagePipePtr imagePipe;
uint32_t imagePipeId = mScenicSession.AllocResourceId();
mScenicSession.Enqueue(scenic::NewCreateImagePipeCmd(imagePipeId, imagePipe.NewRequest()));
zx_handle_t imagePipeHandle = 0;
uint32_t imagePipeId = mScenicSession.AllocResourceId();
if (GetImagePipeSwapchainLayerImplementationVersion() > 1u)
{
fuchsia::images::ImagePipe2Ptr imagePipe;
mScenicSession.Enqueue(scenic::NewCreateImagePipe2Cmd(imagePipeId, imagePipe.NewRequest()));
imagePipeHandle = imagePipe.Unbind().TakeChannel().release();
}
else
{
fuchsia::images::ImagePipePtr imagePipe;
mScenicSession.Enqueue(scenic::NewCreateImagePipeCmd(imagePipeId, imagePipe.NewRequest()));
imagePipeHandle = imagePipe.Unbind().TakeChannel().release();
}
mMaterial.SetTexture(imagePipeId);
mScenicSession.ReleaseResource(imagePipeId);
mScenicSession.Present(0, [](fuchsia::images::PresentationInfo info) {});
mFuchsiaEGLWindow.reset(
fuchsia_egl_window_create(imagePipe.Unbind().TakeChannel().release(), mWidth, mHeight));
mFuchsiaEGLWindow.reset(fuchsia_egl_window_create(imagePipeHandle, mWidth, mHeight));
}
EGLNativeWindowType ScenicWindow::getNativeWindow() const
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment