Commit 4864413b by Xinyi He Committed by Commit Bot

Vulkan: Implement eglWaitNative function

Implement eglWaitNative API. It will call XSync() on XCB and do nothing on other systems. Bug: angleproject:4281 Change-Id: I597b75124a380df519ab10af3cab9b6e26f3194f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2059620Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 2527327a
...@@ -392,7 +392,9 @@ static constexpr uint32_t kScratchBufferLifetime = 64u; ...@@ -392,7 +392,9 @@ static constexpr uint32_t kScratchBufferLifetime = 64u;
} // anonymous namespace } // anonymous namespace
DisplayState::DisplayState() : label(nullptr), featuresAllDisabled(false) {} DisplayState::DisplayState(EGLNativeDisplayType nativeDisplayId)
: label(nullptr), featuresAllDisabled(false), displayId(nativeDisplayId)
{}
DisplayState::~DisplayState() {} DisplayState::~DisplayState() {}
...@@ -506,8 +508,8 @@ Display *Display::GetDisplayFromDevice(Device *device, const AttributeMap &attri ...@@ -506,8 +508,8 @@ Display *Display::GetDisplayFromDevice(Device *device, const AttributeMap &attri
} }
Display::Display(EGLenum platform, EGLNativeDisplayType displayId, Device *eglDevice) Display::Display(EGLenum platform, EGLNativeDisplayType displayId, Device *eglDevice)
: mImplementation(nullptr), : mState(displayId),
mDisplayId(displayId), mImplementation(nullptr),
mAttributeMap(), mAttributeMap(),
mConfigSet(), mConfigSet(),
mContextSet(), mContextSet(),
...@@ -535,7 +537,7 @@ Display::~Display() ...@@ -535,7 +537,7 @@ Display::~Display()
if (mPlatform == EGL_PLATFORM_ANGLE_ANGLE) if (mPlatform == EGL_PLATFORM_ANGLE_ANGLE)
{ {
ANGLEPlatformDisplayMap *displays = GetANGLEPlatformDisplayMap(); ANGLEPlatformDisplayMap *displays = GetANGLEPlatformDisplayMap();
ANGLEPlatformDisplayMap::iterator iter = displays->find(mDisplayId); ANGLEPlatformDisplayMap::iterator iter = displays->find(mState.displayId);
if (iter != displays->end()) if (iter != displays->end())
{ {
displays->erase(iter); displays->erase(iter);
......
...@@ -51,7 +51,7 @@ using SurfaceSet = std::set<Surface *>; ...@@ -51,7 +51,7 @@ using SurfaceSet = std::set<Surface *>;
struct DisplayState final : private angle::NonCopyable struct DisplayState final : private angle::NonCopyable
{ {
DisplayState(); DisplayState(EGLNativeDisplayType nativeDisplayId);
~DisplayState(); ~DisplayState();
EGLLabelKHR label; EGLLabelKHR label;
...@@ -59,6 +59,7 @@ struct DisplayState final : private angle::NonCopyable ...@@ -59,6 +59,7 @@ struct DisplayState final : private angle::NonCopyable
std::vector<std::string> featureOverridesEnabled; std::vector<std::string> featureOverridesEnabled;
std::vector<std::string> featureOverridesDisabled; std::vector<std::string> featureOverridesDisabled;
bool featuresAllDisabled; bool featuresAllDisabled;
EGLNativeDisplayType displayId;
}; };
// Constant coded here as a sanity limit. // Constant coded here as a sanity limit.
...@@ -187,7 +188,7 @@ class Display final : public LabeledObject, angle::NonCopyable ...@@ -187,7 +188,7 @@ class Display final : public LabeledObject, angle::NonCopyable
EGLint programCacheResize(EGLint limit, EGLenum mode); EGLint programCacheResize(EGLint limit, EGLenum mode);
const AttributeMap &getAttributeMap() const { return mAttributeMap; } const AttributeMap &getAttributeMap() const { return mAttributeMap; }
EGLNativeDisplayType getNativeDisplayId() const { return mDisplayId; } EGLNativeDisplayType getNativeDisplayId() const { return mState.displayId; }
rx::DisplayImpl *getImplementation() const { return mImplementation; } rx::DisplayImpl *getImplementation() const { return mImplementation; }
Device *getDevice() const; Device *getDevice() const;
...@@ -237,7 +238,6 @@ class Display final : public LabeledObject, angle::NonCopyable ...@@ -237,7 +238,6 @@ class Display final : public LabeledObject, angle::NonCopyable
DisplayState mState; DisplayState mState;
rx::DisplayImpl *mImplementation; rx::DisplayImpl *mImplementation;
EGLNativeDisplayType mDisplayId;
AttributeMap mAttributeMap; AttributeMap mAttributeMap;
ConfigSet mConfigSet; ConfigSet mConfigSet;
......
...@@ -92,8 +92,13 @@ egl::Error DisplayVk::waitClient(const gl::Context *context) ...@@ -92,8 +92,13 @@ egl::Error DisplayVk::waitClient(const gl::Context *context)
egl::Error DisplayVk::waitNative(const gl::Context *context, EGLint engine) egl::Error DisplayVk::waitNative(const gl::Context *context, EGLint engine)
{ {
UNIMPLEMENTED(); ANGLE_TRACE_EVENT0("gpu.angle", "DisplayVk::waitNative");
return egl::EglBadAccess(); return angle::ResultToEGL(waitNativeImpl());
}
angle::Result DisplayVk::waitNativeImpl()
{
return angle::Result::Continue;
} }
SurfaceImpl *DisplayVk::createWindowSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayVk::createWindowSurface(const egl::SurfaceState &state,
......
...@@ -103,6 +103,8 @@ class DisplayVk : public DisplayImpl, public vk::Context ...@@ -103,6 +103,8 @@ class DisplayVk : public DisplayImpl, public vk::Context
EGLNativeWindowType window) = 0; EGLNativeWindowType window) = 0;
void generateCaps(egl::Caps *outCaps) const override; void generateCaps(egl::Caps *outCaps) const override;
virtual angle::Result waitNativeImpl();
mutable angle::ScratchBuffer mScratchBuffer; mutable angle::ScratchBuffer mScratchBuffer;
std::string mStoredErrorString; std::string mStoredErrorString;
......
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include <xcb/xcb.h> #include <xcb/xcb.h>
#include "libANGLE/Display.h"
#include "libANGLE/renderer/vulkan/vk_caps_utils.h" #include "libANGLE/renderer/vulkan/vk_caps_utils.h"
#include "libANGLE/renderer/vulkan/xcb/WindowSurfaceVkXcb.h" #include "libANGLE/renderer/vulkan/xcb/WindowSurfaceVkXcb.h"
...@@ -121,4 +122,10 @@ DisplayImpl *CreateVulkanXcbDisplay(const egl::DisplayState &state) ...@@ -121,4 +122,10 @@ DisplayImpl *CreateVulkanXcbDisplay(const egl::DisplayState &state)
{ {
return new DisplayVkXcb(state); return new DisplayVkXcb(state);
} }
angle::Result DisplayVkXcb::waitNativeImpl()
{
XSync(mState.displayId, False);
return angle::Result::Continue;
}
} // namespace rx } // namespace rx
...@@ -34,6 +34,7 @@ class DisplayVkXcb : public DisplayVk ...@@ -34,6 +34,7 @@ class DisplayVkXcb : public DisplayVk
bool checkConfigSupport(egl::Config *config) override; bool checkConfigSupport(egl::Config *config) override;
const char *getWSIExtension() const override; const char *getWSIExtension() const override;
angle::Result waitNativeImpl() override;
private: private:
xcb_connection_t *mXcbConnection; xcb_connection_t *mXcbConnection;
......
...@@ -233,6 +233,17 @@ TEST_P(EGLSyncTest, BasicOperations) ...@@ -233,6 +233,17 @@ TEST_P(EGLSyncTest, BasicOperations)
EXPECT_EGL_TRUE(eglDestroySyncKHR(display, sync)); EXPECT_EGL_TRUE(eglDestroySyncKHR(display, sync));
} }
// Test eglWaitNative api
TEST_P(EGLSyncTest, WaitNative)
{
// Clear to red color
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
EXPECT_EGL_TRUE(eglWaitNative(EGL_CORE_NATIVE_ENGINE));
EXPECT_PIXEL_COLOR_EQ(getWindowWidth() / 2, getWindowHeight() / 2, GLColor::red);
}
ANGLE_INSTANTIATE_TEST(EGLSyncTest, ANGLE_INSTANTIATE_TEST(EGLSyncTest,
ES2_D3D9(), ES2_D3D9(),
ES2_D3D11(), ES2_D3D11(),
......
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