diff --git a/util/test/demos/CMakeLists.txt b/util/test/demos/CMakeLists.txt index b9a63941d..fd2fd4c8a 100644 --- a/util/test/demos/CMakeLists.txt +++ b/util/test/demos/CMakeLists.txt @@ -11,6 +11,7 @@ set(VULKAN_SRC vk/vk_descriptor_index.cpp vk/vk_discard_rects.cpp vk/vk_draw_zoo.cpp + vk/vk_empty_capture.cpp vk/vk_ext_buffer_address.cpp vk/vk_image_layouts.cpp vk/vk_imageless_framebuffer.cpp @@ -48,6 +49,7 @@ set(OPENGL_SRC gl/gl_callstacks.cpp gl/gl_cbuffer_zoo.cpp gl/gl_depthstencil_fbo.cpp + gl/gl_empty_capture.cpp gl/gl_entry_points.cpp gl/gl_large_bcn_arrays.cpp gl/gl_marker_test.cpp diff --git a/util/test/demos/d3d11/d3d11_empty_capture.cpp b/util/test/demos/d3d11/d3d11_empty_capture.cpp new file mode 100644 index 000000000..4ac297621 --- /dev/null +++ b/util/test/demos/d3d11/d3d11_empty_capture.cpp @@ -0,0 +1,58 @@ +/****************************************************************************** + * 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 "d3d11_test.h" + +RD_TEST(D3D11_Empty_Capture, D3D11GraphicsTest) +{ + static constexpr const char *Description = + "Draws nothing but will trigger a completely empty capture at frame 10."; + + int main() + { + // initialise, create window, create device, etc + if(!Init()) + return 3; + + while(Running()) + { + ClearRenderTargetView(bbRTV, {0.2f, 0.2f, 0.2f, 1.0f}); + + Present(); + + if(curFrame == 10 && rdoc) + { + rdoc->StartFrameCapture(NULL, NULL); + rdoc->EndFrameCapture(NULL, NULL); + } + + if(curFrame > 50) + break; + } + + return 0; + } +}; + +REGISTER_TEST(); diff --git a/util/test/demos/d3d12/d3d12_empty_capture.cpp b/util/test/demos/d3d12/d3d12_empty_capture.cpp new file mode 100644 index 000000000..83caa41db --- /dev/null +++ b/util/test/demos/d3d12/d3d12_empty_capture.cpp @@ -0,0 +1,73 @@ +/****************************************************************************** + * 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 "d3d12_test.h" + +RD_TEST(D3D12_Empty_Capture, D3D12GraphicsTest) +{ + static constexpr const char *Description = + "Draws nothing but will trigger a completely empty capture at frame 10."; + + int main() + { + // initialise, create window, create device, etc + if(!Init()) + return 3; + + while(Running()) + { + 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}); + + FinishUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET); + + cmd->Close(); + + Submit({cmd}); + + Present(); + + if(rdoc) + { + rdoc->StartFrameCapture(NULL, NULL); + rdoc->EndFrameCapture(NULL, NULL); + } + + if(curFrame > 50) + break; + } + + return 0; + } +}; + +REGISTER_TEST(); diff --git a/util/test/demos/demos.vcxproj b/util/test/demos/demos.vcxproj index fc6e71155..7af777531 100644 --- a/util/test/demos/demos.vcxproj +++ b/util/test/demos/demos.vcxproj @@ -128,6 +128,7 @@ + @@ -162,6 +163,7 @@ + @@ -197,6 +199,7 @@ + @@ -236,6 +239,7 @@ + diff --git a/util/test/demos/demos.vcxproj.filters b/util/test/demos/demos.vcxproj.filters index 6171dc33a..b2c62f030 100644 --- a/util/test/demos/demos.vcxproj.filters +++ b/util/test/demos/demos.vcxproj.filters @@ -436,6 +436,18 @@ OpenGL\demos + + Vulkan\demos + + + OpenGL\demos + + + D3D12\demos + + + D3D11\demos + diff --git a/util/test/demos/gl/gl_empty_capture.cpp b/util/test/demos/gl/gl_empty_capture.cpp new file mode 100644 index 000000000..fc3559b55 --- /dev/null +++ b/util/test/demos/gl/gl_empty_capture.cpp @@ -0,0 +1,59 @@ +/****************************************************************************** + * 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_Empty_Capture, OpenGLGraphicsTest) +{ + static constexpr const char *Description = + "Draws nothing but will trigger a completely empty capture at frame 10."; + + int main() + { + // initialise, create window, create context, etc + if(!Init()) + return 3; + + while(Running()) + { + float col[] = {0.2f, 0.2f, 0.2f, 1.0f}; + glClearBufferfv(GL_COLOR, 0, col); + + Present(); + + if(rdoc) + { + rdoc->StartFrameCapture(NULL, NULL); + rdoc->EndFrameCapture(NULL, NULL); + } + + if(curFrame > 50) + break; + } + + return 0; + } +}; + +REGISTER_TEST(); diff --git a/util/test/demos/vk/vk_empty_capture.cpp b/util/test/demos/vk/vk_empty_capture.cpp new file mode 100644 index 000000000..e68e59780 --- /dev/null +++ b/util/test/demos/vk/vk_empty_capture.cpp @@ -0,0 +1,73 @@ +/****************************************************************************** + * 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 "vk_test.h" + +RD_TEST(VK_Empty_Capture, VulkanGraphicsTest) +{ + static constexpr const char *Description = + "Draws nothing but will trigger a completely empty capture at frame 10."; + + int main() + { + // initialise, create window, create context, etc + if(!Init()) + return 3; + + while(Running()) + { + 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()); + + FinishUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL); + + vkEndCommandBuffer(cmd); + + Submit(0, 1, {cmd}); + + Present(); + + if(rdoc) + { + rdoc->StartFrameCapture(NULL, NULL); + rdoc->EndFrameCapture(NULL, NULL); + } + + if(curFrame > 50) + break; + } + + return 0; + } +}; + +REGISTER_TEST(); diff --git a/util/test/tests/D3D11/D3D11_Empty_Capture.py b/util/test/tests/D3D11/D3D11_Empty_Capture.py new file mode 100644 index 000000000..113408173 --- /dev/null +++ b/util/test/tests/D3D11/D3D11_Empty_Capture.py @@ -0,0 +1,14 @@ +import renderdoc as rd +import rdtest + + +class D3D11_Empty_Capture(rdtest.TestCase): + demos_test_name = 'D3D11_Empty_Capture' + demos_frame_cap = 100 + + def check_capture(self): + draws = self.controller.GetDrawcalls() + + self.check(len(draws) == 1) + self.check('End' in draws[0].name) + self.check(draws[0].eventId == 1) \ No newline at end of file diff --git a/util/test/tests/D3D12/D3D12_Empty_Capture.py b/util/test/tests/D3D12/D3D12_Empty_Capture.py new file mode 100644 index 000000000..743b4a175 --- /dev/null +++ b/util/test/tests/D3D12/D3D12_Empty_Capture.py @@ -0,0 +1,14 @@ +import renderdoc as rd +import rdtest + + +class D3D12_Empty_Capture(rdtest.TestCase): + demos_test_name = 'D3D12_Empty_Capture' + demos_frame_cap = 100 + + def check_capture(self): + draws = self.controller.GetDrawcalls() + + self.check(len(draws) == 1) + self.check('End' in draws[0].name) + self.check(draws[0].eventId == 1) \ No newline at end of file diff --git a/util/test/tests/GL/GL_Empty_Capture.py b/util/test/tests/GL/GL_Empty_Capture.py new file mode 100644 index 000000000..ffe80bef9 --- /dev/null +++ b/util/test/tests/GL/GL_Empty_Capture.py @@ -0,0 +1,15 @@ +import renderdoc as rd +import rdtest + + +class GL_Empty_Capture(rdtest.TestCase): + demos_test_name = 'GL_Empty_Capture' + demos_frame_cap = 100 + + def check_capture(self): + draws = self.controller.GetDrawcalls() + + self.check(len(draws) == 1) + self.check('End' in draws[0].name) + # EID 1 is the implicit context activation + self.check(draws[0].eventId == 2) \ No newline at end of file diff --git a/util/test/tests/Vulkan/VK_Empty_Capture.py b/util/test/tests/Vulkan/VK_Empty_Capture.py new file mode 100644 index 000000000..1fe687110 --- /dev/null +++ b/util/test/tests/Vulkan/VK_Empty_Capture.py @@ -0,0 +1,14 @@ +import renderdoc as rd +import rdtest + + +class VK_Empty_Capture(rdtest.TestCase): + demos_test_name = 'VK_Empty_Capture' + demos_frame_cap = 100 + + def check_capture(self): + draws = self.controller.GetDrawcalls() + + self.check(len(draws) == 1) + self.check('End' in draws[0].name) + self.check(draws[0].eventId == 1) \ No newline at end of file