OpenGL object labels and debug groups

This commit is contained in:
Magnus Norddahl 2016-08-17 23:18:47 +02:00
parent 2825bd4967
commit d380d765c9
13 changed files with 133 additions and 32 deletions

View file

@ -59,6 +59,7 @@
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/system/gl_debug.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
@ -127,6 +128,8 @@ void FGLRenderer::BloomScene()
if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT) if (!gl_bloom || !FGLRenderBuffers::IsEnabled() || gl_fixedcolormap != CM_DEFAULT)
return; return;
FGLDebug::PushGroup("BloomScene");
FGLPostProcessState savedState; FGLPostProcessState savedState;
const float blurAmount = gl_bloom_amount; const float blurAmount = gl_bloom_amount;
@ -196,6 +199,8 @@ void FGLRenderer::BloomScene()
mBloomCombineShader->BloomTexture.Set(0); mBloomCombineShader->BloomTexture.Set(0);
RenderScreenQuad(); RenderScreenQuad();
glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height); glViewport(mScreenViewport.left, mScreenViewport.top, mScreenViewport.width, mScreenViewport.height);
FGLDebug::PopGroup();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -209,6 +214,8 @@ void FGLRenderer::TonemapScene()
if (gl_tonemap == 0 || !FGLRenderBuffers::IsEnabled()) if (gl_tonemap == 0 || !FGLRenderBuffers::IsEnabled())
return; return;
FGLDebug::PushGroup("TonemapScene");
FGLPostProcessState savedState; FGLPostProcessState savedState;
mBuffers->BindNextFB(); mBuffers->BindNextFB();
@ -218,6 +225,8 @@ void FGLRenderer::TonemapScene()
mTonemapShader->Exposure.Set(mCameraExposure); mTonemapShader->Exposure.Set(mCameraExposure);
RenderScreenQuad(); RenderScreenQuad();
mBuffers->NextTexture(); mBuffers->NextTexture();
FGLDebug::PopGroup();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -231,6 +240,8 @@ void FGLRenderer::LensDistortScene()
if (gl_lens == 0 || !FGLRenderBuffers::IsEnabled()) if (gl_lens == 0 || !FGLRenderBuffers::IsEnabled())
return; return;
FGLDebug::PushGroup("LensDistortScene");
float k[4] = float k[4] =
{ {
gl_lens_k, gl_lens_k,
@ -272,6 +283,8 @@ void FGLRenderer::LensDistortScene()
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
mBuffers->NextTexture(); mBuffers->NextTexture();
FGLDebug::PopGroup();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@ -283,6 +296,7 @@ void FGLRenderer::LensDistortScene()
void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma) void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma)
{ {
m2DDrawer->Flush(); // draw all pending 2D stuff before copying the buffer m2DDrawer->Flush(); // draw all pending 2D stuff before copying the buffer
FGLDebug::PushGroup("CopyToBackbuffer");
if (FGLRenderBuffers::IsEnabled()) if (FGLRenderBuffers::IsEnabled())
{ {
FGLPostProcessState savedState; FGLPostProcessState savedState;
@ -327,6 +341,7 @@ void FGLRenderer::CopyToBackbuffer(const GL_IRECT *bounds, bool applyGamma)
FGLPostProcessState savedState; FGLPostProcessState savedState;
ClearBorders(); ClearBorders();
} }
FGLDebug::PopGroup();
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------

View file

@ -47,6 +47,7 @@
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/system/gl_debug.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_renderbuffers.h" #include "gl/renderer/gl_renderbuffers.h"
#include "w_wad.h" #include "w_wad.h"
@ -195,18 +196,18 @@ void FGLRenderBuffers::CreateScene(int width, int height, int samples)
ClearScene(); ClearScene();
if (samples > 1) if (samples > 1)
mSceneMultisample = CreateRenderBuffer(GetHdrFormat(), samples, width, height); mSceneMultisample = CreateRenderBuffer("SceneMultisample", GetHdrFormat(), samples, width, height);
if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0) if ((gl.flags & RFL_NO_DEPTHSTENCIL) != 0)
{ {
mSceneDepth = CreateRenderBuffer(GL_DEPTH_COMPONENT24, samples, width, height); mSceneDepth = CreateRenderBuffer("SceneDepth", GL_DEPTH_COMPONENT24, samples, width, height);
mSceneStencil = CreateRenderBuffer(GL_STENCIL_INDEX8, samples, width, height); mSceneStencil = CreateRenderBuffer("SceneStencil", GL_STENCIL_INDEX8, samples, width, height);
mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1); mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepth, mSceneStencil, samples > 1);
} }
else else
{ {
mSceneDepthStencil = CreateRenderBuffer(GL_DEPTH24_STENCIL8, samples, width, height); mSceneDepthStencil = CreateRenderBuffer("SceneDepthStencil", GL_DEPTH24_STENCIL8, samples, width, height);
mSceneFB = CreateFrameBuffer(samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1); mSceneFB = CreateFrameBuffer("SceneFB", samples > 1 ? mSceneMultisample : mPipelineTexture[0], mSceneDepthStencil, samples > 1);
} }
} }
@ -222,8 +223,8 @@ void FGLRenderBuffers::CreatePipeline(int width, int height)
for (int i = 0; i < NumPipelineTextures; i++) for (int i = 0; i < NumPipelineTextures; i++)
{ {
mPipelineTexture[i] = Create2DTexture(GetHdrFormat(), width, height); mPipelineTexture[i] = Create2DTexture("PipelineTexture", GetHdrFormat(), width, height);
mPipelineFB[i] = CreateFrameBuffer(mPipelineTexture[i]); mPipelineFB[i] = CreateFrameBuffer("PipelineFB", mPipelineTexture[i]);
} }
} }
@ -249,10 +250,10 @@ void FGLRenderBuffers::CreateBloom(int width, int height)
level.Width = MAX(bloomWidth / 2, 1); level.Width = MAX(bloomWidth / 2, 1);
level.Height = MAX(bloomHeight / 2, 1); level.Height = MAX(bloomHeight / 2, 1);
level.VTexture = Create2DTexture(GetHdrFormat(), level.Width, level.Height); level.VTexture = Create2DTexture("Bloom.VTexture", GetHdrFormat(), level.Width, level.Height);
level.HTexture = Create2DTexture(GetHdrFormat(), level.Width, level.Height); level.HTexture = Create2DTexture("Bloom.HTexture", GetHdrFormat(), level.Width, level.Height);
level.VFramebuffer = CreateFrameBuffer(level.VTexture); level.VFramebuffer = CreateFrameBuffer("Bloom.VFramebuffer", level.VTexture);
level.HFramebuffer = CreateFrameBuffer(level.HTexture); level.HFramebuffer = CreateFrameBuffer("Bloom.HFramebuffer", level.HTexture);
bloomWidth = level.Width; bloomWidth = level.Width;
bloomHeight = level.Height; bloomHeight = level.Height;
@ -276,12 +277,13 @@ GLuint FGLRenderBuffers::GetHdrFormat()
// //
//========================================================================== //==========================================================================
GLuint FGLRenderBuffers::Create2DTexture(GLuint format, int width, int height) GLuint FGLRenderBuffers::Create2DTexture(const FString &name, GLuint format, int width, int height)
{ {
GLuint type = (format == GL_RGBA16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE; GLuint type = (format == GL_RGBA16) ? GL_UNSIGNED_SHORT : GL_UNSIGNED_BYTE;
GLuint handle = 0; GLuint handle = 0;
glGenTextures(1, &handle); glGenTextures(1, &handle);
glBindTexture(GL_TEXTURE_2D, handle); glBindTexture(GL_TEXTURE_2D, handle);
FGLDebug::LabelObject(GL_TEXTURE, handle, name);
glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr); glTexImage2D(GL_TEXTURE_2D, 0, format, width, height, 0, GL_RGBA, type, nullptr);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
@ -296,23 +298,25 @@ GLuint FGLRenderBuffers::Create2DTexture(GLuint format, int width, int height)
// //
//========================================================================== //==========================================================================
GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int width, int height) GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int width, int height)
{ {
GLuint handle = 0; GLuint handle = 0;
glGenRenderbuffers(1, &handle); glGenRenderbuffers(1, &handle);
glBindRenderbuffer(GL_RENDERBUFFER, handle); glBindRenderbuffer(GL_RENDERBUFFER, handle);
FGLDebug::LabelObject(GL_RENDERBUFFER, handle, name);
glRenderbufferStorage(GL_RENDERBUFFER, format, width, height); glRenderbufferStorage(GL_RENDERBUFFER, format, width, height);
return handle; return handle;
} }
GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int samples, int width, int height) GLuint FGLRenderBuffers::CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height)
{ {
if (samples <= 1) if (samples <= 1)
return CreateRenderBuffer(format, width, height); return CreateRenderBuffer(name, format, width, height);
GLuint handle = 0; GLuint handle = 0;
glGenRenderbuffers(1, &handle); glGenRenderbuffers(1, &handle);
glBindRenderbuffer(GL_RENDERBUFFER, handle); glBindRenderbuffer(GL_RENDERBUFFER, handle);
FGLDebug::LabelObject(GL_RENDERBUFFER, handle, name);
glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, format, width, height); glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples, format, width, height);
return handle; return handle;
} }
@ -323,22 +327,24 @@ GLuint FGLRenderBuffers::CreateRenderBuffer(GLuint format, int samples, int widt
// //
//========================================================================== //==========================================================================
GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer) GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer)
{ {
GLuint handle = 0; GLuint handle = 0;
glGenFramebuffers(1, &handle); glGenFramebuffers(1, &handle);
glBindFramebuffer(GL_FRAMEBUFFER, handle); glBindFramebuffer(GL_FRAMEBUFFER, handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0); glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorbuffer, 0);
CheckFrameBufferCompleteness(); CheckFrameBufferCompleteness();
ClearFrameBuffer(); ClearFrameBuffer();
return handle; return handle;
} }
GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer) GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer)
{ {
GLuint handle = 0; GLuint handle = 0;
glGenFramebuffers(1, &handle); glGenFramebuffers(1, &handle);
glBindFramebuffer(GL_FRAMEBUFFER, handle); glBindFramebuffer(GL_FRAMEBUFFER, handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name);
if (colorIsARenderBuffer) if (colorIsARenderBuffer)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer);
else else
@ -349,11 +355,12 @@ GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depthstenc
return handle; return handle;
} }
GLuint FGLRenderBuffers::CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer) GLuint FGLRenderBuffers::CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer)
{ {
GLuint handle = 0; GLuint handle = 0;
glGenFramebuffers(1, &handle); glGenFramebuffers(1, &handle);
glBindFramebuffer(GL_FRAMEBUFFER, handle); glBindFramebuffer(GL_FRAMEBUFFER, handle);
FGLDebug::LabelObject(GL_FRAMEBUFFER, handle, name);
if (colorIsARenderBuffer) if (colorIsARenderBuffer)
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer); glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, colorbuffer);
else else

View file

@ -47,12 +47,12 @@ private:
void CreateScene(int width, int height, int samples); void CreateScene(int width, int height, int samples);
void CreatePipeline(int width, int height); void CreatePipeline(int width, int height);
void CreateBloom(int width, int height); void CreateBloom(int width, int height);
GLuint Create2DTexture(GLuint format, int width, int height); GLuint Create2DTexture(const FString &name, GLuint format, int width, int height);
GLuint CreateRenderBuffer(GLuint format, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int width, int height);
GLuint CreateRenderBuffer(GLuint format, int samples, int width, int height); GLuint CreateRenderBuffer(const FString &name, GLuint format, int samples, int width, int height);
GLuint CreateFrameBuffer(GLuint colorbuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer);
GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depthstencil, bool colorIsARenderBuffer);
GLuint CreateFrameBuffer(GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer); GLuint CreateFrameBuffer(const FString &name, GLuint colorbuffer, GLuint depth, GLuint stencil, bool colorIsARenderBuffer);
void CheckFrameBufferCompleteness(); void CheckFrameBufferCompleteness();
void ClearFrameBuffer(); void ClearFrameBuffer();
void DeleteTexture(GLuint &handle); void DeleteTexture(GLuint &handle);

View file

@ -54,6 +54,7 @@
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
#include "gl/system/gl_framebuffer.h" #include "gl/system/gl_framebuffer.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/system/gl_debug.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/renderer/gl_lightdata.h" #include "gl/renderer/gl_lightdata.h"
#include "gl/renderer/gl_renderstate.h" #include "gl/renderer/gl_renderstate.h"
@ -131,6 +132,7 @@ void FGLRenderer::Initialize(int width, int height)
{ {
glGenVertexArrays(1, &mVAOID); glGenVertexArrays(1, &mVAOID);
glBindVertexArray(mVAOID); glBindVertexArray(mVAOID);
FGLDebug::LabelObject(GL_VERTEX_ARRAY, mVAOID, "FGLRenderer.mVAOID");
} }
else mVAOID = 0; else mVAOID = 0;
@ -366,9 +368,13 @@ void FGLRenderer::FlushTextures()
bool FGLRenderer::StartOffscreen() bool FGLRenderer::StartOffscreen()
{ {
if (mFBID == 0) glGenFramebuffers(1, &mFBID); bool firstBind = (mFBID == 0);
if (mFBID == 0)
glGenFramebuffers(1, &mFBID);
glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID); glGetIntegerv(GL_FRAMEBUFFER_BINDING, &mOldFBID);
glBindFramebuffer(GL_FRAMEBUFFER, mFBID); glBindFramebuffer(GL_FRAMEBUFFER, mFBID);
if (firstBind)
FGLDebug::LabelObject(GL_FRAMEBUFFER, mFBID, "OffscreenFB");
return true; return true;
} }

View file

@ -50,6 +50,7 @@
#include "cmdlib.h" #include "cmdlib.h"
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
#include "gl/system/gl_debug.h"
#include "gl/data/gl_data.h" #include "gl/data/gl_data.h"
#include "gl/data/gl_matrix.h" #include "gl/data/gl_matrix.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
@ -179,6 +180,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
hVertProg = glCreateShader(GL_VERTEX_SHADER); hVertProg = glCreateShader(GL_VERTEX_SHADER);
hFragProg = glCreateShader(GL_FRAGMENT_SHADER); hFragProg = glCreateShader(GL_FRAGMENT_SHADER);
FGLDebug::LabelObject(GL_SHADER, hVertProg, vert_prog_lump);
FGLDebug::LabelObject(GL_SHADER, hFragProg, frag_prog_lump);
int vp_size = (int)vp_comb.Len(); int vp_size = (int)vp_comb.Len();
int fp_size = (int)fp_comb.Len(); int fp_size = (int)fp_comb.Len();
@ -193,6 +196,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
glCompileShader(hFragProg); glCompileShader(hFragProg);
hShader = glCreateProgram(); hShader = glCreateProgram();
FGLDebug::LabelObject(GL_PROGRAM, hShader, name);
glAttachShader(hShader, hVertProg); glAttachShader(hShader, hVertProg);
glAttachShader(hShader, hFragProg); glAttachShader(hShader, hFragProg);

View file

@ -46,6 +46,7 @@
#include "vectors.h" #include "vectors.h"
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/system/gl_debug.h"
#include "gl/shaders/gl_shaderprogram.h" #include "gl/shaders/gl_shaderprogram.h"
#include "w_wad.h" #include "w_wad.h"
#include "i_system.h" #include "i_system.h"
@ -107,6 +108,8 @@ void FShaderProgram::Compile(ShaderType type, const char *name, const FString &c
const auto &handle = mShaders[type]; const auto &handle = mShaders[type];
FGLDebug::LabelObject(GL_SHADER, handle, name);
FString patchedCode = PatchShader(type, code, defines, maxGlslVersion); FString patchedCode = PatchShader(type, code, defines, maxGlslVersion);
int lengths[1] = { (int)patchedCode.Len() }; int lengths[1] = { (int)patchedCode.Len() };
const char *sources[1] = { patchedCode.GetChars() }; const char *sources[1] = { patchedCode.GetChars() };
@ -147,6 +150,7 @@ void FShaderProgram::SetFragDataLocation(int index, const char *name)
void FShaderProgram::Link(const char *name) void FShaderProgram::Link(const char *name)
{ {
FGLDebug::LabelObject(GL_PROGRAM, mProgram, name);
glLinkProgram(mProgram); glLinkProgram(mProgram);
GLint status = 0; GLint status = 0;

View file

@ -63,6 +63,52 @@ void FGLDebug::Update()
OutputMessageLog(); OutputMessageLog();
} }
//-----------------------------------------------------------------------------
//
// Label objects so they are referenced by name in debug messages and in
// OpenGL debuggers (renderdoc)
//
//-----------------------------------------------------------------------------
void FGLDebug::LabelObject(GLenum type, GLuint handle, const FString &name)
{
if (gl_debug_level != 0)
{
glObjectLabel(type, handle, (GLsizei)name.Len(), name.GetChars());
}
}
void FGLDebug::LabelObjectPtr(void *ptr, const FString &name)
{
if (gl_debug_level != 0)
{
glObjectPtrLabel(ptr, (GLsizei)name.Len(), name.GetChars());
}
}
//-----------------------------------------------------------------------------
//
// Marks which render pass/group is executing commands so that debuggers can
// display this information
//
//-----------------------------------------------------------------------------
void FGLDebug::PushGroup(const FString &name)
{
if (gl_debug_level != 0)
{
glPushDebugGroup(GL_DEBUG_SOURCE_APPLICATION, 0, (GLsizei)name.Len(), name.GetChars());
}
}
void FGLDebug::PopGroup()
{
if (gl_debug_level != 0)
{
glPopDebugGroup();
}
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// //
// Turns on synchronous debugging on and off based on gl_debug_breakpoint // Turns on synchronous debugging on and off based on gl_debug_breakpoint
@ -160,6 +206,9 @@ void FGLDebug::OutputMessageLog()
void FGLDebug::PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message) void FGLDebug::PrintMessage(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar *message)
{ {
if (type == GL_DEBUG_TYPE_PUSH_GROUP || type == GL_DEBUG_TYPE_POP_GROUP)
return;
static int messagesPrinted = 0; static int messagesPrinted = 0;
messagesPrinted++; messagesPrinted++;
if (messagesPrinted == 50) if (messagesPrinted == 50)

View file

@ -11,6 +11,12 @@ class FGLDebug
public: public:
void Update(); void Update();
static void LabelObject(GLenum type, GLuint handle, const FString &name);
static void LabelObjectPtr(void *ptr, const FString &name);
static void PushGroup(const FString &name);
static void PopGroup();
private: private:
void SetupBreakpointMode(); void SetupBreakpointMode();
void UpdateLoggingLevel(); void UpdateLoggingLevel();

View file

@ -153,7 +153,7 @@ bool OpenGLFrameBuffer::WipeStartScreen(int type)
const auto &viewport = GLRenderer->mScreenViewport; const auto &viewport = GLRenderer->mScreenViewport;
wipestartscreen = new FHardwareTexture(viewport.width, viewport.height, true); wipestartscreen = new FHardwareTexture(viewport.width, viewport.height, true);
wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0); wipestartscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen");
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1); GLRenderer->mSamplerManager->Bind(1, CLAMP_NONE, -1);
glFinish(); glFinish();
@ -193,7 +193,7 @@ void OpenGLFrameBuffer::WipeEndScreen()
const auto &viewport = GLRenderer->mScreenViewport; const auto &viewport = GLRenderer->mScreenViewport;
wipeendscreen = new FHardwareTexture(viewport.width, viewport.height, true); wipeendscreen = new FHardwareTexture(viewport.width, viewport.height, true);
wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0); wipeendscreen->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen");
GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1); GLRenderer->mSamplerManager->Bind(0, CLAMP_NOFILTER, -1);
glFinish(); glFinish();
wipeendscreen->Bind(0, false, false); wipeendscreen->Bind(0, false, false);
@ -565,7 +565,7 @@ bool OpenGLFrameBuffer::Wiper_Burn::Run(int ticks, OpenGLFrameBuffer *fb)
// Burn the new screen on top of it. // Burn the new screen on top of it.
fb->wipeendscreen->Bind(0, 0, false); fb->wipeendscreen->Bind(0, 0, false);
BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0); BurnTexture->CreateTexture(rgb_buffer, WIDTH, HEIGHT, 1, true, 0, "BurnTexture");
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
gl_RenderState.SetEffect(EFF_NONE); gl_RenderState.SetEffect(EFF_NONE);

View file

@ -48,6 +48,7 @@
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/system/gl_debug.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl/textures/gl_material.h" #include "gl/textures/gl_material.h"
@ -184,7 +185,7 @@ void FHardwareTexture::Resize(int width, int height, unsigned char *src_data, un
// //
//=========================================================================== //===========================================================================
unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation) unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const FString &name)
{ {
int rh,rw; int rh,rw;
int texformat=TexFormat[gl_texture_format]; int texformat=TexFormat[gl_texture_format];
@ -198,6 +199,7 @@ unsigned int FHardwareTexture::CreateTexture(unsigned char * buffer, int w, int
if (glTex->glTexID==0) glGenTextures(1,&glTex->glTexID); if (glTex->glTexID==0) glGenTextures(1,&glTex->glTexID);
if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit); if (texunit != 0) glActiveTexture(GL_TEXTURE0+texunit);
glBindTexture(GL_TEXTURE_2D, glTex->glTexID); glBindTexture(GL_TEXTURE_2D, glTex->glTexID);
FGLDebug::LabelObject(GL_TEXTURE, glTex->glTexID, name);
lastbound[texunit] = glTex->glTexID; lastbound[texunit] = glTex->glTexID;
if (!buffer) if (!buffer)

View file

@ -77,7 +77,7 @@ public:
void BindToFrameBuffer(); void BindToFrameBuffer();
unsigned int Bind(int texunit, int translation, bool needmipmap); unsigned int Bind(int texunit, int translation, bool needmipmap);
unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation); unsigned int CreateTexture(unsigned char * buffer, int w, int h, int texunit, bool mipmap, int translation, const FString &name);
void Clean(bool all); void Clean(bool all);
void CleanUnused(SpriteHits &usedtranslations); void CleanUnused(SpriteHits &usedtranslations);

View file

@ -337,7 +337,7 @@ const FHardwareTexture *FGLTexture::Bind(int texunit, int clampmode, int transla
} }
tex->ProcessData(buffer, w, h, false); tex->ProcessData(buffer, w, h, false);
} }
if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation)) if (!hwtex->CreateTexture(buffer, w, h, texunit, needmipmap, translation, "FGLTexture.Bind"))
{ {
// could not create texture // could not create texture
delete[] buffer; delete[] buffer;

View file

@ -42,6 +42,7 @@
#include "gl/system/gl_interface.h" #include "gl/system/gl_interface.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
#include "gl/system/gl_debug.h"
#include "gl/renderer/gl_renderer.h" #include "gl/renderer/gl_renderer.h"
#include "gl_samplers.h" #include "gl_samplers.h"
#include "gl_material.h" #include "gl_material.h"
@ -67,6 +68,13 @@ FSamplerManager::FSamplerManager()
glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glSamplerParameteri(mSamplers[3], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glSamplerParameteri(mSamplers[4], GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
for (int i = 0; i < 7; i++)
{
FString name;
name.Format("mSamplers[%d]", i);
FGLDebug::LabelObject(GL_SAMPLER, mSamplers[i], name);
}
} }
} }