mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
tests/shader_runner: Use the common resource_readback structure in d3d9 and d3d11 readback structures.
Signed-off-by: Zebediah Figura <zfigura@codeweavers.com> Signed-off-by: Giovanni Mascellani <gmascellani@codeweavers.com> Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
b5e773058c
commit
ccdb702d53
@ -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 d3d12_resource_readback
|
||||||
{
|
{
|
||||||
struct resource_readback rb;
|
struct resource_readback rb;
|
||||||
|
@ -540,15 +540,16 @@ static bool d3d11_runner_draw(struct shader_runner *r,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct resource_readback
|
struct d3d11_resource_readback
|
||||||
{
|
{
|
||||||
|
struct resource_readback rb;
|
||||||
ID3D11Resource *resource;
|
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_TEXTURE2D_DESC texture_desc;
|
||||||
|
D3D11_MAPPED_SUBRESOURCE map_desc;
|
||||||
HRESULT hr;
|
HRESULT hr;
|
||||||
|
|
||||||
ID3D11Texture2D_GetDesc(runner->rt, &texture_desc);
|
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);
|
ok(hr == S_OK, "Failed to create texture, hr %#lx.\n", hr);
|
||||||
|
|
||||||
ID3D11DeviceContext_CopyResource(runner->immediate_context, rb->resource, (ID3D11Resource *)runner->rt);
|
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);
|
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);
|
ID3D11DeviceContext_Unmap(runner->immediate_context, rb->resource, 0);
|
||||||
ID3D11Resource_Release(rb->resource);
|
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)
|
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,
|
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)
|
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 d3d11_shader_runner *runner = d3d11_shader_runner(r);
|
||||||
struct resource_readback rb;
|
struct d3d11_resource_readback rb;
|
||||||
|
|
||||||
init_readback(runner, &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);
|
release_readback(runner, &rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,14 +449,15 @@ static bool d3d9_runner_draw(struct shader_runner *r,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct resource_readback
|
struct d3d9_resource_readback
|
||||||
{
|
{
|
||||||
|
struct resource_readback rb;
|
||||||
IDirect3DSurface9 *surface;
|
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;
|
D3DSURFACE_DESC desc;
|
||||||
HRESULT hr;
|
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);
|
hr = IDirect3DDevice9Ex_GetRenderTargetData(runner->device, runner->rt, rb->surface);
|
||||||
ok(hr == D3D_OK, "Failed to get render target data, hr %#lx.\n", hr);
|
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);
|
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)
|
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,
|
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);
|
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_UnlockRect(rb->surface);
|
||||||
IDirect3DSurface9_Release(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)
|
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 d3d9_shader_runner *runner = d3d9_shader_runner(r);
|
||||||
struct resource_readback rb;
|
struct d3d9_resource_readback rb;
|
||||||
|
|
||||||
init_readback(runner, &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);
|
release_readback(&rb);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
struct vec2
|
struct vec2
|
||||||
@ -33,6 +34,15 @@ struct vec4
|
|||||||
float x, y, z, w;
|
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)
|
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;
|
size_t new_capacity, max_capacity;
|
||||||
|
Loading…
Reference in New Issue
Block a user