Skip to content

Commit

Permalink
libgui|GL: Debugging shaders
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Sep 1, 2019
1 parent feaff7c commit dc14c25
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
13 changes: 12 additions & 1 deletion doomsday/libs/gui/src/graphics/glshader.cpp
Expand Up @@ -43,7 +43,7 @@ DENG2_PIMPL(GLShader)
{
if (!name)
{
name = LIBGUI_GL.glCreateShader(type == Vertex ? GL_VERTEX_SHADER
name = LIBGUI_GL.glCreateShader(type == Vertex ? GL_VERTEX_SHADER
: type == Geometry ? GL_GEOMETRY_SHADER
: GL_FRAGMENT_SHADER);
LIBGUI_ASSERT_GL_OK();
Expand Down Expand Up @@ -221,6 +221,17 @@ void GLShader::compile(Type shaderType, IByteArray const &shaderSource)
Block log{Block::Size(logSize)};
LIBGUI_GL.glGetShaderInfoLog(d->name, logSize, &count, reinterpret_cast<GLchar *>(log.data()));

#if defined (DENG2_DEBUG)
{
QTextStream ins(src);
int lineNum = 1;
while (!ins.atEnd())
{
qDebug("%4i: %s", lineNum++, ins.readLine().toLatin1().constData());
}
}
#endif

throw CompilerError("GLShader::compile",
"Compilation of " + String(d->type == Fragment? "fragment" :
d->type == Geometry? "geometry" :
Expand Down
8 changes: 7 additions & 1 deletion doomsday/libs/gui/src/graphics/glshaderbank.cpp
Expand Up @@ -33,6 +33,11 @@

namespace de {

//static int countLines(String const &text)
//{
// return text.count(QChar('\n'));
//}

static String processIncludes(String source, String const &sourceFolderPath)
{
QRegularExpression const re("#include\\s+['\"]([^\"']+)['\"]");
Expand All @@ -46,7 +51,8 @@ static String processIncludes(String source, String const &sourceFolderPath)
incSource = processIncludes(incSource, incFilePath.fileNamePath());

Rangei const capRange(found.capturedStart(), found.capturedEnd());
source = source.substr(0, capRange.start)
String const prefix = source.substr(0, capRange.start);
source = prefix //+ String::format("#line %i\n", countLines(prefix))
+ incSource
+ source.substr(capRange.end);
}
Expand Down
9 changes: 9 additions & 0 deletions doomsday/libs/gui/src/graphics/modeldrawable.cpp
Expand Up @@ -1685,6 +1685,15 @@ void ModelDrawable::drawInstanced(GLBuffer const &instanceAttribs,
{
d->drawInstanced(instanceAttribs, animation);
}
#if defined (DENG2_DEBUG)
else
{
qDebug() << "[ModelDrawable] drawInstanced isReady:"
<< isReady()
<< "program:" << d->program
<< "atlas:" << d->glData.textureBank.atlas();
}
#endif
}

ModelDrawable::Pass const *ModelDrawable::currentPass() const
Expand Down

0 comments on commit dc14c25

Please sign in to comment.