mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 11:48:06 +02:00
tu: Move buffer view related code to tu_buffer_view.cc/h
More code isolation. Match the structure of the common Vulkan runtime, NVK and RADV. Signed-off-by: Valentine Burley <valentine.burley@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29441>
This commit is contained in:
parent
09d224685d
commit
d8ebc632eb
6 changed files with 79 additions and 54 deletions
|
|
@ -22,6 +22,7 @@ libtu_files = files(
|
|||
'layers/tu_rmv_layer.cc',
|
||||
'tu_autotune.cc',
|
||||
'tu_buffer.cc',
|
||||
'tu_buffer_view.cc',
|
||||
'tu_clear_blit.cc',
|
||||
'tu_cmd_buffer.cc',
|
||||
'tu_cs_breadcrumbs.cc',
|
||||
|
|
|
|||
52
src/freedreno/vulkan/tu_buffer_view.cc
Normal file
52
src/freedreno/vulkan/tu_buffer_view.cc
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* Copyright © 2024 Valentine Burley
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#include "tu_buffer_view.h"
|
||||
|
||||
#include "tu_buffer.h"
|
||||
#include "tu_device.h"
|
||||
#include "tu_formats.h"
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
tu_CreateBufferView(VkDevice _device,
|
||||
const VkBufferViewCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkBufferView *pView)
|
||||
{
|
||||
VK_FROM_HANDLE(tu_device, device, _device);
|
||||
VK_FROM_HANDLE(tu_buffer, buffer, pCreateInfo->buffer);
|
||||
struct tu_buffer_view *view;
|
||||
|
||||
view = (struct tu_buffer_view *) vk_buffer_view_create(
|
||||
&device->vk, pCreateInfo, pAllocator, sizeof(*view));
|
||||
|
||||
if (!view)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
uint8_t swiz[4] = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z,
|
||||
PIPE_SWIZZLE_W };
|
||||
|
||||
fdl6_buffer_view_init(
|
||||
view->descriptor, tu_vk_format_to_pipe_format(view->vk.format),
|
||||
swiz, buffer->iova + view->vk.offset, view->vk.range);
|
||||
|
||||
*pView = tu_buffer_view_to_handle(view);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
tu_DestroyBufferView(VkDevice _device,
|
||||
VkBufferView bufferView,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(tu_device, device, _device);
|
||||
VK_FROM_HANDLE(tu_buffer_view, view, bufferView);
|
||||
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
vk_buffer_view_destroy(&device->vk, pAllocator, &view->vk);
|
||||
}
|
||||
25
src/freedreno/vulkan/tu_buffer_view.h
Normal file
25
src/freedreno/vulkan/tu_buffer_view.h
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright © 2024 Valentine Burley
|
||||
* SPDX-License-Identifier: MIT
|
||||
*/
|
||||
|
||||
#ifndef TU_BUFFER_VIEW_H
|
||||
#define TU_BUFFER_VIEW_H
|
||||
|
||||
#include "tu_common.h"
|
||||
|
||||
#include "vk_buffer_view.h"
|
||||
|
||||
struct tu_buffer_view
|
||||
{
|
||||
struct vk_buffer_view vk;
|
||||
|
||||
uint32_t descriptor[A6XX_TEX_CONST_DWORDS];
|
||||
|
||||
struct tu_buffer *buffer;
|
||||
};
|
||||
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(tu_buffer_view, vk.base, VkBufferView,
|
||||
VK_OBJECT_TYPE_BUFFER_VIEW)
|
||||
|
||||
#endif /* TU_BUFFER_VIEW_H */
|
||||
|
|
@ -28,6 +28,7 @@
|
|||
#include "vk_util.h"
|
||||
|
||||
#include "tu_buffer.h"
|
||||
#include "tu_buffer_view.h"
|
||||
#include "tu_device.h"
|
||||
#include "tu_image.h"
|
||||
#include "tu_formats.h"
|
||||
|
|
|
|||
|
|
@ -1086,48 +1086,6 @@ tu_DestroyImageView(VkDevice _device,
|
|||
vk_object_free(&device->vk, pAllocator, iview);
|
||||
}
|
||||
|
||||
VKAPI_ATTR VkResult VKAPI_CALL
|
||||
tu_CreateBufferView(VkDevice _device,
|
||||
const VkBufferViewCreateInfo *pCreateInfo,
|
||||
const VkAllocationCallbacks *pAllocator,
|
||||
VkBufferView *pView)
|
||||
{
|
||||
VK_FROM_HANDLE(tu_device, device, _device);
|
||||
VK_FROM_HANDLE(tu_buffer, buffer, pCreateInfo->buffer);
|
||||
struct tu_buffer_view *view;
|
||||
|
||||
view = (struct tu_buffer_view *) vk_buffer_view_create(
|
||||
&device->vk, pCreateInfo, pAllocator, sizeof(*view));
|
||||
|
||||
if (!view)
|
||||
return vk_error(device, VK_ERROR_OUT_OF_HOST_MEMORY);
|
||||
|
||||
uint8_t swiz[4] = { PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z,
|
||||
PIPE_SWIZZLE_W };
|
||||
|
||||
fdl6_buffer_view_init(
|
||||
view->descriptor, tu_vk_format_to_pipe_format(view->vk.format),
|
||||
swiz, buffer->iova + view->vk.offset, view->vk.range);
|
||||
|
||||
*pView = tu_buffer_view_to_handle(view);
|
||||
|
||||
return VK_SUCCESS;
|
||||
}
|
||||
|
||||
VKAPI_ATTR void VKAPI_CALL
|
||||
tu_DestroyBufferView(VkDevice _device,
|
||||
VkBufferView bufferView,
|
||||
const VkAllocationCallbacks *pAllocator)
|
||||
{
|
||||
VK_FROM_HANDLE(tu_device, device, _device);
|
||||
VK_FROM_HANDLE(tu_buffer_view, view, bufferView);
|
||||
|
||||
if (!view)
|
||||
return;
|
||||
|
||||
vk_buffer_view_destroy(&device->vk, pAllocator, &view->vk);
|
||||
}
|
||||
|
||||
/* Impelements the operations described in "Fragment Density Map Operations."
|
||||
*/
|
||||
void
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@
|
|||
#define TU_IMAGE_H
|
||||
|
||||
#include "tu_common.h"
|
||||
#include "vk_buffer_view.h"
|
||||
|
||||
#define TU_MAX_PLANE_COUNT 3
|
||||
|
||||
|
|
@ -69,17 +68,6 @@ struct tu_image_view
|
|||
VK_DEFINE_NONDISP_HANDLE_CASTS(tu_image_view, vk.base, VkImageView,
|
||||
VK_OBJECT_TYPE_IMAGE_VIEW);
|
||||
|
||||
struct tu_buffer_view
|
||||
{
|
||||
struct vk_buffer_view vk;
|
||||
|
||||
uint32_t descriptor[A6XX_TEX_CONST_DWORDS];
|
||||
|
||||
struct tu_buffer *buffer;
|
||||
};
|
||||
VK_DEFINE_NONDISP_HANDLE_CASTS(tu_buffer_view, vk.base, VkBufferView,
|
||||
VK_OBJECT_TYPE_BUFFER_VIEW)
|
||||
|
||||
uint32_t tu6_plane_count(VkFormat format);
|
||||
enum pipe_format tu6_plane_format(VkFormat format, uint32_t plane);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue