ReactOS 0.4.17-dev-923-g4c9a150
vkd3d_private.h File Reference
#include "vkd3d_common.h"
#include "vkd3d_blob.h"
#include "vkd3d_memory.h"
#include "vkd3d_utf8.h"
#include "wine/list.h"
#include "wine/rbtree.h"
#include "vkd3d.h"
#include "vkd3d_shader.h"
#include <inttypes.h>
#include <limits.h>
#include <stdbool.h>
#include "vulkan_procs.h"
Include dependency graph for vkd3d_private.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  vkd3d_vk_global_procs
 
struct  vkd3d_vk_instance_procs
 
struct  vkd3d_vk_device_procs
 
struct  vkd3d_device_descriptor_limits
 
struct  vkd3d_vulkan_info
 
struct  vkd3d_instance
 
union  vkd3d_thread_handle
 
struct  vkd3d_waiting_fence
 
struct  vkd3d_fence_worker
 
struct  vkd3d_gpu_va_allocation
 
struct  vkd3d_gpu_va_slab
 
struct  vkd3d_gpu_va_allocator
 
struct  vkd3d_render_pass_key
 
struct  vkd3d_render_pass_cache
 
struct  vkd3d_private_store
 
struct  vkd3d_private_data
 
struct  vkd3d_signaled_semaphore
 
struct  d3d12_fence
 
struct  d3d12_fence::vkd3d_waiting_event
 
struct  d3d12_heap
 
struct  vkd3d_tiled_region_extent
 
struct  vkd3d_subresource_tile_info
 
struct  d3d12_resource_tile_info
 
struct  d3d12_resource
 
struct  vkd3d_resource_allocation_info
 
struct  vkd3d_resource_view
 
struct  vkd3d_texture_view_desc
 
struct  vkd3d_desc_header
 
struct  vkd3d_view
 
struct  vkd3d_cbuffer_desc
 
struct  d3d12_desc
 
struct  d3d12_rtv_desc
 
struct  d3d12_dsv_desc
 
struct  vkd3d_vk_descriptor_heap_layout
 
struct  d3d12_descriptor_heap_vk_set
 
struct  d3d12_descriptor_heap
 
struct  d3d12_query_heap
 
struct  d3d12_root_descriptor_table_range
 
struct  d3d12_root_descriptor_table
 
struct  d3d12_root_constant
 
struct  d3d12_root_descriptor
 
struct  d3d12_root_parameter
 
struct  d3d12_descriptor_set_layout
 
struct  d3d12_root_signature
 
struct  d3d12_graphics_pipeline_state
 
struct  d3d12_compute_pipeline_state
 
struct  d3d12_pipeline_uav_counter_state
 
struct  d3d12_pipeline_state
 
struct  d3d12_pipeline_state_desc
 
struct  vkd3d_buffer
 
struct  d3d12_command_allocator
 
struct  vkd3d_push_descriptor
 
struct  vkd3d_pipeline_bindings
 
struct  d3d12_command_list
 
struct  vkd3d_queue
 
struct  vkd3d_cs_wait
 
struct  vkd3d_cs_signal
 
struct  vkd3d_cs_execute
 
struct  vkd3d_cs_update_mappings
 
struct  vkd3d_cs_copy_mappings
 
struct  vkd3d_cs_op_data
 
struct  d3d12_command_queue_op_array
 
struct  d3d12_command_queue
 
struct  d3d12_command_signature
 
struct  vkd3d_null_resources
 
struct  vkd3d_format_compatibility_list
 
struct  vkd3d_uav_clear_args
 
struct  vkd3d_uav_clear_pipelines
 
struct  vkd3d_uav_clear_state
 
struct  desc_object_cache_head
 
struct  vkd3d_desc_object_cache
 
struct  d3d12_device
 
struct  vkd3d_format
 

Macros

#define WIDL_C_INLINE_WRAPPERS
 
#define COBJMACROS
 
#define NONAMELESSUNION
 
#define VK_NO_PROTOTYPES
 
#define CONST_VTABLE
 
#define VK_CALL(f)   (vk_procs->f)
 
#define VKD3D_DESCRIPTOR_MAGIC_FREE   0x00000000u
 
#define VKD3D_DESCRIPTOR_MAGIC_CBV   VKD3D_MAKE_TAG('C', 'B', 'V', 0)
 
#define VKD3D_DESCRIPTOR_MAGIC_SRV   VKD3D_MAKE_TAG('S', 'R', 'V', 0)
 
#define VKD3D_DESCRIPTOR_MAGIC_UAV   VKD3D_MAKE_TAG('U', 'A', 'V', 0)
 
#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER   VKD3D_MAKE_TAG('S', 'M', 'P', 0)
 
#define VKD3D_DESCRIPTOR_MAGIC_DSV   VKD3D_MAKE_TAG('D', 'S', 'V', 0)
 
#define VKD3D_DESCRIPTOR_MAGIC_RTV   VKD3D_MAKE_TAG('R', 'T', 'V', 0)
 
#define VKD3D_MAX_COMPATIBLE_FORMAT_COUNT   6u
 
#define VKD3D_MAX_QUEUE_FAMILY_COUNT   3u
 
#define VKD3D_MAX_SHADER_EXTENSIONS   5u
 
#define VKD3D_MAX_SHADER_STAGES   5u
 
#define VKD3D_MAX_VK_SYNC_OBJECTS   4u
 
#define VKD3D_MAX_DEVICE_BLOCKED_QUEUES   16u
 
#define VKD3D_MAX_DESCRIPTOR_SETS   64u
 
#define VKD3D_MAX_DESCRIPTOR_SET_SAMPLERS   2048u
 
#define VKD3D_MAX_VIRTUAL_HEAP_DESCRIPTORS_PER_TYPE   (16 * 1024u)
 
#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_INSTANCE_PFN   DECLARE_VK_PFN
 
#define VK_DEVICE_PFN   DECLARE_VK_PFN
 
#define VK_DEVICE_EXT_PFN   DECLARE_VK_PFN
 
#define VKD3D_RESOURCE_PUBLIC_FLAGS    (VKD3D_RESOURCE_INITIAL_STATE_TRANSITION | VKD3D_RESOURCE_PRESENT_STATE_TRANSITION)
 
#define VKD3D_RESOURCE_EXTERNAL   0x00000004
 
#define VKD3D_RESOURCE_DEDICATED_HEAP   0x00000008
 
#define VKD3D_RESOURCE_LINEAR_TILING   0x00000010
 
#define VKD3D_DESCRIPTOR_POOL_COUNT   6
 

Enumerations

enum  vkd3d_config_flags { VKD3D_CONFIG_FLAG_VULKAN_DEBUG = 0x00000001 , VKD3D_CONFIG_FLAG_VIRTUAL_HEAPS = 0x00000002 }
 
enum  vkd3d_view_type { VKD3D_VIEW_TYPE_BUFFER , VKD3D_VIEW_TYPE_IMAGE , VKD3D_VIEW_TYPE_SAMPLER }
 
enum  vkd3d_vk_descriptor_set_index {
  VKD3D_SET_INDEX_SAMPLER , VKD3D_SET_INDEX_UAV_COUNTER , VKD3D_SET_INDEX_MUTABLE , VKD3D_SET_INDEX_UNIFORM_BUFFER = VKD3D_SET_INDEX_MUTABLE ,
  VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER , VKD3D_SET_INDEX_SAMPLED_IMAGE , VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER , VKD3D_SET_INDEX_STORAGE_IMAGE ,
  VKD3D_SET_INDEX_COUNT
}
 
enum  vkd3d_pipeline_bind_point { VKD3D_PIPELINE_BIND_POINT_GRAPHICS = 0x0 , VKD3D_PIPELINE_BIND_POINT_COMPUTE = 0x1 , VKD3D_PIPELINE_BIND_POINT_COUNT = 0x2 }
 
enum  vkd3d_cs_op {
  VKD3D_CS_OP_WAIT , VKD3D_CS_OP_SIGNAL , VKD3D_CS_OP_EXECUTE , VKD3D_CS_OP_UPDATE_MAPPINGS ,
  VKD3D_CS_OP_COPY_MAPPINGS
}
 
enum  vkd3d_format_type { VKD3D_FORMAT_TYPE_OTHER , VKD3D_FORMAT_TYPE_TYPELESS , VKD3D_FORMAT_TYPE_SINT , VKD3D_FORMAT_TYPE_UINT }
 

Functions

HRESULT hresult_from_errno (int rc)
 
HRESULT hresult_from_vk_result (VkResult vr)
 
HRESULT hresult_from_vkd3d_result (int vkd3d_result)
 
HRESULT vkd3d_create_thread (struct vkd3d_instance *instance, PFN_vkd3d_thread thread_main, void *data, union vkd3d_thread_handle *thread)
 
HRESULT vkd3d_join_thread (struct vkd3d_instance *instance, union vkd3d_thread_handle *thread)
 
D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate (struct vkd3d_gpu_va_allocator *allocator, size_t alignment, uint64_t size, void *ptr)
 
void * vkd3d_gpu_va_allocator_dereference (struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
 
void vkd3d_gpu_va_allocator_free (struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
 
void vkd3d_render_pass_cache_cleanup (struct vkd3d_render_pass_cache *cache, struct d3d12_device *device)
 
HRESULT vkd3d_render_pass_cache_find (struct vkd3d_render_pass_cache *cache, struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass)
 
void vkd3d_render_pass_cache_init (struct vkd3d_render_pass_cache *cache)
 
static void vkd3d_private_data_destroy (struct vkd3d_private_data *data)
 
static HRESULT vkd3d_private_store_init (struct vkd3d_private_store *store)
 
static void vkd3d_private_store_destroy (struct vkd3d_private_store *store)
 
HRESULT vkd3d_get_private_data (struct vkd3d_private_store *store, const GUID *tag, unsigned int *out_size, void *out)
 
HRESULT vkd3d_set_private_data (struct vkd3d_private_store *store, const GUID *tag, unsigned int data_size, const void *data)
 
HRESULT vkd3d_set_private_data_interface (struct vkd3d_private_store *store, const GUID *tag, const IUnknown *object)
 
HRESULT d3d12_fence_create (struct d3d12_device *device, uint64_t initial_value, D3D12_FENCE_FLAGS flags, struct d3d12_fence **fence)
 
VkResult vkd3d_create_timeline_semaphore (const struct d3d12_device *device, uint64_t initial_value, VkSemaphore *timeline_semaphore)
 
HRESULT d3d12_heap_create (struct d3d12_device *device, const D3D12_HEAP_DESC *desc, const struct d3d12_resource *resource, ID3D12ProtectedResourceSession *protected_session, struct d3d12_heap **heap)
 
struct d3d12_heap * unsafe_impl_from_ID3D12Heap (ID3D12Heap *iface)
 
static struct d3d12_resource * impl_from_ID3D12Resource (ID3D12Resource *iface)
 
static struct d3d12_resource * impl_from_ID3D12Resource2 (ID3D12Resource2 *iface)
 
static bool d3d12_resource_is_buffer (const struct d3d12_resource *resource)
 
static bool d3d12_resource_is_texture (const struct d3d12_resource *resource)
 
bool d3d12_resource_is_cpu_accessible (const struct d3d12_resource *resource)
 
HRESULT d3d12_resource_validate_desc (const D3D12_RESOURCE_DESC1 *desc, struct d3d12_device *device)
 
void d3d12_resource_get_tiling (struct d3d12_device *device, const struct d3d12_resource *resource, UINT *total_tile_count, D3D12_PACKED_MIP_INFO *packed_mip_info, D3D12_TILE_SHAPE *standard_tile_shape, UINT *sub_resource_tiling_count, UINT first_sub_resource_tiling, D3D12_SUBRESOURCE_TILING *sub_resource_tilings)
 
HRESULT d3d12_committed_resource_create (struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, ID3D12ProtectedResourceSession *protected_session, struct d3d12_resource **resource)
 
HRESULT d3d12_placed_resource_create (struct d3d12_device *device, struct d3d12_heap *heap, uint64_t heap_offset, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
 
HRESULT d3d12_reserved_resource_create (struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
 
struct d3d12_resource * unsafe_impl_from_ID3D12Resource (ID3D12Resource *iface)
 
static void d3d12_resource_desc1_from_desc (D3D12_RESOURCE_DESC1 *desc1, const D3D12_RESOURCE_DESC *desc)
 
HRESULT vkd3d_allocate_buffer_memory (struct d3d12_device *device, VkBuffer vk_buffer, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size)
 
HRESULT vkd3d_create_buffer (struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer)
 
HRESULT vkd3d_get_image_allocation_info (struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, struct vkd3d_resource_allocation_info *allocation_info)
 
bool vkd3d_create_buffer_view (struct d3d12_device *device, uint32_t magic, VkBuffer vk_buffer, const struct vkd3d_format *format, VkDeviceSize offset, VkDeviceSize size, struct vkd3d_view **view)
 
bool vkd3d_create_texture_view (struct d3d12_device *device, uint32_t magic, VkImage vk_image, const struct vkd3d_texture_view_desc *desc, struct vkd3d_view **view)
 
void vkd3d_view_decref (void *view, struct d3d12_device *device)
 
static bool vkd3d_view_incref (void *desc)
 
static void * d3d12_desc_get_object_ref (const volatile struct d3d12_desc *src, struct d3d12_device *device)
 
static struct d3d12_desc * d3d12_desc_from_cpu_handle (D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)
 
static struct d3d12_desc * d3d12_desc_from_gpu_handle (D3D12_GPU_DESCRIPTOR_HANDLE gpu_handle)
 
static void d3d12_desc_copy_raw (struct d3d12_desc *dst, const struct d3d12_desc *src)
 
void d3d12_desc_copy (struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_descriptor_heap *dst_heap, struct d3d12_device *device)
 
void d3d12_desc_create_cbv (struct d3d12_desc *descriptor, struct d3d12_device *device, const D3D12_CONSTANT_BUFFER_VIEW_DESC *desc)
 
void d3d12_desc_create_srv (struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_SHADER_RESOURCE_VIEW_DESC *desc)
 
void d3d12_desc_create_uav (struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, struct d3d12_resource *counter_resource, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
 
void d3d12_desc_create_sampler (struct d3d12_desc *sampler, struct d3d12_device *device, const D3D12_SAMPLER_DESC *desc)
 
void d3d12_desc_write_atomic (struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_device *device)
 
bool vkd3d_create_raw_buffer_view (struct d3d12_device *device, D3D12_GPU_VIRTUAL_ADDRESS gpu_address, D3D12_ROOT_PARAMETER_TYPE parameter_type, VkBufferView *vk_buffer_view)
 
HRESULT vkd3d_create_static_sampler (struct d3d12_device *device, const D3D12_STATIC_SAMPLER_DESC *desc, VkSampler *vk_sampler)
 
static struct d3d12_rtv_desc * d3d12_rtv_desc_from_cpu_handle (D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)
 
void d3d12_rtv_desc_create_rtv (struct d3d12_rtv_desc *rtv_desc, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_RENDER_TARGET_VIEW_DESC *desc)
 
static struct d3d12_dsv_desc * d3d12_dsv_desc_from_cpu_handle (D3D12_CPU_DESCRIPTOR_HANDLE cpu_handle)
 
void d3d12_dsv_desc_create_dsv (struct d3d12_dsv_desc *dsv_desc, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_DEPTH_STENCIL_VIEW_DESC *desc)
 
static enum vkd3d_vk_descriptor_set_index vkd3d_vk_descriptor_set_index_from_vk_descriptor_type (VkDescriptorType type)
 
void d3d12_desc_flush_vk_heap_updates_locked (struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device)
 
static struct d3d12_descriptor_heap * d3d12_desc_get_descriptor_heap (const struct d3d12_desc *descriptor)
 
static unsigned int d3d12_desc_heap_range_size (const struct d3d12_desc *descriptor)
 
HRESULT d3d12_descriptor_heap_create (struct d3d12_device *device, const D3D12_DESCRIPTOR_HEAP_DESC *desc, struct d3d12_descriptor_heap **descriptor_heap)
 
HRESULT d3d12_query_heap_create (struct d3d12_device *device, const D3D12_QUERY_HEAP_DESC *desc, struct d3d12_query_heap **heap)
 
struct d3d12_query_heap * unsafe_impl_from_ID3D12QueryHeap (ID3D12QueryHeap *iface)
 
static bool d3d12_query_heap_is_result_available (const struct d3d12_query_heap *heap, unsigned int query_index)
 
static void d3d12_query_heap_mark_result_as_available (struct d3d12_query_heap *heap, unsigned int query_index)
 
HRESULT d3d12_root_signature_create (struct d3d12_device *device, const void *bytecode, size_t bytecode_length, struct d3d12_root_signature **root_signature)
 
struct d3d12_root_signature * unsafe_impl_from_ID3D12RootSignature (ID3D12RootSignature *iface)
 
int vkd3d_parse_root_signature_v_1_0 (const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_versioned_root_signature_desc *desc)
 
static unsigned int dsv_attachment_mask (const struct d3d12_graphics_pipeline_state *graphics)
 
static bool d3d12_pipeline_state_is_compute (const struct d3d12_pipeline_state *state)
 
static bool d3d12_pipeline_state_is_graphics (const struct d3d12_pipeline_state *state)
 
static bool d3d12_pipeline_state_has_unknown_dsv_format (struct d3d12_pipeline_state *state)
 
HRESULT d3d12_pipeline_state_create_compute (struct d3d12_device *device, const D3D12_COMPUTE_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state)
 
HRESULT d3d12_pipeline_state_create_graphics (struct d3d12_device *device, const D3D12_GRAPHICS_PIPELINE_STATE_DESC *desc, struct d3d12_pipeline_state **state)
 
HRESULT d3d12_pipeline_state_create (struct d3d12_device *device, const D3D12_PIPELINE_STATE_STREAM_DESC *desc, struct d3d12_pipeline_state **state)
 
VkPipeline d3d12_pipeline_state_get_or_create_pipeline (struct d3d12_pipeline_state *state, D3D12_PRIMITIVE_TOPOLOGY topology, const uint32_t *strides, VkFormat dsv_format, VkRenderPass *vk_render_pass)
 
struct d3d12_pipeline_state * unsafe_impl_from_ID3D12PipelineState (ID3D12PipelineState *iface)
 
HRESULT d3d12_command_allocator_create (struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator **allocator)
 
HRESULT d3d12_command_list_create (struct d3d12_device *device, UINT node_mask, D3D12_COMMAND_LIST_TYPE type, ID3D12CommandAllocator *allocator_iface, ID3D12PipelineState *initial_pipeline_state, struct d3d12_command_list **list)
 
VkQueue vkd3d_queue_acquire (struct vkd3d_queue *queue)
 
HRESULT vkd3d_queue_create (struct d3d12_device *device, uint32_t family_index, const VkQueueFamilyProperties *properties, struct vkd3d_queue **queue)
 
void vkd3d_queue_destroy (struct vkd3d_queue *queue, struct d3d12_device *device)
 
void vkd3d_queue_release (struct vkd3d_queue *queue)
 
HRESULT d3d12_command_queue_create (struct d3d12_device *device, const D3D12_COMMAND_QUEUE_DESC *desc, struct d3d12_command_queue **queue)
 
HRESULT d3d12_command_signature_create (struct d3d12_device *device, const D3D12_COMMAND_SIGNATURE_DESC *desc, struct d3d12_command_signature **signature)
 
struct d3d12_command_signature * unsafe_impl_from_ID3D12CommandSignature (ID3D12CommandSignature *iface)
 
HRESULT vkd3d_init_null_resources (struct vkd3d_null_resources *null_resources, struct d3d12_device *device)
 
void vkd3d_destroy_null_resources (struct vkd3d_null_resources *null_resources, struct d3d12_device *device)
 
HRESULT vkd3d_uav_clear_state_init (struct vkd3d_uav_clear_state *state, struct d3d12_device *device)
 
void vkd3d_uav_clear_state_cleanup (struct vkd3d_uav_clear_state *state, struct d3d12_device *device)
 
HRESULT d3d12_device_create (struct vkd3d_instance *instance, const struct vkd3d_device_create_info *create_info, struct d3d12_device **device)
 
struct vkd3d_queue * d3d12_device_get_vkd3d_queue (struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type)
 
bool d3d12_device_is_uma (struct d3d12_device *device, bool *coherent)
 
void d3d12_device_mark_as_removed (struct d3d12_device *device, HRESULT reason, const char *message,...) VKD3D_PRINTF_FUNC(3
 
void struct d3d12_device * unsafe_impl_from_ID3D12Device9 (ID3D12Device9 *iface)
 
HRESULT d3d12_device_add_descriptor_heap (struct d3d12_device *device, struct d3d12_descriptor_heap *heap)
 
void d3d12_device_remove_descriptor_heap (struct d3d12_device *device, struct d3d12_descriptor_heap *heap)
 
static HRESULT d3d12_device_query_interface (struct d3d12_device *device, REFIID iid, void **object)
 
static ULONG d3d12_device_add_ref (struct d3d12_device *device)
 
static ULONG d3d12_device_release (struct d3d12_device *device)
 
static unsigned int d3d12_device_get_descriptor_handle_increment_size (struct d3d12_device *device, D3D12_DESCRIPTOR_HEAP_TYPE descriptor_type)
 
static size_t vkd3d_format_get_data_offset (const struct vkd3d_format *format, unsigned int row_pitch, unsigned int slice_pitch, unsigned int x, unsigned int y, unsigned int z)
 
static bool vkd3d_format_is_compressed (const struct vkd3d_format *format)
 
void vkd3d_format_copy_data (const struct vkd3d_format *format, const uint8_t *src, unsigned int src_row_pitch, unsigned int src_slice_pitch, uint8_t *dst, unsigned int dst_row_pitch, unsigned int dst_slice_pitch, unsigned int w, unsigned int h, unsigned int d)
 
const struct vkd3d_format * vkd3d_get_format (const struct d3d12_device *device, DXGI_FORMAT dxgi_format, bool depth_stencil)
 
const struct vkd3d_format * vkd3d_find_uint_format (const struct d3d12_device *device, DXGI_FORMAT dxgi_format)
 
HRESULT vkd3d_init_format_info (struct d3d12_device *device)
 
void vkd3d_cleanup_format_info (struct d3d12_device *device)
 
static const struct vkd3d_format * vkd3d_format_from_d3d12_resource_desc (const struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, DXGI_FORMAT view_format)
 
static bool d3d12_box_is_empty (const D3D12_BOX *box)
 
static unsigned int d3d12_resource_desc_get_width (const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
 
static unsigned int d3d12_resource_desc_get_height (const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
 
static unsigned int d3d12_resource_desc_get_depth (const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
 
static unsigned int d3d12_resource_desc_get_layer_count (const D3D12_RESOURCE_DESC1 *desc)
 
static unsigned int d3d12_resource_desc_get_sub_resource_count (const D3D12_RESOURCE_DESC1 *desc)
 
static unsigned int vkd3d_compute_workgroup_count (unsigned int thread_count, unsigned int workgroup_size)
 
VkCompareOp vk_compare_op_from_d3d12 (D3D12_COMPARISON_FUNC op)
 
VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc (const DXGI_SAMPLE_DESC *desc)
 
VkSampleCountFlagBits vk_samples_from_sample_count (unsigned int sample_count)
 
bool is_valid_feature_level (D3D_FEATURE_LEVEL feature_level)
 
bool is_valid_resource_state (D3D12_RESOURCE_STATES state)
 
bool is_write_resource_state (D3D12_RESOURCE_STATES state)
 
HRESULT return_interface (void *iface, REFIID iface_iid, REFIID requested_iid, void **object)
 
const char * debug_cpu_handle (D3D12_CPU_DESCRIPTOR_HANDLE handle)
 
const char * debug_d3d12_box (const D3D12_BOX *box)
 
const char * debug_d3d12_shader_component_mapping (unsigned int mapping)
 
const char * debug_gpu_handle (D3D12_GPU_DESCRIPTOR_HANDLE handle)
 
const char * debug_vk_extent_3d (VkExtent3D extent)
 
const char * debug_vk_memory_heap_flags (VkMemoryHeapFlags flags)
 
const char * debug_vk_memory_property_flags (VkMemoryPropertyFlags flags)
 
const char * debug_vk_queue_flags (VkQueueFlags flags)
 
static void debug_ignored_node_mask (unsigned int mask)
 
HRESULT vkd3d_load_vk_global_procs (struct vkd3d_vk_global_procs *procs, PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr)
 
HRESULT vkd3d_load_vk_instance_procs (struct vkd3d_vk_instance_procs *procs, const struct vkd3d_vk_global_procs *global_procs, VkInstance instance)
 
HRESULT vkd3d_load_vk_device_procs (struct vkd3d_vk_device_procs *procs, const struct vkd3d_vk_instance_procs *parent_procs, VkDevice device)
 
bool vkd3d_get_program_name (char program_name[PATH_MAX])
 
VkResult vkd3d_set_vk_object_name_utf8 (struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const char *name)
 
HRESULT vkd3d_set_vk_object_name (struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const WCHAR *name)
 
static void vk_prepend_struct (void *header, void *structure)
 
static void vkd3d_prepend_struct (void *header, void *structure)
 
int vkd3d_shader_open_cache (struct vkd3d_shader_cache **cache)
 
unsigned int vkd3d_shader_cache_incref (struct vkd3d_shader_cache *cache)
 
unsigned int vkd3d_shader_cache_decref (struct vkd3d_shader_cache *cache)
 
int vkd3d_shader_cache_put (struct vkd3d_shader_cache *cache, const void *key, size_t key_size, const void *value, size_t value_size)
 
int vkd3d_shader_cache_get (struct vkd3d_shader_cache *cache, const void *key, size_t key_size, void *value, size_t *value_size)
 

Variables

uint64_t object_global_serial_id
 
enum vkd3d_vk_descriptor_set_index vk_descriptor_set_index_table []
 
const char vkd3d_build []
 

Macro Definition Documentation

◆ COBJMACROS

#define COBJMACROS

Definition at line 25 of file vkd3d_private.h.

◆ CONST_VTABLE

#define CONST_VTABLE

Definition at line 28 of file vkd3d_private.h.

◆ DECLARE_VK_PFN

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

Definition at line 81 of file vkd3d_private.h.

◆ NONAMELESSUNION

#define NONAMELESSUNION

Definition at line 26 of file vkd3d_private.h.

◆ VK_CALL

#define VK_CALL (   f)    (vk_procs->f)

Definition at line 44 of file vkd3d_private.h.

◆ VK_DEVICE_EXT_PFN

#define VK_DEVICE_EXT_PFN   DECLARE_VK_PFN

Definition at line 93 of file vkd3d_private.h.

◆ VK_DEVICE_PFN

#define VK_DEVICE_PFN   DECLARE_VK_PFN

Definition at line 92 of file vkd3d_private.h.

◆ VK_INSTANCE_EXT_PFN

#define VK_INSTANCE_EXT_PFN   DECLARE_VK_PFN

Definition at line 85 of file vkd3d_private.h.

◆ VK_INSTANCE_PFN [1/2]

#define VK_INSTANCE_PFN   DECLARE_VK_PFN

Definition at line 91 of file vkd3d_private.h.

◆ VK_INSTANCE_PFN [2/2]

#define VK_INSTANCE_PFN   DECLARE_VK_PFN

Definition at line 91 of file vkd3d_private.h.

◆ VK_NO_PROTOTYPES

#define VK_NO_PROTOTYPES

Definition at line 27 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_MAGIC_CBV

#define VKD3D_DESCRIPTOR_MAGIC_CBV   VKD3D_MAKE_TAG('C', 'B', 'V', 0)

Definition at line 47 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_MAGIC_DSV

#define VKD3D_DESCRIPTOR_MAGIC_DSV   VKD3D_MAKE_TAG('D', 'S', 'V', 0)

Definition at line 51 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_MAGIC_FREE

#define VKD3D_DESCRIPTOR_MAGIC_FREE   0x00000000u

Definition at line 46 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_MAGIC_RTV

#define VKD3D_DESCRIPTOR_MAGIC_RTV   VKD3D_MAKE_TAG('R', 'T', 'V', 0)

Definition at line 52 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_MAGIC_SAMPLER

#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER   VKD3D_MAKE_TAG('S', 'M', 'P', 0)

Definition at line 50 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_MAGIC_SRV

#define VKD3D_DESCRIPTOR_MAGIC_SRV   VKD3D_MAKE_TAG('S', 'R', 'V', 0)

Definition at line 48 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_MAGIC_UAV

#define VKD3D_DESCRIPTOR_MAGIC_UAV   VKD3D_MAKE_TAG('U', 'A', 'V', 0)

Definition at line 49 of file vkd3d_private.h.

◆ VKD3D_DESCRIPTOR_POOL_COUNT

#define VKD3D_DESCRIPTOR_POOL_COUNT   6

Definition at line 1531 of file vkd3d_private.h.

◆ VKD3D_MAX_COMPATIBLE_FORMAT_COUNT

#define VKD3D_MAX_COMPATIBLE_FORMAT_COUNT   6u

Definition at line 54 of file vkd3d_private.h.

◆ VKD3D_MAX_DESCRIPTOR_SET_SAMPLERS

#define VKD3D_MAX_DESCRIPTOR_SET_SAMPLERS   2048u

Definition at line 62 of file vkd3d_private.h.

◆ VKD3D_MAX_DESCRIPTOR_SETS

#define VKD3D_MAX_DESCRIPTOR_SETS   64u

Definition at line 60 of file vkd3d_private.h.

◆ VKD3D_MAX_DEVICE_BLOCKED_QUEUES

#define VKD3D_MAX_DEVICE_BLOCKED_QUEUES   16u

Definition at line 59 of file vkd3d_private.h.

◆ VKD3D_MAX_QUEUE_FAMILY_COUNT

#define VKD3D_MAX_QUEUE_FAMILY_COUNT   3u

Definition at line 55 of file vkd3d_private.h.

◆ VKD3D_MAX_SHADER_EXTENSIONS

#define VKD3D_MAX_SHADER_EXTENSIONS   5u

Definition at line 56 of file vkd3d_private.h.

◆ VKD3D_MAX_SHADER_STAGES

#define VKD3D_MAX_SHADER_STAGES   5u

Definition at line 57 of file vkd3d_private.h.

◆ VKD3D_MAX_VIRTUAL_HEAP_DESCRIPTORS_PER_TYPE

#define VKD3D_MAX_VIRTUAL_HEAP_DESCRIPTORS_PER_TYPE   (16 * 1024u)

Definition at line 66 of file vkd3d_private.h.

◆ VKD3D_MAX_VK_SYNC_OBJECTS

#define VKD3D_MAX_VK_SYNC_OBJECTS   4u

Definition at line 58 of file vkd3d_private.h.

◆ VKD3D_RESOURCE_DEDICATED_HEAP

#define VKD3D_RESOURCE_DEDICATED_HEAP   0x00000008

Definition at line 444 of file vkd3d_private.h.

◆ VKD3D_RESOURCE_EXTERNAL

#define VKD3D_RESOURCE_EXTERNAL   0x00000004

Definition at line 443 of file vkd3d_private.h.

◆ VKD3D_RESOURCE_LINEAR_TILING

#define VKD3D_RESOURCE_LINEAR_TILING   0x00000010

Definition at line 445 of file vkd3d_private.h.

◆ VKD3D_RESOURCE_PUBLIC_FLAGS

Definition at line 441 of file vkd3d_private.h.

◆ WIDL_C_INLINE_WRAPPERS

#define WIDL_C_INLINE_WRAPPERS

Definition at line 23 of file vkd3d_private.h.

Enumeration Type Documentation

◆ vkd3d_config_flags

Enumerator
VKD3D_CONFIG_FLAG_VULKAN_DEBUG 
VKD3D_CONFIG_FLAG_VIRTUAL_HEAPS 

Definition at line 172 of file vkd3d_private.h.

173{
176};
@ VKD3D_CONFIG_FLAG_VIRTUAL_HEAPS
@ VKD3D_CONFIG_FLAG_VULKAN_DEBUG

◆ vkd3d_cs_op

Enumerator
VKD3D_CS_OP_WAIT 
VKD3D_CS_OP_SIGNAL 
VKD3D_CS_OP_EXECUTE 
VKD3D_CS_OP_UPDATE_MAPPINGS 
VKD3D_CS_OP_COPY_MAPPINGS 

Definition at line 1335 of file vkd3d_private.h.

1336{
1342};
@ VKD3D_CS_OP_UPDATE_MAPPINGS
@ VKD3D_CS_OP_SIGNAL
@ VKD3D_CS_OP_WAIT
@ VKD3D_CS_OP_EXECUTE
@ VKD3D_CS_OP_COPY_MAPPINGS

◆ vkd3d_format_type

Enumerator
VKD3D_FORMAT_TYPE_OTHER 
VKD3D_FORMAT_TYPE_TYPELESS 
VKD3D_FORMAT_TYPE_SINT 
VKD3D_FORMAT_TYPE_UINT 

Definition at line 1638 of file vkd3d_private.h.

1639{
1644};
@ VKD3D_FORMAT_TYPE_SINT
@ VKD3D_FORMAT_TYPE_UINT
@ VKD3D_FORMAT_TYPE_OTHER
@ VKD3D_FORMAT_TYPE_TYPELESS

◆ vkd3d_pipeline_bind_point

Enumerator
VKD3D_PIPELINE_BIND_POINT_GRAPHICS 
VKD3D_PIPELINE_BIND_POINT_COMPUTE 
VKD3D_PIPELINE_BIND_POINT_COUNT 

Definition at line 1244 of file vkd3d_private.h.

1245{
1249};
@ VKD3D_PIPELINE_BIND_POINT_COUNT
@ VKD3D_PIPELINE_BIND_POINT_GRAPHICS
@ VKD3D_PIPELINE_BIND_POINT_COMPUTE

◆ vkd3d_view_type

Enumerator
VKD3D_VIEW_TYPE_BUFFER 
VKD3D_VIEW_TYPE_IMAGE 
VKD3D_VIEW_TYPE_SAMPLER 

Definition at line 568 of file vkd3d_private.h.

569{
573};
@ VKD3D_VIEW_TYPE_SAMPLER
@ VKD3D_VIEW_TYPE_IMAGE
@ VKD3D_VIEW_TYPE_BUFFER

◆ vkd3d_vk_descriptor_set_index

Enumerator
VKD3D_SET_INDEX_SAMPLER 
VKD3D_SET_INDEX_UAV_COUNTER 
VKD3D_SET_INDEX_MUTABLE 
VKD3D_SET_INDEX_UNIFORM_BUFFER 
VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER 
VKD3D_SET_INDEX_SAMPLED_IMAGE 
VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER 
VKD3D_SET_INDEX_STORAGE_IMAGE 
VKD3D_SET_INDEX_COUNT 

Definition at line 773 of file vkd3d_private.h.

774{
778
779 /* These are used when mutable descriptors are not available to back
780 * SRV-UAV-CBV descriptor heaps. They must stay at the end of this
781 * enumeration, so that they can be ignored when mutable descriptors are
782 * used. */
788
790};
@ VKD3D_SET_INDEX_MUTABLE
@ VKD3D_SET_INDEX_STORAGE_IMAGE
@ VKD3D_SET_INDEX_UNIFORM_TEXEL_BUFFER
@ VKD3D_SET_INDEX_SAMPLED_IMAGE
@ VKD3D_SET_INDEX_UNIFORM_BUFFER
@ VKD3D_SET_INDEX_STORAGE_TEXEL_BUFFER
@ VKD3D_SET_INDEX_SAMPLER
@ VKD3D_SET_INDEX_UAV_COUNTER
@ VKD3D_SET_INDEX_COUNT

Function Documentation

◆ d3d12_box_is_empty()

static bool d3d12_box_is_empty ( const D3D12_BOX *  box)
inlinestatic

Definition at line 1692 of file vkd3d_private.h.

1693{
1694 return box->right <= box->left || box->bottom <= box->top || box->back <= box->front;
1695}
Definition: palette.c:466

Referenced by d3d12_resource_ReadFromSubresource(), and d3d12_resource_WriteToSubresource().

◆ d3d12_command_allocator_create()

HRESULT d3d12_command_allocator_create ( struct d3d12_device *  device,
D3D12_COMMAND_LIST_TYPE  type,
struct d3d12_command_allocator **  allocator 
)

Definition at line 1895 of file command.c.

1897{
1899 HRESULT hr;
1900
1902 {
1903 WARN("Invalid type %#x.\n", type);
1904 return E_INVALIDARG;
1905 }
1906
1907 if (!(object = vkd3d_malloc(sizeof(*object))))
1908 return E_OUTOFMEMORY;
1909
1911 {
1912 vkd3d_free(object);
1913 return hr;
1914 }
1915
1916 TRACE("Created command allocator %p.\n", object);
1917
1918 *allocator = object;
1919
1920 return S_OK;
1921}
#define WARN(fmt,...)
Definition: precomp.h:61
static HRESULT d3d12_command_allocator_init(struct d3d12_command_allocator *allocator, struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type)
Definition: command.c:1817
@ D3D12_COMMAND_LIST_TYPE_COPY
Definition: d3d12.idl:2192
@ D3D12_COMMAND_LIST_TYPE_DIRECT
Definition: d3d12.idl:2189
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
HRESULT hr
Definition: delayimp.cpp:582
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
#define TRACE(s)
Definition: solgame.cpp:4
Definition: devices.h:37
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52
static void * vkd3d_malloc(size_t size)
Definition: vkd3d_memory.h:28

Referenced by d3d12_device_CreateCommandAllocator().

◆ d3d12_command_list_create()

HRESULT d3d12_command_list_create ( struct d3d12_device *  device,
UINT  node_mask,
D3D12_COMMAND_LIST_TYPE  type,
ID3D12CommandAllocator *  allocator_iface,
ID3D12PipelineState *  initial_pipeline_state,
struct d3d12_command_list **  list 
)

Definition at line 6262 of file command.c.

6265{
6267 struct d3d12_command_list *object;
6268 HRESULT hr;
6269
6270 if (!(allocator = unsafe_impl_from_ID3D12CommandAllocator(allocator_iface)))
6271 {
6272 WARN("Command allocator is NULL.\n");
6273 return E_INVALIDARG;
6274 }
6275
6276 if (allocator->type != type)
6277 {
6278 WARN("Command list types do not match (allocator %#x, list %#x).\n",
6279 allocator->type, type);
6280 return E_INVALIDARG;
6281 }
6282
6283 debug_ignored_node_mask(node_mask);
6284
6285 if (!(object = vkd3d_malloc(sizeof(*object))))
6286 return E_OUTOFMEMORY;
6287
6288 if (FAILED(hr = d3d12_command_list_init(object, device, type, allocator, initial_pipeline_state)))
6289 {
6290 vkd3d_free(object);
6291 return hr;
6292 }
6293
6294 TRACE("Created command list %p.\n", object);
6295
6296 *list = object;
6297
6298 return S_OK;
6299}
Definition: list.h:39
static HRESULT d3d12_command_list_init(struct d3d12_command_list *list, struct d3d12_device *device, D3D12_COMMAND_LIST_TYPE type, struct d3d12_command_allocator *allocator, ID3D12PipelineState *initial_pipeline_state)
Definition: command.c:6227
static struct d3d12_command_allocator * unsafe_impl_from_ID3D12CommandAllocator(ID3D12CommandAllocator *iface)
Definition: command.c:1792
static void debug_ignored_node_mask(unsigned int mask)

Referenced by d3d12_device_CreateCommandList().

◆ d3d12_command_queue_create()

HRESULT d3d12_command_queue_create ( struct d3d12_device *  device,
const D3D12_COMMAND_QUEUE_DESC *  desc,
struct d3d12_command_queue **  queue 
)

Definition at line 7464 of file command.c.

7466{
7468 HRESULT hr;
7469
7470 if (!(object = vkd3d_malloc(sizeof(*object))))
7471 return E_OUTOFMEMORY;
7472
7473 if (FAILED(hr = d3d12_command_queue_init(object, device, desc)))
7474 {
7475 vkd3d_free(object);
7476 return hr;
7477 }
7478
7479 TRACE("Created command queue %p.\n", object);
7480
7481 *queue = object;
7482
7483 return S_OK;
7484}
static HRESULT d3d12_command_queue_init(struct d3d12_command_queue *queue, struct d3d12_device *device, const D3D12_COMMAND_QUEUE_DESC *desc)
Definition: command.c:7410
D3D11_SHADER_VARIABLE_DESC desc
Definition: reflection.c:1683
Definition: queue.c:179

Referenced by d3d12_device_CreateCommandQueue().

◆ d3d12_command_signature_create()

HRESULT d3d12_command_signature_create ( struct d3d12_device *  device,
const D3D12_COMMAND_SIGNATURE_DESC *  desc,
struct d3d12_command_signature **  signature 
)

Definition at line 7635 of file command.c.

7637{
7639 unsigned int i;
7640 HRESULT hr;
7641
7642 for (i = 0; i < desc->NumArgumentDescs; ++i)
7643 {
7644 const D3D12_INDIRECT_ARGUMENT_DESC *argument_desc = &desc->pArgumentDescs[i];
7645 switch (argument_desc->Type)
7646 {
7650 if (i != desc->NumArgumentDescs - 1)
7651 {
7652 WARN("Draw/dispatch must be the last element of a command signature.\n");
7653 return E_INVALIDARG;
7654 }
7655 break;
7656 default:
7657 break;
7658 }
7659 }
7660
7661 if (!(object = vkd3d_malloc(sizeof(*object))))
7662 return E_OUTOFMEMORY;
7663
7664 object->ID3D12CommandSignature_iface.lpVtbl = &d3d12_command_signature_vtbl;
7665 object->refcount = 1;
7666 object->internal_refcount = 1;
7667
7668 object->desc = *desc;
7669 if (!(object->desc.pArgumentDescs = vkd3d_calloc(desc->NumArgumentDescs, sizeof(*desc->pArgumentDescs))))
7670 {
7671 vkd3d_free(object);
7672 return E_OUTOFMEMORY;
7673 }
7674 memcpy((void *)object->desc.pArgumentDescs, desc->pArgumentDescs,
7675 desc->NumArgumentDescs * sizeof(*desc->pArgumentDescs));
7676
7677 if (FAILED(hr = vkd3d_private_store_init(&object->private_store)))
7678 {
7679 vkd3d_free((void *)object->desc.pArgumentDescs);
7680 vkd3d_free(object);
7681 return hr;
7682 }
7683
7685
7686 TRACE("Created command signature %p.\n", object);
7687
7688 *signature = object;
7689
7690 return S_OK;
7691}
static const struct ID3D12CommandSignatureVtbl d3d12_command_signature_vtbl
Definition: command.c:7612
@ D3D12_INDIRECT_ARGUMENT_TYPE_DISPATCH
Definition: d3d12.idl:3092
@ D3D12_INDIRECT_ARGUMENT_TYPE_DRAW
Definition: d3d12.idl:3090
@ D3D12_INDIRECT_ARGUMENT_TYPE_DRAW_INDEXED
Definition: d3d12.idl:3091
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
D3D12_INDIRECT_ARGUMENT_TYPE Type
Definition: d3d12.idl:3105
static void * vkd3d_calloc(size_t count, size_t size)
Definition: vkd3d_memory.h:43
static ULONG d3d12_device_add_ref(struct d3d12_device *device)
static HRESULT vkd3d_private_store_init(struct vkd3d_private_store *store)

Referenced by d3d12_device_CreateCommandSignature().

◆ d3d12_committed_resource_create()

HRESULT d3d12_committed_resource_create ( struct d3d12_device *  device,
const D3D12_HEAP_PROPERTIES *  heap_properties,
D3D12_HEAP_FLAGS  heap_flags,
const D3D12_RESOURCE_DESC1 *  desc,
D3D12_RESOURCE_STATES  initial_state,
const D3D12_CLEAR_VALUE *  optimized_clear_value,
ID3D12ProtectedResourceSession *  protected_session,
struct d3d12_resource **  resource 
)

Definition at line 2112 of file resource.c.

2117{
2118 struct d3d12_resource *object;
2119 HRESULT hr;
2120
2121 if (!heap_properties)
2122 {
2123 WARN("Heap properties are NULL.\n");
2124 return E_INVALIDARG;
2125 }
2126
2127 if (protected_session)
2128 FIXME("Protected session is not supported.\n");
2129
2130 if (FAILED(hr = d3d12_resource_create(device, heap_properties, heap_flags,
2131 desc, initial_state, optimized_clear_value, &object)))
2132 return hr;
2133
2134 if (FAILED(hr = vkd3d_allocate_resource_memory(device, object, heap_properties, heap_flags)))
2135 {
2136 d3d12_resource_Release(&object->ID3D12Resource2_iface);
2137 return hr;
2138 }
2139
2140 TRACE("Created committed resource %p.\n", object);
2141
2142 *resource = object;
2143
2144 return S_OK;
2145}
#define FIXME(fmt,...)
Definition: precomp.h:53
static HRESULT vkd3d_allocate_resource_memory(struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags)
Definition: resource.c:2096
static ULONG STDMETHODCALLTYPE d3d12_resource_Release(ID3D12Resource2 *iface)
Definition: resource.c:1303
static HRESULT d3d12_resource_create(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, D3D12_RESOURCE_STATES initial_state, const D3D12_CLEAR_VALUE *optimized_clear_value, struct d3d12_resource **resource)
Definition: resource.c:2073
D3D12_RESOURCE_STATES initial_state

Referenced by d3d12_device_CreateCommittedResource(), d3d12_device_CreateCommittedResource1(), and d3d12_device_CreateCommittedResource2().

◆ d3d12_desc_copy()

void d3d12_desc_copy ( struct d3d12_desc *  dst,
const struct d3d12_desc *  src,
struct d3d12_descriptor_heap *  dst_heap,
struct d3d12_device *  device 
)

Definition at line 2723 of file resource.c.

2725{
2726 struct d3d12_desc tmp;
2727
2728 VKD3D_ASSERT(dst != src);
2729
2730 tmp.s.u.object = d3d12_desc_get_object_ref(src, device);
2731 descriptor_heap_write_atomic(dst_heap, dst, &tmp, device);
2732}
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
static void descriptor_heap_write_atomic(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_desc *dst, const struct d3d12_desc *src, struct d3d12_device *device)
Definition: resource.c:2700
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49
static void * d3d12_desc_get_object_ref(const volatile struct d3d12_desc *src, struct d3d12_device *device)

Referenced by d3d12_device_CopyDescriptors().

◆ d3d12_desc_copy_raw()

static void d3d12_desc_copy_raw ( struct d3d12_desc *  dst,
const struct d3d12_desc *  src 
)
inlinestatic

Definition at line 710 of file vkd3d_private.h.

711{
712 dst->s = src->s;
713}

◆ d3d12_desc_create_cbv()

void d3d12_desc_create_cbv ( struct d3d12_desc *  descriptor,
struct d3d12_device *  device,
const D3D12_CONSTANT_BUFFER_VIEW_DESC *  desc 
)

Definition at line 3140 of file resource.c.

3142{
3143 struct VkDescriptorBufferInfo *buffer_info;
3144 struct vkd3d_cbuffer_desc *cb_desc;
3145 struct d3d12_resource *resource;
3146
3147 if (!desc)
3148 {
3149 WARN("Constant buffer desc is NULL.\n");
3150 return;
3151 }
3152
3153 if (!(cb_desc = vkd3d_cbuffer_desc_create(device)))
3154 {
3155 ERR("Failed to allocate descriptor object.\n");
3156 return;
3157 }
3158
3160 {
3161 WARN("Size is not %u bytes aligned.\n", D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT);
3162 return;
3163 }
3164
3165 buffer_info = &cb_desc->vk_cbv_info;
3166 if (desc->BufferLocation)
3167 {
3168 resource = vkd3d_gpu_va_allocator_dereference(&device->gpu_va_allocator, desc->BufferLocation);
3169 buffer_info->buffer = resource->u.vk_buffer;
3170 buffer_info->offset = desc->BufferLocation - resource->gpu_address;
3171 buffer_info->range = min(desc->SizeInBytes, resource->desc.Width - buffer_info->offset);
3172 }
3173 else
3174 {
3175 /* NULL descriptor */
3176 buffer_info->buffer = device->null_resources.vk_buffer;
3177 buffer_info->offset = 0;
3178 buffer_info->range = VK_WHOLE_SIZE;
3179 }
3180
3181 descriptor->s.u.cb_desc = cb_desc;
3182}
#define ERR(fmt,...)
Definition: precomp.h:57
const UINT D3D12_CONSTANT_BUFFER_DATA_PLACEMENT_ALIGNMENT
Definition: d3d12.idl:69
#define resource
Definition: kernel32.h:9
#define min(a, b)
Definition: monoChain.cc:55
descriptor
Definition: scsi.h:3997
void * vkd3d_gpu_va_allocator_dereference(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2495
static struct vkd3d_cbuffer_desc * vkd3d_cbuffer_desc_create(struct d3d12_device *device)
Definition: resource.c:2390
VkDescriptorBufferInfo vk_cbv_info
#define VK_WHOLE_SIZE
Definition: vulkan.h:53

Referenced by d3d12_device_CreateConstantBufferView().

◆ d3d12_desc_create_sampler()

void d3d12_desc_create_sampler ( struct d3d12_desc *  sampler,
struct d3d12_device *  device,
const D3D12_SAMPLER_DESC *  desc 
)

Definition at line 3780 of file resource.c.

3782{
3784 struct vkd3d_view *view;
3785
3786 if (!desc)
3787 {
3788 WARN("NULL sampler desc.\n");
3789 return;
3790 }
3791
3795 static_colour = d3d12_static_border_colour(desc->BorderColor);
3796
3799 return;
3800 view->v.u.vk_sampler = VK_NULL_HANDLE;
3801 view->v.format = NULL;
3802
3803 if (d3d12_create_sampler(device, desc->Filter, desc->AddressU, desc->AddressV,
3804 desc->AddressW, desc->MipLODBias, desc->MaxAnisotropy, desc->ComparisonFunc,
3805 static_colour, desc->MinLOD, desc->MaxLOD, &view->v.u.vk_sampler) < 0)
3806 {
3808 return;
3809 }
3810
3811 sampler->s.u.view = view;
3812}
D3D12_STATIC_BORDER_COLOR
Definition: d3d12.idl:1221
@ D3D12_STATIC_BORDER_COLOR_TRANSPARENT_BLACK
Definition: d3d12.idl:1222
@ D3D12_TEXTURE_ADDRESS_MODE_BORDER
Definition: d3d12.idl:1333
#define NULL
Definition: types.h:112
GLuint sampler
Definition: glext.h:7283
static D3D12_STATIC_BORDER_COLOR d3d12_static_border_colour(const float *colour)
Definition: resource.c:3753
static struct vkd3d_view * vkd3d_view_create(uint32_t magic, VkDescriptorType vk_descriptor_type, enum vkd3d_view_type type, struct d3d12_device *device)
Definition: resource.c:2404
void vkd3d_view_decref(void *view, struct d3d12_device *device)
Definition: resource.c:2453
static VkResult d3d12_create_sampler(struct d3d12_device *device, D3D12_FILTER filter, D3D12_TEXTURE_ADDRESS_MODE address_u, D3D12_TEXTURE_ADDRESS_MODE address_v, D3D12_TEXTURE_ADDRESS_MODE address_w, float mip_lod_bias, unsigned int max_anisotropy, D3D12_COMPARISON_FUNC comparison_func, D3D12_STATIC_BORDER_COLOR border_colour, float min_lod, float max_lod, VkSampler *vk_sampler)
Definition: resource.c:3708
#define VKD3D_DESCRIPTOR_MAGIC_SAMPLER
Definition: vkd3d_private.h:50
@ VK_DESCRIPTOR_TYPE_SAMPLER
Definition: vulkan.h:2464
#define VK_NULL_HANDLE
Definition: vulkan.h:861

Referenced by d3d12_device_CreateSampler().

◆ d3d12_desc_create_srv()

void d3d12_desc_create_srv ( struct d3d12_desc *  descriptor,
struct d3d12_device *  device,
struct d3d12_resource *  resource,
const D3D12_SHADER_RESOURCE_VIEW_DESC *  desc 
)

Definition at line 3302 of file resource.c.

3305{
3306 struct vkd3d_texture_view_desc vkd3d_desc;
3307
3308 if (!resource)
3309 {
3311 return;
3312 }
3313
3315 {
3317 return;
3318 }
3319
3320 if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
3321 return;
3322
3323 vkd3d_desc.miplevel_count = VK_REMAINING_MIP_LEVELS;
3324 vkd3d_desc.allowed_swizzle = true;
3325 vkd3d_desc.usage = VK_IMAGE_USAGE_SAMPLED_BIT;
3326
3327 if (desc)
3328 {
3329 if (desc->Shader4ComponentMapping != D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING)
3330 {
3331 TRACE("Component mapping %s for format %#x.\n",
3332 debug_d3d12_shader_component_mapping(desc->Shader4ComponentMapping), desc->Format);
3333
3334 vk_component_mapping_from_d3d12(&vkd3d_desc.components, desc->Shader4ComponentMapping);
3335 }
3336
3337 switch (desc->ViewDimension)
3338 {
3340 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_1D;
3341 vkd3d_desc.miplevel_idx = desc->u.Texture1D.MostDetailedMip;
3342 vkd3d_desc.miplevel_count = desc->u.Texture1D.MipLevels;
3343 break;
3345 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3346 vkd3d_desc.miplevel_idx = desc->u.Texture2D.MostDetailedMip;
3347 vkd3d_desc.miplevel_count = desc->u.Texture2D.MipLevels;
3348 if (desc->u.Texture2D.PlaneSlice)
3349 vkd3d_desc.vk_image_aspect = vk_image_aspect_flags_from_d3d12_plane_slice(resource->format,
3350 desc->u.Texture2D.PlaneSlice);
3351 if (desc->u.Texture2D.ResourceMinLODClamp)
3352 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.Texture2D.ResourceMinLODClamp);
3353 break;
3355 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3356 vkd3d_desc.miplevel_idx = desc->u.Texture2DArray.MostDetailedMip;
3357 vkd3d_desc.miplevel_count = desc->u.Texture2DArray.MipLevels;
3358 vkd3d_desc.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
3359 vkd3d_desc.layer_count = desc->u.Texture2DArray.ArraySize;
3360 if (desc->u.Texture2DArray.PlaneSlice)
3361 vkd3d_desc.vk_image_aspect = vk_image_aspect_flags_from_d3d12_plane_slice(resource->format,
3362 desc->u.Texture2DArray.PlaneSlice);
3363 if (desc->u.Texture2DArray.ResourceMinLODClamp)
3364 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.Texture2DArray.ResourceMinLODClamp);
3365 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3366 break;
3368 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3369 break;
3371 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3372 vkd3d_desc.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
3373 vkd3d_desc.layer_count = desc->u.Texture2DMSArray.ArraySize;
3374 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3375 break;
3377 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_3D;
3378 vkd3d_desc.miplevel_idx = desc->u.Texture3D.MostDetailedMip;
3379 vkd3d_desc.miplevel_count = desc->u.Texture3D.MipLevels;
3380 if (desc->u.Texture3D.ResourceMinLODClamp)
3381 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.Texture2D.ResourceMinLODClamp);
3382 break;
3384 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_CUBE;
3385 vkd3d_desc.miplevel_idx = desc->u.TextureCube.MostDetailedMip;
3386 vkd3d_desc.miplevel_count = desc->u.TextureCube.MipLevels;
3387 vkd3d_desc.layer_count = 6;
3388 if (desc->u.TextureCube.ResourceMinLODClamp)
3389 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.TextureCube.ResourceMinLODClamp);
3390 break;
3392 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_CUBE_ARRAY;
3393 vkd3d_desc.miplevel_idx = desc->u.TextureCubeArray.MostDetailedMip;
3394 vkd3d_desc.miplevel_count = desc->u.TextureCubeArray.MipLevels;
3395 vkd3d_desc.layer_idx = desc->u.TextureCubeArray.First2DArrayFace;
3396 vkd3d_desc.layer_count = desc->u.TextureCubeArray.NumCubes;
3397 if (vkd3d_desc.layer_count != UINT_MAX)
3398 vkd3d_desc.layer_count *= 6;
3399 if (desc->u.TextureCubeArray.ResourceMinLODClamp)
3400 FIXME("Unhandled min LOD clamp %.8e.\n", desc->u.TextureCubeArray.ResourceMinLODClamp);
3401 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3402 break;
3403 default:
3404 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3405 }
3406 }
3407
3409 &descriptor->s.u.view);
3410}
@ D3D12_SRV_DIMENSION_TEXTURE2DMSARRAY
Definition: d3d12.idl:1460
@ D3D12_SRV_DIMENSION_TEXTURECUBE
Definition: d3d12.idl:1462
@ D3D12_SRV_DIMENSION_TEXTURE3D
Definition: d3d12.idl:1461
@ D3D12_SRV_DIMENSION_TEXTURECUBEARRAY
Definition: d3d12.idl:1463
@ D3D12_SRV_DIMENSION_TEXTURE2DARRAY
Definition: d3d12.idl:1458
@ D3D12_SRV_DIMENSION_TEXTURE2DMS
Definition: d3d12.idl:1459
@ D3D12_SRV_DIMENSION_TEXTURE1D
Definition: d3d12.idl:1455
@ D3D12_SRV_DIMENSION_TEXTURE2D
Definition: d3d12.idl:1457
#define UINT_MAX
Definition: limits.h:27
static void vkd3d_create_buffer_srv(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_SHADER_RESOURCE_VIEW_DESC *desc)
Definition: resource.c:3257
static VkImageAspectFlags vk_image_aspect_flags_from_d3d12_plane_slice(const struct vkd3d_format *format, unsigned int plane_slice)
Definition: resource.c:3281
static void vk_component_mapping_from_d3d12(VkComponentMapping *components, unsigned int component_mapping)
Definition: resource.c:2939
static void vkd3d_texture_view_desc_normalise(struct vkd3d_texture_view_desc *desc, const D3D12_RESOURCE_DESC1 *resource_desc)
Definition: resource.c:3049
static bool init_default_texture_view_desc(struct vkd3d_texture_view_desc *desc, struct d3d12_resource *resource, DXGI_FORMAT view_format)
Definition: resource.c:2996
static void vkd3d_create_null_srv(struct d3d12_desc *descriptor, struct d3d12_device *device, const D3D12_SHADER_RESOURCE_VIEW_DESC *desc)
Definition: resource.c:3193
bool vkd3d_create_texture_view(struct d3d12_device *device, uint32_t magic, VkImage vk_image, const struct vkd3d_texture_view_desc *desc, struct vkd3d_view **view)
Definition: resource.c:3082
const char * debug_d3d12_shader_component_mapping(unsigned int mapping)
Definition: utils.c:682
#define VKD3D_DESCRIPTOR_MAGIC_SRV
Definition: vkd3d_private.h:48
static bool d3d12_resource_is_buffer(const struct d3d12_resource *resource)
#define VK_REMAINING_MIP_LEVELS
Definition: vulkan.h:50
@ VK_IMAGE_VIEW_TYPE_1D
Definition: vulkan.h:3548
@ VK_IMAGE_VIEW_TYPE_2D_ARRAY
Definition: vulkan.h:3553
@ 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
@ VK_IMAGE_USAGE_SAMPLED_BIT
Definition: vulkan.h:3512

Referenced by d3d12_device_CreateShaderResourceView().

◆ d3d12_desc_create_uav()

void d3d12_desc_create_uav ( struct d3d12_desc *  descriptor,
struct d3d12_device *  device,
struct d3d12_resource *  resource,
struct d3d12_resource *  counter_resource,
const D3D12_UNORDERED_ACCESS_VIEW_DESC *  desc 
)

Definition at line 3589 of file resource.c.

3592{
3593 if (!resource)
3594 {
3595 if (counter_resource)
3596 FIXME("Ignoring counter resource %p.\n", counter_resource);
3598 return;
3599 }
3600
3602 {
3604 }
3605 else
3606 {
3607 if (counter_resource)
3608 FIXME("Unexpected counter resource for texture view.\n");
3610 }
3611}
static void vkd3d_create_texture_uav(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
Definition: resource.c:3531
static void vkd3d_create_null_uav(struct d3d12_desc *descriptor, struct d3d12_device *device, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
Definition: resource.c:3421
static void vkd3d_create_buffer_uav(struct d3d12_desc *descriptor, struct d3d12_device *device, struct d3d12_resource *resource, struct d3d12_resource *counter_resource, const D3D12_UNORDERED_ACCESS_VIEW_DESC *desc)
Definition: resource.c:3485

Referenced by d3d12_device_CreateUnorderedAccessView().

◆ d3d12_desc_flush_vk_heap_updates_locked()

void d3d12_desc_flush_vk_heap_updates_locked ( struct d3d12_descriptor_heap *  descriptor_heap,
struct d3d12_device *  device 
)

Definition at line 2639 of file resource.c.

2640{
2641 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2642 struct d3d12_desc *descriptors, *src;
2643 struct descriptor_writes writes;
2644 union d3d12_desc_object u;
2645 unsigned int i, next;
2646
2647 if ((i = vkd3d_atomic_exchange_u32(&descriptor_heap->dirty_list_head, UINT_MAX)) == UINT_MAX)
2648 return;
2649
2650 writes.null_vk_cbv_info.buffer = VK_NULL_HANDLE;
2651 writes.null_vk_cbv_info.offset = 0;
2652 writes.null_vk_cbv_info.range = VK_WHOLE_SIZE;
2653 writes.null_vk_buffer_view = VK_NULL_HANDLE;
2654 writes.count = 0;
2655 writes.held_ref_count = 0;
2656
2657 descriptors = (struct d3d12_desc *)descriptor_heap->descriptors;
2658
2659 for (; i != UINT_MAX; i = next)
2660 {
2661 src = &descriptors[i];
2662 next = vkd3d_atomic_exchange_u32(&src->next, 0);
2663 next = (int)next >> 1;
2664
2665 /* A race exists here between updating src->next and getting the current object. The best
2666 * we can do is get the object last, which may result in a harmless rewrite later. */
2668
2669 if (!u.object)
2670 continue;
2671
2672 writes.held_refs[writes.held_ref_count++] = u.object;
2673 d3d12_desc_write_vk_heap(descriptor_heap, i, &writes, u.object, device);
2674 }
2675
2676 /* Avoid thunk calls wherever possible. */
2677 if (writes.count)
2678 VK_CALL(vkUpdateDescriptorSets(device->vk_device, writes.count, writes.vk_descriptor_writes, 0, NULL));
2680}
unsigned int(__cdecl typeof(jpeg_read_scanlines))(struct jpeg_decompress_struct *
Definition: typeof.h:31
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
for(i=0;i< sizeof(testsuite)/sizeof(testsuite[0]);++i) ok(call_test(testsuite[i].func)
static unsigned __int64 next
Definition: rand_nt.c:6
static void descriptor_writes_free_object_refs(struct descriptor_writes *writes, struct d3d12_device *device)
Definition: resource.c:2485
static void d3d12_desc_write_vk_heap(struct d3d12_descriptor_heap *descriptor_heap, unsigned int dst_array_element, struct descriptor_writes *writes, void *object, struct d3d12_device *device)
Definition: resource.c:2552
unsigned int volatile dirty_list_head
static uint32_t vkd3d_atomic_exchange_u32(uint32_t volatile *x, uint32_t val)
Definition: vkd3d_common.h:509
void VKAPI_CALL vkUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, const VkWriteDescriptorSet *pDescriptorWrites, uint32_t descriptorCopyCount, const VkCopyDescriptorSet *pDescriptorCopies)
#define VK_CALL(f)
Definition: wined3d_vk.h:272

Referenced by command_list_add_descriptor_heap(), command_list_flush_vk_heap_updates(), and device_worker_main().

◆ d3d12_desc_from_cpu_handle()

◆ d3d12_desc_from_gpu_handle()

static struct d3d12_desc * d3d12_desc_from_gpu_handle ( D3D12_GPU_DESCRIPTOR_HANDLE  gpu_handle)
inlinestatic

Definition at line 705 of file vkd3d_private.h.

706{
707 return (struct d3d12_desc *)(intptr_t)gpu_handle.ptr;
708}
int intptr_t
Definition: corecrt.h:176

Referenced by d3d12_command_list_set_descriptor_table().

◆ d3d12_desc_get_descriptor_heap()

static struct d3d12_descriptor_heap * d3d12_desc_get_descriptor_heap ( const struct d3d12_desc *  descriptor)
inlinestatic

◆ d3d12_desc_get_object_ref()

static void * d3d12_desc_get_object_ref ( const volatile struct d3d12_desc *  src,
struct d3d12_device *  device 
)
inlinestatic

Definition at line 677 of file vkd3d_private.h.

678{
679 void *view;
680
681 /* Some games, e.g. Shadow of the Tomb Raider, GRID 2019, and Horizon Zero Dawn, write descriptors
682 * from multiple threads without synchronisation. This is apparently valid in Windows. */
683 for (;;)
684 {
685 do
686 {
687 if (!(view = src->s.u.object))
688 return NULL;
689 } while (!vkd3d_view_incref(view));
690
691 /* Check if the object is still in src to handle the case where it was
692 * already freed and reused elsewhere when the refcount was incremented. */
693 if (view == src->s.u.object)
694 return view;
695
697 }
698}
void vkd3d_view_decref(void *view, struct d3d12_device *device)
Definition: resource.c:2453
static bool vkd3d_view_incref(void *desc)

Referenced by d3d12_desc_copy(), and d3d12_desc_flush_vk_heap_updates_locked().

◆ d3d12_desc_heap_range_size()

static unsigned int d3d12_desc_heap_range_size ( const struct d3d12_desc *  descriptor)
inlinestatic

Definition at line 860 of file vkd3d_private.h.

861{
863 return heap->desc.NumDescriptors - descriptor->index;
864}
Definition: heap.c:86
static struct d3d12_descriptor_heap * d3d12_desc_get_descriptor_heap(const struct d3d12_desc *descriptor)

Referenced by d3d12_command_list_prepare_descriptors(), and d3d12_command_list_update_descriptor_table().

◆ d3d12_desc_write_atomic()

◆ d3d12_descriptor_heap_create()

HRESULT d3d12_descriptor_heap_create ( struct d3d12_device *  device,
const D3D12_DESCRIPTOR_HEAP_DESC *  desc,
struct d3d12_descriptor_heap **  descriptor_heap 
)

Definition at line 4366 of file resource.c.

4368{
4369 size_t max_descriptor_count, descriptor_size;
4371 struct d3d12_desc *dst;
4372 unsigned int i;
4373 HRESULT hr;
4374
4375 if (!(descriptor_size = d3d12_device_get_descriptor_handle_increment_size(device, desc->Type)))
4376 {
4377 WARN("No descriptor size for descriptor type %#x.\n", desc->Type);
4378 return E_INVALIDARG;
4379 }
4380
4383 {
4384 WARN("RTV/DSV descriptor heaps cannot be shader visible.\n");
4385 return E_INVALIDARG;
4386 }
4387
4388 max_descriptor_count = (~(size_t)0 - sizeof(*object)) / descriptor_size;
4389 if (desc->NumDescriptors > max_descriptor_count)
4390 {
4391 WARN("Invalid descriptor count %u (max %zu).\n", desc->NumDescriptors, max_descriptor_count);
4392 return E_OUTOFMEMORY;
4393 }
4394
4395 if (!(object = vkd3d_malloc(offsetof(struct d3d12_descriptor_heap,
4396 descriptors[descriptor_size * desc->NumDescriptors]))))
4397 return E_OUTOFMEMORY;
4398
4400 {
4401 vkd3d_free(object);
4402 return hr;
4403 }
4404
4406 {
4407 dst = (struct d3d12_desc *)object->descriptors;
4408 for (i = 0; i < desc->NumDescriptors; ++i)
4409 {
4410 memset(&dst[i].s, 0, sizeof(dst[i].s));
4411 dst[i].index = i;
4412 dst[i].next = 0;
4413 }
4414 object->dirty_list_head = UINT_MAX;
4415
4416 if (object->use_vk_heaps && FAILED(hr = d3d12_device_add_descriptor_heap(device, object)))
4417 {
4418 vkd3d_free(object);
4419 return hr;
4420 }
4421 }
4422 else
4423 {
4424 memset(object->descriptors, 0, descriptor_size * desc->NumDescriptors);
4425 }
4426
4427 TRACE("Created descriptor heap %p.\n", object);
4428
4429 *descriptor_heap = object;
4430
4431 return S_OK;
4432}
@ D3D12_DESCRIPTOR_HEAP_FLAG_SHADER_VISIBLE
Definition: d3d12.idl:1431
@ D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV
Definition: d3d12.idl:1421
@ D3D12_DESCRIPTOR_HEAP_TYPE_SAMPLER
Definition: d3d12.idl:1422
@ D3D12_DESCRIPTOR_HEAP_TYPE_RTV
Definition: d3d12.idl:1423
@ D3D12_DESCRIPTOR_HEAP_TYPE_DSV
Definition: d3d12.idl:1424
unsigned int size_t
Definition: corecrt.h:203
GLdouble s
Definition: gl.h:2039
#define offsetof(TYPE, MEMBER)
#define memset(x, y, z)
Definition: compat.h:39
HRESULT d3d12_device_add_descriptor_heap(struct d3d12_device *device, struct d3d12_descriptor_heap *heap)
Definition: device.c:5569
static HRESULT d3d12_descriptor_heap_init(struct d3d12_descriptor_heap *descriptor_heap, struct d3d12_device *device, const D3D12_DESCRIPTOR_HEAP_DESC *desc)
Definition: resource.c:4339
void * object
static unsigned int d3d12_device_get_descriptor_handle_increment_size(struct d3d12_device *device, D3D12_DESCRIPTOR_HEAP_TYPE descriptor_type)

Referenced by d3d12_device_CreateDescriptorHeap().

◆ d3d12_device_add_descriptor_heap()

HRESULT d3d12_device_add_descriptor_heap ( struct d3d12_device *  device,
struct d3d12_descriptor_heap *  heap 
)

Definition at line 5569 of file device.c.

5570{
5571 vkd3d_mutex_lock(&device->worker_mutex);
5572
5573 if (!vkd3d_array_reserve((void **)&device->heaps, &device->heap_capacity, device->heap_count + 1,
5574 sizeof(*device->heaps)))
5575 {
5576 vkd3d_mutex_unlock(&device->worker_mutex);
5577 return E_OUTOFMEMORY;
5578 }
5579 device->heaps[device->heap_count++] = heap;
5580
5581 vkd3d_mutex_unlock(&device->worker_mutex);
5582
5583 return S_OK;
5584}
static void vkd3d_mutex_unlock(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:584
static void vkd3d_mutex_lock(struct vkd3d_mutex *lock)
Definition: vkd3d_common.h:572
bool vkd3d_array_reserve(void **elements, size_t *capacity, size_t element_count, size_t element_size)
Definition: memory.c:22

Referenced by d3d12_descriptor_heap_create().

◆ d3d12_device_add_ref()

◆ d3d12_device_create()

HRESULT d3d12_device_create ( struct vkd3d_instance *  instance,
const struct vkd3d_device_create_info *  create_info,
struct d3d12_device **  device 
)

Definition at line 5534 of file device.c.

5536{
5537 struct d3d12_device *object;
5538 HRESULT hr;
5539
5540 if (!(object = vkd3d_malloc(sizeof(*object))))
5541 return E_OUTOFMEMORY;
5542
5543 if (FAILED(hr = d3d12_device_init(object, instance, create_info)))
5544 {
5545 vkd3d_free(object);
5546 return hr;
5547 }
5548
5549 TRACE("Created device %p.\n", object);
5550
5551 *device = object;
5552
5553 return S_OK;
5554}
static HINSTANCE instance
Definition: main.c:35
static HRESULT d3d12_device_init(struct d3d12_device *device, struct vkd3d_instance *instance, const struct vkd3d_device_create_info *create_info)
Definition: device.c:5440

Referenced by vkd3d_create_device().

◆ d3d12_device_get_descriptor_handle_increment_size()

static unsigned int d3d12_device_get_descriptor_handle_increment_size ( struct d3d12_device *  device,
D3D12_DESCRIPTOR_HEAP_TYPE  descriptor_type 
)
inlinestatic

Definition at line 1631 of file vkd3d_private.h.

1633{
1634 return ID3D12Device9_GetDescriptorHandleIncrementSize(&device->ID3D12Device9_iface, descriptor_type);
1635}

Referenced by d3d12_descriptor_heap_create().

◆ d3d12_device_get_vkd3d_queue()

struct vkd3d_queue * d3d12_device_get_vkd3d_queue ( struct d3d12_device *  device,
D3D12_COMMAND_LIST_TYPE  type 
)

Definition at line 1800 of file command.c.

1802{
1803 switch (type)
1804 {
1806 return device->direct_queue;
1808 return device->compute_queue;
1810 return device->copy_queue;
1811 default:
1812 FIXME("Unhandled command list type %#x.\n", type);
1813 return NULL;
1814 }
1815}
@ D3D12_COMMAND_LIST_TYPE_COMPUTE
Definition: d3d12.idl:2191

Referenced by d3d12_command_allocator_init(), d3d12_command_queue_init(), and vkd3d_init_null_resources_data().

◆ d3d12_device_is_uma()

bool d3d12_device_is_uma ( struct d3d12_device *  device,
bool *  coherent 
)

Definition at line 3358 of file device.c.

3359{
3360 unsigned int i;
3361
3362 if (coherent)
3363 *coherent = true;
3364
3365 for (i = 0; i < device->memory_properties.memoryTypeCount; ++i)
3366 {
3367 if (!(device->memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT))
3368 return false;
3369 if (coherent && !(device->memory_properties.memoryTypes[i].propertyFlags
3371 *coherent = false;
3372 }
3373
3374 return true;
3375}
@ VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
Definition: vulkan.h:3772
@ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
Definition: vulkan.h:3771

Referenced by d3d12_device_CheckFeatureSupport(), d3d12_device_GetCustomHeapProperties(), and vkd3d_select_memory_type().

◆ d3d12_device_mark_as_removed()

void d3d12_device_mark_as_removed ( struct d3d12_device *  device,
HRESULT  reason,
const char *  message,
  ... 
)

◆ d3d12_device_query_interface()

◆ d3d12_device_release()

◆ d3d12_device_remove_descriptor_heap()

void d3d12_device_remove_descriptor_heap ( struct d3d12_device *  device,
struct d3d12_descriptor_heap *  heap 
)

Definition at line 5586 of file device.c.

5587{
5588 size_t i;
5589
5590 vkd3d_mutex_lock(&device->worker_mutex);
5591
5592 for (i = 0; i < device->heap_count; ++i)
5593 {
5594 if (device->heaps[i] == heap)
5595 {
5596 device->heaps[i] = device->heaps[--device->heap_count];
5597 break;
5598 }
5599 }
5600
5601 vkd3d_mutex_unlock(&device->worker_mutex);
5602}

Referenced by d3d12_descriptor_heap_Release().

◆ d3d12_dsv_desc_create_dsv()

void d3d12_dsv_desc_create_dsv ( struct d3d12_dsv_desc *  dsv_desc,
struct d3d12_device *  device,
struct d3d12_resource *  resource,
const D3D12_DEPTH_STENCIL_VIEW_DESC *  desc 
)

Definition at line 3931 of file resource.c.

3933{
3934 struct vkd3d_texture_view_desc vkd3d_desc;
3935 struct vkd3d_view *view;
3936
3937 d3d12_dsv_desc_destroy(dsv_desc, device);
3938
3939 if (!resource)
3940 {
3941 FIXME("NULL resource DSV not implemented.\n");
3942 return;
3943 }
3944
3945 if (resource->desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
3946 {
3947 WARN("Cannot create DSV for 3D texture.\n");
3948 return;
3949 }
3950
3951 if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
3952 return;
3953
3955
3956 if (!(vkd3d_desc.format->vk_aspect_mask & (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)))
3957 {
3958 WARN("Trying to create DSV for format %#x.\n", vkd3d_desc.format->dxgi_format);
3959 return;
3960 }
3961
3962 if (desc)
3963 {
3964 if (desc->Flags)
3965 FIXME("Ignoring flags %#x.\n", desc->Flags);
3966
3967 switch (desc->ViewDimension)
3968 {
3970 vkd3d_desc.miplevel_idx = desc->u.Texture2D.MipSlice;
3971 break;
3973 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3974 vkd3d_desc.miplevel_idx = desc->u.Texture2DArray.MipSlice;
3975 vkd3d_desc.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
3976 vkd3d_desc.layer_count = desc->u.Texture2DArray.ArraySize;
3977 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3978 break;
3980 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3981 break;
3983 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3984 vkd3d_desc.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
3985 vkd3d_desc.layer_count = desc->u.Texture2DMSArray.ArraySize;
3986 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3987 break;
3988 default:
3989 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3990 }
3991 }
3992
3994
3995 if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_DSV, resource->u.vk_image, &vkd3d_desc, &view))
3996 return;
3997
3998 dsv_desc->sample_count = vk_samples_from_dxgi_sample_desc(&resource->desc.SampleDesc);
3999 dsv_desc->format = vkd3d_desc.format;
4000 dsv_desc->width = d3d12_resource_desc_get_width(&resource->desc, vkd3d_desc.miplevel_idx);
4001 dsv_desc->height = d3d12_resource_desc_get_height(&resource->desc, vkd3d_desc.miplevel_idx);
4002 dsv_desc->layer_count = vkd3d_desc.layer_count;
4003 dsv_desc->view = view;
4004 dsv_desc->resource = resource;
4005}
@ D3D12_RESOURCE_DIMENSION_TEXTURE3D
Definition: d3d12.idl:986
@ D3D12_DSV_DIMENSION_TEXTURE2DMSARRAY
Definition: d3d12.idl:1761
@ D3D12_DSV_DIMENSION_TEXTURE2DMS
Definition: d3d12.idl:1760
@ D3D12_DSV_DIMENSION_TEXTURE2D
Definition: d3d12.idl:1758
@ D3D12_DSV_DIMENSION_TEXTURE2DARRAY
Definition: d3d12.idl:1759
VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc(const DXGI_SAMPLE_DESC *desc)
Definition: resource.c:641
static void d3d12_dsv_desc_destroy(struct d3d12_dsv_desc *dsv, struct d3d12_device *device)
Definition: resource.c:3922
struct vkd3d_view * view
VkSampleCountFlagBits sample_count
unsigned int height
struct d3d12_resource * resource
const struct vkd3d_format * format
unsigned int layer_count
#define VKD3D_DESCRIPTOR_MAGIC_DSV
Definition: vkd3d_private.h:51
static unsigned int d3d12_resource_desc_get_width(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
static bool d3d12_resource_is_texture(const struct d3d12_resource *resource)
static unsigned int d3d12_resource_desc_get_height(const D3D12_RESOURCE_DESC1 *desc, unsigned int miplevel_idx)
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan.h:3367
@ VK_IMAGE_ASPECT_DEPTH_BIT
Definition: vulkan.h:3366
@ VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT
Definition: vulkan.h:3515

Referenced by d3d12_device_CreateDepthStencilView().

◆ d3d12_dsv_desc_from_cpu_handle()

static struct d3d12_dsv_desc * d3d12_dsv_desc_from_cpu_handle ( D3D12_CPU_DESCRIPTOR_HANDLE  cpu_handle)
inlinestatic

◆ d3d12_fence_create()

HRESULT d3d12_fence_create ( struct d3d12_device *  device,
uint64_t  initial_value,
D3D12_FENCE_FLAGS  flags,
struct d3d12_fence **  fence 
)

Definition at line 1222 of file command.c.

1224{
1225 struct d3d12_fence *object;
1226
1227 if (!(object = vkd3d_malloc(sizeof(*object))))
1228 return E_OUTOFMEMORY;
1229
1230 d3d12_fence_init(object, device, initial_value, flags);
1231
1232 TRACE("Created fence %p.\n", object);
1233
1234 *fence = object;
1235
1236 return S_OK;
1237}
static HRESULT d3d12_fence_init(struct d3d12_fence *fence, struct d3d12_device *device, UINT64 initial_value, D3D12_FENCE_FLAGS flags)
Definition: command.c:1162
GLbitfield flags
Definition: glext.h:7161

Referenced by d3d12_device_CreateFence().

◆ d3d12_heap_create()

HRESULT d3d12_heap_create ( struct d3d12_device *  device,
const D3D12_HEAP_DESC *  desc,
const struct d3d12_resource *  resource,
ID3D12ProtectedResourceSession *  protected_session,
struct d3d12_heap **  heap 
)

Definition at line 576 of file resource.c.

579{
580 struct d3d12_heap *object;
581 HRESULT hr;
582
583 if (protected_session)
584 FIXME("Protected session is not supported.\n");
585
586 if (!(object = vkd3d_malloc(sizeof(*object))))
587 return E_OUTOFMEMORY;
588
589 if (FAILED(hr = d3d12_heap_init(object, device, desc, resource)))
590 {
591 vkd3d_free(object);
592 return hr;
593 }
594
595 TRACE("Created %s %p.\n", object->is_private ? "private heap" : "heap", object);
596
597 *heap = object;
598
599 return S_OK;
600}
static HRESULT d3d12_heap_init(struct d3d12_heap *heap, struct d3d12_device *device, const D3D12_HEAP_DESC *desc, const struct d3d12_resource *resource)
Definition: resource.c:479

Referenced by d3d12_device_CreateHeap(), d3d12_device_CreateHeap1(), and vkd3d_allocate_resource_memory().

◆ d3d12_pipeline_state_create()

HRESULT d3d12_pipeline_state_create ( struct d3d12_device *  device,
const D3D12_PIPELINE_STATE_STREAM_DESC *  desc,
struct d3d12_pipeline_state **  state 
)

Definition at line 3655 of file state.c.

3657{
3658 struct d3d12_pipeline_state_desc pipeline_desc;
3660 VkPipelineBindPoint bind_point;
3661 HRESULT hr;
3662
3663 if (FAILED(hr = pipeline_state_desc_from_d3d12_stream_desc(&pipeline_desc, desc, &bind_point)))
3664 return hr;
3665
3666 if (!(object = vkd3d_calloc(1, sizeof(*object))))
3667 return E_OUTOFMEMORY;
3668
3669 switch (bind_point)
3670 {
3672 hr = d3d12_pipeline_state_init_compute(object, device, &pipeline_desc);
3673 break;
3674
3676 hr = d3d12_pipeline_state_init_graphics(object, device, &pipeline_desc);
3677 break;
3678
3679 default:
3681 }
3682
3683 if (FAILED(hr))
3684 {
3685 vkd3d_free(object);
3686 return hr;
3687 }
3688
3689 TRACE("Created pipeline state %p.\n", object);
3690
3691 *state = object;
3692 return S_OK;
3693}
static int state
Definition: maze.c:121
static HRESULT pipeline_state_desc_from_d3d12_stream_desc(struct d3d12_pipeline_state_desc *desc, const D3D12_PIPELINE_STATE_STREAM_DESC *d3d12_desc, VkPipelineBindPoint *vk_bind_point)
Definition: state.c:1930
static HRESULT d3d12_pipeline_state_init_compute(struct d3d12_pipeline_state *state, struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc)
Definition: state.c:2518
static HRESULT d3d12_pipeline_state_init_graphics(struct d3d12_pipeline_state *state, struct d3d12_device *device, const struct d3d12_pipeline_state_desc *desc)
Definition: state.c:3084
#define vkd3d_unreachable()
Definition: vkd3d_common.h:119
VkPipelineBindPoint
Definition: vulkan.h:4067
@ VK_PIPELINE_BIND_POINT_GRAPHICS
Definition: vulkan.h:4068
@ VK_PIPELINE_BIND_POINT_COMPUTE
Definition: vulkan.h:4069

Referenced by d3d12_device_CreatePipelineState().

◆ d3d12_pipeline_state_create_compute()

HRESULT d3d12_pipeline_state_create_compute ( struct d3d12_device *  device,
const D3D12_COMPUTE_PIPELINE_STATE_DESC *  desc,
struct d3d12_pipeline_state **  state 
)

Definition at line 2621 of file state.c.

2623{
2624 struct d3d12_pipeline_state_desc pipeline_desc;
2626 HRESULT hr;
2627
2629
2630 if (!(object = vkd3d_malloc(sizeof(*object))))
2631 return E_OUTOFMEMORY;
2632
2633 if (FAILED(hr = d3d12_pipeline_state_init_compute(object, device, &pipeline_desc)))
2634 {
2635 vkd3d_free(object);
2636 return hr;
2637 }
2638
2639 TRACE("Created compute pipeline state %p.\n", object);
2640
2641 *state = object;
2642
2643 return S_OK;
2644}
static void pipeline_state_desc_from_d3d12_compute_desc(struct d3d12_pipeline_state_desc *desc, const D3D12_COMPUTE_PIPELINE_STATE_DESC *d3d12_desc)
Definition: state.c:1919

Referenced by d3d12_device_CreateComputePipelineState().

◆ d3d12_pipeline_state_create_graphics()

HRESULT d3d12_pipeline_state_create_graphics ( struct d3d12_device *  device,
const D3D12_GRAPHICS_PIPELINE_STATE_DESC *  desc,
struct d3d12_pipeline_state **  state 
)

Definition at line 3630 of file state.c.

3632{
3633 struct d3d12_pipeline_state_desc pipeline_desc;
3635 HRESULT hr;
3636
3638
3639 if (!(object = vkd3d_malloc(sizeof(*object))))
3640 return E_OUTOFMEMORY;
3641
3642 if (FAILED(hr = d3d12_pipeline_state_init_graphics(object, device, &pipeline_desc)))
3643 {
3644 vkd3d_free(object);
3645 return hr;
3646 }
3647
3648 TRACE("Created graphics pipeline state %p.\n", object);
3649
3650 *state = object;
3651
3652 return S_OK;
3653}
static void pipeline_state_desc_from_d3d12_graphics_desc(struct d3d12_pipeline_state_desc *desc, const D3D12_GRAPHICS_PIPELINE_STATE_DESC *d3d12_desc)
Definition: state.c:1892

Referenced by d3d12_device_CreateGraphicsPipelineState().

◆ d3d12_pipeline_state_get_or_create_pipeline()

VkPipeline d3d12_pipeline_state_get_or_create_pipeline ( struct d3d12_pipeline_state *  state,
D3D12_PRIMITIVE_TOPOLOGY  topology,
const uint32_t *  strides,
VkFormat  dsv_format,
VkRenderPass *  vk_render_pass 
)

Definition at line 3827 of file state.c.

3830{
3832 const struct vkd3d_vk_device_procs *vk_procs = &state->device->vk_procs;
3833 struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
3835 VkPipelineTessellationStateCreateInfo tessellation_info;
3839 struct d3d12_device *device = state->device;
3840 VkGraphicsPipelineCreateInfo pipeline_desc;
3841 struct vkd3d_pipeline_key pipeline_key;
3842 size_t binding_count = 0;
3843 VkPipeline vk_pipeline;
3844 unsigned int i;
3845 uint32_t mask;
3846 VkResult vr;
3847 HRESULT hr;
3848
3849 static const VkPipelineViewportStateCreateInfo vp_desc =
3850 {
3852 .pNext = NULL,
3853 .flags = 0,
3854 .viewportCount = 1,
3855 .pViewports = NULL,
3856 .scissorCount = 1,
3857 .pScissors = NULL,
3858 };
3859 static const VkDynamicState dynamic_states[] =
3860 {
3866 };
3867 static const VkPipelineDynamicStateCreateInfo dynamic_desc =
3868 {
3870 .pNext = NULL,
3871 .flags = 0,
3872 .dynamicStateCount = ARRAY_SIZE(dynamic_states),
3873 .pDynamicStates = dynamic_states,
3874 };
3875
3877
3878 memset(&pipeline_key, 0, sizeof(pipeline_key));
3879 pipeline_key.topology = topology;
3880
3881 for (i = 0, mask = 0; i < graphics->attribute_count; ++i)
3882 {
3885
3886 binding = graphics->attributes[i].binding;
3887 if (mask & (1u << binding))
3888 continue;
3889
3890 if (binding_count == ARRAY_SIZE(bindings))
3891 {
3892 FIXME("Maximum binding count exceeded.\n");
3893 break;
3894 }
3895
3896 mask |= 1u << binding;
3897 b = &bindings[binding_count];
3898 b->binding = binding;
3899 b->stride = strides[binding];
3900 b->inputRate = graphics->input_rates[binding];
3901
3902 pipeline_key.strides[binding_count] = strides[binding];
3903
3904 ++binding_count;
3905 }
3906
3907 pipeline_key.dsv_format = dsv_format;
3908
3909 if ((vk_pipeline = d3d12_pipeline_state_find_compiled_pipeline(state, &pipeline_key, vk_render_pass)))
3910 return vk_pipeline;
3911
3913 input_desc.pNext = NULL;
3914 input_desc.flags = 0;
3915 input_desc.vertexBindingDescriptionCount = binding_count;
3916 input_desc.pVertexBindingDescriptions = bindings;
3917 input_desc.vertexAttributeDescriptionCount = graphics->attribute_count;
3918 input_desc.pVertexAttributeDescriptions = graphics->attributes;
3919
3920 if (graphics->instance_divisor_count)
3921 {
3922 input_desc.pNext = &input_divisor_info;
3924 input_divisor_info.pNext = NULL;
3925 input_divisor_info.vertexBindingDivisorCount = graphics->instance_divisor_count;
3926 input_divisor_info.pVertexBindingDivisors = graphics->instance_divisors;
3927 }
3928
3930 ia_desc.pNext = NULL;
3931 ia_desc.flags = 0;
3932 ia_desc.topology = vk_topology_from_d3d12_topology(topology);
3935
3937 {
3938 WARN("Primitive topology is undefined.\n");
3939 return VK_NULL_HANDLE;
3940 }
3941
3943 tessellation_info.pNext = NULL;
3944 tessellation_info.flags = 0;
3945 tessellation_info.patchControlPoints
3947
3949 blend_desc.pNext = NULL;
3950 blend_desc.flags = 0;
3951 blend_desc.logicOpEnable = graphics->om_logic_op_enable;
3952 blend_desc.logicOp = graphics->om_logic_op;
3953 blend_desc.attachmentCount = graphics->rt_count;
3954 blend_desc.pAttachments = graphics->blend_attachments;
3955 blend_desc.blendConstants[0] = D3D12_DEFAULT_BLEND_FACTOR_RED;
3956 blend_desc.blendConstants[1] = D3D12_DEFAULT_BLEND_FACTOR_GREEN;
3957 blend_desc.blendConstants[2] = D3D12_DEFAULT_BLEND_FACTOR_BLUE;
3958 blend_desc.blendConstants[3] = D3D12_DEFAULT_BLEND_FACTOR_ALPHA;
3959
3961 pipeline_desc.pNext = NULL;
3962 pipeline_desc.flags = 0;
3963 pipeline_desc.stageCount = graphics->stage_count;
3964 pipeline_desc.pStages = graphics->stages;
3965 pipeline_desc.pVertexInputState = &input_desc;
3966 pipeline_desc.pInputAssemblyState = &ia_desc;
3967 pipeline_desc.pTessellationState = &tessellation_info;
3968 pipeline_desc.pViewportState = &vp_desc;
3969 pipeline_desc.pRasterizationState = &graphics->rs_desc;
3970 pipeline_desc.pMultisampleState = &graphics->ms_desc;
3971 pipeline_desc.pDepthStencilState = &graphics->ds_desc;
3972 pipeline_desc.pColorBlendState = &blend_desc;
3973 pipeline_desc.pDynamicState = &dynamic_desc;
3974 pipeline_desc.layout = state->uav_counters.vk_pipeline_layout ? state->uav_counters.vk_pipeline_layout
3975 : graphics->root_signature->vk_pipeline_layout;
3976 pipeline_desc.subpass = 0;
3977 pipeline_desc.basePipelineHandle = VK_NULL_HANDLE;
3978 pipeline_desc.basePipelineIndex = -1;
3979
3980 /* Create a render pass for pipelines with DXGI_FORMAT_UNKNOWN. */
3981 if (!(pipeline_desc.renderPass = graphics->render_pass))
3982 {
3983 if (graphics->null_attachment_mask & dsv_attachment_mask(graphics))
3984 TRACE("Compiling %p with DSV format %#x.\n", state, dsv_format);
3985
3987 &pipeline_desc.renderPass)))
3988 return VK_NULL_HANDLE;
3989 }
3990
3991 *vk_render_pass = pipeline_desc.renderPass;
3992
3993 if ((vr = VK_CALL(vkCreateGraphicsPipelines(device->vk_device, device->vk_pipeline_cache,
3994 1, &pipeline_desc, NULL, &vk_pipeline))) < 0)
3995 {
3996 WARN("Failed to create Vulkan graphics pipeline, vr %d.\n", vr);
3997 return VK_NULL_HANDLE;
3998 }
3999
4000 if (d3d12_pipeline_state_put_pipeline_to_cache(state, &pipeline_key, vk_pipeline, pipeline_desc.renderPass))
4001 return vk_pipeline;
4002
4003 /* Other thread compiled the pipeline before us. */
4004 VK_CALL(vkDestroyPipeline(device->vk_device, vk_pipeline, NULL));
4005 vk_pipeline = d3d12_pipeline_state_find_compiled_pipeline(state, &pipeline_key, vk_render_pass);
4006 if (!vk_pipeline)
4007 ERR("Could not get the pipeline compiled by other thread from the cache.\n");
4008 return vk_pipeline;
4009}
#define ARRAY_SIZE(A)
Definition: main.h:20
const UINT D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT
Definition: d3d12.idl:265
@ D3D_PRIMITIVE_TOPOLOGY_1_CONTROL_POINT_PATCHLIST
Definition: d3dcommon.idl:395
UINT32 uint32_t
Definition: types.h:75
GLenum GLint GLuint mask
Definition: glext.h:6028
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define b
Definition: ke_i.h:79
static RPC_BINDING_HANDLE binding
Definition: server.c:166
static HRESULT d3d12_graphics_pipeline_state_create_render_pass(struct d3d12_graphics_pipeline_state *graphics, struct d3d12_device *device, VkFormat dynamic_dsv_format, VkRenderPass *vk_render_pass)
Definition: state.c:3001
static enum VkPrimitiveTopology vk_topology_from_d3d12_topology(D3D12_PRIMITIVE_TOPOLOGY topology)
Definition: state.c:3695
static bool vk_topology_can_restart(VkPrimitiveTopology topology)
Definition: state.c:3750
static bool d3d12_pipeline_state_put_pipeline_to_cache(struct d3d12_pipeline_state *state, const struct vkd3d_pipeline_key *key, VkPipeline vk_pipeline, VkRenderPass vk_render_pass)
Definition: state.c:3794
static VkPipeline d3d12_pipeline_state_find_compiled_pipeline(const struct d3d12_pipeline_state *state, const struct vkd3d_pipeline_key *key, VkRenderPass *vk_render_pass)
Definition: state.c:3767
const VkPipelineTessellationStateCreateInfo * pTessellationState
Definition: vulkan.h:17601
const VkPipelineDepthStencilStateCreateInfo * pDepthStencilState
Definition: vulkan.h:17605
const VkPipelineDynamicStateCreateInfo * pDynamicState
Definition: vulkan.h:17607
const VkPipelineColorBlendStateCreateInfo * pColorBlendState
Definition: vulkan.h:17606
VkPipelineCreateFlags flags
Definition: vulkan.h:17596
const VkPipelineInputAssemblyStateCreateInfo * pInputAssemblyState
Definition: vulkan.h:17600
const VkPipelineMultisampleStateCreateInfo * pMultisampleState
Definition: vulkan.h:17604
const VkPipelineVertexInputStateCreateInfo * pVertexInputState
Definition: vulkan.h:17599
const VkPipelineShaderStageCreateInfo * pStages
Definition: vulkan.h:17598
VkStructureType sType
Definition: vulkan.h:17594
const VkPipelineRasterizationStateCreateInfo * pRasterizationState
Definition: vulkan.h:17603
const VkPipelineViewportStateCreateInfo * pViewportState
Definition: vulkan.h:17602
VkPipelineColorBlendStateCreateFlags flags
Definition: vulkan.h:13050
const VkPipelineColorBlendAttachmentState * pAttachments
Definition: vulkan.h:13054
VkPipelineInputAssemblyStateCreateFlags flags
Definition: vulkan.h:13216
VkPipelineTessellationStateCreateFlags flags
Definition: vulkan.h:13376
const VkVertexInputBindingDivisorDescription * pVertexBindingDivisors
Definition: vulkan.h:16666
const VkVertexInputAttributeDescription * pVertexAttributeDescriptions
Definition: vulkan.h:16679
const VkVertexInputBindingDescription * pVertexBindingDescriptions
Definition: vulkan.h:16677
VkPipelineVertexInputStateCreateFlags flags
Definition: vulkan.h:16675
VkPipelineDepthStencilStateCreateInfo ds_desc
D3D12_INDEX_BUFFER_STRIP_CUT_VALUE index_buffer_strip_cut_value
VkPipelineMultisampleStateCreateInfo ms_desc
VkVertexInputAttributeDescription attributes[D3D12_VS_INPUT_REGISTER_COUNT]
VkPipelineRasterizationStateCreateInfo rs_desc
const struct d3d12_root_signature * root_signature
VkPipelineShaderStageCreateInfo stages[VKD3D_MAX_SHADER_STAGES]
VkVertexInputBindingDivisorDescriptionEXT instance_divisors[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
VkVertexInputRate input_rates[D3D12_IA_VERTEX_INPUT_RESOURCE_SLOT_COUNT]
VkPipelineColorBlendAttachmentState blend_attachments[D3D12_SIMULTANEOUS_RENDER_TARGET_COUNT]
D3D12_PRIMITIVE_TOPOLOGY topology
Definition: state.c:2046
#define max(a, b)
Definition: svc.c:63
static bool d3d12_pipeline_state_is_graphics(const struct d3d12_pipeline_state *state)
static unsigned int dsv_attachment_mask(const struct d3d12_graphics_pipeline_state *graphics)
VkDynamicState
Definition: vulkan.h:2605
@ VK_DYNAMIC_STATE_BLEND_CONSTANTS
Definition: vulkan.h:2610
@ VK_DYNAMIC_STATE_VIEWPORT
Definition: vulkan.h:2606
@ VK_DYNAMIC_STATE_DEPTH_BOUNDS
Definition: vulkan.h:2611
@ VK_DYNAMIC_STATE_STENCIL_REFERENCE
Definition: vulkan.h:2614
@ VK_DYNAMIC_STATE_SCISSOR
Definition: vulkan.h:2607
@ VK_PRIMITIVE_TOPOLOGY_MAX_ENUM
Definition: vulkan.h:4447
VkResult
Definition: vulkan.h:4639
VkResult VKAPI_CALL vkCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, uint32_t createInfoCount, const VkGraphicsPipelineCreateInfo *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines)
void VKAPI_CALL vkDestroyPipeline(VkDevice device, VkPipeline pipeline, const VkAllocationCallbacks *pAllocator)
@ VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO
Definition: vulkan.h:4991
@ VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO
Definition: vulkan.h:4990
@ VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO
Definition: vulkan.h:4984
@ VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO
Definition: vulkan.h:4992
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT
Definition: vulkan.h:5938
@ VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO
Definition: vulkan.h:4985
@ VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO
Definition: vulkan.h:4986
@ VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO
Definition: vulkan.h:4983

Referenced by d3d12_command_list_update_graphics_pipeline().

◆ d3d12_pipeline_state_has_unknown_dsv_format()

static bool d3d12_pipeline_state_has_unknown_dsv_format ( struct d3d12_pipeline_state *  state)
inlinestatic

Definition at line 1096 of file vkd3d_private.h.

1097{
1099 {
1100 struct d3d12_graphics_pipeline_state *graphics = &state->u.graphics;
1101
1102 return graphics->null_attachment_mask & dsv_attachment_mask(graphics);
1103 }
1104
1105 return false;
1106}

Referenced by d3d12_command_list_has_depth_stencil_view(), and d3d12_command_list_OMSetRenderTargets().

◆ d3d12_pipeline_state_is_compute()

static bool d3d12_pipeline_state_is_compute ( const struct d3d12_pipeline_state *  state)
inlinestatic

◆ d3d12_pipeline_state_is_graphics()

◆ d3d12_placed_resource_create()

HRESULT d3d12_placed_resource_create ( struct d3d12_device *  device,
struct d3d12_heap *  heap,
uint64_t  heap_offset,
const D3D12_RESOURCE_DESC1 *  desc,
D3D12_RESOURCE_STATES  initial_state,
const D3D12_CLEAR_VALUE *  optimized_clear_value,
struct d3d12_resource **  resource 
)

Definition at line 2216 of file resource.c.

2219{
2220 struct d3d12_resource *object;
2221 HRESULT hr;
2222
2223 if (FAILED(hr = d3d12_resource_create(device, &heap->desc.Properties, heap->desc.Flags,
2224 desc, initial_state, optimized_clear_value, &object)))
2225 return hr;
2226
2228 {
2229 d3d12_resource_Release(&object->ID3D12Resource2_iface);
2230 return hr;
2231 }
2232
2233 TRACE("Created placed resource %p.\n", object);
2234
2235 *resource = object;
2236
2237 return S_OK;
2238}
static HRESULT vkd3d_bind_heap_memory(struct d3d12_device *device, struct d3d12_resource *resource, struct d3d12_heap *heap, uint64_t heap_offset)
Definition: resource.c:2147
uint64_t heap_offset

Referenced by d3d12_device_CreatePlacedResource(), and d3d12_device_CreatePlacedResource1().

◆ d3d12_query_heap_create()

HRESULT d3d12_query_heap_create ( struct d3d12_device *  device,
const D3D12_QUERY_HEAP_DESC *  desc,
struct d3d12_query_heap **  heap 
)

Definition at line 4568 of file resource.c.

4570{
4571 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4572 struct d3d12_query_heap *object;
4573 VkQueryPoolCreateInfo pool_info;
4574 unsigned int element_count;
4575 VkResult vr;
4576 HRESULT hr;
4577
4578 element_count = DIV_ROUND_UP(desc->Count, sizeof(*object->availability_mask) * CHAR_BIT);
4580 return E_OUTOFMEMORY;
4581
4582 object->ID3D12QueryHeap_iface.lpVtbl = &d3d12_query_heap_vtbl;
4583 object->refcount = 1;
4584 object->device = device;
4585 memset(object->availability_mask, 0, element_count * sizeof(*object->availability_mask));
4586
4588 pool_info.pNext = NULL;
4589 pool_info.flags = 0;
4590 pool_info.queryCount = desc->Count;
4591
4592 switch (desc->Type)
4593 {
4596 pool_info.pipelineStatistics = 0;
4597 break;
4598
4601 pool_info.pipelineStatistics = 0;
4602 break;
4603
4617 break;
4618
4620 if (!device->vk_info.transform_feedback_queries)
4621 {
4622 FIXME("Transform feedback queries are not supported by Vulkan implementation.\n");
4623 vkd3d_free(object);
4624 return E_NOTIMPL;
4625 }
4626
4628 pool_info.pipelineStatistics = 0;
4629 break;
4630
4631 default:
4632 WARN("Invalid query heap type %u.\n", desc->Type);
4633 vkd3d_free(object);
4634 return E_INVALIDARG;
4635 }
4636
4637 if (FAILED(hr = vkd3d_private_store_init(&object->private_store)))
4638 {
4639 vkd3d_free(object);
4640 return hr;
4641 }
4642
4643 if ((vr = VK_CALL(vkCreateQueryPool(device->vk_device, &pool_info, NULL, &object->vk_query_pool))) < 0)
4644 {
4645 WARN("Failed to create Vulkan query pool, vr %d.\n", vr);
4646 vkd3d_private_store_destroy(&object->private_store);
4647 vkd3d_free(object);
4648 return hresult_from_vk_result(vr);
4649 }
4650
4652
4653 TRACE("Created query heap %p.\n", object);
4654
4655 *heap = object;
4656
4657 return S_OK;
4658}
@ D3D12_QUERY_HEAP_TYPE_TIMESTAMP
Definition: d3d12.idl:3073
@ D3D12_QUERY_HEAP_TYPE_SO_STATISTICS
Definition: d3d12.idl:3075
@ D3D12_QUERY_HEAP_TYPE_PIPELINE_STATISTICS
Definition: d3d12.idl:3074
@ D3D12_QUERY_HEAP_TYPE_OCCLUSION
Definition: d3d12.idl:3072
#define E_NOTIMPL
Definition: ddrawi.h:99
#define CHAR_BIT
Definition: cabinet.h:45
static HRESULT hresult_from_vk_result(VkResult vr)
Definition: swapchain.c:1114
static ULONG ** element_count
Definition: exception.c:124
static const struct ID3D12QueryHeapVtbl d3d12_query_heap_vtbl
Definition: resource.c:4545
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
uint64_t availability_mask[]
struct d3d12_device * device
#define DIV_ROUND_UP(a, b)
Definition: vkd3d_common.h:45
static void vkd3d_private_store_destroy(struct vkd3d_private_store *store)
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 d3d12_device_CreateQueryHeap().

◆ d3d12_query_heap_is_result_available()

static bool d3d12_query_heap_is_result_available ( const struct d3d12_query_heap *  heap,
unsigned int  query_index 
)
inlinestatic

Definition at line 891 of file vkd3d_private.h.

893{
894 unsigned int index = query_index / (sizeof(*heap->availability_mask) * CHAR_BIT);
895 unsigned int shift = query_index % (sizeof(*heap->availability_mask) * CHAR_BIT);
896 return heap->availability_mask[index] & ((uint64_t)1 << shift);
897}
#define index(s, c)
Definition: various.h:29
GLuint index
Definition: glext.h:6031
#define shift
Definition: input.c:3280
#define uint64_t
Definition: nsiface.idl:62

Referenced by d3d12_command_list_ResolveQueryData().

◆ d3d12_query_heap_mark_result_as_available()

static void d3d12_query_heap_mark_result_as_available ( struct d3d12_query_heap *  heap,
unsigned int  query_index 
)
inlinestatic

Definition at line 899 of file vkd3d_private.h.

901{
902 unsigned int index = query_index / (sizeof(*heap->availability_mask) * CHAR_BIT);
903 unsigned int shift = query_index % (sizeof(*heap->availability_mask) * CHAR_BIT);
904 heap->availability_mask[index] |= (uint64_t)1 << shift;
905}

Referenced by d3d12_command_list_EndQuery().

◆ d3d12_reserved_resource_create()

HRESULT d3d12_reserved_resource_create ( struct d3d12_device *  device,
const D3D12_RESOURCE_DESC1 *  desc,
D3D12_RESOURCE_STATES  initial_state,
const D3D12_CLEAR_VALUE *  optimized_clear_value,
struct d3d12_resource **  resource 
)

Definition at line 2240 of file resource.c.

2243{
2244 struct d3d12_resource *object;
2245 HRESULT hr;
2246
2248 desc, initial_state, optimized_clear_value, &object)))
2249 return hr;
2250
2251 if (!d3d12_resource_init_tiles(object, device))
2252 {
2253 d3d12_resource_Release(&object->ID3D12Resource2_iface);
2254 return E_OUTOFMEMORY;
2255 }
2256
2257 TRACE("Created reserved resource %p.\n", object);
2258
2259 *resource = object;
2260
2261 return S_OK;
2262}
static bool d3d12_resource_init_tiles(struct d3d12_resource *resource, struct d3d12_device *device)
Definition: resource.c:1144

Referenced by d3d12_device_CreateReservedResource().

◆ d3d12_resource_desc1_from_desc()

◆ d3d12_resource_desc_get_depth()

static unsigned int d3d12_resource_desc_get_depth ( const D3D12_RESOURCE_DESC1 *  desc,
unsigned int  miplevel_idx 
)
inlinestatic

◆ d3d12_resource_desc_get_height()

◆ d3d12_resource_desc_get_layer_count()

static unsigned int d3d12_resource_desc_get_layer_count ( const D3D12_RESOURCE_DESC1 *  desc)
inlinestatic

Definition at line 1716 of file vkd3d_private.h.

1717{
1718 return desc->Dimension != D3D12_RESOURCE_DIMENSION_TEXTURE3D ? desc->DepthOrArraySize : 1;
1719}

Referenced by d3d12_command_list_CopyResource(), d3d12_resource_desc_get_sub_resource_count(), and init_default_texture_view_desc().

◆ d3d12_resource_desc_get_sub_resource_count()

static unsigned int d3d12_resource_desc_get_sub_resource_count ( const D3D12_RESOURCE_DESC1 *  desc)
inlinestatic

Definition at line 1721 of file vkd3d_private.h.

1722{
1723 return d3d12_resource_desc_get_layer_count(desc) * desc->MipLevels;
1724}
static unsigned int d3d12_resource_desc_get_layer_count(const D3D12_RESOURCE_DESC1 *desc)

Referenced by d3d12_command_list_ResourceBarrier(), d3d12_device_get_copyable_footprints(), d3d12_resource_init_tiles(), d3d12_resource_Map(), and d3d12_resource_Unmap().

◆ d3d12_resource_desc_get_width()

◆ d3d12_resource_get_tiling()

void d3d12_resource_get_tiling ( struct d3d12_device *  device,
const struct d3d12_resource *  resource,
UINT *  total_tile_count,
D3D12_PACKED_MIP_INFO *  packed_mip_info,
D3D12_TILE_SHAPE *  standard_tile_shape,
UINT *  sub_resource_tiling_count,
UINT  first_sub_resource_tiling,
D3D12_SUBRESOURCE_TILING *  sub_resource_tilings 
)

Definition at line 1085 of file resource.c.

1089{
1090 unsigned int i, subresource, subresource_count, miplevel_idx, count;
1091 const struct vkd3d_subresource_tile_info *tile_info;
1092 const VkExtent3D *tile_extent;
1093
1094 tile_extent = &resource->tiles.tile_extent;
1095
1096 if (packed_mip_info)
1097 {
1098 packed_mip_info->NumStandardMips = resource->tiles.standard_mip_count;
1099 packed_mip_info->NumPackedMips = resource->desc.MipLevels - packed_mip_info->NumStandardMips;
1100 packed_mip_info->NumTilesForPackedMips = !!resource->tiles.packed_mip_tile_count; /* non-zero dummy value */
1101 packed_mip_info->StartTileIndexInOverallResource = packed_mip_info->NumPackedMips
1102 ? resource->tiles.subresources[resource->tiles.standard_mip_count].offset : 0;
1103 }
1104
1105 if (standard_tile_shape)
1106 {
1107 /* D3D12 docs say tile shape is cleared to zero if there is no standard mip, but drivers don't to do this. */
1108 standard_tile_shape->WidthInTexels = tile_extent->width;
1109 standard_tile_shape->HeightInTexels = tile_extent->height;
1110 standard_tile_shape->DepthInTexels = tile_extent->depth;
1111 }
1112
1113 if (total_tile_count)
1114 *total_tile_count = resource->tiles.total_count;
1115
1116 if (!subresource_tiling_count)
1117 return;
1118
1119 subresource_count = resource->tiles.subresource_count;
1120
1121 count = subresource_count - min(first_subresource_tiling, subresource_count);
1122 count = min(count, *subresource_tiling_count);
1123
1124 for (i = 0; i < count; ++i)
1125 {
1126 subresource = i + first_subresource_tiling;
1127 miplevel_idx = subresource % resource->desc.MipLevels;
1128 if (miplevel_idx >= resource->tiles.standard_mip_count)
1129 {
1130 memset(&subresource_tilings[i], 0, sizeof(subresource_tilings[i]));
1131 subresource_tilings[i].StartTileIndexInOverallResource = D3D12_PACKED_TILE;
1132 continue;
1133 }
1134
1135 tile_info = &resource->tiles.subresources[subresource];
1136 subresource_tilings[i].StartTileIndexInOverallResource = tile_info->offset;
1137 subresource_tilings[i].WidthInTiles = tile_info->extent.width;
1138 subresource_tilings[i].HeightInTiles = tile_info->extent.height;
1139 subresource_tilings[i].DepthInTiles = tile_info->extent.depth;
1140 }
1141 *subresource_tiling_count = i;
1142}
const UINT D3D12_PACKED_TILE
Definition: d3d12.idl:298
GLuint GLuint GLsizei count
Definition: gl.h:1545
UINT NumTilesForPackedMips
Definition: d3d12.idl:898
UINT StartTileIndexInOverallResource
Definition: d3d12.idl:899
UINT DepthInTexels
Definition: d3d12.idl:869
UINT WidthInTexels
Definition: d3d12.idl:867
UINT HeightInTexels
Definition: d3d12.idl:868
uint32_t depth
Definition: vulkan.h:8674
uint32_t height
Definition: vulkan.h:8673
uint32_t width
Definition: vulkan.h:8672
struct vkd3d_tiled_region_extent extent

Referenced by d3d12_device_GetResourceTiling().

◆ d3d12_resource_is_buffer()

◆ d3d12_resource_is_cpu_accessible()

bool d3d12_resource_is_cpu_accessible ( const struct d3d12_resource *  resource)

Definition at line 1029 of file resource.c.

1030{
1031 return resource->heap && is_cpu_accessible_heap(&resource->heap->desc.Properties);
1032}
static bool is_cpu_accessible_heap(const D3D12_HEAP_PROPERTIES *properties)
Definition: resource.c:27

Referenced by d3d12_command_list_transition_resource_to_initial_state(), d3d12_resource_Map(), d3d12_resource_ReadFromSubresource(), and d3d12_resource_WriteToSubresource().

◆ d3d12_resource_is_texture()

◆ d3d12_resource_validate_desc()

HRESULT d3d12_resource_validate_desc ( const D3D12_RESOURCE_DESC1 *  desc,
struct d3d12_device *  device 
)

Definition at line 1850 of file resource.c.

1851{
1852 const D3D12_MIP_REGION *mip_region = &desc->SamplerFeedbackMipRegion;
1853 const struct vkd3d_format *format;
1854
1855 switch (desc->Dimension)
1856 {
1858 if (desc->MipLevels != 1)
1859 {
1860 WARN("Invalid miplevel count %u for buffer.\n", desc->MipLevels);
1861 return E_INVALIDARG;
1862 }
1863
1864 if (desc->Format != DXGI_FORMAT_UNKNOWN || desc->Layout != D3D12_TEXTURE_LAYOUT_ROW_MAJOR
1865 || desc->Height != 1 || desc->DepthOrArraySize != 1
1866 || desc->SampleDesc.Count != 1 || desc->SampleDesc.Quality != 0
1867 || (desc->Alignment != 0 && desc->Alignment != D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT))
1868 {
1869 WARN("Invalid parameters for a buffer resource.\n");
1870 return E_INVALIDARG;
1871 }
1872 break;
1873
1875 if (desc->Height != 1)
1876 {
1877 WARN("1D texture with a height of %u.\n", desc->Height);
1878 return E_INVALIDARG;
1879 }
1880 /* Fall through. */
1883 if (!desc->SampleDesc.Count)
1884 {
1885 WARN("Invalid sample count 0.\n");
1886 return E_INVALIDARG;
1887 }
1888 if (desc->SampleDesc.Count > 1
1890 {
1891 WARN("Sample count %u invalid without ALLOW_RENDER_TARGET or ALLOW_DEPTH_STENCIL.\n",
1892 desc->SampleDesc.Count);
1893 return E_INVALIDARG;
1894 }
1895
1897 {
1898 WARN("Invalid format %#x.\n", desc->Format);
1899 return E_INVALIDARG;
1900 }
1901
1903 {
1904 if (desc->Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D && !device->vk_info.sparse_residency_3d)
1905 {
1906 WARN("The device does not support tiled 3D images.\n");
1907 return E_INVALIDARG;
1908 }
1909 if (format->plane_count > 1)
1910 {
1911 WARN("Invalid format %#x. D3D12 does not support multiplanar formats for tiled resources.\n",
1912 format->dxgi_format);
1913 return E_INVALIDARG;
1914 }
1915 }
1916
1919 return E_INVALIDARG;
1920 break;
1921
1922 default:
1923 WARN("Invalid resource dimension %#x.\n", desc->Dimension);
1924 return E_INVALIDARG;
1925 }
1926
1928
1929 if (mip_region->Width && mip_region->Height && mip_region->Depth)
1930 {
1931 FIXME("Unhandled sampler feedback mip region size (%u, %u, %u).\n", mip_region->Width, mip_region->Height,
1932 mip_region->Depth);
1933 }
1934
1935 return S_OK;
1936}
@ D3D12_RESOURCE_DIMENSION_TEXTURE1D
Definition: d3d12.idl:984
@ D3D12_RESOURCE_DIMENSION_TEXTURE2D
Definition: d3d12.idl:985
@ D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL
Definition: d3d12.idl:1001
@ D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET
Definition: d3d12.idl:1000
const UINT D3D12_DEFAULT_RESOURCE_PLACEMENT_ALIGNMENT
Definition: d3d12.idl:140
@ D3D12_TEXTURE_LAYOUT_ROW_MAJOR
Definition: d3d12.idl:992
@ D3D12_TEXTURE_LAYOUT_64KB_UNDEFINED_SWIZZLE
Definition: d3d12.idl:993
@ DXGI_FORMAT_UNKNOWN
Definition: dxgiformat.idl:23
static bool d3d12_resource_validate_texture_alignment(const D3D12_RESOURCE_DESC1 *desc, const struct vkd3d_format *format)
Definition: resource.c:1815
static void d3d12_validate_resource_flags(D3D12_RESOURCE_FLAGS flags)
Definition: resource.c:1778
static bool d3d12_resource_validate_texture_format(const D3D12_RESOURCE_DESC1 *desc, const struct vkd3d_format *format)
Definition: resource.c:1794
static const struct vkd3d_format * vkd3d_format_from_d3d12_resource_desc(const struct d3d12_device *device, const D3D12_RESOURCE_DESC1 *desc, DXGI_FORMAT view_format)

Referenced by d3d12_device_get_copyable_footprints(), d3d12_device_get_resource1_allocation_info(), d3d12_resource_init(), and vkd3d_get_image_allocation_info().

◆ d3d12_root_signature_create()

HRESULT d3d12_root_signature_create ( struct d3d12_device *  device,
const void *  bytecode,
size_t  bytecode_length,
struct d3d12_root_signature **  root_signature 
)

Definition at line 1630 of file state.c.

1632{
1633 const struct vkd3d_shader_code dxbc = {bytecode, bytecode_length};
1634 union
1635 {
1638 } root_signature_desc;
1640 HRESULT hr;
1641 int ret;
1642
1643 if ((ret = vkd3d_parse_root_signature_v_1_0(&dxbc, &root_signature_desc.vkd3d)) < 0)
1644 {
1645 WARN("Failed to parse root signature, vkd3d result %d.\n", ret);
1647 }
1648
1649 if (!(object = vkd3d_malloc(sizeof(*object))))
1650 {
1651 vkd3d_shader_free_root_signature(&root_signature_desc.vkd3d);
1652 return E_OUTOFMEMORY;
1653 }
1654
1655 hr = d3d12_root_signature_init(object, device, &root_signature_desc.d3d12.u.Desc_1_0);
1656 vkd3d_shader_free_root_signature(&root_signature_desc.vkd3d);
1657 if (FAILED(hr))
1658 {
1659 vkd3d_free(object);
1660 return hr;
1661 }
1662
1663 TRACE("Created root signature %p.\n", object);
1664
1665 *root_signature = object;
1666
1667 return S_OK;
1668}
static HRESULT hresult_from_vkd3d_result(int vkd3d_result)
Definition: compiler.c:30
return ret
Definition: mutex.c:147
static HRESULT d3d12_root_signature_init(struct d3d12_root_signature *root_signature, struct d3d12_device *device, const D3D12_ROOT_SIGNATURE_DESC *desc)
Definition: state.c:1509
int vkd3d_parse_root_signature_v_1_0(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_versioned_root_signature_desc *out_desc)
Definition: vkd3d_main.c:170
VKD3D_SHADER_API void vkd3d_shader_free_root_signature(struct vkd3d_shader_versioned_root_signature_desc *root_signature)

Referenced by d3d12_device_CreateRootSignature(), and d3d12_pipeline_state_init_compute().

◆ d3d12_rtv_desc_create_rtv()

void d3d12_rtv_desc_create_rtv ( struct d3d12_rtv_desc *  rtv_desc,
struct d3d12_device *  device,
struct d3d12_resource *  resource,
const D3D12_RENDER_TARGET_VIEW_DESC *  desc 
)

Definition at line 3835 of file resource.c.

3837{
3838 struct vkd3d_texture_view_desc vkd3d_desc;
3839 struct vkd3d_view *view;
3840
3841 d3d12_rtv_desc_destroy(rtv_desc, device);
3842
3843 if (!resource)
3844 {
3845 FIXME("NULL resource RTV not implemented.\n");
3846 return;
3847 }
3848
3849 if (!init_default_texture_view_desc(&vkd3d_desc, resource, desc ? desc->Format : 0))
3850 return;
3851
3852 vkd3d_desc.usage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT;
3853
3854 if (vkd3d_desc.format->vk_aspect_mask != VK_IMAGE_ASPECT_COLOR_BIT)
3855 {
3856 WARN("Trying to create RTV for depth/stencil format %#x.\n", vkd3d_desc.format->dxgi_format);
3857 return;
3858 }
3859
3860 if (desc)
3861 {
3862 switch (desc->ViewDimension)
3863 {
3865 vkd3d_desc.miplevel_idx = desc->u.Texture2D.MipSlice;
3866 if (desc->u.Texture2D.PlaneSlice)
3867 vkd3d_desc.vk_image_aspect = vk_image_aspect_flags_from_d3d12_plane_slice(resource->format,
3868 desc->u.Texture2D.PlaneSlice);
3869 break;
3871 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3872 vkd3d_desc.miplevel_idx = desc->u.Texture2DArray.MipSlice;
3873 vkd3d_desc.layer_idx = desc->u.Texture2DArray.FirstArraySlice;
3874 vkd3d_desc.layer_count = desc->u.Texture2DArray.ArraySize;
3875 if (desc->u.Texture2DArray.PlaneSlice)
3876 vkd3d_desc.vk_image_aspect = vk_image_aspect_flags_from_d3d12_plane_slice(resource->format,
3877 desc->u.Texture2DArray.PlaneSlice);
3878 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3879 break;
3881 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D;
3882 break;
3884 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3885 vkd3d_desc.layer_idx = desc->u.Texture2DMSArray.FirstArraySlice;
3886 vkd3d_desc.layer_count = desc->u.Texture2DMSArray.ArraySize;
3887 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3888 break;
3890 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3891 vkd3d_desc.miplevel_idx = desc->u.Texture3D.MipSlice;
3892 vkd3d_desc.layer_idx = desc->u.Texture3D.FirstWSlice;
3893 vkd3d_desc.layer_count = desc->u.Texture3D.WSize;
3894 vkd3d_texture_view_desc_normalise(&vkd3d_desc, &resource->desc);
3895 break;
3896 default:
3897 FIXME("Unhandled view dimension %#x.\n", desc->ViewDimension);
3898 }
3899 }
3900 else if (resource->desc.Dimension == D3D12_RESOURCE_DIMENSION_TEXTURE3D)
3901 {
3902 vkd3d_desc.view_type = VK_IMAGE_VIEW_TYPE_2D_ARRAY;
3903 vkd3d_desc.layer_idx = 0;
3904 vkd3d_desc.layer_count = resource->desc.DepthOrArraySize;
3905 }
3906
3908
3909 if (!vkd3d_create_texture_view(device, VKD3D_DESCRIPTOR_MAGIC_RTV, resource->u.vk_image, &vkd3d_desc, &view))
3910 return;
3911
3912 rtv_desc->sample_count = vk_samples_from_dxgi_sample_desc(&resource->desc.SampleDesc);
3913 rtv_desc->format = vkd3d_desc.format;
3914 rtv_desc->width = d3d12_resource_desc_get_width(&resource->desc, vkd3d_desc.miplevel_idx);
3915 rtv_desc->height = d3d12_resource_desc_get_height(&resource->desc, vkd3d_desc.miplevel_idx);
3916 rtv_desc->layer_count = vkd3d_desc.layer_count;
3917 rtv_desc->view = view;
3918 rtv_desc->resource = resource;
3919}
@ D3D12_RTV_DIMENSION_TEXTURE2DMSARRAY
Definition: d3d12.idl:1682
@ D3D12_RTV_DIMENSION_TEXTURE3D
Definition: d3d12.idl:1683
@ D3D12_RTV_DIMENSION_TEXTURE2D
Definition: d3d12.idl:1679
@ D3D12_RTV_DIMENSION_TEXTURE2DMS
Definition: d3d12.idl:1681
@ D3D12_RTV_DIMENSION_TEXTURE2DARRAY
Definition: d3d12.idl:1680
static void d3d12_rtv_desc_destroy(struct d3d12_rtv_desc *rtv, struct d3d12_device *device)
Definition: resource.c:3826
struct vkd3d_view * view
VkSampleCountFlagBits sample_count
unsigned int height
unsigned int layer_count
const struct vkd3d_format * format
struct d3d12_resource * resource
#define VKD3D_DESCRIPTOR_MAGIC_RTV
Definition: vkd3d_private.h:52
@ VK_IMAGE_ASPECT_COLOR_BIT
Definition: vulkan.h:3365
@ VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
Definition: vulkan.h:3514

Referenced by d3d12_device_CreateRenderTargetView().

◆ d3d12_rtv_desc_from_cpu_handle()

static struct d3d12_rtv_desc * d3d12_rtv_desc_from_cpu_handle ( D3D12_CPU_DESCRIPTOR_HANDLE  cpu_handle)
inlinestatic

◆ debug_cpu_handle()

◆ debug_d3d12_box()

const char * debug_d3d12_box ( const D3D12_BOX *  box)

Definition at line 650 of file utils.c.

651{
652 if (!box)
653 return "(null)";
654
655 return vkd3d_dbg_sprintf("(%u, %u, %u)-(%u, %u, %u)",
656 box->left, box->top, box->front,
657 box->right, box->bottom, box->back);
658}

Referenced by d3d12_command_list_CopyTextureRegion(), d3d12_resource_ReadFromSubresource(), and d3d12_resource_WriteToSubresource().

◆ debug_d3d12_shader_component_mapping()

const char * debug_d3d12_shader_component_mapping ( unsigned int  mapping)

Definition at line 682 of file utils.c.

683{
684 return vkd3d_dbg_sprintf("{%s, %s, %s, %s}",
685 debug_d3d12_shader_component(D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(0, mapping)),
686 debug_d3d12_shader_component(D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(1, mapping)),
687 debug_d3d12_shader_component(D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(2, mapping)),
688 debug_d3d12_shader_component(D3D12_DECODE_SHADER_4_COMPONENT_MAPPING(3, mapping)));
689}
GLenum GLenum GLenum GLenum mapping
Definition: glext.h:9031
static const char * debug_d3d12_shader_component(D3D12_SHADER_COMPONENT_MAPPING component)
Definition: utils.c:660

Referenced by d3d12_desc_create_srv().

◆ debug_gpu_handle()

◆ debug_ignored_node_mask()

static void debug_ignored_node_mask ( unsigned int  mask)
inlinestatic

◆ debug_vk_extent_3d()

const char * debug_vk_extent_3d ( VkExtent3D  extent)

Definition at line 696 of file utils.c.

697{
698 return vkd3d_dbg_sprintf("(%u, %u, %u)",
699 (unsigned int)extent.width,
700 (unsigned int)extent.height,
701 (unsigned int)extent.depth);
702}

Referenced by vkd3d_trace_physical_device().

◆ debug_vk_memory_heap_flags()

const char * debug_vk_memory_heap_flags ( VkMemoryHeapFlags  flags)

Definition at line 728 of file utils.c.

729{
730 char buffer[80];
731
732 buffer[0] = '\0';
733#define FLAG_TO_STR(f) if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }
736#undef FLAG_TO_STR
737 if (flags)
738 FIXME("Unrecognized flag(s) %#x.\n", flags);
739
740 if (!buffer[0])
741 return "0";
742 return vkd3d_dbg_sprintf("%s", &buffer[3]);
743}
GLuint buffer
Definition: glext.h:5915
#define FLAG_TO_STR(f)
@ VK_MEMORY_HEAP_MULTI_INSTANCE_BIT
Definition: vulkan.h:3749
@ VK_MEMORY_HEAP_DEVICE_LOCAL_BIT
Definition: vulkan.h:3748

Referenced by vkd3d_trace_physical_device().

◆ debug_vk_memory_property_flags()

const char * debug_vk_memory_property_flags ( VkMemoryPropertyFlags  flags)

Definition at line 745 of file utils.c.

746{
747 char buffer[320];
748
749 buffer[0] = '\0';
750#define FLAG_TO_STR(f) if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }
759#undef FLAG_TO_STR
760 if (flags)
761 FIXME("Unrecognized flag(s) %#x.\n", flags);
762
763 if (!buffer[0])
764 return "0";
765 return vkd3d_dbg_sprintf("%s", &buffer[3]);
766}
@ VK_MEMORY_PROPERTY_DEVICE_UNCACHED_BIT_AMD
Definition: vulkan.h:3777
@ VK_MEMORY_PROPERTY_DEVICE_COHERENT_BIT_AMD
Definition: vulkan.h:3776
@ VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT
Definition: vulkan.h:3774
@ VK_MEMORY_PROPERTY_PROTECTED_BIT
Definition: vulkan.h:3775
@ VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT
Definition: vulkan.h:3770
@ VK_MEMORY_PROPERTY_HOST_CACHED_BIT
Definition: vulkan.h:3773

Referenced by vkd3d_trace_physical_device().

◆ debug_vk_queue_flags()

const char * debug_vk_queue_flags ( VkQueueFlags  flags)

Definition at line 704 of file utils.c.

705{
706 char buffer[191];
707
708 buffer[0] = '\0';
709#define FLAG_TO_STR(f) if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }
715#undef FLAG_TO_STR
716#define FLAG_TO_STR(f, n) if (flags & f) { strcat(buffer, " | "#n); flags &= ~f; }
719#undef FLAG_TO_STR
720 if (flags)
721 FIXME("Unrecognized flag(s) %#x.\n", flags);
722
723 if (!buffer[0])
724 return "0";
725 return vkd3d_dbg_sprintf("%s", &buffer[3]);
726}
@ VK_QUEUE_SPARSE_BINDING_BIT
Definition: vulkan.h:4534
@ VK_QUEUE_PROTECTED_BIT
Definition: vulkan.h:4535
@ VK_QUEUE_COMPUTE_BIT
Definition: vulkan.h:4532
@ VK_QUEUE_TRANSFER_BIT
Definition: vulkan.h:4533
@ VK_QUEUE_VIDEO_ENCODE_BIT_KHR
Definition: vulkan.h:4537
@ VK_QUEUE_VIDEO_DECODE_BIT_KHR
Definition: vulkan.h:4536
@ VK_QUEUE_GRAPHICS_BIT
Definition: vulkan.h:4531

Referenced by vkd3d_trace_physical_device().

◆ dsv_attachment_mask()

◆ hresult_from_errno()

HRESULT hresult_from_errno ( int  rc)

Definition at line 768 of file utils.c.

769{
770 switch (rc)
771 {
772 case 0:
773 return S_OK;
774 case ENOMEM:
775 return E_OUTOFMEMORY;
776 case EINVAL:
777 return E_INVALIDARG;
778 default:
779 FIXME("Unhandled errno %d.\n", rc);
780 return E_FAIL;
781 }
782}
#define E_FAIL
Definition: ddrawi.h:102
#define EINVAL
Definition: errno.h:44
#define ENOMEM
Definition: errno.h:35

Referenced by vkd3d_create_thread(), and vkd3d_join_thread().

◆ hresult_from_vk_result()

HRESULT hresult_from_vk_result ( VkResult  vr)

Definition at line 784 of file utils.c.

785{
786 switch (vr)
787 {
788 case VK_SUCCESS:
789 return S_OK;
791 WARN("Out of device memory.\n");
792 /* fall-through */
794 return E_OUTOFMEMORY;
795 default:
796 FIXME("Unhandled VkResult %d.\n", vr);
797 /* fall-through */
800 return E_FAIL;
801 }
802}
@ VK_ERROR_EXTENSION_NOT_PRESENT
Definition: vulkan.h:4665
@ VK_ERROR_DEVICE_LOST
Definition: vulkan.h:4668
@ VK_SUCCESS
Definition: vulkan.h:4672
@ VK_ERROR_OUT_OF_HOST_MEMORY
Definition: vulkan.h:4671
@ VK_ERROR_OUT_OF_DEVICE_MEMORY
Definition: vulkan.h:4670

Referenced by vkd3d_set_vk_object_name().

◆ hresult_from_vkd3d_result()

HRESULT hresult_from_vkd3d_result ( int  vkd3d_result)

Definition at line 21 of file error.c.

22{
23 switch (vkd3d_result)
24 {
25 case VKD3D_OK:
26 return S_OK;
28 WARN("Invalid shader.\n");
29 /* fall-through */
30 case VKD3D_ERROR:
31 return E_FAIL;
33 return E_OUTOFMEMORY;
35 return E_INVALIDARG;
37 return E_NOTIMPL;
44 default:
45 FIXME("Unhandled vkd3d result %d.\n", vkd3d_result);
46 return E_FAIL;
47 }
48}
vkd3d_result
Definition: vkd3d_types.h:41
@ VKD3D_ERROR_INVALID_ARGUMENT
Definition: vkd3d_types.h:51
@ VKD3D_ERROR_NOT_IMPLEMENTED
Definition: vkd3d_types.h:55
@ VKD3D_ERROR_KEY_ALREADY_EXISTS
Definition: vkd3d_types.h:57
@ VKD3D_ERROR_INVALID_SHADER
Definition: vkd3d_types.h:53
@ VKD3D_ERROR_MORE_DATA
Definition: vkd3d_types.h:61
@ VKD3D_ERROR
Definition: vkd3d_types.h:47
@ VKD3D_OK
Definition: vkd3d_types.h:43
@ VKD3D_ERROR_OUT_OF_MEMORY
Definition: vkd3d_types.h:49
@ VKD3D_ERROR_NOT_FOUND
Definition: vkd3d_types.h:59
#define DXGI_ERROR_NOT_FOUND
Definition: winerror.h:7122
#define DXGI_ERROR_MORE_DATA
Definition: winerror.h:7123
#define DXGI_ERROR_ALREADY_EXISTS
Definition: winerror.h:7160

◆ impl_from_ID3D12Resource()

static struct d3d12_resource * impl_from_ID3D12Resource ( ID3D12Resource *  iface)
inlinestatic

◆ impl_from_ID3D12Resource2()

◆ is_valid_feature_level()

bool is_valid_feature_level ( D3D_FEATURE_LEVEL  feature_level)

Definition at line 548 of file utils.c.

549{
550 static const D3D_FEATURE_LEVEL valid_feature_levels[] =
551 {
563 };
564 unsigned int i;
565
566 for (i = 0; i < ARRAY_SIZE(valid_feature_levels); ++i)
567 {
568 if (valid_feature_levels[i] == feature_level)
569 return true;
570 }
571
572 return false;
573}
D3D_FEATURE_LEVEL
Definition: d3dcommon.idl:102
@ D3D_FEATURE_LEVEL_10_0
Definition: d3dcommon.idl:107
@ D3D_FEATURE_LEVEL_9_1
Definition: d3dcommon.idl:104
@ D3D_FEATURE_LEVEL_12_2
Definition: d3dcommon.idl:113
@ D3D_FEATURE_LEVEL_9_2
Definition: d3dcommon.idl:105
@ D3D_FEATURE_LEVEL_9_3
Definition: d3dcommon.idl:106
@ D3D_FEATURE_LEVEL_10_1
Definition: d3dcommon.idl:108
@ D3D_FEATURE_LEVEL_1_0_CORE
Definition: d3dcommon.idl:103
@ D3D_FEATURE_LEVEL_12_1
Definition: d3dcommon.idl:112
@ D3D_FEATURE_LEVEL_12_0
Definition: d3dcommon.idl:111
@ D3D_FEATURE_LEVEL_11_0
Definition: d3dcommon.idl:109
@ D3D_FEATURE_LEVEL_11_1
Definition: d3dcommon.idl:110

Referenced by vkd3d_create_device().

◆ is_valid_resource_state()

bool is_valid_resource_state ( D3D12_RESOURCE_STATES  state)

Definition at line 590 of file utils.c.

591{
592 const D3D12_RESOURCE_STATES valid_states =
611
612 if (state & ~valid_states)
613 {
614 WARN("Invalid resource states %#x.\n", state & ~valid_states);
615 return false;
616 }
617
618 /* Exactly one bit must be set for write states. */
620 {
621 WARN("Write state cannot be mixed with other states: %#x.\n", state);
622 return false;
623 }
624
625 return true;
626}
D3D12_RESOURCE_STATES
Definition: d3d12.idl:903
@ D3D12_RESOURCE_STATE_GENERIC_READ
Definition: d3d12.idl:921
@ D3D12_RESOURCE_STATE_RESOLVE_DEST
Definition: d3d12.idl:917
@ D3D12_RESOURCE_STATE_INDEX_BUFFER
Definition: d3d12.idl:906
@ D3D12_RESOURCE_STATE_COPY_DEST
Definition: d3d12.idl:915
@ D3D12_RESOURCE_STATE_RENDER_TARGET
Definition: d3d12.idl:907
@ D3D12_RESOURCE_STATE_COPY_SOURCE
Definition: d3d12.idl:916
@ D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE
Definition: d3d12.idl:912
@ D3D12_RESOURCE_STATE_UNORDERED_ACCESS
Definition: d3d12.idl:908
@ D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT
Definition: d3d12.idl:914
@ D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE
Definition: d3d12.idl:911
@ D3D12_RESOURCE_STATE_DEPTH_WRITE
Definition: d3d12.idl:909
@ D3D12_RESOURCE_STATE_DEPTH_READ
Definition: d3d12.idl:910
@ D3D12_RESOURCE_STATE_STREAM_OUT
Definition: d3d12.idl:913
@ D3D12_RESOURCE_STATE_COMMON
Definition: d3d12.idl:904
@ D3D12_RESOURCE_STATE_PREDICATION
Definition: d3d12.idl:924
@ D3D12_RESOURCE_STATE_RESOLVE_SOURCE
Definition: d3d12.idl:918
@ D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER
Definition: d3d12.idl:905
@ D3D12_RESOURCE_STATE_PRESENT
Definition: d3d12.idl:923
bool is_write_resource_state(D3D12_RESOURCE_STATES state)
Definition: utils.c:575
static bool is_power_of_two(unsigned int x)
Definition: utils.c:585

Referenced by d3d12_command_list_ResourceBarrier(), d3d12_find_ds_multiplanar_transition(), and d3d12_resource_init().

◆ is_write_resource_state()

◆ return_interface()

◆ unsafe_impl_from_ID3D12CommandSignature()

struct d3d12_command_signature * unsafe_impl_from_ID3D12CommandSignature ( ID3D12CommandSignature *  iface)

Definition at line 7627 of file command.c.

7628{
7629 if (!iface)
7630 return NULL;
7631 VKD3D_ASSERT(iface->lpVtbl == &d3d12_command_signature_vtbl);
7632 return CONTAINING_RECORD(iface, struct d3d12_command_signature, ID3D12CommandSignature_iface);
7633}

Referenced by d3d12_command_list_ExecuteIndirect().

◆ unsafe_impl_from_ID3D12Device9()

void struct d3d12_device * unsafe_impl_from_ID3D12Device9 ( ID3D12Device9 *  iface)

Definition at line 5398 of file device.c.

5399{
5400 if (!iface)
5401 return NULL;
5402 VKD3D_ASSERT(iface->lpVtbl == &d3d12_device_vtbl);
5403 return impl_from_ID3D12Device9(iface);
5404}
static struct d3d12_device * impl_from_ID3D12Device9(ID3D12Device9 *iface)
Definition: device.c:3028
static const struct ID3D12Device9Vtbl d3d12_device_vtbl
Definition: device.c:5306

Referenced by vkd3d_create_image_resource().

◆ unsafe_impl_from_ID3D12Heap()

struct d3d12_heap * unsafe_impl_from_ID3D12Heap ( ID3D12Heap *  iface)

Definition at line 442 of file resource.c.

443{
444 if (!iface)
445 return NULL;
446 VKD3D_ASSERT(iface->lpVtbl == &d3d12_heap_vtbl);
447 return impl_from_ID3D12Heap(iface);
448}
static struct d3d12_heap * impl_from_ID3D12Heap(ID3D12Heap *iface)
Definition: resource.c:281
static const struct ID3D12HeapVtbl d3d12_heap_vtbl
Definition: resource.c:425

Referenced by d3d12_command_queue_UpdateTileMappings(), d3d12_device_CreatePlacedResource(), and d3d12_device_CreatePlacedResource1().

◆ unsafe_impl_from_ID3D12PipelineState()

struct d3d12_pipeline_state * unsafe_impl_from_ID3D12PipelineState ( ID3D12PipelineState *  iface)

Definition at line 2242 of file state.c.

2243{
2244 if (!iface)
2245 return NULL;
2246 VKD3D_ASSERT(iface->lpVtbl == &d3d12_pipeline_state_vtbl);
2247 return impl_from_ID3D12PipelineState(iface);
2248}
static const struct ID3D12PipelineStateVtbl d3d12_pipeline_state_vtbl
Definition: state.c:2225
static struct d3d12_pipeline_state * impl_from_ID3D12PipelineState(ID3D12PipelineState *iface)
Definition: state.c:2060

Referenced by d3d12_command_list_SetPipelineState().

◆ unsafe_impl_from_ID3D12QueryHeap()

struct d3d12_query_heap * unsafe_impl_from_ID3D12QueryHeap ( ID3D12QueryHeap *  iface)

Definition at line 4560 of file resource.c.

4561{
4562 if (!iface)
4563 return NULL;
4564 VKD3D_ASSERT(iface->lpVtbl == &d3d12_query_heap_vtbl);
4565 return impl_from_ID3D12QueryHeap(iface);
4566}
static struct d3d12_query_heap * impl_from_ID3D12QueryHeap(ID3D12QueryHeap *iface)
Definition: resource.c:4435

Referenced by d3d12_command_list_BeginQuery(), d3d12_command_list_EndQuery(), and d3d12_command_list_ResolveQueryData().

◆ unsafe_impl_from_ID3D12Resource()

◆ unsafe_impl_from_ID3D12RootSignature()

struct d3d12_root_signature * unsafe_impl_from_ID3D12RootSignature ( ID3D12RootSignature *  iface)

Definition at line 193 of file state.c.

194{
195 if (!iface)
196 return NULL;
197 VKD3D_ASSERT(iface->lpVtbl == &d3d12_root_signature_vtbl);
198 return impl_from_ID3D12RootSignature(iface);
199}
static struct d3d12_root_signature * impl_from_ID3D12RootSignature(ID3D12RootSignature *iface)
Definition: state.c:26
static const struct ID3D12RootSignatureVtbl d3d12_root_signature_vtbl
Definition: state.c:178

Referenced by d3d12_command_list_SetComputeRootSignature(), d3d12_command_list_SetGraphicsRootSignature(), d3d12_pipeline_state_init_compute(), and d3d12_pipeline_state_init_graphics().

◆ vk_compare_op_from_d3d12()

VkCompareOp vk_compare_op_from_d3d12 ( D3D12_COMPARISON_FUNC  op)

Definition at line 2764 of file state.c.

2765{
2766 switch (op)
2767 {
2769 return VK_COMPARE_OP_NEVER;
2771 return VK_COMPARE_OP_LESS;
2773 return VK_COMPARE_OP_EQUAL;
2777 return VK_COMPARE_OP_GREATER;
2783 return VK_COMPARE_OP_ALWAYS;
2784 default:
2785 FIXME("Unhandled compare op %#x.\n", op);
2786 return VK_COMPARE_OP_NEVER;
2787 }
2788}
@ D3D12_COMPARISON_FUNC_GREATER_EQUAL
Definition: d3d12.idl:1345
@ D3D12_COMPARISON_FUNC_ALWAYS
Definition: d3d12.idl:1346
@ D3D12_COMPARISON_FUNC_NOT_EQUAL
Definition: d3d12.idl:1344
@ D3D12_COMPARISON_FUNC_LESS_EQUAL
Definition: d3d12.idl:1342
@ D3D12_COMPARISON_FUNC_LESS
Definition: d3d12.idl:1340
@ D3D12_COMPARISON_FUNC_NEVER
Definition: d3d12.idl:1339
@ D3D12_COMPARISON_FUNC_EQUAL
Definition: d3d12.idl:1341
@ D3D12_COMPARISON_FUNC_GREATER
Definition: d3d12.idl:1343
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

Referenced by d3d12_create_sampler(), ds_desc_from_d3d12(), and vk_stencil_op_state_from_d3d12().

◆ vk_prepend_struct()

static void vk_prepend_struct ( void *  header,
void *  structure 
)
inlinestatic

Definition at line 1773 of file vkd3d_private.h.

1774{
1775 VkBaseOutStructure *vk_header = header, *vk_structure = structure;
1776
1777 vk_structure->pNext = vk_header->pNext;
1778 vk_header->pNext = vk_structure;
1779}
struct VkBaseOutStructure * pNext
Definition: vulkan.h:7431

Referenced by rs_depth_clip_info_from_d3d12(), rs_stream_info_from_d3d12(), and vkd3d_chain_physical_device_info_structures().

◆ vk_samples_from_dxgi_sample_desc()

VkSampleCountFlagBits vk_samples_from_dxgi_sample_desc ( const DXGI_SAMPLE_DESC *  desc)

Definition at line 641 of file resource.c.

642{
643 VkSampleCountFlagBits vk_samples;
644
645 if ((vk_samples = vk_samples_from_sample_count(desc->Count)))
646 return vk_samples;
647
648 FIXME("Unhandled sample count %u.\n", desc->Count);
650}
VkSampleCountFlagBits vk_samples_from_sample_count(unsigned int sample_count)
Definition: resource.c:618
VkSampleCountFlagBits
Definition: vulkan.h:4700
@ VK_SAMPLE_COUNT_1_BIT
Definition: vulkan.h:4701

Referenced by d3d12_dsv_desc_create_dsv(), d3d12_pipeline_state_init_graphics(), d3d12_rtv_desc_create_rtv(), and vkd3d_create_image().

◆ vk_samples_from_sample_count()

VkSampleCountFlagBits vk_samples_from_sample_count ( unsigned int  sample_count)

Definition at line 618 of file resource.c.

619{
620 switch (sample_count)
621 {
622 case 1:
624 case 2:
626 case 4:
628 case 8:
630 case 16:
632 case 32:
634 case 64:
636 default:
637 return 0;
638 }
639}
@ VK_SAMPLE_COUNT_8_BIT
Definition: vulkan.h:4704
@ VK_SAMPLE_COUNT_64_BIT
Definition: vulkan.h:4707
@ VK_SAMPLE_COUNT_32_BIT
Definition: vulkan.h:4706
@ VK_SAMPLE_COUNT_2_BIT
Definition: vulkan.h:4702
@ VK_SAMPLE_COUNT_4_BIT
Definition: vulkan.h:4703
@ VK_SAMPLE_COUNT_16_BIT
Definition: vulkan.h:4705

Referenced by d3d12_device_check_multisample_quality_levels(), and vk_samples_from_dxgi_sample_desc().

◆ vkd3d_allocate_buffer_memory()

HRESULT vkd3d_allocate_buffer_memory ( struct d3d12_device *  device,
VkBuffer  vk_buffer,
const D3D12_HEAP_PROPERTIES *  heap_properties,
D3D12_HEAP_FLAGS  heap_flags,
VkDeviceMemory *  vk_memory,
uint32_t *  vk_memory_type,
VkDeviceSize *  vk_memory_size 
)

Definition at line 155 of file resource.c.

158{
159 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
160 VkMemoryDedicatedAllocateInfo *dedicated_allocation = NULL;
161 VkMemoryDedicatedRequirements dedicated_requirements;
162 VkMemoryDedicatedAllocateInfo dedicated_info;
163 VkMemoryRequirements2 memory_requirements2;
164 VkMemoryRequirements *memory_requirements;
166 VkResult vr;
167 HRESULT hr;
168
169 memory_requirements = &memory_requirements2.memoryRequirements;
170
171 if (device->vk_info.KHR_dedicated_allocation)
172 {
174 info.pNext = NULL;
175 info.buffer = vk_buffer;
176
178 dedicated_requirements.pNext = NULL;
179
180 memory_requirements2.sType = VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2;
181 memory_requirements2.pNext = &dedicated_requirements;
182
183 VK_CALL(vkGetBufferMemoryRequirements2KHR(device->vk_device, &info, &memory_requirements2));
184
185 if (dedicated_requirements.prefersDedicatedAllocation)
186 {
187 dedicated_allocation = &dedicated_info;
188
190 dedicated_info.pNext = NULL;
191 dedicated_info.image = VK_NULL_HANDLE;
192 dedicated_info.buffer = vk_buffer;
193 }
194 }
195 else
196 {
197 VK_CALL(vkGetBufferMemoryRequirements(device->vk_device, vk_buffer, memory_requirements));
198 }
199
200 if (FAILED(hr = vkd3d_allocate_device_memory(device, heap_properties, heap_flags,
201 memory_requirements, dedicated_allocation, vk_memory, vk_memory_type)))
202 return hr;
203
204 if ((vr = VK_CALL(vkBindBufferMemory(device->vk_device, vk_buffer, *vk_memory, 0))) < 0)
205 {
206 WARN("Failed to bind memory, vr %d.\n", vr);
207 VK_CALL(vkFreeMemory(device->vk_device, *vk_memory, NULL));
208 *vk_memory = VK_NULL_HANDLE;
209 }
210
211 if (vk_memory_size)
212 *vk_memory_size = memory_requirements->size;
213
214 return hresult_from_vk_result(vr);
215}
static HRESULT vkd3d_allocate_device_memory(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const VkMemoryRequirements *memory_requirements, const VkMemoryDedicatedAllocateInfo *dedicated_allocate_info, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type)
Definition: resource.c:114
VkStructureType sType
Definition: vulkan.h:9386
VkBool32 prefersDedicatedAllocation
Definition: vulkan.h:9397
VkStructureType sType
Definition: vulkan.h:9395
VkStructureType sType
Definition: vulkan.h:9465
char buffer[256]
Definition: notification.c:80
void VKAPI_CALL vkGetBufferMemoryRequirements2KHR(VkDevice device, const VkBufferMemoryRequirementsInfo2 *pInfo, VkMemoryRequirements2 *pMemoryRequirements)
void VKAPI_CALL vkGetBufferMemoryRequirements(VkDevice device, VkBuffer buffer, VkMemoryRequirements *pMemoryRequirements)
void VKAPI_CALL vkFreeMemory(VkDevice device, VkDeviceMemory memory, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkBindBufferMemory(VkDevice device, VkBuffer buffer, VkDeviceMemory memory, VkDeviceSize memoryOffset)
@ VK_STRUCTURE_TYPE_BUFFER_MEMORY_REQUIREMENTS_INFO_2
Definition: vulkan.h:5226
@ VK_STRUCTURE_TYPE_MEMORY_REQUIREMENTS_2
Definition: vulkan.h:5229
@ VK_STRUCTURE_TYPE_MEMORY_DEDICATED_REQUIREMENTS
Definition: vulkan.h:5204
@ VK_STRUCTURE_TYPE_MEMORY_DEDICATED_ALLOCATE_INFO
Definition: vulkan.h:5205

Referenced by d3d12_command_list_allocate_transfer_buffer(), d3d12_heap_init(), and vkd3d_init_null_resources().

◆ vkd3d_cleanup_format_info()

void vkd3d_cleanup_format_info ( struct d3d12_device *  device)

Definition at line 414 of file utils.c.

415{
418}
static void vkd3d_cleanup_format_compatibility_lists(struct d3d12_device *device)
Definition: utils.c:346
static void vkd3d_cleanup_depth_stencil_formats(struct d3d12_device *device)
Definition: utils.c:393

Referenced by d3d12_device_init(), and d3d12_device_Release().

◆ vkd3d_compute_workgroup_count()

static unsigned int vkd3d_compute_workgroup_count ( unsigned int  thread_count,
unsigned int  workgroup_size 
)
inlinestatic

Definition at line 1726 of file vkd3d_private.h.

1727{
1728 return (thread_count + workgroup_size - 1) / workgroup_size;
1729}
static uint32_t thread_count(IN pnfs_layout_state *state, IN enum pnfs_iomode iomode, IN uint64_t offset, IN uint64_t length)
Definition: pnfs_io.c:137

Referenced by d3d12_command_list_clear_uav().

◆ vkd3d_create_buffer()

HRESULT vkd3d_create_buffer ( struct d3d12_device *  device,
const D3D12_HEAP_PROPERTIES *  heap_properties,
D3D12_HEAP_FLAGS  heap_flags,
const D3D12_RESOURCE_DESC1 *  desc,
VkBuffer *  vk_buffer 
)

Definition at line 652 of file resource.c.

655{
656 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
657 const bool sparse_resource = !heap_properties;
658 VkBufferCreateInfo buffer_info;
659 D3D12_HEAP_TYPE heap_type;
660 VkResult vr;
661
662 heap_type = heap_properties ? heap_properties->Type : D3D12_HEAP_TYPE_DEFAULT;
663
665 buffer_info.pNext = NULL;
666 buffer_info.flags = 0;
667 buffer_info.size = desc->Width;
668
669 if (sparse_resource)
670 {
672 if (device->vk_info.sparse_properties.residencyNonResidentStrict)
674 }
675
682
683 if (device->vk_info.EXT_conditional_rendering)
685
686 if (heap_type == D3D12_HEAP_TYPE_DEFAULT && device->vk_info.EXT_transform_feedback)
687 {
690 }
691
692 if (heap_type == D3D12_HEAP_TYPE_UPLOAD)
693 buffer_info.usage &= ~VK_BUFFER_USAGE_TRANSFER_DST_BIT;
694 else if (heap_type == D3D12_HEAP_TYPE_READBACK)
696
701
702 /* Buffers always have properties of D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS. */
704 {
705 WARN("D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS cannot be set for buffers.\n");
706 return E_INVALIDARG;
707 }
708
709 if (device->queue_family_count > 1)
710 {
712 buffer_info.queueFamilyIndexCount = device->queue_family_count;
713 buffer_info.pQueueFamilyIndices = device->queue_family_indices;
714 }
715 else
716 {
718 buffer_info.queueFamilyIndexCount = 0;
719 buffer_info.pQueueFamilyIndices = NULL;
720 }
721
723 FIXME("Unsupported resource flags %#x.\n", desc->Flags);
724
725 if ((vr = VK_CALL(vkCreateBuffer(device->vk_device, &buffer_info, NULL, vk_buffer))) < 0)
726 {
727 WARN("Failed to create Vulkan buffer, vr %d.\n", vr);
728 *vk_buffer = VK_NULL_HANDLE;
729 }
730
731 return hresult_from_vk_result(vr);
732}
@ D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS
Definition: d3d12.idl:1002
@ D3D12_RESOURCE_FLAG_DENY_SHADER_RESOURCE
Definition: d3d12.idl:1003
@ D3D12_RESOURCE_FLAG_ALLOW_SIMULTANEOUS_ACCESS
Definition: d3d12.idl:1005
D3D12_HEAP_TYPE
Definition: d3d12.idl:780
@ D3D12_HEAP_TYPE_DEFAULT
Definition: d3d12.idl:781
@ D3D12_HEAP_TYPE_READBACK
Definition: d3d12.idl:783
@ D3D12_HEAP_TYPE_UPLOAD
Definition: d3d12.idl:782
D3D12_HEAP_TYPE Type
Definition: d3d12.idl:804
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
@ VK_SHARING_MODE_CONCURRENT
Definition: vulkan.h:4922
@ VK_SHARING_MODE_EXCLUSIVE
Definition: vulkan.h:4921
VkResult VKAPI_CALL vkCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer)
@ 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_TRANSFER_DST_BIT
Definition: vulkan.h:1916
@ 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_CONDITIONAL_RENDERING_BIT_EXT
Definition: vulkan.h:1924
@ VK_BUFFER_USAGE_VERTEX_BUFFER_BIT
Definition: vulkan.h:1922
@ VK_BUFFER_USAGE_TRANSFER_SRC_BIT
Definition: vulkan.h:1915
@ VK_BUFFER_CREATE_SPARSE_BINDING_BIT
Definition: vulkan.h:1901
@ VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT
Definition: vulkan.h:1902
@ VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO
Definition: vulkan.h:4976

Referenced by d3d12_command_list_allocate_transfer_buffer(), d3d12_resource_init(), and vkd3d_init_null_resources().

◆ vkd3d_create_buffer_view()

bool vkd3d_create_buffer_view ( struct d3d12_device *  device,
uint32_t  magic,
VkBuffer  vk_buffer,
const struct vkd3d_format *  format,
VkDeviceSize  offset,
VkDeviceSize  size,
struct vkd3d_view **  view 
)

Definition at line 2792 of file resource.c.

2795{
2796 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
2797 VkBufferView vk_view = VK_NULL_HANDLE;
2798 struct vkd3d_view *object;
2799
2800 if (vk_buffer && !vkd3d_create_vk_buffer_view(device, vk_buffer, format, offset, size, &vk_view))
2801 return false;
2802
2803 if (!(object = vkd3d_view_create(magic, magic == VKD3D_DESCRIPTOR_MAGIC_UAV
2806 {
2807 VK_CALL(vkDestroyBufferView(device->vk_device, vk_view, NULL));
2808 return false;
2809 }
2810
2811 object->v.u.vk_buffer_view = vk_view;
2812 object->v.format = format;
2813 object->v.info.buffer.offset = offset;
2814 object->v.info.buffer.size = size;
2815 *view = object;
2816 return true;
2817}
GLsizeiptr size
Definition: glext.h:5919
GLintptr offset
Definition: glext.h:5920
static bool vkd3d_create_vk_buffer_view(struct d3d12_device *device, VkBuffer vk_buffer, const struct vkd3d_format *format, VkDeviceSize offset, VkDeviceSize range, VkBufferView *vk_view)
Definition: resource.c:2761
#define VKD3D_DESCRIPTOR_MAGIC_UAV
Definition: vkd3d_private.h:49
void VKAPI_CALL vkDestroyBufferView(VkDevice device, VkBufferView bufferView, const VkAllocationCallbacks *pAllocator)
@ VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER
Definition: vulkan.h:2469
@ VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER
Definition: vulkan.h:2468

Referenced by create_uint_view(), vkd3d_create_buffer_view_for_resource(), vkd3d_create_null_srv(), and vkd3d_create_null_uav().

◆ vkd3d_create_raw_buffer_view()

bool vkd3d_create_raw_buffer_view ( struct d3d12_device *  device,
D3D12_GPU_VIRTUAL_ADDRESS  gpu_address,
D3D12_ROOT_PARAMETER_TYPE  parameter_type,
VkBufferView *  vk_buffer_view 
)

Definition at line 3613 of file resource.c.

3615{
3616 const struct vkd3d_format *format;
3617 struct d3d12_resource *resource;
3618
3620
3621 if (!gpu_address)
3622 {
3623 if (device->vk_info.EXT_robustness2)
3624 {
3625 *vk_buffer_view = VK_NULL_HANDLE;
3626 return true;
3627 }
3628 WARN("Creating null buffer view.\n");
3630 ? device->null_resources.vk_storage_buffer : device->null_resources.vk_buffer,
3631 format, 0, VK_WHOLE_SIZE, vk_buffer_view);
3632 }
3633
3636 return vkd3d_create_vk_buffer_view(device, resource->u.vk_buffer, format,
3637 gpu_address - resource->gpu_address, VK_WHOLE_SIZE, vk_buffer_view);
3638}
@ D3D12_ROOT_PARAMETER_TYPE_UAV
Definition: d3d12.idl:1181
@ DXGI_FORMAT_R32_UINT
Definition: dxgiformat.idl:65
const struct vkd3d_format * vkd3d_get_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format, bool depth_stencil)
Definition: utils.c:442
D3D12_GPU_VIRTUAL_ADDRESS gpu_address

Referenced by d3d12_command_list_set_root_descriptor().

◆ vkd3d_create_static_sampler()

HRESULT vkd3d_create_static_sampler ( struct d3d12_device *  device,
const D3D12_STATIC_SAMPLER_DESC *  desc,
VkSampler *  vk_sampler 
)

Definition at line 3814 of file resource.c.

3816{
3817 VkResult vr;
3818
3819 vr = d3d12_create_sampler(device, desc->Filter, desc->AddressU, desc->AddressV,
3820 desc->AddressW, desc->MipLODBias, desc->MaxAnisotropy, desc->ComparisonFunc,
3821 desc->BorderColor, desc->MinLOD, desc->MaxLOD, vk_sampler);
3822 return hresult_from_vk_result(vr);
3823}

Referenced by d3d12_root_signature_init_static_samplers().

◆ vkd3d_create_texture_view()

bool vkd3d_create_texture_view ( struct d3d12_device *  device,
uint32_t  magic,
VkImage  vk_image,
const struct vkd3d_texture_view_desc *  desc,
struct vkd3d_view **  view 
)

Definition at line 3082 of file resource.c.

3084{
3085 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
3086 const struct vkd3d_format *format = desc->format;
3088 struct VkImageViewCreateInfo view_desc;
3089 VkImageView vk_view = VK_NULL_HANDLE;
3090 struct vkd3d_view *object;
3091 VkResult vr;
3092
3093 if (vk_image)
3094 {
3096 view_desc.pNext = NULL;
3097 view_desc.flags = 0;
3098 view_desc.image = vk_image;
3099 view_desc.viewType = desc->view_type;
3100 view_desc.format = format->vk_format;
3101 vkd3d_set_view_swizzle_for_format(&view_desc.components, format, desc->allowed_swizzle);
3102 if (desc->allowed_swizzle)
3103 vk_component_mapping_compose(&view_desc.components, &desc->components);
3104 view_desc.subresourceRange.aspectMask = desc->vk_image_aspect;
3105 view_desc.subresourceRange.baseMipLevel = desc->miplevel_idx;
3106 view_desc.subresourceRange.levelCount = desc->miplevel_count;
3107 view_desc.subresourceRange.baseArrayLayer = desc->layer_idx;
3108 view_desc.subresourceRange.layerCount = desc->layer_count;
3109 if (device->vk_info.KHR_maintenance2)
3110 {
3112 usage_desc.pNext = NULL;
3113 usage_desc.usage = desc->usage;
3114 view_desc.pNext = &usage_desc;
3115 }
3116 if ((vr = VK_CALL(vkCreateImageView(device->vk_device, &view_desc, NULL, &vk_view))) < 0)
3117 {
3118 WARN("Failed to create Vulkan image view, vr %d.\n", vr);
3119 return false;
3120 }
3121 }
3122
3125 {
3126 VK_CALL(vkDestroyImageView(device->vk_device, vk_view, NULL));
3127 return false;
3128 }
3129
3130 object->v.u.vk_image_view = vk_view;
3131 object->v.format = format;
3132 object->v.info.texture.vk_view_type = desc->view_type;
3133 object->v.info.texture.miplevel_idx = desc->miplevel_idx;
3134 object->v.info.texture.layer_idx = desc->layer_idx;
3135 object->v.info.texture.layer_count = desc->layer_count;
3136 *view = object;
3137 return true;
3138}
static void vkd3d_set_view_swizzle_for_format(VkComponentMapping *components, const struct vkd3d_format *format, bool allowed_swizzle)
Definition: resource.c:2857
static void vk_component_mapping_compose(VkComponentMapping *dst, const VkComponentMapping *b)
Definition: resource.c:2986
VkImageUsageFlags usage
Definition: vulkan.h:9149
VkStructureType sType
Definition: vulkan.h:9147
void VKAPI_CALL vkDestroyImageView(VkDevice device, VkImageView imageView, const VkAllocationCallbacks *pAllocator)
VkResult VKAPI_CALL vkCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkImageView *pView)
@ VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE
Definition: vulkan.h:2466
@ VK_DESCRIPTOR_TYPE_STORAGE_IMAGE
Definition: vulkan.h:2467
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_USAGE_CREATE_INFO
Definition: vulkan.h:5198
@ VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO
Definition: vulkan.h:4979

Referenced by create_uint_view(), d3d12_desc_create_srv(), d3d12_dsv_desc_create_dsv(), d3d12_rtv_desc_create_rtv(), vkd3d_create_null_srv(), vkd3d_create_null_uav(), and vkd3d_create_texture_uav().

◆ vkd3d_create_thread()

HRESULT vkd3d_create_thread ( struct vkd3d_instance *  instance,
PFN_vkd3d_thread  thread_main,
void *  data,
union vkd3d_thread_handle *  thread 
)

Definition at line 5620 of file device.c.

5622{
5623 HRESULT hr = S_OK;
5624
5625 if (instance->create_thread)
5626 {
5627 if (!(thread->handle = instance->create_thread(thread_main, data)))
5628 {
5629 ERR("Failed to create thread.\n");
5630 hr = E_FAIL;
5631 }
5632 }
5633 else
5634 {
5635#ifdef _WIN32
5636 struct thread_data *thread_data;
5637
5638 if (!(thread_data = vkd3d_malloc(sizeof(*thread_data))))
5639 return E_OUTOFMEMORY;
5640
5641 thread_data->main_pfn = thread_main;
5643 if (!(thread->handle = CreateThread(NULL, 0, call_thread_main, thread_data, 0, NULL)))
5644 {
5645 ERR("Failed to create thread, error %lu.\n", GetLastError());
5647 hr = E_FAIL;
5648 }
5649#else
5650 int rc;
5651
5652 if ((rc = pthread_create(&thread->pthread, NULL, thread_main, data)))
5653 {
5654 ERR("Failed to create thread, error %d.\n", rc);
5655 hr = hresult_from_errno(rc);
5656 }
5657#endif
5658 }
5659
5660 return hr;
5661}
static HANDLE thread
Definition: service.c:33
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static unsigned int WINAPI thread_main(void *args)
Definition: nfs41_daemon.c:84
HRESULT hresult_from_errno(int rc)
Definition: utils.c:768
void * data
Definition: main.c:1575
DWORD WINAPI GetLastError(void)
Definition: except.c:1042

Referenced by d3d12_device_init(), and vkd3d_fence_worker_start().

◆ vkd3d_create_timeline_semaphore()

VkResult vkd3d_create_timeline_semaphore ( const struct d3d12_device *  device,
uint64_t  initial_value,
VkSemaphore *  timeline_semaphore 
)

Definition at line 1239 of file command.c.

1241{
1242 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1245
1247 info.pNext = &type_info;
1248 info.flags = 0;
1249
1251 type_info.pNext = NULL;
1253 type_info.initialValue = initial_value;
1254
1255 return VK_CALL(vkCreateSemaphore(device->vk_device, &info, NULL, timeline_semaphore));
1256}
struct __type_info type_info
VkResult VKAPI_CALL vkCreateSemaphore(VkDevice device, const VkSemaphoreCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkSemaphore *pSemaphore)
@ VK_SEMAPHORE_TYPE_TIMELINE_KHR
Definition: vulkan.h:4805
@ VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO
Definition: vulkan.h:4973
@ VK_STRUCTURE_TYPE_SEMAPHORE_TYPE_CREATE_INFO_KHR
Definition: vulkan.h:5949

Referenced by d3d12_fence_init().

◆ vkd3d_destroy_null_resources()

void vkd3d_destroy_null_resources ( struct vkd3d_null_resources *  null_resources,
struct d3d12_device *  device 
)

Definition at line 4965 of file resource.c.

4967{
4968 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4969
4970 VK_CALL(vkDestroyBuffer(device->vk_device, null_resources->vk_buffer, NULL));
4971 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_buffer_memory, NULL));
4972
4973 VK_CALL(vkDestroyBuffer(device->vk_device, null_resources->vk_storage_buffer, NULL));
4974 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_storage_buffer_memory, NULL));
4975
4976 VK_CALL(vkDestroyImage(device->vk_device, null_resources->vk_2d_image, NULL));
4977 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_2d_image_memory, NULL));
4978
4979 VK_CALL(vkDestroyImage(device->vk_device, null_resources->vk_2d_storage_image, NULL));
4980 VK_CALL(vkFreeMemory(device->vk_device, null_resources->vk_2d_storage_image_memory, NULL));
4981
4982 memset(null_resources, 0, sizeof(*null_resources));
4983}
VkDeviceMemory vk_buffer_memory
VkDeviceMemory vk_2d_image_memory
VkDeviceMemory vk_2d_storage_image_memory
VkDeviceMemory vk_storage_buffer_memory
void VKAPI_CALL vkDestroyBuffer(VkDevice device, VkBuffer buffer, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyImage(VkDevice device, VkImage image, const VkAllocationCallbacks *pAllocator)

Referenced by d3d12_device_init(), d3d12_device_Release(), and vkd3d_init_null_resources().

◆ vkd3d_find_uint_format()

const struct vkd3d_format * vkd3d_find_uint_format ( const struct d3d12_device *  device,
DXGI_FORMAT  dxgi_format 
)

Definition at line 465 of file utils.c.

466{
467 DXGI_FORMAT typeless_format = DXGI_FORMAT_UNKNOWN;
468 const struct vkd3d_format *vkd3d_format;
469 unsigned int i;
470
472 {
474 {
476 break;
477 }
478 }
479
480 if (!typeless_format)
481 return NULL;
482
484 {
485 if (vkd3d_format_compatibility_info[i].typeless_format != typeless_format)
486 continue;
487
490 return vkd3d_format;
491 }
492
493 return NULL;
494}
DXGI_FORMAT dxgi_format
Definition: texture.c:51
DXGI_FORMAT
Definition: dxgiformat.idl:22
enum vkd3d_format_type type

Referenced by create_uint_view().

◆ vkd3d_format_copy_data()

void vkd3d_format_copy_data ( const struct vkd3d_format *  format,
const uint8_t *  src,
unsigned int  src_row_pitch,
unsigned int  src_slice_pitch,
uint8_t *  dst,
unsigned int  dst_row_pitch,
unsigned int  dst_slice_pitch,
unsigned int  w,
unsigned int  h,
unsigned int  d 
)

Definition at line 496 of file utils.c.

499{
500 unsigned int row_block_count, row_count, row_size, slice, row;
501 unsigned int slice_count = d;
502 const uint8_t *src_row;
503 uint8_t *dst_row;
504
505 row_block_count = (w + format->block_width - 1) / format->block_width;
506 row_count = (h + format->block_height - 1) / format->block_height;
507 row_size = row_block_count * format->byte_count * format->block_byte_count;
508
509 for (slice = 0; slice < slice_count; ++slice)
510 {
511 for (row = 0; row < row_count; ++row)
512 {
513 src_row = &src[slice * src_slice_pitch + row * src_row_pitch];
514 dst_row = &dst[slice * dst_slice_pitch + row * dst_row_pitch];
515 memcpy(dst_row, src_row, row_size);
516 }
517 }
518}
unsigned char uint8_t
Definition: stdint.h:33
struct png_info_def *typedef unsigned char **typedef struct png_info_def *typedef struct png_info_def *typedef struct png_info_def *typedef unsigned char ** row
Definition: typeof.h:78
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723

Referenced by d3d12_resource_ReadFromSubresource(), and d3d12_resource_WriteToSubresource().

◆ vkd3d_format_from_d3d12_resource_desc()

static const struct vkd3d_format * vkd3d_format_from_d3d12_resource_desc ( const struct d3d12_device *  device,
const D3D12_RESOURCE_DESC1 *  desc,
DXGI_FORMAT  view_format 
)
inlinestatic

Definition at line 1685 of file vkd3d_private.h.

1687{
1688 return vkd3d_get_format(device, view_format ? view_format : desc->Format,
1690}
const struct vkd3d_format * vkd3d_get_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format, bool depth_stencil)
Definition: utils.c:442

Referenced by d3d12_command_list_CopyTextureRegion(), d3d12_command_list_ResolveSubresource(), d3d12_device_get_copyable_footprints(), d3d12_resource_init(), d3d12_resource_validate_desc(), init_default_texture_view_desc(), vkd3d_create_buffer_view_for_resource(), vkd3d_create_image(), and vkd3d_create_image_resource().

◆ vkd3d_format_get_data_offset()

static size_t vkd3d_format_get_data_offset ( const struct vkd3d_format *  format,
unsigned int  row_pitch,
unsigned int  slice_pitch,
unsigned int  x,
unsigned int  y,
unsigned int  z 
)
inlinestatic

Definition at line 1660 of file vkd3d_private.h.

1663{
1664 return z * slice_pitch
1665 + (y / format->block_height) * row_pitch
1666 + (x / format->block_width) * format->byte_count * format->block_byte_count;
1667}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLdouble GLdouble z
Definition: glext.h:5874

Referenced by d3d12_resource_ReadFromSubresource(), d3d12_resource_WriteToSubresource(), vk_buffer_image_copy_from_d3d12(), and vk_image_buffer_copy_from_d3d12().

◆ vkd3d_format_is_compressed()

static bool vkd3d_format_is_compressed ( const struct vkd3d_format *  format)
inlinestatic

◆ vkd3d_get_format()

const struct vkd3d_format * vkd3d_get_format ( const struct d3d12_device *  device,
DXGI_FORMAT  dxgi_format,
bool  depth_stencil 
)

Definition at line 442 of file utils.c.

444{
445 const struct vkd3d_format *format;
446 unsigned int i;
447
449 return format;
450
451 for (i = 0; i < ARRAY_SIZE(vkd3d_formats); ++i)
452 {
454 return &vkd3d_formats[i];
455 }
456
457 /* Do not check VkPhysicalDevice4444FormatsFeaturesEXT because apps
458 * should query format support, which returns more detailed info. */
459 if (dxgi_format == format_b4g4r4a4.dxgi_format && device->vk_info.EXT_4444_formats)
460 return &format_b4g4r4a4;
461
462 return NULL;
463}
static void depth_stencil(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
Definition: ffp_gl.c:766
static const struct vkd3d_format vkd3d_formats[]
Definition: utils.c:30
static const struct vkd3d_format * vkd3d_get_depth_stencil_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format)
Definition: utils.c:424
static const struct vkd3d_format format_b4g4r4a4
Definition: utils.c:121

Referenced by compute_input_layout_offsets(), d3d12_device_check_multisample_quality_levels(), d3d12_device_CheckFeatureSupport(), d3d12_device_supports_typed_uav_load_additional_formats(), d3d12_pipeline_state_init_graphics(), vkd3d_create_buffer_uav(), vkd3d_create_buffer_view_for_resource(), vkd3d_create_null_srv(), vkd3d_create_null_uav(), vkd3d_create_raw_buffer_view(), vkd3d_find_uint_format(), vkd3d_fixup_clear_uav_uint_colour(), vkd3d_format_from_d3d12_resource_desc(), and vkd3d_get_vk_format().

◆ vkd3d_get_image_allocation_info()

HRESULT vkd3d_get_image_allocation_info ( struct d3d12_device *  device,
const D3D12_RESOURCE_DESC1 *  desc,
struct vkd3d_resource_allocation_info *  allocation_info 
)

Definition at line 942 of file resource.c.

944{
945 static const D3D12_HEAP_PROPERTIES heap_properties = {D3D12_HEAP_TYPE_DEFAULT};
946 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
947 D3D12_RESOURCE_DESC1 validated_desc;
948 VkMemoryRequirements requirements;
949 VkImage vk_image;
950 bool tiled;
951 HRESULT hr;
952
955
956 if (!desc->MipLevels)
957 {
958 validated_desc = *desc;
959 validated_desc.MipLevels = max_miplevel_count(desc);
960 desc = &validated_desc;
961 }
962
964
965 /* XXX: We have to create an image to get its memory requirements. */
966 if (SUCCEEDED(hr = vkd3d_create_image(device, tiled ? NULL : &heap_properties, 0, desc, NULL, &vk_image)))
967 {
968 VK_CALL(vkGetImageMemoryRequirements(device->vk_device, vk_image, &requirements));
969 VK_CALL(vkDestroyImage(device->vk_device, vk_image, NULL));
970
971 allocation_info->size_in_bytes = requirements.size;
972 allocation_info->alignment = requirements.alignment;
973 }
974
975 return hr;
976}
#define SUCCEEDED(hr)
Definition: intsafe.h:50
HRESULT d3d12_resource_validate_desc(const D3D12_RESOURCE_DESC1 *desc, struct d3d12_device *device)
Definition: resource.c:1850
static HRESULT vkd3d_create_image(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, struct d3d12_resource *resource, VkImage *vk_image)
Definition: resource.c:776
static unsigned int max_miplevel_count(const D3D12_RESOURCE_DESC1 *desc)
Definition: resource.c:734
void VKAPI_CALL vkGetImageMemoryRequirements(VkDevice device, VkImage image, VkMemoryRequirements *pMemoryRequirements)

Referenced by d3d12_device_get_resource1_allocation_info(), and d3d12_is_64k_msaa_supported().

◆ vkd3d_get_private_data()

HRESULT vkd3d_get_private_data ( struct vkd3d_private_store *  store,
const GUID *  tag,
unsigned int *  out_size,
void *  out 
)

Definition at line 994 of file utils.c.

996{
997 const struct vkd3d_private_data *data;
998 HRESULT hr = S_OK;
999 unsigned int size;
1000
1001 if (!out_size)
1002 return E_INVALIDARG;
1003
1004 vkd3d_mutex_lock(&store->mutex);
1005
1007 {
1008 *out_size = 0;
1010 goto done;
1011 }
1012
1013 size = *out_size;
1014 *out_size = data->size;
1015 if (!out)
1016 goto done;
1017
1018 if (size < data->size)
1019 {
1021 goto done;
1022 }
1023
1024 if (data->is_object)
1025 IUnknown_AddRef(data->u.object);
1026 memcpy(out, data->u.data, data->size);
1027
1028done:
1029 vkd3d_mutex_unlock(&store->mutex);
1030 return hr;
1031}
static HANDLE PIO_APC_ROUTINE PVOID PIO_STATUS_BLOCK ULONG PVOID ULONG PVOID ULONG out_size
Definition: file.c:72
static struct vkd3d_private_data * vkd3d_private_store_get_private_data(const struct vkd3d_private_store *store, const GUID *tag)
Definition: utils.c:939
Definition: ecma_167.h:138
struct vkd3d_mutex mutex
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383

Referenced by d3d12_cache_session_GetPrivateData(), d3d12_command_allocator_GetPrivateData(), d3d12_command_list_GetPrivateData(), d3d12_command_queue_GetPrivateData(), d3d12_command_signature_GetPrivateData(), d3d12_descriptor_heap_GetPrivateData(), d3d12_device_GetPrivateData(), d3d12_fence_GetPrivateData(), d3d12_heap_GetPrivateData(), d3d12_pipeline_state_GetPrivateData(), d3d12_query_heap_GetPrivateData(), d3d12_resource_GetPrivateData(), and d3d12_root_signature_GetPrivateData().

◆ vkd3d_get_program_name()

bool vkd3d_get_program_name ( char  program_name[PATH_MAX])

Definition at line 931 of file utils.c.

932{
933 *program_name = '\0';
934 return false;
935}
static char * program_name
Definition: mkdosfs.c:519

Referenced by vkd3d_instance_init().

◆ vkd3d_gpu_va_allocator_allocate()

D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate ( struct vkd3d_gpu_va_allocator *  allocator,
size_t  alignment,
uint64_t  size,
void *  ptr 
)

Definition at line 2424 of file device.c.

2426{
2428
2429 if (size > ~(uint64_t)0 - (alignment - 1))
2430 return 0;
2432
2433 vkd3d_mutex_lock(&allocator->mutex);
2434
2435 if (size <= VKD3D_VA_SLAB_SIZE && allocator->free_slab)
2437 else
2439
2441
2442 return address;
2443}
_Check_return_ _Ret_maybenull_ _In_ size_t alignment
Definition: align.cpp:48
UINT64 D3D12_GPU_VIRTUAL_ADDRESS
Definition: d3d12.idl:1443
UINT64 uint64_t
Definition: types.h:77
GLuint address
Definition: glext.h:9393
static PVOID ptr
Definition: dispmode.c:27
static D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate_fallback(struct vkd3d_gpu_va_allocator *allocator, size_t alignment, uint64_t aligned_size, void *ptr)
Definition: device.c:2392
static D3D12_GPU_VIRTUAL_ADDRESS vkd3d_gpu_va_allocator_allocate_slab(struct vkd3d_gpu_va_allocator *allocator, uint64_t aligned_size, void *ptr)
Definition: device.c:2370
static size_t align(size_t addr, size_t alignment)

Referenced by d3d12_resource_init().

◆ vkd3d_gpu_va_allocator_dereference()

void * vkd3d_gpu_va_allocator_dereference ( struct vkd3d_gpu_va_allocator *  allocator,
D3D12_GPU_VIRTUAL_ADDRESS  address 
)

Definition at line 2495 of file device.c.

2497{
2498 void *ret;
2499
2500 /* If we land in the non-fallback region, dereferencing VA is lock-less.
2501 * The base pointer is immutable, and the only way we can have a data race
2502 * is if some other thread is poking into the
2503 * slab_mem_allocation[base_index] block. This can only happen if someone
2504 * is trying to free the entry while we're dereferencing it, which would
2505 * be a serious application bug. */
2508
2509 /* Slow fallback. */
2510 vkd3d_mutex_lock(&allocator->mutex);
2511
2513
2515
2516 return ret;
2517}
static void * vkd3d_gpu_va_allocator_dereference_fallback(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2484
#define VKD3D_VA_FALLBACK_BASE
Definition: device.c:2364
static void * vkd3d_gpu_va_allocator_dereference_slab(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2445

Referenced by d3d12_command_list_IASetIndexBuffer(), d3d12_command_list_IASetVertexBuffers(), d3d12_command_list_set_root_cbv(), d3d12_command_list_SOSetTargets(), d3d12_command_list_WriteBufferImmediate(), d3d12_desc_create_cbv(), and vkd3d_create_raw_buffer_view().

◆ vkd3d_gpu_va_allocator_free()

void vkd3d_gpu_va_allocator_free ( struct vkd3d_gpu_va_allocator *  allocator,
D3D12_GPU_VIRTUAL_ADDRESS  address 
)

Definition at line 2565 of file device.c.

2566{
2567 vkd3d_mutex_lock(&allocator->mutex);
2568
2570 {
2573 return;
2574 }
2575
2577
2579}
static void vkd3d_gpu_va_allocator_free_slab(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2519
static void vkd3d_gpu_va_allocator_free_fallback(struct vkd3d_gpu_va_allocator *allocator, D3D12_GPU_VIRTUAL_ADDRESS address)
Definition: device.c:2543

Referenced by d3d12_resource_destroy().

◆ vkd3d_init_format_info()

HRESULT vkd3d_init_format_info ( struct d3d12_device *  device)

Definition at line 401 of file utils.c.

402{
403 HRESULT hr;
404
406 return hr;
407
410
411 return hr;
412}
static HRESULT vkd3d_init_depth_stencil_formats(struct d3d12_device *device)
Definition: utils.c:354
static HRESULT vkd3d_init_format_compatibility_lists(struct d3d12_device *device)
Definition: utils.c:269

Referenced by d3d12_device_init().

◆ vkd3d_init_null_resources()

HRESULT vkd3d_init_null_resources ( struct vkd3d_null_resources *  null_resources,
struct d3d12_device *  device 
)

Definition at line 4846 of file resource.c.

4848{
4849 const bool use_sparse_resources = device->vk_info.sparse_properties.residencyNonResidentStrict;
4850 D3D12_HEAP_PROPERTIES heap_properties;
4851 D3D12_RESOURCE_DESC1 resource_desc;
4852 HRESULT hr;
4853
4854 TRACE("Creating resources for NULL views.\n");
4855
4856 memset(null_resources, 0, sizeof(*null_resources));
4857
4858 if (device->vk_info.EXT_robustness2)
4859 return S_OK;
4860
4861 memset(&heap_properties, 0, sizeof(heap_properties));
4862 heap_properties.Type = D3D12_HEAP_TYPE_DEFAULT;
4863
4864 /* buffer */
4866 resource_desc.Alignment = 0;
4867 resource_desc.Width = VKD3D_NULL_BUFFER_SIZE;
4868 resource_desc.Height = 1;
4869 resource_desc.DepthOrArraySize = 1;
4870 resource_desc.MipLevels = 1;
4871 resource_desc.Format = DXGI_FORMAT_UNKNOWN;
4872 resource_desc.SampleDesc.Count = 1;
4873 resource_desc.SampleDesc.Quality = 0;
4874 resource_desc.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
4875 resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
4876 memset(&resource_desc.SamplerFeedbackMipRegion, 0, sizeof(resource_desc.SamplerFeedbackMipRegion));
4877
4878 if (FAILED(hr = vkd3d_create_buffer(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
4879 &resource_desc, &null_resources->vk_buffer)))
4880 goto fail;
4881 if (FAILED(hr = vkd3d_allocate_buffer_memory(device, null_resources->vk_buffer,
4882 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_buffer_memory, NULL, NULL)))
4883 goto fail;
4884
4885 /* buffer UAV */
4887
4888 if (FAILED(hr = vkd3d_create_buffer(device, use_sparse_resources ? NULL : &heap_properties, D3D12_HEAP_FLAG_NONE,
4889 &resource_desc, &null_resources->vk_storage_buffer)))
4890 goto fail;
4891 if (!use_sparse_resources && FAILED(hr = vkd3d_allocate_buffer_memory(device, null_resources->vk_storage_buffer,
4892 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_storage_buffer_memory, NULL, NULL)))
4893 goto fail;
4894
4895 /* 2D SRV */
4897 resource_desc.Alignment = 0;
4898 resource_desc.Width = 1;
4899 resource_desc.Height = 1;
4900 resource_desc.DepthOrArraySize = 1;
4901 resource_desc.MipLevels = 1;
4902 resource_desc.Format = VKD3D_NULL_VIEW_FORMAT;
4903 resource_desc.SampleDesc.Count = 1;
4904 resource_desc.SampleDesc.Quality = 0;
4905 resource_desc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
4906 resource_desc.Flags = D3D12_RESOURCE_FLAG_NONE;
4907
4908 if (FAILED(hr = vkd3d_create_image(device, &heap_properties, D3D12_HEAP_FLAG_NONE,
4909 &resource_desc, NULL, &null_resources->vk_2d_image)))
4910 goto fail;
4912 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_2d_image_memory, NULL, NULL)))
4913 goto fail;
4914
4915 /* 2D UAV */
4917 resource_desc.Alignment = 0;
4918 resource_desc.Width = 1;
4919 resource_desc.Height = 1;
4920 resource_desc.DepthOrArraySize = 1;
4921 resource_desc.MipLevels = 1;
4922 resource_desc.Format = VKD3D_NULL_VIEW_FORMAT;
4923 resource_desc.SampleDesc.Count = 1;
4924 resource_desc.SampleDesc.Quality = 0;
4925 resource_desc.Layout = use_sparse_resources
4928
4929 if (FAILED(hr = vkd3d_create_image(device, use_sparse_resources ? NULL : &heap_properties, D3D12_HEAP_FLAG_NONE,
4930 &resource_desc, NULL, &null_resources->vk_2d_storage_image)))
4931 goto fail;
4932 if (!use_sparse_resources && FAILED(hr = vkd3d_allocate_image_memory(device, null_resources->vk_2d_storage_image,
4933 &heap_properties, D3D12_HEAP_FLAG_NONE, &null_resources->vk_2d_storage_image_memory, NULL, NULL)))
4934 goto fail;
4935
4936 /* set Vulkan object names */
4942 VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT, "NULL UAV buffer");
4944 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "NULL 2D SRV image");
4946 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL 2D SRV memory");
4948 VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT, "NULL 2D UAV image");
4949 if (!use_sparse_resources)
4950 {
4952 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL UAV buffer memory");
4954 VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT, "NULL 2D UAV memory");
4955 }
4956
4957 return vkd3d_init_null_resources_data(null_resources, device);
4958
4959fail:
4960 ERR("Failed to initialise NULL resources, hr %s.\n", debugstr_hresult(hr));
4961 vkd3d_destroy_null_resources(null_resources, device);
4962 return hr;
4963}
@ D3D12_RESOURCE_FLAG_NONE
Definition: d3d12.idl:999
@ D3D12_HEAP_FLAG_NONE
Definition: d3d12.idl:813
@ D3D12_TEXTURE_LAYOUT_UNKNOWN
Definition: d3d12.idl:991
#define VKD3D_NULL_VIEW_FORMAT
Definition: resource.c:23
void vkd3d_destroy_null_resources(struct vkd3d_null_resources *null_resources, struct d3d12_device *device)
Definition: resource.c:4965
HRESULT vkd3d_create_buffer(struct d3d12_device *device, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, const D3D12_RESOURCE_DESC1 *desc, VkBuffer *vk_buffer)
Definition: resource.c:652
static HRESULT vkd3d_allocate_image_memory(struct d3d12_device *device, VkImage vk_image, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size)
Definition: resource.c:217
#define VKD3D_NULL_BUFFER_SIZE
Definition: resource.c:22
static HRESULT vkd3d_init_null_resources_data(struct vkd3d_null_resources *null_resource, struct d3d12_device *device)
Definition: resource.c:4660
HRESULT vkd3d_allocate_buffer_memory(struct d3d12_device *device, VkBuffer vk_buffer, const D3D12_HEAP_PROPERTIES *heap_properties, D3D12_HEAP_FLAGS heap_flags, VkDeviceMemory *vk_memory, uint32_t *vk_memory_type, VkDeviceSize *vk_memory_size)
Definition: resource.c:155
VkResult vkd3d_set_vk_object_name_utf8(struct d3d12_device *device, uint64_t vk_object, VkDebugReportObjectTypeEXT vk_object_type, const char *name)
Definition: utils.c:1060
D3D12_RESOURCE_DIMENSION Dimension
Definition: d3d12.idl:1035
D3D12_RESOURCE_FLAGS Flags
Definition: d3d12.idl:1044
D3D12_TEXTURE_LAYOUT Layout
Definition: d3d12.idl:1043
DXGI_SAMPLE_DESC SampleDesc
Definition: d3d12.idl:1042
DXGI_FORMAT Format
Definition: d3d12.idl:1041
UINT16 DepthOrArraySize
Definition: d3d12.idl:1039
static const char * debugstr_hresult(HRESULT hr)
Definition: vkd3d_common.h:244
@ VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT
Definition: vulkan.h:2339
@ VK_DEBUG_REPORT_OBJECT_TYPE_DEVICE_MEMORY_EXT
Definition: vulkan.h:2337
@ VK_DEBUG_REPORT_OBJECT_TYPE_BUFFER_EXT
Definition: vulkan.h:2338

Referenced by d3d12_device_init().

◆ vkd3d_join_thread()

HRESULT vkd3d_join_thread ( struct vkd3d_instance *  instance,
union vkd3d_thread_handle *  thread 
)

Definition at line 5663 of file device.c.

5664{
5665 HRESULT hr = S_OK;
5666 int rc;
5667
5668 if (instance->join_thread)
5669 {
5670 if (FAILED(hr = instance->join_thread(thread->handle)))
5671 ERR("Failed to join thread, hr %s.\n", debugstr_hresult(hr));
5672 }
5673 else
5674 {
5675#ifdef _WIN32
5676 if ((rc = WaitForSingleObject(thread->handle, INFINITE)) != WAIT_OBJECT_0)
5677 {
5678 ERR("Failed to wait for thread, ret %#x.\n", rc);
5679 hr = E_FAIL;
5680 }
5681 CloseHandle(thread->handle);
5682#else
5683 if ((rc = pthread_join(thread->pthread, NULL)))
5684 {
5685 ERR("Failed to join thread, error %d.\n", rc);
5686 hr = hresult_from_errno(rc);
5687 }
5688#endif
5689 }
5690
5691 return hr;
5692}
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WAIT_OBJECT_0
Definition: winbase.h:383

Referenced by device_worker_stop(), and vkd3d_fence_worker_stop().

◆ vkd3d_load_vk_device_procs()

HRESULT vkd3d_load_vk_device_procs ( struct vkd3d_vk_device_procs *  procs,
const struct vkd3d_vk_instance_procs *  parent_procs,
VkDevice  device 
)

Definition at line 857 of file utils.c.

859{
860 memset(procs, 0, sizeof(*procs));
861
862#define VK_INSTANCE_PFN COPY_PARENT_PFN
863#define VK_DEVICE_PFN LOAD_DEVICE_PFN
864#define VK_DEVICE_EXT_PFN LOAD_DEVICE_OPTIONAL_PFN
865#include "vulkan_procs.h"
866
867 TRACE("Loaded procs for VkDevice %p.\n", device);
868 return S_OK;
869}

Referenced by vkd3d_create_vk_device().

◆ vkd3d_load_vk_global_procs()

HRESULT vkd3d_load_vk_global_procs ( struct vkd3d_vk_global_procs *  procs,
PFN_vkGetInstanceProcAddr  vkGetInstanceProcAddr 
)

Definition at line 811 of file utils.c.

813{
814 memset(procs, 0, sizeof(*procs));
815
817
820
821 TRACE("Loaded global Vulkan procs.\n");
822 return S_OK;
823}
#define LOAD_GLOBAL_PFN(name)
Definition: utils.c:804
PFN_vkGetInstanceProcAddr vkGetInstanceProcAddr
Definition: vkd3d_private.h:78
VkResult VKAPI_CALL vkEnumerateInstanceExtensionProperties(const char *pLayerName, uint32_t *pPropertyCount, VkExtensionProperties *pProperties)
PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)
VkResult VKAPI_CALL vkCreateInstance(const VkInstanceCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, VkInstance *pInstance)

Referenced by vkd3d_init_vk_global_procs().

◆ vkd3d_load_vk_instance_procs()

HRESULT vkd3d_load_vk_instance_procs ( struct vkd3d_vk_instance_procs *  procs,
const struct vkd3d_vk_global_procs *  global_procs,
VkInstance  instance 
)

Definition at line 834 of file utils.c.

836{
837 memset(procs, 0, sizeof(*procs));
838
839#define VK_INSTANCE_PFN LOAD_INSTANCE_PFN
840#define VK_INSTANCE_EXT_PFN LOAD_INSTANCE_OPTIONAL_PFN
841#include "vulkan_procs.h"
842
843 TRACE("Loaded procs for VkInstance %p.\n", instance);
844 return S_OK;
845}

Referenced by vkd3d_instance_init().

◆ vkd3d_parse_root_signature_v_1_0()

int vkd3d_parse_root_signature_v_1_0 ( const struct vkd3d_shader_code *  dxbc,
struct vkd3d_shader_versioned_root_signature_desc *  desc 
)

Definition at line 170 of file vkd3d_main.c.

172{
174 int ret;
175
176 if ((ret = vkd3d_shader_parse_root_signature(dxbc, &desc, NULL)) < 0)
177 {
178 WARN("Failed to parse root signature, vkd3d result %d.\n", ret);
179 return ret;
180 }
181
183 {
184 *out_desc = desc;
185 }
186 else
187 {
189
192 if (ret < 0)
193 {
194 WARN("Failed to convert from version %#x, vkd3d result %d.\n", version, ret);
195 return ret;
196 }
197
198 *out_desc = converted_desc;
199 }
200
201 return ret;
202}
static const WCHAR version[]
Definition: asmname.c:66
VKD3D_SHADER_API int vkd3d_shader_parse_root_signature(const struct vkd3d_shader_code *dxbc, struct vkd3d_shader_versioned_root_signature_desc *root_signature, char **messages)
Definition: dxbc.c:1043
VKD3D_SHADER_API int vkd3d_shader_convert_root_signature(struct vkd3d_shader_versioned_root_signature_desc *dst, enum vkd3d_shader_root_signature_version version, const struct vkd3d_shader_versioned_root_signature_desc *src)
Definition: dxbc.c:1756
vkd3d_shader_root_signature_version
@ VKD3D_SHADER_ROOT_SIGNATURE_VERSION_1_0

Referenced by d3d12_root_signature_create(), and d3d12_root_signature_deserializer_init().

◆ vkd3d_prepend_struct()

static void vkd3d_prepend_struct ( void *  header,
void *  structure 
)
inlinestatic

Definition at line 1781 of file vkd3d_private.h.

1782{
1783 struct
1784 {
1785 unsigned int type;
1786 const void *next;
1787 } *vkd3d_header = header, *vkd3d_structure = structure;
1788
1789 VKD3D_ASSERT(!vkd3d_structure->next);
1790 vkd3d_structure->next = vkd3d_header->next;
1791 vkd3d_header->next = vkd3d_structure;
1792}

Referenced by d3d12_pipeline_state_init_compute(), and d3d12_pipeline_state_init_graphics().

◆ vkd3d_private_data_destroy()

static void vkd3d_private_data_destroy ( struct vkd3d_private_data *  data)
inlinestatic

Definition at line 321 of file vkd3d_private.h.

322{
323 if (data->is_object)
324 IUnknown_Release(data->u.object);
325 list_remove(&data->entry);
327}
static void list_remove(struct list_entry *entry)
Definition: list.h:90

Referenced by vkd3d_private_store_destroy(), and vkd3d_private_store_set_private_data().

◆ vkd3d_private_store_destroy()

static void vkd3d_private_store_destroy ( struct vkd3d_private_store *  store)
inlinestatic

◆ vkd3d_private_store_init()

◆ vkd3d_queue_acquire()

◆ vkd3d_queue_create()

HRESULT vkd3d_queue_create ( struct d3d12_device *  device,
uint32_t  family_index,
const VkQueueFamilyProperties *  properties,
struct vkd3d_queue **  queue 
)

Definition at line 34 of file command.c.

36{
37 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
38 struct vkd3d_queue *object;
39
40 if (!(object = vkd3d_malloc(sizeof(*object))))
41 return E_OUTOFMEMORY;
42
43 vkd3d_mutex_init(&object->mutex);
44
45 object->completed_sequence_number = 0;
46 object->submitted_sequence_number = 0;
47
48 object->vk_family_index = family_index;
49 object->vk_queue_flags = properties->queueFlags;
50 object->timestamp_bits = properties->timestampValidBits;
51
52 object->semaphores = NULL;
53 object->semaphores_size = 0;
54 object->semaphore_count = 0;
55
56 memset(object->old_vk_semaphores, 0, sizeof(object->old_vk_semaphores));
57
58 VK_CALL(vkGetDeviceQueue(device->vk_device, family_index, 0, &object->vk_queue));
59
60 TRACE("Created queue %p for queue family index %u.\n", object, family_index);
61
62 *queue = object;
63
64 return S_OK;
65}
uint32_t timestampValidBits
Definition: vulkan.h:13538
VkQueueFlags queueFlags
Definition: vulkan.h:13536
void VKAPI_CALL vkGetDeviceQueue(VkDevice device, uint32_t queueFamilyIndex, uint32_t queueIndex, VkQueue *pQueue)

Referenced by d3d12_device_create_vkd3d_queues().

◆ vkd3d_queue_destroy()

void vkd3d_queue_destroy ( struct vkd3d_queue *  queue,
struct d3d12_device *  device 
)

Definition at line 67 of file command.c.

68{
69 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
70 unsigned int i;
71
72 vkd3d_mutex_lock(&queue->mutex);
73
74 for (i = 0; i < queue->semaphore_count; ++i)
75 VK_CALL(vkDestroySemaphore(device->vk_device, queue->semaphores[i].vk_semaphore, NULL));
76
77 vkd3d_free(queue->semaphores);
78
79 for (i = 0; i < ARRAY_SIZE(queue->old_vk_semaphores); ++i)
80 {
81 if (queue->old_vk_semaphores[i])
82 VK_CALL(vkDestroySemaphore(device->vk_device, queue->old_vk_semaphores[i], NULL));
83 }
84
86
89}
void VKAPI_CALL vkDestroySemaphore(VkDevice device, VkSemaphore semaphore, const VkAllocationCallbacks *pAllocator)

Referenced by d3d12_device_destroy_vkd3d_queues().

◆ vkd3d_queue_release()

◆ vkd3d_render_pass_cache_cleanup()

void vkd3d_render_pass_cache_cleanup ( struct vkd3d_render_pass_cache *  cache,
struct d3d12_device *  device 
)

Definition at line 1845 of file state.c.

1847{
1848 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1849 unsigned int i;
1850
1851 for (i = 0; i < cache->render_pass_count; ++i)
1852 {
1853 struct vkd3d_render_pass_entry *current = &cache->render_passes[i];
1854 VK_CALL(vkDestroyRenderPass(device->vk_device, current->vk_render_pass, NULL));
1855 }
1856
1857 vkd3d_free(cache->render_passes);
1858 cache->render_passes = NULL;
1859}
struct task_struct * current
Definition: linux.c:32
Definition: cache.c:41
Definition: state.c:1672
void VKAPI_CALL vkDestroyRenderPass(VkDevice device, VkRenderPass renderPass, const VkAllocationCallbacks *pAllocator)

Referenced by d3d12_device_Release().

◆ vkd3d_render_pass_cache_find()

HRESULT vkd3d_render_pass_cache_find ( struct vkd3d_render_pass_cache *  cache,
struct d3d12_device *  device,
const struct vkd3d_render_pass_key *  key,
VkRenderPass *  vk_render_pass 
)

Definition at line 1809 of file state.c.

1811{
1812 bool found = false;
1813 HRESULT hr = S_OK;
1814 unsigned int i;
1815
1816 vkd3d_mutex_lock(&device->pipeline_cache_mutex);
1817
1818 for (i = 0; i < cache->render_pass_count; ++i)
1819 {
1820 struct vkd3d_render_pass_entry *current = &cache->render_passes[i];
1821
1822 if (!memcmp(&current->key, key, sizeof(*key)))
1823 {
1824 *vk_render_pass = current->vk_render_pass;
1825 found = true;
1826 break;
1827 }
1828 }
1829
1830 if (!found)
1832
1833 vkd3d_mutex_unlock(&device->pipeline_cache_mutex);
1834
1835 return hr;
1836}
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2807
static HRESULT vkd3d_render_pass_cache_create_pass_locked(struct vkd3d_render_pass_cache *cache, struct d3d12_device *device, const struct vkd3d_render_pass_key *key, VkRenderPass *vk_render_pass)
Definition: state.c:1679
Definition: copy.c:22
VkRenderPass vk_render_pass
Definition: state.c:1674

Referenced by d3d12_graphics_pipeline_state_create_render_pass().

◆ vkd3d_render_pass_cache_init()

void vkd3d_render_pass_cache_init ( struct vkd3d_render_pass_cache *  cache)

Definition at line 1838 of file state.c.

1839{
1840 cache->render_passes = NULL;
1841 cache->render_pass_count = 0;
1842 cache->render_passes_size = 0;
1843}

Referenced by d3d12_device_init().

◆ vkd3d_set_private_data()

HRESULT vkd3d_set_private_data ( struct vkd3d_private_store *  store,
const GUID *  tag,
unsigned int  data_size,
const void *  data 
)

◆ vkd3d_set_private_data_interface()

◆ vkd3d_set_vk_object_name()

HRESULT vkd3d_set_vk_object_name ( struct d3d12_device *  device,
uint64_t  vk_object,
VkDebugReportObjectTypeEXT  vk_object_type,
const WCHAR *  name 
)

Definition at line 1077 of file utils.c.

1079{
1080 char *name_utf8;
1081 VkResult vr;
1082
1083 if (!name)
1084 return E_INVALIDARG;
1085
1086 if (!device->vk_info.EXT_debug_marker)
1087 return S_OK;
1088
1089 if (!(name_utf8 = vkd3d_strdup_w_utf8(name, device->wchar_size)))
1090 return E_OUTOFMEMORY;
1091
1092 vr = vkd3d_set_vk_object_name_utf8(device, vk_object, vk_object_type, name_utf8);
1093
1094 vkd3d_free(name_utf8);
1095
1096 return hresult_from_vk_result(vr);
1097}
HRESULT hresult_from_vk_result(VkResult vr)
Definition: utils.c:784
Definition: name.c:39
char * vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size)
Definition: utf8.c:159

Referenced by d3d12_command_allocator_SetName(), d3d12_command_queue_SetName(), d3d12_device_SetName(), d3d12_heap_SetName(), d3d12_pipeline_state_SetName(), d3d12_query_heap_SetName(), and d3d12_resource_SetName().

◆ vkd3d_set_vk_object_name_utf8()

VkResult vkd3d_set_vk_object_name_utf8 ( struct d3d12_device *  device,
uint64_t  vk_object,
VkDebugReportObjectTypeEXT  vk_object_type,
const char *  name 
)

Definition at line 1060 of file utils.c.

1062{
1063 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
1065
1066 if (!device->vk_info.EXT_debug_marker)
1067 return VK_SUCCESS;
1068
1070 info.pNext = NULL;
1071 info.objectType = vk_object_type;
1072 info.object = vk_object;
1073 info.pObjectName = name;
1074 return VK_CALL(vkDebugMarkerSetObjectNameEXT(device->vk_device, &info));
1075}
VkResult VKAPI_CALL vkDebugMarkerSetObjectNameEXT(VkDevice device, const VkDebugMarkerObjectNameInfoEXT *pNameInfo)
@ VK_STRUCTURE_TYPE_DEBUG_MARKER_OBJECT_NAME_INFO_EXT
Definition: vulkan.h:5026

Referenced by vkd3d_init_null_resources(), and vkd3d_set_vk_object_name().

◆ vkd3d_shader_cache_decref()

unsigned int vkd3d_shader_cache_decref ( struct vkd3d_shader_cache *  cache)

Definition at line 115 of file cache.c.

116{
117 unsigned int refcount = vkd3d_atomic_decrement_u32(&cache->refcount);
118 TRACE("cache %p refcount %u.\n", cache, refcount);
119
120 if (refcount)
121 return refcount;
122
125
127 return 0;
128}
static void rb_destroy(struct rb_tree *tree, rb_traverse_func_t *callback, void *context)
Definition: rbtree.h:185
static void vkd3d_shader_cache_destroy_entry(struct rb_entry *entry, void *context)
Definition: cache.c:108
HANDLE lock
Definition: cache.c:44
static uint32_t vkd3d_atomic_decrement_u32(uint32_t volatile *x)
Definition: vkd3d_common.h:477

Referenced by d3d12_cache_session_destroy().

◆ vkd3d_shader_cache_get()

int vkd3d_shader_cache_get ( struct vkd3d_shader_cache *  cache,
const void *  key,
size_t  key_size,
void *  value,
size_t *  value_size 
)

Definition at line 208 of file cache.c.

210{
211 struct shader_cache_entry *e;
212 struct shader_cache_key k;
213 struct rb_entry *entry;
214 enum vkd3d_result ret;
215 size_t size_in;
216
217 TRACE("%p, %p, %#zx, %p, %p.\n", cache, key, key_size, value, value_size);
218
219 size_in = *value_size;
220
221 k.hash = vkd3d_shader_cache_hash_key(key, key_size);
222 k.key = key;
223 k.key_size = key_size;
224
226
227 entry = rb_get(&cache->tree, &k);
228 if (!entry)
229 {
230 WARN("Entry not found.\n");
232 goto done;
233 }
234
236
237 *value_size = e->h.value_size;
238 if (!value)
239 {
240 TRACE("Found item %#"PRIx64", returning needed size %#"PRIx64".\n",
241 e->h.hash, e->h.value_size);
242 ret = VKD3D_OK;
243 goto done;
244 }
245
246 if (size_in < e->h.value_size)
247 {
248 WARN("Output buffer is too small for item %#"PRIx64", got %#zx want %#"PRIx64".\n",
249 e->h.hash, size_in, e->h.value_size);
251 goto done;
252 }
253
254 memcpy(value, e->payload + e->h.key_size, e->h.value_size);
255 ret = VKD3D_OK;
256 TRACE("Returning cached item %#"PRIx64".\n", e->h.hash);
257
258done:
260 return ret;
261}
#define e
Definition: ke_i.h:82
int k
Definition: mpi.c:3369
#define RB_ENTRY_VALUE(element, type, field)
Definition: rbtree.h:26
static struct rb_entry * rb_get(const struct rb_tree *tree, const void *key)
Definition: rbtree.h:192
static uint64_t vkd3d_shader_cache_hash_key(const void *key, size_t size)
Definition: cache.c:130
static void vkd3d_shader_cache_lock(struct vkd3d_shader_cache *cache)
Definition: cache.c:143
static void vkd3d_shader_cache_unlock(struct vkd3d_shader_cache *cache)
Definition: cache.c:148
Definition: rbtree.h:30
Definition: cache.c:37
Definition: pdh_main.c:64

Referenced by d3d12_cache_session_FindValue().

◆ vkd3d_shader_cache_incref()

unsigned int vkd3d_shader_cache_incref ( struct vkd3d_shader_cache *  cache)

Definition at line 101 of file cache.c.

102{
103 unsigned int refcount = vkd3d_atomic_increment_u32(&cache->refcount);
104 TRACE("cache %p refcount %u.\n", cache, refcount);
105 return refcount;
106}
static uint32_t vkd3d_atomic_increment_u32(uint32_t volatile *x)
Definition: vkd3d_common.h:482

Referenced by d3d12_cache_session_init().

◆ vkd3d_shader_cache_put()

int vkd3d_shader_cache_put ( struct vkd3d_shader_cache *  cache,
const void *  key,
size_t  key_size,
const void *  value,
size_t  value_size 
)

Definition at line 153 of file cache.c.

155{
156 struct shader_cache_entry *e;
157 struct shader_cache_key k;
158 struct rb_entry *entry;
159 enum vkd3d_result ret;
160
161 TRACE("%p, %p, %#zx, %p, %#zx.\n", cache, key, key_size, value, value_size);
162
163 k.hash = vkd3d_shader_cache_hash_key(key, key_size);
164 k.key = key;
165 k.key_size = key_size;
166
168
169 entry = rb_get(&cache->tree, &k);
171
172 if (e)
173 {
174 WARN("Key already exists, returning VKD3D_ERROR_KEY_ALREADY_EXISTS.\n");
176 goto done;
177 }
178
179 e = vkd3d_malloc(sizeof(*e));
180 if (!e)
181 {
183 goto done;
184 }
185 e->payload = vkd3d_malloc(key_size + value_size);
186 if (!e->payload)
187 {
188 vkd3d_free(e);
190 goto done;
191 }
192
193 e->h.key_size = key_size;
194 e->h.value_size = value_size;
195 e->h.hash = k.hash;
196 memcpy(e->payload, key, key_size);
197 memcpy(e->payload + key_size, value, value_size);
198
200 TRACE("Cache entry %#"PRIx64" stored.\n", k.hash);
201 ret = VKD3D_OK;
202
203done:
205 return ret;
206}
static void vkd3d_shader_cache_add_entry(struct vkd3d_shader_cache *cache, struct shader_cache_entry *e)
Definition: cache.c:69

Referenced by d3d12_cache_session_StoreValue().

◆ vkd3d_shader_open_cache()

int vkd3d_shader_open_cache ( struct vkd3d_shader_cache **  cache)

Definition at line 82 of file cache.c.

83{
85
86 TRACE("%p.\n", cache);
87
88 object = vkd3d_malloc(sizeof(*object));
89 if (!object)
91
92 object->refcount = 1;
95
96 *cache = object;
97
98 return VKD3D_OK;
99}
static void rb_init(struct rb_tree *tree, rb_compare_func_t compare)
Definition: rbtree.h:173
static int vkd3d_shader_cache_compare_key(const void *key, const struct rb_entry *entry)
Definition: cache.c:50

Referenced by d3d12_cache_session_init().

◆ vkd3d_uav_clear_state_cleanup()

void vkd3d_uav_clear_state_cleanup ( struct vkd3d_uav_clear_state *  state,
struct d3d12_device *  device 
)

Definition at line 4054 of file state.c.

4055{
4056 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
4057
4060
4061 VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout_image, NULL));
4062 VK_CALL(vkDestroyPipelineLayout(device->vk_device, state->vk_pipeline_layout_buffer, NULL));
4063
4064 VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout_image, NULL));
4065 VK_CALL(vkDestroyDescriptorSetLayout(device->vk_device, state->vk_set_layout_buffer, NULL));
4066}
static void vkd3d_uav_clear_pipelines_cleanup(struct vkd3d_uav_clear_pipelines *pipelines, struct d3d12_device *device)
Definition: state.c:4041
void VKAPI_CALL vkDestroyPipelineLayout(VkDevice device, VkPipelineLayout pipelineLayout, const VkAllocationCallbacks *pAllocator)
void VKAPI_CALL vkDestroyDescriptorSetLayout(VkDevice device, VkDescriptorSetLayout descriptorSetLayout, const VkAllocationCallbacks *pAllocator)

Referenced by d3d12_device_init(), d3d12_device_Release(), and vkd3d_uav_clear_state_init().

◆ vkd3d_uav_clear_state_init()

HRESULT vkd3d_uav_clear_state_init ( struct vkd3d_uav_clear_state *  state,
struct d3d12_device *  device 
)

Definition at line 4068 of file state.c.

4069{
4070 struct vkd3d_shader_push_constant_buffer push_constant;
4071 struct vkd3d_shader_interface_info shader_interface;
4073 VkDescriptorSetLayoutBinding set_binding;
4074 VkPushConstantRange push_constant_range;
4075 unsigned int i;
4076 HRESULT hr;
4077
4078 const struct
4079 {
4080 VkDescriptorSetLayout *set_layout;
4081 VkPipelineLayout *pipeline_layout;
4082 VkDescriptorType descriptor_type;
4083 }
4084 set_layouts[] =
4085 {
4086 {&state->vk_set_layout_buffer, &state->vk_pipeline_layout_buffer, VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER},
4087 {&state->vk_set_layout_image, &state->vk_pipeline_layout_image, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE},
4088 };
4089
4090 const struct
4091 {
4092 VkPipeline *pipeline;
4093 VkPipelineLayout *pipeline_layout;
4094 struct vkd3d_shader_code code;
4095 }
4096 pipelines[] =
4097 {
4098#define SHADER_CODE(name) {name, sizeof(name)}
4099 {&state->pipelines_float.buffer, &state->vk_pipeline_layout_buffer,
4101 {&state->pipelines_float.image_1d, &state->vk_pipeline_layout_image,
4103 {&state->pipelines_float.image_1d_array, &state->vk_pipeline_layout_image,
4105 {&state->pipelines_float.image_2d, &state->vk_pipeline_layout_image,
4107 {&state->pipelines_float.image_2d_array, &state->vk_pipeline_layout_image,
4109 {&state->pipelines_float.image_3d, &state->vk_pipeline_layout_image,
4111
4112 {&state->pipelines_uint.buffer, &state->vk_pipeline_layout_buffer,
4114 {&state->pipelines_uint.image_1d, &state->vk_pipeline_layout_image,
4116 {&state->pipelines_uint.image_1d_array, &state->vk_pipeline_layout_image,
4118 {&state->pipelines_uint.image_2d, &state->vk_pipeline_layout_image,
4120 {&state->pipelines_uint.image_2d_array, &state->vk_pipeline_layout_image,
4122 {&state->pipelines_uint.image_3d, &state->vk_pipeline_layout_image,
4124#undef SHADER_CODE
4125 };
4126
4127 memset(state, 0, sizeof(*state));
4128
4129 set_binding.binding = 0;
4130 set_binding.descriptorCount = 1;
4131 set_binding.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
4132 set_binding.pImmutableSamplers = NULL;
4133
4135 binding.register_space = 0;
4136 binding.register_index = 0;
4137 binding.shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE;
4138 binding.binding.set = 0;
4139 binding.binding.binding = 0;
4140 binding.binding.count = 1;
4141
4142 push_constant_range.stageFlags = VK_SHADER_STAGE_COMPUTE_BIT;
4143 push_constant_range.offset = 0;
4144 push_constant_range.size = sizeof(struct vkd3d_uav_clear_args);
4145
4146 push_constant.register_space = 0;
4147 push_constant.register_index = 0;
4148 push_constant.shader_visibility = VKD3D_SHADER_VISIBILITY_COMPUTE;
4149 push_constant.offset = 0;
4150 push_constant.size = sizeof(struct vkd3d_uav_clear_args);
4151
4152 for (i = 0; i < ARRAY_SIZE(set_layouts); ++i)
4153 {
4154 set_binding.descriptorType = set_layouts[i].descriptor_type;
4155
4157 1, false, &set_binding, set_layouts[i].set_layout)))
4158 {
4159 ERR("Failed to create descriptor set layout %u, hr %s.\n", i, debugstr_hresult(hr));
4160 goto fail;
4161 }
4162
4163 if (FAILED(hr = vkd3d_create_pipeline_layout(device, 1, set_layouts[i].set_layout,
4164 1, &push_constant_range, set_layouts[i].pipeline_layout)))
4165 {
4166 ERR("Failed to create pipeline layout %u, hr %s.\n", i, debugstr_hresult(hr));
4167 goto fail;
4168 }
4169 }
4170
4171 shader_interface.type = VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO;
4172 shader_interface.next = NULL;
4173 shader_interface.bindings = &binding;
4174 shader_interface.binding_count = 1;
4175 shader_interface.push_constant_buffers = &push_constant;
4176 shader_interface.push_constant_buffer_count = 1;
4177 shader_interface.combined_samplers = NULL;
4178 shader_interface.combined_sampler_count = 0;
4179 shader_interface.uav_counters = NULL;
4180 shader_interface.uav_counter_count = 0;
4181
4182 for (i = 0; i < ARRAY_SIZE(pipelines); ++i)
4183 {
4184 struct vkd3d_shader_code dxbc;
4185 int ret;
4186
4187 if ((ret = compile_hlsl_cs(&pipelines[i].code, &dxbc)))
4188 {
4189 ERR("Failed to compile HLSL compute shader %u, ret %d.\n", i, ret);
4191 goto fail;
4192 }
4193
4194 if (pipelines[i].pipeline_layout == &state->vk_pipeline_layout_buffer)
4196 else
4198
4200 &shader_interface, *pipelines[i].pipeline_layout, pipelines[i].pipeline);
4202 if (FAILED(hr))
4203 {
4204 ERR("Failed to create compute pipeline %u, hr %s.\n", i, debugstr_hresult(hr));
4205 goto fail;
4206 }
4207 }
4208
4209 return S_OK;
4210
4211fail:
4213 return hr;
4214}
const GLuint * pipelines
Definition: glext.h:7624
static HRESULT vkd3d_create_pipeline_layout(struct d3d12_device *device, unsigned int set_layout_count, const VkDescriptorSetLayout *set_layouts, unsigned int push_constant_count, const VkPushConstantRange *push_constants, VkPipelineLayout *pipeline_layout)
Definition: state.c:1424
#define SHADER_CODE(name)
static HRESULT vkd3d_create_descriptor_set_layout(struct d3d12_device *device, VkDescriptorSetLayoutCreateFlags flags, unsigned int binding_count, bool unbounded, const VkDescriptorSetLayoutBinding *bindings, VkDescriptorSetLayout *set_layout)
Definition: state.c:1368
void vkd3d_uav_clear_state_cleanup(struct vkd3d_uav_clear_state *state, struct d3d12_device *device)
Definition: state.c:4054
static HRESULT vkd3d_create_compute_pipeline(struct d3d12_device *device, const D3D12_SHADER_BYTECODE *code, const struct vkd3d_shader_interface_info *shader_interface, VkPipelineLayout vk_pipeline_layout, VkPipeline *vk_pipeline)
Definition: state.c:2359
static int compile_hlsl_cs(const struct vkd3d_shader_code *hlsl, struct vkd3d_shader_code *dxbc)
Definition: state.c:4011
VkShaderStageFlags stageFlags
Definition: vulkan.h:13441
Definition: inflate.c:139
uint64_t size
Definition: devices.h:44
VKD3D_SHADER_API void vkd3d_shader_free_shader_code(struct vkd3d_shader_code *code)
@ VKD3D_SHADER_STRUCTURE_TYPE_INTERFACE_INFO
Definition: vkd3d_shader.h:70
@ VKD3D_SHADER_VISIBILITY_COMPUTE
Definition: vkd3d_shader.h:398
@ VKD3D_SHADER_DESCRIPTOR_TYPE_UAV
Definition: vkd3d_shader.h:430
@ VKD3D_SHADER_BINDING_FLAG_IMAGE
Definition: vkd3d_shader.h:469
@ VKD3D_SHADER_BINDING_FLAG_BUFFER
Definition: vkd3d_shader.h:468
static const char cs_uav_clear_3d_uint_code[]
static const char cs_uav_clear_1d_array_float_code[]
Definition: vkd3d_shaders.h:56
static const char cs_uav_clear_2d_array_uint_code[]
static const char cs_uav_clear_1d_array_uint_code[]
Definition: vkd3d_shaders.h:73
static const char cs_uav_clear_1d_float_code[]
Definition: vkd3d_shaders.h:90
static const char cs_uav_clear_buffer_float_code[]
Definition: vkd3d_shaders.h:22
static const char cs_uav_clear_2d_uint_code[]
static const char cs_uav_clear_3d_float_code[]
static const char cs_uav_clear_buffer_uint_code[]
Definition: vkd3d_shaders.h:39
static const char cs_uav_clear_1d_uint_code[]
static const char cs_uav_clear_2d_array_float_code[]
static const char cs_uav_clear_2d_float_code[]
@ VK_SHADER_STAGE_COMPUTE_BIT
Definition: vulkan.h:4880
VkDescriptorType
Definition: vulkan.h:2463

Referenced by d3d12_device_init().

◆ vkd3d_view_decref()

void vkd3d_view_decref ( void *  view,
struct d3d12_device *  device 
)

Definition at line 2453 of file resource.c.

2454{
2455 union d3d12_desc_object u = {view};
2456
2457 if (vkd3d_atomic_decrement_u32(&u.header->refcount))
2458 return;
2459
2460 if (u.header->magic != VKD3D_DESCRIPTOR_MAGIC_CBV)
2462 else
2463 vkd3d_desc_object_cache_push(&device->cbuffer_desc_cache, u.object);
2464}
static void vkd3d_desc_object_cache_push(struct vkd3d_desc_object_cache *cache, void *object)
Definition: resource.c:2365
static void vkd3d_view_destroy(struct vkd3d_view *view, struct d3d12_device *device)
Definition: resource.c:2426
#define VKD3D_DESCRIPTOR_MAGIC_CBV
Definition: vkd3d_private.h:47

Referenced by d3d12_command_allocator_free_resources(), d3d12_command_list_ClearUnorderedAccessViewFloat(), d3d12_command_list_ClearUnorderedAccessViewUint(), d3d12_desc_create_sampler(), d3d12_desc_get_object_ref(), d3d12_desc_replace(), d3d12_dsv_desc_destroy(), d3d12_rtv_desc_destroy(), descriptor_writes_free_object_refs(), and vkd3d_create_buffer_uav().

◆ vkd3d_view_incref()

static bool vkd3d_view_incref ( void *  desc)
inlinestatic

Definition at line 660 of file vkd3d_private.h.

661{
662 struct vkd3d_desc_header *h = desc;
663 unsigned int refcount;
664
665 do
666 {
667 refcount = h->refcount;
668 /* Avoid incrementing a freed object. Reading the value is safe because objects are recycled. */
669 if (refcount <= 0)
670 return false;
671 }
672 while (!vkd3d_atomic_compare_exchange_u32(&h->refcount, refcount, refcount + 1));
673
674 return true;
675}
unsigned int volatile refcount
static bool vkd3d_atomic_compare_exchange_u32(uint32_t volatile *x, uint32_t expected, uint32_t val)
Definition: vkd3d_common.h:487

Referenced by d3d12_command_allocator_add_view(), and d3d12_desc_get_object_ref().

◆ vkd3d_vk_descriptor_set_index_from_vk_descriptor_type()

static enum vkd3d_vk_descriptor_set_index vkd3d_vk_descriptor_set_index_from_vk_descriptor_type ( VkDescriptorType  type)
inlinestatic

Definition at line 794 of file vkd3d_private.h.

796{
799
801}
enum vkd3d_vk_descriptor_set_index vk_descriptor_set_index_table[]
Definition: resource.c:4227
@ VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER
Definition: vulkan.h:2470

Referenced by d3d12_desc_write_vk_heap().

Variable Documentation

◆ object_global_serial_id

uint64_t object_global_serial_id
extern

Definition at line 25 of file resource.c.

Referenced by d3d12_descriptor_heap_init().

◆ vk_descriptor_set_index_table

enum vkd3d_vk_descriptor_set_index vk_descriptor_set_index_table[]
extern

Definition at line 4227 of file resource.c.

Referenced by vkd3d_vk_descriptor_set_index_from_vk_descriptor_type().

◆ vkd3d_build

const char vkd3d_build[]
extern