Vulkan: Implement robustness extensions.

Device recovery is not possible but device loss can be tracked.

BUG=angleproject:2787

Change-Id: Ib94dd557b6b005a560b7a64275b176f7b1777211
Reviewed-on: https://chromium-review.googlesource.com/1194458
Reviewed-by: Tobin Ehlis <tobine@google.com>
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Commit-Queue: Geoff Lang <geofflang@chromium.org>
This commit is contained in:
Geoff Lang 2018-08-28 14:00:24 -04:00 коммит произвёл Commit Bot
Родитель 16c20140e0
Коммит 2fe5e1d3e6
6 изменённых файлов: 42 добавлений и 7 удалений

Просмотреть файл

@ -563,7 +563,14 @@ gl::Error ContextVk::drawElementsIndirect(const gl::Context *context,
GLenum ContextVk::getResetStatus() GLenum ContextVk::getResetStatus()
{ {
UNIMPLEMENTED(); if (mRenderer->isDeviceLost())
{
// TODO(geofflang): It may be possible to track which context caused the device lost and
// return either GL_GUILTY_CONTEXT_RESET or GL_INNOCENT_CONTEXT_RESET.
// http://anglebug.com/2787
return GL_UNKNOWN_CONTEXT_RESET;
}
return GL_NO_ERROR; return GL_NO_ERROR;
} }
@ -1175,6 +1182,11 @@ void ContextVk::handleError(VkResult errorCode, const char *file, unsigned int l
errorStream << "Internal Vulkan error: " << VulkanResultString(errorCode) << ", in " << file errorStream << "Internal Vulkan error: " << VulkanResultString(errorCode) << ", in " << file
<< ", line " << line << "."; << ", line " << line << ".";
if (errorCode == VK_ERROR_DEVICE_LOST)
{
mRenderer->markDeviceLost();
}
mErrors->handleError(gl::Error(glErrorCode, glErrorCode, errorStream.str())); mErrors->handleError(gl::Error(glErrorCode, glErrorCode, errorStream.str()));
} }

Просмотреть файл

@ -52,14 +52,14 @@ egl::Error DisplayVk::makeCurrent(egl::Surface * /*drawSurface*/,
bool DisplayVk::testDeviceLost() bool DisplayVk::testDeviceLost()
{ {
// TODO(jmadill): Figure out how to do device lost in Vulkan. return mRenderer->isDeviceLost();
return false;
} }
egl::Error DisplayVk::restoreLostDevice(const egl::Display *display) egl::Error DisplayVk::restoreLostDevice(const egl::Display *display)
{ {
UNIMPLEMENTED(); // A vulkan device cannot be restored, the entire renderer would have to be re-created along
return egl::EglBadAccess(); // with any other EGL objects that reference it.
return egl::EglBadDisplay();
} }
std::string DisplayVk::getVendorString() const std::string DisplayVk::getVendorString() const
@ -165,6 +165,7 @@ gl::Version DisplayVk::getMaxSupportedESVersion() const
void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const void DisplayVk::generateExtensions(egl::DisplayExtensions *outExtensions) const
{ {
outExtensions->createContextRobustness = true;
outExtensions->surfaceOrientation = true; outExtensions->surfaceOrientation = true;
outExtensions->displayTextureShareGroup = true; outExtensions->displayTextureShareGroup = true;
@ -193,6 +194,11 @@ void DisplayVk::handleError(VkResult result, const char *file, unsigned int line
errorStream << "Internal Vulkan error: " << VulkanResultString(result) << ", in " << file errorStream << "Internal Vulkan error: " << VulkanResultString(result) << ", in " << file
<< ", line " << line << "."; << ", line " << line << ".";
mStoredErrorString = errorStream.str(); mStoredErrorString = errorStream.str();
if (result == VK_ERROR_DEVICE_LOST)
{
mRenderer->markDeviceLost();
}
} }
// TODO(jmadill): Remove this. http://anglebug.com/2491 // TODO(jmadill): Remove this. http://anglebug.com/2491

Просмотреть файл

@ -299,6 +299,7 @@ RendererVk::RendererVk()
mDevice(VK_NULL_HANDLE), mDevice(VK_NULL_HANDLE),
mLastCompletedQueueSerial(mQueueSerialFactory.generate()), mLastCompletedQueueSerial(mQueueSerialFactory.generate()),
mCurrentQueueSerial(mQueueSerialFactory.generate()), mCurrentQueueSerial(mQueueSerialFactory.generate()),
mDeviceLost(false),
mPipelineCacheVkUpdateTimeout(kPipelineCacheVkUpdatePeriod) mPipelineCacheVkUpdateTimeout(kPipelineCacheVkUpdatePeriod)
{ {
} }
@ -355,6 +356,16 @@ void RendererVk::onDestroy(vk::Context *context)
mPhysicalDevice = VK_NULL_HANDLE; mPhysicalDevice = VK_NULL_HANDLE;
} }
void RendererVk::markDeviceLost()
{
mDeviceLost = true;
}
bool RendererVk::isDeviceLost() const
{
return mDeviceLost;
}
angle::Result RendererVk::initialize(DisplayVk *displayVk, angle::Result RendererVk::initialize(DisplayVk *displayVk,
const egl::AttributeMap &attribs, const egl::AttributeMap &attribs,
const char *wsiName) const char *wsiName)

Просмотреть файл

@ -48,6 +48,9 @@ class RendererVk : angle::NonCopyable
const char *wsiName); const char *wsiName);
void onDestroy(vk::Context *context); void onDestroy(vk::Context *context);
void markDeviceLost();
bool isDeviceLost() const;
std::string getVendorString() const; std::string getVendorString() const;
std::string getRendererDescription() const; std::string getRendererDescription() const;
@ -183,6 +186,8 @@ class RendererVk : angle::NonCopyable
Serial mLastCompletedQueueSerial; Serial mLastCompletedQueueSerial;
Serial mCurrentQueueSerial; Serial mCurrentQueueSerial;
bool mDeviceLost;
struct CommandBatch final : angle::NonCopyable struct CommandBatch final : angle::NonCopyable
{ {
CommandBatch(); CommandBatch();

Просмотреть файл

@ -46,6 +46,7 @@ void GenerateCaps(const VkPhysicalDeviceProperties &physicalDeviceProperties,
outExtensions->framebufferBlit = true; outExtensions->framebufferBlit = true;
outExtensions->copyTexture = true; outExtensions->copyTexture = true;
outExtensions->debugMarker = true; outExtensions->debugMarker = true;
outExtensions->robustness = true;
// TODO(lucferron): Eventually remove everything above this line in this function as the caps // TODO(lucferron): Eventually remove everything above this line in this function as the caps
// get implemented. // get implemented.

Просмотреть файл

@ -228,7 +228,7 @@ TEST_P(EGLRobustnessTest, DISABLED_ResettingDisplayWorks)
// if there was a TDR caused by D3D so we don't run D3D tests at the same time as the OpenGL tests. // if there was a TDR caused by D3D so we don't run D3D tests at the same time as the OpenGL tests.
#define D3D_HAS_PRIORITY 1 #define D3D_HAS_PRIORITY 1
#if D3D_HAS_PRIORITY && (defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11)) #if D3D_HAS_PRIORITY && (defined(ANGLE_ENABLE_D3D9) || defined(ANGLE_ENABLE_D3D11))
ANGLE_INSTANTIATE_TEST(EGLRobustnessTest, ES2_D3D9(), ES2_D3D11()); ANGLE_INSTANTIATE_TEST(EGLRobustnessTest, ES2_VULKAN(), ES2_D3D9(), ES2_D3D11());
#else #else
ANGLE_INSTANTIATE_TEST(EGLRobustnessTest, ES2_OPENGL()); ANGLE_INSTANTIATE_TEST(EGLRobustnessTest, ES2_VULKAN(), ES2_OPENGL());
#endif #endif