From d8afb35c403040e3684ca224a30dfd5b6bad2bc3 Mon Sep 17 00:00:00 2001 From: "specialfred453@gmail.com" Date: Thu, 9 Jan 2025 20:58:25 -0500 Subject: [PATCH] nv2a/vk: Scale line width by surface scale --- hw/xbox/nv2a/pgraph/vk/draw.c | 10 +++++++++- hw/xbox/nv2a/pgraph/vk/instance.c | 6 +++--- hw/xbox/nv2a/pgraph/vk/renderer.h | 1 + 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hw/xbox/nv2a/pgraph/vk/draw.c b/hw/xbox/nv2a/pgraph/vk/draw.c index c082c5cfb4..0e5d2aff7d 100644 --- a/hw/xbox/nv2a/pgraph/vk/draw.c +++ b/hw/xbox/nv2a/pgraph/vk/draw.c @@ -810,13 +810,21 @@ static void create_pipeline(PGRAPHState *pg) // FIXME: Handle in shader? } + float lineWidth = 1.0f; + if(r->physical_device_features.wideLines == VK_TRUE) + { + lineWidth = MIN(r->device_props.limits.lineWidthRange[1], + MAX(r->device_props.limits.lineWidthRange[0], + (float)pg->surface_scale_factor)); + } + VkPipelineRasterizationStateCreateInfo rasterizer = { .sType = VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO, .depthClampEnable = VK_TRUE, .rasterizerDiscardEnable = VK_FALSE, .polygonMode = pgraph_polygon_mode_vk_map[r->shader_binding->state .polygon_front_mode], - .lineWidth = 1.0f, + .lineWidth = lineWidth, .frontFace = (pgraph_reg_r(pg, NV_PGRAPH_SETUPRASTER) & NV_PGRAPH_SETUPRASTER_FRONTFACE) ? VK_FRONT_FACE_COUNTER_CLOCKWISE : diff --git a/hw/xbox/nv2a/pgraph/vk/instance.c b/hw/xbox/nv2a/pgraph/vk/instance.c index 9df440930c..416f12dff8 100644 --- a/hw/xbox/nv2a/pgraph/vk/instance.c +++ b/hw/xbox/nv2a/pgraph/vk/instance.c @@ -523,15 +523,15 @@ static bool create_logical_device(PGRAPHState *pg, Error **errp) }; // Ensure device supports required features - VkPhysicalDeviceFeatures available_features, enabled_features; - vkGetPhysicalDeviceFeatures(r->physical_device, &available_features); + VkPhysicalDeviceFeatures enabled_features; + vkGetPhysicalDeviceFeatures(r->physical_device, &r->physical_device_features); memset(&enabled_features, 0, sizeof(enabled_features)); struct { const char *name; VkBool32 available, *enabled; } required_features[] = { - #define F(n) { #n, available_features.n, &enabled_features.n } + #define F(n) { #n, r->physical_device_features.n, &enabled_features.n } F(shaderClipDistance), F(geometryShader), F(shaderTessellationAndGeometryPointSize), diff --git a/hw/xbox/nv2a/pgraph/vk/renderer.h b/hw/xbox/nv2a/pgraph/vk/renderer.h index 3c3bb4ce91..354275da31 100644 --- a/hw/xbox/nv2a/pgraph/vk/renderer.h +++ b/hw/xbox/nv2a/pgraph/vk/renderer.h @@ -334,6 +334,7 @@ typedef struct PGRAPHVkState { bool memory_budget_extension_enabled; VkPhysicalDevice physical_device; + VkPhysicalDeviceFeatures physical_device_features; VkPhysicalDeviceProperties device_props; VkDevice device; VmaAllocator allocator;