Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nv2a: Vulkan line width #1872

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion hw/xbox/nv2a/pgraph/vk/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@ static void create_display_pipeline(PGRAPHState *pg)
.depthClampEnable = VK_FALSE,
.rasterizerDiscardEnable = VK_FALSE,
.polygonMode = VK_POLYGON_MODE_FILL,
.lineWidth = 1.0f,
.lineWidth = (float)pg->surface_scale_factor,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like for GL, before using a value other than 1, we must check that the device supports wideLines and the supported value ranges. Check out VkPhysicalDeviceFeatures/VkPhysicalDeviceLimits

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! I removed this change as well as the one in create_clear_pipeline in draw.c because it became apparent that these functions aren't being called when surface scale factor changes and that doesn't seem to affect the rendered image.

In the remaining change in create_pipeline in draw.c I've added logic to clamp the line width to a value within the range defined in r->device_props.limits.lineWidthRange

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, display and clear pipelines shouldn't be drawing lines. Only draw pipeline needs the line width adjustment

.cullMode = VK_CULL_MODE_BACK_BIT,
.frontFace = VK_FRONT_FACE_CLOCKWISE,
.depthBiasEnable = VK_FALSE,
Expand Down
8 changes: 4 additions & 4 deletions hw/xbox/nv2a/pgraph/vk/draw.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ static void create_clear_pipeline(PGRAPHState *pg)
.depthClampEnable = VK_FALSE,
.rasterizerDiscardEnable = VK_FALSE,
.polygonMode = VK_POLYGON_MODE_FILL,
.lineWidth = 1.0f,
.lineWidth = (float)pg->surface_scale_factor,
.cullMode = VK_CULL_MODE_BACK_BIT,
.frontFace = VK_FRONT_FACE_CLOCKWISE,
.depthBiasEnable = VK_FALSE,
Expand Down Expand Up @@ -820,7 +820,7 @@ static void create_pipeline(PGRAPHState *pg)
.rasterizerDiscardEnable = VK_FALSE,
.polygonMode = pgraph_polygon_mode_vk_map[r->shader_binding->state
.polygon_front_mode],
.lineWidth = 1.0f,
.lineWidth = (float)pg->surface_scale_factor,
.frontFace = (pgraph_reg_r(pg, NV_PGRAPH_SETUPRASTER) &
NV_PGRAPH_SETUPRASTER_FRONTFACE) ?
VK_FRONT_FACE_COUNTER_CLOCKWISE :
Expand Down Expand Up @@ -949,8 +949,8 @@ static void create_pipeline(PGRAPHState *pg)
.blendConstants[3] = blend_constant[3],
};

VkDynamicState dynamic_states[2] = { VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR };
VkDynamicState dynamic_states[] = { VK_DYNAMIC_STATE_VIEWPORT,
VK_DYNAMIC_STATE_SCISSOR };

VkPipelineDynamicStateCreateInfo dynamic_state = {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
Expand Down
Loading