mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-03 20:10:17 +01:00
Signed-off-by: Chia-I Wu <olvaffe@gmail.com> Reviewed-by: Ryan Neph <ryanneph@google.com> Reviewed-by: Gert Wollny <gert.wollny@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5800>
209 lines
5.3 KiB
C
209 lines
5.3 KiB
C
/*
|
|
* Copyright 2019 Google LLC
|
|
* SPDX-License-Identifier: MIT
|
|
*
|
|
* based in part on anv and radv which are:
|
|
* Copyright © 2015 Intel Corporation
|
|
* Copyright © 2016 Red Hat.
|
|
* Copyright © 2016 Bas Nieuwenhuizen
|
|
*/
|
|
|
|
#ifndef VN_DEVICE_H
|
|
#define VN_DEVICE_H
|
|
|
|
#include "vn_common.h"
|
|
|
|
#include "vn_cs.h"
|
|
#include "vn_renderer.h"
|
|
#include "vn_ring.h"
|
|
|
|
struct vn_instance {
|
|
struct vn_instance_base base;
|
|
|
|
struct driOptionCache dri_options;
|
|
struct driOptionCache available_dri_options;
|
|
|
|
struct vn_renderer *renderer;
|
|
struct vn_renderer_info renderer_info;
|
|
uint32_t renderer_version;
|
|
|
|
/* to synchronize renderer/ring */
|
|
mtx_t roundtrip_mutex;
|
|
uint32_t roundtrip_next;
|
|
|
|
struct {
|
|
mtx_t mutex;
|
|
struct vn_renderer_bo *bo;
|
|
struct vn_ring ring;
|
|
uint64_t id;
|
|
|
|
struct vn_cs_encoder upload;
|
|
uint32_t command_dropped;
|
|
} ring;
|
|
|
|
struct {
|
|
struct vn_renderer_bo *bo;
|
|
size_t size;
|
|
size_t used;
|
|
void *ptr;
|
|
} reply;
|
|
|
|
mtx_t physical_device_mutex;
|
|
struct vn_physical_device *physical_devices;
|
|
uint32_t physical_device_count;
|
|
};
|
|
VK_DEFINE_HANDLE_CASTS(vn_instance,
|
|
base.base.base,
|
|
VkInstance,
|
|
VK_OBJECT_TYPE_INSTANCE)
|
|
|
|
struct vn_physical_device {
|
|
struct vn_physical_device_base base;
|
|
|
|
struct vn_instance *instance;
|
|
|
|
uint32_t renderer_version;
|
|
struct vk_device_extension_table renderer_extensions;
|
|
|
|
uint32_t *extension_spec_versions;
|
|
|
|
VkPhysicalDeviceFeatures2 features;
|
|
VkPhysicalDeviceVulkan11Features vulkan_1_1_features;
|
|
VkPhysicalDeviceVulkan12Features vulkan_1_2_features;
|
|
|
|
VkPhysicalDeviceProperties2 properties;
|
|
VkPhysicalDeviceVulkan11Properties vulkan_1_1_properties;
|
|
VkPhysicalDeviceVulkan12Properties vulkan_1_2_properties;
|
|
|
|
VkQueueFamilyProperties2 *queue_family_properties;
|
|
uint32_t *queue_family_sync_queue_bases;
|
|
uint32_t queue_family_count;
|
|
|
|
VkPhysicalDeviceMemoryProperties2 memory_properties;
|
|
|
|
VkExternalMemoryHandleTypeFlags external_memory_handles;
|
|
VkExternalFenceHandleTypeFlags external_fence_handles;
|
|
VkExternalSemaphoreHandleTypeFlags external_binary_semaphore_handles;
|
|
VkExternalSemaphoreHandleTypeFlags external_timeline_semaphore_handles;
|
|
};
|
|
VK_DEFINE_HANDLE_CASTS(vn_physical_device,
|
|
base.base.base,
|
|
VkPhysicalDevice,
|
|
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
|
|
|
|
struct vn_device {
|
|
struct vn_device_base base;
|
|
|
|
struct vn_instance *instance;
|
|
struct vn_physical_device *physical_device;
|
|
|
|
struct vn_queue *queues;
|
|
uint32_t queue_count;
|
|
};
|
|
VK_DEFINE_HANDLE_CASTS(vn_device,
|
|
base.base.base,
|
|
VkDevice,
|
|
VK_OBJECT_TYPE_DEVICE)
|
|
|
|
struct vn_queue {
|
|
struct vn_object_base base;
|
|
|
|
struct vn_device *device;
|
|
uint32_t family;
|
|
uint32_t index;
|
|
uint32_t flags;
|
|
|
|
uint32_t sync_queue_index;
|
|
|
|
struct vn_renderer_sync *idle_sync;
|
|
uint64_t idle_sync_value;
|
|
};
|
|
VK_DEFINE_HANDLE_CASTS(vn_queue, base.base, VkQueue, VK_OBJECT_TYPE_QUEUE)
|
|
|
|
enum vn_sync_type {
|
|
/* no payload */
|
|
VN_SYNC_TYPE_INVALID,
|
|
|
|
/* When we signal or reset, we update both the device object and the
|
|
* renderer sync. When we wait or query, we use the renderer sync only.
|
|
*
|
|
* TODO VkFence does not need the device object
|
|
*/
|
|
VN_SYNC_TYPE_SYNC,
|
|
|
|
/* device object only; no renderer sync */
|
|
VN_SYNC_TYPE_DEVICE_ONLY,
|
|
|
|
/* already signaled by WSI */
|
|
VN_SYNC_TYPE_WSI_SIGNALED,
|
|
};
|
|
|
|
struct vn_sync_payload {
|
|
enum vn_sync_type type;
|
|
struct vn_renderer_sync *sync;
|
|
};
|
|
|
|
struct vn_fence {
|
|
struct vn_object_base base;
|
|
|
|
struct vn_sync_payload *payload;
|
|
|
|
struct vn_sync_payload permanent;
|
|
struct vn_sync_payload temporary;
|
|
};
|
|
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_fence,
|
|
base.base,
|
|
VkFence,
|
|
VK_OBJECT_TYPE_FENCE)
|
|
|
|
struct vn_semaphore {
|
|
struct vn_object_base base;
|
|
|
|
VkSemaphoreType type;
|
|
|
|
struct vn_sync_payload *payload;
|
|
|
|
struct vn_sync_payload permanent;
|
|
struct vn_sync_payload temporary;
|
|
};
|
|
VK_DEFINE_NONDISP_HANDLE_CASTS(vn_semaphore,
|
|
base.base,
|
|
VkSemaphore,
|
|
VK_OBJECT_TYPE_SEMAPHORE)
|
|
|
|
struct vn_command_buffer {
|
|
struct vn_object_base base;
|
|
|
|
struct vn_device *device;
|
|
};
|
|
VK_DEFINE_HANDLE_CASTS(vn_command_buffer,
|
|
base.base,
|
|
VkCommandBuffer,
|
|
VK_OBJECT_TYPE_COMMAND_BUFFER)
|
|
|
|
VkResult
|
|
vn_instance_submit_roundtrip(struct vn_instance *instance,
|
|
uint32_t *roundtrip_seqno);
|
|
|
|
struct vn_instance_submit_command {
|
|
/* empty command implies errors */
|
|
struct vn_cs_encoder command;
|
|
/* non-zero implies waiting */
|
|
size_t reply_size;
|
|
|
|
/* when reply_size is non-zero, NULL can be returned on errors */
|
|
struct vn_renderer_bo *reply_bo;
|
|
struct vn_cs_decoder reply;
|
|
};
|
|
|
|
void
|
|
vn_instance_submit_command(struct vn_instance *instance,
|
|
struct vn_instance_submit_command *submit);
|
|
|
|
void
|
|
vn_fence_signal_wsi(struct vn_device *dev, struct vn_fence *fence);
|
|
|
|
void
|
|
vn_semaphore_signal_wsi(struct vn_device *dev, struct vn_semaphore *sem);
|
|
|
|
#endif /* VN_DEVICE_H */
|