mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-11-26 14:20:59 +00:00
[vulkan] Correct the semantics of QFV_NextOffset
I'm not at all sure what I was thinking when I designed it, but I certainly designed it wrong (to the point of being fairly useless). It turns out memory requirements are already aligned in size (so just multiplying is fine), and what I really wanted was to get the next offset aligned to the given requirements.
This commit is contained in:
parent
36e0d857a2
commit
743a732bd7
4 changed files with 7 additions and 9 deletions
|
@ -45,7 +45,7 @@ VkBufferView QFV_CreateBufferView (struct qfv_device_s *device,
|
||||||
VkBuffer buffer, VkFormat format,
|
VkBuffer buffer, VkFormat format,
|
||||||
VkDeviceSize offset, VkDeviceSize size);
|
VkDeviceSize offset, VkDeviceSize size);
|
||||||
|
|
||||||
VkDeviceSize QFV_NextOffset (VkDeviceSize current, VkDeviceSize count,
|
VkDeviceSize QFV_NextOffset (VkDeviceSize current,
|
||||||
const VkMemoryRequirements *requirements)
|
const VkMemoryRequirements *requirements)
|
||||||
__attribute__((pure));
|
__attribute__((pure));
|
||||||
|
|
||||||
|
|
|
@ -111,7 +111,7 @@ Vulkan_Mod_SpriteLoadFrames (mod_sprite_ctx_t *sprite_ctx, vulkan_ctx_t *ctx)
|
||||||
dfunc->vkGetImageMemoryRequirements (device->dev, sprite->image, &ireq);
|
dfunc->vkGetImageMemoryRequirements (device->dev, sprite->image, &ireq);
|
||||||
VkMemoryRequirements vreq;
|
VkMemoryRequirements vreq;
|
||||||
dfunc->vkGetBufferMemoryRequirements (device->dev, sprite->verts, &vreq);
|
dfunc->vkGetBufferMemoryRequirements (device->dev, sprite->verts, &vreq);
|
||||||
size_t size = QFV_NextOffset (QFV_NextOffset (0, 1, &vreq), 1, &ireq);
|
size_t size = QFV_NextOffset (vreq.size, &ireq) + ireq.size;
|
||||||
|
|
||||||
sprite->memory = QFV_AllocBufferMemory (device, sprite->verts,
|
sprite->memory = QFV_AllocBufferMemory (device, sprite->verts,
|
||||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||||
|
@ -122,7 +122,7 @@ Vulkan_Mod_SpriteLoadFrames (mod_sprite_ctx_t *sprite_ctx, vulkan_ctx_t *ctx)
|
||||||
|
|
||||||
QFV_BindBufferMemory (device, sprite->verts, sprite->memory, 0);
|
QFV_BindBufferMemory (device, sprite->verts, sprite->memory, 0);
|
||||||
QFV_BindImageMemory (device, sprite->image, sprite->memory,
|
QFV_BindImageMemory (device, sprite->image, sprite->memory,
|
||||||
QFV_NextOffset (0, 1, &vreq));
|
QFV_NextOffset (vreq.size, &ireq));
|
||||||
sprite->view = QFV_CreateImageView (device, sprite->image,
|
sprite->view = QFV_CreateImageView (device, sprite->image,
|
||||||
VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
VK_IMAGE_VIEW_TYPE_2D_ARRAY,
|
||||||
VK_FORMAT_R8G8B8A8_UNORM,
|
VK_FORMAT_R8G8B8A8_UNORM,
|
||||||
|
|
|
@ -164,10 +164,8 @@ QFV_CreateBufferView (qfv_device_t *device, VkBuffer buffer, VkFormat format,
|
||||||
}
|
}
|
||||||
|
|
||||||
VkDeviceSize
|
VkDeviceSize
|
||||||
QFV_NextOffset (VkDeviceSize current, VkDeviceSize count,
|
QFV_NextOffset (VkDeviceSize current, const VkMemoryRequirements *requirements)
|
||||||
const VkMemoryRequirements *requirements)
|
|
||||||
{
|
{
|
||||||
VkDeviceSize align = requirements->alignment - 1;
|
VkDeviceSize align = requirements->alignment - 1;
|
||||||
VkDeviceSize size = (requirements->size + align) & ~align;
|
return ((current + align) & ~align);
|
||||||
return ((current + align) & ~align) + count * size;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -334,7 +334,7 @@ Vulkan_Lighting_Init (vulkan_ctx_t *ctx)
|
||||||
&requirements);
|
&requirements);
|
||||||
lctx->light_memory = QFV_AllocBufferMemory (device, lbuffers->a[0],
|
lctx->light_memory = QFV_AllocBufferMemory (device, lbuffers->a[0],
|
||||||
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT,
|
||||||
QFV_NextOffset (0, frames, &requirements), 0);
|
frames * requirements.size, 0);
|
||||||
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY,
|
QFV_duSetObjectName (device, VK_OBJECT_TYPE_DEVICE_MEMORY,
|
||||||
lctx->light_memory, "memory:lighting");
|
lctx->light_memory, "memory:lighting");
|
||||||
|
|
||||||
|
@ -389,7 +389,7 @@ Vulkan_Lighting_Init (vulkan_ctx_t *ctx)
|
||||||
lframe->light_buffer = lbuffers->a[i];
|
lframe->light_buffer = lbuffers->a[i];
|
||||||
QFV_BindBufferMemory (device, lbuffers->a[i], lctx->light_memory,
|
QFV_BindBufferMemory (device, lbuffers->a[i], lctx->light_memory,
|
||||||
light_offset);
|
light_offset);
|
||||||
light_offset = QFV_NextOffset (light_offset, 1, &requirements);
|
light_offset += requirements.size;
|
||||||
|
|
||||||
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
|
QFV_duSetObjectName (device, VK_OBJECT_TYPE_COMMAND_BUFFER,
|
||||||
lframe->cmd, "cmd:lighting");
|
lframe->cmd, "cmd:lighting");
|
||||||
|
|
Loading…
Reference in a new issue