Skip to content

Commit

Permalink
Merge remote-tracking branch 'RetroArch_Official/master' into MesaTes…
Browse files Browse the repository at this point in the history
…ting
  • Loading branch information
Misunderstood-Wookiee committed May 19, 2024
2 parents d091b3e + 741e7f8 commit 1ad8d14
Show file tree
Hide file tree
Showing 20 changed files with 1,658 additions and 785 deletions.
7 changes: 7 additions & 0 deletions config.def.h
Original file line number Diff line number Diff line change
Expand Up @@ -1413,7 +1413,14 @@
#define DEFAULT_FASTFORWARD_FRAMESKIP true

/* Enable runloop for variable refresh rate screens. Force x1 speed while handling fast forward too. */
#ifdef IOS
/* FIXME: coreaudio will cause the main thread to hang on backgrounding, causing
* a crash. the fix is to turn off audio synchronization. with that off, we need
* this on */
#define DEFAULT_VRR_RUNLOOP_ENABLE true
#else
#define DEFAULT_VRR_RUNLOOP_ENABLE false
#endif

/* Run core logic one or more frames ahead then load the state back to reduce perceived input lag. */
#define DEFAULT_RUN_AHEAD_FRAMES 1
Expand Down
2 changes: 1 addition & 1 deletion configuration.c
Original file line number Diff line number Diff line change
Expand Up @@ -1471,7 +1471,7 @@ bool config_overlay_enable_default(void)
{
if (g_defaults.overlay_set)
return g_defaults.overlay_enable;
#if defined(RARCH_MOBILE)
#if defined(RARCH_MOBILE) && !TARGET_OS_TV
return true;
#else
return false;
Expand Down
6 changes: 6 additions & 0 deletions frontend/drivers/platform_darwin.m
Original file line number Diff line number Diff line change
Expand Up @@ -721,7 +721,11 @@ static int frontend_darwin_parse_drive_list(void *data, bool load_content)

if (list->size == 0)
menu_entries_append(list,
#if TARGET_OS_TV
"~/Library/Caches/RetroArch",
#else
"~/Documents/RetroArch",
#endif
msg_hash_to_str(MENU_ENUM_LABEL_FILE_DETECT_CORE_LIST_PUSH_DIR),
enum_idx,
FILE_TYPE_DIRECTORY, 0, 0, NULL);
Expand Down Expand Up @@ -811,6 +815,8 @@ static enum retro_language frontend_darwin_get_user_language(void)
CFArrayRef langs = CFLocaleCopyPreferredLanguages();
CFStringRef langCode = CFArrayGetValueAtIndex(langs, 0);
CFStringGetCString(langCode, s, sizeof(s), kCFStringEncodingUTF8);
/* iOS and OS X only support the language ID syntax consisting of a language designator and optional region or script designator. */
string_replace_all_chars(s, '-', '_');
return retroarch_get_language_from_iso(s);
}

Expand Down
121 changes: 84 additions & 37 deletions gfx/common/vulkan_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,9 +356,14 @@ static bool vulkan_find_extensions(const char * const *exts, unsigned num_exts,
return true;
}

static bool vulkan_find_instance_extensions(const char * const *exts, unsigned num_exts)
static bool vulkan_find_instance_extensions(
const char **enabled, unsigned *inout_enabled_count,
const char **exts, unsigned num_exts,
const char **optional_exts, unsigned num_optional_exts)
{
uint32_t property_count;
unsigned i;
unsigned count = *inout_enabled_count;
bool ret = true;
VkExtensionProperties *properties = NULL;

Expand All @@ -380,13 +385,21 @@ static bool vulkan_find_instance_extensions(const char * const *exts, unsigned n

if (!vulkan_find_extensions(exts, num_exts, properties, property_count))
{
RARCH_ERR("[Vulkan]: Could not find instance extensions. Will attempt without them.\n");
RARCH_ERR("[Vulkan]: Could not find required instance extensions. Will attempt without them.\n");
ret = false;
goto end;
}

memcpy((void*)(enabled + count), exts, num_exts * sizeof(*exts));
count += num_exts;

for (i = 0; i < num_optional_exts; i++)
if (vulkan_find_extensions(&optional_exts[i], 1, properties, property_count))
enabled[count++] = optional_exts[i];

end:
free(properties);
*inout_enabled_count = count;
return ret;
}

Expand Down Expand Up @@ -828,6 +841,16 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk)
return true;
}

#ifdef VULKAN_HDR_SWAPCHAIN
#define VULKAN_COLORSPACE_EXTENSION_NAME "VK_EXT_swapchain_colorspace"
#endif

static const char *vulkan_optional_instance_extensions[] = {
#ifdef VULKAN_HDR_SWAPCHAIN
VULKAN_COLORSPACE_EXTENSION_NAME
#endif
};

static VkInstance vulkan_context_create_instance_wrapper(void *opaque, const VkInstanceCreateInfo *create_info)
{
VkResult res;
Expand All @@ -836,44 +859,48 @@ static VkInstance vulkan_context_create_instance_wrapper(void *opaque, const VkI
gfx_ctx_vulkan_data_t *vk = (gfx_ctx_vulkan_data_t *)opaque;
VkInstanceCreateInfo info = *create_info;
VkInstance instance = VK_NULL_HANDLE;
const char **instance_extensions = (const char**)malloc((info.enabledExtensionCount + 3) * sizeof(const char *));
const char **instance_layers = (const char**)malloc((info.enabledLayerCount + 1) * sizeof(const char *));
const char **instance_extensions = (const char**)malloc((info.enabledExtensionCount + 3
+ ARRAY_SIZE(vulkan_optional_device_extensions)) * sizeof(const char *));
const char **instance_layers = (const char**)malloc((info.enabledLayerCount + 1) * sizeof(const char *));

const char *required_extensions[3];
uint32_t required_extension_count = 0;

memcpy((void*)instance_extensions, info.ppEnabledExtensionNames, info.enabledExtensionCount * sizeof(const char *));
memcpy((void*)instance_layers, info.ppEnabledLayerNames, info.enabledLayerCount * sizeof(const char *));
info.ppEnabledExtensionNames = instance_extensions;
info.ppEnabledLayerNames = instance_layers;

instance_extensions[info.enabledExtensionCount++] = "VK_KHR_surface";
required_extensions[required_extension_count++] = "VK_KHR_surface";

switch (vk->wsi_type)
{
case VULKAN_WSI_WAYLAND:
instance_extensions[info.enabledExtensionCount++] = "VK_KHR_wayland_surface";
required_extensions[required_extension_count++] = "VK_KHR_wayland_surface";
break;
case VULKAN_WSI_ANDROID:
instance_extensions[info.enabledExtensionCount++] = "VK_KHR_android_surface";
required_extensions[required_extension_count++] = "VK_KHR_android_surface";
break;
case VULKAN_WSI_WIN32:
instance_extensions[info.enabledExtensionCount++] = "VK_KHR_win32_surface";
required_extensions[required_extension_count++] = "VK_KHR_win32_surface";
break;
case VULKAN_WSI_XLIB:
instance_extensions[info.enabledExtensionCount++] = "VK_KHR_xlib_surface";
required_extensions[required_extension_count++] = "VK_KHR_xlib_surface";
break;
case VULKAN_WSI_XCB:
instance_extensions[info.enabledExtensionCount++] = "VK_KHR_xcb_surface";
required_extensions[required_extension_count++] = "VK_KHR_xcb_surface";
break;
case VULKAN_WSI_MIR:
instance_extensions[info.enabledExtensionCount++] = "VK_KHR_mir_surface";
required_extensions[required_extension_count++] = "VK_KHR_mir_surface";
break;
case VULKAN_WSI_DISPLAY:
instance_extensions[info.enabledExtensionCount++] = "VK_KHR_display";
required_extensions[required_extension_count++] = "VK_KHR_display";
break;
case VULKAN_WSI_MVK_MACOS:
instance_extensions[info.enabledExtensionCount++] = "VK_MVK_macos_surface";
required_extensions[required_extension_count++] = "VK_MVK_macos_surface";
break;
case VULKAN_WSI_MVK_IOS:
instance_extensions[info.enabledExtensionCount++] = "VK_MVK_ios_surface";
required_extensions[required_extension_count++] = "VK_MVK_ios_surface";
break;
case VULKAN_WSI_NONE:
default:
Expand All @@ -882,22 +909,35 @@ static VkInstance vulkan_context_create_instance_wrapper(void *opaque, const VkI

#ifdef VULKAN_DEBUG
instance_layers[info.enabledLayerCount++] = "VK_LAYER_KHRONOS_validation";
instance_extensions[info.enabledExtensionCount++] = "VK_EXT_debug_utils";
required_extensions[required_extension_count++] = "VK_EXT_debug_utils";
#endif

layer_count = ARRAY_SIZE(properties);
vkEnumerateInstanceLayerProperties(&layer_count, properties);

/* Be careful about validating supported instance extensions when using explicit layers.
* If core wants to enable debug layers, we'll have to do deeper validation and query
* supported extensions per-layer which is annoying. vkCreateInstance will validate this on its own anyways. */
if ( (info.enabledLayerCount == 0)
&& !vulkan_find_instance_extensions(info.ppEnabledExtensionNames, info.enabledExtensionCount))
if (!(vulkan_find_instance_extensions(
instance_extensions, &info.enabledExtensionCount,
required_extensions, required_extension_count,
vulkan_optional_instance_extensions,
ARRAY_SIZE(vulkan_optional_instance_extensions))))
{
RARCH_ERR("[Vulkan]: Instance does not support required extensions.\n");
goto end;
}

#ifdef VULKAN_HDR_SWAPCHAIN
/* Check if HDR colorspace extension was enabled */
vk->context.flags &= ~VK_CTX_FLAG_HDR_SUPPORT;
for (i = 0; i < info.enabledExtensionCount; i++)
{
if (string_is_equal(instance_extensions[i], VULKAN_COLORSPACE_EXTENSION_NAME))
{
vk->context.flags |= VK_CTX_FLAG_HDR_SUPPORT;
break;
}
}
#endif

if (info.pApplicationInfo)
{
uint32_t supported_instance_version = VK_API_VERSION_1_0;
Expand Down Expand Up @@ -2069,27 +2109,33 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
}

#ifdef VULKAN_HDR_SWAPCHAIN
if (settings->bools.video_hdr_enable)
vk->context.flags |= VK_CTX_FLAG_HDR_ENABLE;
else
vk->context.flags &= ~VK_CTX_FLAG_HDR_ENABLE;
if (vk->context.flags & VK_CTX_FLAG_HDR_SUPPORT)
{
if (settings->bools.video_hdr_enable)
vk->context.flags |= VK_CTX_FLAG_HDR_ENABLE;
else
vk->context.flags &= ~VK_CTX_FLAG_HDR_ENABLE;

video_driver_unset_hdr_support();
video_driver_unset_hdr_support();

for (i = 0; i < format_count; i++)
{
if ( (vulkan_is_hdr10_format(formats[i].format))
&& (formats[i].colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT))
for (i = 0; i < format_count; i++)
{
format = formats[i];
video_driver_set_hdr_support();
break;
if ( (vulkan_is_hdr10_format(formats[i].format))
&& (formats[i].colorSpace == VK_COLOR_SPACE_HDR10_ST2084_EXT))
{
format = formats[i];
video_driver_set_hdr_support();
break;
}
}
}

if ( (!(vk->context.flags & VK_CTX_FLAG_HDR_ENABLE))
|| (format.format == VK_FORMAT_UNDEFINED))
if (!vulkan_is_hdr10_format(format.format))
vk->context.flags &= ~VK_CTX_FLAG_HDR_ENABLE;
}
else
{
vk->context.flags &= ~VK_CTX_FLAG_HDR_ENABLE;
}

if (!(vk->context.flags & VK_CTX_FLAG_HDR_ENABLE))
#endif /* VULKAN_HDR_SWAPCHAIN */
Expand Down Expand Up @@ -2203,8 +2249,9 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk,
info.imageExtent.height = swapchain_size.height;
info.imageArrayLayers = 1;
info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT
| VK_IMAGE_USAGE_TRANSFER_DST_BIT;
| VK_IMAGE_USAGE_TRANSFER_SRC_BIT
| VK_IMAGE_USAGE_TRANSFER_DST_BIT
| VK_IMAGE_USAGE_SAMPLED_BIT;
info.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
info.queueFamilyIndexCount = 0;
info.pQueueFamilyIndices = NULL;
Expand Down
5 changes: 5 additions & 0 deletions gfx/common/vulkan_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ enum vulkan_context_flags
VK_CTX_FLAG_SWAPCHAIN_IS_SRGB = (1 << 2),
VK_CTX_FLAG_SWAP_INTERVAL_EMULATION_LOCK = (1 << 3),
VK_CTX_FLAG_HAS_ACQUIRED_SWAPCHAIN = (1 << 4),
/* Whether HDR colorspaces are supported by the instance */
VK_CTX_FLAG_HDR_SUPPORT = (1 << 5),
};

enum vulkan_emulated_mailbox_flags
Expand Down Expand Up @@ -554,7 +556,9 @@ typedef struct vk
struct vk_per_frame *chain;
struct vk_image *backbuffer;
#ifdef VULKAN_HDR_SWAPCHAIN
VkRenderPass readback_render_pass;
struct vk_image main_buffer;
struct vk_image readback_image;
#endif /* VULKAN_HDR_SWAPCHAIN */

unsigned video_width;
Expand Down Expand Up @@ -603,6 +607,7 @@ typedef struct vk
VkPipeline rgb565_to_rgba8888;
#ifdef VULKAN_HDR_SWAPCHAIN
VkPipeline hdr;
VkPipeline hdr_to_sdr; /* for readback */
#endif /* VULKAN_HDR_SWAPCHAIN */
VkDescriptorSetLayout set_layout;
VkPipelineLayout layout;
Expand Down
Loading

0 comments on commit 1ad8d14

Please sign in to comment.