Fix clearing all samples of multisample render targets. Only libGLESv2 was clearing all the samples of a multisample buffer. Since all known APIs always clear all the samples, this could be handled in the Renderer. Bug swiftshader:77 Change-Id: Ib9adc3c61d263420ed0a0ae4828a693bd360b076 Reviewed-on: https://swiftshader-review.googlesource.com/10788 Reviewed-by: Alexis Hétu <sugoi@google.com> Reviewed-by: Nicolas Capens <nicolascapens@google.com> Tested-by: Nicolas Capens <nicolascapens@google.com>
diff --git a/src/Renderer/Renderer.cpp b/src/Renderer/Renderer.cpp index 7afbb9f..252d744 100644 --- a/src/Renderer/Renderer.cpp +++ b/src/Renderer/Renderer.cpp
@@ -672,9 +672,15 @@ } } - void Renderer::clear(void *pixel, Format format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask) + void Renderer::clear(void *value, Format format, Surface *dest, const Rect &clearRect, unsigned int rgbaMask) { - blitter->clear(pixel, format, dest, dRect, rgbaMask); + SliceRect rect = clearRect; + int samples = dest->getDepth(); + + for(rect.slice = 0; rect.slice < samples; rect.slice++) + { + blitter->clear(value, format, dest, rect, rgbaMask); + } } void Renderer::blit(Surface *source, const SliceRect &sRect, Surface *dest, const SliceRect &dRect, bool filter, bool isStencil)
diff --git a/src/Renderer/Renderer.hpp b/src/Renderer/Renderer.hpp index dedd17a..d796475 100644 --- a/src/Renderer/Renderer.hpp +++ b/src/Renderer/Renderer.hpp
@@ -326,7 +326,7 @@ void draw(DrawType drawType, unsigned int indexOffset, unsigned int count, bool update = true); - void clear(void* pixel, Format format, Surface *dest, const SliceRect &dRect, unsigned int rgbaMask); + void clear(void *value, Format format, Surface *dest, const Rect &rect, unsigned int rgbaMask); void blit(Surface *source, const SliceRect &sRect, Surface *dest, const SliceRect &dRect, bool filter, bool isStencil = false); void blit3D(Surface *source, Surface *dest);
diff --git a/src/Renderer/Surface.cpp b/src/Renderer/Surface.cpp index 1a63ff9..6bcc657 100644 --- a/src/Renderer/Surface.cpp +++ b/src/Renderer/Surface.cpp
@@ -3193,14 +3193,14 @@ resource->unlock(); } - bool Surface::isEntire(const SliceRect& rect) const + bool Surface::isEntire(const Rect& rect) const { return (rect.x0 == 0 && rect.y0 == 0 && rect.x1 == internal.width && rect.y1 == internal.height && internal.depth == 1); } - SliceRect Surface::getRect() const + Rect Surface::getRect() const { - return SliceRect(0, 0, internal.width, internal.height, 0); + return Rect(0, 0, internal.width, internal.height); } void Surface::clearDepth(float depth, int x0, int y0, int width, int height)
diff --git a/src/Renderer/Surface.hpp b/src/Renderer/Surface.hpp index b54565e..6418c08 100644 --- a/src/Renderer/Surface.hpp +++ b/src/Renderer/Surface.hpp
@@ -299,8 +299,8 @@ inline int getMultiSampleCount() const; inline int getSuperSampleCount() const; - bool isEntire(const SliceRect& rect) const; - SliceRect getRect() const; + bool isEntire(const Rect& rect) const; + Rect getRect() const; void clearDepth(float depth, int x0, int y0, int width, int height); void clearStencil(unsigned char stencil, unsigned char mask, int x0, int y0, int width, int height); void fill(const Color<float> &color, int x0, int y0, int width, int height);