Vulkan has no support for edgeflags.
If the user has a geometry shader bound nothing needs to be done as edgeflags
don't work with them, otherwise a geometry shader that emulates them
is generated.
Reviewed-by: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21238>
shaders@point-vertex-id gl_vertexid gl_instanceid,Fail
shaders@point-vertex-id gl_vertexid,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag-quads,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag,Fail
-
spec@!opengl 1.0@gl-1.0-no-op-paths,Fail
spec@!opengl 1.0@gl-1.0-spot-light,Fail
# (and more)
spec@!opengl 1.1@polygon-mode,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag,Fail
-
spec@!opengl 2.0@vs-point_size-zero,Fail
spec@!opengl 2.1@pbo,Fail
shaders@point-vertex-id gl_vertexid divisor,Fail
shaders@point-vertex-id gl_vertexid gl_instanceid,Fail
shaders@point-vertex-id gl_vertexid gl_instanceid divisor,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag-quads,Fail
spec@!opengl 1.0@gl-1.0-no-op-paths,Fail
spec@!opengl 1.1@linestipple,Fail
spec@!opengl 1.1@linestipple@Factor 2x,Fail
spec@!opengl 1.1@polygon-mode-offset@config 6: Expected white pixel on right edge,Fail
spec@!opengl 1.1@polygon-mode-offset@config 6: Expected white pixel on top edge,Fail
spec@!opengl 1.2@copyteximage 3d,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail
spec@!opengl 2.1@pbo,Fail
spec@!opengl 2.1@pbo@test_polygon_stip,Fail
spec@!opengl 2.1@polygon-stipple-fs,Fail
spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb-fp@sRGB decode full precision,Fail
spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag-quads,Fail
spec@!opengl 1.0@gl-1.0-no-op-paths,Fail
spec@!opengl 1.1@linestipple@Factor 2x,Fail
spec@!opengl 1.1@linestipple@Factor 3x,Fail
spec@!opengl 1.1@polygon-mode-offset,Fail
spec@!opengl 1.5@depth-tex-compare,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail
spec@!opengl 2.0@vs-point_size-zero,Fail
spec@!opengl 2.1@pbo,Fail
spec@!opengl 2.1@pbo@test_polygon_stip,Fail
spec@khr_texture_compression_astc@sliced-3d-miptree-gl srgb-fp@sRGB decode full precision,Fail
spec@oes_shader_io_blocks@compiler@layout-location-aliasing.vert,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag,Fail
-spec@!opengl 1.0@gl-1.0-edgeflag-quads,Fail
spec@!opengl 1.0@gl-1.0-no-op-paths,Fail
spec@!opengl 1.1@linestipple@Factor 2x,Fail
spec@!opengl 1.1@linestipple@Factor 3x,Fail
spec@!opengl 1.1@polygon-mode-offset,Fail
spec@!opengl 1.5@depth-tex-compare,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag,Fail
-spec@!opengl 2.0@gl-2.0-edgeflag-immediate,Fail
spec@!opengl 2.0@vs-point_size-zero,Fail
spec@!opengl 2.1@pbo,Fail
spec@!opengl 2.1@pbo@test_polygon_stip,Fail
}
ctx->gfx_pipeline_state.gfx_prim_mode = mode;
- if (!screen->optimal_keys &&
- (lines_changed || points_changed || rast_state_changed || ctx->gfx_pipeline_state.modules_changed))
- zink_set_primitive_emulation_keys(ctx);
+ if ((mode_changed || points_changed || lines_changed || rast_state_changed || ctx->gfx_pipeline_state.modules_changed)) {
+ if (screen->optimal_keys)
+ zink_create_primitive_emulation_gs(ctx);
+ else
+ zink_set_primitive_emulation_keys(ctx);
+ }
if (index_size) {
const VkIndexType index_type[3] = {
util_queue_add_job(&screen->cache_get_thread, data, fence, execute, cleanup, job_size);
}
+static bool
+has_edge_flags(struct zink_context *ctx)
+{
+ switch(ctx->gfx_pipeline_state.gfx_prim_mode) {
+ case PIPE_PRIM_POINTS:
+ case PIPE_PRIM_LINE_STRIP:
+ case PIPE_PRIM_LINE_STRIP_ADJACENCY:
+ case PIPE_PRIM_LINES:
+ case PIPE_PRIM_LINE_LOOP:
+ case PIPE_PRIM_LINES_ADJACENCY:
+ case PIPE_PRIM_TRIANGLE_STRIP:
+ case PIPE_PRIM_TRIANGLE_FAN:
+ case PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY:
+ case PIPE_PRIM_QUAD_STRIP:
+ return false;
+ case PIPE_PRIM_TRIANGLES:
+ case PIPE_PRIM_TRIANGLES_ADJACENCY:
+ case PIPE_PRIM_QUADS:
+ case PIPE_PRIM_POLYGON:
+ case PIPE_PRIM_PATCHES:
+ case PIPE_PRIM_MAX:
+ default:
+ break;
+ }
+ return ctx->gfx_pipeline_state.rast_prim == PIPE_PRIM_LINES &&
+ ctx->gfx_stages[MESA_SHADER_VERTEX]->has_edgeflags;
+}
+
void
zink_set_primitive_emulation_keys(struct zink_context *ctx)
{
ctx->rast_state->base.line_smooth &&
!ctx->num_so_targets;
+ bool lower_edge_flags = has_edge_flags(ctx);
+
if (zink_get_fs_key(ctx)->lower_line_smooth != lower_line_smooth) {
assert(zink_get_gs_key(ctx)->lower_line_smooth ==
zink_get_fs_key(ctx)->lower_line_smooth);
zink_set_fs_key(ctx)->lower_point_smooth = lower_point_smooth;
}
- if (lower_line_stipple || lower_line_smooth ||
+ if (lower_line_stipple || lower_line_smooth || lower_edge_flags ||
zink_get_gs_key(ctx)->lower_gl_point) {
enum pipe_shader_type prev_vertex_stage =
ctx->gfx_stages[MESA_SHADER_TESS_EVAL] ?
nir_shader *nir = nir_create_passthrough_gs(
&screen->nir_options,
ctx->gfx_stages[prev_vertex_stage]->nir,
- (lower_line_stipple || lower_line_smooth) ? SHADER_PRIM_LINE_STRIP : SHADER_PRIM_POINTS,
- false);
+ ctx->gfx_pipeline_state.gfx_prim_mode,
+ lower_edge_flags);
+
+ struct zink_shader *shader = zink_shader_create(screen, nir, NULL);
+ ctx->gfx_stages[prev_vertex_stage]->non_fs.generated_gs[ctx->gfx_pipeline_state.gfx_prim_mode] = shader;
+ shader->non_fs.is_generated = true;
+ }
+
+ bind_gfx_stage(ctx, MESA_SHADER_GEOMETRY,
+ ctx->gfx_stages[prev_vertex_stage]->non_fs.generated_gs[ctx->gfx_pipeline_state.gfx_prim_mode]);
+ }
+ } else if (ctx->gfx_stages[MESA_SHADER_GEOMETRY] &&
+ ctx->gfx_stages[MESA_SHADER_GEOMETRY]->non_fs.is_generated)
+ bind_gfx_stage(ctx, MESA_SHADER_GEOMETRY, NULL);
+}
+
+void
+zink_create_primitive_emulation_gs(struct zink_context *ctx)
+{
+ struct zink_screen *screen = zink_screen(ctx->base.screen);
+ bool lower_edge_flags = has_edge_flags(ctx);
+
+ if (lower_edge_flags) {
+ enum pipe_shader_type prev_vertex_stage =
+ ctx->gfx_stages[MESA_SHADER_TESS_EVAL] ?
+ MESA_SHADER_TESS_EVAL : MESA_SHADER_VERTEX;
+
+ if (!ctx->gfx_stages[MESA_SHADER_GEOMETRY] ||
+ (ctx->gfx_stages[MESA_SHADER_GEOMETRY]->nir->info.gs.input_primitive != ctx->gfx_pipeline_state.gfx_prim_mode)) {
+
+ if (!ctx->gfx_stages[prev_vertex_stage]->non_fs.generated_gs[ctx->gfx_pipeline_state.gfx_prim_mode]) {
+ nir_shader *nir = nir_create_passthrough_gs(
+ &screen->nir_options,
+ ctx->gfx_stages[prev_vertex_stage]->nir,
+ ctx->gfx_pipeline_state.gfx_prim_mode,
+ lower_edge_flags);
struct zink_shader *shader = zink_shader_create(screen, nir, NULL);
ctx->gfx_stages[prev_vertex_stage]->non_fs.generated_gs[ctx->gfx_pipeline_state.gfx_prim_mode] = shader;
void
zink_set_primitive_emulation_keys(struct zink_context *ctx);
+void
+zink_create_primitive_emulation_gs(struct zink_context *ctx);
+
static inline const struct zink_shader_key_base *
zink_get_shader_key_base(const struct zink_context *ctx, gl_shader_stage pstage)
{