diff options
author | Timothy Arceri <[email protected]> | 2017-04-08 10:54:56 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-04-10 10:55:34 +1000 |
commit | d0791ac2eddd3d9aaae91034ae897c9628f66174 (patch) | |
tree | 92134c8f43420692909e66318580e03f807e8b03 /src/mesa/state_tracker | |
parent | d9fe82fe4198425cd42081e7fd5bd7ac69aacdd2 (diff) |
mesa/st: take ownership rather than adding reference for new renderbuffers
This avoids locking in the reference calls and fixes a leak after the
RefCount initialisation was change from 0 to 1.
Fixes: 32141e53d1520 (mesa: tidy up renderbuffer RefCount initialisation)
Reviewed-by: Emil Velikov <[email protected]>
Tested-by: Bartosz Tomczyk <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r-- | src/mesa/state_tracker/st_manager.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c index f469ebd3a0d..a91dc76d226 100644 --- a/src/mesa/state_tracker/st_manager.c +++ b/src/mesa/state_tracker/st_manager.c @@ -312,13 +312,21 @@ st_framebuffer_add_renderbuffer(struct st_framebuffer *stfb, return FALSE; if (idx != BUFFER_DEPTH) { - _mesa_add_renderbuffer(&stfb->Base, idx, rb); + _mesa_add_renderbuffer_without_ref(&stfb->Base, idx, rb); + return TRUE; } - else { - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)) - _mesa_add_renderbuffer(&stfb->Base, BUFFER_DEPTH, rb); - if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) + + bool rb_ownership_taken = false; + if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 0)) { + _mesa_add_renderbuffer_without_ref(&stfb->Base, BUFFER_DEPTH, rb); + rb_ownership_taken = true; + } + + if (util_format_get_component_bits(format, UTIL_FORMAT_COLORSPACE_ZS, 1)) { + if (rb_ownership_taken) _mesa_add_renderbuffer(&stfb->Base, BUFFER_STENCIL, rb); + else + _mesa_add_renderbuffer_without_ref(&stfb->Base, BUFFER_STENCIL, rb); } return TRUE; |