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;