| @@ -221,7 +221,7 @@ static int vk_ffv1_start_frame(AVCodecContext *avctx, · 220 unmodified lines |
| 221 | &fp->slice_status_buf, | 221 | &fp->slice_status_buf, |
| 222 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | | 222 | VK_BUFFER_USAGE_STORAGE_BUFFER_BIT | |
| 223 | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, | 223 | VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT, |
| 224 | NULL, f->slice_count*sizeof(uint32_t), | 224 | NULL, 2*f->slice_count*sizeof(uint32_t), |
| 225 | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | | 225 | VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT | |
| 226 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); | 226 | VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT); |
| 227 | if (err < 0) | 227 | if (err < 0) |
| @@ -408,7 +408,7 @@ static int vk_ffv1_end_frame(AVCodecContext *avctx) · 180 unmodified lines |
| 408 | ff_vk_shader_update_desc_buffer(&ctx->s, exec, &fv->setup, | 408 | ff_vk_shader_update_desc_buffer(&ctx->s, exec, &fv->setup, |
| 409 | 1, 2, 0, | 409 | 1, 2, 0, |
| 410 | slice_status, | 410 | slice_status, |
| 411 | 0, f->slice_count*sizeof(uint32_t), | 411 | 0, 2*f->slice_count*sizeof(uint32_t), |
| 412 | VK_FORMAT_UNDEFINED); | 412 | VK_FORMAT_UNDEFINED); |
| 413 | | 413 | |
| 414 | ff_vk_exec_bind_shader(&ctx->s, exec, &fv->setup); | 414 | ff_vk_exec_bind_shader(&ctx->s, exec, &fv->setup); |
| @@ -538,10 +538,15 @@ static int vk_ffv1_end_frame(AVCodecContext *avctx) · 123 unmodified lines |
| 538 | 1, 1, | 538 | 1, 1, |
| 539 | VK_IMAGE_LAYOUT_GENERAL, | 539 | VK_IMAGE_LAYOUT_GENERAL, |
| 540 | VK_NULL_HANDLE); | 540 | VK_NULL_HANDLE); |
| | 541 | ff_vk_shader_update_desc_buffer(&ctx->s, exec, decode_shader, |
| | 542 | 1, 2, 0, |
| | 543 | slice_status, |
| | 544 | 0, 2*f->slice_count*sizeof(uint32_t), |
| | 545 | VK_FORMAT_UNDEFINED); |
| 541 | if (is_rgb) | 546 | if (is_rgb) |
| 542 | ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader, | 547 | ff_vk_shader_update_img_array(&ctx->s, exec, decode_shader, |
| 543 | f->picture.f, vp->view.out, | 548 | f->picture.f, vp->view.out, |
| 544 | 1, 2, | 549 | 1, 3, |
| 545 | VK_IMAGE_LAYOUT_GENERAL, | 550 | VK_IMAGE_LAYOUT_GENERAL, |
| 546 | VK_NULL_HANDLE); | 551 | VK_NULL_HANDLE); |
| 547 | | 552 | |
| @@ -700,8 +705,8 @@ static int init_setup_shader(FFV1Context *f, FFVulkanContext *s, · 152 unmodified lines |
| 700 | .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, | 705 | .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 701 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, | 706 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, |
| 702 | .mem_quali = "writeonly", | 707 | .mem_quali = "writeonly", |
| 703 | .buf_content = "uint32_t slice_crc_mismatch", | 708 | .buf_content = "uint32_t slice_status", |
| 704 | .buf_elems = f->max_slice_count, | 709 | .buf_elems = 2*f->max_slice_count, |
| 705 | }, | 710 | }, |
| 706 | }; | 711 | }; |
| 707 | RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 0, 0)); | 712 | RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3, 0, 0)); |
| @@ -895,6 +900,14 @@ static int init_decode_shader(FFV1Context *f, FFVulkanContext *s, · 187 unmodified lines |
| 895 | .elems = av_pix_fmt_count_planes(dec_frames_ctx->sw_format), | 900 | .elems = av_pix_fmt_count_planes(dec_frames_ctx->sw_format), |
| 896 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, | 901 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, |
| 897 | }, | 902 | }, |
| | 903 | { |
| | 904 | .name = "slice_status_buf", |
| | 905 | .type = VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| | 906 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, |
| | 907 | .mem_quali = "writeonly", |
| | 908 | .buf_content = "uint32_t slice_status", |
| | 909 | .buf_elems = 2*f->max_slice_count, |
| | 910 | }, |
| 898 | { | 911 | { |
| 899 | .name = "dst", | 912 | .name = "dst", |
| 900 | .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, | 913 | .type = VK_DESCRIPTOR_TYPE_STORAGE_IMAGE, |
| @@ -906,7 +919,7 @@ static int init_decode_shader(FFV1Context *f, FFVulkanContext *s, · 5 unmodified lines |
| 906 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, | 919 | .stages = VK_SHADER_STAGE_COMPUTE_BIT, |
| 907 | }, | 920 | }, |
| 908 | }; | 921 | }; |
| 909 | RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 2 + rgb, 0, 0)); | 922 | RET(ff_vk_shader_add_descriptor_set(s, shd, desc_set, 3 + rgb, 0, 0)); |
| 910 | | 923 | |
| 911 | GLSLD(ff_source_ffv1_dec_comp); | 924 | GLSLD(ff_source_ffv1_dec_comp); |
| 912 | | 925 | |
| @@ -1114,22 +1127,35 @@ fail: · 201 unmodified lines |
| 1114 | | 1127 | |
| 1115 | static void vk_ffv1_free_frame_priv(AVRefStructOpaque _hwctx, void *data) | 1128 | static void vk_ffv1_free_frame_priv(AVRefStructOpaque _hwctx, void *data) |
| 1116 | { | 1129 | { |
| 1117 | AVHWDeviceContext *hwctx = _hwctx.nc; | 1130 | AVHWDeviceContext *dev_ctx = _hwctx.nc; |
| | 1131 | AVVulkanDeviceContext *hwctx = dev_ctx->hwctx; |
| 1118 | | 1132 | |
| 1119 | FFv1VulkanDecodePicture *fp = data; | 1133 | FFv1VulkanDecodePicture *fp = data; |
| 1120 | FFVulkanDecodePicture *vp = &fp->vp; | 1134 | FFVulkanDecodePicture *vp = &fp->vp; |
| | 1135 | FFVkBuffer *slice_status = (FFVkBuffer *)fp->slice_status_buf->data; |
| 1121 | | 1136 | |
| 1122 | ff_vk_decode_free_frame(hwctx, vp); | 1137 | ff_vk_decode_free_frame(dev_ctx, vp); |
| | 1138 | |
| | 1139 | /* Invalidate slice/output data if needed */ |
| | 1140 | if (!(slice_status->flags & VK_MEMORY_PROPERTY_HOST_COHERENT_BIT)) { |
| | 1141 | VkMappedMemoryRange invalidate_data = { |
| | 1142 | .sType = VK_STRUCTURE_TYPE_MAPPED_MEMORY_RANGE, |
| | 1143 | .memory = slice_status->mem, |
| | 1144 | .offset = 0, |
| | 1145 | .size = 2*fp->slice_num*sizeof(uint32_t), |
| | 1146 | }; |
| | 1147 | vp->invalidate_memory_ranges(hwctx->act_dev, |
| | 1148 | 1, &invalidate_data); |
| | 1149 | } |
| 1123 | | 1150 | |
| 1124 | if (fp->crc_checked) { | 1151 | for (int i = 0; i < fp->slice_num; i++) { |
| 1125 | FFVkBuffer *slice_status = (FFVkBuffer *)fp->slice_status_buf->data; | 1152 | uint32_t crc_res = 0; |
| 1126 | for (int i = 0; i < fp->slice_num; i++) { | 1153 | if (fp->crc_checked) |
| 1127 | uint32_t crc_res; | 1154 | crc_res = AV_RN32(slice_status->mapped_mem + 2*i*sizeof(uint32_t) + 0); |
| 1128 | crc_res = AV_RN32(slice_status->mapped_mem + i*sizeof(uint32_t)); | 1155 | uint32_t status = AV_RN32(slice_status->mapped_mem + 2*i*sizeof(uint32_t) + 4); |
| 1129 | if (crc_res != 0) | 1156 | if (status || crc_res) |
| 1130 | av_log(hwctx, AV_LOG_ERROR, "CRC mismatch in slice %i, res: 0x%x\n", | 1157 | av_log(dev_ctx, AV_LOG_ERROR, "Slice %i status: 0x%x, CRC 0x%x\n", |
| 1131 | i, crc_res); | 1158 | i, status, crc_res); |
| 1132 | } | | |
| 1133 | } | 1159 | } |
| 1134 | | 1160 | |
| 1135 | av_buffer_unref(&vp->slices_buf); | 1161 | av_buffer_unref(&vp->slices_buf); |