Quake II RTX doxygen  1.0 dev
mgpu.c File Reference
#include "vkpt.h"

Go to the source code of this file.

Functions

void vkpt_image_copy (VkCommandBuffer cmd_buf, int src_image_index, int dst_image_index, VkOffset2D src_offset, VkOffset2D dst_offset, VkExtent2D size)
 

Function Documentation

◆ vkpt_image_copy()

void vkpt_image_copy ( VkCommandBuffer  cmd_buf,
int  src_image_index,
int  dst_image_index,
VkOffset2D  src_offset,
VkOffset2D  dst_offset,
VkExtent2D  size 
)

Definition at line 111 of file mgpu.c.

117 {
118  VkImageSubresourceRange subresource_range = {
119  .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
120  .baseMipLevel = 0,
121  .levelCount = 1,
122  .baseArrayLayer = 0,
123  .layerCount = 1
124  };
125 
126  VkImageSubresourceLayers subresource_layers = {
127  .aspectMask = VK_IMAGE_ASPECT_COLOR_BIT,
128  .mipLevel = 0,
129  .baseArrayLayer = 0,
130  .layerCount = 1
131  };
132 
133  VkImageCopy copy_region = {
134  .srcSubresource = subresource_layers,
135  .srcOffset.x = src_offset.x,
136  .srcOffset.y = src_offset.y,
137  .srcOffset.z = 0,
138  .dstSubresource = subresource_layers,
139  .dstOffset.x = dst_offset.x,
140  .dstOffset.y = dst_offset.y,
141  .dstOffset.z = 0,
142  .extent.width = size.width,
143  .extent.height = size.height,
144  .extent.depth = 1
145  };
146 
147  VkMemoryBarrier mem_barrier = {
148  .sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER,
149  .pNext = NULL,
150  .srcAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
151  .dstAccessMask = VK_ACCESS_MEMORY_READ_BIT | VK_ACCESS_MEMORY_WRITE_BIT,
152  };
153 
154  vkCmdPipelineBarrier(cmd_buf,
155  VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, VK_PIPELINE_STAGE_ALL_COMMANDS_BIT,
156  0,
157  1, &mem_barrier,
158  0, NULL,
159  0, NULL);
160 
161  vkCmdCopyImage(cmd_buf,
162  qvk.images[src_image_index], VK_IMAGE_LAYOUT_GENERAL,
163  qvk.images[dst_image_index], VK_IMAGE_LAYOUT_GENERAL,
164  1, &copy_region);
165 }
QVK_s::images
VkImage images[NUM_VKPT_IMAGES]
Definition: vkpt.h:231
qvk
QVK_t qvk
Definition: main.c:377