From b7eb7bd47b57ced7c3b056182539a65a216fcae0 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Mon, 6 Dec 2021 16:41:21 +1000 Subject: [PATCH] mesa: remove unused buffer object code. Reviewed-by: Timothy Arceri Part-of: --- src/mesa/main/bufferobj.c | 267 ---------------------------------------------- src/mesa/main/bufferobj.h | 3 - 2 files changed, 270 deletions(-) diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index ac4b951..05990ee 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -451,24 +451,6 @@ convert_clear_buffer_data(struct gl_context *ctx, } } - -/** - * Allocate and initialize a new buffer object. - * - * Default callback for the \c dd_function_table::NewBufferObject() hook. - */ -static struct gl_buffer_object * -_mesa_new_buffer_object(struct gl_context *ctx, GLuint name) -{ - struct gl_buffer_object *obj = MALLOC_STRUCT(gl_buffer_object); - if (!obj) - return NULL; - - _mesa_initialize_buffer_object(ctx, obj, name); - return obj; -} - - /** * Delete a buffer object. * @@ -609,118 +591,6 @@ _mesa_total_buffer_object_memory(struct gl_context *ctx) return total; } - -/** - * Allocate space for and store data in a buffer object. Any data that was - * previously stored in the buffer object is lost. If \c data is \c NULL, - * memory will be allocated, but no copy will occur. - * - * This is the default callback for \c dd_function_table::BufferData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param size Size, in bytes, of the new data store. - * \param data Pointer to the data to store in the buffer object. This - * pointer may be \c NULL. - * \param usage Hints about how the data will be used. - * \param bufObj Object to be used. - * - * \return GL_TRUE for success, GL_FALSE for failure - * \sa glBufferDataARB, dd_function_table::BufferData. - */ -static GLboolean -buffer_data_fallback(struct gl_context *ctx, GLenum target, GLsizeiptrARB size, - const GLvoid *data, GLenum usage, GLenum storageFlags, - struct gl_buffer_object *bufObj) -{ - void * new_data; - - (void) target; - - align_free( bufObj->Data ); - - new_data = align_malloc( size, ctx->Const.MinMapBufferAlignment ); - if (new_data) { - bufObj->Data = (GLubyte *) new_data; - bufObj->Size = size; - bufObj->Usage = usage; - bufObj->StorageFlags = storageFlags; - - if (data) { - memcpy( bufObj->Data, data, size ); - } - - return GL_TRUE; - } - else { - return GL_FALSE; - } -} - - -/** - * Replace data in a subrange of buffer object. If the data range - * specified by \c size + \c offset extends beyond the end of the buffer or - * if \c data is \c NULL, no copy is performed. - * - * This is the default callback for \c dd_function_table::BufferSubData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param offset Offset of the first byte to be modified. - * \param size Size, in bytes, of the data range. - * \param data Pointer to the data to store in the buffer object. - * \param bufObj Object to be used. - * - * \sa glBufferSubDataARB, dd_function_table::BufferSubData. - */ -static void -buffer_sub_data_fallback(struct gl_context *ctx, GLintptrARB offset, - GLsizeiptrARB size, const GLvoid *data, - struct gl_buffer_object *bufObj) -{ - (void) ctx; - - /* this should have been caught in _mesa_BufferSubData() */ - assert(size + offset <= bufObj->Size); - - if (bufObj->Data) { - memcpy( (GLubyte *) bufObj->Data + offset, data, size ); - } -} - - -/** - * Retrieve data from a subrange of buffer object. If the data range - * specified by \c size + \c offset extends beyond the end of the buffer or - * if \c data is \c NULL, no copy is performed. - * - * This is the default callback for \c dd_function_table::GetBufferSubData() - * Note that all GL error checking will have been done already. - * - * \param ctx GL context. - * \param target Buffer object target on which to operate. - * \param offset Offset of the first byte to be fetched. - * \param size Size, in bytes, of the data range. - * \param data Destination for data - * \param bufObj Object to be used. - * - * \sa glBufferGetSubDataARB, dd_function_table::GetBufferSubData. - */ -static void -buffer_get_subdata(struct gl_context *ctx, GLintptrARB offset, - GLsizeiptrARB size, GLvoid *data, - struct gl_buffer_object *bufObj ) -{ - (void) ctx; - - if (bufObj->Data && ((GLsizeiptrARB) (size + offset) <= bufObj->Size)) { - memcpy( data, (GLubyte *) bufObj->Data + offset, size ); - } -} - - /** * Clear a subrange of the buffer object with copies of the supplied data. * If data is NULL the buffer is filled with zeros. @@ -774,115 +644,6 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx, ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_INTERNAL); } - -/** - * Default fallback for \c dd_function_table::MapBufferRange(). - * Called via glMapBufferRange(). - */ -static void * -map_buffer_range_fallback(struct gl_context *ctx, GLintptr offset, - GLsizeiptr length, GLbitfield access, - struct gl_buffer_object *bufObj, - gl_map_buffer_index index) -{ - (void) ctx; - assert(!_mesa_bufferobj_mapped(bufObj, index)); - /* Just return a direct pointer to the data */ - bufObj->Mappings[index].Pointer = bufObj->Data + offset; - bufObj->Mappings[index].Length = length; - bufObj->Mappings[index].Offset = offset; - bufObj->Mappings[index].AccessFlags = access; - return bufObj->Mappings[index].Pointer; -} - - -/** - * Default fallback for \c dd_function_table::FlushMappedBufferRange(). - * Called via glFlushMappedBufferRange(). - */ -static void -flush_mapped_buffer_range_fallback(struct gl_context *ctx, - GLintptr offset, GLsizeiptr length, - struct gl_buffer_object *obj, - gl_map_buffer_index index) -{ - (void) ctx; - (void) offset; - (void) length; - (void) obj; - (void) index; - /* no-op */ -} - - -/** - * Default callback for \c dd_function_table::UnmapBuffer(). - * - * The input parameters will have been already tested for errors. - * - * \sa glUnmapBufferARB, dd_function_table::UnmapBuffer - */ -static GLboolean -unmap_buffer_fallback(struct gl_context *ctx, struct gl_buffer_object *bufObj, - gl_map_buffer_index index) -{ - (void) ctx; - /* XXX we might assert here that bufObj->Pointer is non-null */ - bufObj->Mappings[index].Pointer = NULL; - bufObj->Mappings[index].Length = 0; - bufObj->Mappings[index].Offset = 0; - bufObj->Mappings[index].AccessFlags = 0x0; - return GL_TRUE; -} - - -/** - * Default fallback for \c dd_function_table::CopyBufferSubData(). - * Called via glCopyBufferSubData(). - */ -static void -copy_buffer_sub_data_fallback(struct gl_context *ctx, - struct gl_buffer_object *src, - struct gl_buffer_object *dst, - GLintptr readOffset, GLintptr writeOffset, - GLsizeiptr size) -{ - GLubyte *srcPtr, *dstPtr; - - if (src == dst) { - srcPtr = dstPtr = ctx->Driver.MapBufferRange(ctx, 0, src->Size, - GL_MAP_READ_BIT | - GL_MAP_WRITE_BIT, src, - MAP_INTERNAL); - - if (!srcPtr) - return; - - srcPtr += readOffset; - dstPtr += writeOffset; - } else { - srcPtr = ctx->Driver.MapBufferRange(ctx, readOffset, size, - GL_MAP_READ_BIT, src, - MAP_INTERNAL); - dstPtr = ctx->Driver.MapBufferRange(ctx, writeOffset, size, - (GL_MAP_WRITE_BIT | - GL_MAP_INVALIDATE_RANGE_BIT), dst, - MAP_INTERNAL); - } - - /* Note: the src and dst regions will never overlap. Trying to do so - * would generate GL_INVALID_VALUE earlier. - */ - if (srcPtr && dstPtr) - memcpy(dstPtr, srcPtr, size); - - ctx->Driver.UnmapBuffer(ctx, src, MAP_INTERNAL); - if (dst != src) - ctx->Driver.UnmapBuffer(ctx, dst, MAP_INTERNAL); -} - - - /** * Initialize the state associated with buffer objects */ @@ -1270,34 +1031,6 @@ unbind(struct gl_context *ctx, } } - -/** - * Plug default/fallback buffer object functions into the device - * driver hooks. - */ -void -_mesa_init_buffer_object_functions(struct dd_function_table *driver) -{ - /* GL_ARB_vertex/pixel_buffer_object */ - driver->NewBufferObject = _mesa_new_buffer_object; - driver->DeleteBuffer = _mesa_delete_buffer_object; - driver->BufferData = buffer_data_fallback; - driver->BufferSubData = buffer_sub_data_fallback; - driver->GetBufferSubData = buffer_get_subdata; - driver->UnmapBuffer = unmap_buffer_fallback; - - /* GL_ARB_clear_buffer_object */ - driver->ClearBufferSubData = _mesa_ClearBufferSubData_sw; - - /* GL_ARB_map_buffer_range */ - driver->MapBufferRange = map_buffer_range_fallback; - driver->FlushMappedBufferRange = flush_mapped_buffer_range_fallback; - - /* GL_ARB_copy_buffer */ - driver->CopyBufferSubData = copy_buffer_sub_data_fallback; -} - - void _mesa_buffer_unmap_all_mappings(struct gl_context *ctx, struct gl_buffer_object *bufObj) diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index f78e642..46f6aae 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -138,9 +138,6 @@ extern GLuint _mesa_total_buffer_object_memory(struct gl_context *ctx); extern void -_mesa_init_buffer_object_functions(struct dd_function_table *driver); - -extern void _mesa_buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj, GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage, const char *func); -- 2.7.4