Commit f2637d0d by Jonah Ryan-Davis

Present should return OUT_OF_DATE if the window size outdated

This is the correct behavior according to the spec. This CL modifies MetalSurface, XcbSurfaceKHR and XlibSurfaceKHR. Bug: swiftshader: 140 Change-Id: I3f1829506a9d95c11c07f6a3a9ea1e7557e78725 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/38648 Kokoro-Presubmit: kokoro <noreply+kokoro@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarJonah Ryan-Davis <jonahr@google.com>
parent e7ce4e53
...@@ -144,7 +144,14 @@ VkResult MetalSurface::present(PresentImage* image) API_AVAILABLE(macosx(10.11)) ...@@ -144,7 +144,14 @@ VkResult MetalSurface::present(PresentImage* image) API_AVAILABLE(macosx(10.11))
auto drawable = metalLayer->getNextDrawable(); auto drawable = metalLayer->getNextDrawable();
if(drawable) if(drawable)
{ {
VkExtent2D windowExtent = metalLayer->getExtent();
VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0); VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
if (windowExtent.width != extent.width || windowExtent.height != extent.height)
{
return VK_ERROR_OUT_OF_DATE_KHR;
}
[drawable.texture replaceRegion:MTLRegionMake2D(0, 0, extent.width, extent.height) [drawable.texture replaceRegion:MTLRegionMake2D(0, 0, extent.width, extent.height)
mipmapLevel:0 mipmapLevel:0
withBytes:image->getImageMemory()->getOffsetPointer(0) withBytes:image->getImageMemory()->getOffsetPointer(0)
......
...@@ -144,8 +144,17 @@ VkResult XcbSurfaceKHR::present(PresentImage* image) ...@@ -144,8 +144,17 @@ VkResult XcbSurfaceKHR::present(PresentImage* image)
auto it = graphicsContexts.find(image); auto it = graphicsContexts.find(image);
if(it != graphicsContexts.end()) if(it != graphicsContexts.end())
{ {
// TODO: Convert image if not RGB888. auto geom = libXcb->xcb_get_geometry_reply(connection, libXcb->xcb_get_geometry(connection, window), nullptr);
VkExtent2D windowExtent = {static_cast<uint32_t>(geom->width), static_cast<uint32_t>(geom->height)};
free(geom);
VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0); VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
if (windowExtent.width != extent.width || windowExtent.height != extent.height)
{
return VK_ERROR_OUT_OF_DATE_KHR;
}
// TODO: Convert image if not RGB888.
int stride = image->getImage()->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0); int stride = image->getImage()->rowPitchBytes(VK_IMAGE_ASPECT_COLOR_BIT, 0);
auto buffer = reinterpret_cast<uint8_t*>(image->getImageMemory()->getOffsetPointer(0)); auto buffer = reinterpret_cast<uint8_t*>(image->getImageMemory()->getOffsetPointer(0));
size_t bufferSize = extent.height * stride; size_t bufferSize = extent.height * stride;
......
...@@ -91,7 +91,16 @@ VkResult XlibSurfaceKHR::present(PresentImage* image) ...@@ -91,7 +91,16 @@ VkResult XlibSurfaceKHR::present(PresentImage* image)
if(xImage->data) if(xImage->data)
{ {
XWindowAttributes attr;
libX11->XGetWindowAttributes(pDisplay, window, &attr);
VkExtent2D windowExtent = {static_cast<uint32_t>(attr.width), static_cast<uint32_t>(attr.height)};
VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0); VkExtent3D extent = image->getImage()->getMipLevelExtent(VK_IMAGE_ASPECT_COLOR_BIT, 0);
if (windowExtent.width != extent.width || windowExtent.height != extent.height)
{
return VK_ERROR_OUT_OF_DATE_KHR;
}
libX11->XPutImage(pDisplay, window, gc, xImage, 0, 0, 0, 0, extent.width, extent.height); libX11->XPutImage(pDisplay, window, gc, xImage, 0, 0, 0, 0, extent.width, extent.height);
} }
} }
......
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