[04/10] wined3d: Ignore SetTextureStageState on unsupported texture stages

H. Verbeet hverbeet at gmail.com
Mon Apr 16 14:19:51 CDT 2007


Tests indicate that Windows doesn't actually check the bounds on this
call. However, since our memory layout is almost certainly different
from Windows' an application might very well get away with a little
bit of memory corruption on Windows and not on Wine. It seems to me
that the best way to deal with this is to simply print a WARN and
return WINED3D_OK.

Changelog:
  - Ignore SetTextureStageState on unsupported texture stages
-------------- next part --------------
---

 dlls/wined3d/device.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index d4f8ddd..ba9698b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3774,6 +3774,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if
 
     TRACE("(%p) : Stage=%d, Type=%s(%d), Value=%d\n", This, Stage, debug_d3dtexturestate(Type), Type, Value);
 
+    if (Stage >= GL_LIMITS(texture_stages)) {
+        WARN("Attempting to set stage %u which is higher than the max stage %u, ignoring\n", Stage, GL_LIMITS(texture_stages) - 1);
+        return WINED3D_OK;
+    }
+
     This->updateStateBlock->changed.textureState[Stage][Type] = TRUE;
     This->updateStateBlock->set.textureState[Stage][Type]     = TRUE;
     This->updateStateBlock->textureState[Stage][Type]         = Value;


More information about the wine-patches mailing list