Commit 5f46bdb6 authored by Louis-Francis Ratté-Boulianne's avatar Louis-Francis Ratté-Boulianne Committed by Erik Faye-Lund

d3d12: Lower point sprites when polygon mode is GL_POINT

parent 1d9d99ad
......@@ -302,26 +302,6 @@ manual_depth_range(struct d3d12_context *ctx)
return fs && fs->initial->info.inputs_read & VARYING_BIT_POS;
}
static bool
needs_point_sprite_lowering(struct d3d12_context *ctx, const struct pipe_draw_info *dinfo)
{
struct d3d12_shader_selector *vs = ctx->gfx_stages[PIPE_SHADER_VERTEX];
struct d3d12_shader_selector *gs = ctx->gfx_stages[PIPE_SHADER_GEOMETRY];
if (gs != NULL && !gs->is_gs_variant) {
/* There is an user GS; Check if it outputs points with PSIZE */
return (gs->initial->info.gs.output_primitive == GL_POINTS &&
gs->initial->info.outputs_written & VARYING_BIT_PSIZ);
} else {
/* No user GS; check if we are drawing wide points */
return (dinfo->mode == PIPE_PRIM_POINTS &&
(ctx->gfx_pipeline_state.rast->base.point_size > 1.0 ||
(ctx->gfx_pipeline_state.rast->base.point_size_per_vertex &&
vs->initial->info.outputs_written & VARYING_BIT_PSIZ)) &&
(vs->initial->info.outputs_written & VARYING_BIT_POS));
}
}
static bool
needs_edge_flag_fix(enum pipe_prim_type mode)
{
......@@ -357,6 +337,27 @@ fill_mode_lowered(struct d3d12_context *ctx, const struct pipe_draw_info *dinfo)
return PIPE_POLYGON_MODE_FILL;
}
static bool
needs_point_sprite_lowering(struct d3d12_context *ctx, const struct pipe_draw_info *dinfo)
{
struct d3d12_shader_selector *vs = ctx->gfx_stages[PIPE_SHADER_VERTEX];
struct d3d12_shader_selector *gs = ctx->gfx_stages[PIPE_SHADER_GEOMETRY];
if (gs != NULL && !gs->is_gs_variant) {
/* There is an user GS; Check if it outputs points with PSIZE */
return (gs->initial->info.gs.output_primitive == GL_POINTS &&
gs->initial->info.outputs_written & VARYING_BIT_PSIZ);
} else {
/* No user GS; check if we are drawing wide points */
return ((dinfo->mode == PIPE_PRIM_POINTS ||
fill_mode_lowered(ctx, dinfo) == PIPE_POLYGON_MODE_POINT) &&
(ctx->gfx_pipeline_state.rast->base.point_size > 1.0 ||
(ctx->gfx_pipeline_state.rast->base.point_size_per_vertex &&
vs->initial->info.outputs_written & VARYING_BIT_PSIZ)) &&
(vs->initial->info.outputs_written & VARYING_BIT_POS));
}
}
static unsigned
cull_mode_lowered(struct d3d12_context *ctx, unsigned fill_mode)
{
......@@ -509,15 +510,7 @@ validate_geometry_shader_variant(struct d3d12_selection_context *sel_ctx)
return;
/* Fill the geometry shader variant key */
if (sel_ctx->needs_point_sprite_lowering) {
key.passthrough = true;
variant_needed = true;
} else if (sel_ctx->needs_vertex_reordering) {
/* TODO support cases where flat shading (pv != 0) and xfb are enabled */
key.provoking_vertex = sel_ctx->provoking_vertex;
key.alternate_tri = sel_ctx->alternate_tri;
variant_needed = true;
} else if (sel_ctx->fill_mode_lowered != PIPE_POLYGON_MODE_FILL) {
if (sel_ctx->fill_mode_lowered != PIPE_POLYGON_MODE_FILL) {
key.fill_mode = sel_ctx->fill_mode_lowered;
key.cull_mode = sel_ctx->cull_mode_lowered;
key.has_front_face = (fs->initial->info.inputs_read & VARYING_BIT_FACE) ? 1 : 0;
......@@ -528,6 +521,14 @@ validate_geometry_shader_variant(struct d3d12_selection_context *sel_ctx)
if (key.flat_varyings != 0)
key.flatshade_first = ctx->gfx_pipeline_state.rast->base.flatshade_first;
variant_needed = true;
} else if (sel_ctx->needs_point_sprite_lowering) {
key.passthrough = true;
variant_needed = true;
} else if (sel_ctx->needs_vertex_reordering) {
/* TODO support cases where flat shading (pv != 0) and xfb are enabled */
key.provoking_vertex = sel_ctx->provoking_vertex;
key.alternate_tri = sel_ctx->alternate_tri;
variant_needed = true;
}
if (variant_needed)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment