st/nine: Set CLAMP_TO_EDGE on cubetextures
authorPatrick Rudolph <siro@das-labor.org>
Sat, 24 Sep 2016 16:19:26 +0000 (18:19 +0200)
committerAxel Davy <axel.davy@ens.fr>
Mon, 10 Oct 2016 21:43:51 +0000 (23:43 +0200)
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@das-labor.org>
Reviewed-by: Axel Davy <axel.davy@ens.fr>
src/gallium/state_trackers/nine/nine_pipe.c
src/gallium/state_trackers/nine/nine_state.c
src/gallium/state_trackers/nine/nine_state.h

index ea7dc167ec37805c734c2b0b3ea247fafef28dca..7e33c0a9c390bcaa5ac0ed0b3f4bc08c22defd5e 100644 (file)
@@ -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 ||
index ed3c821f3376715c621f0637619cb421723fbff9..f6bf51e976341d53e23572bff86da6cccab1b076 100644 (file)
@@ -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)
index 05eb2c170d6478096d268318bee1ddb86e353201..1c50775670d9936e570d8cfae9b2b8ca55c86299 100644 (file)
@@ -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)