mirror of
https://github.com/jojo61/vdr-plugin-softhdcuvid.git
synced 2023-10-10 13:37:41 +02:00
use pl_vulkan_hold
This commit is contained in:
parent
e14d5b1195
commit
c682b02e85
6
config.h
6
config.h
@ -19,17 +19,17 @@
|
|||||||
#define LIBPLACEBO_CONFIG_H_
|
#define LIBPLACEBO_CONFIG_H_
|
||||||
|
|
||||||
// Increased any time the library changes in a fundamental/major way.
|
// Increased any time the library changes in a fundamental/major way.
|
||||||
#define PL_MAJOR_VER 0
|
#define PL_MAJOR_VER 1
|
||||||
|
|
||||||
// Increased any time the API changes. (Note: Does not reset when PL_MAJOR_VER
|
// Increased any time the API changes. (Note: Does not reset when PL_MAJOR_VER
|
||||||
// is increased)
|
// is increased)
|
||||||
#define PL_API_VER 6
|
#define PL_API_VER 7
|
||||||
|
|
||||||
// Increased any time a fix is made to a given API version.
|
// Increased any time a fix is made to a given API version.
|
||||||
#define PL_FIX_VER 0
|
#define PL_FIX_VER 0
|
||||||
|
|
||||||
// Friendly name (`git describe`) for the overall version of the library
|
// Friendly name (`git describe`) for the overall version of the library
|
||||||
#define PL_VERSION "v0.6.0-44-gaa02132"
|
#define PL_VERSION "v1.7.0-rc1"
|
||||||
|
|
||||||
// Feature tests. These aren't described in further detail, but may be useful
|
// Feature tests. These aren't described in further detail, but may be useful
|
||||||
// for programmers wanting to programmatically check for feature support
|
// for programmers wanting to programmatically check for feature support
|
||||||
|
84
video.c
84
video.c
@ -1678,6 +1678,7 @@ struct priv {
|
|||||||
struct pl_render_target r_target;
|
struct pl_render_target r_target;
|
||||||
struct pl_render_params r_params;
|
struct pl_render_params r_params;
|
||||||
struct pl_tex final_fbo;
|
struct pl_tex final_fbo;
|
||||||
|
VkSemaphore sig_in;
|
||||||
};
|
};
|
||||||
struct priv *p;
|
struct priv *p;
|
||||||
#endif
|
#endif
|
||||||
@ -2535,7 +2536,7 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder * decoder,
|
|||||||
decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 1;
|
decoder->SurfacesNeeded = VIDEO_SURFACES_MAX + 1;
|
||||||
CuvidSetupOutput(decoder);
|
CuvidSetupOutput(decoder);
|
||||||
#ifdef PLACEBO // dont show first frame
|
#ifdef PLACEBO // dont show first frame
|
||||||
decoder->newchannel = 1;
|
// decoder->newchannel = 1;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2551,33 +2552,6 @@ static enum AVPixelFormat Cuvid_get_format(CuvidDecoder * decoder,
|
|||||||
return *fmt_idx;
|
return *fmt_idx;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PLACEBO
|
|
||||||
enum queue_type {
|
|
||||||
GRAPHICS,
|
|
||||||
COMPUTE,
|
|
||||||
TRANSFER,
|
|
||||||
};
|
|
||||||
struct vk_memslice {
|
|
||||||
VkDeviceMemory vkmem;
|
|
||||||
VkDeviceSize offset;
|
|
||||||
VkDeviceSize size;
|
|
||||||
void *priv;
|
|
||||||
};
|
|
||||||
struct pl_tex_vk {
|
|
||||||
bool held;
|
|
||||||
bool external_img;
|
|
||||||
bool may_invalidate;
|
|
||||||
enum queue_type transfer_queue;
|
|
||||||
VkImageType type;
|
|
||||||
VkImage img;
|
|
||||||
struct vk_memslice mem;
|
|
||||||
// for sampling
|
|
||||||
VkImageView view;
|
|
||||||
VkSampler sampler;
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_GRAB
|
#ifdef USE_GRAB
|
||||||
|
|
||||||
int get_RGB(CuvidDecoder *decoder) {
|
int get_RGB(CuvidDecoder *decoder) {
|
||||||
@ -2585,10 +2559,10 @@ int get_RGB(CuvidDecoder *decoder) {
|
|||||||
#ifdef PLACEBO
|
#ifdef PLACEBO
|
||||||
struct pl_render_params render_params = pl_render_default_params;
|
struct pl_render_params render_params = pl_render_default_params;
|
||||||
struct pl_render_target target = {0};
|
struct pl_render_target target = {0};
|
||||||
struct pl_tex_vk *vkp;
|
|
||||||
const struct pl_fmt *fmt;
|
const struct pl_fmt *fmt;
|
||||||
// struct pl_image *img;
|
VkImage Image;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
uint8_t *base;
|
uint8_t *base;
|
||||||
int width;
|
int width;
|
||||||
int height;
|
int height;
|
||||||
@ -2655,7 +2629,6 @@ int get_RGB(CuvidDecoder *decoder) {
|
|||||||
.format = fmt,
|
.format = fmt,
|
||||||
.sampleable = true,
|
.sampleable = true,
|
||||||
.renderable = true,
|
.renderable = true,
|
||||||
// .host_writable = true,
|
|
||||||
.sample_mode = PL_TEX_SAMPLE_LINEAR,
|
.sample_mode = PL_TEX_SAMPLE_LINEAR,
|
||||||
.address_mode = PL_TEX_ADDRESS_CLAMP,
|
.address_mode = PL_TEX_ADDRESS_CLAMP,
|
||||||
});
|
});
|
||||||
@ -2675,17 +2648,21 @@ int get_RGB(CuvidDecoder *decoder) {
|
|||||||
target.color.sig_peak = 0;
|
target.color.sig_peak = 0;
|
||||||
target.color.sig_avg = 0;
|
target.color.sig_avg = 0;
|
||||||
|
|
||||||
// render_params.upscaler = &pl_filter_catmull_rom;
|
Image = pl_vulkan_unwrap(p->gpu, target.fbo,0,0); // GetImage from text
|
||||||
|
|
||||||
if (!pl_render_image(p->renderer, &decoder->pl_images[current], &target, &render_params)) {
|
if (!pl_render_image(p->renderer, &decoder->pl_images[current], &target, &render_params)) {
|
||||||
Fatal(_("Failed rendering frame!\n"));
|
Fatal(_("Failed rendering frame!\n"));
|
||||||
}
|
}
|
||||||
pl_gpu_finish(p->gpu);
|
pl_gpu_finish(p->gpu);
|
||||||
|
|
||||||
vkp = target.fbo->priv;
|
pl_vulkan_hold(p->gpu,target.fbo, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_ACCESS_MEMORY_READ_BIT, p->sig_in); // get it for me
|
||||||
glDrawVkImageNV((GLuint64)(VkImage)vkp->img, 0, 0,0,width, height, 0,0,1,1,0);
|
glWaitVkSemaphoreNV((GLuint64)p->sig_in);
|
||||||
|
|
||||||
|
glDrawVkImageNV((GLuint64)Image, 0, 0,0,width, height, 0,0,1,1,0);
|
||||||
|
pl_vulkan_release(p->gpu, target.fbo,0,0,0); //
|
||||||
pl_tex_destroy(p->gpu,&target.fbo);
|
pl_tex_destroy(p->gpu,&target.fbo);
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (OsdShown && decoder->grab == 2) {
|
if (OsdShown && decoder->grab == 2) {
|
||||||
@ -3273,6 +3250,7 @@ static void CuvidMixVideo(CuvidDecoder * decoder, int level)
|
|||||||
struct pl_swapchain_frame frame;
|
struct pl_swapchain_frame frame;
|
||||||
struct pl_tex_vk *vkp;
|
struct pl_tex_vk *vkp;
|
||||||
const struct pl_fmt *fmt;
|
const struct pl_fmt *fmt;
|
||||||
|
VkImage Image;
|
||||||
struct pl_image *img;
|
struct pl_image *img;
|
||||||
// SDL_Event evt;
|
// SDL_Event evt;
|
||||||
bool ok;
|
bool ok;
|
||||||
@ -3384,7 +3362,7 @@ static void CuvidMixVideo(CuvidDecoder * decoder, int level)
|
|||||||
img->src_rect.x1 = video_src_rect.x1;
|
img->src_rect.x1 = video_src_rect.x1;
|
||||||
img->src_rect.y1 = video_src_rect.y1;
|
img->src_rect.y1 = video_src_rect.y1;
|
||||||
|
|
||||||
fmt = pl_find_named_fmt(p->gpu,"rgba16hf");
|
fmt = pl_find_named_fmt(p->gpu,"rgba8");
|
||||||
target.fbo = pl_tex_create(p->gpu, &(struct pl_tex_params) {
|
target.fbo = pl_tex_create(p->gpu, &(struct pl_tex_params) {
|
||||||
.w = decoder->OutputWidth,
|
.w = decoder->OutputWidth,
|
||||||
.h = decoder->OutputHeight,
|
.h = decoder->OutputHeight,
|
||||||
@ -3403,8 +3381,8 @@ static void CuvidMixVideo(CuvidDecoder * decoder, int level)
|
|||||||
target.repr.sys = PL_COLOR_SYSTEM_RGB;
|
target.repr.sys = PL_COLOR_SYSTEM_RGB;
|
||||||
target.repr.levels = PL_COLOR_LEVELS_PC;
|
target.repr.levels = PL_COLOR_LEVELS_PC;
|
||||||
target.repr.alpha = PL_ALPHA_UNKNOWN;
|
target.repr.alpha = PL_ALPHA_UNKNOWN;
|
||||||
target.repr.bits.sample_depth = 16;
|
target.repr.bits.sample_depth = 8;
|
||||||
target.repr.bits.color_depth = 16;
|
target.repr.bits.color_depth = 8;
|
||||||
target.repr.bits.bit_shift =0;
|
target.repr.bits.bit_shift =0;
|
||||||
target.color.primaries = PL_COLOR_PRIM_BT_709;
|
target.color.primaries = PL_COLOR_PRIM_BT_709;
|
||||||
target.color.transfer = PL_COLOR_TRC_BT_1886;
|
target.color.transfer = PL_COLOR_TRC_BT_1886;
|
||||||
@ -3413,25 +3391,31 @@ static void CuvidMixVideo(CuvidDecoder * decoder, int level)
|
|||||||
target.color.sig_avg = 0;
|
target.color.sig_avg = 0;
|
||||||
|
|
||||||
|
|
||||||
// render_params.upscaler = &pl_filter_catmull_rom;
|
// render_params.upscaler = &pl_filter_ewa_lanczos;
|
||||||
render_params.upscaler = &pl_filter_robidouxsharp;
|
render_params.upscaler = &pl_filter_robidouxsharp;
|
||||||
//printf("Start renderer on frame %d\n",current);
|
|
||||||
|
|
||||||
if (!pl_render_image(p->renderer, &decoder->pl_images[current], &target, &render_params)) {
|
if (!pl_render_image(p->renderer, &decoder->pl_images[current], &target, &render_params)) {
|
||||||
Fatal(_("Failed rendering frame!\n"));
|
Fatal(_("Failed rendering frame!\n"));
|
||||||
}
|
}
|
||||||
pl_gpu_finish(p->gpu);
|
pl_gpu_finish(p->gpu);
|
||||||
//printf("Finish renderer on frame %d with IN: %d-%d on image %d-%d\n",current,w,h,decoder->pl_images[current].width,decoder->pl_images[current].height);
|
|
||||||
vkp = target.fbo->priv;
|
// if (decoder->newchannel == 1 && current == 0)
|
||||||
if (decoder->newchannel == 1 && current == 0)
|
// ;
|
||||||
;
|
// else {
|
||||||
else {
|
Image = pl_vulkan_unwrap(p->gpu, target.fbo,0,0); // GetImage from texture
|
||||||
glDrawVkImageNV((GLuint64)(VkImage)vkp->img, 0, dst_video_rect.x0,dst_video_rect.y0,dst_video_rect.x1, dst_video_rect.y1, 0,0,1,1,0);
|
pl_vulkan_hold(p->gpu,target.fbo, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_ACCESS_MEMORY_READ_BIT, p->sig_in); // get it for me
|
||||||
|
glWaitVkSemaphoreNV((GLuint64)p->sig_in);
|
||||||
|
|
||||||
|
glDrawVkImageNV((GLuint64)Image, 0, dst_video_rect.x0,dst_video_rect.y0,dst_video_rect.x1, dst_video_rect.y1, 0,0,1,1,0);
|
||||||
|
GlxCheck();
|
||||||
|
pl_vulkan_release(p->gpu, target.fbo,0,0,0); // give it back
|
||||||
|
#if 0
|
||||||
}
|
}
|
||||||
if (decoder->newchannel && current)
|
if (decoder->newchannel && current)
|
||||||
decoder->newchannel = 0;
|
decoder->newchannel = 0;
|
||||||
|
#endif
|
||||||
pl_tex_destroy(p->gpu,&target.fbo);
|
pl_tex_destroy(p->gpu,&target.fbo); // destroy texture
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4704,6 +4688,11 @@ static void *VideoDisplayHandlerThread(void *dummy)
|
|||||||
Fatal(_("Failed initializing libplacebo renderer\n"));
|
Fatal(_("Failed initializing libplacebo renderer\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const VkSemaphoreCreateInfo sinfo = {
|
||||||
|
.sType = VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO,
|
||||||
|
};
|
||||||
|
vkCreateSemaphore(p->vk->device, &sinfo, NULL, &p->sig_in);
|
||||||
|
|
||||||
Debug(3,"Placebo: init ok");
|
Debug(3,"Placebo: init ok");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -4733,6 +4722,7 @@ static void *VideoDisplayHandlerThread(void *dummy)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef PLACEBO
|
#ifdef PLACEBO
|
||||||
|
vkDestroySemaphore(p->vk->device, p->sig_in, NULL);
|
||||||
pl_renderer_destroy(&p->renderer);
|
pl_renderer_destroy(&p->renderer);
|
||||||
pl_vulkan_destroy(&p->vk);
|
pl_vulkan_destroy(&p->vk);
|
||||||
pl_context_destroy(&p->ctx);
|
pl_context_destroy(&p->ctx);
|
||||||
|
Loading…
Reference in New Issue
Block a user