Commit d544cc9f by Austin Kinross Committed by Geoff Lang

Fail any ANGLE test if it outputs D3D11 SDK message in debug mode

Also: - Disable some Feature Level 9_3 tests that trigger SDK messages - Fix a debug object name issue. If you try to assign a debug name to an object twice then you get an SDK warning message. This can occur if you 'create' two objects (e.g. Rasterizer States) with identical DESCs on the same device, since D3D11 can optimize this and return the same object both times. - Disable the message checks in Line Loops tests, since the tests trigger incorrect D3D11 SDK messages on Win7 machines BUG=angleproject:667;angleproject:1282 Change-Id: I7284fb3a11377afde24e0014e21dbcea80ebb126 Reviewed-on: https://chromium-review.googlesource.com/321393Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tryjob-Request: Austin Kinross <aukinros@microsoft.com> Tested-by: 's avatarAustin Kinross <aukinros@microsoft.com>
parent fc7cf8e9
......@@ -1394,8 +1394,36 @@ void SetPositionLayerTexCoord3DVertex(PositionLayerTexCoord3DVertex* vertex, flo
HRESULT SetDebugName(ID3D11DeviceChild *resource, const char *name)
{
#if defined(_DEBUG)
return resource->SetPrivateData(WKPDID_D3DDebugObjectName,
static_cast<unsigned int>(strlen(name)), name);
UINT existingDataSize = 0;
resource->GetPrivateData(WKPDID_D3DDebugObjectName, &existingDataSize, nullptr);
// Don't check the HRESULT- if it failed then that probably just means that no private data
// exists yet
if (existingDataSize > 0)
{
// In some cases, ANGLE will try to apply two names to one object, which causes
// a D3D SDK Layers warning. This can occur if, for example, you 'create' two objects
// (e.g.Rasterizer States) with identical DESCs on the same device. D3D11 will optimize
// these calls and return the same object both times.
static const char *multipleNamesUsed = "Multiple names set by ANGLE";
// Remove the existing name
HRESULT hr = resource->SetPrivateData(WKPDID_D3DDebugObjectName, 0, nullptr);
if (FAILED(hr))
{
return hr;
}
// Apply the new name
return resource->SetPrivateData(WKPDID_D3DDebugObjectName,
static_cast<unsigned int>(strlen(multipleNamesUsed)),
multipleNamesUsed);
}
else
{
return resource->SetPrivateData(WKPDID_D3DDebugObjectName,
static_cast<unsigned int>(strlen(name)), name);
}
#else
return S_OK;
#endif
......
......@@ -179,6 +179,13 @@ TEST_P(BlendMinMaxTest, RGBA32f)
return;
}
// TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
if (isD3D11_FL93())
{
std::cout << "Test skipped on Feature Level 9_3." << std::endl;
return;
}
runTest(GL_RGBA32F);
}
......
......@@ -134,12 +134,20 @@ class LineLoopTest : public ANGLETest
TEST_P(LineLoopTest, LineLoopUByteIndices)
{
// Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details
// On Win7, the D3D SDK Layers emits a false warning for these tests.
// This doesn't occur on Windows 10 (Version 1511) though.
ignoreD3D11SDKLayersWarnings();
static const GLubyte indices[] = { 0, 7, 6, 9, 8, 0 };
runTest(GL_UNSIGNED_BYTE, 0, indices + 1);
}
TEST_P(LineLoopTest, LineLoopUShortIndices)
{
// Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details
ignoreD3D11SDKLayersWarnings();
static const GLushort indices[] = { 0, 7, 6, 9, 8, 0 };
runTest(GL_UNSIGNED_SHORT, 0, indices + 1);
}
......@@ -151,12 +159,18 @@ TEST_P(LineLoopTest, LineLoopUIntIndices)
return;
}
// Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details
ignoreD3D11SDKLayersWarnings();
static const GLuint indices[] = { 0, 7, 6, 9, 8, 0 };
runTest(GL_UNSIGNED_INT, 0, indices + 1);
}
TEST_P(LineLoopTest, LineLoopUByteIndexBuffer)
{
// Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details
ignoreD3D11SDKLayersWarnings();
static const GLubyte indices[] = { 0, 7, 6, 9, 8, 0 };
GLuint buf;
......@@ -171,6 +185,9 @@ TEST_P(LineLoopTest, LineLoopUByteIndexBuffer)
TEST_P(LineLoopTest, LineLoopUShortIndexBuffer)
{
// Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details
ignoreD3D11SDKLayersWarnings();
static const GLushort indices[] = { 0, 7, 6, 9, 8, 0 };
GLuint buf;
......@@ -190,6 +207,9 @@ TEST_P(LineLoopTest, LineLoopUIntIndexBuffer)
return;
}
// Disable D3D11 SDK Layers warnings checks, see ANGLE issue 667 for details
ignoreD3D11SDKLayersWarnings();
static const GLuint indices[] = { 0, 7, 6, 9, 8, 0 };
GLuint buf;
......
......@@ -1086,6 +1086,13 @@ TEST_P(Texture2DTest, CopySubImageFloat_RGB_RG)
TEST_P(Texture2DTest, CopySubImageFloat_RGB_RGB)
{
// TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
if (isD3D11_FL93())
{
std::cout << "Test skipped on Feature Level 9_3." << std::endl;
return;
}
testFloatCopySubImage(3, 3);
}
......@@ -1101,11 +1108,25 @@ TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RG)
TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RGB)
{
// TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
if (isD3D11_FL93())
{
std::cout << "Test skipped on Feature Level 9_3." << std::endl;
return;
}
testFloatCopySubImage(4, 3);
}
TEST_P(Texture2DTest, CopySubImageFloat_RGBA_RGBA)
{
// TODO (bug 1284): Investigate RGBA32f D3D SDK Layers messages on D3D11_FL9_3
if (isD3D11_FL93())
{
std::cout << "Test skipped on Feature Level 9_3." << std::endl;
return;
}
testFloatCopySubImage(4, 4);
}
......
......@@ -13,9 +13,7 @@
#include "system_utils.h"
ANGLETest::ANGLETest()
: mEGLWindow(nullptr),
mWidth(16),
mHeight(16)
: mEGLWindow(nullptr), mWidth(16), mHeight(16), mIgnoreD3D11SDKLayersWarnings(false)
{
mEGLWindow =
new EGLWindow(GetParam().majorVersion, GetParam().minorVersion, GetParam().eglParameters);
......@@ -64,6 +62,8 @@ void ANGLETest::SetUp()
void ANGLETest::TearDown()
{
checkD3D11SDKLayersMessages();
const auto &info = testing::UnitTest::GetInstance()->current_test_info();
angle::WriteDebugMessage("Exiting %s.%s\n", info->test_case_name(), info->name());
......@@ -166,6 +166,79 @@ GLuint ANGLETest::compileShader(GLenum type, const std::string &source)
return shader;
}
void ANGLETest::checkD3D11SDKLayersMessages()
{
#if defined(ANGLE_PLATFORM_WINDOWS) && !defined(NDEBUG)
// In debug D3D11 mode, check ID3D11InfoQueue to see if any D3D11 SDK Layers messages
// were outputted by the test
if (mIgnoreD3D11SDKLayersWarnings ||
mEGLWindow->getPlatform().renderer != EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE ||
mEGLWindow->getDisplay() == EGL_NO_DISPLAY)
{
return;
}
const char *extensionString =
static_cast<const char *>(eglQueryString(mEGLWindow->getDisplay(), EGL_EXTENSIONS));
if (!strstr(extensionString, "EGL_EXT_device_query"))
{
return;
}
EGLAttrib device = 0;
EGLAttrib angleDevice = 0;
PFNEGLQUERYDISPLAYATTRIBEXTPROC queryDisplayAttribEXT;
PFNEGLQUERYDEVICEATTRIBEXTPROC queryDeviceAttribEXT;
queryDisplayAttribEXT = reinterpret_cast<PFNEGLQUERYDISPLAYATTRIBEXTPROC>(
eglGetProcAddress("eglQueryDisplayAttribEXT"));
queryDeviceAttribEXT = reinterpret_cast<PFNEGLQUERYDEVICEATTRIBEXTPROC>(
eglGetProcAddress("eglQueryDeviceAttribEXT"));
ASSERT_NE(nullptr, queryDisplayAttribEXT);
ASSERT_NE(nullptr, queryDeviceAttribEXT);
ASSERT_EGL_TRUE(queryDisplayAttribEXT(mEGLWindow->getDisplay(), EGL_DEVICE_EXT, &angleDevice));
ASSERT_EGL_TRUE(queryDeviceAttribEXT(reinterpret_cast<EGLDeviceEXT>(angleDevice),
EGL_D3D11_DEVICE_ANGLE, &device));
ID3D11Device *d3d11Device = reinterpret_cast<ID3D11Device *>(device);
ID3D11InfoQueue *infoQueue = nullptr;
HRESULT hr =
d3d11Device->QueryInterface(__uuidof(infoQueue), reinterpret_cast<void **>(&infoQueue));
if (SUCCEEDED(hr))
{
UINT64 numStoredD3DDebugMessages =
infoQueue->GetNumStoredMessagesAllowedByRetrievalFilter();
if (numStoredD3DDebugMessages > 0)
{
for (UINT64 i = 0; i < numStoredD3DDebugMessages; i++)
{
SIZE_T messageLength = 0;
hr = infoQueue->GetMessage(i, nullptr, &messageLength);
if (SUCCEEDED(hr))
{
D3D11_MESSAGE *pMessage =
reinterpret_cast<D3D11_MESSAGE *>(malloc(messageLength));
infoQueue->GetMessage(i, pMessage, &messageLength);
std::cout << "Message " << i << ":"
<< " " << pMessage->pDescription << "\n";
free(pMessage);
}
}
FAIL() << numStoredD3DDebugMessages
<< " D3D11 SDK Layers message(s) detected! Test Failed.\n";
}
}
SafeRelease(infoQueue);
#endif
}
static bool checkExtensionExists(const char *allExtensions, const std::string &extName)
{
return strstr(allExtensions, extName.c_str()) != nullptr;
......@@ -352,6 +425,12 @@ EGLint ANGLETest::getPlatformRenderer() const
return mEGLWindow->getPlatform().renderer;
}
void ANGLETest::ignoreD3D11SDKLayersWarnings()
{
// Some tests may need to disable the D3D11 SDK Layers Warnings checks
mIgnoreD3D11SDKLayersWarnings = true;
}
OSWindow *ANGLETest::mOSWindow = NULL;
void ANGLETestEnvironment::SetUp()
......
......@@ -123,14 +123,20 @@ class ANGLETest : public ::testing::TestWithParam<angle::PlatformParameters>
bool isD3DSM3() const;
EGLint getPlatformRenderer() const;
void ignoreD3D11SDKLayersWarnings();
private:
bool createEGLContext();
bool destroyEGLContext();
void checkD3D11SDKLayersMessages();
EGLWindow *mEGLWindow;
int mWidth;
int mHeight;
bool mIgnoreD3D11SDKLayersWarnings;
static OSWindow *mOSWindow;
};
......
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