1
0
mirror of https://github.com/mpv-player/mpv synced 2025-03-19 01:47:38 +00:00
mpv/video/out/opengl/gl_utils.h
wm4 1d0bf4073b vo_opengl: handle probing GL texture formats better
Retrieve the depth for each component and internal texture format
separately. Only for 8 bit per component textures we assume that all
bits are used (or else we would in my opinion create too many probe
textures).

Assuming 8 bit components are always correct also fixes operation in
GLES3, where we assumed that each component had -1 bits depth, and this
all UNORM formats were considered unusable. On GLES, the function to
check the real bit depth is not available. Since GLES has no 16 bit
UNORM textures at all, except with the MPGL_CAP_EXT16 extension, just
drop the special condition for it. (Of course GLES still manages to
introduce a funny special case by allowing GL_LUMINANCE , but not
defining GL_TEXTURE_LUMINANCE_SIZE.)

Should fix #4749.
2017-08-11 21:29:35 +02:00

72 lines
2.2 KiB
C

/*
* This file is part of mpv.
* Parts based on MPlayer code by Reimar Döffinger.
*
* mpv is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* mpv is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with mpv. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef MP_GL_UTILS_
#define MP_GL_UTILS_
#include <math.h>
#include "common.h"
#include "ra.h"
struct mp_log;
void gl_check_error(GL *gl, struct mp_log *log, const char *info);
void gl_upload_tex(GL *gl, GLenum target, GLenum format, GLenum type,
const void *dataptr, int stride,
int x, int y, int w, int h);
mp_image_t *gl_read_fbo_contents(GL *gl, int fbo, int w, int h);
struct gl_vao {
GL *gl;
GLuint vao; // the VAO object, or 0 if unsupported by driver
GLuint buffer; // GL_ARRAY_BUFFER used for the data
int stride; // size of each element (interleaved elements are assumed)
const struct ra_renderpass_input *entries;
int num_entries;
};
void gl_vao_init(struct gl_vao *vao, GL *gl, int stride,
const struct ra_renderpass_input *entries,
int num_entries);
void gl_vao_uninit(struct gl_vao *vao);
void gl_vao_draw_data(struct gl_vao *vao, GLenum prim, void *ptr, size_t num);
void gl_set_debug_logger(GL *gl, struct mp_log *log);
#define NUM_PBO_BUFFERS 3
struct gl_pbo_upload {
GL *gl;
int index;
GLuint buffer;
size_t buffer_size;
};
void gl_pbo_upload_tex(struct gl_pbo_upload *pbo, GL *gl, bool use_pbo,
GLenum target, GLenum format, GLenum type,
int tex_w, int tex_h, const void *dataptr, int stride,
int x, int y, int w, int h);
void gl_pbo_upload_uninit(struct gl_pbo_upload *pbo);
int gl_get_fb_depth(GL *gl, int fbo);
#endif