[PATCH 2/2] ddraw: Set _TSS_ALPHA_OP to _SELECT_ARG1 in case of NULL texture in fixup_texture_alpha_op().
Paul Gofman
gofmanp at gmail.com
Sat Jun 22 11:56:26 CDT 2019
Signed-off-by: Paul Gofman <gofmanp at gmail.com>
---
dlls/ddraw/device.c | 6 ++--
dlls/ddraw/tests/ddraw4.c | 65 +++++++++++++++++++++++++++------------
2 files changed, 49 insertions(+), 22 deletions(-)
diff --git a/dlls/ddraw/device.c b/dlls/ddraw/device.c
index 266499df4d..5f86450eec 100644
--- a/dlls/ddraw/device.c
+++ b/dlls/ddraw/device.c
@@ -2669,7 +2669,7 @@ static void fixup_texture_alpha_op(struct d3d_device *device)
/* This fixup is required by the way D3DTBLEND_MODULATE maps to texture stage states.
See d3d_device3_SetRenderState() for details. */
struct wined3d_texture *tex;
- BOOL tex_alpha = FALSE;
+ BOOL tex_alpha = TRUE;
DDPIXELFORMAT ddfmt;
if (!(device->legacyTextureBlending && device->texture_map_blend == D3DTBLEND_MODULATE))
@@ -2682,8 +2682,8 @@ static void fixup_texture_alpha_op(struct d3d_device *device)
wined3d_resource_get_desc(wined3d_texture_get_resource(tex), &desc);
ddfmt.dwSize = sizeof(ddfmt);
ddrawformat_from_wined3dformat(&ddfmt, desc.format);
- if (ddfmt.u5.dwRGBAlphaBitMask)
- tex_alpha = TRUE;
+ if (!ddfmt.u5.dwRGBAlphaBitMask)
+ tex_alpha = FALSE;
}
/* Args 1 and 2 are already set to WINED3DTA_TEXTURE/WINED3DTA_CURRENT in case of D3DTBLEND_MODULATE */
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index 6121f4f2c1..139566dbca 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -9506,6 +9506,7 @@ static void test_texturemapblend(void)
DDCOLORKEY ckey;
D3DCOLOR color;
ULONG refcount;
+ DWORD value;
HWND window;
DDBLTFX fx;
HRESULT hr;
@@ -9548,20 +9549,24 @@ static void test_texturemapblend(void)
}
hr = IDirect3DDevice3_GetDirect3D(device, &d3d);
- ok(SUCCEEDED(hr), "Failed to get d3d interface, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3D3_QueryInterface(d3d, &IID_IDirectDraw4, (void **)&ddraw);
- ok(SUCCEEDED(hr), "Failed to get ddraw interface, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderTarget(device, &rt);
- ok(SUCCEEDED(hr), "Failed to get render target, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
viewport = create_viewport(device, 0, 0, 640, 480);
hr = IDirect3DDevice3_SetCurrentViewport(device, viewport);
- ok(SUCCEEDED(hr), "Failed to set current viewport, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_GetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, &texturemapblend);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
ok(texturemapblend == D3DTBLEND_MODULATE, "Got unexpected texture map blend %#x.\n", texturemapblend);
+ hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
+
/* Test alpha with DDPF_ALPHAPIXELS texture - should be taken from texture
* alpha channel.
*
@@ -9582,15 +9587,29 @@ static void test_texturemapblend(void)
U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
U5(U4(surface_desc).ddpfPixelFormat).dwRGBAlphaBitMask = 0xff000000;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
- ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetTexture(device, 0, texture);
- ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
+
+ hr = IDirect3DDevice3_SetTexture(device, 0, NULL);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(value == D3DTOP_SELECTARG1, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
+
+ hr = IDirect3DDevice3_SetTexture(device, 0, texture);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
- ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
memset(&fx, 0, sizeof(fx));
fx.dwSize = sizeof(fx);
@@ -9615,8 +9634,12 @@ static void test_texturemapblend(void)
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+#if 0
+ /* Disable the call to test that the device has this state by default. */
hr = IDirect3DDevice3_SetRenderState(device, D3DRENDERSTATE_TEXTUREMAPBLEND, D3DTBLEND_MODULATE);
ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+#endif
/* Texture stage state does not change so legacy texture blending stays enabled. */
hr = IDirect3DDevice3_SetTextureStageState(device, 0, D3DTSS_COLOROP, D3DTOP_MODULATE);
@@ -9727,7 +9750,7 @@ static void test_texturemapblend(void)
ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
hr = IDirect3DDevice3_SetTexture(device, 0, NULL);
- ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
IDirect3DTexture2_Release(texture);
refcount = IDirectDrawSurface4_Release(surface);
ok(!refcount, "Surface not properly released, refcount %u.\n", refcount);
@@ -9748,33 +9771,37 @@ static void test_texturemapblend(void)
U4(U4(surface_desc).ddpfPixelFormat).dwBBitMask = 0x000000ff;
hr = IDirectDraw4_CreateSurface(ddraw, &surface_desc, &surface, NULL);
- ok(SUCCEEDED(hr), "Failed to create surface, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirectDrawSurface4_QueryInterface(surface, &IID_IDirect3DTexture2, (void **)&texture);
- ok(SUCCEEDED(hr), "Failed to get texture interface, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_SetTexture(device, 0, texture);
- ok(SUCCEEDED(hr), "Failed to set texture, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+
+ hr = IDirect3DDevice3_GetTextureStageState(device, 0, D3DTSS_ALPHAOP, &value);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
+ ok(value == D3DTOP_SELECTARG2, "Got unexpected D3DTSS_ALPHAOP value %#x.\n", value);
hr = IDirect3DViewport3_Clear(viewport, 1, &clear_rect, D3DCLEAR_TARGET);
- ok(SUCCEEDED(hr), "Failed to clear render target, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
U5(fx).dwFillColor = 0xff0000ff;
hr = IDirectDrawSurface4_Blt(surface, NULL, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
- ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
U5(fx).dwFillColor = 0x800000ff;
hr = IDirectDrawSurface4_Blt(surface, &rect, NULL, NULL, DDBLT_COLORFILL | DDBLT_WAIT, &fx);
- ok(SUCCEEDED(hr), "Failed to clear texture, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_BeginScene(device);
- ok(SUCCEEDED(hr), "Failed to begin scene, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[0], 4, 0);
- ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_DrawPrimitive(device, D3DPT_TRIANGLESTRIP,
D3DFVF_XYZRHW | D3DFVF_DIFFUSE | D3DFVF_TEX1, &test1_quads[4], 4, 0);
- ok(SUCCEEDED(hr), "Failed to draw, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
hr = IDirect3DDevice3_EndScene(device);
- ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+ ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr);
color = get_surface_color(rt, 5, 5);
ok(compare_color(color, 0x000000ff, 2), "Got unexpected color 0x%08x.\n", color);
--
2.21.0
More information about the wine-devel
mailing list