diff --git a/src/dxvk/hud/dxvk_hud.cpp b/src/dxvk/hud/dxvk_hud.cpp index 4fcd3bd20..22b9e8053 100644 --- a/src/dxvk/hud/dxvk_hud.cpp +++ b/src/dxvk/hud/dxvk_hud.cpp @@ -87,7 +87,7 @@ namespace dxvk::hud { HudPos position = { 8.0f, 24.0f }; if (m_config.elements.test(HudElement::DxvkVersion)) { - m_renderer.drawText(ctx, 16.0f, + m_renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, "DXVK " DXVK_VERSION); @@ -95,20 +95,18 @@ namespace dxvk::hud { } if (m_config.elements.test(HudElement::DxvkClientApi)) { - m_renderer.drawText(ctx, 16.0f, + m_renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, m_device->clientApi()); position.y += 24.0f; } - if (m_config.elements.test(HudElement::DeviceInfo)) { - position = m_hudDeviceInfo.render( - ctx, m_renderer, position); - } + if (m_config.elements.test(HudElement::DeviceInfo)) + position = m_hudDeviceInfo.render(m_renderer, position); - position = m_hudFramerate.render(ctx, m_renderer, position); - position = m_hudStats .render(ctx, m_renderer, position); + position = m_hudFramerate.render(m_renderer, position); + position = m_hudStats .render(m_renderer, position); } diff --git a/src/dxvk/hud/dxvk_hud_devinfo.cpp b/src/dxvk/hud/dxvk_hud_devinfo.cpp index 4b1604d42..811d19c1e 100644 --- a/src/dxvk/hud/dxvk_hud_devinfo.cpp +++ b/src/dxvk/hud/dxvk_hud_devinfo.cpp @@ -22,20 +22,19 @@ namespace dxvk::hud { HudPos HudDeviceInfo::render( - const Rc& context, HudRenderer& renderer, HudPos position) { - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, m_deviceName); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y + 24 }, { 1.0f, 1.0f, 1.0f, 1.0f }, m_driverVer); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y + 44 }, { 1.0f, 1.0f, 1.0f, 1.0f }, m_vulkanVer); diff --git a/src/dxvk/hud/dxvk_hud_devinfo.h b/src/dxvk/hud/dxvk_hud_devinfo.h index 43da89092..7036d3c28 100644 --- a/src/dxvk/hud/dxvk_hud_devinfo.h +++ b/src/dxvk/hud/dxvk_hud_devinfo.h @@ -18,7 +18,6 @@ namespace dxvk::hud { ~HudDeviceInfo(); HudPos render( - const Rc& context, HudRenderer& renderer, HudPos position); diff --git a/src/dxvk/hud/dxvk_hud_fps.cpp b/src/dxvk/hud/dxvk_hud_fps.cpp index f8cb6e7dc..dc3a42d60 100644 --- a/src/dxvk/hud/dxvk_hud_fps.cpp +++ b/src/dxvk/hud/dxvk_hud_fps.cpp @@ -43,28 +43,22 @@ namespace dxvk::hud { HudPos HudFps::render( - const Rc& context, HudRenderer& renderer, HudPos position) { - if (m_elements.test(HudElement::Framerate)) { - position = this->renderFpsText( - context, renderer, position); - } + if (m_elements.test(HudElement::Framerate)) + position = this->renderFpsText(renderer, position); - if (m_elements.test(HudElement::Frametimes)) { - position = this->renderFrametimeGraph( - context, renderer, position); - } + if (m_elements.test(HudElement::Frametimes)) + position = this->renderFrametimeGraph(renderer, position); return position; } HudPos HudFps::renderFpsText( - const Rc& context, HudRenderer& renderer, HudPos position) { - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, m_fpsString); @@ -74,7 +68,6 @@ namespace dxvk::hud { HudPos HudFps::renderFrametimeGraph( - const Rc& context, HudRenderer& renderer, HudPos position) { std::array vData; @@ -116,15 +109,15 @@ namespace dxvk::hud { vData[2 * i + 1] = HudLineVertex { { x, y - h }, color }; } - renderer.drawLines(context, vData.size(), vData.data()); + renderer.drawLines(vData.size(), vData.data()); // Paint min/max frame times in the entire window - renderer.drawText(context, 14.0f, + renderer.drawText(14.0f, { position.x, position.y + 44.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, str::format("min: ", minMs / 10, ".", minMs % 10)); - renderer.drawText(context, 14.0f, + renderer.drawText(14.0f, { position.x + 150.0f, position.y + 44.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, str::format("max: ", maxMs / 10, ".", maxMs % 10)); diff --git a/src/dxvk/hud/dxvk_hud_fps.h b/src/dxvk/hud/dxvk_hud_fps.h index a7d16c27d..e3db750f5 100644 --- a/src/dxvk/hud/dxvk_hud_fps.h +++ b/src/dxvk/hud/dxvk_hud_fps.h @@ -27,7 +27,6 @@ namespace dxvk::hud { void update(); HudPos render( - const Rc& context, HudRenderer& renderer, HudPos position); @@ -45,12 +44,10 @@ namespace dxvk::hud { uint32_t m_dataPointId = 0; HudPos renderFpsText( - const Rc& context, HudRenderer& renderer, HudPos position); HudPos renderFrametimeGraph( - const Rc& context, HudRenderer& renderer, HudPos position); diff --git a/src/dxvk/hud/dxvk_hud_renderer.cpp b/src/dxvk/hud/dxvk_hud_renderer.cpp index 10a2b277c..076d34f44 100644 --- a/src/dxvk/hud/dxvk_hud_renderer.cpp +++ b/src/dxvk/hud/dxvk_hud_renderer.cpp @@ -36,25 +36,23 @@ namespace dxvk::hud { m_mode = Mode::RenderNone; m_surfaceSize = surfaceSize; + m_context = context; } void HudRenderer::drawText( - const Rc& context, float size, HudPos pos, HudColor color, const std::string& text) { - beginTextRendering(context); + beginTextRendering(); uint32_t vertexCount = 6 * text.size(); - auto vertexSlice = allocVertexBuffer(context, - vertexCount * sizeof(HudTextVertex)); - - context->bindVertexBuffer(0, vertexSlice, sizeof(HudTextVertex)); - context->pushConstants(0, sizeof(color), &color); - context->draw(vertexCount, 1, 0, 0); + auto vertexSlice = allocVertexBuffer(vertexCount * sizeof(HudTextVertex)); + m_context->bindVertexBuffer(0, vertexSlice, sizeof(HudTextVertex)); + m_context->pushConstants(0, sizeof(color), &color); + m_context->draw(vertexCount, 1, 0, 0); auto vertexData = reinterpret_cast( vertexSlice.getSliceHandle().mapPtr); @@ -108,16 +106,13 @@ namespace dxvk::hud { void HudRenderer::drawLines( - const Rc& context, size_t vertexCount, const HudLineVertex* vertexData) { - beginLineRendering(context); + beginLineRendering(); - auto vertexSlice = allocVertexBuffer(context, - vertexCount * sizeof(HudLineVertex)); - - context->bindVertexBuffer(0, vertexSlice, sizeof(HudLineVertex)); - context->draw(vertexCount, 1, 0, 0); + auto vertexSlice = allocVertexBuffer(vertexCount * sizeof(HudLineVertex)); + m_context->bindVertexBuffer(0, vertexSlice, sizeof(HudLineVertex)); + m_context->draw(vertexCount, 1, 0, 0); auto dstVertexData = reinterpret_cast( vertexSlice.getSliceHandle().mapPtr); @@ -128,12 +123,11 @@ namespace dxvk::hud { DxvkBufferSlice HudRenderer::allocVertexBuffer( - const Rc& context, VkDeviceSize dataSize) { dataSize = align(dataSize, 64); if (m_vertexOffset + dataSize > m_vertexBuffer->info().size) { - context->invalidateBuffer(m_vertexBuffer, m_vertexBuffer->allocSlice()); + m_context->invalidateBuffer(m_vertexBuffer, m_vertexBuffer->allocSlice()); m_vertexOffset = 0; } @@ -143,13 +137,12 @@ namespace dxvk::hud { } - void HudRenderer::beginTextRendering( - const Rc& context) { + void HudRenderer::beginTextRendering() { if (m_mode != Mode::RenderText) { m_mode = Mode::RenderText; - context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, m_textShaders.vert); - context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, m_textShaders.frag); + m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, m_textShaders.vert); + m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, m_textShaders.frag); static const DxvkInputAssemblyState iaState = { VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST, @@ -164,8 +157,8 @@ namespace dxvk::hud { { 0, VK_VERTEX_INPUT_RATE_VERTEX }, }}; - context->setInputAssemblyState(iaState); - context->setInputLayout( + m_context->setInputAssemblyState(iaState); + m_context->setInputLayout( ilAttributes.size(), ilAttributes.data(), ilBindings.size(), @@ -174,13 +167,12 @@ namespace dxvk::hud { } - void HudRenderer::beginLineRendering( - const Rc& context) { + void HudRenderer::beginLineRendering() { if (m_mode != Mode::RenderLines) { m_mode = Mode::RenderLines; - context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, m_lineShaders.vert); - context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, m_lineShaders.frag); + m_context->bindShader(VK_SHADER_STAGE_VERTEX_BIT, m_lineShaders.vert); + m_context->bindShader(VK_SHADER_STAGE_FRAGMENT_BIT, m_lineShaders.frag); static const DxvkInputAssemblyState iaState = { VK_PRIMITIVE_TOPOLOGY_LINE_LIST, @@ -195,8 +187,8 @@ namespace dxvk::hud { { 0, VK_VERTEX_INPUT_RATE_VERTEX }, }}; - context->setInputAssemblyState(iaState); - context->setInputLayout( + m_context->setInputAssemblyState(iaState); + m_context->setInputLayout( ilAttributes.size(), ilAttributes.data(), ilBindings.size(), diff --git a/src/dxvk/hud/dxvk_hud_renderer.h b/src/dxvk/hud/dxvk_hud_renderer.h index 8d30091aa..8b658c49d 100644 --- a/src/dxvk/hud/dxvk_hud_renderer.h +++ b/src/dxvk/hud/dxvk_hud_renderer.h @@ -88,14 +88,12 @@ namespace dxvk::hud { VkExtent2D surfaceSize); void drawText( - const Rc& context, float size, HudPos pos, HudColor color, const std::string& text); void drawLines( - const Rc& context, size_t vertexCount, const HudLineVertex* vertexData); @@ -120,6 +118,7 @@ namespace dxvk::hud { Mode m_mode; VkExtent2D m_surfaceSize; + Rc m_context; ShaderPair m_textShaders; ShaderPair m_lineShaders; @@ -132,14 +131,11 @@ namespace dxvk::hud { VkDeviceSize m_vertexOffset = 0; DxvkBufferSlice allocVertexBuffer( - const Rc& context, VkDeviceSize dataSize); - void beginTextRendering( - const Rc& context); + void beginTextRendering(); - void beginLineRendering( - const Rc& context); + void beginLineRendering(); ShaderPair createTextShaders( const Rc& device); diff --git a/src/dxvk/hud/dxvk_hud_stats.cpp b/src/dxvk/hud/dxvk_hud_stats.cpp index ff4d17eae..e714e58ac 100644 --- a/src/dxvk/hud/dxvk_hud_stats.cpp +++ b/src/dxvk/hud/dxvk_hud_stats.cpp @@ -30,26 +30,25 @@ namespace dxvk::hud { HudPos HudStats::render( - const Rc& context, HudRenderer& renderer, HudPos position) { if (m_elements.test(HudElement::StatSubmissions)) - position = this->printSubmissionStats(context, renderer, position); + position = this->printSubmissionStats(renderer, position); if (m_elements.test(HudElement::StatDrawCalls)) - position = this->printDrawCallStats(context, renderer, position); + position = this->printDrawCallStats(renderer, position); if (m_elements.test(HudElement::StatPipelines)) - position = this->printPipelineStats(context, renderer, position); + position = this->printPipelineStats(renderer, position); if (m_elements.test(HudElement::StatMemory)) - position = this->printMemoryStats(context, renderer, position); - + position = this->printMemoryStats(renderer, position); + if (m_elements.test(HudElement::StatGpuLoad)) - position = this->printGpuLoad(context, renderer, position); + position = this->printGpuLoad(renderer, position); if (m_elements.test(HudElement::CompilerActivity)) { - this->printCompilerActivity(context, renderer, + this->printCompilerActivity(renderer, { position.x, float(renderer.surfaceSize().height) - 20.0f }); } @@ -77,7 +76,6 @@ namespace dxvk::hud { HudPos HudStats::printDrawCallStats( - const Rc& context, HudRenderer& renderer, HudPos position) { const uint64_t frameCount = std::max(m_diffCounters.getCtr(DxvkStatCounter::QueuePresentCount), 1); @@ -90,17 +88,17 @@ namespace dxvk::hud { const std::string strDispatchCalls = str::format("Dispatch calls: ", cpCalls); const std::string strRenderPasses = str::format("Render passes: ", rpCalls); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, strDrawCalls); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y + 20.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, strDispatchCalls); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y + 40.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, strRenderPasses); @@ -110,7 +108,6 @@ namespace dxvk::hud { HudPos HudStats::printSubmissionStats( - const Rc& context, HudRenderer& renderer, HudPos position) { const uint64_t frameCount = std::max(m_diffCounters.getCtr(DxvkStatCounter::QueuePresentCount), 1); @@ -118,7 +115,7 @@ namespace dxvk::hud { const std::string strSubmissions = str::format("Queue submissions: ", numSubmits); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, strSubmissions); @@ -128,7 +125,6 @@ namespace dxvk::hud { HudPos HudStats::printPipelineStats( - const Rc& context, HudRenderer& renderer, HudPos position) { const uint64_t gpCount = m_prevCounters.getCtr(DxvkStatCounter::PipeCountGraphics); @@ -137,12 +133,12 @@ namespace dxvk::hud { const std::string strGpCount = str::format("Graphics pipelines: ", gpCount); const std::string strCpCount = str::format("Compute pipelines: ", cpCount); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, strGpCount); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y + 20.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, strCpCount); @@ -152,7 +148,6 @@ namespace dxvk::hud { HudPos HudStats::printMemoryStats( - const Rc& context, HudRenderer& renderer, HudPos position) { constexpr uint64_t mib = 1024 * 1024; @@ -163,12 +158,12 @@ namespace dxvk::hud { const std::string strMemAllocated = str::format("Memory allocated: ", memAllocated / mib, " MB"); const std::string strMemUsed = str::format("Memory used: ", memUsed / mib, " MB"); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, strMemAllocated); - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y + 20.0f }, { 1.0f, 1.0f, 1.0f, 1.0f }, strMemUsed); @@ -178,10 +173,9 @@ namespace dxvk::hud { HudPos HudStats::printGpuLoad( - const Rc& context, HudRenderer& renderer, HudPos position) { - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, m_gpuLoadString); @@ -191,7 +185,6 @@ namespace dxvk::hud { HudPos HudStats::printCompilerActivity( - const Rc& context, HudRenderer& renderer, HudPos position) { auto now = dxvk::high_resolution_clock::now(); @@ -207,7 +200,7 @@ namespace dxvk::hud { } if (doShow) { - renderer.drawText(context, 16.0f, + renderer.drawText(16.0f, { position.x, position.y }, { 1.0f, 1.0f, 1.0f, 1.0f }, "Compiling shaders..."); diff --git a/src/dxvk/hud/dxvk_hud_stats.h b/src/dxvk/hud/dxvk_hud_stats.h index 6df1b32e1..50311c09a 100644 --- a/src/dxvk/hud/dxvk_hud_stats.h +++ b/src/dxvk/hud/dxvk_hud_stats.h @@ -27,7 +27,6 @@ namespace dxvk::hud { const Rc& device); HudPos render( - const Rc& context, HudRenderer& renderer, HudPos position); @@ -49,32 +48,26 @@ namespace dxvk::hud { void updateGpuLoad(); HudPos printDrawCallStats( - const Rc& context, HudRenderer& renderer, HudPos position); HudPos printSubmissionStats( - const Rc& context, HudRenderer& renderer, HudPos position); HudPos printPipelineStats( - const Rc& context, HudRenderer& renderer, HudPos position); HudPos printMemoryStats( - const Rc& context, HudRenderer& renderer, HudPos position); HudPos printGpuLoad( - const Rc& context, HudRenderer& renderer, HudPos position); HudPos printCompilerActivity( - const Rc& context, HudRenderer& renderer, HudPos position);