[Mesa-dev] [PATCH 72/75] st/nine: Set CLAMP_TO_EDGE on cubetextures

Axel Davy axel.davy at ens.fr
Wed Oct 5 20:09:45 UTC 2016


From: Patrick Rudolph <siro at das-labor.org>

Wine tests show that cubetextures always use
PIPE_TEX_WRAP_CLAMP_TO_EDGE regardless of set
sampler states.

Fixes failing d3d9 wine test test_cube_wrap.

Signed-off-by: Patrick Rudolph <siro at das-labor.org>
Reviewed-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/nine_pipe.c  | 14 +++++++++++---
 src/gallium/state_trackers/nine/nine_state.c | 10 +++++++++-
 src/gallium/state_trackers/nine/nine_state.h |  3 ++-
 3 files changed, 22 insertions(+), 5 deletions(-)

diff --git a/src/gallium/state_trackers/nine/nine_pipe.c b/src/gallium/state_trackers/nine/nine_pipe.c
index ea7dc16..7e33c0a 100644
--- a/src/gallium/state_trackers/nine/nine_pipe.c
+++ b/src/gallium/state_trackers/nine/nine_pipe.c
@@ -220,9 +220,17 @@ nine_convert_sampler_state(struct cso_context *ctx, int idx, const DWORD *ss)
         samp.min_mip_filter = PIPE_TEX_MIPFILTER_NONE;
     }
     samp.max_lod = 15.0f;
-    samp.wrap_s = d3dtextureaddress_to_pipe_tex_wrap(ss[D3DSAMP_ADDRESSU]);
-    samp.wrap_t = d3dtextureaddress_to_pipe_tex_wrap(ss[D3DSAMP_ADDRESSV]);
-    samp.wrap_r = d3dtextureaddress_to_pipe_tex_wrap(ss[D3DSAMP_ADDRESSW]);
+
+    if (ss[NINED3DSAMP_CUBETEX]) {
+        /* Cube textures are always clamped to edge on D3D */
+        samp.wrap_s = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+        samp.wrap_t = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+        samp.wrap_r = PIPE_TEX_WRAP_CLAMP_TO_EDGE;
+    } else {
+        samp.wrap_s = d3dtextureaddress_to_pipe_tex_wrap(ss[D3DSAMP_ADDRESSU]);
+        samp.wrap_t = d3dtextureaddress_to_pipe_tex_wrap(ss[D3DSAMP_ADDRESSV]);
+        samp.wrap_r = d3dtextureaddress_to_pipe_tex_wrap(ss[D3DSAMP_ADDRESSW]);
+    }
     samp.min_img_filter = (ss[D3DSAMP_MINFILTER] == D3DTEXF_POINT && !ss[NINED3DSAMP_SHADOW]) ? PIPE_TEX_FILTER_NEAREST : PIPE_TEX_FILTER_LINEAR;
     samp.mag_img_filter = (ss[D3DSAMP_MAGFILTER] == D3DTEXF_POINT && !ss[NINED3DSAMP_SHADOW]) ? PIPE_TEX_FILTER_NEAREST : PIPE_TEX_FILTER_LINEAR;
     if (ss[D3DSAMP_MINFILTER] == D3DTEXF_ANISOTROPIC ||
diff --git a/src/gallium/state_trackers/nine/nine_state.c b/src/gallium/state_trackers/nine/nine_state.c
index ed3c821..f6bf51e 100644
--- a/src/gallium/state_trackers/nine/nine_state.c
+++ b/src/gallium/state_trackers/nine/nine_state.c
@@ -714,6 +714,13 @@ update_sampler_derived(struct nine_state *state, unsigned s)
         state->samp[s][NINED3DSAMP_SHADOW] = state->texture[s]->shadow;
     }
 
+    if (state->samp[s][NINED3DSAMP_CUBETEX] !=
+        (NineResource9(state->texture[s])->type == D3DRTYPE_CUBETEXTURE)) {
+        changed = TRUE;
+        state->samp[s][NINED3DSAMP_CUBETEX] =
+                NineResource9(state->texture[s])->type == D3DRTYPE_CUBETEXTURE;
+    }
+
     if (state->samp[s][D3DSAMP_MIPFILTER] != D3DTEXF_NONE) {
         int lod = state->samp[s][D3DSAMP_MAXMIPLEVEL] - state->texture[s]->managed.lod;
         if (lod < 0)
@@ -1264,7 +1271,8 @@ static const DWORD nine_samp_state_defaults[NINED3DSAMP_LAST + 1] =
     [D3DSAMP_ELEMENTINDEX] = 0,
     [D3DSAMP_DMAPOFFSET] = 0,
     [NINED3DSAMP_MINLOD] = 0,
-    [NINED3DSAMP_SHADOW] = 0
+    [NINED3DSAMP_SHADOW] = 0,
+    [NINED3DSAMP_CUBETEX] = 0
 };
 
 void nine_state_restore_non_cso(struct NineDevice9 *device)
diff --git a/src/gallium/state_trackers/nine/nine_state.h b/src/gallium/state_trackers/nine/nine_state.h
index 05eb2c1..1c50775 100644
--- a/src/gallium/state_trackers/nine/nine_state.h
+++ b/src/gallium/state_trackers/nine/nine_state.h
@@ -30,6 +30,7 @@
 
 #define NINED3DSAMP_MINLOD (D3DSAMP_DMAPOFFSET + 1)
 #define NINED3DSAMP_SHADOW (D3DSAMP_DMAPOFFSET + 2)
+#define NINED3DSAMP_CUBETEX (D3DSAMP_DMAPOFFSET + 3)
 
 #define NINED3DRS_VSPOINTSIZE (D3DRS_BLENDOPALPHA + 1)
 #define NINED3DRS_RTMASK      (D3DRS_BLENDOPALPHA + 2)
@@ -42,7 +43,7 @@
 
 #define D3DRS_LAST       D3DRS_BLENDOPALPHA
 #define NINED3DRS_LAST   NINED3DRS_MULTISAMPLE /* 214 */
-#define NINED3DSAMP_LAST NINED3DSAMP_SHADOW /* 15 */
+#define NINED3DSAMP_LAST NINED3DSAMP_CUBETEX /* 16 */
 #define NINED3DTSS_LAST  D3DTSS_CONSTANT
 #define NINED3DTS_LAST   D3DTS_WORLDMATRIX(255)
 
-- 
2.10.0



More information about the mesa-dev mailing list