Commit 222c517f by Jamie Madill Committed by Commit Bot

Control Debug layers in ANGLE_platform_angle.

Debug layers seem to be a universal thing among functional back-ends. D3D, OpenGL and Vulkan all need some kind of controls for debugging, so it seems to make sense to make this control part of the base extension. Default the extension to EGL_DONT_CARE, which allows the back-end to have a lot of flexibility in terms of implementation. Also enable the extension in the D3D11 and OpenGL back-ends, and set the extension to enabled for angle_end2end_tests. Remove EGLVulkanEXTTest since it no longer tests anything not tested in the base ANGLETest class. BUG=angleproject:2086 Change-Id: I52d8170effd1846b9afbe6e4052c699fe5cb0de8 Reviewed-on: https://chromium-review.googlesource.com/578369 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarYuly Novikov <ynovikov@chromium.org>
parent a59a1c1e
...@@ -22,7 +22,7 @@ Status ...@@ -22,7 +22,7 @@ Status
Version Version
Version 3, 2014-10-20 Version 4, 2017-07-19
Number Number
...@@ -70,6 +70,7 @@ New Tokens ...@@ -70,6 +70,7 @@ New Tokens
EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203
EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205
EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED 0x3451
Accepted as values for the EGL_PLATFORM_ANGLE_TYPE_ANGLE attribute: Accepted as values for the EGL_PLATFORM_ANGLE_TYPE_ANGLE attribute:
...@@ -103,6 +104,10 @@ New Behavior ...@@ -103,6 +104,10 @@ New Behavior
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE are implicitly set to EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE are implicitly set to
EGL_DONT_CARE. EGL_DONT_CARE.
If no <attrib_list> is specified, the value of
EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED is implicitly set to
EGL_DONT_CARE.
If EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE is set to EGL_DONT_CARE and If EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE is set to EGL_DONT_CARE and
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE is not set to EGL_DONT_CARE, EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE is not set to EGL_DONT_CARE,
an EGL_BAD_ATTRIBUTE error is generated and EGL_NO_DISPLAY is returned. an EGL_BAD_ATTRIBUTE error is generated and EGL_NO_DISPLAY is returned.
...@@ -111,9 +116,21 @@ New Behavior ...@@ -111,9 +116,21 @@ New Behavior
requested by the value of EGL_PLATFORM_ANGLE_TYPE_ANGLE is available, requested by the value of EGL_PLATFORM_ANGLE_TYPE_ANGLE is available,
EGL_NO_DISPLAY is returned. No error condition is raised in this case. EGL_NO_DISPLAY is returned. No error condition is raised in this case.
If EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED is specified, it
controls enabling back-end validation layers. EGL_TRUE enables
validation and EGL_FALSE disables it. If it is set to EGL_DONT_CARE, the
default setting depends on the implementation. Any value other than these
will result in an error.
Issues Issues
None 1) Should the validation layers default to on, off, or no guarantee?
Defaulting to off offers some consistency. However, it's customary for
some applications like ANGLE to turn on debugging features by default
in Debug builds.
RESOLVED: default to implementation-dependent behaviour.
Revision History Revision History
...@@ -125,3 +142,5 @@ Revision History ...@@ -125,3 +142,5 @@ Revision History
Version 3, 2014-10-20 (Geoff Lang) Version 3, 2014-10-20 (Geoff Lang)
- Add attributes to request specific feature level and context versions. - Add attributes to request specific feature level and context versions.
- Moved descriptions of platforms to child extension specs. - Moved descriptions of platforms to child extension specs.
Version 4, 2017-07-19 (Jamie Madill)
- Add a debug layers enabled attribute to control runtime validation.
...@@ -20,7 +20,7 @@ Status ...@@ -20,7 +20,7 @@ Status
Version Version
Version 1, 2016-11-17 Version 2, 2017-07-19
Number Number
...@@ -52,11 +52,6 @@ New Tokens ...@@ -52,11 +52,6 @@ New Tokens
EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
Accepted as an attribute name in the <attrib_list> argument of
eglGetPlatformDisplayEXT:
EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE 0x3451
Additions to the EGL Specification Additions to the EGL Specification
None. None.
...@@ -67,13 +62,6 @@ New Behavior ...@@ -67,13 +62,6 @@ New Behavior
EGL_PLATFORM_ANGLE_TYPE_ANGLE should be EGL_PLATFORM_ANGLE_TYPE_ANGLE should be
EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE. EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE.
If EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE is specified, it
controls enabling the standard Vulkan validation layers. EGL_TRUE enables
the validation and EGL_FALSE disables it. Any value other than these will
result in an error. If the flag is not specified, validation may default
to either enabled or disabled, depending on compile-time parameters in the
implementation.
If EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE and If EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE and
EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE are not specified, the EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE are not specified, the
implementation will decide which version of Vulkan to instantiate. If they implementation will decide which version of Vulkan to instantiate. If they
...@@ -83,21 +71,7 @@ New Behavior ...@@ -83,21 +71,7 @@ New Behavior
Issues Issues
1) Would it be better to specify validation layers individually? 1) Should ANGLE always instantiate the highest available version of Vulkan?
RESOLVED: It would give more fined grained control, but the layers
are sensitive to ordering, and there may be new ones added or old ones
removed, this abstracts the logic into a simpler form. The validation
layers maintainers are also moving towards a single-layer model from
the current multiple layers approach.
2) Should the validation layers default to on, off, or no guarantee?
Defaulting to off offers some consistency. However, it's customary for
some applications like ANGLE to turn on debugging features by default
in Debug builds.
3) Should ANGLE always instantiate the highest available version of Vulkan?
RESOLVED: It's possible that in a future implementation of Vulkan there RESOLVED: It's possible that in a future implementation of Vulkan there
may be driver issues present only on some version of Vulkan, and there's may be driver issues present only on some version of Vulkan, and there's
...@@ -108,3 +82,5 @@ Revision History ...@@ -108,3 +82,5 @@ Revision History
Version 1, 2016-11-17 (Jamie Madill) Version 1, 2016-11-17 (Jamie Madill)
- Initial draft - Initial draft
Version 2, 2017-07-19 (Jamie Madill)
- Moved debug layer control to EGL_ANGLE_platform_angle
...@@ -50,6 +50,7 @@ ...@@ -50,6 +50,7 @@
#define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MAJOR_ANGLE 0x3204
#define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205 #define EGL_PLATFORM_ANGLE_MAX_VERSION_MINOR_ANGLE 0x3205
#define EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE 0x3206 #define EGL_PLATFORM_ANGLE_TYPE_DEFAULT_ANGLE 0x3206
#define EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE 0x3451
#endif /* EGL_ANGLE_platform_angle */ #endif /* EGL_ANGLE_platform_angle */
#ifndef EGL_ANGLE_platform_angle_d3d #ifndef EGL_ANGLE_platform_angle_d3d
...@@ -77,7 +78,6 @@ ...@@ -77,7 +78,6 @@
#ifndef EGL_ANGLE_platform_angle_vulkan #ifndef EGL_ANGLE_platform_angle_vulkan
#define EGL_ANGLE_platform_angle_vulkan 1 #define EGL_ANGLE_platform_angle_vulkan 1
#define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 #define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450
#define EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE 0x3451
#endif /* EGL_ANGLE_platform_angle_vulkan */ #endif /* EGL_ANGLE_platform_angle_vulkan */
#ifndef EGL_ANGLE_x11_visual #ifndef EGL_ANGLE_x11_visual
......
...@@ -382,6 +382,7 @@ const uint32_t ScratchMemoryBufferLifetime = 1000; ...@@ -382,6 +382,7 @@ const uint32_t ScratchMemoryBufferLifetime = 1000;
Renderer11::Renderer11(egl::Display *display) Renderer11::Renderer11(egl::Display *display)
: RendererD3D(display), : RendererD3D(display),
mCreateDebugDevice(false),
mStateCache(), mStateCache(),
mStateManager(this), mStateManager(this),
mLastHistogramUpdateTime( mLastHistogramUpdateTime(
...@@ -488,6 +489,8 @@ Renderer11::Renderer11(egl::Display *display) ...@@ -488,6 +489,8 @@ Renderer11::Renderer11(egl::Display *display)
const EGLenum presentPath = static_cast<EGLenum>(attributes.get( const EGLenum presentPath = static_cast<EGLenum>(attributes.get(
EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE, EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE)); EGL_EXPERIMENTAL_PRESENT_PATH_ANGLE, EGL_EXPERIMENTAL_PRESENT_PATH_COPY_ANGLE));
mPresentPathFastEnabled = (presentPath == EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE); mPresentPathFastEnabled = (presentPath == EGL_EXPERIMENTAL_PRESENT_PATH_FAST_ANGLE);
mCreateDebugDevice = ShouldUseDebugLayers(attributes);
} }
else if (display->getPlatform() == EGL_PLATFORM_DEVICE_EXT) else if (display->getPlatform() == EGL_PLATFORM_DEVICE_EXT)
{ {
...@@ -707,7 +710,7 @@ egl::Error Renderer11::initializeD3DDevice() ...@@ -707,7 +710,7 @@ egl::Error Renderer11::initializeD3DDevice()
} }
#endif #endif
#ifdef _DEBUG if (mCreateDebugDevice)
{ {
TRACE_EVENT0("gpu.angle", "D3D11CreateDevice (Debug)"); TRACE_EVENT0("gpu.angle", "D3D11CreateDevice (Debug)");
result = D3D11CreateDevice(nullptr, mRequestedDriverType, nullptr, result = D3D11CreateDevice(nullptr, mRequestedDriverType, nullptr,
...@@ -715,15 +718,14 @@ egl::Error Renderer11::initializeD3DDevice() ...@@ -715,15 +718,14 @@ egl::Error Renderer11::initializeD3DDevice()
static_cast<unsigned int>(mAvailableFeatureLevels.size()), static_cast<unsigned int>(mAvailableFeatureLevels.size()),
D3D11_SDK_VERSION, &mDevice, D3D11_SDK_VERSION, &mDevice,
&(mRenderer11DeviceCaps.featureLevel), &mDeviceContext); &(mRenderer11DeviceCaps.featureLevel), &mDeviceContext);
}
if (!mDevice || FAILED(result)) if (!mDevice || FAILED(result))
{ {
WARN() << "Failed creating Debug D3D11 device - falling back to release runtime."; WARN() << "Failed creating Debug D3D11 device - falling back to release runtime.";
}
} }
if (!mDevice || FAILED(result)) if (!mDevice || FAILED(result))
#endif
{ {
SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.D3D11CreateDeviceMS"); SCOPED_ANGLE_HISTOGRAM_TIMER("GPU.ANGLE.D3D11CreateDeviceMS");
TRACE_EVENT0("gpu.angle", "D3D11CreateDevice"); TRACE_EVENT0("gpu.angle", "D3D11CreateDevice");
...@@ -2813,17 +2815,13 @@ bool Renderer11::testDeviceResettable() ...@@ -2813,17 +2815,13 @@ bool Renderer11::testDeviceResettable()
ID3D11Device *dummyDevice; ID3D11Device *dummyDevice;
D3D_FEATURE_LEVEL dummyFeatureLevel; D3D_FEATURE_LEVEL dummyFeatureLevel;
ID3D11DeviceContext *dummyContext; ID3D11DeviceContext *dummyContext;
UINT flags = (mCreateDebugDevice ? D3D11_CREATE_DEVICE_DEBUG : 0);
ASSERT(mRequestedDriverType != D3D_DRIVER_TYPE_UNKNOWN); ASSERT(mRequestedDriverType != D3D_DRIVER_TYPE_UNKNOWN);
HRESULT result = D3D11CreateDevice( HRESULT result = D3D11CreateDevice(
nullptr, mRequestedDriverType, nullptr, nullptr, mRequestedDriverType, nullptr, flags, mAvailableFeatureLevels.data(),
#if defined(_DEBUG) static_cast<unsigned int>(mAvailableFeatureLevels.size()), D3D11_SDK_VERSION, &dummyDevice,
D3D11_CREATE_DEVICE_DEBUG, &dummyFeatureLevel, &dummyContext);
#else
0,
#endif
mAvailableFeatureLevels.data(), static_cast<unsigned int>(mAvailableFeatureLevels.size()),
D3D11_SDK_VERSION, &dummyDevice, &dummyFeatureLevel, &dummyContext);
if (!mDevice || FAILED(result)) if (!mDevice || FAILED(result))
{ {
......
...@@ -590,23 +590,24 @@ class Renderer11 : public RendererD3D ...@@ -590,23 +590,24 @@ class Renderer11 : public RendererD3D
const gl::TextureCaps &colorBufferFormatCaps, const gl::TextureCaps &colorBufferFormatCaps,
const gl::TextureCaps &depthStencilBufferFormatCaps) const; const gl::TextureCaps &depthStencilBufferFormatCaps) const;
egl::Error initializeD3DDevice();
void initializeDevice();
void releaseDeviceResources();
void release();
d3d11::ANGLED3D11DeviceType getDeviceType() const;
HMODULE mD3d11Module; HMODULE mD3d11Module;
HMODULE mDxgiModule; HMODULE mDxgiModule;
HMODULE mDCompModule; HMODULE mDCompModule;
std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels; std::vector<D3D_FEATURE_LEVEL> mAvailableFeatureLevels;
D3D_DRIVER_TYPE mRequestedDriverType; D3D_DRIVER_TYPE mRequestedDriverType;
bool mCreateDebugDevice;
bool mCreatedWithDeviceEXT; bool mCreatedWithDeviceEXT;
DeviceD3D *mEGLDevice; DeviceD3D *mEGLDevice;
HLSLCompiler mCompiler; HLSLCompiler mCompiler;
egl::Error initializeD3DDevice();
void initializeDevice();
void releaseDeviceResources();
void release();
d3d11::ANGLED3D11DeviceType getDeviceType() const;
RenderStateCache mStateCache; RenderStateCache mStateCache;
// Currently applied sampler states // Currently applied sampler states
......
...@@ -35,6 +35,7 @@ ...@@ -35,6 +35,7 @@
#include "libANGLE/renderer/gl/TransformFeedbackGL.h" #include "libANGLE/renderer/gl/TransformFeedbackGL.h"
#include "libANGLE/renderer/gl/VertexArrayGL.h" #include "libANGLE/renderer/gl/VertexArrayGL.h"
#include "libANGLE/renderer/gl/renderergl_utils.h" #include "libANGLE/renderer/gl/renderergl_utils.h"
#include "libANGLE/renderer/renderer_utils.h"
namespace namespace
{ {
...@@ -54,7 +55,6 @@ std::vector<GLuint> GatherPaths(const std::vector<gl::Path *> &paths) ...@@ -54,7 +55,6 @@ std::vector<GLuint> GatherPaths(const std::vector<gl::Path *> &paths)
} // namespace } // namespace
#ifndef NDEBUG
static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source, static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source,
GLenum type, GLenum type,
GLuint id, GLuint id,
...@@ -158,7 +158,6 @@ static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source, ...@@ -158,7 +158,6 @@ static void INTERNAL_GL_APIENTRY LogGLDebugMessage(GLenum source,
<< "\tMessage: " << message; << "\tMessage: " << message;
} }
} }
#endif
namespace rx namespace rx
{ {
...@@ -168,7 +167,7 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at ...@@ -168,7 +167,7 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at
mFunctions(functions), mFunctions(functions),
mStateManager(nullptr), mStateManager(nullptr),
mBlitter(nullptr), mBlitter(nullptr),
mHasDebugOutput(false), mUseDebugOutput(false),
mSkipDrawCalls(false), mSkipDrawCalls(false),
mCapsInitialized(false), mCapsInitialized(false),
mMultiviewImplementationType(MultiviewImplementationTypeGL::UNSPECIFIED) mMultiviewImplementationType(MultiviewImplementationTypeGL::UNSPECIFIED)
...@@ -178,12 +177,14 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at ...@@ -178,12 +177,14 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at
mStateManager = new StateManagerGL(mFunctions, getNativeCaps()); mStateManager = new StateManagerGL(mFunctions, getNativeCaps());
mBlitter = new BlitGL(functions, mWorkarounds, mStateManager); mBlitter = new BlitGL(functions, mWorkarounds, mStateManager);
mHasDebugOutput = mFunctions->isAtLeastGL(gl::Version(4, 3)) || bool hasDebugOutput = mFunctions->isAtLeastGL(gl::Version(4, 3)) ||
mFunctions->hasGLExtension("GL_KHR_debug") || mFunctions->hasGLExtension("GL_KHR_debug") ||
mFunctions->isAtLeastGLES(gl::Version(3, 2)) || mFunctions->isAtLeastGLES(gl::Version(3, 2)) ||
mFunctions->hasGLESExtension("GL_KHR_debug"); mFunctions->hasGLESExtension("GL_KHR_debug");
#ifndef NDEBUG
if (mHasDebugOutput) mUseDebugOutput = hasDebugOutput && ShouldUseDebugLayers(attribMap);
if (mUseDebugOutput)
{ {
mFunctions->enable(GL_DEBUG_OUTPUT); mFunctions->enable(GL_DEBUG_OUTPUT);
mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS); mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
...@@ -197,7 +198,6 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at ...@@ -197,7 +198,6 @@ RendererGL::RendererGL(const FunctionsGL *functions, const egl::AttributeMap &at
0, nullptr, GL_FALSE); 0, nullptr, GL_FALSE);
mFunctions->debugMessageCallback(&LogGLDebugMessage, nullptr); mFunctions->debugMessageCallback(&LogGLDebugMessage, nullptr);
} }
#endif
EGLint deviceType = EGLint deviceType =
static_cast<EGLint>(attribMap.get(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_NONE)); static_cast<EGLint>(attribMap.get(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE, EGL_NONE));
...@@ -232,21 +232,17 @@ gl::Error RendererGL::flush() ...@@ -232,21 +232,17 @@ gl::Error RendererGL::flush()
gl::Error RendererGL::finish() gl::Error RendererGL::finish()
{ {
#ifdef NDEBUG if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mUseDebugOutput)
if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mHasDebugOutput)
{ {
mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS); mFunctions->enable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
} }
#endif
mFunctions->finish(); mFunctions->finish();
#ifdef NDEBUG if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mUseDebugOutput)
if (mWorkarounds.finishDoesNotCauseQueriesToBeAvailable && mHasDebugOutput)
{ {
mFunctions->disable(GL_DEBUG_OUTPUT_SYNCHRONOUS); mFunctions->disable(GL_DEBUG_OUTPUT_SYNCHRONOUS);
} }
#endif
return gl::NoError(); return gl::NoError();
} }
......
...@@ -191,7 +191,7 @@ class RendererGL : angle::NonCopyable ...@@ -191,7 +191,7 @@ class RendererGL : angle::NonCopyable
WorkaroundsGL mWorkarounds; WorkaroundsGL mWorkarounds;
bool mHasDebugOutput; bool mUseDebugOutput;
// For performance debugging // For performance debugging
bool mSkipDrawCalls; bool mSkipDrawCalls;
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "image_util/copyimage.h" #include "image_util/copyimage.h"
#include "image_util/imageformats.h" #include "image_util/imageformats.h"
#include "libANGLE/AttributeMap.h"
#include "libANGLE/formatutils.h" #include "libANGLE/formatutils.h"
#include "libANGLE/renderer/Format.h" #include "libANGLE/renderer/Format.h"
...@@ -300,4 +301,17 @@ ColorCopyFunction FastCopyFunctionMap::get(const gl::FormatType &formatType) con ...@@ -300,4 +301,17 @@ ColorCopyFunction FastCopyFunctionMap::get(const gl::FormatType &formatType) con
return nullptr; return nullptr;
} }
bool ShouldUseDebugLayers(const egl::AttributeMap &attribs)
{
EGLAttrib debugSetting =
attribs.get(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE, EGL_DONT_CARE);
// Prefer to enable debug layers if compiling in Debug, and disabled in Release.
#if !defined(NDEBUG)
return (debugSetting != EGL_FALSE);
#else
return (debugSetting == EGL_TRUE);
#endif // !defined(NDEBUG)
}
} // namespace rx } // namespace rx
...@@ -21,13 +21,18 @@ ...@@ -21,13 +21,18 @@
namespace angle namespace angle
{ {
struct Format; struct Format;
} } // namespace angle
namespace gl namespace gl
{ {
struct FormatType; struct FormatType;
struct InternalFormat; struct InternalFormat;
} } // namespace gl
namespace egl
{
class AttributeMap;
} // namespace egl
namespace rx namespace rx
{ {
...@@ -182,6 +187,8 @@ struct LoadImageFunctionInfo ...@@ -182,6 +187,8 @@ struct LoadImageFunctionInfo
using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum); using LoadFunctionMap = LoadImageFunctionInfo (*)(GLenum);
bool ShouldUseDebugLayers(const egl::AttributeMap &attribs);
} // namespace rx } // namespace rx
#endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_ #endif // LIBANGLE_RENDERER_RENDERER_UTILS_H_
...@@ -154,17 +154,7 @@ RendererVk::~RendererVk() ...@@ -154,17 +154,7 @@ RendererVk::~RendererVk()
vk::Error RendererVk::initialize(const egl::AttributeMap &attribs, const char *wsiName) vk::Error RendererVk::initialize(const egl::AttributeMap &attribs, const char *wsiName)
{ {
#if !defined(NDEBUG) mEnableValidationLayers = ShouldUseDebugLayers(attribs);
// Validation layers enabled by default in Debug.
mEnableValidationLayers = true;
#endif
// If specified in the attributes, override the default.
if (attribs.contains(EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE))
{
mEnableValidationLayers =
(attribs.get(EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE, EGL_FALSE) == EGL_TRUE);
}
// If we're loading the validation layers, we could be running from any random directory. // If we're loading the validation layers, we could be running from any random directory.
// Change to the executable directory so we can find the layers, then change back to the // Change to the executable directory so we can find the layers, then change back to the
...@@ -214,7 +204,8 @@ vk::Error RendererVk::initialize(const egl::AttributeMap &attribs, const char *w ...@@ -214,7 +204,8 @@ vk::Error RendererVk::initialize(const egl::AttributeMap &attribs, const char *w
if (!HasStandardValidationLayer(instanceLayerProps)) if (!HasStandardValidationLayer(instanceLayerProps))
{ {
// Generate an error if the attribute was requested, warning otherwise. // Generate an error if the attribute was requested, warning otherwise.
if (attribs.contains(EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE)) if (attribs.get(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE, EGL_DONT_CARE) ==
EGL_TRUE)
{ {
ERR() << "Vulkan standard validation layers are missing."; ERR() << "Vulkan standard validation layers are missing.";
} }
......
...@@ -382,21 +382,16 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform, ...@@ -382,21 +382,16 @@ Error ValidateGetPlatformDisplayCommon(EGLenum platform,
deviceType = value; deviceType = value;
break; break;
case EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE: case EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE:
if (!clientExtensions.platformANGLEVulkan) if (!clientExtensions.platformANGLE)
{ {
return EglBadAttribute() return EglBadAttribute() << "EGL_ANGLE_platform_angle extension not active";
<< "EGL_ANGLE_platform_angle_vulkan extension not active";
}
if (platformType != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
{
return EglBadAttribute()
<< "Validation can only be enabled for the Vulkan back-end.";
} }
if (value != EGL_TRUE && value != EGL_FALSE) if (value != EGL_TRUE && value != EGL_FALSE && value != EGL_DONT_CARE)
{ {
return EglBadAttribute() return EglBadAttribute() << "EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE "
<< "Validation layer attribute must be EGL_TRUE or EGL_FALSE."; "must be EGL_TRUE, EGL_FALSE, or "
"EGL_DONT_CARE.";
} }
break; break;
......
...@@ -99,7 +99,6 @@ ...@@ -99,7 +99,6 @@
'<(angle_path)/src/tests/egl_tests/EGLSanityCheckTest.cpp', '<(angle_path)/src/tests/egl_tests/EGLSanityCheckTest.cpp',
'<(angle_path)/src/tests/egl_tests/EGLSurfacelessContextTest.cpp', '<(angle_path)/src/tests/egl_tests/EGLSurfacelessContextTest.cpp',
'<(angle_path)/src/tests/egl_tests/EGLSurfaceTest.cpp', '<(angle_path)/src/tests/egl_tests/EGLSurfaceTest.cpp',
'<(angle_path)/src/tests/egl_tests/EGLVulkanEXTTest.cpp',
'<(angle_path)/src/tests/test_utils/ANGLETest.cpp', '<(angle_path)/src/tests/test_utils/ANGLETest.cpp',
'<(angle_path)/src/tests/test_utils/ANGLETest.h', '<(angle_path)/src/tests/test_utils/ANGLETest.h',
'<(angle_path)/src/tests/test_utils/angle_test_configs.cpp', '<(angle_path)/src/tests/test_utils/angle_test_configs.cpp',
......
//
// Copyright 2016 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// VulkanEXTTest:
// Tests specific to the ANGLE Vulkan extension.
//
#include "test_utils/ANGLETest.h"
using namespace angle;
namespace
{
class VulkanEXTTest : public ANGLETest
{
public:
VulkanEXTTest() {}
// Intentionally do not call base class so we can run EGL in the tests.
void SetUp() override {}
};
// ANGLE requires that the vulkan validation layers are available.
TEST_P(VulkanEXTTest, ValidationLayersAvailable)
{
setVulkanLayersEnabled(true);
ASSERT_TRUE(getEGLWindow()->initializeGL(GetOSWindow()));
}
ANGLE_INSTANTIATE_TEST(VulkanEXTTest, ES2_VULKAN());
} // anonymous namespace
...@@ -211,14 +211,11 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params) ...@@ -211,14 +211,11 @@ ANGLETestBase::ANGLETestBase(const angle::PlatformParameters &params)
{ {
mEGLWindow = new EGLWindow(params.majorVersion, params.minorVersion, params.eglParameters); mEGLWindow = new EGLWindow(params.majorVersion, params.minorVersion, params.eglParameters);
// Default vulkan layers to enabled. // Default debug layers to enabled in tests.
EGLint renderer = params.getRenderer(); mEGLWindow->setDebugLayersEnabled(true);
if (renderer == EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)
{
mEGLWindow->setVulkanLayersEnabled(true);
}
// Workaround for NVIDIA not being able to share OpenGL and Vulkan contexts. // Workaround for NVIDIA not being able to share OpenGL and Vulkan contexts.
EGLint renderer = params.getRenderer();
bool needsWindowSwap = mLastRendererType.valid() && bool needsWindowSwap = mLastRendererType.valid() &&
((renderer != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) != ((renderer != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE) !=
(mLastRendererType.value() != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE)); (mLastRendererType.value() != EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE));
...@@ -744,9 +741,9 @@ void ANGLETestBase::setBindGeneratesResource(bool bindGeneratesResource) ...@@ -744,9 +741,9 @@ void ANGLETestBase::setBindGeneratesResource(bool bindGeneratesResource)
mEGLWindow->setBindGeneratesResource(bindGeneratesResource); mEGLWindow->setBindGeneratesResource(bindGeneratesResource);
} }
void ANGLETestBase::setVulkanLayersEnabled(bool enabled) void ANGLETestBase::setDebugLayersEnabled(bool enabled)
{ {
mEGLWindow->setVulkanLayersEnabled(enabled); mEGLWindow->setDebugLayersEnabled(enabled);
} }
void ANGLETestBase::setClientArraysEnabled(bool enabled) void ANGLETestBase::setClientArraysEnabled(bool enabled)
......
...@@ -281,7 +281,7 @@ class ANGLETestBase ...@@ -281,7 +281,7 @@ class ANGLETestBase
void setNoErrorEnabled(bool enabled); void setNoErrorEnabled(bool enabled);
void setWebGLCompatibilityEnabled(bool webglCompatibility); void setWebGLCompatibilityEnabled(bool webglCompatibility);
void setBindGeneratesResource(bool bindGeneratesResource); void setBindGeneratesResource(bool bindGeneratesResource);
void setVulkanLayersEnabled(bool enabled); void setDebugLayersEnabled(bool enabled);
void setClientArraysEnabled(bool enabled); void setClientArraysEnabled(bool enabled);
void setRobustResourceInit(bool enabled); void setRobustResourceInit(bool enabled);
void setContextProgramCacheEnabled(bool enabled); void setContextProgramCacheEnabled(bool enabled);
......
...@@ -122,7 +122,7 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion, ...@@ -122,7 +122,7 @@ EGLWindow::EGLWindow(EGLint glesMajorVersion,
mRobustResourceInit(), mRobustResourceInit(),
mSwapInterval(-1), mSwapInterval(-1),
mSamples(-1), mSamples(-1),
mVulkanLayersEnabled(), mDebugLayersEnabled(),
mContextProgramCacheEnabled(), mContextProgramCacheEnabled(),
mPlatformMethods(nullptr) mPlatformMethods(nullptr)
{ {
...@@ -195,11 +195,11 @@ bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow) ...@@ -195,11 +195,11 @@ bool EGLWindow::initializeDisplayAndSurface(OSWindow *osWindow)
displayAttributes.push_back(mPlatform.presentPath); displayAttributes.push_back(mPlatform.presentPath);
} }
// Set vulkan validation layer settings if requested. // Set debug layer settings if requested.
if (mVulkanLayersEnabled.valid()) if (mDebugLayersEnabled.valid())
{ {
displayAttributes.push_back(EGL_PLATFORM_ANGLE_ENABLE_VALIDATION_LAYER_ANGLE); displayAttributes.push_back(EGL_PLATFORM_ANGLE_DEBUG_LAYERS_ENABLED_ANGLE);
displayAttributes.push_back(mVulkanLayersEnabled.value() ? EGL_TRUE : EGL_FALSE); displayAttributes.push_back(mDebugLayersEnabled.value() ? EGL_TRUE : EGL_FALSE);
} }
if (mPlatformMethods) if (mPlatformMethods)
......
...@@ -84,7 +84,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable ...@@ -84,7 +84,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
{ {
mBindGeneratesResource = bindGeneratesResource; mBindGeneratesResource = bindGeneratesResource;
} }
void setVulkanLayersEnabled(bool enabled) { mVulkanLayersEnabled = enabled; } void setDebugLayersEnabled(bool enabled) { mDebugLayersEnabled = enabled; }
void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; } void setClientArraysEnabled(bool enabled) { mClientArraysEnabled = enabled; }
void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; } void setRobustResourceInit(bool enabled) { mRobustResourceInit = enabled; }
void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; } void setSwapInterval(EGLint swapInterval) { mSwapInterval = swapInterval; }
...@@ -159,7 +159,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable ...@@ -159,7 +159,7 @@ class ANGLE_EXPORT EGLWindow : angle::NonCopyable
Optional<bool> mRobustResourceInit; Optional<bool> mRobustResourceInit;
EGLint mSwapInterval; EGLint mSwapInterval;
EGLint mSamples; EGLint mSamples;
Optional<bool> mVulkanLayersEnabled; Optional<bool> mDebugLayersEnabled;
Optional<bool> mContextProgramCacheEnabled; Optional<bool> mContextProgramCacheEnabled;
angle::PlatformMethods *mPlatformMethods; angle::PlatformMethods *mPlatformMethods;
}; };
......
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