ReactOS 0.4.17-dev-923-g4c9a150
utils.c File Reference
#include "vkd3d_private.h"
#include <errno.h>
#include "vulkan_procs.h"
Include dependency graph for utils.c:

Go to the source code of this file.

Classes

struct  vkd3d_format_compatibility_info
 

Macros

#define COLOR   (VK_IMAGE_ASPECT_COLOR_BIT)
 
#define DEPTH   (VK_IMAGE_ASPECT_DEPTH_BIT)
 
#define STENCIL   (VK_IMAGE_ASPECT_STENCIL_BIT)
 
#define DEPTH_STENCIL   (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT)
 
#define TYPELESS   VKD3D_FORMAT_TYPE_TYPELESS
 
#define SINT   VKD3D_FORMAT_TYPE_SINT
 
#define UINT   VKD3D_FORMAT_TYPE_UINT
 
#define FLAG_TO_STR(f)   if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }
 
#define FLAG_TO_STR(f, n)   if (flags & f) { strcat(buffer, " | "#n); flags &= ~f; }
 
#define FLAG_TO_STR(f)   if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }
 
#define FLAG_TO_STR(f)   if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }
 
#define LOAD_GLOBAL_PFN(name)
 
#define LOAD_INSTANCE_PFN(name)
 
#define LOAD_INSTANCE_OPTIONAL_PFN(name)    procs->name = (void *)global_procs->vkGetInstanceProcAddr(instance, #name);
 
#define VK_INSTANCE_PFN   LOAD_INSTANCE_PFN
 
#define VK_INSTANCE_EXT_PFN   LOAD_INSTANCE_OPTIONAL_PFN
 
#define COPY_PARENT_PFN(name)   procs->name = parent_procs->name;
 
#define LOAD_DEVICE_PFN(name)
 
#define LOAD_DEVICE_OPTIONAL_PFN(name)    procs->name = (void *)procs->vkGetDeviceProcAddr(device, #name);
 
#define VK_INSTANCE_PFN   COPY_PARENT_PFN
 
#define VK_DEVICE_PFN   LOAD_DEVICE_PFN
 
#define VK_DEVICE_EXT_PFN   LOAD_DEVICE_OPTIONAL_PFN
 

Functions

static bool dxgi_format_is_depth_stencil (DXGI_FORMAT dxgi_format)
 
static HRESULT vkd3d_init_format_compatibility_lists (struct d3d12_device *device)
 
static void vkd3d_cleanup_format_compatibility_lists (struct d3d12_device *device)
 
static HRESULT vkd3d_init_depth_stencil_formats (struct d3d12_device *device)
 
static void vkd3d_cleanup_depth_stencil_formats (struct d3d12_device *device)
 
HRESULT vkd3d_init_format_info (struct d3d12_device *device)
 
void vkd3d_cleanup_format_info (struct d3d12_device *device)
 
static const struct vkd3d_format * vkd3d_get_depth_stencil_format (const struct d3d12_device *device, DXGI_FORMAT dxgi_format)
 
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)
 
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)
 
VkFormat vkd3d_get_vk_format (DXGI_FORMAT format)
 
DXGI_FORMAT vkd3d_get_dxgi_format (VkFormat format)
 
bool is_valid_feature_level (D3D_FEATURE_LEVEL feature_level)
 
bool is_write_resource_state (D3D12_RESOURCE_STATES state)
 
static bool is_power_of_two (unsigned int x)
 
bool is_valid_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)
 
static const char * debug_d3d12_shader_component (D3D12_SHADER_COMPONENT_MAPPING component)
 
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_queue_flags (VkQueueFlags flags)
 
const char * debug_vk_memory_heap_flags (VkMemoryHeapFlags flags)
 
const char * debug_vk_memory_property_flags (VkMemoryPropertyFlags flags)
 
HRESULT hresult_from_errno (int rc)
 
HRESULT hresult_from_vk_result (VkResult vr)
 
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])
 
static struct vkd3d_private_data * vkd3d_private_store_get_private_data (const struct vkd3d_private_store *store, const GUID *tag)
 
static HRESULT vkd3d_private_store_set_private_data (struct vkd3d_private_store *store, const GUID *tag, const void *data, unsigned int data_size, bool is_object)
 
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)
 
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)
 

Variables

static const struct vkd3d_format vkd3d_formats []
 
static const struct vkd3d_format format_b4g4r4a4
 
static const struct vkd3d_format vkd3d_depth_stencil_formats []
 
static const struct vkd3d_format_compatibility_info vkd3d_format_compatibility_info []
 

Macro Definition Documentation

◆ COLOR

Definition at line 23 of file utils.c.

◆ COPY_PARENT_PFN

#define COPY_PARENT_PFN (   name)    procs->name = parent_procs->name;

Definition at line 847 of file utils.c.

◆ DEPTH

Definition at line 24 of file utils.c.

◆ DEPTH_STENCIL

Definition at line 26 of file utils.c.

◆ FLAG_TO_STR [1/4]

#define FLAG_TO_STR (   f)    if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }

◆ FLAG_TO_STR [2/4]

#define FLAG_TO_STR (   f)    if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }

◆ FLAG_TO_STR [3/4]

#define FLAG_TO_STR (   f)    if (flags & f) { strcat(buffer, " | "#f); flags &= ~f; }

◆ FLAG_TO_STR [4/4]

#define FLAG_TO_STR (   f,
  n 
)    if (flags & f) { strcat(buffer, " | "#n); flags &= ~f; }

◆ LOAD_DEVICE_OPTIONAL_PFN

#define LOAD_DEVICE_OPTIONAL_PFN (   name)     procs->name = (void *)procs->vkGetDeviceProcAddr(device, #name);

Definition at line 854 of file utils.c.

◆ LOAD_DEVICE_PFN

#define LOAD_DEVICE_PFN (   name)
Value:
if (!(procs->name = (void *)procs->vkGetDeviceProcAddr(device, #name))) \
{ \
ERR("Could not get device proc addr for '" #name "'.\n"); \
return E_FAIL; \
}
#define E_FAIL
Definition: ddrawi.h:102
Definition: devices.h:37
Definition: name.c:39

Definition at line 848 of file utils.c.

◆ LOAD_GLOBAL_PFN

#define LOAD_GLOBAL_PFN (   name)
Value:
if (!(procs->name = (void *)vkGetInstanceProcAddr(NULL, #name))) \
{ \
ERR("Could not get global proc addr for '" #name "'.\n"); \
return E_FAIL; \
}
#define NULL
Definition: types.h:112
PFN_vkVoidFunction VKAPI_CALL vkGetInstanceProcAddr(VkInstance instance, const char *pName)

Definition at line 804 of file utils.c.

◆ LOAD_INSTANCE_OPTIONAL_PFN

#define LOAD_INSTANCE_OPTIONAL_PFN (   name)     procs->name = (void *)global_procs->vkGetInstanceProcAddr(instance, #name);

Definition at line 831 of file utils.c.

◆ LOAD_INSTANCE_PFN

#define LOAD_INSTANCE_PFN (   name)
Value:
if (!(procs->name = (void *)global_procs->vkGetInstanceProcAddr(instance, #name))) \
{ \
ERR("Could not get instance proc addr for '" #name "'.\n"); \
return E_FAIL; \
}
static HINSTANCE instance
Definition: main.c:35

Definition at line 825 of file utils.c.

◆ SINT

Definition at line 28 of file utils.c.

◆ STENCIL

Definition at line 25 of file utils.c.

◆ TYPELESS

Definition at line 27 of file utils.c.

◆ UINT

Definition at line 29 of file utils.c.

Referenced by __acrt_get_qualified_locale(), __acrt_get_qualified_locale_downlevel(), __crt_MessageBoxA(), CIniPropertyBag::_GetSectionAndName(), _gmtime64_s(), _isctype_l(), _localtime64_s(), CDesktopUpgradePropertyBag::_ReadFlags(), _Success_(), CBandSiteBase::_UpdateBand(), AboutDlgProc(), CBandSiteBase::AddBand(), AddCharacterToCharSet(), AddCodePage(), AllSysInfo(), Anime_FreeInfo(), ApplicationPage_OnEndTask(), ApplicationPage_OnGotoProcess(), ApplicationPage_OnSwitchTo(), ApplicationPage_OnWindowsBringToFront(), ApplicationPage_OnWindowsCascade(), ApplicationPage_OnWindowsMaximize(), ApplicationPage_OnWindowsMinimize(), ApplicationPage_OnWindowsTile(), asn_any_copy(), BuildCodePageList(), cal_return_number(), CalculateBitmapSize(), CTrayClockWnd::CalculateDueTime(), CardRegion::CardRegion(), CBGetTextAreaHeight(), CBindStatusCallback_UpdateProgress(), CBPaintText(), CheckListWndProc(), CLIPFORMAT_UserMarshal(), CLIPFORMAT_UserSize(), CLIPFORMAT_UserUnmarshal(), COMBO_ItemOp(), CommandDir(), CRecycleBin::CompareIDs(), CPlApplet(), CreateFolderFromNameSpace(), CreateStarBitmap(), CreateSysMenu(), DECLARE_INTERFACE_(), DefineDosDeviceW(), DeviceProblemTextW(), DIALOG_GoTo(), DirPrintWideList(), DisplayPageProc(), DlgPreferencesProc(), CDefView::DoColumnContextMenu(), CardRegion::DoFlash(), DoTestEntry(), DumpMenu(), EmbeddedComplexSize(), EMFDC_WriteNamedEscape(), EnableDialogText(), CMenuSite::EnumBands(), EnumFontSizesProc(), ExecuteREBytecode(), ExtractFilesCallback(), ExtractIconExW(), f_read(), f_write(), FGetComponentPath(), FileGetString(), FileStruct_Att(), FontFamilyFillInfo(), FontSizeChange(), FormatByteSize(), FormatFileSizeWithBytes(), ftGdiGetGlyphOutline(), GdipGetImagePaletteSize(), GdipGetSupportedFileExtensions(), gen_numname(), get_fat(), get_ldnumber(), get_support_msi(), BtrfsContextMenu::get_uac_icon(), GetCharacterPlacementW(), GetConsoleIMECommandLine(), GetDevNum(), GetFileTimeString(), GetKnownPath(), GetLocaleInfoW(), CMruNode::GetNodeSlot(), GetRawInputDeviceInfoA(), GetSelectedDriveItem(), GetSelectedItem(), GetSelectedUsageAction(), CFolder::GetUIObjectFromVariant(), GreGetDIBitsInternal(), IdnToNameprepUnicode(), ImageList_Create(), INF_OpenBufferedFileA(), CDrvDefExt::InitGeneralPage(), InitializeRecycleBinDlg(), install_wine_mono(), IntMapVirtualKeyEx(), IntSendCandListCHS(), KeyboardProc(), KeyboardSpeedProc(), LISTBOX_Create(), LISTBOX_DeleteItem(), LISTBOX_FindStringPos(), LISTBOX_InsertItem(), LISTVIEW_RefreshOwnerDraw(), LISTVIEW_ShowFocusRect(), LISTVIEW_WindowProc(), load_string(), locale_return_number(), LogOffDialogProc(), LpkGetCharacterPlacement(), LZCopy(), MainWndProc(), MakeFloatValueString(), MakeSimplePidl(), MD_OnChar(), MD_OnDeadChar(), MD_OnHotKey(), MD_OnKey(), MD_OnSysChar(), MD_OnSysDeadChar(), MD_OnSysKey(), MD_OnUniChar(), MENU_mnu2mnuii(), MenuHelp(), modify_binary_dlgproc(), MonthCalSetupDayTimer(), MouseCommand(), MsgMemorySize(), NdrBaseTypeMemorySize(), NdrSimpleTypeUnmarshall(), NextPathA(), NextPathW(), NICTestRAM(), notify_itemactivate(), NtUserEnableMenuItem(), NtUserGetRawInputDeviceInfo(), NtUserGetRawInputDeviceList(), NtUserRegisterWindowMessage(), NtUserSetWindowWord(), ok_strings_(), CDefView::OnCommand(), CAutoComplete::OnEditKeyDown(), CMainToolbar::OnGetDispInfo(), CShellLink::OnNotify(), OnSelChange(), CInternetToolbar::OnTipText(), CChangeNotifyServer::OnUnRegister(), OptionProc(), OptionsProc(), OverrideFileContent(), ParseMinMaxQuantifier(), ParseQuantifier(), ParseTerm(), performance_tool_ProcessPMsg(), PlaySoundRoutine(), ProgressWindowProc(), push_token(), put_fat(), CInternetToolbar::QIBand(), ReadAndDumpString(), ReadIpConfiguration(), REBAR_DeleteBand(), RecycleBin5_Create(), CBandSiteBase::RemoveBand(), SASWindowProc(), SaveFontSubstitutionSettings(), SetNTPServer(), setSBUpLow(), SettingsPageProc(), SetupCommitFileQueueW(), SetupOpenInfFileExW(), Shell_MergeMenus(), SHEvaluateSystemCommandTemplate(), SHGetFileDescriptionA(), SHInvokeCommandsOnContextMenu(), CNetConnectionPropertyUi::ShowNetworkComponentProperties(), SHParseName(), ShutdownDialogProc(), SndMixerGetLineName(), SndMixerGetProductName(), SnmpUtilVarBindCpy(), STATIC_PaintOwnerDrawfn(), CardRegion::StopFlash(), StrStrCase(), TAB_DrawItemInterior(), Test_CopyImage_Flags(), test_CreateStdAccessibleObject_classes(), test_FileTimeToLocalFileTime(), test_FileTimeToSystemTime(), test_menu_search_bycommand(), test_msidecomposedesc(), test_RegLoadMUIString(), test_sha_ctx(), Test_Write_StreamPosition(), text_buffer_changed(), TOOLBAR_KeyDown(), TreeListEndLabelEdit(), TreeListKeyDown(), TreeListMouseClick(), TreeListMouseNotify(), TreeListStartAutoEdit(), TreeListStartNotifyEdit(), UserpFormatMessages(), UserSetClassLongPtr(), weld_udec3(), WhoamiPrintTable(), wmain(), WritePageFileSettings(), WSHGetBroadcastSockaddr(), and WSHGetWildcardSockaddr().

◆ VK_DEVICE_EXT_PFN

#define VK_DEVICE_EXT_PFN   LOAD_DEVICE_OPTIONAL_PFN

◆ VK_DEVICE_PFN

#define VK_DEVICE_PFN   LOAD_DEVICE_PFN

◆ VK_INSTANCE_EXT_PFN

#define VK_INSTANCE_EXT_PFN   LOAD_INSTANCE_OPTIONAL_PFN

◆ VK_INSTANCE_PFN [1/2]

#define VK_INSTANCE_PFN   LOAD_INSTANCE_PFN

◆ VK_INSTANCE_PFN [2/2]

#define VK_INSTANCE_PFN   COPY_PARENT_PFN

Function Documentation

◆ 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}
Definition: palette.c:466

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

◆ debug_d3d12_shader_component()

static const char * debug_d3d12_shader_component ( D3D12_SHADER_COMPONENT_MAPPING  component)
static

Definition at line 660 of file utils.c.

661{
662 switch (component)
663 {
665 return "r";
667 return "g";
669 return "b";
671 return "a";
673 return "0";
675 return "1";
676 }
677
678 FIXME("Invalid component mapping %#x.\n", component);
679 return "invalid";
680}
#define FIXME(fmt,...)
Definition: precomp.h:53
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_1
Definition: d3d12.idl:1477
@ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_0
Definition: d3d12.idl:1480
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_3
Definition: d3d12.idl:1479
@ D3D12_SHADER_COMPONENT_MAPPING_FORCE_VALUE_1
Definition: d3d12.idl:1481
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_0
Definition: d3d12.idl:1476
@ D3D12_SHADER_COMPONENT_MAPPING_FROM_MEMORY_COMPONENT_2
Definition: d3d12.idl:1478

Referenced by debug_d3d12_shader_component_mapping().

◆ 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_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
GLbitfield flags
Definition: glext.h:7161
#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_HOST_COHERENT_BIT
Definition: vulkan.h:3772
@ 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
@ VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT
Definition: vulkan.h:3771

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().

◆ dxgi_format_is_depth_stencil()

static bool dxgi_format_is_depth_stencil ( DXGI_FORMAT  dxgi_format)
static

Definition at line 247 of file utils.c.

248{
249 unsigned int i;
250
251 for (i = 0; i < ARRAY_SIZE(vkd3d_formats); ++i)
252 {
253 const struct vkd3d_format *current = &vkd3d_formats[i];
254
255 if (current->dxgi_format == dxgi_format)
257 }
258
260 {
262 return true;
263 }
264
265 return false;
266}
#define ARRAY_SIZE(A)
Definition: main.h:20
DXGI_FORMAT dxgi_format
Definition: texture.c:51
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
struct task_struct * current
Definition: linux.c:32
static const struct vkd3d_format vkd3d_formats[]
Definition: utils.c:30
static const struct vkd3d_format vkd3d_depth_stencil_formats[]
Definition: utils.c:125
@ VK_IMAGE_ASPECT_STENCIL_BIT
Definition: vulkan.h:3367
@ VK_IMAGE_ASPECT_DEPTH_BIT
Definition: vulkan.h:3366

Referenced by vkd3d_init_format_compatibility_lists().

◆ 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_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_INVALIDARG
Definition: ddrawi.h:101
#define EINVAL
Definition: errno.h:44
#define ENOMEM
Definition: errno.h:35
#define S_OK
Definition: intsafe.h:52

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}
#define WARN(fmt,...)
Definition: precomp.h:61
@ 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().

◆ is_power_of_two()

static bool is_power_of_two ( unsigned int  x)
static

Definition at line 585 of file utils.c.

586{
587 return x && !(x & (x -1));
588}
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Referenced by is_valid_resource_state().

◆ 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}
static int state
Definition: maze.c:121
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()

HRESULT return_interface ( void *  iface,
REFIID  iface_iid,
REFIID  requested_iid,
void **  object 
)

◆ vkd3d_cleanup_depth_stencil_formats()

static void vkd3d_cleanup_depth_stencil_formats ( struct d3d12_device *  device)
static

Definition at line 393 of file utils.c.

394{
395 if (vkd3d_depth_stencil_formats != device->depth_stencil_formats)
396 vkd3d_free((void *)device->depth_stencil_formats);
397
398 device->depth_stencil_formats = NULL;
399}
static void vkd3d_free(void *ptr)
Definition: vkd3d_memory.h:52

Referenced by vkd3d_cleanup_format_info(), and vkd3d_init_format_info().

◆ vkd3d_cleanup_format_compatibility_lists()

static void vkd3d_cleanup_format_compatibility_lists ( struct d3d12_device *  device)
static

Definition at line 346 of file utils.c.

347{
348 vkd3d_free((void *)device->format_compatibility_lists);
349
350 device->format_compatibility_lists = NULL;
351 device->format_compatibility_list_count = 0;
352}

Referenced by vkd3d_cleanup_format_info().

◆ 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_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
Definition: dxgiformat.idl:22
@ DXGI_FORMAT_UNKNOWN
Definition: dxgiformat.idl:23
const struct vkd3d_format * vkd3d_get_format(const struct d3d12_device *device, DXGI_FORMAT dxgi_format, bool depth_stencil)
Definition: utils.c:442
enum vkd3d_format_type type
@ VKD3D_FORMAT_TYPE_UINT

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
GLenum src
Definition: glext.h:6340
GLenum GLenum dst
Definition: glext.h:6340
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
GLfloat GLfloat GLfloat GLfloat h
Definition: glext.h:7723
#define d
Definition: ke_i.h:81
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878

Referenced by d3d12_resource_ReadFromSubresource(), and d3d12_resource_WriteToSubresource().

◆ vkd3d_get_depth_stencil_format()

static const struct vkd3d_format * vkd3d_get_depth_stencil_format ( const struct d3d12_device *  device,
DXGI_FORMAT  dxgi_format 
)
static

Definition at line 424 of file utils.c.

426{
427 const struct vkd3d_format *formats;
428 unsigned int i;
429
431 formats = device->depth_stencil_formats;
432
434 {
436 return &formats[i];
437 }
438
439 return NULL;
440}
static const struct wined3d_format_channels formats[]
Definition: utils.c:82
#define VKD3D_ASSERT(cond)
Definition: vkd3d_common.h:49

Referenced by vkd3d_get_format().

◆ vkd3d_get_dxgi_format()

DXGI_FORMAT vkd3d_get_dxgi_format ( VkFormat  format)

Definition at line 530 of file utils.c.

531{
533 VkFormat vk_format;
534 unsigned int i;
535
536 for (i = 0; i < ARRAY_SIZE(vkd3d_formats); ++i)
537 {
538 vk_format = vkd3d_formats[i].vk_format;
539 dxgi_format = vkd3d_formats[i].dxgi_format;
540 if (vk_format == format && vkd3d_formats[i].type != VKD3D_FORMAT_TYPE_TYPELESS)
541 return dxgi_format;
542 }
543
544 FIXME("Unhandled Vulkan format %#x.\n", format);
545 return DXGI_FORMAT_UNKNOWN;
546}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
@ VKD3D_FORMAT_TYPE_TYPELESS
VkFormat
Definition: vulkan.h:2815

◆ 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_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_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}
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizeiptr size
Definition: glext.h:5919
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
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
wchar_t tm const _CrtWcstime_Writes_and_advances_ptr_ count wchar_t ** out
Definition: wcsftime.cpp:383
#define DXGI_ERROR_NOT_FOUND
Definition: winerror.h:7122
#define DXGI_ERROR_MORE_DATA
Definition: winerror.h:7123

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_get_vk_format()

VkFormat vkd3d_get_vk_format ( DXGI_FORMAT  format)

Definition at line 520 of file utils.c.

521{
522 const struct vkd3d_format *vkd3d_format;
523
524 if (!(vkd3d_format = vkd3d_get_format(NULL, format, false)))
525 return VK_FORMAT_UNDEFINED;
526
527 return vkd3d_format->vk_format;
528}
VkFormat vk_format
@ VK_FORMAT_UNDEFINED
Definition: vulkan.h:2816

Referenced by d3d12_swapchain_create_d3d12_resources(), select_vk_format(), and vkd3d_init_format_compatibility_lists().

◆ vkd3d_init_depth_stencil_formats()

static HRESULT vkd3d_init_depth_stencil_formats ( struct d3d12_device *  device)
static

Definition at line 354 of file utils.c.

355{
356 const unsigned int count = ARRAY_SIZE(vkd3d_depth_stencil_formats);
357 const struct vkd3d_vk_device_procs *vk_procs = &device->vk_procs;
358 VkFormatProperties properties;
359 struct vkd3d_format *formats;
360 unsigned int i;
361
363 VK_FORMAT_D24_UNORM_S8_UINT, &properties));
364
366 {
367 device->depth_stencil_formats = vkd3d_depth_stencil_formats;
368 }
369 else
370 {
371 /* AMD doesn't support VK_FORMAT_D24_UNORM_S8_UINT. */
372 WARN("Mapping VK_FORMAT_D24_UNORM_S8_UINT to VK_FORMAT_D32_SFLOAT_S8_UINT.\n");
373
374 if (!(formats = vkd3d_calloc(count, sizeof(*formats))))
375 return E_OUTOFMEMORY;
376
378 for (i = 0; i < count; ++i)
379 {
381 {
383 formats[i].is_emulated = true;
384 }
385 }
386
387 device->depth_stencil_formats = formats;
388 }
389
390 return S_OK;
391}
GLuint GLuint GLsizei count
Definition: gl.h:1545
VkFormatFeatureFlags optimalTilingFeatures
Definition: vulkan.h:8746
static void * vkd3d_calloc(size_t count, size_t size)
Definition: vkd3d_memory.h:43
@ VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT
Definition: vulkan.h:3137
void VKAPI_CALL vkGetPhysicalDeviceFormatProperties(VkPhysicalDevice physicalDevice, VkFormat format, VkFormatProperties *pFormatProperties)
@ VK_FORMAT_D24_UNORM_S8_UINT
Definition: vulkan.h:2945
@ VK_FORMAT_D32_SFLOAT_S8_UINT
Definition: vulkan.h:2946
#define VK_CALL(f)
Definition: wined3d_vk.h:272

Referenced by vkd3d_init_format_info().

◆ vkd3d_init_format_compatibility_lists()

static HRESULT vkd3d_init_format_compatibility_lists ( struct d3d12_device *  device)
static

Definition at line 269 of file utils.c.

270{
271 struct vkd3d_format_compatibility_list *lists, *current_list;
274 VkFormat vk_format;
275 unsigned int count;
276 unsigned int i, j;
277
278 device->format_compatibility_list_count = 0;
279 device->format_compatibility_lists = NULL;
280
281 if (!device->vk_info.KHR_image_format_list)
282 return S_OK;
283
284 count = 1;
287 {
289
291 {
292 ++count;
294 }
295 }
296
297 if (!(lists = vkd3d_calloc(count, sizeof(*lists))))
298 return E_OUTOFMEMORY;
299
300 count = 0;
301 current_list = lists;
304 {
306
307 if (current_list->typeless_format != current->typeless_format)
308 {
309 /* Avoid empty format lists. */
310 if (current_list->format_count)
311 {
312 ++current_list;
313 ++count;
314 }
315
316 current_list->typeless_format = current->typeless_format;
317 }
318
319 /* In Vulkan, each depth-stencil format is only compatible with itself. */
321 continue;
322
323 if (!(vk_format = vkd3d_get_vk_format(current->format)))
324 continue;
325
326 for (j = 0; j < current_list->format_count; ++j)
327 {
328 if (current_list->vk_formats[j] == vk_format)
329 break;
330 }
331
332 if (j >= current_list->format_count)
333 {
335 current_list->vk_formats[current_list->format_count++] = vk_format;
336 }
337 }
338 if (current_list->format_count)
339 ++count;
340
341 device->format_compatibility_list_count = count;
342 device->format_compatibility_lists = lists;
343 return S_OK;
344}
GLsizei GLenum const GLvoid * lists
Definition: glfuncs.h:14
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint j
Definition: glfuncs.h:250
static bool dxgi_format_is_depth_stencil(DXGI_FORMAT dxgi_format)
Definition: utils.c:247
VkFormat vkd3d_get_vk_format(DXGI_FORMAT format)
Definition: utils.c:520
VkFormat vk_formats[VKD3D_MAX_COMPATIBLE_FORMAT_COUNT]
#define VKD3D_MAX_COMPATIBLE_FORMAT_COUNT
Definition: vkd3d_private.h:54

Referenced by vkd3d_init_format_info().

◆ 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}
#define FAILED(hr)
Definition: intsafe.h:51
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_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}
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4

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)
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_private_store_get_private_data()

static struct vkd3d_private_data * vkd3d_private_store_get_private_data ( const struct vkd3d_private_store *  store,
const GUID *  tag 
)
static

Definition at line 939 of file utils.c.

941{
942 struct vkd3d_private_data *data;
943
945 {
946 if (IsEqualGUID(&data->tag, tag))
947 return data;
948 }
949
950 return NULL;
951}
uint32_t entry
Definition: isohybrid.c:63
#define LIST_FOR_EACH_ENTRY(elem, list, type, field)
Definition: list.h:236

Referenced by vkd3d_get_private_data(), and vkd3d_private_store_set_private_data().

◆ vkd3d_private_store_set_private_data()

static HRESULT vkd3d_private_store_set_private_data ( struct vkd3d_private_store *  store,
const GUID *  tag,
const void *  data,
unsigned int  data_size,
bool  is_object 
)
static

Definition at line 953 of file utils.c.

955{
956 struct vkd3d_private_data *d, *old_data;
957 const void *ptr = data;
958
959 if (!data)
960 {
962 {
964 return S_OK;
965 }
966
967 return S_FALSE;
968 }
969
970 if (is_object)
971 {
972 if (data_size != sizeof(IUnknown *))
973 return E_INVALIDARG;
974 ptr = &data;
975 }
976
977 if (!(d = vkd3d_malloc(offsetof(struct vkd3d_private_data, u.data[data_size]))))
978 return E_OUTOFMEMORY;
979
980 d->tag = *tag;
981 d->size = data_size;
982 d->is_object = is_object;
983 memcpy(d->u.data, ptr, data_size);
984 if (is_object)
985 IUnknown_AddRef(d->u.object);
986
987 if ((old_data = vkd3d_private_store_get_private_data(store, tag)))
989 list_add_tail(&store->content, &d->entry);
990
991 return S_OK;
992}
static void list_add_tail(struct list_entry *head, struct list_entry *entry)
Definition: list.h:83
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
static PVOID ptr
Definition: dispmode.c:27
#define offsetof(TYPE, MEMBER)
int is_object(const type_t *iface)
Definition: header.c:972
struct list entry
Definition: wpp.c:51
static void * vkd3d_malloc(size_t size)
Definition: vkd3d_memory.h:28
static void vkd3d_private_data_destroy(struct vkd3d_private_data *data)
#define S_FALSE
Definition: winerror.h:3451

Referenced by vkd3d_set_private_data(), and vkd3d_set_private_data_interface().

◆ 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}
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
HRESULT hresult_from_vk_result(VkResult vr)
Definition: utils.c:784
char * vkd3d_strdup_w_utf8(const WCHAR *wstr, size_t wchar_size)
Definition: utf8.c:159
VkResult
Definition: vulkan.h:4639

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().

Variable Documentation

◆ format_b4g4r4a4

const struct vkd3d_format format_b4g4r4a4
static
Initial value:
=
@ DXGI_FORMAT_B4G4R4A4_UNORM
Definition: dxgiformat.idl:138
#define COLOR
Definition: utils.c:23
@ VK_FORMAT_A4R4G4B4_UNORM_PACK16_EXT
Definition: vulkan.h:3118

Definition at line 121 of file utils.c.

Referenced by vkd3d_get_format().

◆ vkd3d_depth_stencil_formats

const struct vkd3d_format vkd3d_depth_stencil_formats[]
static
Initial value:
=
{
}
@ DXGI_FORMAT_D32_FLOAT_S8X24_UINT
Definition: dxgiformat.idl:43
@ DXGI_FORMAT_R32_FLOAT
Definition: dxgiformat.idl:64
@ DXGI_FORMAT_R24_UNORM_X8_TYPELESS
Definition: dxgiformat.idl:69
@ DXGI_FORMAT_R32_FLOAT_X8X24_TYPELESS
Definition: dxgiformat.idl:44
@ DXGI_FORMAT_X24_TYPELESS_G8_UINT
Definition: dxgiformat.idl:70
@ DXGI_FORMAT_R16_UNORM
Definition: dxgiformat.idl:79
@ DXGI_FORMAT_D24_UNORM_S8_UINT
Definition: dxgiformat.idl:68
@ DXGI_FORMAT_R32_TYPELESS
Definition: dxgiformat.idl:62
@ DXGI_FORMAT_R24G8_TYPELESS
Definition: dxgiformat.idl:67
@ DXGI_FORMAT_R16_TYPELESS
Definition: dxgiformat.idl:76
@ DXGI_FORMAT_R32G8X24_TYPELESS
Definition: dxgiformat.idl:42
@ DXGI_FORMAT_X32_TYPELESS_G8X24_UINT
Definition: dxgiformat.idl:45
#define TYPELESS
Definition: utils.c:27
#define DEPTH
Definition: utils.c:24
#define DEPTH_STENCIL
Definition: utils.c:26
#define STENCIL
Definition: utils.c:25
@ VK_FORMAT_D32_SFLOAT
Definition: vulkan.h:2942
@ VK_FORMAT_D16_UNORM
Definition: vulkan.h:2940

Definition at line 125 of file utils.c.

Referenced by dxgi_format_is_depth_stencil(), vkd3d_cleanup_depth_stencil_formats(), vkd3d_get_depth_stencil_format(), and vkd3d_init_depth_stencil_formats().

◆ vkd3d_format_compatibility_info

◆ vkd3d_formats

const struct vkd3d_format vkd3d_formats[]
static

Definition at line 30 of file utils.c.

Referenced by dxgi_format_is_depth_stencil(), vkd3d_get_dxgi_format(), and vkd3d_get_format().