Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
Citra2018
Commits
012d5bb6
Unverified
Commit
012d5bb6
authored
Oct 01, 2020
by
Libretro-Admin
Committed by
GitHub
Oct 01, 2020
Browse files
Merge pull request #73 from barbudreadmon/master
improve context requests
parents
84f31e95
20557a0f
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
externals/libretro/libretro.h
View file @
012d5bb6
This diff is collapsed.
Click to expand it.
src/citra_libretro/citra_libretro.cpp
View file @
012d5bb6
...
...
@@ -416,6 +416,47 @@ void retro_reset() {
context_reset
();
// Force the renderer to appear
}
static
bool
try_init_context
(
retro_hw_context_type
context_type
)
{
emu_instance
->
hw_render
.
context_type
=
context_type
;
emu_instance
->
hw_render
.
context_reset
=
context_reset
;
emu_instance
->
hw_render
.
context_destroy
=
context_destroy
;
emu_instance
->
hw_render
.
cache_context
=
false
;
emu_instance
->
hw_render
.
bottom_left_origin
=
true
;
switch
(
context_type
)
{
case
RETRO_HW_CONTEXT_OPENGL_CORE
:
// minimum requirements to run is opengl 3.3 (RA will try to use highest version available anyway)
emu_instance
->
hw_render
.
version_major
=
3
;
emu_instance
->
hw_render
.
version_minor
=
3
;
if
(
LibRetro
::
SetHWRenderer
(
&
emu_instance
->
hw_render
))
return
true
;
break
;
case
RETRO_HW_CONTEXT_OPENGL
:
// when using RETRO_HW_CONTEXT_OPENGL you can't set version above 3.0 (RA will try to use highest version available anyway)
emu_instance
->
hw_render
.
version_major
=
3
;
emu_instance
->
hw_render
.
version_minor
=
0
;
if
(
LibRetro
::
SetHWRenderer
(
&
emu_instance
->
hw_render
))
return
true
;
break
;
}
return
false
;
}
static
bool
init_hw_context
()
{
retro_hw_context_type
preferred_context
=
LibRetro
::
GetPreferredHWContext
();
bool
found_context
=
false
;
// try requesting the right context for current driver
if
(
preferred_context
==
RETRO_HW_CONTEXT_OPENGL
||
preferred_context
==
RETRO_HW_CONTEXT_OPENGL_CORE
)
found_context
=
try_init_context
(
preferred_context
);
// if not found, try requesting every compatible context
if
(
!
found_context
)
found_context
=
try_init_context
(
RETRO_HW_CONTEXT_OPENGL_CORE
);
if
(
!
found_context
)
found_context
=
try_init_context
(
RETRO_HW_CONTEXT_OPENGL
);
return
found_context
;
}
/**
* libretro callback; Called when a game is to be loaded.
*/
...
...
@@ -424,6 +465,8 @@ bool retro_load_game(const struct retro_game_info* info) {
LibRetro
::
settings
.
file_path
=
info
->
path
;
// why is "hw shared context" force-enabled here ? i can't find any issue when it's disabled
// i'm not gonna change this, but for the reminder, it's adding rendering latency -barbudreadmon
LibRetro
::
SetHWSharedContext
();
if
(
!
LibRetro
::
SetPixelFormat
(
RETRO_PIXEL_FORMAT_XRGB8888
))
{
...
...
@@ -432,14 +475,7 @@ bool retro_load_game(const struct retro_game_info* info) {
return
false
;
}
emu_instance
->
hw_render
.
context_type
=
RETRO_HW_CONTEXT_OPENGL_CORE
;
emu_instance
->
hw_render
.
version_major
=
3
;
emu_instance
->
hw_render
.
version_minor
=
3
;
emu_instance
->
hw_render
.
context_reset
=
context_reset
;
emu_instance
->
hw_render
.
context_destroy
=
context_destroy
;
emu_instance
->
hw_render
.
cache_context
=
false
;
emu_instance
->
hw_render
.
bottom_left_origin
=
true
;
if
(
!
LibRetro
::
SetHWRenderer
(
&
emu_instance
->
hw_render
))
{
if
(
!
init_hw_context
())
{
LOG_CRITICAL
(
Frontend
,
"OpenGL 3.3 is not supported."
);
LibRetro
::
DisplayMessage
(
"OpenGL 3.3 is not supported."
);
return
false
;
...
...
src/citra_libretro/environment.cpp
View file @
012d5bb6
...
...
@@ -24,6 +24,13 @@ void UploadVideoFrame(const void* data, unsigned width, unsigned height, size_t
return
video_cb
(
data
,
width
,
height
,
pitch
);
}
retro_hw_context_type
GetPreferredHWContext
()
{
retro_hw_context_type
preferred_context
;
if
(
!
environ_cb
(
RETRO_ENVIRONMENT_GET_PREFERRED_HW_RENDER
,
&
preferred_context
))
preferred_context
=
RETRO_HW_CONTEXT_DUMMY
;
return
preferred_context
;
}
bool
SetHWSharedContext
()
{
return
environ_cb
(
RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT
,
NULL
);
}
...
...
src/citra_libretro/environment.h
View file @
012d5bb6
...
...
@@ -25,6 +25,8 @@ void PollInput();
/// Sets the environmental variables used for settings.
bool
SetVariables
(
const
retro_variable
vars
[]);
retro_hw_context_type
GetPreferredHWContext
();
bool
SetHWSharedContext
(
void
);
/// Returns the LibRetro save directory, or a empty string if one doesn't exist.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment