DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(0)
DRI_CONF_VK_X11_STRICT_IMAGE_COUNT("false")
DRI_CONF_SECTION_END
+
+ DRI_CONF_SECTION_DEBUG
+ DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST("false")
+ DRI_CONF_SECTION_END
DRI_CONF_END;
static void radv_init_dri_options(struct radv_instance *instance)
DRI_CONF_SECTION_DEBUG
DRI_CONF_ALWAYS_FLUSH_CACHE("false")
+ DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST("false")
DRI_CONF_SECTION_END
DRI_CONF_END;
<application name="gfxbench" executable="testfw_app">
<option name="vk_x11_override_min_image_count" value="2" />
+ <option name="vk_wsi_force_bgra8_unorm_first" value="true" />
</application>
<!-- Gallium Nine workarounds: -->
DRI_CONF_DESC(en,gettext("Adapt the monitor sync to the application performance (when possible)")) \
DRI_CONF_OPT_END
+#define DRI_CONF_VK_WSI_FORCE_BGRA8_UNORM_FIRST(def) \
+DRI_CONF_OPT_BEGIN_B(vk_wsi_force_bgra8_unorm_first, def) \
+ DRI_CONF_DESC(en,gettext("Force vkGetPhysicalDeviceSurfaceFormatsKHR to return VK_FORMAT_B8G8R8A8_UNORM as the first format")) \
+DRI_CONF_OPT_END
+
#define DRI_CONF_VK_X11_OVERRIDE_MIN_IMAGE_COUNT(def) \
DRI_CONF_OPT_BEGIN_V(vk_x11_override_min_image_count, int, def, "0:999") \
DRI_CONF_DESC(en,gettext("Override the VkSurfaceCapabilitiesKHR::minImageCount (0 = no override)")) \
if (driCheckOption(dri_options, "adaptive_sync", DRI_BOOL))
wsi->enable_adaptive_sync = driQueryOptionb(dri_options,
"adaptive_sync");
+
+ if (driCheckOption(dri_options, "vk_wsi_force_bgra8_unorm_first", DRI_BOOL)) {
+ wsi->force_bgra8_unorm_first =
+ driQueryOptionb(dri_options, "vk_wsi_force_bgra8_unorm_first");
+ }
}
return VK_SUCCESS;
bool supports_modifiers;
uint32_t maxImageDimension2D;
VkPresentModeKHR override_present_mode;
+ bool force_bgra8_unorm_first;
/* Whether to enable adaptive sync for a swapchain if implemented and
* available. Not all window systems might support this. */
{ .format = VK_FORMAT_B8G8R8A8_UNORM, .drm_format = DRM_FORMAT_XRGB8888 },
};
+static void
+get_sorted_vk_formats(struct wsi_device *wsi_device, VkFormat *sorted_formats)
+{
+ for (unsigned i = 0; i < ARRAY_SIZE(available_surface_formats); i++)
+ sorted_formats[i] = available_surface_formats[i].format;
+
+ if (wsi_device->force_bgra8_unorm_first) {
+ for (unsigned i = 0; i < ARRAY_SIZE(available_surface_formats); i++) {
+ if (sorted_formats[i] == VK_FORMAT_B8G8R8A8_UNORM) {
+ sorted_formats[i] = sorted_formats[0];
+ sorted_formats[0] = VK_FORMAT_B8G8R8A8_UNORM;
+ break;
+ }
+ }
+ }
+}
+
static VkResult
wsi_display_surface_get_formats(VkIcdSurfaceBase *icd_surface,
struct wsi_device *wsi_device,
{
VK_OUTARRAY_MAKE(out, surface_formats, surface_format_count);
- for (unsigned i = 0; i < ARRAY_SIZE(available_surface_formats); i++) {
+ VkFormat sorted_formats[ARRAY_SIZE(available_surface_formats)];
+ get_sorted_vk_formats(wsi_device, sorted_formats);
+
+ for (unsigned i = 0; i < ARRAY_SIZE(sorted_formats); i++) {
vk_outarray_append(&out, f) {
- f->format = available_surface_formats[i].format;
+ f->format = sorted_formats[i];
f->colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
}
}
{
VK_OUTARRAY_MAKE(out, surface_formats, surface_format_count);
- for (unsigned i = 0; i < ARRAY_SIZE(available_surface_formats); i++) {
+ VkFormat sorted_formats[ARRAY_SIZE(available_surface_formats)];
+ get_sorted_vk_formats(wsi_device, sorted_formats);
+
+ for (unsigned i = 0; i < ARRAY_SIZE(sorted_formats); i++) {
vk_outarray_append(&out, f) {
assert(f->sType == VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR);
- f->surfaceFormat.format = available_surface_formats[i].format;
+ f->surfaceFormat.format = sorted_formats[i];
f->surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
}
}
if (display->drm.wl_drm || display->dmabuf.wl_dmabuf)
wl_display_roundtrip_queue(display->wl_display, display->queue);
+ if (wsi_wl->wsi->force_bgra8_unorm_first) {
+ /* Find BGRA8_UNORM in the list and swap it to the first position if we
+ * can find it. Some apps get confused if SRGB is first in the list.
+ */
+ VkFormat *first_fmt = u_vector_head(display->formats);
+ VkFormat *iter_fmt;
+ u_vector_foreach(iter_fmt, display->formats) {
+ if (*iter_fmt == VK_FORMAT_B8G8R8A8_UNORM) {
+ *iter_fmt = *first_fmt;
+ *first_fmt = VK_FORMAT_B8G8R8A8_UNORM;
+ break;
+ }
+ }
+ }
+
/* We need prime support for wl_drm */
if (display->drm.wl_drm &&
(display->drm.capabilities & WL_DRM_CAPABILITY_PRIME)) {
return result;
}
+static void
+get_sorted_vk_formats(struct wsi_device *wsi_device, VkFormat *sorted_formats)
+{
+ memcpy(sorted_formats, formats, sizeof(formats));
+
+ if (wsi_device->force_bgra8_unorm_first) {
+ for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
+ if (sorted_formats[i] == VK_FORMAT_B8G8R8A8_UNORM) {
+ sorted_formats[i] = sorted_formats[0];
+ sorted_formats[0] = VK_FORMAT_B8G8R8A8_UNORM;
+ break;
+ }
+ }
+ }
+}
+
static VkResult
x11_surface_get_formats(VkIcdSurfaceBase *surface,
struct wsi_device *wsi_device,
{
VK_OUTARRAY_MAKE(out, pSurfaceFormats, pSurfaceFormatCount);
- for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
+ VkFormat sorted_formats[ARRAY_SIZE(formats)];
+ get_sorted_vk_formats(wsi_device, sorted_formats);
+
+ for (unsigned i = 0; i < ARRAY_SIZE(sorted_formats); i++) {
vk_outarray_append(&out, f) {
- f->format = formats[i];
+ f->format = sorted_formats[i];
f->colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
}
}
{
VK_OUTARRAY_MAKE(out, pSurfaceFormats, pSurfaceFormatCount);
- for (unsigned i = 0; i < ARRAY_SIZE(formats); i++) {
+ VkFormat sorted_formats[ARRAY_SIZE(formats)];
+ get_sorted_vk_formats(wsi_device, sorted_formats);
+
+ for (unsigned i = 0; i < ARRAY_SIZE(sorted_formats); i++) {
vk_outarray_append(&out, f) {
assert(f->sType == VK_STRUCTURE_TYPE_SURFACE_FORMAT_2_KHR);
- f->surfaceFormat.format = formats[i];
+ f->surfaceFormat.format = sorted_formats[i];
f->surfaceFormat.colorSpace = VK_COLORSPACE_SRGB_NONLINEAR_KHR;
}
}