Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=38138 Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/wined3d/arb_program_shader.c | 2 +- dlls/wined3d/glsl_shader.c | 4 ++-- dlls/wined3d/state.c | 2 +- dlls/wined3d/wined3d_private.h | 5 +++++ 4 files changed, 9 insertions(+), 4 deletions(-)
diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 4dafb3442e..37ec7e9093 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -5945,7 +5945,7 @@ static void alpha_test_arbfp(struct wined3d_context *context, const struct wined return; }
- ref = ((float)state->render_states[WINED3D_RS_ALPHAREF]) / 255.0f; + ref = wined3d_alpha_ref(state); glParm = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ALPHAFUNC]);
if (glParm) diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 714ab0249e..70b4458977 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2149,7 +2149,7 @@ static void shader_glsl_load_constants(void *shader_priv, struct wined3d_context
if (update_mask & WINED3D_SHADER_CONST_PS_ALPHA_TEST) { - float ref = state->render_states[WINED3D_RS_ALPHAREF] / 255.0f; + float ref = wined3d_alpha_ref(state);
GL_EXTCALL(glUniform1f(prog->ps.alpha_test_ref_location, ref)); checkGLcall("alpha test emulation uniform"); @@ -12874,7 +12874,7 @@ static void glsl_fragment_pipe_alpha_test_func(struct wined3d_context *context, { const struct wined3d_gl_info *gl_info = context->gl_info; GLint func = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ALPHAFUNC]); - float ref = state->render_states[WINED3D_RS_ALPHAREF] / 255.0f; + float ref = wined3d_alpha_ref(state);
if (func) { diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index c62cd92c01..a80009ca5a 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -681,7 +681,7 @@ void state_alpha_test(struct wined3d_context *context, const struct wined3d_stat } else { - ref = ((float)state->render_states[WINED3D_RS_ALPHAREF]) / 255.0f; + ref = wined3d_alpha_ref(state); glParm = wined3d_gl_compare_func(state->render_states[WINED3D_RS_ALPHAFUNC]); } if (glParm) diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 825843b0d3..200e36184f 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3112,6 +3112,11 @@ static inline BOOL isStateDirty(const struct wined3d_context *context, DWORD sta return context->isStateDirty[idx] & (1u << shift); }
+static inline float wined3d_alpha_ref(const struct wined3d_state *state) +{ + return (state->render_states[WINED3D_RS_ALPHAREF] & 0xff) / 255.0f; +} + const char *wined3d_debug_resource_access(DWORD access) DECLSPEC_HIDDEN; const char *wined3d_debug_bind_flags(DWORD bind_flags) DECLSPEC_HIDDEN; const char *wined3d_debug_view_desc(const struct wined3d_view_desc *d,
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d9/tests/visual.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 7fb3a6337c..f999ea99cd 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -13607,6 +13607,7 @@ static void alphatest_test(void) D3DCOLOR color; ULONG refcount; D3DCAPS9 caps; + DWORD value; HWND window; HRESULT hr;
@@ -13738,10 +13739,32 @@ static void alphatest_test(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr); color = getPixelColor(device, 320, 240); - ok(color_match(color, testdata[i].color_greater, 1), "Alphatest failed. Got color 0x%08x, expected 0x%08x. alpha > ref, func %u\n", - color, testdata[i].color_greater, testdata[i].func); + ok(color_match(color, testdata[i].color_greater, 1), + "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n", + color, testdata[i].color_greater, testdata[i].func); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); - ok(SUCCEEDED(hr), "IDirect3DDevice9_Present failed with 0x%08x\n", hr); + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed, hr %#x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice9_Clear failed, hr %#x.\n", hr); + hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ALPHAREF, 0xff70); + ok(hr == D3D_OK, "IDirect3DDevice9_SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice9_GetRenderState(device, D3DRS_ALPHAREF, &value); + ok(hr == D3D_OK, "IDirect3DDevice9_GetRenderState failed, hr %#x.\n", hr); + ok(value == 0xff70, "Unexpected D3DRS_ALPHAREF value %#x.\n", value); + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_BeginScene failed, hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad)); + ok(hr == D3D_OK, "IDirect3DDevice9_DrawPrimitiveUP failed, hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice9_EndScene failed, hr %#x.\n", hr); + color = getPixelColor(device, 320, 240); + ok(color_match(color, testdata[i].color_greater, 1), + "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n", + color, testdata[i].color_greater, testdata[i].func); + hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice9_Present failed, hr %#x.\n", hr); + } }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/d3d8/tests/visual.c | 164 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 164 insertions(+)
diff --git a/dlls/d3d8/tests/visual.c b/dlls/d3d8/tests/visual.c index 7399d270e8..cda1b46544 100644 --- a/dlls/d3d8/tests/visual.c +++ b/dlls/d3d8/tests/visual.c @@ -10739,6 +10739,169 @@ static void test_sysmem_draw(void) DestroyWindow(window); }
+static void test_alphatest(void) +{ +#define ALPHATEST_PASSED 0x0000ff00 +#define ALPHATEST_FAILED 0x00ff0000 + D3DPRESENT_PARAMETERS present_parameters = {0}; + IDirect3DDevice8 *device; + unsigned int i, j; + IDirect3D8 *d3d; + D3DCOLOR color; + ULONG refcount; + D3DCAPS8 caps; + DWORD value; + HWND window; + HRESULT hr; + DWORD ps; + + + static const struct + { + D3DCMPFUNC func; + D3DCOLOR color_less; + D3DCOLOR color_equal; + D3DCOLOR color_greater; + } + test_data[] = + { + {D3DCMP_NEVER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_FAILED}, + {D3DCMP_LESS, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_FAILED}, + {D3DCMP_EQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_FAILED}, + {D3DCMP_LESSEQUAL, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_FAILED}, + {D3DCMP_GREATER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_PASSED}, + {D3DCMP_NOTEQUAL, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_PASSED}, + {D3DCMP_GREATEREQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_PASSED}, + {D3DCMP_ALWAYS, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_PASSED}, + }; + static const struct + { + struct vec3 position; + DWORD diffuse; + } + quad[] = + { + {{-1.0f, -1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + {{-1.0f, 1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + {{ 1.0f, -1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + {{ 1.0f, 1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + }; + + window = create_window(); + ok(!!window, "Failed to create a window.\n"); + + d3d = Direct3DCreate8(D3D_SDK_VERSION); + ok(!!d3d, "Failed to create a D3D object.\n"); + + present_parameters.BackBufferWidth = 640; + present_parameters.BackBufferHeight = 480; + present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8; + present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD; + present_parameters.hDeviceWindow = window; + present_parameters.Windowed = TRUE; + present_parameters.EnableAutoDepthStencil = TRUE; + present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8; + if (FAILED(hr = IDirect3D8_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, + window, D3DCREATE_MIXED_VERTEXPROCESSING, &present_parameters, &device))) + { + skip("Failed to create a D3D device, skipping tests.\n"); + IDirect3D8_Release(d3d); + DestroyWindow(window); + return; + } + + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, 0xff0000ff, 1.0f, 0); + ok(hr == D3D_OK, "Failed to clear, hr %#x.\n", hr); + + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_LIGHTING, FALSE); + ok(hr == D3D_OK, "Failed to disable lighting, hr %#x.\n", hr); + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHATESTENABLE, TRUE); + ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState, hr %#x.\n", hr); + hr = IDirect3DDevice8_SetVertexShader(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); + ok(hr == D3D_OK, "IDirect3DDevice8_SetVertexShader failed, hr %#x.\n", hr); + + ps = 0; + for (j = 0; j < 2; ++j) + { + if (j == 1) + { + /* Try a pixel shader instead of fixed function. The wined3d code + * may emulate the alpha test either for performance reasons + * (floating point RTs) or to work around driver bugs (GeForce + * 7x00 cards on MacOS). There may be a different codepath for ffp + * and shader in this case, and the test should cover both. */ + static const DWORD shader_code[] = + { + 0xffff0101, /* ps_1_1 */ + 0x00000001, 0x800f0000, 0x90e40000, /* mov r0, v0 */ + 0x0000ffff /* end */ + }; + memset(&caps, 0, sizeof(caps)); + hr = IDirect3DDevice8_GetDeviceCaps(device, &caps); + ok(hr == D3D_OK, "IDirect3DDevice8_GetDeviceCaps failed, hr %#x.\n", hr); + if(caps.PixelShaderVersion < D3DPS_VERSION(1, 1)) { + break; + } + + hr = IDirect3DDevice8_CreatePixelShader(device, shader_code, &ps); + ok(hr == D3D_OK, "IDirect3DDevice8_CreatePixelShader failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_SetPixelShader(device, ps); + ok(hr == D3D_OK, "IDirect3DDevice8_SetPixelShader failed, hr %#x.\n", hr); + } + + for(i = 0; i < ARRAY_SIZE(test_data); ++i) + { + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHAFUNC, test_data[i].func); + ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#x.\n", hr); + + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHAREF, 0x70); + ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad)); + ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed, hr %#x.\n", hr); + color = getPixelColor(device, 320, 240); + ok(color_match(color, test_data[i].color_greater, 1), + "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n", + color, test_data[i].color_greater, test_data[i].func); + hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr %#x.\n", hr); + + hr = IDirect3DDevice8_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice8_Clear failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_SetRenderState(device, D3DRS_ALPHAREF, 0xff70); + ok(hr == D3D_OK, "IDirect3DDevice8_SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_GetRenderState(device, D3DRS_ALPHAREF, &value); + ok(hr == D3D_OK, "IDirect3DDevice8_GetRenderState failed, hr %#x.\n", hr); + ok(value == 0xff70, "Unexpected D3DRS_ALPHAREF value %#x.\n", value); + hr = IDirect3DDevice8_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice8_BeginScene failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad)); + ok(hr == D3D_OK, "IDirect3DDevice8_DrawPrimitiveUP failed, hr %#x.\n", hr); + hr = IDirect3DDevice8_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice8_EndScene failed, hr %#x.\n", hr); + color = getPixelColor(device, 320, 240); + ok(color_match(color, test_data[i].color_greater, 1), + "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n", + color, test_data[i].color_greater, test_data[i].func); + hr = IDirect3DDevice8_Present(device, NULL, NULL, NULL, NULL); + ok(hr == D3D_OK, "IDirect3DDevice8_Present failed, hr %#x.\n", hr); + } + } + if (ps) + IDirect3DDevice8_DeletePixelShader(device, ps); + + refcount = IDirect3DDevice8_Release(device); + ok(!refcount, "Device has %u references left.\n", refcount); +done: + IDirect3D8_Release(d3d); + DestroyWindow(window); +} + START_TEST(visual) { D3DADAPTER_IDENTIFIER8 identifier; @@ -10814,4 +10977,5 @@ START_TEST(visual) test_viewport(); test_color_vertex(); test_sysmem_draw(); + test_alphatest(); }
On Tue, 5 Feb 2019 at 19:42, Paul Gofman gofmanp@gmail.com wrote:
- present_parameters.BackBufferWidth = 640;
- present_parameters.BackBufferHeight = 480;
- present_parameters.BackBufferFormat = D3DFMT_A8R8G8B8;
- present_parameters.SwapEffect = D3DSWAPEFFECT_DISCARD;
- present_parameters.hDeviceWindow = window;
- present_parameters.Windowed = TRUE;
- present_parameters.EnableAutoDepthStencil = TRUE;
- present_parameters.AutoDepthStencilFormat = D3DFMT_D24S8;
- if (FAILED(hr = IDirect3D8_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
window, D3DCREATE_MIXED_VERTEXPROCESSING, &present_parameters, &device)))
Does this really require mixed vertex processing?
if(caps.PixelShaderVersion < D3DPS_VERSION(1, 1)) {
Formatting.
On 2/5/19 20:58, Henri Verbeet wrote:
On Tue, 5 Feb 2019 at 19:42, Paul Gofman gofmanp@gmail.com wrote:
- if (FAILED(hr = IDirect3D8_CreateDevice(d3d, D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL,
window, D3DCREATE_MIXED_VERTEXPROCESSING, &present_parameters, &device)))
Does this really require mixed vertex processing?
Oh, not really. I will change this to use create_device() instead.
Signed-off-by: Paul Gofman gofmanp@gmail.com --- dlls/ddraw/tests/visual.c | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+)
diff --git a/dlls/ddraw/tests/visual.c b/dlls/ddraw/tests/visual.c index 2cb1c89231..5ce751b5b5 100644 --- a/dlls/ddraw/tests/visual.c +++ b/dlls/ddraw/tests/visual.c @@ -1594,6 +1594,99 @@ static void DX1_BackBufferFlipTest(void) if (window) DestroyWindow(window); }
+static void alphatest_test(IDirect3DDevice7 *device) +{ +#define ALPHATEST_PASSED 0x0000ff00 +#define ALPHATEST_FAILED 0x00ff0000 + unsigned int i, j; + D3DCOLOR color; + DWORD value; + HRESULT hr; + + static const struct + { + D3DCMPFUNC func; + D3DCOLOR color_less; + D3DCOLOR color_equal; + D3DCOLOR color_greater; + } + test_data[] = + { + {D3DCMP_NEVER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_FAILED}, + {D3DCMP_LESS, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_FAILED}, + {D3DCMP_EQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_FAILED}, + {D3DCMP_LESSEQUAL, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_FAILED}, + {D3DCMP_GREATER, ALPHATEST_FAILED, ALPHATEST_FAILED, ALPHATEST_PASSED}, + {D3DCMP_NOTEQUAL, ALPHATEST_PASSED, ALPHATEST_FAILED, ALPHATEST_PASSED}, + {D3DCMP_GREATEREQUAL, ALPHATEST_FAILED, ALPHATEST_PASSED, ALPHATEST_PASSED}, + {D3DCMP_ALWAYS, ALPHATEST_PASSED, ALPHATEST_PASSED, ALPHATEST_PASSED}, + }; + static struct + { + struct vec3 position; + DWORD diffuse; + } + quad[] = + { + {{-1.0f, -1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + {{-1.0f, 1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + {{ 1.0f, -1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + {{ 1.0f, 1.0f, 0.1f}, ALPHATEST_PASSED | 0x80000000}, + }; + + hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0xff0000ff, 0.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_LIGHTING, FALSE); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ZENABLE, FALSE); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHATESTENABLE, TRUE); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr %#x.\n", hr); + + for(i = 0; i < ARRAY_SIZE(test_data); ++i) + { + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHAFUNC, test_data[i].func); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr %#x.\n", hr); + + hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0x70); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, + D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0); + ok(hr == D3D_OK, "IDirect3DDevice7_DrawPrimitive failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed, hr %#x.\n", hr); + color = getPixelColor(device, 320, 240); + ok(color_match(color, test_data[i].color_greater, 1), + "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n", + color, test_data[i].color_greater, test_data[i].func); + + hr = IDirect3DDevice7_Clear(device, 0, NULL, D3DCLEAR_TARGET, ALPHATEST_FAILED, 0.0f, 0); + ok(hr == D3D_OK, "IDirect3DDevice7_Clear failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHAREF, 0xff70); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_GetRenderState(device, D3DRENDERSTATE_ALPHAREF, &value); + ok(hr == D3D_OK, "IDirect3DDevice7_GetRenderState failed, hr %#x.\n", hr); + ok(value == 0xff70, "Unexpected D3DRS_ALPHAREF value %#x.\n", value); + hr = IDirect3DDevice7_BeginScene(device); + ok(hr == D3D_OK, "IDirect3DDevice7_BeginScene failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_DrawPrimitive(device, D3DPT_TRIANGLESTRIP, + D3DFVF_XYZ | D3DFVF_DIFFUSE, quad, ARRAY_SIZE(quad), 0); + ok(hr == D3D_OK, "IDirect3DDevice7_DrawPrimitive failed, hr %#x.\n", hr); + hr = IDirect3DDevice7_EndScene(device); + ok(hr == D3D_OK, "IDirect3DDevice7_EndScene failed, hr %#x.\n", hr); + color = getPixelColor(device, 320, 240); + ok(color_match(color, test_data[i].color_greater, 1), + "Alphatest failed, color 0x%08x, expected 0x%08x, alpha > ref, func %u.\n", + color, test_data[i].color_greater, test_data[i].func); + } + hr = IDirect3DDevice7_SetRenderState(device, D3DRENDERSTATE_ALPHATESTENABLE, FALSE); + ok(hr == D3D_OK, "IDirect3DDevice7_SetRenderState failed, hr %#x.\n", hr); +} + START_TEST(visual) { HRESULT hr; @@ -1640,6 +1733,7 @@ START_TEST(visual) test_blend(Direct3DDevice); rhw_zero_test(Direct3DDevice); cubemap_test(Direct3DDevice); + alphatest_test(Direct3DDevice);
releaseObjects(); /* release DX7 interfaces to test D3D1 */
On Tue, 5 Feb 2019 at 19:47, Paul Gofman gofmanp@gmail.com wrote:
dlls/ddraw/tests/visual.c | 94 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+)
New ddraw tests should go into ddraw[1247].c.