diff --git a/dlls/d3d10core/tests/device.c b/dlls/d3d10core/tests/device.c index 44f3fae06f9..3e8a1e8bc4e 100644 --- a/dlls/d3d10core/tests/device.c +++ b/dlls/d3d10core/tests/device.c @@ -568,24 +568,29 @@ static void get_texture_readback(ID3D10Texture2D *texture, unsigned int sub_reso ID3D10Device_Release(device); } +static void *get_readback_data(struct resource_readback *rb, unsigned int x, unsigned int y, unsigned byte_width) +{ + return (BYTE *)rb->map_desc.pData + y * rb->map_desc.RowPitch + x * byte_width; +} + static DWORD get_readback_color(struct resource_readback *rb, unsigned int x, unsigned int y) { - return ((DWORD *)rb->map_desc.pData)[rb->map_desc.RowPitch * y / sizeof(DWORD) + x]; + return *(DWORD *)get_readback_data(rb, x, y, sizeof(DWORD)); } static float get_readback_float(struct resource_readback *rb, unsigned int x, unsigned int y) { - return ((float *)rb->map_desc.pData)[rb->map_desc.RowPitch * y / sizeof(float) + x]; + return *(float *)get_readback_data(rb, x, y, sizeof(float)); } static const struct vec4 *get_readback_vec4(struct resource_readback *rb, unsigned int x, unsigned int y) { - return &((const struct vec4 *)rb->map_desc.pData)[rb->map_desc.RowPitch * y / sizeof(struct vec4) + x]; + return get_readback_data(rb, x, y, sizeof(struct vec4)); } static const struct uvec4 *get_readback_uvec4(struct resource_readback *rb, unsigned int x, unsigned int y) { - return &((const struct uvec4 *)rb->map_desc.pData)[rb->map_desc.RowPitch * y / sizeof(struct uvec4) + x]; + return get_readback_data(rb, x, y, sizeof(struct uvec4)); } static void release_resource_readback(struct resource_readback *rb)