summaryrefslogtreecommitdiff
path: root/drivers/vulkan/rendering_device_vulkan.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/vulkan/rendering_device_vulkan.h')
-rw-r--r--drivers/vulkan/rendering_device_vulkan.h300
1 files changed, 158 insertions, 142 deletions
diff --git a/drivers/vulkan/rendering_device_vulkan.h b/drivers/vulkan/rendering_device_vulkan.h
index 6f8bbc9c64..a2527d5c33 100644
--- a/drivers/vulkan/rendering_device_vulkan.h
+++ b/drivers/vulkan/rendering_device_vulkan.h
@@ -5,8 +5,8 @@
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
-/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
-/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
+/* Copyright (c) 2007-2021 Juan Linietsky, Ariel Manzur. */
+/* Copyright (c) 2014-2021 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
@@ -31,9 +31,10 @@
#ifndef RENDERING_DEVICE_VULKAN_H
#define RENDERING_DEVICE_VULKAN_H
-#include "core/oa_hash_map.h"
#include "core/os/thread_safe.h"
-#include "core/rid_owner.h"
+#include "core/templates/local_vector.h"
+#include "core/templates/oa_hash_map.h"
+#include "core/templates/rid_owner.h"
#include "servers/rendering/rendering_device.h"
#ifdef DEBUG_ENABLED
@@ -45,11 +46,6 @@
#include <vulkan/vulkan.h>
-//todo:
-//compute
-//push constants
-//views of texture slices
-
class VulkanContext;
class RenderingDeviceVulkan : public RenderingDevice {
@@ -99,7 +95,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
ID_BASE_SHIFT = 58 //5 bits for ID types
};
- VkDevice device;
+ VkDevice device = VK_NULL_HANDLE;
Map<RID, Set<RID>> dependency_map; //IDs to IDs that depend on it
Map<RID, Set<RID>> reverse_dependency_map; //same as above, but in reverse
@@ -124,35 +120,40 @@ class RenderingDeviceVulkan : public RenderingDevice {
// for a framebuffer to render into it.
struct Texture {
- VkImage image;
- VmaAllocation allocation;
+ VkImage image = VK_NULL_HANDLE;
+ VmaAllocation allocation = nullptr;
VmaAllocationInfo allocation_info;
- VkImageView view;
+ VkImageView view = VK_NULL_HANDLE;
TextureType type;
DataFormat format;
TextureSamples samples;
- uint32_t width;
- uint32_t height;
- uint32_t depth;
- uint32_t layers;
- uint32_t mipmaps;
- uint32_t usage_flags;
- uint32_t base_mipmap;
- uint32_t base_layer;
+ uint32_t width = 0;
+ uint32_t height = 0;
+ uint32_t depth = 0;
+ uint32_t layers = 0;
+ uint32_t mipmaps = 0;
+ uint32_t usage_flags = 0;
+ uint32_t base_mipmap = 0;
+ uint32_t base_layer = 0;
Vector<DataFormat> allowed_shared_formats;
VkImageLayout layout;
- uint32_t read_aspect_mask;
- uint32_t barrier_aspect_mask;
- bool bound; //bound to framebffer
+ uint64_t used_in_frame = 0;
+ bool used_in_transfer = false;
+ bool used_in_raster = false;
+ bool used_in_compute = false;
+
+ uint32_t read_aspect_mask = 0;
+ uint32_t barrier_aspect_mask = 0;
+ bool bound = false; //bound to framebffer
RID owner;
};
RID_Owner<Texture, true> texture_owner;
- uint32_t texture_upload_region_size_px;
+ uint32_t texture_upload_region_size_px = 0;
Vector<uint8_t> _texture_get_data_from_image(Texture *tex, VkImage p_image, VmaAllocation p_allocation, uint32_t p_layer, bool p_2d = false);
@@ -188,32 +189,28 @@ class RenderingDeviceVulkan : public RenderingDevice {
// See the comments in the code to understand better how it works.
struct StagingBufferBlock {
- VkBuffer buffer;
- VmaAllocation allocation;
- uint64_t frame_used;
- uint32_t fill_amount;
+ VkBuffer buffer = VK_NULL_HANDLE;
+ VmaAllocation allocation = nullptr;
+ uint64_t frame_used = 0;
+ uint32_t fill_amount = 0;
};
Vector<StagingBufferBlock> staging_buffer_blocks;
- int staging_buffer_current;
- uint32_t staging_buffer_block_size;
- uint64_t staging_buffer_max_size;
- bool staging_buffer_used;
+ int staging_buffer_current = 0;
+ uint32_t staging_buffer_block_size = 0;
+ uint64_t staging_buffer_max_size = 0;
+ bool staging_buffer_used = false;
Error _staging_buffer_allocate(uint32_t p_amount, uint32_t p_required_align, uint32_t &r_alloc_offset, uint32_t &r_alloc_size, bool p_can_segment = true, bool p_on_draw_command_buffer = false);
Error _insert_staging_block();
struct Buffer {
- uint32_t size;
- uint32_t usage;
- VkBuffer buffer;
- VmaAllocation allocation;
+ uint32_t size = 0;
+ uint32_t usage = 0;
+ VkBuffer buffer = VK_NULL_HANDLE;
+ VmaAllocation allocation = nullptr;
VkDescriptorBufferInfo buffer_info; //used for binding
Buffer() {
- size = 0;
- usage = 0;
- buffer = VK_NULL_HANDLE;
- allocation = nullptr;
}
};
@@ -236,13 +233,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
// used for the render pipelines.
struct FramebufferFormatKey {
- Size2i empty_size;
Vector<AttachmentFormat> attachments;
bool operator<(const FramebufferFormatKey &p_key) const {
- if (empty_size != p_key.empty_size) {
- return empty_size < p_key.empty_size;
- }
-
int as = attachments.size();
int bs = p_key.attachments.size();
if (as != bs) {
@@ -276,15 +268,15 @@ class RenderingDeviceVulkan : public RenderingDevice {
Map<FramebufferFormatKey, FramebufferFormatID> framebuffer_format_cache;
struct FramebufferFormat {
const Map<FramebufferFormatKey, FramebufferFormatID>::Element *E;
- VkRenderPass render_pass; //here for constructing shaders, never used, see section (7.2. Render Pass Compatibility from Vulkan spec)
- int color_attachments; //used for pipeline validation
+ VkRenderPass render_pass = VK_NULL_HANDLE; //here for constructing shaders, never used, see section (7.2. Render Pass Compatibility from Vulkan spec)
+ int color_attachments = 0; //used for pipeline validation
TextureSamples samples;
};
Map<FramebufferFormatID, FramebufferFormat> framebuffer_formats;
struct Framebuffer {
- FramebufferFormatID format_id;
+ FramebufferFormatID format_id = 0;
struct VersionKey {
InitialAction initial_color_action;
FinalAction final_color_action;
@@ -307,12 +299,12 @@ class RenderingDeviceVulkan : public RenderingDevice {
}
};
- uint32_t storage_mask;
+ uint32_t storage_mask = 0;
Vector<RID> texture_ids;
struct Version {
- VkFramebuffer framebuffer;
- VkRenderPass render_pass; //this one is owned
+ VkFramebuffer framebuffer = VK_NULL_HANDLE;
+ VkRenderPass render_pass = VK_NULL_HANDLE; //this one is owned
};
Map<VersionKey, Version> framebuffers;
@@ -399,8 +391,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct VertexDescriptionCache {
Vector<VertexAttribute> vertex_formats;
- VkVertexInputBindingDescription *bindings;
- VkVertexInputAttributeDescription *attributes;
+ VkVertexInputBindingDescription *bindings = nullptr;
+ VkVertexInputAttributeDescription *attributes = nullptr;
VkPipelineVertexInputStateCreateInfo create_info;
};
@@ -408,9 +400,9 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct VertexArray {
RID buffer;
- VertexFormatID description;
- int vertex_count;
- uint32_t max_instances_allowed;
+ VertexFormatID description = 0;
+ int vertex_count = 0;
+ uint32_t max_instances_allowed = 0;
Vector<VkBuffer> buffers; //not owned, just referenced
Vector<VkDeviceSize> offsets;
@@ -419,21 +411,21 @@ class RenderingDeviceVulkan : public RenderingDevice {
RID_Owner<VertexArray, true> vertex_array_owner;
struct IndexBuffer : public Buffer {
- uint32_t max_index; //used for validation
- uint32_t index_count;
- VkIndexType index_type;
- bool supports_restart_indices;
+ uint32_t max_index = 0; //used for validation
+ uint32_t index_count = 0;
+ VkIndexType index_type = VK_INDEX_TYPE_NONE_NV;
+ bool supports_restart_indices = false;
};
RID_Owner<IndexBuffer, true> index_buffer_owner;
struct IndexArray {
- uint32_t max_index; //remember the maximum index here too, for validation
+ uint32_t max_index = 0; //remember the maximum index here too, for validation
VkBuffer buffer; //not owned, inherited from index buffer
- uint32_t offset;
- uint32_t indices;
- VkIndexType index_type;
- bool supports_restart_indices;
+ uint32_t offset = 0;
+ uint32_t indices = 0;
+ VkIndexType index_type = VK_INDEX_TYPE_NONE_NV;
+ bool supports_restart_indices = false;
};
RID_Owner<IndexArray, true> index_array_owner;
@@ -459,10 +451,10 @@ class RenderingDeviceVulkan : public RenderingDevice {
};
struct UniformInfo {
- UniformType type;
- int binding;
- uint32_t stages;
- int length; //size of arrays (in total elements), or ubos (in bytes * total elements)
+ UniformType type = UniformType::UNIFORM_TYPE_MAX;
+ int binding = 0;
+ uint32_t stages = 0;
+ int length = 0; //size of arrays (in total elements), or ubos (in bytes * total elements)
bool operator!=(const UniformInfo &p_info) const {
return (binding != p_info.binding || type != p_info.type || stages != p_info.stages || length != p_info.length);
@@ -528,25 +520,27 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct Shader {
struct Set {
Vector<UniformInfo> uniform_info;
- VkDescriptorSetLayout descriptor_set_layout;
+ VkDescriptorSetLayout descriptor_set_layout = VK_NULL_HANDLE;
};
- uint32_t vertex_input_mask; //inputs used, this is mostly for validation
- int fragment_outputs;
+ uint32_t vertex_input_mask = 0; //inputs used, this is mostly for validation
+ int fragment_outputs = 0;
struct PushConstant {
- uint32_t push_constant_size;
- uint32_t push_constants_vk_stage;
+ uint32_t push_constant_size = 0;
+ uint32_t push_constants_vk_stage = 0;
};
PushConstant push_constant;
+ uint32_t compute_local_size[3] = { 0, 0, 0 };
+
bool is_compute = false;
- int max_output;
+ int max_output = 0;
Vector<Set> sets;
Vector<uint32_t> set_formats;
Vector<VkPipelineShaderStageCreateInfo> pipeline_stages;
- VkPipelineLayout pipeline_layout;
+ VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
};
String _shader_uniform_debug(RID p_shader, int p_set = -1);
@@ -610,7 +604,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
};
Map<DescriptorPoolKey, Set<DescriptorPool *>> descriptor_pools;
- uint32_t max_descriptors_per_pool;
+ uint32_t max_descriptors_per_pool = 0;
DescriptorPool *_descriptor_pool_allocate(const DescriptorPoolKey &p_key);
void _descriptor_pool_free(const DescriptorPoolKey &p_key, DescriptorPool *p_pool);
@@ -621,7 +615,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
//texture buffer needs a view
struct TextureBuffer {
Buffer buffer;
- VkBufferView view;
+ VkBufferView view = VK_NULL_HANDLE;
};
RID_Owner<TextureBuffer, true> texture_buffer_owner;
@@ -635,14 +629,19 @@ class RenderingDeviceVulkan : public RenderingDevice {
// the above restriction is not too serious.
struct UniformSet {
- uint32_t format;
+ uint32_t format = 0;
RID shader_id;
- uint32_t shader_set;
- DescriptorPool *pool;
+ uint32_t shader_set = 0;
+ DescriptorPool *pool = nullptr;
DescriptorPoolKey pool_key;
- VkDescriptorSet descriptor_set;
+ VkDescriptorSet descriptor_set = VK_NULL_HANDLE;
//VkPipelineLayout pipeline_layout; //not owned, inherited from shader
- Vector<RID> attachable_textures; //used for validation
+ struct AttachableTexture {
+ uint32_t bind;
+ RID texture;
+ };
+
+ LocalVector<AttachableTexture> attachable_textures; //used for validation
Vector<Texture *> mutable_sampled_textures; //used for layout change
Vector<Texture *> mutable_storage_textures; //used for layout change
};
@@ -668,21 +667,21 @@ class RenderingDeviceVulkan : public RenderingDevice {
//Cached values for validation
#ifdef DEBUG_ENABLED
struct Validation {
- FramebufferFormatID framebuffer_format;
- uint32_t dynamic_state;
- VertexFormatID vertex_format;
- bool uses_restart_indices;
- uint32_t primitive_minimum;
- uint32_t primitive_divisor;
+ FramebufferFormatID framebuffer_format = 0;
+ uint32_t dynamic_state = 0;
+ VertexFormatID vertex_format = 0;
+ bool uses_restart_indices = false;
+ uint32_t primitive_minimum = 0;
+ uint32_t primitive_divisor = 0;
} validation;
#endif
//Actual pipeline
RID shader;
Vector<uint32_t> set_formats;
- VkPipelineLayout pipeline_layout; // not owned, needed for push constants
- VkPipeline pipeline;
- uint32_t push_constant_size;
- uint32_t push_constant_stages;
+ VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // not owned, needed for push constants
+ VkPipeline pipeline = VK_NULL_HANDLE;
+ uint32_t push_constant_size = 0;
+ uint32_t push_constant_stages = 0;
};
RID_Owner<RenderPipeline, true> render_pipeline_owner;
@@ -690,10 +689,11 @@ class RenderingDeviceVulkan : public RenderingDevice {
struct ComputePipeline {
RID shader;
Vector<uint32_t> set_formats;
- VkPipelineLayout pipeline_layout; // not owned, needed for push constants
- VkPipeline pipeline;
- uint32_t push_constant_size;
- uint32_t push_constant_stages;
+ VkPipelineLayout pipeline_layout = VK_NULL_HANDLE; // not owned, needed for push constants
+ VkPipeline pipeline = VK_NULL_HANDLE;
+ uint32_t push_constant_size = 0;
+ uint32_t push_constant_stages = 0;
+ uint32_t local_group_size[3] = { 0, 0, 0 };
};
RID_Owner<ComputePipeline, true> compute_pipeline_owner;
@@ -714,14 +714,14 @@ class RenderingDeviceVulkan : public RenderingDevice {
// each needs it's own command pool.
struct SplitDrawListAllocator {
- VkCommandPool command_pool;
+ VkCommandPool command_pool = VK_NULL_HANDLE;
Vector<VkCommandBuffer> command_buffers; //one for each frame
};
Vector<SplitDrawListAllocator> split_draw_list_allocators;
struct DrawList {
- VkCommandBuffer command_buffer; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
+ VkCommandBuffer command_buffer = VK_NULL_HANDLE; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
Rect2i viewport;
struct SetState {
@@ -755,7 +755,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
bool index_buffer_uses_restart_indices = false;
uint32_t index_array_size = 0;
uint32_t index_array_max_index = 0;
- uint32_t index_array_offset;
+ uint32_t index_array_offset = 0;
Vector<uint32_t> set_formats;
Vector<bool> set_bound;
Vector<RID> set_rids;
@@ -766,8 +766,8 @@ class RenderingDeviceVulkan : public RenderingDevice {
RID pipeline_shader;
uint32_t invalid_set_from = 0;
bool pipeline_uses_restart_indices = false;
- uint32_t pipeline_primitive_divisor;
- uint32_t pipeline_primitive_minimum;
+ uint32_t pipeline_primitive_divisor = 0;
+ uint32_t pipeline_primitive_minimum = 0;
Vector<uint32_t> pipeline_set_formats;
uint32_t pipeline_push_constant_size = 0;
bool pipeline_push_constant_supplied = false;
@@ -781,25 +781,26 @@ class RenderingDeviceVulkan : public RenderingDevice {
#endif
};
- DrawList *draw_list; // One for regular draw lists, multiple for split.
- uint32_t draw_list_count;
- bool draw_list_split;
+ DrawList *draw_list = nullptr; // One for regular draw lists, multiple for split.
+ uint32_t draw_list_count = 0;
+ bool draw_list_split = false;
Vector<RID> draw_list_bound_textures;
Vector<RID> draw_list_storage_textures;
- bool draw_list_unbind_color_textures;
- bool draw_list_unbind_depth_textures;
+ bool draw_list_unbind_color_textures = false;
+ bool draw_list_unbind_depth_textures = false;
void _draw_list_insert_clear_region(DrawList *draw_list, Framebuffer *framebuffer, Point2i viewport_offset, Point2i viewport_size, bool p_clear_color, const Vector<Color> &p_clear_colors, bool p_clear_depth, float p_depth, uint32_t p_stencil);
Error _draw_list_setup_framebuffer(Framebuffer *p_framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, VkFramebuffer *r_framebuffer, VkRenderPass *r_render_pass);
Error _draw_list_render_pass_begin(Framebuffer *framebuffer, InitialAction p_initial_color_action, FinalAction p_final_color_action, InitialAction p_initial_depth_action, FinalAction p_final_depth_action, const Vector<Color> &p_clear_colors, float p_clear_depth, uint32_t p_clear_stencil, Point2i viewport_offset, Point2i viewport_size, VkFramebuffer vkframebuffer, VkRenderPass render_pass, VkCommandBuffer command_buffer, VkSubpassContents subpass_contents, const Vector<RID> &p_storage_textures);
_FORCE_INLINE_ DrawList *_get_draw_list_ptr(DrawListID p_id);
+ Buffer *_get_buffer_from_owner(RID p_buffer, VkPipelineStageFlags &dst_stage_mask, VkAccessFlags &dst_access, uint32_t p_post_barrier);
/**********************/
/**** COMPUTE LIST ****/
/**********************/
struct ComputeList {
- VkCommandBuffer command_buffer; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
+ VkCommandBuffer command_buffer = VK_NULL_HANDLE; // If persistent, this is owned, otherwise it's shared with the ringbuffer.
struct SetState {
uint32_t pipeline_expected_format = 0;
@@ -815,8 +816,10 @@ class RenderingDeviceVulkan : public RenderingDevice {
uint32_t set_count = 0;
RID pipeline;
RID pipeline_shader;
+ uint32_t local_group_size[3] = { 0, 0, 0 };
VkPipelineLayout pipeline_layout = VK_NULL_HANDLE;
uint32_t pipeline_push_constant_stages = 0;
+ bool allow_draw_overlap;
} state;
#ifdef DEBUG_ENABLED
@@ -836,7 +839,7 @@ class RenderingDeviceVulkan : public RenderingDevice {
#endif
};
- ComputeList *compute_list;
+ ComputeList *compute_list = nullptr;
/**************************/
/**** FRAME MANAGEMENT ****/
@@ -868,46 +871,46 @@ class RenderingDeviceVulkan : public RenderingDevice {
List<RenderPipeline> render_pipelines_to_dispose_of;
List<ComputePipeline> compute_pipelines_to_dispose_of;
- VkCommandPool command_pool;
- VkCommandBuffer setup_command_buffer; //used at the beginning of every frame for set-up
- VkCommandBuffer draw_command_buffer; //used at the beginning of every frame for set-up
+ VkCommandPool command_pool = VK_NULL_HANDLE;
+ VkCommandBuffer setup_command_buffer = VK_NULL_HANDLE; //used at the beginning of every frame for set-up
+ VkCommandBuffer draw_command_buffer = VK_NULL_HANDLE; //used at the beginning of every frame for set-up
struct Timestamp {
String description;
- uint64_t value;
+ uint64_t value = 0;
};
VkQueryPool timestamp_pool;
- String *timestamp_names;
- uint64_t *timestamp_cpu_values;
- uint32_t timestamp_count;
- String *timestamp_result_names;
- uint64_t *timestamp_cpu_result_values;
- uint64_t *timestamp_result_values;
- uint32_t timestamp_result_count;
- uint64_t index;
+ String *timestamp_names = nullptr;
+ uint64_t *timestamp_cpu_values = nullptr;
+ uint32_t timestamp_count = 0;
+ String *timestamp_result_names = nullptr;
+ uint64_t *timestamp_cpu_result_values = nullptr;
+ uint64_t *timestamp_result_values = nullptr;
+ uint32_t timestamp_result_count = 0;
+ uint64_t index = 0;
};
- uint32_t max_timestamp_query_elements;
+ uint32_t max_timestamp_query_elements = 0;
- Frame *frames; //frames available, for main device they are cycled (usually 3), for local devices only 1
- int frame; //current frame
- int frame_count; //total amount of frames
- uint64_t frames_drawn;
+ Frame *frames = nullptr; //frames available, for main device they are cycled (usually 3), for local devices only 1
+ int frame = 0; //current frame
+ int frame_count = 0; //total amount of frames
+ uint64_t frames_drawn = 0;
RID local_device;
bool local_device_processing = false;
void _free_pending_resources(int p_frame);
- VmaAllocator allocator;
+ VmaAllocator allocator = nullptr;
- VulkanContext *context;
+ VulkanContext *context = nullptr;
void _free_internal(RID p_id);
void _flush(bool p_current_frame);
- bool screen_prepared;
+ bool screen_prepared = false;
template <class T>
void _free_rids(T &p_owner, const char *p_type);
@@ -920,27 +923,27 @@ public:
virtual RID texture_create_shared(const TextureView &p_view, RID p_with_texture);
virtual RID texture_create_shared_from_slice(const TextureView &p_view, RID p_with_texture, uint32_t p_layer, uint32_t p_mipmap, TextureSliceType p_slice_type = TEXTURE_SLICE_2D);
- virtual Error texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, bool p_sync_with_draw = false);
+ virtual Error texture_update(RID p_texture, uint32_t p_layer, const Vector<uint8_t> &p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL);
virtual Vector<uint8_t> texture_get_data(RID p_texture, uint32_t p_layer);
virtual bool texture_is_format_supported_for_usage(DataFormat p_format, uint32_t p_usage) const;
virtual bool texture_is_shared(RID p_texture);
virtual bool texture_is_valid(RID p_texture);
- virtual Error texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, bool p_sync_with_draw = false);
- virtual Error texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, bool p_sync_with_draw = false);
- virtual Error texture_resolve_multisample(RID p_from_texture, RID p_to_texture, bool p_sync_with_draw = false);
+ virtual Error texture_copy(RID p_from_texture, RID p_to_texture, const Vector3 &p_from, const Vector3 &p_to, const Vector3 &p_size, uint32_t p_src_mipmap, uint32_t p_dst_mipmap, uint32_t p_src_layer, uint32_t p_dst_layer, uint32_t p_post_barrier = BARRIER_MASK_ALL);
+ virtual Error texture_clear(RID p_texture, const Color &p_color, uint32_t p_base_mipmap, uint32_t p_mipmaps, uint32_t p_base_layer, uint32_t p_layers, uint32_t p_post_barrier = BARRIER_MASK_ALL);
+ virtual Error texture_resolve_multisample(RID p_from_texture, RID p_to_texture, uint32_t p_post_barrier = BARRIER_MASK_ALL);
/*********************/
/**** FRAMEBUFFER ****/
/*********************/
virtual FramebufferFormatID framebuffer_format_create(const Vector<AttachmentFormat> &p_format);
- virtual FramebufferFormatID framebuffer_format_create_empty(const Size2i &p_size);
+ virtual FramebufferFormatID framebuffer_format_create_empty(TextureSamples p_samples = TEXTURE_SAMPLES_1);
virtual TextureSamples framebuffer_format_get_texture_samples(FramebufferFormatID p_format);
virtual RID framebuffer_create(const Vector<RID> &p_texture_attachments, FramebufferFormatID p_format_check = INVALID_ID);
- virtual RID framebuffer_create_empty(const Size2i &p_size, FramebufferFormatID p_format_check = INVALID_ID);
+ virtual RID framebuffer_create_empty(const Size2i &p_size, TextureSamples p_samples = TEXTURE_SAMPLES_1, FramebufferFormatID p_format_check = INVALID_ID);
virtual FramebufferFormatID framebuffer_get_format(RID p_framebuffer);
@@ -954,7 +957,7 @@ public:
/**** VERTEX ARRAY ****/
/**********************/
- virtual RID vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>());
+ virtual RID vertex_buffer_create(uint32_t p_size_bytes, const Vector<uint8_t> &p_data = Vector<uint8_t>(), bool p_use_as_storage = false);
// Internally reference counted, this ID is warranted to be unique for the same description, but needs to be freed as many times as it was allocated
virtual VertexFormatID vertex_format_create(const Vector<VertexAttribute> &p_vertex_formats);
@@ -982,7 +985,8 @@ public:
virtual RID uniform_set_create(const Vector<Uniform> &p_uniforms, RID p_shader, uint32_t p_shader_set);
virtual bool uniform_set_is_valid(RID p_uniform_set);
- virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, bool p_sync_with_draw = false); //works for any buffer
+ virtual Error buffer_update(RID p_buffer, uint32_t p_offset, uint32_t p_size, const void *p_data, uint32_t p_post_barrier = BARRIER_MASK_ALL); //works for any buffer
+ virtual Error buffer_clear(RID p_buffer, uint32_t p_offset, uint32_t p_size, uint32_t p_post_barrier = BARRIER_MASK_ALL);
virtual Vector<uint8_t> buffer_get_data(RID p_buffer);
/*************************/
@@ -1028,22 +1032,24 @@ public:
virtual void draw_list_enable_scissor(DrawListID p_list, const Rect2 &p_rect);
virtual void draw_list_disable_scissor(DrawListID p_list);
- virtual void draw_list_end();
+ virtual void draw_list_end(uint32_t p_post_barrier = BARRIER_MASK_ALL);
/***********************/
/**** COMPUTE LISTS ****/
/***********************/
- virtual ComputeListID compute_list_begin();
+ virtual ComputeListID compute_list_begin(bool p_allow_draw_overlap = false);
virtual void compute_list_bind_compute_pipeline(ComputeListID p_list, RID p_compute_pipeline);
virtual void compute_list_bind_uniform_set(ComputeListID p_list, RID p_uniform_set, uint32_t p_index);
virtual void compute_list_set_push_constant(ComputeListID p_list, const void *p_data, uint32_t p_data_size);
virtual void compute_list_add_barrier(ComputeListID p_list);
virtual void compute_list_dispatch(ComputeListID p_list, uint32_t p_x_groups, uint32_t p_y_groups, uint32_t p_z_groups);
+ virtual void compute_list_dispatch_threads(ComputeListID p_list, uint32_t p_x_threads, uint32_t p_y_threads, uint32_t p_z_threads);
virtual void compute_list_dispatch_indirect(ComputeListID p_list, RID p_buffer, uint32_t p_offset);
- virtual void compute_list_end();
+ virtual void compute_list_end(uint32_t p_post_barrier = BARRIER_MASK_ALL);
+ virtual void barrier(uint32_t p_from = BARRIER_MASK_ALL, uint32_t p_to = BARRIER_MASK_ALL);
virtual void full_barrier();
/**************/
@@ -1056,7 +1062,7 @@ public:
/**** Timing ****/
/****************/
- virtual void capture_timestamp(const String &p_name, bool p_sync_to_draw);
+ virtual void capture_timestamp(const String &p_name);
virtual uint32_t get_captured_timestamps_count() const;
virtual uint64_t get_captured_timestamps_frame() const;
virtual uint64_t get_captured_timestamp_gpu_time(uint32_t p_index) const;
@@ -1084,6 +1090,16 @@ public:
virtual uint64_t get_memory_usage() const;
+ virtual void set_resource_name(RID p_id, const String p_name);
+
+ virtual void draw_command_begin_label(String p_label_name, const Color p_color = Color(1, 1, 1, 1));
+ virtual void draw_command_insert_label(String p_label_name, const Color p_color = Color(1, 1, 1, 1));
+ virtual void draw_command_end_label();
+
+ virtual String get_device_vendor_name() const;
+ virtual String get_device_name() const;
+ virtual String get_device_pipeline_cache_uuid() const;
+
RenderingDeviceVulkan();
~RenderingDeviceVulkan();
};