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);
}
}
GLuint name)
{
memcpy(vao, &ctx->Array.DefaultVAOState, sizeof(*vao));
-
vao->Name = name;
- _mesa_reference_buffer_object(ctx, &vao->IndexBufferObj,
- ctx->Shared->NullBufferObj);
}
} 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);
}
return;
}
- param[0] = vao->IndexBufferObj->Name;
+ param[0] = vao->IndexBufferObj ? vao->IndexBufferObj->Name : 0;
}
_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);
+ }
}
/**
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,
/* 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 */
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);
"(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)
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 */
/* 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;
/* 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;
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:
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:
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:
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:
/* restore */
_mesa_reference_buffer_object(ctx,
- &ctx->DefaultPacking.BufferObj,
- ctx->Shared->NullBufferObj);
+ &ctx->DefaultPacking.BufferObj, NULL);
if (!ok) {
if (_mesa_is_bufferobj(pack->BufferObj)) {
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;
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
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);
}
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)) {
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;
ctx->TransformFeedback.Objects = _mesa_NewHashTable();
_mesa_reference_buffer_object(ctx,
- &ctx->TransformFeedback.CurrentBuffer,
- ctx->Shared->NullBufferObj);
+ &ctx->TransformFeedback.CurrentBuffer, NULL);
}
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;
} 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;
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;
*/
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;
}
ib.count = count;
ib.index_size_shift = 2;
- ib.obj = split->ctx->Shared->NullBufferObj;
+ ib.obj = NULL;
ib.ptr = elts;
tmpprim = *prim;
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) {
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,