Lines Matching refs:buffer
64 * We count the number of buffer modification calls to check for
65 * inefficient buffer use. This is the number of such calls before we
72 * Replace data in a subrange of buffer object. If the data range
73 * specified by size + offset extends beyond the end of the buffer or
93 * then the contents of the buffer object's data store is undefined. We just
99 if (!obj->buffer) {
100 /* we probably ran out of memory during buffer allocation */
106 * even if the buffer is currently referenced by hardware - they
108 * buffer directly.
110 * If the buffer is mapped, suppress implicit buffer range invalidation
115 pipe->buffer_subdata(pipe, obj->buffer,
139 if (!obj->buffer) {
140 /* we probably ran out of memory during buffer allocation */
144 pipe_buffer_read(ctx->pipe, obj->buffer,
158 * Return bitmask of PIPE_BIND_x flags corresponding a GL buffer target.
209 * From a buffer object's target, immutability flag, storage flags and
284 size && obj->buffer &&
290 * This should be the same as creating a new buffer, but we avoid
293 * If the buffer is mapped, we can't discard it.
295 * PIPE_MAP_DIRECTLY supresses implicit buffer range
298 pipe->buffer_subdata(pipe, obj->buffer,
306 pipe->invalidate_resource(pipe, obj->buffer);
323 debug_printf("Create buffer size %" PRId64 " bind 0x%x\n",
328 struct pipe_resource buffer;
330 memset(&buffer, 0, sizeof buffer);
331 buffer.target = PIPE_BUFFER;
332 buffer.format = PIPE_FORMAT_R8_UNORM; /* want TYPELESS or similar */
333 buffer.bind = bindings;
334 buffer.usage =
336 buffer.flags = storage_flags_to_buffer_flags(storageFlags);
337 buffer.width0 = size;
338 buffer.height0 = 1;
339 buffer.depth0 = 1;
340 buffer.array_size = 1;
343 obj->buffer = screen->resource_from_memobj(screen, &buffer,
348 obj->buffer =
349 screen->resource_from_user_memory(screen, &buffer, (void*)data);
352 obj->buffer = screen->resource_create(screen, &buffer);
354 if (obj->buffer && data)
355 pipe_buffer_write(pipe, obj->buffer, 0, size, data);
358 if (!obj->buffer) {
367 /* The current buffer may be bound, so we have to revalidate all atoms that
385 * Allocate space for and store data in a buffer object. Any data that was
386 * previously stored in the buffer object is lost. If data is NULL,
417 * \param wholeBuffer is the whole buffer being mapped?
500 obj->buffer,
577 /* buffer should not already be mapped */
583 pipe->resource_copy_region(pipe, dst->buffer, 0, writeOffset, 0, 0,
584 src->buffer, 0, &box);
624 * updating a buffer created with GL_STATIC_DRAW. Called via the macro
649 * Used as a placeholder for buffer objects between glGenBuffers() and
659 * Return pointer to address of a buffer object target.
661 * \param target the buffer object target to be retrieved.
662 * \return pointer to pointer to the buffer object bound to \c target in the
756 * Get the buffer object bound to the specified target in a GL context.
758 * \param target the buffer object target to be retrieved.
760 * \return pointer to the buffer object bound to \c target in the
775 _mesa_error(ctx, error, "%s(no buffer bound)", func);
784 * Convert a GLbitfield describing the mapped buffer access flags
811 * BUFFER_ACCESS_OES Z1 GetBufferParameteriv WRITE_ONLY_OES buffer map flag
823 * Test if the buffer is mapped, and if so, if the mapped range overlaps the
858 * \param bufObj The buffer object.
862 * If false, checks if buffer is mapped.
886 "%s(offset %lu + size %lu > buffer size %lu)", caller,
907 "%s(buffer is mapped without persistent bit)",
1013 if (!obj->buffer)
1017 * the buffer. See the header file for explanation.
1021 p_atomic_add(&obj->buffer->reference.count,
1027 pipe_resource_reference(&obj->buffer, NULL);
1031 * Delete a buffer object.
1069 /* Unreference the old buffer */
1074 /* Count references only if the context doesn't own the buffer or if
1076 * buffer object being a buffer bound within a texture object).
1093 /* reference new buffer */
1136 * Compute total size (in bytes) of all buffer objects for the given context.
1151 * Initialize the state associated with buffer objects
1184 * Detach the context from the buffer to re-enable buffer reference counting
1198 * reference for the lifetime of the buffer ID to skip refcount
1207 * buffer it created that can't be unreferenced when another context deletes
1208 * it. Such a buffer becomes a zombie, which means that it's no longer usable
1210 * the buffer. Only the creating context can remove the reference, which is
1214 * context owns the buffer.
1231 * When a context creates buffers, it holds a global buffer reference count
1232 * for each buffer and doesn't update their RefCount. When the context is
1248 * bound buffer in the context at this point, therefore we can just
1250 * might still be using the buffer.
1324 * Create a buffer object that will be backed by an OpenGL buffer ID
1325 * where the creating context will hold one global buffer reference instead
1326 * of updating buffer RefCount for every binding point.
1336 buf->RefCount++; /* global buffer reference held by the context */
1342 GLuint buffer,
1354 /* If this is a new buffer object id, or one which was generated but
1355 * never used before, allocate a buffer object now.
1357 *buf_handle = new_gl_buffer_object(ctx, buffer);
1364 _mesa_HashInsertLocked(ctx->Shared->BufferObjects, buffer,
1381 * Bind the specified target to buffer for the specified context.
1386 struct gl_buffer_object **bindTarget, GLuint buffer,
1394 /* Get pointer to old buffer object (to be unbound) */
1396 if ((oldBufObj && oldBufObj->Name == buffer && !oldBufObj->DeletePending) ||
1397 (!oldBufObj && buffer == 0))
1398 return; /* rebinding the same buffer object- no change */
1401 * Get pointer to new buffer object (newBufObj)
1403 if (buffer != 0) {
1404 /* non-default buffer object */
1405 newBufObj = _mesa_lookup_bufferobj(ctx, buffer);
1406 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
1412 /* bind new buffer */
1418 * Update the default buffer objects in the given context to reference those
1439 _mesa_lookup_bufferobj(struct gl_context *ctx, GLuint buffer)
1441 if (buffer == 0)
1445 _mesa_HashLookupMaybeLocked(ctx->Shared->BufferObjects, buffer,
1451 _mesa_lookup_bufferobj_locked(struct gl_context *ctx, GLuint buffer)
1453 if (buffer == 0)
1457 _mesa_HashLookupLocked(ctx->Shared->BufferObjects, buffer);
1462 * GL_INVALID_OPERATION if buffer is not the name of an existing
1463 * buffer object.
1466 _mesa_lookup_bufferobj_err(struct gl_context *ctx, GLuint buffer,
1471 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
1474 "%s(non-existent buffer object %u)", caller, buffer);
1483 * Look up a buffer object for a multi-bind function.
1486 * of generating an error if the buffer ID is not zero or the name
1487 * of an existing buffer object.
1489 * If the buffer ID refers to an existing buffer object, a pointer
1490 * to the buffer object is returned. If the ID is zero, NULL is returned.
1491 * If the ID is not zero and does not refer to a valid buffer object, this
1511 /* The multi-bind functions don't create the buffer objects
1521 * buffer object (per binding)."
1525 "of an existing buffer object)",
1536 * If *ptr points to obj, set ptr = the Null/default buffer object.
1537 * This is a helper for buffer object deletion.
1538 * The GL spec says that deleting a buffer object causes it to get
1572 _mesa_BindBuffer_no_error(GLenum target, GLuint buffer)
1577 bind_buffer_object(ctx, bindTarget, buffer, true);
1582 _mesa_BindBuffer(GLenum target, GLuint buffer)
1588 _mesa_enum_to_string(target), buffer);
1598 bind_buffer_object(ctx, bindTarget, buffer, false);
1608 /* Move the buffer reference from the parameter to the bind point. */
1615 * Binds a buffer object to a binding point.
1634 /* If this is a real buffer object, mark it has having been used
1635 * at some point as an atomic counter buffer.
1694 * Binds a buffer object to a uniform buffer binding point.
1715 * Binds a buffer object to a shader storage buffer binding point.
1736 * Binds a buffer object to an atomic buffer binding point.
1754 * Bind a buffer object to a uniform block binding point.
1776 * Bind a buffer object to a shader storage block binding point.
1798 * Bind a buffer object to a shader storage block binding point.
1820 * Delete a set of buffer objects.
1822 * \param n Number of buffer objects to delete.
1823 * \param ids Array of \c n buffer object IDs.
1845 /* unbind any vertex pointers bound to this buffer */
1925 /* unbind any pixel pack/unpack pointers bound to this buffer */
1941 /* unbind query buffer binding point */
1949 * We don't want to allow re-binding a buffer object that's been
1961 * the buffer holds the other one.
2017 * This must be atomic (generation and allocation of buffer object IDs)
2032 * DummyBufferObject. Otherwise, create a new buffer object and insert
2073 * Generate a set of unique buffer object IDs and store them in \c buffers.
2094 * Create a set of buffer objects and store their unique IDs in \c buffers.
2116 * Determine if ID is the name of a buffer object.
2118 * \param id ID of the potential buffer object.
2119 * \return \c GL_TRUE if \c id is the name of a buffer object,
2202 /* Unmap the existing buffer. We'll replace it now. Not an error. */
2236 inlined_buffer_storage(GLenum target, GLuint buffer, GLsizeiptr size,
2280 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2282 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
2320 _mesa_NamedBufferStorageEXT(GLuint buffer, GLsizeiptr size,
2325 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2326 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
2330 inlined_buffer_storage(GL_NONE, buffer, size, data, flags, GL_NONE, 0,
2354 _mesa_NamedBufferStorage_no_error(GLuint buffer, GLsizeiptr size,
2357 /* In direct state access, buffer objects have an unspecified target
2360 inlined_buffer_storage(GL_NONE, buffer, size, data, flags, GL_NONE, 0,
2366 _mesa_NamedBufferStorage(GLuint buffer, GLsizeiptr size, const GLvoid *data,
2369 /* In direct state access, buffer objects have an unspecified target
2372 inlined_buffer_storage(GL_NONE, buffer, size, data, flags, GL_NONE, 0,
2377 _mesa_NamedBufferStorageMemEXT(GLuint buffer, GLsizeiptr size,
2380 inlined_buffer_storage(GL_NONE, buffer, size, NULL, 0, memory, offset,
2386 _mesa_NamedBufferStorageMemEXT_no_error(GLuint buffer, GLsizeiptr size,
2389 inlined_buffer_storage(GL_NONE, buffer, size, NULL, 0, memory, offset,
2448 /* Unmap the existing buffer. We'll replace it now. Not an error. */
2537 _mesa_NamedBufferData_no_error(GLuint buffer, GLsizeiptr size,
2542 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2548 _mesa_NamedBufferData(GLuint buffer, GLsizeiptr size, const GLvoid *data,
2554 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glNamedBufferData");
2558 /* In direct state access, buffer objects have an unspecified target since
2566 _mesa_NamedBufferDataEXT(GLuint buffer, GLsizeiptr size, const GLvoid *data,
2572 if (!buffer) {
2574 "glNamedBufferDataEXT(buffer=0)");
2578 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2579 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
2608 /* If the application declared the buffer as static draw/copy or stream
2612 "using %s(buffer %u, offset %u, size %u) to "
2613 "update a %s buffer",
2626 * \param bufObj The buffer object.
2649 buffer_sub_data(GLenum target, GLuint buffer, GLintptr offset,
2658 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2660 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
2698 _mesa_NamedBufferSubData_no_error(GLuint buffer, GLintptr offset,
2701 buffer_sub_data(0, buffer, offset, size, data, true, true,
2706 _mesa_NamedBufferSubData(GLuint buffer, GLintptr offset,
2709 buffer_sub_data(0, buffer, offset, size, data, true, false,
2714 _mesa_NamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
2720 if (!buffer) {
2722 "glNamedBufferSubDataEXT(buffer=0)");
2726 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2727 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
2759 _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
2765 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
2780 _mesa_GetNamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
2786 if (!buffer) {
2788 "glGetNamedBufferSubDataEXT(buffer=0)");
2792 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2793 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
2862 ctx->pipe->clear_buffer(ctx->pipe, bufObj->buffer, offset, size,
2921 _mesa_ClearNamedBufferData_no_error(GLuint buffer, GLenum internalformat,
2927 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2935 _mesa_ClearNamedBufferData(GLuint buffer, GLenum internalformat,
2941 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glClearNamedBufferData");
2952 _mesa_ClearNamedBufferDataEXT(GLuint buffer, GLenum internalformat,
2956 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
2957 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
3002 _mesa_ClearNamedBufferSubData_no_error(GLuint buffer, GLenum internalformat,
3009 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3017 _mesa_ClearNamedBufferSubData(GLuint buffer, GLenum internalformat,
3025 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
3036 _mesa_ClearNamedBufferSubDataEXT(GLuint buffer, GLenum internalformat,
3042 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3043 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
3073 "%s(buffer is not mapped)", func);
3085 _mesa_warning(ctx, "Out of bounds buffer object write detected"
3140 _mesa_UnmapNamedBufferEXT_no_error(GLuint buffer)
3143 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3149 _mesa_UnmapNamedBufferEXT(GLuint buffer)
3154 if (!buffer) {
3156 "glUnmapNamedBufferEXT(buffer=0)");
3160 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glUnmapNamedBuffer");
3263 _mesa_GetNamedBufferParameteriv(GLuint buffer, GLenum pname, GLint *params)
3269 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
3282 _mesa_GetNamedBufferParameterivEXT(GLuint buffer, GLenum pname, GLint *params)
3288 if (!buffer) {
3290 "glGetNamedBufferParameterivEXT: buffer=0");
3294 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3295 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
3307 _mesa_GetNamedBufferParameteri64v(GLuint buffer, GLenum pname,
3314 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
3348 _mesa_GetNamedBufferPointerv(GLuint buffer, GLenum pname, GLvoid **params)
3359 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
3368 _mesa_GetNamedBufferPointervEXT(GLuint buffer, GLenum pname, GLvoid **params)
3373 if (!buffer) {
3375 "glGetNamedBufferPointervEXT(buffer=0)");
3384 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3385 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
3680 "%s(buffer does not allow read access)", func);
3687 "%s(buffer does not allow write access)", func);
3694 "%s(buffer does not allow coherent access)", func);
3701 "%s(buffer does not allow persistent access)", func);
3715 "%s(buffer already mapped)", func);
3725 "using %s(buffer %u, offset %u, length %u) to "
3726 "update a %s buffer",
3741 _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(buffer size = 0)", func);
3784 /* buffer is 100 bytes larger than requested, fill with magic value */
3833 _mesa_MapNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
3837 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3844 map_named_buffer_range(GLuint buffer, GLintptr offset, GLsizeiptr length,
3857 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3858 if (!_mesa_handle_bind_buffer_gen(ctx, buffer, &bufObj, func, false))
3861 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, func);
3873 _mesa_MapNamedBufferRangeEXT(GLuint buffer, GLintptr offset, GLsizeiptr length,
3877 if (!buffer) {
3879 "glMapNamedBufferRangeEXT(buffer=0)");
3882 return map_named_buffer_range(buffer, offset, length, access, true,
3887 _mesa_MapNamedBufferRange(GLuint buffer, GLintptr offset, GLsizeiptr length,
3890 return map_named_buffer_range(buffer, offset, length, access, false,
3960 _mesa_MapNamedBuffer_no_error(GLuint buffer, GLenum access)
3967 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
3974 _mesa_MapNamedBuffer(GLuint buffer, GLenum access)
3985 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer, "glMapNamedBuffer");
3998 _mesa_MapNamedBufferEXT(GLuint buffer, GLenum access)
4003 if (!buffer) {
4005 "glMapNamedBufferEXT(buffer=0)");
4013 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
4014 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
4051 /* buffer is not mapped */
4053 "%s(buffer is not mapped)", func);
4107 _mesa_FlushMappedNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
4111 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
4118 _mesa_FlushMappedNamedBufferRange(GLuint buffer, GLintptr offset,
4124 bufObj = _mesa_lookup_bufferobj_err(ctx, buffer,
4134 _mesa_FlushMappedNamedBufferRangeEXT(GLuint buffer, GLintptr offset,
4140 if (!buffer) {
4142 "glFlushMappedNamedBufferRangeEXT(buffer=0)");
4146 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
4147 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
4170 * Bind a region of a buffer object to a uniform block binding point.
4171 * \param index the uniform buffer binding point index
4172 * \param bufObj the buffer object
4173 * \param offset offset to the start of buffer object region
4174 * \param size size of the buffer object region
4213 * Bind a region of a buffer object to a shader storage block binding point.
4214 * \param index the shader storage buffer binding point index
4215 * \param bufObj the buffer object
4216 * \param offset offset to the start of buffer object region
4217 * \param size size of the buffer object region
4255 * Bind a region of a buffer object to an atomic storage block binding point.
4256 * \param index the shader storage buffer binding point index
4257 * \param bufObj the buffer object
4258 * \param offset offset to the start of buffer object region
4259 * \param size size of the buffer object region
4467 * │ Uniform buffer array bindings (see sec. 7.6) │
4570 * │ Shader storage buffer array bindings (see sec. 7.8) │
4929 bind_buffer_range(GLenum target, GLuint index, GLuint buffer, GLintptr offset,
4937 _mesa_enum_to_string(target), index, buffer,
4941 if (buffer == 0) {
4944 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
4945 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
4951 "glBindBufferRange(invalid buffer=%u)", buffer);
4976 if (buffer != 0) {
5015 _mesa_BindBufferRange_no_error(GLenum target, GLuint index, GLuint buffer,
5018 bind_buffer_range(target, index, buffer, offset, size, true);
5023 GLuint buffer, GLintptr offset, GLsizeiptr size)
5025 bind_buffer_range(target, index, buffer, offset, size, false);
5029 _mesa_BindBufferBase(GLenum target, GLuint index, GLuint buffer)
5036 _mesa_enum_to_string(target), index, buffer);
5039 if (buffer == 0) {
5042 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
5043 if (!_mesa_handle_bind_buffer_gen(ctx, buffer,
5049 "glBindBufferBase(invalid buffer=%u)", buffer);
5058 * zero and size equal to the size of buffer."
5063 * buffer object was bound, zero is returned."
5065 * What happens if the size of the buffer changes? Does the size of the
5066 * buffer at the moment glBindBufferBase was called still play a role, like
5072 * size is determined by the size of the bound buffer at the time the
5188 /* If the buffer is mapped, we can't invalidate it. */
5189 if (!obj->buffer || _mesa_bufferobj_mapped(obj, MAP_USER))
5192 pipe->invalidate_resource(pipe, obj->buffer);
5205 _mesa_InvalidateBufferSubData_no_error(GLuint buffer, GLintptr offset,
5210 struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
5215 _mesa_InvalidateBufferSubData(GLuint buffer, GLintptr offset,
5225 * "An INVALID_VALUE error is generated if buffer is zero or is not the
5226 * name of an existing buffer object."
5228 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
5232 buffer);
5250 * "An INVALID_OPERATION error is generated if buffer is currently
5267 _mesa_InvalidateBufferData_no_error(GLuint buffer)
5271 struct gl_buffer_object *bufObj =_mesa_lookup_bufferobj(ctx, buffer);
5276 _mesa_InvalidateBufferData(GLuint buffer)
5284 * "An INVALID_VALUE error is generated if buffer is zero or is not the
5285 * name of an existing buffer object."
5287 bufObj = _mesa_lookup_bufferobj(ctx, buffer);
5291 buffer);
5297 * "An INVALID_OPERATION error is generated if buffer is currently
5319 _mesa_error(ctx, GL_INVALID_OPERATION, "%s(not a sparse buffer object)",
5336 * not extend to the end of the buffer's data store."
5356 if (!pipe->resource_commit(pipe, bufferObj->buffer, 0, &box, commit)) {
5378 _mesa_NamedBufferPageCommitmentARB(GLuint buffer, GLintptr offset,
5384 bufferObj = _mesa_lookup_bufferobj(ctx, buffer);
5389 buffer);
5398 _mesa_NamedBufferPageCommitmentEXT(GLuint buffer, GLintptr offset,
5405 if (buffer != 0) {
5406 bufferObj = _mesa_lookup_bufferobj(ctx, buffer);
5407 if (!_mesa_handle_bind_buffer_gen(ctx, buffer, &bufferObj,
5413 * There is no buffer corresponding to the name zero, these commands
5414 * generate the INVALID_OPERATION error if the buffer parameter is
5418 "glNamedBufferPageCommitmentEXT(buffer = 0)");