Skip to content

Commit

Permalink
Update GLSM
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Oct 6, 2018
1 parent 70449aa commit 528036a
Show file tree
Hide file tree
Showing 5 changed files with 174 additions and 122 deletions.
53 changes: 41 additions & 12 deletions libretro-common/glsm/glsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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:
Expand Down Expand Up @@ -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
}

/*
*
Expand Down Expand Up @@ -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
}

/*
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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;

Expand All @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions libretro-common/include/glsm/glsm.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions libretro-common/include/glsm/glsmsym.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down
Loading

0 comments on commit 528036a

Please sign in to comment.