Mesa (staging/20.0): radeonsi: Use TRUNC_COORD on samplers
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Jun 1 21:38:30 UTC 2020
Module: Mesa
Branch: staging/20.0
Commit: 5618984b679417507fa29d9a95ee16444688500a
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=5618984b679417507fa29d9a95ee16444688500a
Author: Joshua Ashton <joshua at froggi.es>
Date: Wed Apr 22 05:30:36 2020 +0100
radeonsi: Use TRUNC_COORD on samplers
The default behaviour (0) is: "round-nearest-even to n.6 and drop fraction when point sampling" whereas the OpenGL spec simply wants us to floor it (1) "truncate when point sampling".
See 8.14.2 in the OpenGL spec:
https://www.khronos.org/registry/OpenGL/specs/gl/glspec46.core.pdf
The Direct3D spec also mandates this (https://microsoft.github.io/DirectX-Specs/d3d/archive/D3D11_3_FunctionalSpec.htm#7.18.7%20Point%20Sample%20Addressing)
On WineD3D:
This fixes some point-sampling texture precision issues in some Direct3D 9 titles such as Guild Wars 2 and htoL#NiQ: The Firefly Diary that are not present on other vendors.
CC: <mesa-stable at lists.freedesktop.org>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/3953>
(cherry picked from commit d573d1d82524b8a2e5f56938069cabc0f0176a0e)
---
.pick_status.json | 2 +-
src/gallium/drivers/radeonsi/si_state.c | 21 +++++++++++----------
2 files changed, 12 insertions(+), 11 deletions(-)
diff --git a/.pick_status.json b/.pick_status.json
index a0eda751011..5a3b202e5ee 100644
--- a/.pick_status.json
+++ b/.pick_status.json
@@ -5971,7 +5971,7 @@
"description": "radeonsi: Use TRUNC_COORD on samplers",
"nominated": true,
"nomination_type": 0,
- "resolution": 0,
+ "resolution": 1,
"master_sha": null,
"because_sha": null
},
diff --git a/src/gallium/drivers/radeonsi/si_state.c b/src/gallium/drivers/radeonsi/si_state.c
index c44b376c514..a6e1f60eb28 100644
--- a/src/gallium/drivers/radeonsi/si_state.c
+++ b/src/gallium/drivers/radeonsi/si_state.c
@@ -4727,6 +4727,8 @@ static void *si_create_sampler_state(struct pipe_context *ctx,
unsigned max_aniso = sscreen->force_aniso >= 0 ? sscreen->force_aniso
: state->max_anisotropy;
unsigned max_aniso_ratio = si_tex_aniso_filter(max_aniso);
+ bool trunc_coord = state->min_img_filter == PIPE_TEX_FILTER_NEAREST &&
+ state->mag_img_filter == PIPE_TEX_FILTER_NEAREST;
union pipe_color_union clamped_border_color;
if (!rstate) {
@@ -4736,16 +4738,15 @@ static void *si_create_sampler_state(struct pipe_context *ctx,
#ifndef NDEBUG
rstate->magic = SI_SAMPLER_STATE_MAGIC;
#endif
- rstate->val[0] = (S_008F30_CLAMP_X(si_tex_wrap(state->wrap_s)) |
- S_008F30_CLAMP_Y(si_tex_wrap(state->wrap_t)) |
- S_008F30_CLAMP_Z(si_tex_wrap(state->wrap_r)) |
- S_008F30_MAX_ANISO_RATIO(max_aniso_ratio) |
- S_008F30_DEPTH_COMPARE_FUNC(si_tex_compare(state->compare_func)) |
- S_008F30_FORCE_UNNORMALIZED(!state->normalized_coords) |
- S_008F30_ANISO_THRESHOLD(max_aniso_ratio >> 1) |
- S_008F30_ANISO_BIAS(max_aniso_ratio) |
- S_008F30_DISABLE_CUBE_WRAP(!state->seamless_cube_map) |
- S_008F30_COMPAT_MODE(sctx->chip_class == GFX8 || sctx->chip_class == GFX9));
+ rstate->val[0] =
+ (S_008F30_CLAMP_X(si_tex_wrap(state->wrap_s)) | S_008F30_CLAMP_Y(si_tex_wrap(state->wrap_t)) |
+ S_008F30_CLAMP_Z(si_tex_wrap(state->wrap_r)) | S_008F30_MAX_ANISO_RATIO(max_aniso_ratio) |
+ S_008F30_DEPTH_COMPARE_FUNC(si_tex_compare(state->compare_func)) |
+ S_008F30_FORCE_UNNORMALIZED(!state->normalized_coords) |
+ S_008F30_ANISO_THRESHOLD(max_aniso_ratio >> 1) | S_008F30_ANISO_BIAS(max_aniso_ratio) |
+ S_008F30_DISABLE_CUBE_WRAP(!state->seamless_cube_map) |
+ S_008F30_TRUNC_COORD(trunc_coord) |
+ S_008F30_COMPAT_MODE(sctx->chip_class == GFX8 || sctx->chip_class == GFX9));
rstate->val[1] = (S_008F34_MIN_LOD(S_FIXED(CLAMP(state->min_lod, 0, 15), 8)) |
S_008F34_MAX_LOD(S_FIXED(CLAMP(state->max_lod, 0, 15), 8)) |
S_008F34_PERF_MIP(max_aniso_ratio ? max_aniso_ratio + 6 : 0));
More information about the mesa-commit
mailing list