OSDN Git Service

Fixed size verification assert to include border
authorAlexis Hetu <sugoi@google.com>
Mon, 18 Jun 2018 19:19:55 +0000 (15:19 -0400)
committerAlexis Hétu <sugoi@google.com>
Mon, 18 Jun 2018 19:45:30 +0000 (19:45 +0000)
Whenever a cube map was being used, these asserts would fire as soon
as any border computation would happen. Fixed the asserts to allow
cube maps to work properly.

Change-Id: Iedc2661e63db37e5b4e77e08f97ce044e9f88837
Reviewed-on: https://swiftshader-review.googlesource.com/19468
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
src/Renderer/Surface.cpp

index 5fc506d..cc1c5a7 100644 (file)
@@ -44,7 +44,9 @@ namespace sw
 
        void Surface::Buffer::write(int x, int y, int z, const Color<float> &color)
        {
-               ASSERT(x < width && y < height && z < depth);
+               ASSERT((x >= -border) && (x < (width + border)));
+               ASSERT((y >= -border) && (y < (height + border)));
+               ASSERT((z >= 0) && (z < depth));
 
                byte *element = (byte*)buffer + (x + border) * bytes + (y + border) * pitchB + z * samples * sliceB;
 
@@ -57,7 +59,8 @@ namespace sw
 
        void Surface::Buffer::write(int x, int y, const Color<float> &color)
        {
-               ASSERT(x < width && y < height);
+               ASSERT((x >= -border) && (x < (width + border)));
+               ASSERT((y >= -border) && (y < (height + border)));
 
                byte *element = (byte*)buffer + (x + border) * bytes + (y + border) * pitchB;
 
@@ -400,7 +403,9 @@ namespace sw
 
        Color<float> Surface::Buffer::read(int x, int y, int z) const
        {
-               ASSERT(x < width && y < height && z < depth);
+               ASSERT((x >= -border) && (x < (width + border)));
+               ASSERT((y >= -border) && (y < (height + border)));
+               ASSERT((z >= 0) && (z < depth));
 
                void *element = (unsigned char*)buffer + (x + border) * bytes + (y + border) * pitchB + z * samples * sliceB;
 
@@ -409,7 +414,8 @@ namespace sw
 
        Color<float> Surface::Buffer::read(int x, int y) const
        {
-               ASSERT(x < width && y < height);
+               ASSERT((x >= -border) && (x < (width + border)));
+               ASSERT((y >= -border) && (y < (height + border)));
 
                void *element = (unsigned char*)buffer + (x + border) * bytes + (y + border) * pitchB;