Guard against clearing null depth/stencil buffers.
Change-Id: Ic0a16ac68582e398a02eef722d52a77a1ebde877
Reviewed-on: https://swiftshader-review.googlesource.com/18508
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Renderer/Surface.cpp b/src/Renderer/Surface.cpp
index 8bb80ec..9be7467 100644
--- a/src/Renderer/Surface.cpp
+++ b/src/Renderer/Surface.cpp
@@ -3356,7 +3356,15 @@
void Surface::clearDepth(float depth, int x0, int y0, int width, int height)
{
- if(width == 0 || height == 0) return;
+ if(width == 0 || height == 0)
+ {
+ return;
+ }
+
+ if(internal.format == FORMAT_NULL)
+ {
+ return;
+ }
// Not overlapping
if(x0 > internal.width) return;
@@ -3479,7 +3487,15 @@
void Surface::clearStencil(unsigned char s, unsigned char mask, int x0, int y0, int width, int height)
{
- if(mask == 0 || width == 0 || height == 0) return;
+ if(mask == 0 || width == 0 || height == 0)
+ {
+ return;
+ }
+
+ if(stencil.format == FORMAT_NULL)
+ {
+ return;
+ }
// Not overlapping
if(x0 > internal.width) return;