2020-06-19 07:40:27 +01:00
|
|
|
/*
|
|
|
|
* Copyright © 2019 Red Hat.
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a
|
|
|
|
* copy of this software and associated documentation files (the "Software"),
|
|
|
|
* to deal in the Software without restriction, including without limitation
|
|
|
|
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
|
|
|
* and/or sell copies of the Software, and to permit persons to whom the
|
|
|
|
* Software is furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice (including the next
|
|
|
|
* paragraph) shall be included in all copies or substantial portions of the
|
|
|
|
* Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
|
|
|
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
|
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
|
|
|
* IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
#include "util/macros.h"
|
|
|
|
#include "util/list.h"
|
|
|
|
|
|
|
|
#include "compiler/shader_enums.h"
|
|
|
|
#include "pipe/p_screen.h"
|
|
|
|
#include "pipe/p_state.h"
|
|
|
|
#include "nir.h"
|
|
|
|
|
|
|
|
/* Pre-declarations needed for WSI entrypoints */
|
|
|
|
struct wl_surface;
|
|
|
|
struct wl_display;
|
|
|
|
typedef struct xcb_connection_t xcb_connection_t;
|
|
|
|
typedef uint32_t xcb_visualid_t;
|
|
|
|
typedef uint32_t xcb_window_t;
|
|
|
|
|
|
|
|
#define VK_PROTOTYPES
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#include <vulkan/vk_icd.h>
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#include "lvp_entrypoints.h"
|
2021-01-24 15:06:09 +00:00
|
|
|
#include "vk_device.h"
|
2021-01-24 22:57:46 +00:00
|
|
|
#include "vk_instance.h"
|
|
|
|
#include "vk_physical_device.h"
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
#include "wsi_common.h"
|
|
|
|
|
|
|
|
#include <assert.h>
|
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define MAX_SETS 8
|
|
|
|
#define MAX_PUSH_CONSTANTS_SIZE 128
|
2020-12-04 00:24:46 +00:00
|
|
|
#define MAX_PUSH_DESCRIPTORS 32
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2021-02-18 01:09:00 +00:00
|
|
|
#ifdef _WIN32
|
|
|
|
#define lvp_printflike(a, b)
|
|
|
|
#else
|
2020-09-29 20:29:04 +01:00
|
|
|
#define lvp_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
|
2021-02-18 01:09:00 +00:00
|
|
|
#endif
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
int lvp_get_instance_entrypoint_index(const char *name);
|
|
|
|
int lvp_get_device_entrypoint_index(const char *name);
|
|
|
|
int lvp_get_physical_device_entrypoint_index(const char *name);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
const char *lvp_get_instance_entry_name(int index);
|
|
|
|
const char *lvp_get_physical_device_entry_name(int index);
|
|
|
|
const char *lvp_get_device_entry_name(int index);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
bool lvp_instance_entrypoint_is_enabled(int index, uint32_t core_version,
|
2021-01-24 23:50:29 +00:00
|
|
|
const struct vk_instance_extension_table *instance);
|
2020-09-29 20:29:04 +01:00
|
|
|
bool lvp_physical_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
2021-01-24 23:50:29 +00:00
|
|
|
const struct vk_instance_extension_table *instance);
|
2020-09-29 20:29:04 +01:00
|
|
|
bool lvp_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
2021-01-24 23:50:29 +00:00
|
|
|
const struct vk_instance_extension_table *instance,
|
|
|
|
const struct vk_device_extension_table *device);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#define LVP_DEFINE_HANDLE_CASTS(__lvp_type, __VkType) \
|
2020-06-19 07:40:27 +01:00
|
|
|
\
|
2020-09-29 20:29:04 +01:00
|
|
|
static inline struct __lvp_type * \
|
|
|
|
__lvp_type ## _from_handle(__VkType _handle) \
|
2020-06-19 07:40:27 +01:00
|
|
|
{ \
|
2020-09-29 20:29:04 +01:00
|
|
|
return (struct __lvp_type *) _handle; \
|
2020-06-19 07:40:27 +01:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static inline __VkType \
|
2020-09-29 20:29:04 +01:00
|
|
|
__lvp_type ## _to_handle(struct __lvp_type *_obj) \
|
2020-06-19 07:40:27 +01:00
|
|
|
{ \
|
|
|
|
return (__VkType) _obj; \
|
|
|
|
}
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#define LVP_DEFINE_NONDISP_HANDLE_CASTS(__lvp_type, __VkType) \
|
2020-06-19 07:40:27 +01:00
|
|
|
\
|
2020-09-29 20:29:04 +01:00
|
|
|
static inline struct __lvp_type * \
|
|
|
|
__lvp_type ## _from_handle(__VkType _handle) \
|
2020-06-19 07:40:27 +01:00
|
|
|
{ \
|
2020-09-29 20:29:04 +01:00
|
|
|
return (struct __lvp_type *)(uintptr_t) _handle; \
|
2020-06-19 07:40:27 +01:00
|
|
|
} \
|
|
|
|
\
|
|
|
|
static inline __VkType \
|
2020-09-29 20:29:04 +01:00
|
|
|
__lvp_type ## _to_handle(struct __lvp_type *_obj) \
|
2020-06-19 07:40:27 +01:00
|
|
|
{ \
|
|
|
|
return (__VkType)(uintptr_t) _obj; \
|
|
|
|
}
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#define LVP_FROM_HANDLE(__lvp_type, __name, __handle) \
|
|
|
|
struct __lvp_type *__name = __lvp_type ## _from_handle(__handle)
|
|
|
|
|
|
|
|
LVP_DEFINE_HANDLE_CASTS(lvp_cmd_buffer, VkCommandBuffer)
|
|
|
|
LVP_DEFINE_HANDLE_CASTS(lvp_device, VkDevice)
|
|
|
|
LVP_DEFINE_HANDLE_CASTS(lvp_instance, VkInstance)
|
|
|
|
LVP_DEFINE_HANDLE_CASTS(lvp_physical_device, VkPhysicalDevice)
|
|
|
|
LVP_DEFINE_HANDLE_CASTS(lvp_queue, VkQueue)
|
|
|
|
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_cmd_pool, VkCommandPool)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_buffer, VkBuffer)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_buffer_view, VkBufferView)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_pool, VkDescriptorPool)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_set, VkDescriptorSet)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_set_layout, VkDescriptorSetLayout)
|
2020-12-04 00:25:32 +00:00
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_descriptor_update_template, VkDescriptorUpdateTemplate)
|
2020-09-29 20:29:04 +01:00
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_device_memory, VkDeviceMemory)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_event, VkEvent)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_framebuffer, VkFramebuffer)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_image, VkImage)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_image_view, VkImageView);
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_pipeline_cache, VkPipelineCache)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_pipeline, VkPipeline)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_pipeline_layout, VkPipelineLayout)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_query_pool, VkQueryPool)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_render_pass, VkRenderPass)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_sampler, VkSampler)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_shader_module, VkShaderModule)
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_fence, VkFence);
|
|
|
|
LVP_DEFINE_NONDISP_HANDLE_CASTS(lvp_semaphore, VkSemaphore);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
/* Whenever we generate an error, pass it through this function. Useful for
|
|
|
|
* debugging, where we can break on it. Only call at error site, not when
|
|
|
|
* propagating errors. Might be useful to plug in a stack trace here.
|
|
|
|
*/
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
VkResult __vk_errorf(struct lvp_instance *instance, VkResult error, const char *file, int line, const char *format, ...);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#define LVP_DEBUG_ALL_ENTRYPOINTS (1 << 0)
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
#define vk_error(instance, error) __vk_errorf(instance, error, __FILE__, __LINE__, NULL);
|
|
|
|
#define vk_errorf(instance, error, format, ...) __vk_errorf(instance, error, __FILE__, __LINE__, format, ## __VA_ARGS__);
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
void __lvp_finishme(const char *file, int line, const char *format, ...)
|
|
|
|
lvp_printflike(3, 4);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#define lvp_finishme(format, ...) \
|
|
|
|
__lvp_finishme(__FILE__, __LINE__, format, ##__VA_ARGS__);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
#define stub_return(v) \
|
|
|
|
do { \
|
2020-09-29 20:29:04 +01:00
|
|
|
lvp_finishme("stub %s", __func__); \
|
2020-06-19 07:40:27 +01:00
|
|
|
return (v); \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
#define stub() \
|
|
|
|
do { \
|
2020-09-29 20:29:04 +01:00
|
|
|
lvp_finishme("stub %s", __func__); \
|
2020-06-19 07:40:27 +01:00
|
|
|
return; \
|
|
|
|
} while (0)
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_shader_module {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
uint32_t size;
|
|
|
|
char data[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline gl_shader_stage
|
|
|
|
vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage)
|
|
|
|
{
|
|
|
|
assert(__builtin_popcount(vk_stage) == 1);
|
|
|
|
return ffs(vk_stage) - 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline VkShaderStageFlagBits
|
|
|
|
mesa_to_vk_shader_stage(gl_shader_stage mesa_stage)
|
|
|
|
{
|
|
|
|
return (1 << mesa_stage);
|
|
|
|
}
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#define LVP_STAGE_MASK ((1 << MESA_SHADER_STAGES) - 1)
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
#define lvp_foreach_stage(stage, stage_bits) \
|
2020-06-19 07:40:27 +01:00
|
|
|
for (gl_shader_stage stage, \
|
2020-09-29 20:29:04 +01:00
|
|
|
__tmp = (gl_shader_stage)((stage_bits) & LVP_STAGE_MASK); \
|
2021-02-18 01:09:00 +00:00
|
|
|
stage = ffs(__tmp) - 1, __tmp; \
|
2020-06-19 07:40:27 +01:00
|
|
|
__tmp &= ~(1 << (stage)))
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_physical_device {
|
2021-01-24 22:57:46 +00:00
|
|
|
struct vk_physical_device vk;
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
struct pipe_loader_device *pld;
|
|
|
|
struct pipe_screen *pscreen;
|
|
|
|
uint32_t max_images;
|
|
|
|
|
|
|
|
struct wsi_device wsi_device;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_instance {
|
2021-01-24 22:57:46 +00:00
|
|
|
struct vk_instance vk;
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
uint32_t apiVersion;
|
|
|
|
int physicalDeviceCount;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_physical_device physicalDevice;
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
uint64_t debug_flags;
|
|
|
|
|
|
|
|
struct pipe_loader_device *devs;
|
|
|
|
int num_devices;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
VkResult lvp_init_wsi(struct lvp_physical_device *physical_device);
|
|
|
|
void lvp_finish_wsi(struct lvp_physical_device *physical_device);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
bool lvp_physical_device_extension_supported(struct lvp_physical_device *dev,
|
2020-06-19 07:40:27 +01:00
|
|
|
const char *name);
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_queue {
|
2020-06-19 07:40:27 +01:00
|
|
|
VK_LOADER_DATA _loader_data;
|
|
|
|
VkDeviceQueueCreateFlags flags;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_device * device;
|
2020-06-19 07:40:27 +01:00
|
|
|
struct pipe_context *ctx;
|
|
|
|
bool shutdown;
|
|
|
|
thrd_t exec_thread;
|
|
|
|
mtx_t m;
|
|
|
|
cnd_t new_work;
|
|
|
|
struct list_head workqueue;
|
2021-02-18 01:19:16 +00:00
|
|
|
volatile int count;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_queue_work {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct list_head list;
|
|
|
|
uint32_t cmd_buffer_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_buffer **cmd_buffers;
|
|
|
|
struct lvp_fence *fence;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_pipeline_cache {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_device * device;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkAllocationCallbacks alloc;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_device {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_device vk;
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_queue queue;
|
|
|
|
struct lvp_instance * instance;
|
|
|
|
struct lvp_physical_device *physical_device;
|
2020-06-19 07:40:27 +01:00
|
|
|
struct pipe_screen *pscreen;
|
|
|
|
|
|
|
|
mtx_t fence_lock;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
void lvp_device_get_cache_uuid(void *uuid);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_device_memory {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
struct pipe_memory_allocation *pmem;
|
|
|
|
uint32_t type_index;
|
|
|
|
VkDeviceSize map_size;
|
|
|
|
void * map;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_image {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
VkImageType type;
|
|
|
|
VkFormat vk_format;
|
|
|
|
VkDeviceSize size;
|
|
|
|
uint32_t alignment;
|
|
|
|
struct pipe_resource *bo;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline uint32_t
|
2020-09-29 20:29:04 +01:00
|
|
|
lvp_get_layerCount(const struct lvp_image *image,
|
2020-06-19 07:40:27 +01:00
|
|
|
const VkImageSubresourceRange *range)
|
|
|
|
{
|
|
|
|
return range->layerCount == VK_REMAINING_ARRAY_LAYERS ?
|
|
|
|
image->bo->array_size - range->baseArrayLayer : range->layerCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline uint32_t
|
2020-09-29 20:29:04 +01:00
|
|
|
lvp_get_levelCount(const struct lvp_image *image,
|
2020-06-19 07:40:27 +01:00
|
|
|
const VkImageSubresourceRange *range)
|
|
|
|
{
|
|
|
|
return range->levelCount == VK_REMAINING_MIP_LEVELS ?
|
|
|
|
(image->bo->last_level + 1) - range->baseMipLevel : range->levelCount;
|
|
|
|
}
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_image_create_info {
|
2020-06-19 07:40:27 +01:00
|
|
|
const VkImageCreateInfo *vk_info;
|
|
|
|
uint32_t bind_flags;
|
|
|
|
uint32_t stride;
|
|
|
|
};
|
|
|
|
|
|
|
|
VkResult
|
2020-09-29 20:29:04 +01:00
|
|
|
lvp_image_create(VkDevice _device,
|
|
|
|
const struct lvp_image_create_info *create_info,
|
2020-06-19 07:40:27 +01:00
|
|
|
const VkAllocationCallbacks* alloc,
|
|
|
|
VkImage *pImage);
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_image_view {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
2020-09-29 20:29:04 +01:00
|
|
|
const struct lvp_image *image; /**< VkImageViewCreateInfo::image */
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
VkImageViewType view_type;
|
|
|
|
VkFormat format;
|
|
|
|
enum pipe_format pformat;
|
|
|
|
VkComponentMapping components;
|
|
|
|
VkImageSubresourceRange subresourceRange;
|
|
|
|
|
|
|
|
struct pipe_surface *surface; /* have we created a pipe surface for this? */
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_subpass_attachment {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t attachment;
|
|
|
|
VkImageLayout layout;
|
|
|
|
bool in_render_loop;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_subpass {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t attachment_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_subpass_attachment * attachments;
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
uint32_t input_count;
|
|
|
|
uint32_t color_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_subpass_attachment * input_attachments;
|
|
|
|
struct lvp_subpass_attachment * color_attachments;
|
|
|
|
struct lvp_subpass_attachment * resolve_attachments;
|
|
|
|
struct lvp_subpass_attachment * depth_stencil_attachment;
|
|
|
|
struct lvp_subpass_attachment * ds_resolve_attachment;
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
/** Subpass has at least one color resolve attachment */
|
|
|
|
bool has_color_resolve;
|
|
|
|
|
|
|
|
/** Subpass has at least one color attachment */
|
|
|
|
bool has_color_att;
|
|
|
|
|
|
|
|
VkSampleCountFlagBits max_sample_count;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_render_pass_attachment {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkFormat format;
|
|
|
|
uint32_t samples;
|
|
|
|
VkAttachmentLoadOp load_op;
|
|
|
|
VkAttachmentLoadOp stencil_load_op;
|
|
|
|
VkImageLayout initial_layout;
|
|
|
|
VkImageLayout final_layout;
|
|
|
|
|
|
|
|
/* The subpass id in which the attachment will be used first/last. */
|
|
|
|
uint32_t first_subpass_idx;
|
|
|
|
uint32_t last_subpass_idx;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_render_pass {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
uint32_t attachment_count;
|
|
|
|
uint32_t subpass_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_subpass_attachment * subpass_attachments;
|
|
|
|
struct lvp_render_pass_attachment * attachments;
|
|
|
|
struct lvp_subpass subpasses[0];
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_sampler {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
VkSamplerCreateInfo create_info;
|
|
|
|
uint32_t state[4];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_framebuffer {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t layers;
|
|
|
|
|
|
|
|
uint32_t attachment_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_image_view * attachments[0];
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_set_binding_layout {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint16_t descriptor_index;
|
|
|
|
/* Number of array elements in this binding */
|
|
|
|
VkDescriptorType type;
|
|
|
|
uint16_t array_size;
|
|
|
|
bool valid;
|
|
|
|
|
|
|
|
int16_t dynamic_index;
|
|
|
|
struct {
|
|
|
|
int16_t const_buffer_index;
|
|
|
|
int16_t shader_buffer_index;
|
|
|
|
int16_t sampler_index;
|
|
|
|
int16_t sampler_view_index;
|
|
|
|
int16_t image_index;
|
|
|
|
} stage[MESA_SHADER_STAGES];
|
|
|
|
|
|
|
|
/* Immutable samplers (or NULL if no immutable samplers) */
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_sampler **immutable_samplers;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_set_layout {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
2021-02-09 03:44:58 +00:00
|
|
|
|
2021-02-24 07:02:51 +00:00
|
|
|
const VkAllocationCallbacks *alloc;
|
2021-02-09 03:44:58 +00:00
|
|
|
/* Descriptor set layouts can be destroyed at almost any time */
|
|
|
|
uint32_t ref_cnt;
|
|
|
|
|
2020-06-19 07:40:27 +01:00
|
|
|
/* Number of bindings in this descriptor set */
|
|
|
|
uint16_t binding_count;
|
|
|
|
|
|
|
|
/* Total size of the descriptor set with room for all array entries */
|
|
|
|
uint16_t size;
|
|
|
|
|
|
|
|
/* Shader stages affected by this descriptor set */
|
|
|
|
uint16_t shader_stages;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint16_t const_buffer_count;
|
|
|
|
uint16_t shader_buffer_count;
|
|
|
|
uint16_t sampler_count;
|
|
|
|
uint16_t sampler_view_count;
|
|
|
|
uint16_t image_count;
|
|
|
|
} stage[MESA_SHADER_STAGES];
|
|
|
|
|
|
|
|
/* Number of dynamic offsets used by this descriptor set */
|
|
|
|
uint16_t dynamic_offset_count;
|
|
|
|
|
|
|
|
/* Bindings in this descriptor set */
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_set_binding_layout binding[0];
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2021-02-09 03:44:58 +00:00
|
|
|
void lvp_descriptor_set_layout_destroy(struct lvp_device *device,
|
|
|
|
struct lvp_descriptor_set_layout *layout);
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
lvp_descriptor_set_layout_ref(struct lvp_descriptor_set_layout *layout)
|
|
|
|
{
|
|
|
|
assert(layout && layout->ref_cnt >= 1);
|
|
|
|
p_atomic_inc(&layout->ref_cnt);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
lvp_descriptor_set_layout_unref(struct lvp_device *device,
|
|
|
|
struct lvp_descriptor_set_layout *layout)
|
|
|
|
{
|
|
|
|
assert(layout && layout->ref_cnt >= 1);
|
|
|
|
if (p_atomic_dec_zero(&layout->ref_cnt))
|
|
|
|
lvp_descriptor_set_layout_destroy(device, layout);
|
|
|
|
}
|
|
|
|
|
2020-12-04 00:22:40 +00:00
|
|
|
union lvp_descriptor_info {
|
|
|
|
struct {
|
|
|
|
struct lvp_sampler *sampler;
|
|
|
|
struct lvp_image_view *iview;
|
|
|
|
VkImageLayout image_layout;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
struct lvp_buffer *buffer;
|
|
|
|
VkDeviceSize offset;
|
|
|
|
VkDeviceSize range;
|
|
|
|
};
|
|
|
|
struct lvp_buffer_view *buffer_view;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDescriptorType type;
|
|
|
|
|
2020-12-04 00:22:40 +00:00
|
|
|
union lvp_descriptor_info info;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_set {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
2021-02-09 03:44:58 +00:00
|
|
|
struct lvp_descriptor_set_layout *layout;
|
2020-06-19 07:40:27 +01:00
|
|
|
struct list_head link;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor descriptors[0];
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_pool {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
VkDescriptorPoolCreateFlags flags;
|
|
|
|
uint32_t max_sets;
|
|
|
|
|
|
|
|
struct list_head sets;
|
|
|
|
};
|
|
|
|
|
2020-12-04 00:25:32 +00:00
|
|
|
struct lvp_descriptor_update_template {
|
|
|
|
struct vk_object_base base;
|
|
|
|
uint32_t entry_count;
|
|
|
|
uint32_t set;
|
|
|
|
VkDescriptorUpdateTemplateType type;
|
|
|
|
struct lvp_descriptor_set_layout *descriptor_set_layout;
|
|
|
|
VkPipelineBindPoint bind_point;
|
|
|
|
struct lvp_pipeline_layout *pipeline_layout;
|
|
|
|
VkDescriptorUpdateTemplateEntry entry[0];
|
|
|
|
};
|
|
|
|
|
2020-06-19 07:40:27 +01:00
|
|
|
VkResult
|
2020-09-29 20:29:04 +01:00
|
|
|
lvp_descriptor_set_create(struct lvp_device *device,
|
2021-02-09 03:44:58 +00:00
|
|
|
struct lvp_descriptor_set_layout *layout,
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_set **out_set);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
void
|
2020-09-29 20:29:04 +01:00
|
|
|
lvp_descriptor_set_destroy(struct lvp_device *device,
|
|
|
|
struct lvp_descriptor_set *set);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_pipeline_layout {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
struct {
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_set_layout *layout;
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t dynamic_offset_start;
|
|
|
|
} set[MAX_SETS];
|
|
|
|
|
|
|
|
uint32_t num_sets;
|
|
|
|
uint32_t push_constant_size;
|
|
|
|
struct {
|
|
|
|
bool has_dynamic_offsets;
|
|
|
|
} stage[MESA_SHADER_STAGES];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_pipeline {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_device * device;
|
|
|
|
struct lvp_pipeline_layout * layout;
|
2020-06-19 07:40:27 +01:00
|
|
|
|
2020-12-07 22:31:58 +00:00
|
|
|
void *mem_ctx;
|
2020-06-19 07:40:27 +01:00
|
|
|
bool is_compute_pipeline;
|
|
|
|
bool force_min_sample;
|
|
|
|
nir_shader *pipeline_nir[MESA_SHADER_STAGES];
|
|
|
|
void *shader_cso[PIPE_SHADER_TYPES];
|
|
|
|
VkGraphicsPipelineCreateInfo graphics_create_info;
|
|
|
|
VkComputePipelineCreateInfo compute_create_info;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_event {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
uint64_t event_storage;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_fence {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
bool signaled;
|
|
|
|
struct pipe_fence_handle *handle;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_semaphore {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
bool dummy;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_buffer {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_device * device;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDeviceSize size;
|
|
|
|
|
|
|
|
VkBufferUsageFlags usage;
|
|
|
|
VkDeviceSize offset;
|
|
|
|
|
|
|
|
struct pipe_resource *bo;
|
|
|
|
uint64_t total_size;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_buffer_view {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
VkFormat format;
|
|
|
|
enum pipe_format pformat;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_buffer *buffer;
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t offset;
|
|
|
|
uint64_t range;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_query_pool {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
VkQueryType type;
|
|
|
|
uint32_t count;
|
2020-11-13 07:06:31 +00:00
|
|
|
VkQueryPipelineStatisticFlags pipeline_stats;
|
2020-06-19 07:40:27 +01:00
|
|
|
enum pipe_query_type base_type;
|
|
|
|
struct pipe_query *queries[0];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_pool {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
VkAllocationCallbacks alloc;
|
|
|
|
struct list_head cmd_buffers;
|
|
|
|
struct list_head free_cmd_buffers;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
enum lvp_cmd_buffer_status {
|
|
|
|
LVP_CMD_BUFFER_STATUS_INVALID,
|
|
|
|
LVP_CMD_BUFFER_STATUS_INITIAL,
|
|
|
|
LVP_CMD_BUFFER_STATUS_RECORDING,
|
|
|
|
LVP_CMD_BUFFER_STATUS_EXECUTABLE,
|
|
|
|
LVP_CMD_BUFFER_STATUS_PENDING,
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_buffer {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct vk_object_base base;
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_device * device;
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
VkCommandBufferLevel level;
|
2020-09-29 20:29:04 +01:00
|
|
|
enum lvp_cmd_buffer_status status;
|
|
|
|
struct lvp_cmd_pool * pool;
|
2020-06-19 07:40:27 +01:00
|
|
|
struct list_head pool_link;
|
|
|
|
|
|
|
|
struct list_head cmds;
|
|
|
|
|
|
|
|
uint8_t push_constants[MAX_PUSH_CONSTANTS_SIZE];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* in same order and buffer building commands in spec. */
|
2020-09-29 20:29:04 +01:00
|
|
|
enum lvp_cmds {
|
|
|
|
LVP_CMD_BIND_PIPELINE,
|
|
|
|
LVP_CMD_SET_VIEWPORT,
|
|
|
|
LVP_CMD_SET_SCISSOR,
|
|
|
|
LVP_CMD_SET_LINE_WIDTH,
|
|
|
|
LVP_CMD_SET_DEPTH_BIAS,
|
|
|
|
LVP_CMD_SET_BLEND_CONSTANTS,
|
|
|
|
LVP_CMD_SET_DEPTH_BOUNDS,
|
|
|
|
LVP_CMD_SET_STENCIL_COMPARE_MASK,
|
|
|
|
LVP_CMD_SET_STENCIL_WRITE_MASK,
|
|
|
|
LVP_CMD_SET_STENCIL_REFERENCE,
|
|
|
|
LVP_CMD_BIND_DESCRIPTOR_SETS,
|
|
|
|
LVP_CMD_BIND_INDEX_BUFFER,
|
|
|
|
LVP_CMD_BIND_VERTEX_BUFFERS,
|
|
|
|
LVP_CMD_DRAW,
|
|
|
|
LVP_CMD_DRAW_INDEXED,
|
|
|
|
LVP_CMD_DRAW_INDIRECT,
|
|
|
|
LVP_CMD_DRAW_INDEXED_INDIRECT,
|
|
|
|
LVP_CMD_DISPATCH,
|
|
|
|
LVP_CMD_DISPATCH_INDIRECT,
|
|
|
|
LVP_CMD_COPY_BUFFER,
|
|
|
|
LVP_CMD_COPY_IMAGE,
|
|
|
|
LVP_CMD_BLIT_IMAGE,
|
|
|
|
LVP_CMD_COPY_BUFFER_TO_IMAGE,
|
|
|
|
LVP_CMD_COPY_IMAGE_TO_BUFFER,
|
|
|
|
LVP_CMD_UPDATE_BUFFER,
|
|
|
|
LVP_CMD_FILL_BUFFER,
|
|
|
|
LVP_CMD_CLEAR_COLOR_IMAGE,
|
|
|
|
LVP_CMD_CLEAR_DEPTH_STENCIL_IMAGE,
|
|
|
|
LVP_CMD_CLEAR_ATTACHMENTS,
|
|
|
|
LVP_CMD_RESOLVE_IMAGE,
|
|
|
|
LVP_CMD_SET_EVENT,
|
|
|
|
LVP_CMD_RESET_EVENT,
|
|
|
|
LVP_CMD_WAIT_EVENTS,
|
|
|
|
LVP_CMD_PIPELINE_BARRIER,
|
|
|
|
LVP_CMD_BEGIN_QUERY,
|
|
|
|
LVP_CMD_END_QUERY,
|
|
|
|
LVP_CMD_RESET_QUERY_POOL,
|
|
|
|
LVP_CMD_WRITE_TIMESTAMP,
|
|
|
|
LVP_CMD_COPY_QUERY_POOL_RESULTS,
|
|
|
|
LVP_CMD_PUSH_CONSTANTS,
|
|
|
|
LVP_CMD_BEGIN_RENDER_PASS,
|
|
|
|
LVP_CMD_NEXT_SUBPASS,
|
|
|
|
LVP_CMD_END_RENDER_PASS,
|
|
|
|
LVP_CMD_EXECUTE_COMMANDS,
|
2020-11-27 08:21:17 +00:00
|
|
|
LVP_CMD_DRAW_INDIRECT_COUNT,
|
|
|
|
LVP_CMD_DRAW_INDEXED_INDIRECT_COUNT,
|
2020-12-04 00:24:46 +00:00
|
|
|
LVP_CMD_PUSH_DESCRIPTOR_SET,
|
2020-12-08 04:48:44 +00:00
|
|
|
LVP_CMD_BIND_TRANSFORM_FEEDBACK_BUFFERS,
|
|
|
|
LVP_CMD_BEGIN_TRANSFORM_FEEDBACK,
|
|
|
|
LVP_CMD_END_TRANSFORM_FEEDBACK,
|
|
|
|
LVP_CMD_DRAW_INDIRECT_BYTE_COUNT,
|
2020-12-04 06:41:17 +00:00
|
|
|
LVP_CMD_BEGIN_CONDITIONAL_RENDERING,
|
|
|
|
LVP_CMD_END_CONDITIONAL_RENDERING,
|
2021-03-01 05:52:07 +00:00
|
|
|
LVP_CMD_SET_CULL_MODE,
|
|
|
|
LVP_CMD_SET_FRONT_FACE,
|
|
|
|
LVP_CMD_SET_PRIMITIVE_TOPOLOGY,
|
|
|
|
LVP_CMD_SET_DEPTH_TEST_ENABLE,
|
|
|
|
LVP_CMD_SET_DEPTH_WRITE_ENABLE,
|
|
|
|
LVP_CMD_SET_DEPTH_COMPARE_OP,
|
|
|
|
LVP_CMD_SET_DEPTH_BOUNDS_TEST_ENABLE,
|
|
|
|
LVP_CMD_SET_STENCIL_TEST_ENABLE,
|
|
|
|
LVP_CMD_SET_STENCIL_OP,
|
2020-09-29 20:29:04 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_bind_pipeline {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkPipelineBindPoint bind_point;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_pipeline *pipeline;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_set_viewport {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t first_viewport;
|
|
|
|
uint32_t viewport_count;
|
|
|
|
VkViewport viewports[16];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_set_scissor {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t first_scissor;
|
|
|
|
uint32_t scissor_count;
|
|
|
|
VkRect2D scissors[16];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_set_line_width {
|
2020-06-19 07:40:27 +01:00
|
|
|
float line_width;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_set_depth_bias {
|
2020-06-19 07:40:27 +01:00
|
|
|
float constant_factor;
|
|
|
|
float clamp;
|
|
|
|
float slope_factor;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_set_blend_constants {
|
2020-06-19 07:40:27 +01:00
|
|
|
float blend_constants[4];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_set_depth_bounds {
|
2020-06-19 07:40:27 +01:00
|
|
|
float min_depth;
|
|
|
|
float max_depth;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_set_stencil_vals {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkStencilFaceFlags face_mask;
|
|
|
|
uint32_t value;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_bind_descriptor_sets {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkPipelineBindPoint bind_point;
|
2021-02-11 01:53:24 +00:00
|
|
|
struct lvp_descriptor_set_layout *set_layout[MAX_SETS];
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t first;
|
|
|
|
uint32_t count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_descriptor_set **sets;
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t dynamic_offset_count;
|
|
|
|
const uint32_t *dynamic_offsets;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_bind_index_buffer {
|
|
|
|
const struct lvp_buffer *buffer;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDeviceSize offset;
|
|
|
|
VkIndexType index_type;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_bind_vertex_buffers {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t first;
|
|
|
|
uint32_t binding_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_buffer **buffers;
|
2020-06-19 07:40:27 +01:00
|
|
|
const VkDeviceSize *offsets;
|
2021-03-01 05:52:07 +00:00
|
|
|
const VkDeviceSize *sizes;
|
|
|
|
const VkDeviceSize *strides;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_draw {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t vertex_count;
|
|
|
|
uint32_t instance_count;
|
|
|
|
uint32_t first_vertex;
|
|
|
|
uint32_t first_instance;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_draw_indexed {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t index_count;
|
|
|
|
uint32_t instance_count;
|
|
|
|
uint32_t first_index;
|
|
|
|
uint32_t vertex_offset;
|
|
|
|
uint32_t first_instance;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_draw_indirect {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDeviceSize offset;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_buffer *buffer;
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t draw_count;
|
|
|
|
uint32_t stride;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_dispatch {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t x;
|
|
|
|
uint32_t y;
|
|
|
|
uint32_t z;
|
2020-12-18 02:29:59 +00:00
|
|
|
uint32_t base_x;
|
|
|
|
uint32_t base_y;
|
|
|
|
uint32_t base_z;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_dispatch_indirect {
|
|
|
|
const struct lvp_buffer *buffer;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDeviceSize offset;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_copy_buffer {
|
|
|
|
struct lvp_buffer *src;
|
|
|
|
struct lvp_buffer *dst;
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t region_count;
|
|
|
|
const VkBufferCopy *regions;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_copy_image {
|
|
|
|
struct lvp_image *src;
|
|
|
|
struct lvp_image *dst;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageLayout src_layout;
|
|
|
|
VkImageLayout dst_layout;
|
|
|
|
uint32_t region_count;
|
|
|
|
const VkImageCopy *regions;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_blit_image {
|
|
|
|
struct lvp_image *src;
|
|
|
|
struct lvp_image *dst;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageLayout src_layout;
|
|
|
|
VkImageLayout dst_layout;
|
|
|
|
uint32_t region_count;
|
|
|
|
const VkImageBlit *regions;
|
|
|
|
VkFilter filter;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_copy_buffer_to_image {
|
|
|
|
struct lvp_buffer *src;
|
|
|
|
struct lvp_image *dst;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageLayout dst_layout;
|
|
|
|
uint32_t region_count;
|
|
|
|
const VkBufferImageCopy *regions;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_copy_image_to_buffer {
|
|
|
|
struct lvp_image *src;
|
|
|
|
struct lvp_buffer *dst;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageLayout src_layout;
|
|
|
|
uint32_t region_count;
|
|
|
|
const VkBufferImageCopy *regions;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_update_buffer {
|
|
|
|
struct lvp_buffer *buffer;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDeviceSize offset;
|
|
|
|
VkDeviceSize data_size;
|
|
|
|
char data[0];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_fill_buffer {
|
|
|
|
struct lvp_buffer *buffer;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDeviceSize offset;
|
|
|
|
VkDeviceSize fill_size;
|
|
|
|
uint32_t data;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_clear_color_image {
|
|
|
|
struct lvp_image *image;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageLayout layout;
|
|
|
|
VkClearColorValue clear_val;
|
|
|
|
uint32_t range_count;
|
|
|
|
VkImageSubresourceRange *ranges;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_clear_ds_image {
|
|
|
|
struct lvp_image *image;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageLayout layout;
|
|
|
|
VkClearDepthStencilValue clear_val;
|
|
|
|
uint32_t range_count;
|
|
|
|
VkImageSubresourceRange *ranges;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_clear_attachments {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t attachment_count;
|
|
|
|
VkClearAttachment *attachments;
|
|
|
|
uint32_t rect_count;
|
|
|
|
VkClearRect *rects;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_resolve_image {
|
|
|
|
struct lvp_image *src;
|
|
|
|
struct lvp_image *dst;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageLayout src_layout;
|
|
|
|
VkImageLayout dst_layout;
|
|
|
|
uint32_t region_count;
|
|
|
|
VkImageResolve *regions;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_event_set {
|
|
|
|
struct lvp_event *event;
|
2020-06-19 07:40:27 +01:00
|
|
|
bool value;
|
|
|
|
bool flush;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_wait_events {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t event_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_event **events;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkPipelineStageFlags src_stage_mask;
|
|
|
|
VkPipelineStageFlags dst_stage_mask;
|
|
|
|
uint32_t memory_barrier_count;
|
|
|
|
VkMemoryBarrier *memory_barriers;
|
|
|
|
uint32_t buffer_memory_barrier_count;
|
|
|
|
VkBufferMemoryBarrier *buffer_memory_barriers;
|
|
|
|
uint32_t image_memory_barrier_count;
|
|
|
|
VkImageMemoryBarrier *image_memory_barriers;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_pipeline_barrier {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkPipelineStageFlags src_stage_mask;
|
|
|
|
VkPipelineStageFlags dst_stage_mask;
|
|
|
|
bool by_region;
|
|
|
|
uint32_t memory_barrier_count;
|
|
|
|
VkMemoryBarrier *memory_barriers;
|
|
|
|
uint32_t buffer_memory_barrier_count;
|
|
|
|
VkBufferMemoryBarrier *buffer_memory_barriers;
|
|
|
|
uint32_t image_memory_barrier_count;
|
|
|
|
VkImageMemoryBarrier *image_memory_barriers;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_query_cmd {
|
|
|
|
struct lvp_query_pool *pool;
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t query;
|
|
|
|
uint32_t index;
|
|
|
|
bool precise;
|
|
|
|
bool flush;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_copy_query_pool_results {
|
|
|
|
struct lvp_query_pool *pool;
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t first_query;
|
|
|
|
uint32_t query_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_buffer *dst;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkDeviceSize dst_offset;
|
|
|
|
VkDeviceSize stride;
|
|
|
|
VkQueryResultFlags flags;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_push_constants {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkShaderStageFlags stage;
|
|
|
|
uint32_t offset;
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t val[1];
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_attachment_state {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkImageAspectFlags pending_clear_aspects;
|
|
|
|
VkClearValue clear_value;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_begin_render_pass {
|
|
|
|
struct lvp_framebuffer *framebuffer;
|
|
|
|
struct lvp_render_pass *render_pass;
|
2020-06-19 07:40:27 +01:00
|
|
|
VkRect2D render_area;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_attachment_state *attachments;
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_next_subpass {
|
2020-06-19 07:40:27 +01:00
|
|
|
VkSubpassContents contents;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_execute_commands {
|
2020-06-19 07:40:27 +01:00
|
|
|
uint32_t command_buffer_count;
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_buffer *cmd_buffers[0];
|
2020-06-19 07:40:27 +01:00
|
|
|
};
|
|
|
|
|
2020-11-27 08:21:17 +00:00
|
|
|
struct lvp_cmd_draw_indirect_count {
|
|
|
|
VkDeviceSize offset;
|
|
|
|
struct lvp_buffer *buffer;
|
|
|
|
VkDeviceSize count_buffer_offset;
|
|
|
|
struct lvp_buffer *count_buffer;
|
|
|
|
uint32_t max_draw_count;
|
|
|
|
uint32_t stride;
|
|
|
|
};
|
|
|
|
|
2020-12-04 00:24:46 +00:00
|
|
|
struct lvp_write_descriptor {
|
|
|
|
uint32_t dst_binding;
|
|
|
|
uint32_t dst_array_element;
|
|
|
|
uint32_t descriptor_count;
|
|
|
|
VkDescriptorType descriptor_type;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_push_descriptor_set {
|
|
|
|
VkPipelineBindPoint bind_point;
|
|
|
|
struct lvp_pipeline_layout *layout;
|
|
|
|
uint32_t set;
|
|
|
|
uint32_t descriptor_write_count;
|
|
|
|
struct lvp_write_descriptor *descriptors;
|
|
|
|
union lvp_descriptor_info *infos;
|
|
|
|
};
|
|
|
|
|
2020-12-08 04:48:44 +00:00
|
|
|
struct lvp_cmd_bind_transform_feedback_buffers {
|
|
|
|
uint32_t first_binding;
|
|
|
|
uint32_t binding_count;
|
|
|
|
struct lvp_buffer **buffers;
|
|
|
|
VkDeviceSize *offsets;
|
|
|
|
VkDeviceSize *sizes;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_begin_transform_feedback {
|
|
|
|
uint32_t first_counter_buffer;
|
|
|
|
uint32_t counter_buffer_count;
|
|
|
|
struct lvp_buffer **counter_buffers;
|
|
|
|
VkDeviceSize *counter_buffer_offsets;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_end_transform_feedback {
|
|
|
|
uint32_t first_counter_buffer;
|
|
|
|
uint32_t counter_buffer_count;
|
|
|
|
struct lvp_buffer **counter_buffers;
|
|
|
|
VkDeviceSize *counter_buffer_offsets;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_draw_indirect_byte_count {
|
|
|
|
uint32_t instance_count;
|
|
|
|
uint32_t first_instance;
|
|
|
|
struct lvp_buffer *counter_buffer;
|
|
|
|
VkDeviceSize counter_buffer_offset;
|
|
|
|
uint32_t counter_offset;
|
|
|
|
uint32_t vertex_stride;
|
|
|
|
};
|
|
|
|
|
2020-12-04 06:41:17 +00:00
|
|
|
struct lvp_cmd_begin_conditional_rendering {
|
|
|
|
struct lvp_buffer *buffer;
|
|
|
|
VkDeviceSize offset;
|
|
|
|
bool inverted;
|
|
|
|
};
|
|
|
|
|
2021-03-01 05:52:07 +00:00
|
|
|
struct lvp_cmd_set_cull_mode {
|
|
|
|
VkCullModeFlags cull_mode;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_front_face {
|
|
|
|
VkFrontFace front_face;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_primitive_topology {
|
|
|
|
VkPrimitiveTopology prim;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_depth_test_enable {
|
|
|
|
VkBool32 depth_test_enable;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_depth_write_enable {
|
|
|
|
VkBool32 depth_write_enable;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_depth_bounds_test_enable {
|
|
|
|
VkBool32 depth_bounds_test_enable;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_depth_compare_op {
|
|
|
|
VkCompareOp depth_op;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_stencil_test_enable {
|
|
|
|
VkBool32 stencil_test_enable;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct lvp_cmd_set_stencil_op {
|
|
|
|
VkStencilFaceFlags face_mask;
|
|
|
|
VkStencilOp fail_op;
|
|
|
|
VkStencilOp pass_op;
|
|
|
|
VkStencilOp depth_fail_op;
|
|
|
|
VkCompareOp compare_op;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_buffer_entry {
|
2020-06-19 07:40:27 +01:00
|
|
|
struct list_head cmd_link;
|
|
|
|
uint32_t cmd_type;
|
|
|
|
union {
|
2020-09-29 20:29:04 +01:00
|
|
|
struct lvp_cmd_bind_pipeline pipeline;
|
|
|
|
struct lvp_cmd_set_viewport set_viewport;
|
|
|
|
struct lvp_cmd_set_scissor set_scissor;
|
|
|
|
struct lvp_cmd_set_line_width set_line_width;
|
|
|
|
struct lvp_cmd_set_depth_bias set_depth_bias;
|
|
|
|
struct lvp_cmd_set_blend_constants set_blend_constants;
|
|
|
|
struct lvp_cmd_set_depth_bounds set_depth_bounds;
|
|
|
|
struct lvp_cmd_set_stencil_vals stencil_vals;
|
|
|
|
struct lvp_cmd_bind_descriptor_sets descriptor_sets;
|
|
|
|
struct lvp_cmd_bind_vertex_buffers vertex_buffers;
|
|
|
|
struct lvp_cmd_bind_index_buffer index_buffer;
|
|
|
|
struct lvp_cmd_draw draw;
|
|
|
|
struct lvp_cmd_draw_indexed draw_indexed;
|
|
|
|
struct lvp_cmd_draw_indirect draw_indirect;
|
|
|
|
struct lvp_cmd_dispatch dispatch;
|
|
|
|
struct lvp_cmd_dispatch_indirect dispatch_indirect;
|
|
|
|
struct lvp_cmd_copy_buffer copy_buffer;
|
|
|
|
struct lvp_cmd_copy_image copy_image;
|
|
|
|
struct lvp_cmd_blit_image blit_image;
|
|
|
|
struct lvp_cmd_copy_buffer_to_image buffer_to_img;
|
|
|
|
struct lvp_cmd_copy_image_to_buffer img_to_buffer;
|
|
|
|
struct lvp_cmd_update_buffer update_buffer;
|
|
|
|
struct lvp_cmd_fill_buffer fill_buffer;
|
|
|
|
struct lvp_cmd_clear_color_image clear_color_image;
|
|
|
|
struct lvp_cmd_clear_ds_image clear_ds_image;
|
|
|
|
struct lvp_cmd_clear_attachments clear_attachments;
|
|
|
|
struct lvp_cmd_resolve_image resolve_image;
|
|
|
|
struct lvp_cmd_event_set event_set;
|
|
|
|
struct lvp_cmd_wait_events wait_events;
|
|
|
|
struct lvp_cmd_pipeline_barrier pipeline_barrier;
|
|
|
|
struct lvp_cmd_query_cmd query;
|
|
|
|
struct lvp_cmd_copy_query_pool_results copy_query_pool_results;
|
|
|
|
struct lvp_cmd_push_constants push_constants;
|
|
|
|
struct lvp_cmd_begin_render_pass begin_render_pass;
|
|
|
|
struct lvp_cmd_next_subpass next_subpass;
|
|
|
|
struct lvp_cmd_execute_commands execute_commands;
|
2020-11-27 08:21:17 +00:00
|
|
|
struct lvp_cmd_draw_indirect_count draw_indirect_count;
|
2020-12-04 00:24:46 +00:00
|
|
|
struct lvp_cmd_push_descriptor_set push_descriptor_set;
|
2020-12-08 04:48:44 +00:00
|
|
|
struct lvp_cmd_bind_transform_feedback_buffers bind_transform_feedback_buffers;
|
|
|
|
struct lvp_cmd_begin_transform_feedback begin_transform_feedback;
|
|
|
|
struct lvp_cmd_end_transform_feedback end_transform_feedback;
|
|
|
|
struct lvp_cmd_draw_indirect_byte_count draw_indirect_byte_count;
|
2020-12-04 06:41:17 +00:00
|
|
|
struct lvp_cmd_begin_conditional_rendering begin_conditional_rendering;
|
2021-03-01 05:52:07 +00:00
|
|
|
struct lvp_cmd_set_cull_mode set_cull_mode;
|
|
|
|
struct lvp_cmd_set_front_face set_front_face;
|
|
|
|
struct lvp_cmd_set_primitive_topology set_primitive_topology;
|
|
|
|
struct lvp_cmd_set_depth_test_enable set_depth_test_enable;
|
|
|
|
struct lvp_cmd_set_depth_write_enable set_depth_write_enable;
|
|
|
|
struct lvp_cmd_set_depth_compare_op set_depth_compare_op;
|
|
|
|
struct lvp_cmd_set_depth_bounds_test_enable set_depth_bounds_test_enable;
|
|
|
|
struct lvp_cmd_set_stencil_test_enable set_stencil_test_enable;
|
|
|
|
struct lvp_cmd_set_stencil_op set_stencil_op;
|
2020-06-19 07:40:27 +01:00
|
|
|
} u;
|
|
|
|
};
|
|
|
|
|
2020-09-29 20:29:04 +01:00
|
|
|
VkResult lvp_execute_cmds(struct lvp_device *device,
|
|
|
|
struct lvp_queue *queue,
|
|
|
|
struct lvp_fence *fence,
|
|
|
|
struct lvp_cmd_buffer *cmd_buffer);
|
2020-06-19 07:40:27 +01:00
|
|
|
|
|
|
|
enum pipe_format vk_format_to_pipe(VkFormat format);
|
|
|
|
|
|
|
|
static inline VkImageAspectFlags
|
|
|
|
vk_format_aspects(VkFormat format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case VK_FORMAT_UNDEFINED:
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
case VK_FORMAT_S8_UINT:
|
|
|
|
return VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
|
|
|
|
|
case VK_FORMAT_D16_UNORM_S8_UINT:
|
|
|
|
case VK_FORMAT_D24_UNORM_S8_UINT:
|
|
|
|
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
|
|
|
return VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
|
|
|
|
|
case VK_FORMAT_D16_UNORM:
|
|
|
|
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
|
|
|
case VK_FORMAT_D32_SFLOAT:
|
|
|
|
return VK_IMAGE_ASPECT_DEPTH_BIT;
|
|
|
|
|
|
|
|
default:
|
|
|
|
return VK_IMAGE_ASPECT_COLOR_BIT;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|