Commit 3685c219 authored by Henri Verbeet's avatar Henri Verbeet Committed by Alexandre Julliard

wined3d: Implement Vulkan texture uploads.

parent 07981fa6
......@@ -550,6 +550,32 @@ void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_v
ERR("Failed to find fence for command buffer with id 0x%s.\n", wine_dbgstr_longlong(id));
}
void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk,
VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask,
VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout,
VkImageLayout new_layout, VkImage image, VkImageAspectFlags aspect_mask)
{
const struct wined3d_vk_info *vk_info = context_vk->vk_info;
VkImageMemoryBarrier barrier;
barrier.sType = VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER;
barrier.pNext = NULL;
barrier.srcAccessMask = src_access_mask;
barrier.dstAccessMask = dst_access_mask;
barrier.oldLayout = old_layout;
barrier.newLayout = new_layout;
barrier.srcQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.dstQueueFamilyIndex = VK_QUEUE_FAMILY_IGNORED;
barrier.image = image;
barrier.subresourceRange.aspectMask = aspect_mask;
barrier.subresourceRange.baseMipLevel = 0;
barrier.subresourceRange.levelCount = VK_REMAINING_MIP_LEVELS;
barrier.subresourceRange.baseArrayLayer = 0;
barrier.subresourceRange.layerCount = VK_REMAINING_ARRAY_LAYERS;
VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, src_stage_mask, dst_stage_mask, 0, 0, NULL, 0, NULL, 1, &barrier));
}
HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk, struct wined3d_swapchain *swapchain)
{
VkCommandPoolCreateInfo command_pool_info;
......
......@@ -5977,6 +5977,36 @@ enum wined3d_format_id pixelformat_for_depth(DWORD depth)
}
}
void wined3d_format_copy_data(const struct wined3d_format *format, const uint8_t *src,
unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch,
unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d)
{
unsigned int row_block_count, row_count, row_size, slice, row;
unsigned int slice_count = d;
const uint8_t *src_row;
uint8_t *dst_row;
row_block_count = (w + format->block_width - 1) / format->block_width;
row_count = (h + format->block_height - 1) / format->block_height;
row_size = row_block_count * format->block_byte_count;
if (src_row_pitch == row_size && dst_row_pitch == row_size && src_slice_pitch == dst_slice_pitch)
{
memcpy(dst, src, slice_count * row_count * row_size);
return;
}
for (slice = 0; slice < slice_count; ++slice)
{
for (row = 0; row < row_count; ++row)
{
src_row = &src[slice * src_slice_pitch + row * src_row_pitch];
dst_row = &dst[slice * dst_slice_pitch + row * dst_row_pitch];
memcpy(dst_row, src_row, row_size);
}
}
}
void multiply_matrix(struct wined3d_matrix *dst, const struct wined3d_matrix *src1, const struct wined3d_matrix *src2)
{
struct wined3d_matrix tmp;
......
......@@ -2261,6 +2261,10 @@ void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk,
void wined3d_context_vk_destroy_memory(struct wined3d_context_vk *context_vk,
VkDeviceMemory vk_memory, uint64_t command_buffer_id) DECLSPEC_HIDDEN;
VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk) DECLSPEC_HIDDEN;
void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk,
VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask,
VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout,
VkImageLayout new_layout, VkImage image, VkImageAspectFlags aspect_mask) DECLSPEC_HIDDEN;
HRESULT wined3d_context_vk_init(struct wined3d_context_vk *context_vk,
struct wined3d_swapchain *swapchain) DECLSPEC_HIDDEN;
void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk,
......@@ -3958,6 +3962,7 @@ struct wined3d_texture_vk
VkImage vk_image;
struct wined3d_allocator_block *memory;
VkDeviceMemory vk_memory;
enum VkImageLayout layout;
uint64_t command_buffer_id;
};
......@@ -5155,6 +5160,9 @@ UINT wined3d_format_calculate_size(const struct wined3d_format *format,
UINT alignment, UINT width, UINT height, UINT depth) DECLSPEC_HIDDEN;
DWORD wined3d_format_convert_from_float(const struct wined3d_format *format,
const struct wined3d_color *color) DECLSPEC_HIDDEN;
void wined3d_format_copy_data(const struct wined3d_format *format, const uint8_t *src,
unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch,
unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d) DECLSPEC_HIDDEN;
void wined3d_format_get_float_color_key(const struct wined3d_format *format,
const struct wined3d_color_key *key, struct wined3d_color *float_colors) DECLSPEC_HIDDEN;
BOOL wined3d_format_is_depth_view(enum wined3d_format_id resource_format_id,
......@@ -5538,6 +5546,20 @@ static inline BOOL wined3d_bitmap_get_range(const DWORD *bitmap, unsigned int bi
return TRUE;
}
static inline VkImageAspectFlags vk_aspect_mask_from_format(const struct wined3d_format *format)
{
VkImageAspectFlags mask = 0;
if (format->depth_size)
mask |= VK_IMAGE_ASPECT_DEPTH_BIT;
if (format->stencil_size)
mask |= VK_IMAGE_ASPECT_STENCIL_BIT;
if (!mask || format->red_size || format->green_size || format->blue_size || format->alpha_size)
mask |= VK_IMAGE_ASPECT_COLOR_BIT;
return mask;
}
/* The WNDCLASS-Name for the fake window which we use to retrieve the GL capabilities */
#define WINED3D_OPENGL_WINDOW_CLASS_NAME "WineD3D_OpenGL"
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment