2019-11-25 15:29:12 +00:00
|
|
|
/*
|
|
|
|
* Copyright © 2019 Raspberry Pi
|
|
|
|
*
|
|
|
|
* based in part on anv driver which is:
|
|
|
|
* Copyright © 2015 Intel Corporation
|
|
|
|
*
|
|
|
|
* based in part on radv driver which is:
|
|
|
|
* Copyright © 2016 Red Hat.
|
|
|
|
* Copyright © 2016 Bas Nieuwenhuizen
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
#ifndef V3DV_PRIVATE_H
|
|
|
|
#define V3DV_PRIVATE_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#include <vulkan/vk_icd.h>
|
2020-01-15 07:48:07 +00:00
|
|
|
#include <vk_enum_to_str.h>
|
2019-11-25 15:29:12 +00:00
|
|
|
|
2019-11-29 12:55:38 +00:00
|
|
|
#include <xf86drm.h>
|
|
|
|
|
2019-11-27 10:49:12 +00:00
|
|
|
#ifdef HAVE_VALGRIND
|
|
|
|
#include <valgrind/valgrind.h>
|
|
|
|
#include <valgrind/memcheck.h>
|
|
|
|
#define VG(x) x
|
|
|
|
#else
|
|
|
|
#define VG(x) ((void)0)
|
|
|
|
#endif
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
#include "common/v3d_device_info.h"
|
2019-12-03 11:54:30 +00:00
|
|
|
#include "common/v3d_limits.h"
|
2019-11-25 15:29:12 +00:00
|
|
|
|
2019-12-02 12:59:04 +00:00
|
|
|
#include "compiler/shader_enums.h"
|
|
|
|
#include "compiler/spirv/nir_spirv.h"
|
|
|
|
|
|
|
|
#include "compiler/v3d_compiler.h"
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
#include "vk_debug_report.h"
|
2019-12-13 09:48:12 +00:00
|
|
|
#include "util/set.h"
|
|
|
|
#include "util/hash_table.h"
|
2019-11-25 15:29:12 +00:00
|
|
|
#include "util/xmlconfig.h"
|
|
|
|
|
|
|
|
#include "v3dv_entrypoints.h"
|
|
|
|
#include "v3dv_extensions.h"
|
2019-12-10 11:00:49 +00:00
|
|
|
#include "v3dv_bo.h"
|
2019-11-25 15:29:12 +00:00
|
|
|
|
2020-04-20 12:24:09 +01:00
|
|
|
#include "drm-uapi/v3d_drm.h"
|
|
|
|
|
2019-12-11 09:10:27 +00:00
|
|
|
/* FIXME: hooks for the packet definition functions. */
|
|
|
|
static inline void
|
|
|
|
pack_emit_reloc(void *cl, const void *reloc) {}
|
|
|
|
|
2019-12-13 09:48:12 +00:00
|
|
|
#define __gen_user_data struct v3dv_cl
|
|
|
|
#define __gen_address_type struct v3dv_cl_reloc
|
|
|
|
#define __gen_address_offset(reloc) (((reloc)->bo ? (reloc)->bo->offset : 0) + \
|
|
|
|
(reloc)->offset)
|
|
|
|
#define __gen_emit_reloc cl_pack_emit_reloc
|
|
|
|
#define __gen_unpack_address(cl, s, e) __unpack_address(cl, s, e)
|
2019-12-11 09:10:27 +00:00
|
|
|
#include "v3dv_cl.h"
|
|
|
|
|
2019-11-27 10:49:49 +00:00
|
|
|
#include "vk_alloc.h"
|
2019-11-29 12:55:38 +00:00
|
|
|
#include "simulator/v3d_simulator.h"
|
2019-11-27 10:49:49 +00:00
|
|
|
|
2019-12-02 12:59:04 +00:00
|
|
|
|
2019-12-03 11:54:30 +00:00
|
|
|
/* FIXME: pipe_box from Gallium. Needed for some v3d_tiling.c functions.
|
|
|
|
* In the future we might want to drop that depedency, but for now it is
|
|
|
|
* good enough.
|
|
|
|
*/
|
|
|
|
#include "util/u_box.h"
|
2020-01-16 10:14:17 +00:00
|
|
|
#include "wsi_common.h"
|
2019-12-03 11:54:30 +00:00
|
|
|
|
2020-01-05 00:51:04 +00:00
|
|
|
#include "broadcom/cle/v3dx_pack.h"
|
|
|
|
|
2019-12-03 11:54:30 +00:00
|
|
|
/* A non-fatal assert. Useful for debugging. */
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define v3dv_assert(x) ({ \
|
|
|
|
if (unlikely(!(x))) \
|
|
|
|
fprintf(stderr, "%s:%d ASSERT: %s", __FILE__, __LINE__, #x); \
|
|
|
|
})
|
|
|
|
#else
|
|
|
|
#define v3dv_assert(x)
|
|
|
|
#endif
|
|
|
|
|
2020-03-18 09:41:19 +00:00
|
|
|
#define perf_debug(...) do { \
|
|
|
|
if (unlikely(V3D_DEBUG & V3D_DEBUG_PERF)) \
|
|
|
|
fprintf(stderr, __VA_ARGS__); \
|
|
|
|
} while (0)
|
|
|
|
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
#define for_each_bit(b, dword) \
|
|
|
|
for (uint32_t __dword = (dword); \
|
|
|
|
(b) = __builtin_ffs(__dword) - 1, __dword; __dword &= ~(1 << (b)))
|
|
|
|
|
2019-12-28 11:11:48 +00:00
|
|
|
#define typed_memcpy(dest, src, count) ({ \
|
|
|
|
STATIC_ASSERT(sizeof(*src) == sizeof(*dest)); \
|
|
|
|
memcpy((dest), (src), (count) * sizeof(*(src))); \
|
|
|
|
})
|
|
|
|
|
2020-01-14 08:48:19 +00:00
|
|
|
#define NSEC_PER_SEC 1000000000ull
|
|
|
|
|
2019-12-28 10:59:32 +00:00
|
|
|
/* From vulkan spec "If the multiple viewports feature is not enabled,
|
|
|
|
* scissorCount must be 1", ditto for viewportCount. For now we don't support
|
|
|
|
* that feature.
|
|
|
|
*/
|
|
|
|
#define MAX_VIEWPORTS 1
|
|
|
|
#define MAX_SCISSORS 1
|
|
|
|
|
2020-07-31 00:11:39 +01:00
|
|
|
#define MAX_VBS 16
|
|
|
|
#define MAX_VERTEX_ATTRIBS 16
|
|
|
|
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
#define MAX_SETS 16
|
|
|
|
|
2020-09-11 22:26:07 +01:00
|
|
|
#define MAX_PUSH_CONSTANTS_SIZE 128
|
|
|
|
|
2020-02-24 10:32:57 +00:00
|
|
|
#define MAX_DYNAMIC_UNIFORM_BUFFERS 16
|
|
|
|
#define MAX_DYNAMIC_STORAGE_BUFFERS 8
|
|
|
|
#define MAX_DYNAMIC_BUFFERS \
|
|
|
|
(MAX_DYNAMIC_UNIFORM_BUFFERS + MAX_DYNAMIC_STORAGE_BUFFERS)
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
struct v3dv_instance;
|
|
|
|
|
2019-11-29 12:55:38 +00:00
|
|
|
#ifdef USE_V3D_SIMULATOR
|
|
|
|
#define using_v3d_simulator true
|
|
|
|
#else
|
|
|
|
#define using_v3d_simulator false
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct v3d_simulator_file;
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
struct v3dv_physical_device {
|
|
|
|
VK_LOADER_DATA _loader_data;
|
|
|
|
|
|
|
|
struct v3dv_instance *instance;
|
|
|
|
|
|
|
|
struct v3dv_device_extension_table supported_extensions;
|
|
|
|
struct v3dv_physical_device_dispatch_table dispatch;
|
|
|
|
|
2019-11-29 08:01:56 +00:00
|
|
|
char *name;
|
2020-01-23 10:59:28 +00:00
|
|
|
int32_t render_fd;
|
2020-01-20 09:45:06 +00:00
|
|
|
int32_t display_fd;
|
2019-11-28 08:48:29 +00:00
|
|
|
uint8_t pipeline_cache_uuid[VK_UUID_SIZE];
|
|
|
|
|
2020-01-16 10:14:17 +00:00
|
|
|
struct wsi_device wsi_device;
|
|
|
|
|
2019-12-04 09:25:21 +00:00
|
|
|
VkPhysicalDeviceMemoryProperties memory;
|
|
|
|
|
2019-11-29 12:55:38 +00:00
|
|
|
struct v3d_device_info devinfo;
|
|
|
|
|
|
|
|
struct v3d_simulator_file *sim_file;
|
2019-12-02 12:59:04 +00:00
|
|
|
|
|
|
|
const struct v3d_compiler *compiler;
|
|
|
|
uint32_t next_program_id;
|
2020-01-10 10:31:51 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
bool merge_jobs;
|
|
|
|
} options;
|
2019-11-25 15:29:12 +00:00
|
|
|
};
|
|
|
|
|
2020-01-16 10:14:17 +00:00
|
|
|
VkResult v3dv_wsi_init(struct v3dv_physical_device *physical_device);
|
|
|
|
void v3dv_wsi_finish(struct v3dv_physical_device *physical_device);
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
struct v3dv_app_info {
|
|
|
|
const char *app_name;
|
|
|
|
uint32_t app_version;
|
|
|
|
const char *engine_name;
|
|
|
|
uint32_t engine_version;
|
|
|
|
uint32_t api_version;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_instance {
|
|
|
|
VK_LOADER_DATA _loader_data;
|
|
|
|
|
|
|
|
VkAllocationCallbacks alloc;
|
|
|
|
|
|
|
|
struct v3dv_app_info app_info;
|
|
|
|
|
|
|
|
struct v3dv_instance_extension_table enabled_extensions;
|
|
|
|
struct v3dv_instance_dispatch_table dispatch;
|
|
|
|
struct v3dv_device_dispatch_table device_dispatch;
|
|
|
|
|
|
|
|
int physicalDeviceCount;
|
|
|
|
struct v3dv_physical_device physicalDevice;
|
|
|
|
|
|
|
|
struct vk_debug_report_instance debug_report_callbacks;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_queue {
|
|
|
|
VK_LOADER_DATA _loader_data;
|
|
|
|
|
|
|
|
struct v3dv_device *device;
|
|
|
|
|
|
|
|
VkDeviceQueueCreateFlags flags;
|
|
|
|
};
|
|
|
|
|
2020-03-31 12:06:55 +01:00
|
|
|
struct v3dv_meta_color_clear_pipeline {
|
|
|
|
VkPipeline pipeline;
|
|
|
|
VkRenderPass pass;
|
|
|
|
};
|
|
|
|
|
2020-04-21 13:09:23 +01:00
|
|
|
struct v3dv_meta_blit_pipeline {
|
|
|
|
VkPipeline pipeline;
|
|
|
|
VkRenderPass pass;
|
|
|
|
};
|
|
|
|
|
2020-05-12 09:39:54 +01:00
|
|
|
#define V3DV_META_BLIT_CACHE_KEY_SIZE (3 * sizeof(uint32_t))
|
2020-04-30 14:27:02 +01:00
|
|
|
|
2019-11-29 11:44:40 +00:00
|
|
|
struct v3dv_device {
|
|
|
|
VK_LOADER_DATA _loader_data;
|
|
|
|
|
|
|
|
VkAllocationCallbacks alloc;
|
|
|
|
|
|
|
|
struct v3dv_instance *instance;
|
|
|
|
|
|
|
|
struct v3dv_device_extension_table enabled_extensions;
|
|
|
|
struct v3dv_device_dispatch_table dispatch;
|
|
|
|
|
2020-01-23 10:59:28 +00:00
|
|
|
int32_t render_fd;
|
2020-01-20 09:45:06 +00:00
|
|
|
int32_t display_fd;
|
2019-11-29 11:44:40 +00:00
|
|
|
struct v3d_device_info devinfo;
|
|
|
|
struct v3dv_queue queue;
|
|
|
|
|
2020-01-13 07:53:26 +00:00
|
|
|
/* Last command buffer submitted on this device. We use this to check if
|
|
|
|
* the GPU is idle.
|
|
|
|
*/
|
|
|
|
uint32_t last_job_sync;
|
2020-03-31 11:59:44 +01:00
|
|
|
|
|
|
|
/* Resources used for meta operations */
|
|
|
|
struct {
|
2020-03-31 12:06:55 +01:00
|
|
|
mtx_t mtx;
|
2020-03-31 11:59:44 +01:00
|
|
|
struct {
|
|
|
|
VkPipelineLayout playout;
|
2020-03-31 12:06:55 +01:00
|
|
|
struct hash_table *cache; /* v3dv_meta_color_clear_pipeline */
|
2020-03-31 11:59:44 +01:00
|
|
|
} color_clear;
|
2020-04-21 13:09:23 +01:00
|
|
|
struct {
|
|
|
|
VkDescriptorSetLayout dslayout;
|
|
|
|
VkPipelineLayout playout;
|
2020-04-28 12:36:37 +01:00
|
|
|
struct hash_table *cache[3]; /* v3dv_meta_blit_pipeline for 1d, 2d, 3d */
|
2020-04-21 13:09:23 +01:00
|
|
|
} blit;
|
2020-03-31 11:59:44 +01:00
|
|
|
} meta;
|
2019-11-29 11:44:40 +00:00
|
|
|
};
|
|
|
|
|
2019-11-27 21:08:51 +00:00
|
|
|
struct v3dv_device_memory {
|
2019-12-12 10:02:04 +00:00
|
|
|
struct v3dv_bo *bo;
|
2019-12-04 09:39:01 +00:00
|
|
|
const VkMemoryType *type;
|
2019-11-27 21:08:51 +00:00
|
|
|
};
|
|
|
|
|
2019-12-02 10:25:28 +00:00
|
|
|
#define V3D_OUTPUT_IMAGE_FORMAT_NO 255
|
2020-02-10 08:42:29 +00:00
|
|
|
#define TEXTURE_DATA_FORMAT_NO 255
|
2019-12-02 10:25:28 +00:00
|
|
|
|
|
|
|
struct v3dv_format {
|
|
|
|
bool supported;
|
|
|
|
|
|
|
|
/* One of V3D33_OUTPUT_IMAGE_FORMAT_*, or OUTPUT_IMAGE_FORMAT_NO */
|
|
|
|
uint8_t rt_type;
|
|
|
|
|
|
|
|
/* One of V3D33_TEXTURE_DATA_FORMAT_*. */
|
|
|
|
uint8_t tex_type;
|
|
|
|
|
|
|
|
/* Swizzle to apply to the RGBA shader output for storing to the tile
|
|
|
|
* buffer, to the RGBA tile buffer to produce shader input (for
|
|
|
|
* blending), and for turning the rgba8888 texture sampler return
|
|
|
|
* value into shader rgba values.
|
|
|
|
*/
|
|
|
|
uint8_t swizzle[4];
|
|
|
|
|
|
|
|
/* Whether the return value is 16F/I/UI or 32F/I/UI. */
|
|
|
|
uint8_t return_size;
|
2020-04-14 23:56:31 +01:00
|
|
|
|
|
|
|
/* If the format supports (linear) filtering when texturing. */
|
|
|
|
bool supports_filtering;
|
2019-12-02 10:25:28 +00:00
|
|
|
};
|
|
|
|
|
2019-12-03 11:54:30 +00:00
|
|
|
/**
|
|
|
|
* Tiling mode enum used for v3d_resource.c, which maps directly to the Memory
|
|
|
|
* Format field of render target and Z/Stencil config.
|
|
|
|
*/
|
|
|
|
enum v3d_tiling_mode {
|
|
|
|
/* Untiled resources. Not valid as texture inputs. */
|
|
|
|
VC5_TILING_RASTER,
|
|
|
|
|
|
|
|
/* Single line of u-tiles. */
|
|
|
|
VC5_TILING_LINEARTILE,
|
|
|
|
|
|
|
|
/* Departure from standard 4-UIF block column format. */
|
|
|
|
VC5_TILING_UBLINEAR_1_COLUMN,
|
|
|
|
|
|
|
|
/* Departure from standard 4-UIF block column format. */
|
|
|
|
VC5_TILING_UBLINEAR_2_COLUMN,
|
|
|
|
|
|
|
|
/* Normal tiling format: grouped in 4x4 UIFblocks, each of which is
|
|
|
|
* split 2x2 into utiles.
|
|
|
|
*/
|
|
|
|
VC5_TILING_UIF_NO_XOR,
|
|
|
|
|
|
|
|
/* Normal tiling format: grouped in 4x4 UIFblocks, each of which is
|
|
|
|
* split 2x2 into utiles.
|
|
|
|
*/
|
|
|
|
VC5_TILING_UIF_XOR,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3d_resource_slice {
|
|
|
|
uint32_t offset;
|
|
|
|
uint32_t stride;
|
|
|
|
uint32_t padded_height;
|
|
|
|
/* Size of a single pane of the slice. For 3D textures, there will be
|
|
|
|
* a number of panes equal to the minified, power-of-two-aligned
|
|
|
|
* depth.
|
|
|
|
*/
|
|
|
|
uint32_t size;
|
|
|
|
uint8_t ub_pad;
|
|
|
|
enum v3d_tiling_mode tiling;
|
|
|
|
uint32_t padded_height_of_output_image_in_uif_blocks;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_image {
|
|
|
|
VkImageType type;
|
|
|
|
VkImageAspectFlags aspects;
|
|
|
|
|
|
|
|
VkExtent3D extent;
|
|
|
|
uint32_t levels;
|
|
|
|
uint32_t array_size;
|
|
|
|
uint32_t samples;
|
|
|
|
VkImageUsageFlags usage;
|
|
|
|
VkImageCreateFlags create_flags;
|
|
|
|
VkImageTiling tiling;
|
|
|
|
|
|
|
|
VkFormat vk_format;
|
|
|
|
const struct v3dv_format *format;
|
|
|
|
|
|
|
|
uint32_t cpp;
|
|
|
|
|
|
|
|
uint64_t drm_format_mod;
|
|
|
|
bool tiled;
|
|
|
|
|
|
|
|
struct v3d_resource_slice slices[V3D_MAX_MIP_LEVELS];
|
|
|
|
uint32_t size; /* Total size in bytes */
|
|
|
|
uint32_t cube_map_stride;
|
|
|
|
uint32_t alignment;
|
2019-12-05 09:36:24 +00:00
|
|
|
|
|
|
|
struct v3dv_device_memory *mem;
|
|
|
|
VkDeviceSize mem_offset;
|
2019-12-03 11:54:30 +00:00
|
|
|
};
|
|
|
|
|
2020-04-28 12:36:37 +01:00
|
|
|
VkImageViewType v3dv_image_type_to_view_type(VkImageType type);
|
|
|
|
|
2019-12-05 11:35:02 +00:00
|
|
|
struct v3dv_image_view {
|
|
|
|
const struct v3dv_image *image;
|
|
|
|
VkImageAspectFlags aspects;
|
|
|
|
VkExtent3D extent;
|
|
|
|
|
|
|
|
VkFormat vk_format;
|
|
|
|
const struct v3dv_format *format;
|
|
|
|
bool swap_rb;
|
|
|
|
uint32_t internal_bpp;
|
|
|
|
uint32_t internal_type;
|
|
|
|
|
2019-12-16 13:21:29 +00:00
|
|
|
uint32_t base_level;
|
2020-03-29 15:29:55 +01:00
|
|
|
uint32_t max_level;
|
2019-12-05 11:35:02 +00:00
|
|
|
uint32_t first_layer;
|
|
|
|
uint32_t last_layer;
|
|
|
|
uint32_t offset;
|
2020-03-29 15:29:55 +01:00
|
|
|
|
|
|
|
/* Precomputed (composed from createinfo->components and formar swizzle)
|
|
|
|
* swizzles to pass in to the shader key.
|
|
|
|
*
|
|
|
|
* FIXME: this is also a candidate to be included on the descriptor info.
|
|
|
|
*/
|
|
|
|
uint8_t swizzle[4];
|
|
|
|
|
|
|
|
/* FIXME: here we store the packet TEXTURE_SHADER_STATE, that is referenced
|
|
|
|
* as part of the tmu configuration, and the content is set per sampler. A
|
|
|
|
* possible perf improvement, to avoid bo fragmentation, would be to save
|
|
|
|
* the state as static, have the bo as part of the descriptor (booked from
|
|
|
|
* the descriptor pools), and then copy this content to the descriptor bo
|
|
|
|
* on UpdateDescriptor. This also makes sense because not all the images
|
|
|
|
* are used as textures.
|
|
|
|
*/
|
|
|
|
struct v3dv_bo *texture_shader_state;
|
2019-12-05 11:35:02 +00:00
|
|
|
};
|
|
|
|
|
2019-12-17 07:48:10 +00:00
|
|
|
uint32_t v3dv_layer_offset(const struct v3dv_image *image, uint32_t level, uint32_t layer);
|
|
|
|
|
2019-12-09 09:07:36 +00:00
|
|
|
struct v3dv_buffer {
|
|
|
|
VkDeviceSize size;
|
|
|
|
VkBufferUsageFlags usage;
|
|
|
|
uint32_t alignment;
|
2019-12-09 09:40:32 +00:00
|
|
|
|
|
|
|
struct v3dv_device_memory *mem;
|
|
|
|
VkDeviceSize mem_offset;
|
2019-12-09 09:07:36 +00:00
|
|
|
};
|
|
|
|
|
2020-02-26 08:07:42 +00:00
|
|
|
struct v3dv_buffer_view {
|
|
|
|
const struct v3dv_buffer *buffer;
|
|
|
|
|
|
|
|
VkFormat vk_format;
|
|
|
|
const struct v3dv_format *format;
|
|
|
|
uint32_t internal_bpp;
|
|
|
|
uint32_t internal_type;
|
|
|
|
|
|
|
|
uint32_t offset;
|
|
|
|
uint32_t size;
|
|
|
|
uint32_t num_elements;
|
|
|
|
};
|
|
|
|
|
2019-12-09 11:16:35 +00:00
|
|
|
struct v3dv_subpass_attachment {
|
|
|
|
uint32_t attachment;
|
|
|
|
VkImageLayout layout;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_subpass {
|
|
|
|
uint32_t input_count;
|
|
|
|
struct v3dv_subpass_attachment *input_attachments;
|
|
|
|
|
|
|
|
uint32_t color_count;
|
|
|
|
struct v3dv_subpass_attachment *color_attachments;
|
|
|
|
struct v3dv_subpass_attachment *resolve_attachments;
|
|
|
|
|
|
|
|
struct v3dv_subpass_attachment ds_attachment;
|
2020-03-18 09:41:19 +00:00
|
|
|
|
|
|
|
bool has_srgb_rt;
|
2019-12-09 11:16:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_render_pass_attachment {
|
|
|
|
VkAttachmentDescription desc;
|
2020-01-28 15:53:54 +00:00
|
|
|
uint32_t first_subpass;
|
|
|
|
uint32_t last_subpass;
|
2019-12-09 11:16:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_render_pass {
|
|
|
|
uint32_t attachment_count;
|
|
|
|
struct v3dv_render_pass_attachment *attachments;
|
|
|
|
|
|
|
|
uint32_t subpass_count;
|
|
|
|
struct v3dv_subpass *subpasses;
|
|
|
|
|
|
|
|
struct v3dv_subpass_attachment *subpass_attachments;
|
|
|
|
};
|
|
|
|
|
2020-04-06 08:25:28 +01:00
|
|
|
void v3dv_subpass_get_granularity(struct v3dv_render_pass *pass,
|
|
|
|
uint32_t subpass_idx,
|
|
|
|
VkExtent2D *granularity);
|
|
|
|
|
2019-12-09 12:16:16 +00:00
|
|
|
struct v3dv_framebuffer {
|
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t layers;
|
|
|
|
|
2020-03-02 16:21:26 +00:00
|
|
|
uint32_t attachment_count;
|
|
|
|
uint32_t color_attachment_count;
|
|
|
|
struct v3dv_image_view *attachments[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_frame_tiling {
|
2020-03-03 10:57:59 +00:00
|
|
|
uint32_t width;
|
|
|
|
uint32_t height;
|
|
|
|
uint32_t render_target_count;
|
2019-12-13 09:31:05 +00:00
|
|
|
uint32_t internal_bpp;
|
2020-03-03 10:57:59 +00:00
|
|
|
uint32_t layers;
|
2019-12-13 09:31:05 +00:00
|
|
|
uint32_t tile_width;
|
|
|
|
uint32_t tile_height;
|
|
|
|
uint32_t draw_tiles_x;
|
|
|
|
uint32_t draw_tiles_y;
|
2019-12-17 07:51:33 +00:00
|
|
|
uint32_t supertile_width;
|
|
|
|
uint32_t supertile_height;
|
|
|
|
uint32_t frame_width_in_supertiles;
|
|
|
|
uint32_t frame_height_in_supertiles;
|
2019-12-09 12:16:16 +00:00
|
|
|
};
|
|
|
|
|
2020-03-02 16:21:26 +00:00
|
|
|
uint8_t v3dv_framebuffer_compute_internal_bpp(const struct v3dv_framebuffer *framebuffer,
|
|
|
|
const struct v3dv_subpass *subpass);
|
2020-01-07 07:46:12 +00:00
|
|
|
|
2019-12-10 08:03:49 +00:00
|
|
|
struct v3dv_cmd_pool {
|
|
|
|
VkAllocationCallbacks alloc;
|
|
|
|
struct list_head cmd_buffers;
|
|
|
|
};
|
|
|
|
|
2019-12-11 10:57:08 +00:00
|
|
|
enum v3dv_cmd_buffer_status {
|
|
|
|
V3DV_CMD_BUFFER_STATUS_NEW = 0,
|
|
|
|
V3DV_CMD_BUFFER_STATUS_INITIALIZED = 1,
|
2019-12-17 08:48:54 +00:00
|
|
|
V3DV_CMD_BUFFER_STATUS_RECORDING = 2,
|
|
|
|
V3DV_CMD_BUFFER_STATUS_EXECUTABLE = 3
|
2019-12-11 10:57:08 +00:00
|
|
|
};
|
|
|
|
|
2019-12-17 07:58:20 +00:00
|
|
|
union v3dv_clear_value {
|
|
|
|
uint32_t color[4];
|
2020-03-17 13:38:57 +00:00
|
|
|
struct {
|
|
|
|
float z;
|
|
|
|
uint8_t s;
|
|
|
|
};
|
2019-12-17 07:58:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_cmd_buffer_attachment_state {
|
2020-04-02 11:38:10 +01:00
|
|
|
/* The original clear value as provided by the Vulkan API */
|
|
|
|
VkClearValue vk_clear_value;
|
|
|
|
|
|
|
|
/* The hardware clear value */
|
2019-12-17 07:58:20 +00:00
|
|
|
union v3dv_clear_value clear_value;
|
|
|
|
};
|
|
|
|
|
2020-02-06 11:34:15 +00:00
|
|
|
void v3dv_get_hw_clear_color(const VkClearColorValue *color,
|
|
|
|
uint32_t internal_type,
|
|
|
|
uint32_t internal_size,
|
|
|
|
uint32_t *hw_color);
|
|
|
|
|
2019-12-28 10:59:32 +00:00
|
|
|
struct v3dv_viewport_state {
|
|
|
|
uint32_t count;
|
|
|
|
VkViewport viewports[MAX_VIEWPORTS];
|
2020-01-03 11:27:08 +00:00
|
|
|
float translate[MAX_VIEWPORTS][3];
|
|
|
|
float scale[MAX_VIEWPORTS][3];
|
2019-12-28 10:59:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_scissor_state {
|
|
|
|
uint32_t count;
|
|
|
|
VkRect2D scissors[MAX_SCISSORS];
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Mostly a v3dv mapping of VkDynamicState, used to track which data as
|
|
|
|
* defined as dynamic
|
|
|
|
*/
|
|
|
|
enum v3dv_dynamic_state_bits {
|
|
|
|
V3DV_DYNAMIC_VIEWPORT = 1 << 0,
|
|
|
|
V3DV_DYNAMIC_SCISSOR = 1 << 1,
|
2020-02-04 16:43:49 +00:00
|
|
|
V3DV_DYNAMIC_STENCIL_COMPARE_MASK = 1 << 2,
|
|
|
|
V3DV_DYNAMIC_STENCIL_WRITE_MASK = 1 << 3,
|
|
|
|
V3DV_DYNAMIC_STENCIL_REFERENCE = 1 << 4,
|
2020-03-18 10:50:47 +00:00
|
|
|
V3DV_DYNAMIC_BLEND_CONSTANTS = 1 << 5,
|
2020-05-13 09:35:30 +01:00
|
|
|
V3DV_DYNAMIC_DEPTH_BIAS = 1 << 6,
|
2020-05-13 11:21:55 +01:00
|
|
|
V3DV_DYNAMIC_LINE_WIDTH = 1 << 7,
|
|
|
|
V3DV_DYNAMIC_ALL = (1 << 8) - 1,
|
2019-12-28 10:59:32 +00:00
|
|
|
};
|
|
|
|
|
v3dv: fix the mess with dynamic state handling
The general idea is that we always emit from our dynamic state, and when
a particular piece of state is not dynamic, we just set our dynamic state
from the pipeline state, however, the implementation was quite confusing:
the mask of dynamic states flagged states that were not dynamic and some
places woud mix dirty flags and dynamic state flags. We also were not
updating the dynamic state mask in the command buffer, etc.
This patch, hopefully, simplifies all this and makes it less confusing,
starting by making the dynamic state mask flag dynamic states, fixing
the places where we would confuse dirty state flags with dynamic state
flags, making sure that our command buffer state is setup correctly
and that we only emit state when it is actually dirty.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-05 09:53:20 +00:00
|
|
|
/* Flags for dirty pipeline state.
|
2019-12-28 10:59:32 +00:00
|
|
|
*/
|
|
|
|
enum v3dv_cmd_dirty_bits {
|
v3dv: fix the mess with dynamic state handling
The general idea is that we always emit from our dynamic state, and when
a particular piece of state is not dynamic, we just set our dynamic state
from the pipeline state, however, the implementation was quite confusing:
the mask of dynamic states flagged states that were not dynamic and some
places woud mix dirty flags and dynamic state flags. We also were not
updating the dynamic state mask in the command buffer, etc.
This patch, hopefully, simplifies all this and makes it less confusing,
starting by making the dynamic state mask flag dynamic states, fixing
the places where we would confuse dirty state flags with dynamic state
flags, making sure that our command buffer state is setup correctly
and that we only emit state when it is actually dirty.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-05 09:53:20 +00:00
|
|
|
V3DV_CMD_DIRTY_VIEWPORT = 1 << 0,
|
|
|
|
V3DV_CMD_DIRTY_SCISSOR = 1 << 1,
|
|
|
|
V3DV_CMD_DIRTY_STENCIL_COMPARE_MASK = 1 << 2,
|
|
|
|
V3DV_CMD_DIRTY_STENCIL_WRITE_MASK = 1 << 3,
|
|
|
|
V3DV_CMD_DIRTY_STENCIL_REFERENCE = 1 << 4,
|
|
|
|
V3DV_CMD_DIRTY_PIPELINE = 1 << 5,
|
|
|
|
V3DV_CMD_DIRTY_VERTEX_BUFFER = 1 << 6,
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
V3DV_CMD_DIRTY_DESCRIPTOR_SETS = 1 << 7,
|
2020-09-11 22:26:07 +01:00
|
|
|
V3DV_CMD_DIRTY_PUSH_CONSTANTS = 1 << 8,
|
2020-03-18 10:50:47 +00:00
|
|
|
V3DV_CMD_DIRTY_BLEND_CONSTANTS = 1 << 9,
|
2020-03-25 10:50:16 +00:00
|
|
|
V3DV_CMD_DIRTY_SHADER_VARIANTS = 1 << 10,
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
V3DV_CMD_DIRTY_OCCLUSION_QUERY = 1 << 11,
|
2020-05-13 09:35:30 +01:00
|
|
|
V3DV_CMD_DIRTY_DEPTH_BIAS = 1 << 12,
|
2020-05-13 11:21:55 +01:00
|
|
|
V3DV_CMD_DIRTY_LINE_WIDTH = 1 << 13,
|
2019-12-28 10:59:32 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_dynamic_state {
|
|
|
|
/**
|
|
|
|
* Bitmask of (1 << VK_DYNAMIC_STATE_*).
|
|
|
|
* Defines the set of saved dynamic state.
|
|
|
|
*/
|
|
|
|
uint32_t mask;
|
|
|
|
|
|
|
|
struct v3dv_viewport_state viewport;
|
|
|
|
|
|
|
|
struct v3dv_scissor_state scissor;
|
2020-02-04 16:43:49 +00:00
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t front;
|
|
|
|
uint32_t back;
|
|
|
|
} stencil_compare_mask;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t front;
|
|
|
|
uint32_t back;
|
|
|
|
} stencil_write_mask;
|
|
|
|
|
|
|
|
struct {
|
|
|
|
uint32_t front;
|
|
|
|
uint32_t back;
|
|
|
|
} stencil_reference;
|
2020-03-18 10:50:47 +00:00
|
|
|
|
|
|
|
float blend_constants[4];
|
2020-05-13 09:35:30 +01:00
|
|
|
|
|
|
|
struct {
|
|
|
|
float constant_factor;
|
|
|
|
float slope_factor;
|
|
|
|
} depth_bias;
|
2020-05-13 11:21:55 +01:00
|
|
|
|
|
|
|
float line_width;
|
2019-12-28 10:59:32 +00:00
|
|
|
};
|
|
|
|
|
2019-12-28 11:11:48 +00:00
|
|
|
extern const struct v3dv_dynamic_state default_dynamic_state;
|
|
|
|
|
2020-02-03 11:55:25 +00:00
|
|
|
void v3dv_viewport_compute_xform(const VkViewport *viewport,
|
|
|
|
float scale[3],
|
|
|
|
float translate[3]);
|
|
|
|
|
2020-02-04 09:26:04 +00:00
|
|
|
enum v3dv_ez_state {
|
|
|
|
VC5_EZ_UNDECIDED = 0,
|
|
|
|
VC5_EZ_GT_GE,
|
|
|
|
VC5_EZ_LT_LE,
|
|
|
|
VC5_EZ_DISABLED,
|
|
|
|
};
|
|
|
|
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
enum v3dv_job_type {
|
2020-04-20 12:24:09 +01:00
|
|
|
V3DV_JOB_TYPE_GPU_CL = 0,
|
|
|
|
V3DV_JOB_TYPE_GPU_TFU,
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
V3DV_JOB_TYPE_CPU_RESET_QUERIES,
|
|
|
|
V3DV_JOB_TYPE_CPU_END_QUERY,
|
|
|
|
V3DV_JOB_TYPE_CPU_COPY_QUERY_RESULTS,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_reset_query_cpu_job_info {
|
|
|
|
struct v3dv_query_pool *pool;
|
|
|
|
uint32_t first;
|
|
|
|
uint32_t count;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_end_query_cpu_job_info {
|
|
|
|
struct v3dv_query_pool *pool;
|
|
|
|
uint32_t query;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_copy_query_results_cpu_job_info {
|
|
|
|
struct v3dv_query_pool *pool;
|
|
|
|
uint32_t first;
|
|
|
|
uint32_t count;
|
|
|
|
struct v3dv_buffer *dst;
|
|
|
|
uint32_t offset;
|
|
|
|
uint32_t stride;
|
|
|
|
VkQueryResultFlags flags;
|
|
|
|
};
|
|
|
|
|
2020-01-08 10:14:35 +00:00
|
|
|
struct v3dv_job {
|
|
|
|
struct list_head list_link;
|
|
|
|
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
enum v3dv_job_type type;
|
|
|
|
|
2020-03-13 10:35:06 +00:00
|
|
|
struct v3dv_device *device;
|
|
|
|
|
2020-01-08 10:14:35 +00:00
|
|
|
struct v3dv_cmd_buffer *cmd_buffer;
|
|
|
|
|
|
|
|
struct v3dv_cl bcl;
|
|
|
|
struct v3dv_cl rcl;
|
|
|
|
struct v3dv_cl indirect;
|
|
|
|
|
|
|
|
/* Set of all BOs referenced by the job. This will be used for making
|
|
|
|
* the list of BOs that the kernel will need to have paged in to
|
|
|
|
* execute our job.
|
|
|
|
*/
|
|
|
|
struct set *bos;
|
|
|
|
uint32_t bo_count;
|
|
|
|
|
2020-02-11 14:12:32 +00:00
|
|
|
/* A subset of the BOs set above that are allocated internally by
|
|
|
|
* the job and that should be explicitly freed with it.
|
|
|
|
*/
|
|
|
|
struct set *extra_bos;
|
|
|
|
|
2020-01-08 10:14:35 +00:00
|
|
|
struct v3dv_bo *tile_alloc;
|
|
|
|
struct v3dv_bo *tile_state;
|
|
|
|
|
|
|
|
bool tmu_dirty_rcl;
|
2020-01-10 10:31:51 +00:00
|
|
|
|
|
|
|
uint32_t first_subpass;
|
2020-02-04 09:26:04 +00:00
|
|
|
|
v3dv: implement vkCmdClearAttachments
For now this only implements a fast path using the tile buffer, so it
can only be used when clearing full images, but this is good enough
for VkRunner.
The implementation is a bit tricky because this command executes
inside a render pass, and yet, since we are using the tile buffer to
clear, this needs to go in its own job. This means that with this, we
need to be able to split a subpass into multiple jobs which creates
some issues.
For example, certain operations, such as the subpass load operation
(particularly if it is a clear) should only happen on the first job of
the subpass and subsequent jobs in the same subpass should always
load.
Similarly, we should not discard the last store on an attachment
unless we know it is the last job for the last subpass that uses the
attachment.
To handle these cases we add two new flags to the job, one to know if
the job is not the first in a subpass (is_subpass_continue) and
another one to know if a job is the last in a subpass
(is_subpass_finish).
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-06 11:39:48 +00:00
|
|
|
/* When the current subpass is split into multiple jobs, this flag is set
|
|
|
|
* to true for any jobs after the first in the same subpass.
|
|
|
|
*/
|
|
|
|
bool is_subpass_continue;
|
|
|
|
|
|
|
|
/* If this job is the last job emitted for a subpass. */
|
|
|
|
bool is_subpass_finish;
|
|
|
|
|
2020-03-02 16:21:26 +00:00
|
|
|
struct v3dv_frame_tiling frame_tiling;
|
|
|
|
|
2020-02-04 09:26:04 +00:00
|
|
|
enum v3dv_ez_state ez_state;
|
|
|
|
enum v3dv_ez_state first_ez_state;
|
2020-03-13 10:35:06 +00:00
|
|
|
|
2020-03-18 09:00:31 +00:00
|
|
|
/* Number of draw calls recorded into the job */
|
|
|
|
uint32_t draw_count;
|
|
|
|
|
|
|
|
/* A flag indicating whether we want to flush every draw separately. This
|
|
|
|
* can be used for debugging, or for cases where special circumstances
|
|
|
|
* require this behavior.
|
|
|
|
*/
|
|
|
|
bool always_flush;
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
|
|
|
|
/* Job specs for CPU jobs */
|
|
|
|
union {
|
|
|
|
struct v3dv_reset_query_cpu_job_info query_reset;
|
|
|
|
struct v3dv_end_query_cpu_job_info query_end;
|
|
|
|
struct v3dv_copy_query_results_cpu_job_info query_copy_results;
|
|
|
|
} cpu;
|
2020-04-20 12:24:09 +01:00
|
|
|
|
|
|
|
/* Job spects for TFU jobs */
|
|
|
|
struct drm_v3d_submit_tfu tfu;
|
2020-01-08 10:14:35 +00:00
|
|
|
};
|
|
|
|
|
2020-03-13 10:35:06 +00:00
|
|
|
void v3dv_job_init(struct v3dv_job *job,
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
enum v3dv_job_type type,
|
2020-03-13 10:35:06 +00:00
|
|
|
struct v3dv_device *device,
|
|
|
|
struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
int32_t subpass_idx);
|
|
|
|
void v3dv_job_destroy(struct v3dv_job *job);
|
2020-01-08 10:14:35 +00:00
|
|
|
void v3dv_job_add_bo(struct v3dv_job *job, struct v3dv_bo *bo);
|
2020-02-11 14:12:32 +00:00
|
|
|
void v3dv_job_add_extra_bo(struct v3dv_job *job, struct v3dv_bo *bo);
|
2020-01-10 11:26:14 +00:00
|
|
|
void v3dv_job_emit_binning_flush(struct v3dv_job *job);
|
2020-03-13 10:35:06 +00:00
|
|
|
void v3dv_job_start_frame(struct v3dv_job *job,
|
|
|
|
uint32_t width,
|
|
|
|
uint32_t height,
|
|
|
|
uint32_t layers,
|
|
|
|
uint32_t render_target_count,
|
|
|
|
uint8_t max_internal_bpp);
|
2020-01-08 10:14:35 +00:00
|
|
|
|
2020-07-31 00:11:39 +01:00
|
|
|
struct v3dv_vertex_binding {
|
|
|
|
struct v3dv_buffer *buffer;
|
|
|
|
VkDeviceSize offset;
|
|
|
|
};
|
|
|
|
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
struct v3dv_descriptor_state {
|
v3dv/descriptor_set: support for array of ubo/ssbo
For that we include the array_index when asking for a ubo/ssbo index
from the descriptor_map.
Until now, array_index was not included, but the descriptor_map took
into account the array_size. This had the advantage that you only need
a entry on the descriptor map, and the index was properly return.
But this make it complex to get back the set, binding and array_index
back from the ubo/ssbo binding. So it was more easy to just add
array_index. Somehow now the "key" on the descriptor map is the
combination of (set, binding, array_index).
Note that this also make sense as the vulkan api identifies each array
index as a descriptor, so for example, from spec,
VkDescriptorSetLayoutBinding:descriptorCount
"descriptorCount is the number of descriptors contained in the
binding, accessed in a shader as an array"
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-13 21:22:18 +00:00
|
|
|
struct v3dv_descriptor_set *descriptor_sets[MAX_SETS];
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
uint32_t valid;
|
2020-02-24 10:32:57 +00:00
|
|
|
uint32_t dynamic_offsets[MAX_DYNAMIC_BUFFERS];
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
};
|
|
|
|
|
2019-12-13 09:48:12 +00:00
|
|
|
struct v3dv_cmd_buffer_state {
|
2020-03-31 11:59:44 +01:00
|
|
|
struct v3dv_render_pass *pass;
|
|
|
|
struct v3dv_framebuffer *framebuffer;
|
2019-12-17 07:58:20 +00:00
|
|
|
VkRect2D render_area;
|
|
|
|
|
2020-01-09 11:50:43 +00:00
|
|
|
/* Current job being recorded */
|
|
|
|
struct v3dv_job *job;
|
2019-12-18 10:44:35 +00:00
|
|
|
|
2019-12-17 07:58:20 +00:00
|
|
|
uint32_t subpass_idx;
|
2019-12-18 14:38:21 +00:00
|
|
|
|
|
|
|
struct v3dv_pipeline *pipeline;
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
struct v3dv_descriptor_state descriptor_state;
|
2019-12-28 10:59:32 +00:00
|
|
|
|
|
|
|
struct v3dv_dynamic_state dynamic;
|
|
|
|
uint32_t dirty;
|
2019-12-30 12:01:44 +00:00
|
|
|
|
2020-04-01 09:17:22 +01:00
|
|
|
/* Current clip window. We use this to check whether we have an active
|
|
|
|
* scissor, since in that case we can't use TLB clears and need to fallback
|
|
|
|
* to drawing rects.
|
|
|
|
*/
|
|
|
|
VkRect2D clip_window;
|
|
|
|
|
2020-04-02 11:38:10 +01:00
|
|
|
/* Whether our render area is aligned to tile boundaries. If this is false
|
|
|
|
* then we have tiles that are only partially covered by the render area,
|
|
|
|
* and therefore, we need to be careful with our loads and stores so we don't
|
|
|
|
* modify pixels for the tile area that is not covered by the render area.
|
|
|
|
* This means, for example, that we can't use the TLB to clear, since that
|
|
|
|
* always clears full tiles.
|
|
|
|
*/
|
|
|
|
bool tile_aligned_render_area;
|
|
|
|
|
2020-01-09 11:50:43 +00:00
|
|
|
uint32_t attachment_count;
|
|
|
|
struct v3dv_cmd_buffer_attachment_state *attachments;
|
2020-07-31 00:11:39 +01:00
|
|
|
|
|
|
|
struct v3dv_vertex_binding vertex_bindings[MAX_VBS];
|
2020-02-07 09:10:39 +00:00
|
|
|
|
|
|
|
uint8_t index_size;
|
2020-03-12 10:59:04 +00:00
|
|
|
|
|
|
|
/* Used to flag OOM conditions during command buffer recording */
|
|
|
|
bool oom;
|
2020-03-31 11:59:44 +01:00
|
|
|
|
|
|
|
/* Command buffer state saved during a meta operation */
|
|
|
|
struct {
|
|
|
|
uint32_t subpass_idx;
|
|
|
|
VkRenderPass pass;
|
|
|
|
VkPipeline pipeline;
|
|
|
|
VkFramebuffer framebuffer;
|
2020-04-03 08:41:45 +01:00
|
|
|
|
|
|
|
uint32_t attachment_alloc_count;
|
|
|
|
uint32_t attachment_count;
|
|
|
|
struct v3dv_cmd_buffer_attachment_state *attachments;
|
|
|
|
|
|
|
|
bool tile_aligned_render_area;
|
|
|
|
VkRect2D render_area;
|
|
|
|
|
|
|
|
struct v3dv_dynamic_state dynamic;
|
2020-04-22 07:27:58 +01:00
|
|
|
|
|
|
|
struct v3dv_descriptor_state descriptor_state;
|
2020-04-22 08:26:27 +01:00
|
|
|
|
|
|
|
uint32_t push_constants[MAX_PUSH_CONSTANTS_SIZE / 4];
|
2020-03-31 11:59:44 +01:00
|
|
|
} meta;
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
|
|
|
|
/* Command buffer state for queries */
|
|
|
|
struct {
|
|
|
|
/* A list of vkCmdQueryEnd commands recorded in the command buffer during
|
|
|
|
* a render pass. We queue these here and then schedule the corresponding
|
|
|
|
* CPU jobs for them at the time we finish the GPU job in which they have
|
|
|
|
* been recorded.
|
|
|
|
*/
|
|
|
|
struct {
|
|
|
|
uint32_t used_count;
|
|
|
|
uint32_t alloc_count;
|
|
|
|
struct v3dv_end_query_cpu_job_info *states;
|
|
|
|
} end;
|
|
|
|
|
|
|
|
/* This is not NULL if we have an active query, that is, we have called
|
|
|
|
* vkCmdBeginQuery but not vkCmdEndQuery.
|
|
|
|
*/
|
|
|
|
struct v3dv_bo *active_query;
|
|
|
|
} query;
|
2019-12-13 09:48:12 +00:00
|
|
|
};
|
|
|
|
|
2020-09-11 22:26:07 +01:00
|
|
|
struct v3dv_descriptor {
|
2020-03-29 15:29:55 +01:00
|
|
|
VkDescriptorType type;
|
|
|
|
|
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
struct v3dv_image_view *image_view;
|
|
|
|
struct v3dv_sampler *sampler;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct {
|
|
|
|
struct v3dv_buffer *buffer;
|
|
|
|
uint32_t offset;
|
|
|
|
};
|
|
|
|
};
|
2020-09-11 22:26:07 +01:00
|
|
|
};
|
|
|
|
|
2020-03-16 11:34:02 +00:00
|
|
|
/* Aux struct as it is really common to have a pair bo/address. Called
|
|
|
|
* resource because it is really likely that we would need something like that
|
|
|
|
* if we work on reuse the same bo at different points (like the shader
|
|
|
|
* assembly).
|
|
|
|
*/
|
|
|
|
struct v3dv_resource {
|
|
|
|
struct v3dv_bo *bo;
|
|
|
|
uint32_t offset;
|
|
|
|
};
|
|
|
|
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
struct v3dv_query {
|
|
|
|
bool maybe_available;
|
|
|
|
struct v3dv_bo *bo;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_query_pool {
|
|
|
|
uint32_t query_count;
|
|
|
|
struct v3dv_query *queries;
|
|
|
|
};
|
|
|
|
|
|
|
|
VkResult v3dv_get_query_pool_results_cpu(struct v3dv_device *device,
|
|
|
|
struct v3dv_query_pool *pool,
|
|
|
|
uint32_t first,
|
|
|
|
uint32_t count,
|
|
|
|
void *data,
|
|
|
|
VkDeviceSize stride,
|
|
|
|
VkQueryResultFlags flags);
|
|
|
|
|
2020-04-29 08:13:00 +01:00
|
|
|
typedef void (*v3dv_cmd_buffer_private_obj_destroy_cb)(VkDevice device,
|
2020-05-14 08:23:40 +01:00
|
|
|
uint64_t pobj,
|
2020-04-29 08:13:00 +01:00
|
|
|
VkAllocationCallbacks *alloc);
|
|
|
|
struct v3dv_cmd_buffer_private_obj {
|
|
|
|
struct list_head list_link;
|
2020-05-14 08:23:40 +01:00
|
|
|
uint64_t obj;
|
2020-04-29 08:13:00 +01:00
|
|
|
v3dv_cmd_buffer_private_obj_destroy_cb destroy_cb;
|
|
|
|
};
|
|
|
|
|
2019-12-10 08:33:13 +00:00
|
|
|
struct v3dv_cmd_buffer {
|
|
|
|
VK_LOADER_DATA _loader_data;
|
|
|
|
|
|
|
|
struct v3dv_device *device;
|
|
|
|
|
|
|
|
struct v3dv_cmd_pool *pool;
|
|
|
|
struct list_head pool_link;
|
|
|
|
|
|
|
|
VkCommandBufferUsageFlags usage_flags;
|
|
|
|
VkCommandBufferLevel level;
|
2019-12-11 09:14:10 +00:00
|
|
|
|
2019-12-11 10:57:08 +00:00
|
|
|
enum v3dv_cmd_buffer_status status;
|
2019-12-13 09:48:12 +00:00
|
|
|
|
|
|
|
struct v3dv_cmd_buffer_state state;
|
|
|
|
|
2020-09-11 22:26:07 +01:00
|
|
|
uint32_t push_constants_data[MAX_PUSH_CONSTANTS_SIZE / 4];
|
2020-03-16 11:34:02 +00:00
|
|
|
struct v3dv_resource push_constants_resource;
|
2020-09-11 22:26:07 +01:00
|
|
|
|
2020-04-29 08:13:00 +01:00
|
|
|
/* Collection of Vulkan objects created internally by the driver (typically
|
|
|
|
* during recording of meta operations) that are part of the command buffer
|
|
|
|
* and should be destroyed with it.
|
|
|
|
*/
|
|
|
|
struct list_head private_objs; /* v3dv_cmd_buffer_private_obj */
|
|
|
|
|
2020-04-29 08:42:01 +01:00
|
|
|
/* Per-command buffer resources for meta operations. */
|
|
|
|
struct {
|
|
|
|
struct {
|
|
|
|
VkDescriptorPool dspool;
|
|
|
|
} blit;
|
|
|
|
} meta;
|
|
|
|
|
2020-01-08 10:14:35 +00:00
|
|
|
/* List of jobs to submit to the kernel */
|
|
|
|
struct list_head submit_jobs;
|
2019-12-10 08:33:13 +00:00
|
|
|
};
|
|
|
|
|
v3dv: implement vkCmdClearAttachments
For now this only implements a fast path using the tile buffer, so it
can only be used when clearing full images, but this is good enough
for VkRunner.
The implementation is a bit tricky because this command executes
inside a render pass, and yet, since we are using the tile buffer to
clear, this needs to go in its own job. This means that with this, we
need to be able to split a subpass into multiple jobs which creates
some issues.
For example, certain operations, such as the subpass load operation
(particularly if it is a clear) should only happen on the first job of
the subpass and subsequent jobs in the same subpass should always
load.
Similarly, we should not discard the last store on an attachment
unless we know it is the last job for the last subpass that uses the
attachment.
To handle these cases we add two new flags to the job, one to know if
the job is not the first in a subpass (is_subpass_continue) and
another one to know if a job is the last in a subpass
(is_subpass_finish).
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-06 11:39:48 +00:00
|
|
|
struct v3dv_job *v3dv_cmd_buffer_start_job(struct v3dv_cmd_buffer *cmd_buffer,
|
2020-03-02 11:08:19 +00:00
|
|
|
int32_t subpass_idx);
|
2020-01-08 10:14:35 +00:00
|
|
|
void v3dv_cmd_buffer_finish_job(struct v3dv_cmd_buffer *cmd_buffer);
|
2019-12-13 09:48:12 +00:00
|
|
|
|
2020-03-31 11:59:44 +01:00
|
|
|
struct v3dv_job *v3dv_cmd_buffer_subpass_start(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
uint32_t subpass_idx);
|
2020-04-03 13:19:40 +01:00
|
|
|
struct v3dv_job *v3dv_cmd_buffer_subpass_resume(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
uint32_t subpass_idx);
|
2020-03-31 11:59:44 +01:00
|
|
|
|
|
|
|
void v3dv_cmd_buffer_subpass_finish(struct v3dv_cmd_buffer *cmd_buffer);
|
|
|
|
|
2020-04-22 07:27:58 +01:00
|
|
|
void v3dv_cmd_buffer_meta_state_push(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
bool push_descriptor_state);
|
2020-04-03 08:41:45 +01:00
|
|
|
void v3dv_cmd_buffer_meta_state_pop(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
uint32_t dirty_dynamic_state);
|
2020-03-31 11:59:44 +01:00
|
|
|
|
v3dv: implement vkCmdClearAttachments
For now this only implements a fast path using the tile buffer, so it
can only be used when clearing full images, but this is good enough
for VkRunner.
The implementation is a bit tricky because this command executes
inside a render pass, and yet, since we are using the tile buffer to
clear, this needs to go in its own job. This means that with this, we
need to be able to split a subpass into multiple jobs which creates
some issues.
For example, certain operations, such as the subpass load operation
(particularly if it is a clear) should only happen on the first job of
the subpass and subsequent jobs in the same subpass should always
load.
Similarly, we should not discard the last store on an attachment
unless we know it is the last job for the last subpass that uses the
attachment.
To handle these cases we add two new flags to the job, one to know if
the job is not the first in a subpass (is_subpass_continue) and
another one to know if a job is the last in a subpass
(is_subpass_finish).
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-06 11:39:48 +00:00
|
|
|
void v3dv_render_pass_setup_render_target(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
int rt,
|
|
|
|
uint32_t *rt_bpp,
|
|
|
|
uint32_t *rt_type,
|
|
|
|
uint32_t *rt_clamp);
|
|
|
|
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
void v3dv_cmd_buffer_reset_queries(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
struct v3dv_query_pool *pool,
|
|
|
|
uint32_t first,
|
|
|
|
uint32_t count);
|
|
|
|
|
|
|
|
void v3dv_cmd_buffer_begin_query(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
struct v3dv_query_pool *pool,
|
|
|
|
uint32_t query,
|
|
|
|
VkQueryControlFlags flags);
|
|
|
|
|
|
|
|
void v3dv_cmd_buffer_end_query(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
struct v3dv_query_pool *pool,
|
|
|
|
uint32_t query);
|
|
|
|
|
|
|
|
void v3dv_cmd_buffer_copy_query_results(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
struct v3dv_query_pool *pool,
|
|
|
|
uint32_t first,
|
|
|
|
uint32_t count,
|
|
|
|
struct v3dv_buffer *dst,
|
|
|
|
uint32_t offset,
|
|
|
|
uint32_t stride,
|
|
|
|
VkQueryResultFlags flags);
|
|
|
|
|
2020-04-20 12:24:09 +01:00
|
|
|
void v3dv_cmd_buffer_add_tfu_job(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
struct drm_v3d_submit_tfu *tfu);
|
|
|
|
|
2020-04-29 08:13:00 +01:00
|
|
|
void v3dv_cmd_buffer_add_private_obj(struct v3dv_cmd_buffer *cmd_buffer,
|
2020-05-14 08:23:40 +01:00
|
|
|
uint64_t obj,
|
2020-04-29 08:13:00 +01:00
|
|
|
v3dv_cmd_buffer_private_obj_destroy_cb destroy_cb);
|
|
|
|
|
2020-01-13 11:31:12 +00:00
|
|
|
struct v3dv_semaphore {
|
|
|
|
/* A syncobject handle associated with this semaphore */
|
|
|
|
uint32_t sync;
|
2020-01-13 16:45:04 +00:00
|
|
|
|
|
|
|
/* The file handle of a fence that we imported into our syncobject */
|
|
|
|
int32_t fd;
|
2020-01-13 11:31:12 +00:00
|
|
|
};
|
|
|
|
|
2020-01-14 08:48:19 +00:00
|
|
|
struct v3dv_fence {
|
|
|
|
/* A syncobject handle associated with this fence */
|
|
|
|
uint32_t sync;
|
|
|
|
|
|
|
|
/* The file handle of a fence that we imported into our syncobject */
|
|
|
|
int32_t fd;
|
|
|
|
};
|
|
|
|
|
2020-02-26 08:36:27 +00:00
|
|
|
struct v3dv_event {
|
|
|
|
struct v3dv_bo *bo;
|
|
|
|
};
|
|
|
|
|
2019-12-02 10:47:25 +00:00
|
|
|
struct v3dv_shader_module {
|
2020-03-31 11:52:06 +01:00
|
|
|
/* A NIR shader. We create NIR modules for shaders that are generated
|
|
|
|
* internally by the driver.
|
|
|
|
*/
|
|
|
|
struct nir_shader *nir;
|
|
|
|
|
|
|
|
/* A SPIR-V shader */
|
2019-12-02 10:47:25 +00:00
|
|
|
unsigned char sha1[20];
|
|
|
|
uint32_t size;
|
|
|
|
char data[0];
|
|
|
|
};
|
|
|
|
|
2019-12-02 12:59:04 +00:00
|
|
|
/* FIXME: the same function at anv, radv and tu, perhaps create common
|
|
|
|
* place?
|
|
|
|
*/
|
|
|
|
static inline gl_shader_stage
|
|
|
|
vk_to_mesa_shader_stage(VkShaderStageFlagBits vk_stage)
|
|
|
|
{
|
|
|
|
assert(__builtin_popcount(vk_stage) == 1);
|
|
|
|
return ffs(vk_stage) - 1;
|
|
|
|
}
|
|
|
|
|
2020-03-24 11:18:10 +00:00
|
|
|
struct v3dv_shader_variant {
|
|
|
|
union {
|
|
|
|
struct v3d_prog_data *base;
|
|
|
|
struct v3d_vs_prog_data *vs;
|
|
|
|
struct v3d_fs_prog_data *fs;
|
|
|
|
} prog_data;
|
|
|
|
|
|
|
|
/* FIXME: using one bo per shader. Eventually we would be interested on
|
|
|
|
* reusing the same bo for all the shaders, like a bo per v3dv_pipeline for
|
|
|
|
* shaders.
|
|
|
|
*/
|
|
|
|
struct v3dv_bo *assembly_bo;
|
|
|
|
};
|
|
|
|
|
2019-12-02 12:59:04 +00:00
|
|
|
/*
|
2019-12-30 12:01:44 +00:00
|
|
|
* Per-stage info for each stage, useful so shader_module_compile_to_nir and
|
|
|
|
* other methods doesn't have so many parameters.
|
2019-12-02 12:59:04 +00:00
|
|
|
*
|
|
|
|
* FIXME: for the case of the coordinate shader and the vertex shader, module,
|
|
|
|
* entrypoint, spec_info and nir are the same. There are also info only
|
|
|
|
* relevant to some stages. But seemed too much a hassle to create a new
|
|
|
|
* struct only to handle that. Revisit if such kind of info starts to grow.
|
|
|
|
*/
|
|
|
|
struct v3dv_pipeline_stage {
|
|
|
|
struct v3dv_pipeline *pipeline;
|
|
|
|
|
|
|
|
gl_shader_stage stage;
|
|
|
|
/* FIXME: is_coord only make sense if stage == MESA_SHADER_VERTEX. Perhaps
|
|
|
|
* a stage base/vs/fs as keys and prog_data?
|
|
|
|
*/
|
|
|
|
bool is_coord;
|
|
|
|
|
|
|
|
const struct v3dv_shader_module *module;
|
|
|
|
const char *entrypoint;
|
|
|
|
const VkSpecializationInfo *spec_info;
|
|
|
|
|
|
|
|
nir_shader *nir;
|
|
|
|
|
|
|
|
/** A name for this program, so you can track it in shader-db output. */
|
|
|
|
uint32_t program_id;
|
2020-03-24 11:18:10 +00:00
|
|
|
/** How many variants of this program were compiled, for shader-db. */
|
|
|
|
uint32_t compiled_variant_count;
|
2019-12-02 12:59:04 +00:00
|
|
|
|
2020-03-24 11:18:10 +00:00
|
|
|
/* The following are the default v3d_key populated using
|
|
|
|
* VkCreateGraphicsPipelineCreateInfo. Variants will be created tweaking
|
|
|
|
* them, so we don't need to maintain a copy of that create info struct
|
|
|
|
* around
|
|
|
|
*/
|
2019-12-02 12:59:04 +00:00
|
|
|
union {
|
|
|
|
struct v3d_key base;
|
|
|
|
struct v3d_vs_key vs;
|
|
|
|
struct v3d_fs_key fs;
|
|
|
|
} key;
|
|
|
|
|
2020-03-24 11:18:10 +00:00
|
|
|
/* Cache with all the shader variant.
|
|
|
|
*/
|
|
|
|
struct hash_table *cache;
|
|
|
|
|
|
|
|
struct v3dv_shader_variant *current_variant;
|
2019-12-02 12:59:04 +00:00
|
|
|
|
2020-01-02 11:34:43 +00:00
|
|
|
/* FIXME: only make sense on vs, so perhaps a v3dv key like radv? or a kind
|
|
|
|
* of pipe_draw_info
|
|
|
|
*/
|
|
|
|
enum pipe_prim_type topology;
|
2019-12-02 12:59:04 +00:00
|
|
|
};
|
|
|
|
|
2020-01-09 12:54:22 +00:00
|
|
|
/* FIXME: although the full vpm_config is not required at this point, as we
|
|
|
|
* don't plan to initially support GS, it is more readable and serves as a
|
|
|
|
* placeholder, to have the struct and fill it with default values.
|
|
|
|
*/
|
|
|
|
struct vpm_config {
|
|
|
|
uint32_t As;
|
|
|
|
uint32_t Vc;
|
|
|
|
uint32_t Gs;
|
|
|
|
uint32_t Gd;
|
|
|
|
uint32_t Gv;
|
|
|
|
uint32_t Ve;
|
|
|
|
uint32_t gs_width;
|
|
|
|
};
|
|
|
|
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
struct v3dv_descriptor_pool_entry
|
|
|
|
{
|
|
|
|
struct v3dv_descriptor_set *set;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_descriptor_pool {
|
|
|
|
uint8_t *host_memory_base;
|
|
|
|
uint8_t *host_memory_ptr;
|
|
|
|
uint8_t *host_memory_end;
|
|
|
|
|
|
|
|
uint32_t entry_count;
|
|
|
|
uint32_t max_entry_count;
|
|
|
|
struct v3dv_descriptor_pool_entry entries[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_descriptor_set {
|
|
|
|
struct v3dv_descriptor_pool *pool;
|
|
|
|
|
|
|
|
const struct v3dv_descriptor_set_layout *layout;
|
|
|
|
|
|
|
|
/* The descriptors below can be indexed (set/binding) using the set_layout
|
|
|
|
*/
|
|
|
|
struct v3dv_descriptor descriptors[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_descriptor_set_binding_layout {
|
|
|
|
VkDescriptorType type;
|
|
|
|
|
|
|
|
/* Number of array elements in this binding */
|
|
|
|
uint32_t array_size;
|
|
|
|
|
|
|
|
uint32_t descriptor_index;
|
2020-02-24 10:32:57 +00:00
|
|
|
|
|
|
|
uint32_t dynamic_offset_count;
|
|
|
|
uint32_t dynamic_offset_index;
|
2020-04-02 12:24:13 +01:00
|
|
|
|
|
|
|
/* Offset in the v3dv_descriptor_set_layout of the immutable samplers, or 0
|
|
|
|
* if there are no immutable samplers.
|
|
|
|
*/
|
|
|
|
uint32_t immutable_samplers_offset;
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_descriptor_set_layout {
|
|
|
|
VkDescriptorSetLayoutCreateFlags flags;
|
|
|
|
|
|
|
|
/* Number of bindings in this descriptor set */
|
|
|
|
uint32_t binding_count;
|
|
|
|
|
2020-03-29 15:29:55 +01:00
|
|
|
/* Total size of the descriptor set with room for all array entries */
|
|
|
|
uint32_t size;
|
|
|
|
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
/* Shader stages affected by this descriptor set */
|
|
|
|
uint16_t shader_stages;
|
|
|
|
|
|
|
|
/* Number of descriptors in this descriptor set */
|
|
|
|
uint32_t descriptor_count;
|
|
|
|
|
2020-02-24 10:32:57 +00:00
|
|
|
/* Number of dynamic offsets used by this descriptor set */
|
|
|
|
uint16_t dynamic_offset_count;
|
|
|
|
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
/* Bindings in this descriptor set */
|
|
|
|
struct v3dv_descriptor_set_binding_layout binding[0];
|
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_pipeline_layout {
|
|
|
|
struct {
|
|
|
|
struct v3dv_descriptor_set_layout *layout;
|
|
|
|
uint32_t dynamic_offset_start;
|
|
|
|
} set[MAX_SETS];
|
|
|
|
|
|
|
|
uint32_t num_sets;
|
2020-02-24 10:32:57 +00:00
|
|
|
uint32_t dynamic_offset_count;
|
2020-03-04 14:38:55 +00:00
|
|
|
|
|
|
|
uint32_t push_constant_size;
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct v3dv_descriptor_map {
|
|
|
|
/* TODO: avoid fixed size array/justify the size */
|
v3dv/descriptor_set: support for array of ubo/ssbo
For that we include the array_index when asking for a ubo/ssbo index
from the descriptor_map.
Until now, array_index was not included, but the descriptor_map took
into account the array_size. This had the advantage that you only need
a entry on the descriptor map, and the index was properly return.
But this make it complex to get back the set, binding and array_index
back from the ubo/ssbo binding. So it was more easy to just add
array_index. Somehow now the "key" on the descriptor map is the
combination of (set, binding, array_index).
Note that this also make sense as the vulkan api identifies each array
index as a descriptor, so for example, from spec,
VkDescriptorSetLayoutBinding:descriptorCount
"descriptorCount is the number of descriptors contained in the
binding, accessed in a shader as an array"
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-13 21:22:18 +00:00
|
|
|
unsigned num_desc; /* Number of descriptors */
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
int set[64];
|
|
|
|
int binding[64];
|
v3dv/descriptor_set: support for array of ubo/ssbo
For that we include the array_index when asking for a ubo/ssbo index
from the descriptor_map.
Until now, array_index was not included, but the descriptor_map took
into account the array_size. This had the advantage that you only need
a entry on the descriptor map, and the index was properly return.
But this make it complex to get back the set, binding and array_index
back from the ubo/ssbo binding. So it was more easy to just add
array_index. Somehow now the "key" on the descriptor map is the
combination of (set, binding, array_index).
Note that this also make sense as the vulkan api identifies each array
index as a descriptor, so for example, from spec,
VkDescriptorSetLayoutBinding:descriptorCount
"descriptorCount is the number of descriptors contained in the
binding, accessed in a shader as an array"
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-02-13 21:22:18 +00:00
|
|
|
int array_index[64];
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
int array_size[64];
|
|
|
|
};
|
|
|
|
|
2020-03-29 15:29:55 +01:00
|
|
|
struct v3dv_sampler {
|
v3dv/descriptor_set: combine texture and sampler indices
OpenGL doesn't have the concept of individual texture and sampler, so
texture and sampler indexes have the same value. v3d compiler uses
this assumption, so for example, the texture info at the v3d key
include values that you need to use the texture format and the sampler
to fill (like the return_size).
One option would be to adapt the v3d compiler to handle both, but then
we would need to adapt to the lowerings it uses, like nir_lower_tex,
that also take the same assumption.
We deal with this on the Vulkan driver, by reassigning the texture and
sampler index to a combined one. We add a hash table to map the
combined texture idx and sampler idx to this combined idx, and a
simple array to the opposite map. On the driver we work with the
separate indices to fill up the data, while the v3d compiler works
with the combined one.
As mentioned, this is needed to properly fill up the texture return
size, so as we are here, we fix that. This gets tests like the
following working:
dEQP-VK.glsl.texture_gather.basic.2d.depth32f.base_level.level_2
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-06 23:33:14 +01:00
|
|
|
bool compare_enable;
|
|
|
|
|
2020-03-29 15:29:55 +01:00
|
|
|
/* FIXME: here we store the packet SAMPLER_STATE, that is referenced as part
|
|
|
|
* of the tmu configuration, and the content is set per sampler. A possible
|
|
|
|
* perf improvement, to avoid bo fragmentation, would be to save the state
|
|
|
|
* as static, have the bo as part of the descriptor (booked from the
|
|
|
|
* descriptor pools), and then copy this content to the descriptor bo on
|
|
|
|
* UpdateDescriptor
|
|
|
|
*/
|
|
|
|
struct v3dv_bo *state;
|
|
|
|
};
|
|
|
|
|
2020-04-11 13:50:50 +01:00
|
|
|
#define V3DV_NO_SAMPLER_IDX 666
|
|
|
|
|
v3dv/descriptor_set: combine texture and sampler indices
OpenGL doesn't have the concept of individual texture and sampler, so
texture and sampler indexes have the same value. v3d compiler uses
this assumption, so for example, the texture info at the v3d key
include values that you need to use the texture format and the sampler
to fill (like the return_size).
One option would be to adapt the v3d compiler to handle both, but then
we would need to adapt to the lowerings it uses, like nir_lower_tex,
that also take the same assumption.
We deal with this on the Vulkan driver, by reassigning the texture and
sampler index to a combined one. We add a hash table to map the
combined texture idx and sampler idx to this combined idx, and a
simple array to the opposite map. On the driver we work with the
separate indices to fill up the data, while the v3d compiler works
with the combined one.
As mentioned, this is needed to properly fill up the texture return
size, so as we are here, we fix that. This gets tests like the
following working:
dEQP-VK.glsl.texture_gather.basic.2d.depth32f.base_level.level_2
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-06 23:33:14 +01:00
|
|
|
/*
|
|
|
|
* Following two methods are using on the combined to/from texture/sampler
|
|
|
|
* indices maps at v3dv_pipeline.
|
|
|
|
*/
|
|
|
|
static inline uint32_t
|
|
|
|
v3dv_pipeline_combined_index_key_create(uint32_t texture_index,
|
|
|
|
uint32_t sampler_index)
|
|
|
|
{
|
|
|
|
return texture_index << 24 | sampler_index;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void
|
|
|
|
v3dv_pipeline_combined_index_key_unpack(uint32_t combined_index_key,
|
|
|
|
uint32_t *texture_index,
|
|
|
|
uint32_t *sampler_index)
|
|
|
|
{
|
|
|
|
uint32_t texture = combined_index_key >> 24;
|
|
|
|
uint32_t sampler = combined_index_key & 0xffffff;
|
|
|
|
|
|
|
|
if (texture_index)
|
|
|
|
*texture_index = texture;
|
|
|
|
|
|
|
|
if (sampler_index)
|
|
|
|
*sampler_index = sampler;
|
|
|
|
}
|
|
|
|
|
2019-12-02 12:59:04 +00:00
|
|
|
struct v3dv_pipeline {
|
|
|
|
struct v3dv_device *device;
|
|
|
|
|
|
|
|
VkShaderStageFlags active_stages;
|
|
|
|
|
2020-03-17 11:10:58 +00:00
|
|
|
struct v3dv_render_pass *pass;
|
2019-12-02 12:59:04 +00:00
|
|
|
struct v3dv_subpass *subpass;
|
|
|
|
|
|
|
|
/* Note: We can't use just a MESA_SHADER_STAGES array as we need to track
|
|
|
|
* too the coordinate shader
|
|
|
|
*/
|
|
|
|
struct v3dv_pipeline_stage *vs;
|
|
|
|
struct v3dv_pipeline_stage *vs_bin;
|
|
|
|
struct v3dv_pipeline_stage *fs;
|
2019-12-28 11:11:48 +00:00
|
|
|
|
|
|
|
struct v3dv_dynamic_state dynamic_state;
|
2020-01-05 00:51:04 +00:00
|
|
|
|
2020-02-24 10:32:57 +00:00
|
|
|
struct v3dv_pipeline_layout *layout;
|
|
|
|
|
2020-02-04 09:26:04 +00:00
|
|
|
enum v3dv_ez_state ez_state;
|
|
|
|
|
2020-02-18 10:08:44 +00:00
|
|
|
bool primitive_restart;
|
|
|
|
|
2020-07-31 00:11:39 +01:00
|
|
|
/* Accessed by binding. So vb[binding]->stride is the stride of the vertex
|
|
|
|
* array with such binding
|
|
|
|
*/
|
|
|
|
struct v3dv_pipeline_vertex_binding {
|
|
|
|
uint32_t stride;
|
|
|
|
uint32_t instance_divisor;
|
|
|
|
} vb[MAX_VBS];
|
|
|
|
uint32_t vb_count;
|
|
|
|
|
|
|
|
/* Note that a lot of info from VkVertexInputAttributeDescription is
|
|
|
|
* already prepacked, so storing here only those that need recheck later
|
|
|
|
*
|
|
|
|
* Note that they are not indexed by the location or nir driver location,
|
|
|
|
* as we are defining here only the inputs that the shader are really
|
|
|
|
* using.
|
|
|
|
*/
|
|
|
|
struct v3dv_pipeline_vertex_attrib {
|
|
|
|
uint32_t binding;
|
|
|
|
uint32_t offset;
|
|
|
|
/* We store driver_location instead of location because most v3d structs
|
|
|
|
* are indexed by driver_location
|
|
|
|
*/
|
|
|
|
uint32_t driver_location;
|
2020-01-14 15:17:09 +00:00
|
|
|
VkFormat vk_format;
|
2020-07-31 00:11:39 +01:00
|
|
|
} va[MAX_VERTEX_ATTRIBS];
|
|
|
|
uint32_t va_count;
|
|
|
|
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
struct v3dv_descriptor_map ubo_map;
|
|
|
|
struct v3dv_descriptor_map ssbo_map;
|
|
|
|
|
2020-03-10 11:34:00 +00:00
|
|
|
struct v3dv_descriptor_map sampler_map;
|
|
|
|
struct v3dv_descriptor_map texture_map;
|
|
|
|
|
v3dv/descriptor_set: combine texture and sampler indices
OpenGL doesn't have the concept of individual texture and sampler, so
texture and sampler indexes have the same value. v3d compiler uses
this assumption, so for example, the texture info at the v3d key
include values that you need to use the texture format and the sampler
to fill (like the return_size).
One option would be to adapt the v3d compiler to handle both, but then
we would need to adapt to the lowerings it uses, like nir_lower_tex,
that also take the same assumption.
We deal with this on the Vulkan driver, by reassigning the texture and
sampler index to a combined one. We add a hash table to map the
combined texture idx and sampler idx to this combined idx, and a
simple array to the opposite map. On the driver we work with the
separate indices to fill up the data, while the v3d compiler works
with the combined one.
As mentioned, this is needed to properly fill up the texture return
size, so as we are here, we fix that. This gets tests like the
following working:
dEQP-VK.glsl.texture_gather.basic.2d.depth32f.base_level.level_2
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-06 23:33:14 +01:00
|
|
|
/*
|
|
|
|
* Vulkan has separate texture and sampler objects. Previous sampler and
|
|
|
|
* texture map uses a sampler and texture index respectively, that can be
|
|
|
|
* different. But OpenGL combine both (or in other words, they are the
|
|
|
|
* same). The v3d compiler and all the nir lowerings that they use were
|
|
|
|
* written under that assumption. In order to not update all those, we
|
|
|
|
* combine the indexes, and we use the following maps to get one or the
|
|
|
|
* other. In general the driver side uses the tex/sampler indexes to gather
|
|
|
|
* resources, and the compiler side uses the combined index (so the v3d key
|
|
|
|
* texture info will be indexed using the combined index).
|
|
|
|
*/
|
|
|
|
struct hash_table *combined_index_map;
|
|
|
|
uint32_t combined_index_to_key_map[32];
|
|
|
|
uint32_t next_combined_index;
|
|
|
|
|
2020-01-14 15:17:09 +00:00
|
|
|
/* FIXME: this bo is another candidate to data to be uploaded using a
|
|
|
|
* resource manager, instead of a individual bo
|
|
|
|
*/
|
|
|
|
struct v3dv_bo *default_attribute_values;
|
|
|
|
|
2020-01-09 12:54:22 +00:00
|
|
|
struct vpm_config vpm_cfg;
|
|
|
|
struct vpm_config vpm_cfg_bin;
|
2020-01-29 15:35:39 +00:00
|
|
|
|
|
|
|
/* If the pipeline should emit any of the stencil configuration packets */
|
|
|
|
bool emit_stencil_cfg[2];
|
|
|
|
|
2020-09-11 22:26:07 +01:00
|
|
|
/* If the pipeline is using push constants */
|
|
|
|
bool use_push_constants;
|
|
|
|
|
2020-03-17 11:10:58 +00:00
|
|
|
/* Blend state */
|
|
|
|
struct {
|
|
|
|
/* Per-RT bit mask with blend enables */
|
|
|
|
uint8_t enables;
|
|
|
|
/* Per-RT prepacked blend config packets */
|
|
|
|
uint8_t cfg[V3D_MAX_DRAW_BUFFERS][cl_packet_length(BLEND_CFG)];
|
|
|
|
/* Flag indicating whether the blend factors in use require
|
|
|
|
* color constants.
|
|
|
|
*/
|
|
|
|
bool needs_color_constants;
|
|
|
|
/* Mask with enabled color channels for each RT (4 bits per RT) */
|
|
|
|
uint32_t color_write_masks;
|
|
|
|
} blend;
|
|
|
|
|
2020-05-13 09:35:30 +01:00
|
|
|
/* Depth bias */
|
|
|
|
struct {
|
|
|
|
bool enabled;
|
|
|
|
bool is_z16;
|
|
|
|
} depth_bias;
|
|
|
|
|
2020-01-05 00:51:04 +00:00
|
|
|
/* Packets prepacked during pipeline creation
|
|
|
|
*/
|
|
|
|
uint8_t cfg_bits[cl_packet_length(CFG_BITS)];
|
2020-01-09 12:54:22 +00:00
|
|
|
uint8_t shader_state_record[cl_packet_length(GL_SHADER_STATE_RECORD)];
|
2020-01-09 13:34:13 +00:00
|
|
|
uint8_t vcm_cache_size[cl_packet_length(VCM_CACHE_SIZE)];
|
2020-07-31 00:11:39 +01:00
|
|
|
uint8_t vertex_attrs[cl_packet_length(GL_SHADER_STATE_ATTRIBUTE_RECORD) *
|
2020-03-06 11:21:34 +00:00
|
|
|
MAX_VERTEX_ATTRIBS];
|
2020-01-29 15:35:39 +00:00
|
|
|
uint8_t stencil_cfg[2][cl_packet_length(STENCIL_CFG)];
|
2019-12-02 12:59:04 +00:00
|
|
|
};
|
|
|
|
|
2020-03-31 11:59:44 +01:00
|
|
|
const nir_shader_compiler_options *v3dv_pipeline_get_nir_options(void);
|
|
|
|
|
2020-02-06 11:36:48 +00:00
|
|
|
static inline uint32_t
|
|
|
|
v3dv_zs_buffer_from_aspect_bits(VkImageAspectFlags aspects)
|
|
|
|
{
|
|
|
|
const VkImageAspectFlags zs_aspects =
|
|
|
|
VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT;
|
|
|
|
const VkImageAspectFlags filtered_aspects = aspects & zs_aspects;
|
|
|
|
|
|
|
|
if (filtered_aspects == zs_aspects)
|
|
|
|
return ZSTENCIL;
|
|
|
|
else if (filtered_aspects == VK_IMAGE_ASPECT_DEPTH_BIT)
|
|
|
|
return Z;
|
|
|
|
else if (filtered_aspects == VK_IMAGE_ASPECT_STENCIL_BIT)
|
|
|
|
return STENCIL;
|
|
|
|
else
|
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
|
2020-02-07 11:24:18 +00:00
|
|
|
static inline uint32_t
|
|
|
|
v3dv_zs_buffer_from_vk_format(VkFormat format)
|
|
|
|
{
|
|
|
|
switch (format) {
|
|
|
|
case VK_FORMAT_D16_UNORM_S8_UINT:
|
|
|
|
case VK_FORMAT_D24_UNORM_S8_UINT:
|
|
|
|
case VK_FORMAT_D32_SFLOAT_S8_UINT:
|
|
|
|
return ZSTENCIL;
|
|
|
|
case VK_FORMAT_D16_UNORM:
|
|
|
|
case VK_FORMAT_D32_SFLOAT:
|
|
|
|
case VK_FORMAT_X8_D24_UNORM_PACK32:
|
|
|
|
return Z;
|
|
|
|
case VK_FORMAT_S8_UINT:
|
|
|
|
return STENCIL;
|
|
|
|
default:
|
|
|
|
return NONE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
uint32_t v3dv_physical_device_api_version(struct v3dv_physical_device *dev);
|
|
|
|
|
|
|
|
int v3dv_get_instance_entrypoint_index(const char *name);
|
|
|
|
int v3dv_get_device_entrypoint_index(const char *name);
|
|
|
|
int v3dv_get_physical_device_entrypoint_index(const char *name);
|
|
|
|
|
|
|
|
const char *v3dv_get_instance_entry_name(int index);
|
|
|
|
const char *v3dv_get_physical_device_entry_name(int index);
|
|
|
|
const char *v3dv_get_device_entry_name(int index);
|
|
|
|
|
|
|
|
bool
|
|
|
|
v3dv_instance_entrypoint_is_enabled(int index, uint32_t core_version,
|
|
|
|
const struct v3dv_instance_extension_table *instance);
|
|
|
|
bool
|
|
|
|
v3dv_physical_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
|
|
|
const struct v3dv_instance_extension_table *instance);
|
|
|
|
bool
|
|
|
|
v3dv_device_entrypoint_is_enabled(int index, uint32_t core_version,
|
|
|
|
const struct v3dv_instance_extension_table *instance,
|
|
|
|
const struct v3dv_device_extension_table *device);
|
|
|
|
|
|
|
|
void *v3dv_lookup_entrypoint(const struct v3d_device_info *devinfo,
|
|
|
|
const char *name);
|
|
|
|
|
|
|
|
#define v3dv_printflike(a, b) __attribute__((__format__(__printf__, a, b)))
|
|
|
|
|
|
|
|
VkResult __vk_errorf(struct v3dv_instance *instance, VkResult error,
|
|
|
|
const char *file, int line,
|
|
|
|
const char *format, ...);
|
|
|
|
|
|
|
|
#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__);
|
|
|
|
|
|
|
|
void v3dv_loge(const char *format, ...) v3dv_printflike(1, 2);
|
|
|
|
void v3dv_loge_v(const char *format, va_list va);
|
|
|
|
|
2020-01-15 07:48:07 +00:00
|
|
|
#define v3dv_debug_ignored_stype(sType) \
|
|
|
|
v3dv_loge("%s: ignored VkStructureType %u:%s\n", __func__, (sType), vk_StructureType_to_str(sType))
|
|
|
|
|
2019-12-03 11:54:30 +00:00
|
|
|
const struct v3dv_format *v3dv_get_format(VkFormat);
|
2019-12-10 14:15:06 +00:00
|
|
|
const uint8_t *v3dv_get_format_swizzle(VkFormat f);
|
2019-12-05 11:35:02 +00:00
|
|
|
void v3dv_get_internal_type_bpp_for_output_format(uint32_t format, uint32_t *type, uint32_t *bpp);
|
v3dv/descriptor_set: combine texture and sampler indices
OpenGL doesn't have the concept of individual texture and sampler, so
texture and sampler indexes have the same value. v3d compiler uses
this assumption, so for example, the texture info at the v3d key
include values that you need to use the texture format and the sampler
to fill (like the return_size).
One option would be to adapt the v3d compiler to handle both, but then
we would need to adapt to the lowerings it uses, like nir_lower_tex,
that also take the same assumption.
We deal with this on the Vulkan driver, by reassigning the texture and
sampler index to a combined one. We add a hash table to map the
combined texture idx and sampler idx to this combined idx, and a
simple array to the opposite map. On the driver we work with the
separate indices to fill up the data, while the v3d compiler works
with the combined one.
As mentioned, this is needed to properly fill up the texture return
size, so as we are here, we fix that. This gets tests like the
following working:
dEQP-VK.glsl.texture_gather.basic.2d.depth32f.base_level.level_2
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-06 23:33:14 +01:00
|
|
|
uint8_t v3dv_get_tex_return_size(const struct v3dv_format *vf, bool compare_enable);
|
2020-04-20 12:24:09 +01:00
|
|
|
bool v3dv_tfu_supports_tex_format(const struct v3d_device_info *devinfo,
|
|
|
|
uint32_t tex_format);
|
|
|
|
|
2020-03-25 10:50:16 +00:00
|
|
|
|
2019-12-03 11:54:30 +00:00
|
|
|
|
|
|
|
uint32_t v3d_utile_width(int cpp);
|
|
|
|
uint32_t v3d_utile_height(int cpp);
|
|
|
|
|
|
|
|
void v3d_load_tiled_image(void *dst, uint32_t dst_stride,
|
|
|
|
void *src, uint32_t src_stride,
|
|
|
|
enum v3d_tiling_mode tiling_format,
|
|
|
|
int cpp, uint32_t image_h,
|
|
|
|
const struct pipe_box *box);
|
|
|
|
|
|
|
|
void v3d_store_tiled_image(void *dst, uint32_t dst_stride,
|
|
|
|
void *src, uint32_t src_stride,
|
|
|
|
enum v3d_tiling_mode tiling_format,
|
|
|
|
int cpp, uint32_t image_h,
|
|
|
|
const struct pipe_box *box);
|
|
|
|
|
2020-01-03 11:43:35 +00:00
|
|
|
struct v3dv_cl_reloc v3dv_write_uniforms(struct v3dv_cmd_buffer *cmd_buffer,
|
|
|
|
struct v3dv_pipeline_stage *p_stage);
|
|
|
|
|
2020-03-25 10:50:16 +00:00
|
|
|
struct v3dv_shader_variant *
|
|
|
|
v3dv_get_shader_variant(struct v3dv_pipeline_stage *p_stage,
|
|
|
|
struct v3d_key *key,
|
2020-04-29 14:58:10 +01:00
|
|
|
size_t key_size,
|
|
|
|
const VkAllocationCallbacks *pAllocator,
|
|
|
|
VkResult *out_vk_result);
|
2020-03-25 10:50:16 +00:00
|
|
|
|
|
|
|
struct v3dv_descriptor *
|
|
|
|
v3dv_descriptor_map_get_descriptor(struct v3dv_descriptor_state *descriptor_state,
|
|
|
|
struct v3dv_descriptor_map *map,
|
|
|
|
struct v3dv_pipeline_layout *pipeline_layout,
|
|
|
|
uint32_t index,
|
|
|
|
uint32_t *dynamic_offset);
|
|
|
|
|
2020-04-06 23:32:49 +01:00
|
|
|
const struct v3dv_sampler *
|
|
|
|
v3dv_descriptor_map_get_sampler(struct v3dv_descriptor_state *descriptor_state,
|
|
|
|
struct v3dv_descriptor_map *map,
|
|
|
|
struct v3dv_pipeline_layout *pipeline_layout,
|
|
|
|
uint32_t index);
|
|
|
|
|
|
|
|
struct v3dv_image_view *
|
|
|
|
v3dv_descriptor_map_get_image_view(struct v3dv_descriptor_state *descriptor_state,
|
|
|
|
struct v3dv_descriptor_map *map,
|
|
|
|
struct v3dv_pipeline_layout *pipeline_layout,
|
|
|
|
uint32_t index);
|
|
|
|
|
2020-04-02 12:24:13 +01:00
|
|
|
static inline const struct v3dv_sampler *
|
|
|
|
v3dv_immutable_samplers(const struct v3dv_descriptor_set_layout *set,
|
|
|
|
const struct v3dv_descriptor_set_binding_layout *binding)
|
|
|
|
{
|
|
|
|
assert(binding->immutable_samplers_offset);
|
|
|
|
return (const struct v3dv_sampler *) ((const char *) set + binding->immutable_samplers_offset);
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
#define V3DV_DEFINE_HANDLE_CASTS(__v3dv_type, __VkType) \
|
|
|
|
\
|
|
|
|
static inline struct __v3dv_type * \
|
|
|
|
__v3dv_type ## _from_handle(__VkType _handle) \
|
|
|
|
{ \
|
|
|
|
return (struct __v3dv_type *) _handle; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static inline __VkType \
|
|
|
|
__v3dv_type ## _to_handle(struct __v3dv_type *_obj) \
|
|
|
|
{ \
|
|
|
|
return (__VkType) _obj; \
|
|
|
|
}
|
|
|
|
|
2019-11-27 21:08:51 +00:00
|
|
|
#define V3DV_DEFINE_NONDISP_HANDLE_CASTS(__v3dv_type, __VkType) \
|
|
|
|
\
|
|
|
|
static inline struct __v3dv_type * \
|
|
|
|
__v3dv_type ## _from_handle(__VkType _handle) \
|
|
|
|
{ \
|
|
|
|
return (struct __v3dv_type *)(uintptr_t) _handle; \
|
|
|
|
} \
|
|
|
|
\
|
|
|
|
static inline __VkType \
|
|
|
|
__v3dv_type ## _to_handle(struct __v3dv_type *_obj) \
|
|
|
|
{ \
|
|
|
|
return (__VkType)(uintptr_t) _obj; \
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
#define V3DV_FROM_HANDLE(__v3dv_type, __name, __handle) \
|
|
|
|
struct __v3dv_type *__name = __v3dv_type ## _from_handle(__handle)
|
|
|
|
|
|
|
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_cmd_buffer, VkCommandBuffer)
|
|
|
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_device, VkDevice)
|
|
|
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_instance, VkInstance)
|
|
|
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_physical_device, VkPhysicalDevice)
|
|
|
|
V3DV_DEFINE_HANDLE_CASTS(v3dv_queue, VkQueue)
|
|
|
|
|
2019-12-10 08:03:49 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_cmd_pool, VkCommandPool)
|
2019-12-09 09:07:36 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_buffer, VkBuffer)
|
2020-02-26 08:07:42 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_buffer_view, VkBufferView)
|
2019-11-27 21:08:51 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_device_memory, VkDeviceMemory)
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_pool, VkDescriptorPool)
|
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_set, VkDescriptorSet)
|
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_descriptor_set_layout, VkDescriptorSetLayout)
|
2020-02-26 08:36:27 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_event, VkEvent)
|
2020-01-14 08:48:19 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_fence, VkFence)
|
2019-12-09 12:16:16 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_framebuffer, VkFramebuffer)
|
2019-12-03 11:54:30 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image, VkImage)
|
2019-12-05 11:35:02 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_image_view, VkImageView)
|
2019-12-02 12:59:04 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_pipeline, VkPipeline)
|
v3dv: initial descriptor set support
Focused on getting the basic UBO and SSBO cases implemented. So no
dynamic offset, push contanst, samplers, and so on.
This include a initial implementation for CreatedescriptorPool,
CreateDescriptorSetLayout, AllocateDescriptorSets,
UpdateDescriptorSets, CreatePipelineLayout, and CmdBindDescriptorSets.
Also introduces lowering vulkan intrinsics. For now just
vulkan_resource_index.
We also introduce a descriptor_map, in this case for the ubos and
ssbos, used to assign a index for each set/binding combination, that
would be used when filling back the details of the ubo or ssbo on
other places (like QUNIFORM_UBO_ADDR or QUNIFORM_SSBO_OFFSET).
Note that at this point we don't need a bo for the descriptor pool, so
descriptor sets are not getting a piece of it. That would likely
change as we start to support more descriptor set types.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-01-20 14:29:38 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_pipeline_layout, VkPipelineLayout)
|
v3dv: implement occlusion queries
The design for queries in Vulkan requires that some commands execute
in the GPU as part of a command buffer. Unfortunately, V3D doesn't
really have supprt for this, which means that we need to execute them
in the CPU but we still need to make it look as if they happened
inside the comamnd buffer from the point of view of the user, which
adds certain hassle.
The above means that in some cases we need to do CPU waits for certain
parts of the command buffer to execute so we can then run the CPU
code. For exmaple, we need to wait before executing a query resets
just in case the GPU is using them, and we have to do a CPU wait wait
for previous GPU jobs to complete before copying query results if the
user has asked us to do that. In the future, we may want to have
submission thread instead so we don't block the main thread in these
scenarios.
Because we now need to execute some tasks in the CPU as part of a
command buffer, this introduces the concept of job types, there is one
type for all GPU jobs, and then we have one type for each kind of job
that needs to execute in the CPU. CPU jobs are executed by the queue
in order just like GPU jobs, only that they are exclusively CPU tasks.
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6766>
2020-04-16 09:30:38 +01:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_query_pool, VkQueryPool)
|
2019-12-09 10:16:09 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_render_pass, VkRenderPass)
|
2020-03-29 15:29:55 +01:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_sampler, VkSampler)
|
2020-01-13 11:31:12 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_semaphore, VkSemaphore)
|
2019-12-02 10:47:25 +00:00
|
|
|
V3DV_DEFINE_NONDISP_HANDLE_CASTS(v3dv_shader_module, VkShaderModule)
|
2019-11-25 15:29:12 +00:00
|
|
|
|
2019-12-05 11:35:02 +00:00
|
|
|
/* This is defined as a macro so that it works for both
|
|
|
|
* VkImageSubresourceRange and VkImageSubresourceLayers
|
|
|
|
*/
|
|
|
|
#define v3dv_layer_count(_image, _range) \
|
|
|
|
((_range)->layerCount == VK_REMAINING_ARRAY_LAYERS ? \
|
|
|
|
(_image)->array_size - (_range)->baseArrayLayer : (_range)->layerCount)
|
|
|
|
|
2020-03-29 15:29:55 +01:00
|
|
|
#define v3dv_level_count(_image, _range) \
|
|
|
|
((_range)->levelCount == VK_REMAINING_MIP_LEVELS ? \
|
|
|
|
(_image)->levels - (_range)->baseMipLevel : (_range)->levelCount)
|
|
|
|
|
2019-11-29 12:55:38 +00:00
|
|
|
static inline int
|
|
|
|
v3dv_ioctl(int fd, unsigned long request, void *arg)
|
|
|
|
{
|
|
|
|
if (using_v3d_simulator)
|
|
|
|
return v3d_simulator_ioctl(fd, request, arg);
|
|
|
|
else
|
|
|
|
return drmIoctl(fd, request, arg);
|
|
|
|
}
|
|
|
|
|
2019-11-25 15:29:12 +00:00
|
|
|
#endif /* V3DV_PRIVATE_H */
|