mirror of
https://github.com/libretro/beetle-psx-libretro.git
synced 2024-11-23 16:59:49 +00:00
Renderer core option now has two options: hardware and software
This commit is contained in:
parent
d469c7aaf5
commit
8dd93d7e99
94
libretro.cpp
94
libretro.cpp
@ -2633,30 +2633,6 @@ static void check_variables(bool startup)
|
||||
|
||||
extern void PSXDitherApply(bool);
|
||||
|
||||
if (startup)
|
||||
{
|
||||
var.key = BEETLE_OPT(renderer);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
if (!strcmp(var.value, "software"))
|
||||
{
|
||||
rsx_intf_set_type(RSX_SOFTWARE);
|
||||
rsx_intf_set_fallback_type(RSX_SOFTWARE);
|
||||
}
|
||||
else if (!strcmp(var.value, "opengl"))
|
||||
{
|
||||
rsx_intf_set_type(RSX_OPENGL);
|
||||
rsx_intf_set_fallback_type(RSX_VULKAN);
|
||||
}
|
||||
else if (!strcmp(var.value, "vulkan"))
|
||||
{
|
||||
rsx_intf_set_type(RSX_VULKAN);
|
||||
rsx_intf_set_fallback_type(RSX_OPENGL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef EMSCRIPTEN
|
||||
var.key = BEETLE_OPT(cd_access_method);
|
||||
|
||||
@ -2783,15 +2759,17 @@ static void check_variables(bool startup)
|
||||
else
|
||||
input_enable_calibration( false );
|
||||
|
||||
rsx_intf_refresh_variables();
|
||||
|
||||
switch (rsx_intf_is_type())
|
||||
if (startup)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
var.key = BEETLE_OPT(renderer);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value && !strcmp(var.value, "software"))
|
||||
{
|
||||
var.key = BEETLE_OPT(internal_resolution);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
uint8_t new_upscale_shift;
|
||||
uint8_t val = atoi(var.value);
|
||||
|
||||
// Upscale must be a power of two
|
||||
@ -2799,21 +2777,48 @@ static void check_variables(bool startup)
|
||||
|
||||
// Crappy "ffs" implementation since the standard function is not
|
||||
// widely supported by libc in the wild
|
||||
uint8_t new_upscale_shift;
|
||||
for (new_upscale_shift = 0; (val & 1) == 0; ++new_upscale_shift)
|
||||
{
|
||||
val >>= 1;
|
||||
}
|
||||
psx_gpu_upscale_shift = new_upscale_shift;
|
||||
}
|
||||
else
|
||||
psx_gpu_upscale_shift = 0;
|
||||
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
case RSX_VULKAN:
|
||||
}
|
||||
else
|
||||
psx_gpu_upscale_shift = 0;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
rsx_intf_refresh_variables();
|
||||
|
||||
switch (rsx_intf_is_type())
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
var.key = BEETLE_OPT(internal_resolution);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
{
|
||||
uint8_t new_upscale_shift;
|
||||
uint8_t val = atoi(var.value);
|
||||
|
||||
// Upscale must be a power of two
|
||||
assert((val & (val - 1)) == 0);
|
||||
|
||||
// Crappy "ffs" implementation since the standard function is not
|
||||
// widely supported by libc in the wild
|
||||
for (new_upscale_shift = 0; (val & 1) == 0; ++new_upscale_shift)
|
||||
val >>= 1;
|
||||
psx_gpu_upscale_shift = new_upscale_shift;
|
||||
}
|
||||
else
|
||||
psx_gpu_upscale_shift = 0;
|
||||
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
case RSX_VULKAN:
|
||||
psx_gpu_upscale_shift = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var.key = BEETLE_OPT(dither_mode);
|
||||
@ -3775,21 +3780,6 @@ unsigned retro_api_version(void)
|
||||
return RETRO_API_VERSION;
|
||||
}
|
||||
|
||||
#if defined(HAVE_VULKAN)
|
||||
#define FIRST_RENDERER "vulkan"
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
#define EXT_RENDERER "|opengl|software"
|
||||
#else
|
||||
#define EXT_RENDERER "|software"
|
||||
#endif
|
||||
#elif defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
#define FIRST_RENDERER "opengl"
|
||||
#define EXT_RENDERER "|software"
|
||||
#else
|
||||
#define FIRST_RENDERER "software"
|
||||
#define EXT_RENDERER ""
|
||||
#endif
|
||||
|
||||
void retro_set_environment(retro_environment_t cb)
|
||||
{
|
||||
struct retro_vfs_interface_info vfs_iface_info;
|
||||
@ -3797,7 +3787,7 @@ void retro_set_environment(retro_environment_t cb)
|
||||
|
||||
static const struct retro_variable vars[] = {
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) || defined(HAVE_VULKAN)
|
||||
{ BEETLE_OPT(renderer), "Renderer (restart); " FIRST_RENDERER EXT_RENDERER },
|
||||
{ BEETLE_OPT(renderer), "Renderer (restart); hardware|software"},
|
||||
{ BEETLE_OPT(renderer_software_fb), "Software framebuffer; enabled|disabled" },
|
||||
#endif
|
||||
#ifdef HAVE_VULKAN
|
||||
|
131
rsx/rsx_intf.cpp
131
rsx/rsx_intf.cpp
@ -20,17 +20,19 @@
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
|
||||
static enum rsx_renderer_type rsx_type =
|
||||
#if defined(HAVE_VULKAN)
|
||||
RSX_VULKAN
|
||||
#elif defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
RSX_OPENGL
|
||||
#else
|
||||
RSX_SOFTWARE
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
extern retro_environment_t environ_cb;
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
;
|
||||
|
||||
static enum rsx_renderer_type rsx_fallback_type = RSX_SOFTWARE;
|
||||
static enum rsx_renderer_type rsx_type = RSX_SOFTWARE;
|
||||
|
||||
static bool gl_initialized = false;
|
||||
static bool vk_initialized = false;
|
||||
|
||||
void rsx_intf_set_environment(retro_environment_t cb)
|
||||
{
|
||||
@ -97,60 +99,51 @@ enum rsx_renderer_type rsx_intf_is_type(void)
|
||||
return rsx_type;
|
||||
}
|
||||
|
||||
void rsx_intf_set_type(enum rsx_renderer_type type)
|
||||
{
|
||||
rsx_type = type;
|
||||
}
|
||||
|
||||
void rsx_intf_set_fallback_type(enum rsx_renderer_type type)
|
||||
{
|
||||
rsx_fallback_type = type;
|
||||
}
|
||||
|
||||
bool rsx_intf_open(bool is_pal)
|
||||
{
|
||||
bool ret = true;
|
||||
switch (rsx_type)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
if (!rsx_soft_open(is_pal))
|
||||
ret = false;
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
if (!rsx_gl_open(is_pal))
|
||||
ret = false;
|
||||
#else
|
||||
ret = false;
|
||||
#endif
|
||||
break;
|
||||
case RSX_VULKAN:
|
||||
struct retro_variable var = {0};
|
||||
bool software_selected = false;
|
||||
vk_initialized = false;
|
||||
gl_initialized = false;
|
||||
|
||||
var.key = BEETLE_OPT(renderer);
|
||||
|
||||
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
|
||||
if (!strcmp(var.value, "software"))
|
||||
software_selected = true;
|
||||
|
||||
#if defined(HAVE_VULKAN)
|
||||
if (!rsx_vulkan_open(is_pal))
|
||||
ret = false;
|
||||
#else
|
||||
ret = false;
|
||||
#endif
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ret)
|
||||
if (!software_selected && rsx_vulkan_open(is_pal))
|
||||
{
|
||||
if (rsx_fallback_type == rsx_type) // We're screwed.
|
||||
return false;
|
||||
|
||||
// Try the fallback type.
|
||||
rsx_type = rsx_fallback_type;
|
||||
rsx_fallback_type = RSX_SOFTWARE; // This shouldn't ever fail.
|
||||
return rsx_intf_open(is_pal);
|
||||
rsx_type = RSX_VULKAN;
|
||||
vk_initialized = true;
|
||||
goto end;
|
||||
}
|
||||
|
||||
#if defined(RSX_DUMP)
|
||||
const char *env = getenv("RSX_DUMP");
|
||||
if (env)
|
||||
rsx_dump_init(env);
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
if (!software_selected && rsx_gl_open(is_pal))
|
||||
{
|
||||
rsx_type = RSX_OPENGL;
|
||||
gl_initialized = true;
|
||||
goto end;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (rsx_soft_open(is_pal))
|
||||
goto end;
|
||||
|
||||
rsx_type = RSX_SOFTWARE;
|
||||
return rsx_intf_open(is_pal);
|
||||
|
||||
end:
|
||||
#if defined(RSX_DUMP)
|
||||
{
|
||||
const char *env = getenv("RSX_DUMP");
|
||||
if (env)
|
||||
rsx_dump_init(env);
|
||||
}
|
||||
#endif
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -160,21 +153,21 @@ void rsx_intf_close(void)
|
||||
rsx_dump_deinit();
|
||||
#endif
|
||||
|
||||
switch (rsx_type)
|
||||
{
|
||||
case RSX_SOFTWARE:
|
||||
break;
|
||||
case RSX_OPENGL:
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
rsx_gl_close();
|
||||
#endif
|
||||
break;
|
||||
case RSX_VULKAN:
|
||||
#if defined(HAVE_VULKAN)
|
||||
rsx_vulkan_close();
|
||||
#endif
|
||||
break;
|
||||
if (rsx_type != RSX_SOFTWARE && vk_initialized)
|
||||
{
|
||||
rsx_vulkan_close();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||
if (rsx_type != RSX_SOFTWARE && gl_initialized)
|
||||
{
|
||||
rsx_gl_close();
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void rsx_intf_refresh_variables(void)
|
||||
|
@ -115,9 +115,6 @@ void rsx_intf_copy_rect(uint16_t src_x, uint16_t src_y,
|
||||
uint16_t w, uint16_t h,
|
||||
uint32_t mask_test, uint32_t set_mask);
|
||||
|
||||
void rsx_intf_set_type(enum rsx_renderer_type type);
|
||||
void rsx_intf_set_fallback_type(enum rsx_renderer_type type);
|
||||
|
||||
enum rsx_renderer_type rsx_intf_is_type(void);
|
||||
|
||||
void rsx_intf_toggle_display(bool status);
|
||||
|
Loading…
Reference in New Issue
Block a user