Commit 81519cfc by Alexis Hetu Committed by Alexis Hétu

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/7131Tested-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <capn@google.com>
parent bffe803c
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Main/FrameBuffer.hpp" #include "Main/FrameBuffer.hpp"
#include "Common/Math.hpp" #include "Common/Math.hpp"
#include "Common/Configurator.hpp" #include "Common/Configurator.hpp"
#include "Common/Memory.hpp"
#include "Common/Timer.hpp" #include "Common/Timer.hpp"
#include "../common/debug.h" #include "../common/debug.h"
...@@ -181,6 +182,18 @@ namespace gl ...@@ -181,6 +182,18 @@ namespace gl
delete context; 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) void Device::clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask)
{ {
if(!renderTarget || !rgbaMask) if(!renderTarget || !rgbaMask)
......
...@@ -51,6 +51,9 @@ namespace gl ...@@ -51,6 +51,9 @@ namespace gl
virtual ~Device(); 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 clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask);
void clearDepth(float z); void clearDepth(float z);
void clearStencil(unsigned int stencil, unsigned int mask); void clearStencil(unsigned int stencil, unsigned int mask);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Main/FrameBuffer.hpp" #include "Main/FrameBuffer.hpp"
#include "Common/Math.hpp" #include "Common/Math.hpp"
#include "Common/Configurator.hpp" #include "Common/Configurator.hpp"
#include "Common/Memory.hpp"
#include "Common/Timer.hpp" #include "Common/Timer.hpp"
#include "../common/debug.h" #include "../common/debug.h"
...@@ -146,6 +147,18 @@ namespace es1 ...@@ -146,6 +147,18 @@ namespace es1
delete context; 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) void Device::clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask)
{ {
if(!renderTarget || !rgbaMask) if(!renderTarget || !rgbaMask)
......
...@@ -43,6 +43,9 @@ namespace es1 ...@@ -43,6 +43,9 @@ namespace es1
virtual ~Device(); 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 clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask);
void clearDepth(float z); void clearDepth(float z);
void clearStencil(unsigned int stencil, unsigned int mask); void clearStencil(unsigned int stencil, unsigned int mask);
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "Main/FrameBuffer.hpp" #include "Main/FrameBuffer.hpp"
#include "Common/Math.hpp" #include "Common/Math.hpp"
#include "Common/Configurator.hpp" #include "Common/Configurator.hpp"
#include "Common/Memory.hpp"
#include "Common/Timer.hpp" #include "Common/Timer.hpp"
#include "../common/debug.h" #include "../common/debug.h"
...@@ -172,6 +173,18 @@ namespace es2 ...@@ -172,6 +173,18 @@ namespace es2
delete context; 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) void Device::clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask)
{ {
if(!rgbaMask) if(!rgbaMask)
......
...@@ -43,6 +43,9 @@ namespace es2 ...@@ -43,6 +43,9 @@ namespace es2
virtual ~Device(); 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 clearColor(float red, float green, float blue, float alpha, unsigned int rgbaMask);
void clearDepth(float z); void clearDepth(float z);
void clearStencil(unsigned int stencil, unsigned int mask); void clearStencil(unsigned int stencil, unsigned int mask);
......
...@@ -135,7 +135,7 @@ ...@@ -135,7 +135,7 @@
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat> <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<BrowseInformation>true</BrowseInformation> <BrowseInformation>true</BrowseInformation>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4316;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
...@@ -200,7 +200,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr ...@@ -200,7 +200,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions> <IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4316;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
...@@ -275,7 +275,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr ...@@ -275,7 +275,7 @@ copy "$(OutDir)libGLESv2.dll" "$(SolutionDir)lib\$(Configuration)_$(Platform)\tr
<WholeProgramOptimization>true</WholeProgramOptimization> <WholeProgramOptimization>true</WholeProgramOptimization>
<IntrinsicFunctions>false</IntrinsicFunctions> <IntrinsicFunctions>false</IntrinsicFunctions>
<TreatWarningAsError>true</TreatWarningAsError> <TreatWarningAsError>true</TreatWarningAsError>
<DisableSpecificWarnings>4316;%(DisableSpecificWarnings)</DisableSpecificWarnings> <DisableSpecificWarnings>%(DisableSpecificWarnings)</DisableSpecificWarnings>
</ClCompile> </ClCompile>
<Link> <Link>
<AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies> <AdditionalDependencies>dxguid.lib;WS2_32.lib;%(AdditionalDependencies)</AdditionalDependencies>
......
...@@ -190,6 +190,18 @@ namespace sw ...@@ -190,6 +190,18 @@ namespace sw
delete swiftConfig; 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) void Renderer::clear(void *pixel, Format format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask)
{ {
blitter.clear(pixel, format, dest, dRect, rgbaMask); blitter.clear(pixel, format, dest, dRect, rgbaMask);
......
...@@ -318,6 +318,9 @@ namespace sw ...@@ -318,6 +318,9 @@ namespace sw
virtual ~Renderer(); 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 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 blit(Surface *source, const SliceRect &sRect, Surface *dest, const SliceRect &dRect, bool filter);
void blit3D(Surface *source, Surface *dest); void blit3D(Surface *source, Surface *dest);
......
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