mirror of
https://github.com/libretro/RetroArch
synced 2025-02-09 09:39:56 +00:00
Some performance fixes (PC doesn't seem to like buffers :P
This commit is contained in:
parent
79905252dd
commit
e703b37501
2
config.h
2
config.h
@ -76,7 +76,7 @@ static const bool force_aspect = true;
|
|||||||
////////////////////////
|
////////////////////////
|
||||||
|
|
||||||
// If you change this to something other than FILTER_NONE, make sure that you build the filter module in config.mk.
|
// If you change this to something other than FILTER_NONE, make sure that you build the filter module in config.mk.
|
||||||
#define VIDEO_FILTER FILTER_NTSC
|
#define VIDEO_FILTER FILTER_NONE
|
||||||
|
|
||||||
|
|
||||||
////////////////
|
////////////////
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
|
|
||||||
BUILD_OPENGL = 1
|
BUILD_OPENGL = 1
|
||||||
BUILD_FILTER = 1
|
BUILD_FILTER = 0
|
||||||
|
|
||||||
BUILD_RSOUND = 0
|
BUILD_RSOUND = 0
|
||||||
BUILD_OSS = 0
|
BUILD_OSS = 0
|
||||||
|
50
gl.c
50
gl.c
@ -24,11 +24,18 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
|
|
||||||
static GLuint texture, pbo, vbo;
|
static GLuint texture;
|
||||||
static uint8_t *gl_buffer, *vertex_buf;
|
static uint8_t *gl_buffer;
|
||||||
static bool keep_aspect = true;
|
static bool keep_aspect = true;
|
||||||
static GLuint tex_filter;
|
static GLuint tex_filter;
|
||||||
|
|
||||||
|
static const GLfloat vertexes[] = {
|
||||||
|
0, 0, 0,
|
||||||
|
0, 1, 0,
|
||||||
|
1, 1, 0,
|
||||||
|
1, 0, 0
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct gl
|
typedef struct gl
|
||||||
{
|
{
|
||||||
bool vsync;
|
bool vsync;
|
||||||
@ -212,11 +219,19 @@ static bool gl_frame(void *data, const uint16_t* frame, int width, int height, i
|
|||||||
(float)width/gl->real_x, 0,
|
(float)width/gl->real_x, 0,
|
||||||
(float)width/gl->real_x, (float)height/gl->real_y
|
(float)width/gl->real_x, (float)height/gl->real_y
|
||||||
};
|
};
|
||||||
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch >> 1);
|
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), tex_coords);
|
||||||
|
|
||||||
|
static int pitch_pixels = 1024;
|
||||||
|
if (pitch_pixels != (pitch >> 1))
|
||||||
|
{
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, pitch >> 1);
|
||||||
|
pitch_pixels = pitch >> 1;
|
||||||
|
}
|
||||||
|
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 128, sizeof(tex_coords), tex_coords);
|
glBufferSubData(GL_ARRAY_BUFFER, 128, sizeof(tex_coords), tex_coords);
|
||||||
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, height * pitch, frame);
|
glBufferSubData(GL_PIXEL_UNPACK_BUFFER, 0, height * pitch, frame);
|
||||||
|
|
||||||
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
|
glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, GL_BGRA, GL_UNSIGNED_SHORT_1_5_5_5_REV, frame);
|
||||||
glDrawArrays(GL_QUADS, 0, 4);
|
glDrawArrays(GL_QUADS, 0, 4);
|
||||||
|
|
||||||
show_fps();
|
show_fps();
|
||||||
@ -230,11 +245,8 @@ static void gl_free(void *data)
|
|||||||
glDisableClientState(GL_VERTEX_ARRAY);
|
glDisableClientState(GL_VERTEX_ARRAY);
|
||||||
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glDeleteTextures(1, &texture);
|
glDeleteTextures(1, &texture);
|
||||||
glDeleteBuffers(1, &pbo);
|
|
||||||
glDeleteBuffers(1, &vbo);
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
free(gl_buffer);
|
free(gl_buffer);
|
||||||
free(vertex_buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void gl_set_nonblock_state(void *data, bool state)
|
static void gl_set_nonblock_state(void *data, bool state)
|
||||||
@ -281,8 +293,7 @@ static void* gl_init(video_info_t *video, const input_driver_t **input)
|
|||||||
gl->vsync = video->vsync;
|
gl->vsync = video->vsync;
|
||||||
|
|
||||||
gl_buffer = calloc(1, 256 * 256 * 2 * video->input_scale * video->input_scale);
|
gl_buffer = calloc(1, 256 * 256 * 2 * video->input_scale * video->input_scale);
|
||||||
vertex_buf = calloc(1, 256);
|
if (!gl_buffer)
|
||||||
if ( !gl_buffer || !vertex_buf )
|
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Couldn't allocate memory :<\n");
|
fprintf(stderr, "Couldn't allocate memory :<\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
@ -303,36 +314,21 @@ static void* gl_init(video_info_t *video, const input_driver_t **input)
|
|||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
glGenTextures(1, &texture);
|
glGenTextures(1, &texture);
|
||||||
glGenBuffers(1, &pbo);
|
|
||||||
glGenBuffers(1, &vbo);
|
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, pbo);
|
|
||||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, 256 * 256 * 2 * video->input_scale * video->input_scale, gl_buffer, GL_STREAM_DRAW);
|
|
||||||
|
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glTexImage2D(GL_TEXTURE_2D,
|
glTexImage2D(GL_TEXTURE_2D,
|
||||||
0, GL_RGB, 256 * video->input_scale, 256 * video->input_scale, 0, GL_BGRA,
|
0, GL_RGB, 256 * video->input_scale, 256 * video->input_scale, 0, GL_BGRA,
|
||||||
GL_UNSIGNED_SHORT_1_5_5_5_REV, NULL);
|
GL_UNSIGNED_SHORT_1_5_5_5_REV, gl_buffer);
|
||||||
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_BORDER);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_BORDER);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, tex_filter);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, tex_filter);
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, tex_filter);
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, tex_filter);
|
||||||
|
glPixelStorei(GL_UNPACK_ROW_LENGTH, 1024);
|
||||||
GLfloat vertexes[] = {
|
|
||||||
0, 0, 0,
|
|
||||||
0, 1, 0,
|
|
||||||
1, 1, 0,
|
|
||||||
1, 0, 0
|
|
||||||
};
|
|
||||||
|
|
||||||
glBindBuffer(GL_ARRAY_BUFFER, vbo);
|
|
||||||
glBufferData(GL_ARRAY_BUFFER, 256, vertex_buf, GL_STREAM_DRAW);
|
|
||||||
glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(vertexes), vertexes);
|
|
||||||
|
|
||||||
glEnableClientState(GL_VERTEX_ARRAY);
|
glEnableClientState(GL_VERTEX_ARRAY);
|
||||||
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
|
||||||
glVertexPointer(3, GL_FLOAT, 3 * sizeof(GLfloat), NULL);
|
glVertexPointer(3, GL_FLOAT, 3 * sizeof(GLfloat), vertexes);
|
||||||
glTexCoordPointer(2, GL_FLOAT, 2 * sizeof(GLfloat), (void*)128);
|
|
||||||
|
|
||||||
*input = &input_glfw;
|
*input = &input_glfw;
|
||||||
return gl;
|
return gl;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user