Skip to content

Commit

Permalink
Stricter compiler flags
Browse files Browse the repository at this point in the history
  • Loading branch information
panos-lunarg committed Aug 31, 2023
1 parent 215926d commit fb47ac8
Show file tree
Hide file tree
Showing 54 changed files with 3,046 additions and 1,121 deletions.
15 changes: 10 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ set(GFXRECONSTRUCT_PROJECT_VERSION_PATCH 0)

set(GFXRECON_PROJECT_VERSION_SHA1 "unknown-build-source")

if(UNIX)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pedantic -Wall -Wconversion -Wextra -Werror -Wno-unused-parameter -Wno-missing-field-initializers -Wno-sign-conversion -Wno-maybe-uninitialized")
endif()

option(BUILD_STATIC "Build static binaries for HPC clusters (will not build the tracer library)" OFF)

if (NOT DEFINED HEADLESS)
Expand Down Expand Up @@ -175,7 +179,7 @@ if(MSVC)
"set D3D12_SUPPORT=OFF or configure the build with the recommended Windows SDK version. See BUILD.md "
"for more information.")
endif()

else()
set(BUILD_LAUNCHER_AND_INTERCEPTOR OFF)
endif()
Expand All @@ -187,22 +191,22 @@ if(MSVC)

# Add option to enable/disable AGS support.
option(GFXRECON_AGS_SUPPORT "Build with AGS support enabled. Ignored if D3D12_SUPPORT=OFF." ON)

if (${D3D12_SUPPORT})
if (${GFXRECON_AGS_SUPPORT})
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
find_package(AGS)
if (TARGET AGS::AGS)
add_definitions(-DGFXRECON_AGS_SUPPORT)

# The value for option GFXRECON_AGS_SUPPORT gets cached so use a non-cached variable
# to determine the final result.
set(GFXRECON_AGS_SUPPORT_FINAL ON)
endif() # TARGET AGS::AGS
endif() # CMAKE_SIZEOF_VOID_P EQUAL 8
endif() # GFXRECON_AGS_SUPPORT
endif() # D3D12_SUPPORT

else(MSVC)
# Turn off D3D12 support for non MSVC builds.
set(D3D12_SUPPORT OFF)
Expand Down Expand Up @@ -297,7 +301,8 @@ target_compile_options(vulkan_memory_allocator INTERFACE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>>:
-Wno-nullability-completeness>
)
target_include_directories(vulkan_memory_allocator INTERFACE ${CMAKE_SOURCE_DIR}/external/VulkanMemoryAllocator/include)

target_include_directories(vulkan_memory_allocator SYSTEM INTERFACE ${CMAKE_SOURCE_DIR}/external/VulkanMemoryAllocator/include)

if (${RUN_TESTS})
add_library(catch2 INTERFACE)
Expand Down
9 changes: 6 additions & 3 deletions android/framework/util/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,12 @@ target_compile_definitions(gfxrecon_util

target_include_directories(gfxrecon_util
PUBLIC
${GFXRECON_SOURCE_DIR}/external/precompiled/android/include
${GFXRECON_SOURCE_DIR}/external/stb
${GFXRECON_SOURCE_DIR}/framework)
${GFXRECON_SOURCE_DIR}/external/precompiled/android/include
${GFXRECON_SOURCE_DIR}/framework)

target_include_directories(gfxrecon_util
SYSTEM PUBLIC
${GFXRECON_SOURCE_DIR}/external/stb)

target_link_libraries(gfxrecon_util
platform_specific
Expand Down
1 change: 1 addition & 0 deletions android/tools/replay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ add_subdirectory(../../framework/application ${CMAKE_SOURCE_DIR}/../../framework
add_library(gfxrecon-replay
SHARED
${GFXRECON_SOURCE_DIR}/tools/tool_settings.h
${GFXRECON_SOURCE_DIR}/tools/tool_settings.cpp
${GFXRECON_SOURCE_DIR}/tools/replay/replay_settings.h
${GFXRECON_SOURCE_DIR}/tools/replay/android_main.cpp)

Expand Down
4 changes: 2 additions & 2 deletions framework/application/application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ Application::Application(const std::string& name,
const std::string& cli_wsi_extension,
decode::FileProcessor* file_processor) :
name_(name),
file_processor_(file_processor), cli_wsi_extension_(cli_wsi_extension), running_(false), paused_(false),
pause_frame_(0), fps_info_(nullptr)
file_processor_(file_processor), running_(false), paused_(false), pause_frame_(0),
cli_wsi_extension_(cli_wsi_extension), fps_info_(nullptr)
{
if (!cli_wsi_extension_.empty())
{
Expand Down
2 changes: 1 addition & 1 deletion framework/application/wayland_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ void WaylandWindow::UpdateWindowSize()
scale_ = output_info.scale;
}

if (output_info.width == width_ && output_info.height == height_)
if (static_cast<uint32_t>(output_info.width) == width_ && static_cast<uint32_t>(output_info.height) == height_)
{
wl.shell_surface_set_fullscreen(shell_surface_, WL_SHELL_SURFACE_FULLSCREEN_METHOD_DEFAULT, 0, output_);
}
Expand Down
3 changes: 1 addition & 2 deletions framework/application/xcb_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ const char kBypassCompositorName[] = "_NET_WM_BYPASS_COMPOSITOR";
// Masks for window geometry configuration.
const uint16_t kConfigurePositionMask = XCB_CONFIG_WINDOW_X | XCB_CONFIG_WINDOW_Y;
const uint16_t kConfigureSizeMask = XCB_CONFIG_WINDOW_WIDTH | XCB_CONFIG_WINDOW_HEIGHT;
const uint16_t kConfigurePositionSizeMask = kConfigurePositionMask | kConfigureSizeMask;

XcbWindow::XcbWindow(XcbContext* xcb_context) :
xcb_context_(xcb_context), width_(0), height_(0), screen_width_(std::numeric_limits<uint32_t>::max()),
Expand Down Expand Up @@ -430,7 +429,7 @@ xcb_intern_atom_cookie_t
XcbWindow::SendAtomRequest(xcb_connection_t* connection, const char* name, uint8_t only_if_exists) const
{
auto& xcb = xcb_context_->GetXcbFunctionTable();
return xcb.intern_atom(connection, only_if_exists, strlen(name), name);
return xcb.intern_atom(connection, only_if_exists, static_cast<uint16_t>(strlen(name)), name);
}

xcb_atom_t
Expand Down
3 changes: 2 additions & 1 deletion framework/application/xlib_window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ bool XlibWindow::Create(
int32_t y = ypos;
bool go_fullscreen = false;

if ((root_attributes.height <= height) || (root_attributes.width <= width))
if ((static_cast<uint32_t>(root_attributes.height) <= height) ||
(static_cast<uint32_t>(root_attributes.width) <= width))
{
if ((screen_height_ == height) || (screen_width_ == width))
{
Expand Down
1 change: 0 additions & 1 deletion framework/decode/custom_vulkan_struct_to_json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ void FieldToJson(nlohmann::ordered_json& jdata, const Decoded_VkClearColorValue*
if (data && data->decoded_value)
{
const auto& decoded_value = *data->decoded_value;
const auto& meta_struct = *data;
FieldToJson(jdata["float32"], decoded_value.float32, 4, options);
FieldToJson(jdata["int32"], decoded_value.int32, 4, options);
FieldToJson(jdata["uint32"], decoded_value.uint32, 4, options);
Expand Down
2 changes: 1 addition & 1 deletion framework/decode/decoder_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ bool IsComplete(std::vector<T>& consumers, uint64_t block_index)
}
}

return completed_consumers == consumers.size();
return static_cast<size_t>(completed_consumers) == consumers.size();
}

GFXRECON_END_NAMESPACE(decode)
Expand Down
19 changes: 8 additions & 11 deletions framework/decode/file_processor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ GFXRECON_BEGIN_NAMESPACE(decode)
const uint32_t kFirstFrame = 0;

FileProcessor::FileProcessor() :
file_header_{}, file_descriptor_(nullptr), current_frame_number_(kFirstFrame), bytes_read_(0),
error_state_(kErrorInvalidFileDescriptor), annotation_handler_(nullptr), compressor_(nullptr), block_index_(0),
file_descriptor_(nullptr), current_frame_number_(kFirstFrame), annotation_handler_(nullptr),
error_state_(kErrorInvalidFileDescriptor), block_index_(0), file_header_{}, bytes_read_(0), compressor_(nullptr),
api_call_index_(0), block_limit_(0), capture_uses_frame_markers_(false), first_frame_(kFirstFrame + 1)
{}

Expand Down Expand Up @@ -72,7 +72,7 @@ void FileProcessor::WaitDecodersIdle()
{
decoder->WaitIdle();
}
};
}

bool FileProcessor::Initialize(const std::string& filename)
{
Expand Down Expand Up @@ -169,7 +169,7 @@ bool FileProcessor::ContinueDecoding()
}
}

if (completed_decoders == decoders_.size())
if (static_cast<size_t>(completed_decoders) == decoders_.size())
{
early_exit = true;
}
Expand Down Expand Up @@ -322,8 +322,7 @@ bool FileProcessor::ProcessBlocks()
}
else if (block_header.type == format::BlockType::kFrameMarkerBlock)
{
format::MarkerType marker_type = format::MarkerType::kUnknownMarker;
uint64_t frame_number = 0;
format::MarkerType marker_type = format::MarkerType::kUnknownMarker;

success = ReadBytes(&marker_type, sizeof(marker_type));

Expand Down Expand Up @@ -357,8 +356,7 @@ bool FileProcessor::ProcessBlocks()
}
else if (block_header.type == format::BlockType::kStateMarkerBlock)
{
format::MarkerType marker_type = format::MarkerType::kUnknownMarker;
uint64_t frame_number = 0;
format::MarkerType marker_type = format::MarkerType::kUnknownMarker;

success = ReadBytes(&marker_type, sizeof(marker_type));

Expand Down Expand Up @@ -1724,8 +1722,7 @@ bool FileProcessor::ProcessMetaData(const format::BlockHeader& block_header, for
}
else if (meta_data_type == format::MetaDataType::kDx12RuntimeInfoCommand)
{
format::Dx12RuntimeInfoCommandHeader dx12_runtime_info_header;
memset(&dx12_runtime_info_header, 0, sizeof(dx12_runtime_info_header));
format::Dx12RuntimeInfoCommandHeader dx12_runtime_info_header = {};

success = ReadBytes(&dx12_runtime_info_header.thread_id, sizeof(dx12_runtime_info_header.thread_id));

Expand Down Expand Up @@ -1835,7 +1832,7 @@ bool FileProcessor::ProcessStateMarker(const format::BlockHeader& block_header,

bool FileProcessor::ProcessAnnotation(const format::BlockHeader& block_header, format::AnnotationType annotation_type)
{
bool success = false;
bool success = false;
decltype(format::AnnotationHeader::label_length) label_length = 0;
decltype(format::AnnotationHeader::data_length) data_length = 0;

Expand Down
3 changes: 1 addition & 2 deletions framework/decode/file_transformer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,8 +226,7 @@ bool FileTransformer::ProcessNextBlock()
}
else if (block_header.type == format::BlockType::kStateMarkerBlock)
{
format::MarkerType marker_type = format::MarkerType::kUnknownMarker;
uint64_t frame_number = 0;
format::MarkerType marker_type = format::MarkerType::kUnknownMarker;

success = ReadBytes(&marker_type, sizeof(marker_type));

Expand Down
6 changes: 3 additions & 3 deletions framework/decode/file_transformer.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,15 +146,15 @@ class FileTransformer
bool ReadBlockHeader(format::BlockHeader* block_header);

private:
format::FileHeader file_header_;
FILE* input_file_;
FILE* output_file_;
format::FileHeader file_header_;
std::vector<format::FileOptionPair> file_options_;
format::EnabledOptions enabled_options_;
uint64_t bytes_read_;
uint64_t bytes_written_;
Error error_state_;
bool loading_state_;
std::vector<format::FileOptionPair> file_options_;
format::EnabledOptions enabled_options_;
std::vector<uint8_t> parameter_buffer_;
std::vector<uint8_t> compressed_parameter_buffer_;
std::unique_ptr<util::Compressor> compressor_;
Expand Down
2 changes: 1 addition & 1 deletion framework/decode/pointer_decoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ class PointerDecoder : public PointerDecoderBase

size_t capacity = n * m;

if ((data != nullptr) && (capacity > 0))
if (capacity > 0)
{
data_ = reinterpret_cast<T*>(data);
capacity_ = capacity;
Expand Down
1 change: 0 additions & 1 deletion framework/decode/vulkan_captured_swapchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,6 @@ void VulkanCapturedSwapchain::ProcessSetSwapchainImageStateCommand(
const VulkanObjectInfoTable& object_info_table,
SwapchainImageTracker& swapchain_image_tracker)
{
VkDevice device = device_info->handle;
VkSwapchainKHR swapchain = swapchain_info->handle;

VkPhysicalDevice physical_device = device_info->parent;
Expand Down
5 changes: 2 additions & 3 deletions framework/decode/vulkan_realign_allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,9 +263,8 @@ VkResult VulkanRealignAllocator::WriteMappedMemoryRange(MemoryData allocator
uint64_t size,
const uint8_t* data)
{
VkResult result = VK_ERROR_MEMORY_MAP_FAILED;
VkDeviceSize realign_offset = offset;
auto memory_info = GetMemoryAllocInfo(allocator_data);
VkResult result = VK_ERROR_MEMORY_MAP_FAILED;
auto memory_info = GetMemoryAllocInfo(allocator_data);

if (memory_info != nullptr)
{
Expand Down
Loading

0 comments on commit fb47ac8

Please sign in to comment.