gallium: explicitly specify line rasterization mode
Currently, drivers infer the line rasterization mode from the multisampling and line_smooth rasterization state. This is always correct for OpenGL, but is subtly incorrect for DirectX 9, 10 and Vulkan (when VK_EXT_line_rasterization is supported). So let's allow front-ends to choose freely between rectangle and paralellogram rendering. The reason why there's no added cap for this, is that the implicit selection that drivers currently do will work just as well (or more correclty, just as subtly wrong) as before. And there's nothing reasonable the front-ends can do to get the correct behavior, so there's really no fall-back code to write either. Reviewed-by: Dave Airlie <airlied@redhat.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11782>
This commit is contained in:

committed by
Marge Bot

parent
e0472217b0
commit
1c2690ec20
@@ -232,6 +232,7 @@ CreateRasterizerState(
|
||||
state.point_tri_clip = 1;
|
||||
|
||||
state.line_width = 1.0f;
|
||||
state.line_rectangular = 0;
|
||||
|
||||
pRasterizerState->handle = pipe->create_rasterizer_state(pipe, &state);
|
||||
}
|
||||
|
@@ -510,6 +510,7 @@ static void handle_graphics_pipeline(struct lvp_cmd_buffer_entry *cmd,
|
||||
state->rs_state.half_pixel_center = true;
|
||||
state->rs_state.scissor = true;
|
||||
state->rs_state.no_ms_sample_mask_out = true;
|
||||
state->rs_state.line_rectangular = pipeline->line_rectangular;
|
||||
|
||||
if (!dynamic_states[VK_DYNAMIC_STATE_LINE_WIDTH])
|
||||
state->rs_state.line_width = rsc->lineWidth;
|
||||
|
@@ -815,11 +815,14 @@ lvp_graphics_pipeline_init(struct lvp_pipeline *pipeline,
|
||||
pipeline->line_smooth = line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
|
||||
pipeline->disable_multisample = line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
|
||||
line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT;
|
||||
pipeline->line_rectangular = line_state->lineRasterizationMode != VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
|
||||
line_state->lineRasterizationMode != VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT;
|
||||
if (!dynamic_state_contains(pipeline->graphics_create_info.pDynamicState, VK_DYNAMIC_STATE_LINE_STIPPLE_EXT)) {
|
||||
pipeline->line_stipple_factor = line_state->lineStippleFactor - 1;
|
||||
pipeline->line_stipple_pattern = line_state->lineStipplePattern;
|
||||
}
|
||||
}
|
||||
} else
|
||||
pipeline->line_rectangular = false;
|
||||
|
||||
|
||||
for (uint32_t i = 0; i < pCreateInfo->stageCount; i++) {
|
||||
|
@@ -484,6 +484,7 @@ struct lvp_pipeline {
|
||||
bool line_stipple_enable;
|
||||
bool line_smooth;
|
||||
bool disable_multisample;
|
||||
bool line_rectangular;
|
||||
bool gs_output_lines;
|
||||
bool provoking_vertex_last;
|
||||
};
|
||||
|
@@ -116,6 +116,7 @@ nine_convert_rasterizer_state(struct NineDevice9 *device,
|
||||
/* rast.line_stipple_pattern = 0; */
|
||||
rast.sprite_coord_enable = rs[D3DRS_POINTSPRITEENABLE] ? 0xff : 0x00;
|
||||
rast.line_width = 1.0f;
|
||||
rast.line_rectangular = 0;
|
||||
if (rs[NINED3DRS_VSPOINTSIZE]) {
|
||||
rast.point_size = 1.0f;
|
||||
} else {
|
||||
|
@@ -117,6 +117,7 @@ struct pipe_rasterizer_state
|
||||
unsigned line_smooth:1;
|
||||
unsigned line_stipple_enable:1;
|
||||
unsigned line_last_pixel:1;
|
||||
unsigned line_rectangular:1; /** lines rasterized as rectangles or parallelograms */
|
||||
unsigned conservative_raster_mode:2; /**< PIPE_CONSERVATIVE_RASTER_x */
|
||||
|
||||
/**
|
||||
|
@@ -246,6 +246,8 @@ st_update_rasterizer(struct st_context *st)
|
||||
ctx->Const.MaxLineWidth);
|
||||
}
|
||||
|
||||
raster->line_rectangular = multisample || ctx->Line.SmoothFlag;
|
||||
|
||||
/* When the pattern is all 1's, it means line stippling is disabled */
|
||||
raster->line_stipple_enable = ctx->Line.StippleFlag && ctx->Line.StipplePattern != 0xffff;
|
||||
raster->line_stipple_pattern = ctx->Line.StipplePattern;
|
||||
|
Reference in New Issue
Block a user