|
|
@ -2,6 +2,7 @@
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#include <vulkan/vulkan.h>
|
|
|
|
#include <wlr/util/log.h>
|
|
|
|
#include <wlr/util/log.h>
|
|
|
|
|
|
|
|
#include <xf86drm.h>
|
|
|
|
#include "render/vulkan.h"
|
|
|
|
#include "render/vulkan.h"
|
|
|
|
|
|
|
|
|
|
|
|
// Reversed endianess of shm and vulkan format names
|
|
|
|
// Reversed endianess of shm and vulkan format names
|
|
|
@ -134,9 +135,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|
|
|
for (unsigned i = 0u; i < modp.drmFormatModifierCount; ++i) {
|
|
|
|
for (unsigned i = 0u; i < modp.drmFormatModifierCount; ++i) {
|
|
|
|
VkDrmFormatModifierPropertiesEXT m =
|
|
|
|
VkDrmFormatModifierPropertiesEXT m =
|
|
|
|
modp.pDrmFormatModifierProperties[i];
|
|
|
|
modp.pDrmFormatModifierProperties[i];
|
|
|
|
wlr_log(WLR_DEBUG, " modifier: 0x%"PRIx64 ": features 0x%"PRIx32", %d planes",
|
|
|
|
const char *render_status, *texture_status;
|
|
|
|
m.drmFormatModifier, m.drmFormatModifierTilingFeatures,
|
|
|
|
|
|
|
|
m.drmFormatModifierPlaneCount);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// check that specific modifier for render usage
|
|
|
|
// check that specific modifier for render usage
|
|
|
|
if ((m.drmFormatModifierTilingFeatures & render_features) == render_features) {
|
|
|
|
if ((m.drmFormatModifierTilingFeatures & render_features) == render_features) {
|
|
|
@ -151,7 +150,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|
|
|
res);
|
|
|
|
res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " >> rendering: format not supported");
|
|
|
|
render_status = "✗ render (unsupported format)";
|
|
|
|
} else if (emp->externalMemoryFeatures &
|
|
|
|
} else if (emp->externalMemoryFeatures &
|
|
|
|
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) {
|
|
|
|
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) {
|
|
|
|
unsigned c = props->render_mod_count;
|
|
|
|
unsigned c = props->render_mod_count;
|
|
|
@ -170,12 +169,12 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|
|
|
wlr_drm_format_set_add(&dev->dmabuf_render_formats,
|
|
|
|
wlr_drm_format_set_add(&dev->dmabuf_render_formats,
|
|
|
|
props->format.drm_format, m.drmFormatModifier);
|
|
|
|
props->format.drm_format, m.drmFormatModifier);
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " >> rendering: supported");
|
|
|
|
render_status = "✓ render";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wlr_log(WLR_DEBUG, " >> rendering: importing not supported");
|
|
|
|
render_status = "✗ render (import not supported)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wlr_log(WLR_DEBUG, " >> rendering: format features not supported");
|
|
|
|
render_status = "✗ render (missing required features)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// check that specific modifier for texture usage
|
|
|
|
// check that specific modifier for texture usage
|
|
|
@ -191,7 +190,7 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|
|
|
res);
|
|
|
|
res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " >> dmatex: format not supported");
|
|
|
|
texture_status = "✗ texture (unsupported format)";
|
|
|
|
} else if (emp->externalMemoryFeatures &
|
|
|
|
} else if (emp->externalMemoryFeatures &
|
|
|
|
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) {
|
|
|
|
VK_EXTERNAL_MEMORY_FEATURE_IMPORTABLE_BIT) {
|
|
|
|
unsigned c = props->texture_mod_count;
|
|
|
|
unsigned c = props->texture_mod_count;
|
|
|
@ -210,13 +209,20 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|
|
|
wlr_drm_format_set_add(&dev->dmabuf_texture_formats,
|
|
|
|
wlr_drm_format_set_add(&dev->dmabuf_texture_formats,
|
|
|
|
props->format.drm_format, m.drmFormatModifier);
|
|
|
|
props->format.drm_format, m.drmFormatModifier);
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " >> dmatex: supported");
|
|
|
|
texture_status = "✓ texture";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wlr_log(WLR_DEBUG, " >> dmatex: importing not supported");
|
|
|
|
texture_status = "✗ texture (import not supported)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wlr_log(WLR_DEBUG, " >> dmatex: format features not supported");
|
|
|
|
texture_status = "✗ texture (missing required features)";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *modifier_name = drmGetFormatModifierName(m.drmFormatModifier);
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " DMA-BUF modifier %s "
|
|
|
|
|
|
|
|
"(0x%016"PRIX64", %"PRIu32" planes): %s %s",
|
|
|
|
|
|
|
|
modifier_name ? modifier_name : "<unknown>", m.drmFormatModifier,
|
|
|
|
|
|
|
|
m.drmFormatModifierPlaneCount, texture_status, render_status);
|
|
|
|
|
|
|
|
free(modifier_name);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
free(modp.pDrmFormatModifierProperties);
|
|
|
|
free(modp.pDrmFormatModifierProperties);
|
|
|
@ -225,11 +231,13 @@ static bool query_modifier_support(struct wlr_vk_device *dev,
|
|
|
|
|
|
|
|
|
|
|
|
void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|
|
|
void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|
|
|
const struct wlr_vk_format *format) {
|
|
|
|
const struct wlr_vk_format *format) {
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, "vulkan: Checking support for format %.4s (0x%" PRIx32 ")",
|
|
|
|
|
|
|
|
(const char *)&format->drm_format, format->drm_format);
|
|
|
|
|
|
|
|
VkResult res;
|
|
|
|
VkResult res;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
char *format_name = drmGetFormatName(format->drm_format);
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " %s (0x%08"PRIX32")",
|
|
|
|
|
|
|
|
format_name ? format_name : "<unknown>", format->drm_format);
|
|
|
|
|
|
|
|
free(format_name);
|
|
|
|
|
|
|
|
|
|
|
|
// get general features and modifiers
|
|
|
|
// get general features and modifiers
|
|
|
|
VkFormatProperties2 fmtp = {0};
|
|
|
|
VkFormatProperties2 fmtp = {0};
|
|
|
|
fmtp.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
|
|
|
|
fmtp.sType = VK_STRUCTURE_TYPE_FORMAT_PROPERTIES_2;
|
|
|
@ -254,13 +262,8 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|
|
|
struct wlr_vk_format_props props = {0};
|
|
|
|
struct wlr_vk_format_props props = {0};
|
|
|
|
props.format = *format;
|
|
|
|
props.format = *format;
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " drmFormatModifierCount: %d", modp.drmFormatModifierCount);
|
|
|
|
|
|
|
|
if (modp.drmFormatModifierCount > 0) {
|
|
|
|
|
|
|
|
add_fmt_props |= query_modifier_support(dev, &props,
|
|
|
|
|
|
|
|
modp.drmFormatModifierCount, fmti);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// non-dmabuf texture properties
|
|
|
|
// non-dmabuf texture properties
|
|
|
|
|
|
|
|
const char *shm_texture_status;
|
|
|
|
if ((fmtp.formatProperties.optimalTilingFeatures & tex_features) == tex_features) {
|
|
|
|
if ((fmtp.formatProperties.optimalTilingFeatures & tex_features) == tex_features) {
|
|
|
|
fmti.pNext = NULL;
|
|
|
|
fmti.pNext = NULL;
|
|
|
|
ifmtp.pNext = NULL;
|
|
|
|
ifmtp.pNext = NULL;
|
|
|
@ -275,14 +278,14 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|
|
|
res);
|
|
|
|
res);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " >> shmtex: format not supported");
|
|
|
|
shm_texture_status = "✗ texture (unsupported format)";
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
VkExtent3D me = ifmtp.imageFormatProperties.maxExtent;
|
|
|
|
VkExtent3D me = ifmtp.imageFormatProperties.maxExtent;
|
|
|
|
props.max_extent.width = me.width;
|
|
|
|
props.max_extent.width = me.width;
|
|
|
|
props.max_extent.height = me.height;
|
|
|
|
props.max_extent.height = me.height;
|
|
|
|
props.features = fmtp.formatProperties.optimalTilingFeatures;
|
|
|
|
props.features = fmtp.formatProperties.optimalTilingFeatures;
|
|
|
|
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " >> shmtex: supported");
|
|
|
|
shm_texture_status = "✓ texture";
|
|
|
|
|
|
|
|
|
|
|
|
dev->shm_formats[dev->shm_format_count] = format->drm_format;
|
|
|
|
dev->shm_formats[dev->shm_format_count] = format->drm_format;
|
|
|
|
++dev->shm_format_count;
|
|
|
|
++dev->shm_format_count;
|
|
|
@ -290,7 +293,13 @@ void vulkan_format_props_query(struct wlr_vk_device *dev,
|
|
|
|
add_fmt_props = true;
|
|
|
|
add_fmt_props = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
wlr_log(WLR_DEBUG, " >> shmtex: format features not supported");
|
|
|
|
shm_texture_status = "✗ texture (missing required features)";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
wlr_log(WLR_DEBUG, " Shared memory: %s", shm_texture_status);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (modp.drmFormatModifierCount > 0) {
|
|
|
|
|
|
|
|
add_fmt_props |= query_modifier_support(dev, &props,
|
|
|
|
|
|
|
|
modp.drmFormatModifierCount, fmti);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (add_fmt_props) {
|
|
|
|
if (add_fmt_props) {
|
|
|
|