Commit 810f3db8 by Nicolas Capens Committed by Nicolas Capens

Fix stencil buffer memory leak.

Locking stencil buffers with a NULL format resulted in nullptr being returned without acquiring the resource lock, while unlocking did release the lock. Instead of not releasing it on unlock, we must acquire it on lock because otherwise the object could get destroyed before draw operations end and attempt to unlock. Bug b/116876483 Change-Id: Ie883115a1d6df3b40eb7c1feb5dcfde7316ec970 Reviewed-on: https://swiftshader-review.googlesource.com/21148Reviewed-by: 's avatarKrzysztof Kosiński <krzysio@google.com> Reviewed-by: 's avatarAlexis Hétu <sugoi@google.com> Tested-by: 's avatarKrzysztof Kosiński <krzysio@google.com> Tested-by: 's avatarNicolas Capens <nicolascapens@google.com>
parent 876760bb
......@@ -23,11 +23,11 @@ script:
- make
- ./unittests
notifications:
email:
recipients:
- swiftshader-team@google.com
on_success: never
notifications:
email:
recipients:
- swiftshader-team@google.com
on_success: never
on_failure: always
deploy:
......
......@@ -15,6 +15,7 @@
#include "Resource.hpp"
#include "Memory.hpp"
#include "Debug.hpp"
namespace sw
{
......@@ -106,6 +107,7 @@ namespace sw
void Resource::unlock()
{
criticalSection.lock();
ASSERT(count > 0);
count--;
......@@ -131,6 +133,7 @@ namespace sw
void Resource::unlock(Accessor relinquisher)
{
criticalSection.lock();
ASSERT(count > 0);
while(count > 0 && accessor == relinquisher)
{
......
......@@ -1389,9 +1389,9 @@ namespace sw
deallocate(stencil.buffer);
external.buffer = 0;
internal.buffer = 0;
stencil.buffer = 0;
external.buffer = nullptr;
internal.buffer = nullptr;
stencil.buffer = nullptr;
}
void *Surface::lockExternal(int x, int y, int z, Lock lock, Accessor client)
......@@ -1529,13 +1529,13 @@ namespace sw
void *Surface::lockStencil(int x, int y, int front, Accessor client)
{
resource->lock(client);
if(stencil.format == FORMAT_NULL)
{
return nullptr;
}
resource->lock(client);
if(!stencil.buffer)
{
stencil.buffer = allocateBuffer(stencil.width, stencil.height, stencil.depth, stencil.border, stencil.samples, stencil.format);
......
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