mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-06 11:38:05 +02:00
v3dv: implement vk{Create,Destroy}Buffer
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
This commit is contained in:
parent
dee9976200
commit
b478e8c53c
2 changed files with 52 additions and 0 deletions
|
|
@ -1299,3 +1299,48 @@ v3dv_BindImageMemory(VkDevice _device,
|
|||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VkResult
|
||||
v3dv_CreateBuffer(VkDevice _device,
|
||||
const VkBufferCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkBuffer *pBuffer)
|
||||
{
|
||||
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||
struct v3dv_buffer *buffer;
|
||||
|
||||
assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
|
||||
assert(pCreateInfo->usage != 0);
|
||||
|
||||
/* We don't support any flags for now */
|
||||
assert(pCreateInfo->flags == 0);
|
||||
|
||||
buffer = vk_alloc2(&device->alloc, pAllocator, sizeof(*buffer), 8,
|
||||
VK_SYSTEM_ALLOCATION_SCOPE_OBJECT);
|
||||
if (buffer == NULL)
|
||||
return vk_error(device->instance, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
buffer->size = pCreateInfo->size;
|
||||
buffer->usage = pCreateInfo->usage;
|
||||
buffer->alignment = 256; /* nonCoherentAtomSize */
|
||||
|
||||
assert((buffer->size & 0xffffffff) == buffer->size);
|
||||
|
||||
*pBuffer = v3dv_buffer_to_handle(buffer);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
void
|
||||
v3dv_DestroyBuffer(VkDevice _device,
|
||||
VkBuffer _buffer,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
V3DV_FROM_HANDLE(v3dv_device, device, _device);
|
||||
V3DV_FROM_HANDLE(v3dv_buffer, buffer, _buffer);
|
||||
|
||||
if (!buffer)
|
||||
return;
|
||||
|
||||
vk_free2(&device->alloc, pAllocator, buffer);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -295,6 +295,12 @@ struct v3dv_image_view {
|
|||
uint32_t offset;
|
||||
};
|
||||
|
||||
struct v3dv_buffer {
|
||||
VkDeviceSize size;
|
||||
VkBufferUsageFlags usage;
|
||||
uint32_t alignment;
|
||||
};
|
||||
|
||||
struct v3dv_shader_module {
|
||||
unsigned char sha1[20];
|
||||
uint32_t size;
|
||||
|
|
@ -392,6 +398,7 @@ V3DV_DEFINE_HANDLE_CASTS(v3dv_instance, VkInstance)
|
|||
V3DV_DEFINE_HANDLE_CASTS(v3dv_physical_device, VkPhysicalDevice)
|
||||
V3DV_DEFINE_HANDLE_CASTS(v3dv_queue, VkQueue)
|
||||
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_buffer, VkBuffer)
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_device_memory, VkDeviceMemory)
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image, VkImage)
|
||||
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image_view, VkImageView)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue