From ac44765bd7b8677d12083cb73d0a109ed2891a52 Mon Sep 17 00:00:00 2001 From: baldurk Date: Thu, 31 Dec 2015 22:33:15 +0100 Subject: [PATCH] Implement highlight box rendering --- renderdoc/data/embedded_files.h | 2 + renderdoc/data/renderdoc.rc | 2 + renderdoc/data/resource.h | 2 + renderdoc/data/spv/generic.frag | 39 ++++++++ renderdoc/data/spv/generic.vert | 46 +++++++++ renderdoc/driver/vulkan/vk_debug.cpp | 135 ++++++++++++++++++++++++-- renderdoc/driver/vulkan/vk_debug.h | 21 ++-- renderdoc/driver/vulkan/vk_replay.cpp | 89 ++++++++++++++++- renderdoc/renderdoc.vcxproj | 4 + renderdoc/renderdoc.vcxproj.filters | 12 +++ 10 files changed, 335 insertions(+), 17 deletions(-) create mode 100644 renderdoc/data/spv/generic.frag create mode 100644 renderdoc/data/spv/generic.vert diff --git a/renderdoc/data/embedded_files.h b/renderdoc/data/embedded_files.h index 8da73cee5..3a4c4e962 100644 --- a/renderdoc/data/embedded_files.h +++ b/renderdoc/data/embedded_files.h @@ -52,5 +52,7 @@ DECLARE_EMBED(checkerboardfs_spv); DECLARE_EMBED(texdisplayfs_spv); DECLARE_EMBED(textvs_spv); DECLARE_EMBED(textfs_spv); +DECLARE_EMBED(genericvs_spv); +DECLARE_EMBED(genericfs_spv); #undef DECLARE_EMBED diff --git a/renderdoc/data/renderdoc.rc b/renderdoc/data/renderdoc.rc index 7d46c78b6..c6aedd3f8 100644 --- a/renderdoc/data/renderdoc.rc +++ b/renderdoc/data/renderdoc.rc @@ -136,6 +136,8 @@ RESOURCE_checkerboardfs_spv TYPE_EMBED "spv/checkerboardfs.spv" RESOURCE_texdisplayfs_spv TYPE_EMBED "spv/texdisplayfs.spv" RESOURCE_textvs_spv TYPE_EMBED "spv/textvs.spv" RESOURCE_textfs_spv TYPE_EMBED "spv/textfs.spv" +RESOURCE_genericvs_spv TYPE_EMBED "spv/genericvs.spv" +RESOURCE_genericfs_spv TYPE_EMBED "spv/genericfs.spv" #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// diff --git a/renderdoc/data/resource.h b/renderdoc/data/resource.h index ab659df2f..1d8b18fff 100644 --- a/renderdoc/data/resource.h +++ b/renderdoc/data/resource.h @@ -38,6 +38,8 @@ #define RESOURCE_texdisplayfs_spv 403 #define RESOURCE_textvs_spv 404 #define RESOURCE_textfs_spv 405 +#define RESOURCE_genericvs_spv 406 +#define RESOURCE_genericfs_spv 407 #if !defined(STRINGIZE) #define STRINGIZE2(a) #a diff --git a/renderdoc/data/spv/generic.frag b/renderdoc/data/spv/generic.frag new file mode 100644 index 000000000..09d5c519a --- /dev/null +++ b/renderdoc/data/spv/generic.frag @@ -0,0 +1,39 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2014 Crytek + * + * 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. + ******************************************************************************/ + +#version 420 core + +layout (location = 0) out vec4 color_out; + +layout (binding = 0, std140) uniform genericuniforms +{ + vec4 offset; + vec4 scale; + vec4 color; +} generic; + +void main(void) +{ + color_out = generic.color; +} diff --git a/renderdoc/data/spv/generic.vert b/renderdoc/data/spv/generic.vert new file mode 100644 index 000000000..c8cd2e0ed --- /dev/null +++ b/renderdoc/data/spv/generic.vert @@ -0,0 +1,46 @@ +/****************************************************************************** + * The MIT License (MIT) + * + * Copyright (c) 2014 Crytek + * + * 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. + ******************************************************************************/ + +#version 420 core + +layout (location = 0) in vec4 position; + +layout (binding = 0, std140) uniform genericuniforms +{ + vec4 offset; + vec4 scale; + vec4 color; +} generic; + +out gl_PerVertex +{ + vec4 gl_Position; + float gl_PointSize; + float gl_ClipDistance[]; +}; + +void main(void) +{ + gl_Position = position*generic.scale + generic.offset; +} diff --git a/renderdoc/driver/vulkan/vk_debug.cpp b/renderdoc/driver/vulkan/vk_debug.cpp index ba7175d3c..aa0caaab5 100644 --- a/renderdoc/driver/vulkan/vk_debug.cpp +++ b/renderdoc/driver/vulkan/vk_debug.cpp @@ -62,6 +62,13 @@ struct fontuniforms Vec2f CharacterSize; Vec2f FontScreenAspect; }; + +struct genericuniforms +{ + Vec4f Offset; + Vec4f Scale; + Vec4f Color; +}; struct glyph { @@ -79,7 +86,7 @@ struct stringdata uint32_t str[256][4]; }; -void VulkanDebugManager::UBO::Create(WrappedVulkan *driver, VkDevice dev, VkDeviceSize size) +void VulkanDebugManager::GPUBuffer::Create(WrappedVulkan *driver, VkDevice dev, VkDeviceSize size) { const VkLayerDispatchTable *vt = ObjDisp(dev); @@ -124,7 +131,7 @@ void VulkanDebugManager::UBO::Create(WrappedVulkan *driver, VkDevice dev, VkDevi VKMGR()->WrapResource(Unwrap(dev), view); } -void VulkanDebugManager::UBO::Destroy(const VkLayerDispatchTable *vt, VkDevice dev) +void VulkanDebugManager::GPUBuffer::Destroy(const VkLayerDispatchTable *vt, VkDevice dev) { VkResult vkr = VK_SUCCESS; if(view != VK_NULL_HANDLE) @@ -152,7 +159,7 @@ void VulkanDebugManager::UBO::Destroy(const VkLayerDispatchTable *vt, VkDevice d } } -void *VulkanDebugManager::UBO::Map(const VkLayerDispatchTable *vt, VkDevice dev, VkDeviceSize offset, VkDeviceSize size) +void *VulkanDebugManager::GPUBuffer::Map(const VkLayerDispatchTable *vt, VkDevice dev, VkDeviceSize offset, VkDeviceSize size) { void *ptr = NULL; VkResult vkr = vt->MapMemory(Unwrap(dev), Unwrap(mem), offset, size, 0, (void **)&ptr); @@ -160,7 +167,7 @@ void *VulkanDebugManager::UBO::Map(const VkLayerDispatchTable *vt, VkDevice dev, return ptr; } -void VulkanDebugManager::UBO::Unmap(const VkLayerDispatchTable *vt, VkDevice dev) +void VulkanDebugManager::GPUBuffer::Unmap(const VkLayerDispatchTable *vt, VkDevice dev) { vt->UnmapMemory(Unwrap(dev), Unwrap(mem)); } @@ -200,6 +207,11 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) m_TextAtlasMem = VK_NULL_HANDLE; m_TextAtlasView = VK_NULL_HANDLE; + m_GenericDescSetLayout = VK_NULL_HANDLE; + m_GenericPipeLayout = VK_NULL_HANDLE; + m_GenericDescSet = VK_NULL_HANDLE; + m_GenericPipeline = VK_NULL_HANDLE; + m_Device = dev; const VkLayerDispatchTable *vt = ObjDisp(dev); @@ -247,6 +259,12 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) RDCASSERT(vkr == VK_SUCCESS); VKMGR()->WrapResource(Unwrap(dev), m_CheckerboardDescSetLayout); + + // identical layout + vkr = vt->CreateDescriptorSetLayout(Unwrap(dev), &descsetLayoutInfo, &m_GenericDescSetLayout); + RDCASSERT(vkr == VK_SUCCESS); + + VKMGR()->WrapResource(Unwrap(dev), m_GenericDescSetLayout); } { @@ -310,6 +328,13 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) VKMGR()->WrapResource(Unwrap(dev), m_TextPipeLayout); + pipeLayoutInfo.pSetLayouts = UnwrapPtr(m_GenericDescSetLayout); + + vkr = vt->CreatePipelineLayout(Unwrap(dev), &pipeLayoutInfo, &m_GenericPipeLayout); + RDCASSERT(vkr == VK_SUCCESS); + + VKMGR()->WrapResource(Unwrap(dev), m_GenericPipeLayout); + VkDescriptorTypeCount descPoolTypes[] = { { VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, 1024, }, { VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, 1024, }, @@ -320,7 +345,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) ARRAY_COUNT(descPoolTypes), &descPoolTypes[0], }; - vkr = vt->CreateDescriptorPool(Unwrap(dev), VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT, 3, &descpoolInfo, &m_DescriptorPool); + vkr = vt->CreateDescriptorPool(Unwrap(dev), VK_DESCRIPTOR_POOL_USAGE_ONE_SHOT, 4, &descpoolInfo, &m_DescriptorPool); RDCASSERT(vkr == VK_SUCCESS); VKMGR()->WrapResource(Unwrap(dev), m_DescriptorPool); @@ -343,6 +368,40 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) RDCASSERT(vkr == VK_SUCCESS); VKMGR()->WrapResource(Unwrap(dev), m_TextDescSet); + + vkr = vt->AllocDescriptorSets(Unwrap(dev), Unwrap(m_DescriptorPool), VK_DESCRIPTOR_SET_USAGE_STATIC, 1, + UnwrapPtr(m_GenericDescSetLayout), &m_GenericDescSet, &count); + RDCASSERT(vkr == VK_SUCCESS); + + VKMGR()->WrapResource(Unwrap(dev), m_GenericDescSet); + + m_GenericUBO.Create(driver, dev, 128); + RDCCOMPILE_ASSERT(sizeof(genericuniforms) <= 128, "outline strip VBO size"); + + { + float data[] = { + 0.0f, -1.0f, 0.0f, 1.0f, + 1.0f, -1.0f, 0.0f, 1.0f, + + 1.0f, -1.0f, 0.0f, 1.0f, + 1.0f, 0.0f, 0.0f, 1.0f, + + 1.0f, 0.0f, 0.0f, 1.0f, + 0.0f, 0.0f, 0.0f, 1.0f, + + 0.0f, 0.1f, 0.0f, 1.0f, + 0.0f, -1.0f, 0.0f, 1.0f, + }; + + m_OutlineStripVBO.Create(driver, dev, 128); + RDCCOMPILE_ASSERT(sizeof(data) <= 128, "outline strip VBO size"); + + float *mapped = (float *)m_OutlineStripVBO.Map(vt, dev); + + memcpy(mapped, data, sizeof(data)); + + m_OutlineStripVBO.Unmap(vt, dev); + } m_CheckerboardUBO.Create(driver, dev, 128); m_TexDisplayUBO.Create(driver, dev, 128); @@ -391,6 +450,8 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) GetEmbeddedResource(texdisplayfs_spv), GetEmbeddedResource(textvs_spv), GetEmbeddedResource(textfs_spv), + GetEmbeddedResource(genericvs_spv), + GetEmbeddedResource(genericfs_spv), }; enum shaderIdx @@ -400,6 +461,8 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) TEXDISPLAYFS, TEXTVS, TEXTFS, + GENERICVS, + GENERICFS, }; VkShaderModule module[ARRAY_COUNT(shaderSources)]; @@ -530,6 +593,35 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) RDCASSERT(vkr == VK_SUCCESS); VKMGR()->WrapResource(Unwrap(dev), m_TextPipeline); + + ia.topology = VK_PRIMITIVE_TOPOLOGY_LINE_LIST; + attState.blendEnable = false; + + VkVertexInputBindingDescription vertexBind = { + 0, sizeof(Vec4f), VK_VERTEX_INPUT_STEP_RATE_VERTEX, + }; + + VkVertexInputAttributeDescription vertexAttr = { + 0, 0, VK_FORMAT_R32G32B32A32_SFLOAT, 0, + }; + + VkPipelineVertexInputStateCreateInfo vi = { + VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, NULL, + 1, &vertexBind, + 1, &vertexAttr, + }; + + pipeInfo.pVertexInputState = &vi; + + stages[0].shader = Unwrap(shader[GENERICVS]); + stages[1].shader = Unwrap(shader[GENERICFS]); + + pipeInfo.layout = Unwrap(m_GenericPipeLayout); + + vkr = vt->CreateGraphicsPipelines(Unwrap(dev), VK_NULL_HANDLE, 1, &pipeInfo, &m_GenericPipeline); + RDCASSERT(vkr == VK_SUCCESS); + + VKMGR()->WrapResource(Unwrap(dev), m_GenericPipeline); for(size_t i=0; i < ARRAY_COUNT(module); i++) { @@ -694,7 +786,7 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) m_TextGlyphUBO.Unmap(vt, dev); } - VkDescriptorInfo desc[6]; + VkDescriptorInfo desc[7]; RDCEraseEl(desc); // checkerboard @@ -711,6 +803,9 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) desc[5].imageLayout = VK_IMAGE_LAYOUT_GENERAL; desc[5].imageView = Unwrap(m_TextAtlasView); desc[5].sampler = Unwrap(m_LinearSampler); + + // generic + desc[6].bufferView = Unwrap(m_GenericUBO.view); VkWriteDescriptorSet writeSet[] = { { @@ -737,6 +832,10 @@ VulkanDebugManager::VulkanDebugManager(WrappedVulkan *driver, VkDevice dev) VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL, Unwrap(m_TextDescSet), 3, 0, 1, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, &desc[5] }, + { + VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET, NULL, + Unwrap(m_GenericDescSet), 0, 0, 1, VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, &desc[6] + }, }; vkr = vt->UpdateDescriptorSets(Unwrap(dev), ARRAY_COUNT(writeSet), writeSet, 0, NULL); @@ -889,6 +988,30 @@ VulkanDebugManager::~VulkanDebugManager() RDCASSERT(vkr == VK_SUCCESS); VKMGR()->ReleaseWrappedResource(m_TextAtlasMem); } + + if(m_GenericDescSetLayout != VK_NULL_HANDLE) + { + vkr = vt->DestroyDescriptorSetLayout(Unwrap(dev), Unwrap(m_GenericDescSetLayout)); + RDCASSERT(vkr == VK_SUCCESS); + VKMGR()->ReleaseWrappedResource(m_GenericDescSetLayout); + } + + if(m_GenericPipeLayout != VK_NULL_HANDLE) + { + vkr = vt->DestroyPipelineLayout(Unwrap(dev), Unwrap(m_GenericPipeLayout)); + RDCASSERT(vkr == VK_SUCCESS); + VKMGR()->ReleaseWrappedResource(m_GenericPipeLayout); + } + + if(m_GenericPipeline != VK_NULL_HANDLE) + { + vkr = vt->DestroyPipeline(Unwrap(dev), Unwrap(m_GenericPipeline)); + RDCASSERT(vkr == VK_SUCCESS); + VKMGR()->ReleaseWrappedResource(m_GenericPipeline); + } + + m_OutlineStripVBO.Destroy(vt, dev); + m_GenericUBO.Destroy(vt, dev); } void VulkanDebugManager::RenderText(const TextPrintState &textstate, float x, float y, const char *textfmt, ...) diff --git a/renderdoc/driver/vulkan/vk_debug.h b/renderdoc/driver/vulkan/vk_debug.h index f8c2c8724..8121b8b91 100644 --- a/renderdoc/driver/vulkan/vk_debug.h +++ b/renderdoc/driver/vulkan/vk_debug.h @@ -48,9 +48,9 @@ class VulkanDebugManager void RenderText(const TextPrintState &textstate, float x, float y, const char *fmt, ...); - struct UBO + struct GPUBuffer { - UBO() : buf(VK_NULL_HANDLE), mem(VK_NULL_HANDLE), view(VK_NULL_HANDLE) {} + GPUBuffer() : buf(VK_NULL_HANDLE), mem(VK_NULL_HANDLE), view(VK_NULL_HANDLE) {} void Create(WrappedVulkan *driver, VkDevice dev, VkDeviceSize size); void Destroy(const VkLayerDispatchTable *vt, VkDevice dev); @@ -73,21 +73,28 @@ class VulkanDebugManager VkPipelineLayout m_CheckerboardPipeLayout; VkDescriptorSet m_CheckerboardDescSet; VkPipeline m_CheckerboardPipeline; - UBO m_CheckerboardUBO; + GPUBuffer m_CheckerboardUBO; + + VkDescriptorSetLayout m_GenericDescSetLayout; + VkPipelineLayout m_GenericPipeLayout; + VkDescriptorSet m_GenericDescSet; + VkPipeline m_GenericPipeline; + GPUBuffer m_OutlineStripVBO; + GPUBuffer m_GenericUBO; VkDescriptorSetLayout m_TexDisplayDescSetLayout; VkPipelineLayout m_TexDisplayPipeLayout; VkDescriptorSet m_TexDisplayDescSet; VkPipeline m_TexDisplayPipeline, m_TexDisplayBlendPipeline; - UBO m_TexDisplayUBO; + GPUBuffer m_TexDisplayUBO; VkDescriptorSetLayout m_TextDescSetLayout; VkPipelineLayout m_TextPipeLayout; VkDescriptorSet m_TextDescSet; VkPipeline m_TextPipeline; - UBO m_TextGeneralUBO; - UBO m_TextGlyphUBO; - UBO m_TextStringUBO; + GPUBuffer m_TextGeneralUBO; + GPUBuffer m_TextGlyphUBO; + GPUBuffer m_TextStringUBO; VkImage m_TextAtlas; VkDeviceMemory m_TextAtlasMem; VkImageView m_TextAtlasView; diff --git a/renderdoc/driver/vulkan/vk_replay.cpp b/renderdoc/driver/vulkan/vk_replay.cpp index 957b0a17f..7a1c601f8 100644 --- a/renderdoc/driver/vulkan/vk_replay.cpp +++ b/renderdoc/driver/vulkan/vk_replay.cpp @@ -55,6 +55,13 @@ struct displayuniforms Vec2f Padding; }; +struct genericuniforms +{ + Vec4f Offset; + Vec4f Scale; + Vec4f Color; +}; + VulkanReplay::OutputWindow::OutputWindow() : wnd(NULL_WND_HANDLE), width(0), height(0), dsimg(VK_NULL_HANDLE), dsmem(VK_NULL_HANDLE) { @@ -847,8 +854,6 @@ void VulkanReplay::RenderCheckerboard(Vec3f light, Vec3f dark) vkr = vt->BeginCommandBuffer(Unwrap(cmd), &beginInfo); RDCASSERT(vkr == VK_SUCCESS); - void *barrier = (void *)&outw.bbtrans; - // VKTODOHIGH once we stop doing DeviceWaitIdle/QueueWaitIdle all over, this // needs to be ring-buffered Vec4f *data = (Vec4f *)GetDebugManager()->m_CheckerboardUBO.Map(vt, dev); @@ -896,9 +901,85 @@ void VulkanReplay::RenderCheckerboard(Vec3f light, Vec3f dark) void VulkanReplay::RenderHighlightBox(float w, float h, float scale) { - VULKANNOTIMP("RenderHighlightBox"); -} + auto it = m_OutputWindows.find(m_ActiveWinID); + if(m_ActiveWinID == 0 || it == m_OutputWindows.end()) + return; + + OutputWindow &outw = it->second; + + VkDevice dev = m_pDriver->GetDev(); + VkCmdBuffer cmd = m_pDriver->GetCmd(); + VkQueue q = m_pDriver->GetQ(); + const VkLayerDispatchTable *vt = ObjDisp(dev); + + VkCmdBufferBeginInfo beginInfo = { VK_STRUCTURE_TYPE_CMD_BUFFER_BEGIN_INFO, NULL, VK_CMD_BUFFER_OPTIMIZE_SMALL_BATCH_BIT | VK_CMD_BUFFER_OPTIMIZE_ONE_TIME_SUBMIT_BIT }; + VkResult vkr = vt->ResetCommandBuffer(Unwrap(cmd), 0); + RDCASSERT(vkr == VK_SUCCESS); + vkr = vt->BeginCommandBuffer(Unwrap(cmd), &beginInfo); + RDCASSERT(vkr == VK_SUCCESS); + + const float xpixdim = 2.0f/w; + const float ypixdim = 2.0f/h; + + const float xdim = scale*xpixdim; + const float ydim = scale*ypixdim; + + // VKTODOHIGH once we stop doing DeviceWaitIdle/QueueWaitIdle all over, this + // needs to be ring-buffered + genericuniforms *data = (genericuniforms *)GetDebugManager()->m_GenericUBO.Map(vt, dev); + data->Offset = Vec4f(0.0f, 0.0f, 0.0f, 0.0f); + data->Scale = Vec4f(xdim, ydim, 1.0f, 1.0f); + data->Color = Vec4f(1.0f, 1.0f, 1.0f, 1.0f); + GetDebugManager()->m_GenericUBO.Unmap(vt, dev); + + { + VkClearValue clearval = {0}; + VkRenderPassBeginInfo rpbegin = { + VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO, NULL, + Unwrap(outw.renderpass), Unwrap(outw.fb), + { { 0, 0, }, { outw.width, outw.height } }, + 1, &clearval, + }; + vt->CmdBeginRenderPass(Unwrap(cmd), &rpbegin, VK_RENDER_PASS_CONTENTS_INLINE); + + vt->CmdBindPipeline(Unwrap(cmd), VK_PIPELINE_BIND_POINT_GRAPHICS, Unwrap(GetDebugManager()->m_GenericPipeline)); + vt->CmdBindDescriptorSets(Unwrap(cmd), VK_PIPELINE_BIND_POINT_GRAPHICS, Unwrap(GetDebugManager()->m_GenericPipeLayout), 0, 1, UnwrapPtr(GetDebugManager()->m_GenericDescSet), 0, NULL); + + vt->CmdBindDynamicViewportState(Unwrap(cmd), Unwrap(outw.fullVP)); + vt->CmdBindDynamicRasterState(Unwrap(cmd), Unwrap(GetDebugManager()->m_DynamicRSState)); + vt->CmdBindDynamicColorBlendState(Unwrap(cmd), Unwrap(GetDebugManager()->m_DynamicCBStateWhite)); + vt->CmdBindDynamicDepthStencilState(Unwrap(cmd), Unwrap(GetDebugManager()->m_DynamicDSStateDisabled)); + + VkDeviceSize zero = 0; + vt->CmdBindVertexBuffers(Unwrap(cmd), 0, 1, UnwrapPtr(GetDebugManager()->m_OutlineStripVBO.buf), &zero); + + vt->CmdDraw(Unwrap(cmd), 0, 8, 0, 1); + + genericuniforms secondOutline; + secondOutline.Offset = Vec4f(-xpixdim, ypixdim, 0.0f, 0.0f); + secondOutline.Scale = Vec4f(xdim+xpixdim*2, ydim+ypixdim*2, 1.0f, 1.0f); + secondOutline.Color = Vec4f(0.0f, 0.0f, 0.0f, 1.0f); + + vt->CmdUpdateBuffer(Unwrap(cmd), Unwrap(GetDebugManager()->m_GenericUBO.buf), 0, sizeof(genericuniforms), (uint32_t *)&secondOutline); + + vt->CmdDraw(Unwrap(cmd), 0, 8, 0, 1); + + vt->CmdEndRenderPass(Unwrap(cmd)); + } + + vkr = vt->EndCommandBuffer(Unwrap(cmd)); + RDCASSERT(vkr == VK_SUCCESS); + + vkr = vt->QueueSubmit(Unwrap(q), 1, UnwrapPtr(cmd), VK_NULL_HANDLE); + RDCASSERT(vkr == VK_SUCCESS); + + // VKTODOMED ideally all the commands from Bind to Flip would be recorded + // into a single command buffer and we can just have several allocated + // ring-buffer style + vt->QueueWaitIdle(Unwrap(q)); +} + ResourceId VulkanReplay::RenderOverlay(ResourceId texid, TextureDisplayOverlay overlay, uint32_t frameID, uint32_t eventID, const vector &passEvents) { RDCUNIMPLEMENTED("RenderOverlay"); diff --git a/renderdoc/renderdoc.vcxproj b/renderdoc/renderdoc.vcxproj index c38612b9d..ed8ce97fd 100644 --- a/renderdoc/renderdoc.vcxproj +++ b/renderdoc/renderdoc.vcxproj @@ -361,6 +361,10 @@ + + + + diff --git a/renderdoc/renderdoc.vcxproj.filters b/renderdoc/renderdoc.vcxproj.filters index 16d177975..9d7f80528 100644 --- a/renderdoc/renderdoc.vcxproj.filters +++ b/renderdoc/renderdoc.vcxproj.filters @@ -460,6 +460,18 @@ Resources\spv + + Resources\spv + + + Resources\spv + + + Resources\spv + + + Resources\spv +