mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-06 17:30:20 +01:00
venus: break up vn_device.h
Break it up into vn_{device,instance,physical_device}.h. Suggested by
Ryan Neph.
Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12144>
This commit is contained in:
parent
4b364ab4bc
commit
22cb100ea0
42 changed files with 262 additions and 216 deletions
|
|
@ -1,4 +1,4 @@
|
|||
/* This file is generated by venus-protocol git-f59e7aad. */
|
||||
/* This file is generated by venus-protocol git-0d51970a. */
|
||||
|
||||
/*
|
||||
* Copyright 2020 Google LLC
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_BUFFER_H
|
||||
#define VN_PROTOCOL_DRIVER_BUFFER_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkExternalMemoryBufferCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_BUFFER_VIEW_H
|
||||
#define VN_PROTOCOL_DRIVER_BUFFER_VIEW_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkBufferViewCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_COMMAND_BUFFER_H
|
||||
#define VN_PROTOCOL_DRIVER_COMMAND_BUFFER_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkCommandBufferAllocateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_COMMAND_POOL_H
|
||||
#define VN_PROTOCOL_DRIVER_COMMAND_POOL_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkCommandPoolCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_DESCRIPTOR_POOL_H
|
||||
#define VN_PROTOCOL_DRIVER_DESCRIPTOR_POOL_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkDescriptorPoolSize */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_DESCRIPTOR_SET_H
|
||||
#define VN_PROTOCOL_DRIVER_DESCRIPTOR_SET_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_DESCRIPTOR_SET_LAYOUT_H
|
||||
#define VN_PROTOCOL_DRIVER_DESCRIPTOR_SET_LAYOUT_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkDescriptorSetLayoutBinding */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_DESCRIPTOR_UPDATE_TEMPLATE_H
|
||||
#define VN_PROTOCOL_DRIVER_DESCRIPTOR_UPDATE_TEMPLATE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkDescriptorUpdateTemplateEntry */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_DEVICE_H
|
||||
#define VN_PROTOCOL_DRIVER_DEVICE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_DEVICE_MEMORY_H
|
||||
#define VN_PROTOCOL_DRIVER_DEVICE_MEMORY_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_EVENT_H
|
||||
#define VN_PROTOCOL_DRIVER_EVENT_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkEventCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_FENCE_H
|
||||
#define VN_PROTOCOL_DRIVER_FENCE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkExportFenceCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_FRAMEBUFFER_H
|
||||
#define VN_PROTOCOL_DRIVER_FRAMEBUFFER_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkFramebufferAttachmentImageInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_IMAGE_H
|
||||
#define VN_PROTOCOL_DRIVER_IMAGE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkSparseImageMemoryRequirements */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_IMAGE_VIEW_H
|
||||
#define VN_PROTOCOL_DRIVER_IMAGE_VIEW_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkImageViewUsageCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_INSTANCE_H
|
||||
#define VN_PROTOCOL_DRIVER_INSTANCE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_PIPELINE_H
|
||||
#define VN_PROTOCOL_DRIVER_PIPELINE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkSpecializationMapEntry */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_PIPELINE_CACHE_H
|
||||
#define VN_PROTOCOL_DRIVER_PIPELINE_CACHE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkPipelineCacheCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_PIPELINE_LAYOUT_H
|
||||
#define VN_PROTOCOL_DRIVER_PIPELINE_LAYOUT_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkPushConstantRange */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_QUERY_POOL_H
|
||||
#define VN_PROTOCOL_DRIVER_QUERY_POOL_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkQueryPoolCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_QUEUE_H
|
||||
#define VN_PROTOCOL_DRIVER_QUEUE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkDeviceGroupSubmitInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_RENDER_PASS_H
|
||||
#define VN_PROTOCOL_DRIVER_RENDER_PASS_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkAttachmentDescription */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_SAMPLER_H
|
||||
#define VN_PROTOCOL_DRIVER_SAMPLER_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkSamplerReductionModeCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_SAMPLER_YCBCR_CONVERSION_H
|
||||
#define VN_PROTOCOL_DRIVER_SAMPLER_YCBCR_CONVERSION_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkSamplerYcbcrConversionCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_SEMAPHORE_H
|
||||
#define VN_PROTOCOL_DRIVER_SEMAPHORE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkExportSemaphoreCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_SHADER_MODULE_H
|
||||
#define VN_PROTOCOL_DRIVER_SHADER_MODULE_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/* struct VkShaderModuleCreateInfo chain */
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
#ifndef VN_PROTOCOL_DRIVER_TRANSPORT_H
|
||||
#define VN_PROTOCOL_DRIVER_TRANSPORT_H
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_protocol_driver_structs.h"
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -24,6 +24,8 @@
|
|||
#include "vn_device.h"
|
||||
#include "vn_device_memory.h"
|
||||
#include "vn_image.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_physical_device.h"
|
||||
#include "vn_queue.h"
|
||||
|
||||
static int
|
||||
|
|
@ -208,8 +210,8 @@ vn_GetSwapchainGrallocUsage2ANDROID(
|
|||
|
||||
struct cros_gralloc0_buffer_info {
|
||||
uint32_t drm_fourcc;
|
||||
int num_fds; /* ignored */
|
||||
int fds[4]; /* ignored */
|
||||
int num_fds; /* ignored */
|
||||
int fds[4]; /* ignored */
|
||||
uint64_t modifier;
|
||||
uint32_t offset[4];
|
||||
uint32_t stride[4];
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
#include "vn_cs.h"
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_renderer.h"
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -23,6 +23,8 @@
|
|||
#include "vn_android.h"
|
||||
#include "vn_device_memory.h"
|
||||
#include "vn_icd.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_physical_device.h"
|
||||
#include "vn_queue.h"
|
||||
#include "vn_renderer.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -13,120 +13,7 @@
|
|||
|
||||
#include "vn_common.h"
|
||||
|
||||
#include "venus-protocol/vn_protocol_driver_defines.h"
|
||||
|
||||
#include "vn_cs.h"
|
||||
#include "vn_device_memory.h"
|
||||
#include "vn_renderer.h"
|
||||
#include "vn_ring.h"
|
||||
#include "vn_wsi.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;
|
||||
|
||||
/* Between the driver and the app, VN_MAX_API_VERSION is what we advertise
|
||||
* and base.base.app_info.api_version is what the app requests.
|
||||
*
|
||||
* Between the driver and the renderer, renderer_api_version is the api
|
||||
* version we request internally, which can be higher than
|
||||
* base.base.app_info.api_version. renderer_version is the instance
|
||||
* version we can use internally.
|
||||
*/
|
||||
uint32_t renderer_api_version;
|
||||
uint32_t renderer_version;
|
||||
|
||||
/* to synchronize renderer/ring */
|
||||
mtx_t roundtrip_mutex;
|
||||
uint32_t roundtrip_next;
|
||||
|
||||
struct {
|
||||
mtx_t mutex;
|
||||
struct vn_renderer_shmem *shmem;
|
||||
struct vn_ring ring;
|
||||
uint64_t id;
|
||||
|
||||
struct vn_cs_encoder upload;
|
||||
uint32_t command_dropped;
|
||||
} ring;
|
||||
|
||||
struct {
|
||||
struct vn_renderer_shmem *shmem;
|
||||
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;
|
||||
|
||||
/* XXX staged features to be merged to core venus protocol */
|
||||
VkVenusExperimentalFeatures100000MESA experimental;
|
||||
};
|
||||
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;
|
||||
|
||||
/* Between the driver and the app, properties.properties.apiVersion is what
|
||||
* we advertise and is capped by VN_MAX_API_VERSION and others.
|
||||
*
|
||||
* Between the driver and the renderer, renderer_version is the device
|
||||
* version we can use internally.
|
||||
*/
|
||||
uint32_t renderer_version;
|
||||
|
||||
/* Between the driver and the app, base.base.supported_extensions is what
|
||||
* we advertise.
|
||||
*
|
||||
* Between the driver and the renderer, renderer_extensions is what we can
|
||||
* use internally (after enabling).
|
||||
*/
|
||||
struct vk_device_extension_table renderer_extensions;
|
||||
uint32_t *extension_spec_versions;
|
||||
|
||||
VkPhysicalDeviceFeatures2 features;
|
||||
VkPhysicalDeviceVulkan11Features vulkan_1_1_features;
|
||||
VkPhysicalDeviceVulkan12Features vulkan_1_2_features;
|
||||
VkPhysicalDeviceTransformFeedbackFeaturesEXT transform_feedback_features;
|
||||
|
||||
VkPhysicalDeviceProperties2 properties;
|
||||
VkPhysicalDeviceVulkan11Properties vulkan_1_1_properties;
|
||||
VkPhysicalDeviceVulkan12Properties vulkan_1_2_properties;
|
||||
VkPhysicalDeviceTransformFeedbackPropertiesEXT
|
||||
transform_feedback_properties;
|
||||
|
||||
VkQueueFamilyProperties2 *queue_family_properties;
|
||||
uint32_t queue_family_count;
|
||||
|
||||
VkPhysicalDeviceMemoryProperties2 memory_properties;
|
||||
|
||||
struct {
|
||||
VkExternalMemoryHandleTypeFlagBits renderer_handle_type;
|
||||
VkExternalMemoryHandleTypeFlags supported_handle_types;
|
||||
} external_memory;
|
||||
|
||||
VkExternalFenceHandleTypeFlags external_fence_handles;
|
||||
VkExternalSemaphoreHandleTypeFlags external_binary_semaphore_handles;
|
||||
VkExternalSemaphoreHandleTypeFlags external_timeline_semaphore_handles;
|
||||
|
||||
struct wsi_device wsi_device;
|
||||
};
|
||||
VK_DEFINE_HANDLE_CASTS(vn_physical_device,
|
||||
base.base.base,
|
||||
VkPhysicalDevice,
|
||||
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
|
||||
|
||||
struct vn_device {
|
||||
struct vn_device_base base;
|
||||
|
|
@ -148,73 +35,4 @@ VK_DEFINE_HANDLE_CASTS(vn_device,
|
|||
VkDevice,
|
||||
VK_OBJECT_TYPE_DEVICE)
|
||||
|
||||
VkResult
|
||||
vn_instance_submit_roundtrip(struct vn_instance *instance,
|
||||
uint32_t *roundtrip_seqno);
|
||||
|
||||
void
|
||||
vn_instance_wait_roundtrip(struct vn_instance *instance,
|
||||
uint32_t roundtrip_seqno);
|
||||
|
||||
static inline void
|
||||
vn_instance_roundtrip(struct vn_instance *instance)
|
||||
{
|
||||
uint32_t roundtrip_seqno;
|
||||
if (vn_instance_submit_roundtrip(instance, &roundtrip_seqno) == VK_SUCCESS)
|
||||
vn_instance_wait_roundtrip(instance, roundtrip_seqno);
|
||||
}
|
||||
|
||||
VkResult
|
||||
vn_instance_ring_submit(struct vn_instance *instance,
|
||||
const struct vn_cs_encoder *cs);
|
||||
|
||||
struct vn_instance_submit_command {
|
||||
/* empty command implies errors */
|
||||
struct vn_cs_encoder command;
|
||||
struct vn_cs_encoder_buffer buffer;
|
||||
/* non-zero implies waiting */
|
||||
size_t reply_size;
|
||||
|
||||
/* when reply_size is non-zero, NULL can be returned on errors */
|
||||
struct vn_renderer_shmem *reply_shmem;
|
||||
struct vn_cs_decoder reply;
|
||||
};
|
||||
|
||||
static inline struct vn_cs_encoder *
|
||||
vn_instance_submit_command_init(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit,
|
||||
void *cmd_data,
|
||||
size_t cmd_size,
|
||||
size_t reply_size)
|
||||
{
|
||||
submit->command = VN_CS_ENCODER_INITIALIZER_LOCAL(cmd_data, cmd_size);
|
||||
/* fix submit->command.buffers to not point to a local variable */
|
||||
submit->buffer = submit->command.buffers[0];
|
||||
submit->command.buffers = &submit->buffer;
|
||||
|
||||
submit->reply_size = reply_size;
|
||||
submit->reply_shmem = NULL;
|
||||
|
||||
return &submit->command;
|
||||
}
|
||||
|
||||
void
|
||||
vn_instance_submit_command(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit);
|
||||
|
||||
static inline struct vn_cs_decoder *
|
||||
vn_instance_get_command_reply(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit)
|
||||
{
|
||||
return submit->reply_shmem ? &submit->reply : NULL;
|
||||
}
|
||||
|
||||
static inline void
|
||||
vn_instance_free_command_reply(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit)
|
||||
{
|
||||
assert(submit->reply_shmem);
|
||||
vn_renderer_shmem_unref(instance->renderer, submit->reply_shmem);
|
||||
}
|
||||
|
||||
#endif /* VN_DEVICE_H */
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
#include "vn_buffer.h"
|
||||
#include "vn_device.h"
|
||||
#include "vn_image.h"
|
||||
#include "vn_physical_device.h"
|
||||
|
||||
/* device memory commands */
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
#include "vn_icd.h"
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
|
||||
/* we support all versions from version 1 up to version 5 */
|
||||
static uint32_t vn_icd_version = 5;
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@
|
|||
#include "vn_android.h"
|
||||
#include "vn_device.h"
|
||||
#include "vn_device_memory.h"
|
||||
#include "vn_wsi.h"
|
||||
|
||||
static void
|
||||
vn_image_init_memory_requirements(struct vn_image *img,
|
||||
|
|
|
|||
144
src/virtio/vulkan/vn_instance.h
Normal file
144
src/virtio/vulkan/vn_instance.h
Normal file
|
|
@ -0,0 +1,144 @@
|
|||
/*
|
||||
* 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_INSTANCE_H
|
||||
#define VN_INSTANCE_H
|
||||
|
||||
#include "vn_common.h"
|
||||
|
||||
#include "venus-protocol/vn_protocol_driver_defines.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;
|
||||
|
||||
/* Between the driver and the app, VN_MAX_API_VERSION is what we advertise
|
||||
* and base.base.app_info.api_version is what the app requests.
|
||||
*
|
||||
* Between the driver and the renderer, renderer_api_version is the api
|
||||
* version we request internally, which can be higher than
|
||||
* base.base.app_info.api_version. renderer_version is the instance
|
||||
* version we can use internally.
|
||||
*/
|
||||
uint32_t renderer_api_version;
|
||||
uint32_t renderer_version;
|
||||
|
||||
/* to synchronize renderer/ring */
|
||||
mtx_t roundtrip_mutex;
|
||||
uint32_t roundtrip_next;
|
||||
|
||||
struct {
|
||||
mtx_t mutex;
|
||||
struct vn_renderer_shmem *shmem;
|
||||
struct vn_ring ring;
|
||||
uint64_t id;
|
||||
|
||||
struct vn_cs_encoder upload;
|
||||
uint32_t command_dropped;
|
||||
} ring;
|
||||
|
||||
struct {
|
||||
struct vn_renderer_shmem *shmem;
|
||||
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;
|
||||
|
||||
/* XXX staged features to be merged to core venus protocol */
|
||||
VkVenusExperimentalFeatures100000MESA experimental;
|
||||
};
|
||||
VK_DEFINE_HANDLE_CASTS(vn_instance,
|
||||
base.base.base,
|
||||
VkInstance,
|
||||
VK_OBJECT_TYPE_INSTANCE)
|
||||
|
||||
VkResult
|
||||
vn_instance_submit_roundtrip(struct vn_instance *instance,
|
||||
uint32_t *roundtrip_seqno);
|
||||
|
||||
void
|
||||
vn_instance_wait_roundtrip(struct vn_instance *instance,
|
||||
uint32_t roundtrip_seqno);
|
||||
|
||||
static inline void
|
||||
vn_instance_roundtrip(struct vn_instance *instance)
|
||||
{
|
||||
uint32_t roundtrip_seqno;
|
||||
if (vn_instance_submit_roundtrip(instance, &roundtrip_seqno) == VK_SUCCESS)
|
||||
vn_instance_wait_roundtrip(instance, roundtrip_seqno);
|
||||
}
|
||||
|
||||
VkResult
|
||||
vn_instance_ring_submit(struct vn_instance *instance,
|
||||
const struct vn_cs_encoder *cs);
|
||||
|
||||
struct vn_instance_submit_command {
|
||||
/* empty command implies errors */
|
||||
struct vn_cs_encoder command;
|
||||
struct vn_cs_encoder_buffer buffer;
|
||||
/* non-zero implies waiting */
|
||||
size_t reply_size;
|
||||
|
||||
/* when reply_size is non-zero, NULL can be returned on errors */
|
||||
struct vn_renderer_shmem *reply_shmem;
|
||||
struct vn_cs_decoder reply;
|
||||
};
|
||||
|
||||
static inline struct vn_cs_encoder *
|
||||
vn_instance_submit_command_init(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit,
|
||||
void *cmd_data,
|
||||
size_t cmd_size,
|
||||
size_t reply_size)
|
||||
{
|
||||
submit->command = VN_CS_ENCODER_INITIALIZER_LOCAL(cmd_data, cmd_size);
|
||||
/* fix submit->command.buffers to not point to a local variable */
|
||||
submit->buffer = submit->command.buffers[0];
|
||||
submit->command.buffers = &submit->buffer;
|
||||
|
||||
submit->reply_size = reply_size;
|
||||
submit->reply_shmem = NULL;
|
||||
|
||||
return &submit->command;
|
||||
}
|
||||
|
||||
void
|
||||
vn_instance_submit_command(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit);
|
||||
|
||||
static inline struct vn_cs_decoder *
|
||||
vn_instance_get_command_reply(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit)
|
||||
{
|
||||
return submit->reply_shmem ? &submit->reply : NULL;
|
||||
}
|
||||
|
||||
static inline void
|
||||
vn_instance_free_command_reply(struct vn_instance *instance,
|
||||
struct vn_instance_submit_command *submit)
|
||||
{
|
||||
assert(submit->reply_shmem);
|
||||
vn_renderer_shmem_unref(instance->renderer, submit->reply_shmem);
|
||||
}
|
||||
|
||||
#endif /* VN_INSTANCE_H */
|
||||
72
src/virtio/vulkan/vn_physical_device.h
Normal file
72
src/virtio/vulkan/vn_physical_device.h
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* 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_PHYSICAL_DEVICE_H
|
||||
#define VN_PHYSICAL_DEVICE_H
|
||||
|
||||
#include "vn_common.h"
|
||||
|
||||
#include "vn_wsi.h"
|
||||
|
||||
struct vn_physical_device {
|
||||
struct vn_physical_device_base base;
|
||||
|
||||
struct vn_instance *instance;
|
||||
|
||||
/* Between the driver and the app, properties.properties.apiVersion is what
|
||||
* we advertise and is capped by VN_MAX_API_VERSION and others.
|
||||
*
|
||||
* Between the driver and the renderer, renderer_version is the device
|
||||
* version we can use internally.
|
||||
*/
|
||||
uint32_t renderer_version;
|
||||
|
||||
/* Between the driver and the app, base.base.supported_extensions is what
|
||||
* we advertise.
|
||||
*
|
||||
* Between the driver and the renderer, renderer_extensions is what we can
|
||||
* use internally (after enabling).
|
||||
*/
|
||||
struct vk_device_extension_table renderer_extensions;
|
||||
uint32_t *extension_spec_versions;
|
||||
|
||||
VkPhysicalDeviceFeatures2 features;
|
||||
VkPhysicalDeviceVulkan11Features vulkan_1_1_features;
|
||||
VkPhysicalDeviceVulkan12Features vulkan_1_2_features;
|
||||
VkPhysicalDeviceTransformFeedbackFeaturesEXT transform_feedback_features;
|
||||
|
||||
VkPhysicalDeviceProperties2 properties;
|
||||
VkPhysicalDeviceVulkan11Properties vulkan_1_1_properties;
|
||||
VkPhysicalDeviceVulkan12Properties vulkan_1_2_properties;
|
||||
VkPhysicalDeviceTransformFeedbackPropertiesEXT
|
||||
transform_feedback_properties;
|
||||
|
||||
VkQueueFamilyProperties2 *queue_family_properties;
|
||||
uint32_t queue_family_count;
|
||||
|
||||
VkPhysicalDeviceMemoryProperties2 memory_properties;
|
||||
|
||||
struct {
|
||||
VkExternalMemoryHandleTypeFlagBits renderer_handle_type;
|
||||
VkExternalMemoryHandleTypeFlags supported_handle_types;
|
||||
} external_memory;
|
||||
|
||||
VkExternalFenceHandleTypeFlags external_fence_handles;
|
||||
VkExternalSemaphoreHandleTypeFlags external_binary_semaphore_handles;
|
||||
VkExternalSemaphoreHandleTypeFlags external_timeline_semaphore_handles;
|
||||
|
||||
struct wsi_device wsi_device;
|
||||
};
|
||||
VK_DEFINE_HANDLE_CASTS(vn_physical_device,
|
||||
base.base.base,
|
||||
VkPhysicalDevice,
|
||||
VK_OBJECT_TYPE_PHYSICAL_DEVICE)
|
||||
|
||||
#endif /* VN_PHYSICAL_DEVICE_H */
|
||||
|
|
@ -16,6 +16,7 @@
|
|||
#include "venus-protocol/vn_protocol_driver_shader_module.h"
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_physical_device.h"
|
||||
|
||||
/* shader module commands */
|
||||
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@
|
|||
#include "vn_device.h"
|
||||
#include "vn_device_memory.h"
|
||||
#include "vn_renderer.h"
|
||||
#include "vn_wsi.h"
|
||||
|
||||
/* queue commands */
|
||||
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
|
||||
#include "vn_device.h"
|
||||
#include "vn_image.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_physical_device.h"
|
||||
#include "vn_queue.h"
|
||||
|
||||
/* The common WSI support makes some assumptions about the driver.
|
||||
|
|
|
|||
|
|
@ -10,7 +10,8 @@
|
|||
|
||||
#include "wsi_common_wayland.h"
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_physical_device.h"
|
||||
#include "vn_wsi.h"
|
||||
|
||||
VkResult
|
||||
|
|
|
|||
|
|
@ -12,7 +12,8 @@
|
|||
|
||||
#include "wsi_common_x11.h"
|
||||
|
||||
#include "vn_device.h"
|
||||
#include "vn_instance.h"
|
||||
#include "vn_physical_device.h"
|
||||
#include "vn_wsi.h"
|
||||
|
||||
/* XCB surface commands */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue