From: Zebediah Figura zfigura@codeweavers.com
Signed-off-by: Zebediah Figura zfigura@codeweavers.com Signed-off-by: Giovanni Mascellani gmascellani@codeweavers.com --- tests/d3d12_test_utils.h | 9 --------- tests/shader_runner_d3d11.c | 23 +++++++++++++++-------- tests/shader_runner_d3d9.c | 23 +++++++++++++++-------- tests/utils.h | 10 ++++++++++ 4 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/tests/d3d12_test_utils.h b/tests/d3d12_test_utils.h index 061931c2..d8220409 100644 --- a/tests/d3d12_test_utils.h +++ b/tests/d3d12_test_utils.h @@ -411,15 +411,6 @@ static inline unsigned int format_block_height(DXGI_FORMAT format) } }
-struct resource_readback -{ - uint64_t width; - unsigned int height; - unsigned int depth; - uint64_t row_pitch; - void *data; -}; - struct d3d12_resource_readback { struct resource_readback rb; diff --git a/tests/shader_runner_d3d11.c b/tests/shader_runner_d3d11.c index 9d1ed09b..c8304ce6 100644 --- a/tests/shader_runner_d3d11.c +++ b/tests/shader_runner_d3d11.c @@ -540,15 +540,16 @@ static bool d3d11_runner_draw(struct shader_runner *r, return true; }
-struct resource_readback +struct d3d11_resource_readback { + struct resource_readback rb; ID3D11Resource *resource; - D3D11_MAPPED_SUBRESOURCE map_desc; };
-static void init_readback(struct d3d11_shader_runner *runner, struct resource_readback *rb) +static void init_readback(struct d3d11_shader_runner *runner, struct d3d11_resource_readback *rb) { D3D11_TEXTURE2D_DESC texture_desc; + D3D11_MAPPED_SUBRESOURCE map_desc; HRESULT hr;
ID3D11Texture2D_GetDesc(runner->rt, &texture_desc); @@ -560,11 +561,17 @@ static void init_readback(struct d3d11_shader_runner *runner, struct resource_re ok(hr == S_OK, "Failed to create texture, hr %#lx.\n", hr);
ID3D11DeviceContext_CopyResource(runner->immediate_context, rb->resource, (ID3D11Resource *)runner->rt); - hr = ID3D11DeviceContext_Map(runner->immediate_context, rb->resource, 0, D3D11_MAP_READ, 0, &rb->map_desc); + hr = ID3D11DeviceContext_Map(runner->immediate_context, rb->resource, 0, D3D11_MAP_READ, 0, &map_desc); ok(hr == S_OK, "Failed to map texture, hr %#lx.\n", hr); + + rb->rb.data = map_desc.pData; + rb->rb.row_pitch = map_desc.RowPitch; + rb->rb.width = texture_desc.Width; + rb->rb.height = texture_desc.Height; + rb->rb.depth = 1; }
-static void release_readback(struct d3d11_shader_runner *runner, struct resource_readback *rb) +static void release_readback(struct d3d11_shader_runner *runner, struct d3d11_resource_readback *rb) { ID3D11DeviceContext_Unmap(runner->immediate_context, rb->resource, 0); ID3D11Resource_Release(rb->resource); @@ -572,7 +579,7 @@ static void release_readback(struct d3d11_shader_runner *runner, struct resource
static const struct vec4 *get_readback_vec4(struct resource_readback *rb, unsigned int x, unsigned int y) { - return (struct vec4 *)((BYTE *)rb->map_desc.pData + y * rb->map_desc.RowPitch) + x; + return (struct vec4 *)((BYTE *)rb->data + y * rb->row_pitch) + x; }
static void check_readback_data_vec4(struct resource_readback *rb, @@ -603,10 +610,10 @@ static void check_readback_data_vec4(struct resource_readback *rb, static void d3d11_runner_probe_vec4(struct shader_runner *r, const RECT *rect, const struct vec4 *v, unsigned int ulps) { struct d3d11_shader_runner *runner = d3d11_shader_runner(r); - struct resource_readback rb; + struct d3d11_resource_readback rb;
init_readback(runner, &rb); - check_readback_data_vec4(&rb, rect, v, ulps); + check_readback_data_vec4(&rb.rb, rect, v, ulps); release_readback(runner, &rb); }
diff --git a/tests/shader_runner_d3d9.c b/tests/shader_runner_d3d9.c index f2875d42..14f8184a 100644 --- a/tests/shader_runner_d3d9.c +++ b/tests/shader_runner_d3d9.c @@ -449,14 +449,15 @@ static bool d3d9_runner_draw(struct shader_runner *r, return true; }
-struct resource_readback +struct d3d9_resource_readback { + struct resource_readback rb; IDirect3DSurface9 *surface; - D3DLOCKED_RECT rect; };
-static void init_readback(struct d3d9_shader_runner *runner, struct resource_readback *rb) +static void init_readback(struct d3d9_shader_runner *runner, struct d3d9_resource_readback *rb) { + D3DLOCKED_RECT map_desc; D3DSURFACE_DESC desc; HRESULT hr;
@@ -469,13 +470,19 @@ static void init_readback(struct d3d9_shader_runner *runner, struct resource_rea hr = IDirect3DDevice9Ex_GetRenderTargetData(runner->device, runner->rt, rb->surface); ok(hr == D3D_OK, "Failed to get render target data, hr %#lx.\n", hr);
- hr = IDirect3DSurface9_LockRect(rb->surface, &rb->rect, NULL, D3DLOCK_READONLY); + hr = IDirect3DSurface9_LockRect(rb->surface, &map_desc, NULL, D3DLOCK_READONLY); ok(hr == D3D_OK, "Failed to lock surface, hr %#lx.\n", hr); + + rb->rb.data = map_desc.pBits; + rb->rb.row_pitch = map_desc.Pitch; + rb->rb.width = desc.Width; + rb->rb.height = desc.Height; + rb->rb.depth = 1; }
static const struct vec4 *get_readback_vec4(const struct resource_readback *rb, unsigned int x, unsigned int y) { - return (struct vec4 *)((BYTE *)rb->rect.pBits + y * rb->rect.Pitch + x * sizeof(struct vec4)); + return (struct vec4 *)((BYTE *)rb->data + y * rb->row_pitch + x * sizeof(struct vec4)); }
static void check_readback_data_vec4(struct resource_readback *rb, @@ -503,7 +510,7 @@ static void check_readback_data_vec4(struct resource_readback *rb, got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y); }
-static void release_readback(struct resource_readback *rb) +static void release_readback(struct d3d9_resource_readback *rb) { IDirect3DSurface9_UnlockRect(rb->surface); IDirect3DSurface9_Release(rb->surface); @@ -512,10 +519,10 @@ static void release_readback(struct resource_readback *rb) static void d3d9_runner_probe_vec4(struct shader_runner *r, const RECT *rect, const struct vec4 *v, unsigned int ulps) { struct d3d9_shader_runner *runner = d3d9_shader_runner(r); - struct resource_readback rb; + struct d3d9_resource_readback rb;
init_readback(runner, &rb); - check_readback_data_vec4(&rb, rect, v, ulps); + check_readback_data_vec4(&rb.rb, rect, v, ulps); release_readback(&rb); }
diff --git a/tests/utils.h b/tests/utils.h index 563f0b0f..2cb9511f 100644 --- a/tests/utils.h +++ b/tests/utils.h @@ -21,6 +21,7 @@
#include <limits.h> #include <stdbool.h> +#include <stdint.h> #include <stdlib.h>
struct vec2 @@ -33,6 +34,15 @@ struct vec4 float x, y, z, w; };
+struct resource_readback +{ + uint64_t width; + unsigned int height; + unsigned int depth; + uint64_t row_pitch; + void *data; +}; + static inline bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size) { size_t new_capacity, max_capacity;