Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/context_gl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 73d520e5709..1f9003ed16e 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -627,7 +627,8 @@ static struct fbo_entry *wined3d_context_gl_find_fbo_entry(struct wined3d_contex struct fbo_entry *entry;
if (depth_stencil->resource && depth_stencil->resource->type != WINED3D_RTYPE_BUFFER - && render_targets[0].resource && render_targets[0].resource->type != WINED3D_RTYPE_BUFFER) + && render_targets[0].resource && render_targets[0].resource->type != WINED3D_RTYPE_BUFFER + && render_targets[0].resource->format->id != WINED3DFMT_NULL) { rt_texture = wined3d_texture_from_resource(render_targets[0].resource); rt_level = render_targets[0].sub_resource_idx % rt_texture->level_count;
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/d3d9/tests/visual.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index 5218d8a2029..efd8d701885 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -24986,6 +24986,7 @@ static void test_null_format(void) {600, 320, 0x0000ff00}, }; IDirect3DSurface9 *original_rt, *small_rt, *null_rt, *small_null_rt; + struct surface_readback rb; IDirect3DDevice9 *device; IDirect3D9 *d3d; unsigned int i; @@ -25101,13 +25102,15 @@ static void test_null_format(void) hr = IDirect3DDevice9_EndScene(device); ok(SUCCEEDED(hr), "Failed to end scene, hr %#x.\n", hr);
+ get_rt_readback(original_rt, &rb); for (i = 0; i < ARRAY_SIZE(expected_colors); ++i) { - color = getPixelColor(device, expected_colors[i].x, expected_colors[i].y); + color = get_readback_color(&rb, expected_colors[i].x, expected_colors[i].y); ok(color_match(color, expected_colors[i].color, 1), "Expected color 0x%08x at (%u, %u), got 0x%08x.\n", expected_colors[i].color, expected_colors[i].x, expected_colors[i].y, color); } + release_surface_readback(&rb);
hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- v2: Clear the depth buffer to a different value to workaround precision issues on Intel, use get_readback_color(), clean up a bit.
dlls/d3d9/tests/visual.c | 65 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+)
diff --git a/dlls/d3d9/tests/visual.c b/dlls/d3d9/tests/visual.c index efd8d701885..7c0a0157389 100644 --- a/dlls/d3d9/tests/visual.c +++ b/dlls/d3d9/tests/visual.c @@ -24931,6 +24931,7 @@ done:
static void test_null_format(void) { + static const D3DVIEWPORT9 vp_part_400 = {0, 100, 400, 200, 0.0f, 1.0f}; static const D3DVIEWPORT9 vp_lower = {0, 60, 640, 420, 0.0f, 1.0f}; static const D3DVIEWPORT9 vp_560 = {0, 180, 560, 300, 0.0f, 1.0f}; static const D3DVIEWPORT9 vp_full = {0, 0, 640, 480, 0.0f, 1.0f}; @@ -24984,8 +24985,21 @@ static void test_null_format(void) {440, 320, 0x000000ff}, {520, 320, 0x00000000}, {600, 320, 0x0000ff00}, + }, + expected_small[] = + { + {100, 100, 0x00ff0000}, + {200, 100, 0x00ff0000}, + {300, 100, 0x00ff0000}, + {100, 150, 0x00000000}, + {200, 150, 0x00000000}, + {300, 150, 0x00ff0000}, + {100, 200, 0x00000000}, + {200, 200, 0x00000000}, + {300, 200, 0x00ff0000}, }; IDirect3DSurface9 *original_rt, *small_rt, *null_rt, *small_null_rt; + IDirect3DSurface9 *original_ds, *small_ds; struct surface_readback rb; IDirect3DDevice9 *device; IDirect3D9 *d3d; @@ -25027,6 +25041,12 @@ static void test_null_format(void) D3DMULTISAMPLE_NONE, 0, FALSE, &small_null_rt, NULL); ok(SUCCEEDED(hr), "Failed to create render target, hr %#x.\n", hr);
+ hr = IDirect3DDevice9_GetDepthStencilSurface(device, &original_ds); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_CreateDepthStencilSurface(device, 400, 300, D3DFMT_D24S8, 0, 0, FALSE, + &small_ds, NULL); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetFVF(device, D3DFVF_XYZ | D3DFVF_DIFFUSE); ok(SUCCEEDED(hr), "Failed to set FVF, hr %#x.\n", hr); hr = IDirect3DDevice9_SetRenderState(device, D3DRS_ZENABLE, D3DZB_TRUE); @@ -25112,9 +25132,54 @@ static void test_null_format(void) } release_surface_readback(&rb);
+ /* Clears and draws on a depth buffer smaller than the "NULL" RT work just + * fine. */ + hr = IDirect3DDevice9_SetRenderTarget(device, 0, null_rt); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetDepthStencilSurface(device, small_ds); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_SetViewport(device, &vp_full); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_ZBUFFER, 0, 0.6f, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetViewport(device, &vp_part_400); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_BeginScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad_partial, sizeof(*quad_partial)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_SetRenderTarget(device, 0, small_rt); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_Clear(device, 0, NULL, D3DCLEAR_TARGET, 0, 0.0f, 0); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + hr = IDirect3DDevice9_DrawPrimitiveUP(device, D3DPT_TRIANGLESTRIP, 2, quad, sizeof(*quad)); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + hr = IDirect3DDevice9_EndScene(device); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); + + get_rt_readback(small_rt, &rb); + for (i = 0; i < ARRAY_SIZE(expected_small); ++i) + { + color = get_readback_color(&rb, expected_small[i].x, expected_small[i].y); + ok(color_match(color, expected_small[i].color, 1), + "Expected color 0x%08x at (%u, %u), got 0x%08x.\n", + expected_small[i].color, expected_small[i].x, expected_small[i].y, color); + } + release_surface_readback(&rb); + + hr = IDirect3DDevice9_StretchRect(device, small_rt, NULL, original_rt, NULL, D3DTEXF_POINT); + ok(hr == D3D_OK, "Got unexpected hr %#x.\n", hr); hr = IDirect3DDevice9_Present(device, NULL, NULL, NULL, NULL); ok(SUCCEEDED(hr), "Failed to present, hr %#x.\n", hr);
+ IDirect3DSurface9_Release(small_ds); + IDirect3DSurface9_Release(original_ds); IDirect3DSurface9_Release(small_null_rt); IDirect3DSurface9_Release(null_rt); IDirect3DSurface9_Release(small_rt);
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/texture.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dlls/wined3d/texture.c b/dlls/wined3d/texture.c index 2f42a41754f..41e4415f13f 100644 --- a/dlls/wined3d/texture.c +++ b/dlls/wined3d/texture.c @@ -5398,7 +5398,10 @@ static void ffp_blitter_clear_rendertargets(struct wined3d_device *device, unsig { gl_info->gl_ops.gl.p_glDepthMask(GL_TRUE); context_invalidate_state(context, STATE_DEPTH_STENCIL); - gl_info->gl_ops.gl.p_glClearDepth(depth); + if (gl_info->supported[ARB_ES2_COMPATIBILITY]) + GL_EXTCALL(glClearDepthf(depth)); + else + gl_info->gl_ops.gl.p_glClearDepth(depth); checkGLcall("glClearDepth"); clear_mask = clear_mask | GL_DEPTH_BUFFER_BIT; }
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com
Signed-off-by: Matteo Bruni mbruni@codeweavers.com --- dlls/wined3d/context_gl.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/wined3d/context_gl.c b/dlls/wined3d/context_gl.c index 1f9003ed16e..f2b5e8697b6 100644 --- a/dlls/wined3d/context_gl.c +++ b/dlls/wined3d/context_gl.c @@ -91,6 +91,8 @@ static void wined3d_context_gl_bind_fbo(struct wined3d_context_gl *context_gl, G { const struct wined3d_gl_info *gl_info = context_gl->gl_info;
+ TRACE("context_gl %p, target %#x, fbo %u.\n", context_gl, target, fbo); + switch (target) { case GL_READ_FRAMEBUFFER:
Signed-off-by: Henri Verbeet hverbeet@codeweavers.com