#include "util/u_math.h"
#include "util/u_memory.h"
+#include "state_tracker/st_cb_bufferobjects.h"
const GLubyte
_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX] =
if (_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
continue;
- ctx->Driver.MapBufferRange(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
+ st_bufferobj_map_range(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
}
}
/* map the index buffer, if there is one, and not already mapped */
if (bo && !_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
- ctx->Driver.MapBufferRange(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
+ st_bufferobj_map_range(ctx, 0, bo->Size, access, bo, MAP_INTERNAL);
_mesa_vao_map_arrays(ctx, vao, access);
}
if (!_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
continue;
- ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, bo, MAP_INTERNAL);
}
}
/* unmap the index buffer, if there is one, and still mapped */
if (bo && _mesa_bufferobj_mapped(bo, MAP_INTERNAL))
- ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, bo, MAP_INTERNAL);
_mesa_vao_unmap_arrays(ctx, vao);
}
#include "util/u_memory.h"
#include "util/set.h"
+#include "state_tracker/st_cb_bufferobjects.h"
/* Debug flags */
/*#define VBO_DEBUG*/
*/
if (shared_binding || ctx != oldObj->Ctx) {
if (p_atomic_dec_zero(&oldObj->RefCount)) {
- assert(ctx->Driver.DeleteBuffer);
- ctx->Driver.DeleteBuffer(ctx, oldObj);
+ st_bufferobj_free(ctx, oldObj);
}
} else if (ctx == oldObj->Ctx) {
/* Update the private ref count. */
GLsizeiptr i;
GLubyte *dest;
- assert(ctx->Driver.MapBufferRange);
- dest = ctx->Driver.MapBufferRange(ctx, offset, size,
- GL_MAP_WRITE_BIT |
- GL_MAP_INVALIDATE_RANGE_BIT,
- bufObj, MAP_INTERNAL);
+ dest = st_bufferobj_map_range(ctx, offset, size,
+ GL_MAP_WRITE_BIT |
+ GL_MAP_INVALIDATE_RANGE_BIT,
+ bufObj, MAP_INTERNAL);
if (!dest) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glClearBuffer[Sub]Data");
if (clearValue == NULL) {
/* Clear with zeros, per the spec */
memset(dest, 0, size);
- ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, bufObj, MAP_INTERNAL);
return;
}
dest += clearValueSize;
}
- ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, bufObj, MAP_INTERNAL);
}
/**
static struct gl_buffer_object *
new_gl_buffer_object(struct gl_context *ctx, GLuint id)
{
- struct gl_buffer_object *buf = ctx->Driver.NewBufferObject(ctx, id);
+ struct gl_buffer_object *buf = st_bufferobj_alloc(ctx, id);
buf->Ctx = ctx;
buf->RefCount++; /* global buffer reference held by the context */
{
for (int i = 0; i < MAP_COUNT; i++) {
if (_mesa_bufferobj_mapped(bufObj, i)) {
- ctx->Driver.UnmapBuffer(ctx, bufObj, i);
+ st_bufferobj_unmap(ctx, bufObj, i);
assert(bufObj->Mappings[i].Pointer == NULL);
bufObj->Mappings[i].AccessFlags = 0;
}
*/
for (int i = 0; i < n; i++) {
if (dsa) {
- assert(ctx->Driver.NewBufferObject);
buf = new_gl_buffer_object(ctx, buffers[i]);
if (!buf) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCreateBuffers");
bufObj->MinMaxCacheDirty = true;
if (memObj) {
- assert(ctx->Driver.BufferDataMem);
- res = ctx->Driver.BufferDataMem(ctx, target, size, memObj, offset,
- GL_DYNAMIC_DRAW, bufObj);
+ res = st_bufferobj_data_mem(ctx, target, size, memObj, offset,
+ GL_DYNAMIC_DRAW, bufObj);
}
else {
- assert(ctx->Driver.BufferData);
- res = ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
- flags, bufObj);
+ res = st_bufferobj_data(ctx, target, size, data, GL_DYNAMIC_DRAW,
+ flags, bufObj);
}
if (!res) {
size += 100;
#endif
- assert(ctx->Driver.BufferData);
- if (!ctx->Driver.BufferData(ctx, target, size, data, usage,
- GL_MAP_READ_BIT |
- GL_MAP_WRITE_BIT |
- GL_DYNAMIC_STORAGE_BIT,
- bufObj)) {
+ if (!st_bufferobj_data(ctx, target, size, data, usage,
+ GL_MAP_READ_BIT |
+ GL_MAP_WRITE_BIT |
+ GL_DYNAMIC_STORAGE_BIT,
+ bufObj)) {
if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
if (!no_error) {
/* From GL_AMD_pinned_memory:
bufObj->Written = GL_TRUE;
bufObj->MinMaxCacheDirty = true;
- assert(ctx->Driver.BufferSubData);
- ctx->Driver.BufferSubData(ctx, offset, size, data, bufObj);
+ st_bufferobj_subdata(ctx, offset, size, data, bufObj);
}
return;
}
- assert(ctx->Driver.GetBufferSubData);
- ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
+ st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
}
void GLAPIENTRY
return;
}
- assert(ctx->Driver.GetBufferSubData);
- ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
+ st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
}
return;
}
- assert(ctx->Driver.GetBufferSubData);
- ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
+ st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
}
/**
if (data == NULL) {
/* clear to zeros, per the spec */
- ctx->Driver.ClearBufferSubData(ctx, offset, size,
+ st_clear_buffer_subdata(ctx, offset, size,
NULL, clearValueSize, bufObj);
return;
}
return;
}
- ctx->Driver.ClearBufferSubData(ctx, offset, size,
- clearValue, clearValueSize, bufObj);
+ st_clear_buffer_subdata(ctx, offset, size,
+ clearValue, clearValueSize, bufObj);
}
static void
static GLboolean
unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj)
{
- GLboolean status = ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_USER);
+ GLboolean status = st_bufferobj_unmap(ctx, bufObj, MAP_USER);
bufObj->Mappings[MAP_USER].AccessFlags = 0;
assert(bufObj->Mappings[MAP_USER].Pointer == NULL);
assert(bufObj->Mappings[MAP_USER].Offset == 0);
dst->MinMaxCacheDirty = true;
- ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size);
+ st_copy_buffer_subdata(ctx, src, dst, readOffset, writeOffset, size);
}
void GLAPIENTRY
struct gl_buffer_object *dst = *dst_ptr;
dst->MinMaxCacheDirty = true;
- ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset,
- size);
+ st_copy_buffer_subdata(ctx, src, dst, readOffset, writeOffset,
+ size);
}
void GLAPIENTRY
struct gl_buffer_object *dst = _mesa_lookup_bufferobj(ctx, writeBuffer);
dst->MinMaxCacheDirty = true;
- ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset,
- size);
+ st_copy_buffer_subdata(ctx, src, dst, readOffset, writeOffset,
+ size);
}
void GLAPIENTRY
goto done; /* the error is already set */
dst->MinMaxCacheDirty = true;
- ctx->Driver.CopyBufferSubData(ctx, src, dst, srcOffset, dstOffset, size);
+ st_copy_buffer_subdata(ctx, src, dst, srcOffset, dstOffset, size);
done:
/* The caller passes the reference to this function, so unreference it. */
return NULL;
}
- assert(ctx->Driver.MapBufferRange);
- void *map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj,
- MAP_USER);
+ void *map = st_bufferobj_map_range(ctx, offset, length, access, bufObj,
+ MAP_USER);
if (!map) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(map failed)", func);
}
assert(bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_WRITE_BIT);
- if (ctx->Driver.FlushMappedBufferRange)
- ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj,
- MAP_USER);
+ st_bufferobj_flush_mapped_range(ctx, offset, length, bufObj,
+ MAP_USER);
}
void GLAPIENTRY
struct gl_buffer_object **bufObjPtr = get_buffer_target(ctx, target);
struct gl_buffer_object *bufObj = *bufObjPtr;
- if (ctx->Driver.FlushMappedBufferRange)
- ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj,
- MAP_USER);
+ st_bufferobj_flush_mapped_range(ctx, offset, length, bufObj,
+ MAP_USER);
}
void GLAPIENTRY
GET_CURRENT_CONTEXT(ctx);
struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
- if (ctx->Driver.FlushMappedBufferRange)
- ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj,
- MAP_USER);
+ st_bufferobj_flush_mapped_range(ctx, offset, length, bufObj,
+ MAP_USER);
}
void GLAPIENTRY
return;
}
- ctx->Driver.BufferPageCommitment(ctx, bufferObj, offset, size, commit);
+ st_bufferobj_page_commitment(ctx, bufferObj, offset, size, commit);
}
void GLAPIENTRY
* \name Vertex/pixel buffer object functions
*/
/*@{*/
- struct gl_buffer_object * (*NewBufferObject)(struct gl_context *ctx,
- GLuint buffer);
-
- void (*DeleteBuffer)( struct gl_context *ctx, struct gl_buffer_object *obj );
-
- GLboolean (*BufferData)(struct gl_context *ctx, GLenum target,
- GLsizeiptrARB size, const GLvoid *data, GLenum usage,
- GLenum storageFlags, struct gl_buffer_object *obj);
-
- void (*BufferSubData)( struct gl_context *ctx, GLintptrARB offset,
- GLsizeiptrARB size, const GLvoid *data,
- struct gl_buffer_object *obj );
-
- void (*GetBufferSubData)( struct gl_context *ctx,
- GLintptrARB offset, GLsizeiptrARB size,
- GLvoid *data, struct gl_buffer_object *obj );
-
- void (*ClearBufferSubData)( struct gl_context *ctx,
- GLintptr offset, GLsizeiptr size,
- const GLvoid *clearValue,
- GLsizeiptr clearValueSize,
- struct gl_buffer_object *obj );
-
- void (*CopyBufferSubData)( struct gl_context *ctx,
- struct gl_buffer_object *src,
- struct gl_buffer_object *dst,
- GLintptr readOffset, GLintptr writeOffset,
- GLsizeiptr size );
-
void (*InvalidateBufferSubData)( struct gl_context *ctx,
struct gl_buffer_object *obj,
GLintptr offset,
GLsizeiptr length );
- /* Returns pointer to the start of the mapped range.
- * May return NULL if MESA_MAP_NOWAIT_BIT is set in access:
- */
- void * (*MapBufferRange)( struct gl_context *ctx, GLintptr offset,
- GLsizeiptr length, GLbitfield access,
- struct gl_buffer_object *obj,
- gl_map_buffer_index index);
-
- void (*FlushMappedBufferRange)(struct gl_context *ctx,
- GLintptr offset, GLsizeiptr length,
- struct gl_buffer_object *obj,
- gl_map_buffer_index index);
-
- GLboolean (*UnmapBuffer)( struct gl_context *ctx,
- struct gl_buffer_object *obj,
- gl_map_buffer_index index);
/*@}*/
/**
/*@}*/
/**
- * \name GL_ARB_sparse_buffer interface
- */
- /*@{*/
- void (*BufferPageCommitment)(struct gl_context *ctx,
- struct gl_buffer_object *bufferObj,
- GLintptr offset, GLsizeiptr size,
- GLboolean commit);
- /*@}*/
-
- /**
- * Use a memory object as the backing data for a buffer object
- */
- GLboolean (*BufferDataMem)(struct gl_context *ctx,
- GLenum target,
- GLsizeiptrARB size,
- struct gl_memory_object *memObj,
- GLuint64 offset,
- GLenum usage,
- struct gl_buffer_object *bufObj);
-
- /**
* \name GL_ARB_get_program_binary
*/
/*@{*/
#include "state_tracker/st_cb_texture.h"
#include "state_tracker/st_cb_bitmap.h"
+#include "state_tracker/st_cb_bufferobjects.h"
#define USE_BITMAP_ATLAS 1
GLvoid *image;
map = (GLubyte *)
- ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
- GL_MAP_READ_BIT, unpack->BufferObj,
- MAP_INTERNAL);
+ st_bufferobj_map_range(ctx, 0, unpack->BufferObj->Size,
+ GL_MAP_READ_BIT, unpack->BufferObj,
+ MAP_INTERNAL);
if (!map) {
/* unable to map src buffer! */
_mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
image = _mesa_unpack_image(dimensions, width, height, depth,
format, type, src, unpack);
- ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, unpack->BufferObj, MAP_INTERNAL);
if (!image) {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
#include "main/dispatch.h"
#include "main/bufferobj.h"
+#include "state_tracker/st_cb_bufferobjects.h"
+
/**
* Create an upload buffer. This is called from the app thread, so everything
* has to be thread-safe in the driver.
{
assert(ctx->GLThread.SupportsBufferUploads);
- struct gl_buffer_object *obj = ctx->Driver.NewBufferObject(ctx, -1);
+ struct gl_buffer_object *obj = st_bufferobj_alloc(ctx, -1);
if (!obj)
return NULL;
obj->Immutable = true;
- if (!ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER, size, NULL,
- GL_WRITE_ONLY,
- GL_CLIENT_STORAGE_BIT | GL_MAP_WRITE_BIT,
- obj)) {
- ctx->Driver.DeleteBuffer(ctx, obj);
+ if (!st_bufferobj_data(ctx, GL_ARRAY_BUFFER, size, NULL,
+ GL_WRITE_ONLY,
+ GL_CLIENT_STORAGE_BIT | GL_MAP_WRITE_BIT,
+ obj)) {
+ st_bufferobj_free(ctx, obj);
return NULL;
}
- *ptr = ctx->Driver.MapBufferRange(ctx, 0, size,
- GL_MAP_WRITE_BIT |
- GL_MAP_UNSYNCHRONIZED_BIT |
- MESA_MAP_THREAD_SAFE_BIT,
- obj, MAP_GLTHREAD);
+ *ptr = st_bufferobj_map_range(ctx, 0, size,
+ GL_MAP_WRITE_BIT |
+ GL_MAP_UNSYNCHRONIZED_BIT |
+ MESA_MAP_THREAD_SAFE_BIT,
+ obj, MAP_GLTHREAD);
if (!*ptr) {
- ctx->Driver.DeleteBuffer(ctx, obj);
+ st_bufferobj_free(ctx, obj);
return NULL;
}
#include "macros.h"
#include "pbo.h"
+#include "state_tracker/st_cb_bufferobjects.h"
/**
if (unpack->BufferObj) {
/* unpack from PBO */
- buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
- unpack->BufferObj->Size,
- GL_MAP_READ_BIT,
- unpack->BufferObj,
- MAP_INTERNAL);
+ buf = (GLubyte *) st_bufferobj_map_range(ctx, 0,
+ unpack->BufferObj->Size,
+ GL_MAP_READ_BIT,
+ unpack->BufferObj,
+ MAP_INTERNAL);
if (!buf)
return NULL;
{
assert(unpack != &ctx->Pack); /* catch pack/unpack mismatch */
if (unpack->BufferObj) {
- ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, unpack->BufferObj, MAP_INTERNAL);
}
}
if (pack->BufferObj) {
/* pack into PBO */
- buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
- pack->BufferObj->Size,
- GL_MAP_WRITE_BIT,
- pack->BufferObj,
- MAP_INTERNAL);
+ buf = (GLubyte *) st_bufferobj_map_range(ctx, 0,
+ pack->BufferObj->Size,
+ GL_MAP_WRITE_BIT,
+ pack->BufferObj,
+ MAP_INTERNAL);
if (!buf)
return NULL;
{
assert(pack != &ctx->Unpack); /* catch pack/unpack mismatch */
if (pack->BufferObj) {
- ctx->Driver.UnmapBuffer(ctx, pack->BufferObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, pack->BufferObj, MAP_INTERNAL);
}
}
return NULL;
}
- buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
- unpack->BufferObj->Size,
- GL_MAP_READ_BIT,
- unpack->BufferObj,
- MAP_INTERNAL);
+ buf = (GLubyte *) st_bufferobj_map_range(ctx, 0,
+ unpack->BufferObj->Size,
+ GL_MAP_READ_BIT,
+ unpack->BufferObj,
+ MAP_INTERNAL);
if (!buf) {
_mesa_error(ctx, GL_INVALID_OPERATION, "%s%uD(PBO is mapped)", funcName,
dimensions);
return pixels;
}
- buf = (GLubyte*) ctx->Driver.MapBufferRange(ctx, 0,
- packing->BufferObj->Size,
- GL_MAP_READ_BIT,
- packing->BufferObj,
- MAP_INTERNAL);
+ buf = (GLubyte*) st_bufferobj_map_range(ctx, 0,
+ packing->BufferObj->Size,
+ GL_MAP_READ_BIT,
+ packing->BufferObj,
+ MAP_INTERNAL);
/* Validation above already checked that PBO is not mapped, so buffer
* should not be null.
const struct gl_pixelstore_attrib *unpack)
{
if (unpack->BufferObj) {
- ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, unpack->BufferObj, MAP_INTERNAL);
}
}
#include "pixeltransfer.h"
#include "state_tracker/st_cb_texture.h"
+#include "state_tracker/st_cb_bufferobjects.h"
/**
* Can the given type represent negative values?
* texture data to the PBO if the PBO is in VRAM along with the texture.
*/
GLubyte *buf = (GLubyte *)
- ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size,
- GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
- MAP_INTERNAL);
+ st_bufferobj_map_range(ctx, 0, ctx->Pack.BufferObj->Size,
+ GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
+ MAP_INTERNAL);
if (!buf) {
/* out of memory or other unexpected error */
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)");
}
if (ctx->Pack.BufferObj) {
- ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
}
}
if (ctx->Pack.BufferObj) {
/* pack texture image into a PBO */
dest = (GLubyte *)
- ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size,
- GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
- MAP_INTERNAL);
+ st_bufferobj_map_range(ctx, 0, ctx->Pack.BufferObj->Size,
+ GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
+ MAP_INTERNAL);
if (!dest) {
/* out of memory or other unexpected error */
_mesa_error(ctx, GL_OUT_OF_MEMORY,
}
if (ctx->Pack.BufferObj) {
- ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
}
}
* lookup an opaque structure. It would be nice if the handles and
* internal structure where somehow shared.
*/
-static struct gl_buffer_object *
+struct gl_buffer_object *
st_bufferobj_alloc(struct gl_context *ctx, GLuint name)
{
struct st_buffer_object *st_obj = ST_CALLOC_STRUCT(st_buffer_object);
* Deallocate/free a vertex/pixel buffer object.
* Called via glDeleteBuffersARB().
*/
-static void
-st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj)
+void st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj)
{
assert(obj->RefCount == 0);
_mesa_buffer_unmap_all_mappings(ctx, obj);
* if data is NULL, no copy is performed.
* Called via glBufferSubDataARB().
*/
-static void
+void
st_bufferobj_subdata(struct gl_context *ctx,
GLintptrARB offset,
GLsizeiptrARB size,
/**
* Called via glGetBufferSubDataARB().
*/
-static void
+void
st_bufferobj_get_subdata(struct gl_context *ctx,
GLintptrARB offset,
GLsizeiptrARB size,
* Called via ctx->Driver.BufferData().
* \return GL_TRUE for success, GL_FALSE if out of memory
*/
-static GLboolean
+GLboolean
st_bufferobj_data(struct gl_context *ctx,
GLenum target,
GLsizeiptrARB size,
return bufferobj_data(ctx, target, size, data, NULL, 0, usage, storageFlags, obj);
}
-static GLboolean
+GLboolean
st_bufferobj_data_mem(struct gl_context *ctx,
GLenum target,
GLsizeiptrARB size,
/**
* Called via glMapBufferRange().
*/
-static void *
+void *
st_bufferobj_map_range(struct gl_context *ctx,
GLintptr offset, GLsizeiptr length, GLbitfield access,
struct gl_buffer_object *obj,
}
-static void
+void
st_bufferobj_flush_mapped_range(struct gl_context *ctx,
GLintptr offset, GLsizeiptr length,
struct gl_buffer_object *obj,
/**
* Called via glUnmapBufferARB().
*/
-static GLboolean
+GLboolean
st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
gl_map_buffer_index index)
{
/**
* Called via glCopyBufferSubData().
*/
-static void
+void
st_copy_buffer_subdata(struct gl_context *ctx,
struct gl_buffer_object *src,
struct gl_buffer_object *dst,
/**
* Called via glClearBufferSubData().
*/
-static void
+void
st_clear_buffer_subdata(struct gl_context *ctx,
GLintptr offset, GLsizeiptr size,
const void *clearValue,
clearValue, clearValueSize);
}
-static void
+void
st_bufferobj_page_commitment(struct gl_context *ctx,
struct gl_buffer_object *bufferObj,
GLintptr offset, GLsizeiptr size,
st_init_bufferobject_functions(struct pipe_screen *screen,
struct dd_function_table *functions)
{
- functions->NewBufferObject = st_bufferobj_alloc;
- functions->DeleteBuffer = st_bufferobj_free;
- functions->BufferData = st_bufferobj_data;
- functions->BufferDataMem = st_bufferobj_data_mem;
- functions->BufferSubData = st_bufferobj_subdata;
- functions->GetBufferSubData = st_bufferobj_get_subdata;
- functions->MapBufferRange = st_bufferobj_map_range;
- functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;
- functions->UnmapBuffer = st_bufferobj_unmap;
- functions->CopyBufferSubData = st_copy_buffer_subdata;
- functions->ClearBufferSubData = st_clear_buffer_subdata;
- functions->BufferPageCommitment = st_bufferobj_page_commitment;
-
if (screen->get_param(screen, PIPE_CAP_INVALIDATE_BUFFER))
functions->InvalidateBufferSubData = st_bufferobj_invalidate;
}
return buffer;
}
+struct gl_buffer_object *st_bufferobj_alloc(struct gl_context *ctx, GLuint name);
+void st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj);
+void st_bufferobj_subdata(struct gl_context *ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ const void * data, struct gl_buffer_object *obj);
+void st_bufferobj_get_subdata(struct gl_context *ctx,
+ GLintptrARB offset,
+ GLsizeiptrARB size,
+ void * data, struct gl_buffer_object *obj);
+GLboolean st_bufferobj_data(struct gl_context *ctx,
+ GLenum target,
+ GLsizeiptrARB size,
+ const void *data,
+ GLenum usage,
+ GLbitfield storageFlags,
+ struct gl_buffer_object *obj);
+GLboolean st_bufferobj_data_mem(struct gl_context *ctx,
+ GLenum target,
+ GLsizeiptrARB size,
+ struct gl_memory_object *memObj,
+ GLuint64 offset,
+ GLenum usage,
+ struct gl_buffer_object *bufObj);
+void *st_bufferobj_map_range(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr length,
+ GLbitfield access,
+ struct gl_buffer_object *obj,
+ gl_map_buffer_index index);
+
+void st_bufferobj_flush_mapped_range(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr length,
+ struct gl_buffer_object *obj,
+ gl_map_buffer_index index);
+GLboolean st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
+ gl_map_buffer_index index);
+void st_copy_buffer_subdata(struct gl_context *ctx,
+ struct gl_buffer_object *src,
+ struct gl_buffer_object *dst,
+ GLintptr readOffset, GLintptr writeOffset,
+ GLsizeiptr size);
+void st_clear_buffer_subdata(struct gl_context *ctx,
+ GLintptr offset, GLsizeiptr size,
+ const void *clearValue,
+ GLsizeiptr clearValueSize,
+ struct gl_buffer_object *bufObj);
+void st_bufferobj_page_commitment(struct gl_context *ctx,
+ struct gl_buffer_object *bufferObj,
+ GLintptr offset, GLsizeiptr size,
+ GLboolean commit);
+
#endif
#include "vbo_noop.h"
#include "vbo_private.h"
+#include "state_tracker/st_cb_bufferobjects.h"
/** ID/name for immediate-mode VBO */
#define IMM_BUFFER_NAME 0xaabbccdd
{
struct gl_context *ctx = gl_context_from_vbo_exec(exec);
- exec->vtx.bufferobj = ctx->Driver.NewBufferObject(ctx, IMM_BUFFER_NAME);
+ exec->vtx.bufferobj = st_bufferobj_alloc(ctx, IMM_BUFFER_NAME);
vbo_exec_vtxfmt_init(exec);
_mesa_noop_vtxfmt_init(ctx, &exec->vtxfmt_noop);
*/
if (exec->vtx.bufferobj &&
_mesa_bufferobj_mapped(exec->vtx.bufferobj, MAP_INTERNAL)) {
- ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, exec->vtx.bufferobj, MAP_INTERNAL);
}
_mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
}
#include "vbo_noop.h"
#include "vbo_private.h"
+#include "state_tracker/st_cb_bufferobjects.h"
static void
vbo_exec_debug_verts(struct vbo_exec_context *exec)
if (exec->vtx.bufferobj) {
struct gl_context *ctx = gl_context_from_vbo_exec(exec);
- if (ctx->Driver.FlushMappedBufferRange &&
- !ctx->Extensions.ARB_buffer_storage) {
+ if (!ctx->Extensions.ARB_buffer_storage) {
GLintptr offset = exec->vtx.buffer_used -
exec->vtx.bufferobj->Mappings[MAP_INTERNAL].Offset;
GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) *
sizeof(float);
if (length)
- ctx->Driver.FlushMappedBufferRange(ctx, offset, length,
- exec->vtx.bufferobj,
- MAP_INTERNAL);
+ st_bufferobj_flush_mapped_range(ctx, offset, length,
+ exec->vtx.bufferobj,
+ MAP_INTERNAL);
}
exec->vtx.buffer_used += (exec->vtx.buffer_ptr -
assert(exec->vtx.buffer_used <= ctx->Const.glBeginEndBufferSize);
assert(exec->vtx.buffer_ptr != NULL);
- ctx->Driver.UnmapBuffer(ctx, exec->vtx.bufferobj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, exec->vtx.bufferobj, MAP_INTERNAL);
exec->vtx.buffer_map = NULL;
exec->vtx.buffer_ptr = NULL;
exec->vtx.max_vert = 0;
/* The VBO exists and there's room for more */
if (exec->vtx.bufferobj->Size > 0) {
exec->vtx.buffer_map = (fi_type *)
- ctx->Driver.MapBufferRange(ctx,
- exec->vtx.buffer_used,
- ctx->Const.glBeginEndBufferSize
- - exec->vtx.buffer_used,
- accessRange,
- exec->vtx.bufferobj,
- MAP_INTERNAL);
+ st_bufferobj_map_range(ctx,
+ exec->vtx.buffer_used,
+ ctx->Const.glBeginEndBufferSize
+ - exec->vtx.buffer_used,
+ accessRange,
+ exec->vtx.bufferobj,
+ MAP_INTERNAL);
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
}
else {
/* Need to allocate a new VBO */
exec->vtx.buffer_used = 0;
- if (ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER_ARB,
- ctx->Const.glBeginEndBufferSize,
- NULL, usage,
- GL_MAP_WRITE_BIT |
- (ctx->Extensions.ARB_buffer_storage ?
- GL_MAP_PERSISTENT_BIT |
- GL_MAP_COHERENT_BIT |
- GL_MAP_READ_BIT : 0) |
- GL_DYNAMIC_STORAGE_BIT |
- GL_CLIENT_STORAGE_BIT,
- exec->vtx.bufferobj)) {
+ if (st_bufferobj_data(ctx, GL_ARRAY_BUFFER_ARB,
+ ctx->Const.glBeginEndBufferSize,
+ NULL, usage,
+ GL_MAP_WRITE_BIT |
+ (ctx->Extensions.ARB_buffer_storage ?
+ GL_MAP_PERSISTENT_BIT |
+ GL_MAP_COHERENT_BIT |
+ GL_MAP_READ_BIT : 0) |
+ GL_DYNAMIC_STORAGE_BIT |
+ GL_CLIENT_STORAGE_BIT,
+ exec->vtx.bufferobj)) {
/* buffer allocation worked, now map the buffer */
exec->vtx.buffer_map =
- (fi_type *)ctx->Driver.MapBufferRange(ctx,
- 0, ctx->Const.glBeginEndBufferSize,
- accessRange,
- exec->vtx.bufferobj,
- MAP_INTERNAL);
+ (fi_type *)st_bufferobj_map_range(ctx,
+ 0, ctx->Const.glBeginEndBufferSize,
+ accessRange,
+ exec->vtx.bufferobj,
+ MAP_INTERNAL);
}
else {
_mesa_error(ctx, GL_OUT_OF_MEMORY, "VBO allocation");
#include "util/u_memory.h"
#include "pipe/p_state.h"
+#include "state_tracker/st_cb_bufferobjects.h"
struct minmax_cache_key {
GLintptr offset;
max_index))
return;
- indices = ctx->Driver.MapBufferRange(ctx, offset, size, GL_MAP_READ_BIT,
- obj, MAP_INTERNAL);
+ indices = st_bufferobj_map_range(ctx, offset, size, GL_MAP_READ_BIT,
+ obj, MAP_INTERNAL);
}
vbo_get_minmax_index_mapped(count, index_size, restart_index,
if (obj) {
vbo_minmax_cache_store(ctx, obj, index_size, offset, count, *min_index,
*max_index);
- ctx->Driver.UnmapBuffer(ctx, obj, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, obj, MAP_INTERNAL);
}
}
#include "vbo_noop.h"
#include "vbo_private.h"
+#include "state_tracker/st_cb_bufferobjects.h"
#ifdef ERROR
#undef ERROR
if (total_bytes_needed > available_bytes) {
if (save->current_bo)
_mesa_reference_buffer_object(ctx, &save->current_bo, NULL);
- save->current_bo = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID + 1);
- bool success = ctx->Driver.BufferData(ctx,
- GL_ELEMENT_ARRAY_BUFFER_ARB,
- MAX2(total_bytes_needed, VBO_SAVE_BUFFER_SIZE),
- NULL,
- GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
- MESA_GALLIUM_VERTEX_STATE_STORAGE,
- save->current_bo);
+ save->current_bo = st_bufferobj_alloc(ctx, VBO_BUF_ID + 1);
+ bool success = st_bufferobj_data(ctx,
+ GL_ELEMENT_ARRAY_BUFFER_ARB,
+ MAX2(total_bytes_needed, VBO_SAVE_BUFFER_SIZE),
+ NULL,
+ GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
+ MESA_GALLIUM_VERTEX_STATE_STORAGE,
+ save->current_bo);
if (!success) {
_mesa_reference_buffer_object(ctx, &save->current_bo, NULL);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "IB allocation");
_mesa_reference_buffer_object(ctx, &node->cold->ib.obj, save->current_bo);
/* Upload the vertices first (see buffer_offset) */
- ctx->Driver.BufferSubData(ctx,
- save->current_bo_bytes_used,
- total_vert_count * save->vertex_size * sizeof(fi_type),
- vertex_to_index ? temp_vertices_buffer : save->vertex_store->buffer_in_ram,
- node->cold->ib.obj);
+ st_bufferobj_subdata(ctx,
+ save->current_bo_bytes_used,
+ total_vert_count * save->vertex_size * sizeof(fi_type),
+ vertex_to_index ? temp_vertices_buffer : save->vertex_store->buffer_in_ram,
+ node->cold->ib.obj);
save->current_bo_bytes_used += total_vert_count * save->vertex_size * sizeof(fi_type);
if (vertex_to_index) {
/* Then upload the indices. */
if (node->cold->ib.obj) {
- ctx->Driver.BufferSubData(ctx,
- save->current_bo_bytes_used,
- idx * sizeof(uint32_t),
- indices,
- node->cold->ib.obj);
+ st_bufferobj_subdata(ctx,
+ save->current_bo_bytes_used,
+ idx * sizeof(uint32_t),
+ indices,
+ node->cold->ib.obj);
save->current_bo_bytes_used += idx * sizeof(uint32_t);
} else {
node->cold->vertex_count = 0;
node->draw_begins = node->cold->prims[0].begin;
if (!save->current_bo) {
- save->current_bo = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID + 1);
- bool success = ctx->Driver.BufferData(ctx,
- GL_ELEMENT_ARRAY_BUFFER_ARB,
- VBO_SAVE_BUFFER_SIZE,
- NULL,
- GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
- MESA_GALLIUM_VERTEX_STATE_STORAGE,
- save->current_bo);
+ save->current_bo = st_bufferobj_alloc(ctx, VBO_BUF_ID + 1);
+ bool success = st_bufferobj_data(ctx,
+ GL_ELEMENT_ARRAY_BUFFER_ARB,
+ VBO_SAVE_BUFFER_SIZE,
+ NULL,
+ GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
+ MESA_GALLIUM_VERTEX_STATE_STORAGE,
+ save->current_bo);
if (!success)
handle_out_of_memory(ctx);
}
#include "vbo_private.h"
+#include "state_tracker/st_cb_bufferobjects.h"
static void
copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao,
const struct vbo_save_vertex_list *list)
{
struct gl_buffer_object *bo = list->cold->VAO[0]->BufferBinding[0].BufferObj;
- void *buffer = ctx->Driver.MapBufferRange(ctx, 0, bo->Size, GL_MAP_READ_BIT, /* ? */
- bo, MAP_INTERNAL);
+ void *buffer = st_bufferobj_map_range(ctx, 0, bo->Size, GL_MAP_READ_BIT, /* ? */
+ bo, MAP_INTERNAL);
/* TODO: in this case, we shouldn't create a bo at all and instead keep
* the in-RAM buffer. */
_vbo_loopback_vertex_list(ctx, list, buffer);
- ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
+ st_bufferobj_unmap(ctx, bo, MAP_INTERNAL);
}