Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ValveSoftware/vkd3d.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHenri Verbeet <hverbeet@codeweavers.com>2019-10-18 16:58:56 +0300
committerAlexandre Julliard <julliard@winehq.org>2019-10-18 19:06:10 +0300
commit769dd2b68c813324a00af8e6b1f99159f403863a (patch)
tree5848535eed3fc8628c76906872bf2fa9231e4514
parent7ec32ebfc59073b1f3df5b7a7a18bb51993a5efc (diff)
vkd3d: Introduce vkd3d_format_get_data_offset().
Signed-off-by: Henri Verbeet <hverbeet@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
-rw-r--r--libs/vkd3d/command.c11
-rw-r--r--libs/vkd3d/resource.c12
-rw-r--r--libs/vkd3d/vkd3d_private.h9
3 files changed, 17 insertions, 15 deletions
diff --git a/libs/vkd3d/command.c b/libs/vkd3d/command.c
index d420863b..59ea4829 100644
--- a/libs/vkd3d/command.c
+++ b/libs/vkd3d/command.c
@@ -3065,9 +3065,8 @@ static void vk_buffer_image_copy_from_d3d12(VkBufferImageCopy *copy,
if (src_box)
{
VkDeviceSize row_count = footprint->Footprint.Height / format->block_height;
- copy->bufferOffset += src_box->left / format->block_width * format->byte_count * format->block_byte_count;
- copy->bufferOffset += src_box->top / format->block_height * footprint->Footprint.RowPitch;
- copy->bufferOffset += src_box->front * footprint->Footprint.RowPitch * row_count;
+ copy->bufferOffset += vkd3d_format_get_data_offset(format, footprint->Footprint.RowPitch,
+ row_count * footprint->Footprint.RowPitch, src_box->left, src_box->top, src_box->front);
}
copy->bufferRowLength = footprint->Footprint.RowPitch /
(format->byte_count * format->block_byte_count) * format->block_width;
@@ -3098,10 +3097,8 @@ static void vk_image_buffer_copy_from_d3d12(VkBufferImageCopy *copy,
{
VkDeviceSize row_count = footprint->Footprint.Height / format->block_height;
- copy->bufferOffset = footprint->Offset;
- copy->bufferOffset += dst_x / format->block_width * format->byte_count * format->block_byte_count;
- copy->bufferOffset += dst_y / format->block_height * footprint->Footprint.RowPitch;
- copy->bufferOffset += dst_z * footprint->Footprint.RowPitch * row_count;
+ copy->bufferOffset = footprint->Offset + vkd3d_format_get_data_offset(format,
+ footprint->Footprint.RowPitch, row_count * footprint->Footprint.RowPitch, dst_x, dst_y, dst_z);
copy->bufferRowLength = footprint->Footprint.RowPitch /
(format->byte_count * format->block_byte_count) * format->block_width;
copy->bufferImageHeight = footprint->Footprint.Height;
diff --git a/libs/vkd3d/resource.c b/libs/vkd3d/resource.c
index db5e9917..626772e9 100644
--- a/libs/vkd3d/resource.c
+++ b/libs/vkd3d/resource.c
@@ -1376,10 +1376,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_WriteToSubresource(ID3D12Resourc
return hr;
}
- dst_data += vk_layout.offset;
- dst_data += dst_box->left / format->block_width * format->byte_count * format->block_byte_count;
- dst_data += dst_box->top / format->block_height * vk_layout.rowPitch;
- dst_data += dst_box->front * vk_layout.depthPitch;
+ dst_data += vk_layout.offset + vkd3d_format_get_data_offset(format, vk_layout.rowPitch,
+ vk_layout.depthPitch, dst_box->left, dst_box->top, dst_box->front);
vkd3d_format_copy_data(format, src_data, src_row_pitch, src_slice_pitch,
dst_data, vk_layout.rowPitch, vk_layout.depthPitch, dst_box->right - dst_box->left,
@@ -1470,10 +1468,8 @@ static HRESULT STDMETHODCALLTYPE d3d12_resource_ReadFromSubresource(ID3D12Resour
return hr;
}
- src_data += vk_layout.offset;
- src_data += src_box->left / format->block_width * format->byte_count * format->block_byte_count;
- src_data += src_box->top / format->block_height * vk_layout.rowPitch;
- src_data += src_box->front * vk_layout.depthPitch;
+ src_data += vk_layout.offset + vkd3d_format_get_data_offset(format, vk_layout.rowPitch,
+ vk_layout.depthPitch, src_box->left, src_box->top, src_box->front);
vkd3d_format_copy_data(format, src_data, vk_layout.rowPitch, vk_layout.depthPitch,
dst_data, dst_row_pitch, dst_slice_pitch, src_box->right - src_box->left,
diff --git a/libs/vkd3d/vkd3d_private.h b/libs/vkd3d/vkd3d_private.h
index fd98463c..69b08a2d 100644
--- a/libs/vkd3d/vkd3d_private.h
+++ b/libs/vkd3d/vkd3d_private.h
@@ -1150,6 +1150,15 @@ struct vkd3d_format
bool is_emulated;
};
+static inline size_t vkd3d_format_get_data_offset(const struct vkd3d_format *format,
+ unsigned int row_pitch, unsigned int slice_pitch,
+ unsigned int x, unsigned int y, unsigned int z)
+{
+ return z * slice_pitch
+ + (y / format->block_height) * row_pitch
+ + (x / format->block_width) * format->byte_count * format->block_byte_count;
+}
+
static inline bool vkd3d_format_is_compressed(const struct vkd3d_format *format)
{
return format->block_byte_count != 1;