mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 09:00:10 +01:00
mesa/st: replace most of buffer funcs with direct calls.
This leaves invalidate buffer for later Acked-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14100>
This commit is contained in:
parent
f60add48ee
commit
c9fec99c4a
14 changed files with 229 additions and 261 deletions
|
|
@ -57,6 +57,7 @@
|
|||
#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] =
|
||||
|
|
@ -871,7 +872,7 @@ _mesa_vao_map_arrays(struct gl_context *ctx, struct gl_vertex_array_object *vao,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -887,7 +888,7 @@ _mesa_vao_map(struct gl_context *ctx, struct gl_vertex_array_object *vao,
|
|||
|
||||
/* 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);
|
||||
}
|
||||
|
|
@ -913,7 +914,7 @@ _mesa_vao_unmap_arrays(struct gl_context *ctx,
|
|||
if (!_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
|
||||
continue;
|
||||
|
||||
ctx->Driver.UnmapBuffer(ctx, bo, MAP_INTERNAL);
|
||||
st_bufferobj_unmap(ctx, bo, MAP_INTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -928,7 +929,7 @@ _mesa_vao_unmap(struct gl_context *ctx, struct gl_vertex_array_object *vao)
|
|||
|
||||
/* 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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,6 +49,7 @@
|
|||
#include "util/u_memory.h"
|
||||
#include "util/set.h"
|
||||
|
||||
#include "state_tracker/st_cb_bufferobjects.h"
|
||||
|
||||
/* Debug flags */
|
||||
/*#define VBO_DEBUG*/
|
||||
|
|
@ -499,8 +500,7 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
|
|||
*/
|
||||
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. */
|
||||
|
|
@ -618,11 +618,10 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
|
|||
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");
|
||||
|
|
@ -632,7 +631,7 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -641,7 +640,7 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
|
|||
dest += clearValueSize;
|
||||
}
|
||||
|
||||
ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_INTERNAL);
|
||||
st_bufferobj_unmap(ctx, bufObj, MAP_INTERNAL);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -811,7 +810,7 @@ _mesa_free_buffer_objects( struct gl_context *ctx )
|
|||
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 */
|
||||
|
|
@ -1037,7 +1036,7 @@ _mesa_buffer_unmap_all_mappings(struct gl_context *ctx,
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
|
@ -1515,7 +1514,6 @@ create_buffers(struct gl_context *ctx, GLsizei n, GLuint *buffers, bool dsa)
|
|||
*/
|
||||
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");
|
||||
|
|
@ -1691,14 +1689,12 @@ buffer_storage(struct gl_context *ctx, struct gl_buffer_object *bufObj,
|
|||
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) {
|
||||
|
|
@ -1946,12 +1942,11 @@ buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
|
|||
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:
|
||||
|
|
@ -2126,8 +2121,7 @@ _mesa_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2238,8 +2232,7 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset,
|
|||
return;
|
||||
}
|
||||
|
||||
assert(ctx->Driver.GetBufferSubData);
|
||||
ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
|
||||
st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
|
|
@ -2259,8 +2252,7 @@ _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
|
|||
return;
|
||||
}
|
||||
|
||||
assert(ctx->Driver.GetBufferSubData);
|
||||
ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
|
||||
st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -2287,8 +2279,7 @@ _mesa_GetNamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
|
|||
return;
|
||||
}
|
||||
|
||||
assert(ctx->Driver.GetBufferSubData);
|
||||
ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
|
||||
st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -2337,7 +2328,7 @@ clear_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *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;
|
||||
}
|
||||
|
|
@ -2347,8 +2338,8 @@ clear_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
|
|||
return;
|
||||
}
|
||||
|
||||
ctx->Driver.ClearBufferSubData(ctx, offset, size,
|
||||
clearValue, clearValueSize, bufObj);
|
||||
st_clear_buffer_subdata(ctx, offset, size,
|
||||
clearValue, clearValueSize, bufObj);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -2540,7 +2531,7 @@ _mesa_ClearNamedBufferSubDataEXT(GLuint buffer, GLenum internalformat,
|
|||
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);
|
||||
|
|
@ -2943,7 +2934,7 @@ copy_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *src,
|
|||
|
||||
dst->MinMaxCacheDirty = true;
|
||||
|
||||
ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size);
|
||||
st_copy_buffer_subdata(ctx, src, dst, readOffset, writeOffset, size);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
|
|
@ -2960,8 +2951,8 @@ _mesa_CopyBufferSubData_no_error(GLenum readTarget, GLenum writeTarget,
|
|||
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
|
||||
|
|
@ -3021,8 +3012,8 @@ _mesa_CopyNamedBufferSubData_no_error(GLuint readBuffer, GLuint writeBuffer,
|
|||
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
|
||||
|
|
@ -3081,7 +3072,7 @@ _mesa_InternalBufferSubDataCopyMESA(GLintptr srcBuffer, GLuint srcOffset,
|
|||
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. */
|
||||
|
|
@ -3235,9 +3226,8 @@ map_buffer_range(struct gl_context *ctx, struct gl_buffer_object *bufObj,
|
|||
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);
|
||||
}
|
||||
|
|
@ -3565,9 +3555,8 @@ flush_mapped_buffer_range(struct gl_context *ctx,
|
|||
|
||||
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
|
||||
|
|
@ -3578,9 +3567,8 @@ _mesa_FlushMappedBufferRange_no_error(GLenum target, GLintptr offset,
|
|||
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
|
||||
|
|
@ -3606,9 +3594,8 @@ _mesa_FlushMappedNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
|
|||
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
|
||||
|
|
@ -4824,7 +4811,7 @@ buffer_page_commitment(struct gl_context *ctx,
|
|||
return;
|
||||
}
|
||||
|
||||
ctx->Driver.BufferPageCommitment(ctx, bufferObj, offset, size, commit);
|
||||
st_bufferobj_page_commitment(ctx, bufferObj, offset, size, commit);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
|
|
|
|||
|
|
@ -265,56 +265,11 @@ struct dd_function_table {
|
|||
* \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);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
|
|
@ -455,27 +410,6 @@ struct dd_function_table {
|
|||
const GLuint *group_size);
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
* \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
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@
|
|||
|
||||
#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
|
||||
|
||||
|
|
@ -1473,9 +1474,9 @@ unpack_image(struct gl_context *ctx, GLuint dimensions,
|
|||
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");
|
||||
|
|
@ -1486,7 +1487,7 @@ unpack_image(struct gl_context *ctx, GLuint dimensions,
|
|||
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");
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
#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.
|
||||
|
|
@ -34,27 +36,27 @@ new_upload_buffer(struct gl_context *ctx, GLsizeiptr size, uint8_t **ptr)
|
|||
{
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@
|
|||
#include "macros.h"
|
||||
#include "pbo.h"
|
||||
|
||||
#include "state_tracker/st_cb_bufferobjects.h"
|
||||
|
||||
|
||||
/**
|
||||
|
|
@ -153,11 +154,11 @@ _mesa_map_pbo_source(struct gl_context *ctx,
|
|||
|
||||
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;
|
||||
|
||||
|
|
@ -285,7 +286,7 @@ _mesa_unmap_pbo_source(struct gl_context *ctx,
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -307,11 +308,11 @@ _mesa_map_pbo_dest(struct gl_context *ctx,
|
|||
|
||||
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;
|
||||
|
||||
|
|
@ -382,7 +383,7 @@ _mesa_unmap_pbo_dest(struct gl_context *ctx,
|
|||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -413,11 +414,11 @@ _mesa_validate_pbo_teximage(struct gl_context *ctx, GLuint dimensions,
|
|||
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);
|
||||
|
|
@ -455,11 +456,11 @@ _mesa_validate_pbo_compressed_teximage(struct gl_context *ctx,
|
|||
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.
|
||||
|
|
@ -479,6 +480,6 @@ _mesa_unmap_teximage_pbo(struct gl_context *ctx,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@
|
|||
#include "pixeltransfer.h"
|
||||
|
||||
#include "state_tracker/st_cb_texture.h"
|
||||
#include "state_tracker/st_cb_bufferobjects.h"
|
||||
|
||||
/**
|
||||
* Can the given type represent negative values?
|
||||
|
|
@ -709,9 +710,9 @@ _mesa_GetTexSubImage_sw(struct gl_context *ctx,
|
|||
* 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)");
|
||||
|
|
@ -761,7 +762,7 @@ _mesa_GetTexSubImage_sw(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
if (ctx->Pack.BufferObj) {
|
||||
ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
|
||||
st_bufferobj_unmap(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -791,9 +792,9 @@ get_compressed_texsubimage_sw(struct gl_context *ctx,
|
|||
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,
|
||||
|
|
@ -836,7 +837,7 @@ get_compressed_texsubimage_sw(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
if (ctx->Pack.BufferObj) {
|
||||
ctx->Driver.UnmapBuffer(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
|
||||
st_bufferobj_unmap(ctx, ctx->Pack.BufferObj, MAP_INTERNAL);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@
|
|||
* 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);
|
||||
|
|
@ -97,8 +97,7 @@ release_buffer(struct gl_buffer_object *obj)
|
|||
* 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);
|
||||
|
|
@ -114,7 +113,7 @@ st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *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,
|
||||
|
|
@ -164,7 +163,7 @@ st_bufferobj_subdata(struct gl_context *ctx,
|
|||
/**
|
||||
* Called via glGetBufferSubDataARB().
|
||||
*/
|
||||
static void
|
||||
void
|
||||
st_bufferobj_get_subdata(struct gl_context *ctx,
|
||||
GLintptrARB offset,
|
||||
GLsizeiptrARB size,
|
||||
|
|
@ -427,7 +426,7 @@ bufferobj_data(struct gl_context *ctx,
|
|||
* 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,
|
||||
|
|
@ -439,7 +438,7 @@ st_bufferobj_data(struct gl_context *ctx,
|
|||
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,
|
||||
|
|
@ -530,7 +529,7 @@ st_access_flags_to_transfer_flags(GLbitfield access, bool wholeBuffer)
|
|||
/**
|
||||
* 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,
|
||||
|
|
@ -576,7 +575,7 @@ st_bufferobj_map_range(struct gl_context *ctx,
|
|||
}
|
||||
|
||||
|
||||
static void
|
||||
void
|
||||
st_bufferobj_flush_mapped_range(struct gl_context *ctx,
|
||||
GLintptr offset, GLsizeiptr length,
|
||||
struct gl_buffer_object *obj,
|
||||
|
|
@ -603,7 +602,7 @@ st_bufferobj_flush_mapped_range(struct gl_context *ctx,
|
|||
/**
|
||||
* Called via glUnmapBufferARB().
|
||||
*/
|
||||
static GLboolean
|
||||
GLboolean
|
||||
st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
|
||||
gl_map_buffer_index index)
|
||||
{
|
||||
|
|
@ -624,7 +623,7 @@ st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
|
|||
/**
|
||||
* Called via glCopyBufferSubData().
|
||||
*/
|
||||
static void
|
||||
void
|
||||
st_copy_buffer_subdata(struct gl_context *ctx,
|
||||
struct gl_buffer_object *src,
|
||||
struct gl_buffer_object *dst,
|
||||
|
|
@ -652,7 +651,7 @@ st_copy_buffer_subdata(struct gl_context *ctx,
|
|||
/**
|
||||
* Called via glClearBufferSubData().
|
||||
*/
|
||||
static void
|
||||
void
|
||||
st_clear_buffer_subdata(struct gl_context *ctx,
|
||||
GLintptr offset, GLsizeiptr size,
|
||||
const void *clearValue,
|
||||
|
|
@ -676,7 +675,7 @@ st_clear_buffer_subdata(struct gl_context *ctx,
|
|||
clearValue, clearValueSize);
|
||||
}
|
||||
|
||||
static void
|
||||
void
|
||||
st_bufferobj_page_commitment(struct gl_context *ctx,
|
||||
struct gl_buffer_object *bufferObj,
|
||||
GLintptr offset, GLsizeiptr size,
|
||||
|
|
@ -698,19 +697,6 @@ void
|
|||
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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -115,4 +115,55 @@ st_get_buffer_reference(struct gl_context *ctx, struct gl_buffer_object *obj)
|
|||
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
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#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
|
||||
|
|
@ -1034,7 +1035,7 @@ vbo_exec_vtx_init(struct vbo_exec_context *exec)
|
|||
{
|
||||
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);
|
||||
|
|
@ -1069,7 +1070,7 @@ vbo_exec_vtx_destroy(struct vbo_exec_context *exec)
|
|||
*/
|
||||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@
|
|||
#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)
|
||||
|
|
@ -157,17 +158,16 @@ vbo_exec_vtx_unmap(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 -
|
||||
|
|
@ -176,7 +176,7 @@ vbo_exec_vtx_unmap(struct vbo_exec_context *exec)
|
|||
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;
|
||||
|
|
@ -227,13 +227,13 @@ vbo_exec_vtx_map(struct vbo_exec_context *exec)
|
|||
/* 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 {
|
||||
|
|
@ -245,24 +245,24 @@ vbo_exec_vtx_map(struct vbo_exec_context *exec)
|
|||
/* 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");
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@
|
|||
#include "util/u_memory.h"
|
||||
#include "pipe/p_state.h"
|
||||
|
||||
#include "state_tracker/st_cb_bufferobjects.h"
|
||||
|
||||
struct minmax_cache_key {
|
||||
GLintptr offset;
|
||||
|
|
@ -338,8 +339,8 @@ vbo_get_minmax_index(struct gl_context *ctx, struct gl_buffer_object *obj,
|
|||
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,
|
||||
|
|
@ -349,7 +350,7 @@ vbo_get_minmax_index(struct gl_context *ctx, struct gl_buffer_object *obj,
|
|||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|||
#include "vbo_noop.h"
|
||||
#include "vbo_private.h"
|
||||
|
||||
#include "state_tracker/st_cb_bufferobjects.h"
|
||||
|
||||
#ifdef ERROR
|
||||
#undef ERROR
|
||||
|
|
@ -776,14 +777,14 @@ compile_vertex_list(struct gl_context *ctx)
|
|||
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");
|
||||
|
|
@ -832,11 +833,11 @@ compile_vertex_list(struct gl_context *ctx)
|
|||
_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) {
|
||||
|
|
@ -854,11 +855,11 @@ compile_vertex_list(struct gl_context *ctx)
|
|||
|
||||
/* 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;
|
||||
|
|
@ -909,14 +910,14 @@ end:
|
|||
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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@
|
|||
|
||||
#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,
|
||||
|
|
@ -147,14 +148,14 @@ loopback_vertex_list(struct gl_context *ctx,
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue