forge
Explore
Log in

Don't you dare go Hollow

Vk encode: EncoderConfig::quality picks the Vulkan quality level (1 = driver best, each step faster; default level 1, RADV balance), session parameters created at that level; content hint DESKTOP; AV1 enables CDEF with four strength candidates per 64x64 block. Decode RGB upsamples chroma bilinearly, left-sited and row-centred as the RGB->NV12 shader writes it (GPU shader and ec-dsp i420_to_packed stay bit-identical)

Browse files at this commit

9876fb67e5024ad21452acda9fd1adc97a7066abAhmet Kaan GümüşParent: 511a95b
crates/ec-dsp/src/rgb.rsmodified+22 -3
@@ -125,10 +125,9 @@ pub fn i420_to_packed(
125125 let mut sum = [0u32; 3];
126126 for sy in y0..y1 {
127127 for sx in x0..x1 {
128- let c = (sy / 2) * cw + sx / 2;
129128 let yy = i32::from(y[sy * w + sx]) - 16;
130- let uu = i32::from(u[c]) - 128;
131- let vv = i32::from(v[c]) - 128;
129+ let uu = chroma_at(u, (cw, h / 2), sx, sy) - 128;
130+ let vv = chroma_at(v, (cw, h / 2), sx, sy) - 128;
132131 let r = ((k.ky * yy + k.rv * vv + 128) >> 8).clamp(0, 255);
133132 let g = ((k.ky * yy + k.gu * uu + k.gv * vv + 128) >> 8).clamp(0, 255);
134133 let b = ((k.ky * yy + k.bu * uu + 128) >> 8).clamp(0, 255);
@@ -147,6 +146,26 @@ pub fn i420_to_packed(
147146 out
148147 }
149148
149+/// Bilinear 4:2:0 chroma at luma `(x, y)`: samples left-sited on even columns and centred between row pairs, as the RGB to I420 conversions write them.
150+fn chroma_at(plane: &[u8], (cw, ch): (usize, usize), x: usize, y: usize) -> i32 {
151+ let j = x / 2;
152+ let row = |r: usize| {
153+ let a = i32::from(plane[r * cw + j]);
154+ if x % 2 == 0 {
155+ 2 * a
156+ } else {
157+ a + i32::from(plane[r * cw + (j + 1).min(cw - 1)])
158+ }
159+ };
160+ let k = y / 2;
161+ let s = if y % 2 == 0 {
162+ row(k.saturating_sub(1)) + 3 * row(k)
163+ } else {
164+ 3 * row(k) + row((k + 1).min(ch - 1))
165+ };
166+ (s + 4) >> 3
167+}
168+
150169 fn footprint(o: usize, n_in: usize, n_out: usize) -> (usize, usize) {
151170 (o * n_in / n_out, ((o + 1) * n_in).div_ceil(n_out))
152171 }
crates/ec-hw/src/hw.rsmodified+3 -0
@@ -931,6 +931,7 @@ fn open_vk(config: EncoderConfig) -> Result<VkEncoder> {
931931 profile: vk_h264_profile(config.h264_profile),
932932 level,
933933 colour,
934+ quality: config.quality,
934935 },
935936 )?),
936937 EncCodec::H265 => VkEncoder::H265(ec_vk::H265Encoder::new(
@@ -944,6 +945,7 @@ fn open_vk(config: EncoderConfig) -> Result<VkEncoder> {
944945 bit_depth: config.bit_depth,
945946 level,
946947 colour,
948+ quality: config.quality,
947949 },
948950 )?),
949951 EncCodec::Av1 => VkEncoder::Av1(ec_vk::Av1Encoder::new(
@@ -957,6 +959,7 @@ fn open_vk(config: EncoderConfig) -> Result<VkEncoder> {
957959 bit_depth: config.bit_depth,
958960 level,
959961 colour,
962+ quality: config.quality,
960963 },
961964 )?),
962965 })
crates/ec-hw/src/types.rsmodified+3 -1
@@ -106,7 +106,9 @@ pub struct EncoderConfig {
106106 pub h264_profile: H264Profile,
107107 /// Rate control mode.
108108 pub rate_control: RateControlMode,
109- /// Driver quality/speed level, 1 (best quality) upwards; 0 = driver default.
109+ /// Driver quality/speed level, 1 (best quality) upwards, each step one level
110+ /// faster; 0 = default. On Vulkan the default is the second-fastest level,
111+ /// which costs RADV about 0.3 ms over the fastest.
110112 pub quality: u32,
111113 /// The colour description to write into the VUI, or `None` to leave it
112114 /// unsignalled (`video_signal_type_present_flag = 0`) as before.
crates/ec-vk/examples/av1_encode.rsmodified+1 -0
@@ -38,6 +38,7 @@ fn main() {
3838 },
3939 bit_depth: 8,
4040 colour: None,
41+ quality: 0,
4142 };
4243 let mut encoder = Av1Encoder::new(&gpu, cfg).expect("create encoder");
4344
crates/ec-vk/examples/h264_encode.rsmodified+1 -0
@@ -30,6 +30,7 @@ fn main() {
3030 gop_size: 30,
3131 profile: H264Profile::High,
3232 colour: None,
33+ quality: 0,
3334 rate: match std::env::args().nth(2) {
3435 Some(b) => RateControl::Cbr {
3536 bitrate: b.parse().expect("bitrate"),
crates/ec-vk/examples/h265_encode.rsmodified+1 -0
@@ -37,6 +37,7 @@ fn main() {
3737 },
3838 bit_depth: 8,
3939 colour: None,
40+ quality: 0,
4041 };
4142 let mut encoder = H265Encoder::new(&gpu, cfg).expect("create encoder");
4243 let mut out = Vec::new();
crates/ec-vk/src/av1.rsmodified+3 -0
@@ -26,6 +26,8 @@ pub struct Av1EncoderConfig {
2626 pub level: u8,
2727 /// Colour config of the sequence header, or none.
2828 pub colour: Option<Colour>,
29+ /// Speed/quality trade-off as in ec-hw's `EncoderConfig::quality`: 0 for the default level, 1 for the driver's best, each step up one level faster.
30+ pub quality: u32,
2931 }
3032
3133 /// AV1 encoder: order hint, DPB slot and LAST reference bookkeeping over [`Av1EncodeSession`].
@@ -59,6 +61,7 @@ impl Av1Encoder {
5961 bit_depth: cfg.bit_depth,
6062 level: cfg.level,
6163 colour: cfg.colour,
64+ quality: cfg.quality,
6265 },
6366 )?;
6467 let sequence_header = session.sequence_header();
crates/ec-vk/src/h265.rsmodified+3 -0
@@ -24,6 +24,8 @@ pub struct H265EncoderConfig {
2424 pub level: u8,
2525 /// Colour description for the VUI, or none.
2626 pub colour: Option<Colour>,
27+ /// Speed/quality trade-off as in ec-hw's `EncoderConfig::quality`: 0 for the default level, 1 for the driver's best, each step up one level faster.
28+ pub quality: u32,
2729 }
2830
2931 /// H.265 encoder: GOP, POC and DPB slot bookkeeping over [`H265EncodeSession`].
@@ -57,6 +59,7 @@ impl H265Encoder {
5759 bit_depth: cfg.bit_depth,
5860 level: cfg.level,
5961 colour: cfg.colour,
62+ quality: cfg.quality,
6063 },
6164 )?;
6265 let parameter_sets = session.parameter_sets()?;
crates/ec-vk/src/lib.rsmodified+3 -0
@@ -47,6 +47,8 @@ pub struct H264EncoderConfig {
4747 pub level: u8,
4848 /// Colour description for the VUI, or none.
4949 pub colour: Option<Colour>,
50+ /// Speed/quality trade-off as in ec-hw's `EncoderConfig::quality`: 0 for the default level, 1 for the driver's best, each step up one level faster.
51+ pub quality: u32,
5052 }
5153
5254 /// One coded frame, Annex-B. Keyframes carry SPS and PPS before the slice.
@@ -124,6 +126,7 @@ impl H264Encoder {
124126 profile: cfg.profile,
125127 level: cfg.level,
126128 colour: cfg.colour,
129+ quality: cfg.quality,
127130 },
128131 )?;
129132 let parameter_sets = session.parameter_sets()?;
shims/vk-video-ffi/examples/dmabuf_smoke.rsmodified+3 -0
@@ -90,6 +90,7 @@ impl Encode for H264EncodeSession {
9090 profile: H264Profile::High,
9191 level: 62,
9292 colour: None,
93+ quality: 0,
9394 };
9495 H264EncodeSession::new(gpu, &cfg)
9596 }
@@ -133,6 +134,7 @@ impl Encode for H265EncodeSession {
133134 bit_depth: bits,
134135 level: 186,
135136 colour: None,
137+ quality: 0,
136138 };
137139 H265EncodeSession::new(gpu, &cfg)
138140 }
@@ -179,6 +181,7 @@ impl Encode for Av1EncodeSession {
179181 bit_depth: bits,
180182 level: 23,
181183 colour: None,
184+ quality: 0,
182185 };
183186 Av1EncodeSession::new(gpu, &cfg)
184187 }
shims/vk-video-ffi/shaders/nv12_to_rgb.compmodified+22 -3
@@ -32,11 +32,30 @@ uint sample_at(uint e) {
3232 return byte_at(e * pc.bytes + pc.bytes - 1u);
3333 }
3434
35+ivec2 chroma_row(uint r, uint x) {
36+ uint j = x / 2u;
37+ uint c = pc.w * pc.h + r * pc.w + 2u * j;
38+ ivec2 a = ivec2(int(sample_at(c)), int(sample_at(c + 1u)));
39+ if ((x & 1u) == 0u) {
40+ return 2 * a;
41+ }
42+ uint n = pc.w * pc.h + r * pc.w + 2u * min(j + 1u, pc.w / 2u - 1u);
43+ return a + ivec2(int(sample_at(n)), int(sample_at(n + 1u)));
44+}
45+
46+ivec2 chroma_at(uint x, uint y) {
47+ uint k = y / 2u;
48+ ivec2 s = (y & 1u) == 0u
49+ ? chroma_row(k == 0u ? 0u : k - 1u, x) + 3 * chroma_row(k, x)
50+ : 3 * chroma_row(k, x) + chroma_row(min(k + 1u, pc.h / 2u - 1u), x);
51+ return ((s + 4) >> 3) - 128;
52+}
53+
3554 ivec3 rgb_at(uint x, uint y) {
3655 int yy = int(sample_at(y * pc.w + x)) - 16;
37- uint c = pc.w * pc.h + (y / 2u) * pc.w + 2u * (x / 2u);
38- int u = int(sample_at(c)) - 128;
39- int v = int(sample_at(c + 1u)) - 128;
56+ ivec2 uv = chroma_at(x, y);
57+ int u = uv.x;
58+ int v = uv.y;
4059 int r = (pc.ky * yy + pc.rv * v + 128) >> 8;
4160 int g = (pc.ky * yy + pc.gu * u + pc.gv * v + 128) >> 8;
4261 int b = (pc.ky * yy + pc.bu * u + 128) >> 8;
shims/vk-video-ffi/shaders/nv12_to_rgb.spvmodified+0 -0

Binary file changed

shims/vk-video-ffi/src/av1_encode.rsmodified+28 -3
@@ -7,6 +7,7 @@ use vulkanalia::vk::KhrVideoQueueExtensionDeviceCommands;
77 use crate::dmabuf::DmaBuf;
88 use crate::rgb_convert::{Input, check_rgb};
99 use crate::session::{
10+ quality_level,
1011 DPB_SLOTS, Encoder, VideoSession, component_bit_depth, picture_resource, validate_rate,
1112 video_caps, vk, zeroed,
1213 };
@@ -32,6 +33,8 @@ pub struct Av1EncodeConfig {
3233 pub level: u8,
3334 /// Colour config of the sequence header, or none (unspecified).
3435 pub colour: Option<Colour>,
36+ /// Speed/quality trade-off as in ec-hw's `EncoderConfig::quality`: 0 for the default level, 1 for the driver's best, each step up one level faster.
37+ pub quality: u32,
3538 }
3639
3740 /// One picture to encode.
@@ -61,6 +64,7 @@ struct Caps {
6164 max_extent: vk::Extent2D,
6265 size_align: u64,
6366 rc_modes: vk::VideoEncodeRateControlModeFlagsKHR,
67+ quality_levels: u32,
6468 single_ref: bool,
6569 sb64: bool,
6670 max_level: vk::video::StdVideoAV1Level,
@@ -87,7 +91,7 @@ impl Profile {
8791 .build(),
8892 usage: vk::VideoEncodeUsageInfoKHR::builder()
8993 .video_usage_hints(vk::VideoEncodeUsageFlagsKHR::STREAMING)
90- .video_content_hints(vk::VideoEncodeContentFlagsKHR::CAMERA)
94+ .video_content_hints(vk::VideoEncodeContentFlagsKHR::DESKTOP)
9195 .tuning_mode(vk::VideoEncodeTuningModeKHR::LOW_LATENCY)
9296 .build(),
9397 });
@@ -215,6 +219,7 @@ impl Av1EncodeSession {
215219 (cfg.rate, cfg.fps),
216220 caps.size_align,
217221 )?;
222+ enc.vs.quality_level = quality_level(cfg.quality, caps.quality_levels);
218223 let params = create_parameters(&enc.vs, extent, sb128, cfg, level)?;
219224 enc.vs.set_params(params);
220225 Ok(Av1EncodeSession {
@@ -374,7 +379,7 @@ impl Av1EncodeSession {
374379 quant.base_q_idx = q_index(self.enc.rate) as u8;
375380 let mut loop_filter = zeroed::<vk::video::StdVideoAV1LoopFilter>();
376381 loop_filter.loop_filter_level = [1; 4];
377- let cdef = zeroed::<vk::video::StdVideoAV1CDEF>();
382+ let cdef = cdef_params();
378383 let restoration = zeroed::<vk::video::StdVideoAV1LoopRestoration>();
379384 let motion = zeroed::<vk::video::StdVideoAV1GlobalMotion>();
380385 std_pic.pTileInfo = &tile;
@@ -536,6 +541,7 @@ fn create_parameters(
536541 seq.max_frame_height_minus_1 = (extent.height - 1) as u16;
537542 seq.order_hint_bits_minus_1 = 7;
538543 seq.seq_force_integer_mv = vk::video::STD_VIDEO_AV1_SELECT_INTEGER_MV as u8;
544+ seq.flags.set_enable_cdef(1);
539545 seq.pColorConfig = &color;
540546
541547 let mut op = zeroed::<vk::video::StdVideoEncodeAV1OperatingPointInfo>();
@@ -547,8 +553,12 @@ fn create_parameters(
547553 std_operating_points: &op,
548554 ..Default::default()
549555 };
556+ let mut quality = vk::VideoEncodeQualityLevelInfoKHR::builder()
557+ .quality_level(vs.quality_level)
558+ .build();
550559 let info = vk::VideoSessionParametersCreateInfoKHR::builder()
551560 .video_session(vs.session)
561+ .push_next(&mut quality)
552562 .push_next(&mut av1)
553563 .build();
554564 unsafe {
@@ -643,7 +653,7 @@ fn sequence_header_obu(
643653 b.put(0, 1);
644654 b.put(7, 3);
645655 b.put(0, 1);
646- b.put(0, 1);
656+ b.put(1, 1);
647657 b.put(0, 1);
648658 b.put((bit_depth == 10) as u32, 1);
649659 b.put(0, 1);
@@ -712,6 +722,7 @@ fn query_caps(gpu: &Gpu, profile: &vk::VideoProfileInfoKHR) -> Result<Caps, Erro
712722 max_extent: caps.max_coded_extent,
713723 size_align: caps.min_bitstream_buffer_size_alignment,
714724 rc_modes: encode.rate_control_modes,
725+ quality_levels: encode.max_quality_levels,
715726 single_ref: av1.max_single_reference_count > 0 && av1.single_reference_name_mask & 1 != 0,
716727 sb64: av1.superblock_sizes.contains(
717728 vk::VideoEncodeAV1SuperblockSizeFlagsKHR::VIDEO_ENCODE_AV1_SUPERBLOCK_SIZE_64,
@@ -730,3 +741,17 @@ fn av1_level(
730741 let level = vk::video::StdVideoAV1Level(i32::from(idx));
731742 Ok(if level.0 > driver_max.0 { driver_max } else { level })
732743 }
744+
745+/// CDEF candidates the encoder picks from per 64x64 block: a main strength, off for fine texture, half and double.
746+fn cdef_params() -> vk::video::StdVideoAV1CDEF {
747+ let mut cdef = zeroed::<vk::video::StdVideoAV1CDEF>();
748+ cdef.cdef_damping_minus_3 = 2;
749+ cdef.cdef_bits = 2;
750+ for (i, (pri, sec)) in [(4, 1), (0, 0), (2, 1), (8, 2)].into_iter().enumerate() {
751+ cdef.cdef_y_pri_strength[i] = pri;
752+ cdef.cdef_uv_pri_strength[i] = pri;
753+ cdef.cdef_y_sec_strength[i] = sec;
754+ cdef.cdef_uv_sec_strength[i] = sec;
755+ }
756+ cdef
757+}
shims/vk-video-ffi/src/h264_encode.rsmodified+11 -1
@@ -9,6 +9,7 @@ use vulkanalia::vk::{
99 use crate::dmabuf::DmaBuf;
1010 use crate::rgb_convert::{Input, check_rgb};
1111 use crate::session::{
12+ quality_level,
1213 DPB_SLOTS, Encoder, VideoSession, align, picture_resource, validate_rate, video_caps, vk,
1314 zeroed,
1415 };
@@ -120,6 +121,8 @@ pub struct H264EncodeConfig {
120121 pub level: u8,
121122 /// Colour description for the VUI, or none.
122123 pub colour: Option<Colour>,
124+ /// Speed/quality trade-off as in ec-hw's `EncoderConfig::quality`: 0 for the default level, 1 for the driver's best, each step up one level faster.
125+ pub quality: u32,
123126 }
124127
125128 /// frame_num wraps at 1 << LOG2_MAX_FRAME_NUM.
@@ -159,6 +162,7 @@ struct Caps {
159162 max_extent: vk::Extent2D,
160163 size_align: u64,
161164 rc_modes: vk::VideoEncodeRateControlModeFlagsKHR,
165+ quality_levels: u32,
162166 max_refs: u32,
163167 max_level: vk::video::StdVideoH264LevelIdc,
164168 }
@@ -188,7 +192,7 @@ impl Profile {
188192 .build(),
189193 usage: vk::VideoEncodeUsageInfoKHR::builder()
190194 .video_usage_hints(vk::VideoEncodeUsageFlagsKHR::STREAMING)
191- .video_content_hints(vk::VideoEncodeContentFlagsKHR::CAMERA)
195+ .video_content_hints(vk::VideoEncodeContentFlagsKHR::DESKTOP)
192196 .tuning_mode(vk::VideoEncodeTuningModeKHR::LOW_LATENCY)
193197 .build(),
194198 });
@@ -312,6 +316,7 @@ impl H264EncodeSession {
312316 (cfg.rate, cfg.fps),
313317 caps.size_align,
314318 )?;
319+ enc.vs.quality_level = quality_level(cfg.quality, caps.quality_levels);
315320 let params = create_parameters(&enc.vs, cfg, level)?;
316321 enc.vs.set_params(params);
317322 Ok(H264EncodeSession {
@@ -643,8 +648,12 @@ fn create_parameters(
643648 .max_std_pps_count(1)
644649 .parameters_add_info(&add)
645650 .build();
651+ let mut quality = vk::VideoEncodeQualityLevelInfoKHR::builder()
652+ .quality_level(vs.quality_level)
653+ .build();
646654 let info = vk::VideoSessionParametersCreateInfoKHR::builder()
647655 .video_session(vs.session)
656+ .push_next(&mut quality)
648657 .push_next(&mut h264)
649658 .build();
650659 unsafe {
@@ -681,6 +690,7 @@ fn query_caps(gpu: &Gpu, profile: &vk::VideoProfileInfoKHR) -> Result<Caps, Erro
681690 max_extent: caps.max_coded_extent,
682691 size_align: caps.min_bitstream_buffer_size_alignment,
683692 rc_modes: encode.rate_control_modes,
693+ quality_levels: encode.max_quality_levels,
684694 max_refs: h264.max_p_picture_l0_reference_count,
685695 max_level: h264.max_level_idc,
686696 })
shims/vk-video-ffi/src/h265_encode.rsmodified+11 -1
@@ -10,6 +10,7 @@ use crate::dmabuf::DmaBuf;
1010 use crate::h264_encode::validate;
1111 use crate::rgb_convert::{Input, check_rgb};
1212 use crate::session::{
13+ quality_level,
1314 DPB_SLOTS, Encoder, VideoSession, align, component_bit_depth, picture_resource, video_caps, vk,
1415 zeroed,
1516 };
@@ -32,6 +33,8 @@ pub struct H265EncodeConfig {
3233 pub level: u8,
3334 /// Colour description for the VUI, or none.
3435 pub colour: Option<Colour>,
36+ /// Speed/quality trade-off as in ec-hw's `EncoderConfig::quality`: 0 for the default level, 1 for the driver's best, each step up one level faster.
37+ pub quality: u32,
3538 }
3639
3740 /// One picture to encode.
@@ -63,6 +66,7 @@ struct Caps {
6366 max_extent: vk::Extent2D,
6467 size_align: u64,
6568 rc_modes: vk::VideoEncodeRateControlModeFlagsKHR,
69+ quality_levels: u32,
6670 max_refs: u32,
6771 max_level: vk::video::StdVideoH265LevelIdc,
6872 ctb_sizes: vk::VideoEncodeH265CtbSizeFlagsKHR,
@@ -103,7 +107,7 @@ impl Profile {
103107 .build(),
104108 usage: vk::VideoEncodeUsageInfoKHR::builder()
105109 .video_usage_hints(vk::VideoEncodeUsageFlagsKHR::STREAMING)
106- .video_content_hints(vk::VideoEncodeContentFlagsKHR::CAMERA)
110+ .video_content_hints(vk::VideoEncodeContentFlagsKHR::DESKTOP)
107111 .tuning_mode(vk::VideoEncodeTuningModeKHR::LOW_LATENCY)
108112 .build(),
109113 });
@@ -235,6 +239,7 @@ impl H265EncodeSession {
235239 (cfg.rate, cfg.fps),
236240 caps.size_align,
237241 )?;
242+ enc.vs.quality_level = quality_level(cfg.quality, caps.quality_levels);
238243 let params = create_parameters(&enc.vs, cfg, &coding)?;
239244 enc.vs.set_params(params);
240245 Ok(H265EncodeSession { enc })
@@ -594,8 +599,12 @@ fn create_parameters(
594599 .max_std_pps_count(1)
595600 .parameters_add_info(&add)
596601 .build();
602+ let mut quality = vk::VideoEncodeQualityLevelInfoKHR::builder()
603+ .quality_level(vs.quality_level)
604+ .build();
597605 let info = vk::VideoSessionParametersCreateInfoKHR::builder()
598606 .video_session(vs.session)
607+ .push_next(&mut quality)
599608 .push_next(&mut h265)
600609 .build();
601610 unsafe {
@@ -695,6 +704,7 @@ fn query_caps(gpu: &Gpu, profile: &vk::VideoProfileInfoKHR) -> Result<Caps, Erro
695704 max_extent: caps.max_coded_extent,
696705 size_align: caps.min_bitstream_buffer_size_alignment,
697706 rc_modes: encode.rate_control_modes,
707+ quality_levels: encode.max_quality_levels,
698708 max_refs: h265.max_p_picture_l0_reference_count,
699709 max_level: h265.max_level_idc,
700710 ctb_sizes: h265.ctb_sizes,
shims/vk-video-ffi/src/session.rsmodified+14 -1
@@ -62,6 +62,17 @@ pub(crate) fn align_u64(value: u64, to: u64) -> u64 {
6262 value.div_ceil(to) * to
6363 }
6464
65+const DEFAULT_QUALITY_LEVEL: u32 = 1;
66+
67+/// The encode quality level for `quality` (0 default, 1 best, each step up one level faster) on a driver with `levels` levels, best last.
68+pub(crate) fn quality_level(quality: u32, levels: u32) -> u32 {
69+ let top = levels.saturating_sub(1);
70+ match quality {
71+ 0 => DEFAULT_QUALITY_LEVEL.min(top),
72+ q => top.saturating_sub(q - 1),
73+ }
74+}
75+
6576 pub(crate) fn validate_rate(fps: (u32, u32), rate: RateControl) -> Result<(), Error> {
6677 if fps.0 == 0 || fps.1 == 0 {
6778 return Err(Error::Invalid("frame rate".into()));
@@ -483,6 +494,7 @@ pub(crate) struct VideoSession {
483494 pub(crate) format: vk::Format,
484495 pub(crate) session: vk::VideoSessionKHR,
485496 pub(crate) params: vk::VideoSessionParametersKHR,
497+ pub(crate) quality_level: u32,
486498 memories: Vec<vk::DeviceMemory>,
487499 }
488500
@@ -507,6 +519,7 @@ impl VideoSession {
507519 format,
508520 session: Default::default(),
509521 params: Default::default(),
522+ quality_level: 0,
510523 memories: Vec::new(),
511524 };
512525 let d = gpu.device();
@@ -1343,7 +1356,7 @@ impl Encoder {
13431356 let cb = slot.main.cb;
13441357 let query = k as u32;
13451358 let mut quality = vk::VideoEncodeQualityLevelInfoKHR::builder()
1346- .quality_level(0)
1359+ .quality_level(self.vs.quality_level)
13471360 .build();
13481361 let reset = !self.coded;
13491362 let update = reset || self.dirty;