diff options
-rw-r--r-- | src/mesa/drivers/x11/xm_dd.c | 2 | ||||
-rw-r--r-- | src/mesa/main/arrayobj.c | 17 | ||||
-rw-r--r-- | src/mesa/main/attrib.c | 13 | ||||
-rw-r--r-- | src/mesa/main/bufferobj.c | 51 | ||||
-rw-r--r-- | src/mesa/main/draw.c | 3 | ||||
-rw-r--r-- | src/mesa/main/get.c | 38 | ||||
-rw-r--r-- | src/mesa/main/pixel.c | 3 | ||||
-rw-r--r-- | src/mesa/main/pixelstore.c | 9 | ||||
-rw-r--r-- | src/mesa/main/queryobj.c | 2 | ||||
-rw-r--r-- | src/mesa/main/texstate.c | 3 | ||||
-rw-r--r-- | src/mesa/main/transformfeedback.c | 3 | ||||
-rw-r--r-- | src/mesa/main/varray.c | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_rebase.c | 4 | ||||
-rw-r--r-- | src/mesa/tnl/t_split_copy.c | 2 | ||||
-rw-r--r-- | src/mesa/tnl/t_split_inplace.c | 2 | ||||
-rw-r--r-- | src/mesa/vbo/vbo_primitive_restart.c | 9 |
16 files changed, 62 insertions, 103 deletions
diff --git a/src/mesa/drivers/x11/xm_dd.c b/src/mesa/drivers/x11/xm_dd.c index 790cbccf505..1f8d78cb541 100644 --- a/src/mesa/drivers/x11/xm_dd.c +++ b/src/mesa/drivers/x11/xm_dd.c @@ -546,7 +546,7 @@ xmesa_DrawPixels_5R6G5B( struct gl_context *ctx, XPutImage(dpy, xrb->pixmap, gc, &ximage, 0, 0, dstX, dstY, w, h); } - if (unpack->BufferObj->Name) { + if (unpack->BufferObj) { ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL); } } diff --git a/src/mesa/main/arrayobj.c b/src/mesa/main/arrayobj.c index c05627b05b9..cf848bc177e 100644 --- a/src/mesa/main/arrayobj.c +++ b/src/mesa/main/arrayobj.c @@ -394,10 +394,7 @@ _mesa_initialize_vao(struct gl_context *ctx, GLuint name) { memcpy(vao, &ctx->Array.DefaultVAOState, sizeof(*vao)); - vao->Name = name; - _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, - ctx->Shared->NullBufferObj); } @@ -1242,14 +1239,16 @@ vertex_array_element_buffer(struct gl_context *ctx, GLuint vaobj, GLuint buffer, } else { bufObj = _mesa_lookup_bufferobj(ctx, buffer); } - } else { - bufObj = ctx->Shared->NullBufferObj; - } - if (bufObj) { + if (!bufObj) + return; + bufObj->UsageHistory |= USAGE_ELEMENT_ARRAY_BUFFER; - _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, bufObj); + } else { + bufObj = NULL; } + + _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj, bufObj); } @@ -1299,5 +1298,5 @@ _mesa_GetVertexArrayiv(GLuint vaobj, GLenum pname, GLint *param) return; } - param[0] = vao->IndexBufferObj->Name; + param[0] = vao->IndexBufferObj ? vao->IndexBufferObj->Name : 0; } diff --git a/src/mesa/main/attrib.c b/src/mesa/main/attrib.c index ce6c519737f..f84844ccea2 100644 --- a/src/mesa/main/attrib.c +++ b/src/mesa/main/attrib.c @@ -1666,21 +1666,24 @@ restore_array_attrib(struct gl_context *ctx, _mesa_BindVertexArray(src->VAO->Name); /* Restore or recreate the buffer objects by the names ... */ - if (is_vao_name_zero || src->ArrayBufferObj->Name == 0 || + if (is_vao_name_zero || !src->ArrayBufferObj || _mesa_IsBuffer(src->ArrayBufferObj->Name)) { /* ... and restore its content */ copy_array_attrib(ctx, dest, src, false); _mesa_BindBuffer(GL_ARRAY_BUFFER_ARB, - src->ArrayBufferObj->Name); + src->ArrayBufferObj ? + src->ArrayBufferObj->Name : 0); } else { copy_array_attrib(ctx, dest, src, true); } - if (is_vao_name_zero || src->VAO->IndexBufferObj->Name == 0 || - _mesa_IsBuffer(src->VAO->IndexBufferObj->Name)) + if (is_vao_name_zero || !src->VAO->IndexBufferObj || + _mesa_IsBuffer(src->VAO->IndexBufferObj->Name)) { _mesa_BindBuffer(GL_ELEMENT_ARRAY_BUFFER_ARB, - src->VAO->IndexBufferObj->Name); + src->VAO->IndexBufferObj ? + src->VAO->IndexBufferObj->Name : 0); + } } /** diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 9c4630bca12..39a620b22e6 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -869,35 +869,6 @@ _mesa_init_buffer_objects( struct gl_context *ctx ) simple_mtx_init(&DummyBufferObject.MinMaxCacheMutex, mtx_plain); DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */ - _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->CopyReadBuffer, - ctx->Shared->NullBufferObj); - _mesa_reference_buffer_object(ctx, &ctx->CopyWriteBuffer, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->UniformBuffer, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->ShaderStorageBuffer, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->AtomicBuffer, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->DrawIndirectBuffer, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->ParameterBuffer, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->DispatchIndirectBuffer, - ctx->Shared->NullBufferObj); - - _mesa_reference_buffer_object(ctx, &ctx->QueryBuffer, - ctx->Shared->NullBufferObj); - for (i = 0; i < MAX_COMBINED_UNIFORM_BUFFERS; i++) { _mesa_reference_buffer_object(ctx, &ctx->UniformBufferBindings[i].BufferObject, @@ -1012,29 +983,23 @@ bind_buffer_object(struct gl_context *ctx, /* Get pointer to old buffer object (to be unbound) */ oldBufObj = *bindTarget; - if (oldBufObj && oldBufObj->Name == buffer && !oldBufObj->DeletePending) + if ((oldBufObj && oldBufObj->Name == buffer && !oldBufObj->DeletePending) || + (!oldBufObj && buffer == 0)) return; /* rebinding the same buffer object- no change */ /* * Get pointer to new buffer object (newBufObj) */ - if (buffer == 0) { - /* The spec says there's not a buffer object named 0, but we use - * one internally because it simplifies things. - */ - newBufObj = ctx->Shared->NullBufferObj; - } - else { + if (buffer != 0) { /* non-default buffer object */ newBufObj = _mesa_lookup_bufferobj(ctx, buffer); if (!_mesa_handle_bind_buffer_gen(ctx, buffer, &newBufObj, "glBindBuffer")) return; - } - /* record usage history */ - if (bindTarget == &ctx->Pack.BufferObj) { - newBufObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER; + /* record usage history */ + if (bindTarget == &ctx->Pack.BufferObj) + newBufObj->UsageHistory |= USAGE_PIXEL_PACK_BUFFER; } /* bind new buffer */ @@ -1050,9 +1015,7 @@ bind_buffer_object(struct gl_context *ctx, void _mesa_update_default_objects_buffer_objects(struct gl_context *ctx) { - /* Bind the NullBufferObj to remove references to those - * in the shared context hash table. - */ + /* Bind 0 to remove references to those in the shared context hash table. */ bind_buffer_object(ctx, &ctx->Array.ArrayBufferObj, 0); bind_buffer_object(ctx, &ctx->Array.VAO->IndexBufferObj, 0); bind_buffer_object(ctx, &ctx->Pack.BufferObj, 0); diff --git a/src/mesa/main/draw.c b/src/mesa/main/draw.c index 5bb254e00d2..53946a72b20 100644 --- a/src/mesa/main/draw.c +++ b/src/mesa/main/draw.c @@ -917,7 +917,8 @@ _mesa_DrawRangeElementsBaseVertex(GLenum mode, GLuint start, GLuint end, "(start %u, end %u, type 0x%x, count %d) ElemBuf %u, " "base %d\n", start, end, type, count, - ctx->Array.VAO->IndexBufferObj->Name, basevertex); + ctx->Array.VAO->IndexBufferObj ? + ctx->Array.VAO->IndexBufferObj->Name : 0, basevertex); } if ((int) start + basevertex < 0 || end + basevertex >= max_element) diff --git a/src/mesa/main/get.c b/src/mesa/main/get.c index cbfe9c8b309..f71fd55c814 100644 --- a/src/mesa/main/get.c +++ b/src/mesa/main/get.c @@ -1009,14 +1009,16 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu v->value_int = (*buffer_obj) ? (*buffer_obj)->Name : 0; break; case GL_ARRAY_BUFFER_BINDING_ARB: - v->value_int = ctx->Array.ArrayBufferObj->Name; + buf = ctx->Array.ArrayBufferObj; + v->value_int = buf ? buf->Name : 0; break; case GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING_ARB: buf = ctx->Array.VAO->BufferBinding[VERT_ATTRIB_TEX(ctx->Array.ActiveTexture)].BufferObj; v->value_int = buf ? buf->Name : 0; break; case GL_ELEMENT_ARRAY_BUFFER_BINDING_ARB: - v->value_int = ctx->Array.VAO->IndexBufferObj->Name; + buf = ctx->Array.VAO->IndexBufferObj; + v->value_int = buf ? buf->Name : 0; break; /* ARB_vertex_array_bgra */ @@ -1031,20 +1033,21 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu /* ARB_copy_buffer */ case GL_COPY_READ_BUFFER: - v->value_int = ctx->CopyReadBuffer->Name; + v->value_int = ctx->CopyReadBuffer ? ctx->CopyReadBuffer->Name : 0; break; case GL_COPY_WRITE_BUFFER: - v->value_int = ctx->CopyWriteBuffer->Name; + v->value_int = ctx->CopyWriteBuffer ? ctx->CopyWriteBuffer->Name : 0; break; case GL_PIXEL_PACK_BUFFER_BINDING_EXT: - v->value_int = ctx->Pack.BufferObj->Name; + v->value_int = ctx->Pack.BufferObj ? ctx->Pack.BufferObj->Name : 0; break; case GL_PIXEL_UNPACK_BUFFER_BINDING_EXT: - v->value_int = ctx->Unpack.BufferObj->Name; + v->value_int = ctx->Unpack.BufferObj ? ctx->Unpack.BufferObj->Name : 0; break; case GL_TRANSFORM_FEEDBACK_BUFFER_BINDING: - v->value_int = ctx->TransformFeedback.CurrentBuffer->Name; + v->value_int = ctx->TransformFeedback.CurrentBuffer ? + ctx->TransformFeedback.CurrentBuffer->Name : 0; break; case GL_TRANSFORM_FEEDBACK_BUFFER_PAUSED: v->value_int = ctx->TransformFeedback.CurrentObject->Paused; @@ -1120,7 +1123,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu /* GL_ARB_texture_buffer_object */ case GL_TEXTURE_BUFFER_ARB: - v->value_int = ctx->Texture.BufferObject->Name; + v->value_int = ctx->Texture.BufferObject ? ctx->Texture.BufferObject->Name : 0; break; case GL_TEXTURE_BINDING_BUFFER_ARB: unit = ctx->Texture.CurrentUnit; @@ -1150,15 +1153,15 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; /* GL_ARB_uniform_buffer_object */ case GL_UNIFORM_BUFFER_BINDING: - v->value_int = ctx->UniformBuffer->Name; + v->value_int = ctx->UniformBuffer ? ctx->UniformBuffer->Name : 0; break; /* GL_ARB_shader_storage_buffer_object */ case GL_SHADER_STORAGE_BUFFER_BINDING: - v->value_int = ctx->ShaderStorageBuffer->Name; + v->value_int = ctx->ShaderStorageBuffer ? ctx->ShaderStorageBuffer->Name : 0; break; /* GL_ARB_query_buffer_object */ case GL_QUERY_BUFFER_BINDING: - v->value_int = ctx->QueryBuffer->Name; + v->value_int = ctx->QueryBuffer ? ctx->QueryBuffer->Name : 0; break; /* GL_ARB_timer_query */ case GL_TIMESTAMP: @@ -1179,11 +1182,7 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; /* GL_ARB_shader_atomic_counters */ case GL_ATOMIC_COUNTER_BUFFER_BINDING: - if (ctx->AtomicBuffer) { - v->value_int = ctx->AtomicBuffer->Name; - } else { - v->value_int = 0; - } + v->value_int = ctx->AtomicBuffer ? ctx->AtomicBuffer->Name : 0; break; /* GL 4.3 */ case GL_NUM_SHADING_LANGUAGE_VERSIONS: @@ -1191,11 +1190,11 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; /* GL_ARB_draw_indirect */ case GL_DRAW_INDIRECT_BUFFER_BINDING: - v->value_int = ctx->DrawIndirectBuffer->Name; + v->value_int = ctx->DrawIndirectBuffer ? ctx->DrawIndirectBuffer->Name: 0; break; /* GL_ARB_indirect_parameters */ case GL_PARAMETER_BUFFER_BINDING_ARB: - v->value_int = ctx->ParameterBuffer->Name; + v->value_int = ctx->ParameterBuffer ? ctx->ParameterBuffer->Name : 0; break; /* GL_ARB_separate_shader_objects */ case GL_PROGRAM_PIPELINE_BINDING: @@ -1207,7 +1206,8 @@ find_custom_value(struct gl_context *ctx, const struct value_desc *d, union valu break; /* GL_ARB_compute_shader */ case GL_DISPATCH_INDIRECT_BUFFER_BINDING: - v->value_int = ctx->DispatchIndirectBuffer->Name; + v->value_int = ctx->DispatchIndirectBuffer ? + ctx->DispatchIndirectBuffer->Name : 0; break; /* GL_ARB_multisample */ case GL_SAMPLES: diff --git a/src/mesa/main/pixel.c b/src/mesa/main/pixel.c index b234bacd9b6..f5856a0ea79 100644 --- a/src/mesa/main/pixel.c +++ b/src/mesa/main/pixel.c @@ -155,8 +155,7 @@ validate_pbo_access(struct gl_context *ctx, /* restore */ _mesa_reference_buffer_object(ctx, - &ctx->DefaultPacking.BufferObj, - ctx->Shared->NullBufferObj); + &ctx->DefaultPacking.BufferObj, NULL); if (!ok) { if (_mesa_is_bufferobj(pack->BufferObj)) { diff --git a/src/mesa/main/pixelstore.c b/src/mesa/main/pixelstore.c index 6123da92278..a7c3492b604 100644 --- a/src/mesa/main/pixelstore.c +++ b/src/mesa/main/pixelstore.c @@ -272,8 +272,7 @@ _mesa_init_pixelstore(struct gl_context *ctx) ctx->Pack.CompressedBlockHeight = 0; ctx->Pack.CompressedBlockDepth = 0; ctx->Pack.CompressedBlockSize = 0; - _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, - ctx->Shared->NullBufferObj); + _mesa_reference_buffer_object(ctx, &ctx->Pack.BufferObj, NULL); ctx->Unpack.Alignment = 4; ctx->Unpack.RowLength = 0; ctx->Unpack.ImageHeight = 0; @@ -287,8 +286,7 @@ _mesa_init_pixelstore(struct gl_context *ctx) ctx->Unpack.CompressedBlockHeight = 0; ctx->Unpack.CompressedBlockDepth = 0; ctx->Unpack.CompressedBlockSize = 0; - _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, - ctx->Shared->NullBufferObj); + _mesa_reference_buffer_object(ctx, &ctx->Unpack.BufferObj, NULL); /* * _mesa_unpack_image() returns image data in this format. When we @@ -305,8 +303,7 @@ _mesa_init_pixelstore(struct gl_context *ctx) ctx->DefaultPacking.SwapBytes = GL_FALSE; ctx->DefaultPacking.LsbFirst = GL_FALSE; ctx->DefaultPacking.Invert = GL_FALSE; - _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, - ctx->Shared->NullBufferObj); + _mesa_reference_buffer_object(ctx, &ctx->DefaultPacking.BufferObj, NULL); } diff --git a/src/mesa/main/queryobj.c b/src/mesa/main/queryobj.c index 032f9e9a437..0bbc5cfb887 100644 --- a/src/mesa/main/queryobj.c +++ b/src/mesa/main/queryobj.c @@ -825,7 +825,7 @@ get_query_object(struct gl_context *ctx, const char *func, return; } - if (buf && buf != ctx->Shared->NullBufferObj) { + if (buf) { bool is_64bit = ptype == GL_INT64_ARB || ptype == GL_UNSIGNED_INT64_ARB; if (!_mesa_has_ARB_query_buffer_object(ctx)) { diff --git a/src/mesa/main/texstate.c b/src/mesa/main/texstate.c index 9b64b64ae58..dfcfc4e8015 100644 --- a/src/mesa/main/texstate.c +++ b/src/mesa/main/texstate.c @@ -1072,8 +1072,7 @@ _mesa_init_texture(struct gl_context *ctx) return GL_FALSE; /* GL_ARB_texture_buffer_object */ - _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, - ctx->Shared->NullBufferObj); + _mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL); ctx->Texture.NumCurrentTexUsed = 0; diff --git a/src/mesa/main/transformfeedback.c b/src/mesa/main/transformfeedback.c index 06719b1ce82..b9cbe5a309b 100644 --- a/src/mesa/main/transformfeedback.c +++ b/src/mesa/main/transformfeedback.c @@ -142,8 +142,7 @@ _mesa_init_transform_feedback(struct gl_context *ctx) ctx->TransformFeedback.Objects = _mesa_NewHashTable(); _mesa_reference_buffer_object(ctx, - &ctx->TransformFeedback.CurrentBuffer, - ctx->Shared->NullBufferObj); + &ctx->TransformFeedback.CurrentBuffer, NULL); } diff --git a/src/mesa/main/varray.c b/src/mesa/main/varray.c index ec5e7191761..f516d0008d6 100644 --- a/src/mesa/main/varray.c +++ b/src/mesa/main/varray.c @@ -901,10 +901,6 @@ update_array(struct gl_context *ctx, assert((vao->NewArrays | ~vao->Enabled) & VERT_BIT(attrib)); array->Ptr = ptr; - /* TODO: remove this hack by not using NullBufferObj in callers */ - if (obj == ctx->Shared->NullBufferObj) - obj = NULL; - /* Update the vertex buffer binding */ GLsizei effectiveStride = stride != 0 ? stride : array->Format._ElementSize; diff --git a/src/mesa/tnl/t_rebase.c b/src/mesa/tnl/t_rebase.c index 07e603b0107..e6e5c9f3dfa 100644 --- a/src/mesa/tnl/t_rebase.c +++ b/src/mesa/tnl/t_rebase.c @@ -151,7 +151,7 @@ void t_rebase_prims( struct gl_context *ctx, } else if (ib) { /* Unfortunately need to adjust each index individually. */ - GLboolean map_ib = ib->obj->Name && + GLboolean map_ib = ib->obj && !ib->obj->Mappings[MAP_INTERNAL].Pointer; void *ptr; @@ -184,7 +184,7 @@ void t_rebase_prims( struct gl_context *ctx, return; } - tmp_ib.obj = ctx->Shared->NullBufferObj; + tmp_ib.obj = NULL; tmp_ib.ptr = tmp_indices; tmp_ib.count = ib->count; tmp_ib.index_size_shift = ib->index_size_shift; diff --git a/src/mesa/tnl/t_split_copy.c b/src/mesa/tnl/t_split_copy.c index 5b300e93553..9df55c78558 100644 --- a/src/mesa/tnl/t_split_copy.c +++ b/src/mesa/tnl/t_split_copy.c @@ -555,7 +555,7 @@ replay_init(struct copy_context *copy) */ copy->dstib.count = 0; /* duplicates dstelt_nr */ copy->dstib.index_size_shift = 2; - copy->dstib.obj = ctx->Shared->NullBufferObj; + copy->dstib.obj = NULL; copy->dstib.ptr = copy->dstelt; } diff --git a/src/mesa/tnl/t_split_inplace.c b/src/mesa/tnl/t_split_inplace.c index 76d3d89094a..817b641e515 100644 --- a/src/mesa/tnl/t_split_inplace.c +++ b/src/mesa/tnl/t_split_inplace.c @@ -228,7 +228,7 @@ split_prims(struct split_context *split) ib.count = count; ib.index_size_shift = 2; - ib.obj = split->ctx->Shared->NullBufferObj; + ib.obj = NULL; ib.ptr = elts; tmpprim = *prim; diff --git a/src/mesa/vbo/vbo_primitive_restart.c b/src/mesa/vbo/vbo_primitive_restart.c index 830f658d29c..1349740249f 100644 --- a/src/mesa/vbo/vbo_primitive_restart.c +++ b/src/mesa/vbo/vbo_primitive_restart.c @@ -179,8 +179,8 @@ vbo_sw_primitive_restart(struct gl_context *ctx, GLuint sub_end_index; GLuint restart_index = _mesa_primitive_restart_index(ctx, 1 << ib->index_size_shift); struct _mesa_prim temp_prim; - GLboolean map_ib = ib->obj->Name && !ib->obj->Mappings[MAP_INTERNAL].Pointer; - void *ptr; + GLboolean map_ib = ib->obj && !ib->obj->Mappings[MAP_INTERNAL].Pointer; + const void *ptr; /* If there is an indirect buffer, map it and extract the draw params */ if (indirect) { @@ -224,7 +224,10 @@ vbo_sw_primitive_restart(struct gl_context *ctx, ib->obj, MAP_INTERNAL); } - ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr); + if (ib->obj) + ptr = ADD_POINTERS(ib->obj->Mappings[MAP_INTERNAL].Pointer, ib->ptr); + else + ptr = ib->ptr; sub_prims = find_sub_primitives(ptr, 1 << ib->index_size_shift, 0, ib->count, restart_index, |