[Mesa-stable] [PATCH 2/4] nine: Add pool check to SetTexture (v2)

David Heidelberg david at ixit.cz
Fri Nov 21 19:13:58 PST 2014


From: Axel Davy <axel.davy at ens.fr>

D3DPOOL_SCRATCH is disallowed according to spec.
D3DPOOL_SYSTEMMEM should be allowed but we don't handle it right for now.

v2: Fixes segfault in SetTexture when unsetting the texture

Cc: "10.4" <mesa-stable at lists.freedesktop.org>
Tested-by: David Heidelberg <david at ixit.cz>
Signed-off-by: Axel Davy <axel.davy at ens.fr>
---
 src/gallium/state_trackers/nine/device9.c | 10 +++++++++-
 1 file changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/gallium/state_trackers/nine/device9.c b/src/gallium/state_trackers/nine/device9.c
index 5f95b42..db410a1 100644
--- a/src/gallium/state_trackers/nine/device9.c
+++ b/src/gallium/state_trackers/nine/device9.c
@@ -2172,6 +2172,7 @@ NineDevice9_SetTexture( struct NineDevice9 *This,
                         IDirect3DBaseTexture9 *pTexture )
 {
     struct nine_state *state = This->update;
+    struct NineBaseTexture9 *tex = NineBaseTexture9(pTexture);
 
     DBG("This=%p Stage=%u pTexture=%p\n", This, Stage, pTexture);
 
@@ -2179,12 +2180,19 @@ NineDevice9_SetTexture( struct NineDevice9 *This,
                 Stage == D3DDMAPSAMPLER ||
                 (Stage >= D3DVERTEXTEXTURESAMPLER0 &&
                  Stage <= D3DVERTEXTEXTURESAMPLER3), D3DERR_INVALIDCALL);
+    user_assert(!tex || tex->base.pool != D3DPOOL_SCRATCH, D3DERR_INVALIDCALL);
+
+    if (unlikely(tex && tex->base.pool == D3DPOOL_SYSTEMMEM)) {
+        /* TODO: Currently not implemented. Better return error
+         * with message telling what's wrong */
+        ERR("This=%p D3DPOOL_SYSTEMMEM not implemented for SetTexture\n", This);
+        user_assert(tex->base.pool != D3DPOOL_SYSTEMMEM, D3DERR_INVALIDCALL);
+    }
 
     if (Stage >= D3DDMAPSAMPLER)
         Stage = Stage - D3DDMAPSAMPLER + NINE_MAX_SAMPLERS_PS;
 
     if (!This->is_recording) {
-        struct NineBaseTexture9 *tex = NineBaseTexture9(pTexture);
         struct NineBaseTexture9 *old = state->texture[Stage];
         if (old == tex)
             return D3D_OK;
-- 
2.1.3



More information about the mesa-stable mailing list