From 47708a771714ea9853d4b1490530f675a5e32fb3 Mon Sep 17 00:00:00 2001 From: "H. Verbeet" Date: Wed, 27 Jun 2007 23:47:24 +0200 Subject: [PATCH] wined3d: Check more thoroughly if a stage references a texture. --- dlls/wined3d/device.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 1385c378a04..55b161d0927 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -3222,7 +3222,38 @@ static void device_update_fixed_function_usage_map(IWineD3DDeviceImpl *This) { int i; for (i = 0; i < MAX_TEXTURES; ++i) { - This->fixed_function_usage_map[i] = This->stateBlock->textures[i] ? TRUE : FALSE; + WINED3DTEXTUREOP color_op = This->stateBlock->textureState[i][WINED3DTSS_COLOROP]; + WINED3DTEXTUREOP alpha_op = This->stateBlock->textureState[i][WINED3DTSS_ALPHAOP]; + DWORD color_arg1 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG1] & WINED3DTA_SELECTMASK; + DWORD color_arg2 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG2] & WINED3DTA_SELECTMASK; + DWORD color_arg3 = This->stateBlock->textureState[i][WINED3DTSS_COLORARG0] & WINED3DTA_SELECTMASK; + DWORD alpha_arg1 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG1] & WINED3DTA_SELECTMASK; + DWORD alpha_arg2 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG2] & WINED3DTA_SELECTMASK; + DWORD alpha_arg3 = This->stateBlock->textureState[i][WINED3DTSS_ALPHAARG0] & WINED3DTA_SELECTMASK; + + if (color_op == WINED3DTOP_DISABLE) { + /* Not used, and disable higher stages */ + while (i < MAX_TEXTURES) { + This->fixed_function_usage_map[i] = FALSE; + ++i; + } + break; + } + + if (((color_arg1 == WINED3DTA_TEXTURE) && color_op != WINED3DTOP_SELECTARG2) + || ((color_arg2 == WINED3DTA_TEXTURE) && color_op != WINED3DTOP_SELECTARG1) + || ((color_arg3 == WINED3DTA_TEXTURE) && (color_op == WINED3DTOP_MULTIPLYADD || color_op == WINED3DTOP_LERP)) + || ((alpha_arg1 == WINED3DTA_TEXTURE) && alpha_op != WINED3DTOP_SELECTARG2) + || ((alpha_arg2 == WINED3DTA_TEXTURE) && alpha_op != WINED3DTOP_SELECTARG1) + || ((alpha_arg3 == WINED3DTA_TEXTURE) && (alpha_op == WINED3DTOP_MULTIPLYADD || alpha_op == WINED3DTOP_LERP))) { + This->fixed_function_usage_map[i] = TRUE; + } else { + This->fixed_function_usage_map[i] = FALSE; + } + + if ((color_op == WINED3DTOP_BUMPENVMAP || color_op == WINED3DTOP_BUMPENVMAPLUMINANCE) && i < MAX_TEXTURES - 1) { + This->fixed_function_usage_map[i+1] = TRUE; + } } }