Hello community, here is the log from the commit of package libplacebo for openSUSE:Factory checked in at 2020-05-06 11:05:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/libplacebo (Old) and /work/SRC/openSUSE:Factory/.libplacebo.new.2738 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "libplacebo" Wed May 6 11:05:11 2020 rev:10 rq:800533 version:2.43.1 Changes: -------- --- /work/SRC/openSUSE:Factory/libplacebo/libplacebo.changes 2020-04-23 18:33:07.996397157 +0200 +++ /work/SRC/openSUSE:Factory/.libplacebo.new.2738/libplacebo.changes 2020-05-06 11:05:15.379390061 +0200 @@ -1,0 +2,32 @@ +Wed May 6 04:56:38 UTC 2020 - Mia Herkt <[email protected]> + +- Update to version 2.43.1 +This release backports a number of bug fixes from master affecting +the v2.43.0 release, and also slightly extends the range of +backwards compatibility with respect to vulkan-headers versions. +(This change is not on master, so this can be seen as a +compatibility release) + +Bug fixes: + * fix GLSL version checks when overriding GLSL versions with + pl_shader_params.glsl + * fix minor order-of-operations issue in AV1 grain synthesis + * fix glInvalidate* backwards compatibility issue + * fix compilation with older vulkan-headers (e.g. ubuntu 18.04) + * fix a bug where pl_shader_encode_color sometimes uploaded and + applied an identity matrix unnecessarily + * work around upstream issues with MSL shader compilation by + ensuring all buffer elements are sorted by offset + * fix hypothetical edge case with swapchain image usages + forbidden by the swapchain image format + * fix an issue where blending overlays caused the rest of the + image to be discarded + +Other changes: + * log the vulkan surface selection choices + * log the overall library version on initialization + * add a few more pl_gpu validation checks + * significantly reduce the CPU consumpation of blocking texture + downloads + +------------------------------------------------------------------- Old: ---- libplacebo-v2.43.0.tar.bz2 New: ---- libplacebo-v2.43.1.tar.bz2 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ libplacebo.spec ++++++ --- /var/tmp/diff_new_pack.xaYHLS/_old 2020-05-06 11:05:16.463392388 +0200 +++ /var/tmp/diff_new_pack.xaYHLS/_new 2020-05-06 11:05:16.463392388 +0200 @@ -18,7 +18,7 @@ %define sover 43 Name: libplacebo -Version: 2.43.0 +Version: 2.43.1 Release: 0 Summary: Library for GPU-accelerated video/image rendering primitives License: LGPL-2.1-or-later ++++++ libplacebo-v2.43.0.tar.bz2 -> libplacebo-v2.43.1.tar.bz2 ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/meson.build new/libplacebo-v2.43.1/meson.build --- old/libplacebo-v2.43.0/meson.build 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/meson.build 2020-04-30 20:49:16.000000000 +0200 @@ -2,7 +2,7 @@ license: 'LGPL2.1+', default_options: ['c_std=c99', 'cpp_std=c++11', 'warning_level=2'], meson_version: '>=0.49', - version: '2.43.0', + version: '2.43.1', ) # Version number diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/context.c new/libplacebo-v2.43.1/src/context.c --- old/libplacebo-v2.43.0/src/context.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/context.c 2020-04-30 20:49:16.000000000 +0200 @@ -73,6 +73,7 @@ struct pl_context *ctx = talloc_zero(NULL, struct pl_context); ctx->params = *PL_DEF(params, &pl_context_default_params); + pl_info(ctx, "Initialized libplacebo %s", PL_VERSION); return ctx; } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/dispatch.c new/libplacebo-v2.43.1/src/dispatch.c --- old/libplacebo-v2.43.0/src/dispatch.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/dispatch.c 2020-04-30 20:49:16.000000000 +0200 @@ -217,15 +217,29 @@ } } +static int cmp_buffer_var(const void *pa, const void *pb) +{ + const struct pl_buffer_var * const *a = pa, * const *b = pb; + return PL_CMP((*a)->layout.offset, (*b)->layout.offset); +} + static void add_buffer_vars(struct pl_dispatch *dp, struct bstr *body, - const struct pl_buffer_var *vars, int num) + const struct pl_buffer_var *vars, int num, + void *tmp) { + // Sort buffer vars + const struct pl_buffer_var **sorted_vars = NULL; + TARRAY_RESIZE(tmp, sorted_vars, num); + for (int i = 0; i < num; i++) + sorted_vars[i] = &vars[i]; + qsort(sorted_vars, num, sizeof(sorted_vars[0]), cmp_buffer_var); + ADD(body, "{\n"); for (int i = 0; i < num; i++) { // Add an explicit offset wherever possible if (dp->gpu->glsl.version >= 440) - ADD(body, " layout(offset=%zu) ", vars[i].layout.offset); - add_var(dp, body, &vars[i].var); + ADD(body, " layout(offset=%zu) ", sorted_vars[i]->layout.offset); + add_var(dp, body, &sorted_vars[i]->var); } ADD(body, "};\n"); } @@ -242,7 +256,8 @@ static void generate_shaders(struct pl_dispatch *dp, struct pass *pass, struct pl_pass_params *params, - struct pl_shader *sh, ident_t vert_pos) + struct pl_shader *sh, ident_t vert_pos, + void *tmp) { const struct pl_gpu *gpu = dp->gpu; const struct pl_shader_res *res = pl_shader_finalize(sh); @@ -350,18 +365,24 @@ // Add all of the push constants as their own element if (params->push_constants_size) { - ADD(glsl, "layout(std430, push_constant) uniform PushC {\n"); + // We re-use add_buffer_vars to make sure variables are sorted, this + // is important because the push constants can be out-of-order in + // `pass->vars` + struct pl_buffer_var *pc_bvars = NULL; + int num_bvars = 0; + for (int i = 0; i < res->num_variables; i++) { - struct pl_var *var = &res->variables[i].var; - struct pass_var *pv = &pass->vars[i]; - if (pv->type != PASS_VAR_PUSHC) + if (pass->vars[i].type != PASS_VAR_PUSHC) continue; - // Note: Don't remove this offset, since the push constants - // can be out-of-order in `pass->vars`! - ADD(glsl, " layout(offset=%zu) ", pv->layout.offset); - add_var(dp, glsl, var); + + TARRAY_APPEND(tmp, pc_bvars, num_bvars, (struct pl_buffer_var) { + .var = res->variables[i].var, + .layout = pass->vars[i].layout, + }); } - ADD(glsl, "};\n"); + + ADD(glsl, "layout(std430, push_constant) uniform PushC "); + add_buffer_vars(dp, glsl, pc_bvars, num_bvars, tmp); } // Add all of the required descriptors @@ -419,7 +440,7 @@ ADD(glsl, "layout(std140) "); } ADD(glsl, "uniform %s ", desc->name); - add_buffer_vars(dp, glsl, sd->buffer_vars, sd->num_buffer_vars); + add_buffer_vars(dp, glsl, sd->buffer_vars, sd->num_buffer_vars, tmp); break; case PL_DESC_BUF_STORAGE: @@ -430,7 +451,7 @@ } ADD(glsl, "%s buffer %s ", pl_desc_access_glsl_name(desc->access), desc->name); - add_buffer_vars(dp, glsl, sd->buffer_vars, sd->num_buffer_vars); + add_buffer_vars(dp, glsl, sd->buffer_vars, sd->num_buffer_vars, tmp); break; case PL_DESC_BUF_TEXEL_UNIFORM: @@ -503,7 +524,7 @@ static struct pass *find_pass(struct pl_dispatch *dp, struct pl_shader *sh, const struct pl_tex *target, ident_t vert_pos, - const struct pl_blend_params *blend) + const struct pl_blend_params *blend, bool load) { uint64_t sig = pl_shader_signature(sh); @@ -521,6 +542,7 @@ tfmt = p->pass->params.target_dummy.params.format; bool raster_ok = target->params.format == tfmt; raster_ok &= blend_equal(p->pass->params.blend_params, blend); + raster_ok &= load == p->pass->params.load_target; if (raster_ok) return dp->passes[i]; } @@ -550,6 +572,7 @@ if (params.type == PL_PASS_RASTER) { assert(target); params.target_dummy = *target; + params.load_target = load; // Fill in the vertex attributes array params.num_vertex_attribs = res->num_vertex_attribs; @@ -642,7 +665,7 @@ rparams->push_constants = talloc_zero_size(pass, params.push_constants_size); // Finally, finalize the shaders and create the pass itself - generate_shaders(dp, pass, ¶ms, sh, vert_pos); + generate_shaders(dp, pass, ¶ms, sh, vert_pos, tmp); pass->pass = rparams->pass = pl_pass_create(dp->gpu, ¶ms); if (!pass->pass) { PL_ERR(dp, "Failed creating render pass for dispatch"); @@ -854,7 +877,17 @@ }); } - struct pass *pass = find_pass(dp, sh, target, vert_pos, blend); + // We need to set pl_pass_params.load_target when either blending is + // enabled or we're drawing to some scissored sub-rect of the texture + struct pl_rect2d rc_norm = *rc; + pl_rect2d_normalize(&rc_norm); + rc_norm.x0 = PL_MAX(rc_norm.x0, 0); + rc_norm.y0 = PL_MAX(rc_norm.y0, 0); + rc_norm.x1 = PL_MIN(rc_norm.x1, tpars->w); + rc_norm.y1 = PL_MIN(rc_norm.y1, tpars->h); + bool load = blend || !pl_rect2d_eq(rc_norm, full); + + struct pass *pass = find_pass(dp, sh, target, vert_pos, blend, load); // Silently return on failed passes if (pass->failed) @@ -901,8 +934,7 @@ rparams->compute_groups[2] = 1; } else { // Update the scissors for performance - rparams->scissors = *rc; - pl_rect2d_normalize(&rparams->scissors); + rparams->scissors = rc_norm; } // Dispatch the actual shader @@ -953,7 +985,7 @@ goto error; } - struct pass *pass = find_pass(dp, sh, NULL, NULL, NULL); + struct pass *pass = find_pass(dp, sh, NULL, NULL, NULL, false); // Silently return on failed passes if (pass->failed) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/gpu.c new/libplacebo-v2.43.1/src/gpu.c --- old/libplacebo-v2.43.0/src/gpu.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/gpu.c 2020-04-30 20:49:16.000000000 +0200 @@ -1043,6 +1043,7 @@ require(target_fmt); require(target_fmt->caps & PL_FMT_CAP_RENDERABLE); require(!params->blend_params || target_fmt->caps & PL_FMT_CAP_BLENDABLE); + require(!params->blend_params || params->load_target); break; case PL_PASS_COMPUTE: require(gpu->caps & PL_GPU_CAP_COMPUTE); @@ -1060,7 +1061,14 @@ for (int i = 0; i < params->num_descriptors; i++) { struct pl_desc desc = params->descriptors[i]; require(desc.name); - // TODO: enforce disjoint bindings if possible? + + // enforce disjoint descriptor bindings for each namespace + int namespace = pl_desc_namespace(gpu, desc.type); + for (int j = i+1; j < params->num_descriptors; j++) { + struct pl_desc other = params->descriptors[j]; + require(desc.binding != other.binding || + namespace != pl_desc_namespace(gpu, other.type)); + } } require(params->push_constants_size <= gpu->limits.max_pushc_size); @@ -1332,7 +1340,7 @@ if (pl_buf_poll(gpu, buf, 0)) { PL_TRACE(gpu, "pl_tex_download without buffer: blocking (slow path)"); - while (pl_buf_poll(gpu, buf, 1000000)) ; // 1 ms + while (pl_buf_poll(gpu, buf, UINT64_MAX)) ; } return pl_buf_read(gpu, buf, 0, params->ptr, bufparams.size); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/include/libplacebo/gpu.h new/libplacebo-v2.43.1/src/include/libplacebo/gpu.h --- old/libplacebo-v2.43.0/src/include/libplacebo/gpu.h 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/include/libplacebo/gpu.h 2020-04-30 20:49:16.000000000 +0200 @@ -905,6 +905,8 @@ // If false, the target's existing contents will be discarded before the // pass is run. (Semantically equivalent to calling pl_tex_invalidate // before every pl_pass_run, but slightly more efficient) + // + // Specifying `blend_params` requires `load_target` to be true. bool load_target; }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/opengl/gpu.c new/libplacebo-v2.43.1/src/opengl/gpu.c --- old/libplacebo-v2.43.0/src/opengl/gpu.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/opengl/gpu.c 2020-04-30 20:49:16.000000000 +0200 @@ -29,6 +29,7 @@ int gl_ver; int gles_ver; bool has_stride; + bool has_invalidate; bool has_vao; }; @@ -269,6 +270,7 @@ // Cached some existing capability checks p->has_stride = test_ext(gpu, "GL_EXT_unpack_subimage", 11, 30); p->has_vao = test_ext(gpu, "GL_ARB_vertex_array_object", 30, 0); + p->has_invalidate = test_ext(gpu, "GL_ARB_invalidate_subdata", 43, 30); // We simply don't know, so make up some values gpu->limits.align_tex_xfer_offset = 32; @@ -472,12 +474,13 @@ static bool gl_fb_query(const struct pl_gpu *gpu, int fbo, struct pl_fmt *fmt) { + struct pl_gl *p = TA_PRIV(gpu); if (!test_ext(gpu, "GL_ARB_framebuffer_object", 30, 20)) return true; glBindFramebuffer(GL_FRAMEBUFFER, fbo); - GLenum obj = gpu->glsl.gles ? GL_BACK : GL_BACK_LEFT; + GLenum obj = p->gles_ver ? GL_BACK : GL_BACK_LEFT; if (fbo != 0) obj = GL_COLOR_ATTACHMENT0; @@ -570,11 +573,14 @@ struct pl_gl *p = TA_PRIV(gpu); struct pl_tex_gl *tex_gl = TA_PRIV(tex); - if (tex_gl->wrapped_fb && (p->gl_ver >= 43 || p->gles_ver >= 30)) { + if (!p->has_invalidate) + return; + + if (tex_gl->wrapped_fb) { glBindFramebuffer(GL_FRAMEBUFFER, tex_gl->fbo); glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, (GLenum[]){GL_COLOR}); glBindFramebuffer(GL_FRAMEBUFFER, 0); - } else if (p->gl_ver >= 43) { + } else { glInvalidateTexImage(tex_gl->texture, 0); } @@ -1379,6 +1385,7 @@ { const struct pl_pass *pass = params->pass; struct pl_pass_gl *pass_gl = TA_PRIV(pass); + struct pl_gl *p = TA_PRIV(gpu); glUseProgram(pass_gl->program); @@ -1395,7 +1402,7 @@ case PL_PASS_RASTER: { struct pl_tex_gl *target_gl = TA_PRIV(params->target); glBindFramebuffer(GL_FRAMEBUFFER, target_gl->fbo); - if (!pass->params.load_target) { + if (!pass->params.load_target && p->has_invalidate) { GLenum fb = target_gl->fbo ? GL_COLOR_ATTACHMENT0 : GL_COLOR; glInvalidateFramebuffer(GL_FRAMEBUFFER, 1, &fb); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/renderer.c new/libplacebo-v2.43.1/src/renderer.c --- old/libplacebo-v2.43.0/src/renderer.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/renderer.c 2020-04-30 20:49:16.000000000 +0200 @@ -1171,4 +1171,7 @@ .repr = frame->color_repr, .color = frame->color_space, }; + + if (frame->flipped) + PL_SWAP(out_target->dst_rect.y0, out_target->dst_rect.y1); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/shaders/av1.c new/libplacebo-v2.43.1/src/shaders/av1.c --- old/libplacebo-v2.43.0/src/shaders/av1.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/shaders/av1.c 2020-04-30 20:49:16.000000000 +0200 @@ -489,7 +489,7 @@ int by = ctx->points[i][1]; int dx = ctx->points[i + 1][0] - bx; int dy = ctx->points[i + 1][1] - by; - int delta = dy * ((0xFFFF + (dx >> 1))) / dx; + int delta = dy * ((0x10000 + (dx >> 1)) / dx); for (int x = 0; x < dx; x++) { int v = by + ((x * delta + 0x8000) >> 16); data[bx + x] = v / range; @@ -671,7 +671,13 @@ if (!sh_require(sh, PL_SHADER_SIG_COLOR, 0, 0)) return false; - if (SH_GPU(sh)->glsl.version < 130) { + const struct pl_gpu *gpu = SH_GPU(sh); + if (!gpu) { + PL_ERR(sh, "pl_shader_av1_grain requires a non-NULL pl_gpu!"); + return false; + } + + if (sh_glsl(sh).version < 130) { PL_ERR(sh, "pl_shader_av1_grain requires GLSL >= 130!"); return false; } @@ -746,22 +752,22 @@ // SSBO layout in this case struct pl_var grain_y = pl_var_float("grain_y"); grain_y.dim_a = GRAIN_WIDTH_LUT * GRAIN_HEIGHT_LUT; - ok &= sh_buf_desc_append(obj->tmp, SH_GPU(sh), &obj->desc, + ok &= sh_buf_desc_append(obj->tmp, gpu, &obj->desc, &obj->layout_y, grain_y); struct pl_var grain_cb = pl_var_float("grain_cb"); grain_cb.dim_a = chroma_lut_size; - ok &= sh_buf_desc_append(obj->tmp, SH_GPU(sh), &obj->desc, + ok &= sh_buf_desc_append(obj->tmp, gpu, &obj->desc, &obj->layout_cb, grain_cb); struct pl_var grain_cr = pl_var_float("grain_cr"); grain_cr.dim_a = chroma_lut_size; - ok &= sh_buf_desc_append(obj->tmp, SH_GPU(sh), &obj->desc, + ok &= sh_buf_desc_append(obj->tmp, gpu, &obj->desc, &obj->layout_cr, grain_cr); struct pl_var offsets = pl_var_uint("offsets"); offsets.dim_a = offsets_x * offsets_y; - ok &= sh_buf_desc_append(obj->tmp, SH_GPU(sh), &obj->desc, + ok &= sh_buf_desc_append(obj->tmp, gpu, &obj->desc, &obj->layout_off, offsets); if (!ok) { @@ -793,7 +799,7 @@ if (last_buf && last_buf->params.size > ssbo_params.size) ssbo_params.size = last_buf->params.size; - ssbo = pl_buf_pool_get(SH_GPU(sh), &obj->ssbos, &ssbo_params); + ssbo = pl_buf_pool_get(gpu, &obj->ssbos, &ssbo_params); if (!ssbo) { PL_ERR(sh, "Failed creating/getting SSBO buffer for AV1 grain!"); return false; @@ -808,7 +814,7 @@ if (has_luma) { pl_assert(obj->layout_y.stride == sizeof(float)); - pl_buf_write(SH_GPU(sh), ssbo, obj->layout_y.offset, obj->grain, + pl_buf_write(gpu, ssbo, obj->layout_y.offset, obj->grain, sizeof(obj->grain)); } @@ -816,19 +822,19 @@ generate_grain_uv(&obj->grain[0][0], obj->grain_tmp_uv, obj->grain_tmp_y, PL_CHANNEL_CB, params); pl_assert(obj->layout_cb.stride == sizeof(float)); - pl_buf_write(SH_GPU(sh), ssbo, obj->layout_cb.offset, obj->grain, + pl_buf_write(gpu, ssbo, obj->layout_cb.offset, obj->grain, sizeof(float) * chroma_lut_size); generate_grain_uv(&obj->grain[0][0], obj->grain_tmp_uv, obj->grain_tmp_y, PL_CHANNEL_CR, params); pl_assert(obj->layout_cr.stride == sizeof(float)); - pl_buf_write(SH_GPU(sh), ssbo, obj->layout_cr.offset, obj->grain, + pl_buf_write(gpu, ssbo, obj->layout_cr.offset, obj->grain, sizeof(float) * chroma_lut_size); } generate_offsets(obj->offsets, offsets_x, offsets_y, data); pl_assert(obj->layout_off.stride == sizeof(uint32_t)); - pl_buf_write(SH_GPU(sh), ssbo, obj->layout_off.offset, obj->offsets, + pl_buf_write(gpu, ssbo, obj->layout_off.offset, obj->offsets, obj->num_offsets * obj->layout_off.stride); obj->data = *data; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/shaders/colorspace.c new/libplacebo-v2.43.1/src/shaders/colorspace.c --- old/libplacebo-v2.43.0/src/shaders/colorspace.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/shaders/colorspace.c 2020-04-30 20:49:16.000000000 +0200 @@ -51,7 +51,7 @@ }); ident_t cmat_c = sh_var(sh, (struct pl_shader_var) { - .var = pl_var_vec3("cmat_m"), + .var = pl_var_vec3("cmat_c"), .data = tr.c, }); @@ -151,16 +151,6 @@ void pl_shader_encode_color(struct pl_shader *sh, const struct pl_color_repr *repr) { - // Since this is a relatively rare operation, bypass it as much as possible - bool skip = true; - skip &= PL_DEF(repr->sys, PL_COLOR_SYSTEM_RGB) == PL_COLOR_SYSTEM_RGB; - skip &= PL_DEF(repr->levels, PL_COLOR_LEVELS_PC) == PL_COLOR_LEVELS_PC; - skip &= PL_DEF(repr->alpha, PL_ALPHA_PREMULTIPLIED) == PL_ALPHA_PREMULTIPLIED; - skip &= repr->bits.sample_depth == repr->bits.color_depth; - skip &= !repr->bits.bit_shift; - if (skip) - return; - if (!sh_require(sh, PL_SHADER_SIG_COLOR, 0, 0)) return; @@ -217,29 +207,41 @@ break; } - struct pl_color_repr copy = *repr; - float xyzscale = (repr->sys == PL_COLOR_SYSTEM_XYZ) - ? pl_color_repr_normalize(©) - : 0.0; - - struct pl_transform3x3 tr = pl_color_repr_decode(©, NULL); - pl_transform3x3_invert(&tr); - - ident_t cmat = sh_var(sh, (struct pl_shader_var) { - .var = pl_var_mat3("cmat"), - .data = PL_TRANSPOSE_3X3(tr.mat.m), - }); + // Since this is a relatively rare operation, bypass it as much as possible + bool skip = true; + skip &= PL_DEF(repr->sys, PL_COLOR_SYSTEM_RGB) == PL_COLOR_SYSTEM_RGB; + skip &= PL_DEF(repr->levels, PL_COLOR_LEVELS_PC) == PL_COLOR_LEVELS_PC; + skip &= PL_DEF(repr->bits.sample_depth, 8) == PL_DEF(repr->bits.color_depth, 8); + skip &= !repr->bits.bit_shift; - ident_t cmat_c = sh_var(sh, (struct pl_shader_var) { - .var = pl_var_vec3("cmat_m"), - .data = tr.c, - }); + if (!skip) { + struct pl_color_repr copy = *repr; + float xyzscale = (repr->sys == PL_COLOR_SYSTEM_XYZ) + ? pl_color_repr_normalize(©) + : 0.0; + + struct pl_transform3x3 tr = pl_color_repr_decode(©, NULL); + pl_transform3x3_invert(&tr); + + ident_t cmat = sh_var(sh, (struct pl_shader_var) { + .var = pl_var_mat3("cmat"), + .data = PL_TRANSPOSE_3X3(tr.mat.m), + }); + + ident_t cmat_c = sh_var(sh, (struct pl_shader_var) { + .var = pl_var_vec3("cmat_c"), + .data = tr.c, + }); + + GLSL("color.rgb = %s * color.rgb + %s;\n", cmat, cmat_c); + + if (repr->sys == PL_COLOR_SYSTEM_XYZ) + GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.6)) * vec3(1.0/%f); \n", xyzscale); + } - GLSL("color.rgb = %s * color.rgb + %s;\n", cmat, cmat_c); - if (repr->sys == PL_COLOR_SYSTEM_XYZ) - GLSL("color.rgb = pow(color.rgb, vec3(1.0/2.6)) * vec3(1.0/%f); \n", xyzscale); if (repr->alpha == PL_ALPHA_INDEPENDENT) GLSL("color.rgb /= vec3(max(color.a, 1e-6));\n"); + GLSL("}\n"); } @@ -600,8 +602,6 @@ struct pl_shader_obj **state, const struct pl_peak_detect_params *params) { - const struct pl_gpu *gpu = SH_GPU(sh); - params = PL_DEF(params, &pl_peak_detect_default_params); if (!sh_require(sh, PL_SHADER_SIG_COLOR, 0, 0)) return false; @@ -611,7 +611,7 @@ return false; } - if (gpu->glsl.version < 130) { + if (sh_glsl(sh).version < 130) { // uint was added in GLSL 130 PL_ERR(sh, "HDR peak detection requires GLSL >= 130!"); return false; @@ -623,6 +623,7 @@ if (!obj) return false; + const struct pl_gpu *gpu = SH_GPU(sh); obj->gpu = gpu; if (!obj->buf) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/vulkan/context.c new/libplacebo-v2.43.1/src/vulkan/context.c --- old/libplacebo-v2.43.0/src/vulkan/context.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/vulkan/context.c 2020-04-30 20:49:16.000000000 +0200 @@ -125,11 +125,13 @@ {0}, }, #endif +#ifdef VK_EXT_pci_bus_info }, { .name = VK_EXT_PCI_BUS_INFO_EXTENSION_NAME, .funs = (struct vk_fun[]) { {0} }, +#endif } }; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/vulkan/gpu.c new/libplacebo-v2.43.1/src/vulkan/gpu.c --- old/libplacebo-v2.43.0/src/vulkan/gpu.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/vulkan/gpu.c 2020-04-30 20:49:16.000000000 +0200 @@ -361,13 +361,8 @@ gpu->import_caps.sync = 0; // Not supported yet if (pl_gpu_supports_interop(gpu)) { - VkPhysicalDevicePCIBusInfoPropertiesEXT pci_props = { - .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT, - }; - VkPhysicalDeviceIDPropertiesKHR id_props = { .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_ID_PROPERTIES_KHR, - .pNext = &pci_props, }; VkPhysicalDeviceProperties2KHR props = { @@ -375,14 +370,24 @@ .pNext = &id_props, }; +#ifdef VK_EXT_pci_bus_info + VkPhysicalDevicePCIBusInfoPropertiesEXT pci_props = { + .sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT, + }; + + id_props.pNext = &pci_props, +#endif + vk->GetPhysicalDeviceProperties2KHR(vk->physd, &props); assert(sizeof(gpu->uuid) == VK_UUID_SIZE); memcpy(gpu->uuid, id_props.deviceUUID, sizeof(gpu->uuid)); +#ifdef VK_EXT_pci_bus_info gpu->pci.domain = pci_props.pciDomain; gpu->pci.bus = pci_props.pciBus; gpu->pci.device = pci_props.pciDevice; gpu->pci.function = pci_props.pciFunction; +#endif } if (vk->CmdPushDescriptorSetKHR) { diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/libplacebo-v2.43.0/src/vulkan/swapchain.c new/libplacebo-v2.43.1/src/vulkan/swapchain.c --- old/libplacebo-v2.43.0/src/vulkan/swapchain.c 2020-04-22 08:53:22.000000000 +0200 +++ new/libplacebo-v2.43.1/src/vulkan/swapchain.c 2020-04-30 20:49:16.000000000 +0200 @@ -258,6 +258,9 @@ if (!pick_surf_format(gpu, vk, params->surface, &sfmt, &csp)) return NULL; + PL_DEBUG(gpu, "Picked surface format 0x%x, space 0x%x", + sfmt.format, sfmt.colorSpace); + struct pl_swapchain *sw = talloc_zero_priv(NULL, struct pl_swapchain, struct priv); sw->impl = &vulkan_swapchain; sw->ctx = vk->ctx; @@ -370,6 +373,8 @@ if (caps.supportedCompositeAlpha & alphaModes[i].vk_mode) { info->compositeAlpha = alphaModes[i].vk_mode; p->color_repr.alpha = alphaModes[i].pl_mode; + PL_DEBUG(vk, "Requested alpha compositing mode: 0x%x", + info->compositeAlpha); break; } } @@ -391,6 +396,7 @@ for (int i = 0; i < PL_ARRAY_SIZE(rotModes); i++) { if (caps.supportedTransforms & rotModes[i]) { info->preTransform = rotModes[i]; + PL_DEBUG(vk, "Requested surface transform: 0x%x", info->preTransform); break; } } @@ -435,20 +441,10 @@ h = PL_MIN(PL_MAX(h, caps.minImageExtent.height), caps.maxImageExtent.height); info->imageExtent = (VkExtent2D) { w, h }; - // We just request whatever usage we can, and let the pl_vk decide what - // pl_tex_params that translates to. This makes the images as flexible - // as possible. However, require at least blitting and rendering. - VkImageUsageFlags required_flags = 0; - required_flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; - required_flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; - if ((caps.supportedUsageFlags & required_flags) != required_flags) { - PL_ERR(vk, "The swapchain doesn't support rendering and blitting!"); - goto error; - } - - - // We need to intersect the swapchain supported usage flags with the - // format supported usage flags + // We just request whatever we can, and let the pl_vk decide what + // pl_tex_params that translates to. This makes the image as flexible as + // possible. That said, we still need to intersect the swapchain supported + // usage flags with the format supported usage flags info->imageUsage = caps.supportedUsageFlags; VkFormatProperties fmtprop; vk->GetPhysicalDeviceFormatProperties(vk->physd, info->imageFormat, &fmtprop); @@ -457,9 +453,21 @@ if (!((fmtprop.optimalTilingFeatures & VK_FORMAT_FEATURE_##feature##_BIT))) \ info->imageUsage &= ~VK_IMAGE_USAGE_##usage##_BIT + CHECK(TRANSFER_SRC, TRANSFER_SRC); + CHECK(TRANSFER_DST, TRANSFER_DST); CHECK(SAMPLED, SAMPLED_IMAGE); - CHECK(COLOR_ATTACHMENT, COLOR_ATTACHMENT); CHECK(STORAGE, STORAGE_IMAGE); + CHECK(COLOR_ATTACHMENT, COLOR_ATTACHMENT); + + // Make sure we support at least rendering and blitting! + VkImageUsageFlags required_flags = 0; + required_flags |= VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT; + required_flags |= VK_IMAGE_USAGE_TRANSFER_DST_BIT; + if ((info->imageUsage & required_flags) != required_flags) { + PL_ERR(vk, "The swapchain doesn't support rendering and blitting!"); + goto error; + } + return true; error:
