Skip to content

Commit

Permalink
(GL) We don't need gl_common.c anymore
Browse files Browse the repository at this point in the history
  • Loading branch information
inactive123 committed Feb 2, 2019
1 parent 350b0dd commit 0c0ab19
Show file tree
Hide file tree
Showing 6 changed files with 129 additions and 172 deletions.
1 change: 0 additions & 1 deletion Makefile.common
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,6 @@ ifeq ($(HAVE_GL_CONTEXT), 1)
OBJ += gfx/drivers/gl.o \
gfx/drivers_renderchain/gl2_renderchain.o \
$(LIBRETRO_COMM_DIR)/gfx/gl_capabilities.o \
gfx/common/gl_common.o \
gfx/drivers_font/gl_raster_font.o \
$(LIBRETRO_COMM_DIR)/glsym/rglgen.o

Expand Down
150 changes: 0 additions & 150 deletions gfx/common/gl_common.c

This file was deleted.

22 changes: 2 additions & 20 deletions gfx/common/gl_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -356,26 +356,6 @@ static INLINE unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type)
return 0;
}

bool gl_query_core_context_in_use(void);

void gl_load_texture_image(GLenum target,
GLint level,
GLint internalFormat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid * data);

void gl_load_texture_data(
uint32_t id_data,
enum gfx_wrap_type wrap_type,
enum texture_filter_type filter_type,
unsigned alignment,
unsigned width, unsigned height,
const void *frame, unsigned base_size);

static INLINE GLenum gl_min_filter_to_mag(GLenum type)
{
switch (type)
Expand Down Expand Up @@ -408,6 +388,8 @@ static INLINE bool gl_set_core_context(enum retro_hw_context_type ctx_type)
return true;
}

bool gl_query_core_context_in_use(void);

bool gl_load_luts(
const void *shader_data,
GLuint *textures_lut);
Expand Down
69 changes: 69 additions & 0 deletions gfx/drivers/gl.c
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,75 @@ void context_bind_hw_render(void *data, bool enable)
gl_context_bind_hw_render(gl, enable);
}

static void gl_load_texture_data(
uint32_t id_data,
enum gfx_wrap_type wrap_type,
enum texture_filter_type filter_type,
unsigned alignment,
unsigned width, unsigned height,
const void *frame, unsigned base_size)
{
GLint mag_filter, min_filter;
bool want_mipmap = false;
bool use_rgba = video_driver_supports_rgba();
bool rgb32 = (base_size == (sizeof(uint32_t)));
GLenum wrap = gl_wrap_type_to_enum(wrap_type);
GLuint id = (GLuint)id_data;
bool have_mipmap = gl_check_capability(GL_CAPS_MIPMAP);

if (!have_mipmap)
{
/* Assume no mipmapping support. */
switch (filter_type)
{
case TEXTURE_FILTER_MIPMAP_LINEAR:
filter_type = TEXTURE_FILTER_LINEAR;
break;
case TEXTURE_FILTER_MIPMAP_NEAREST:
filter_type = TEXTURE_FILTER_NEAREST;
break;
default:
break;
}
}

switch (filter_type)
{
case TEXTURE_FILTER_MIPMAP_LINEAR:
min_filter = GL_LINEAR_MIPMAP_NEAREST;
mag_filter = GL_LINEAR;
want_mipmap = true;
break;
case TEXTURE_FILTER_MIPMAP_NEAREST:
min_filter = GL_NEAREST_MIPMAP_NEAREST;
mag_filter = GL_NEAREST;
want_mipmap = true;
break;
case TEXTURE_FILTER_NEAREST:
min_filter = GL_NEAREST;
mag_filter = GL_NEAREST;
break;
case TEXTURE_FILTER_LINEAR:
default:
min_filter = GL_LINEAR;
mag_filter = GL_LINEAR;
break;
}

gl_bind_texture(id, wrap, mag_filter, min_filter);

glPixelStorei(GL_UNPACK_ALIGNMENT, alignment);
glTexImage2D(GL_TEXTURE_2D,
0,
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_INTERNAL_FORMAT32,
width, height, 0,
(use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32,
(rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame);

if (want_mipmap && have_mipmap)
glGenerateMipmap(GL_TEXTURE_2D);
}

static bool gl_add_lut(
const char *lut_path,
bool lut_mipmap,
Expand Down
58 changes: 58 additions & 0 deletions gfx/drivers_renderchain/gl2_renderchain.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,64 @@ static void gl2_renderchain_convert_geometry(
}
}

static void gl_size_format(GLint* internalFormat)
{
#ifndef HAVE_PSGL
switch (*internalFormat)
{
case GL_RGB:
/* FIXME: PS3 does not support this, neither does it have GL_RGB565_OES. */
*internalFormat = GL_RGB565;
break;
case GL_RGBA:
#ifdef HAVE_OPENGLES2
*internalFormat = GL_RGBA8_OES;
#else
*internalFormat = GL_RGBA8;
#endif
break;
}
#endif
}

/* This function should only be used without mipmaps
and when data == NULL */
static void gl_load_texture_image(GLenum target,
GLint level,
GLint internalFormat,
GLsizei width,
GLsizei height,
GLint border,
GLenum format,
GLenum type,
const GLvoid * data)
{
#if !defined(HAVE_PSGL) && !defined(ORBIS)
#ifdef HAVE_OPENGLES2
if (gl_check_capability(GL_CAPS_TEX_STORAGE_EXT) && internalFormat != GL_BGRA_EXT)
{
gl_size_format(&internalFormat);
glTexStorage2DEXT(target, 1, internalFormat, width, height);
}
#else
if (gl_check_capability(GL_CAPS_TEX_STORAGE) && internalFormat != GL_BGRA_EXT)
{
gl_size_format(&internalFormat);
glTexStorage2D(target, 1, internalFormat, width, height);
}
#endif
else
#endif
{
#ifdef HAVE_OPENGLES
if (gl_check_capability(GL_CAPS_GLES3_SUPPORTED))
#endif
gl_size_format(&internalFormat);
glTexImage2D(target, level, internalFormat, width,
height, border, format, type, data);
}
}

static bool gl_recreate_fbo(
struct video_fbo_rect *fbo_rect,
GLuint fbo,
Expand Down
1 change: 0 additions & 1 deletion griffin/griffin.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,6 @@ VIDEO DRIVER
#include "../gfx/display_servers/dispserv_null.c"

#ifdef HAVE_OPENGL
#include "../gfx/common/gl_common.c"
#include "../gfx/drivers/gl.c"
#include "../libretro-common/gfx/gl_capabilities.c"
#include "../gfx/drivers_renderchain/gl2_renderchain.c"
Expand Down

0 comments on commit 0c0ab19

Please sign in to comment.