Commit 426cb5e1 by Nicolas Capens Committed by Nicolas Capens

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/10788Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 56f256e7
......@@ -365,7 +365,7 @@ namespace D3D8
for(unsigned int i = 0; i < count; i++)
{
sw::SliceRect clearRect(rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2, 0);
sw::Rect clearRect(rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
clearRect.clip(viewport.X, viewport.Y, viewport.X + viewport.Width, viewport.Y + viewport.Height);
......
......@@ -396,7 +396,7 @@ namespace D3D9
for(unsigned int i = 0; i < count; i++)
{
sw::SliceRect clearRect(rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2, 0);
sw::Rect clearRect(rects[i].x1, rects[i].y1, rects[i].x2, rects[i].y2);
clearRect.clip(viewport.X, viewport.Y, viewport.X + viewport.Width, viewport.Y + viewport.Height);
......
......@@ -201,7 +201,7 @@ namespace gl
return;
}
sw::SliceRect clearRect = renderTarget->getRect();
sw::Rect clearRect = renderTarget->getRect();
if(scissorEnable)
{
......@@ -225,7 +225,7 @@ namespace gl
}
z = clamp01(z);
sw::SliceRect clearRect = depthStencil->getRect();
sw::Rect clearRect = depthStencil->getRect();
if(scissorEnable)
{
......@@ -242,7 +242,7 @@ namespace gl
return;
}
sw::SliceRect clearRect = depthStencil->getRect();
sw::Rect clearRect = depthStencil->getRect();
if(scissorEnable)
{
......
......@@ -172,7 +172,7 @@ namespace es1
rgba[2] = blue;
rgba[3] = alpha;
sw::SliceRect clearRect = renderTarget->getRect();
sw::Rect clearRect = renderTarget->getRect();
if(scissorEnable)
{
......@@ -190,7 +190,7 @@ namespace es1
}
z = clamp01(z);
sw::SliceRect clearRect = depthBuffer->getRect();
sw::Rect clearRect = depthBuffer->getRect();
if(scissorEnable)
{
......@@ -207,7 +207,7 @@ namespace es1
return;
}
sw::SliceRect clearRect = stencilBuffer->getRect();
sw::Rect clearRect = stencilBuffer->getRect();
if(scissorEnable)
{
......
......@@ -3329,7 +3329,7 @@ void Context::clearColorBuffer(GLint drawbuffer, void *value, sw::Format format)
if(colorbuffer)
{
sw::SliceRect clearRect = colorbuffer->getRect();
sw::Rect clearRect = colorbuffer->getRect();
if(mState.scissorTestEnabled)
{
......@@ -3368,7 +3368,7 @@ void Context::clearDepthBuffer(const GLfloat value)
if(depthbuffer)
{
float depth = clamp01(value);
sw::SliceRect clearRect = depthbuffer->getRect();
sw::Rect clearRect = depthbuffer->getRect();
if(mState.scissorTestEnabled)
{
......@@ -3392,7 +3392,7 @@ void Context::clearStencilBuffer(const GLint value)
if(stencilbuffer)
{
unsigned char stencil = value < 0 ? 0 : static_cast<unsigned char>(value & 0x000000FF);
sw::SliceRect clearRect = stencilbuffer->getRect();
sw::Rect clearRect = stencilbuffer->getRect();
if(mState.scissorTestEnabled)
{
......
......@@ -202,18 +202,14 @@ namespace es2
{
if(renderTarget[i])
{
sw::SliceRect clearRect = renderTarget[i]->getRect();
sw::Rect clearRect = renderTarget[i]->getRect();
if(scissorEnable)
{
clearRect.clip(scissorRect.x0, scissorRect.y0, scissorRect.x1, scissorRect.y1);
}
int depth = sw::max(renderTarget[i]->getDepth(), 1);
for(clearRect.slice = 0; clearRect.slice < depth; clearRect.slice++)
{
clear(rgba, FORMAT_A32B32G32R32F, renderTarget[i], clearRect, rgbaMask);
}
clear(rgba, FORMAT_A32B32G32R32F, renderTarget[i], clearRect, rgbaMask);
}
}
}
......@@ -226,7 +222,7 @@ namespace es2
}
z = clamp01(z);
sw::SliceRect clearRect = depthBuffer->getRect();
sw::Rect clearRect = depthBuffer->getRect();
if(scissorEnable)
{
......@@ -243,7 +239,7 @@ namespace es2
return;
}
sw::SliceRect clearRect = stencilBuffer->getRect();
sw::Rect clearRect = stencilBuffer->getRect();
if(scissorEnable)
{
......
......@@ -672,9 +672,15 @@ namespace sw
}
}
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)
......
......@@ -326,7 +326,7 @@ namespace sw
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);
......
......@@ -3193,14 +3193,14 @@ namespace sw
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)
......
......@@ -299,8 +299,8 @@ namespace sw
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);
......
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