Commit 2490b1ae by Nicolas Capens Committed by Nicolas Capens

Undefine Bool after the headers that define them

X11/Xlib.h defines Bool as a macro, which clashes with Reactor's Bool class. This X11 header is also included by vulkan.h, vk_icd.h, and EGL/eglplatform.h Previously we undefined Bool in various places. It's not possible to just undefine it in Reactor.hpp because one can have headers following the inclusion of Reactor.hpp which redefine it (note our convention is to include platform headers after project headers). Since X11 is only needed in select places related to the windowing system, we can instead avoid the use of these headers in other headers, and only include them in .cpp files where necessary. Note that vulkan_core.h contains the whole plaform-independent Vulkan API, so it should be used instead of vulkan.h for all non-WSI code. Bug: b/127920555 Change-Id: Id11a1c58b87802fe9e530387831693e44accae2b Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46368 Presubmit-Ready: Nicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com>
parent cd0af645
......@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
#include "vulkan.h"
#include "vulkan_core.h"
// THIS FILE SHOULD BE DELETED IF VK_EXT_provoking_vertex IS EVER ADDED TO THE VULKAN HEADERS
#ifdef VK_EXT_provoking_vertex
......
......@@ -16,8 +16,6 @@
#include "Common/SharedLibrary.hpp"
#define Bool int
LibX11exports::LibX11exports(void *libX11, void *libXext)
{
XOpenDisplay = (Display *(*)(char*))getProcAddress(libX11, "XOpenDisplay");
......
......@@ -48,8 +48,6 @@ struct LibX11exports
int (*XShmPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height, bool send_event);
};
#undef Bool // b/127920555
class LibX11
{
public:
......
......@@ -21,6 +21,7 @@
#include "Renderer/Surface.hpp"
#include <EGL/egl.h>
#undef Bool
namespace egl
{
......
......@@ -19,6 +19,8 @@
#include "Renderer/Surface.hpp"
#include <EGL/egl.h>
#undef Bool
#include <GLES/gl.h>
namespace gl { class Surface; }
......
......@@ -20,10 +20,6 @@
#include "Reactor/Print.hpp"
#include "Reactor/Reactor.hpp"
#ifdef None
# undef None // b/127920555
#endif
namespace sw {
using namespace rr;
......
......@@ -26,8 +26,6 @@
#include <tuple>
#include <unordered_set>
#undef Bool // b/127920555
#ifdef ENABLE_RR_DEBUG_INFO
// Functions used for generating JIT debug info.
// See docs/ReactorDebugInfo.md for more information.
......
......@@ -18,10 +18,6 @@
#include <stdint.h>
#include <type_traits>
#ifdef Bool
# undef Bool // b/127920555
#endif
namespace rr {
// Forward declarations
......
......@@ -15,9 +15,7 @@
#ifndef VK_DESCRIPTOR_SET_HPP_
#define VK_DESCRIPTOR_SET_HPP_
// Intentionally not including VkObject.hpp here due to b/127920555
#include "VkConfig.hpp"
#include "VkObject.hpp"
#include "marl/mutex.h"
#include <array>
......@@ -35,19 +33,9 @@ struct alignas(16) DescriptorSetHeader
marl::mutex mutex;
};
class alignas(16) DescriptorSet
class alignas(16) DescriptorSet : public Object<DescriptorSet, VkDescriptorSet>
{
public:
static inline DescriptorSet *Cast(VkDescriptorSet object)
{
return static_cast<DescriptorSet *>(static_cast<void *>(object));
}
operator VkDescriptorSet()
{
return { static_cast<uint64_t>(reinterpret_cast<uintptr_t>(this)) };
}
using Array = std::array<DescriptorSet *, vk::MAX_BOUND_DESCRIPTOR_SETS>;
using Bindings = std::array<uint8_t *, vk::MAX_BOUND_DESCRIPTOR_SETS>;
using DynamicOffsets = std::array<uint32_t, vk::MAX_DESCRIPTOR_SET_COMBINED_BUFFERS_DYNAMIC>;
......
......@@ -20,8 +20,10 @@
#include "System/Debug.hpp"
#include "Vulkan/VulkanPlatform.hpp"
#include <vulkan/vk_icd.h>
#undef None
#undef Bool
#include <new>
namespace vk {
......
......@@ -17,11 +17,10 @@
#include "VkObject.hpp"
#include "Device/Renderer.hpp"
#include <vulkan/vk_icd.h>
#include <thread>
#include "System/Synchronization.hpp"
#include <thread>
namespace marl {
class Scheduler;
}
......
......@@ -16,8 +16,8 @@
#include "System/Debug.hpp"
#include "vulkan/vk_ext_provoking_vertex.h"
#include "vulkan/vk_google_filtering_precision.h"
#include <vulkan/vk_ext_provoking_vertex.h>
#include <vulkan/vk_google_filtering_precision.h>
#include <iostream>
#include <map>
......
......@@ -17,7 +17,7 @@
#ifndef VK_STRINGIFY_HPP_
#define VK_STRINGIFY_HPP_
#include <vulkan/vulkan.h>
#include <vulkan/vulkan_core.h>
#include <string>
namespace vk {
......
......@@ -27,8 +27,8 @@ public:
{
static_assert(sizeof(VkNonDispatchableHandle) == sizeof(uint64_t), "Size is not 64 bits!");
// VkNonDispatchabbleHandle must be POD to ensure it gets passed by value the same way as a uint64_t,
// which is the upstream header's handle type when compiled for 32b architectures. On 64b architectures,
// VkNonDispatchableHandle must be POD to ensure it gets passed by value the same way as a uint64_t,
// which is the upstream header's handle type when compiled for 32-bit architectures. On 64-bit architectures,
// the upstream header's handle type is a pointer type.
static_assert(std::is_trivial<VkNonDispatchableHandle<T>>::value, "VkNonDispatchableHandle<T> is not trivial!");
static_assert(std::is_standard_layout<VkNonDispatchableHandle<T>>::value, "VkNonDispatchableHandle<T> is not standard layout!");
......@@ -51,12 +51,7 @@ public:
#include <vulkan/vk_ext_provoking_vertex.h>
#include <vulkan/vk_google_filtering_precision.h>
#include <vulkan/vulkan.h>
#ifdef Bool
# undef Bool // b/127920555
# undef None
#endif
#include <vulkan/vulkan_core.h>
namespace vk {
// Here we define constants that used to be in the Vulkan headers, but are not part of the spec.
......
......@@ -17,11 +17,12 @@
#include "VkSurfaceKHR.hpp"
#include "Vulkan/VkObject.hpp"
#ifdef VK_USE_PLATFORM_MACOS_MVK
# include "vulkan/vulkan_macos.h"
# include <vulkan/vulkan_macos.h>
#endif
#ifdef VK_USE_PLATFORM_METAL_EXT
# include "vulkan/vulkan_metal.h"
# include <vulkan/vulkan_metal.h>
#endif
namespace vk {
......
......@@ -22,8 +22,8 @@
#if !defined(WIN32_LEAN_AND_MEAN)
# define WIN32_LEAN_AND_MEAN
#endif // !defined(WIN32_LEAN_AND_MEAN)
#include "vulkan/vulkan_win32.h"
#include <Windows.h>
#include <vulkan/vulkan_win32.h>
#include <map>
......
......@@ -17,7 +17,8 @@
#include "VkSurfaceKHR.hpp"
#include "Vulkan/VkObject.hpp"
#include "vulkan/vulkan_xcb.h"
#include <vulkan/vulkan_xcb.h>
#include <xcb/xcb.h>
#include <unordered_map>
......
......@@ -18,7 +18,8 @@
#include "VkSurfaceKHR.hpp"
#include "libX11.hpp"
#include "Vulkan/VkObject.hpp"
#include "vulkan/vulkan_xlib.h"
#include <vulkan/vulkan_xlib.h>
#include <unordered_map>
......
......@@ -16,8 +16,6 @@
#include "System/SharedLibrary.hpp"
#define Bool int
namespace {
template<typename FPTR>
......
......@@ -49,8 +49,6 @@ struct LibX11exports
int (*XShmPutImage)(Display *display, Drawable d, GC gc, XImage *image, int src_x, int src_y, int dest_x, int dest_y, unsigned int width, unsigned int height, bool send_event);
};
#undef Bool // b/127920555
class LibX11
{
public:
......
......@@ -160,7 +160,7 @@ BENCHMARK_DEFINE_F(LRUCacheBenchmark, GetComplexKeyCacheHit)
ComplexKey key;
for(size_t w = 0; w < key.words.size(); w++)
{
key.words[w] = (1U << w);
key.words[w] = (1ull << w);
}
cache.add(key, i);
}
......@@ -172,7 +172,7 @@ BENCHMARK_DEFINE_F(LRUCacheBenchmark, GetComplexKeyCacheHit)
ComplexKey key;
for(size_t w = 0; w < key.words.size(); w++)
{
key.words[w] = i & (1U << w);
key.words[w] = i & (1ull << w);
}
cache.lookup(key);
}
......@@ -190,7 +190,7 @@ BENCHMARK_DEFINE_F(LRUCacheBenchmark, GetComplexKeyCacheMiss)
ComplexKey key;
for(size_t w = 0; w < key.words.size(); w++)
{
key.words[w] = 8 + (1U << w);
key.words[w] = 8 + (1ull << w);
}
cache.add(key, i);
}
......@@ -202,7 +202,7 @@ BENCHMARK_DEFINE_F(LRUCacheBenchmark, GetComplexKeyCacheMiss)
ComplexKey key;
for(size_t w = 0; w < key.words.size(); w++)
{
key.words[w] = i & (1U << w);
key.words[w] = i & (1ull << w);
}
cache.lookup(key);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment