diff --git a/util/test/demos/CMakeLists.txt b/util/test/demos/CMakeLists.txt
index cd8a7efb5..a44c079c1 100644
--- a/util/test/demos/CMakeLists.txt
+++ b/util/test/demos/CMakeLists.txt
@@ -44,6 +44,7 @@ set(OPENGL_SRC
gl/gl_test_linux.cpp
gl/gl_buffer_spam.cpp
gl/gl_buffer_updates.cpp
+ gl/gl_callstacks.cpp
gl/gl_cbuffer_zoo.cpp
gl/gl_depthstencil_fbo.cpp
gl/gl_entry_points.cpp
diff --git a/util/test/demos/demos.vcxproj b/util/test/demos/demos.vcxproj
index 5dca80021..a067f0dd9 100644
--- a/util/test/demos/demos.vcxproj
+++ b/util/test/demos/demos.vcxproj
@@ -180,6 +180,7 @@
+
diff --git a/util/test/demos/demos.vcxproj.filters b/util/test/demos/demos.vcxproj.filters
index 835311d4b..31e3314ec 100644
--- a/util/test/demos/demos.vcxproj.filters
+++ b/util/test/demos/demos.vcxproj.filters
@@ -373,6 +373,9 @@
D3D12\demos
+
+ OpenGL\demos
+
diff --git a/util/test/demos/gl/gl_callstacks.cpp b/util/test/demos/gl/gl_callstacks.cpp
new file mode 100644
index 000000000..62440d3f3
--- /dev/null
+++ b/util/test/demos/gl/gl_callstacks.cpp
@@ -0,0 +1,127 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019-2020 Baldur Karlsson
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ ******************************************************************************/
+
+#include "gl_test.h"
+
+RD_TEST(GL_Callstacks, OpenGLGraphicsTest)
+{
+ static constexpr const char *Description =
+ "This test isn't strictly GL related but tests that callstacks resolve correctly.";
+
+ std::string common = R"EOSHADER(
+
+#version 420 core
+
+#define v2f v2f_block \
+{ \
+ vec4 pos; \
+ vec4 col; \
+ vec4 uv; \
+}
+
+)EOSHADER";
+
+ std::string vertex = R"EOSHADER(
+
+layout(location = 0) in vec3 Position;
+layout(location = 1) in vec4 Color;
+layout(location = 2) in vec2 UV;
+
+out v2f vertOut;
+
+void main()
+{
+ vertOut.pos = vec4(Position.xyz, 1);
+ gl_Position = vertOut.pos;
+ vertOut.col = Color;
+ vertOut.uv = vec4(UV.xy, 0, 1);
+}
+
+)EOSHADER";
+
+ std::string pixel = R"EOSHADER(
+
+in v2f vertIn;
+
+layout(location = 0, index = 0) out vec4 Color;
+
+void main()
+{
+ Color = vertIn.col;
+}
+
+)EOSHADER";
+
+ void testFunction()
+ {
+#line 7000
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+ }
+
+ int main()
+ {
+ // initialise, create window, create context, etc
+ if(!Init())
+ return 3;
+
+ GLuint vao = MakeVAO();
+ glBindVertexArray(vao);
+
+ GLuint vb = MakeBuffer();
+ glBindBuffer(GL_ARRAY_BUFFER, vb);
+ glBufferStorage(GL_ARRAY_BUFFER, sizeof(DefaultTri), DefaultTri, 0);
+
+ glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(DefaultA2V), (void *)(0));
+ glVertexAttribPointer(1, 4, GL_FLOAT, GL_FALSE, sizeof(DefaultA2V), (void *)(sizeof(Vec3f)));
+ glVertexAttribPointer(2, 2, GL_FLOAT, GL_FALSE, sizeof(DefaultA2V),
+ (void *)(sizeof(Vec3f) + sizeof(Vec4f)));
+
+ glEnableVertexAttribArray(0);
+ glEnableVertexAttribArray(1);
+ glEnableVertexAttribArray(2);
+
+ GLuint program = MakeProgram(common + vertex, common + pixel);
+
+ while(Running())
+ {
+ float col[] = {0.4f, 0.5f, 0.6f, 1.0f};
+ glClearBufferfv(GL_COLOR, 0, col);
+
+ glBindVertexArray(vao);
+
+ glUseProgram(program);
+
+ glViewport(0, 0, GLsizei(screenWidth), GLsizei(screenHeight));
+
+#line 8000
+ testFunction();
+
+ Present();
+ }
+
+ return 0;
+ }
+};
+
+REGISTER_TEST();
diff --git a/util/test/tests/GL/GL_Callstacks.py b/util/test/tests/GL/GL_Callstacks.py
new file mode 100644
index 000000000..cfca585a4
--- /dev/null
+++ b/util/test/tests/GL/GL_Callstacks.py
@@ -0,0 +1,61 @@
+import renderdoc as rd
+import rdtest
+
+
+class GL_Callstacks(rdtest.TestCase):
+ demos_test_name = 'GL_Callstacks'
+
+ def get_capture_options(self):
+ ret = rd.CaptureOptions()
+ ret.captureCallstacks = True
+ return ret
+
+ def check_capture(self):
+ # Need capture access. Rather than trying to keep the original around, we just open a new one
+ cap = rd.OpenCaptureFile()
+
+ # Open a particular file
+ status = cap.OpenFile(self.capture_filename, '', None)
+
+ # Make sure the file opened successfully
+ if status != rd.ReplayStatus.Succeeded:
+ cap.Shutdown()
+ raise rdtest.TestFailureException("Couldn't open capture for access: {}".format(self.capture_filename, str(status)))
+
+ if not cap.HasCallstacks():
+ raise rdtest.TestFailureException("Capture does not report having callstacks")
+
+ if not cap.InitResolver(False, None):
+ raise rdtest.TestFailureException("Failed to initialise callstack resolver")
+
+ draw = self.find_draw("Draw")
+
+ event: rd.APIEvent = draw.events[-1]
+
+ expected_funcs = [
+ "GL_Callstacks::testFunction",
+ "GL_Callstacks::main",
+ ]
+
+ expected_lines = [
+ 7001,
+ 8002
+ ]
+
+ callstack = cap.GetResolve(list(event.callstack))
+
+ if len(callstack) < len(expected_funcs):
+ raise rdtest.TestFailureException("Resolved callstack isn't long enough ({} stack frames), expected at least {}".format(len(event.callstack), len(expected_funcs)))
+
+ for i in range(len(expected_funcs)):
+ stack: str = callstack[i]
+ if expected_funcs[i] not in stack:
+ raise rdtest.TestFailureException("Expected '{}' in '{}'".format(expected_funcs[i], stack))
+ idx = callstack[i].find("line")
+ if idx < 0:
+ raise rdtest.TestFailureException("Expected a line number in '{}'".format(stack))
+
+ if int(stack[idx+5:]) != expected_lines[i]:
+ raise rdtest.TestFailureException("Expected line number {} in '{}'".format(expected_lines[i], stack))
+
+ rdtest.log.success("Callstacks are as expected")