Commit 5883a44b by Jamie Madill Committed by Commit Bot

Vulkan: Don't pass width/height to Surface constructors.

These values are accessible already from the Surface state. Sometimes they don't apply (e.g. GGP). Remove them to keep the code clearer. Updates the offscreen surface constructor to pull width and height from the attributes map instead of using parameters. Otherwise they weren't used. Refactoring change only. Bug: angleproject:4078 Change-Id: I9e49eadc7116562f62bd8d11342d6b8835376719 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1895762Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 2f6a9afd
...@@ -98,21 +98,14 @@ SurfaceImpl *DisplayVk::createWindowSurface(const egl::SurfaceState &state, ...@@ -98,21 +98,14 @@ SurfaceImpl *DisplayVk::createWindowSurface(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
EGLint width = attribs.getAsInt(EGL_WIDTH, 0); return createWindowSurfaceVk(state, window);
EGLint height = attribs.getAsInt(EGL_HEIGHT, 0);
return createWindowSurfaceVk(state, window, width, height);
} }
SurfaceImpl *DisplayVk::createPbufferSurface(const egl::SurfaceState &state, SurfaceImpl *DisplayVk::createPbufferSurface(const egl::SurfaceState &state,
const egl::AttributeMap &attribs) const egl::AttributeMap &attribs)
{ {
ASSERT(mRenderer); ASSERT(mRenderer);
return new OffscreenSurfaceVk(state);
EGLint width = attribs.getAsInt(EGL_WIDTH, 0);
EGLint height = attribs.getAsInt(EGL_HEIGHT, 0);
return new OffscreenSurfaceVk(state, width, height);
} }
SurfaceImpl *DisplayVk::createPbufferFromClientBuffer(const egl::SurfaceState &state, SurfaceImpl *DisplayVk::createPbufferFromClientBuffer(const egl::SurfaceState &state,
......
...@@ -97,9 +97,7 @@ class DisplayVk : public DisplayImpl, public vk::Context ...@@ -97,9 +97,7 @@ class DisplayVk : public DisplayImpl, public vk::Context
private: private:
virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, virtual SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window) = 0;
EGLint width,
EGLint height) = 0;
void generateExtensions(egl::DisplayExtensions *outExtensions) const override; void generateExtensions(egl::DisplayExtensions *outExtensions) const override;
void generateCaps(egl::Caps *outCaps) const override; void generateCaps(egl::Caps *outCaps) const override;
......
...@@ -167,10 +167,10 @@ void OffscreenSurfaceVk::AttachmentImage::destroy(const egl::Display *display) ...@@ -167,10 +167,10 @@ void OffscreenSurfaceVk::AttachmentImage::destroy(const egl::Display *display)
imageViews.destroy(device); imageViews.destroy(device);
} }
OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState, OffscreenSurfaceVk::OffscreenSurfaceVk(const egl::SurfaceState &surfaceState)
EGLint width, : SurfaceVk(surfaceState),
EGLint height) mWidth(mState.attributes.getAsInt(EGL_WIDTH, 0)),
: SurfaceVk(surfaceState), mWidth(width), mHeight(height) mHeight(mState.attributes.getAsInt(EGL_HEIGHT, 0))
{ {
mColorRenderTarget.init(&mColorAttachment.image, &mColorAttachment.imageViews, 0, 0); mColorRenderTarget.init(&mColorAttachment.image, &mColorAttachment.imageViews, 0, 0);
mDepthStencilRenderTarget.init(&mDepthStencilAttachment.image, mDepthStencilRenderTarget.init(&mDepthStencilAttachment.image,
...@@ -387,10 +387,7 @@ angle::Result SwapHistory::waitFence(ContextVk *contextVk) ...@@ -387,10 +387,7 @@ angle::Result SwapHistory::waitFence(ContextVk *contextVk)
using namespace impl; using namespace impl;
WindowSurfaceVk::WindowSurfaceVk(const egl::SurfaceState &surfaceState, WindowSurfaceVk::WindowSurfaceVk(const egl::SurfaceState &surfaceState, EGLNativeWindowType window)
EGLNativeWindowType window,
EGLint width,
EGLint height)
: SurfaceVk(surfaceState), : SurfaceVk(surfaceState),
mNativeWindowType(window), mNativeWindowType(window),
mSurface(VK_NULL_HANDLE), mSurface(VK_NULL_HANDLE),
......
...@@ -40,7 +40,7 @@ class SurfaceVk : public SurfaceImpl ...@@ -40,7 +40,7 @@ class SurfaceVk : public SurfaceImpl
class OffscreenSurfaceVk : public SurfaceVk class OffscreenSurfaceVk : public SurfaceVk
{ {
public: public:
OffscreenSurfaceVk(const egl::SurfaceState &surfaceState, EGLint width, EGLint height); OffscreenSurfaceVk(const egl::SurfaceState &surfaceState);
~OffscreenSurfaceVk() override; ~OffscreenSurfaceVk() override;
egl::Error initialize(const egl::Display *display) override; egl::Error initialize(const egl::Display *display) override;
...@@ -175,10 +175,7 @@ struct SwapchainImage : angle::NonCopyable ...@@ -175,10 +175,7 @@ struct SwapchainImage : angle::NonCopyable
class WindowSurfaceVk : public SurfaceVk class WindowSurfaceVk : public SurfaceVk
{ {
public: public:
WindowSurfaceVk(const egl::SurfaceState &surfaceState, WindowSurfaceVk(const egl::SurfaceState &surfaceState, EGLNativeWindowType window);
EGLNativeWindowType window,
EGLint width,
EGLint height);
~WindowSurfaceVk() override; ~WindowSurfaceVk() override;
void destroy(const egl::Display *display) override; void destroy(const egl::Display *display) override;
......
...@@ -42,11 +42,9 @@ bool DisplayVkAndroid::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -42,11 +42,9 @@ bool DisplayVkAndroid::isValidNativeWindow(EGLNativeWindowType window) const
} }
SurfaceImpl *DisplayVkAndroid::createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *DisplayVkAndroid::createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window)
EGLint width,
EGLint height)
{ {
return new WindowSurfaceVkAndroid(state, window, width, height); return new WindowSurfaceVkAndroid(state, window);
} }
egl::ConfigSet DisplayVkAndroid::generateConfigs() egl::ConfigSet DisplayVkAndroid::generateConfigs()
......
...@@ -24,9 +24,7 @@ class DisplayVkAndroid : public DisplayVk ...@@ -24,9 +24,7 @@ class DisplayVkAndroid : public DisplayVk
bool isValidNativeWindow(EGLNativeWindowType window) const override; bool isValidNativeWindow(EGLNativeWindowType window) const override;
SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window) override;
EGLint width,
EGLint height) override;
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override; bool checkConfigSupport(egl::Config *config) override;
......
...@@ -17,10 +17,8 @@ namespace rx ...@@ -17,10 +17,8 @@ namespace rx
{ {
WindowSurfaceVkAndroid::WindowSurfaceVkAndroid(const egl::SurfaceState &surfaceState, WindowSurfaceVkAndroid::WindowSurfaceVkAndroid(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window, EGLNativeWindowType window)
EGLint width, : WindowSurfaceVk(surfaceState, window)
EGLint height)
: WindowSurfaceVk(surfaceState, window, width, height)
{} {}
angle::Result WindowSurfaceVkAndroid::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) angle::Result WindowSurfaceVkAndroid::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
......
...@@ -18,10 +18,7 @@ namespace rx ...@@ -18,10 +18,7 @@ namespace rx
class WindowSurfaceVkAndroid : public WindowSurfaceVk class WindowSurfaceVkAndroid : public WindowSurfaceVk
{ {
public: public:
WindowSurfaceVkAndroid(const egl::SurfaceState &surfaceState, WindowSurfaceVkAndroid(const egl::SurfaceState &surfaceState, EGLNativeWindowType window);
EGLNativeWindowType window,
EGLint width,
EGLint height);
private: private:
angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override; angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override;
......
...@@ -23,12 +23,10 @@ bool DisplayVkFuchsia::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -23,12 +23,10 @@ bool DisplayVkFuchsia::isValidNativeWindow(EGLNativeWindowType window) const
} }
SurfaceImpl *DisplayVkFuchsia::createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *DisplayVkFuchsia::createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window)
EGLint width,
EGLint height)
{ {
ASSERT(isValidNativeWindow(window)); ASSERT(isValidNativeWindow(window));
return new WindowSurfaceVkFuchsia(state, window, width, height); return new WindowSurfaceVkFuchsia(state, window);
} }
egl::ConfigSet DisplayVkFuchsia::generateConfigs() egl::ConfigSet DisplayVkFuchsia::generateConfigs()
......
...@@ -23,9 +23,7 @@ class DisplayVkFuchsia : public DisplayVk ...@@ -23,9 +23,7 @@ class DisplayVkFuchsia : public DisplayVk
bool isValidNativeWindow(EGLNativeWindowType window) const override; bool isValidNativeWindow(EGLNativeWindowType window) const override;
SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window) override;
EGLint width,
EGLint height) override;
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override; bool checkConfigSupport(egl::Config *config) override;
......
...@@ -21,10 +21,8 @@ namespace rx ...@@ -21,10 +21,8 @@ namespace rx
{ {
WindowSurfaceVkFuchsia::WindowSurfaceVkFuchsia(const egl::SurfaceState &surfaceState, WindowSurfaceVkFuchsia::WindowSurfaceVkFuchsia(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window, EGLNativeWindowType window)
EGLint width, : WindowSurfaceVk(surfaceState, window)
EGLint height)
: WindowSurfaceVk(surfaceState, window, width, height)
{} {}
WindowSurfaceVkFuchsia::~WindowSurfaceVkFuchsia() {} WindowSurfaceVkFuchsia::~WindowSurfaceVkFuchsia() {}
......
...@@ -18,10 +18,7 @@ namespace rx ...@@ -18,10 +18,7 @@ namespace rx
class WindowSurfaceVkFuchsia : public WindowSurfaceVk class WindowSurfaceVkFuchsia : public WindowSurfaceVk
{ {
public: public:
WindowSurfaceVkFuchsia(const egl::SurfaceState &surfaceState, WindowSurfaceVkFuchsia(const egl::SurfaceState &surfaceState, EGLNativeWindowType window);
EGLNativeWindowType window,
EGLint width,
EGLint height);
~WindowSurfaceVkFuchsia() override; ~WindowSurfaceVkFuchsia() override;
static bool isValidNativeWindow(EGLNativeWindowType window); static bool isValidNativeWindow(EGLNativeWindowType window);
......
...@@ -25,11 +25,9 @@ bool DisplayVkWin32::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -25,11 +25,9 @@ bool DisplayVkWin32::isValidNativeWindow(EGLNativeWindowType window) const
} }
SurfaceImpl *DisplayVkWin32::createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *DisplayVkWin32::createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window)
EGLint width,
EGLint height)
{ {
return new WindowSurfaceVkWin32(state, window, width, height); return new WindowSurfaceVkWin32(state, window);
} }
egl::ConfigSet DisplayVkWin32::generateConfigs() egl::ConfigSet DisplayVkWin32::generateConfigs()
......
...@@ -22,9 +22,7 @@ class DisplayVkWin32 : public DisplayVk ...@@ -22,9 +22,7 @@ class DisplayVkWin32 : public DisplayVk
bool isValidNativeWindow(EGLNativeWindowType window) const override; bool isValidNativeWindow(EGLNativeWindowType window) const override;
SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window) override;
EGLint width,
EGLint height) override;
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override; bool checkConfigSupport(egl::Config *config) override;
......
...@@ -15,10 +15,8 @@ namespace rx ...@@ -15,10 +15,8 @@ namespace rx
{ {
WindowSurfaceVkWin32::WindowSurfaceVkWin32(const egl::SurfaceState &surfaceState, WindowSurfaceVkWin32::WindowSurfaceVkWin32(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window, EGLNativeWindowType window)
EGLint width, : WindowSurfaceVk(surfaceState, window)
EGLint height)
: WindowSurfaceVk(surfaceState, window, width, height)
{} {}
angle::Result WindowSurfaceVkWin32::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) angle::Result WindowSurfaceVkWin32::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
......
...@@ -18,10 +18,7 @@ namespace rx ...@@ -18,10 +18,7 @@ namespace rx
class WindowSurfaceVkWin32 : public WindowSurfaceVk class WindowSurfaceVkWin32 : public WindowSurfaceVk
{ {
public: public:
WindowSurfaceVkWin32(const egl::SurfaceState &surfaceState, WindowSurfaceVkWin32(const egl::SurfaceState &surfaceState, EGLNativeWindowType window);
EGLNativeWindowType window,
EGLint width,
EGLint height);
private: private:
angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override; angle::Result createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) override;
......
...@@ -67,7 +67,7 @@ bool DisplayVkXcb::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -67,7 +67,7 @@ bool DisplayVkXcb::isValidNativeWindow(EGLNativeWindowType window) const
// window ID, but xcb_query_tree_reply will return nullptr if the window doesn't exist. // window ID, but xcb_query_tree_reply will return nullptr if the window doesn't exist.
xcb_query_tree_cookie_t cookie = xcb_query_tree_cookie_t cookie =
xcb_query_tree(mXcbConnection, static_cast<xcb_window_t>(window)); xcb_query_tree(mXcbConnection, static_cast<xcb_window_t>(window));
xcb_query_tree_reply_t *reply = xcb_query_tree_reply(mXcbConnection, cookie, nullptr); xcb_query_tree_reply_t *reply = xcb_query_tree_reply(mXcbConnection, cookie, nullptr);
if (reply) if (reply)
{ {
free(reply); free(reply);
...@@ -77,11 +77,9 @@ bool DisplayVkXcb::isValidNativeWindow(EGLNativeWindowType window) const ...@@ -77,11 +77,9 @@ bool DisplayVkXcb::isValidNativeWindow(EGLNativeWindowType window) const
} }
SurfaceImpl *DisplayVkXcb::createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *DisplayVkXcb::createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window)
EGLint width,
EGLint height)
{ {
return new WindowSurfaceVkXcb(state, window, width, height, mXcbConnection); return new WindowSurfaceVkXcb(state, window, mXcbConnection);
} }
egl::ConfigSet DisplayVkXcb::generateConfigs() egl::ConfigSet DisplayVkXcb::generateConfigs()
......
...@@ -28,9 +28,7 @@ class DisplayVkXcb : public DisplayVk ...@@ -28,9 +28,7 @@ class DisplayVkXcb : public DisplayVk
bool isValidNativeWindow(EGLNativeWindowType window) const override; bool isValidNativeWindow(EGLNativeWindowType window) const override;
SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state, SurfaceImpl *createWindowSurfaceVk(const egl::SurfaceState &state,
EGLNativeWindowType window, EGLNativeWindowType window) override;
EGLint width,
EGLint height) override;
egl::ConfigSet generateConfigs() override; egl::ConfigSet generateConfigs() override;
bool checkConfigSupport(egl::Config *config) override; bool checkConfigSupport(egl::Config *config) override;
......
...@@ -16,10 +16,8 @@ namespace rx ...@@ -16,10 +16,8 @@ namespace rx
WindowSurfaceVkXcb::WindowSurfaceVkXcb(const egl::SurfaceState &surfaceState, WindowSurfaceVkXcb::WindowSurfaceVkXcb(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window, EGLNativeWindowType window,
EGLint width,
EGLint height,
xcb_connection_t *conn) xcb_connection_t *conn)
: WindowSurfaceVk(surfaceState, window, width, height), mXcbConnection(conn) : WindowSurfaceVk(surfaceState, window), mXcbConnection(conn)
{} {}
angle::Result WindowSurfaceVkXcb::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut) angle::Result WindowSurfaceVkXcb::createSurfaceVk(vk::Context *context, gl::Extents *extentsOut)
...@@ -41,7 +39,7 @@ angle::Result WindowSurfaceVkXcb::getCurrentWindowSize(vk::Context *context, ...@@ -41,7 +39,7 @@ angle::Result WindowSurfaceVkXcb::getCurrentWindowSize(vk::Context *context,
{ {
xcb_get_geometry_cookie_t cookie = xcb_get_geometry_cookie_t cookie =
xcb_get_geometry(mXcbConnection, static_cast<xcb_drawable_t>(mNativeWindowType)); xcb_get_geometry(mXcbConnection, static_cast<xcb_drawable_t>(mNativeWindowType));
xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(mXcbConnection, cookie, nullptr); xcb_get_geometry_reply_t *reply = xcb_get_geometry_reply(mXcbConnection, cookie, nullptr);
ASSERT(reply); ASSERT(reply);
*extentsOut = gl::Extents(reply->width, reply->height, 1); *extentsOut = gl::Extents(reply->width, reply->height, 1);
free(reply); free(reply);
......
...@@ -22,8 +22,6 @@ class WindowSurfaceVkXcb : public WindowSurfaceVk ...@@ -22,8 +22,6 @@ class WindowSurfaceVkXcb : public WindowSurfaceVk
public: public:
WindowSurfaceVkXcb(const egl::SurfaceState &surfaceState, WindowSurfaceVkXcb(const egl::SurfaceState &surfaceState,
EGLNativeWindowType window, EGLNativeWindowType window,
EGLint width,
EGLint height,
xcb_connection_t *conn); xcb_connection_t *conn);
private: private:
......
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