v3dv: implement VK_EXT_line_rasterization

Allow to choose the line rasterization algorithm. It supports
rectangular and Bresenham-style line rasterization.

v2 (Iago):
 - Update documentation.

Signed-off-by: Juan A. Suarez Romero <jasuarez@igalia.com>
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15407>
This commit is contained in:
Juan A. Suarez Romero 2022-03-17 12:20:41 +01:00 committed by Marge Bot
parent 22759e9174
commit 730a294b90
6 changed files with 50 additions and 5 deletions

View File

@ -550,7 +550,7 @@ Khronos extensions that are not part of any Vulkan version:
VK_EXT_image_drm_format_modifier DONE (anv, radv/gfx9+, tu, v3dv, vn)
VK_EXT_image_view_min_lod DONE (radv)
VK_EXT_index_type_uint8 DONE (anv, lvp, radv/gfx8+, v3dv, tu)
VK_EXT_line_rasterization DONE (anv, lvp, radv, tu)
VK_EXT_line_rasterization DONE (anv, lvp, radv, tu, v3dv)
VK_EXT_memory_budget DONE (anv, radv, tu)
VK_EXT_memory_priority DONE (radv)
VK_EXT_multi_draw DONE (anv, lvp, radv)

View File

@ -2822,6 +2822,14 @@ v3dv_CmdSetDepthBounds(VkCommandBuffer commandBuffer,
*/
}
VKAPI_ATTR void VKAPI_CALL
v3dv_CmdSetLineStippleEXT(VkCommandBuffer commandBuffer,
uint32_t lineStippleFactor,
uint16_t lineStipplePattern)
{
/* We do not support stippled line rasterization so we just ignore this. */
}
VKAPI_ATTR void VKAPI_CALL
v3dv_CmdSetLineWidth(VkCommandBuffer commandBuffer,
float lineWidth)

View File

@ -157,6 +157,7 @@ get_device_extensions(const struct v3dv_physical_device *device,
.EXT_host_query_reset = true,
.EXT_image_drm_format_modifier = true,
.EXT_index_type_uint8 = true,
.EXT_line_rasterization = true,
.EXT_physical_device_drm = true,
.EXT_pipeline_creation_cache_control = true,
.EXT_pipeline_creation_feedback = true,
@ -1158,6 +1159,18 @@ v3dv_GetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice,
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_FEATURES_EXT: {
VkPhysicalDeviceLineRasterizationFeaturesEXT *features =
(VkPhysicalDeviceLineRasterizationFeaturesEXT *)ext;
features->rectangularLines = true;
features->bresenhamLines = true;
features->smoothLines = false;
features->stippledRectangularLines = false;
features->stippledBresenhamLines = false;
features->stippledSmoothLines = false;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_COLOR_WRITE_ENABLE_FEATURES_EXT: {
VkPhysicalDeviceColorWriteEnableFeaturesEXT *features = (void *) ext;
features->colorWriteEnable = true;
@ -1598,6 +1611,12 @@ v3dv_GetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice,
}
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_LINE_RASTERIZATION_PROPERTIES_EXT: {
VkPhysicalDeviceLineRasterizationPropertiesEXT *props =
(VkPhysicalDeviceLineRasterizationPropertiesEXT *)ext;
props->lineSubPixelPrecisionBits = V3D_COORD_SHIFT;
break;
}
case VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MAINTENANCE_3_PROPERTIES: {
VkPhysicalDeviceMaintenance3Properties *props =
(VkPhysicalDeviceMaintenance3Properties *)ext;

View File

@ -2987,6 +2987,12 @@ pipeline_init(struct v3dv_pipeline *pipeline,
PIPELINE_RASTERIZATION_PROVOKING_VERTEX_STATE_CREATE_INFO_EXT) :
NULL;
const VkPipelineRasterizationLineStateCreateInfoEXT *ls_info =
rs_info ? vk_find_struct_const(
rs_info->pNext,
PIPELINE_RASTERIZATION_LINE_STATE_CREATE_INFO_EXT) :
NULL;
const VkPipelineColorBlendStateCreateInfo *cb_info =
raster_enabled ? pCreateInfo->pColorBlendState : NULL;
@ -3008,7 +3014,8 @@ pipeline_init(struct v3dv_pipeline *pipeline,
assert(!ds_info || !ds_info->depthBoundsTestEnable);
v3dv_X(device, pipeline_pack_state)(pipeline, cb_info, ds_info,
rs_info, pv_info, ms_info);
rs_info, pv_info, ls_info,
ms_info);
pipeline_set_ez_state(pipeline, ds_info);
enable_depth_bias(pipeline, rs_info);

View File

@ -146,6 +146,7 @@ pack_cfg_bits(struct v3dv_pipeline *pipeline,
const VkPipelineDepthStencilStateCreateInfo *ds_info,
const VkPipelineRasterizationStateCreateInfo *rs_info,
const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT *pv_info,
const VkPipelineRasterizationLineStateCreateInfoEXT *ls_info,
const VkPipelineMultisampleStateCreateInfo *ms_info)
{
assert(sizeof(pipeline->cfg_bits) == cl_packet_length(CFG_BITS));
@ -170,14 +171,22 @@ pack_cfg_bits(struct v3dv_pipeline *pipeline,
* exposing, at least, a minimum of 4-bits of subpixel precision
* (the minimum requirement).
*/
if (ls_info &&
ls_info->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT)
config.line_rasterization = V3D_LINE_RASTERIZATION_DIAMOND_EXIT;
else
config.line_rasterization = V3D_LINE_RASTERIZATION_PERP_END_CAPS;
if (rs_info && rs_info->polygonMode != VK_POLYGON_MODE_FILL) {
config.direct3d_wireframe_triangles_mode = true;
config.direct3d_point_fill_mode =
rs_info->polygonMode == VK_POLYGON_MODE_POINT;
}
config.rasterizer_oversample_mode = pipeline->msaa ? 1 : 0;
/* diamond-exit rasterization does not suport oversample */
config.rasterizer_oversample_mode =
(config.line_rasterization == V3D_LINE_RASTERIZATION_PERP_END_CAPS &&
pipeline->msaa) ? 1 : 0;
/* From the Vulkan spec:
*
@ -341,10 +350,11 @@ v3dX(pipeline_pack_state)(struct v3dv_pipeline *pipeline,
const VkPipelineDepthStencilStateCreateInfo *ds_info,
const VkPipelineRasterizationStateCreateInfo *rs_info,
const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT *pv_info,
const VkPipelineRasterizationLineStateCreateInfoEXT *ls_info,
const VkPipelineMultisampleStateCreateInfo *ms_info)
{
pack_blend(pipeline, cb_info);
pack_cfg_bits(pipeline, ds_info, rs_info, pv_info, ms_info);
pack_cfg_bits(pipeline, ds_info, rs_info, pv_info, ls_info, ms_info);
pack_stencil_cfg(pipeline, ds_info);
}

View File

@ -300,6 +300,7 @@ v3dX(pipeline_pack_state)(struct v3dv_pipeline *pipeline,
const VkPipelineDepthStencilStateCreateInfo *ds_info,
const VkPipelineRasterizationStateCreateInfo *rs_info,
const VkPipelineRasterizationProvokingVertexStateCreateInfoEXT *pv_info,
const VkPipelineRasterizationLineStateCreateInfoEXT *ls_info,
const VkPipelineMultisampleStateCreateInfo *ms_info);
void
v3dX(pipeline_pack_compile_state)(struct v3dv_pipeline *pipeline,