v3dv: implement wide lines

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
Iago Toral Quiroga 2020-05-13 12:21:55 +02:00 committed by Marge Bot
parent 21936e8493
commit 98ade03113
6 changed files with 47 additions and 15 deletions

View File

@ -53,6 +53,7 @@ const struct v3dv_dynamic_state default_dynamic_state = {
.constant_factor = 0.0f,
.slope_factor = 0.0f,
},
.line_width = 1.0f,
};
void
@ -2002,6 +2003,13 @@ cmd_buffer_bind_pipeline_static_state(struct v3dv_cmd_buffer *cmd_buffer,
}
}
if (!(dynamic_mask & V3DV_DYNAMIC_LINE_WIDTH)) {
if (dest->line_width != src->line_width) {
dest->line_width = src->line_width;
dirty |= V3DV_CMD_DIRTY_LINE_WIDTH;
}
}
cmd_buffer->state.dynamic.mask = dynamic_mask;
cmd_buffer->state.dirty |= dirty;
}
@ -2575,6 +2583,20 @@ emit_depth_bias(struct v3dv_cmd_buffer *cmd_buffer)
cmd_buffer->state.dirty &= ~V3DV_CMD_DIRTY_DEPTH_BIAS;
}
static void
emit_line_width(struct v3dv_cmd_buffer *cmd_buffer)
{
struct v3dv_job *job = cmd_buffer->state.job;
assert(job);
v3dv_cl_ensure_space_with_branch(&job->bcl, cl_packet_length(LINE_WIDTH));
cl_emit(&job->bcl, LINE_WIDTH, line) {
line.line_width = cmd_buffer->state.dynamic.line_width;
}
cmd_buffer->state.dirty &= ~V3DV_CMD_DIRTY_LINE_WIDTH;
}
static void
emit_blend(struct v3dv_cmd_buffer *cmd_buffer)
{
@ -3159,6 +3181,9 @@ cmd_buffer_emit_pre_draw(struct v3dv_cmd_buffer *cmd_buffer)
if (*dirty & V3DV_CMD_DIRTY_OCCLUSION_QUERY)
emit_occlusion_query(cmd_buffer);
if (*dirty & V3DV_CMD_DIRTY_LINE_WIDTH)
emit_line_width(cmd_buffer);
cmd_buffer->state.dirty &= ~V3DV_CMD_DIRTY_PIPELINE;
}
@ -3438,6 +3463,16 @@ v3dv_CmdSetDepthBounds(VkCommandBuffer commandBuffer,
*/
}
void
v3dv_CmdSetLineWidth(VkCommandBuffer commandBuffer,
float lineWidth)
{
V3DV_FROM_HANDLE(v3dv_cmd_buffer, cmd_buffer, commandBuffer);
cmd_buffer->state.dynamic.line_width = lineWidth;
cmd_buffer->state.dirty |= V3DV_CMD_DIRTY_LINE_WIDTH;
}
void
v3dv_CmdBindDescriptorSets(VkCommandBuffer commandBuffer,
VkPipelineBindPoint pipelineBindPoint,

View File

@ -553,7 +553,7 @@ v3dv_GetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice,
.depthBiasClamp = false,
.fillModeNonSolid = false,
.depthBounds = false, /* Only available since V3D 4.3.16.2 */
.wideLines = false,
.wideLines = true,
.largePoints = false,
.alphaToOne = false,
.multiViewport = false,
@ -754,9 +754,9 @@ v3dv_GetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice,
.maxCombinedClipAndCullDistances = 0,
.discreteQueuePriorities = 2,
.pointSizeRange = { 1.0f, 1.0f },
.lineWidthRange = { 1.0f, 1.0f },
.lineWidthRange = { 1.0f, 32.0f },
.pointSizeGranularity = 0.0f,
.lineWidthGranularity = 0.0f,
.lineWidthGranularity = 2.0f / (1 << v3d_coord_shift),
.strictLines = true,
.standardSampleLocations = false,
.optimalBufferCopyOffsetAlignment = 32,

View File

@ -212,9 +212,6 @@ create_pipeline(struct v3dv_device *device,
* As a consequence, vkCmdBindPipeline writes no dynamic state
* to the cmd buffer. Therefore, at the end of the meta clear,
* we need only restore dynamic state that was vkCmdSet.
*
* FIXME: Update this when we support more dynamic states (adding
* them now will assert because they are not supported).
*/
.pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
@ -227,9 +224,7 @@ create_pipeline(struct v3dv_device *device,
VK_DYNAMIC_STATE_STENCIL_REFERENCE,
VK_DYNAMIC_STATE_BLEND_CONSTANTS,
VK_DYNAMIC_STATE_DEPTH_BIAS,
#if 0
VK_DYNAMIC_STATE_LINE_WIDTH,
#endif
},
},

View File

@ -3032,9 +3032,6 @@ create_pipeline(struct v3dv_device *device,
* As a consequence, vkCmdBindPipeline writes no dynamic state
* to the cmd buffer. Therefore, at the end of the meta clear,
* we need only restore dynamic state that was vkCmdSet.
*
* FIXME: Update this when we support more dynamic states (adding
* them now will assert because they are not supported).
*/
.pDynamicState = &(VkPipelineDynamicStateCreateInfo) {
.sType = VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO,
@ -3047,9 +3044,7 @@ create_pipeline(struct v3dv_device *device,
VK_DYNAMIC_STATE_STENCIL_REFERENCE,
VK_DYNAMIC_STATE_BLEND_CONSTANTS,
VK_DYNAMIC_STATE_DEPTH_BIAS,
#if 0
VK_DYNAMIC_STATE_LINE_WIDTH,
#endif
},
},

View File

@ -1541,6 +1541,8 @@ v3dv_dynamic_state_mask(VkDynamicState state)
return V3DV_DYNAMIC_BLEND_CONSTANTS;
case VK_DYNAMIC_STATE_DEPTH_BIAS:
return V3DV_DYNAMIC_DEPTH_BIAS;
case VK_DYNAMIC_STATE_LINE_WIDTH:
return V3DV_DYNAMIC_LINE_WIDTH;
/* Depth bounds testing is not available in in V3D 4.2 so here we are just
* ignoring this dynamic state. We are already asserting at pipeline creation
@ -1638,6 +1640,8 @@ pipeline_init_dynamic_state(struct v3dv_pipeline *pipeline,
dynamic->depth_bias.slope_factor =
pCreateInfo->pRasterizationState->depthBiasSlopeFactor;
}
if (!(dynamic_states & V3DV_DYNAMIC_LINE_WIDTH))
dynamic->line_width = pCreateInfo->pRasterizationState->lineWidth;
}
pipeline->dynamic_state.mask = dynamic_states;

View File

@ -543,7 +543,8 @@ enum v3dv_dynamic_state_bits {
V3DV_DYNAMIC_STENCIL_REFERENCE = 1 << 4,
V3DV_DYNAMIC_BLEND_CONSTANTS = 1 << 5,
V3DV_DYNAMIC_DEPTH_BIAS = 1 << 6,
V3DV_DYNAMIC_ALL = (1 << 7) - 1,
V3DV_DYNAMIC_LINE_WIDTH = 1 << 7,
V3DV_DYNAMIC_ALL = (1 << 8) - 1,
};
/* Flags for dirty pipeline state.
@ -562,9 +563,9 @@ enum v3dv_cmd_dirty_bits {
V3DV_CMD_DIRTY_SHADER_VARIANTS = 1 << 10,
V3DV_CMD_DIRTY_OCCLUSION_QUERY = 1 << 11,
V3DV_CMD_DIRTY_DEPTH_BIAS = 1 << 12,
V3DV_CMD_DIRTY_LINE_WIDTH = 1 << 13,
};
struct v3dv_dynamic_state {
/**
* Bitmask of (1 << VK_DYNAMIC_STATE_*).
@ -597,6 +598,8 @@ struct v3dv_dynamic_state {
float constant_factor;
float slope_factor;
} depth_bias;
float line_width;
};
extern const struct v3dv_dynamic_state default_dynamic_state;