diff --git a/util/test/demos/CMakeLists.txt b/util/test/demos/CMakeLists.txt
index d062e059c..828031cc9 100644
--- a/util/test/demos/CMakeLists.txt
+++ b/util/test/demos/CMakeLists.txt
@@ -27,6 +27,7 @@ set(VULKAN_SRC
vk/vk_khr_buffer_address.cpp
vk/vk_large_buffer.cpp
vk/vk_large_descriptor_sets.cpp
+ vk/vk_leak_check.cpp
vk/vk_line_raster.cpp
vk/vk_mesh_zoo.cpp
vk/vk_misaligned_dirty.cpp
@@ -72,6 +73,7 @@ set(OPENGL_SRC
gl/gl_entry_points.cpp
gl/gl_large_bcn_arrays.cpp
gl/gl_large_buffer.cpp
+ gl/gl_leak_check.cpp
gl/gl_marker_test.cpp
gl/gl_map_overrun.cpp
gl/gl_mesh_zoo.cpp
diff --git a/util/test/demos/d3d11/d3d11_leak_check.cpp b/util/test/demos/d3d11/d3d11_leak_check.cpp
new file mode 100644
index 000000000..8a65a0ff5
--- /dev/null
+++ b/util/test/demos/d3d11/d3d11_leak_check.cpp
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019-2021 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 "d3d11_test.h"
+
+RD_TEST(D3D11_Leak_Check, D3D11GraphicsTest)
+{
+ static constexpr const char *Description =
+ "Checks that we don't have memory leaks by exiting if memory usage gets too high, so we can "
+ "wait and capture a late frame to check for leaks.";
+
+ int main()
+ {
+ // initialise, create window, create device, etc
+ if(!Init())
+ return 3;
+
+ ID3DBlobPtr vsblob = Compile(D3DDefaultVertex, "main", "vs_4_0");
+ ID3DBlobPtr psblob = Compile(D3DDefaultPixel, "main", "ps_4_0");
+
+ CreateDefaultInputLayout(vsblob);
+
+ ID3D11VertexShaderPtr vs = CreateVS(vsblob);
+ ID3D11PixelShaderPtr ps = CreatePS(psblob);
+
+ ID3D11BufferPtr vb = MakeBuffer().Vertex().Data(DefaultTri);
+
+ // make a simple texture so that the structured data includes texture initial states
+ ID3D11Texture2DPtr fltTex = MakeTexture(DXGI_FORMAT_R32G32B32A32_FLOAT, 4, 4).RTV();
+ ID3D11RenderTargetViewPtr fltRT = MakeRTV(fltTex);
+
+ while(Running())
+ {
+ // allow a generous 500MB, we're really only after catching big leaks here
+ if(GetMemoryUsage() > 500 * 1000 * 1000)
+ {
+ TEST_ERROR("Memory usage of %llu is too high!", GetMemoryUsage());
+ break;
+ }
+
+ ClearRenderTargetView(bbRTV, {0.2f, 0.2f, 0.2f, 1.0f});
+ ClearRenderTargetView(fltRT, {0.2f, 0.2f, 0.2f, 1.0f});
+
+ IASetVertexBuffer(vb, sizeof(DefaultA2V), 0);
+ ctx->IASetPrimitiveTopology(D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+ ctx->IASetInputLayout(defaultLayout);
+
+ ctx->VSSetShader(vs, NULL, 0);
+ ctx->PSSetShader(ps, NULL, 0);
+
+ RSSetViewport({0.0f, 0.0f, (float)screenWidth, (float)screenHeight, 0.0f, 1.0f});
+
+ ctx->OMSetRenderTargets(1, &bbRTV.GetInterfacePtr(), NULL);
+
+ ctx->Draw(3, 0);
+
+ Present();
+ }
+
+ return 0;
+ }
+};
+
+REGISTER_TEST();
diff --git a/util/test/demos/d3d12/d3d12_leak_check.cpp b/util/test/demos/d3d12/d3d12_leak_check.cpp
new file mode 100644
index 000000000..b928480cb
--- /dev/null
+++ b/util/test/demos/d3d12/d3d12_leak_check.cpp
@@ -0,0 +1,102 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019-2021 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 "d3d12_test.h"
+
+RD_TEST(D3D12_Leak_Check, D3D12GraphicsTest)
+{
+ static constexpr const char *Description =
+ "Checks that we don't have memory leaks by exiting if memory usage gets too high, so we can "
+ "wait and capture a late frame to check for leaks.";
+
+ int main()
+ {
+ // initialise, create window, create device, etc
+ if(!Init())
+ return 3;
+
+ ID3DBlobPtr vsblob = Compile(D3DDefaultVertex, "main", "vs_4_0");
+ ID3DBlobPtr psblob = Compile(D3DDefaultPixel, "main", "ps_4_0");
+
+ ID3D12ResourcePtr vb = MakeBuffer().Data(DefaultTri);
+
+ ID3D12RootSignaturePtr sig = MakeSig({});
+
+ ID3D12PipelineStatePtr pso = MakePSO().RootSig(sig).InputLayout().VS(vsblob).PS(psblob);
+
+ ResourceBarrier(vb, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
+
+ ID3D12ResourcePtr rtvtex = MakeTexture(DXGI_FORMAT_R32G32B32A32_FLOAT, 4, 4)
+ .RTV()
+ .InitialState(D3D12_RESOURCE_STATE_RENDER_TARGET);
+
+ while(Running())
+ {
+ // allow a generous 500MB, we're really only after catching big leaks here
+ if(GetMemoryUsage() > 500 * 1000 * 1000)
+ {
+ TEST_ERROR("Memory usage of %llu is too high!", GetMemoryUsage());
+ break;
+ }
+
+ ID3D12GraphicsCommandListPtr cmd = GetCommandBuffer();
+
+ Reset(cmd);
+
+ ID3D12ResourcePtr bb = StartUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET);
+
+ D3D12_CPU_DESCRIPTOR_HANDLE rtv =
+ MakeRTV(bb).Format(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB).CreateCPU(0);
+
+ ClearRenderTargetView(cmd, rtv, {0.2f, 0.2f, 0.2f, 1.0f});
+
+ ClearRenderTargetView(cmd, MakeRTV(rtvtex).CreateCPU(1), {0.2f, 0.2f, 0.2f, 1.0f});
+
+ cmd->IASetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
+
+ IASetVertexBuffer(cmd, vb, sizeof(DefaultA2V), 0);
+ cmd->SetPipelineState(pso);
+ cmd->SetGraphicsRootSignature(sig);
+
+ RSSetViewport(cmd, {0.0f, 0.0f, (float)screenWidth, (float)screenHeight, 0.0f, 1.0f});
+ RSSetScissorRect(cmd, {0, 0, screenWidth, screenHeight});
+
+ OMSetRenderTargets(cmd, {rtv}, {});
+
+ cmd->DrawInstanced(3, 1, 0, 0);
+
+ FinishUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET);
+
+ cmd->Close();
+
+ Submit({cmd});
+
+ Present();
+ }
+
+ return 0;
+ }
+};
+
+REGISTER_TEST();
diff --git a/util/test/demos/demos.vcxproj b/util/test/demos/demos.vcxproj
index a86ab7ee3..3c208c497 100644
--- a/util/test/demos/demos.vcxproj
+++ b/util/test/demos/demos.vcxproj
@@ -141,6 +141,7 @@
+
@@ -183,6 +184,7 @@
+
@@ -231,6 +233,7 @@
+
@@ -280,6 +283,7 @@
+
diff --git a/util/test/demos/demos.vcxproj.filters b/util/test/demos/demos.vcxproj.filters
index a2daca41b..cd3013832 100644
--- a/util/test/demos/demos.vcxproj.filters
+++ b/util/test/demos/demos.vcxproj.filters
@@ -574,6 +574,18 @@
OpenGL\demos
+
+ Vulkan\demos
+
+
+ OpenGL\demos
+
+
+ D3D12\demos
+
+
+ D3D11\demos
+
diff --git a/util/test/demos/gl/gl_leak_check.cpp b/util/test/demos/gl/gl_leak_check.cpp
new file mode 100644
index 000000000..51213723f
--- /dev/null
+++ b/util/test/demos/gl/gl_leak_check.cpp
@@ -0,0 +1,84 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019-2021 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_Leak_Check, OpenGLGraphicsTest)
+{
+ static constexpr const char *Description =
+ "Checks that we don't have memory leaks by exiting if memory usage gets too high, so we can "
+ "wait and capture a late frame to check for leaks.";
+
+ 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);
+
+ ConfigureDefaultVAO();
+
+ GLuint program = MakeProgram(GLDefaultVertex, GLDefaultPixel);
+
+ // make a simple texture so that the structured data includes texture initial states
+ GLuint tex = MakeTexture();
+ glBindTexture(GL_TEXTURE_2D, tex);
+ glTexStorage2D(GL_TEXTURE_2D, 1, GL_RGBA32F, 4, 4);
+
+ while(Running())
+ {
+ // allow a generous 500MB, we're really only after catching big leaks here
+ if(GetMemoryUsage() > 500 * 1000 * 1000)
+ {
+ TEST_ERROR("Memory usage of %llu is too high!", GetMemoryUsage());
+ break;
+ }
+
+ float col[] = {0.2f, 0.2f, 0.2f, 1.0f};
+ glClearBufferfv(GL_COLOR, 0, col);
+
+ glClearTexImage(tex, 0, GL_RGBA, GL_FLOAT, col);
+
+ glBindVertexArray(vao);
+
+ glUseProgram(program);
+
+ glViewport(0, 0, GLsizei(screenWidth), GLsizei(screenHeight));
+
+ glDrawArrays(GL_TRIANGLES, 0, 3);
+
+ Present();
+ }
+
+ return 0;
+ }
+};
+
+REGISTER_TEST();
diff --git a/util/test/demos/gl/gl_test.h b/util/test/demos/gl/gl_test.h
index 79537902e..ebff4c6ce 100644
--- a/util/test/demos/gl/gl_test.h
+++ b/util/test/demos/gl/gl_test.h
@@ -69,6 +69,8 @@ struct OpenGLGraphicsTest : public GraphicsTest
bool coreProfile = true;
bool gles = false;
+ bool vsync = false;
+
GLuint swapBlitFBO;
GraphicsWindow *mainWindow = NULL;
diff --git a/util/test/demos/gl/gl_test_linux.cpp b/util/test/demos/gl/gl_test_linux.cpp
index 0b8fd7366..d2d0a8227 100644
--- a/util/test/demos/gl/gl_test_linux.cpp
+++ b/util/test/demos/gl/gl_test_linux.cpp
@@ -147,6 +147,9 @@ bool OpenGLGraphicsTest::Init()
return false;
}
+ if(GLX_EXT_swap_control)
+ glXSwapIntervalEXT(vsync ? 1 : 0);
+
PostInit();
return true;
diff --git a/util/test/demos/gl/gl_test_win32.cpp b/util/test/demos/gl/gl_test_win32.cpp
index 8a4e57ecb..49c6b0661 100644
--- a/util/test/demos/gl/gl_test_win32.cpp
+++ b/util/test/demos/gl/gl_test_win32.cpp
@@ -123,6 +123,9 @@ bool OpenGLGraphicsTest::Init()
return false;
}
+ if(WGL_EXT_swap_control)
+ wglSwapIntervalEXT(vsync ? 1 : 0);
+
PostInit();
return true;
diff --git a/util/test/demos/linux/linux_platform.cpp b/util/test/demos/linux/linux_platform.cpp
index 215afa4bd..f5afa5c70 100644
--- a/util/test/demos/linux/linux_platform.cpp
+++ b/util/test/demos/linux/linux_platform.cpp
@@ -23,8 +23,31 @@
******************************************************************************/
#include
+#include
#include "test_common.h"
+uint64_t GetMemoryUsage()
+{
+ FILE *f = fopen("/proc/self/statm", "r");
+
+ if(f == NULL)
+ {
+ RDCWARN("Couldn't open /proc/self/statm");
+ return 0;
+ }
+
+ char line[512] = {};
+ fgets(line, 511, f);
+
+ uint32_t vmPages = 0;
+ int num = sscanf(line, "%u", &vmPages);
+
+ if(num == 1 && vmPages > 0)
+ return vmPages * (uint64_t)sysconf(_SC_PAGESIZE);
+
+ return 0;
+}
+
std::string GetCWD()
{
char cwd[MAX_PATH + 1] = {0};
diff --git a/util/test/demos/test_common.h b/util/test/demos/test_common.h
index f28d28129..27db5282d 100644
--- a/util/test/demos/test_common.h
+++ b/util/test/demos/test_common.h
@@ -287,6 +287,7 @@ void RegisterTest(TestMetadata test);
std::string GetCWD();
std::string GetEnvVar(const char *var);
+uint64_t GetMemoryUsage();
#ifndef ARRAY_COUNT
#define ARRAY_COUNT(arr) (sizeof(arr) / sizeof(arr[0]))
diff --git a/util/test/demos/vk/vk_leak_check.cpp b/util/test/demos/vk/vk_leak_check.cpp
new file mode 100644
index 000000000..c449e438a
--- /dev/null
+++ b/util/test/demos/vk/vk_leak_check.cpp
@@ -0,0 +1,125 @@
+/******************************************************************************
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2019-2021 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 "vk_test.h"
+
+RD_TEST(VK_Leak_Check, VulkanGraphicsTest)
+{
+ static constexpr const char *Description =
+ "Checks that we don't have memory leaks by exiting if memory usage gets too high, so we can "
+ "wait and capture a late frame to check for leaks.";
+
+ int main()
+ {
+ // initialise, create window, create context, etc
+ if(!Init())
+ return 3;
+
+ VkPipelineLayout layout = createPipelineLayout(vkh::PipelineLayoutCreateInfo());
+
+ vkh::GraphicsPipelineCreateInfo pipeCreateInfo;
+
+ pipeCreateInfo.layout = layout;
+ pipeCreateInfo.renderPass = mainWindow->rp;
+
+ pipeCreateInfo.vertexInputState.vertexBindingDescriptions = {vkh::vertexBind(0, DefaultA2V)};
+ pipeCreateInfo.vertexInputState.vertexAttributeDescriptions = {
+ vkh::vertexAttr(0, 0, DefaultA2V, pos), vkh::vertexAttr(1, 0, DefaultA2V, col),
+ vkh::vertexAttr(2, 0, DefaultA2V, uv),
+ };
+
+ pipeCreateInfo.stages = {
+ CompileShaderModule(VKDefaultVertex, ShaderLang::glsl, ShaderStage::vert, "main"),
+ CompileShaderModule(VKDefaultPixel, ShaderLang::glsl, ShaderStage::frag, "main"),
+ };
+
+ VkPipeline pipe = createGraphicsPipeline(pipeCreateInfo);
+
+ AllocatedBuffer vb(
+ this, vkh::BufferCreateInfo(sizeof(DefaultTri), VK_BUFFER_USAGE_VERTEX_BUFFER_BIT |
+ VK_BUFFER_USAGE_TRANSFER_DST_BIT),
+ VmaAllocationCreateInfo({0, VMA_MEMORY_USAGE_CPU_TO_GPU}));
+
+ vb.upload(DefaultTri);
+
+ AllocatedImage offimg(this, vkh::ImageCreateInfo(4, 4, 0, VK_FORMAT_R32G32B32A32_SFLOAT,
+ VK_IMAGE_USAGE_TRANSFER_DST_BIT),
+ VmaAllocationCreateInfo({0, VMA_MEMORY_USAGE_GPU_ONLY}));
+
+ while(Running())
+ {
+ // allow a generous 500MB, we're really only after catching big leaks here
+ if(GetMemoryUsage() > 500 * 1000 * 1000)
+ {
+ TEST_ERROR("Memory usage of %llu is too high!", GetMemoryUsage());
+ break;
+ }
+
+ VkCommandBuffer cmd = GetCommandBuffer();
+
+ vkBeginCommandBuffer(cmd, vkh::CommandBufferBeginInfo());
+
+ VkImage swapimg =
+ StartUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL);
+
+ vkCmdClearColorImage(cmd, swapimg, VK_IMAGE_LAYOUT_GENERAL,
+ vkh::ClearColorValue(0.2f, 0.2f, 0.2f, 1.0f), 1,
+ vkh::ImageSubresourceRange());
+
+ vkh::cmdPipelineBarrier(
+ cmd, {
+ vkh::ImageMemoryBarrier(0, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_UNDEFINED,
+ VK_IMAGE_LAYOUT_GENERAL, offimg.image),
+ });
+
+ vkCmdClearColorImage(cmd, offimg.image, VK_IMAGE_LAYOUT_GENERAL,
+ vkh::ClearColorValue(0.2f, 0.2f, 0.2f, 1.0f), 1,
+ vkh::ImageSubresourceRange());
+
+ vkCmdBeginRenderPass(
+ cmd, vkh::RenderPassBeginInfo(mainWindow->rp, mainWindow->GetFB(), mainWindow->scissor),
+ VK_SUBPASS_CONTENTS_INLINE);
+
+ vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, pipe);
+ vkCmdSetViewport(cmd, 0, 1, &mainWindow->viewport);
+ vkCmdSetScissor(cmd, 0, 1, &mainWindow->scissor);
+ vkh::cmdBindVertexBuffers(cmd, 0, {vb.buffer}, {0});
+ vkCmdDraw(cmd, 3, 1, 0, 0);
+
+ vkCmdEndRenderPass(cmd);
+
+ FinishUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL);
+
+ vkEndCommandBuffer(cmd);
+
+ Submit(0, 1, {cmd});
+
+ Present();
+ }
+
+ return 0;
+ }
+};
+
+REGISTER_TEST();
diff --git a/util/test/demos/win32/win32_platform.cpp b/util/test/demos/win32/win32_platform.cpp
index debf33e82..92b1391a6 100644
--- a/util/test/demos/win32/win32_platform.cpp
+++ b/util/test/demos/win32/win32_platform.cpp
@@ -24,6 +24,34 @@
#include "../test_common.h"
+#include
+
+uint64_t GetMemoryUsage()
+{
+ HANDLE proc = GetCurrentProcess();
+
+ if(proc == NULL)
+ {
+ TEST_ERROR("Couldn't open process: %d", GetLastError());
+ return 0;
+ }
+
+ PROCESS_MEMORY_COUNTERS memInfo = {};
+
+ uint64_t ret = 0;
+
+ if(GetProcessMemoryInfo(proc, &memInfo, sizeof(memInfo)))
+ {
+ ret = memInfo.WorkingSetSize;
+ }
+ else
+ {
+ TEST_ERROR("Couldn't get process memory info: %d", GetLastError());
+ }
+
+ return ret;
+}
+
std::string GetCWD()
{
char cwd[MAX_PATH + 1] = {0};
diff --git a/util/test/tests/D3D11/D3D11_Leak_Check.py b/util/test/tests/D3D11/D3D11_Leak_Check.py
new file mode 100644
index 000000000..0187cc69a
--- /dev/null
+++ b/util/test/tests/D3D11/D3D11_Leak_Check.py
@@ -0,0 +1,16 @@
+import renderdoc as rd
+import rdtest
+
+
+class D3D11_Leak_Check(rdtest.TestCase):
+ demos_test_name = 'D3D11_Leak_Check'
+ demos_frame_cap = 50000
+ demos_frame_count = 1
+
+ def check_capture(self):
+ memory: int = rd.GetCurrentProcessMemoryUsage()
+
+ if memory > 500*1000*1000:
+ raise rdtest.TestFailureException("Memory usage of {} is too high".format(memory))
+
+ rdtest.log.success("Capture {} opened with reasonable memory ({})".format(self.demos_frame_cap, memory))
diff --git a/util/test/tests/D3D12/D3D12_Leak_Check.py b/util/test/tests/D3D12/D3D12_Leak_Check.py
new file mode 100644
index 000000000..e4f24b740
--- /dev/null
+++ b/util/test/tests/D3D12/D3D12_Leak_Check.py
@@ -0,0 +1,16 @@
+import renderdoc as rd
+import rdtest
+
+
+class D3D12_Leak_Check(rdtest.TestCase):
+ demos_test_name = 'D3D12_Leak_Check'
+ demos_frame_cap = 50000
+ demos_frame_count = 1
+
+ def check_capture(self):
+ memory: int = rd.GetCurrentProcessMemoryUsage()
+
+ if memory > 500*1000*1000:
+ raise rdtest.TestFailureException("Memory usage of {} is too high".format(memory))
+
+ rdtest.log.success("Capture {} opened with reasonable memory ({})".format(self.demos_frame_cap, memory))
diff --git a/util/test/tests/GL/GL_Leak_Check.py b/util/test/tests/GL/GL_Leak_Check.py
new file mode 100644
index 000000000..58b1b7622
--- /dev/null
+++ b/util/test/tests/GL/GL_Leak_Check.py
@@ -0,0 +1,16 @@
+import renderdoc as rd
+import rdtest
+
+
+class GL_Leak_Check(rdtest.TestCase):
+ demos_test_name = 'GL_Leak_Check'
+ demos_frame_cap = 50000
+ demos_frame_count = 1
+
+ def check_capture(self):
+ memory: int = rd.GetCurrentProcessMemoryUsage()
+
+ if memory > 500*1000*1000:
+ raise rdtest.TestFailureException("Memory usage of {} is too high".format(memory))
+
+ rdtest.log.success("Capture {} opened with reasonable memory ({})".format(self.demos_frame_cap, memory))
diff --git a/util/test/tests/Vulkan/VK_Leak_Check.py b/util/test/tests/Vulkan/VK_Leak_Check.py
new file mode 100644
index 000000000..9916531c6
--- /dev/null
+++ b/util/test/tests/Vulkan/VK_Leak_Check.py
@@ -0,0 +1,16 @@
+import renderdoc as rd
+import rdtest
+
+
+class VK_Leak_Check(rdtest.TestCase):
+ demos_test_name = 'VK_Leak_Check'
+ demos_frame_cap = 50000
+ demos_frame_count = 1
+
+ def check_capture(self):
+ memory: int = rd.GetCurrentProcessMemoryUsage()
+
+ if memory > 500*1000*1000:
+ raise rdtest.TestFailureException("Memory usage of {} is too high".format(memory))
+
+ rdtest.log.success("Capture {} opened with reasonable memory ({})".format(self.demos_frame_cap, memory))