diff --git a/util/test/demos/CMakeLists.txt b/util/test/demos/CMakeLists.txt
index d099518f6..ec2faf436 100644
--- a/util/test/demos/CMakeLists.txt
+++ b/util/test/demos/CMakeLists.txt
@@ -76,6 +76,7 @@ set(OPENGL_SRC
gl/gl_callstacks.cpp
gl/gl_cbuffer_zoo.cpp
gl/gl_depthstencil_fbo.cpp
+ gl/gl_depth_bounds.cpp
gl/gl_discard_zoo.cpp
gl/gl_draw_zoo.cpp
gl/gl_empty_capture.cpp
diff --git a/util/test/demos/demos.vcxproj b/util/test/demos/demos.vcxproj
index 5d9618c1b..1b86dec10 100644
--- a/util/test/demos/demos.vcxproj
+++ b/util/test/demos/demos.vcxproj
@@ -230,6 +230,7 @@
+
diff --git a/util/test/demos/demos.vcxproj.filters b/util/test/demos/demos.vcxproj.filters
index ba4496a80..d5682026c 100644
--- a/util/test/demos/demos.vcxproj.filters
+++ b/util/test/demos/demos.vcxproj.filters
@@ -625,6 +625,9 @@
Vulkan\demos
+
+ OpenGL\demos
+
diff --git a/util/test/demos/gl/gl_depth_bounds.cpp b/util/test/demos/gl/gl_depth_bounds.cpp
new file mode 100644
index 000000000..894026f81
--- /dev/null
+++ b/util/test/demos/gl/gl_depth_bounds.cpp
@@ -0,0 +1,90 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019-2022 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_Depth_Bounds, OpenGLGraphicsTest)
+{
+ static constexpr const char *Description = "Tests of depth bounds and interactions.";
+
+ int main()
+ {
+ // initialise, create window, create context, etc
+ if(!Init())
+ return 3;
+
+ GLuint vao = MakeVAO();
+ glBindVertexArray(vao);
+
+ const DefaultA2V tri[3] = {
+ {Vec3f(-0.5f, -0.5f, -0.9f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 0.0f)},
+ {Vec3f(0.0f, 0.5f, 0.0f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 1.0f)},
+ {Vec3f(0.5f, -0.5f, 0.9f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(1.0f, 0.0f)},
+ };
+
+ GLuint vb = MakeBuffer();
+ glBindBuffer(GL_ARRAY_BUFFER, vb);
+ glBufferData(GL_ARRAY_BUFFER, sizeof(tri), tri, GL_STATIC_DRAW);
+
+ ConfigureDefaultVAO();
+
+ glDepthBoundsEXT(0.2f, 0.8f);
+ glEnable(GL_DEPTH_BOUNDS_TEST_EXT);
+ glEnable(GL_DEPTH_TEST);
+ glDepthFunc(GL_LEQUAL);
+ glDepthMask(GL_TRUE);
+
+ GLuint program = MakeProgram(GLDefaultVertex, GLDefaultPixel);
+
+ while(Running())
+ {
+ glDisable(GL_DEPTH_BOUNDS_TEST_EXT);
+ float col[] = {1.0f, 0.0f, 1.0f, 1.0f};
+ glClearBufferfv(GL_COLOR, 0, col);
+ glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0f, 0);
+
+ glBindVertexArray(vao);
+
+ glUseProgram(program);
+
+ glViewport(0, 0, GLsizei(screenWidth), GLsizei(screenHeight));
+
+ glDisable(GL_DEPTH_BOUNDS_TEST_EXT);
+ glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+
+ setMarker("Test");
+
+ glEnable(GL_DEPTH_BOUNDS_TEST_EXT);
+ glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+
+ Present();
+ }
+
+ return 0;
+ }
+};
+
+REGISTER_TEST();
diff --git a/util/test/tests/GL/GL_Depth_Bounds.py b/util/test/tests/GL/GL_Depth_Bounds.py
new file mode 100644
index 000000000..7c6b251ff
--- /dev/null
+++ b/util/test/tests/GL/GL_Depth_Bounds.py
@@ -0,0 +1,34 @@
+import copy
+import rdtest
+import renderdoc as rd
+from typing import Tuple
+
+
+class GL_Depth_Bounds(rdtest.TestCase):
+ demos_test_name = 'GL_Depth_Bounds'
+
+ def check_capture(self):
+ eid = self.find_action("Test").next.eventId
+ self.controller.SetFrameEvent(eid, False)
+
+ glpipe = self.controller.GetGLPipelineState()
+
+ self.check(glpipe.depthState.depthBounds)
+
+ if (not rdtest.value_compare(glpipe.depthState.nearBound, 0.2) or
+ not rdtest.value_compare(glpipe.depthState.farBound, 0.8)):
+ raise rdtest.TestFailureException("Bounds {} - {} aren't as expected"
+ .format(glpipe.depthState.nearBound, glpipe.depthState.farBound))
+
+ pipe = self.controller.GetPipelineState()
+
+ tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
+
+ self.check_pixel_value(tex, 200, 200, [0.0, 1.0, 0.0, 1.0])
+ self.check_pixel_value(tex, 200, 100, [0.0, 1.0, 0.0, 1.0])
+ self.check_pixel_value(tex, 125, 100, [1.0, 0.0, 1.0, 1.0])
+ self.check_pixel_value(tex, 125, 200, [1.0, 0.0, 1.0, 1.0])
+ self.check_pixel_value(tex, 275, 100, [1.0, 0.0, 1.0, 1.0])
+ self.check_pixel_value(tex, 275, 200, [1.0, 0.0, 1.0, 1.0])
+
+ rdtest.log.success("Triangle is clipped as expected")