summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorassiduous <assiduous@diligentgraphics.com>2020-06-10 21:54:41 +0000
committerassiduous <assiduous@diligentgraphics.com>2020-06-10 21:54:41 +0000
commite0d30b2e8a50adefcfa299b6cce8ec44056c2638 (patch)
treee3b0603b5311b3fd77615dec99a9fd32fcf81825
parentAdded static tests to catch base class misalginment issues (diff)
downloadDiligentCore-e0d30b2e8a50adefcfa299b6cce8ec44056c2638.tar.gz
DiligentCore-e0d30b2e8a50adefcfa299b6cce8ec44056c2638.zip
Fixed few alignment-related issues (API Version 240063)
-rw-r--r--Graphics/GraphicsEngine/interface/APIInfo.h2
-rw-r--r--Graphics/GraphicsEngine/interface/GraphicsTypes.h3
-rw-r--r--Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp2
-rw-r--r--Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp9
4 files changed, 13 insertions, 3 deletions
diff --git a/Graphics/GraphicsEngine/interface/APIInfo.h b/Graphics/GraphicsEngine/interface/APIInfo.h
index c86914dc..18833f81 100644
--- a/Graphics/GraphicsEngine/interface/APIInfo.h
+++ b/Graphics/GraphicsEngine/interface/APIInfo.h
@@ -30,7 +30,7 @@
/// \file
/// Diligent API information
-#define DILIGENT_API_VERSION 240062
+#define DILIGENT_API_VERSION 240063
#include "../../../Primitives/interface/BasicTypes.h"
diff --git a/Graphics/GraphicsEngine/interface/GraphicsTypes.h b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
index ece12fea..0d0631b7 100644
--- a/Graphics/GraphicsEngine/interface/GraphicsTypes.h
+++ b/Graphics/GraphicsEngine/interface/GraphicsTypes.h
@@ -1866,6 +1866,9 @@ struct TextureFormatInfo DILIGENT_DERIVE(TextureFormatAttribs)
/// Indicates if the format is supported by the device
bool Supported DEFAULT_INITIALIZER(false);
+
+ // Explicitly pad the structure to 8-byte boundary
+ bool Padding[7];
};
typedef struct TextureFormatInfo TextureFormatInfo;
diff --git a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
index 74293d1b..523a5108 100644
--- a/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
+++ b/Graphics/GraphicsEngineVulkan/src/ShaderVkImpl.cpp
@@ -61,7 +61,7 @@ ShaderVkImpl::ShaderVkImpl(IReferenceCounters* pRefCounters,
DEV_CHECK_ERR(CreationAttribs.ByteCode == nullptr, "'ByteCode' must be null when shader is created from source code or a file");
DEV_CHECK_ERR(CreationAttribs.ByteCodeSize == 0, "'ByteCodeSize' must be 0 when shader is created from source code or a file");
- static constexpr char* VulkanDefine =
+ static constexpr char VulkanDefine[] =
"#ifndef VULKAN\n"
"# define VULKAN 1\n"
"#endif\n";
diff --git a/Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp b/Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp
index c78f7a9f..d5c39436 100644
--- a/Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp
+++ b/Tests/IncludeTest/GraphicsEngine/GraphicsTypesH_test.cpp
@@ -65,12 +65,19 @@ namespace
// When compiling S2 with x64 gcc, it will place 'b' right after 'a', not after the end of struct S1.
// We try to catch such issues below
+
+#ifdef __GNUC__
+// Disable GCC warnings like this one:
+// warning: offsetof within non-standard-layout type ‘Diligent::{anonymous}::DeviceObjectAttribs is conditionally-supported [-Winvalid-offsetof]
+# pragma GCC diagnostic ignored "-Winvalid-offsetof"
+#endif
+
#define CHECK_BASE_STRUCT_ALIGNMENT(StructName) \
struct StructName##Test : StructName \
{ \
Uint8 AlignmentTest; \
}; \
- static_assert(offsetof(StructName##Test, AlignmentTest) == sizeof(StructName), "Using " #StructName " as a base class causes misalignment")
+ static_assert(offsetof(StructName##Test, AlignmentTest) == sizeof(StructName), "Using " #StructName " as a base class may result in misalignment")
CHECK_BASE_STRUCT_ALIGNMENT(DeviceObjectAttribs);
CHECK_BASE_STRUCT_ALIGNMENT(EngineCreateInfo);