Code Monkey home page Code Monkey logo

Comments (16)

nowrep avatar nowrep commented on July 21, 2024 1

What about this patch on top of current master

diff --git a/src/vklayer.h b/src/vklayer.h
index 52003da..967922e 100644
--- a/src/vklayer.h
+++ b/src/vklayer.h
@@ -31,6 +31,54 @@ with this program. If not, see <https://www.gnu.org/licenses/>
 #include <vulkan/vulkan_xlib.h>
 #endif
 
+#ifndef VK_EXT_image_drm_format_modifier
+#define VK_EXT_image_drm_format_modifier 1
+#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION 1
+#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME "VK_EXT_image_drm_format_modifier"
+
+#define VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT -1000158000
+#define VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT 1000158000
+#define VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT 1000158003
+#define VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT 1000158005
+
+typedef struct VkDrmFormatModifierPropertiesEXT {
+    uint64_t                drmFormatModifier;
+    uint32_t                drmFormatModifierPlaneCount;
+    VkFormatFeatureFlags    drmFormatModifierTilingFeatures;
+} VkDrmFormatModifierPropertiesEXT;
+
+typedef struct VkDrmFormatModifierPropertiesListEXT {
+    VkStructureType                      sType;
+    void*                                pNext;
+    uint32_t                             drmFormatModifierCount;
+    VkDrmFormatModifierPropertiesEXT*    pDrmFormatModifierProperties;
+} VkDrmFormatModifierPropertiesListEXT;
+
+typedef struct VkPhysicalDeviceImageDrmFormatModifierInfoEXT {
+    VkStructureType    sType;
+    const void*        pNext;
+    uint64_t           drmFormatModifier;
+    VkSharingMode      sharingMode;
+    uint32_t           queueFamilyIndexCount;
+    const uint32_t*    pQueueFamilyIndices;
+} VkPhysicalDeviceImageDrmFormatModifierInfoEXT;
+
+typedef struct VkImageDrmFormatModifierListCreateInfoEXT {
+    VkStructureType    sType;
+    const void*        pNext;
+    uint32_t           drmFormatModifierCount;
+    const uint64_t*    pDrmFormatModifiers;
+} VkImageDrmFormatModifierListCreateInfoEXT;
+
+typedef struct VkImageDrmFormatModifierPropertiesEXT {
+    VkStructureType    sType;
+    void*              pNext;
+    uint64_t           drmFormatModifier;
+} VkImageDrmFormatModifierPropertiesEXT;
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetImageDrmFormatModifierPropertiesEXT)(VkDevice device, VkImage image, VkImageDrmFormatModifierPropertiesEXT* pProperties);
+#endif
+
 #define DEF_FUNC(x) PFN_vk##x x
 
 struct vk_inst_funcs {

from obs-vkcapture.

nowrep avatar nowrep commented on July 21, 2024 1
diff --git a/src/vklayer.h b/src/vklayer.h
index 52003da..a8950fa 100644
--- a/src/vklayer.h
+++ b/src/vklayer.h
@@ -31,6 +31,56 @@ with this program. If not, see <https://www.gnu.org/licenses/>
 #include <vulkan/vulkan_xlib.h>
 #endif
 
+#ifndef VK_EXT_image_drm_format_modifier
+#define VK_EXT_image_drm_format_modifier 1
+#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_SPEC_VERSION 1
+#define VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME "VK_EXT_image_drm_format_modifier"
+
+#define VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT -1000158000
+#define VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT 1000158000
+#define VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT 1000158003
+#define VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT 1000158005
+#define VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT 1000158002
+#define VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT 1000158000
+
+typedef struct VkDrmFormatModifierPropertiesEXT {
+    uint64_t                drmFormatModifier;
+    uint32_t                drmFormatModifierPlaneCount;
+    VkFormatFeatureFlags    drmFormatModifierTilingFeatures;
+} VkDrmFormatModifierPropertiesEXT;
+
+typedef struct VkDrmFormatModifierPropertiesListEXT {
+    VkStructureType                      sType;
+    void*                                pNext;
+    uint32_t                             drmFormatModifierCount;
+    VkDrmFormatModifierPropertiesEXT*    pDrmFormatModifierProperties;
+} VkDrmFormatModifierPropertiesListEXT;
+
+typedef struct VkPhysicalDeviceImageDrmFormatModifierInfoEXT {
+    VkStructureType    sType;
+    const void*        pNext;
+    uint64_t           drmFormatModifier;
+    VkSharingMode      sharingMode;
+    uint32_t           queueFamilyIndexCount;
+    const uint32_t*    pQueueFamilyIndices;
+} VkPhysicalDeviceImageDrmFormatModifierInfoEXT;
+
+typedef struct VkImageDrmFormatModifierListCreateInfoEXT {
+    VkStructureType    sType;
+    const void*        pNext;
+    uint32_t           drmFormatModifierCount;
+    const uint64_t*    pDrmFormatModifiers;
+} VkImageDrmFormatModifierListCreateInfoEXT;
+
+typedef struct VkImageDrmFormatModifierPropertiesEXT {
+    VkStructureType    sType;
+    void*              pNext;
+    uint64_t           drmFormatModifier;
+} VkImageDrmFormatModifierPropertiesEXT;
+
+typedef VkResult (VKAPI_PTR *PFN_vkGetImageDrmFormatModifierPropertiesEXT)(VkDevice device, VkImage image, VkImageDrmFormatModifierPropertiesEXT* pProperties);
+#endif
+
 #define DEF_FUNC(x) PFN_vk##x x
 
 struct vk_inst_funcs {

from obs-vkcapture.

nowrep avatar nowrep commented on July 21, 2024

I think the newest extension it requires is https://www.khronos.org/registry/vulkan/specs/1.2-extensions/man/html/VK_EXT_image_drm_format_modifier.html and that was added in 2018.
So in theory it could work?

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

OK, I'm getting build errors like this:

In file included from /<path-to-project>/OBSVkCapture/src/vklayer.c:19:0:
/<path-to-project>/OBSVkCapture/src/vklayer.h:33:21: error: unknown type name 'PFN_vkGetImageDrmFormatModifierPropertiesEXT'
 #define DEF_FUNC(x) PFN_vk##x x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:81:5: note: in expansion of macro 'DEF_FUNC'
     DEF_FUNC(GetImageDrmFormatModifierPropertiesEXT);
     ^~~~~~~~
/<path-to-project>/OBSVkCapture/src/vklayer.h: In function 'result_to_str':
/<path-to-project>/OBSVkCapture/src/vklayer.h:351:9: error: 'VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT' undeclared (first use in this function)
     VAL(VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:90:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:351:9: note: each undeclared identifier is reported only once for each function it appears in
     VAL(VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:90:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:352:9: error: 'VK_ERROR_FRAGMENTATION_EXT' undeclared (first use in this function); did you mean 'VK_ERROR_FRAGMENTED_POOL'?
     VAL(VK_ERROR_FRAGMENTATION_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:90:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:354:9: error: 'VK_ERROR_INVALID_DEVICE_ADDRESS_EXT' undeclared (first use in this function); did you mean 'VK_ERROR_INVALID_SHADER_NV'?
     VAL(VK_ERROR_INVALID_DEVICE_ADDRESS_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:90:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:355:9: error: 'VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT' undeclared (first use in this function)
     VAL(VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:90:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.c: In function 'vk_shtex_init_vulkan_tex':
/<path-to-project>/OBSVkCapture/src/vklayer.c:575:5: error: unknown type name 'VkImageDrmFormatModifierListCreateInfoEXT'; did you mean 'VkImageFormatListCreateInfoKHR'?
     VkImageDrmFormatModifierListCreateInfoEXT image_modifier_list = {};
     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
     VkImageFormatListCreateInfoKHR
/<path-to-project>/OBSVkCapture/src/vklayer.c:575:69: error: empty scalar initializer
     VkImageDrmFormatModifierListCreateInfoEXT image_modifier_list = {};
                                                                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:575:69: note: (near initialization for 'image_modifier_list')
/<path-to-project>/OBSVkCapture/src/vklayer.c:580:9: error: unknown type name 'VkDrmFormatModifierPropertiesListEXT'; did you mean 'VkMemoryHostPointerPropertiesEXT'?
         VkDrmFormatModifierPropertiesListEXT modifier_props_list = {};
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         VkMemoryHostPointerPropertiesEXT
/<path-to-project>/OBSVkCapture/src/vklayer.c:580:68: error: empty scalar initializer
         VkDrmFormatModifierPropertiesListEXT modifier_props_list = {};
                                                                    ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:580:68: note: (near initialization for 'modifier_props_list')
/<path-to-project>/OBSVkCapture/src/vklayer.c:581:28: error: request for member 'sType' in something not a structure or union
         modifier_props_list.sType = VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT;
                            ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:581:37: error: 'VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT' undeclared (first use in this function); did you mean 'VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT'?
         modifier_props_list.sType = VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT;
                                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                     VK_STRUCTURE_TYPE_MEMORY_HOST_POINTER_PROPERTIES_EXT
/<path-to-project>/OBSVkCapture/src/vklayer.c:591:51: error: request for member 'drmFormatModifierCount' in something not a structure or union
             vk_alloc(data->ac, modifier_props_list.drmFormatModifierCount * sizeof(struct VkDrmFormatModifierPropertiesEXT),
                                                   ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:591:84: error: invalid application of 'sizeof' to incomplete type 'struct VkDrmFormatModifierPropertiesEXT'
             vk_alloc(data->ac, modifier_props_list.drmFormatModifierCount * sizeof(struct VkDrmFormatModifierPropertiesEXT),
                                                                                    ^~~~~~
/<path-to-project>/OBSVkCapture/src/vklayer.c:592:30: error: invalid application of '__alignof__' to incomplete type 'struct VkDrmFormatModifierPropertiesEXT'
                     _Alignof(struct VkDrmFormatModifierPropertiesEXT), VK_SYSTEM_ALLOCATION_SCOPE_COMMAND);
                              ^~~~~~
/<path-to-project>/OBSVkCapture/src/vklayer.c:594:28: error: request for member 'pDrmFormatModifierProperties' in something not a structure or union
         modifier_props_list.pDrmFormatModifierProperties = modifier_props;
                            ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:599:53: error: request for member 'drmFormatModifierCount' in something not a structure or union
         for (uint32_t i = 0; i < modifier_props_list.drmFormatModifierCount; i++) {
                                                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:600:13: error: unknown type name 'VkPhysicalDeviceImageDrmFormatModifierInfoEXT'; did you mean 'VkPhysicalDeviceImageFormatInfo2'?
             VkPhysicalDeviceImageDrmFormatModifierInfoEXT mod_info = {};
             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
             VkPhysicalDeviceImageFormatInfo2
/<path-to-project>/OBSVkCapture/src/vklayer.c:600:70: error: empty scalar initializer
             VkPhysicalDeviceImageDrmFormatModifierInfoEXT mod_info = {};
                                                                      ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:600:70: note: (near initialization for 'mod_info')
/<path-to-project>/OBSVkCapture/src/vklayer.c:601:21: error: request for member 'sType' in something not a structure or union
             mod_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT;
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:601:30: error: 'VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT' undeclared (first use in this function); did you mean 'VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2'?
             mod_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT;
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2
/<path-to-project>/OBSVkCapture/src/vklayer.c:602:21: error: request for member 'drmFormatModifier' in something not a structure or union
             mod_info.drmFormatModifier = modifier_props[i].drmFormatModifier;
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:602:56: error: invalid use of undefined type 'struct VkDrmFormatModifierPropertiesEXT'
             mod_info.drmFormatModifier = modifier_props[i].drmFormatModifier;
                                                        ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:602:56: error: dereferencing pointer to incomplete type 'struct VkDrmFormatModifierPropertiesEXT'
/<path-to-project>/OBSVkCapture/src/vklayer.c:603:21: error: request for member 'sharingMode' in something not a structure or union
             mod_info.sharingMode = img_info.sharingMode;
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:610:34: error: 'VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT' undeclared (first use in this function); did you mean 'VK_IMAGE_TILING_MAX_ENUM'?
             format_info.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                  VK_IMAGE_TILING_MAX_ENUM
/<path-to-project>/OBSVkCapture/src/vklayer.c:621:31: error: invalid use of undefined type 'struct VkDrmFormatModifierPropertiesEXT'
                 modifier_props[modifier_prop_count++] = modifier_props[i];
                               ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:621:71: error: invalid use of undefined type 'struct VkDrmFormatModifierPropertiesEXT'
                 modifier_props[modifier_prop_count++] = modifier_props[i];
                                                                       ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:630:52: error: invalid use of undefined type 'struct VkDrmFormatModifierPropertiesEXT'
                 image_modifiers[i] = modifier_props[i].drmFormatModifier;
                                                    ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:633:32: error: request for member 'sType' in something not a structure or union
             image_modifier_list.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT;
                                ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:633:41: error: 'VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT' undeclared (first use in this function); did you mean 'VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR'?
             image_modifier_list.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_LIST_CREATE_INFO_EXT;
                                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                         VK_STRUCTURE_TYPE_IMAGE_FORMAT_LIST_CREATE_INFO_KHR
/<path-to-project>/OBSVkCapture/src/vklayer.c:634:32: error: request for member 'drmFormatModifierCount' in something not a structure or union
             image_modifier_list.drmFormatModifierCount = modifier_prop_count;
                                ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:635:32: error: request for member 'pDrmFormatModifiers' in something not a structure or union
             image_modifier_list.pDrmFormatModifiers = image_modifiers;
                                ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:740:9: error: unknown type name 'VkImageDrmFormatModifierPropertiesEXT'; did you mean 'VkImageFormatProperties2'?
         VkImageDrmFormatModifierPropertiesEXT image_mod_props = {};
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
         VkImageFormatProperties2
/<path-to-project>/OBSVkCapture/src/vklayer.c:740:65: error: empty scalar initializer
         VkImageDrmFormatModifierPropertiesEXT image_mod_props = {};
                                                                 ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:740:65: note: (near initialization for 'image_mod_props')
/<path-to-project>/OBSVkCapture/src/vklayer.c:741:24: error: request for member 'sType' in something not a structure or union
         image_mod_props.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT;
                        ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:741:33: error: 'VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT' undeclared (first use in this function); did you mean 'VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT'?
         image_mod_props.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT;
                                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                 VK_STRUCTURE_TYPE_DRM_FORMAT_MODIFIER_PROPERTIES_LIST_EXT
/<path-to-project>/OBSVkCapture/src/vklayer.c:742:15: error: called object is not a function or function pointer
         res = funcs->GetImageDrmFormatModifierPropertiesEXT(device, swap->export_image, &image_mod_props);
               ^~~~~
/<path-to-project>/OBSVkCapture/src/vklayer.c:747:52: error: request for member 'drmFormatModifier' in something not a structure or union
             swap->dmabuf_modifier = image_mod_props.drmFormatModifier;
                                                    ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:749:35: error: invalid use of undefined type 'struct VkDrmFormatModifierPropertiesEXT'
                 if (modifier_props[i].drmFormatModifier == swap->dmabuf_modifier) {
                                   ^
/<path-to-project>/OBSVkCapture/src/vklayer.c:750:48: error: invalid use of undefined type 'struct VkDrmFormatModifierPropertiesEXT'
                     num_planes = modifier_props[i].drmFormatModifierPlaneCount;
                                                ^
/<path-to-project>/OBSVkCapture/src/vklayer.c: In function 'OBS_CreateInstance':
/<path-to-project>/OBSVkCapture/src/vklayer.c:1172:29: error: 'VK_API_VERSION_1_2' undeclared (first use in this function); did you mean 'VK_API_VERSION_1_1'?
         if (ai.apiVersion < VK_API_VERSION_1_2)
                             ^~~~~~~~~~~~~~~~~~
                             VK_API_VERSION_1_1
/<path-to-project>/OBSVkCapture/src/vklayer.c: In function 'OBS_CreateDevice':
/<path-to-project>/OBSVkCapture/src/vklayer.c:1296:62: error: 'VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME' undeclared (first use in this function); did you mean 'VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME'?
         } else if (!strcmp(info->ppEnabledExtensionNames[i], VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME)) {
                                                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                              VK_KHR_IMAGE_FORMAT_LIST_EXTENSION_NAME
/<path-to-project>/OBSVkCapture/src/vklayer.c:1425:55: error: 'PFN_vkGetImageDrmFormatModifierPropertiesEXT' undeclared (first use in this function); did you mean 'PFN_vkGetMemoryHostPointerPropertiesEXT'?
     dfuncs->GetImageDrmFormatModifierPropertiesEXT = (PFN_vkGetImageDrmFormatModifierPropertiesEXT)
                                                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                                       PFN_vkGetMemoryHostPointerPropertiesEXT
/<path-to-project>/OBSVkCapture/src/vklayer.c:1426:9: error: expected ';' before 'gdpa'
         gdpa(device, "vkGetImageDrmFormatModifierPropertiesEXT");
         ^~~~
CMakeFiles/VkLayer_obs_vkcapture.dir/build.make:62: recipe for target 'CMakeFiles/VkLayer_obs_vkcapture.dir/src/vklayer.c.o' failed
make[2]: *** [CMakeFiles/VkLayer_obs_vkcapture.dir/src/vklayer.c.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/VkLayer_obs_vkcapture.dir/all' failed
make[1]: *** [CMakeFiles/VkLayer_obs_vkcapture.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

And those symbols seem to be the ones added in that extension.

So how would I go about installing that extension from 2018? The tags in The Vulkan Extension Layer repository don't seem to go back that far.

Am I looking in the right place?

from obs-vkcapture.

nowrep avatar nowrep commented on July 21, 2024

If this is all that would prevent it to work on your system, then I think it's worth it to add some #ifs (detect if Vulkan is too old and not having the extension) around this code.

from obs-vkcapture.

nowrep avatar nowrep commented on July 21, 2024
diff --git a/src/vklayer.c b/src/vklayer.c
index 73dc41c..31b3855 100644
--- a/src/vklayer.c
+++ b/src/vklayer.c
@@ -572,6 +572,8 @@ static inline bool vk_shtex_init_vulkan_tex(struct vk_data *data,
 
     int num_planes = 1; // format itself may be multi-planar?
     uint64_t *image_modifiers = NULL;
+
+#if VK_EXT_image_drm_format_modifier
     VkImageDrmFormatModifierListCreateInfoEXT image_modifier_list = {};
     struct VkDrmFormatModifierPropertiesEXT *modifier_props = NULL;
     uint32_t modifier_prop_count = 0;
@@ -650,6 +652,7 @@ static inline bool vk_shtex_init_vulkan_tex(struct vk_data *data,
             hlog("No suitable DRM modifier found!");
         }
     }
+#endif
 
     VkDevice device = data->device;
 
@@ -747,6 +750,7 @@ static inline bool vk_shtex_init_vulkan_tex(struct vk_data *data,
         return false;
     }
 
+#if VK_EXT_image_drm_format_modifier
     if (funcs->GetImageDrmFormatModifierPropertiesEXT) {
         VkImageDrmFormatModifierPropertiesEXT image_mod_props = {};
         image_mod_props.sType = VK_STRUCTURE_TYPE_IMAGE_DRM_FORMAT_MODIFIER_PROPERTIES_EXT;
@@ -764,6 +768,9 @@ static inline bool vk_shtex_init_vulkan_tex(struct vk_data *data,
             }
         }
         vk_free(data->ac, modifier_props);
+#else
+    if (false) {
+#endif
     } else {
         swap->dmabuf_modifier = DRM_FORMAT_MOD_INVALID;
     }
@@ -1305,19 +1312,24 @@ static VkResult VKAPI_CALL OBS_CreateDevice(VkPhysicalDevice phy_device,
     for (uint32_t i = 0; i < info->enabledExtensionCount; ++i) {
         if (!strcmp(info->ppEnabledExtensionNames[i], VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME)) {
             add_mem_fd_ext = false;
-        } else if (!strcmp(info->ppEnabledExtensionNames[i], VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME)) {
+        }
+#if VK_EXT_image_drm_format_modifier
+        else if (!strcmp(info->ppEnabledExtensionNames[i], VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME)) {
             add_drm_mod_ext = false;
         }
+#endif
     }
     int add_count = 0;
     if (add_mem_fd_ext) {
         add_count++;
         hlog("Injecting %s extension", VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME);
     }
+#if VK_EXT_image_drm_format_modifier
     if (add_drm_mod_ext) {
         add_count++;
         hlog("Injecting %s extension", VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME);
     }
+#endif
     if (add_count) {
         int new_count = info->enabledExtensionCount + add_count;
         const char **exts = (const char**)malloc(sizeof(char*) * new_count);
@@ -1325,9 +1337,11 @@ static VkResult VKAPI_CALL OBS_CreateDevice(VkPhysicalDevice phy_device,
         if (add_mem_fd_ext) {
             exts[new_count - add_count--] = VK_KHR_EXTERNAL_MEMORY_FD_EXTENSION_NAME;
         }
+#if VK_EXT_image_drm_format_modifier
         if (add_drm_mod_ext) {
             exts[new_count - add_count--] = VK_EXT_IMAGE_DRM_FORMAT_MODIFIER_EXTENSION_NAME;
         }
+#endif
         VkDeviceCreateInfo *i = (VkDeviceCreateInfo*)info;
         i->enabledExtensionCount = new_count;
         i->ppEnabledExtensionNames = exts;
@@ -1434,11 +1448,13 @@ static VkResult VKAPI_CALL OBS_CreateDevice(VkPhysicalDevice phy_device,
     GETADDR(GetImageSubresourceLayout);
     GETADDR(GetMemoryFdKHR);
 
+#if VK_EXT_image_drm_format_modifier
     dfuncs->GetImageDrmFormatModifierPropertiesEXT = (PFN_vkGetImageDrmFormatModifierPropertiesEXT)
         gdpa(device, "vkGetImageDrmFormatModifierPropertiesEXT");
     if (!dfuncs->GetImageDrmFormatModifierPropertiesEXT) {
         hlog("DRM format modifier support not available");
     }
+#endif
 
 #undef GETADDR
 
diff --git a/src/vklayer.h b/src/vklayer.h
index 8b78573..89d6d28 100644
--- a/src/vklayer.h
+++ b/src/vklayer.h
@@ -79,7 +79,9 @@ struct vk_device_funcs {
     DEF_FUNC(ResetFences);
     DEF_FUNC(GetImageSubresourceLayout);
     DEF_FUNC(GetMemoryFdKHR);
+#if VK_EXT_image_drm_format_modifier
     DEF_FUNC(GetImageDrmFormatModifierPropertiesEXT);
+#endif
 };
 
 #undef DEF_FUNC
@@ -349,7 +351,9 @@ static const char *result_to_str(VkResult result)
     VAL(VK_ERROR_INCOMPATIBLE_DISPLAY_KHR);
     VAL(VK_ERROR_VALIDATION_FAILED_EXT);
     VAL(VK_ERROR_INVALID_SHADER_NV);
+#if VK_EXT_image_drm_format_modifier
     VAL(VK_ERROR_INVALID_DRM_FORMAT_MODIFIER_PLANE_LAYOUT_EXT);
+#endif
     VAL(VK_ERROR_FRAGMENTATION_EXT);
     VAL(VK_ERROR_NOT_PERMITTED_EXT);
     VAL(VK_ERROR_INVALID_DEVICE_ADDRESS_EXT);

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

That's a bit better, but these errors are still cropping up:

In file included from /<path-to-project>/OBSVkCapture/src/vklayer.c:19:0:
/<path-to-project>/OBSVkCapture/src/vklayer.h: In function 'result_to_str':
/<path-to-project>/OBSVkCapture/src/vklayer.h:357:9: error: 'VK_ERROR_FRAGMENTATION_EXT' undeclared (first use in this function); did you mean 'VK_ERROR_FRAGMENTED_POOL'?
     VAL(VK_ERROR_FRAGMENTATION_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:93:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:357:9: note: each undeclared identifier is reported only once for each function it appears in
     VAL(VK_ERROR_FRAGMENTATION_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:93:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:359:9: error: 'VK_ERROR_INVALID_DEVICE_ADDRESS_EXT' undeclared (first use in this function); did you mean 'VK_ERROR_INVALID_SHADER_NV'?
     VAL(VK_ERROR_INVALID_DEVICE_ADDRESS_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:93:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:360:9: error: 'VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT' undeclared (first use in this function)
     VAL(VK_ERROR_FULL_SCREEN_EXCLUSIVE_MODE_LOST_EXT);
         ^
/<path-to-project>/OBSVkCapture/src/vklayer.h:93:21: note: in definition of macro 'VAL'
 #define VAL(x) case x: return #x
                     ^
/<path-to-project>/OBSVkCapture/src/vklayer.c: In function 'OBS_CreateInstance':
/<path-to-project>/OBSVkCapture/src/vklayer.c:1191:29: error: 'VK_API_VERSION_1_2' undeclared (first use in this function); did you mean 'VK_API_VERSION_1_1'?
         if (ai.apiVersion < VK_API_VERSION_1_2)
                             ^~~~~~~~~~~~~~~~~~
                             VK_API_VERSION_1_1
CMakeFiles/VkLayer_obs_vkcapture.dir/build.make:62: recipe for target 'CMakeFiles/VkLayer_obs_vkcapture.dir/src/vklayer.c.o' failed
make[2]: *** [CMakeFiles/VkLayer_obs_vkcapture.dir/src/vklayer.c.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/VkLayer_obs_vkcapture.dir/all' failed
make[1]: *** [CMakeFiles/VkLayer_obs_vkcapture.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

That last error is from the version number macro being used. It's essentially a hard coded value. I search for the macro and found that vulkan_core.h says to use the VK_MAKE_VERSION() macro instead.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

Could the lines with those undefined macro values be safely moved up into that #if block you just added? They're all right beneath it in the same switch statement.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

I moved those lines and replaced that macro with the VK_MAKE_VERSION() macro to see if it would build (I don't know whether it would break any functionality or not).

It compiles, but it won't link because the build scipt doesn't gracefully handle file paths with spaces in them.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

The problem is in the link.txt files. The path isn't enclosed in quotes like it is everywhere else. I manually went in and added the enclosing quotes for the vk and gl targets, and it finally linked fine.

However, I don't know this project's code base anywhere near well enough to know whether moving those additional lines in the switch statement in vklayer.h -> result_to_str() was a safe thing to do, or whether it broke some functionality.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

It seems to be working ok with your changes & the additional ones I made, and the manual editing of the link.txt files to wrap the path in quotes. Is there any way to have those files created with the paths properly quoted? I looked around but I couldn't figure out where they get created.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

Looks like a couple got missed, and the version macro is spelled wrong:

/<path-to-project>/OBSVkCapture/src/vklayer.c: In function 'vk_shtex_init_vulkan_tex':
/<path-to-project>/OBSVkCapture/src/vklayer.c:612:30: error: 'VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT' undeclared (first use in this function); did you mean 'VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2'?
             mod_info.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_DRM_FORMAT_MODIFIER_INFO_EXT;
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                              VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGE_FORMAT_INFO_2
/<path-to-project>/OBSVkCapture/src/vklayer.c:612:30: note: each undeclared identifier is reported only once for each function it appears in
/<path-to-project>/OBSVkCapture/src/vklayer.c:621:34: error: 'VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT' undeclared (first use in this function); did you mean 'VK_IMAGE_TILING_MAX_ENUM'?
             format_info.tiling = VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT;
                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
                                  VK_IMAGE_TILING_MAX_ENUM
/<path-to-project>/OBSVkCapture/src/vklayer.c: In function 'OBS_CreateInstance':
/<path-to-project>/OBSVkCapture/src/vklayer.c:1185:29: warning: implicit declaration of function 'VK_MAKE_API_VERSION'; did you mean 'VK_MAKE_VERSION'? [-Wimplicit-function-declaration]
         if (ai.apiVersion < VK_MAKE_API_VERSION(0, 1, 2, 0))
                             ^~~~~~~~~~~~~~~~~~~
                             VK_MAKE_VERSION
CMakeFiles/VkLayer_obs_vkcapture.dir/build.make:62: recipe for target 'CMakeFiles/VkLayer_obs_vkcapture.dir/src/vklayer.c.o' failed
make[2]: *** [CMakeFiles/VkLayer_obs_vkcapture.dir/src/vklayer.c.o] Error 1
CMakeFiles/Makefile2:72: recipe for target 'CMakeFiles/VkLayer_obs_vkcapture.dir/all' failed
make[1]: *** [CMakeFiles/VkLayer_obs_vkcapture.dir/all] Error 2
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2

from obs-vkcapture.

nowrep avatar nowrep commented on July 21, 2024

VK_MAKE_API_VERSION is a newer addition then.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

Yeah, I was looking it up just now.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

It builds. I'll test it shortly and let you know how it goes.

from obs-vkcapture.

BloodyMess avatar BloodyMess commented on July 21, 2024

It seems to be working fine now. Half an hour of 1080p at 60fps. No noticeable lag while recording, and the resulting video looks fine.

Thanks for the fixes!

from obs-vkcapture.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.