Skip to content

build: add -wconversion and fix the related conversion issues#7

Open
dabrain34 wants to merge 8 commits into
mainfrom
dab_fix_conversion
Open

build: add -wconversion and fix the related conversion issues#7
dabrain34 wants to merge 8 commits into
mainfrom
dab_fix_conversion

Conversation

@dabrain34
Copy link
Copy Markdown
Contributor

@dabrain34 dabrain34 commented Dec 17, 2024

Description

Fix the conversion issues using -Wconversion during the build. Usefull for CTS.

Type of change

bug fix

Issue (optional)

Tests

Intel(R) Iris(R) Xe Graphics (ADL GT2) / Intel open-source Mesa driver Mesa 26.2.0-devel (git-e6064cf077) / Ubuntu 24.04.4 LTS

Total Tests: 77
Passed: 52
Crashed: 0
Failed: 0
Not Supported: 16
Skipped: 9 (in skip list)
Success Rate: 100.0%

Additional Details (optional)

@dabrain34
Copy link
Copy Markdown
Contributor Author

dabrain34 commented Dec 17, 2024

@zlatinski Can you give a glance to this PR. It allows to avoid non regression when we change something in vulkan-video-samples. I had the issue today again with CTS bots failing because of Vulkan-Video-Samples.

This is quite a big change but necessary.

Copy link
Copy Markdown
Contributor

@zlatinski zlatinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Stephane, for these changes. These look good in general, but I would like to request a bit more improvements. If you want, you can change the VP9 types to concrete, but you don't have to at this point because we are updating the parser based on the latest Vulkan VP9 spec, anyway.

Comment thread common/libs/VkCodecUtils/VulkanFrame.cpp Outdated
Comment thread vk_video_decoder/libs/NvVideoParser/include/VulkanH264Decoder.h Outdated
Comment thread vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX2.cpp Outdated
Comment thread vk_video_decoder/libs/NvVideoParser/src/NextStartCodeAVX512.cpp Outdated
Comment thread vk_video_decoder/libs/NvVideoParser/src/NextStartCodeSSSE3.cpp Outdated
Comment thread vk_video_decoder/libs/NvVideoParser/src/VulkanH264Parser.cpp Outdated
Comment thread vk_video_decoder/libs/NvVideoParser/src/VulkanH264Parser.cpp
Comment thread vk_video_decoder/libs/NvVideoParser/src/VulkanVP9Decoder.cpp Outdated
@dabrain34 dabrain34 force-pushed the dab_fix_conversion branch 2 times, most recently from b184ffc to c18a749 Compare December 19, 2024 10:21
Copy link
Copy Markdown
Contributor

@zlatinski zlatinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, Stephane. Your change has exposed some issues, which are indeed good to address. Thank you for doing that! Unfortunately, there are more fixes needed :( sorry!

Comment thread common/libs/VkCodecUtils/VulkanFrame.cpp Outdated
Comment thread common/libs/VkCodecUtils/VulkanFrame.cpp
Comment thread common/libs/VkCodecUtils/VulkanVideoUtils.cpp Outdated
Comment thread common/libs/VkCodecUtils/crcgenerator.cpp Outdated
Comment thread vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp Outdated
Comment thread vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp Outdated
Comment thread vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp Outdated
Comment thread vk_video_decoder/libs/VkVideoParser/VulkanVideoParser.cpp Outdated
Comment thread vk_video_decoder/libs/NvVideoParser/src/VulkanH265Parser.cpp Outdated
@dabrain34 dabrain34 force-pushed the dab_fix_conversion branch 2 times, most recently from ba1547b to 2cd1ba3 Compare December 19, 2024 16:37
@dabrain34 dabrain34 changed the title Add -Wconversion and fix the releated conversion issues Add -Wconversion and fix the related conversion issues Dec 19, 2024
@dabrain34 dabrain34 force-pushed the dab_fix_conversion branch from 2cd1ba3 to dbec2b1 Compare March 17, 2025 09:34
@dabrain34
Copy link
Copy Markdown
Contributor Author

@zlatinski are you okay to merge this change ?

@dabrain34
Copy link
Copy Markdown
Contributor Author

ping @zlatinski

Copy link
Copy Markdown
Contributor

@zlatinski zlatinski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the fixes, Stephane! I'm fine with the changes, as long as after applying the changes, the Fluster's results don't get regressed.

@dabrain34 dabrain34 force-pushed the dab_fix_conversion branch 4 times, most recently from e7e05b7 to d415221 Compare May 14, 2025 14:36
@dabrain34
Copy link
Copy Markdown
Contributor Author

Found some regression with Fluster AV1 tests that have been addressed.

Having a bot to check that would be great but thanks for asking to check that again.

Unfortunately the bot is unhappy now because of spirv. Need to investigate whats happening ...

@dabrain34
Copy link
Copy Markdown
Contributor Author

Just pushed a new serie to fix the latest conversion issues.

I gave a try to fluster AV1, H264, H265, VP9 and so far no regressions.

Would request anyway another review to be sure about it.

@dabrain34 dabrain34 force-pushed the dab_fix_conversion branch from a131d28 to 3d4758c Compare May 7, 2026 08:50
@dabrain34 dabrain34 changed the title Add -Wconversion and fix the related conversion issues build: add -wconversion and fix the related conversion issues May 7, 2026
dabrain34 added 2 commits May 21, 2026 12:35
Due to -Wconversion, a lot of conversion have been discovered.
@dabrain34 dabrain34 force-pushed the dab_fix_conversion branch from 3d4758c to b13efdc Compare May 21, 2026 10:56
@dabrain34 dabrain34 force-pushed the dab_fix_conversion branch from b13efdc to 3c57c30 Compare May 21, 2026 11:50
clang does not support string to boolean conversation
in the assert.
size_t i = 0;
{
static const int lanes = (int)svcntb();
static const uint8_t lanes = (uint8_t)svcntb();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SVE vector length is hardware-dependent, using uint8_t for svcntb() is unsafe because implementations could expose vector lengths larger than 255 bytes.

inline int VulkanAV1Decoder::ReadDeltaQ(uint32_t bits)
{
return u(1) ? ReadSignedBits(bits) : 0;
return u(1) ? (uint8_t)ReadSignedBits(bits) : 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would drop the (uint8_t). ReadDeltaQ return type is int.
In line 1314, where ReadDeltaQ is called, the return value is converted to int8_t.
The -Wconversion warning should already be silenced by the explicit (int8_t) in line 1314 and other places where the function is called.

#define VKVS_DEBUG_TRAP() abort()
#endif

#define VKVS_ASSERT(cond, fmt, ...) \
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This changes the behavior of release builds. Now if the assertion is triggered, it always writes to stderr, only the abort() is conditional.

Comment thread common/libs/VkCodecUtils/VulkanFrame.cpp
if (scaleInput) {
if (displayWidth && (displayWidth != inputImageToDrawFrom->imageWidth)) {
constants.texMatrix[0] = vk::Vec2((float)displayWidth / inputImageToDrawFrom->imageWidth, 0.0f);
constants.texMatrix[0] = vk::Vec2((float)(double)displayWidth / (float)(double)inputImageToDrawFrom->imageWidth, 0.0f);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See previous review comment:#7 (comment).
The code was changed to:
constants.texMatrix[0] = vk::Vec2((float)(double)displayWidth / (float)(double)inputImageToDrawFrom->imageWidth, 0.0f);
It keeps the division precision in float instead of double.
Same for line 800.

h264->svcext.f.ref_layer_chroma_phase_x_plus1_flag = slh->ref_layer_chroma_phase_x_plus1_flag;
h264->svcext.f.store_ref_base_pic_flag = slh->store_ref_base_pic_flag;
h264->svcext.f.inter_layer_deblocking_filter_control_present_flag = sps->svc.inter_layer_deblocking_filter_control_present_flag & 0x1;
h264->svcext.f.extended_spatial_scalability_idc = sps->svc.extended_spatial_scalability_idc & 0x3;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seq_parameter_set_svc_extension_s has not been modified yet, therefore these changes are not reverted. Is there a plan for this?

assert(!"Invalid level idc");
return -1;
VKVS_FAIL("Invalid level idc");
return 0;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it correct to return here 0 instead of -1?
Are the callers also treating 0 as an error?

@@ -2442,13 +2442,13 @@ bool VulkanH265Decoder::dpb_sequence_start(VkSharedBaseObj<hevc_seq_param_s>& sp
nvsi.frameRate = PackFrameRate(sps->stdVui.vui_time_scale, sps->stdVui.vui_num_units_in_tick);
}
nvsi.bProgSeq = 1; //!sps->vui.field_seq_flag;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bProgSeq type changed to bool. To be consistent, assign here to true

m_loopFilterRefDeltas[i] = u(6);
m_loopFilterRefDeltas[i] = (int8_t)u(6);
if (u(1)) { // sign
m_loopFilterRefDeltas[i] = -m_loopFilterRefDeltas[i];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line now triggers a warning with Clang 21.1.8:
error: implicit conversion loses integer precision: 'int' to 'int8_t' (aka 'signed char') on negation [-Werror,-Wimplicit-int-conversion-on-negation].
Same for lines 667 and 757.

m_loopFilterModeDeltas[i] = u(6);
m_loopFilterModeDeltas[i] = (int8_t)u(6);
if(u(1)) { // sign
m_loopFilterModeDeltas[i] = -m_loopFilterRefDeltas[i];
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the warning with newer clang versions mentioned for line 656, this line seems line a copy paste error (already existing bug before this PR).
m_loopFilterModeDeltas[i] should be assigned to -m_loopFilterModeDeltas[i], not -m_loopFilterRefDeltas[i].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants