diff options
author | Timothy Arceri <[email protected]> | 2017-04-21 13:29:46 +1000 |
---|---|---|
committer | Timothy Arceri <[email protected]> | 2017-04-22 10:01:15 +1000 |
commit | 622a68ed3e36a6b56db35df62c5913d2d54d5ed6 (patch) | |
tree | 974998286efcf4ed0528766666b54013e8e07c62 | |
parent | 0cc8c81902dffdd0c2e1f74e7828a6132cb70b9f (diff) |
mesa: remove fallback RefCount == 0 pattern
We should never get here if this is 0 unless there is a
bug. Replace the check with an assert.
Reviewed-by: Nicolai Hähnle <[email protected]>
Reviewed-by: Samuel Pitoiset <[email protected]>
-rw-r--r-- | src/mesa/main/arrayobj.c | 14 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.c | 14 | ||||
-rw-r--r-- | src/mesa/main/pipelineobj.c | 14 | ||||
-rw-r--r-- | src/mesa/main/samplerobj.c | 14 | ||||
-rw-r--r-- | src/mesa/main/texobj.c | 14 | ||||
-rw-r--r-- | src/mesa/main/transformfeedback.c | 14 |
6 files changed, 25 insertions, 59 deletions
diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index ab1b834b6d9..fdb3caad954 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -208,16 +208,10 @@ _mesa_reference_vao_(struct gl_context *ctx, if (vao) { /* reference new array object */ mtx_lock(&vao->Mutex); - if (vao->RefCount == 0) { - /* this array's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted array object"); - *ptr = NULL; - } - else { - vao->RefCount++; - *ptr = vao; - } + assert(vao->RefCount > 0); + + vao->RefCount++; + *ptr = vao; mtx_unlock(&vao->Mutex); } } diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 922c7d82fcb..961871c91d5 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -511,16 +511,10 @@ _mesa_reference_buffer_object_(struct gl_context *ctx, if (bufObj) { /* reference new buffer */ mtx_lock(&bufObj->Mutex); - if (bufObj->RefCount == 0) { - /* this buffer's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted buffer object"); - *ptr = NULL; - } - else { - bufObj->RefCount++; - *ptr = bufObj; - } + assert(bufObj->RefCount > 0); + + bufObj->RefCount++; + *ptr = bufObj; mtx_unlock(&bufObj->Mutex); } } diff --git a/src/mesa/main/pipelineobj.c b/src/mesa/main/pipelineobj.c index c1dd8d75c76..2988c97455e 100644 --- a/src/mesa/main/pipelineobj.c +++ b/src/mesa/main/pipelineobj.c @@ -206,16 +206,10 @@ _mesa_reference_pipeline_object_(struct gl_context *ctx, if (obj) { /* reference new pipeline object */ mtx_lock(&obj->Mutex); - if (obj->RefCount == 0) { - /* this pipeline's being deleted (look just above) */ - /* Not sure this can ever really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted pipeline object"); - *ptr = NULL; - } - else { - obj->RefCount++; - *ptr = obj; - } + assert(obj->RefCount > 0); + + obj->RefCount++; + *ptr = obj; mtx_unlock(&obj->Mutex); } } diff --git a/src/mesa/main/samplerobj.c b/src/mesa/main/samplerobj.c index 183f1d2a862..63beaf1abba 100644 --- a/src/mesa/main/samplerobj.c +++ b/src/mesa/main/samplerobj.c @@ -97,16 +97,10 @@ _mesa_reference_sampler_object_(struct gl_context *ctx, if (samp) { /* reference new sampler */ mtx_lock(&samp->Mutex); - if (samp->RefCount == 0) { - /* this sampler's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted sampler object"); - *ptr = NULL; - } - else { - samp->RefCount++; - *ptr = samp; - } + assert(samp->RefCount > 0); + + samp->RefCount++; + *ptr = samp; mtx_unlock(&samp->Mutex); } } diff --git a/src/mesa/main/texobj.c b/src/mesa/main/texobj.c index 00feb975522..af9baa976fc 100644 --- a/src/mesa/main/texobj.c +++ b/src/mesa/main/texobj.c @@ -566,16 +566,10 @@ _mesa_reference_texobj_(struct gl_texture_object **ptr, /* reference new texture */ assert(valid_texture_object(tex)); mtx_lock(&tex->Mutex); - if (tex->RefCount == 0) { - /* this texture's being deleted (look just above) */ - /* Not sure this can every really happen. Warn if it does. */ - _mesa_problem(NULL, "referencing deleted texture object"); - *ptr = NULL; - } - else { - tex->RefCount++; - *ptr = tex; - } + assert(tex->RefCount > 0); + + tex->RefCount++; + *ptr = tex; mtx_unlock(&tex->Mutex); } } diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 96f3df1c961..131014ff653 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -110,16 +110,12 @@ reference_transform_feedback_object(struct gl_transform_feedback_object **ptr, assert(!*ptr); if (obj) { + assert(obj->RefCount > 0); + /* reference new object */ - if (obj->RefCount == 0) { - _mesa_problem(NULL, "referencing deleted transform feedback object"); - *ptr = NULL; - } - else { - obj->RefCount++; - obj->EverBound = GL_TRUE; - *ptr = obj; - } + obj->RefCount++; + obj->EverBound = GL_TRUE; + *ptr = obj; } } |