ReactOS 0.4.17-dev-923-g4c9a150
wined3d_vk.h File Reference
#include "stdint.h"
#include "wine/list.h"
#include "wine/wined3d.h"
#include "wine/vulkan.h"
#include "wined3d_private.h"
Include dependency graph for wined3d_vk.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  vulkan_ops
 
struct  wined3d_vk_info
 
struct  wined3d_bo_vk
 
struct  wined3d_bo_slab_vk_key
 
struct  wined3d_bo_slab_vk
 
struct  wined3d_image_vk
 
struct  wined3d_query_pool_vk
 
struct  wined3d_query_pool_idx_vk
 
struct  wined3d_query_vk
 
struct  wined3d_command_buffer_vk
 
struct  wined3d_retired_object_vk
 
struct  wined3d_retired_objects_vk
 
struct  wined3d_render_pass_attachment_vk
 
struct  wined3d_render_pass_key_vk
 
struct  wined3d_render_pass_vk
 
struct  wined3d_pipeline_layout_key_vk
 
struct  wined3d_pipeline_layout_vk
 
struct  wined3d_graphics_pipeline_key_vk
 
struct  wined3d_graphics_pipeline_vk
 
struct  wined3d_shader_resource_binding
 
struct  wined3d_shader_resource_bindings
 
struct  wined3d_shader_descriptor_writes_vk
 
struct  wined3d_context_vk
 
struct  wined3d_adapter_vk
 
struct  wined3d_null_resources_vk
 
struct  wined3d_null_views_vk
 
struct  wined3d_allocator_chunk_vk
 
struct  wined3d_uav_clear_pipelines_vk
 
struct  wined3d_uav_clear_state_vk
 
struct  wined3d_device_vk
 
struct  wined3d_texture_vk
 
struct  wined3d_sampler_vk
 
struct  wined3d_buffer_vk
 
struct  wined3d_rendertarget_view_vk
 
struct  wined3d_view_vk
 
struct  wined3d_shader_resource_view_vk
 
struct  wined3d_unordered_access_view_vk
 
struct  wined3d_swapchain_vk
 
struct  wined3d_format_vk
 

Macros

#define VK_NO_PROTOTYPES
 
#define VK_INSTANCE_FUNCS()
 
#define VK_DEVICE_FUNCS()
 
#define DECLARE_VK_PFN(name)   PFN_##name name;
 
#define VK_INSTANCE_PFN   DECLARE_VK_PFN
 
#define VK_INSTANCE_EXT_PFN   DECLARE_VK_PFN
 
#define VK_DEVICE_PFN   DECLARE_VK_PFN
 
#define VK_DEVICE_EXT_PFN   DECLARE_VK_PFN
 
#define VK_CALL(f)   (vk_info->vk_ops.f)
 
#define WINED3D_QUERY_VK_FLAG_ACTIVE   0x00000001
 
#define WINED3D_QUERY_VK_FLAG_STARTED   0x00000002
 
#define WINED3D_QUERY_VK_FLAG_RENDER_PASS   0x00000004
 
#define WINED3D_FB_ATTACHMENT_FLAG_DISCARDED   1
 
#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_C   2
 
#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_S   4
 
#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_Z   8
 

Enumerations

enum  wined3d_vk_extension {
  WINED3D_VK_EXT_NONE , WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE , WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE2 , WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE3 ,
  WINED3D_VK_EXT_HOST_QUERY_RESET , WINED3D_VK_EXT_SHADER_STENCIL_EXPORT , WINED3D_VK_EXT_TRANSFORM_FEEDBACK , WINED3D_VK_EXT_VERTEX_ATTRIBUTE_DIVISOR ,
  WINED3D_VK_KHR_MAINTENANCE2 , WINED3D_VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE , WINED3D_VK_KHR_SHADER_DRAW_PARAMETERS , WINED3D_VK_EXT_COUNT
}
 
enum  wined3d_retired_object_type_vk {
  WINED3D_RETIRED_FREE_VK , WINED3D_RETIRED_FRAMEBUFFER_VK , WINED3D_RETIRED_DESCRIPTOR_POOL_VK , WINED3D_RETIRED_MEMORY_VK ,
  WINED3D_RETIRED_ALLOCATOR_BLOCK_VK , WINED3D_RETIRED_BO_SLAB_SLICE_VK , WINED3D_RETIRED_BUFFER_VK , WINED3D_RETIRED_IMAGE_VK ,
  WINED3D_RETIRED_BUFFER_VIEW_VK , WINED3D_RETIRED_IMAGE_VIEW_VK , WINED3D_RETIRED_SAMPLER_VK , WINED3D_RETIRED_QUERY_POOL_VK ,
  WINED3D_RETIRED_EVENT_VK , WINED3D_RETIRED_PIPELINE_VK
}
 
enum  wined3d_shader_descriptor_type {
  WINED3D_SHADER_DESCRIPTOR_TYPE_CBV , WINED3D_SHADER_DESCRIPTOR_TYPE_SRV , WINED3D_SHADER_DESCRIPTOR_TYPE_UAV , WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER ,
  WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER
}
 

Functions

VkAccessFlags vk_access_mask_from_bind_flags (uint32_t bind_flags)
 
VkCompareOp vk_compare_op_from_wined3d (enum wined3d_cmp_func op)
 
VkImageViewType vk_image_view_type_from_wined3d (enum wined3d_resource_type type, uint32_t flags)
 
VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags (uint32_t bind_flags)
 
VkShaderStageFlagBits vk_shader_stage_from_wined3d (enum wined3d_shader_type shader_type)
 
VkAccessFlags vk_access_mask_from_buffer_usage (VkBufferUsageFlags usage)
 
VkPipelineStageFlags vk_pipeline_stage_mask_from_buffer_usage (VkBufferUsageFlags usage)
 
VkBufferUsageFlags vk_buffer_usage_from_bind_flags (uint32_t bind_flags)
 
VkMemoryPropertyFlags vk_memory_type_from_access_flags (uint32_t access, uint32_t usage)
 
void wined3d_format_colour_to_vk (const struct wined3d_format *format, const struct wined3d_color *c, VkClearColorValue *retval)
 
void wined3d_vk_swizzle_from_color_fixup (VkComponentMapping *mapping, struct color_fixup_desc fixup)
 
const char * wined3d_debug_vkresult (VkResult vr)
 
static VkImageAspectFlags vk_aspect_mask_from_format (const struct wined3d_format *format)
 
static struct wined3d_bo_vk * wined3d_bo_vk (struct wined3d_bo *bo)
 
void * wined3d_bo_slab_vk_map (struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_bo_slab_vk_unmap (struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk)
 
bool wined3d_query_pool_vk_allocate_query (struct wined3d_query_pool_vk *pool_vk, size_t *idx)
 
void wined3d_query_pool_vk_mark_free (struct wined3d_context_vk *context_vk, struct wined3d_query_pool_vk *pool_vk, uint32_t start, uint32_t count)
 
void wined3d_query_pool_vk_cleanup (struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk)
 
bool wined3d_query_pool_vk_init (struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk, enum wined3d_query_type type, struct list *free_pools)
 
static struct wined3d_query_vk * wined3d_query_vk (struct wined3d_query *query)
 
bool wined3d_query_vk_accumulate_data (struct wined3d_query_vk *query_vk, struct wined3d_device_vk *device_vk, const struct wined3d_query_pool_idx_vk *pool_idx)
 
HRESULT wined3d_query_vk_create (struct wined3d_device *device, enum wined3d_query_type type, void *parent, const struct wined3d_parent_ops *parent_ops, struct wined3d_query **query)
 
void wined3d_query_vk_resume (struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_query_vk_suspend (struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk)
 
static struct wined3d_context_vk * wined3d_context_vk (struct wined3d_context *context)
 
bool wined3d_context_vk_allocate_query (struct wined3d_context_vk *context_vk, enum wined3d_query_type type, struct wined3d_query_pool_idx_vk *pool_idx)
 
VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory (struct wined3d_context_vk *context_vk, unsigned int pool, size_t size)
 
VkCommandBuffer wined3d_context_vk_apply_compute_state (struct wined3d_context_vk *context_vk, const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk)
 
VkCommandBuffer wined3d_context_vk_apply_draw_state (struct wined3d_context_vk *context_vk, const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk, bool indexed)
 
void wined3d_context_vk_cleanup (struct wined3d_context_vk *context_vk)
 
BOOL wined3d_context_vk_create_bo (struct wined3d_context_vk *context_vk, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo)
 
BOOL wined3d_context_vk_create_image (struct wined3d_context_vk *context_vk, VkImageType vk_image_type, VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth, unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags, struct wined3d_image_vk *image)
 
void wined3d_context_vk_destroy_allocator_block (struct wined3d_context_vk *context_vk, struct wined3d_allocator_block *block, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_bo (struct wined3d_context_vk *context_vk, const struct wined3d_bo_vk *bo)
 
void wined3d_context_vk_destroy_image (struct wined3d_context_vk *context_vk, struct wined3d_image_vk *image_vk)
 
void wined3d_context_vk_destroy_vk_buffer_view (struct wined3d_context_vk *context_vk, VkBufferView vk_view, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_vk_framebuffer (struct wined3d_context_vk *context_vk, VkFramebuffer vk_framebuffer, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_vk_image (struct wined3d_context_vk *context_vk, VkImage vk_image, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_vk_image_view (struct wined3d_context_vk *context_vk, VkImageView vk_view, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_vk_memory (struct wined3d_context_vk *context_vk, VkDeviceMemory vk_memory, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_vk_sampler (struct wined3d_context_vk *context_vk, VkSampler vk_sampler, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_vk_event (struct wined3d_context_vk *context_vk, VkEvent vk_event, uint64_t command_buffer_id)
 
void wined3d_context_vk_destroy_vk_pipeline (struct wined3d_context_vk *context_vk, VkPipeline vk_pipeline, uint64_t command_buffer_id)
 
void wined3d_context_vk_end_current_render_pass (struct wined3d_context_vk *context_vk)
 
VkCommandBuffer wined3d_context_vk_get_command_buffer (struct wined3d_context_vk *context_vk)
 
struct wined3d_pipeline_layout_vk * wined3d_context_vk_get_pipeline_layout (struct wined3d_context_vk *context_vk, VkDescriptorSetLayoutBinding *bindings, SIZE_T binding_count)
 
VkRenderPass wined3d_context_vk_get_render_pass (struct wined3d_context_vk *context_vk, const struct wined3d_fb_state *fb, unsigned int rt_count, bool depth_stencil, uint32_t clear_flags)
 
void wined3d_context_vk_image_barrier (struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range)
 
HRESULT wined3d_context_vk_init (struct wined3d_context_vk *context_vk, struct wined3d_swapchain *swapchain)
 
void wined3d_context_vk_submit_command_buffer (struct wined3d_context_vk *context_vk, unsigned int wait_semaphore_count, const VkSemaphore *wait_semaphores, const VkPipelineStageFlags *wait_stages, unsigned int signal_semaphore_count, const VkSemaphore *signal_semaphores)
 
void wined3d_context_vk_wait_command_buffer (struct wined3d_context_vk *context_vk, uint64_t id)
 
VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set (struct wined3d_context_vk *context_vk, VkDescriptorSetLayout vk_set_layout)
 
static struct wined3d_adapter_vk * wined3d_adapter_vk (struct wined3d_adapter *adapter)
 
void adapter_vk_copy_bo_address (struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags)
 
unsigned int wined3d_adapter_vk_get_memory_type_index (const struct wined3d_adapter_vk *adapter_vk, uint32_t memory_type_mask, VkMemoryPropertyFlags flags)
 
BOOL wined3d_adapter_vk_init_format_info (struct wined3d_adapter_vk *adapter_vk, const struct wined3d_vk_info *vk_info)
 
static struct wined3d_allocator_chunk_vk * wined3d_allocator_chunk_vk (struct wined3d_allocator_chunk *chunk)
 
void * wined3d_allocator_chunk_vk_map (struct wined3d_allocator_chunk_vk *chunk_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_allocator_chunk_vk_unmap (struct wined3d_allocator_chunk_vk *chunk_vk, struct wined3d_context_vk *context_vk)
 
static struct wined3d_device_vk * wined3d_device_vk (struct wined3d_device *device)
 
static struct wined3d_device_vk * wined3d_device_vk_from_allocator (struct wined3d_allocator *allocator)
 
static void wined3d_device_vk_allocator_lock (struct wined3d_device_vk *device_vk)
 
static void wined3d_device_vk_allocator_unlock (struct wined3d_device_vk *device_vk)
 
bool wined3d_device_vk_create_null_resources (struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
 
bool wined3d_device_vk_create_null_views (struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_device_vk_destroy_null_resources (struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_device_vk_destroy_null_views (struct wined3d_device_vk *device_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_device_vk_uav_clear_state_init (struct wined3d_device_vk *device_vk)
 
void wined3d_device_vk_uav_clear_state_cleanup (struct wined3d_device_vk *device_vk)
 
static struct wined3d_texture_vk * wined3d_texture_vk (struct wined3d_texture *texture)
 
void wined3d_texture_vk_barrier (struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
 
const VkDescriptorImageInfo * wined3d_texture_vk_get_default_image_info (struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
 
HRESULT wined3d_texture_vk_init (struct wined3d_texture_vk *texture_vk, struct wined3d_device *device, const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count, uint32_t flags, void *parent, const struct wined3d_parent_ops *parent_ops)
 
void wined3d_texture_vk_make_generic (struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
 
BOOL wined3d_texture_vk_prepare_texture (struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
 
static struct wined3d_sampler_vk * wined3d_sampler_vk (struct wined3d_sampler *sampler)
 
void wined3d_sampler_vk_init (struct wined3d_sampler_vk *sampler_vk, struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static struct wined3d_buffer_vk * wined3d_buffer_vk (struct wined3d_buffer *buffer)
 
void wined3d_buffer_vk_barrier (struct wined3d_buffer_vk *buffer_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
 
const VkDescriptorBufferInfo * wined3d_buffer_vk_get_buffer_info (struct wined3d_buffer_vk *buffer_vk)
 
HRESULT wined3d_buffer_vk_init (struct wined3d_buffer_vk *buffer_vk, struct wined3d_device *device, const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static void wined3d_resource_vk_barrier (struct wined3d_resource *resource, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
 
static struct wined3d_rendertarget_view_vk * wined3d_rendertarget_view_vk (struct wined3d_rendertarget_view *view)
 
static void wined3d_rendertarget_view_vk_barrier (struct wined3d_rendertarget_view_vk *rtv_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
 
static VkImageView wined3d_rendertarget_view_vk_get_image_view (struct wined3d_rendertarget_view_vk *rtv_vk, struct wined3d_context_vk *context_vk)
 
HRESULT wined3d_rendertarget_view_vk_init (struct wined3d_rendertarget_view_vk *view_vk, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static struct wined3d_shader_resource_view_vk * wined3d_shader_resource_view_vk (struct wined3d_shader_resource_view *view)
 
static void wined3d_shader_resource_view_vk_barrier (struct wined3d_shader_resource_view_vk *srv_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
 
void wined3d_shader_resource_view_vk_generate_mipmap (struct wined3d_shader_resource_view_vk *srv_vk, struct wined3d_context_vk *context_vk)
 
HRESULT wined3d_shader_resource_view_vk_init (struct wined3d_shader_resource_view_vk *view_vk, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
void wined3d_shader_resource_view_vk_update_buffer (struct wined3d_shader_resource_view_vk *view_vk, struct wined3d_context_vk *context_vk)
 
void wined3d_shader_resource_view_vk_update_layout (struct wined3d_shader_resource_view_vk *srv_vk, VkImageLayout layout)
 
static struct wined3d_unordered_access_view_vk * wined3d_unordered_access_view_vk (struct wined3d_unordered_access_view *view)
 
static void wined3d_unordered_access_view_vk_barrier (struct wined3d_unordered_access_view_vk *uav_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
 
void wined3d_unordered_access_view_vk_clear (struct wined3d_unordered_access_view_vk *view_vk, const struct wined3d_uvec4 *clear_value, struct wined3d_context_vk *context_vk, bool fp)
 
HRESULT wined3d_unordered_access_view_vk_init (struct wined3d_unordered_access_view_vk *view_vk, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
 
void wined3d_unordered_access_view_vk_update (struct wined3d_unordered_access_view_vk *view_vk, struct wined3d_context_vk *context_vk)
 
static struct wined3d_swapchain_vk * wined3d_swapchain_vk (struct wined3d_swapchain *swapchain)
 
void wined3d_swapchain_vk_cleanup (struct wined3d_swapchain_vk *swapchain_vk)
 
HRESULT wined3d_swapchain_vk_init (struct wined3d_swapchain_vk *swapchain_vk, struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops)
 
static const struct wined3d_format_vk * wined3d_format_vk (const struct wined3d_format *format)
 
static void wined3d_context_vk_reference_bo (const struct wined3d_context_vk *context_vk, struct wined3d_bo_vk *bo)
 
static void wined3d_context_vk_reference_image (const struct wined3d_context_vk *context_vk, struct wined3d_image_vk *image)
 
static void wined3d_context_vk_reference_texture (const struct wined3d_context_vk *context_vk, struct wined3d_texture_vk *texture_vk)
 
static void wined3d_context_vk_reference_resource (const struct wined3d_context_vk *context_vk, struct wined3d_resource *resource)
 
static void wined3d_context_vk_reference_query (const struct wined3d_context_vk *context_vk, struct wined3d_query_vk *query_vk)
 
static void wined3d_context_vk_reference_sampler (const struct wined3d_context_vk *context_vk, struct wined3d_sampler_vk *sampler_vk)
 
static void wined3d_context_vk_reference_rendertarget_view (const struct wined3d_context_vk *context_vk, struct wined3d_rendertarget_view_vk *rtv_vk)
 
static void wined3d_context_vk_reference_shader_resource_view (const struct wined3d_context_vk *context_vk, struct wined3d_shader_resource_view_vk *srv_vk)
 
static void wined3d_context_vk_reference_unordered_access_view (const struct wined3d_context_vk *context_vk, struct wined3d_unordered_access_view_vk *uav_vk)
 

Variables

static const VkAccessFlags WINED3D_READ_ONLY_ACCESS_FLAGS
 

Macro Definition Documentation

◆ DECLARE_VK_PFN

#define DECLARE_VK_PFN (   name)    PFN_##name name;

Definition at line 217 of file wined3d_vk.h.

◆ VK_CALL

#define VK_CALL (   f)    (vk_info->vk_ops.f)

Definition at line 272 of file wined3d_vk.h.

◆ VK_DEVICE_EXT_PFN

#define VK_DEVICE_EXT_PFN   DECLARE_VK_PFN

Definition at line 224 of file wined3d_vk.h.

◆ VK_DEVICE_FUNCS

#define VK_DEVICE_FUNCS ( )

Definition at line 61 of file wined3d_vk.h.

◆ VK_DEVICE_PFN

#define VK_DEVICE_PFN   DECLARE_VK_PFN

Definition at line 223 of file wined3d_vk.h.

◆ VK_INSTANCE_EXT_PFN

#define VK_INSTANCE_EXT_PFN   DECLARE_VK_PFN

Definition at line 222 of file wined3d_vk.h.

◆ VK_INSTANCE_FUNCS

#define VK_INSTANCE_FUNCS ( )
Value:
VK_INSTANCE_PFN(vkDestroyInstance) \
VK_INSTANCE_PFN(vkEnumeratePhysicalDevices) \
VK_INSTANCE_PFN(vkGetDeviceProcAddr) \
VK_INSTANCE_PFN(vkGetPhysicalDeviceFeatures) \
VK_INSTANCE_PFN(vkGetPhysicalDeviceProperties) \
/* Vulkan 1.1 */ \
VK_INSTANCE_EXT_PFN(vkGetPhysicalDeviceFeatures2) \
VK_INSTANCE_EXT_PFN(vkGetPhysicalDeviceProperties2) \
/* VK_KHR_surface */ \
VK_INSTANCE_PFN(vkDestroySurfaceKHR) \
/* VK_KHR_win32_surface */ \
VK_INSTANCE_PFN(vkCreateWin32SurfaceKHR) \
/* VK_EXT_host_query_reset */ \
VK_INSTANCE_EXT_PFN(vkResetQueryPoolEXT)
void VKAPI_CALL vkGetPhysicalDeviceMemoryProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceMemoryProperties *pMemoryProperties)
VkResult VKAPI_CALL vkEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
void VKAPI_CALL vkGetPhysicalDeviceQueueFamilyProperties(VkPhysicalDevice physicalDevice, uint32_t *pQueueFamilyPropertyCount, VkQueueFamilyProperties *pQueueFamilyProperties)
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfacePresentModesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pPresentModeCount, VkPresentModeKHR *pPresentModes)
void VKAPI_CALL vkGetPhysicalDeviceFeatures(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures *pFeatures)
PFN_vkVoidFunction VKAPI_CALL vkGetDeviceProcAddr(VkDevice device, const char *pName)
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceCapabilitiesKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, VkSurfaceCapabilitiesKHR *pSurfaceCapabilities)
VkResult VKAPI_CALL vkCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkDevice *pDevice)
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceSupportKHR(VkPhysicalDevice physicalDevice, uint32_t queueFamilyIndex, VkSurfaceKHR surface, VkBool32 *pSupported)
void VKAPI_CALL vkResetQueryPoolEXT(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)
VkResult VKAPI_CALL vkGetPhysicalDeviceImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties)
void VKAPI_CALL vkGetPhysicalDeviceFeatures2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceFeatures2 *pFeatures)
VkResult VKAPI_CALL vkGetPhysicalDeviceSurfaceFormatsKHR(VkPhysicalDevice physicalDevice, VkSurfaceKHR surface, uint32_t *pSurfaceFormatCount, VkSurfaceFormatKHR *pSurfaceFormats)
void VKAPI_CALL vkGetPhysicalDeviceProperties2(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties2 *pProperties)
VkResult VKAPI_CALL vkCreateWin32SurfaceKHR(VkInstance instance, const VkWin32SurfaceCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSurfaceKHR *pSurface)
void VKAPI_CALL vkDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkEnumerateDeviceLayerProperties(VkPhysicalDevice physicalDevice, uint32_t *pPropertyCount, VkLayerProperties *pProperties)
VkResult VKAPI_CALL vkEnumeratePhysicalDevices(VkInstance instance, uint32_t *pPhysicalDeviceCount, VkPhysicalDevice *pPhysicalDevices)
void VKAPI_CALL vkGetPhysicalDeviceProperties(VkPhysicalDevice physicalDevice, VkPhysicalDeviceProperties *pProperties)
void VKAPI_CALL vkDestroySurfaceKHR(VkInstance instance, VkSurfaceKHR surface, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkGetPhysicalDeviceSparseImageFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkSampleCountFlagBits samples, VkImageUsageFlags usage, VkImageTiling tiling, uint32_t *pPropertyCount, VkSparseImageFormatProperties *pProperties)
#define VK_INSTANCE_PFN
Definition: wined3d_vk.h:221

Definition at line 33 of file wined3d_vk.h.

◆ VK_INSTANCE_PFN

#define VK_INSTANCE_PFN   DECLARE_VK_PFN

Definition at line 221 of file wined3d_vk.h.

◆ VK_NO_PROTOTYPES

#define VK_NO_PROTOTYPES

Definition at line 25 of file wined3d_vk.h.

◆ WINED3D_FB_ATTACHMENT_FLAG_CLEAR_C

#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_C   2

Definition at line 485 of file wined3d_vk.h.

◆ WINED3D_FB_ATTACHMENT_FLAG_CLEAR_S

#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_S   4

Definition at line 486 of file wined3d_vk.h.

◆ WINED3D_FB_ATTACHMENT_FLAG_CLEAR_Z

#define WINED3D_FB_ATTACHMENT_FLAG_CLEAR_Z   8

Definition at line 487 of file wined3d_vk.h.

◆ WINED3D_FB_ATTACHMENT_FLAG_DISCARDED

#define WINED3D_FB_ATTACHMENT_FLAG_DISCARDED   1

Definition at line 484 of file wined3d_vk.h.

◆ WINED3D_QUERY_VK_FLAG_ACTIVE

#define WINED3D_QUERY_VK_FLAG_ACTIVE   0x00000001

Definition at line 389 of file wined3d_vk.h.

◆ WINED3D_QUERY_VK_FLAG_RENDER_PASS

#define WINED3D_QUERY_VK_FLAG_RENDER_PASS   0x00000004

Definition at line 391 of file wined3d_vk.h.

◆ WINED3D_QUERY_VK_FLAG_STARTED

#define WINED3D_QUERY_VK_FLAG_STARTED   0x00000002

Definition at line 390 of file wined3d_vk.h.

Enumeration Type Documentation

◆ wined3d_retired_object_type_vk

Enumerator
WINED3D_RETIRED_FREE_VK 
WINED3D_RETIRED_FRAMEBUFFER_VK 
WINED3D_RETIRED_DESCRIPTOR_POOL_VK 
WINED3D_RETIRED_MEMORY_VK 
WINED3D_RETIRED_ALLOCATOR_BLOCK_VK 
WINED3D_RETIRED_BO_SLAB_SLICE_VK 
WINED3D_RETIRED_BUFFER_VK 
WINED3D_RETIRED_IMAGE_VK 
WINED3D_RETIRED_BUFFER_VIEW_VK 
WINED3D_RETIRED_IMAGE_VIEW_VK 
WINED3D_RETIRED_SAMPLER_VK 
WINED3D_RETIRED_QUERY_POOL_VK 
WINED3D_RETIRED_EVENT_VK 
WINED3D_RETIRED_PIPELINE_VK 

Definition at line 426 of file wined3d_vk.h.

427{
442};
@ WINED3D_RETIRED_QUERY_POOL_VK
Definition: wined3d_vk.h:439
@ WINED3D_RETIRED_SAMPLER_VK
Definition: wined3d_vk.h:438
@ WINED3D_RETIRED_DESCRIPTOR_POOL_VK
Definition: wined3d_vk.h:430
@ WINED3D_RETIRED_ALLOCATOR_BLOCK_VK
Definition: wined3d_vk.h:432
@ WINED3D_RETIRED_EVENT_VK
Definition: wined3d_vk.h:440
@ WINED3D_RETIRED_BUFFER_VK
Definition: wined3d_vk.h:434
@ WINED3D_RETIRED_IMAGE_VIEW_VK
Definition: wined3d_vk.h:437
@ WINED3D_RETIRED_MEMORY_VK
Definition: wined3d_vk.h:431
@ WINED3D_RETIRED_FRAMEBUFFER_VK
Definition: wined3d_vk.h:429
@ WINED3D_RETIRED_IMAGE_VK
Definition: wined3d_vk.h:435
@ WINED3D_RETIRED_BUFFER_VIEW_VK
Definition: wined3d_vk.h:436
@ WINED3D_RETIRED_BO_SLAB_SLICE_VK
Definition: wined3d_vk.h:433
@ WINED3D_RETIRED_PIPELINE_VK
Definition: wined3d_vk.h:441
@ WINED3D_RETIRED_FREE_VK
Definition: wined3d_vk.h:428

◆ wined3d_shader_descriptor_type

Enumerator
WINED3D_SHADER_DESCRIPTOR_TYPE_CBV 
WINED3D_SHADER_DESCRIPTOR_TYPE_SRV 
WINED3D_SHADER_DESCRIPTOR_TYPE_UAV 
WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER 
WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER 

Definition at line 555 of file wined3d_vk.h.

556{
562};
@ WINED3D_SHADER_DESCRIPTOR_TYPE_UAV
Definition: wined3d_vk.h:559
@ WINED3D_SHADER_DESCRIPTOR_TYPE_SRV
Definition: wined3d_vk.h:558
@ WINED3D_SHADER_DESCRIPTOR_TYPE_UAV_COUNTER
Definition: wined3d_vk.h:560
@ WINED3D_SHADER_DESCRIPTOR_TYPE_CBV
Definition: wined3d_vk.h:557
@ WINED3D_SHADER_DESCRIPTOR_TYPE_SAMPLER
Definition: wined3d_vk.h:561

◆ wined3d_vk_extension

Enumerator
WINED3D_VK_EXT_NONE 
WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE 
WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE2 
WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE3 
WINED3D_VK_EXT_HOST_QUERY_RESET 
WINED3D_VK_EXT_SHADER_STENCIL_EXPORT 
WINED3D_VK_EXT_TRANSFORM_FEEDBACK 
WINED3D_VK_EXT_VERTEX_ATTRIBUTE_DIVISOR 
WINED3D_VK_KHR_MAINTENANCE2 
WINED3D_VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE 
WINED3D_VK_KHR_SHADER_DRAW_PARAMETERS 
WINED3D_VK_EXT_COUNT 

Definition at line 236 of file wined3d_vk.h.

237{
239
250
252};
@ WINED3D_VK_KHR_SHADER_DRAW_PARAMETERS
Definition: wined3d_vk.h:249
@ WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE
Definition: wined3d_vk.h:240
@ WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE2
Definition: wined3d_vk.h:241
@ WINED3D_VK_EXT_SHADER_STENCIL_EXPORT
Definition: wined3d_vk.h:244
@ WINED3D_VK_KHR_MAINTENANCE2
Definition: wined3d_vk.h:247
@ WINED3D_VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE
Definition: wined3d_vk.h:248
@ WINED3D_VK_EXT_VERTEX_ATTRIBUTE_DIVISOR
Definition: wined3d_vk.h:246
@ WINED3D_VK_EXT_HOST_QUERY_RESET
Definition: wined3d_vk.h:243
@ WINED3D_VK_EXT_TRANSFORM_FEEDBACK
Definition: wined3d_vk.h:245
@ WINED3D_VK_EXT_EXTENDED_DYNAMIC_STATE3
Definition: wined3d_vk.h:242
@ WINED3D_VK_EXT_COUNT
Definition: wined3d_vk.h:251
@ WINED3D_VK_EXT_NONE
Definition: wined3d_vk.h:238

Function Documentation

◆ adapter_vk_copy_bo_address()

void adapter_vk_copy_bo_address ( struct wined3d_context *  context,
const struct wined3d_bo_address *  dst,
const struct wined3d_bo_address *  src,
unsigned int  range_count,
const struct wined3d_range *  ranges,
uint32_t  map_flags 
)

Definition at line 1020 of file adapter_vk.c.

1023{
1024 struct wined3d_context_vk *context_vk = wined3d_context_vk(context);
1025 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1026 struct wined3d_bo_vk staging_bo, *src_bo, *dst_bo;
1027 VkAccessFlags src_access_mask, dst_access_mask;
1028 VkBufferMemoryBarrier vk_barrier[2];
1029 const struct wined3d_range *range;
1030 struct wined3d_bo_address staging;
1031 VkCommandBuffer vk_command_buffer;
1032 uint8_t *dst_ptr, *src_ptr;
1034 size_t size = 0;
1035 unsigned int i;
1036
1037 src_bo = src->buffer_object ? wined3d_bo_vk(src->buffer_object) : NULL;
1038 dst_bo = dst->buffer_object ? wined3d_bo_vk(dst->buffer_object) : NULL;
1039
1040 if (src_bo && dst_bo)
1041 {
1042 if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
1043 {
1044 ERR("Failed to get command buffer.\n");
1045 return;
1046 }
1047
1049
1050 src_access_mask = vk_access_mask_from_buffer_usage(src_bo->usage);
1051 dst_access_mask = vk_access_mask_from_buffer_usage(dst_bo->usage);
1052
1054 vk_barrier[0].pNext = NULL;
1057 vk_barrier[0].buffer = src_bo->vk_buffer;
1058
1060 vk_barrier[1].pNext = NULL;
1063 vk_barrier[1].buffer = dst_bo->vk_buffer;
1064
1065 for (i = 0; i < range_count; ++i)
1066 {
1067 range = &ranges[i];
1068
1069 region.srcOffset = src_bo->b.buffer_offset + (uintptr_t)src->addr + range->offset;
1070 region.dstOffset = dst_bo->b.buffer_offset + (uintptr_t)dst->addr + range->offset;
1071 region.size = range->size;
1072
1073 vk_barrier[0].offset = region.srcOffset;
1074 vk_barrier[0].size = region.size;
1075
1076 vk_barrier[1].offset = region.dstOffset;
1077 vk_barrier[1].size = region.size;
1078
1079 vk_barrier[0].srcAccessMask = src_access_mask;
1081
1082 vk_barrier[1].srcAccessMask = dst_access_mask;
1084
1086 VK_PIPELINE_STAGE_TRANSFER_BIT, 0, 0, NULL, 2, vk_barrier, 0, NULL));
1087
1088 VK_CALL(vkCmdCopyBuffer(vk_command_buffer, src_bo->vk_buffer, dst_bo->vk_buffer, 1, &region));
1089
1091 vk_barrier[0].dstAccessMask = src_access_mask;
1092
1094 vk_barrier[1].dstAccessMask = dst_access_mask;
1095
1097 VK_PIPELINE_STAGE_ALL_COMMANDS_BIT, 0, 0, NULL, 2, vk_barrier, 0, NULL));
1098 }
1099
1100 wined3d_context_vk_reference_bo(context_vk, src_bo);
1101 wined3d_context_vk_reference_bo(context_vk, dst_bo);
1102
1103 return;
1104 }
1105
1106 for (i = 0; i < range_count; ++i)
1107 size = max(size, ranges[i].offset + ranges[i].size);
1108
1109 if (src_bo && !(src_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
1110 {
1113 {
1114 ERR("Failed to create staging bo.\n");
1115 return;
1116 }
1117
1118 staging.buffer_object = &staging_bo.b;
1119 staging.addr = NULL;
1120 adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges, WINED3D_MAP_WRITE);
1121 adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges, WINED3D_MAP_WRITE);
1122
1123 wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
1124
1125 return;
1126 }
1127
1128 if (dst_bo && (!(dst_bo->memory_type & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT) || (!(map_flags & WINED3D_MAP_DISCARD)
1129 && dst_bo->command_buffer_id > context_vk->completed_command_buffer_id)))
1130 {
1133 {
1134 ERR("Failed to create staging bo.\n");
1135 return;
1136 }
1137
1138 staging.buffer_object = &staging_bo.b;
1139 staging.addr = NULL;
1140 adapter_vk_copy_bo_address(context, &staging, src, range_count, ranges, WINED3D_MAP_WRITE);
1141 adapter_vk_copy_bo_address(context, dst, &staging, range_count, ranges, WINED3D_MAP_WRITE);
1142
1143 wined3d_context_vk_destroy_bo(context_vk, &staging_bo);
1144
1145 return;
1146 }
1147
1149 dst_ptr = adapter_vk_map_bo_address(context, dst, size, map_flags);
1150
1151 for (i = 0; i < range_count; ++i)
1152 memcpy(dst_ptr + ranges[i].offset, src_ptr + ranges[i].offset, ranges[i].size);
1153
1154 adapter_vk_unmap_bo_address(context, dst, range_count, ranges);
1156}
VkAccessFlags vk_access_mask_from_buffer_usage(VkBufferUsageFlags usage)
Definition: adapter_vk.c:835
static void * adapter_vk_map_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, size_t size, uint32_t map_flags)
Definition: adapter_vk.c:887
void adapter_vk_copy_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *dst, const struct wined3d_bo_address *src, unsigned int range_count, const struct wined3d_range *ranges, uint32_t map_flags)
Definition: adapter_vk.c:1020
static void adapter_vk_unmap_bo_address(struct wined3d_context *context, const struct wined3d_bo_address *data, unsigned int range_count, const struct wined3d_range *ranges)
Definition: adapter_vk.c:998
#define ERR(fmt,...)
Definition: precomp.h:57
BOOL wined3d_context_vk_create_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo)
Definition: context_vk.c:528
void wined3d_context_vk_end_current_render_pass(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1564
VkCommandBuffer wined3d_context_vk_get_command_buffer(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1805
void wined3d_context_vk_destroy_bo(struct wined3d_context_vk *context_vk, const struct wined3d_bo_vk *bo)
Definition: context_vk.c:1106
range
Definition: d3dx9_private.h:58
#define NULL
Definition: types.h:112
unsigned int uintptr_t
Definition: corecrt.h:185
unsigned char uint8_t
Definition: stdint.h:33
GLenum src
Definition: glext.h:6340
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
GLenum GLenum dst
Definition: glext.h:6340
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VkAccessFlags srcAccessMask
Definition: vulkan.h:7632
VkAccessFlags dstAccessMask
Definition: vulkan.h:7633
uint32_t srcQueueFamilyIndex
Definition: vulkan.h:7634
const void * pNext
Definition: vulkan.h:7631
VkStructureType sType
Definition: vulkan.h:7630
uint32_t dstQueueFamilyIndex
Definition: vulkan.h:7635
Definition: http.c:7252
struct wined3d_bo b
Definition: wined3d_vk.h:310
VkBufferUsageFlags usage
Definition: wined3d_vk.h:319
VkBuffer vk_buffer
Definition: wined3d_vk.h:312
uint64_t command_buffer_id
Definition: wined3d_vk.h:322
VkMemoryPropertyFlags memory_type
Definition: wined3d_vk.h:320
uint64_t completed_command_buffer_id
Definition: wined3d_vk.h:618
const struct wined3d_vk_info * vk_info
Definition: wined3d_vk.h:590
#define max(a, b)
Definition: svc.c:63
void VKAPI_CALL vkCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, uint32_t regionCount, const VkBufferCopy *pRegions)
@ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
Definition: vulkan.h:3771
VkFlags VkAccessFlags
Definition: vulkan.h:957
@ VK_BUFFER_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:1916
@ VK_BUFFER_USAGE_TRANSFER_SRC_BIT
Definition: vulkan.h:1915
@ VK_ACCESS_TRANSFER_WRITE_BIT
Definition: vulkan.h:1641
@ VK_ACCESS_TRANSFER_READ_BIT
Definition: vulkan.h:1640
@ VK_PIPELINE_STAGE_ALL_COMMANDS_BIT
Definition: vulkan.h:4288
@ VK_PIPELINE_STAGE_TRANSFER_BIT
Definition: vulkan.h:4284
void VKAPI_CALL vkCmdPipelineBarrier(VkCommandBuffer commandBuffer, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkDependencyFlags dependencyFlags, uint32_t memoryBarrierCount, const VkMemoryBarrier *pMemoryBarriers, uint32_t bufferMemoryBarrierCount, const VkBufferMemoryBarrier *pBufferMemoryBarriers, uint32_t imageMemoryBarrierCount, const VkImageMemoryBarrier *pImageMemoryBarriers)
#define VK_QUEUE_FAMILY_IGNORED
Definition: vulkan.h:57
@ VK_STRUCTURE_TYPE_BUFFER_MEMORY_BARRIER
Definition: vulkan.h:5008
#define WINED3D_MAP_READ
Definition: wined3d.h:957
#define WINED3D_MAP_DISCARD
Definition: wined3d.h:953
#define WINED3D_MAP_WRITE
Definition: wined3d.h:956
#define VK_CALL(f)
Definition: wined3d_vk.h:272
static void wined3d_context_vk_reference_bo(const struct wined3d_context_vk *context_vk, struct wined3d_bo_vk *bo)
Definition: wined3d_vk.h:1091

Referenced by adapter_vk_copy_bo_address(), and wined3d_unordered_access_view_vk_clear().

◆ vk_access_mask_from_bind_flags()

VkAccessFlags vk_access_mask_from_bind_flags ( uint32_t  bind_flags)

Definition at line 526 of file resource.c.

527{
529
530 if (bind_flags & WINED3D_BIND_VERTEX_BUFFER)
532 if (bind_flags & WINED3D_BIND_INDEX_BUFFER)
534 if (bind_flags & WINED3D_BIND_CONSTANT_BUFFER)
536 if (bind_flags & WINED3D_BIND_SHADER_RESOURCE)
538 if (bind_flags & WINED3D_BIND_UNORDERED_ACCESS)
540 if (bind_flags & WINED3D_BIND_INDIRECT_BUFFER)
542 if (bind_flags & WINED3D_BIND_RENDER_TARGET)
544 if (bind_flags & WINED3D_BIND_DEPTH_STENCIL)
546 if (bind_flags & WINED3D_BIND_STREAM_OUTPUT)
548
549 return flags;
550}
GLbitfield flags
Definition: glext.h:7161
@ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_WRITE_BIT
Definition: vulkan.h:1639
@ VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT
Definition: vulkan.h:1631
@ VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT
Definition: vulkan.h:1637
@ VK_ACCESS_INDIRECT_COMMAND_READ_BIT
Definition: vulkan.h:1629
@ VK_ACCESS_DEPTH_STENCIL_ATTACHMENT_READ_BIT
Definition: vulkan.h:1638
@ VK_ACCESS_SHADER_WRITE_BIT
Definition: vulkan.h:1635
@ VK_ACCESS_SHADER_READ_BIT
Definition: vulkan.h:1634
@ VK_ACCESS_UNIFORM_READ_BIT
Definition: vulkan.h:1632
@ VK_ACCESS_INDEX_READ_BIT
Definition: vulkan.h:1630
@ VK_ACCESS_TRANSFORM_FEEDBACK_WRITE_BIT_EXT
Definition: vulkan.h:1654
@ VK_ACCESS_COLOR_ATTACHMENT_READ_BIT
Definition: vulkan.h:1636
#define WINED3D_BIND_VERTEX_BUFFER
Definition: wined3d.h:909
#define WINED3D_BIND_UNORDERED_ACCESS
Definition: wined3d.h:916
#define WINED3D_BIND_SHADER_RESOURCE
Definition: wined3d.h:912
#define WINED3D_BIND_INDIRECT_BUFFER
Definition: wined3d.h:917
#define WINED3D_BIND_DEPTH_STENCIL
Definition: wined3d.h:915
#define WINED3D_BIND_RENDER_TARGET
Definition: wined3d.h:914
#define WINED3D_BIND_CONSTANT_BUFFER
Definition: wined3d.h:911
#define WINED3D_BIND_STREAM_OUTPUT
Definition: wined3d.h:913
#define WINED3D_BIND_INDEX_BUFFER
Definition: wined3d.h:910

Referenced by vk_blitter_blit(), wined3d_buffer_vk_barrier(), wined3d_shader_resource_view_vk_generate_mipmap(), wined3d_swapchain_vk_blit(), wined3d_texture_vk_barrier(), wined3d_texture_vk_clear(), wined3d_texture_vk_download_data(), wined3d_texture_vk_upload_data(), and wined3d_unordered_access_view_vk_clear().

◆ vk_access_mask_from_buffer_usage()

VkAccessFlags vk_access_mask_from_buffer_usage ( VkBufferUsageFlags  usage)

Definition at line 835 of file adapter_vk.c.

836{
838
860
861 return flags;
862}
GLsizeiptr const GLvoid GLenum usage
Definition: glext.h:5919
@ VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT
Definition: vulkan.h:1918
@ VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT
Definition: vulkan.h:1917
@ VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT
Definition: vulkan.h:1923
@ VK_BUFFER_USAGE_INDEX_BUFFER_BIT
Definition: vulkan.h:1921
@ VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT
Definition: vulkan.h:1926
@ VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT
Definition: vulkan.h:1919
@ VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT
Definition: vulkan.h:1927
@ VK_BUFFER_USAGE_VERTEX_BUFFER_BIT
Definition: vulkan.h:1922
@ VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_READ_BIT_EXT
Definition: vulkan.h:1655
@ VK_ACCESS_TRANSFORM_FEEDBACK_COUNTER_WRITE_BIT_EXT
Definition: vulkan.h:1656

Referenced by adapter_vk_copy_bo_address(), adapter_vk_map_bo_address(), wined3d_texture_vk_download_data(), and wined3d_texture_vk_upload_data().

◆ vk_aspect_mask_from_format()

static VkImageAspectFlags vk_aspect_mask_from_format ( const struct wined3d_format *  format)
inlinestatic

Definition at line 294 of file wined3d_vk.h.

295{
297
298 if (format->depth_size)
300 if (format->stencil_size)
302 if (!mask || format->red_size || format->green_size || format->blue_size || format->alpha_size)
304
305 return mask;
306}
GLenum GLint GLuint mask
Definition: glext.h:6028
VkFlags VkImageAspectFlags
Definition: vulkan.h:1043
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan.h:3365
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan.h:3367
@ VK_IMAGE_ASPECT_DEPTH_BIT
Definition: vulkan.h:3366

Referenced by vk_blitter_blit(), wined3d_shader_resource_view_vk_generate_mipmap(), wined3d_texture_vk_barrier(), wined3d_texture_vk_clear(), wined3d_texture_vk_download_data(), wined3d_texture_vk_get_default_image_info(), wined3d_texture_vk_make_generic(), wined3d_texture_vk_prepare_texture(), wined3d_texture_vk_upload_data(), and wined3d_view_vk_create_vk_image_view().

◆ vk_buffer_usage_from_bind_flags()

VkBufferUsageFlags vk_buffer_usage_from_bind_flags ( uint32_t  bind_flags)

◆ vk_compare_op_from_wined3d()

VkCompareOp vk_compare_op_from_wined3d ( enum wined3d_cmp_func  op)

Definition at line 30 of file context_vk.c.

31{
32 switch (op)
33 {
37 return VK_COMPARE_OP_LESS;
50 default:
51 if (!op)
52 WARN("Unhandled compare operation %#x.\n", op);
53 else
54 FIXME("Unhandled compare operation %#x.\n", op);
56 }
57}
#define WARN(fmt,...)
Definition: precomp.h:61
UINT op
Definition: effect.c:235
@ VK_COMPARE_OP_LESS_OR_EQUAL
Definition: vulkan.h:2178
@ VK_COMPARE_OP_LESS
Definition: vulkan.h:2176
@ VK_COMPARE_OP_NOT_EQUAL
Definition: vulkan.h:2180
@ VK_COMPARE_OP_NEVER
Definition: vulkan.h:2175
@ VK_COMPARE_OP_ALWAYS
Definition: vulkan.h:2182
@ VK_COMPARE_OP_EQUAL
Definition: vulkan.h:2177
@ VK_COMPARE_OP_GREATER_OR_EQUAL
Definition: vulkan.h:2181
@ VK_COMPARE_OP_GREATER
Definition: vulkan.h:2179
@ WINED3D_CMP_ALWAYS
Definition: wined3d.h:468
@ WINED3D_CMP_GREATER
Definition: wined3d.h:465
@ WINED3D_CMP_LESSEQUAL
Definition: wined3d.h:464
@ WINED3D_CMP_NOTEQUAL
Definition: wined3d.h:466
@ WINED3D_CMP_LESS
Definition: wined3d.h:462
@ WINED3D_CMP_EQUAL
Definition: wined3d.h:463
@ WINED3D_CMP_GREATEREQUAL
Definition: wined3d.h:467
@ WINED3D_CMP_NEVER
Definition: wined3d.h:461

Referenced by wined3d_context_vk_apply_draw_state(), wined3d_context_vk_update_graphics_pipeline_key(), and wined3d_sampler_vk_cs_init().

◆ vk_image_view_type_from_wined3d()

VkImageViewType vk_image_view_type_from_wined3d ( enum wined3d_resource_type  type,
uint32_t  flags 
)

Definition at line 676 of file view.c.

677{
678 switch (type)
679 {
683 else
685
688 {
691 else
693 }
696 else
698
701
702 default:
703 ERR("Unhandled resource type %s.\n", debug_d3dresourcetype(type));
704 return ~0u;
705 }
706}
const char * debug_d3dresourcetype(enum wined3d_resource_type resource_type)
Definition: utils.c:4992
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
@ VK_IMAGE_VIEW_TYPE_1D
Definition: vulkan.h:3548
@ VK_IMAGE_VIEW_TYPE_2D_ARRAY
Definition: vulkan.h:3553
@ VK_IMAGE_VIEW_TYPE_1D_ARRAY
Definition: vulkan.h:3552
@ VK_IMAGE_VIEW_TYPE_CUBE_ARRAY
Definition: vulkan.h:3554
@ VK_IMAGE_VIEW_TYPE_3D
Definition: vulkan.h:3550
@ VK_IMAGE_VIEW_TYPE_2D
Definition: vulkan.h:3549
@ VK_IMAGE_VIEW_TYPE_CUBE
Definition: vulkan.h:3551
#define WINED3D_VIEW_TEXTURE_CUBE
Definition: wined3d.h:1582
@ WINED3D_RTYPE_TEXTURE_2D
Definition: wined3d.h:720
@ WINED3D_RTYPE_TEXTURE_1D
Definition: wined3d.h:719
@ WINED3D_RTYPE_TEXTURE_3D
Definition: wined3d.h:721
#define WINED3D_VIEW_TEXTURE_ARRAY
Definition: wined3d.h:1583

Referenced by wined3d_texture_vk_get_default_image_info(), and wined3d_view_vk_create_vk_image_view().

◆ vk_memory_type_from_access_flags()

VkMemoryPropertyFlags vk_memory_type_from_access_flags ( uint32_t  access,
uint32_t  usage 
)

Definition at line 1150 of file buffer.c.

1151{
1152 VkMemoryPropertyFlags memory_type = 0;
1153
1158 else if (!(usage & WINED3DUSAGE_DYNAMIC))
1160 return memory_type;
1161}
GLuint GLint GLboolean GLint GLenum access
Definition: glext.h:7866
VkFlags VkMemoryPropertyFlags
Definition: vulkan.h:1063
@ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
Definition: vulkan.h:3770
@ VK_MEMORY_PROPERTY_HOST_CACHED_BIT
Definition: vulkan.h:3773
#define WINED3D_RESOURCE_ACCESS_MAP_R
Definition: wined3d.h:53
#define WINED3DUSAGE_DYNAMIC
Definition: wined3d.h:924
#define WINED3D_RESOURCE_ACCESS_MAP_W
Definition: wined3d.h:54

Referenced by adapter_vk_alloc_bo(), and wined3d_buffer_vk_create_buffer_object().

◆ vk_pipeline_stage_mask_from_bind_flags()

VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags ( uint32_t  bind_flags)

Definition at line 552 of file resource.c.

553{
555
562 if (bind_flags & WINED3D_BIND_INDIRECT_BUFFER)
564 if (bind_flags & WINED3D_BIND_RENDER_TARGET)
566 if (bind_flags & WINED3D_BIND_DEPTH_STENCIL)
568 if (bind_flags & WINED3D_BIND_STREAM_OUTPUT)
570
571 return flags;
572}
VkFlags VkPipelineStageFlags
Definition: vulkan.h:1101
@ VK_PIPELINE_STAGE_GEOMETRY_SHADER_BIT
Definition: vulkan.h:4278
@ VK_PIPELINE_STAGE_VERTEX_INPUT_BIT
Definition: vulkan.h:4274
@ VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT
Definition: vulkan.h:4283
@ VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT
Definition: vulkan.h:4279
@ VK_PIPELINE_STAGE_TESSELLATION_EVALUATION_SHADER_BIT
Definition: vulkan.h:4277
@ VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT
Definition: vulkan.h:4282
@ VK_PIPELINE_STAGE_LATE_FRAGMENT_TESTS_BIT
Definition: vulkan.h:4281
@ VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT
Definition: vulkan.h:4273
@ VK_PIPELINE_STAGE_VERTEX_SHADER_BIT
Definition: vulkan.h:4275
@ VK_PIPELINE_STAGE_TESSELLATION_CONTROL_SHADER_BIT
Definition: vulkan.h:4276
@ VK_PIPELINE_STAGE_EARLY_FRAGMENT_TESTS_BIT
Definition: vulkan.h:4280
@ VK_PIPELINE_STAGE_TRANSFORM_FEEDBACK_BIT_EXT
Definition: vulkan.h:4296

Referenced by wined3d_buffer_vk_barrier(), wined3d_texture_vk_barrier(), and wined3d_unordered_access_view_vk_clear().

◆ vk_pipeline_stage_mask_from_buffer_usage()

◆ vk_shader_stage_from_wined3d()

VkShaderStageFlagBits vk_shader_stage_from_wined3d ( enum wined3d_shader_type  shader_type)

Definition at line 59 of file context_vk.c.

60{
61 switch (shader_type)
62 {
75 default:
76 ERR("Unhandled shader type %s.\n", debug_shader_type(shader_type));
77 return 0;
78 }
79}
const char * debug_shader_type(enum wined3d_shader_type type)
Definition: utils.c:5313
@ VK_SHADER_STAGE_VERTEX_BIT
Definition: vulkan.h:4874
@ VK_SHADER_STAGE_COMPUTE_BIT
Definition: vulkan.h:4880
@ VK_SHADER_STAGE_GEOMETRY_BIT
Definition: vulkan.h:4877
@ VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT
Definition: vulkan.h:4875
@ VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT
Definition: vulkan.h:4876
@ VK_SHADER_STAGE_FRAGMENT_BIT
Definition: vulkan.h:4878
@ WINED3D_SHADER_TYPE_HULL
Definition: wined3d.h:844
@ WINED3D_SHADER_TYPE_PIXEL
Definition: wined3d.h:841
@ WINED3D_SHADER_TYPE_GEOMETRY
Definition: wined3d.h:843
@ WINED3D_SHADER_TYPE_DOMAIN
Definition: wined3d.h:845
@ WINED3D_SHADER_TYPE_COMPUTE
Definition: wined3d.h:848
@ WINED3D_SHADER_TYPE_VERTEX
Definition: wined3d.h:842

Referenced by shader_spirv_resource_bindings_init(), and wined3d_context_vk_update_graphics_pipeline_key().

◆ wined3d_adapter_vk()

static struct wined3d_adapter_vk * wined3d_adapter_vk ( struct wined3d_adapter *  adapter)
inlinestatic

Definition at line 737 of file wined3d_vk.h.

738{
740}
return adapter
GLboolean GLboolean GLboolean GLboolean a
Definition: glext.h:6204
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260

◆ wined3d_adapter_vk_get_memory_type_index()

unsigned int wined3d_adapter_vk_get_memory_type_index ( const struct wined3d_adapter_vk *  adapter_vk,
uint32_t  memory_type_mask,
VkMemoryPropertyFlags  flags 
)

Definition at line 1259 of file adapter_vk.c.

1261{
1262 const VkPhysicalDeviceMemoryProperties *memory_info = &adapter_vk->memory_properties;
1263 unsigned int i;
1264
1265 for (i = 0; i < memory_info->memoryTypeCount; ++i)
1266 {
1267 if (!(memory_type_mask & (1u << i)))
1268 continue;
1269 if ((memory_info->memoryTypes[i].propertyFlags & flags) == flags)
1270 return i;
1271 }
1272
1273 return ~0u;
1274}
VkMemoryPropertyFlags propertyFlags
Definition: vulkan.h:9474
VkMemoryType memoryTypes[VK_MAX_MEMORY_TYPES]
Definition: vulkan.h:11320
VkPhysicalDeviceMemoryProperties memory_properties
Definition: wined3d_vk.h:734

Referenced by wined3d_context_vk_create_bo(), and wined3d_context_vk_create_image().

◆ wined3d_adapter_vk_init_format_info()

BOOL wined3d_adapter_vk_init_format_info ( struct wined3d_adapter_vk *  adapter_vk,
const struct wined3d_vk_info *  vk_info 
)

Definition at line 4399 of file utils.c.

4401{
4402 VkPhysicalDevice vk_physical_device = adapter_vk->physical_device;
4403 struct wined3d_adapter *adapter = &adapter_vk->a;
4404 struct wined3d_format_vk *format;
4405 unsigned int i;
4406
4408 return FALSE;
4409
4410 for (i = 0; i < WINED3D_FORMAT_COUNT; ++i)
4411 {
4413
4414 if (format->f.id)
4415 init_vulkan_format_info(format, vk_info, vk_physical_device);
4416 }
4417
4418 if (!init_typeless_formats(adapter)) goto fail;
4419
4420 return TRUE;
4421
4422fail:
4423 free(adapter->formats);
4424 adapter->formats = NULL;
4425 return FALSE;
4426}
#define free
Definition: debug_ros.c:5
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define WINED3D_FORMAT_COUNT
Definition: utils.c:70
static struct wined3d_format * get_format_by_idx(const struct wined3d_adapter *adapter, int fmt_idx)
Definition: utils.c:1958
static BOOL init_typeless_formats(const struct wined3d_adapter *adapter)
Definition: utils.c:3764
static void init_vulkan_format_info(struct wined3d_format_vk *format, const struct wined3d_vk_info *vk_info, VkPhysicalDevice vk_physical_device)
Definition: utils.c:4203
static struct wined3d_format_vk * wined3d_format_vk_mutable(struct wined3d_format *format)
Definition: utils.c:1953
static BOOL wined3d_adapter_init_format_info(struct wined3d_adapter *adapter, size_t format_size)
Definition: utils.c:4107
struct wined3d_adapter a
Definition: wined3d_vk.h:726
VkPhysicalDevice physical_device
Definition: wined3d_vk.h:731

Referenced by wined3d_adapter_vk_init().

◆ wined3d_allocator_chunk_vk()

Definition at line 783 of file wined3d_vk.h.

784{
786}
const GLubyte * c
Definition: glext.h:8905

◆ wined3d_allocator_chunk_vk_map()

void * wined3d_allocator_chunk_vk_map ( struct wined3d_allocator_chunk_vk *  chunk_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 304 of file context_vk.c.

306{
307 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
308 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
309 void *map_ptr;
310 VkResult vr;
311
312 TRACE("chunk %p, memory 0x%s, map_ptr %p.\n", chunk_vk,
313 wine_dbgstr_longlong(chunk_vk->vk_memory), chunk_vk->c.map_ptr);
314
316
317 if (!chunk_vk->c.map_ptr)
318 {
319 if ((vr = VK_CALL(vkMapMemory(device_vk->vk_device,
320 chunk_vk->vk_memory, 0, VK_WHOLE_SIZE, 0, &chunk_vk->c.map_ptr))) < 0)
321 {
322 ERR("Failed to map chunk memory, vr %s.\n", wined3d_debug_vkresult(vr));
324 return NULL;
325 }
326
328 }
329
330 ++chunk_vk->c.map_count;
331 map_ptr = chunk_vk->c.map_ptr;
332
334
335 return map_ptr;
336}
static void wined3d_allocator_chunk_vk_unlock(struct wined3d_allocator_chunk_vk *chunk_vk)
Definition: context_vk.c:299
static void wined3d_allocator_chunk_vk_lock(struct wined3d_allocator_chunk_vk *chunk_vk)
Definition: context_vk.c:294
const char * wined3d_debug_vkresult(VkResult vr)
Definition: utils.c:5463
static __inline const char * wine_dbgstr_longlong(ULONGLONG ll)
Definition: compat.h:49
#define TRACE(s)
Definition: solgame.cpp:4
VkDeviceMemory vk_memory
Definition: wined3d_vk.h:780
struct wined3d_allocator_chunk c
Definition: wined3d_vk.h:779
struct wined3d_device d
Definition: wined3d_vk.h:821
VkDevice vk_device
Definition: wined3d_vk.h:825
struct wined3d_context_vk context_vk
Definition: wined3d_vk.h:823
#define VK_WHOLE_SIZE
Definition: vulkan.h:53
VkResult VKAPI_CALL vkMapMemory(VkDevice device, VkDeviceMemory memory, VkDeviceSize offset, VkDeviceSize size, VkMemoryMapFlags flags, void **ppData)
VkResult
Definition: vulkan.h:4639
ssize_t adapter_adjust_mapped_memory(struct wined3d_adapter *adapter, ssize_t size)
Definition: directx.c:167
#define WINED3D_ALLOCATOR_CHUNK_SIZE

Referenced by wined3d_bo_vk_map().

◆ wined3d_allocator_chunk_vk_unmap()

void wined3d_allocator_chunk_vk_unmap ( struct wined3d_allocator_chunk_vk *  chunk_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 338 of file context_vk.c.

340{
341 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
342 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
343
344 TRACE("chunk_vk %p, context_vk %p.\n", chunk_vk, context_vk);
345
347
348 if (--chunk_vk->c.map_count)
349 {
351 return;
352 }
353
354 VK_CALL(vkUnmapMemory(device_vk->vk_device, chunk_vk->vk_memory));
355 chunk_vk->c.map_ptr = NULL;
356
358
360}
void VKAPI_CALL vkUnmapMemory(VkDevice device, VkDeviceMemory memory)

Referenced by wined3d_bo_vk_unmap(), and wined3d_context_vk_destroy_bo().

◆ wined3d_bo_slab_vk_map()

void * wined3d_bo_slab_vk_map ( struct wined3d_bo_slab_vk *  slab_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 796 of file adapter_vk.c.

797{
798 void *map_ptr;
799
800 TRACE("slab_vk %p, context_vk %p.\n", slab_vk, context_vk);
801
802 wined3d_bo_slab_vk_lock(slab_vk, context_vk);
803
804 if (!slab_vk->map_ptr && !(slab_vk->map_ptr = wined3d_bo_vk_map(&slab_vk->bo, context_vk)))
805 {
806 wined3d_bo_slab_vk_unlock(slab_vk, context_vk);
807 ERR("Failed to map slab.\n");
808 return NULL;
809 }
810
811 ++slab_vk->map_count;
812 map_ptr = slab_vk->map_ptr;
813
814 wined3d_bo_slab_vk_unlock(slab_vk, context_vk);
815
816 return map_ptr;
817}
static void * wined3d_bo_vk_map(struct wined3d_bo_vk *bo, struct wined3d_context_vk *context_vk)
Definition: adapter_vk.c:698
static void wined3d_bo_slab_vk_unlock(struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk)
Definition: adapter_vk.c:791
static void wined3d_bo_slab_vk_lock(struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk)
Definition: adapter_vk.c:786
unsigned int map_count
Definition: wined3d_vk.h:344
struct wined3d_bo_vk bo
Definition: wined3d_vk.h:343

Referenced by wined3d_bo_vk_map().

◆ wined3d_bo_slab_vk_unmap()

void wined3d_bo_slab_vk_unmap ( struct wined3d_bo_slab_vk *  slab_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 819 of file adapter_vk.c.

820{
821 wined3d_bo_slab_vk_lock(slab_vk, context_vk);
822
823 if (--slab_vk->map_count)
824 {
825 wined3d_bo_slab_vk_unlock(slab_vk, context_vk);
826 return;
827 }
828
829 wined3d_bo_vk_unmap(&slab_vk->bo, context_vk);
830 slab_vk->map_ptr = NULL;
831
832 wined3d_bo_slab_vk_unlock(slab_vk, context_vk);
833}
static void wined3d_bo_vk_unmap(struct wined3d_bo_vk *bo, struct wined3d_context_vk *context_vk)
Definition: adapter_vk.c:743

Referenced by wined3d_bo_vk_unmap(), and wined3d_context_vk_destroy_bo().

◆ wined3d_bo_vk()

static struct wined3d_bo_vk * wined3d_bo_vk ( struct wined3d_bo *  bo)
inlinestatic

Definition at line 326 of file wined3d_vk.h.

327{
328 return CONTAINING_RECORD(bo, struct wined3d_bo_vk, b);
329}
GLboolean GLboolean GLboolean b
Definition: glext.h:6204

◆ wined3d_buffer_vk()

static struct wined3d_buffer_vk * wined3d_buffer_vk ( struct wined3d_buffer *  buffer)
inlinestatic

Definition at line 926 of file wined3d_vk.h.

927{
929}
GLuint buffer
Definition: glext.h:5915

◆ wined3d_buffer_vk_barrier()

void wined3d_buffer_vk_barrier ( struct wined3d_buffer_vk *  buffer_vk,
struct wined3d_context_vk *  context_vk,
uint32_t  bind_mask 
)

Definition at line 1280 of file buffer.c.

1282{
1283 uint32_t src_bind_mask = 0;
1284
1285 TRACE("buffer_vk %p, context_vk %p, bind_mask %s.\n",
1286 buffer_vk, context_vk, wined3d_debug_bind_flags(bind_mask));
1287
1288 if (bind_mask & ~WINED3D_READ_ONLY_BIND_MASK)
1289 {
1290 src_bind_mask = buffer_vk->bind_mask & WINED3D_READ_ONLY_BIND_MASK;
1291 if (!src_bind_mask)
1292 src_bind_mask = buffer_vk->bind_mask;
1293
1294 buffer_vk->bind_mask = bind_mask;
1295 }
1296 else if ((buffer_vk->bind_mask & bind_mask) != bind_mask)
1297 {
1298 src_bind_mask = buffer_vk->bind_mask & ~WINED3D_READ_ONLY_BIND_MASK;
1299 buffer_vk->bind_mask |= bind_mask;
1300 }
1301
1302 if (src_bind_mask)
1303 {
1304 const struct wined3d_bo_vk *bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
1305 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1306 VkBufferMemoryBarrier vk_barrier;
1307
1308 TRACE(" %s -> %s.\n",
1309 wined3d_debug_bind_flags(src_bind_mask), wined3d_debug_bind_flags(bind_mask));
1310
1312
1314 vk_barrier.pNext = NULL;
1315 vk_barrier.srcAccessMask = vk_access_mask_from_bind_flags(src_bind_mask);
1316 vk_barrier.dstAccessMask = vk_access_mask_from_bind_flags(bind_mask);
1319 vk_barrier.buffer = bo->vk_buffer;
1320 vk_barrier.offset = bo->b.buffer_offset;
1321 vk_barrier.size = buffer_vk->b.resource.size;
1325 0, 0, NULL, 1, &vk_barrier, 0, NULL));
1326 }
1327}
UINT32 uint32_t
Definition: types.h:75
VkPipelineStageFlags vk_pipeline_stage_mask_from_bind_flags(uint32_t bind_flags)
Definition: resource.c:552
VkAccessFlags vk_access_mask_from_bind_flags(uint32_t bind_flags)
Definition: resource.c:526
const char * wined3d_debug_bind_flags(uint32_t bind_flags)
Definition: utils.c:4845
struct wined3d_buffer b
Definition: wined3d_vk.h:920
uint32_t bind_mask
Definition: wined3d_vk.h:923
static const uint32_t WINED3D_READ_ONLY_BIND_MASK

Referenced by wined3d_context_vk_apply_compute_state(), wined3d_context_vk_load_buffers(), wined3d_context_vk_load_shader_resources(), and wined3d_resource_vk_barrier().

◆ wined3d_buffer_vk_get_buffer_info()

const VkDescriptorBufferInfo * wined3d_buffer_vk_get_buffer_info ( struct wined3d_buffer_vk *  buffer_vk)

Definition at line 1187 of file buffer.c.

1188{
1189 struct wined3d_bo_vk *bo = wined3d_bo_vk(buffer_vk->b.buffer_object);
1190
1191 if (buffer_vk->b.bo_user.valid)
1192 return &buffer_vk->buffer_info;
1193
1194 buffer_vk->buffer_info.buffer = bo->vk_buffer;
1195 buffer_vk->buffer_info.offset = bo->b.buffer_offset;
1196 buffer_vk->buffer_info.range = buffer_vk->b.resource.size;
1197 wined3d_buffer_validate_user(&buffer_vk->b);
1198
1199 return &buffer_vk->buffer_info;
1200}
VkDescriptorBufferInfo buffer_info
Definition: wined3d_vk.h:922
static void wined3d_buffer_validate_user(struct wined3d_buffer *buffer)

Referenced by wined3d_context_vk_apply_draw_state(), wined3d_context_vk_bind_stream_output_buffers(), wined3d_context_vk_bind_vertex_buffers(), and wined3d_shader_descriptor_writes_vk_add_cbv_write().

◆ wined3d_buffer_vk_init()

HRESULT wined3d_buffer_vk_init ( struct wined3d_buffer_vk *  buffer_vk,
struct wined3d_device *  device,
const struct wined3d_buffer_desc *  desc,
const struct wined3d_sub_resource_data *  data,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 1258 of file buffer.c.

1261{
1262 const struct wined3d_vk_info *vk_info = &wined3d_adapter_vk(device->adapter)->vk_info;
1263
1264 TRACE("buffer_vk %p, device %p, desc %p, data %p, parent %p, parent_ops %p.\n",
1265 buffer_vk, device, desc, data, parent, parent_ops);
1266
1267 if ((desc->bind_flags & WINED3D_BIND_STREAM_OUTPUT)
1269 {
1270 WARN("The Vulkan implementation does not support transform feedback.\n");
1272 }
1273
1274 if (desc->access & WINED3D_RESOURCE_ACCESS_GPU)
1275 buffer_vk->b.flags |= WINED3D_BUFFER_USE_BO;
1276
1277 return wined3d_buffer_init(&buffer_vk->b, device, desc, data, parent, parent_ops, &wined3d_buffer_vk_ops);
1278}
static HRESULT wined3d_buffer_init(struct wined3d_buffer *buffer, struct wined3d_device *device, const struct wined3d_buffer_desc *desc, const struct wined3d_sub_resource_data *data, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_buffer_ops *buffer_ops)
Definition: buffer.c:931
static const struct wined3d_buffer_ops wined3d_buffer_vk_ops
Definition: buffer.c:1252
#define WINED3D_BUFFER_USE_BO
Definition: buffer.c:32
r parent
Definition: btrfs.c:3010
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
Definition: devices.h:37
struct wined3d_vk_info vk_info
Definition: wined3d_vk.h:728
BOOL supported[WINED3D_VK_EXT_COUNT]
Definition: wined3d_vk.h:261
#define WINED3D_RESOURCE_ACCESS_GPU
Definition: wined3d.h:51
#define WINED3DERR_INVALIDCALL
Definition: wined3d.h:44

Referenced by adapter_vk_create_buffer().

◆ wined3d_context_vk()

static struct wined3d_context_vk * wined3d_context_vk ( struct wined3d_context *  context)
inlinestatic

Definition at line 662 of file wined3d_vk.h.

663{
665}

◆ wined3d_context_vk_allocate_query()

bool wined3d_context_vk_allocate_query ( struct wined3d_context_vk *  context_vk,
enum wined3d_query_type  type,
struct wined3d_query_pool_idx_vk *  pool_idx 
)

Definition at line 1623 of file context_vk.c.

1625{
1626 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1627 struct wined3d_query_pool_vk *pool_vk, *entry;
1628 struct wined3d_device_vk *device_vk;
1629 struct list *free_pools;
1630 VkResult vr;
1631 size_t idx;
1632
1633 switch (type)
1634 {
1636 free_pools = &context_vk->free_occlusion_query_pools;
1637 break;
1638
1640 free_pools = &context_vk->free_timestamp_query_pools;
1641 break;
1642
1644 free_pools = &context_vk->free_pipeline_statistics_query_pools;
1645 break;
1646
1652 free_pools = &context_vk->free_stream_output_statistics_query_pools;
1653 break;
1654
1655 default:
1656 FIXME("Unhandled query type %#x.\n", type);
1657 return false;
1658 }
1659
1660 LIST_FOR_EACH_ENTRY_SAFE(pool_vk, entry, free_pools, struct wined3d_query_pool_vk, entry)
1661 {
1663 goto done;
1664 list_remove(&pool_vk->entry);
1665 list_init(&pool_vk->entry);
1666 }
1667
1668 if (!(pool_vk = calloc(1, sizeof(*pool_vk))))
1669 return false;
1670 if (!wined3d_query_pool_vk_init(pool_vk, context_vk, type, free_pools))
1671 {
1672 free(pool_vk);
1673 return false;
1674 }
1675
1676 device_vk = wined3d_device_vk(context_vk->c.device);
1677
1679 {
1682 }
1683 else
1684 {
1685 VkEventCreateInfo event_create_info;
1686
1690
1691 event_create_info.sType = VK_STRUCTURE_TYPE_EVENT_CREATE_INFO;
1692 event_create_info.pNext = NULL;
1693 event_create_info.flags = 0;
1694
1695 /* We probably shouldn't call vkGetQueryPoolResults() without synchronizing with vkCmdResetQueryPool()
1696 * even if the query pool is freshly allocated. wined3d_query_vk_accumulate_data() will check this event
1697 * before returning results. */
1698 vr = VK_CALL(vkCreateEvent(device_vk->vk_device, &event_create_info, NULL, &pool_vk->vk_event));
1699 if (vr == VK_SUCCESS)
1700 {
1701 /* At which stage vkCmdResetQueryPool() executes? */
1704 }
1705 else
1706 {
1707 ERR("Failed to create event, vr %s.\n", wined3d_debug_vkresult(vr));
1708 }
1709 }
1710
1712 {
1713 wined3d_query_pool_vk_cleanup(pool_vk, context_vk);
1714 free(pool_vk);
1715 return false;
1716 }
1717
1718done:
1719 pool_idx->pool_vk = pool_vk;
1720 pool_idx->idx = idx;
1721
1722 return true;
1723}
static void list_remove(struct list_entry *entry)
Definition: list.h:90
static void list_init(struct list_entry *head)
Definition: list.h:51
Definition: list.h:39
bool wined3d_query_pool_vk_init(struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk, enum wined3d_query_type type, struct list *free_pools)
Definition: query.c:1390
void wined3d_query_pool_vk_cleanup(struct wined3d_query_pool_vk *pool_vk, struct wined3d_context_vk *context_vk)
Definition: query.c:1378
bool wined3d_query_pool_vk_allocate_query(struct wined3d_query_pool_vk *pool_vk, size_t *idx)
Definition: query.c:1357
unsigned int idx
Definition: utils.c:40
uint32_t entry
Definition: isohybrid.c:63
#define calloc
Definition: rosglue.h:14
#define LIST_FOR_EACH_ENTRY_SAFE(cursor, cursor2, list, type, field)
Definition: list.h:242
const void * pNext
Definition: vulkan.h:8621
VkStructureType sType
Definition: vulkan.h:8620
VkEventCreateFlags flags
Definition: vulkan.h:8622
struct list free_occlusion_query_pools
Definition: wined3d_vk.h:650
struct list free_stream_output_statistics_query_pools
Definition: wined3d_vk.h:653
struct list free_pipeline_statistics_query_pools
Definition: wined3d_vk.h:652
struct wined3d_context c
Definition: wined3d_vk.h:588
struct list free_timestamp_query_pools
Definition: wined3d_vk.h:651
struct wined3d_query_pool_vk * pool_vk
Definition: wined3d_vk.h:385
VkQueryPool vk_query_pool
Definition: wined3d_vk.h:368
void VKAPI_CALL vkCmdResetQueryPool(VkCommandBuffer commandBuffer, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount)
VkResult VKAPI_CALL vkCreateEvent(VkDevice device, const VkEventCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkEvent *pEvent)
@ VK_SUCCESS
Definition: vulkan.h:4672
void VKAPI_CALL vkCmdSetEvent(VkCommandBuffer commandBuffer, VkEvent event, VkPipelineStageFlags stageMask)
@ VK_STRUCTURE_TYPE_EVENT_CREATE_INFO
Definition: vulkan.h:4974
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM2
Definition: wined3d.h:746
@ WINED3D_QUERY_TYPE_SO_STATISTICS
Definition: wined3d.h:742
@ WINED3D_QUERY_TYPE_PIPELINE_STATISTICS
Definition: wined3d.h:741
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM0
Definition: wined3d.h:744
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM1
Definition: wined3d.h:745
@ WINED3D_QUERY_TYPE_TIMESTAMP
Definition: wined3d.h:731
@ WINED3D_QUERY_TYPE_OCCLUSION
Definition: wined3d.h:730
@ WINED3D_QUERY_TYPE_SO_STATISTICS_STREAM3
Definition: wined3d.h:747
#define WINED3D_QUERY_POOL_SIZE

Referenced by wined3d_context_vk_end_current_render_pass(), wined3d_context_vk_get_command_buffer(), wined3d_query_timestamp_vk_issue(), and wined3d_query_vk_issue().

◆ wined3d_context_vk_allocate_vram_chunk_memory()

VkDeviceMemory wined3d_context_vk_allocate_vram_chunk_memory ( struct wined3d_context_vk *  context_vk,
unsigned int  pool,
size_t  size 
)

Definition at line 362 of file context_vk.c.

364{
365 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
366 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
367 VkMemoryAllocateInfo allocate_info;
368 VkDeviceMemory vk_memory;
369 VkResult vr;
370
372 allocate_info.pNext = NULL;
373 allocate_info.allocationSize = size;
374 allocate_info.memoryTypeIndex = pool;
375 if ((vr = VK_CALL(vkAllocateMemory(device_vk->vk_device, &allocate_info, NULL, &vk_memory))) < 0)
376 {
377 ERR("Failed to allocate memory, vr %s.\n", wined3d_debug_vkresult(vr));
378 return VK_NULL_HANDLE;
379 }
380
381 return vk_memory;
382}
VkStructureType sType
Definition: vulkan.h:9351
uint32_t memoryTypeIndex
Definition: vulkan.h:9354
const void * pNext
Definition: vulkan.h:9352
VkResult VKAPI_CALL vkAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, const VkAllocationCallbacks *pAllocator, VkDeviceMemory *pMemory)
#define VK_NULL_HANDLE
Definition: vulkan.h:861
@ VK_STRUCTURE_TYPE_MEMORY_ALLOCATE_INFO
Definition: vulkan.h:4969

Referenced by wined3d_allocator_vk_create_chunk(), and wined3d_context_vk_allocate_memory().

◆ wined3d_context_vk_apply_compute_state()

VkCommandBuffer wined3d_context_vk_apply_compute_state ( struct wined3d_context_vk *  context_vk,
const struct wined3d_state *  state,
struct wined3d_buffer_vk *  indirect_vk 
)

Definition at line 4080 of file context_vk.c.

4082{
4083 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
4084 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
4085 VkCommandBuffer vk_command_buffer;
4086
4088
4090 context_vk->c.shader_update_mask |= 1u << WINED3D_SHADER_TYPE_COMPUTE;
4091
4092 if (context_vk->c.shader_update_mask & (1u << WINED3D_SHADER_TYPE_COMPUTE))
4093 {
4094 device_vk->d.shader_backend->shader_apply_compute_state(device_vk->d.shader_priv, &context_vk->c, state);
4095 if (!context_vk->compute.vk_pipeline)
4096 {
4097 ERR("No compute pipeline set.\n");
4098 return VK_NULL_HANDLE;
4099 }
4100 context_vk->c.update_compute_shader_resource_bindings = 1;
4101 context_vk->c.update_compute_unordered_access_view_bindings = 1;
4102 context_vk->update_compute_pipeline = 1;
4103 }
4104
4106
4107 if (indirect_vk)
4108 {
4109 wined3d_buffer_load_location(&indirect_vk->b, &context_vk->c, WINED3D_LOCATION_BUFFER);
4111 }
4112
4113 if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
4114 {
4115 ERR("Failed to get command buffer.\n");
4116 return VK_NULL_HANDLE;
4117 }
4118
4119 if (context_vk->update_compute_pipeline)
4120 {
4121 VK_CALL(vkCmdBindPipeline(vk_command_buffer,
4122 VK_PIPELINE_BIND_POINT_COMPUTE, context_vk->compute.vk_pipeline));
4123 context_vk->update_compute_pipeline = 0;
4124 }
4125
4128 context_vk->c.update_compute_shader_resource_bindings = 1;
4130 context_vk->c.update_compute_unordered_access_view_bindings = 1;
4131
4132 if (context_vk->c.update_compute_shader_resource_bindings
4133 || context_vk->c.update_compute_unordered_access_view_bindings)
4134 {
4135 if (!wined3d_context_vk_update_descriptors(context_vk, vk_command_buffer, state, WINED3D_PIPELINE_COMPUTE))
4136 {
4137 ERR("Failed to update shader descriptors.\n");
4138 return VK_NULL_HANDLE;
4139 }
4140
4141 context_vk->c.update_compute_shader_resource_bindings = 0;
4142 context_vk->c.update_compute_unordered_access_view_bindings = 0;
4143 }
4144
4145 memset(context_vk->c.dirty_compute_states, 0, sizeof(context_vk->c.dirty_compute_states));
4146 context_vk->c.shader_update_mask &= ~(1u << WINED3D_SHADER_TYPE_COMPUTE);
4147
4148 return vk_command_buffer;
4149}
static int state
Definition: maze.c:121
static void wined3d_context_vk_load_shader_resources(struct wined3d_context_vk *context_vk, const struct wined3d_state *state, enum wined3d_pipeline pipeline)
Definition: context_vk.c:3593
static bool wined3d_context_vk_update_descriptors(struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, const struct wined3d_state *state, enum wined3d_pipeline pipeline)
Definition: context_vk.c:3331
BOOL wined3d_buffer_load_location(struct wined3d_buffer *buffer, struct wined3d_context *context, uint32_t location)
Definition: buffer.c:269
void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk *buffer_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
Definition: buffer.c:1280
#define memset(x, y, z)
Definition: compat.h:39
struct wined3d_context_vk::@363 compute
uint32_t update_compute_pipeline
Definition: wined3d_vk.h:594
@ VK_PIPELINE_BIND_POINT_COMPUTE
Definition: vulkan.h:4069
void VKAPI_CALL vkCmdBindPipeline(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipeline pipeline)
@ WINED3D_PIPELINE_COMPUTE
Definition: wined3d.h:856
#define WINED3D_LOCATION_BUFFER
#define STATE_COMPUTE_SHADER
#define STATE_COMPUTE_CONSTANT_BUFFER
#define STATE_COMPUTE_SHADER_RESOURCE_BINDING
#define STATE_COMPUTE_UNORDERED_ACCESS_VIEW_BINDING
static bool wined3d_context_is_compute_state_dirty(const struct wined3d_context *context, unsigned int state_id)

Referenced by adapter_vk_dispatch_compute().

◆ wined3d_context_vk_apply_draw_state()

VkCommandBuffer wined3d_context_vk_apply_draw_state ( struct wined3d_context_vk *  context_vk,
const struct wined3d_state *  state,
struct wined3d_buffer_vk *  indirect_vk,
bool  indexed 
)

Definition at line 3722 of file context_vk.c.

3724{
3725 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
3726 const struct wined3d_d3d_info *d3d_info = context_vk->c.d3d_info;
3727 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
3728 const struct wined3d_blend_state *b = state->blend_state;
3729 VkSampleCountFlagBits prev_sample_count, sample_count;
3730 bool dual_source_blend = b && b->dual_source;
3731 struct wined3d_rendertarget_view *dsv;
3732 struct wined3d_rendertarget_view *rtv;
3733 struct wined3d_buffer_vk *buffer_vk;
3734 VkCommandBuffer vk_command_buffer;
3735 unsigned int i, invalidate_rt = 0;
3736 uint32_t null_buffer_binding;
3737 bool invalidate_ds = false;
3738
3741 || dual_source_blend != context_vk->c.last_was_dual_source_blend)
3742 {
3743 context_vk->c.shader_update_mask |= (1u << WINED3D_SHADER_TYPE_PIXEL);
3744 context_vk->c.last_was_dual_source_blend = dual_source_blend;
3745 }
3747 context_vk->c.shader_update_mask |= (1u << WINED3D_SHADER_TYPE_VERTEX);
3749 context_vk->c.shader_update_mask |= (1u << WINED3D_SHADER_TYPE_GEOMETRY);
3751 context_vk->c.shader_update_mask |= (1u << WINED3D_SHADER_TYPE_HULL) | (1u << WINED3D_SHADER_TYPE_DOMAIN);
3753 context_vk->c.shader_update_mask |= (1u << WINED3D_SHADER_TYPE_DOMAIN);
3754
3755 prev_sample_count = context_vk->sample_count;
3756 context_vk->sample_count = 0;
3757 for (i = 0; i < ARRAY_SIZE(state->fb.render_targets); ++i)
3758 {
3759 if (!(rtv = state->fb.render_targets[i]) || rtv->format->id == WINED3DFMT_NULL)
3760 continue;
3761
3762 if (wined3d_blend_state_get_writemask(state->blend_state, i))
3763 {
3764 /* We handle clears at the beginning of the render pass, no need for an explicit clear
3765 * first. */
3766 wined3d_context_vk_prepare_used_rtv(context_vk, rtv);
3767 invalidate_rt |= (1 << i);
3768 }
3769 else
3770 {
3771 wined3d_rendertarget_view_prepare_location(rtv, &context_vk->c, rtv->resource->draw_binding);
3772 }
3773
3774 sample_count = max(1, wined3d_resource_get_sample_count(rtv->resource));
3775 if (!context_vk->sample_count)
3776 context_vk->sample_count = sample_count;
3777 else if (context_vk->sample_count != sample_count)
3778 FIXME("Inconsistent sample counts (%u != %u).\n", context_vk->sample_count, sample_count);
3779 }
3780
3781 if ((dsv = state->fb.depth_stencil))
3782 {
3784 wined3d_context_vk_prepare_used_rtv(context_vk, dsv);
3785 else
3786 wined3d_rendertarget_view_prepare_location(dsv, &context_vk->c, dsv->resource->draw_binding);
3787
3788 if (!state->depth_stencil_state || state->depth_stencil_state->writes_ds)
3789 invalidate_ds = true;
3790
3791 sample_count = max(1, wined3d_resource_get_sample_count(dsv->resource));
3792 if (!context_vk->sample_count)
3793 context_vk->sample_count = sample_count;
3794 else if (context_vk->sample_count != sample_count)
3795 FIXME("Inconsistent sample counts (%u != %u).\n", context_vk->sample_count, sample_count);
3796 }
3797
3798 if (!context_vk->sample_count)
3799 context_vk->sample_count = VK_SAMPLE_COUNT_1_BIT;
3800
3801 if (context_vk->sample_count != prev_sample_count)
3802 context_vk->c.update_multisample_state = 1;
3803
3804 if (context_vk->c.shader_update_mask & ~(1u << WINED3D_SHADER_TYPE_COMPUTE))
3805 {
3806 device_vk->d.shader_backend->shader_apply_draw_state(device_vk->d.shader_priv, &context_vk->c, state);
3807 if (!context_vk->graphics.vk_pipeline_layout)
3808 {
3809 ERR("No pipeline layout set.\n");
3810 return VK_NULL_HANDLE;
3811 }
3812 context_vk->c.update_shader_resource_bindings = 1;
3813 context_vk->c.update_unordered_access_view_bindings = 1;
3814 }
3815
3817
3818 wined3d_context_vk_load_buffers(context_vk, state, indirect_vk, indexed);
3819
3822
3823 if (!wined3d_context_vk_begin_render_pass(context_vk, state, vk_info))
3824 {
3825 ERR("Failed to begin render pass.\n");
3826 return VK_NULL_HANDLE;
3827 }
3828 vk_command_buffer = context_vk->current_command_buffer.vk_command_buffer;
3829
3830 while (invalidate_rt)
3831 {
3832 i = wined3d_bit_scan(&invalidate_rt);
3833 rtv = state->fb.render_targets[i];
3836 }
3837
3838 if (invalidate_ds)
3839 {
3842 }
3843
3844 if (wined3d_context_vk_update_graphics_pipeline_key(context_vk, state, context_vk->graphics.vk_pipeline_layout,
3845 &null_buffer_binding) || !context_vk->graphics.vk_pipeline)
3846 {
3847 if (!(context_vk->graphics.vk_pipeline = wined3d_context_vk_get_graphics_pipeline(context_vk)))
3848 {
3849 ERR("Failed to get graphics pipeline.\n");
3850 return VK_NULL_HANDLE;
3851 }
3852
3853 VK_CALL(vkCmdBindPipeline(vk_command_buffer,
3854 VK_PIPELINE_BIND_POINT_GRAPHICS, context_vk->graphics.vk_pipeline));
3855 if (null_buffer_binding != ~0u)
3856 {
3857 VkDeviceSize offset = 0;
3858 VK_CALL(vkCmdBindVertexBuffers(vk_command_buffer, null_buffer_binding, 1,
3859 &device_vk->null_resources_vk.buffer_info.buffer, &offset));
3860 }
3861 }
3862
3864 {
3866 state->stencil_ref & wined3d_mask_from_size(dsv->format->stencil_size)));
3867 }
3868
3870 wined3d_context_vk_bind_vertex_buffers(context_vk, vk_command_buffer, state, vk_info);
3871
3873 {
3874 context_vk->update_stream_output = 1;
3875 context_vk->c.transform_feedback_paused = 0;
3876 }
3877 if (context_vk->c.transform_feedback_active && context_vk->update_stream_output)
3878 {
3879 wined3d_context_vk_bind_stream_output_buffers(context_vk, vk_command_buffer, state, vk_info);
3880 context_vk->update_stream_output = 0;
3881 }
3882
3883 if (wined3d_context_is_graphics_state_dirty(&context_vk->c, STATE_INDEXBUFFER) && state->index_buffer)
3884 {
3886 VkIndexType idx_type;
3887
3888 if (state->index_format == WINED3DFMT_R16_UINT)
3889 idx_type = VK_INDEX_TYPE_UINT16;
3890 else
3891 idx_type = VK_INDEX_TYPE_UINT32;
3892 buffer_vk = wined3d_buffer_vk(state->index_buffer);
3894 wined3d_context_vk_reference_bo(context_vk, wined3d_bo_vk(buffer_vk->b.buffer_object));
3895 VK_CALL(vkCmdBindIndexBuffer(vk_command_buffer, buffer_info->buffer,
3896 buffer_info->offset + state->index_offset, idx_type));
3897 }
3898
3909 context_vk->c.update_shader_resource_bindings = 1;
3911 context_vk->c.update_unordered_access_view_bindings = 1;
3912
3913 if (context_vk->c.update_shader_resource_bindings || context_vk->c.update_unordered_access_view_bindings)
3914 {
3915 if (!wined3d_context_vk_update_descriptors(context_vk, vk_command_buffer, state, WINED3D_PIPELINE_GRAPHICS))
3916 {
3917 ERR("Failed to update shader descriptors.\n");
3918 return VK_NULL_HANDLE;
3919 }
3920
3921 context_vk->c.update_shader_resource_bindings = 0;
3922 context_vk->c.update_unordered_access_view_bindings = 0;
3923 }
3924
3926 VK_CALL(vkCmdSetBlendConstants(vk_command_buffer, &state->blend_factor.r));
3927
3931 {
3932 unsigned int viewport_count = (context_vk->vk_info->multiple_viewports ? WINED3D_MAX_VIEWPORTS : 1);
3935 unsigned int i;
3936
3937 for (i = 0; i < viewport_count; ++i)
3938 {
3939 const struct wined3d_viewport *src_viewport = &state->viewports[i];
3940 VkViewport *viewport = &viewports[i];
3941 VkRect2D *scissor = &scissors[i];
3942
3943 if (i >= state->viewport_count)
3944 {
3945 viewport->x = 0.0f;
3946 viewport->y = 0.0f;
3947 viewport->width = 1.0f;
3948 viewport->height = 1.0f;
3949 viewport->minDepth = 0.0f;
3950 viewport->maxDepth = 0.0f;
3951 memset(scissor, 0, sizeof(*scissor));
3952 continue;
3953 }
3954
3955 viewport->x = src_viewport->x;
3956 viewport->y = src_viewport->y;
3957 viewport->width = src_viewport->width;
3958 viewport->height = src_viewport->height;
3959 viewport->minDepth = src_viewport->min_z;
3960 viewport->maxDepth = src_viewport->max_z;
3961
3962 if (state->rasterizer_state && state->rasterizer_state->desc.scissor)
3963 {
3964 const RECT *r = &state->scissor_rects[i];
3965
3966 if (i >= state->scissor_rect_count)
3967 {
3968 memset(scissor, 0, sizeof(*scissor));
3969 continue;
3970 }
3971
3972 scissor->offset.x = r->left;
3973 scissor->offset.y = r->top;
3974 scissor->extent.width = r->right - r->left;
3975 scissor->extent.height = r->bottom - r->top;
3976 }
3977 else
3978 {
3979 scissor->offset.x = src_viewport->x;
3980 scissor->offset.y = src_viewport->y;
3981 scissor->extent.width = src_viewport->width;
3982 scissor->extent.height = src_viewport->height;
3983 }
3984
3985 /* Scissor offsets need to be non-negative (VUID-VkPipelineViewportStateCreateInfo-x-02821) */
3986 if (scissor->offset.x < 0)
3987 scissor->offset.x = 0;
3988 if (scissor->offset.y < 0)
3989 scissor->offset.y = 0;
3990 viewport->y += viewport->height;
3991 viewport->height = -viewport->height;
3992 }
3993
3994 VK_CALL(vkCmdSetViewport(vk_command_buffer, 0, viewport_count, viewports));
3995 VK_CALL(vkCmdSetScissor(vk_command_buffer, 0, viewport_count, scissors));
3996 }
3997
3998 if (vk_info->dynamic_state2 && context_vk->c.update_primitive_type)
3999 {
4000 VK_CALL(vkCmdSetPrimitiveTopologyEXT(vk_command_buffer, vk_topology_from_wined3d(state->primitive_type)));
4003 !wined3d_primitive_type_is_list(state->primitive_type)));
4004 context_vk->c.update_primitive_type = 0;
4005 }
4006
4007 if (vk_info->dynamic_patch_vertex_count && context_vk->c.update_patch_vertex_count)
4008 {
4009 if (state->patch_vertex_count)
4010 VK_CALL(vkCmdSetPatchControlPointsEXT(vk_command_buffer, state->patch_vertex_count));
4011 context_vk->c.update_patch_vertex_count = 0;
4012 }
4013
4014 if (vk_info->dynamic_multisample_state && context_vk->c.update_multisample_state)
4015 {
4016 unsigned int sample_count = context_vk->sample_count;
4017
4018 VK_CALL(vkCmdSetAlphaToCoverageEnableEXT(vk_command_buffer,
4019 state->blend_state && state->blend_state->desc.alpha_to_coverage));
4020 VK_CALL(vkCmdSetRasterizationSamplesEXT(vk_command_buffer, sample_count));
4021 VK_CALL(vkCmdSetSampleMaskEXT(vk_command_buffer, sample_count, &state->sample_mask));
4022 context_vk->c.update_multisample_state = 0;
4023 }
4024
4027 wined3d_context_vk_set_dynamic_rasterizer_state(context_vk, vk_command_buffer, vk_info, state);
4028
4031 wined3d_context_vk_set_dynamic_blend_state(context_vk, vk_command_buffer, vk_info, state);
4032
4036 {
4037 const struct wined3d_depth_stencil_state *d = state->depth_stencil_state;
4038
4039 if (d)
4040 {
4041 VkBool32 stencil_enable = state->fb.depth_stencil && d->desc.stencil;
4042
4043 VK_CALL(vkCmdSetDepthTestEnableEXT(vk_command_buffer, d->desc.depth));
4044 VK_CALL(vkCmdSetDepthWriteEnableEXT(vk_command_buffer, d->desc.depth_write));
4045 VK_CALL(vkCmdSetDepthCompareOpEXT(vk_command_buffer, vk_compare_op_from_wined3d(d->desc.depth_func)));
4046 VK_CALL(vkCmdSetStencilTestEnableEXT(vk_command_buffer, stencil_enable));
4047 if (stencil_enable)
4048 {
4050 vk_stencil_op_from_wined3d(d->desc.front.fail_op),
4051 vk_stencil_op_from_wined3d(d->desc.front.pass_op),
4052 vk_stencil_op_from_wined3d(d->desc.front.depth_fail_op),
4053 vk_compare_op_from_wined3d(d->desc.front.func)));
4055 vk_stencil_op_from_wined3d(d->desc.back.fail_op),
4056 vk_stencil_op_from_wined3d(d->desc.back.pass_op),
4057 vk_stencil_op_from_wined3d(d->desc.back.depth_fail_op),
4058 vk_compare_op_from_wined3d(d->desc.back.func)));
4059 VK_CALL(vkCmdSetStencilCompareMask(vk_command_buffer,
4060 VK_STENCIL_FACE_FRONT_AND_BACK, d->desc.stencil_read_mask));
4061 VK_CALL(vkCmdSetStencilWriteMask(vk_command_buffer,
4062 VK_STENCIL_FACE_FRONT_AND_BACK, d->desc.stencil_write_mask));
4063 }
4064 }
4065 else
4066 {
4067 VK_CALL(vkCmdSetDepthTestEnableEXT(vk_command_buffer, VK_TRUE));
4068 VK_CALL(vkCmdSetDepthWriteEnableEXT(vk_command_buffer, VK_TRUE));
4070 VK_CALL(vkCmdSetStencilTestEnableEXT(vk_command_buffer, VK_FALSE));
4071 }
4072 }
4073
4074 memset(context_vk->c.dirty_graphics_states, 0, sizeof(context_vk->c.dirty_graphics_states));
4075 context_vk->c.shader_update_mask &= 1u << WINED3D_SHADER_TYPE_COMPUTE;
4076
4077 return vk_command_buffer;
4078}
#define ARRAY_SIZE(A)
Definition: main.h:20
static VkPipeline wined3d_context_vk_get_graphics_pipeline(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:3507
static void wined3d_context_vk_set_dynamic_blend_state(const struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, const struct wined3d_vk_info *vk_info, const struct wined3d_state *state)
Definition: context_vk.c:2427
static void wined3d_context_vk_bind_stream_output_buffers(struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, const struct wined3d_state *state, const struct wined3d_vk_info *vk_info)
Definition: context_vk.c:2934
static bool wined3d_context_vk_begin_render_pass(struct wined3d_context_vk *context_vk, const struct wined3d_state *state, const struct wined3d_vk_info *vk_info)
Definition: context_vk.c:2734
static void wined3d_context_vk_set_dynamic_rasterizer_state(const struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, const struct wined3d_vk_info *vk_info, const struct wined3d_state *state)
Definition: context_vk.c:2335
static VkPrimitiveTopology vk_topology_from_wined3d(enum wined3d_primitive_type t)
Definition: context_vk.c:186
static void wined3d_context_vk_bind_vertex_buffers(struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, const struct wined3d_state *state, const struct wined3d_vk_info *vk_info)
Definition: context_vk.c:2896
static VkStencilOp vk_stencil_op_from_wined3d(enum wined3d_stencil_op op)
Definition: context_vk.c:249
static void wined3d_context_vk_load_buffers(struct wined3d_context_vk *context_vk, const struct wined3d_state *state, struct wined3d_buffer_vk *indirect_vk, bool indexed)
Definition: context_vk.c:3538
static bool wined3d_context_vk_update_graphics_pipeline_key(struct wined3d_context_vk *context_vk, const struct wined3d_state *state, VkPipelineLayout vk_pipeline_layout, uint32_t *null_buffer_binding)
Definition: context_vk.c:2482
static void wined3d_context_vk_prepare_used_rtv(struct wined3d_context_vk *context_vk, struct wined3d_rendertarget_view *rtv)
Definition: context_vk.c:3708
VkCompareOp vk_compare_op_from_wined3d(enum wined3d_cmp_func op)
Definition: context_vk.c:30
const VkDescriptorBufferInfo * wined3d_buffer_vk_get_buffer_info(struct wined3d_buffer_vk *buffer_vk)
Definition: buffer.c:1187
unsigned int wined3d_resource_get_sample_count(const struct wined3d_resource *resource)
Definition: resource.c:456
void wined3d_rendertarget_view_prepare_location(struct wined3d_rendertarget_view *view, struct wined3d_context *context, uint32_t location)
Definition: view.c:469
void wined3d_rendertarget_view_validate_location(struct wined3d_rendertarget_view *view, uint32_t location)
Definition: view.c:495
void wined3d_rendertarget_view_invalidate_location(struct wined3d_rendertarget_view *view, uint32_t location)
Definition: view.c:514
static void scissor(const struct wined3d_rasterizer_state *r, const struct wined3d_gl_info *gl_info)
Definition: ffp_gl.c:873
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
#define d
Definition: ke_i.h:81
Definition: dcommon.idl:28
float y
Definition: vulkan.h:15222
float maxDepth
Definition: vulkan.h:15226
float x
Definition: vulkan.h:15221
float width
Definition: vulkan.h:15223
float height
Definition: vulkan.h:15224
float minDepth
Definition: vulkan.h:15225
VkSampleCountFlagBits sample_count
Definition: wined3d_vk.h:640
struct wined3d_command_buffer_vk current_command_buffer
Definition: wined3d_vk.h:617
struct wined3d_context_vk::@362 graphics
uint32_t update_stream_output
Definition: wined3d_vk.h:595
uint32_t wined3d_creation_flags
struct wined3d_null_resources_vk null_resources_vk
Definition: wined3d_vk.h:832
struct wined3d_resource * resource
const struct wined3d_format * format
bool dynamic_blend_state
Definition: wined3d_vk.h:268
bool dynamic_patch_vertex_count
Definition: wined3d_vk.h:266
bool dynamic_multisample_state
Definition: wined3d_vk.h:267
bool dynamic_rasterizer_state
Definition: wined3d_vk.h:269
void VKAPI_CALL vkCmdSetSampleMaskEXT(VkCommandBuffer commandBuffer, VkSampleCountFlagBits samples, const VkSampleMask *pSampleMask)
void VKAPI_CALL vkCmdSetPrimitiveRestartEnableEXT(VkCommandBuffer commandBuffer, VkBool32 primitiveRestartEnable)
VkIndexType
Definition: vulkan.h:3559
@ VK_INDEX_TYPE_UINT16
Definition: vulkan.h:3560
@ VK_INDEX_TYPE_UINT32
Definition: vulkan.h:3561
void VKAPI_CALL vkCmdSetDepthWriteEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthWriteEnable)
#define VK_TRUE
Definition: vulkan.h:55
void VKAPI_CALL vkCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, const VkViewport *pViewports)
void VKAPI_CALL vkCmdSetStencilWriteMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t writeMask)
uint64_t VkDeviceSize
Definition: vulkan.h:948
void VKAPI_CALL vkCmdSetStencilCompareMask(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t compareMask)
void VKAPI_CALL vkCmdSetBlendConstants(VkCommandBuffer commandBuffer, const float blendConstants[4])
void VKAPI_CALL vkCmdSetRasterizationSamplesEXT(VkCommandBuffer commandBuffer, VkSampleCountFlagBits rasterizationSamples)
@ VK_PIPELINE_BIND_POINT_GRAPHICS
Definition: vulkan.h:4068
void VKAPI_CALL vkCmdSetDepthTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 depthTestEnable)
void VKAPI_CALL vkCmdSetAlphaToCoverageEnableEXT(VkCommandBuffer commandBuffer, VkBool32 alphaToCoverageEnable)
VkSampleCountFlagBits
Definition: vulkan.h:4700
@ VK_SAMPLE_COUNT_1_BIT
Definition: vulkan.h:4701
void VKAPI_CALL vkCmdSetStencilTestEnableEXT(VkCommandBuffer commandBuffer, VkBool32 stencilTestEnable)
void VKAPI_CALL vkCmdSetStencilReference(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, uint32_t reference)
#define VK_FALSE
Definition: vulkan.h:56
void VKAPI_CALL vkCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, VkIndexType indexType)
@ VK_STENCIL_FACE_FRONT_AND_BACK
Definition: vulkan.h:4944
@ VK_STENCIL_FACE_FRONT_BIT
Definition: vulkan.h:4942
@ VK_STENCIL_FACE_BACK_BIT
Definition: vulkan.h:4943
void VKAPI_CALL vkCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, uint32_t scissorCount, const VkRect2D *pScissors)
void VKAPI_CALL vkCmdSetDepthCompareOpEXT(VkCommandBuffer commandBuffer, VkCompareOp depthCompareOp)
void VKAPI_CALL vkCmdSetStencilOpEXT(VkCommandBuffer commandBuffer, VkStencilFaceFlags faceMask, VkStencilOp failOp, VkStencilOp passOp, VkStencilOp depthFailOp, VkCompareOp compareOp)
uint32_t VkBool32
Definition: vulkan.h:946
void VKAPI_CALL vkCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, uint32_t bindingCount, const VkBuffer *pBuffers, const VkDeviceSize *pOffsets)
void VKAPI_CALL vkCmdSetPatchControlPointsEXT(VkCommandBuffer commandBuffer, uint32_t patchControlPoints)
void VKAPI_CALL vkCmdSetPrimitiveTopologyEXT(VkCommandBuffer commandBuffer, VkPrimitiveTopology primitiveTopology)
static int wined3d_bit_scan(unsigned int *x)
Definition: wined3d.h:2982
#define WINED3D_MAX_VIEWPORTS
Definition: wined3d.h:1590
#define WINED3D_NO_PRIMITIVE_RESTART
Definition: wined3d.h:1332
@ WINED3DFMT_NULL
Definition: wined3d.h:276
@ WINED3DFMT_R16_UINT
Definition: wined3d.h:214
@ WINED3D_PIPELINE_GRAPHICS
Definition: wined3d.h:855
#define STATE_DEPTH_STENCIL
static bool wined3d_context_is_graphics_state_dirty(const struct wined3d_context *context, unsigned int state_id)
#define STATE_STENCIL_REF
#define STATE_CONSTANT_BUFFER(a)
#define STATE_GRAPHICS_SHADER_RESOURCE_BINDING
#define STATE_STREAM_OUTPUT
static bool wined3d_state_uses_depth_buffer(const struct wined3d_state *state)
#define STATE_SHADER(a)
#define STATE_BLEND_FACTOR
static uint32_t wined3d_mask_from_size(unsigned int size)
#define STATE_SCISSORRECT
static bool wined3d_primitive_type_is_list(enum wined3d_primitive_type t)
#define STATE_STREAMSRC
#define STATE_RASTERIZER
#define STATE_INDEXBUFFER
#define STATE_VIEWPORT
static unsigned int wined3d_blend_state_get_writemask(const struct wined3d_blend_state *state, unsigned int index)
#define STATE_FRAMEBUFFER
#define STATE_BLEND
#define STATE_GRAPHICS_UNORDERED_ACCESS_VIEW_BINDING

Referenced by adapter_vk_draw_primitive().

◆ wined3d_context_vk_cleanup()

void wined3d_context_vk_cleanup ( struct wined3d_context_vk *  context_vk)

Definition at line 1725 of file context_vk.c.

1726{
1728 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1729 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1730 unsigned int i;
1731
1732 if (buffer->vk_command_buffer)
1733 {
1734 free_command_buffer(context_vk, buffer);
1735 buffer->vk_command_buffer = VK_NULL_HANDLE;
1736 }
1737
1739 context_vk->completed_command_buffer_id = buffer->id;
1740 for (i = 0; i < context_vk->completed.buffer_count; ++i)
1741 free_command_buffer(context_vk, &context_vk->completed.buffers[i]);
1742
1743 free(context_vk->compute.bindings.bindings);
1744 free(context_vk->graphics.bindings.bindings);
1745 for (i = 0; i < context_vk->vk_descriptor_pool_count; ++i)
1747 free(context_vk->vk_descriptor_pools);
1748 if (context_vk->vk_framebuffer)
1749 VK_CALL(vkDestroyFramebuffer(device_vk->vk_device, context_vk->vk_framebuffer, NULL));
1750 if (context_vk->vk_so_counter_bo.vk_buffer)
1751 wined3d_context_vk_destroy_bo(context_vk, &context_vk->vk_so_counter_bo);
1753 /* Destroy the command pool after cleaning up resources. In particular,
1754 * this needs to happen after all command buffers are freed, because
1755 * vkFreeCommandBuffers() requires a valid pool handle. */
1756 VK_CALL(vkDestroyCommandPool(device_vk->vk_device, context_vk->vk_command_pool, NULL));
1762 free(context_vk->submitted.buffers);
1763 free(context_vk->completed.buffers);
1764 free(context_vk->retired.objects);
1765
1770
1771 wined3d_context_cleanup(&context_vk->c);
1772}
static void wined3d_context_vk_destroy_pipeline_layout(struct wine_rb_entry *entry, void *ctx)
Definition: context_vk.c:1330
static void wined3d_context_vk_destroy_graphics_pipeline(struct wine_rb_entry *entry, void *ctx)
Definition: context_vk.c:1315
static void free_command_buffer(struct wined3d_context_vk *context_vk, struct wined3d_command_buffer_vk *buffer)
Definition: context_vk.c:1147
static void wined3d_shader_descriptor_writes_vk_cleanup(struct wined3d_shader_descriptor_writes_vk *writes)
Definition: context_vk.c:1607
static void wined3d_context_vk_destroy_query_pools(struct wined3d_context_vk *context_vk, struct list *free_pools)
Definition: context_vk.c:1612
static void wined3d_context_vk_destroy_render_pass(struct wine_rb_entry *entry, void *ctx)
Definition: context_vk.c:1598
static void wined3d_context_vk_destroy_bo_slab(struct wine_rb_entry *entry, void *ctx)
Definition: context_vk.c:1300
static void wined3d_context_vk_cleanup_resources(struct wined3d_context_vk *context_vk, VkFence vk_fence)
Definition: context_vk.c:1174
void wined3d_context_vk_wait_command_buffer(struct wined3d_context_vk *context_vk, uint64_t id)
Definition: context_vk.c:1990
void wined3d_context_cleanup(struct wined3d_context *context)
Definition: context.c:48
#define wine_rb_destroy
Definition: rbtree.h:408
VkDescriptorPool * vk_descriptor_pools
Definition: wined3d_vk.h:638
struct wined3d_bo_vk vk_so_counter_bo
Definition: wined3d_vk.h:645
struct wined3d_retired_objects_vk retired
Definition: wined3d_vk.h:655
struct wine_rb_tree bo_slab_available
Definition: wined3d_vk.h:659
struct wined3d_shader_descriptor_writes_vk descriptor_writes
Definition: wined3d_vk.h:631
struct wine_rb_tree pipeline_layouts
Definition: wined3d_vk.h:657
SIZE_T vk_descriptor_pool_count
Definition: wined3d_vk.h:637
VkCommandPool vk_command_pool
Definition: wined3d_vk.h:616
VkFramebuffer vk_framebuffer
Definition: wined3d_vk.h:633
struct wined3d_context_vk::@364 submitted
struct wine_rb_tree render_passes
Definition: wined3d_vk.h:656
struct wined3d_context_vk::@364 completed
struct wine_rb_tree graphics_pipelines
Definition: wined3d_vk.h:658
void VKAPI_CALL vkDestroyCommandPool(VkDevice device, VkCommandPool commandPool, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyFramebuffer(VkDevice device, VkFramebuffer framebuffer, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyDescriptorPool(VkDevice device, VkDescriptorPool descriptorPool, const VkAllocationCallbacks *pAllocator)

Referenced by adapter_vk_init_3d(), and adapter_vk_uninit_3d().

◆ wined3d_context_vk_create_bo()

BOOL wined3d_context_vk_create_bo ( struct wined3d_context_vk *  context_vk,
VkDeviceSize  size,
VkBufferUsageFlags  usage,
VkMemoryPropertyFlags  memory_type,
struct wined3d_bo_vk *  bo 
)

Definition at line 528 of file context_vk.c.

530{
531 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
532 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
533 VkMemoryRequirements memory_requirements;
534 struct wined3d_adapter_vk *adapter_vk;
535 VkBufferCreateInfo create_info;
536 unsigned int memory_type_idx;
537 VkResult vr;
538
539 if (wined3d_context_vk_create_slab_bo(context_vk, size, usage, memory_type, bo))
540 return TRUE;
541
542 adapter_vk = wined3d_adapter_vk(device_vk->d.adapter);
543
545 create_info.pNext = NULL;
546 create_info.flags = 0;
547 create_info.size = size;
548 create_info.usage = usage;
550 create_info.queueFamilyIndexCount = 0;
551 create_info.pQueueFamilyIndices = NULL;
552
553 if ((vr = VK_CALL(vkCreateBuffer(device_vk->vk_device, &create_info, NULL, &bo->vk_buffer))) < 0)
554 {
555 ERR("Failed to create Vulkan buffer, vr %s.\n", wined3d_debug_vkresult(vr));
556 return FALSE;
557 }
558
559 VK_CALL(vkGetBufferMemoryRequirements(device_vk->vk_device, bo->vk_buffer, &memory_requirements));
560
561 memory_type_idx = wined3d_adapter_vk_get_memory_type_index(adapter_vk,
562 memory_requirements.memoryTypeBits, memory_type);
563 if (memory_type_idx == ~0u)
564 {
565 ERR("Failed to find suitable memory type.\n");
567 return FALSE;
568 }
570 memory_type_idx, memory_requirements.size, &bo->vk_memory);
571 if (!bo->vk_memory)
572 {
573 ERR("Failed to allocate buffer memory.\n");
575 return FALSE;
576 }
577 bo->b.memory_offset = bo->memory ? bo->memory->offset : 0;
578
579 if ((vr = VK_CALL(vkBindBufferMemory(device_vk->vk_device, bo->vk_buffer,
580 bo->vk_memory, bo->b.memory_offset))) < 0)
581 {
582 ERR("Failed to bind buffer memory, vr %s.\n", wined3d_debug_vkresult(vr));
583 if (bo->memory)
584 wined3d_context_vk_free_memory(context_vk, bo->memory);
585 else
586 VK_CALL(vkFreeMemory(device_vk->vk_device, bo->vk_memory, NULL));
588 return FALSE;
589 }
590
591 bo->b.refcount = 1;
592 bo->b.client_map_count = 0;
593 bo->b.map_ptr = NULL;
594 bo->b.buffer_offset = 0;
595 bo->size = size;
596 bo->usage = usage;
597 bo->memory_type = adapter_vk->memory_properties.memoryTypes[memory_type_idx].propertyFlags;
598 bo->b.coherent = !!(bo->memory_type & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT);
599 list_init(&bo->b.users);
600 bo->command_buffer_id = 0;
601 bo->slab = NULL;
602 bo->host_synced = false;
603
604 TRACE("Created buffer 0x%s, memory 0x%s for bo %p.\n",
606
607 return TRUE;
608}
unsigned int wined3d_adapter_vk_get_memory_type_index(const struct wined3d_adapter_vk *adapter_vk, uint32_t memory_type_mask, VkMemoryPropertyFlags flags)
Definition: adapter_vk.c:1259
static struct wined3d_allocator_block * wined3d_context_vk_allocate_memory(struct wined3d_context_vk *context_vk, unsigned int memory_type, VkDeviceSize size, VkDeviceMemory *vk_memory)
Definition: context_vk.c:384
static bool wined3d_context_vk_create_slab_bo(struct wined3d_context_vk *context_vk, VkDeviceSize size, VkBufferUsageFlags usage, VkMemoryPropertyFlags memory_type, struct wined3d_bo_vk *bo)
Definition: context_vk.c:423
static void wined3d_context_vk_free_memory(struct wined3d_context_vk *context_vk, struct wined3d_allocator_block *block)
Definition: context_vk.c:413
uint32_t queueFamilyIndexCount
Definition: vulkan.h:7608
const uint32_t * pQueueFamilyIndices
Definition: vulkan.h:7609
VkBufferCreateFlags flags
Definition: vulkan.h:7604
VkStructureType sType
Definition: vulkan.h:7602
const void * pNext
Definition: vulkan.h:7603
VkBufferUsageFlags usage
Definition: vulkan.h:7606
VkSharingMode sharingMode
Definition: vulkan.h:7607
uint32_t memoryTypeBits
Definition: vulkan.h:9460
struct wined3d_allocator_block * memory
Definition: wined3d_vk.h:313
VkDeviceSize size
Definition: wined3d_vk.h:318
bool host_synced
Definition: wined3d_vk.h:323
struct wined3d_bo_slab_vk * slab
Definition: wined3d_vk.h:314
VkDeviceMemory vk_memory
Definition: wined3d_vk.h:316
@ VK_SHARING_MODE_EXCLUSIVE
Definition: vulkan.h:4921
@ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
Definition: vulkan.h:3772
VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer)
void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements)
void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
@ VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO
Definition: vulkan.h:4976

Referenced by adapter_vk_alloc_bo(), adapter_vk_copy_bo_address(), adapter_vk_map_bo_address(), wined3d_buffer_vk_create_buffer_object(), wined3d_context_vk_bind_stream_output_buffers(), wined3d_context_vk_create_slab_bo(), wined3d_device_vk_create_null_resources(), wined3d_texture_vk_download_data(), wined3d_texture_vk_prepare_buffer_object(), wined3d_texture_vk_upload_data(), wined3d_unordered_access_view_vk_clear(), and wined3d_unordered_access_view_vk_cs_init().

◆ wined3d_context_vk_create_image()

BOOL wined3d_context_vk_create_image ( struct wined3d_context_vk *  context_vk,
VkImageType  vk_image_type,
VkImageUsageFlags  usage,
VkFormat  vk_format,
unsigned int  width,
unsigned int  height,
unsigned int  depth,
unsigned int  sample_count,
unsigned int  mip_levels,
unsigned int  layer_count,
unsigned int  flags,
struct wined3d_image_vk *  image 
)

Definition at line 610 of file context_vk.c.

614{
615 struct wined3d_adapter_vk *adapter_vk = wined3d_adapter_vk(context_vk->c.device->adapter);
616 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
617 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
618 VkMemoryRequirements memory_requirements;
619 VkImageCreateInfo create_info;
620 unsigned int memory_type_idx;
621 VkResult vr;
622
624 create_info.pNext = NULL;
625 create_info.flags = flags;
626 create_info.imageType = vk_image_type;
627 create_info.format = vk_format;
628 create_info.extent.width = width;
629 create_info.extent.height = height;
630 create_info.extent.depth = depth;
631 create_info.mipLevels = mip_levels;
632 create_info.arrayLayers = layer_count;
633 create_info.samples = sample_count;
634 create_info.tiling = VK_IMAGE_TILING_OPTIMAL;
635 create_info.usage = usage;
637 create_info.queueFamilyIndexCount = 0;
638 create_info.pQueueFamilyIndices = NULL;
640
641 image->command_buffer_id = 0;
642
643 vr = VK_CALL(vkCreateImage(device_vk->vk_device, &create_info, NULL, &image->vk_image));
644 if (vr != VK_SUCCESS)
645 {
646 ERR("Failed to create image, vr %s.\n", wined3d_debug_vkresult(vr));
647 image->vk_image = VK_NULL_HANDLE;
648 return FALSE;
649 }
650
652 &memory_requirements));
653
654 memory_type_idx = wined3d_adapter_vk_get_memory_type_index(adapter_vk,
656 if (memory_type_idx == ~0u)
657 {
658 ERR("Failed to find suitable image memory type.\n");
659 VK_CALL(vkDestroyImage(device_vk->vk_device, image->vk_image, NULL));
660 image->vk_image = VK_NULL_HANDLE;
661 return FALSE;
662 }
663
664 image->memory = wined3d_context_vk_allocate_memory(context_vk, memory_type_idx,
665 memory_requirements.size, &image->vk_memory);
666 if (!image->vk_memory)
667 {
668 ERR("Failed to allocate image memory.\n");
669 VK_CALL(vkDestroyImage(device_vk->vk_device, image->vk_image, NULL));
670 image->vk_image = VK_NULL_HANDLE;
671 return FALSE;
672 }
673
674 vr = VK_CALL(vkBindImageMemory(device_vk->vk_device, image->vk_image, image->vk_memory,
675 image->memory ? image->memory->offset : 0));
676 if (vr != VK_SUCCESS)
677 {
678 VK_CALL(vkDestroyImage(device_vk->vk_device, image->vk_image, NULL));
679 if (image->memory)
680 wined3d_context_vk_free_memory(context_vk, image->memory);
681 else
682 VK_CALL(vkFreeMemory(device_vk->vk_device, image->vk_memory, NULL));
683 ERR("Failed to bind image memory, vr %s.\n", wined3d_debug_vkresult(vr));
684 image->memory = NULL;
685 image->vk_memory = VK_NULL_HANDLE;
686 image->vk_image = VK_NULL_HANDLE;
687 return FALSE;
688 }
689
690 return TRUE;
691}
GLint GLint GLsizei GLsizei GLsizei depth
Definition: gl.h:1546
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLint GLint GLsizei width
Definition: gl.h:1546
uint32_t depth
Definition: vulkan.h:8674
uint32_t height
Definition: vulkan.h:8673
uint32_t width
Definition: vulkan.h:8672
VkImageCreateFlags flags
Definition: vulkan.h:8974
VkSharingMode sharingMode
Definition: vulkan.h:8983
VkImageLayout initialLayout
Definition: vulkan.h:8986
uint32_t mipLevels
Definition: vulkan.h:8978
const void * pNext
Definition: vulkan.h:8973
const uint32_t * pQueueFamilyIndices
Definition: vulkan.h:8985
uint32_t arrayLayers
Definition: vulkan.h:8979
VkSampleCountFlagBits samples
Definition: vulkan.h:8980
VkExtent3D extent
Definition: vulkan.h:8977
VkFormat format
Definition: vulkan.h:8976
uint32_t queueFamilyIndexCount
Definition: vulkan.h:8984
VkImageType imageType
Definition: vulkan.h:8975
VkImageTiling tiling
Definition: vulkan.h:8981
VkStructureType sType
Definition: vulkan.h:8972
VkImageUsageFlags usage
Definition: vulkan.h:8982
Definition: image.c:84
VkResult VKAPI_CALL vkBindImageMemory(VkDevice device, VkImage image, VkDeviceMemory memory, VkDeviceSize memoryOffset)
@ VK_IMAGE_LAYOUT_UNDEFINED
Definition: vulkan.h:3451
@ VK_IMAGE_TILING_OPTIMAL
Definition: vulkan.h:3495
void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements)
VkResult VKAPI_CALL vkCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImage *pImage)
void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator)
@ VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO
Definition: vulkan.h:4978

Referenced by vk_blitter_blit(), wined3d_null_image_vk_init(), and wined3d_texture_vk_prepare_texture().

◆ wined3d_context_vk_create_vk_descriptor_set()

VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set ( struct wined3d_context_vk *  context_vk,
VkDescriptorSetLayout  vk_set_layout 
)

Definition at line 3048 of file context_vk.c.

3050{
3051 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
3052 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
3053 struct VkDescriptorSetAllocateInfo set_desc;
3054 VkDescriptorPool vk_descriptor_pool;
3055 VkDescriptorSet vk_descriptor_set;
3056 VkResult vr;
3057
3058 if (!(vk_descriptor_pool = wined3d_context_vk_get_vk_descriptor_pool(context_vk)))
3059 return VK_NULL_HANDLE;
3060
3062 set_desc.pNext = NULL;
3063 set_desc.descriptorPool = vk_descriptor_pool;
3064 set_desc.descriptorSetCount = 1;
3065 set_desc.pSetLayouts = &vk_set_layout;
3066 if ((vr = VK_CALL(vkAllocateDescriptorSets(device_vk->vk_device, &set_desc, &vk_descriptor_set))) >= 0)
3067 return vk_descriptor_set;
3068
3070 {
3072 vk_descriptor_pool, context_vk->current_command_buffer.id);
3073 context_vk->vk_descriptor_pools[0] = context_vk->vk_descriptor_pools[--context_vk->vk_descriptor_pool_count];
3074 if (!(vk_descriptor_pool = wined3d_context_vk_get_vk_descriptor_pool(context_vk)))
3075 {
3076 WARN("Failed to create descriptor pool.\n");
3077 return VK_NULL_HANDLE;
3078 }
3079
3080 set_desc.descriptorPool = vk_descriptor_pool;
3081 if ((vr = VK_CALL(vkAllocateDescriptorSets(device_vk->vk_device, &set_desc, &vk_descriptor_set))) >= 0)
3082 return vk_descriptor_set;
3083 }
3084
3085 WARN("Failed to allocate descriptor set, vr %s.\n", wined3d_debug_vkresult(vr));
3086
3087 return VK_NULL_HANDLE;
3088}
static void wined3d_context_vk_reset_vk_descriptor_pool(struct wined3d_context_vk *context_vk, VkDescriptorPool vk_descriptor_pool, uint64_t command_buffer_id)
Definition: context_vk.c:755
VkDescriptorPool wined3d_context_vk_get_vk_descriptor_pool(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:3023
@ VK_ERROR_FRAGMENTED_POOL
Definition: vulkan.h:4660
@ VK_ERROR_OUT_OF_POOL_MEMORY
Definition: vulkan.h:4647
VkResult VKAPI_CALL vkAllocateDescriptorSets(VkDevice device, const VkDescriptorSetAllocateInfo *pAllocateInfo, VkDescriptorSet *pDescriptorSets)
@ VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO
Definition: vulkan.h:4998

Referenced by wined3d_context_vk_update_descriptors(), and wined3d_unordered_access_view_vk_clear().

◆ wined3d_context_vk_destroy_allocator_block()

void wined3d_context_vk_destroy_allocator_block ( struct wined3d_context_vk *  context_vk,
struct wined3d_allocator_block *  block,
uint64_t  command_buffer_id 
)

Definition at line 803 of file context_vk.c.

805{
807
809 {
811 TRACE("Freed block %p.\n", block);
812 return;
813 }
814
815 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
816 {
817 ERR("Leaking block %p.\n", block);
818 return;
819 }
820
822 o->u.block = block;
824}
static struct wined3d_retired_object_vk * wined3d_context_vk_get_retired_object_vk(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:693
enum wined3d_retired_object_type_vk type
Definition: wined3d_vk.h:446
union wined3d_retired_object_vk::@359 u
struct wined3d_allocator_block * block
Definition: wined3d_vk.h:453
static unsigned int block
Definition: xmlmemory.c:101

Referenced by wined3d_context_vk_destroy_bo(), and wined3d_context_vk_destroy_image().

◆ wined3d_context_vk_destroy_bo()

void wined3d_context_vk_destroy_bo ( struct wined3d_context_vk *  context_vk,
const struct wined3d_bo_vk *  bo 
)

Definition at line 1106 of file context_vk.c.

1107{
1108 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1109 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1110 struct wined3d_bo_slab_vk *slab_vk;
1111 size_t object_size, idx;
1112
1113 TRACE("context_vk %p, bo %p.\n", context_vk, bo);
1114
1115 assert(list_empty(&bo->b.users));
1116
1117 if (bo->command_buffer_id == context_vk->current_command_buffer.id)
1118 context_vk->retired_bo_size += bo->size;
1119
1120 if ((slab_vk = bo->slab))
1121 {
1122 if (bo->b.map_ptr)
1123 wined3d_bo_slab_vk_unmap(slab_vk, context_vk);
1124 object_size = slab_vk->bo.size / 32;
1125 idx = bo->b.buffer_offset / object_size;
1126 wined3d_context_vk_destroy_bo_slab_slice(context_vk, slab_vk, idx, bo->command_buffer_id);
1127 return;
1128 }
1129
1130 wined3d_context_vk_destroy_vk_buffer(context_vk, bo->vk_buffer, bo->command_buffer_id);
1131 if (bo->memory)
1132 {
1133 if (bo->b.map_ptr)
1135 wined3d_context_vk_destroy_allocator_block(context_vk, bo->memory, bo->command_buffer_id);
1136 return;
1137 }
1138
1139 if (bo->b.map_ptr)
1140 {
1141 VK_CALL(vkUnmapMemory(device_vk->vk_device, bo->vk_memory));
1142 adapter_adjust_mapped_memory(device_vk->d.adapter, -bo->size);
1143 }
1144 wined3d_context_vk_destroy_vk_memory(context_vk, bo->vk_memory, bo->command_buffer_id);
1145}
void wined3d_bo_slab_vk_unmap(struct wined3d_bo_slab_vk *slab_vk, struct wined3d_context_vk *context_vk)
Definition: adapter_vk.c:819
static int list_empty(struct list_entry *head)
Definition: list.h:58
void wined3d_context_vk_destroy_vk_memory(struct wined3d_context_vk *context_vk, VkDeviceMemory vk_memory, uint64_t command_buffer_id)
Definition: context_vk.c:778
static void wined3d_context_vk_destroy_bo_slab_slice(struct wined3d_context_vk *context_vk, struct wined3d_bo_slab_vk *slab, SIZE_T idx, uint64_t command_buffer_id)
Definition: context_vk.c:858
void wined3d_context_vk_destroy_allocator_block(struct wined3d_context_vk *context_vk, struct wined3d_allocator_block *block, uint64_t command_buffer_id)
Definition: context_vk.c:803
static void wined3d_context_vk_destroy_vk_buffer(struct wined3d_context_vk *context_vk, VkBuffer vk_buffer, uint64_t command_buffer_id)
Definition: context_vk.c:881
void wined3d_allocator_chunk_vk_unmap(struct wined3d_allocator_chunk_vk *chunk_vk, struct wined3d_context_vk *context_vk)
Definition: context_vk.c:338
#define assert(_expr)
Definition: assert.h:32
VkDeviceSize retired_bo_size
Definition: wined3d_vk.h:619

Referenced by adapter_vk_copy_bo_address(), adapter_vk_destroy_bo(), adapter_vk_map_bo_address(), wined3d_buffer_vk_unload_location(), wined3d_context_vk_cleanup(), wined3d_context_vk_destroy_bo_slab(), wined3d_device_vk_create_null_resources(), wined3d_device_vk_destroy_null_resources(), wined3d_texture_vk_download_data(), wined3d_texture_vk_unload_location(), wined3d_texture_vk_upload_data(), wined3d_unordered_access_view_vk_clear(), and wined3d_view_vk_destroy_object().

◆ wined3d_context_vk_destroy_image()

void wined3d_context_vk_destroy_image ( struct wined3d_context_vk *  context_vk,
struct wined3d_image_vk *  image_vk 
)

Definition at line 1092 of file context_vk.c.

1093{
1094 wined3d_context_vk_destroy_vk_image(context_vk, image->vk_image, image->command_buffer_id);
1095 if (image->memory)
1097 image->command_buffer_id);
1098 else
1099 wined3d_context_vk_destroy_vk_memory(context_vk, image->vk_memory, image->command_buffer_id);
1100
1101 image->vk_image = VK_NULL_HANDLE;
1102 image->vk_memory = VK_NULL_HANDLE;
1103 image->memory = NULL;
1104}
void wined3d_context_vk_destroy_vk_image(struct wined3d_context_vk *context_vk, VkImage vk_image, uint64_t command_buffer_id)
Definition: context_vk.c:906

Referenced by vk_blitter_blit(), wined3d_device_vk_create_null_resources(), wined3d_device_vk_destroy_null_resources(), and wined3d_texture_vk_unload_location().

◆ wined3d_context_vk_destroy_vk_buffer_view()

void wined3d_context_vk_destroy_vk_buffer_view ( struct wined3d_context_vk *  context_vk,
VkBufferView  vk_view,
uint64_t  command_buffer_id 
)

Definition at line 931 of file context_vk.c.

933{
934 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
935 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
937
939 {
940 VK_CALL(vkDestroyBufferView(device_vk->vk_device, vk_view, NULL));
941 TRACE("Destroyed buffer view 0x%s.\n", wine_dbgstr_longlong(vk_view));
942 return;
943 }
944
945 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
946 {
947 ERR("Leaking buffer view 0x%s.\n", wine_dbgstr_longlong(vk_view));
948 return;
949 }
950
952 o->u.vk_buffer_view = vk_view;
954}
VkBufferView vk_buffer_view
Definition: wined3d_vk.h:461
void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator)

Referenced by wined3d_device_vk_destroy_null_views(), wined3d_shader_resource_view_vk_update_buffer(), wined3d_unordered_access_view_vk_clear(), wined3d_unordered_access_view_vk_update(), and wined3d_view_vk_destroy_object().

◆ wined3d_context_vk_destroy_vk_event()

void wined3d_context_vk_destroy_vk_event ( struct wined3d_context_vk *  context_vk,
VkEvent  vk_event,
uint64_t  command_buffer_id 
)

Definition at line 1067 of file context_vk.c.

1069{
1070 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1071 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1072 struct wined3d_retired_object_vk *o;
1073
1075 {
1077 TRACE("Destroyed event 0x%s.\n", wine_dbgstr_longlong(vk_event));
1078 return;
1079 }
1080
1081 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
1082 {
1083 ERR("Leaking event 0x%s.\n", wine_dbgstr_longlong(vk_event));
1084 return;
1085 }
1086
1088 o->u.vk_event = vk_event;
1090}
void VKAPI_CALL vkDestroyEvent(VkDevice device, VkEvent event, const VkAllocationCallbacks *pAllocator)

Referenced by wined3d_query_event_vk_issue(), and wined3d_query_vk_destroy().

◆ wined3d_context_vk_destroy_vk_framebuffer()

void wined3d_context_vk_destroy_vk_framebuffer ( struct wined3d_context_vk *  context_vk,
VkFramebuffer  vk_framebuffer,
uint64_t  command_buffer_id 
)

Definition at line 712 of file context_vk.c.

714{
715 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
716 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
718
720 {
722 TRACE("Destroyed framebuffer 0x%s.\n", wine_dbgstr_longlong(vk_framebuffer));
723 return;
724 }
725
726 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
727 {
728 ERR("Leaking framebuffer 0x%s.\n", wine_dbgstr_longlong(vk_framebuffer));
729 return;
730 }
731
735}
VkFramebuffer vk_framebuffer
Definition: wined3d_vk.h:450

Referenced by vk_blitter_clear_rendertargets(), and wined3d_context_vk_end_current_render_pass().

◆ wined3d_context_vk_destroy_vk_image()

void wined3d_context_vk_destroy_vk_image ( struct wined3d_context_vk *  context_vk,
VkImage  vk_image,
uint64_t  command_buffer_id 
)

Definition at line 906 of file context_vk.c.

908{
909 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
910 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
912
914 {
916 TRACE("Destroyed image 0x%s.\n", wine_dbgstr_longlong(vk_image));
917 return;
918 }
919
920 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
921 {
922 ERR("Leaking image 0x%s.\n", wine_dbgstr_longlong(vk_image));
923 return;
924 }
925
927 o->u.vk_image = vk_image;
929}

Referenced by wined3d_context_vk_destroy_image().

◆ wined3d_context_vk_destroy_vk_image_view()

void wined3d_context_vk_destroy_vk_image_view ( struct wined3d_context_vk *  context_vk,
VkImageView  vk_view,
uint64_t  command_buffer_id 
)

Definition at line 956 of file context_vk.c.

958{
959 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
960 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
962
964 {
965 VK_CALL(vkDestroyImageView(device_vk->vk_device, vk_view, NULL));
966 TRACE("Destroyed image view 0x%s.\n", wine_dbgstr_longlong(vk_view));
967 return;
968 }
969
970 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
971 {
972 ERR("Leaking image view 0x%s.\n", wine_dbgstr_longlong(vk_view));
973 return;
974 }
975
977 o->u.vk_image_view = vk_view;
979}
void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator)

Referenced by wined3d_device_vk_destroy_null_views(), wined3d_texture_vk_unload_location(), wined3d_unordered_access_view_vk_clear(), and wined3d_view_vk_destroy_object().

◆ wined3d_context_vk_destroy_vk_memory()

void wined3d_context_vk_destroy_vk_memory ( struct wined3d_context_vk *  context_vk,
VkDeviceMemory  vk_memory,
uint64_t  command_buffer_id 
)

Definition at line 778 of file context_vk.c.

780{
781 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
782 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
784
786 {
788 TRACE("Freed memory 0x%s.\n", wine_dbgstr_longlong(vk_memory));
789 return;
790 }
791
792 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
793 {
794 ERR("Leaking memory 0x%s.\n", wine_dbgstr_longlong(vk_memory));
795 return;
796 }
797
799 o->u.vk_memory = vk_memory;
801}
VkDeviceMemory vk_memory
Definition: wined3d_vk.h:452

Referenced by wined3d_context_vk_destroy_bo(), and wined3d_context_vk_destroy_image().

◆ wined3d_context_vk_destroy_vk_pipeline()

void wined3d_context_vk_destroy_vk_pipeline ( struct wined3d_context_vk *  context_vk,
VkPipeline  vk_pipeline,
uint64_t  command_buffer_id 
)

Definition at line 1016 of file context_vk.c.

1018{
1019 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1020 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1021 struct wined3d_retired_object_vk *o;
1022
1024 {
1026 TRACE("Destroyed pipeline 0x%s.\n", wine_dbgstr_longlong(vk_pipeline));
1027 return;
1028 }
1029
1030 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
1031 {
1032 ERR("Leaking pipeline 0x%s.\n", wine_dbgstr_longlong(vk_pipeline));
1033 return;
1034 }
1035
1039}
void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator)

Referenced by shader_spirv_destroy_compute_vk().

◆ wined3d_context_vk_destroy_vk_sampler()

void wined3d_context_vk_destroy_vk_sampler ( struct wined3d_context_vk *  context_vk,
VkSampler  vk_sampler,
uint64_t  command_buffer_id 
)

Definition at line 1042 of file context_vk.c.

1044{
1045 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1046 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1047 struct wined3d_retired_object_vk *o;
1048
1050 {
1052 TRACE("Destroyed sampler 0x%s.\n", wine_dbgstr_longlong(vk_sampler));
1053 return;
1054 }
1055
1056 if (!(o = wined3d_context_vk_get_retired_object_vk(context_vk)))
1057 {
1058 ERR("Leaking sampler 0x%s.\n", wine_dbgstr_longlong(vk_sampler));
1059 return;
1060 }
1061
1063 o->u.vk_sampler = vk_sampler;
1065}
void VKAPI_CALL vkDestroySampler(VkDevice device, VkSampler sampler, const VkAllocationCallbacks *pAllocator)

Referenced by wined3d_sampler_vk_destroy_object().

◆ wined3d_context_vk_end_current_render_pass()

void wined3d_context_vk_end_current_render_pass ( struct wined3d_context_vk *  context_vk)

Definition at line 1564 of file context_vk.c.

1565{
1566 VkCommandBuffer vk_command_buffer = context_vk->current_command_buffer.vk_command_buffer;
1567 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1568 struct wined3d_query_vk *query_vk;
1569
1570 if (context_vk->vk_render_pass)
1571 {
1572 LIST_FOR_EACH_ENTRY(query_vk, &context_vk->render_pass_queries, struct wined3d_query_vk, entry)
1573 wined3d_query_vk_suspend(query_vk, context_vk);
1574
1575 VK_CALL(vkCmdEndRenderPass(vk_command_buffer));
1576 context_vk->vk_render_pass = VK_NULL_HANDLE;
1579
1580 LIST_FOR_EACH_ENTRY(query_vk, &context_vk->render_pass_queries, struct wined3d_query_vk, entry)
1581 {
1582 if (!wined3d_context_vk_allocate_query(context_vk, query_vk->q.type, &query_vk->pool_idx))
1583 {
1584 ERR("Failed to allocate new query.\n");
1585 break;
1586 }
1587 }
1588 }
1589
1590 if (context_vk->vk_framebuffer)
1591 {
1593 context_vk->vk_framebuffer, context_vk->current_command_buffer.id);
1594 context_vk->vk_framebuffer = VK_NULL_HANDLE;
1595 }
1596}
void wined3d_context_vk_destroy_vk_framebuffer(struct wined3d_context_vk *context_vk, VkFramebuffer vk_framebuffer, uint64_t command_buffer_id)
Definition: context_vk.c:712
bool wined3d_context_vk_allocate_query(struct wined3d_context_vk *context_vk, enum wined3d_query_type type, struct wined3d_query_pool_idx_vk *pool_idx)
Definition: context_vk.c:1623
void wined3d_query_vk_suspend(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk)
Definition: query.c:1587
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236
VkRenderPass vk_render_pass
Definition: wined3d_vk.h:634
struct list render_pass_queries
Definition: wined3d_vk.h:647
struct wined3d_query_pool_idx_vk pool_idx
Definition: wined3d_vk.h:398
struct wined3d_query q
Definition: wined3d_vk.h:395
void VKAPI_CALL vkCmdEndRenderPass(VkCommandBuffer commandBuffer)
@ VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT
Definition: vulkan.h:4287

Referenced by adapter_vk_copy_bo_address(), adapter_vk_map_bo_address(), vk_blitter_clear_rendertargets(), wined3d_buffer_vk_barrier(), wined3d_context_vk_allocate_query(), wined3d_context_vk_apply_compute_state(), wined3d_context_vk_apply_draw_state(), wined3d_context_vk_image_barrier(), wined3d_context_vk_prepare_used_rtv(), wined3d_context_vk_submit_command_buffer(), wined3d_query_event_vk_issue(), wined3d_query_vk_issue(), wined3d_swapchain_vk_blit(), wined3d_texture_vk_clear(), wined3d_texture_vk_download_data(), wined3d_texture_vk_upload_data(), wined3d_unordered_access_view_vk_clear(), and wined3d_unordered_access_view_vk_cs_init().

◆ wined3d_context_vk_get_command_buffer()

VkCommandBuffer wined3d_context_vk_get_command_buffer ( struct wined3d_context_vk *  context_vk)

Definition at line 1805 of file context_vk.c.

1806{
1807 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1808 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1810 VkCommandBufferBeginInfo begin_info;
1811 struct wined3d_query_vk *query_vk;
1812 VkResult vr;
1813
1814 TRACE("context_vk %p.\n", context_vk);
1815
1816 buffer = &context_vk->current_command_buffer;
1817 if (buffer->vk_command_buffer)
1818 {
1821 else
1822 {
1823 TRACE("Returning existing command buffer %p with id 0x%s.\n",
1824 buffer->vk_command_buffer, wine_dbgstr_longlong(buffer->id));
1825 return buffer->vk_command_buffer;
1826 }
1827 }
1828
1829 if (context_vk->completed.buffer_count)
1830 {
1831 const struct wined3d_command_buffer_vk *old_buffer;
1832
1833 old_buffer = &context_vk->completed.buffers[--context_vk->completed.buffer_count];
1834 buffer->vk_command_buffer = old_buffer->vk_command_buffer;
1835 buffer->vk_fence = old_buffer->vk_fence;
1836 }
1837 else
1838 {
1839 VkCommandBufferAllocateInfo command_buffer_info;
1840 VkFenceCreateInfo fence_desc;
1841
1843 fence_desc.pNext = NULL;
1844 fence_desc.flags = 0;
1845 if ((vr = VK_CALL(vkCreateFence(device_vk->vk_device, &fence_desc, NULL, &buffer->vk_fence))) < 0)
1846 {
1847 ERR("Failed to create fence, vr %s.\n", wined3d_debug_vkresult(vr));
1848 return VK_NULL_HANDLE;
1849 }
1850
1852 command_buffer_info.pNext = NULL;
1853 command_buffer_info.commandPool = context_vk->vk_command_pool;
1854 command_buffer_info.level = VK_COMMAND_BUFFER_LEVEL_PRIMARY;
1855 command_buffer_info.commandBufferCount = 1;
1856 if ((vr = VK_CALL(vkAllocateCommandBuffers(device_vk->vk_device,
1857 &command_buffer_info, &buffer->vk_command_buffer))) < 0)
1858 {
1859 WARN("Failed to allocate Vulkan command buffer, vr %s.\n", wined3d_debug_vkresult(vr));
1860 VK_CALL(vkDestroyFence(device_vk->vk_device, buffer->vk_fence, NULL));
1861 return VK_NULL_HANDLE;
1862 }
1863 }
1864
1866 begin_info.pNext = NULL;
1868 begin_info.pInheritanceInfo = NULL;
1869 if ((vr = VK_CALL(vkBeginCommandBuffer(buffer->vk_command_buffer, &begin_info))) < 0)
1870 {
1871 WARN("Failed to begin command buffer, vr %s.\n", wined3d_debug_vkresult(vr));
1872 VK_CALL(vkFreeCommandBuffers(device_vk->vk_device, context_vk->vk_command_pool,
1873 1, &buffer->vk_command_buffer));
1874 return buffer->vk_command_buffer = VK_NULL_HANDLE;
1875 }
1876
1877 LIST_FOR_EACH_ENTRY(query_vk, &context_vk->active_queries, struct wined3d_query_vk, entry)
1878 {
1879 if (!wined3d_context_vk_allocate_query(context_vk, query_vk->q.type, &query_vk->pool_idx))
1880 {
1881 ERR("Failed to allocate new query.\n");
1882 break;
1883 }
1884
1885 wined3d_query_vk_resume(query_vk, context_vk);
1886 }
1887
1888 context_vk->command_buffer_work_count = 0;
1889
1890 TRACE("Created new command buffer %p with id 0x%s.\n",
1891 buffer->vk_command_buffer, wine_dbgstr_longlong(buffer->id));
1892
1893 return buffer->vk_command_buffer;
1894}
static bool should_periodic_submit(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1787
void wined3d_context_vk_submit_command_buffer(struct wined3d_context_vk *context_vk, unsigned int wait_semaphore_count, const VkSemaphore *wait_semaphores, const VkPipelineStageFlags *wait_stages, unsigned int signal_semaphore_count, const VkSemaphore *signal_semaphores)
Definition: context_vk.c:1896
void wined3d_query_vk_resume(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk)
Definition: query.c:1579
VkStructureType sType
Definition: vulkan.h:7821
VkCommandBufferLevel level
Definition: vulkan.h:7824
const VkCommandBufferInheritanceInfo * pInheritanceInfo
Definition: vulkan.h:16042
VkStructureType sType
Definition: vulkan.h:16039
const void * pNext
Definition: vulkan.h:16040
VkCommandBufferUsageFlags flags
Definition: vulkan.h:16041
const void * pNext
Definition: vulkan.h:8731
VkFenceCreateFlags flags
Definition: vulkan.h:8732
VkStructureType sType
Definition: vulkan.h:8730
VkCommandBuffer vk_command_buffer
Definition: wined3d_vk.h:422
struct list active_queries
Definition: wined3d_vk.h:648
unsigned int command_buffer_work_count
Definition: wined3d_vk.h:622
void VKAPI_CALL vkFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, const VkCommandBuffer *pCommandBuffers)
@ VK_COMMAND_BUFFER_LEVEL_PRIMARY
Definition: vulkan.h:2140
VkResult VKAPI_CALL vkBeginCommandBuffer(VkCommandBuffer commandBuffer, const VkCommandBufferBeginInfo *pBeginInfo)
@ VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT
Definition: vulkan.h:2153
void VKAPI_CALL vkDestroyFence(VkDevice device, VkFence fence, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, VkCommandBuffer *pCommandBuffers)
VkResult VKAPI_CALL vkCreateFence(VkDevice device, const VkFenceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkFence *pFence)
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO
Definition: vulkan.h:5004
@ VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO
Definition: vulkan.h:5006
@ VK_STRUCTURE_TYPE_FENCE_CREATE_INFO
Definition: vulkan.h:4972
#define WINED3D_RETIRED_BO_SIZE_THRESHOLD

Referenced by adapter_vk_copy_bo_address(), adapter_vk_map_bo_address(), vk_blitter_blit(), vk_blitter_clear_rendertargets(), wined3d_buffer_vk_barrier(), wined3d_context_vk_allocate_query(), wined3d_context_vk_apply_compute_state(), wined3d_context_vk_begin_render_pass(), wined3d_device_vk_create_null_resources(), wined3d_query_event_vk_issue(), wined3d_query_timestamp_vk_issue(), wined3d_query_vk_issue(), wined3d_shader_resource_view_vk_generate_mipmap(), wined3d_swapchain_vk_blit(), wined3d_texture_vk_barrier(), wined3d_texture_vk_clear(), wined3d_texture_vk_download_data(), wined3d_texture_vk_make_generic(), wined3d_texture_vk_prepare_texture(), wined3d_texture_vk_upload_data(), wined3d_unordered_access_view_vk_clear(), and wined3d_unordered_access_view_vk_cs_init().

◆ wined3d_context_vk_get_pipeline_layout()

struct wined3d_pipeline_layout_vk * wined3d_context_vk_get_pipeline_layout ( struct wined3d_context_vk *  context_vk,
VkDescriptorSetLayoutBinding *  bindings,
SIZE_T  binding_count 
)

Definition at line 3442 of file context_vk.c.

3444{
3445 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
3446 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
3448 struct wined3d_pipeline_layout_vk *layout;
3449 VkPipelineLayoutCreateInfo layout_desc;
3450 struct wine_rb_entry *entry;
3451 VkResult vr;
3452
3453 key.bindings = bindings;
3454 key.binding_count = binding_count;
3455 if ((entry = wine_rb_get(&context_vk->pipeline_layouts, &key)))
3457
3458 if (!(layout = malloc(sizeof(*layout))))
3459 return NULL;
3460
3461 if (!(layout->key.bindings = malloc(sizeof(*layout->key.bindings) * key.binding_count)))
3462 {
3463 free(layout);
3464 return NULL;
3465 }
3466 memcpy(layout->key.bindings, key.bindings, sizeof(*layout->key.bindings) * key.binding_count);
3467 layout->key.binding_count = key.binding_count;
3468
3469 if ((vr = wined3d_context_vk_create_vk_descriptor_set_layout(device_vk, vk_info, &key, &layout->vk_set_layout)))
3470 {
3471 WARN("Failed to create descriptor set layout, vr %s.\n", wined3d_debug_vkresult(vr));
3472 goto fail;
3473 }
3474
3476 layout_desc.pNext = NULL;
3477 layout_desc.flags = 0;
3478 layout_desc.setLayoutCount = 1;
3479 layout_desc.pSetLayouts = &layout->vk_set_layout;
3480 layout_desc.pushConstantRangeCount = 0;
3481 layout_desc.pPushConstantRanges = NULL;
3482
3483 if ((vr = VK_CALL(vkCreatePipelineLayout(device_vk->vk_device,
3484 &layout_desc, NULL, &layout->vk_pipeline_layout))) < 0)
3485 {
3486 WARN("Failed to create Vulkan pipeline layout, vr %s.\n", wined3d_debug_vkresult(vr));
3488 goto fail;
3489 }
3490
3491 if (wine_rb_put(&context_vk->pipeline_layouts, &layout->key, &layout->entry) == -1)
3492 {
3493 ERR("Failed to insert pipeline layout.\n");
3496 goto fail;
3497 }
3498
3499 return layout;
3500
3501fail:
3502 free(layout->key.bindings);
3503 free(layout);
3504 return NULL;
3505}
static VkResult wined3d_context_vk_create_vk_descriptor_set_layout(struct wined3d_device_vk *device_vk, const struct wined3d_vk_info *vk_info, const struct wined3d_pipeline_layout_key_vk *key, VkDescriptorSetLayout *vk_set_layout)
Definition: context_vk.c:3423
#define malloc
Definition: debug_ros.c:4
#define wine_rb_entry
Definition: rbtree.h:404
#define WINE_RB_ENTRY_VALUE
Definition: rbtree.h:414
#define wine_rb_put
Definition: rbtree.h:410
#define wine_rb_get
Definition: rbtree.h:409
VkPipelineLayoutCreateFlags flags
Definition: vulkan.h:16646
VkStructureType sType
Definition: vulkan.h:16644
uint32_t pushConstantRangeCount
Definition: vulkan.h:16649
const VkPushConstantRange * pPushConstantRanges
Definition: vulkan.h:16650
const VkDescriptorSetLayout * pSetLayouts
Definition: vulkan.h:16648
Definition: copy.c:22
VkDescriptorSetLayout vk_set_layout
Definition: wined3d_vk.h:522
VkPipelineLayout vk_pipeline_layout
Definition: wined3d_vk.h:521
struct wine_rb_entry entry
Definition: wined3d_vk.h:519
struct wined3d_pipeline_layout_key_vk key
Definition: wined3d_vk.h:520
void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkCreatePipelineLayout(VkDevice device, const VkPipelineLayoutCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkPipelineLayout *pPipelineLayout)
@ VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO
Definition: vulkan.h:4994

Referenced by shader_spirv_apply_draw_state(), shader_spirv_find_compute_program_vk(), and wined3d_device_vk_uav_clear_state_init().

◆ wined3d_context_vk_get_render_pass()

VkRenderPass wined3d_context_vk_get_render_pass ( struct wined3d_context_vk *  context_vk,
const struct wined3d_fb_state *  fb,
unsigned int  rt_count,
bool  depth_stencil,
uint32_t  clear_flags 
)

Definition at line 1533 of file context_vk.c.

1535{
1538 struct wine_rb_entry *entry;
1539
1540 wined3d_render_pass_key_vk_init(&key, fb, rt_count, depth_stencil, clear_flags);
1541 if ((entry = wine_rb_get(&context_vk->render_passes, &key)))
1542 return WINE_RB_ENTRY_VALUE(entry, struct wined3d_render_pass_vk, entry)->vk_render_pass;
1543
1544 if (!(pass = malloc(sizeof(*pass))))
1545 return VK_NULL_HANDLE;
1546
1547 if (!wined3d_render_pass_vk_init(pass, context_vk, &key))
1548 {
1549 free(pass);
1550 return VK_NULL_HANDLE;
1551 }
1552
1553 if (wine_rb_put(&context_vk->render_passes, &pass->key, &pass->entry) == -1)
1554 {
1555 ERR("Failed to insert render pass.\n");
1557 free(pass);
1558 return VK_NULL_HANDLE;
1559 }
1560
1561 return pass->vk_render_pass;
1562}
static void wined3d_render_pass_vk_cleanup(struct wined3d_render_pass_vk *pass, struct wined3d_context_vk *context_vk)
Definition: context_vk.c:1399
static bool wined3d_render_pass_vk_init(struct wined3d_render_pass_vk *pass, struct wined3d_context_vk *context_vk, const struct wined3d_render_pass_key_vk *key)
Definition: context_vk.c:1408
static void wined3d_render_pass_key_vk_init(struct wined3d_render_pass_key_vk *key, const struct wined3d_fb_state *fb, unsigned int rt_count, bool depth_stencil, uint32_t clear_flags)
Definition: context_vk.c:1347
static void depth_stencil(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: ffp_gl.c:766
pass
Definition: typegen.h:25

Referenced by vk_blitter_clear_rendertargets(), and wined3d_context_vk_begin_render_pass().

◆ wined3d_context_vk_image_barrier()

void wined3d_context_vk_image_barrier ( struct wined3d_context_vk *  context_vk,
VkCommandBuffer  vk_command_buffer,
VkPipelineStageFlags  src_stage_mask,
VkPipelineStageFlags  dst_stage_mask,
VkAccessFlags  src_access_mask,
VkAccessFlags  dst_access_mask,
VkImageLayout  old_layout,
VkImageLayout  new_layout,
VkImage  image,
const VkImageSubresourceRange *  range 
)

Definition at line 2022 of file context_vk.c.

2026{
2027 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
2028 VkImageMemoryBarrier barrier;
2029
2031
2033 barrier.pNext = NULL;
2034 barrier.srcAccessMask = src_access_mask;
2035 barrier.dstAccessMask = dst_access_mask;
2036 barrier.oldLayout = old_layout;
2037 barrier.newLayout = new_layout;
2040 barrier.image = image;
2041 barrier.subresourceRange = *range;
2042
2043 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer, src_stage_mask, dst_stage_mask, 0, 0, NULL, 0, NULL, 1, &barrier));
2044}
VkAccessFlags dstAccessMask
Definition: vulkan.h:16393
uint32_t dstQueueFamilyIndex
Definition: vulkan.h:16397
VkAccessFlags srcAccessMask
Definition: vulkan.h:16392
VkStructureType sType
Definition: vulkan.h:16390
VkImageLayout newLayout
Definition: vulkan.h:16395
const void * pNext
Definition: vulkan.h:16391
VkImageSubresourceRange subresourceRange
Definition: vulkan.h:16399
VkImageLayout oldLayout
Definition: vulkan.h:16394
uint32_t srcQueueFamilyIndex
Definition: vulkan.h:16396
@ VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER
Definition: vulkan.h:5009

Referenced by vk_blitter_blit(), wined3d_null_image_vk_init(), wined3d_shader_resource_view_vk_generate_mipmap(), wined3d_swapchain_vk_blit(), wined3d_texture_vk_barrier(), wined3d_texture_vk_clear(), wined3d_texture_vk_download_data(), wined3d_texture_vk_make_generic(), wined3d_texture_vk_prepare_texture(), and wined3d_texture_vk_upload_data().

◆ wined3d_context_vk_init()

HRESULT wined3d_context_vk_init ( struct wined3d_context_vk *  context_vk,
struct wined3d_swapchain *  swapchain 
)

Definition at line 4151 of file context_vk.c.

4152{
4153 VkCommandPoolCreateInfo command_pool_info;
4154 const struct wined3d_vk_info *vk_info;
4155 struct wined3d_adapter_vk *adapter_vk;
4156 struct wined3d_device_vk *device_vk;
4157 VkResult vr;
4158
4159 TRACE("context_vk %p, swapchain %p.\n", context_vk, swapchain);
4160
4161 memset(context_vk, 0, sizeof(*context_vk));
4162 wined3d_context_init(&context_vk->c, swapchain);
4163 device_vk = wined3d_device_vk(swapchain->device);
4164 adapter_vk = wined3d_adapter_vk(device_vk->d.adapter);
4165 context_vk->vk_info = vk_info = &adapter_vk->vk_info;
4166
4168 command_pool_info.pNext = NULL;
4170 command_pool_info.queueFamilyIndex = device_vk->vk_queue_family_index;
4171 if ((vr = VK_CALL(vkCreateCommandPool(device_vk->vk_device,
4172 &command_pool_info, NULL, &context_vk->vk_command_pool))) < 0)
4173 {
4174 ERR("Failed to create Vulkan command pool, vr %s.\n", wined3d_debug_vkresult(vr));
4176 return E_FAIL;
4177 }
4178 context_vk->current_command_buffer.id = 1;
4179
4181
4182 list_init(&context_vk->render_pass_queries);
4183 list_init(&context_vk->active_queries);
4184 list_init(&context_vk->completed_query_pools);
4185 list_init(&context_vk->free_occlusion_query_pools);
4186 list_init(&context_vk->free_timestamp_query_pools);
4187 list_init(&context_vk->free_pipeline_statistics_query_pools);
4188 list_init(&context_vk->free_stream_output_statistics_query_pools);
4189
4194
4195 return WINED3D_OK;
4196}
static int wined3d_render_pass_vk_compare(const void *key, const struct wine_rb_entry *entry)
Definition: context_vk.c:2046
static int wined3d_bo_slab_vk_compare(const void *key, const struct wine_rb_entry *entry)
Definition: context_vk.c:2139
static int wined3d_graphics_pipeline_vk_compare(const void *key, const struct wine_rb_entry *entry)
Definition: context_vk.c:2067
static int wined3d_pipeline_layout_vk_compare(const void *key, const struct wine_rb_entry *entry)
Definition: context_vk.c:2055
static void wined3d_context_vk_init_graphics_pipeline_key(struct wined3d_context_vk *context_vk)
Definition: context_vk.c:2152
#define E_FAIL
Definition: ddrawi.h:102
void wined3d_context_init(struct wined3d_context *context, struct wined3d_swapchain *swapchain)
Definition: context.c:89
#define wine_rb_init
Definition: rbtree.h:406
const void * pNext
Definition: vulkan.h:7873
VkStructureType sType
Definition: vulkan.h:7872
uint32_t queueFamilyIndex
Definition: vulkan.h:7875
VkCommandPoolCreateFlags flags
Definition: vulkan.h:7874
uint32_t vk_queue_family_index
Definition: wined3d_vk.h:827
struct wined3d_vk_info vk_info
Definition: wined3d_vk.h:830
struct wined3d_device * device
@ VK_COMMAND_POOL_CREATE_TRANSIENT_BIT
Definition: vulkan.h:2161
@ VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT
Definition: vulkan.h:2162
VkResult VKAPI_CALL vkCreateCommandPool(VkDevice device, const VkCommandPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkCommandPool *pCommandPool)
@ VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO
Definition: vulkan.h:5003
#define WINED3D_OK
Definition: wined3d.h:33

Referenced by adapter_vk_init_3d().

◆ wined3d_context_vk_reference_bo()

◆ wined3d_context_vk_reference_image()

static void wined3d_context_vk_reference_image ( const struct wined3d_context_vk *  context_vk,
struct wined3d_image_vk *  image 
)
inlinestatic

Definition at line 1097 of file wined3d_vk.h.

1099{
1100 image->command_buffer_id = context_vk->current_command_buffer.id;
1101}

Referenced by vk_blitter_blit(), wined3d_context_vk_reference_texture(), wined3d_device_vk_destroy_null_resources(), and wined3d_null_image_vk_init().

◆ wined3d_context_vk_reference_query()

static void wined3d_context_vk_reference_query ( const struct wined3d_context_vk *  context_vk,
struct wined3d_query_vk *  query_vk 
)
inlinestatic

Definition at line 1118 of file wined3d_vk.h.

1120{
1121 query_vk->command_buffer_id = context_vk->current_command_buffer.id;
1122}
uint64_t command_buffer_id
Definition: wined3d_vk.h:400

Referenced by wined3d_query_event_vk_issue(), wined3d_query_timestamp_vk_issue(), and wined3d_query_vk_begin().

◆ wined3d_context_vk_reference_rendertarget_view()

static void wined3d_context_vk_reference_rendertarget_view ( const struct wined3d_context_vk *  context_vk,
struct wined3d_rendertarget_view_vk *  rtv_vk 
)
inlinestatic

Definition at line 1130 of file wined3d_vk.h.

1132{
1133 wined3d_context_vk_reference_resource(context_vk, rtv_vk->v.resource);
1134 rtv_vk->command_buffer_id = context_vk->current_command_buffer.id;
1135}
struct wined3d_rendertarget_view v
Definition: wined3d_vk.h:949
static void wined3d_context_vk_reference_resource(const struct wined3d_context_vk *context_vk, struct wined3d_resource *resource)
Definition: wined3d_vk.h:1109

Referenced by vk_blitter_clear_rendertargets(), and wined3d_context_vk_begin_render_pass().

◆ wined3d_context_vk_reference_resource()

static void wined3d_context_vk_reference_resource ( const struct wined3d_context_vk *  context_vk,
struct wined3d_resource *  resource 
)
inlinestatic

Definition at line 1109 of file wined3d_vk.h.

1111{
1112 if (resource->type == WINED3D_RTYPE_BUFFER)
1114 else
1116}
@ WINED3D_RTYPE_BUFFER
Definition: wined3d.h:718
static struct wined3d_texture * texture_from_resource(struct wined3d_resource *resource)
static struct wined3d_buffer * buffer_from_resource(struct wined3d_resource *resource)
static void wined3d_context_vk_reference_texture(const struct wined3d_context_vk *context_vk, struct wined3d_texture_vk *texture_vk)
Definition: wined3d_vk.h:1103

Referenced by wined3d_context_vk_reference_rendertarget_view(), wined3d_context_vk_reference_shader_resource_view(), and wined3d_context_vk_reference_unordered_access_view().

◆ wined3d_context_vk_reference_sampler()

static void wined3d_context_vk_reference_sampler ( const struct wined3d_context_vk *  context_vk,
struct wined3d_sampler_vk *  sampler_vk 
)
inlinestatic

Definition at line 1124 of file wined3d_vk.h.

1126{
1127 sampler_vk->command_buffer_id = context_vk->current_command_buffer.id;
1128}
uint64_t command_buffer_id
Definition: wined3d_vk.h:906

Referenced by wined3d_shader_descriptor_writes_vk_add_sampler_write().

◆ wined3d_context_vk_reference_shader_resource_view()

static void wined3d_context_vk_reference_shader_resource_view ( const struct wined3d_context_vk *  context_vk,
struct wined3d_shader_resource_view_vk *  srv_vk 
)
inlinestatic

Definition at line 1137 of file wined3d_vk.h.

1139{
1140 wined3d_context_vk_reference_resource(context_vk, srv_vk->v.resource);
1141 srv_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
1142}
struct wined3d_view_vk view_vk
Definition: wined3d_vk.h:997
struct wined3d_shader_resource_view v
Definition: wined3d_vk.h:996

Referenced by wined3d_shader_descriptor_writes_vk_add_srv_write().

◆ wined3d_context_vk_reference_texture()

static void wined3d_context_vk_reference_texture ( const struct wined3d_context_vk *  context_vk,
struct wined3d_texture_vk *  texture_vk 
)
inlinestatic

Definition at line 1103 of file wined3d_vk.h.

1105{
1106 wined3d_context_vk_reference_image(context_vk, &texture_vk->image);
1107}
struct wined3d_image_vk image
Definition: wined3d_vk.h:877
static void wined3d_context_vk_reference_image(const struct wined3d_context_vk *context_vk, struct wined3d_image_vk *image)
Definition: wined3d_vk.h:1097

Referenced by vk_blitter_blit(), wined3d_context_vk_reference_resource(), wined3d_shader_resource_view_vk_generate_mipmap(), wined3d_swapchain_vk_blit(), wined3d_texture_vk_clear(), wined3d_texture_vk_download_data(), wined3d_texture_vk_prepare_texture(), and wined3d_texture_vk_upload_data().

◆ wined3d_context_vk_reference_unordered_access_view()

static void wined3d_context_vk_reference_unordered_access_view ( const struct wined3d_context_vk *  context_vk,
struct wined3d_unordered_access_view_vk *  uav_vk 
)
inlinestatic

Definition at line 1144 of file wined3d_vk.h.

1146{
1147 wined3d_context_vk_reference_resource(context_vk, uav_vk->v.resource);
1148 uav_vk->view_vk.command_buffer_id = context_vk->current_command_buffer.id;
1149}
struct wined3d_unordered_access_view v
Definition: wined3d_vk.h:1024
struct wined3d_view_vk view_vk
Definition: wined3d_vk.h:1025

Referenced by wined3d_shader_descriptor_writes_vk_add_uav_write(), and wined3d_unordered_access_view_vk_clear().

◆ wined3d_context_vk_submit_command_buffer()

void wined3d_context_vk_submit_command_buffer ( struct wined3d_context_vk *  context_vk,
unsigned int  wait_semaphore_count,
const VkSemaphore *  wait_semaphores,
const VkPipelineStageFlags *  wait_stages,
unsigned int  signal_semaphore_count,
const VkSemaphore *  signal_semaphores 
)

Definition at line 1896 of file context_vk.c.

1899{
1900 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1901 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1902 struct wined3d_query_pool_vk *pool_vk, *pool_vk_next;
1904 struct wined3d_query_vk *query_vk;
1905 VkSubmitInfo submit_info;
1906 VkResult vr;
1907
1908 TRACE("context_vk %p, wait_semaphore_count %u, wait_semaphores %p, wait_stages %p,"
1909 "signal_semaphore_count %u, signal_semaphores %p.\n",
1910 context_vk, wait_semaphore_count, wait_semaphores, wait_stages,
1911 signal_semaphore_count, signal_semaphores);
1912
1913 buffer = &context_vk->current_command_buffer;
1914 if (!buffer->vk_command_buffer)
1915 return;
1916
1917 TRACE("Submitting command buffer %p with id 0x%s.\n",
1918 buffer->vk_command_buffer, wine_dbgstr_longlong(buffer->id));
1919
1921
1922 LIST_FOR_EACH_ENTRY_SAFE(pool_vk, pool_vk_next, &context_vk->completed_query_pools,
1923 struct wined3d_query_pool_vk, completed_entry)
1924 {
1925 list_remove(&pool_vk->completed_entry);
1926 list_init(&pool_vk->completed_entry);
1927
1929 }
1930
1931 LIST_FOR_EACH_ENTRY(query_vk, &context_vk->active_queries, struct wined3d_query_vk, entry)
1932 wined3d_query_vk_suspend(query_vk, context_vk);
1933
1934 context_vk->graphics.vk_pipeline = VK_NULL_HANDLE;
1935 context_vk->update_compute_pipeline = 1;
1936 context_vk->update_stream_output = 1;
1937 context_vk->c.update_shader_resource_bindings = 1;
1938 context_vk->c.update_compute_shader_resource_bindings = 1;
1939 context_vk->c.update_unordered_access_view_bindings = 1;
1940 context_vk->c.update_compute_unordered_access_view_bindings = 1;
1941 context_vk->c.update_primitive_type = 1;
1942 context_vk->c.update_patch_vertex_count = 1;
1943 context_vk->c.update_multisample_state = 1;
1946 context_invalidate_state(&context_vk->c, STATE_BLEND);
1953
1954 VK_CALL(vkEndCommandBuffer(buffer->vk_command_buffer));
1955
1956 VK_CALL(vkResetFences(device_vk->vk_device, 1, &buffer->vk_fence));
1957
1959 submit_info.pNext = NULL;
1960 submit_info.waitSemaphoreCount = wait_semaphore_count;
1961 submit_info.pWaitSemaphores = wait_semaphores;
1962 submit_info.pWaitDstStageMask = wait_stages;
1963 submit_info.commandBufferCount = 1;
1964 submit_info.pCommandBuffers = &buffer->vk_command_buffer;
1965 submit_info.signalSemaphoreCount = signal_semaphore_count;
1966 submit_info.pSignalSemaphores = signal_semaphores;
1967
1968 if ((vr = VK_CALL(vkQueueSubmit(device_vk->vk_queue, 1, &submit_info, buffer->vk_fence))) < 0)
1969 ERR("Failed to submit command buffer %p, vr %s.\n",
1970 buffer->vk_command_buffer, wined3d_debug_vkresult(vr));
1971
1972 if (!wined3d_array_reserve((void **)&context_vk->submitted.buffers, &context_vk->submitted.buffers_size,
1973 context_vk->submitted.buffer_count + 1, sizeof(*context_vk->submitted.buffers)))
1974 ERR("Failed to grow submitted command buffer array.\n");
1975
1976 context_vk->submitted.buffers[context_vk->submitted.buffer_count++] = *buffer;
1977
1978 buffer->vk_command_buffer = VK_NULL_HANDLE;
1979 /* We don't expect this to ever happen, but handle it anyway. */
1980 if (!++buffer->id)
1981 {
1983 context_vk->completed_command_buffer_id = 0;
1984 buffer->id = 1;
1985 }
1986 context_vk->retired_bo_size = 0;
1988}
static void wined3d_context_vk_reset_completed_queries(struct wined3d_context_vk *context_vk, struct wined3d_query_pool_vk *pool_vk, struct wined3d_command_buffer_vk *buffer)
Definition: context_vk.c:981
void context_invalidate_state(struct wined3d_context *context, unsigned int state_id)
Definition: context.c:76
BOOL wined3d_array_reserve(void **elements, SIZE_T *capacity, SIZE_T count, SIZE_T size)
Definition: utils.c:6740
uint32_t waitSemaphoreCount
Definition: vulkan.h:14150
const VkPipelineStageFlags * pWaitDstStageMask
Definition: vulkan.h:14152
uint32_t commandBufferCount
Definition: vulkan.h:14153
const VkSemaphore * pWaitSemaphores
Definition: vulkan.h:14151
uint32_t signalSemaphoreCount
Definition: vulkan.h:14155
const VkCommandBuffer * pCommandBuffers
Definition: vulkan.h:14154
const void * pNext
Definition: vulkan.h:14149
const VkSemaphore * pSignalSemaphores
Definition: vulkan.h:14156
VkStructureType sType
Definition: vulkan.h:14148
struct list completed_query_pools
Definition: wined3d_vk.h:649
struct list completed_entry
Definition: wined3d_vk.h:365
VkResult VKAPI_CALL vkQueueSubmit(VkQueue queue, uint32_t submitCount, const VkSubmitInfo *pSubmits, VkFence fence)
VkResult VKAPI_CALL vkEndCommandBuffer(VkCommandBuffer commandBuffer)
VkResult VKAPI_CALL vkResetFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences)
@ VK_STRUCTURE_TYPE_SUBMIT_INFO
Definition: vulkan.h:4968

Referenced by adapter_vk_flush_context(), adapter_vk_map_bo_address(), wined3d_context_vk_get_command_buffer(), wined3d_swapchain_vk_blit(), and wined3d_texture_vk_download_data().

◆ wined3d_context_vk_wait_command_buffer()

void wined3d_context_vk_wait_command_buffer ( struct wined3d_context_vk *  context_vk,
uint64_t  id 
)

Definition at line 1990 of file context_vk.c.

1991{
1992 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1993 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1994 VkFence vk_fence;
1995 SIZE_T i;
1996
1997 if (id <= context_vk->completed_command_buffer_id
1998 || id > context_vk->current_command_buffer.id) /* In case the buffer ID wrapped. */
1999 return;
2000
2001 for (i = 0; i < context_vk->submitted.buffer_count; ++i)
2002 {
2003 if (context_vk->submitted.buffers[i].id != id)
2004 continue;
2005
2006 vk_fence = context_vk->submitted.buffers[i].vk_fence;
2007 wined3d_context_vk_cleanup_resources(context_vk, vk_fence);
2008 for (i = 0; i < context_vk->submitted.buffer_count; ++i)
2009 {
2010 if (context_vk->submitted.buffers[i].id != id)
2011 continue;
2012
2013 VK_CALL(vkWaitForFences(device_vk->vk_device, 1, &vk_fence, VK_TRUE, UINT64_MAX));
2015 return;
2016 }
2017 }
2018
2019 ERR("Failed to find fence for command buffer with id 0x%s.\n", wine_dbgstr_longlong(id));
2020}
static void wined3d_context_vk_remove_command_buffer(struct wined3d_context_vk *context_vk, unsigned int submit_index)
Definition: context_vk.c:1157
#define UINT64_MAX
Definition: stdint.h:86
ULONG_PTR SIZE_T
Definition: typedefs.h:80
VkResult VKAPI_CALL vkWaitForFences(VkDevice device, uint32_t fenceCount, const VkFence *pFences, VkBool32 waitAll, uint64_t timeout)

Referenced by adapter_vk_map_bo_address(), wined3d_context_vk_cleanup(), wined3d_context_vk_submit_command_buffer(), wined3d_swapchain_vk_blit(), and wined3d_texture_vk_download_data().

◆ wined3d_debug_vkresult()

const char * wined3d_debug_vkresult ( VkResult  vr)

Definition at line 5463 of file utils.c.

5464{
5465 switch (vr)
5466 {
5467#define WINED3D_TO_STR(x) case x: return #x
5496#undef WINED3D_TO_STR
5497 default:
5498 return wine_dbg_sprintf("unrecognised(%d)", vr);
5499 }
5500}
#define WINED3D_TO_STR(x)
const char * wine_dbg_sprintf(const char *format,...)
Definition: compat.c:296
@ VK_ERROR_FRAGMENTATION_EXT
Definition: vulkan.h:4688
@ VK_ERROR_INVALID_SHADER_NV
Definition: vulkan.h:4654
@ VK_SUBOPTIMAL_KHR
Definition: vulkan.h:4678
@ VK_ERROR_EXTENSION_NOT_PRESENT
Definition: vulkan.h:4665
@ VK_INCOMPLETE
Definition: vulkan.h:4677
@ VK_ERROR_INVALID_EXTERNAL_HANDLE
Definition: vulkan.h:4646
@ VK_ERROR_DEVICE_LOST
Definition: vulkan.h:4668
@ VK_EVENT_SET
Definition: vulkan.h:4675
@ VK_EVENT_RESET
Definition: vulkan.h:4676
@ VK_ERROR_INVALID_OPAQUE_CAPTURE_ADDRESS_KHR
Definition: vulkan.h:4692
@ VK_ERROR_OUT_OF_HOST_MEMORY
Definition: vulkan.h:4671
@ VK_ERROR_INITIALIZATION_FAILED
Definition: vulkan.h:4669
@ VK_ERROR_OUT_OF_DEVICE_MEMORY
Definition: vulkan.h:4670
@ VK_ERROR_NATIVE_WINDOW_IN_USE_KHR
Definition: vulkan.h:4657
@ VK_ERROR_NOT_PERMITTED_EXT
Definition: vulkan.h:4689
@ VK_ERROR_OUT_OF_DATE_KHR
Definition: vulkan.h:4656
@ VK_TIMEOUT
Definition: vulkan.h:4674
@ VK_ERROR_FORMAT_NOT_SUPPORTED
Definition: vulkan.h:4661
@ VK_ERROR_SURFACE_LOST_KHR
Definition: vulkan.h:4658
@ VK_NOT_READY
Definition: vulkan.h:4673
@ VK_ERROR_FEATURE_NOT_PRESENT
Definition: vulkan.h:4664
@ VK_ERROR_TOO_MANY_OBJECTS
Definition: vulkan.h:4662
@ VK_ERROR_MEMORY_MAP_FAILED
Definition: vulkan.h:4667
@ VK_ERROR_LAYER_NOT_PRESENT
Definition: vulkan.h:4666
@ VK_ERROR_INCOMPATIBLE_DRIVER
Definition: vulkan.h:4663

Referenced by adapter_vk_create_device(), create_uav_pipeline(), enable_vulkan_instance_extensions(), get_vulkan_physical_device(), init_vulkan_format_info(), shader_spirv_compile_shader(), shader_spirv_find_compute_program_vk(), swapchain_vk_present(), vk_blitter_clear_rendertargets(), wined3d_adapter_vk_init_device_extensions(), wined3d_allocator_chunk_vk_map(), wined3d_bo_vk_map(), wined3d_context_vk_allocate_query(), wined3d_context_vk_allocate_vram_chunk_memory(), wined3d_context_vk_begin_render_pass(), wined3d_context_vk_create_bo(), wined3d_context_vk_create_image(), wined3d_context_vk_create_vk_descriptor_pool(), wined3d_context_vk_create_vk_descriptor_set(), wined3d_context_vk_create_vk_descriptor_set_layout(), wined3d_context_vk_get_command_buffer(), wined3d_context_vk_get_graphics_pipeline(), wined3d_context_vk_get_pipeline_layout(), wined3d_context_vk_get_vk_descriptor_pool(), wined3d_context_vk_init(), wined3d_context_vk_submit_command_buffer(), wined3d_device_vk_create_null_views(), wined3d_init_vulkan(), wined3d_query_event_vk_issue(), wined3d_query_pool_vk_init(), wined3d_query_vk_accumulate_data(), wined3d_sampler_vk_cs_init(), wined3d_swapchain_vk_blit(), wined3d_swapchain_vk_create_vulkan_swapchain(), wined3d_swapchain_vk_create_vulkan_swapchain_images(), wined3d_swapchain_vk_destroy_vulkan_swapchain(), wined3d_swapchain_vk_present_mode_supported(), wined3d_swapchain_vk_select_vk_format(), wined3d_texture_vk_get_default_image_info(), wined3d_unordered_access_view_vk_cs_init(), wined3d_view_vk_create_vk_buffer_view(), and wined3d_view_vk_create_vk_image_view().

◆ wined3d_device_vk()

static struct wined3d_device_vk * wined3d_device_vk ( struct wined3d_device *  device)
inlinestatic

Definition at line 841 of file wined3d_vk.h.

842{
844}

◆ wined3d_device_vk_allocator_lock()

static void wined3d_device_vk_allocator_lock ( struct wined3d_device_vk *  device_vk)
inlinestatic

◆ wined3d_device_vk_allocator_unlock()

static void wined3d_device_vk_allocator_unlock ( struct wined3d_device_vk *  device_vk)
inlinestatic

◆ wined3d_device_vk_create_null_resources()

bool wined3d_device_vk_create_null_resources ( struct wined3d_device_vk *  device_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 839 of file device.c.

841{
842 struct wined3d_null_resources_vk *r = &device_vk->null_resources_vk;
843 const struct wined3d_vk_info *vk_info;
844 const struct wined3d_format *format;
845 VkMemoryPropertyFlags memory_type;
846 VkCommandBuffer vk_command_buffer;
847 unsigned int sample_count = 2;
849
851 while (sample_count && !(sample_count & format->multisample_types))
852 sample_count <<= 1;
853
854 if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
855 {
856 ERR("Failed to get command buffer.\n");
857 return false;
858 }
859
860 vk_info = context_vk->vk_info;
861
865 if (!wined3d_context_vk_create_bo(context_vk, 16, usage, memory_type, &r->bo))
866 return false;
867 VK_CALL(vkCmdFillBuffer(vk_command_buffer, r->bo.vk_buffer, r->bo.b.buffer_offset, r->bo.size, 0x00000000u));
868 r->buffer_info.buffer = r->bo.vk_buffer;
869 r->buffer_info.offset = r->bo.b.buffer_offset;
870 r->buffer_info.range = r->bo.size;
871
872 if (!wined3d_null_image_vk_init(&r->image_1d, context_vk, vk_command_buffer, VK_IMAGE_TYPE_1D, 1, 1))
873 {
874 ERR("Failed to create 1D image.\n");
875 goto fail;
876 }
877
878 if (!wined3d_null_image_vk_init(&r->image_2d, context_vk, vk_command_buffer, VK_IMAGE_TYPE_2D, 6, 1))
879 {
880 ERR("Failed to create 2D image.\n");
881 goto fail;
882 }
883
884 if (!wined3d_null_image_vk_init(&r->image_2dms, context_vk, vk_command_buffer, VK_IMAGE_TYPE_2D, 1, sample_count))
885 {
886 ERR("Failed to create 2D MSAA image.\n");
887 goto fail;
888 }
889
890 if (!wined3d_null_image_vk_init(&r->image_3d, context_vk, vk_command_buffer, VK_IMAGE_TYPE_3D, 1, 1))
891 {
892 ERR("Failed to create 3D image.\n");
893 goto fail;
894 }
895
896 return true;
897
898fail:
899 if (r->image_2dms.vk_image)
900 wined3d_context_vk_destroy_image(context_vk, &r->image_2dms);
901 if (r->image_2d.vk_image)
902 wined3d_context_vk_destroy_image(context_vk, &r->image_2d);
903 if (r->image_1d.vk_image)
904 wined3d_context_vk_destroy_image(context_vk, &r->image_1d);
905 wined3d_context_vk_reference_bo(context_vk, &r->bo);
906 wined3d_context_vk_destroy_bo(context_vk, &r->bo);
907 return false;
908}
void wined3d_context_vk_destroy_image(struct wined3d_context_vk *context_vk, struct wined3d_image_vk *image)
Definition: context_vk.c:1092
static bool wined3d_null_image_vk_init(struct wined3d_image_vk *image, struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkImageType type, unsigned int layer_count, unsigned int sample_count)
Definition: device.c:792
const struct wined3d_format * wined3d_get_format(const struct wined3d_adapter *adapter, enum wined3d_format_id format_id, unsigned int bind_flags)
Definition: utils.c:4428
@ VK_IMAGE_TYPE_2D
Definition: vulkan.h:3503
@ VK_IMAGE_TYPE_3D
Definition: vulkan.h:3504
@ VK_IMAGE_TYPE_1D
Definition: vulkan.h:3502
void VKAPI_CALL vkCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data)
@ WINED3DFMT_R8G8B8A8_UNORM
Definition: wined3d.h:185

Referenced by adapter_vk_init_3d().

◆ wined3d_device_vk_create_null_views()

bool wined3d_device_vk_create_null_views ( struct wined3d_device_vk *  device_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 929 of file device.c.

930{
931 struct wined3d_null_resources_vk *r = &device_vk->null_resources_vk;
932 struct wined3d_null_views_vk *v = &device_vk->null_views_vk;
933 VkBufferViewCreateInfo buffer_create_info;
935 const struct wined3d_vk_info *vk_info;
936 VkImageViewCreateInfo view_desc;
937 VkResult vr;
938
939 vk_info = context_vk->vk_info;
940
942 buffer_create_info.pNext = NULL;
943 buffer_create_info.flags = 0;
944 buffer_create_info.buffer = r->bo.vk_buffer;
945 buffer_create_info.format = VK_FORMAT_R32_UINT;
946 buffer_create_info.offset = r->bo.b.buffer_offset;
947 buffer_create_info.range = r->bo.size;
948
949 if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device,
950 &buffer_create_info, NULL, &v->vk_view_buffer_uint))) < 0)
951 {
952 ERR("Failed to create buffer view, vr %s.\n", wined3d_debug_vkresult(vr));
953 return false;
954 }
955 TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(v->vk_view_buffer_uint));
956
957 buffer_create_info.format = VK_FORMAT_R32G32B32A32_SFLOAT;
958 if ((vr = VK_CALL(vkCreateBufferView(device_vk->vk_device,
959 &buffer_create_info, NULL, &v->vk_view_buffer_float))) < 0)
960 {
961 ERR("Failed to create buffer view, vr %s.\n", wined3d_debug_vkresult(vr));
962 goto fail;
963 }
964 TRACE("Created buffer view 0x%s.\n", wine_dbgstr_longlong(v->vk_view_buffer_float));
965
967 view_desc.pNext = NULL;
968 view_desc.flags = 0;
969 view_desc.image = r->image_1d.vk_image;
977 view_desc.subresourceRange.baseMipLevel = 0;
978 view_desc.subresourceRange.levelCount = 1;
979 view_desc.subresourceRange.baseArrayLayer = 0;
980 view_desc.subresourceRange.layerCount = 1;
981
983 {
985 usage_desc.pNext = NULL;
987
988 view_desc.pNext = &usage_desc;
989 }
990
991 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_1d.imageView))) < 0)
992 {
993 ERR("Failed to create 1D image view, vr %s.\n", wined3d_debug_vkresult(vr));
994 goto fail;
995 }
996 v->vk_info_1d.sampler = VK_NULL_HANDLE;
997 v->vk_info_1d.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
998 TRACE("Created 1D image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_1d.imageView));
999
1001 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_1d_array.imageView))) < 0)
1002 {
1003 ERR("Failed to create 1D image view, vr %s.\n", wined3d_debug_vkresult(vr));
1004 goto fail;
1005 }
1006 v->vk_info_1d_array.sampler = VK_NULL_HANDLE;
1007 v->vk_info_1d_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1008 TRACE("Created 1D array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_1d_array.imageView));
1009
1010 view_desc.image = r->image_2d.vk_image;
1011 view_desc.viewType = VK_IMAGE_VIEW_TYPE_2D;
1012 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2d.imageView))) < 0)
1013 {
1014 ERR("Failed to create 2D image view, vr %s.\n", wined3d_debug_vkresult(vr));
1015 goto fail;
1016 }
1017 v->vk_info_2d.sampler = VK_NULL_HANDLE;
1018 v->vk_info_2d.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1019 TRACE("Created 2D image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2d.imageView));
1020
1021 view_desc.image = r->image_2dms.vk_image;
1022 view_desc.viewType = VK_IMAGE_VIEW_TYPE_2D;
1023 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2dms.imageView))) < 0)
1024 {
1025 ERR("Failed to create 2D MSAA image view, vr %s.\n", wined3d_debug_vkresult(vr));
1026 goto fail;
1027 }
1028 v->vk_info_2dms.sampler = VK_NULL_HANDLE;
1029 v->vk_info_2dms.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1030 TRACE("Created 2D MSAA image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2dms.imageView));
1031
1032 view_desc.image = r->image_3d.vk_image;
1033 view_desc.viewType = VK_IMAGE_VIEW_TYPE_3D;
1034 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_3d.imageView))) < 0)
1035 {
1036 ERR("Failed to create 3D image view, vr %s.\n", wined3d_debug_vkresult(vr));
1037 goto fail;
1038 }
1039 v->vk_info_3d.sampler = VK_NULL_HANDLE;
1040 v->vk_info_3d.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1041 TRACE("Created 3D image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_3d.imageView));
1042
1043 view_desc.image = r->image_2d.vk_image;
1044 view_desc.subresourceRange.layerCount = 6;
1046 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_cube.imageView))) < 0)
1047 {
1048 ERR("Failed to create cube image view, vr %s.\n", wined3d_debug_vkresult(vr));
1049 goto fail;
1050 }
1051 v->vk_info_cube.sampler = VK_NULL_HANDLE;
1052 v->vk_info_cube.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1053 TRACE("Created cube image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_cube.imageView));
1054
1055 view_desc.subresourceRange.layerCount = 1;
1057 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2d_array.imageView))) < 0)
1058 {
1059 ERR("Failed to create 2D array image view, vr %s.\n", wined3d_debug_vkresult(vr));
1060 goto fail;
1061 }
1062 v->vk_info_2d_array.sampler = VK_NULL_HANDLE;
1063 v->vk_info_2d_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1064 TRACE("Created 2D array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2d_array.imageView));
1065
1066 view_desc.image = r->image_2dms.vk_image;
1068 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_2dms_array.imageView))) < 0)
1069 {
1070 ERR("Failed to create 2D MSAA array image view, vr %s.\n", wined3d_debug_vkresult(vr));
1071 goto fail;
1072 }
1073 v->vk_info_2dms_array.sampler = VK_NULL_HANDLE;
1074 v->vk_info_2dms_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1075 TRACE("Created 2D MSAA array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_2dms_array.imageView));
1076
1077 view_desc.image = r->image_2d.vk_image;
1078 view_desc.subresourceRange.layerCount = 6;
1080 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &view_desc, NULL, &v->vk_info_cube_array.imageView))) < 0)
1081 {
1082 ERR("Failed to create cube array image view, vr %s.\n", wined3d_debug_vkresult(vr));
1083 goto fail;
1084 }
1085 v->vk_info_cube_array.sampler = VK_NULL_HANDLE;
1086 v->vk_info_cube_array.imageLayout = VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL;
1087 TRACE("Created cube array image view 0x%s.\n", wine_dbgstr_longlong(v->vk_info_cube_array.imageView));
1088
1089 return true;
1090
1091fail:
1092 if (v->vk_info_cube_array.imageView)
1093 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_cube_array.imageView, NULL));
1094 if (v->vk_info_2d_array.imageView)
1095 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_2d_array.imageView, NULL));
1096 if (v->vk_info_cube.imageView)
1097 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_cube.imageView, NULL));
1098 if (v->vk_info_3d.imageView)
1099 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_3d.imageView, NULL));
1100 if (v->vk_info_2dms.imageView)
1101 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_2dms.imageView, NULL));
1102 if (v->vk_info_2d.imageView)
1103 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_2d.imageView, NULL));
1104 if (v->vk_info_1d_array.imageView)
1105 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_1d_array.imageView, NULL));
1106 if (v->vk_info_1d.imageView)
1107 VK_CALL(vkDestroyImageView(device_vk->vk_device, v->vk_info_1d.imageView, NULL));
1108 if (v->vk_view_buffer_float)
1109 VK_CALL(vkDestroyBufferView(device_vk->vk_device, v->vk_view_buffer_float, NULL));
1110 VK_CALL(vkDestroyBufferView(device_vk->vk_device, v->vk_view_buffer_uint, NULL));
1111 return false;
1112}
const GLdouble * v
Definition: gl.h:2040
const void * pNext
Definition: vulkan.h:7684
VkBufferViewCreateFlags flags
Definition: vulkan.h:7685
VkStructureType sType
Definition: vulkan.h:7683
VkComponentSwizzle r
Definition: vulkan.h:7880
VkComponentSwizzle a
Definition: vulkan.h:7883
VkComponentSwizzle g
Definition: vulkan.h:7881
VkComponentSwizzle b
Definition: vulkan.h:7882
uint32_t baseArrayLayer
Definition: vulkan.h:9076
VkImageAspectFlags aspectMask
Definition: vulkan.h:9073
VkImageSubresourceRange subresourceRange
Definition: vulkan.h:9118
VkComponentMapping components
Definition: vulkan.h:9117
VkImageViewType viewType
Definition: vulkan.h:9115
VkStructureType sType
Definition: vulkan.h:9111
const void * pNext
Definition: vulkan.h:9112
VkImageViewCreateFlags flags
Definition: vulkan.h:9113
VkImageUsageFlags usage
Definition: vulkan.h:9149
VkStructureType sType
Definition: vulkan.h:9147
struct wined3d_null_views_vk null_views_vk
Definition: wined3d_vk.h:833
unsigned int api_version
Definition: wined3d_vk.h:259
@ VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
Definition: vulkan.h:3456
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan.h:3512
@ VK_COMPONENT_SWIZZLE_ZERO
Definition: vulkan.h:2189
VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
VkResult VKAPI_CALL vkCreateBufferView(VkDevice device, const VkBufferViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBufferView *pView)
@ VK_FORMAT_R32G32B32A32_SFLOAT
Definition: vulkan.h:2925
@ VK_FORMAT_R8G8B8A8_UNORM
Definition: vulkan.h:2853
@ VK_FORMAT_R32_UINT
Definition: vulkan.h:2914
#define VK_API_VERSION_1_1
Definition: vulkan.h:843
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO_KHR
Definition: vulkan.h:5896
@ VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO
Definition: vulkan.h:4977
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Definition: vulkan.h:4979

Referenced by adapter_vk_init_3d().

◆ wined3d_device_vk_destroy_null_resources()

void wined3d_device_vk_destroy_null_resources ( struct wined3d_device_vk *  device_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 910 of file device.c.

912{
913 struct wined3d_null_resources_vk *r = &device_vk->null_resources_vk;
914
915 /* We don't track command buffer references to NULL resources. We easily
916 * could, but it doesn't seem worth it. */
917 wined3d_context_vk_reference_image(context_vk, &r->image_3d);
918 wined3d_context_vk_destroy_image(context_vk, &r->image_3d);
919 wined3d_context_vk_reference_image(context_vk, &r->image_2dms);
920 wined3d_context_vk_destroy_image(context_vk, &r->image_2dms);
921 wined3d_context_vk_reference_image(context_vk, &r->image_2d);
922 wined3d_context_vk_destroy_image(context_vk, &r->image_2d);
923 wined3d_context_vk_reference_image(context_vk, &r->image_1d);
924 wined3d_context_vk_destroy_image(context_vk, &r->image_1d);
925 wined3d_context_vk_reference_bo(context_vk, &r->bo);
926 wined3d_context_vk_destroy_bo(context_vk, &r->bo);
927}

Referenced by adapter_vk_uninit_3d_cs().

◆ wined3d_device_vk_destroy_null_views()

void wined3d_device_vk_destroy_null_views ( struct wined3d_device_vk *  device_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1114 of file device.c.

1115{
1116 struct wined3d_null_views_vk *v = &device_vk->null_views_vk;
1117 uint64_t id = context_vk->current_command_buffer.id;
1118
1119 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_cube_array.imageView, id);
1120 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2dms_array.imageView, id);
1121 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2d_array.imageView, id);
1122 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_cube.imageView, id);
1123 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_3d.imageView, id);
1124 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2dms.imageView, id);
1125 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_2d.imageView, id);
1126 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_1d_array.imageView, id);
1127 wined3d_context_vk_destroy_vk_image_view(context_vk, v->vk_info_1d.imageView, id);
1128
1129 wined3d_context_vk_destroy_vk_buffer_view(context_vk, v->vk_view_buffer_float, id);
1130 wined3d_context_vk_destroy_vk_buffer_view(context_vk, v->vk_view_buffer_uint, id);
1131}
void wined3d_context_vk_destroy_vk_buffer_view(struct wined3d_context_vk *context_vk, VkBufferView vk_view, uint64_t command_buffer_id)
Definition: context_vk.c:931
void wined3d_context_vk_destroy_vk_image_view(struct wined3d_context_vk *context_vk, VkImageView vk_view, uint64_t command_buffer_id)
Definition: context_vk.c:956
UINT64 uint64_t
Definition: types.h:77

Referenced by adapter_vk_uninit_3d_cs().

◆ wined3d_device_vk_from_allocator()

static struct wined3d_device_vk * wined3d_device_vk_from_allocator ( struct wined3d_allocator *  allocator)
inlinestatic

◆ wined3d_device_vk_uav_clear_state_cleanup()

void wined3d_device_vk_uav_clear_state_cleanup ( struct wined3d_device_vk *  device_vk)

Definition at line 2057 of file view.c.

2058{
2059 struct wined3d_uav_clear_state_vk *state = &device_vk->uav_clear_state;
2060 const struct wined3d_vk_info *vk_info = &device_vk->vk_info;
2061
2062 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.buffer, NULL));
2063 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_1d, NULL));
2064 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_1d_array, NULL));
2065 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_2d, NULL));
2066 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_2d_array, NULL));
2067 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->float_pipelines.image_3d, NULL));
2068
2069 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.buffer, NULL));
2070 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_1d, NULL));
2071 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_1d_array, NULL));
2072 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_2d, NULL));
2073 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_2d_array, NULL));
2074 VK_CALL(vkDestroyPipeline(device_vk->vk_device, state->uint_pipelines.image_3d, NULL));
2075}
struct wined3d_uav_clear_state_vk uav_clear_state
Definition: wined3d_vk.h:838

Referenced by adapter_vk_uninit_3d_cs().

◆ wined3d_device_vk_uav_clear_state_init()

void wined3d_device_vk_uav_clear_state_init ( struct wined3d_device_vk *  device_vk)

Definition at line 1989 of file view.c.

1990{
1991 struct wined3d_uav_clear_state_vk *state = &device_vk->uav_clear_state;
1992 struct wined3d_context_vk *context_vk = &device_vk->context_vk;
1993 VkDescriptorSetLayoutBinding vk_set_bindings[2];
1994
1995 vk_set_bindings[0].binding = 0;
1996 vk_set_bindings[0].descriptorCount = 1;
1997 vk_set_bindings[0].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
1998 vk_set_bindings[0].pImmutableSamplers = NULL;
2000
2001 vk_set_bindings[1].binding = 1;
2002 vk_set_bindings[1].descriptorCount = 1;
2003 vk_set_bindings[1].stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
2004 vk_set_bindings[1].pImmutableSamplers = NULL;
2005
2007 state->image_layout = wined3d_context_vk_get_pipeline_layout(context_vk, vk_set_bindings, 2);
2008
2010 state->buffer_layout = wined3d_context_vk_get_pipeline_layout(context_vk, vk_set_bindings, 2);
2011
2012 state->float_pipelines.buffer = create_uav_pipeline(context_vk, state->buffer_layout,
2013 "cs_uav_clear_buffer_float_code.hlsl", WINED3D_SHADER_RESOURCE_BUFFER);
2014 state->uint_pipelines.buffer = create_uav_pipeline(context_vk, state->buffer_layout,
2015 "cs_uav_clear_buffer_uint_code.hlsl", WINED3D_SHADER_RESOURCE_BUFFER);
2016 state->float_pipelines.image_1d = create_uav_pipeline(context_vk, state->image_layout,
2017 "cs_uav_clear_1d_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1D);
2018 state->uint_pipelines.image_1d = create_uav_pipeline(context_vk, state->image_layout,
2019 "cs_uav_clear_1d_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1D);
2020 state->float_pipelines.image_1d_array = create_uav_pipeline(context_vk, state->image_layout,
2021 "cs_uav_clear_1d_array_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY);
2022 state->uint_pipelines.image_1d_array = create_uav_pipeline(context_vk, state->image_layout,
2023 "cs_uav_clear_1d_array_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY);
2024 state->float_pipelines.image_2d = create_uav_pipeline(context_vk, state->image_layout,
2025 "cs_uav_clear_2d_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2D);
2026 state->uint_pipelines.image_2d = create_uav_pipeline(context_vk, state->image_layout,
2027 "cs_uav_clear_2d_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2D);
2028 state->float_pipelines.image_2d_array = create_uav_pipeline(context_vk, state->image_layout,
2029 "cs_uav_clear_2d_array_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY);
2030 state->uint_pipelines.image_2d_array = create_uav_pipeline(context_vk, state->image_layout,
2031 "cs_uav_clear_2d_array_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY);
2032 state->float_pipelines.image_3d = create_uav_pipeline(context_vk, state->image_layout,
2033 "cs_uav_clear_3d_float_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_3D);
2034 state->uint_pipelines.image_3d = create_uav_pipeline(context_vk, state->image_layout,
2035 "cs_uav_clear_3d_uint_code.hlsl", WINED3D_SHADER_RESOURCE_TEXTURE_3D);
2036
2037 state->buffer_group_size.x = 128;
2038 state->buffer_group_size.y = 1;
2039 state->buffer_group_size.z = 1;
2040 state->image_1d_group_size.x = 64;
2041 state->image_1d_group_size.y = 1;
2042 state->image_1d_group_size.z = 1;
2043 state->image_1d_array_group_size.x = 64;
2044 state->image_1d_array_group_size.y = 1;
2045 state->image_1d_array_group_size.z = 1;
2046 state->image_2d_group_size.x = 8;
2047 state->image_2d_group_size.y = 8;
2048 state->image_2d_group_size.z = 1;
2049 state->image_2d_array_group_size.x = 8;
2050 state->image_2d_array_group_size.y = 8;
2051 state->image_2d_array_group_size.z = 1;
2052 state->image_3d_group_size.x = 8;
2053 state->image_3d_group_size.y = 8;
2054 state->image_3d_group_size.z = 1;
2055}
struct wined3d_pipeline_layout_vk * wined3d_context_vk_get_pipeline_layout(struct wined3d_context_vk *context_vk, VkDescriptorSetLayoutBinding *bindings, SIZE_T binding_count)
Definition: context_vk.c:3442
static VkPipeline create_uav_pipeline(struct wined3d_context_vk *context_vk, struct wined3d_pipeline_layout_vk *layout, const char *resource_filename, enum wined3d_shader_resource_type resource_type)
Definition: view.c:1888
VkDescriptorType descriptorType
Definition: vulkan.h:8303
const VkSampler * pImmutableSamplers
Definition: vulkan.h:8306
VkShaderStageFlags stageFlags
Definition: vulkan.h:8305
@ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
Definition: vulkan.h:2469
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan.h:2470
@ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
Definition: vulkan.h:2467
@ WINED3D_SHADER_RESOURCE_BUFFER
@ WINED3D_SHADER_RESOURCE_TEXTURE_3D
@ WINED3D_SHADER_RESOURCE_TEXTURE_2D
@ WINED3D_SHADER_RESOURCE_TEXTURE_1DARRAY
@ WINED3D_SHADER_RESOURCE_TEXTURE_2DARRAY
@ WINED3D_SHADER_RESOURCE_TEXTURE_1D

Referenced by adapter_vk_init_3d().

◆ wined3d_format_colour_to_vk()

void wined3d_format_colour_to_vk ( const struct wined3d_format *  format,
const struct wined3d_color *  c,
VkClearColorValue *  retval 
)

Definition at line 5790 of file utils.c.

5792{
5794 {
5795 retval->int32[0] = c->r;
5796 retval->int32[1] = c->g;
5797 retval->int32[2] = c->b;
5798 retval->int32[3] = c->a;
5799 }
5800 else
5801 {
5802 retval->float32[0] = c->r;
5803 retval->float32[1] = c->g;
5804 retval->float32[2] = c->b;
5805 retval->float32[3] = c->a;
5806 }
5807}
int retval
Definition: wcstombs.cpp:91
#define WINED3D_FORMAT_ATTR_INTEGER

Referenced by vk_blitter_clear_rendertargets(), wined3d_context_vk_begin_render_pass(), and wined3d_texture_vk_clear().

◆ wined3d_format_vk()

Definition at line 1086 of file wined3d_vk.h.

1087{
1089}
GLfloat f
Definition: glext.h:7540

◆ wined3d_query_pool_vk_allocate_query()

bool wined3d_query_pool_vk_allocate_query ( struct wined3d_query_pool_vk *  pool_vk,
size_t *  idx 
)

Definition at line 1357 of file query.c.

1358{
1360 return false;
1361 wined3d_bitmap_set(pool_vk->allocated, *idx);
1362
1363 return true;
1364}
uint32_t allocated[WINED3D_BITMAP_SIZE(WINED3D_QUERY_POOL_SIZE)]
Definition: wined3d_vk.h:371
static unsigned int wined3d_bitmap_ffz(const uint32_t *bitmap, unsigned int bit_count, unsigned int start)
static BOOL wined3d_bitmap_set(uint32_t *map, unsigned int idx)

Referenced by wined3d_context_vk_allocate_query().

◆ wined3d_query_pool_vk_cleanup()

void wined3d_query_pool_vk_cleanup ( struct wined3d_query_pool_vk *  pool_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1378 of file query.c.

1379{
1380 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1381 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1382
1383 VK_CALL(vkDestroyQueryPool(device_vk->vk_device, pool_vk->vk_query_pool, NULL));
1384 if (pool_vk->vk_event)
1385 VK_CALL(vkDestroyEvent(device_vk->vk_device, pool_vk->vk_event, NULL));
1386 list_remove(&pool_vk->entry);
1387 list_remove(&pool_vk->completed_entry);
1388}
void VKAPI_CALL vkDestroyQueryPool(VkDevice device, VkQueryPool queryPool, const VkAllocationCallbacks *pAllocator)

Referenced by wined3d_context_vk_allocate_query(), and wined3d_context_vk_destroy_query_pools().

◆ wined3d_query_pool_vk_init()

bool wined3d_query_pool_vk_init ( struct wined3d_query_pool_vk *  pool_vk,
struct wined3d_context_vk *  context_vk,
enum wined3d_query_type  type,
struct list *  free_pools 
)

Definition at line 1390 of file query.c.

1392{
1393 struct wined3d_device_vk *device_vk = wined3d_device_vk(context_vk->c.device);
1394 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1395 VkQueryPoolCreateInfo pool_info;
1396 VkResult vr;
1397
1398 list_init(&pool_vk->entry);
1399 list_init(&pool_vk->completed_entry);
1400 pool_vk->free_list = free_pools;
1401
1403 pool_info.pNext = NULL;
1404 pool_info.flags = 0;
1406
1407 switch (type)
1408 {
1411 pool_info.pipelineStatistics = 0;
1412 break;
1413
1416 pool_info.pipelineStatistics = 0;
1417 break;
1418
1432 break;
1433
1440 pool_info.pipelineStatistics = 0;
1441 break;
1442
1443 default:
1444 FIXME("Unhandled query type %#x.\n", type);
1445 return false;
1446 }
1447
1448 if ((vr = VK_CALL(vkCreateQueryPool(device_vk->vk_device, &pool_info, NULL, &pool_vk->vk_query_pool))) < 0)
1449 {
1450 ERR("Failed to create Vulkan query pool, vr %s.\n", wined3d_debug_vkresult(vr));
1451 return false;
1452 }
1453
1454 list_add_head(free_pools, &pool_vk->entry);
1455
1456 return true;
1457}
static void list_add_head(struct list_entry *head, struct list_entry *entry)
Definition: list.h:76
VkQueryPipelineStatisticFlags pipelineStatistics
Definition: vulkan.h:13483
VkQueryPoolCreateFlags flags
Definition: vulkan.h:13480
const void * pNext
Definition: vulkan.h:13479
VkStructureType sType
Definition: vulkan.h:13478
VkQueryType queryType
Definition: vulkan.h:13481
struct list * free_list
Definition: wined3d_vk.h:367
VkResult VKAPI_CALL vkCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkQueryPool *pQueryPool)
@ VK_QUERY_TYPE_PIPELINE_STATISTICS
Definition: vulkan.h:4510
@ VK_QUERY_TYPE_OCCLUSION
Definition: vulkan.h:4509
@ VK_QUERY_TYPE_TRANSFORM_FEEDBACK_STREAM_EXT
Definition: vulkan.h:4513
@ VK_QUERY_TYPE_TIMESTAMP
Definition: vulkan.h:4511
@ VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_PRIMITIVES_BIT
Definition: vulkan.h:4466
@ VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4468
@ VK_QUERY_PIPELINE_STATISTIC_INPUT_ASSEMBLY_VERTICES_BIT
Definition: vulkan.h:4465
@ VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4474
@ VK_QUERY_PIPELINE_STATISTIC_FRAGMENT_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4472
@ VK_QUERY_PIPELINE_STATISTIC_VERTEX_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4467
@ VK_QUERY_PIPELINE_STATISTIC_GEOMETRY_SHADER_PRIMITIVES_BIT
Definition: vulkan.h:4469
@ VK_QUERY_PIPELINE_STATISTIC_CLIPPING_INVOCATIONS_BIT
Definition: vulkan.h:4470
@ VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT
Definition: vulkan.h:4473
@ VK_QUERY_PIPELINE_STATISTIC_CLIPPING_PRIMITIVES_BIT
Definition: vulkan.h:4471
@ VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT
Definition: vulkan.h:4475
@ VK_STRUCTURE_TYPE_QUERY_POOL_CREATE_INFO
Definition: vulkan.h:4975

Referenced by wined3d_context_vk_allocate_query().

◆ wined3d_query_pool_vk_mark_free()

void wined3d_query_pool_vk_mark_free ( struct wined3d_context_vk *  context_vk,
struct wined3d_query_pool_vk *  pool_vk,
uint32_t  start,
uint32_t  count 
)

Definition at line 1366 of file query.c.

1368{
1369 unsigned int idx, end = start + count;
1370
1371 for (idx = start; idx < end; ++idx)
1373
1374 if (list_empty(&pool_vk->entry))
1375 list_add_tail(pool_vk->free_list, &pool_vk->entry);
1376}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
GLuint start
Definition: gl.h:1545
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLuint GLuint end
Definition: gl.h:1545
static BOOL wined3d_bitmap_clear(uint32_t *map, unsigned int idx)

Referenced by wined3d_context_vk_cleanup_resources(), and wined3d_context_vk_reset_completed_queries().

◆ wined3d_query_vk()

static struct wined3d_query_vk * wined3d_query_vk ( struct wined3d_query *  query)
inlinestatic

Definition at line 407 of file wined3d_vk.h.

408{
409 return CONTAINING_RECORD(query, struct wined3d_query_vk, q);
410}
GLdouble GLdouble GLdouble GLdouble q
Definition: gl.h:2063

◆ wined3d_query_vk_accumulate_data()

bool wined3d_query_vk_accumulate_data ( struct wined3d_query_vk *  query_vk,
struct wined3d_device_vk *  device_vk,
const struct wined3d_query_pool_idx_vk *  pool_idx 
)

Definition at line 1459 of file query.c.

1461{
1462 const struct wined3d_query_data_pipeline_statistics *ps_tmp;
1463 const struct wined3d_vk_info *vk_info = &device_vk->vk_info;
1465 VkResult vr;
1466 union
1467 {
1468 uint64_t occlusion;
1470 struct wined3d_query_data_pipeline_statistics pipeline_statistics;
1471 struct wined3d_query_data_so_statistics so_statistics;
1472 } tmp, *result;
1473
1474 if (pool_idx->pool_vk->vk_event)
1475 {
1476 /* Check if the pool's initial reset command executed. */
1477 vr = VK_CALL(vkGetEventStatus(device_vk->vk_device,
1478 pool_idx->pool_vk->vk_event));
1479 if (vr == VK_EVENT_RESET)
1480 return false;
1481 else if (vr != VK_EVENT_SET)
1482 {
1483 ERR("Failed to get event status, vr %s\n", wined3d_debug_vkresult(vr));
1484 return false;
1485 }
1486 }
1487
1488 if ((vr = VK_CALL(vkGetQueryPoolResults(device_vk->vk_device, pool_idx->pool_vk->vk_query_pool,
1489 pool_idx->idx, 1, sizeof(tmp), &tmp, sizeof(tmp), VK_QUERY_RESULT_64_BIT))) < 0)
1490 {
1491 ERR("Failed to get query results, vr %s.\n", wined3d_debug_vkresult(vr));
1492 return false;
1493 }
1494
1495 if (vr == VK_NOT_READY)
1496 return false;
1497
1498 result = (void *)query_vk->q.data;
1499 switch (query_vk->q.type)
1500 {
1502 result->occlusion += tmp.occlusion;
1503 break;
1504
1506 result->timestamp = tmp.timestamp;
1507 break;
1508
1510 ps_result = &result->pipeline_statistics;
1511 ps_tmp = &tmp.pipeline_statistics;
1512 ps_result->vertices_submitted += ps_tmp->vertices_submitted;
1513 ps_result->primitives_submitted += ps_tmp->primitives_submitted;
1514 ps_result->vs_invocations += ps_tmp->vs_invocations;
1515 ps_result->gs_invocations += ps_tmp->gs_invocations;
1516 ps_result->gs_primitives += ps_tmp->gs_primitives;
1519 ps_result->ps_invocations += ps_tmp->ps_invocations;
1520 ps_result->hs_invocations += ps_tmp->hs_invocations;
1521 ps_result->ds_invocations += ps_tmp->ds_invocations;
1522 ps_result->cs_invocations += ps_tmp->cs_invocations;
1523 break;
1524
1530 result->so_statistics.primitives_written += tmp.so_statistics.primitives_written;
1531 result->so_statistics.primitives_generated += tmp.so_statistics.primitives_generated;
1532 break;
1533
1534 default:
1535 FIXME("Unhandled query type %#x.\n", query_vk->q.type);
1536 return false;
1537 }
1538
1539 return true;
1540}
switch(r->id)
Definition: btrfs.c:3046
GLuint64EXT * result
Definition: glext.h:11304
VkResult VKAPI_CALL vkGetEventStatus(VkDevice device, VkEvent event)
VkResult VKAPI_CALL vkGetQueryPoolResults(VkDevice device, VkQueryPool queryPool, uint32_t firstQuery, uint32_t queryCount, size_t dataSize, void *pData, VkDeviceSize stride, VkQueryResultFlags flags)
@ VK_QUERY_RESULT_64_BIT
Definition: vulkan.h:4490

Referenced by wined3d_query_vk_poll().

◆ wined3d_query_vk_create()

HRESULT wined3d_query_vk_create ( struct wined3d_device *  device,
enum wined3d_query_type  type,
void *  parent,
const struct wined3d_parent_ops *  parent_ops,
struct wined3d_query **  query 
)

Definition at line 1894 of file query.c.

1896{
1897 struct wined3d_query_data_timestamp_disjoint *disjoint_data;
1898 const struct wined3d_query_ops *ops = &wined3d_query_vk_ops;
1899 struct wined3d_query_vk *query_vk;
1900 unsigned int data_size;
1901 void *data;
1902
1903 TRACE("device %p, type %#x, parent %p, parent_ops %p, query %p.\n",
1904 device, type, parent, parent_ops, query);
1905
1906 switch (type)
1907 {
1910 data_size = sizeof(BOOL);
1911 break;
1912
1914 data_size = sizeof(uint64_t);
1915 break;
1916
1919 {
1920 WARN("Timestamp queries not supported.\n");
1922 }
1924 data_size = sizeof(uint64_t);
1925 break;
1926
1929 {
1930 WARN("Timestamp queries not supported.\n");
1932 }
1934 data_size = sizeof(struct wined3d_query_data_timestamp_disjoint);
1935 break;
1936
1938 data_size = sizeof(struct wined3d_query_data_pipeline_statistics);
1939 break;
1940
1947 {
1948 WARN("Stream output queries not supported.\n");
1950 }
1951 data_size = sizeof(struct wined3d_query_data_so_statistics);
1952 break;
1953
1954 default:
1955 FIXME("Unhandled query type %#x.\n", type);
1957 }
1958
1959 if (!(query_vk = calloc(1, sizeof(*query_vk) + data_size)))
1960 return E_OUTOFMEMORY;
1961 data = query_vk + 1;
1962
1963 wined3d_query_init(&query_vk->q, device, type, data, data_size, ops, parent, parent_ops);
1964 query_vk->q.poll_in_cs = false;
1965
1966 switch (type)
1967 {
1970 break;
1971
1973 disjoint_data = data;
1974 disjoint_data->frequency = 1000000000 / wined3d_adapter_vk(device->adapter)->device_limits.timestampPeriod;
1975 disjoint_data->disjoint = FALSE;
1976 break;
1977
1978 default:
1979 break;
1980 }
1981
1982 TRACE("Created query %p.\n", query_vk);
1983 *query = &query_vk->q;
1984
1985 return WINED3D_OK;
1986}
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
static const struct wined3d_query_ops wined3d_query_event_vk_ops
Definition: query.c:1835
static const struct wined3d_query_ops wined3d_query_vk_ops
Definition: query.c:1757
static const struct wined3d_query_ops wined3d_query_timestamp_disjoint_vk_ops
Definition: query.c:1887
static const struct wined3d_query_ops wined3d_query_timestamp_vk_ops
Definition: query.c:1880
static void wined3d_query_init(struct wined3d_query *query, struct wined3d_device *device, enum wined3d_query_type type, const void *data, DWORD data_size, const struct wined3d_query_ops *query_ops, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: query.c:135
#define uint64_t
Definition: nsiface.idl:62
#define BOOL
Definition: nt_native.h:43
VkPhysicalDeviceLimits device_limits
Definition: wined3d_vk.h:733
uint32_t timestamp_bits
Definition: wined3d_vk.h:828
uint32_t control_flags
Definition: wined3d_vk.h:401
@ VK_QUERY_CONTROL_PRECISE_BIT
Definition: vulkan.h:4459
#define WINED3DERR_NOTAVAILABLE
Definition: wined3d.h:42
@ WINED3D_QUERY_TYPE_EVENT
Definition: wined3d.h:729
@ WINED3D_QUERY_TYPE_TIMESTAMP_DISJOINT
Definition: wined3d.h:732

Referenced by adapter_vk_create_query().

◆ wined3d_query_vk_resume()

void wined3d_query_vk_resume ( struct wined3d_query_vk *  query_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1579 of file query.c.

1580{
1581 VkCommandBuffer vk_command_buffer = context_vk->current_command_buffer.vk_command_buffer;
1582
1583 wined3d_query_vk_begin(query_vk, context_vk, vk_command_buffer);
1585}
static void wined3d_query_vk_begin(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer)
Definition: query.c:1542
#define WINED3D_QUERY_VK_FLAG_ACTIVE
Definition: wined3d_vk.h:389

Referenced by wined3d_context_vk_begin_render_pass(), and wined3d_context_vk_get_command_buffer().

◆ wined3d_query_vk_suspend()

void wined3d_query_vk_suspend ( struct wined3d_query_vk *  query_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1587 of file query.c.

1588{
1589 VkCommandBuffer vk_command_buffer = context_vk->current_command_buffer.vk_command_buffer;
1590
1591 wined3d_query_vk_end(query_vk, context_vk, vk_command_buffer);
1592
1593 if (!wined3d_array_reserve((void **)&query_vk->pending, &query_vk->pending_size,
1594 query_vk->pending_count + 1, sizeof(*query_vk->pending)))
1595 {
1596 ERR("Failed to allocate entry.\n");
1597 return;
1598 }
1599
1600 query_vk->pending[query_vk->pending_count++] = query_vk->pool_idx;
1601 query_vk->pool_idx.pool_vk = NULL;
1602 query_vk->flags &= ~WINED3D_QUERY_VK_FLAG_ACTIVE;
1603}
static void wined3d_query_vk_end(struct wined3d_query_vk *query_vk, struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer)
Definition: query.c:1561
struct wined3d_query_pool_idx_vk * pending
Definition: wined3d_vk.h:404
SIZE_T pending_count
Definition: wined3d_vk.h:403
SIZE_T pending_size
Definition: wined3d_vk.h:403

Referenced by wined3d_context_vk_end_current_render_pass(), and wined3d_context_vk_submit_command_buffer().

◆ wined3d_rendertarget_view_vk()

◆ wined3d_rendertarget_view_vk_barrier()

static void wined3d_rendertarget_view_vk_barrier ( struct wined3d_rendertarget_view_vk *  rtv_vk,
struct wined3d_context_vk *  context_vk,
uint32_t  bind_mask 
)
inlinestatic

Definition at line 961 of file wined3d_vk.h.

963{
964 wined3d_resource_vk_barrier(rtv_vk->v.resource, context_vk, bind_mask);
965}
static void wined3d_resource_vk_barrier(struct wined3d_resource *resource, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
Definition: wined3d_vk.h:938

Referenced by vk_blitter_clear_rendertargets(), and wined3d_context_vk_begin_render_pass().

◆ wined3d_rendertarget_view_vk_get_image_view()

static VkImageView wined3d_rendertarget_view_vk_get_image_view ( struct wined3d_rendertarget_view_vk *  rtv_vk,
struct wined3d_context_vk *  context_vk 
)
inlinestatic

Definition at line 967 of file wined3d_vk.h.

969{
970 struct wined3d_texture_vk *texture_vk;
971
972 if (rtv_vk->vk_image_view)
973 return rtv_vk->vk_image_view;
974
975 texture_vk = wined3d_texture_vk(wined3d_texture_from_resource(rtv_vk->v.resource));
976 return wined3d_texture_vk_get_default_image_info(texture_vk, context_vk)->imageView;
977}
struct wined3d_texture *__cdecl wined3d_texture_from_resource(struct wined3d_resource *resource)
Definition: texture.c:3343
const VkDescriptorImageInfo * wined3d_texture_vk_get_default_image_info(struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
Definition: texture.c:4601

Referenced by vk_blitter_clear_rendertargets(), and wined3d_context_vk_begin_render_pass().

◆ wined3d_rendertarget_view_vk_init()

HRESULT wined3d_rendertarget_view_vk_init ( struct wined3d_rendertarget_view_vk *  view_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 916 of file view.c.

919{
920 HRESULT hr;
921
922 TRACE("view_vk %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
923 view_vk, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
924
925 if (FAILED(hr = wined3d_rendertarget_view_init(&view_vk->v, desc, resource, parent, parent_ops)))
926 return hr;
927
929
930 return hr;
931}
void wined3d_cs_init_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2304
HRESULT hr
Definition: delayimp.cpp:582
const char * wined3d_debug_view_desc(const struct wined3d_view_desc *d, const struct wined3d_resource *resource)
Definition: utils.c:4867
static HRESULT wined3d_rendertarget_view_init(struct wined3d_rendertarget_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: view.c:602
static void wined3d_render_target_view_vk_cs_init(void *object)
Definition: view.c:858
#define FAILED(hr)
Definition: intsafe.h:51

Referenced by adapter_vk_create_rendertarget_view().

◆ wined3d_resource_vk_barrier()

static void wined3d_resource_vk_barrier ( struct wined3d_resource *  resource,
struct wined3d_context_vk *  context_vk,
uint32_t  bind_mask 
)
inlinestatic

Definition at line 938 of file wined3d_vk.h.

940{
941 if (resource->type == WINED3D_RTYPE_BUFFER)
943 else
945}
void wined3d_texture_vk_barrier(struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
Definition: texture.c:5524
void wined3d_buffer_vk_barrier(struct wined3d_buffer_vk *buffer_vk, struct wined3d_context_vk *context_vk, uint32_t bind_mask)
Definition: buffer.c:1280

Referenced by wined3d_rendertarget_view_vk_barrier(), wined3d_shader_resource_view_vk_barrier(), and wined3d_unordered_access_view_vk_barrier().

◆ wined3d_sampler_vk()

static struct wined3d_sampler_vk * wined3d_sampler_vk ( struct wined3d_sampler *  sampler)
inlinestatic

Definition at line 909 of file wined3d_vk.h.

910{
912}
GLdouble s
Definition: gl.h:2039
GLuint sampler
Definition: glext.h:7283

◆ wined3d_sampler_vk_init()

void wined3d_sampler_vk_init ( struct wined3d_sampler_vk *  sampler_vk,
struct wined3d_device *  device,
const struct wined3d_sampler_desc *  desc,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 277 of file sampler.c.

279{
280 TRACE("sampler_vk %p, device %p, desc %p, parent %p, parent_ops %p.\n",
281 sampler_vk, device, desc, parent, parent_ops);
282
283 wined3d_sampler_init(&sampler_vk->s, device, desc, parent, parent_ops);
285}
static void wined3d_sampler_init(struct wined3d_sampler *sampler, struct wined3d_device *device, const struct wined3d_sampler_desc *desc, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: sampler.c:58
static void wined3d_sampler_vk_cs_init(void *object)
Definition: sampler.c:215
struct wined3d_sampler s
Definition: wined3d_vk.h:903

Referenced by adapter_vk_create_sampler().

◆ wined3d_shader_resource_view_vk()

◆ wined3d_shader_resource_view_vk_barrier()

static void wined3d_shader_resource_view_vk_barrier ( struct wined3d_shader_resource_view_vk *  srv_vk,
struct wined3d_context_vk *  context_vk,
uint32_t  bind_mask 
)
inlinestatic

Definition at line 1006 of file wined3d_vk.h.

1008{
1009 wined3d_resource_vk_barrier(srv_vk->v.resource, context_vk, bind_mask);
1010}

Referenced by wined3d_context_vk_load_shader_resources().

◆ wined3d_shader_resource_view_vk_generate_mipmap()

void wined3d_shader_resource_view_vk_generate_mipmap ( struct wined3d_shader_resource_view_vk *  srv_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1382 of file view.c.

1384{
1385 unsigned int i, j, layer_count, level_count, base_level, base_layer, sub_resource_idx;
1386 const struct wined3d_vk_info *vk_info = context_vk->vk_info;
1387 VkImageSubresourceRange vk_src_range, vk_dst_range;
1388 struct wined3d_texture_vk *texture_vk;
1389 VkCommandBuffer vk_command_buffer;
1391
1392 TRACE("srv_vk %p.\n", srv_vk);
1393
1394 layer_count = srv_vk->v.desc.u.texture.layer_count;
1395 level_count = srv_vk->v.desc.u.texture.level_count;
1396 base_level = srv_vk->v.desc.u.texture.level_idx;
1397 base_layer = srv_vk->v.desc.u.texture.layer_idx;
1398
1399 texture_vk = wined3d_texture_vk(texture_from_resource(srv_vk->v.resource));
1400 for (i = 0; i < layer_count; ++i)
1401 {
1402 sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level;
1403 if (!wined3d_texture_load_location(&texture_vk->t, sub_resource_idx,
1404 &context_vk->c, WINED3D_LOCATION_TEXTURE_RGB))
1405 ERR("Failed to load source layer %u.\n", base_layer + i);
1406 }
1407
1408 if (context_vk->c.d3d_info->wined3d_creation_flags & WINED3D_SRGB_READ_WRITE_CONTROL)
1409 FIXME("Unhandled sRGB read/write control.\n");
1410
1411 if (wined3d_format_vk(srv_vk->v.format)->vk_format != wined3d_format_vk(texture_vk->t.resource.format)->vk_format)
1412 FIXME("Ignoring view format %s.\n", debug_d3dformat(srv_vk->v.format->id));
1413
1414 if (wined3d_resource_get_sample_count(&texture_vk->t.resource) > 1)
1415 FIXME("Unhandled multi-sampled resource.\n");
1416
1417 if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
1418 {
1419 ERR("Failed to get command buffer.\n");
1420 return;
1421 }
1422
1423 vk_src_range.aspectMask = vk_aspect_mask_from_format(texture_vk->t.resource.format);
1424 vk_src_range.baseMipLevel = base_level;
1425 vk_src_range.levelCount = 1;
1426 vk_src_range.baseArrayLayer = base_layer;
1427 vk_src_range.layerCount = layer_count;
1428
1429 vk_dst_range = vk_src_range;
1430 ++vk_dst_range.baseMipLevel;
1431
1432 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1434 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1437 texture_vk->image.vk_image, &vk_src_range);
1438 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1440 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1443 texture_vk->image.vk_image, &vk_dst_range);
1444
1445 region.srcSubresource.aspectMask = vk_src_range.aspectMask;
1446 region.srcSubresource.mipLevel = vk_src_range.baseMipLevel;
1447 region.srcSubresource.baseArrayLayer = vk_src_range.baseArrayLayer;
1448 region.srcSubresource.layerCount = vk_src_range.layerCount;
1449 region.srcOffsets[0].x = 0;
1450 region.srcOffsets[0].y = 0;
1451 region.srcOffsets[0].z = 0;
1452
1453 region.dstSubresource.aspectMask = vk_dst_range.aspectMask;
1454 region.dstSubresource.mipLevel = vk_dst_range.baseMipLevel;
1455 region.dstSubresource.baseArrayLayer = vk_dst_range.baseArrayLayer;
1456 region.dstSubresource.layerCount = vk_dst_range.layerCount;
1457 region.dstOffsets[0].x = 0;
1458 region.dstOffsets[0].y = 0;
1459 region.dstOffsets[0].z = 0;
1460
1461 for (i = 1; i < level_count; ++i)
1462 {
1463 region.srcOffsets[1].x = wined3d_texture_get_level_width(&texture_vk->t, vk_src_range.baseMipLevel);
1464 region.srcOffsets[1].y = wined3d_texture_get_level_height(&texture_vk->t, vk_src_range.baseMipLevel);
1465 region.srcOffsets[1].z = wined3d_texture_get_level_depth(&texture_vk->t, vk_src_range.baseMipLevel);
1466
1467 region.dstOffsets[1].x = wined3d_texture_get_level_width(&texture_vk->t, vk_dst_range.baseMipLevel);
1468 region.dstOffsets[1].y = wined3d_texture_get_level_height(&texture_vk->t, vk_dst_range.baseMipLevel);
1469 region.dstOffsets[1].z = wined3d_texture_get_level_depth(&texture_vk->t, vk_dst_range.baseMipLevel);
1470
1471 VK_CALL(vkCmdBlitImage(vk_command_buffer, texture_vk->image.vk_image, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL,
1473
1474 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1477 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1479 texture_vk->image.vk_image, &vk_src_range);
1480
1481 if (i == level_count - 1)
1482 {
1483 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1486 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1488 texture_vk->image.vk_image, &vk_dst_range);
1489 }
1490 else
1491 {
1492 region.srcSubresource.mipLevel = ++vk_src_range.baseMipLevel;
1493 region.dstSubresource.mipLevel = ++vk_dst_range.baseMipLevel;
1494
1495 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1499 texture_vk->image.vk_image, &vk_src_range);
1500 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
1502 vk_access_mask_from_bind_flags(texture_vk->t.resource.bind_flags),
1505 texture_vk->image.vk_image, &vk_dst_range);
1506 }
1507 }
1508
1509 for (i = 0; i < layer_count; ++i)
1510 {
1511 for (j = 1; j < level_count; ++j)
1512 {
1513 sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level + j;
1514 wined3d_texture_validate_location(&texture_vk->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
1515 wined3d_texture_invalidate_location(&texture_vk->t, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
1516 }
1517 }
1518
1519 wined3d_context_vk_reference_texture(context_vk, texture_vk);
1520}
void wined3d_context_vk_image_barrier(struct wined3d_context_vk *context_vk, VkCommandBuffer vk_command_buffer, VkPipelineStageFlags src_stage_mask, VkPipelineStageFlags dst_stage_mask, VkAccessFlags src_access_mask, VkAccessFlags dst_access_mask, VkImageLayout old_layout, VkImageLayout new_layout, VkImage image, const VkImageSubresourceRange *range)
Definition: context_vk.c:2022
void wined3d_texture_invalidate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:702
void wined3d_texture_validate_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, uint32_t location)
Definition: texture.c:678
BOOL wined3d_texture_load_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, uint32_t location)
Definition: texture.c:770
const char * debug_d3dformat(enum wined3d_format_id format_id)
Definition: utils.c:4605
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
if(dx< 0)
Definition: linetemp.h:194
VkFormat vk_format
Definition: wined3d_vk.h:1083
struct wined3d_texture t
Definition: wined3d_vk.h:875
enum VkImageLayout layout
Definition: wined3d_vk.h:878
@ VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL
Definition: vulkan.h:3457
@ VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL
Definition: vulkan.h:3458
void VKAPI_CALL vkCmdBlitImage(VkCommandBuffer commandBuffer, VkImage srcImage, VkImageLayout srcImageLayout, VkImage dstImage, VkImageLayout dstImageLayout, uint32_t regionCount, const VkImageBlit *pRegions, VkFilter filter)
@ VK_FILTER_LINEAR
Definition: vulkan.h:2808
#define WINED3D_SRGB_READ_WRITE_CONTROL
Definition: wined3d.h:1330
static unsigned int wined3d_texture_get_level_height(const struct wined3d_texture *texture, unsigned int level)
static unsigned int wined3d_texture_get_level_width(const struct wined3d_texture *texture, unsigned int level)
#define WINED3D_LOCATION_TEXTURE_RGB
static unsigned int wined3d_texture_get_level_depth(const struct wined3d_texture *texture, unsigned int level)
static VkImageAspectFlags vk_aspect_mask_from_format(const struct wined3d_format *format)
Definition: wined3d_vk.h:294

Referenced by adapter_vk_generate_mipmap().

◆ wined3d_shader_resource_view_vk_init()

HRESULT wined3d_shader_resource_view_vk_init ( struct wined3d_shader_resource_view_vk *  view_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 1243 of file view.c.

1246{
1247 HRESULT hr;
1248
1249 TRACE("view_vk %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
1250 view_vk, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
1251
1252 if (FAILED(hr = wined3d_shader_resource_view_init(&view_vk->v, desc, resource, parent, parent_ops)))
1253 return hr;
1254
1255 list_init(&view_vk->view_vk.bo_user.entry);
1257
1258 return hr;
1259}
static void wined3d_shader_resource_view_vk_cs_init(void *object)
Definition: view.c:1167
static HRESULT wined3d_shader_resource_view_init(struct wined3d_shader_resource_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: view.c:1098

Referenced by adapter_vk_create_shader_resource_view().

◆ wined3d_shader_resource_view_vk_update_buffer()

void wined3d_shader_resource_view_vk_update_buffer ( struct wined3d_shader_resource_view_vk *  view_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 1139 of file view.c.

1141{
1142 const struct wined3d_format_vk *view_format_vk = wined3d_format_vk(srv_vk->v.format);
1143 const struct wined3d_view_desc *desc = &srv_vk->v.desc;
1144 struct wined3d_resource *resource = srv_vk->v.resource;
1145 struct wined3d_view_vk *view_vk = &srv_vk->view_vk;
1146 struct wined3d_buffer_vk *buffer_vk;
1147 VkBufferView vk_buffer_view;
1148
1149 assert(!view_vk->bo_user.valid);
1150
1153 if ((vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, desc, buffer_vk, view_format_vk)))
1154 {
1155 view_vk->u.vk_buffer_view = vk_buffer_view;
1156 view_vk->bo_user.valid = true;
1157 list_add_head(&buffer_vk->b.buffer_object->users, &view_vk->bo_user.entry);
1158 }
1159}
static VkBufferView wined3d_view_vk_create_vk_buffer_view(struct wined3d_context_vk *context_vk, const struct wined3d_view_desc *desc, struct wined3d_buffer_vk *buffer_vk, const struct wined3d_format_vk *view_format_vk)
Definition: view.c:708
struct wined3d_bo_user bo_user
Definition: wined3d_vk.h:985
VkBufferView vk_buffer_view
Definition: wined3d_vk.h:988
union wined3d_view_vk::@365 u
uint64_t command_buffer_id
Definition: wined3d_vk.h:991

Referenced by wined3d_context_vk_load_shader_resources().

◆ wined3d_shader_resource_view_vk_update_layout()

void wined3d_shader_resource_view_vk_update_layout ( struct wined3d_shader_resource_view_vk *  srv_vk,
VkImageLayout  layout 
)

Definition at line 1161 of file view.c.

1163{
1164 srv_vk->view_vk.u.vk_image_info.imageLayout = layout;
1165}

Referenced by wined3d_shader_descriptor_writes_vk_add_srv_write().

◆ wined3d_swapchain_vk()

Definition at line 1068 of file wined3d_vk.h.

1069{
1070 return CONTAINING_RECORD(swapchain, struct wined3d_swapchain_vk, s);
1071}

◆ wined3d_swapchain_vk_cleanup()

void wined3d_swapchain_vk_cleanup ( struct wined3d_swapchain_vk *  swapchain_vk)

Definition at line 125 of file swapchain.c.

126{
127 struct wined3d_cs *cs = swapchain_vk->s.device->cs;
128
131
132 wined3d_swapchain_cleanup(&swapchain_vk->s);
133}
void wined3d_cs_destroy_object(struct wined3d_cs *cs, void(*callback)(void *object), void *object)
Definition: cs.c:2299
#define cs
Definition: i386-dis.c:442
struct wined3d_swapchain s
Definition: wined3d_vk.h:1053
static void wined3d_swapchain_vk_destroy_object(void *object)
Definition: swapchain.c:120
void wined3d_swapchain_cleanup(struct wined3d_swapchain *swapchain)
Definition: swapchain.c:30
static void wined3d_cs_finish(struct wined3d_cs *cs, enum wined3d_cs_queue_id queue_id)
@ WINED3D_CS_QUEUE_DEFAULT

Referenced by adapter_vk_destroy_swapchain().

◆ wined3d_swapchain_vk_init()

HRESULT wined3d_swapchain_vk_init ( struct wined3d_swapchain_vk *  swapchain_vk,
struct wined3d_device *  device,
const struct wined3d_swapchain_desc *  desc,
struct wined3d_swapchain_state_parent *  state_parent,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 1707 of file swapchain.c.

1710{
1711 HRESULT hr;
1712
1713 TRACE("swapchain_vk %p, device %p, desc %p, parent %p, parent_ops %p.\n",
1714 swapchain_vk, device, desc, parent, parent_ops);
1715
1716 if (FAILED(hr = wined3d_swapchain_init(&swapchain_vk->s, device, desc, state_parent, parent,
1717 parent_ops, &swapchain_vk_ops)))
1718 return hr;
1719
1720 if (swapchain_vk->s.win_handle == GetDesktopWindow())
1721 {
1722 WARN("Creating a desktop window swapchain.\n");
1723 return hr;
1724 }
1725
1727 WARN("Failed to create a Vulkan swapchain, hr %#lx.\n", hr);
1728
1729 return WINED3D_OK;
1730}
HWND WINAPI GetDesktopWindow(void)
Definition: window.c:628
static HRESULT wined3d_swapchain_vk_create_vulkan_swapchain(struct wined3d_swapchain_vk *swapchain_vk)
Definition: swapchain.c:866
static const struct wined3d_swapchain_ops swapchain_vk_ops
Definition: swapchain.c:1268
static HRESULT wined3d_swapchain_init(struct wined3d_swapchain *swapchain, struct wined3d_device *device, const struct wined3d_swapchain_desc *desc, struct wined3d_swapchain_state_parent *state_parent, void *parent, const struct wined3d_parent_ops *parent_ops, const struct wined3d_swapchain_ops *swapchain_ops)
Definition: swapchain.c:1506

Referenced by adapter_vk_create_swapchain().

◆ wined3d_texture_vk()

static struct wined3d_texture_vk * wined3d_texture_vk ( struct wined3d_texture *  texture)
inlinestatic

Definition at line 884 of file wined3d_vk.h.

885{
887}
GLdouble GLdouble t
Definition: gl.h:2047
GLenum GLuint texture
Definition: glext.h:6295

◆ wined3d_texture_vk_barrier()

void wined3d_texture_vk_barrier ( struct wined3d_texture_vk *  texture_vk,
struct wined3d_context_vk *  context_vk,
uint32_t  bind_mask 
)

Definition at line 5524 of file texture.c.

5526{
5527 enum VkImageLayout new_layout;
5528 uint32_t src_bind_mask = 0;
5529
5530 TRACE("texture_vk %p, context_vk %p, bind_mask %s.\n",
5531 texture_vk, context_vk, wined3d_debug_bind_flags(bind_mask));
5532
5533 new_layout = wined3d_layout_from_bind_mask(texture_vk, bind_mask);
5534
5535 /* A layout transition is potentially a read-write operation, so even if we
5536 * prepare the texture to e.g. read only shader resource mode, we have to wait
5537 * for past operations to finish. */
5538 if (bind_mask & ~WINED3D_READ_ONLY_BIND_MASK || new_layout != texture_vk->layout)
5539 {
5540 src_bind_mask = texture_vk->bind_mask & WINED3D_READ_ONLY_BIND_MASK;
5541 if (!src_bind_mask)
5542 src_bind_mask = texture_vk->bind_mask;
5543
5544 texture_vk->bind_mask = bind_mask;
5545 }
5546 else if ((texture_vk->bind_mask & bind_mask) != bind_mask)
5547 {
5548 src_bind_mask = texture_vk->bind_mask & ~WINED3D_READ_ONLY_BIND_MASK;
5549 texture_vk->bind_mask |= bind_mask;
5550 }
5551
5552 if (src_bind_mask)
5553 {
5554 VkImageSubresourceRange vk_range;
5555
5556 TRACE(" %s(%x) -> %s(%x).\n",
5557 wined3d_debug_bind_flags(src_bind_mask), texture_vk->layout,
5558 wined3d_debug_bind_flags(bind_mask), new_layout);
5559
5560 vk_range.aspectMask = vk_aspect_mask_from_format(texture_vk->t.resource.format);
5561 vk_range.baseMipLevel = 0;
5563 vk_range.baseArrayLayer = 0;
5565
5570 texture_vk->layout, new_layout, texture_vk->image.vk_image, &vk_range);
5571
5572 texture_vk->layout = new_layout;
5573 }
5574}
enum VkImageLayout wined3d_layout_from_bind_mask(const struct wined3d_texture_vk *texture_vk, const uint32_t bind_mask)
Definition: texture.c:5497
uint32_t bind_mask
Definition: wined3d_vk.h:879
VkImageLayout
Definition: vulkan.h:3450
#define VK_REMAINING_MIP_LEVELS
Definition: vulkan.h:50
#define VK_REMAINING_ARRAY_LAYERS
Definition: vulkan.h:51

Referenced by wined3d_resource_vk_barrier().

◆ wined3d_texture_vk_get_default_image_info()

const VkDescriptorImageInfo * wined3d_texture_vk_get_default_image_info ( struct wined3d_texture_vk *  texture_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 4601 of file texture.c.

4603{
4604 const struct wined3d_format_vk *format_vk;
4605 const struct wined3d_vk_info *vk_info;
4606 struct wined3d_device_vk *device_vk;
4607 VkImageViewCreateInfo create_info;
4608 struct color_fixup_desc fixup;
4609 uint32_t flags = 0;
4610 VkResult vr;
4611
4612 if (texture_vk->default_image_info.imageView)
4613 return &texture_vk->default_image_info;
4614
4615 format_vk = wined3d_format_vk(texture_vk->t.resource.format);
4616 device_vk = wined3d_device_vk(texture_vk->t.resource.device);
4617 vk_info = context_vk->vk_info;
4618
4619 if (texture_vk->t.layer_count > 1)
4621
4622 wined3d_texture_vk_prepare_texture(texture_vk, context_vk);
4624 create_info.pNext = NULL;
4625 create_info.flags = 0;
4626 create_info.image = texture_vk->image.vk_image;
4627 create_info.viewType = vk_image_view_type_from_wined3d(texture_vk->t.resource.type, flags);
4628 create_info.format = format_vk->vk_format;
4629 fixup = format_vk->f.color_fixup;
4630 if (is_identity_fixup(fixup) || !can_use_texture_swizzle(context_vk->c.d3d_info, &format_vk->f))
4631 {
4636 }
4637 else
4638 {
4640 }
4641 create_info.subresourceRange.aspectMask = vk_aspect_mask_from_format(&format_vk->f);
4642 create_info.subresourceRange.baseMipLevel = 0;
4643 create_info.subresourceRange.levelCount = texture_vk->t.level_count;
4644 create_info.subresourceRange.baseArrayLayer = 0;
4645 create_info.subresourceRange.layerCount = texture_vk->t.layer_count;
4646 if ((vr = VK_CALL(vkCreateImageView(device_vk->vk_device, &create_info,
4647 NULL, &texture_vk->default_image_info.imageView))) < 0)
4648 {
4649 ERR("Failed to create Vulkan image view, vr %s.\n", wined3d_debug_vkresult(vr));
4650 return NULL;
4651 }
4652
4653 TRACE("Created image view 0x%s.\n", wine_dbgstr_longlong(texture_vk->default_image_info.imageView));
4654
4655 texture_vk->default_image_info.sampler = VK_NULL_HANDLE;
4656
4657 /* The default image view is used for SRVs, UAVs and RTVs when the d3d view encompasses the entire
4658 * resource. Any UAV capable resource will always use VK_IMAGE_LAYOUT_GENERAL, so we can use the
4659 * same image info for SRVs and UAVs. For render targets wined3d_rendertarget_view_vk_get_image_view
4660 * only cares about the VkImageView, not entire image info. So using SHADER_READ_ONLY_OPTIMAL works,
4661 * but relies on what the callers of the function do and don't do with the descriptor we return.
4662 *
4663 * Note that VkWriteDescriptorSet for SRV/UAV use takes a VkDescriptorImageInfo *, so we need a
4664 * place to store the VkDescriptorImageInfo. So returning onlky a VkImageView from this function
4665 * would bring its own problems. */
4666 if (texture_vk->layout == VK_IMAGE_LAYOUT_GENERAL)
4668 else
4670
4671 return &texture_vk->default_image_info;
4672}
void wined3d_vk_swizzle_from_color_fixup(VkComponentMapping *mapping, struct color_fixup_desc fixup)
Definition: texture.c:4583
BOOL wined3d_texture_vk_prepare_texture(struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
Definition: texture.c:5244
VkImageViewType vk_image_view_type_from_wined3d(enum wined3d_resource_type type, uint32_t flags)
Definition: view.c:676
VkImageLayout imageLayout
Definition: vulkan.h:8266
struct wined3d_format f
Definition: wined3d_vk.h:1081
VkDescriptorImageInfo default_image_info
Definition: wined3d_vk.h:881
@ VK_IMAGE_LAYOUT_GENERAL
Definition: vulkan.h:3452
@ VK_COMPONENT_SWIZZLE_IDENTITY
Definition: vulkan.h:2188
static BOOL can_use_texture_swizzle(const struct wined3d_d3d_info *d3d_info, const struct wined3d_format *format)
static BOOL is_identity_fixup(struct color_fixup_desc fixup)

Referenced by wined3d_rendertarget_view_vk_get_image_view(), wined3d_shader_descriptor_writes_vk_add_srv_write(), wined3d_shader_descriptor_writes_vk_add_uav_write(), and wined3d_unordered_access_view_vk_clear().

◆ wined3d_texture_vk_init()

HRESULT wined3d_texture_vk_init ( struct wined3d_texture_vk *  texture_vk,
struct wined3d_device *  device,
const struct wined3d_resource_desc *  desc,
unsigned int  layer_count,
unsigned int  level_count,
uint32_t  flags,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 5484 of file texture.c.

5487{
5488 TRACE("texture_vk %p, device %p, desc %p, layer_count %u, "
5489 "level_count %u, flags %#x, parent %p, parent_ops %p.\n",
5490 texture_vk, device, desc, layer_count,
5491 level_count, flags, parent, parent_ops);
5492
5493 return wined3d_texture_init(&texture_vk->t, desc, layer_count, level_count,
5494 flags, device, parent, parent_ops, &texture_vk[1], &wined3d_texture_vk_ops);
5495}
static const struct wined3d_texture_ops wined3d_texture_vk_ops
Definition: texture.c:5475
static HRESULT wined3d_texture_init(struct wined3d_texture *texture, const struct wined3d_resource_desc *desc, unsigned int layer_count, unsigned int level_count, uint32_t flags, struct wined3d_device *device, void *parent, const struct wined3d_parent_ops *parent_ops, void *sub_resources, const struct wined3d_texture_ops *texture_ops)
Definition: texture.c:3620

Referenced by adapter_vk_create_texture().

◆ wined3d_texture_vk_make_generic()

void wined3d_texture_vk_make_generic ( struct wined3d_texture_vk *  texture_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 5581 of file texture.c.

5583{
5584 VkImageSubresourceRange vk_range;
5585
5586 if (texture_vk->layout == VK_IMAGE_LAYOUT_GENERAL)
5587 return;
5588
5589 vk_range.aspectMask = vk_aspect_mask_from_format(texture_vk->t.resource.format);
5590 vk_range.baseMipLevel = 0;
5592 vk_range.baseArrayLayer = 0;
5594
5598 0, 0,
5599 texture_vk->layout, VK_IMAGE_LAYOUT_GENERAL, texture_vk->image.vk_image, &vk_range);
5600
5601 texture_vk->layout = VK_IMAGE_LAYOUT_GENERAL;
5603}
@ VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT
Definition: vulkan.h:4285

Referenced by wined3d_context_vk_begin_render_pass().

◆ wined3d_texture_vk_prepare_texture()

BOOL wined3d_texture_vk_prepare_texture ( struct wined3d_texture_vk *  texture_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 5244 of file texture.c.

5246{
5247 const struct wined3d_format_vk *format_vk;
5248 struct wined3d_resource *resource;
5249 VkCommandBuffer vk_command_buffer;
5250 VkImageSubresourceRange vk_range;
5251 VkImageUsageFlags vk_usage;
5252 VkImageType vk_image_type;
5253 unsigned int flags = 0;
5254
5255 if (texture_vk->t.flags & WINED3D_TEXTURE_RGB_ALLOCATED)
5256 return TRUE;
5257
5258 if (!(vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk)))
5259 {
5260 ERR("Failed to get command buffer.\n");
5261 return FALSE;
5262 }
5263
5264 resource = &texture_vk->t.resource;
5265 format_vk = wined3d_format_vk(resource->format);
5266
5267 if (wined3d_format_is_typeless(&format_vk->f) || texture_vk->t.swapchain
5268 || (texture_vk->t.resource.bind_flags & WINED3D_BIND_UNORDERED_ACCESS))
5269 {
5270 /* For UAVs, we need this in case a clear necessitates creation of a new view
5271 * with a different format. */
5273 }
5274
5275 switch (resource->type)
5276 {
5278 vk_image_type = VK_IMAGE_TYPE_1D;
5279 break;
5281 vk_image_type = VK_IMAGE_TYPE_2D;
5282 if (texture_vk->t.layer_count >= 6 && resource->width == resource->height)
5284 break;
5286 vk_image_type = VK_IMAGE_TYPE_3D;
5289 break;
5290 default:
5291 ERR("Invalid resource type %s.\n", debug_d3dresourcetype(resource->type));
5292 vk_image_type = VK_IMAGE_TYPE_2D;
5293 break;
5294 }
5295
5297 if (resource->bind_flags & WINED3D_BIND_SHADER_RESOURCE)
5298 vk_usage |= VK_IMAGE_USAGE_SAMPLED_BIT;
5299 if (resource->bind_flags & WINED3D_BIND_RENDER_TARGET)
5301 if (resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
5303 if (resource->bind_flags & WINED3D_BIND_UNORDERED_ACCESS)
5304 vk_usage |= VK_IMAGE_USAGE_STORAGE_BIT;
5305
5306 if (resource->bind_flags & WINED3D_BIND_UNORDERED_ACCESS)
5307 texture_vk->layout = VK_IMAGE_LAYOUT_GENERAL;
5308 else if (resource->bind_flags & WINED3D_BIND_RENDER_TARGET)
5310 else if (resource->bind_flags & WINED3D_BIND_DEPTH_STENCIL)
5312 else if (resource->bind_flags & WINED3D_BIND_SHADER_RESOURCE)
5314 else
5315 {
5316 FIXME("unexpected bind flags %s, using VK_IMAGE_LAYOUT_GENERAL\n", wined3d_debug_bind_flags(resource->bind_flags));
5317 texture_vk->layout = VK_IMAGE_LAYOUT_GENERAL;
5318 }
5319
5320 if (!wined3d_context_vk_create_image(context_vk, vk_image_type, vk_usage, format_vk->vk_format,
5322 texture_vk->t.level_count, texture_vk->t.layer_count, flags, &texture_vk->image))
5323 {
5324 return FALSE;
5325 }
5326
5327 /* We can't use a zero src access mask without synchronization2. Set the last-used bind mask to something
5328 * non-zero to avoid this. */
5329 texture_vk->bind_mask = resource->bind_flags;
5330
5331 vk_range.aspectMask = vk_aspect_mask_from_format(&format_vk->f);
5332 vk_range.baseMipLevel = 0;
5334 vk_range.baseArrayLayer = 0;
5336
5337 wined3d_context_vk_reference_texture(context_vk, texture_vk);
5338 wined3d_context_vk_image_barrier(context_vk, vk_command_buffer,
5340 0, 0,
5341 VK_IMAGE_LAYOUT_UNDEFINED, texture_vk->layout,
5342 texture_vk->image.vk_image, &vk_range);
5343
5344 texture_vk->t.flags |= WINED3D_TEXTURE_RGB_ALLOCATED;
5345
5346 TRACE("Created image 0x%s, memory 0x%s for texture %p.\n",
5347 wine_dbgstr_longlong(texture_vk->image.vk_image), wine_dbgstr_longlong(texture_vk->image.vk_memory), texture_vk);
5348
5349 return TRUE;
5350}
BOOL wined3d_context_vk_create_image(struct wined3d_context_vk *context_vk, VkImageType vk_image_type, VkImageUsageFlags usage, VkFormat vk_format, unsigned int width, unsigned int height, unsigned int depth, unsigned int sample_count, unsigned int mip_levels, unsigned int layer_count, unsigned int flags, struct wined3d_image_vk *image)
Definition: context_vk.c:610
#define resource
Definition: kernel32.h:9
@ VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL
Definition: vulkan.h:3454
@ VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL
Definition: vulkan.h:3453
VkFlags VkImageUsageFlags
Definition: vulkan.h:1050
@ VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT
Definition: vulkan.h:3425
@ VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT
Definition: vulkan.h:3424
@ VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT
Definition: vulkan.h:3423
@ VK_IMAGE_USAGE_TRANSFER_DST_BIT
Definition: vulkan.h:3511
@ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
Definition: vulkan.h:3515
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan.h:3514
@ VK_IMAGE_USAGE_TRANSFER_SRC_BIT
Definition: vulkan.h:3510
@ VK_IMAGE_USAGE_STORAGE_BIT
Definition: vulkan.h:3513
VkImageType
Definition: vulkan.h:3501
@ VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT
Definition: vulkan.h:4272
static BOOL wined3d_format_is_typeless(const struct wined3d_format *format)
#define WINED3D_TEXTURE_RGB_ALLOCATED

Referenced by wined3d_texture_vk_get_default_image_info(), wined3d_texture_vk_prepare_location(), and wined3d_view_vk_create_vk_image_view().

◆ wined3d_unordered_access_view_vk()

◆ wined3d_unordered_access_view_vk_barrier()

static void wined3d_unordered_access_view_vk_barrier ( struct wined3d_unordered_access_view_vk *  uav_vk,
struct wined3d_context_vk *  context_vk,
uint32_t  bind_mask 
)
inlinestatic

Definition at line 1037 of file wined3d_vk.h.

1039{
1040 wined3d_resource_vk_barrier(uav_vk->v.resource, context_vk, bind_mask);
1041}

Referenced by wined3d_context_vk_load_shader_resources().

◆ wined3d_unordered_access_view_vk_clear()

void wined3d_unordered_access_view_vk_clear ( struct wined3d_unordered_access_view_vk *  view_vk,
const struct wined3d_uvec4 *  clear_value,
struct wined3d_context_vk *  context_vk,
bool  fp 
)

Definition at line 2077 of file view.c.

2079{
2080 struct wined3d_bo_address cb_source_address, cb_destination_address;
2081 const struct wined3d_format *view_format = view_vk->v.format;
2082 struct wined3d_view_desc *view_desc = &view_vk->v.desc;
2084 struct wined3d_device *device = context_vk->c.device;
2085 struct wined3d_shader_thread_group_size group_count;
2086 enum wined3d_format_id format_id = view_format->id;
2088 struct wined3d_texture_vk *texture_vk = NULL;
2089 struct wined3d_pipeline_layout_vk *layout;
2091 const struct wined3d_vk_info *vk_info;
2092 VkDescriptorImageInfo vk_image_info;
2093 struct wined3d_device_vk *device_vk;
2094 VkDescriptorBufferInfo buffer_info;
2095 struct wined3d_resource *resource;
2096 VkCommandBuffer vk_command_buffer;
2097 struct wined3d_bo_vk constants_bo;
2098 VkWriteDescriptorSet vk_writes[2];
2099 VkBufferView vk_buffer_view;
2100 struct wined3d_range range;
2101 VkMemoryBarrier vk_barrier;
2102 VkPipeline vk_pipeline;
2103 bool is_array;
2104
2105 device_vk = wined3d_device_vk(device);
2106 state = &device_vk->uav_clear_state;
2107 pipelines = fp ? &state->float_pipelines : &state->uint_pipelines;
2108
2109 resource = view_vk->v.resource;
2111
2112 switch (resource->type)
2113 {
2115 vk_pipeline = pipelines->buffer;
2116 group_count = state->buffer_group_size;
2117 break;
2119 if (is_array)
2120 {
2121 vk_pipeline = pipelines->image_1d_array;
2122 group_count = state->image_1d_array_group_size;
2123 }
2124 else
2125 {
2126 vk_pipeline = pipelines->image_1d;
2127 group_count = state->image_1d_group_size;
2128 }
2129 break;
2131 if (is_array)
2132 {
2133 vk_pipeline = pipelines->image_2d_array;
2134 group_count = state->image_2d_array_group_size;
2135 }
2136 else
2137 {
2138 vk_pipeline = pipelines->image_2d;
2139 group_count = state->image_2d_group_size;
2140 }
2141 break;
2143 vk_pipeline = pipelines->image_3d;
2144 group_count = state->image_3d_group_size;
2145 break;
2146
2147 default:
2148 ERR("Unhandled resource type %s.\n", debug_d3dresourcetype(resource->type));
2149 return;
2150 }
2151
2152 if (vk_pipeline == VK_NULL_HANDLE)
2153 {
2154 ERR("Pipeline was not correctly initialized.\n");
2155 return;
2156 }
2157
2158 vk_writes[0].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
2159 vk_writes[0].pNext = NULL;
2160 vk_writes[0].dstBinding = 1;
2161 vk_writes[0].dstArrayElement = 0;
2162 vk_writes[0].descriptorCount = 1;
2163 vk_writes[0].pImageInfo = NULL;
2164 vk_writes[0].pTexelBufferView = &vk_buffer_view;
2165 vk_writes[0].pImageInfo = &vk_image_info;
2166
2167 if (resource->type == WINED3D_RTYPE_BUFFER)
2168 {
2170 unsigned int offset, size;
2171
2172 layout = state->buffer_layout;
2173 vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER;
2174
2175 if (buffer->structure_byte_stride)
2176 constants.extent.width = view_desc->u.buffer.count * buffer->structure_byte_stride / 4;
2177 else
2178 constants.extent.width = view_desc->u.buffer.count;
2179 constants.extent.height = 1;
2180
2181 get_buffer_view_range(buffer, view_desc, view_format, &offset, &size);
2182 if (!offset && size == buffer->resource.size)
2183 {
2185 }
2186 else
2187 {
2190 }
2193 }
2194 else
2195 {
2196 unsigned int layer_count, level_count, base_level, base_layer, i, j;
2197
2199
2200 layout = state->image_layout;
2201 vk_writes[0].descriptorType = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE;
2202
2203 level_count = view_desc->u.texture.level_count;
2204 base_level = view_desc->u.texture.level_idx;
2206 {
2207 layer_count = 1;
2208 base_layer = 0;
2209 }
2210 else
2211 {
2212 layer_count = view_desc->u.texture.layer_count;
2213 base_layer = view_desc->u.texture.layer_idx;
2214 }
2215
2216 constants.extent.width = wined3d_texture_get_level_width(&texture_vk->t, base_level);
2217 constants.extent.height = wined3d_texture_get_level_height(&texture_vk->t, base_level);
2218 group_count.z = (view_desc->u.texture.layer_count + group_count.z - 1) / group_count.z;
2219
2220 for (i = 0; i < layer_count; ++i)
2221 {
2222 for (j = 0; j < level_count; ++j)
2223 {
2224 unsigned int sub_resource_idx = (base_layer + i) * texture_vk->t.level_count + base_level + j;
2225
2226 wined3d_texture_prepare_location(&texture_vk->t, sub_resource_idx,
2227 &context_vk->c, WINED3D_LOCATION_TEXTURE_RGB);
2228 wined3d_texture_validate_location(&texture_vk->t, sub_resource_idx, WINED3D_LOCATION_TEXTURE_RGB);
2229 wined3d_texture_invalidate_location(&texture_vk->t, sub_resource_idx, ~WINED3D_LOCATION_TEXTURE_RGB);
2230 }
2231 }
2232 }
2233
2234 group_count.x = (constants.extent.width + group_count.x - 1) / group_count.x;
2235 group_count.y = (constants.extent.height + group_count.y - 1) / group_count.y;
2236
2237 constants.color.uint32[0] = clear_value->x;
2238 constants.color.uint32[1] = clear_value->y;
2239 constants.color.uint32[2] = clear_value->z;
2240 constants.color.uint32[3] = clear_value->w;
2241
2242 if (!fp)
2243 {
2244 /* Make sure values are truncated, not saturated to some maximum value. */
2245 constants.color.uint32[0] &= wined3d_mask_from_size(view_format->red_size);
2246 constants.color.uint32[1] &= wined3d_mask_from_size(view_format->green_size);
2247 constants.color.uint32[2] &= wined3d_mask_from_size(view_format->blue_size);
2248 constants.color.uint32[3] &= wined3d_mask_from_size(view_format->alpha_size);
2249
2250 if (view_format->id == WINED3DFMT_R11G11B10_FLOAT)
2251 {
2252 constants.color.uint32[0] |= constants.color.uint32[1] << 11;
2253 constants.color.uint32[0] |= constants.color.uint32[2] << 22;
2255 }
2256 else
2257 {
2258 format_id = wined3d_get_typed_format_id(context_vk->c.device->adapter, view_format,
2260 }
2261 }
2262
2264 {
2265 ERR("Unsupported format %s.\n", debug_d3dformat(view_format->id));
2266 return;
2267 }
2268
2269 if (resource->type == WINED3D_RTYPE_BUFFER)
2270 {
2271 if (format_id == view_format->id)
2272 vk_buffer_view = view_vk->view_vk.u.vk_buffer_view;
2273 else
2274 {
2275 vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, view_desc,
2277 wined3d_get_format(context_vk->c.device->adapter, format_id, WINED3D_BIND_UNORDERED_ACCESS)));
2278 if (vk_buffer_view == VK_NULL_HANDLE)
2279 return;
2280 }
2281 }
2282 else
2283 {
2284 if (format_id == view_format->id)
2285 {
2286 vk_image_info = view_vk->view_vk.u.vk_image_info;
2287 if (!vk_image_info.imageView)
2288 {
2290 if (!(default_info = wined3d_texture_vk_get_default_image_info(texture_vk, context_vk)))
2291 return;
2292 vk_image_info = *default_info;
2293 }
2294 }
2295 else
2296 {
2297 vk_image_info.sampler = VK_NULL_HANDLE;
2298 vk_image_info.imageLayout = texture_vk->layout;
2299 vk_image_info.imageView = wined3d_view_vk_create_vk_image_view(context_vk, view_desc, texture_vk,
2300 wined3d_format_vk(wined3d_get_format(context_vk->c.device->adapter, format_id,
2303
2304 if (vk_image_info.imageView == VK_NULL_HANDLE)
2305 return;
2306 }
2307 }
2308
2309 vk_writes[1].sType = VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET;
2310 vk_writes[1].pNext = NULL;
2311 vk_writes[1].dstBinding = 0;
2312 vk_writes[1].dstArrayElement = 0;
2313 vk_writes[1].descriptorCount = 1;
2314 vk_writes[1].pImageInfo = NULL;
2315 vk_writes[1].pTexelBufferView = NULL;
2316 vk_writes[1].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
2317 vk_writes[1].pBufferInfo = &buffer_info;
2318
2321 {
2322 ERR("Failed to create constants BO.\n");
2323 goto out;
2324 }
2325
2326 cb_source_address.buffer_object = NULL;
2327 cb_source_address.addr = (BYTE *)&constants;
2328 cb_destination_address.buffer_object = &constants_bo.b;
2329 cb_destination_address.addr = 0;
2330
2331 range.offset = 0;
2332 range.size = sizeof(constants);
2333 adapter_vk_copy_bo_address(&context_vk->c, &cb_destination_address,
2334 &cb_source_address, 1, &range, WINED3D_MAP_WRITE | WINED3D_MAP_DISCARD);
2335
2336 buffer_info.buffer = constants_bo.vk_buffer;
2337 buffer_info.range = constants_bo.size;
2338 buffer_info.offset = constants_bo.b.buffer_offset;
2339
2340 vk_info = context_vk->vk_info;
2341
2342 if (!(vk_writes[0].dstSet = wined3d_context_vk_create_vk_descriptor_set(context_vk, layout->vk_set_layout)))
2343 {
2344 ERR("Failed to create descriptor set.\n");
2345 wined3d_context_vk_destroy_bo(context_vk, &constants_bo);
2346 goto out;
2347 }
2348
2349 vk_writes[1].dstSet = vk_writes[0].dstSet;
2350
2351 VK_CALL(vkUpdateDescriptorSets(device_vk->vk_device, 2, vk_writes, 0, NULL));
2352
2353 vk_command_buffer = wined3d_context_vk_get_command_buffer(context_vk);
2355
2357 wined3d_context_vk_reference_bo(context_vk, &constants_bo);
2358 wined3d_context_vk_destroy_bo(context_vk, &constants_bo);
2359
2360 vk_barrier.sType = VK_STRUCTURE_TYPE_MEMORY_BARRIER;
2361 vk_barrier.pNext = NULL;
2362 vk_barrier.srcAccessMask = vk_access_mask_from_bind_flags(resource->bind_flags);
2363 vk_barrier.dstAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
2364
2365 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer,
2368 0, 1, &vk_barrier, 0, NULL, 0, NULL));
2369 VK_CALL(vkCmdBindPipeline(vk_command_buffer, VK_PIPELINE_BIND_POINT_COMPUTE, vk_pipeline));
2371 layout->vk_pipeline_layout, 0, 1, &vk_writes[0].dstSet, 0, NULL));
2372 VK_CALL(vkCmdDispatch(vk_command_buffer, group_count.x, group_count.y, group_count.z));
2373
2374 vk_barrier.srcAccessMask = VK_ACCESS_SHADER_WRITE_BIT;
2375 vk_barrier.dstAccessMask = vk_access_mask_from_bind_flags(resource->bind_flags);
2376
2377 VK_CALL(vkCmdPipelineBarrier(vk_command_buffer,
2380 0, 1, &vk_barrier, 0, NULL, 0, NULL));
2381
2383
2384out:
2385 if (format_id != view_format->id)
2386 {
2387 if (resource->type == WINED3D_RTYPE_BUFFER)
2388 wined3d_context_vk_destroy_vk_buffer_view(context_vk, vk_buffer_view, view_vk->view_vk.command_buffer_id);
2389 else
2390 wined3d_context_vk_destroy_vk_image_view(context_vk, vk_image_info.imageView,
2391 view_vk->view_vk.command_buffer_id);
2392 }
2393}
VkDescriptorSet wined3d_context_vk_create_vk_descriptor_set(struct wined3d_context_vk *context_vk, VkDescriptorSetLayout vk_set_layout)
Definition: context_vk.c:3048
BOOL wined3d_buffer_prepare_location(struct wined3d_buffer *buffer, struct wined3d_context *context, unsigned int location)
Definition: buffer.c:257
void wined3d_buffer_acquire_bo_for_write(struct wined3d_buffer *buffer, struct wined3d_context *context)
Definition: buffer.c:750
void wined3d_buffer_invalidate_location(struct wined3d_buffer *buffer, uint32_t location)
Definition: buffer.c:131
void wined3d_buffer_validate_location(struct wined3d_buffer *buffer, uint32_t location)
Definition: buffer.c:102
void context_invalidate_compute_state(struct wined3d_context *context, DWORD state_id)
Definition: context.c:66
const VkDescriptorImageInfo * wined3d_texture_vk_get_default_image_info(struct wined3d_texture_vk *texture_vk, struct wined3d_context_vk *context_vk)
Definition: texture.c:4601
BOOL wined3d_texture_prepare_location(struct wined3d_texture *texture, unsigned int sub_resource_idx, struct wined3d_context *context, unsigned int location)
Definition: texture.c:2116
enum wined3d_format_id wined3d_get_typed_format_id(const struct wined3d_adapter *adapter, const struct wined3d_format *format, enum wined3d_channel_type channel_type)
Definition: utils.c:4460
static void get_buffer_view_range(const struct wined3d_buffer *buffer, const struct wined3d_view_desc *desc, const struct wined3d_format *view_format, unsigned int *offset, unsigned int *size)
Definition: view.c:291
static VkImageView wined3d_view_vk_create_vk_image_view(struct wined3d_context_vk *context_vk, const struct wined3d_view_desc *desc, struct wined3d_texture_vk *texture_vk, const struct wined3d_format_vk *view_format_vk, struct color_fixup_desc fixup, bool rtv, VkImageUsageFlags usage)
Definition: view.c:742
static struct @1920 default_info
const GLuint * pipelines
Definition: glext.h:7624
constants
Definition: resource.c:30
static UINT format_id
Definition: clipboard.c:1455
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
static int is_array(const type_t *t)
Definition: header.h:60
enum wined3d_format_id id
unsigned int y
Definition: wined3d.h:1660
unsigned int x
Definition: wined3d.h:1659
unsigned int w
Definition: wined3d.h:1662
unsigned int z
Definition: wined3d.h:1661
struct wined3d_view_desc::@4822::@4823 buffer
unsigned int flags
Definition: wined3d.h:2131
struct wined3d_view_desc::@4822::@4824 texture
union wined3d_view_desc::@4822 u
void VKAPI_CALL vkCmdBindDescriptorSets(VkCommandBuffer commandBuffer, VkPipelineBindPoint pipelineBindPoint, VkPipelineLayout layout, uint32_t firstSet, uint32_t descriptorSetCount, const VkDescriptorSet *pDescriptorSets, uint32_t dynamicOffsetCount, const uint32_t *pDynamicOffsets)
void VKAPI_CALL vkCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, uint32_t groupCountY, uint32_t groupCountZ)
void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies)
@ VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET
Definition: vulkan.h:4999
@ VK_STRUCTURE_TYPE_MEMORY_BARRIER
Definition: vulkan.h:5010
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
wined3d_format_id
Definition: wined3d.h:126
@ WINED3DFMT_UNKNOWN
Definition: wined3d.h:127
@ WINED3DFMT_R32_UINT
Definition: wined3d.h:199
@ WINED3DFMT_R11G11B10_FLOAT
Definition: wined3d.h:183
@ WINED3D_CHANNEL_TYPE_UINT
static const struct color_fixup_desc COLOR_FIXUP_IDENTITY
static void wined3d_context_vk_reference_unordered_access_view(const struct wined3d_context_vk *context_vk, struct wined3d_unordered_access_view_vk *uav_vk)
Definition: wined3d_vk.h:1144
unsigned char BYTE
Definition: xxhash.c:193

Referenced by adapter_vk_clear_uav().

◆ wined3d_unordered_access_view_vk_init()

HRESULT wined3d_unordered_access_view_vk_init ( struct wined3d_unordered_access_view_vk *  view_vk,
const struct wined3d_view_desc *  desc,
struct wined3d_resource *  resource,
void *  parent,
const struct wined3d_parent_ops *  parent_ops 
)

Definition at line 2533 of file view.c.

2536{
2537 HRESULT hr;
2538
2539 TRACE("view_vk %p, desc %s, resource %p, parent %p, parent_ops %p.\n",
2540 view_vk, wined3d_debug_view_desc(desc, resource), resource, parent, parent_ops);
2541
2542 if (FAILED(hr = wined3d_unordered_access_view_init(&view_vk->v, desc, resource, parent, parent_ops)))
2543 return hr;
2544
2545 list_init(&view_vk->view_vk.bo_user.entry);
2547
2548 return hr;
2549}
static void wined3d_unordered_access_view_vk_cs_init(void *object)
Definition: view.c:2417
static HRESULT wined3d_unordered_access_view_init(struct wined3d_unordered_access_view *view, const struct wined3d_view_desc *desc, struct wined3d_resource *resource, void *parent, const struct wined3d_parent_ops *parent_ops)
Definition: view.c:1814

Referenced by adapter_vk_create_unordered_access_view().

◆ wined3d_unordered_access_view_vk_update()

void wined3d_unordered_access_view_vk_update ( struct wined3d_unordered_access_view_vk *  view_vk,
struct wined3d_context_vk *  context_vk 
)

Definition at line 2395 of file view.c.

2397{
2398 const struct wined3d_format_vk *view_format_vk = wined3d_format_vk(uav_vk->v.format);
2399 const struct wined3d_view_desc *desc = &uav_vk->v.desc;
2400 struct wined3d_resource *resource = uav_vk->v.resource;
2401 struct wined3d_view_vk *view_vk = &uav_vk->view_vk;
2402 struct wined3d_buffer_vk *buffer_vk;
2403 VkBufferView vk_buffer_view;
2404
2405 assert(!view_vk->bo_user.valid);
2406
2409 if ((vk_buffer_view = wined3d_view_vk_create_vk_buffer_view(context_vk, desc, buffer_vk, view_format_vk)))
2410 {
2411 view_vk->u.vk_buffer_view = vk_buffer_view;
2412 view_vk->bo_user.valid = true;
2413 list_add_head(&buffer_vk->b.buffer_object->users, &view_vk->bo_user.entry);
2414 }
2415}

Referenced by wined3d_context_vk_load_shader_resources().

◆ wined3d_vk_swizzle_from_color_fixup()

void wined3d_vk_swizzle_from_color_fixup ( VkComponentMapping *  mapping,
struct color_fixup_desc  fixup 
)

Definition at line 4583 of file texture.c.

4584{
4585 static const VkComponentSwizzle swizzle_source[] =
4586 {
4587 VK_COMPONENT_SWIZZLE_ZERO, /* CHANNEL_SOURCE_ZERO */
4588 VK_COMPONENT_SWIZZLE_ONE, /* CHANNEL_SOURCE_ONE */
4589 VK_COMPONENT_SWIZZLE_R, /* CHANNEL_SOURCE_X */
4590 VK_COMPONENT_SWIZZLE_G, /* CHANNEL_SOURCE_Y */
4591 VK_COMPONENT_SWIZZLE_B, /* CHANNEL_SOURCE_Z */
4592 VK_COMPONENT_SWIZZLE_A, /* CHANNEL_SOURCE_W */
4593 };
4594
4595 mapping->r = swizzle_source[fixup.x_source];
4596 mapping->g = swizzle_source[fixup.y_source];
4597 mapping->b = swizzle_source[fixup.z_source];
4598 mapping->a = swizzle_source[fixup.w_source];
4599}
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
unsigned short x_source
unsigned short w_source
unsigned short y_source
unsigned short z_source
VkComponentSwizzle
Definition: vulkan.h:2187
@ VK_COMPONENT_SWIZZLE_G
Definition: vulkan.h:2192
@ VK_COMPONENT_SWIZZLE_B
Definition: vulkan.h:2193
@ VK_COMPONENT_SWIZZLE_ONE
Definition: vulkan.h:2190
@ VK_COMPONENT_SWIZZLE_A
Definition: vulkan.h:2194
@ VK_COMPONENT_SWIZZLE_R
Definition: vulkan.h:2191

Referenced by wined3d_texture_vk_get_default_image_info(), and wined3d_view_vk_create_vk_image_view().

Variable Documentation

◆ WINED3D_READ_ONLY_ACCESS_FLAGS