New upstream version 23.2.1+dfsg1

This commit is contained in:
Simon Chopin 2019-07-27 14:47:10 +02:00
parent cdc9a9fc87
commit b14f9eae6d
1017 changed files with 37232 additions and 11111 deletions

View file

@ -57,13 +57,11 @@ bool gl_init_face(GLenum target, GLenum type, uint32_t num_levels,
return success;
}
static bool gl_copy_fbo(struct gs_device *device,
GLuint dst, GLenum dst_target, uint32_t dst_x, uint32_t dst_y,
GLuint src, GLenum src_target, uint32_t src_x, uint32_t src_y,
uint32_t width, uint32_t height,
enum gs_color_format format)
static bool gl_copy_fbo(struct gs_texture *dst, uint32_t dst_x, uint32_t dst_y,
struct gs_texture *src, uint32_t src_x, uint32_t src_y,
uint32_t width, uint32_t height)
{
struct fbo_info *fbo = get_fbo(device, width, height, format);
struct fbo_info *fbo = get_fbo(src, width, height);
GLint last_fbo;
bool success = false;
@ -74,11 +72,11 @@ static bool gl_copy_fbo(struct gs_device *device,
return false;
if (!gl_bind_framebuffer(GL_READ_FRAMEBUFFER, fbo->fbo))
return false;
if (!gl_bind_texture(dst_target, dst))
if (!gl_bind_texture(dst->gl_target, dst->texture))
goto fail;
glFramebufferTexture2D(GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + 0,
src_target, src, 0);
src->gl_target, src->texture, 0);
if (!gl_success("glFrameBufferTexture2D"))
goto fail;
@ -86,7 +84,7 @@ static bool gl_copy_fbo(struct gs_device *device,
if (!gl_success("glReadBuffer"))
goto fail;
glCopyTexSubImage2D(dst_target, 0, dst_x, dst_y, src_x, src_y,
glCopyTexSubImage2D(dst->gl_target, 0, dst_x, dst_y, src_x, src_y,
width, height);
if (!gl_success("glCopyTexSubImage2D"))
goto fail;
@ -94,7 +92,7 @@ static bool gl_copy_fbo(struct gs_device *device,
success = true;
fail:
if (!gl_bind_texture(dst_target, 0))
if (!gl_bind_texture(dst->gl_target, 0))
success = false;
if (!gl_bind_framebuffer(GL_READ_FRAMEBUFFER, last_fbo))
success = false;
@ -102,29 +100,28 @@ fail:
return success;
}
bool gl_copy_texture(struct gs_device *device,
GLuint dst, GLenum dst_target, uint32_t dst_x, uint32_t dst_y,
GLuint src, GLenum src_target, uint32_t src_x, uint32_t src_y,
uint32_t width, uint32_t height, enum gs_color_format format)
bool gl_copy_texture(struct gs_device *device, struct gs_texture *dst,
uint32_t dst_x, uint32_t dst_y, struct gs_texture *src,
uint32_t src_x, uint32_t src_y, uint32_t width,
uint32_t height)
{
bool success = false;
if (device->copy_type == COPY_TYPE_ARB) {
glCopyImageSubData(src, src_target, 0, src_x, src_y, 0,
dst, dst_target, 0, dst_x, dst_y, 0,
width, height, 1);
glCopyImageSubData(src->texture, src->gl_target, 0, src_x,
src_y, 0, dst->texture, dst->gl_target, 0,
dst_x, dst_y, 0, width, height, 1);
success = gl_success("glCopyImageSubData");
} else if (device->copy_type == COPY_TYPE_NV) {
glCopyImageSubDataNV(src, src_target, 0, src_x, src_y, 0,
dst, dst_target, 0, dst_x, dst_y, 0,
width, height, 1);
glCopyImageSubDataNV(src->texture, src->gl_target, 0, src_x,
src_y, 0, dst->texture, dst->gl_target, 0,
dst_x, dst_y, 0, width, height, 1);
success = gl_success("glCopyImageSubDataNV");
} else if (device->copy_type == COPY_TYPE_FBO_BLIT) {
success = gl_copy_fbo(device, dst, dst_target, dst_x, dst_y,
src, src_target, src_x, src_y,
width, height, format);
success = gl_copy_fbo(dst, dst_x, dst_y, src, src_x, src_y,
width, height);
if (!success)
blog(LOG_ERROR, "gl_copy_texture failed");
}

View file

@ -148,11 +148,10 @@ extern bool gl_init_face(GLenum target, GLenum type, uint32_t num_levels,
uint32_t width, uint32_t height, uint32_t size,
const uint8_t ***p_data);
extern bool gl_copy_texture(struct gs_device *device,
GLuint dst, GLenum dst_target, uint32_t dst_x, uint32_t dst_y,
GLuint src, GLenum src_target, uint32_t src_x, uint32_t src_y,
uint32_t width, uint32_t height,
enum gs_color_format format);
extern bool gl_copy_texture(struct gs_device *device, struct gs_texture *dst,
uint32_t dst_x, uint32_t dst_y, struct gs_texture *src,
uint32_t src_x, uint32_t src_y, uint32_t width,
uint32_t height);
extern bool gl_create_buffer(GLenum target, GLuint *buffer, GLsizeiptr size,
const GLvoid *data, GLenum usage);

View file

@ -38,7 +38,7 @@ gs_indexbuffer_t *device_indexbuffer_create(gs_device_t *device,
uint32_t flags)
{
struct gs_index_buffer *ib = bzalloc(sizeof(struct gs_index_buffer));
size_t width = type == GS_UNSIGNED_LONG ? sizeof(long) : sizeof(short);
size_t width = type == GS_UNSIGNED_LONG ? 4 : 2;
ib->device = device;
ib->data = indices;

View file

@ -220,8 +220,20 @@ static bool gl_shader_init(struct gs_shader *shader,
if (!gl_success("glGetShaderiv"))
return false;
if (!compiled)
if (!compiled) {
GLint infoLength = 0;
glGetShaderiv(shader->obj, GL_INFO_LOG_LENGTH, &infoLength);
char *infoLog = malloc(sizeof(char) * infoLength);
GLsizei returnedLength = 0;
glGetShaderInfoLog(shader->obj, infoLength, &returnedLength, infoLog);
blog(LOG_ERROR, "Error compiling shader:\n%s\n", infoLog);
free(infoLog);
success = false;
}
gl_get_shader_info(shader->obj, file, error_string);
@ -455,6 +467,24 @@ static void program_set_param_data(struct gs_program *program,
gl_success("glUniform1iv");
}
} else if (pp->param->type == GS_SHADER_PARAM_INT2) {
if (validate_param(pp, sizeof(int) * 2)) {
glUniform2iv(pp->obj, 1, (int*)array);
gl_success("glUniform2iv");
}
} else if (pp->param->type == GS_SHADER_PARAM_INT3) {
if (validate_param(pp, sizeof(int) * 3)) {
glUniform3iv(pp->obj, 1, (int*)array);
gl_success("glUniform3iv");
}
} else if (pp->param->type == GS_SHADER_PARAM_INT4) {
if (validate_param(pp, sizeof(int) * 4)) {
glUniform4iv(pp->obj, 1, (int*)array);
gl_success("glUniform4iv");
}
} else if (pp->param->type == GS_SHADER_PARAM_FLOAT) {
if (validate_param(pp, sizeof(float))) {
glUniform1fv(pp->obj, 1, (float*)array);
@ -698,6 +728,9 @@ void gs_shader_set_val(gs_sparam_t *param, const void *val, size_t size)
case GS_SHADER_PARAM_FLOAT: expected_size = sizeof(float); break;
case GS_SHADER_PARAM_BOOL:
case GS_SHADER_PARAM_INT: expected_size = sizeof(int); break;
case GS_SHADER_PARAM_INT2: expected_size = sizeof(int) * 2; break;
case GS_SHADER_PARAM_INT3: expected_size = sizeof(int) * 3; break;
case GS_SHADER_PARAM_INT4: expected_size = sizeof(int) * 4; break;
case GS_SHADER_PARAM_VEC2: expected_size = sizeof(float)*2; break;
case GS_SHADER_PARAM_VEC3: expected_size = sizeof(float)*3; break;
case GS_SHADER_PARAM_VEC4: expected_size = sizeof(float)*4; break;

View file

@ -124,7 +124,7 @@ void device_stage_texture(gs_device_t *device, gs_stagesurf_t *dst,
if (!gl_bind_buffer(GL_PIXEL_PACK_BUFFER, dst->pack_buffer))
goto failed;
fbo = get_fbo(device, dst->width, dst->height, dst->format);
fbo = get_fbo(src, dst->width, dst->height);
if (!gl_get_integer_v(GL_READ_FRAMEBUFFER_BINDING, &last_fbo))
goto failed_unbind_buffer;
@ -152,6 +152,8 @@ failed_unbind_buffer:
failed:
if (!success)
blog(LOG_ERROR, "device_stage_texture (GL) failed");
UNUSED_PARAMETER(device);
}
#else

View file

@ -259,16 +259,10 @@ fail:
void device_destroy(gs_device_t *device)
{
if (device) {
size_t i;
for (i = 0; i < device->fbos.num; i++)
fbo_info_destroy(device->fbos.array[i]);
while (device->first_program)
gs_program_destroy(device->first_program);
da_free(device->proj_stack);
da_free(device->fbos);
gl_platform_destroy(device->plat);
bfree(device);
}
@ -658,46 +652,37 @@ static bool get_tex_dimensions(gs_texture_t *tex, uint32_t *width,
* This automatically manages FBOs so that render targets are always given
* an FBO that matches their width/height/format to maximize optimization
*/
struct fbo_info *get_fbo(struct gs_device *device,
uint32_t width, uint32_t height, enum gs_color_format format)
struct fbo_info *get_fbo(gs_texture_t *tex, uint32_t width, uint32_t height)
{
size_t i;
if (tex->fbo && tex->fbo->width == width &&
tex->fbo->height == height &&
tex->fbo->format == tex->format)
return tex->fbo;
GLuint fbo;
struct fbo_info *ptr;
for (i = 0; i < device->fbos.num; i++) {
ptr = device->fbos.array[i];
if (ptr->width == width && ptr->height == height &&
ptr->format == format)
return ptr;
}
glGenFramebuffers(1, &fbo);
if (!gl_success("glGenFramebuffers"))
return NULL;
ptr = bmalloc(sizeof(struct fbo_info));
ptr->fbo = fbo;
ptr->width = width;
ptr->height = height;
ptr->format = format;
ptr->cur_render_target = NULL;
ptr->cur_render_side = 0;
ptr->cur_zstencil_buffer = NULL;
tex->fbo = bmalloc(sizeof(struct fbo_info));
tex->fbo->fbo = fbo;
tex->fbo->width = width;
tex->fbo->height = height;
tex->fbo->format = tex->format;
tex->fbo->cur_render_target = NULL;
tex->fbo->cur_render_side = 0;
tex->fbo->cur_zstencil_buffer = NULL;
da_push_back(device->fbos, &ptr);
return ptr;
return tex->fbo;
}
static inline struct fbo_info *get_fbo_by_tex(struct gs_device *device,
gs_texture_t *tex)
static inline struct fbo_info *get_fbo_by_tex(gs_texture_t *tex)
{
uint32_t width, height;
if (!get_tex_dimensions(tex, &width, &height))
return NULL;
return get_fbo(device, width, height, tex->format);
return get_fbo(tex, width, height);
}
static bool set_current_fbo(gs_device_t *device, struct fbo_info *fbo)
@ -783,7 +768,7 @@ static bool set_target(gs_device_t *device, gs_texture_t *tex, int side,
if (!tex)
return set_current_fbo(device, NULL);
fbo = get_fbo_by_tex(device, tex);
fbo = get_fbo_by_tex(tex);
if (!fbo)
return false;
@ -885,9 +870,8 @@ void device_copy_texture_region(gs_device_t *device,
goto fail;
}
if (!gl_copy_texture(device, dst->texture, dst->gl_target, dst_x, dst_y,
src->texture, src->gl_target, src_x, src_y,
nw, nh, src->format))
if (!gl_copy_texture(device, dst, dst_x, dst_y, src, src_x, src_y, nw,
nh))
goto fail;
return;
@ -1357,6 +1341,22 @@ void device_projection_pop(gs_device_t *device)
da_pop_back(device->proj_stack);
}
void device_debug_marker_begin(gs_device_t *device,
const char *markername, const float color[4])
{
UNUSED_PARAMETER(device);
UNUSED_PARAMETER(color);
glPushDebugGroupKHR(GL_DEBUG_SOURCE_APPLICATION, 0, -1, markername);
}
void device_debug_marker_end(gs_device_t *device)
{
UNUSED_PARAMETER(device);
glPopDebugGroupKHR();
}
void gs_swapchain_destroy(gs_swapchain_t *swapchain)
{
if (!swapchain)

View file

@ -36,7 +36,7 @@ enum copy_type {
COPY_TYPE_FBO_BLIT
};
static inline GLint convert_gs_format(enum gs_color_format format)
static inline GLenum convert_gs_format(enum gs_color_format format)
{
switch (format) {
case GS_A8: return GL_RED;
@ -51,6 +51,7 @@ static inline GLint convert_gs_format(enum gs_color_format format)
case GS_RGBA32F: return GL_RGBA;
case GS_RG16F: return GL_RG;
case GS_RG32F: return GL_RG;
case GS_R8G8: return GL_RG;
case GS_R16F: return GL_RED;
case GS_R32F: return GL_RED;
case GS_DXT1: return GL_RGB;
@ -62,7 +63,7 @@ static inline GLint convert_gs_format(enum gs_color_format format)
return 0;
}
static inline GLint convert_gs_internal_format(enum gs_color_format format)
static inline GLenum convert_gs_internal_format(enum gs_color_format format)
{
switch (format) {
case GS_A8: return GL_R8; /* NOTE: use GL_TEXTURE_SWIZZLE_x */
@ -77,6 +78,7 @@ static inline GLint convert_gs_internal_format(enum gs_color_format format)
case GS_RGBA32F: return GL_RGBA32F;
case GS_RG16F: return GL_RG16F;
case GS_RG32F: return GL_RG32F;
case GS_R8G8: return GL_R16;
case GS_R16F: return GL_R16F;
case GS_R32F: return GL_R32F;
case GS_DXT1: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT;
@ -103,6 +105,7 @@ static inline GLenum get_gl_format_type(enum gs_color_format format)
case GS_RGBA32F: return GL_FLOAT;
case GS_RG16F: return GL_UNSIGNED_SHORT;
case GS_RG32F: return GL_FLOAT;
case GS_R8G8: return GL_UNSIGNED_SHORT;
case GS_R16F: return GL_UNSIGNED_SHORT;
case GS_R32F: return GL_FLOAT;
case GS_DXT1: return GL_UNSIGNED_BYTE;
@ -399,7 +402,7 @@ struct gs_texture {
enum gs_color_format format;
GLenum gl_format;
GLenum gl_target;
GLint gl_internal_format;
GLenum gl_internal_format;
GLenum gl_type;
GLuint texture;
uint32_t levels;
@ -409,6 +412,7 @@ struct gs_texture {
bool gen_mipmaps;
gs_samplerstate_t *cur_sampler;
struct fbo_info *fbo;
};
struct gs_texture_2d {
@ -501,12 +505,11 @@ struct gs_device {
DARRAY(struct matrix4) proj_stack;
DARRAY(struct fbo_info*) fbos;
struct fbo_info *cur_fbo;
};
extern struct fbo_info *get_fbo(struct gs_device *device,
uint32_t width, uint32_t height, enum gs_color_format format);
extern struct fbo_info *get_fbo(gs_texture_t *tex, uint32_t width,
uint32_t height);
extern void gl_update(gs_device_t *device);

View file

@ -138,6 +138,9 @@ void gs_texture_destroy(gs_texture_t *tex)
if (tex->texture)
gl_delete_textures(1, &tex->texture);
if (tex->fbo)
fbo_info_destroy(tex->fbo);
bfree(tex);
}

View file

@ -92,10 +92,11 @@ void gs_cubetexture_destroy(gs_texture_t *tex)
if (!tex)
return;
if (tex->texture) {
glDeleteTextures(1, &tex->texture);
gl_success("glDeleteTextures");
}
if (tex->texture)
gl_delete_textures(1, &tex->texture);
if (tex->fbo)
fbo_info_destroy(tex->fbo);
bfree(tex);
}

View file

@ -532,7 +532,7 @@ void device_enter_context(gs_device_t *device)
hdc = device->cur_swap->wi->hdc;
if (!wgl_make_current(hdc, device->plat->hrc))
blog(LOG_ERROR, "device_load_swapchain (GL) failed");
blog(LOG_ERROR, "device_enter_context (GL) failed");
}
void device_leave_context(gs_device_t *device)