Fixed alignment warnings
Some alignment warnings were popping up on some windows bots.
Rather than silencing them, I just fixed them.
Change-Id: I21bc558e04498357c5d76a9caf9bd86f0a5cb540
Reviewed-on: https://swiftshader-review.googlesource.com/7131
Tested-by: Alexis Hétu <sugoi@google.com>
Reviewed-by: Nicolas Capens <capn@google.com>
diff --git a/src/OpenGL/libGL/Device.cpp b/src/OpenGL/libGL/Device.cpp
index 2070e27..57c669f 100644
--- a/src/OpenGL/libGL/Device.cpp
+++ b/src/OpenGL/libGL/Device.cpp
@@ -25,6 +25,7 @@
#include "Main/FrameBuffer.hpp"
#include "Common/Math.hpp"
#include "Common/Configurator.hpp"
+#include "Common/Memory.hpp"
#include "Common/Timer.hpp"
#include "../common/debug.h"
@@ -181,6 +182,18 @@
delete context;
}
+ // This object has to be mem aligned
+ void* Device::operator new(size_t size)
+ {
+ ASSERT(size == sizeof(Device)); // This operator can't be called from a derived class
+ return sw::allocate(sizeof(gl::Device), 16);
+ }
+
+ void Device::operator delete(void * mem)
+ {
+ sw::deallocate(mem);
+ }
+
void Device::clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask)
{
if(!renderTarget || !rgbaMask)
diff --git a/src/OpenGL/libGL/Device.hpp b/src/OpenGL/libGL/Device.hpp
index e7567ac..b58d309 100644
--- a/src/OpenGL/libGL/Device.hpp
+++ b/src/OpenGL/libGL/Device.hpp
@@ -51,6 +51,9 @@
virtual ~Device();
+ void *operator new(size_t size);
+ void operator delete(void * mem);
+
void clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask);
void clearDepth(float z);
void clearStencil(unsigned int stencil, unsigned int mask);
diff --git a/src/OpenGL/libGLES_CM/Device.cpp b/src/OpenGL/libGLES_CM/Device.cpp
index 7a7f022..6587d36 100644
--- a/src/OpenGL/libGLES_CM/Device.cpp
+++ b/src/OpenGL/libGLES_CM/Device.cpp
@@ -25,6 +25,7 @@
#include "Main/FrameBuffer.hpp"
#include "Common/Math.hpp"
#include "Common/Configurator.hpp"
+#include "Common/Memory.hpp"
#include "Common/Timer.hpp"
#include "../common/debug.h"
@@ -146,6 +147,18 @@
delete context;
}
+ // This object has to be mem aligned
+ void* Device::operator new(size_t size)
+ {
+ ASSERT(size == sizeof(Device)); // This operator can't be called from a derived class
+ return sw::allocate(sizeof(Device), 16);
+ }
+
+ void Device::operator delete(void * mem)
+ {
+ sw::deallocate(mem);
+ }
+
void Device::clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask)
{
if(!renderTarget || !rgbaMask)
diff --git a/src/OpenGL/libGLES_CM/Device.hpp b/src/OpenGL/libGLES_CM/Device.hpp
index defcfee..c40e30d 100644
--- a/src/OpenGL/libGLES_CM/Device.hpp
+++ b/src/OpenGL/libGLES_CM/Device.hpp
@@ -43,6 +43,9 @@
virtual ~Device();
+ void *operator new(size_t size);
+ void operator delete(void * mem);
+
void clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask);
void clearDepth(float z);
void clearStencil(unsigned int stencil, unsigned int mask);
diff --git a/src/OpenGL/libGLESv2/Device.cpp b/src/OpenGL/libGLESv2/Device.cpp
index f24f984..765cc80 100644
--- a/src/OpenGL/libGLESv2/Device.cpp
+++ b/src/OpenGL/libGLESv2/Device.cpp
@@ -25,6 +25,7 @@
#include "Main/FrameBuffer.hpp"
#include "Common/Math.hpp"
#include "Common/Configurator.hpp"
+#include "Common/Memory.hpp"
#include "Common/Timer.hpp"
#include "../common/debug.h"
@@ -172,6 +173,18 @@
delete context;
}
+ // This object has to be mem aligned
+ void* Device::operator new(size_t size)
+ {
+ ASSERT(size == sizeof(Device)); // This operator can't be called from a derived class
+ return sw::allocate(sizeof(Device), 16);
+ }
+
+ void Device::operator delete(void * mem)
+ {
+ sw::deallocate(mem);
+ }
+
void Device::clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask)
{
if(!rgbaMask)
diff --git a/src/OpenGL/libGLESv2/Device.hpp b/src/OpenGL/libGLESv2/Device.hpp
index 9666f53..705597b 100644
--- a/src/OpenGL/libGLESv2/Device.hpp
+++ b/src/OpenGL/libGLESv2/Device.hpp
@@ -43,6 +43,9 @@
virtual ~Device();
+ void *operator new(size_t size);
+ void operator delete(void * mem);
+
void clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask);
void clearDepth(float z);
void clearStencil(unsigned int stencil, unsigned int mask);
diff --git a/src/OpenGL/libGLESv2/libGLESv2.vcxproj b/src/OpenGL/libGLESv2/libGLESv2.vcxproj
index 6321e8a..d4a775c 100644
--- a/src/OpenGL/libGLESv2/libGLESv2.vcxproj
+++ b/src/OpenGL/libGLESv2/libGLESv2.vcxproj
@@ -135,7 +135,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError>
- <DisableSpecificWarnings>4316;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -200,7 +200,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError>
- <DisableSpecificWarnings>4316;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
@@ -275,7 +275,7 @@
<WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError>
- <DisableSpecificWarnings>4316;%(DisableSpecificWarnings)</DisableSpecificWarnings>
+ <DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile>
<Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
diff --git a/src/Renderer/Renderer.cpp b/src/Renderer/Renderer.cpp
index 38b19ec..fe6c7f9 100644
--- a/src/Renderer/Renderer.cpp
+++ b/src/Renderer/Renderer.cpp
@@ -190,6 +190,18 @@
delete swiftConfig;
}
+ // This object has to be mem aligned
+ void* Renderer::operator new(size_t size)
+ {
+ ASSERT(size == sizeof(Renderer)); // This operator can't be called from a derived class
+ return sw::allocate(sizeof(Renderer), 16);
+ }
+
+ void Renderer::operator delete(void * mem)
+ {
+ sw::deallocate(mem);
+ }
+
void Renderer::clear(void *pixel, Format format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask)
{
blitter.clear(pixel, format, dest, dRect, rgbaMask);
diff --git a/src/Renderer/Renderer.hpp b/src/Renderer/Renderer.hpp
index dc644e1..334f814 100644
--- a/src/Renderer/Renderer.hpp
+++ b/src/Renderer/Renderer.hpp
@@ -318,6 +318,9 @@
virtual ~Renderer();
+ void *operator new(size_t size);
+ void operator delete(void * mem);
+
void clear(void* pixel, Format format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask);
void blit(Surface *source, const SliceRect &sRect, Surface *dest, const SliceRect &dRect, bool filter);
void blit3D(Surface *source, Surface *dest);