Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option for stricter compiler warnings #1891

Open
wants to merge 5 commits into
base: dev
Choose a base branch
from

Conversation

fabian-lunarg
Copy link
Contributor

@fabian-lunarg fabian-lunarg commented Nov 27, 2024

  • Add a cmake-option: raise compiler-warnings level for GCC and clang
  • apply stricter settings for targets gfxrecon_format, gfxrecon_util, gfxrecon_graphics

first step towards #1890

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 311184.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5413 running.

@fabian-lunarg fabian-lunarg force-pushed the fabian_stricter_compiler_warnings_guarded branch from 0bda28c to 039a7dc Compare November 27, 2024 12:22
@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 311214.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 311244.

@fabian-lunarg fabian-lunarg self-assigned this Nov 27, 2024
@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5416 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5416 passed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 311459.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5420 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5420 failed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 311489.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5421 running.

reinterpret_cast<const uint8_t*>(&pointer_member) - reinterpret_cast<const uint8_t*>(&base_struct);

// copy pointer-chain recursively
uint32_t copy_size = vulkan_struct_deep_copy(pointer_member, count, offset_ptr(out_data, offset));
uint64_t copy_size = vulkan_struct_deep_copy(pointer_member, (uint32_t)count, offset_ptr(out_data, offset));
Copy link
Contributor

Choose a reason for hiding this comment

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

do we prefer c++ style casting?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we do :) I'll adjust the generator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

reinterpret_cast<const uint8_t*>(&pointer_member) - reinterpret_cast<const uint8_t*>(&base_struct);

// copy pointer-chain recursively
uint32_t copy_size = vulkan_struct_deep_copy(pointer_member, count, offset_ptr(out_data, offset));
uint64_t copy_size = vulkan_struct_deep_copy(pointer_member, (uint32_t)count, offset_ptr(out_data, offset));
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

const VkExtent3D scaled_extent = { static_cast<uint32_t>(std::max(extent.width * scale, 1.0f)),
static_cast<uint32_t>(std::max(extent.height * scale, 1.0f)),
static_cast<uint32_t>(std::max(extent.depth * scale, 1.0f)) };
const VkExtent3D scaled_extent = { static_cast<uint32_t>(std::max((float)extent.width * scale, 1.0f)),
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -1877,7 +1877,7 @@ void VulkanResourcesUtil::ReadFromImageResourceLinear(VkImage ima
subresource_sizes.clear();

const double texel_size = vkuFormatTexelSizeWithAspect(format, aspect);
assert(texel_size == static_cast<uint64_t>(texel_size));
assert(texel_size == static_cast<double>(static_cast<uint64_t>(texel_size)));
Copy link
Contributor

Choose a reason for hiding this comment

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

GFXRECON_ASSERT and.. how about using floor(texel_size)?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

damn me, I had a blackout and was searching for 'fract'

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed to use std::floor

version[3] = (unsigned int)((data & 0x000000000000FFFF));
uint16_t version[4] = {};
std::string str_version;
version[0] = (uint16_t)((data & 0xFFFF000000000000) >> 16 * 3);
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

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

and ... all done :)

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5421 failed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 311512.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5422 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5422 passed.

@fabian-lunarg fabian-lunarg force-pushed the fabian_stricter_compiler_warnings_guarded branch from 85fe2eb to 3729798 Compare November 28, 2024 07:49
@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 312150.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5439 running.

CMakeLists.txt Outdated

if (USE_STRICT_COMPILER_WARNINGS)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wconversion -Wextra -Werror -Wno-unused-parameter -Wno-unused-function -Wno-missing-field-initializers")
Copy link
Contributor

@panos-lunarg panos-lunarg Nov 28, 2024

Choose a reason for hiding this comment

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

Is -Werror=shadow included with these?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, already had to fix at least one location with this appearing as error.

Copy link
Contributor Author

@fabian-lunarg fabian-lunarg Nov 28, 2024

Choose a reason for hiding this comment

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

but weird, I can not spot -Wshadow in any of the lists for -Wall, -Wextra or -pedantic - https://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, my bad. I only saw clang-tidy warnings. will include -Wshadow and iterate again

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, added -Wshadow and fixed all occurances in gfxreconformat/util/graphics. thanks @panos-lunarg !

Copy link
Contributor

Choose a reason for hiding this comment

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

Also keep in mind the parameters I used in #1890 were mostly an experiment and not to be considered the "correct" ones or the "target". They are open to discussion and we can add or remove as we see fit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, totally agree. they are reasonably strict and a great starting point, but subject to some iteration. -Wall and -Wextra are already a huge leap, we even apply -pedantic atm. depending on how much work it causes we can gradually rollback the exceptions -Wno-unused-parameter -Wno-unused-function -Wno-missing-field-initializers

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5439 failed.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 312194.

@fabian-lunarg fabian-lunarg force-pushed the fabian_stricter_compiler_warnings_guarded branch from 0dde75d to 7ee61b8 Compare November 28, 2024 09:07
@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 312200.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 312202.

@fabian-lunarg fabian-lunarg force-pushed the fabian_stricter_compiler_warnings_guarded branch from 77884ec to 8b843d5 Compare November 28, 2024 10:51
@ci-tester-lunarg
Copy link

CI gfxreconstruct build queued with queue ID 312279.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5446 running.

@ci-tester-lunarg
Copy link

CI gfxreconstruct build # 5446 passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants