buildroot/package/mesa3d/0069-zink-setup-driver-work...

98 lines
4.8 KiB
Diff

From 029c0c28de05dc744d98dce9ea543d04993abd13 Mon Sep 17 00:00:00 2001
From: Imagination Technologies <powervr@imgtec.com>
Date: Tue, 27 Sep 2022 12:53:03 +0200
Subject: [PATCH 069/168] zink: setup driver-workaround for missing linestipple
This is not ideal, but at least it should work. In the long run, we
might want to store a bit per mode we're missing, so we can do this
conditionally. But that's quite a bit more complicated, so let's go with
this for now.
The line-stippling logic needs non-optimal shader-keys. So let's drop
some perf on the floor here.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19117>
---
src/gallium/drivers/zink/zink_draw.cpp | 2 +-
src/gallium/drivers/zink/zink_pipeline.c | 2 +-
src/gallium/drivers/zink/zink_screen.c | 17 ++++++++++++++++-
src/gallium/drivers/zink/zink_types.h | 1 +
4 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/src/gallium/drivers/zink/zink_draw.cpp b/src/gallium/drivers/zink/zink_draw.cpp
index 21884073e3f..e414f9e7901 100644
--- a/src/gallium/drivers/zink/zink_draw.cpp
+++ b/src/gallium/drivers/zink/zink_draw.cpp
@@ -670,7 +670,7 @@ zink_draw(struct pipe_context *pctx,
VKCTX(CmdSetCullModeEXT)(batch->state->cmdbuf, ctx->gfx_pipeline_state.dyn_state1.cull_mode);
}
if ((BATCH_CHANGED || rast_state_changed) &&
- (DYNAMIC_STATE >= ZINK_DYNAMIC_STATE3 || (screen->info.have_EXT_line_rasterization && rast_state->base.line_stipple_enable)))
+ (DYNAMIC_STATE >= ZINK_DYNAMIC_STATE3 || (!screen->driver_workarounds.no_linestipple && rast_state->base.line_stipple_enable)))
VKCTX(CmdSetLineStippleEXT)(batch->state->cmdbuf, rast_state->base.line_stipple_factor, rast_state->base.line_stipple_pattern);
if ((BATCH_CHANGED || rast_state_changed) && DYNAMIC_STATE >= ZINK_DYNAMIC_STATE3) {
diff --git a/src/gallium/drivers/zink/zink_pipeline.c b/src/gallium/drivers/zink/zink_pipeline.c
index 12869a7ccc6..b78c5df3408 100644
--- a/src/gallium/drivers/zink/zink_pipeline.c
+++ b/src/gallium/drivers/zink/zink_pipeline.c
@@ -681,7 +681,7 @@ zink_create_gfx_pipeline_library(struct zink_screen *screen, struct zink_gfx_pro
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_LINE_RASTERIZATION_MODE_EXT;
if (screen->info.dynamic_state3_feats.extendedDynamicState3LineStippleEnable)
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_LINE_STIPPLE_ENABLE_EXT;
- if (screen->info.have_EXT_line_rasterization)
+ if (!screen->driver_workarounds.no_linestipple)
dynamicStateEnables[state_count++] = VK_DYNAMIC_STATE_LINE_STIPPLE_EXT;
assert(state_count < ARRAY_SIZE(dynamicStateEnables));
diff --git a/src/gallium/drivers/zink/zink_screen.c b/src/gallium/drivers/zink/zink_screen.c
index 79d85ce1899..e2f65c7a348 100644
--- a/src/gallium/drivers/zink/zink_screen.c
+++ b/src/gallium/drivers/zink/zink_screen.c
@@ -2343,6 +2343,18 @@ init_driver_workarounds(struct zink_screen *screen)
/* performance */
screen->info.border_color_feats.customBorderColorWithoutFormat = VK_FALSE;
}
+
+ if ((!screen->info.have_EXT_line_rasterization ||
+ !screen->info.line_rast_feats.stippledBresenhamLines) &&
+ screen->info.feats.features.geometryShader &&
+ screen->info.feats.features.sampleRateShading) {
+ /* we're using stippledBresenhamLines as a proxy for all of these, to
+ * avoid accidentally changing behavior on VK-drivers where we don't
+ * want to add emulation.
+ */
+ screen->driver_workarounds.no_linestipple = true;
+ }
+
if (screen->info.driver_props.driverID == VK_DRIVER_ID_AMD_OPEN_SOURCE ||
screen->info.driver_props.driverID == VK_DRIVER_ID_AMD_PROPRIETARY ||
screen->info.driver_props.driverID == VK_DRIVER_ID_NVIDIA_PROPRIETARY ||
@@ -2710,7 +2722,10 @@ zink_internal_create_screen(const struct pipe_screen_config *config)
goto fail;
}
- screen->optimal_keys = !screen->need_decompose_attrs && screen->info.have_EXT_non_seamless_cube_map && !screen->driconf.inline_uniforms;
+ screen->optimal_keys = !screen->need_decompose_attrs &&
+ screen->info.have_EXT_non_seamless_cube_map &&
+ !screen->driconf.inline_uniforms &&
+ !screen->driver_workarounds.no_linestipple;
if (!screen->optimal_keys)
screen->info.have_EXT_graphics_pipeline_library = false;
diff --git a/src/gallium/drivers/zink/zink_types.h b/src/gallium/drivers/zink/zink_types.h
index 7968e44aad2..b1d41bfc0cf 100644
--- a/src/gallium/drivers/zink/zink_types.h
+++ b/src/gallium/drivers/zink/zink_types.h
@@ -1279,6 +1279,7 @@ struct zink_screen {
bool always_feedback_loop_zs;
bool needs_sanitised_layer;
bool track_renderpasses;
+ bool no_linestipple;
unsigned z16_unscaled_bias;
unsigned z24_unscaled_bias;
} driver_workarounds;
--
2.17.1