diff --git a/src/video_core/amdgpu/liverpool.h b/src/video_core/amdgpu/liverpool.h index 8bb6c9595..187b7bcde 100644 --- a/src/video_core/amdgpu/liverpool.h +++ b/src/video_core/amdgpu/liverpool.h @@ -304,6 +304,14 @@ struct Liverpool { } }; + struct LineControl { + u32 width_fixed_point; + + float Width() const { + return static_cast(width_fixed_point) / 8.0; + } + }; + struct ModeControl { s32 msaa_enable : 1; s32 vport_scissor_enable : 1; @@ -1387,7 +1395,9 @@ struct Liverpool { PolygonControl polygon_control; ViewportControl viewport_control; VsOutputControl vs_output_control; - INSERT_PADDING_WORDS(0xA287 - 0xA207 - 1); + INSERT_PADDING_WORDS(0xA287 - 0xA207 - 7); + LineControl line_control; + INSERT_PADDING_WORDS(5); HsTessFactorClamp hs_clamp; INSERT_PADDING_WORDS(0xA290 - 0xA287 - 2); GsMode vgt_gs_mode; diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp index 6a6ebec2c..c11a2ac1b 100644 --- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp +++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp @@ -123,7 +123,8 @@ GraphicsPipeline::GraphicsPipeline( }, vk::PipelineRasterizationDepthClipStateCreateInfoEXT{ .depthClipEnable = key.depth_clip_enable, - }}; + }, + }; if (!instance.IsProvokingVertexSupported()) { raster_chain.unlink(); @@ -172,6 +173,7 @@ GraphicsPipeline::GraphicsPipeline( vk::DynamicState::eStencilCompareMask, vk::DynamicState::eStencilWriteMask, vk::DynamicState::eStencilOp, vk::DynamicState::eCullMode, vk::DynamicState::eFrontFace, vk::DynamicState::eRasterizerDiscardEnable, + vk::DynamicState::eLineWidth, }; if (instance.IsPrimitiveRestartDisableSupported()) { diff --git a/src/video_core/renderer_vulkan/vk_instance.cpp b/src/video_core/renderer_vulkan/vk_instance.cpp index a0a906c24..3a461b321 100644 --- a/src/video_core/renderer_vulkan/vk_instance.cpp +++ b/src/video_core/renderer_vulkan/vk_instance.cpp @@ -369,6 +369,7 @@ bool Instance::CreateDevice() { .depthBiasClamp = features.depthBiasClamp, .fillModeNonSolid = features.fillModeNonSolid, .depthBounds = features.depthBounds, + .wideLines = features.wideLines, .multiViewport = features.multiViewport, .samplerAnisotropy = features.samplerAnisotropy, .vertexPipelineStoresAndAtomics = features.vertexPipelineStoresAndAtomics, diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp index 27f3225ea..b6130e873 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp +++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp @@ -1014,6 +1014,7 @@ void Rasterizer::UpdateDynamicState(const GraphicsPipeline& pipeline) const { UpdateViewportScissorState(); UpdateDepthStencilState(); UpdatePrimitiveState(); + UpdateRasterizationState(); auto& dynamic_state = scheduler.GetDynamicState(); dynamic_state.SetBlendConstants(liverpool->regs.blend_constants); @@ -1230,6 +1231,12 @@ void Rasterizer::UpdatePrimitiveState() const { dynamic_state.SetFrontFace(front_face); } +void Rasterizer::UpdateRasterizationState() const { + const auto& regs = liverpool->regs; + auto& dynamic_state = scheduler.GetDynamicState(); + dynamic_state.SetLineWidth(regs.line_control.Width()); +} + void Rasterizer::ScopeMarkerBegin(const std::string_view& str, bool from_guest) { if ((from_guest && !Config::getVkGuestMarkersEnabled()) || (!from_guest && !Config::getVkHostMarkersEnabled())) { diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.h b/src/video_core/renderer_vulkan/vk_rasterizer.h index 1e1680258..79e7722b8 100644 --- a/src/video_core/renderer_vulkan/vk_rasterizer.h +++ b/src/video_core/renderer_vulkan/vk_rasterizer.h @@ -94,6 +94,7 @@ private: void UpdateViewportScissorState() const; void UpdateDepthStencilState() const; void UpdatePrimitiveState() const; + void UpdateRasterizationState() const; bool FilterDraw(); diff --git a/src/video_core/renderer_vulkan/vk_scheduler.cpp b/src/video_core/renderer_vulkan/vk_scheduler.cpp index d7a121bd1..7c3429297 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.cpp +++ b/src/video_core/renderer_vulkan/vk_scheduler.cpp @@ -330,6 +330,10 @@ void DynamicState::Commit(const Instance& instance, const vk::CommandBuffer& cmd cmdbuf.setColorWriteMaskEXT(0, color_write_masks); } } + if (dirty_state.line_width) { + dirty_state.line_width = false; + cmdbuf.setLineWidth(line_width); + } } } // namespace Vulkan diff --git a/src/video_core/renderer_vulkan/vk_scheduler.h b/src/video_core/renderer_vulkan/vk_scheduler.h index 210f9f460..3616d8478 100644 --- a/src/video_core/renderer_vulkan/vk_scheduler.h +++ b/src/video_core/renderer_vulkan/vk_scheduler.h @@ -102,6 +102,7 @@ struct DynamicState { bool blend_constants : 1; bool color_write_masks : 1; + bool line_width : 1; } dirty_state{}; Viewports viewports{}; @@ -137,6 +138,7 @@ struct DynamicState { std::array blend_constants{}; ColorWriteMasks color_write_masks{}; + float line_width{}; /// Commits the dynamic state to the provided command buffer. void Commit(const Instance& instance, const vk::CommandBuffer& cmdbuf); @@ -305,6 +307,13 @@ struct DynamicState { dirty_state.color_write_masks = true; } } + + void SetLineWidth(const float width) { + if (line_width != width) { + line_width = width; + dirty_state.line_width = true; + } + } }; class Scheduler {