mirror of
https://github.com/libretro/RetroArch
synced 2025-02-02 23:54:06 +00:00
Refactor SHADER_CTL_USE
This commit is contained in:
parent
0f65518118
commit
9d85afd358
@ -222,6 +222,7 @@ static void renderchain_set_vertices(void *data, unsigned pass,
|
|||||||
|
|
||||||
shader_info.data = d3d;
|
shader_info.data = d3d;
|
||||||
shader_info.idx = pass;
|
shader_info.idx = pass;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
|
@ -1190,8 +1190,9 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
|||||||
|
|
||||||
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo[i]);
|
glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo[i]);
|
||||||
|
|
||||||
shader_info.data = gl;
|
shader_info.data = gl;
|
||||||
shader_info.idx = i + 1;
|
shader_info.idx = i + 1;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]);
|
glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]);
|
||||||
@ -1263,8 +1264,9 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count,
|
|||||||
/* Render our FBO texture to back buffer. */
|
/* Render our FBO texture to back buffer. */
|
||||||
gl_bind_backbuffer();
|
gl_bind_backbuffer();
|
||||||
|
|
||||||
shader_info.data = gl;
|
shader_info.data = gl;
|
||||||
shader_info.idx = gl->fbo_pass + 1;
|
shader_info.idx = gl->fbo_pass + 1;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
@ -1685,8 +1687,9 @@ static INLINE void gl_set_shader_viewport(gl_t *gl, unsigned idx)
|
|||||||
|
|
||||||
video_driver_get_size(&width, &height);
|
video_driver_get_size(&width, &height);
|
||||||
|
|
||||||
shader_info.data = gl;
|
shader_info.data = gl;
|
||||||
shader_info.idx = idx;
|
shader_info.idx = idx;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
gl_set_viewport(gl, width, height, false, true);
|
gl_set_viewport(gl, width, height, false, true);
|
||||||
@ -1763,8 +1766,9 @@ static INLINE void gl_draw_texture(gl_t *gl)
|
|||||||
gl->coords.color = color;
|
gl->coords.color = color;
|
||||||
glBindTexture(GL_TEXTURE_2D, gl->menu_texture);
|
glBindTexture(GL_TEXTURE_2D, gl->menu_texture);
|
||||||
|
|
||||||
shader_info.data = gl;
|
shader_info.data = gl;
|
||||||
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
@ -1833,9 +1837,9 @@ static bool gl_frame(void *data, const void *frame,
|
|||||||
glBindVertexArray(gl->vao);
|
glBindVertexArray(gl->vao);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
shader_info.data = gl;
|
||||||
shader_info.data = gl;
|
shader_info.idx = 1;
|
||||||
shader_info.idx = 1;
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
@ -2015,8 +2019,9 @@ static bool gl_frame(void *data, const void *frame,
|
|||||||
/* Reset state which could easily mess up libretro core. */
|
/* Reset state which could easily mess up libretro core. */
|
||||||
if (gl->hw_render_fbo_init)
|
if (gl->hw_render_fbo_init)
|
||||||
{
|
{
|
||||||
shader_info.data = gl;
|
shader_info.data = gl;
|
||||||
shader_info.idx = 0;
|
shader_info.idx = 0;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
@ -3600,8 +3605,9 @@ static void gl_render_overlay(gl_t *gl)
|
|||||||
glViewport(0, 0, width, height);
|
glViewport(0, 0, width, height);
|
||||||
|
|
||||||
/* Ensure that we reset the attrib array. */
|
/* Ensure that we reset the attrib array. */
|
||||||
shader_info.data = gl;
|
shader_info.data = gl;
|
||||||
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
|
@ -406,8 +406,9 @@ static void gl_raster_font_setup_viewport(gl_raster_t *font, bool full_screen)
|
|||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, font->tex);
|
glBindTexture(GL_TEXTURE_2D, font->tex);
|
||||||
|
|
||||||
shader_info.data = NULL;
|
shader_info.data = NULL;
|
||||||
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
}
|
}
|
||||||
|
@ -1600,21 +1600,19 @@ static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const void
|
|||||||
static void gl_glsl_use(void *data, void *shader_data, unsigned idx, bool set_active)
|
static void gl_glsl_use(void *data, void *shader_data, unsigned idx, bool set_active)
|
||||||
{
|
{
|
||||||
GLuint id;
|
GLuint id;
|
||||||
glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data;
|
|
||||||
|
|
||||||
(void)data;
|
|
||||||
|
|
||||||
if (!glsl)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (set_active)
|
if (set_active)
|
||||||
{
|
{
|
||||||
|
glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data;
|
||||||
|
if (!glsl)
|
||||||
|
return;
|
||||||
|
|
||||||
gl_glsl_reset_attrib(glsl);
|
gl_glsl_reset_attrib(glsl);
|
||||||
glsl->glsl_active_index = idx;
|
glsl->glsl_active_index = idx;
|
||||||
id = glsl->prg[idx].id;
|
id = glsl->prg[idx].id;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
id = idx;
|
id = (GLuint)idx;
|
||||||
|
|
||||||
glUseProgram(id);
|
glUseProgram(id);
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,7 @@ bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *dat
|
|||||||
video_shader_ctx_info_t *shader_info = (video_shader_ctx_info_t*)data;
|
video_shader_ctx_info_t *shader_info = (video_shader_ctx_info_t*)data;
|
||||||
if (!current_shader || !shader_info)
|
if (!current_shader || !shader_info)
|
||||||
return false;
|
return false;
|
||||||
current_shader->use(shader_info->data, shader_data, shader_info->idx, true);
|
current_shader->use(shader_info->data, shader_data, shader_info->idx, shader_info->set_active);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case SHADER_CTL_WRAP_TYPE:
|
case SHADER_CTL_WRAP_TYPE:
|
||||||
|
@ -216,6 +216,7 @@ typedef struct video_shader_ctx_scale
|
|||||||
|
|
||||||
typedef struct video_shader_ctx_info
|
typedef struct video_shader_ctx_info
|
||||||
{
|
{
|
||||||
|
bool set_active;
|
||||||
unsigned num;
|
unsigned num;
|
||||||
unsigned idx;
|
unsigned idx;
|
||||||
void *data;
|
void *data;
|
||||||
|
@ -493,6 +493,7 @@ menu_ctx_driver_t menu_ctx_zr = {
|
|||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
|
NULL,
|
||||||
"zahnrad",
|
"zahnrad",
|
||||||
zrmenu_environ,
|
zrmenu_environ,
|
||||||
NULL,
|
NULL,
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "zr_common.h"
|
#include "zr_common.h"
|
||||||
|
|
||||||
#include "../menu_display.h"
|
#include "../menu_display.h"
|
||||||
|
#include "../../gfx/video_shader_driver.h"
|
||||||
|
|
||||||
struct zr_image zr_common_image_load(const char *filename)
|
struct zr_image zr_common_image_load(const char *filename)
|
||||||
{
|
{
|
||||||
@ -246,6 +247,7 @@ void zr_common_device_draw(struct zr_device *dev,
|
|||||||
struct zr_context *ctx, int width, int height,
|
struct zr_context *ctx, int width, int height,
|
||||||
enum zr_anti_aliasing AA)
|
enum zr_anti_aliasing AA)
|
||||||
{
|
{
|
||||||
|
video_shader_ctx_info_t shader_info;
|
||||||
struct zr_buffer vbuf, ebuf;
|
struct zr_buffer vbuf, ebuf;
|
||||||
struct zr_convert_config config;
|
struct zr_convert_config config;
|
||||||
const struct zr_draw_command *cmd = NULL;
|
const struct zr_draw_command *cmd = NULL;
|
||||||
@ -276,9 +278,15 @@ void zr_common_device_draw(struct zr_device *dev,
|
|||||||
|
|
||||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||||
glActiveTexture(GL_TEXTURE0);
|
glActiveTexture(GL_TEXTURE0);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* setup program */
|
/* setup program */
|
||||||
glUseProgram(dev->prog);
|
shader_info.data = NULL;
|
||||||
|
shader_info.idx = dev->prog;
|
||||||
|
shader_info.set_active = false;
|
||||||
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||||
glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]);
|
glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]);
|
||||||
|
|
||||||
/* convert from command queue into draw list and draw to screen */
|
/* convert from command queue into draw list and draw to screen */
|
||||||
@ -335,9 +343,13 @@ void zr_common_device_draw(struct zr_device *dev,
|
|||||||
}
|
}
|
||||||
zr_clear(ctx);
|
zr_clear(ctx);
|
||||||
|
|
||||||
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
|
||||||
/* restore old state */
|
/* restore old state */
|
||||||
glUseProgram((GLuint)last_prog);
|
shader_info.data = NULL;
|
||||||
|
shader_info.idx = last_prog;
|
||||||
|
shader_info.set_active = false;
|
||||||
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
|
|
||||||
|
#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES)
|
||||||
glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex);
|
glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex);
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, (GLuint)last_vbo);
|
glBindBuffer(GL_ARRAY_BUFFER, (GLuint)last_vbo);
|
||||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo);
|
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo);
|
||||||
|
@ -84,6 +84,7 @@ static void menu_display_gl_blend_begin(void)
|
|||||||
|
|
||||||
shader_info.data = NULL;
|
shader_info.data = NULL;
|
||||||
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
shader_info.idx = GL_SHADER_STOCK_BLEND;
|
||||||
|
shader_info.set_active = true;
|
||||||
|
|
||||||
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
video_shader_driver_ctl(SHADER_CTL_USE, &shader_info);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user