diff --git a/src/intel/vulkan_hasvk/genX_cmd_video.c b/src/intel/vulkan_hasvk/genX_cmd_video.c index 68878e71a24..93f27eb56db 100644 --- a/src/intel/vulkan_hasvk/genX_cmd_video.c +++ b/src/intel/vulkan_hasvk/genX_cmd_video.c @@ -1191,6 +1191,16 @@ anv_h264_encode_video(struct anv_cmd_buffer *cmd_buffer, { .bo = dst_buffer->address.bo, .offset = bs_abs & ~4095ull }; uint32_t dst_page_off = (uint32_t)(bs_abs & 4095); + /* The PAK gets an access upper bound so it cannot write past the + * allocation. dstBufferRange is what the client declares it needs, and + * clients do leave it at zero -- both the CTS and the Vulkan video sample + * encoder do -- which taken literally bounds the writes to nothing. Use + * what the buffer actually holds instead. */ + uint64_t dst_avail = dst_buffer->vk.size - encode_info->dstBufferOffset; + uint64_t dst_range = encode_info->dstBufferRange; + if (dst_range == 0 || dst_range > dst_avail) + dst_range = dst_avail; + /* Reconstructed picture (pre-deblocking destination). PAK requires a valid * target since PreDeblockingOutputEnable is set, so the setup DPB slot is * mandatory; there is no internal recon-image fallback. */ @@ -1251,7 +1261,7 @@ anv_h264_encode_video(struct anv_cmd_buffer *cmd_buffer, /* Frame-level static state, emitted once before any slice. */ genX(hasvk_mfc_emit_static_state)(cmd_buffer, img, recon_address, sps, pps, dst_address, dst_page_off, - encode_info->dstBufferRange, + dst_range, width_in_mbs, height_in_mbs, is_p, &refs); /* Intra refresh, if the session was created with a mode and this picture --- NOT --- Park edildi. Bkz. docs/vulkan_hasvk.md §10o ve §10q. Ne yapiyor: dstBufferRange sifir geldiginde PAK'in erisim ust sinirini tamponun kalan boyutuna kelepceliyor. Istemciler o alani sifir birakiyor (hem CTS hem Vulkan ornek encoder'i), sifir alininca sinir tabana esitleniyor ve donanima "sifir bayt yazabilirsin" denmis oluyor. Olculen etki (ikisinde de B frame acik, 60 testlik ayri-DPB listesi): yamasiz 48 Pass 0 Fail 0 Warning | bagimsiz istemci BOZUK (64 bayt iniyor) yamali 6 Pass 0 Fail 42 Warning | bagimsiz istemci CALISIYOR (45 dB) Uyarilar fail degil: I frame 29,81 dB, esik 30. Cozulmemis soru: bir erisim bariyerinin kodlama kalitesini nicin 0,2 dB etkiledigi. Anlasilmadan hangisinin dogru oldugu secilemez.