Skip to content

Commit

Permalink
Refactor Vulkan includes, avoid warnings on GCC
Browse files Browse the repository at this point in the history
  • Loading branch information
mikke89 committed Apr 6, 2024
1 parent 20d9cc7 commit 4568762
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 46 deletions.
32 changes: 32 additions & 0 deletions Backends/RmlUi_Include_Vulkan.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#ifndef RMLUI_BACKENDS_INCLUDE_VULKAN_H
#define RMLUI_BACKENDS_INCLUDE_VULKAN_H

#if defined RMLUI_PLATFORM_UNIX
#define VK_USE_PLATFORM_XCB_KHR 1
#endif
#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
#endif

#if defined _MSC_VER
#pragma warning(push, 0)
#elif defined __clang__
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wall"
#pragma clang diagnostic ignored "-Wextra"
#pragma clang diagnostic ignored "-Wnullability-extension"
#pragma clang diagnostic ignored "-Wgnu-zero-variadic-macro-arguments"
#pragma clang diagnostic ignored "-Wnullability-completeness"
#elif defined __GNUC__
#pragma GCC system_header
#endif

#include "RmlUi_Vulkan/vulkan.h"
// Always include "vulkan.h" first, this comment prevents clang-format from reordering the includes.
#include "RmlUi_Vulkan/vk_mem_alloc.h"

#if defined _MSC_VER
#pragma warning(pop)
#elif defined __clang__
#pragma clang diagnostic pop
#endif
8 changes: 1 addition & 7 deletions Backends/RmlUi_Renderer_VK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3038,12 +3038,6 @@ void RenderInterface_VK::MemoryPool::Free_GeometryHandle_ShaderDataOnly(geometry
p_valid_geometry_handle->m_p_shader_allocation = nullptr;
}

RMLUI_DISABLE_ALL_COMPILER_WARNINGS_PUSH

#define GLAD_VULKAN_IMPLEMENTATION
#include "RmlUi_Vulkan/vulkan.h"

#define VMA_IMPLEMENTATION
#include "RmlUi_Vulkan/vk_mem_alloc.h"

RMLUI_DISABLE_ALL_COMPILER_WARNINGS_POP
#include "RmlUi_Include_Vulkan.h"
40 changes: 1 addition & 39 deletions Backends/RmlUi_Renderer_VK.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,50 +31,12 @@

#include <RmlUi/Core/RenderInterface.h>

/**
* Include third-party dependencies.
*/
#ifdef RMLUI_PLATFORM_WIN32
#include "RmlUi_Include_Windows.h"
#define VK_USE_PLATFORM_WIN32_KHR
#endif

#if (_MSC_VER > 0)
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_PUSH _Pragma("warning(push, 0)")
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_POP _Pragma("warning(pop)")
#elif __clang__
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_PUSH \
_Pragma("clang diagnostic push") _Pragma("clang diagnostic ignored \"-Wall\"") _Pragma("clang diagnostic ignored \"-Wextra\"") \
_Pragma("clang diagnostic ignored \"-Wnullability-extension\"") \
_Pragma("clang diagnostic ignored \"-Wgnu-zero-variadic-macro-arguments\"") \
_Pragma("clang diagnostic ignored \"-Wnullability-completeness\"")
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_POP _Pragma("clang diagnostic pop")
#elif __GNUC__
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_PUSH \
_Pragma("GCC diagnostic push") _Pragma("GCC diagnostic ignored \"-Wimplicit-fallthrough\"") \
_Pragma("GCC diagnostic ignored \"-Wunused-function\"") _Pragma("GCC diagnostic ignored \"-Wunused-parameter\"") \
_Pragma("GCC diagnostic ignored \"-Wunused-variable\"") _Pragma("GCC diagnostic ignored \"-Wmissing-field-initializers\"") \
_Pragma("GCC diagnostic ignored \"-Wswitch\"") _Pragma("GCC diagnostic ignored \"-Wpedantic\"") \
_Pragma("GCC diagnostic ignored \"-Wattributes\"") _Pragma("GCC diagnostic ignored \"-Wignored-qualifiers\"") \
_Pragma("GCC diagnostic ignored \"-Wparentheses\"")
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_POP _Pragma("GCC diagnostic pop")
#else
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_PUSH
#define RMLUI_DISABLE_ALL_COMPILER_WARNINGS_POP
#endif

RMLUI_DISABLE_ALL_COMPILER_WARNINGS_PUSH

#if defined(RMLUI_PLATFORM_UNIX)
#define VK_USE_PLATFORM_XCB_KHR 1
#endif
#include "RmlUi_Vulkan/vulkan.h"

#define VMA_STATIC_VULKAN_FUNCTIONS 0
#define VMA_DYNAMIC_VULKAN_FUNCTIONS 1
#include "RmlUi_Vulkan/vk_mem_alloc.h"

RMLUI_DISABLE_ALL_COMPILER_WARNINGS_POP
#include "RmlUi_Include_Vulkan.h"

#ifdef RMLUI_DEBUG
#define RMLUI_VK_ASSERTMSG(statement, msg) RMLUI_ASSERTMSG(statement, msg)
Expand Down

0 comments on commit 4568762

Please sign in to comment.