Commit 6ee1e786 by Austin Kinross Committed by Geoff Lang

Implement GL_EXT_debug_marker in D3D9/D3D11 renderers

BUG=angleproject:1043 Change-Id: I7f3bfb35050662520b901828d0478719fa8d11b3 Reviewed-on: https://chromium-review.googlesource.com/274054Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Tested-by: 's avatarAustin Kinross <aukinros@microsoft.com>
parent 9fc2e4c3
...@@ -44,10 +44,10 @@ void output(bool traceInDebugOnly, MessageType messageType, DebugTraceOutputType ...@@ -44,10 +44,10 @@ void output(bool traceInDebugOnly, MessageType messageType, DebugTraceOutputType
case DebugTraceOutputTypeNone: case DebugTraceOutputTypeNone:
break; break;
case DebugTraceOutputTypeBeginEvent: case DebugTraceOutputTypeBeginEvent:
g_debugAnnotator->beginEvent(formattedWideMessage); g_debugAnnotator->beginEvent(formattedWideMessage.c_str());
break; break;
case DebugTraceOutputTypeSetMarker: case DebugTraceOutputTypeSetMarker:
g_debugAnnotator->setMarker(formattedWideMessage); g_debugAnnotator->setMarker(formattedWideMessage.c_str());
break; break;
} }
} }
......
...@@ -47,9 +47,9 @@ class DebugAnnotator : angle::NonCopyable ...@@ -47,9 +47,9 @@ class DebugAnnotator : angle::NonCopyable
public: public:
DebugAnnotator() { }; DebugAnnotator() { };
virtual ~DebugAnnotator() { }; virtual ~DebugAnnotator() { };
virtual void beginEvent(const std::wstring &eventName) = 0; virtual void beginEvent(const wchar_t *eventName) = 0;
virtual void endEvent() = 0; virtual void endEvent() = 0;
virtual void setMarker(const std::wstring &markerName) = 0; virtual void setMarker(const wchar_t *markerName) = 0;
virtual bool getStatus() = 0; virtual bool getStatus() = 0;
}; };
......
...@@ -135,6 +135,7 @@ Extensions::Extensions() ...@@ -135,6 +135,7 @@ Extensions::Extensions()
translatedShaderSource(false), translatedShaderSource(false),
fboRenderMipmap(false), fboRenderMipmap(false),
discardFramebuffer(false), discardFramebuffer(false),
debugMarker(false),
colorBufferFloat(false) colorBufferFloat(false)
{ {
} }
...@@ -186,6 +187,7 @@ std::vector<std::string> Extensions::getStrings() const ...@@ -186,6 +187,7 @@ std::vector<std::string> Extensions::getStrings() const
InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings); InsertExtensionString("GL_ANGLE_translated_shader_source", translatedShaderSource, &extensionStrings);
InsertExtensionString("GL_OES_fbo_render_mipmap", fboRenderMipmap, &extensionStrings); InsertExtensionString("GL_OES_fbo_render_mipmap", fboRenderMipmap, &extensionStrings);
InsertExtensionString("GL_EXT_discard_framebuffer", discardFramebuffer, &extensionStrings); InsertExtensionString("GL_EXT_discard_framebuffer", discardFramebuffer, &extensionStrings);
InsertExtensionString("GL_EXT_debug_marker", debugMarker, &extensionStrings);
InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings); InsertExtensionString("GL_EXT_color_buffer_float", colorBufferFloat, &extensionStrings);
return extensionStrings; return extensionStrings;
......
...@@ -216,6 +216,9 @@ struct Extensions ...@@ -216,6 +216,9 @@ struct Extensions
// GL_EXT_discard_framebuffer // GL_EXT_discard_framebuffer
bool discardFramebuffer; bool discardFramebuffer;
// EXT_debug_marker
bool debugMarker;
// ES3 Extension support // ES3 Extension support
// GL_EXT_color_buffer_float // GL_EXT_color_buffer_float
......
...@@ -1258,6 +1258,24 @@ Error Context::finish() ...@@ -1258,6 +1258,24 @@ Error Context::finish()
return mRenderer->finish(); return mRenderer->finish();
} }
void Context::insertEventMarker(GLsizei length, const char *marker)
{
ASSERT(mRenderer);
mRenderer->insertEventMarker(length, marker);
}
void Context::pushGroupMarker(GLsizei length, const char *marker)
{
ASSERT(mRenderer);
mRenderer->pushGroupMarker(length, marker);
}
void Context::popGroupMarker()
{
ASSERT(mRenderer);
mRenderer->popGroupMarker();
}
void Context::recordError(const Error &error) void Context::recordError(const Error &error)
{ {
if (error.isError()) if (error.isError())
......
...@@ -171,6 +171,10 @@ class Context final : angle::NonCopyable ...@@ -171,6 +171,10 @@ class Context final : angle::NonCopyable
Error flush(); Error flush();
Error finish(); Error finish();
void insertEventMarker(GLsizei length, const char *marker);
void pushGroupMarker(GLsizei length, const char *marker);
void popGroupMarker();
void recordError(const Error &error); void recordError(const Error &error);
GLenum getError(); GLenum getError();
......
...@@ -68,6 +68,10 @@ class Renderer : public ImplFactory ...@@ -68,6 +68,10 @@ class Renderer : public ImplFactory
virtual std::string getVendorString() const = 0; virtual std::string getVendorString() const = 0;
virtual std::string getRendererDescription() const = 0; virtual std::string getRendererDescription() const = 0;
virtual void insertEventMarker(GLsizei length, const char *marker) = 0;
virtual void pushGroupMarker(GLsizei length, const char *marker) = 0;
virtual void popGroupMarker() = 0;
// Renderer capabilities // Renderer capabilities
const gl::Caps &getRendererCaps() const; const gl::Caps &getRendererCaps() const;
const gl::TextureCapsMap &getRendererTextureCaps() const; const gl::TextureCapsMap &getRendererTextureCaps() const;
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include "libANGLE/renderer/d3d/RendererD3D.h" #include "libANGLE/renderer/d3d/RendererD3D.h"
#include "common/MemoryBuffer.h" #include "common/MemoryBuffer.h"
#include "common/debug.h"
#include "common/utilities.h" #include "common/utilities.h"
#include "libANGLE/Display.h" #include "libANGLE/Display.h"
#include "libANGLE/Framebuffer.h" #include "libANGLE/Framebuffer.h"
...@@ -37,7 +38,8 @@ const uintptr_t RendererD3D::DirtyPointer = std::numeric_limits<uintptr_t>::max( ...@@ -37,7 +38,8 @@ const uintptr_t RendererD3D::DirtyPointer = std::numeric_limits<uintptr_t>::max(
RendererD3D::RendererD3D(egl::Display *display) RendererD3D::RendererD3D(egl::Display *display)
: mDisplay(display), : mDisplay(display),
mDeviceLost(false), mDeviceLost(false),
mScratchMemoryBufferResetCounter(0) mScratchMemoryBufferResetCounter(0),
mAnnotator(nullptr)
{ {
} }
...@@ -54,6 +56,12 @@ void RendererD3D::cleanup() ...@@ -54,6 +56,12 @@ void RendererD3D::cleanup()
incompleteTexture.second.set(NULL); incompleteTexture.second.set(NULL);
} }
mIncompleteTextures.clear(); mIncompleteTextures.clear();
if (mAnnotator != nullptr)
{
gl::UninitializeDebugAnnotations();
SafeDelete(mAnnotator);
}
} }
gl::Error RendererD3D::drawElements(const gl::Data &data, gl::Error RendererD3D::drawElements(const gl::Data &data,
...@@ -617,4 +625,44 @@ gl::Error RendererD3D::getScratchMemoryBuffer(size_t requestedSize, MemoryBuffer ...@@ -617,4 +625,44 @@ gl::Error RendererD3D::getScratchMemoryBuffer(size_t requestedSize, MemoryBuffer
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
void RendererD3D::insertEventMarker(GLsizei length, const char *marker)
{
std::vector<wchar_t> wcstring (length + 1);
size_t convertedChars = 0;
errno_t err = mbstowcs_s(&convertedChars, wcstring.data(), length + 1, marker, _TRUNCATE);
if (err == 0)
{
getAnnotator()->setMarker(wcstring.data());
}
}
void RendererD3D::pushGroupMarker(GLsizei length, const char *marker)
{
std::vector<wchar_t> wcstring(length + 1);
size_t convertedChars = 0;
errno_t err = mbstowcs_s(&convertedChars, wcstring.data(), length + 1, marker, _TRUNCATE);
if (err == 0)
{
getAnnotator()->beginEvent(wcstring.data());
}
}
void RendererD3D::popGroupMarker()
{
getAnnotator()->endEvent();
}
gl::DebugAnnotator *RendererD3D::getAnnotator()
{
if (mAnnotator == nullptr)
{
createAnnotator();
ASSERT(mAnnotator);
gl::InitializeDebugAnnotations(mAnnotator);
}
ASSERT(mAnnotator);
return mAnnotator;
}
} }
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#ifndef LIBANGLE_RENDERER_D3D_RENDERERD3D_H_ #ifndef LIBANGLE_RENDERER_D3D_RENDERERD3D_H_
#define LIBANGLE_RENDERER_D3D_RENDERERD3D_H_ #define LIBANGLE_RENDERER_D3D_RENDERERD3D_H_
#include "common/debug.h"
#include "common/MemoryBuffer.h" #include "common/MemoryBuffer.h"
#include "libANGLE/Data.h" #include "libANGLE/Data.h"
#include "libANGLE/renderer/Renderer.h" #include "libANGLE/renderer/Renderer.h"
...@@ -28,6 +29,7 @@ namespace gl ...@@ -28,6 +29,7 @@ namespace gl
class InfoLog; class InfoLog;
struct LinkedVarying; struct LinkedVarying;
class Texture; class Texture;
class DebugAnnotator;
} }
namespace rx namespace rx
...@@ -183,6 +185,11 @@ class RendererD3D : public Renderer, public BufferFactoryD3D ...@@ -183,6 +185,11 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
gl::Error getScratchMemoryBuffer(size_t requestedSize, MemoryBuffer **bufferOut); gl::Error getScratchMemoryBuffer(size_t requestedSize, MemoryBuffer **bufferOut);
// EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
protected: protected:
virtual gl::Error drawArrays(const gl::Data &data, GLenum mode, GLsizei count, GLsizei instances, bool usesPointSize) = 0; virtual gl::Error drawArrays(const gl::Data &data, GLenum mode, GLsizei count, GLsizei instances, bool usesPointSize) = 0;
virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, virtual gl::Error drawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices,
...@@ -192,12 +199,17 @@ class RendererD3D : public Renderer, public BufferFactoryD3D ...@@ -192,12 +199,17 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
void cleanup(); void cleanup();
virtual void createAnnotator() = 0;
// dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state. // dirtyPointer is a special value that will make the comparison with any valid pointer fail and force the renderer to re-apply the state.
static const uintptr_t DirtyPointer; static const uintptr_t DirtyPointer;
egl::Display *mDisplay; egl::Display *mDisplay;
bool mDeviceLost; bool mDeviceLost;
gl::DebugAnnotator *mAnnotator;
private: private:
//FIXME(jmadill): std::array is currently prohibited by Chromium style guide //FIXME(jmadill): std::array is currently prohibited by Chromium style guide
typedef std::array<gl::Texture*, gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureArray; typedef std::array<gl::Texture*, gl::IMPLEMENTATION_MAX_FRAMEBUFFER_ATTACHMENTS> FramebufferTextureArray;
...@@ -218,6 +230,8 @@ class RendererD3D : public Renderer, public BufferFactoryD3D ...@@ -218,6 +230,8 @@ class RendererD3D : public Renderer, public BufferFactoryD3D
size_t getBoundFramebufferTextures(const gl::Data &data, FramebufferTextureArray *outTextureArray); size_t getBoundFramebufferTextures(const gl::Data &data, FramebufferTextureArray *outTextureArray);
gl::Texture *getIncompleteTexture(GLenum type); gl::Texture *getIncompleteTexture(GLenum type);
gl::DebugAnnotator *getAnnotator();
gl::TextureMap mIncompleteTextures; gl::TextureMap mIncompleteTextures;
MemoryBuffer mScratchMemoryBuffer; MemoryBuffer mScratchMemoryBuffer;
unsigned int mScratchMemoryBufferResetCounter; unsigned int mScratchMemoryBufferResetCounter;
......
...@@ -35,11 +35,11 @@ DebugAnnotator11::~DebugAnnotator11() ...@@ -35,11 +35,11 @@ DebugAnnotator11::~DebugAnnotator11()
} }
} }
void DebugAnnotator11::beginEvent(const std::wstring &eventName) void DebugAnnotator11::beginEvent(const wchar_t *eventName)
{ {
initializeDevice(); initializeDevice();
mUserDefinedAnnotation->BeginEvent(eventName.c_str()); mUserDefinedAnnotation->BeginEvent(eventName);
} }
void DebugAnnotator11::endEvent() void DebugAnnotator11::endEvent()
...@@ -49,11 +49,11 @@ void DebugAnnotator11::endEvent() ...@@ -49,11 +49,11 @@ void DebugAnnotator11::endEvent()
mUserDefinedAnnotation->EndEvent(); mUserDefinedAnnotation->EndEvent();
} }
void DebugAnnotator11::setMarker(const std::wstring &markerName) void DebugAnnotator11::setMarker(const wchar_t *markerName)
{ {
initializeDevice(); initializeDevice();
mUserDefinedAnnotation->SetMarker(markerName.c_str()); mUserDefinedAnnotation->SetMarker(markerName);
} }
bool DebugAnnotator11::getStatus() bool DebugAnnotator11::getStatus()
......
...@@ -19,9 +19,9 @@ class DebugAnnotator11 : public gl::DebugAnnotator ...@@ -19,9 +19,9 @@ class DebugAnnotator11 : public gl::DebugAnnotator
public: public:
DebugAnnotator11(); DebugAnnotator11();
~DebugAnnotator11() override; ~DebugAnnotator11() override;
void beginEvent(const std::wstring &eventName) override; void beginEvent(const wchar_t *eventName) override;
void endEvent() override; void endEvent() override;
void setMarker(const std::wstring &markerName) override; void setMarker(const wchar_t *markerName) override;
bool getStatus() override; bool getStatus() override;
private: private:
......
...@@ -193,9 +193,6 @@ Renderer11::Renderer11(egl::Display *display) ...@@ -193,9 +193,6 @@ Renderer11::Renderer11(egl::Display *display)
mStateCache(this), mStateCache(this),
mDebug(nullptr) mDebug(nullptr)
{ {
// Initialize global annotator
gl::InitializeDebugAnnotations(&mAnnotator);
mVertexDataManager = NULL; mVertexDataManager = NULL;
mIndexDataManager = NULL; mIndexDataManager = NULL;
...@@ -296,8 +293,6 @@ Renderer11::Renderer11(egl::Display *display) ...@@ -296,8 +293,6 @@ Renderer11::Renderer11(egl::Display *display)
Renderer11::~Renderer11() Renderer11::~Renderer11()
{ {
release(); release();
gl::UninitializeDebugAnnotations();
} }
#ifndef __d3d11_1_h__ #ifndef __d3d11_1_h__
...@@ -3705,4 +3700,10 @@ void Renderer11::setShaderResource(gl::SamplerType shaderType, UINT resourceSlot ...@@ -3705,4 +3700,10 @@ void Renderer11::setShaderResource(gl::SamplerType shaderType, UINT resourceSlot
} }
} }
} }
void Renderer11::createAnnotator()
{
mAnnotator = new DebugAnnotator11();
}
} }
...@@ -264,6 +264,9 @@ class Renderer11 : public RendererD3D ...@@ -264,6 +264,9 @@ class Renderer11 : public RendererD3D
RendererClass getRendererClass() const override { return RENDERER_D3D11; } RendererClass getRendererClass() const override { return RENDERER_D3D11; }
protected:
void createAnnotator() override;
private: private:
void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const override; void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const override;
Workarounds generateWorkarounds() const override; Workarounds generateWorkarounds() const override;
...@@ -419,8 +422,6 @@ class Renderer11 : public RendererD3D ...@@ -419,8 +422,6 @@ class Renderer11 : public RendererD3D
char mDescription[128]; char mDescription[128];
DXGIFactory *mDxgiFactory; DXGIFactory *mDxgiFactory;
ID3D11Debug *mDebug; ID3D11Debug *mDebug;
DebugAnnotator11 mAnnotator;
}; };
} }
......
...@@ -610,6 +610,14 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) ...@@ -610,6 +610,14 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
// Draw // Draw
deviceContext->Draw(4, 0); deviceContext->Draw(4, 0);
// Rendering to the swapchain is now complete. Now we can call Present().
// Before that, we perform any cleanup on the D3D device. We do this before Present() to make sure the
// cleanup is caught under the current eglSwapBuffers() PIX/Graphics Diagnostics call rather than the next one.
mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
mRenderer->unapplyRenderTargets();
mRenderer->markAllStateDirty();
#if ANGLE_VSYNC == ANGLE_DISABLED #if ANGLE_VSYNC == ANGLE_DISABLED
result = mSwapChain->Present(0, 0); result = mSwapChain->Present(0, 0);
#else #else
...@@ -647,12 +655,6 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height) ...@@ -647,12 +655,6 @@ EGLint SwapChain11::swapRect(EGLint x, EGLint y, EGLint width, EGLint height)
ERR("Present failed with error code 0x%08X", result); ERR("Present failed with error code 0x%08X", result);
} }
// Unbind
mRenderer->setShaderResource(gl::SAMPLER_PIXEL, 0, NULL);
mRenderer->unapplyRenderTargets();
mRenderer->markAllStateDirty();
return EGL_SUCCESS; return EGL_SUCCESS;
} }
......
...@@ -1151,6 +1151,7 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, cons ...@@ -1151,6 +1151,7 @@ void GenerateCaps(ID3D11Device *device, ID3D11DeviceContext *deviceContext, cons
extensions->discardFramebuffer = false; // TODO: enable this once BUG:497445 is fixed (Chrome WebGL video tests fail with this extension active) extensions->discardFramebuffer = false; // TODO: enable this once BUG:497445 is fixed (Chrome WebGL video tests fail with this extension active)
extensions->translatedShaderSource = true; extensions->translatedShaderSource = true;
extensions->fboRenderMipmap = false; extensions->fboRenderMipmap = false;
extensions->debugMarker = true;
} }
} }
......
...@@ -13,9 +13,9 @@ ...@@ -13,9 +13,9 @@
namespace rx namespace rx
{ {
void DebugAnnotator9::beginEvent(const std::wstring &eventName) void DebugAnnotator9::beginEvent(const wchar_t *eventName)
{ {
D3DPERF_BeginEvent(0, eventName.c_str()); D3DPERF_BeginEvent(0, eventName);
} }
void DebugAnnotator9::endEvent() void DebugAnnotator9::endEvent()
...@@ -23,9 +23,9 @@ void DebugAnnotator9::endEvent() ...@@ -23,9 +23,9 @@ void DebugAnnotator9::endEvent()
D3DPERF_EndEvent(); D3DPERF_EndEvent();
} }
void DebugAnnotator9::setMarker(const std::wstring &markerName) void DebugAnnotator9::setMarker(const wchar_t *markerName)
{ {
D3DPERF_SetMarker(0, markerName.c_str()); D3DPERF_SetMarker(0, markerName);
} }
bool DebugAnnotator9::getStatus() bool DebugAnnotator9::getStatus()
......
...@@ -18,9 +18,9 @@ class DebugAnnotator9 : public gl::DebugAnnotator ...@@ -18,9 +18,9 @@ class DebugAnnotator9 : public gl::DebugAnnotator
{ {
public: public:
DebugAnnotator9() {} DebugAnnotator9() {}
void beginEvent(const std::wstring &eventName) override; void beginEvent(const wchar_t *eventName) override;
void endEvent() override; void endEvent() override;
void setMarker(const std::wstring &markerName) override; void setMarker(const wchar_t *markerName) override;
bool getStatus() override; bool getStatus() override;
}; };
......
...@@ -80,9 +80,6 @@ enum ...@@ -80,9 +80,6 @@ enum
Renderer9::Renderer9(egl::Display *display) Renderer9::Renderer9(egl::Display *display)
: RendererD3D(display) : RendererD3D(display)
{ {
// Initialize global annotator
gl::InitializeDebugAnnotations(&mAnnotator);
mD3d9Module = NULL; mD3d9Module = NULL;
mD3d9 = NULL; mD3d9 = NULL;
...@@ -148,8 +145,6 @@ Renderer9::~Renderer9() ...@@ -148,8 +145,6 @@ Renderer9::~Renderer9()
} }
release(); release();
gl::UninitializeDebugAnnotations();
} }
void Renderer9::release() void Renderer9::release()
...@@ -2942,4 +2937,9 @@ Workarounds Renderer9::generateWorkarounds() const ...@@ -2942,4 +2937,9 @@ Workarounds Renderer9::generateWorkarounds() const
return d3d9::GenerateWorkarounds(); return d3d9::GenerateWorkarounds();
} }
void Renderer9::createAnnotator()
{
mAnnotator = new DebugAnnotator9();
}
} }
...@@ -233,6 +233,9 @@ class Renderer9 : public RendererD3D ...@@ -233,6 +233,9 @@ class Renderer9 : public RendererD3D
D3DDEVTYPE getD3D9DeviceType() const { return mDeviceType; } D3DDEVTYPE getD3D9DeviceType() const { return mDeviceType; }
protected:
void createAnnotator() override;
private: private:
void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const override; void generateCaps(gl::Caps *outCaps, gl::TextureCapsMap *outTextureCaps, gl::Extensions *outExtensions) const override;
Workarounds generateWorkarounds() const override; Workarounds generateWorkarounds() const override;
...@@ -370,8 +373,6 @@ class Renderer9 : public RendererD3D ...@@ -370,8 +373,6 @@ class Renderer9 : public RendererD3D
gl::FramebufferAttachment *buffer; gl::FramebufferAttachment *buffer;
} mNullColorbufferCache[NUM_NULL_COLORBUFFER_CACHE_ENTRIES]; } mNullColorbufferCache[NUM_NULL_COLORBUFFER_CACHE_ENTRIES];
UINT mMaxNullColorbufferLRU; UINT mMaxNullColorbufferLRU;
DebugAnnotator9 mAnnotator;
}; };
} }
......
...@@ -540,6 +540,7 @@ void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceT ...@@ -540,6 +540,7 @@ void GenerateCaps(IDirect3D9 *d3d9, IDirect3DDevice9 *device, D3DDEVTYPE deviceT
extensions->fboRenderMipmap = false; extensions->fboRenderMipmap = false;
extensions->discardFramebuffer = false; // It would be valid to set this to true, since glDiscardFramebufferEXT is just a hint extensions->discardFramebuffer = false; // It would be valid to set this to true, since glDiscardFramebufferEXT is just a hint
extensions->colorBufferFloat = false; extensions->colorBufferFloat = false;
extensions->debugMarker = true;
} }
} }
......
...@@ -230,6 +230,21 @@ TransformFeedbackImpl *RendererGL::createTransformFeedback() ...@@ -230,6 +230,21 @@ TransformFeedbackImpl *RendererGL::createTransformFeedback()
return new TransformFeedbackGL(); return new TransformFeedbackGL();
} }
void RendererGL::insertEventMarker(GLsizei, const char *)
{
UNREACHABLE();
}
void RendererGL::pushGroupMarker(GLsizei, const char *)
{
UNREACHABLE();
}
void RendererGL::popGroupMarker()
{
UNREACHABLE();
}
void RendererGL::notifyDeviceLost() void RendererGL::notifyDeviceLost()
{ {
UNIMPLEMENTED(); UNIMPLEMENTED();
......
...@@ -61,6 +61,11 @@ class RendererGL : public Renderer ...@@ -61,6 +61,11 @@ class RendererGL : public Renderer
// Transform Feedback creation // Transform Feedback creation
TransformFeedbackImpl *createTransformFeedback() override; TransformFeedbackImpl *createTransformFeedback() override;
// EXT_debug_marker
void insertEventMarker(GLsizei length, const char *marker) override;
void pushGroupMarker(GLsizei length, const char *marker) override;
void popGroupMarker() override;
// lost device // lost device
void notifyDeviceLost() override; void notifyDeviceLost() override;
bool isDeviceLost() const override; bool isDeviceLost() const override;
......
...@@ -1942,4 +1942,38 @@ bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei num ...@@ -1942,4 +1942,38 @@ bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei num
return true; return true;
} }
bool ValidateInsertEventMarkerEXT(Context *context, GLsizei length, const char *marker)
{
// Note that debug marker calls must not set error state
if (length < 0)
{
return false;
}
if (marker == nullptr)
{
return false;
}
return true;
}
bool ValidatePushGroupMarkerEXT(Context *context, GLsizei length, const char *marker)
{
// Note that debug marker calls must not set error state
if (length < 0)
{
return false;
}
if (length > 0 && marker == nullptr)
{
return false;
}
return true;
}
} }
...@@ -92,6 +92,8 @@ bool ValidateGetnUniformivEXT(Context *context, GLuint program, GLint location, ...@@ -92,6 +92,8 @@ bool ValidateGetnUniformivEXT(Context *context, GLuint program, GLint location,
bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei numAttachments, bool ValidateDiscardFramebufferBase(Context *context, GLenum target, GLsizei numAttachments,
const GLenum *attachments, bool defaultFramebuffer); const GLenum *attachments, bool defaultFramebuffer);
bool ValidateInsertEventMarkerEXT(Context *context, GLsizei length, const char *marker);
bool ValidatePushGroupMarkerEXT(Context *context, GLsizei length, const char *marker);
} }
#endif // LIBANGLE_VALIDATION_ES_H_ #endif // LIBANGLE_VALIDATION_ES_H_
...@@ -1163,6 +1163,9 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char * ...@@ -1163,6 +1163,9 @@ __eglMustCastToProperFunctionPointerType EGLAPIENTRY GetProcAddress(const char *
{ "glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)gl::MapBufferRangeEXT }, { "glMapBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)gl::MapBufferRangeEXT },
{ "glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)gl::FlushMappedBufferRangeEXT }, { "glFlushMappedBufferRangeEXT", (__eglMustCastToProperFunctionPointerType)gl::FlushMappedBufferRangeEXT },
{ "glDiscardFramebufferEXT", (__eglMustCastToProperFunctionPointerType)gl::DiscardFramebufferEXT }, { "glDiscardFramebufferEXT", (__eglMustCastToProperFunctionPointerType)gl::DiscardFramebufferEXT },
{ "glInsertEventMarkerEXT", (__eglMustCastToProperFunctionPointerType)gl::InsertEventMarkerEXT },
{ "glPushGroupMarkerEXT", (__eglMustCastToProperFunctionPointerType)gl::PushGroupMarkerEXT },
{ "glPopGroupMarkerEXT", (__eglMustCastToProperFunctionPointerType)gl::PopGroupMarkerEXT },
{ "", NULL }, { "", NULL },
}; };
......
...@@ -1088,4 +1088,83 @@ void GL_APIENTRY FlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsiz ...@@ -1088,4 +1088,83 @@ void GL_APIENTRY FlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsiz
} }
} }
void GL_APIENTRY InsertEventMarkerEXT(GLsizei length, const char *marker)
{
// Don't run an EVENT() macro on the EXT_debug_marker entry points.
// It can interfere with the debug events being set by the caller.
Context *context = GetValidGlobalContext();
if (context)
{
if (!context->getExtensions().debugMarker)
{
// The debug marker calls should not set error state
// However, it seems reasonable to set an error state if the extension is not enabled
context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled"));
return;
}
if (!ValidateInsertEventMarkerEXT(context, length, marker))
{
return;
}
context->insertEventMarker(length, marker);
}
}
void GL_APIENTRY PushGroupMarkerEXT(GLsizei length, const char *marker)
{
// Don't run an EVENT() macro on the EXT_debug_marker entry points.
// It can interfere with the debug events being set by the caller.
Context *context = GetValidGlobalContext();
if (context)
{
if (!context->getExtensions().debugMarker)
{
// The debug marker calls should not set error state
// However, it seems reasonable to set an error state if the extension is not enabled
context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled"));
return;
}
if (!ValidatePushGroupMarkerEXT(context, length, marker))
{
return;
}
if (marker == nullptr)
{
// From the EXT_debug_marker spec,
// "If <marker> is null then an empty string is pushed on the stack."
context->pushGroupMarker(length, "");
}
else
{
context->pushGroupMarker(length, marker);
}
}
}
void GL_APIENTRY PopGroupMarkerEXT()
{
// Don't run an EVENT() macro on the EXT_debug_marker entry points.
// It can interfere with the debug events being set by the caller.
Context *context = GetValidGlobalContext();
if (context)
{
if (!context->getExtensions().debugMarker)
{
// The debug marker calls should not set error state
// However, it seems reasonable to set an error state if the extension is not enabled
context->recordError(Error(GL_INVALID_OPERATION, "Extension not enabled"));
return;
}
context->popGroupMarker();
}
}
} }
...@@ -76,6 +76,11 @@ ANGLE_EXPORT void GL_APIENTRY GetBufferPointervOES(GLenum target, GLenum pname, ...@@ -76,6 +76,11 @@ ANGLE_EXPORT void GL_APIENTRY GetBufferPointervOES(GLenum target, GLenum pname,
ANGLE_EXPORT void *GL_APIENTRY MapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); ANGLE_EXPORT void *GL_APIENTRY MapBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access);
ANGLE_EXPORT void GL_APIENTRY FlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length); ANGLE_EXPORT void GL_APIENTRY FlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLsizeiptr length);
// GL_EXT_debug_marker
ANGLE_EXPORT void GL_APIENTRY InsertEventMarkerEXT(GLsizei length, const char *marker);
ANGLE_EXPORT void GL_APIENTRY PushGroupMarkerEXT(GLsizei length, const char *marker);
ANGLE_EXPORT void GL_APIENTRY PopGroupMarkerEXT();
} }
#endif // LIBGLESV2_ENTRYPOINTGLES20EXT_H_ #endif // LIBGLESV2_ENTRYPOINTGLES20EXT_H_
...@@ -1416,4 +1416,19 @@ void GL_APIENTRY glFlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLs ...@@ -1416,4 +1416,19 @@ void GL_APIENTRY glFlushMappedBufferRangeEXT(GLenum target, GLintptr offset, GLs
return gl::FlushMappedBufferRangeEXT(target, offset, length); return gl::FlushMappedBufferRangeEXT(target, offset, length);
} }
void GL_APIENTRY glInsertEventMarkerEXT(GLsizei length, const char *marker)
{
return gl::InsertEventMarkerEXT(length, marker);
}
void GL_APIENTRY glPushGroupMarkerEXT(GLsizei length, const char *marker)
{
return gl::PushGroupMarkerEXT(length, marker);
}
void GL_APIENTRY glPopGroupMarkerEXT()
{
return gl::PopGroupMarkerEXT();
}
} }
...@@ -178,6 +178,9 @@ EXPORTS ...@@ -178,6 +178,9 @@ EXPORTS
glMapBufferRangeEXT @288 glMapBufferRangeEXT @288
glFlushMappedBufferRangeEXT @289 glFlushMappedBufferRangeEXT @289
glDiscardFramebufferEXT @293 glDiscardFramebufferEXT @293
glInsertEventMarkerEXT @294
glPushGroupMarkerEXT @295
glPopGroupMarkerEXT @296
; GLES 3.0 Functions ; GLES 3.0 Functions
glReadBuffer @180 glReadBuffer @180
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
'<(angle_path)/src/tests/gl_tests/ClearTest.cpp', '<(angle_path)/src/tests/gl_tests/ClearTest.cpp',
'<(angle_path)/src/tests/gl_tests/CompressedTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/CompressedTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/CubeMapTextureTest.cpp', '<(angle_path)/src/tests/gl_tests/CubeMapTextureTest.cpp',
'<(angle_path)/src/tests/gl_tests/DebugMarkerTest.cpp',
'<(angle_path)/src/tests/gl_tests/DepthStencilFormatsTest.cpp', '<(angle_path)/src/tests/gl_tests/DepthStencilFormatsTest.cpp',
'<(angle_path)/src/tests/gl_tests/DiscardFramebufferEXTTest.cpp', '<(angle_path)/src/tests/gl_tests/DiscardFramebufferEXTTest.cpp',
'<(angle_path)/src/tests/gl_tests/DrawBuffersTest.cpp', '<(angle_path)/src/tests/gl_tests/DrawBuffersTest.cpp',
......
//
// Copyright 2015 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.
//
// DebugMarkerTest:
// Basic tests to ensure EXT_debug_marker entry points work.
#include "test_utils/ANGLETest.h"
using namespace angle;
namespace
{
class DebugMarkerTest : public ANGLETest
{
protected:
DebugMarkerTest()
{
setWindowWidth(128);
setWindowHeight(128);
setConfigRedBits(8);
setConfigGreenBits(8);
setConfigBlueBits(8);
setConfigAlphaBits(8);
}
};
// Simple test to ensure the various EXT_debug_marker entry points don't crash.
// The debug markers can be validated by capturing this test under PIX/Graphics Diagnostics.
TEST_P(DebugMarkerTest, BasicValidation)
{
if (!extensionEnabled("GL_EXT_debug_marker"))
{
std::cout << "Test skipped due to missing GL_EXT_debug_marker" << std::endl;
return;
}
std::string eventMarkerCaption = "Test event marker caption";
std::string groupMarkerCaption = "Test group marker caption";
glPushGroupMarkerEXT(groupMarkerCaption.length(), groupMarkerCaption.c_str());
// Do some basic operations between calls to extension entry points
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glInsertEventMarkerEXT(eventMarkerCaption.length(), eventMarkerCaption.c_str());
glClearColor(1.0f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glPushGroupMarkerEXT(0, NULL);
glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glPopGroupMarkerEXT();
glClearColor(0.0f, 0.0f, 1.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT);
glPopGroupMarkerEXT();
ASSERT_GL_NO_ERROR();
}
// Use this to select which configurations (e.g. which renderer, which GLES major version) these tests should be run against.
ANGLE_INSTANTIATE_TEST(DebugMarkerTest, ES2_D3D9(), ES2_D3D11(), ES2_OPENGL());
} // namespace
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