tu/lrz: Add tu_ignore_frag_depth_direction driconf

Will be useful if app doesn't specify depth direction correctly.
E.g. the capture of "Sons of The Forest" I have has a shader
where `gl_FragDepth` has `layout(depth_less)`, but the output for different
fragments is actually sometimes less, sometimes more than the original depth
by a tiny margin.

Signed-off-by: Danylo Piliaiev <dpiliaiev@igalia.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34423>
This commit is contained in:
Danylo Piliaiev
2025-05-05 14:32:50 +02:00
committed by Marge Bot
parent 847ad80e03
commit f03be478a9
5 changed files with 15 additions and 1 deletions
+3
View File
@@ -1643,6 +1643,7 @@ static const driOptionDescription tu_dri_options[] = {
DRI_CONF_TU_ALLOW_OOB_INDIRECT_UBO_LOADS(false)
DRI_CONF_TU_DISABLE_D24S8_BORDER_COLOR_WORKAROUND(false)
DRI_CONF_TU_USE_TEX_COORD_ROUND_NEAREST_EVEN_MODE(false)
DRI_CONF_TU_IGNORE_FRAG_DEPTH_DIRECTION(false)
DRI_CONF_SECTION_END
};
@@ -1667,6 +1668,8 @@ tu_init_dri_options(struct tu_instance *instance)
driQueryOptionb(&instance->dri_options, "tu_disable_d24s8_border_color_workaround");
instance->use_tex_coord_round_nearest_even_mode =
driQueryOptionb(&instance->dri_options, "tu_use_tex_coord_round_nearest_even_mode");
instance->ignore_frag_depth_direction =
driQueryOptionb(&instance->dri_options, "tu_ignore_frag_depth_direction");
}
static uint32_t instance_count = 0;
+3
View File
@@ -208,6 +208,9 @@ struct tu_instance
/* D3D emulation requires texture coordinates to be rounded to nearest even value. */
bool use_tex_coord_round_nearest_even_mode;
/* Apps may be accidentally incorrect */
bool ignore_frag_depth_direction;
};
VK_DEFINE_HANDLE_CASTS(tu_instance, vk.base, VkInstance,
VK_OBJECT_TYPE_INSTANCE)
+2 -1
View File
@@ -815,7 +815,8 @@ tu6_calculate_lrz_state(struct tu_cmd_buffer *cmd,
* enable late Z test.
*/
if (!disable_lrz_due_to_fs && fs->variant->writes_pos &&
!fs->variant->fs.early_fragment_tests) {
!fs->variant->fs.early_fragment_tests &&
!cmd->device->instance->ignore_frag_depth_direction) {
if (fs->variant->fs.depth_layout == FRAG_DEPTH_LAYOUT_NONE ||
fs->variant->fs.depth_layout == FRAG_DEPTH_LAYOUT_ANY) {
disable_lrz_due_to_fs = true;
+3
View File
@@ -1262,6 +1262,9 @@ TODO: document the other workarounds.
-->
<option name="tu_use_tex_coord_round_nearest_even_mode" value="true" />
</engine>
<application name="Sons Of The Forest" executable="SonsOfTheForest.exe">
<option name="tu_ignore_frag_depth_direction" value="true" />
</application>
</device>
<device driver="hk">
+4
View File
@@ -676,6 +676,10 @@
DRI_CONF_OPT_B(tu_use_tex_coord_round_nearest_even_mode, def, \
"Use D3D-compliant round-to-nearest-even mode for texture coordinates")
#define DRI_CONF_TU_IGNORE_FRAG_DEPTH_DIRECTION(def) \
DRI_CONF_OPT_B(tu_ignore_frag_depth_direction, def, \
"Ignore direction specified for gl_FragDepth output")
/**
* \brief Honeykrisp specific configuration options
*/