mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2025-02-17 01:11:45 +00:00
[vulkan] Calculate the size of the capture buffer
It turns out that using the swapchain image for the size requirements is unreliable: when running under renderdoc, vkGetImageMemoryRequirements sets the memory requirements fields to 0, leading eventually to a null memory object being passed to vkMapMemory, which does not end well.
This commit is contained in:
parent
71e07e6454
commit
10f85edb21
1 changed files with 8 additions and 5 deletions
|
@ -42,7 +42,6 @@ QFV_CreateCapture (qfv_device_t *device, int numframes,
|
||||||
{
|
{
|
||||||
qfv_instfuncs_t *ifunc = device->physDev->instance->funcs;
|
qfv_instfuncs_t *ifunc = device->physDev->instance->funcs;
|
||||||
qfv_devfuncs_t *dfunc = device->funcs;
|
qfv_devfuncs_t *dfunc = device->funcs;
|
||||||
VkFormat format = VK_FORMAT_R8G8B8A8_UNORM;
|
|
||||||
|
|
||||||
VkFormatProperties format_props;
|
VkFormatProperties format_props;
|
||||||
ifunc->vkGetPhysicalDeviceFormatProperties (device->physDev->dev,
|
ifunc->vkGetPhysicalDeviceFormatProperties (device->physDev->dev,
|
||||||
|
@ -52,8 +51,6 @@ QFV_CreateCapture (qfv_device_t *device, int numframes,
|
||||||
Sys_Printf ("Swapchain does not support reading. FIXME\n");
|
Sys_Printf ("Swapchain does not support reading. FIXME\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
ifunc->vkGetPhysicalDeviceFormatProperties (device->physDev->dev, format,
|
|
||||||
&format_props);
|
|
||||||
|
|
||||||
qfv_capture_t *capture = malloc (sizeof (qfv_capture_t));
|
qfv_capture_t *capture = malloc (sizeof (qfv_capture_t));
|
||||||
capture->device = device;
|
capture->device = device;
|
||||||
|
@ -63,13 +60,19 @@ QFV_CreateCapture (qfv_device_t *device, int numframes,
|
||||||
__auto_type cmdset = QFV_AllocCommandBufferSet (numframes, alloca);
|
__auto_type cmdset = QFV_AllocCommandBufferSet (numframes, alloca);
|
||||||
QFV_AllocateCommandBuffers (device, cmdPool, 1, cmdset);
|
QFV_AllocateCommandBuffers (device, cmdPool, 1, cmdset);
|
||||||
|
|
||||||
capture->imgsize = QFV_GetImageSize (device,
|
//FIXME assumes the swapchain is 32bpp
|
||||||
swapchain->images->a[0]);
|
capture->imgsize = swapchain->extent.width * swapchain->extent.height * 4;
|
||||||
|
|
||||||
for (int i = 0; i < numframes; i++) {
|
for (int i = 0; i < numframes; i++) {
|
||||||
__auto_type image = &capture->image_set->a[i];
|
__auto_type image = &capture->image_set->a[i];
|
||||||
image->buffer = QFV_CreateBuffer (device, capture->imgsize,
|
image->buffer = QFV_CreateBuffer (device, capture->imgsize,
|
||||||
VK_BUFFER_USAGE_TRANSFER_DST_BIT);
|
VK_BUFFER_USAGE_TRANSFER_DST_BIT);
|
||||||
}
|
}
|
||||||
|
VkMemoryRequirements req;
|
||||||
|
dfunc->vkGetBufferMemoryRequirements (device->dev,
|
||||||
|
capture->image_set->a[0].buffer,
|
||||||
|
&req);
|
||||||
|
capture->imgsize = QFV_NextOffset (capture->imgsize, &req);
|
||||||
capture->memsize = numframes * capture->imgsize;
|
capture->memsize = numframes * capture->imgsize;
|
||||||
capture->memory = QFV_AllocBufferMemory (device,
|
capture->memory = QFV_AllocBufferMemory (device,
|
||||||
capture->image_set->a[0].buffer,
|
capture->image_set->a[0].buffer,
|
||||||
|
|
Loading…
Reference in a new issue