mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2025-01-28 13:05:02 -08:00
tests: Move check_readback_data_vec4() to utils.h.
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
1e8e0650c9
commit
e6ea409bbf
@ -506,24 +506,12 @@ static void get_texture_readback_with_command_list(ID3D12Resource *texture, unsi
|
|||||||
assert_that(hr == S_OK, "Failed to map readback buffer, hr %#x.\n", hr);
|
assert_that(hr == S_OK, "Failed to map readback buffer, hr %#x.\n", hr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *get_readback_data(struct resource_readback *rb,
|
|
||||||
unsigned int x, unsigned int y, unsigned int z, size_t element_size)
|
|
||||||
{
|
|
||||||
unsigned int slice_pitch = rb->row_pitch * rb->height;
|
|
||||||
return &((BYTE *)rb->data)[slice_pitch * z + rb->row_pitch * y + x * element_size];
|
|
||||||
}
|
|
||||||
|
|
||||||
static unsigned int get_readback_uint(struct resource_readback *rb,
|
static unsigned int get_readback_uint(struct resource_readback *rb,
|
||||||
unsigned int x, unsigned int y, unsigned int z)
|
unsigned int x, unsigned int y, unsigned int z)
|
||||||
{
|
{
|
||||||
return *(unsigned int *)get_readback_data(rb, x, y, z, sizeof(unsigned int));
|
return *(unsigned int *)get_readback_data(rb, x, y, z, sizeof(unsigned int));
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct vec4 *get_readback_vec4(struct resource_readback *rb, unsigned int x, unsigned int y)
|
|
||||||
{
|
|
||||||
return get_readback_data(rb, x, y, 0, sizeof(struct vec4));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_resource_readback(struct d3d12_resource_readback *rb)
|
static void release_resource_readback(struct d3d12_resource_readback *rb)
|
||||||
{
|
{
|
||||||
D3D12_RANGE range = {0, 0};
|
D3D12_RANGE range = {0, 0};
|
||||||
@ -565,36 +553,6 @@ static void check_readback_data_uint_(unsigned int line, struct resource_readbac
|
|||||||
ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z);
|
ok_(line)(all_match, "Got 0x%08x, expected 0x%08x at (%u, %u, %u).\n", got, expected, x, y, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
#define check_readback_data_vec4(a, b, c, d) check_readback_data_vec4_(__LINE__, a, b, c, d)
|
|
||||||
static void check_readback_data_vec4_(unsigned int line, struct resource_readback *rb,
|
|
||||||
const RECT *rect, const struct vec4 *expected, unsigned int max_diff)
|
|
||||||
{
|
|
||||||
RECT r = {0, 0, rb->width, rb->height};
|
|
||||||
unsigned int x = 0, y = 0;
|
|
||||||
struct vec4 got = {0};
|
|
||||||
bool all_match = true;
|
|
||||||
|
|
||||||
if (rect)
|
|
||||||
r = *rect;
|
|
||||||
|
|
||||||
for (y = r.top; y < r.bottom; ++y)
|
|
||||||
{
|
|
||||||
for (x = r.left; x < r.right; ++x)
|
|
||||||
{
|
|
||||||
got = *get_readback_vec4(rb, x, y);
|
|
||||||
if (!compare_vec4(&got, expected, max_diff))
|
|
||||||
{
|
|
||||||
all_match = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!all_match)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
|
|
||||||
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f)
|
#define check_sub_resource_uint(a, b, c, d, e, f) check_sub_resource_uint_(__LINE__, a, b, c, d, e, f)
|
||||||
static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture,
|
static inline void check_sub_resource_uint_(unsigned int line, ID3D12Resource *texture,
|
||||||
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
|
unsigned int sub_resource_idx, ID3D12CommandQueue *queue, ID3D12GraphicsCommandList *command_list,
|
||||||
|
@ -577,36 +577,6 @@ static void release_readback(struct d3d11_shader_runner *runner, struct d3d11_re
|
|||||||
ID3D11Resource_Release(rb->resource);
|
ID3D11Resource_Release(rb->resource);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const struct vec4 *get_readback_vec4(struct resource_readback *rb, unsigned int x, unsigned int y)
|
|
||||||
{
|
|
||||||
return (struct vec4 *)((BYTE *)rb->data + y * rb->row_pitch) + x;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void check_readback_data_vec4(struct resource_readback *rb,
|
|
||||||
const RECT *rect, const struct vec4 *expected, unsigned int max_diff)
|
|
||||||
{
|
|
||||||
unsigned int x = 0, y = 0;
|
|
||||||
struct vec4 got = {0};
|
|
||||||
bool all_match = true;
|
|
||||||
|
|
||||||
for (y = rect->top; y < rect->bottom; ++y)
|
|
||||||
{
|
|
||||||
for (x = rect->left; x < rect->right; ++x)
|
|
||||||
{
|
|
||||||
got = *get_readback_vec4(rb, x, y);
|
|
||||||
if (!compare_vec4(&got, expected, max_diff))
|
|
||||||
{
|
|
||||||
all_match = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!all_match)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ok(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
|
|
||||||
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
||||||
|
@ -480,36 +480,6 @@ static void init_readback(struct d3d9_shader_runner *runner, struct d3d9_resourc
|
|||||||
rb->rb.depth = 1;
|
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->data + y * rb->row_pitch + x * sizeof(struct vec4));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void check_readback_data_vec4(struct resource_readback *rb,
|
|
||||||
const RECT *rect, const struct vec4 *expected, unsigned int max_diff)
|
|
||||||
{
|
|
||||||
unsigned int x = 0, y = 0;
|
|
||||||
struct vec4 got = {0};
|
|
||||||
bool all_match = true;
|
|
||||||
|
|
||||||
for (y = rect->top; y < rect->bottom; ++y)
|
|
||||||
{
|
|
||||||
for (x = rect->left; x < rect->right; ++x)
|
|
||||||
{
|
|
||||||
got = *get_readback_vec4(rb, x, y);
|
|
||||||
if (!compare_vec4(&got, expected, max_diff))
|
|
||||||
{
|
|
||||||
all_match = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!all_match)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ok(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
|
|
||||||
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void release_readback(struct d3d9_resource_readback *rb)
|
static void release_readback(struct d3d9_resource_readback *rb)
|
||||||
{
|
{
|
||||||
IDirect3DSurface9_UnlockRect(rb->surface);
|
IDirect3DSurface9_UnlockRect(rb->surface);
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#define VK_NO_PROTOTYPES
|
#define VK_NO_PROTOTYPES
|
||||||
|
#define VKD3D_TEST_NO_DEFS
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "vulkan/vulkan.h"
|
#include "vulkan/vulkan.h"
|
||||||
#include "vkd3d_shader.h"
|
#include "vkd3d_shader.h"
|
||||||
#include "vkd3d.h"
|
#include "vkd3d.h"
|
||||||
#include "shader_runner.h"
|
#include "shader_runner.h"
|
||||||
#define VKD3D_TEST_NO_DEFS
|
|
||||||
#include "vkd3d_test.h"
|
#include "vkd3d_test.h"
|
||||||
|
|
||||||
struct vulkan_resource
|
struct vulkan_resource
|
||||||
@ -832,36 +832,6 @@ struct vulkan_resource_readback
|
|||||||
VkBuffer buffer;
|
VkBuffer buffer;
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct vec4 *get_readback_vec4(const struct resource_readback *rb, unsigned int x, unsigned int y)
|
|
||||||
{
|
|
||||||
return (struct vec4 *)((uint8_t *)rb->data + y * rb->row_pitch + x * sizeof(struct vec4));
|
|
||||||
}
|
|
||||||
|
|
||||||
static void check_readback_data_vec4(const struct resource_readback *rb,
|
|
||||||
const RECT *rect, const struct vec4 *expected, unsigned int max_diff)
|
|
||||||
{
|
|
||||||
unsigned int x = 0, y = 0;
|
|
||||||
struct vec4 got = {0};
|
|
||||||
bool all_match = true;
|
|
||||||
|
|
||||||
for (y = rect->top; y < rect->bottom; ++y)
|
|
||||||
{
|
|
||||||
for (x = rect->left; x < rect->right; ++x)
|
|
||||||
{
|
|
||||||
got = *get_readback_vec4(rb, x, y);
|
|
||||||
if (!compare_vec4(&got, expected, max_diff))
|
|
||||||
{
|
|
||||||
all_match = false;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!all_match)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
ok(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
|
|
||||||
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void vulkan_runner_probe_vec4(struct shader_runner *r, const RECT *rect, const struct vec4 *v, unsigned int ulps)
|
static void vulkan_runner_probe_vec4(struct shader_runner *r, const RECT *rect, const struct vec4 *v, unsigned int ulps)
|
||||||
{
|
{
|
||||||
struct vulkan_shader_runner *runner = vulkan_shader_runner(r);
|
struct vulkan_shader_runner *runner = vulkan_shader_runner(r);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include "vkd3d_test.h"
|
||||||
|
|
||||||
struct vec2
|
struct vec2
|
||||||
{
|
{
|
||||||
@ -112,4 +113,46 @@ static inline void set_rect(RECT *rect, int left, int top, int right, int bottom
|
|||||||
rect->bottom = bottom;
|
rect->bottom = bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void *get_readback_data(const struct resource_readback *rb,
|
||||||
|
unsigned int x, unsigned int y, unsigned int z, size_t element_size)
|
||||||
|
{
|
||||||
|
unsigned int slice_pitch = rb->row_pitch * rb->height;
|
||||||
|
return &((uint8_t *)rb->data)[slice_pitch * z + rb->row_pitch * y + x * element_size];
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct vec4 *get_readback_vec4(const struct resource_readback *rb, unsigned int x, unsigned int y)
|
||||||
|
{
|
||||||
|
return get_readback_data(rb, x, y, 0, sizeof(struct vec4));
|
||||||
|
}
|
||||||
|
|
||||||
|
#define check_readback_data_vec4(a, b, c, d) check_readback_data_vec4_(__LINE__, a, b, c, d)
|
||||||
|
static inline void check_readback_data_vec4_(unsigned int line, const struct resource_readback *rb,
|
||||||
|
const RECT *rect, const struct vec4 *expected, unsigned int max_diff)
|
||||||
|
{
|
||||||
|
RECT r = {0, 0, rb->width, rb->height};
|
||||||
|
unsigned int x = 0, y = 0;
|
||||||
|
struct vec4 got = {0};
|
||||||
|
bool all_match = true;
|
||||||
|
|
||||||
|
if (rect)
|
||||||
|
r = *rect;
|
||||||
|
|
||||||
|
for (y = r.top; y < r.bottom; ++y)
|
||||||
|
{
|
||||||
|
for (x = r.left; x < r.right; ++x)
|
||||||
|
{
|
||||||
|
got = *get_readback_vec4(rb, x, y);
|
||||||
|
if (!compare_vec4(&got, expected, max_diff))
|
||||||
|
{
|
||||||
|
all_match = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!all_match)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ok_(line)(all_match, "Got {%.8e, %.8e, %.8e, %.8e}, expected {%.8e, %.8e, %.8e, %.8e} at (%u, %u).\n",
|
||||||
|
got.x, got.y, got.z, got.w, expected->x, expected->y, expected->z, expected->w, x, y);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user