summaryrefslogtreecommitdiffstats
path: root/tools/gfx/open-gl/render-gl.cpp
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2021-04-29 14:19:51 -0700
committerGitHub <noreply@github.com>2021-04-29 14:19:51 -0700
commit2482271fffbe85efc1bd7efcf74a76f6ed436012 (patch)
tree707da083c8eda527b7c548d636cb884cf53c53eb /tools/gfx/open-gl/render-gl.cpp
parentad6f3070251f25cf022c231b8567d78e98061127 (diff)
`gfx` DebugCallback and debug layer. (#1822)
* `gfx` DebugCallback and debug layer.
Diffstat (limited to 'tools/gfx/open-gl/render-gl.cpp')
-rw-r--r--tools/gfx/open-gl/render-gl.cpp28
1 files changed, 18 insertions, 10 deletions
diff --git a/tools/gfx/open-gl/render-gl.cpp b/tools/gfx/open-gl/render-gl.cpp
index d5735add5..3ef3c1aa1 100644
--- a/tools/gfx/open-gl/render-gl.cpp
+++ b/tools/gfx/open-gl/render-gl.cpp
@@ -1789,17 +1789,16 @@ SlangResult SLANG_MCALL createGLDevice(const IDevice::Desc* desc, IDevice** outR
void GLDevice::debugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message)
{
- ::OutputDebugStringA("GL: ");
- ::OutputDebugStringA(message);
- ::OutputDebugStringA("\n");
-
- switch (type)
+ DebugMessageType msgType = DebugMessageType::Info;
+ switch(type)
{
- case GL_DEBUG_TYPE_ERROR:
- break;
- default:
- break;
+ case GL_DEBUG_TYPE_ERROR:
+ msgType = DebugMessageType::Error;
+ break;
+ default:
+ break;
}
+ getDebugCallback()->handleMessage(msgType, DebugMessageSource::Driver, message);
}
/* static */void APIENTRY GLDevice::staticDebugCallback(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam)
@@ -2862,7 +2861,16 @@ Result GLDevice::createProgram(const IShaderProgram::Desc& desc, IShaderProgram*
{
ComPtr<ISlangBlob> kernelCode;
ComPtr<ISlangBlob> diagnostics;
- SLANG_RETURN_ON_FAIL(desc.slangProgram->getEntryPointCode(i, 0, kernelCode.writeRef(), diagnostics.writeRef()));
+ auto compileResult = desc.slangProgram->getEntryPointCode(
+ i, 0, kernelCode.writeRef(), diagnostics.writeRef());
+ if (diagnostics)
+ {
+ getDebugCallback()->handleMessage(
+ compileResult == SLANG_OK ? DebugMessageType::Warning : DebugMessageType::Error,
+ DebugMessageSource::Slang,
+ (char*)diagnostics->getBufferPointer());
+ }
+ SLANG_RETURN_ON_FAIL(compileResult);
GLenum glShaderType = 0;
auto stage = programLayout->getEntryPointByIndex(i)->getStage();
switch (stage)