Update GLSM

This commit is contained in:
twinaphex 2018-10-06 17:32:30 +02:00
parent 70449aadae
commit 528036a210
5 changed files with 174 additions and 122 deletions

View File

@ -200,6 +200,7 @@ struct gl_cached_state
int cap_translate[SGL_CAP_MAX];
};
static GLuint default_framebuffer;
static GLint glsm_max_textures;
struct retro_hw_render_callback hw_render;
static struct gl_cached_state gl_state;
@ -216,6 +217,20 @@ GLenum rglGetError(void)
return glGetError();
}
/*
*
* Core in:
* OpenGL : 3.2
* OpenGLES : N/A
*/
void rglProvokingVertex( GLenum provokeMode)
{
#if defined(HAVE_OPENGL)
glProvokingVertex(provokeMode);
#endif
}
/*
*
* Core in:
@ -2080,6 +2095,18 @@ void rglTexStorage2D(GLenum target, GLsizei levels, GLenum internalFormat,
glTexStorage2D(target, levels, internalFormat, width, height);
#endif
}
/*
*
* Core in:
* OpenGL : 3.2
* OpenGLES : 3.2
*/
void rglDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLvoid *indices, GLint basevertex)
{
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES_3_2)
glDrawRangeElementsBaseVertex(mode, start, end, count, type, indices, basevertex);
#endif
}
/*
*
@ -2457,7 +2484,9 @@ void rglUniform2uiv( GLint location,
#ifdef GLSM_DEBUG
log_cb(RETRO_LOG_INFO, "glUniform2uiv.\n");
#endif
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3)
glUniform2uiv(location, count, value);
#endif
}
/*
@ -2569,7 +2598,8 @@ static void glsm_state_setup(void)
gl_state.bind_textures.ids = (GLuint*)calloc(glsm_max_textures, sizeof(GLuint));
gl_state.framebuf = hw_render.get_current_framebuffer();
default_framebuffer = glsm_get_current_framebuffer();
gl_state.framebuf = default_framebuffer;
gl_state.cullface.mode = GL_BACK;
gl_state.frontface.mode = GL_CCW;
@ -2627,7 +2657,7 @@ static void glsm_state_bind(void)
}
}
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, hw_render.get_current_framebuffer());
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, default_framebuffer);
if (gl_state.blendfunc.used)
glBlendFunc(
@ -2784,10 +2814,8 @@ static bool glsm_state_ctx_destroy(void *data)
return true;
}
static bool glsm_state_ctx_init(void *data)
static bool glsm_state_ctx_init(glsm_ctx_params_t *params)
{
glsm_ctx_params_t *params = (glsm_ctx_params_t*)data;
if (!params || !params->environ_cb)
return false;
@ -2801,15 +2829,16 @@ static bool glsm_state_ctx_init(void *data)
#else
hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES2;
#endif
#else
#ifdef CORE
hw_render.context_type = RETRO_HW_CONTEXT_OPENGL_CORE;
hw_render.version_major = 3;
hw_render.version_minor = 3;
#else
hw_render.context_type = RETRO_HW_CONTEXT_OPENGL;
if (params->context_type != RETRO_HW_CONTEXT_NONE)
hw_render.context_type = params->context_type;
if (params->major != 0)
hw_render.version_major = params->major;
if (params->minor != 0)
hw_render.version_minor = params->minor;
#endif
#endif
hw_render.context_reset = params->context_reset;
hw_render.context_destroy = params->context_destroy;
hw_render.stencil = params->stencil;
@ -2857,7 +2886,7 @@ bool glsm_ctl(enum glsm_state_ctl state, void *data)
glsm_state_ctx_destroy(data);
break;
case GLSM_CTL_STATE_CONTEXT_INIT:
return glsm_state_ctx_init(data);
return glsm_state_ctx_init((glsm_ctx_params_t*)data);
case GLSM_CTL_STATE_SETUP:
glsm_state_setup();
break;

View File

@ -146,6 +146,7 @@ typedef struct glsm_ctx_params
bool stencil;
unsigned major;
unsigned minor;
enum retro_hw_context_type context_type;
} glsm_ctx_params_t;
GLuint glsm_get_current_framebuffer(void);

View File

@ -33,6 +33,8 @@ RETRO_BEGIN_DECLS
#define glTexCoord2f rglTexCoord2f
/* more forward-compatible GL subset symbols */
#define glDrawRangeElementsBaseVertex rglDrawRangeElementsBaseVertex
#define glProvokingVertex rglProvokingVertex
#define glGetInteger64v rglGetInteger64v
#define glGenSamplers rglGenSamplers
#define glBindSampler rglBindSampler
@ -469,6 +471,8 @@ void rglGetInteger64v( GLenum pname,
void rglUniform2iv( GLint location,
GLsizei count,
const GLint *value);
void rglProvokingVertex( GLenum provokeMode);
void rglDrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, GLsizei count, GLenum type, GLvoid *indices, GLint basevertex);
RETRO_END_DECLS

View File

@ -450,6 +450,7 @@ enum retro_key
RETROK_POWER = 320,
RETROK_EURO = 321,
RETROK_UNDO = 322,
RETROK_OEM_102 = 323,
RETROK_LAST,
@ -657,6 +658,15 @@ enum retro_mod
/* Environment 20 was an obsolete version of SET_AUDIO_CALLBACK.
* It was not used by any known core at the time,
* and was removed from the API. */
#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21
/* const struct retro_frame_time_callback * --
* Lets the core know how much time has passed since last
* invocation of retro_run().
* The frontend can tamper with the timing to fake fast-forward,
* slow-motion, frame stepping, etc.
* In this case the delta time will use the reference value
* in frame_time_callback..
*/
#define RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK 22
/* const struct retro_audio_callback * --
* Sets an interface which is used to notify a libretro core about audio
@ -683,15 +693,6 @@ enum retro_mod
* A libretro core using SET_AUDIO_CALLBACK should also make use of
* SET_FRAME_TIME_CALLBACK.
*/
#define RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK 21
/* const struct retro_frame_time_callback * --
* Lets the core know how much time has passed since last
* invocation of retro_run().
* The frontend can tamper with the timing to fake fast-forward,
* slow-motion, frame stepping, etc.
* In this case the delta time will use the reference value
* in frame_time_callback..
*/
#define RETRO_ENVIRONMENT_GET_RUMBLE_INTERFACE 23
/* struct retro_rumble_interface * --
* Gets an interface which is used by a libretro core to set
@ -968,7 +969,37 @@ enum retro_mod
* A frontend must make sure that the pointer obtained from this function is
* writeable (and readable).
*/
#define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* const struct retro_hw_render_interface ** --
* Returns an API specific rendering interface for accessing API specific data.
* Not all HW rendering APIs support or need this.
* The contents of the returned pointer is specific to the rendering API
* being used. See the various headers like libretro_vulkan.h, etc.
*
* GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.
* Similarly, after context_destroyed callback returns,
* the contents of the HW_RENDER_INTERFACE are invalidated.
*/
#define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* const bool * --
* If true, the libretro implementation supports achievements
* either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS
* or via retro_get_memory_data/retro_get_memory_size.
*
* This must be called before the first call to retro_run.
*/
#define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* const struct retro_hw_render_context_negotiation_interface * --
* Sets an interface which lets the libretro core negotiate with frontend how a context is created.
* The semantics of this interface depends on which API is used in SET_HW_RENDER earlier.
* This interface will be used when the frontend is trying to create a HW rendering context,
* so it will be used after SET_HW_RENDER, but before the context_reset callback.
*/
#define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44
/* uint64_t * --
* Sets quirk flags associated with serialization. The frontend will zero any flags it doesn't
* recognize or support. Should be set in either retro_init or retro_load_game, but not both.
*/
#define RETRO_ENVIRONMENT_SET_HW_SHARED_CONTEXT (44 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* N/A (null) * --
* The frontend will try to use a 'shared' hardware context (mostly applicable
@ -980,14 +1011,70 @@ enum retro_mod
* This will do nothing on its own until SET_HW_RENDER env callbacks are
* being used.
*/
#define RETRO_ENVIRONMENT_GET_VFS_INTERFACE (45 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* struct retro_vfs_interface_info * --
* Gets access to the VFS interface.
* VFS presence needs to be queried prior to load_game or any
* get_system/save/other_directory being called to let front end know
* core supports VFS before it starts handing out paths.
* It is recomended to do so in retro_set_environment */
* It is recomended to do so in retro_set_environment
*/
#define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* struct retro_led_interface * --
* Gets an interface which is used by a libretro core to set
* state of LEDs.
*/
#define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* int * --
* Tells the core if the frontend wants audio or video.
* If disabled, the frontend will discard the audio or video,
* so the core may decide to skip generating a frame or generating audio.
* This is mainly used for increasing performance.
* Bit 0 (value 1): Enable Video
* Bit 1 (value 2): Enable Audio
* Bit 2 (value 4): Use Fast Savestates.
* Bit 3 (value 8): Hard Disable Audio
* Other bits are reserved for future use and will default to zero.
* If video is disabled:
* * The frontend wants the core to not generate any video,
* including presenting frames via hardware acceleration.
* * The frontend's video frame callback will do nothing.
* * After running the frame, the video output of the next frame should be
* no different than if video was enabled, and saving and loading state
* should have no issues.
* If audio is disabled:
* * The frontend wants the core to not generate any audio.
* * The frontend's audio callbacks will do nothing.
* * After running the frame, the audio output of the next frame should be
* no different than if audio was enabled, and saving and loading state
* should have no issues.
* Fast Savestates:
* * Guaranteed to be created by the same binary that will load them.
* * Will not be written to or read from the disk.
* * Suggest that the core assumes loading state will succeed.
* * Suggest that the core updates its memory buffers in-place if possible.
* * Suggest that the core skips clearing memory.
* * Suggest that the core skips resetting the system.
* * Suggest that the core may skip validation steps.
* Hard Disable Audio:
* * Used for a secondary core when running ahead.
* * Indicates that the frontend will never need audio from the core.
* * Suggests that the core may stop synthesizing audio, but this should not
* compromise emulation accuracy.
* * Audio output for the next frame does not matter, and the frontend will
* never need an accurate audio state in the future.
* * State will never be saved when using Hard Disable Audio.
*/
#define RETRO_ENVIRONMENT_GET_MIDI_INTERFACE (48 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* struct retro_midi_interface ** --
* Returns a MIDI interface that can be used for raw data I/O.
*/
#define RETRO_ENVIRONMENT_GET_FASTFORWARDING (49 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* bool * --
* Boolean value that indicates whether or not the frontend is in
* fastforwarding mode.
*/
/* VFS functionality */
@ -1047,6 +1134,10 @@ typedef int (RETRO_CALLCONV *retro_vfs_close_t)(struct retro_vfs_file_handle *st
* Introduced in VFS API v1 */
typedef int64_t (RETRO_CALLCONV *retro_vfs_size_t)(struct retro_vfs_file_handle *stream);
/* Truncate file to specified size. Returns 0 on success or -1 on error
* Introduced in VFS API v2 */
typedef int64_t (RETRO_CALLCONV *retro_vfs_truncate_t)(struct retro_vfs_file_handle *stream, int64_t length);
/* Get the current read / write position for the file. Returns - 1 for error.
* Introduced in VFS API v1 */
typedef int64_t (RETRO_CALLCONV *retro_vfs_tell_t)(struct retro_vfs_file_handle *stream);
@ -1077,6 +1168,7 @@ typedef int (RETRO_CALLCONV *retro_vfs_rename_t)(const char *old_path, const cha
struct retro_vfs_interface
{
/* VFS API v1 */
retro_vfs_get_path_t get_path;
retro_vfs_open_t open;
retro_vfs_close_t close;
@ -1088,6 +1180,8 @@ struct retro_vfs_interface
retro_vfs_flush_t flush;
retro_vfs_remove_t remove;
retro_vfs_rename_t rename;
/* VFS API v2 */
retro_vfs_truncate_t truncate;
};
struct retro_vfs_interface_info
@ -1121,66 +1215,12 @@ struct retro_hw_render_interface
unsigned interface_version;
};
#define RETRO_ENVIRONMENT_GET_LED_INTERFACE (46 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* struct retro_led_interface * --
* Gets an interface which is used by a libretro core to set
* state of LEDs.
*/
typedef void (RETRO_CALLCONV *retro_set_led_state_t)(int led, int state);
struct retro_led_interface
{
retro_set_led_state_t set_led_state;
};
#define RETRO_ENVIRONMENT_GET_AUDIO_VIDEO_ENABLE (47 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* int * --
* Tells the core if the frontend wants audio or video.
* If disabled, the frontend will discard the audio or video,
* so the core may decide to skip generating a frame or generating audio.
* This is mainly used for increasing performance.
* Bit 0 (value 1): Enable Video
* Bit 1 (value 2): Enable Audio
* Bit 2 (value 4): Use Fast Savestates.
* Bit 3 (value 8): Hard Disable Audio
* Other bits are reserved for future use and will default to zero.
* If video is disabled:
* * The frontend wants the core to not generate any video,
* including presenting frames via hardware acceleration.
* * The frontend's video frame callback will do nothing.
* * After running the frame, the video output of the next frame should be
* no different than if video was enabled, and saving and loading state
* should have no issues.
* If audio is disabled:
* * The frontend wants the core to not generate any audio.
* * The frontend's audio callbacks will do nothing.
* * After running the frame, the audio output of the next frame should be
* no different than if audio was enabled, and saving and loading state
* should have no issues.
* Fast Savestates:
* * Guaranteed to be created by the same binary that will load them.
* * Will not be written to or read from the disk.
* * Suggest that the core assumes loading state will succeed.
* * Suggest that the core updates its memory buffers in-place if possible.
* * Suggest that the core skips clearing memory.
* * Suggest that the core skips resetting the system.
* * Suggest that the core may skip validation steps.
* Hard Disable Audio:
* * Used for a secondary core when running ahead.
* * Indicates that the frontend will never need audio from the core.
* * Suggests that the core may stop synthesizing audio, but this should not
* compromise emulation accuracy.
* * Audio output for the next frame does not matter, and the frontend will
* never need an accurate audio state in the future.
* * State will never be saved when using Hard Disable Audio.
*/
#define RETRO_ENVIRONMENT_GET_MIDI_INTERFACE (48 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* struct retro_midi_interface ** --
* Returns a MIDI interface that can be used for raw data I/O.
*/
/* Retrieves the current state of the MIDI input.
* Returns true if it's enabled, false otherwise. */
typedef bool (RETRO_CALLCONV *retro_midi_input_enabled_t)(void);
@ -1211,27 +1251,6 @@ struct retro_midi_interface
retro_midi_flush_t flush;
};
#define RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE (41 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* const struct retro_hw_render_interface ** --
* Returns an API specific rendering interface for accessing API specific data.
* Not all HW rendering APIs support or need this.
* The contents of the returned pointer is specific to the rendering API
* being used. See the various headers like libretro_vulkan.h, etc.
*
* GET_HW_RENDER_INTERFACE cannot be called before context_reset has been called.
* Similarly, after context_destroyed callback returns,
* the contents of the HW_RENDER_INTERFACE are invalidated.
*/
#define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* const bool * --
* If true, the libretro implementation supports achievements
* either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS
* or via retro_get_memory_data/retro_get_memory_size.
*
* This must be called before the first call to retro_run.
*/
enum retro_hw_render_context_negotiation_interface_type
{
RETRO_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE_VULKAN = 0,
@ -1245,13 +1264,6 @@ struct retro_hw_render_context_negotiation_interface
enum retro_hw_render_context_negotiation_interface_type interface_type;
unsigned interface_version;
};
#define RETRO_ENVIRONMENT_SET_HW_RENDER_CONTEXT_NEGOTIATION_INTERFACE (43 | RETRO_ENVIRONMENT_EXPERIMENTAL)
/* const struct retro_hw_render_context_negotiation_interface * --
* Sets an interface which lets the libretro core negotiate with frontend how a context is created.
* The semantics of this interface depends on which API is used in SET_HW_RENDER earlier.
* This interface will be used when the frontend is trying to create a HW rendering context,
* so it will be used after SET_HW_RENDER, but before the context_reset callback.
*/
/* Serialized state is incomplete in some way. Set if serialization is
* usable in typical end-user cases but should not be relied upon to
@ -1277,12 +1289,6 @@ struct retro_hw_render_context_negotiation_interface
* dependence */
#define RETRO_SERIALIZATION_QUIRK_PLATFORM_DEPENDENT (1 << 6)
#define RETRO_ENVIRONMENT_SET_SERIALIZATION_QUIRKS 44
/* uint64_t * --
* Sets quirk flags associated with serialization. The frontend will zero any flags it doesn't
* recognize or support. Should be set in either retro_init or retro_load_game, but not both.
*/
#define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */
#define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */
#define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */
@ -2190,17 +2196,26 @@ struct retro_system_info
* Typically used for a GUI to filter
* out extensions. */
/* If true, retro_load_game() is guaranteed to provide a valid pathname
* in retro_game_info::path.
* ::data and ::size are both invalid.
/* Libretro cores that need to have direct access to their content
* files, including cores which use the path of the content files to
* determine the paths of other files, should set need_fullpath to true.
*
* If false, ::data and ::size are guaranteed to be valid, but ::path
* might not be valid.
* Cores should strive for setting need_fullpath to false,
* as it allows the frontend to perform patching, etc.
*
* This is typically set to true for libretro implementations that must
* load from file.
* Implementations should strive for setting this to false, as it allows
* the frontend to perform patching, etc. */
* If need_fullpath is true and retro_load_game() is called:
* - retro_game_info::path is guaranteed to have a valid path
* - retro_game_info::data and retro_game_info::size are invalid
*
* If need_fullpath is false and retro_load_game() is called:
* - retro_game_info::path may be NULL
* - retro_game_info::data and retro_game_info::size are guaranteed
* to be valid
*
* See also:
* - RETRO_ENVIRONMENT_GET_SYSTEM_DIRECTORY
* - RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY
*/
bool need_fullpath;
/* If true, the frontend is not allowed to extract any archives before
@ -2423,7 +2438,7 @@ RETRO_API bool retro_unserialize(const void *data, size_t size);
RETRO_API void retro_cheat_reset(void);
RETRO_API void retro_cheat_set(unsigned index, bool enabled, const char *code);
/* Loads a game.
/* Loads a game.
* Return true to indicate successful loading and false to indicate load failure.
*/
RETRO_API bool retro_load_game(const struct retro_game_info *game);

View File

@ -2192,6 +2192,9 @@ bool rsx_gl_open(bool is_pal)
params.stencil = false;
params.imm_vbo_draw = NULL;
params.imm_vbo_disable = NULL;
params.context_type = RETRO_HW_CONTEXT_OPENGL_CORE;
params.major = 3;
params.minor = 3;
if ( !glsm_ctl(GLSM_CTL_STATE_CONTEXT_INIT, &params) )
return false;