mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-23 19:50:11 +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_math.h"
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
|
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
const GLubyte
|
const GLubyte
|
||||||
_mesa_vao_attribute_map[ATTRIBUTE_MAP_MODE_MAX][VERT_ATTRIB_MAX] =
|
_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))
|
if (_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
|
||||||
continue;
|
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 */
|
/* map the index buffer, if there is one, and not already mapped */
|
||||||
if (bo && !_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
|
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);
|
_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))
|
if (!_mesa_bufferobj_mapped(bo, MAP_INTERNAL))
|
||||||
continue;
|
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 */
|
/* unmap the index buffer, if there is one, and still mapped */
|
||||||
if (bo && _mesa_bufferobj_mapped(bo, MAP_INTERNAL))
|
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);
|
_mesa_vao_unmap_arrays(ctx, vao);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -49,6 +49,7 @@
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "util/set.h"
|
#include "util/set.h"
|
||||||
|
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
/* Debug flags */
|
/* Debug flags */
|
||||||
/*#define VBO_DEBUG*/
|
/*#define VBO_DEBUG*/
|
||||||
|
|
@ -499,8 +500,7 @@ _mesa_reference_buffer_object_(struct gl_context *ctx,
|
||||||
*/
|
*/
|
||||||
if (shared_binding || ctx != oldObj->Ctx) {
|
if (shared_binding || ctx != oldObj->Ctx) {
|
||||||
if (p_atomic_dec_zero(&oldObj->RefCount)) {
|
if (p_atomic_dec_zero(&oldObj->RefCount)) {
|
||||||
assert(ctx->Driver.DeleteBuffer);
|
st_bufferobj_free(ctx, oldObj);
|
||||||
ctx->Driver.DeleteBuffer(ctx, oldObj);
|
|
||||||
}
|
}
|
||||||
} else if (ctx == oldObj->Ctx) {
|
} else if (ctx == oldObj->Ctx) {
|
||||||
/* Update the private ref count. */
|
/* Update the private ref count. */
|
||||||
|
|
@ -618,11 +618,10 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
|
||||||
GLsizeiptr i;
|
GLsizeiptr i;
|
||||||
GLubyte *dest;
|
GLubyte *dest;
|
||||||
|
|
||||||
assert(ctx->Driver.MapBufferRange);
|
dest = st_bufferobj_map_range(ctx, offset, size,
|
||||||
dest = ctx->Driver.MapBufferRange(ctx, offset, size,
|
GL_MAP_WRITE_BIT |
|
||||||
GL_MAP_WRITE_BIT |
|
GL_MAP_INVALIDATE_RANGE_BIT,
|
||||||
GL_MAP_INVALIDATE_RANGE_BIT,
|
bufObj, MAP_INTERNAL);
|
||||||
bufObj, MAP_INTERNAL);
|
|
||||||
|
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glClearBuffer[Sub]Data");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glClearBuffer[Sub]Data");
|
||||||
|
|
@ -632,7 +631,7 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
|
||||||
if (clearValue == NULL) {
|
if (clearValue == NULL) {
|
||||||
/* Clear with zeros, per the spec */
|
/* Clear with zeros, per the spec */
|
||||||
memset(dest, 0, size);
|
memset(dest, 0, size);
|
||||||
ctx->Driver.UnmapBuffer(ctx, bufObj, MAP_INTERNAL);
|
st_bufferobj_unmap(ctx, bufObj, MAP_INTERNAL);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -641,7 +640,7 @@ _mesa_ClearBufferSubData_sw(struct gl_context *ctx,
|
||||||
dest += clearValueSize;
|
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 *
|
static struct gl_buffer_object *
|
||||||
new_gl_buffer_object(struct gl_context *ctx, GLuint id)
|
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->Ctx = ctx;
|
||||||
buf->RefCount++; /* global buffer reference held by the context */
|
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++) {
|
for (int i = 0; i < MAP_COUNT; i++) {
|
||||||
if (_mesa_bufferobj_mapped(bufObj, 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);
|
assert(bufObj->Mappings[i].Pointer == NULL);
|
||||||
bufObj->Mappings[i].AccessFlags = 0;
|
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++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (dsa) {
|
if (dsa) {
|
||||||
assert(ctx->Driver.NewBufferObject);
|
|
||||||
buf = new_gl_buffer_object(ctx, buffers[i]);
|
buf = new_gl_buffer_object(ctx, buffers[i]);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glCreateBuffers");
|
_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;
|
bufObj->MinMaxCacheDirty = true;
|
||||||
|
|
||||||
if (memObj) {
|
if (memObj) {
|
||||||
assert(ctx->Driver.BufferDataMem);
|
res = st_bufferobj_data_mem(ctx, target, size, memObj, offset,
|
||||||
res = ctx->Driver.BufferDataMem(ctx, target, size, memObj, offset,
|
GL_DYNAMIC_DRAW, bufObj);
|
||||||
GL_DYNAMIC_DRAW, bufObj);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
assert(ctx->Driver.BufferData);
|
res = st_bufferobj_data(ctx, target, size, data, GL_DYNAMIC_DRAW,
|
||||||
res = ctx->Driver.BufferData(ctx, target, size, data, GL_DYNAMIC_DRAW,
|
flags, bufObj);
|
||||||
flags, bufObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!res) {
|
if (!res) {
|
||||||
|
|
@ -1946,12 +1942,11 @@ buffer_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
|
||||||
size += 100;
|
size += 100;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
assert(ctx->Driver.BufferData);
|
if (!st_bufferobj_data(ctx, target, size, data, usage,
|
||||||
if (!ctx->Driver.BufferData(ctx, target, size, data, usage,
|
GL_MAP_READ_BIT |
|
||||||
GL_MAP_READ_BIT |
|
GL_MAP_WRITE_BIT |
|
||||||
GL_MAP_WRITE_BIT |
|
GL_DYNAMIC_STORAGE_BIT,
|
||||||
GL_DYNAMIC_STORAGE_BIT,
|
bufObj)) {
|
||||||
bufObj)) {
|
|
||||||
if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
|
if (target == GL_EXTERNAL_VIRTUAL_MEMORY_BUFFER_AMD) {
|
||||||
if (!no_error) {
|
if (!no_error) {
|
||||||
/* From GL_AMD_pinned_memory:
|
/* 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->Written = GL_TRUE;
|
||||||
bufObj->MinMaxCacheDirty = true;
|
bufObj->MinMaxCacheDirty = true;
|
||||||
|
|
||||||
assert(ctx->Driver.BufferSubData);
|
st_bufferobj_subdata(ctx, offset, size, data, bufObj);
|
||||||
ctx->Driver.BufferSubData(ctx, offset, size, data, bufObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2238,8 +2232,7 @@ _mesa_GetBufferSubData(GLenum target, GLintptr offset,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ctx->Driver.GetBufferSubData);
|
st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
|
||||||
ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
@ -2259,8 +2252,7 @@ _mesa_GetNamedBufferSubData(GLuint buffer, GLintptr offset,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ctx->Driver.GetBufferSubData);
|
st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
|
||||||
ctx->Driver.GetBufferSubData(ctx, offset, size, data, bufObj);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -2287,8 +2279,7 @@ _mesa_GetNamedBufferSubDataEXT(GLuint buffer, GLintptr offset,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ctx->Driver.GetBufferSubData);
|
st_bufferobj_get_subdata(ctx, offset, size, data, bufObj);
|
||||||
ctx->Driver.GetBufferSubData(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) {
|
if (data == NULL) {
|
||||||
/* clear to zeros, per the spec */
|
/* clear to zeros, per the spec */
|
||||||
ctx->Driver.ClearBufferSubData(ctx, offset, size,
|
st_clear_buffer_subdata(ctx, offset, size,
|
||||||
NULL, clearValueSize, bufObj);
|
NULL, clearValueSize, bufObj);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -2347,8 +2338,8 @@ clear_buffer_sub_data(struct gl_context *ctx, struct gl_buffer_object *bufObj,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->Driver.ClearBufferSubData(ctx, offset, size,
|
st_clear_buffer_subdata(ctx, offset, size,
|
||||||
clearValue, clearValueSize, bufObj);
|
clearValue, clearValueSize, bufObj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
|
@ -2540,7 +2531,7 @@ _mesa_ClearNamedBufferSubDataEXT(GLuint buffer, GLenum internalformat,
|
||||||
static GLboolean
|
static GLboolean
|
||||||
unmap_buffer(struct gl_context *ctx, struct gl_buffer_object *bufObj)
|
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;
|
bufObj->Mappings[MAP_USER].AccessFlags = 0;
|
||||||
assert(bufObj->Mappings[MAP_USER].Pointer == NULL);
|
assert(bufObj->Mappings[MAP_USER].Pointer == NULL);
|
||||||
assert(bufObj->Mappings[MAP_USER].Offset == 0);
|
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;
|
dst->MinMaxCacheDirty = true;
|
||||||
|
|
||||||
ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset, size);
|
st_copy_buffer_subdata(ctx, src, dst, readOffset, writeOffset, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
@ -2960,8 +2951,8 @@ _mesa_CopyBufferSubData_no_error(GLenum readTarget, GLenum writeTarget,
|
||||||
struct gl_buffer_object *dst = *dst_ptr;
|
struct gl_buffer_object *dst = *dst_ptr;
|
||||||
|
|
||||||
dst->MinMaxCacheDirty = true;
|
dst->MinMaxCacheDirty = true;
|
||||||
ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset,
|
st_copy_buffer_subdata(ctx, src, dst, readOffset, writeOffset,
|
||||||
size);
|
size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
@ -3021,8 +3012,8 @@ _mesa_CopyNamedBufferSubData_no_error(GLuint readBuffer, GLuint writeBuffer,
|
||||||
struct gl_buffer_object *dst = _mesa_lookup_bufferobj(ctx, writeBuffer);
|
struct gl_buffer_object *dst = _mesa_lookup_bufferobj(ctx, writeBuffer);
|
||||||
|
|
||||||
dst->MinMaxCacheDirty = true;
|
dst->MinMaxCacheDirty = true;
|
||||||
ctx->Driver.CopyBufferSubData(ctx, src, dst, readOffset, writeOffset,
|
st_copy_buffer_subdata(ctx, src, dst, readOffset, writeOffset,
|
||||||
size);
|
size);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
@ -3081,7 +3072,7 @@ _mesa_InternalBufferSubDataCopyMESA(GLintptr srcBuffer, GLuint srcOffset,
|
||||||
goto done; /* the error is already set */
|
goto done; /* the error is already set */
|
||||||
|
|
||||||
dst->MinMaxCacheDirty = true;
|
dst->MinMaxCacheDirty = true;
|
||||||
ctx->Driver.CopyBufferSubData(ctx, src, dst, srcOffset, dstOffset, size);
|
st_copy_buffer_subdata(ctx, src, dst, srcOffset, dstOffset, size);
|
||||||
|
|
||||||
done:
|
done:
|
||||||
/* The caller passes the reference to this function, so unreference it. */
|
/* 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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(ctx->Driver.MapBufferRange);
|
void *map = st_bufferobj_map_range(ctx, offset, length, access, bufObj,
|
||||||
void *map = ctx->Driver.MapBufferRange(ctx, offset, length, access, bufObj,
|
MAP_USER);
|
||||||
MAP_USER);
|
|
||||||
if (!map) {
|
if (!map) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "%s(map failed)", func);
|
_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);
|
assert(bufObj->Mappings[MAP_USER].AccessFlags & GL_MAP_WRITE_BIT);
|
||||||
|
|
||||||
if (ctx->Driver.FlushMappedBufferRange)
|
st_bufferobj_flush_mapped_range(ctx, offset, length, bufObj,
|
||||||
ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj,
|
MAP_USER);
|
||||||
MAP_USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
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 **bufObjPtr = get_buffer_target(ctx, target);
|
||||||
struct gl_buffer_object *bufObj = *bufObjPtr;
|
struct gl_buffer_object *bufObj = *bufObjPtr;
|
||||||
|
|
||||||
if (ctx->Driver.FlushMappedBufferRange)
|
st_bufferobj_flush_mapped_range(ctx, offset, length, bufObj,
|
||||||
ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj,
|
MAP_USER);
|
||||||
MAP_USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
@ -3606,9 +3594,8 @@ _mesa_FlushMappedNamedBufferRange_no_error(GLuint buffer, GLintptr offset,
|
||||||
GET_CURRENT_CONTEXT(ctx);
|
GET_CURRENT_CONTEXT(ctx);
|
||||||
struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
|
struct gl_buffer_object *bufObj = _mesa_lookup_bufferobj(ctx, buffer);
|
||||||
|
|
||||||
if (ctx->Driver.FlushMappedBufferRange)
|
st_bufferobj_flush_mapped_range(ctx, offset, length, bufObj,
|
||||||
ctx->Driver.FlushMappedBufferRange(ctx, offset, length, bufObj,
|
MAP_USER);
|
||||||
MAP_USER);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
@ -4824,7 +4811,7 @@ buffer_page_commitment(struct gl_context *ctx,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ctx->Driver.BufferPageCommitment(ctx, bufferObj, offset, size, commit);
|
st_bufferobj_page_commitment(ctx, bufferObj, offset, size, commit);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLAPIENTRY
|
void GLAPIENTRY
|
||||||
|
|
|
||||||
|
|
@ -265,56 +265,11 @@ struct dd_function_table {
|
||||||
* \name Vertex/pixel buffer object functions
|
* \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,
|
void (*InvalidateBufferSubData)( struct gl_context *ctx,
|
||||||
struct gl_buffer_object *obj,
|
struct gl_buffer_object *obj,
|
||||||
GLintptr offset,
|
GLintptr offset,
|
||||||
GLsizeiptr length );
|
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);
|
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
|
* \name GL_ARB_get_program_binary
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -78,6 +78,7 @@
|
||||||
|
|
||||||
#include "state_tracker/st_cb_texture.h"
|
#include "state_tracker/st_cb_texture.h"
|
||||||
#include "state_tracker/st_cb_bitmap.h"
|
#include "state_tracker/st_cb_bitmap.h"
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
#define USE_BITMAP_ATLAS 1
|
#define USE_BITMAP_ATLAS 1
|
||||||
|
|
||||||
|
|
@ -1473,9 +1474,9 @@ unpack_image(struct gl_context *ctx, GLuint dimensions,
|
||||||
GLvoid *image;
|
GLvoid *image;
|
||||||
|
|
||||||
map = (GLubyte *)
|
map = (GLubyte *)
|
||||||
ctx->Driver.MapBufferRange(ctx, 0, unpack->BufferObj->Size,
|
st_bufferobj_map_range(ctx, 0, unpack->BufferObj->Size,
|
||||||
GL_MAP_READ_BIT, unpack->BufferObj,
|
GL_MAP_READ_BIT, unpack->BufferObj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
if (!map) {
|
if (!map) {
|
||||||
/* unable to map src buffer! */
|
/* unable to map src buffer! */
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "unable to map PBO");
|
_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,
|
image = _mesa_unpack_image(dimensions, width, height, depth,
|
||||||
format, type, src, unpack);
|
format, type, src, unpack);
|
||||||
|
|
||||||
ctx->Driver.UnmapBuffer(ctx, unpack->BufferObj, MAP_INTERNAL);
|
st_bufferobj_unmap(ctx, unpack->BufferObj, MAP_INTERNAL);
|
||||||
|
|
||||||
if (!image) {
|
if (!image) {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "display list construction");
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,8 @@
|
||||||
#include "main/dispatch.h"
|
#include "main/dispatch.h"
|
||||||
#include "main/bufferobj.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
|
* Create an upload buffer. This is called from the app thread, so everything
|
||||||
* has to be thread-safe in the driver.
|
* 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);
|
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)
|
if (!obj)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
obj->Immutable = true;
|
obj->Immutable = true;
|
||||||
|
|
||||||
if (!ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER, size, NULL,
|
if (!st_bufferobj_data(ctx, GL_ARRAY_BUFFER, size, NULL,
|
||||||
GL_WRITE_ONLY,
|
GL_WRITE_ONLY,
|
||||||
GL_CLIENT_STORAGE_BIT | GL_MAP_WRITE_BIT,
|
GL_CLIENT_STORAGE_BIT | GL_MAP_WRITE_BIT,
|
||||||
obj)) {
|
obj)) {
|
||||||
ctx->Driver.DeleteBuffer(ctx, obj);
|
st_bufferobj_free(ctx, obj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
*ptr = ctx->Driver.MapBufferRange(ctx, 0, size,
|
*ptr = st_bufferobj_map_range(ctx, 0, size,
|
||||||
GL_MAP_WRITE_BIT |
|
GL_MAP_WRITE_BIT |
|
||||||
GL_MAP_UNSYNCHRONIZED_BIT |
|
GL_MAP_UNSYNCHRONIZED_BIT |
|
||||||
MESA_MAP_THREAD_SAFE_BIT,
|
MESA_MAP_THREAD_SAFE_BIT,
|
||||||
obj, MAP_GLTHREAD);
|
obj, MAP_GLTHREAD);
|
||||||
if (!*ptr) {
|
if (!*ptr) {
|
||||||
ctx->Driver.DeleteBuffer(ctx, obj);
|
st_bufferobj_free(ctx, obj);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -40,6 +40,7 @@
|
||||||
#include "macros.h"
|
#include "macros.h"
|
||||||
#include "pbo.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) {
|
if (unpack->BufferObj) {
|
||||||
/* unpack from PBO */
|
/* unpack from PBO */
|
||||||
buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
|
buf = (GLubyte *) st_bufferobj_map_range(ctx, 0,
|
||||||
unpack->BufferObj->Size,
|
unpack->BufferObj->Size,
|
||||||
GL_MAP_READ_BIT,
|
GL_MAP_READ_BIT,
|
||||||
unpack->BufferObj,
|
unpack->BufferObj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -285,7 +286,7 @@ _mesa_unmap_pbo_source(struct gl_context *ctx,
|
||||||
{
|
{
|
||||||
assert(unpack != &ctx->Pack); /* catch pack/unpack mismatch */
|
assert(unpack != &ctx->Pack); /* catch pack/unpack mismatch */
|
||||||
if (unpack->BufferObj) {
|
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) {
|
if (pack->BufferObj) {
|
||||||
/* pack into PBO */
|
/* pack into PBO */
|
||||||
buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
|
buf = (GLubyte *) st_bufferobj_map_range(ctx, 0,
|
||||||
pack->BufferObj->Size,
|
pack->BufferObj->Size,
|
||||||
GL_MAP_WRITE_BIT,
|
GL_MAP_WRITE_BIT,
|
||||||
pack->BufferObj,
|
pack->BufferObj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
|
|
@ -382,7 +383,7 @@ _mesa_unmap_pbo_dest(struct gl_context *ctx,
|
||||||
{
|
{
|
||||||
assert(pack != &ctx->Unpack); /* catch pack/unpack mismatch */
|
assert(pack != &ctx->Unpack); /* catch pack/unpack mismatch */
|
||||||
if (pack->BufferObj) {
|
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;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = (GLubyte *) ctx->Driver.MapBufferRange(ctx, 0,
|
buf = (GLubyte *) st_bufferobj_map_range(ctx, 0,
|
||||||
unpack->BufferObj->Size,
|
unpack->BufferObj->Size,
|
||||||
GL_MAP_READ_BIT,
|
GL_MAP_READ_BIT,
|
||||||
unpack->BufferObj,
|
unpack->BufferObj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
_mesa_error(ctx, GL_INVALID_OPERATION, "%s%uD(PBO is mapped)", funcName,
|
_mesa_error(ctx, GL_INVALID_OPERATION, "%s%uD(PBO is mapped)", funcName,
|
||||||
dimensions);
|
dimensions);
|
||||||
|
|
@ -455,11 +456,11 @@ _mesa_validate_pbo_compressed_teximage(struct gl_context *ctx,
|
||||||
return pixels;
|
return pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
buf = (GLubyte*) ctx->Driver.MapBufferRange(ctx, 0,
|
buf = (GLubyte*) st_bufferobj_map_range(ctx, 0,
|
||||||
packing->BufferObj->Size,
|
packing->BufferObj->Size,
|
||||||
GL_MAP_READ_BIT,
|
GL_MAP_READ_BIT,
|
||||||
packing->BufferObj,
|
packing->BufferObj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
|
|
||||||
/* Validation above already checked that PBO is not mapped, so buffer
|
/* Validation above already checked that PBO is not mapped, so buffer
|
||||||
* should not be null.
|
* should not be null.
|
||||||
|
|
@ -479,6 +480,6 @@ _mesa_unmap_teximage_pbo(struct gl_context *ctx,
|
||||||
const struct gl_pixelstore_attrib *unpack)
|
const struct gl_pixelstore_attrib *unpack)
|
||||||
{
|
{
|
||||||
if (unpack->BufferObj) {
|
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 "pixeltransfer.h"
|
||||||
|
|
||||||
#include "state_tracker/st_cb_texture.h"
|
#include "state_tracker/st_cb_texture.h"
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Can the given type represent negative values?
|
* 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.
|
* texture data to the PBO if the PBO is in VRAM along with the texture.
|
||||||
*/
|
*/
|
||||||
GLubyte *buf = (GLubyte *)
|
GLubyte *buf = (GLubyte *)
|
||||||
ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size,
|
st_bufferobj_map_range(ctx, 0, ctx->Pack.BufferObj->Size,
|
||||||
GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
|
GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
if (!buf) {
|
if (!buf) {
|
||||||
/* out of memory or other unexpected error */
|
/* out of memory or other unexpected error */
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexImage(map PBO failed)");
|
_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) {
|
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) {
|
if (ctx->Pack.BufferObj) {
|
||||||
/* pack texture image into a PBO */
|
/* pack texture image into a PBO */
|
||||||
dest = (GLubyte *)
|
dest = (GLubyte *)
|
||||||
ctx->Driver.MapBufferRange(ctx, 0, ctx->Pack.BufferObj->Size,
|
st_bufferobj_map_range(ctx, 0, ctx->Pack.BufferObj->Size,
|
||||||
GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
|
GL_MAP_WRITE_BIT, ctx->Pack.BufferObj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
if (!dest) {
|
if (!dest) {
|
||||||
/* out of memory or other unexpected error */
|
/* out of memory or other unexpected error */
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY,
|
_mesa_error(ctx, GL_OUT_OF_MEMORY,
|
||||||
|
|
@ -836,7 +837,7 @@ get_compressed_texsubimage_sw(struct gl_context *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ctx->Pack.BufferObj) {
|
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
|
* lookup an opaque structure. It would be nice if the handles and
|
||||||
* internal structure where somehow shared.
|
* internal structure where somehow shared.
|
||||||
*/
|
*/
|
||||||
static struct gl_buffer_object *
|
struct gl_buffer_object *
|
||||||
st_bufferobj_alloc(struct gl_context *ctx, GLuint name)
|
st_bufferobj_alloc(struct gl_context *ctx, GLuint name)
|
||||||
{
|
{
|
||||||
struct st_buffer_object *st_obj = ST_CALLOC_STRUCT(st_buffer_object);
|
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.
|
* Deallocate/free a vertex/pixel buffer object.
|
||||||
* Called via glDeleteBuffersARB().
|
* Called via glDeleteBuffersARB().
|
||||||
*/
|
*/
|
||||||
static void
|
void st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj)
|
||||||
st_bufferobj_free(struct gl_context *ctx, struct gl_buffer_object *obj)
|
|
||||||
{
|
{
|
||||||
assert(obj->RefCount == 0);
|
assert(obj->RefCount == 0);
|
||||||
_mesa_buffer_unmap_all_mappings(ctx, obj);
|
_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.
|
* if data is NULL, no copy is performed.
|
||||||
* Called via glBufferSubDataARB().
|
* Called via glBufferSubDataARB().
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
st_bufferobj_subdata(struct gl_context *ctx,
|
st_bufferobj_subdata(struct gl_context *ctx,
|
||||||
GLintptrARB offset,
|
GLintptrARB offset,
|
||||||
GLsizeiptrARB size,
|
GLsizeiptrARB size,
|
||||||
|
|
@ -164,7 +163,7 @@ st_bufferobj_subdata(struct gl_context *ctx,
|
||||||
/**
|
/**
|
||||||
* Called via glGetBufferSubDataARB().
|
* Called via glGetBufferSubDataARB().
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
st_bufferobj_get_subdata(struct gl_context *ctx,
|
st_bufferobj_get_subdata(struct gl_context *ctx,
|
||||||
GLintptrARB offset,
|
GLintptrARB offset,
|
||||||
GLsizeiptrARB size,
|
GLsizeiptrARB size,
|
||||||
|
|
@ -427,7 +426,7 @@ bufferobj_data(struct gl_context *ctx,
|
||||||
* Called via ctx->Driver.BufferData().
|
* Called via ctx->Driver.BufferData().
|
||||||
* \return GL_TRUE for success, GL_FALSE if out of memory
|
* \return GL_TRUE for success, GL_FALSE if out of memory
|
||||||
*/
|
*/
|
||||||
static GLboolean
|
GLboolean
|
||||||
st_bufferobj_data(struct gl_context *ctx,
|
st_bufferobj_data(struct gl_context *ctx,
|
||||||
GLenum target,
|
GLenum target,
|
||||||
GLsizeiptrARB size,
|
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);
|
return bufferobj_data(ctx, target, size, data, NULL, 0, usage, storageFlags, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GLboolean
|
GLboolean
|
||||||
st_bufferobj_data_mem(struct gl_context *ctx,
|
st_bufferobj_data_mem(struct gl_context *ctx,
|
||||||
GLenum target,
|
GLenum target,
|
||||||
GLsizeiptrARB size,
|
GLsizeiptrARB size,
|
||||||
|
|
@ -530,7 +529,7 @@ st_access_flags_to_transfer_flags(GLbitfield access, bool wholeBuffer)
|
||||||
/**
|
/**
|
||||||
* Called via glMapBufferRange().
|
* Called via glMapBufferRange().
|
||||||
*/
|
*/
|
||||||
static void *
|
void *
|
||||||
st_bufferobj_map_range(struct gl_context *ctx,
|
st_bufferobj_map_range(struct gl_context *ctx,
|
||||||
GLintptr offset, GLsizeiptr length, GLbitfield access,
|
GLintptr offset, GLsizeiptr length, GLbitfield access,
|
||||||
struct gl_buffer_object *obj,
|
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,
|
st_bufferobj_flush_mapped_range(struct gl_context *ctx,
|
||||||
GLintptr offset, GLsizeiptr length,
|
GLintptr offset, GLsizeiptr length,
|
||||||
struct gl_buffer_object *obj,
|
struct gl_buffer_object *obj,
|
||||||
|
|
@ -603,7 +602,7 @@ st_bufferobj_flush_mapped_range(struct gl_context *ctx,
|
||||||
/**
|
/**
|
||||||
* Called via glUnmapBufferARB().
|
* Called via glUnmapBufferARB().
|
||||||
*/
|
*/
|
||||||
static GLboolean
|
GLboolean
|
||||||
st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
|
st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
|
||||||
gl_map_buffer_index index)
|
gl_map_buffer_index index)
|
||||||
{
|
{
|
||||||
|
|
@ -624,7 +623,7 @@ st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj,
|
||||||
/**
|
/**
|
||||||
* Called via glCopyBufferSubData().
|
* Called via glCopyBufferSubData().
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
st_copy_buffer_subdata(struct gl_context *ctx,
|
st_copy_buffer_subdata(struct gl_context *ctx,
|
||||||
struct gl_buffer_object *src,
|
struct gl_buffer_object *src,
|
||||||
struct gl_buffer_object *dst,
|
struct gl_buffer_object *dst,
|
||||||
|
|
@ -652,7 +651,7 @@ st_copy_buffer_subdata(struct gl_context *ctx,
|
||||||
/**
|
/**
|
||||||
* Called via glClearBufferSubData().
|
* Called via glClearBufferSubData().
|
||||||
*/
|
*/
|
||||||
static void
|
void
|
||||||
st_clear_buffer_subdata(struct gl_context *ctx,
|
st_clear_buffer_subdata(struct gl_context *ctx,
|
||||||
GLintptr offset, GLsizeiptr size,
|
GLintptr offset, GLsizeiptr size,
|
||||||
const void *clearValue,
|
const void *clearValue,
|
||||||
|
|
@ -676,7 +675,7 @@ st_clear_buffer_subdata(struct gl_context *ctx,
|
||||||
clearValue, clearValueSize);
|
clearValue, clearValueSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
st_bufferobj_page_commitment(struct gl_context *ctx,
|
st_bufferobj_page_commitment(struct gl_context *ctx,
|
||||||
struct gl_buffer_object *bufferObj,
|
struct gl_buffer_object *bufferObj,
|
||||||
GLintptr offset, GLsizeiptr size,
|
GLintptr offset, GLsizeiptr size,
|
||||||
|
|
@ -698,19 +697,6 @@ void
|
||||||
st_init_bufferobject_functions(struct pipe_screen *screen,
|
st_init_bufferobject_functions(struct pipe_screen *screen,
|
||||||
struct dd_function_table *functions)
|
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))
|
if (screen->get_param(screen, PIPE_CAP_INVALIDATE_BUFFER))
|
||||||
functions->InvalidateBufferSubData = st_bufferobj_invalidate;
|
functions->InvalidateBufferSubData = st_bufferobj_invalidate;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -115,4 +115,55 @@ st_get_buffer_reference(struct gl_context *ctx, struct gl_buffer_object *obj)
|
||||||
return buffer;
|
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
|
#endif
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
#include "vbo_noop.h"
|
#include "vbo_noop.h"
|
||||||
#include "vbo_private.h"
|
#include "vbo_private.h"
|
||||||
|
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
/** ID/name for immediate-mode VBO */
|
/** ID/name for immediate-mode VBO */
|
||||||
#define IMM_BUFFER_NAME 0xaabbccdd
|
#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);
|
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);
|
vbo_exec_vtxfmt_init(exec);
|
||||||
_mesa_noop_vtxfmt_init(ctx, &exec->vtxfmt_noop);
|
_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 &&
|
if (exec->vtx.bufferobj &&
|
||||||
_mesa_bufferobj_mapped(exec->vtx.bufferobj, MAP_INTERNAL)) {
|
_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);
|
_mesa_reference_buffer_object(ctx, &exec->vtx.bufferobj, NULL);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,6 +39,7 @@
|
||||||
#include "vbo_noop.h"
|
#include "vbo_noop.h"
|
||||||
#include "vbo_private.h"
|
#include "vbo_private.h"
|
||||||
|
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
vbo_exec_debug_verts(struct vbo_exec_context *exec)
|
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) {
|
if (exec->vtx.bufferobj) {
|
||||||
struct gl_context *ctx = gl_context_from_vbo_exec(exec);
|
struct gl_context *ctx = gl_context_from_vbo_exec(exec);
|
||||||
|
|
||||||
if (ctx->Driver.FlushMappedBufferRange &&
|
if (!ctx->Extensions.ARB_buffer_storage) {
|
||||||
!ctx->Extensions.ARB_buffer_storage) {
|
|
||||||
GLintptr offset = exec->vtx.buffer_used -
|
GLintptr offset = exec->vtx.buffer_used -
|
||||||
exec->vtx.bufferobj->Mappings[MAP_INTERNAL].Offset;
|
exec->vtx.bufferobj->Mappings[MAP_INTERNAL].Offset;
|
||||||
GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) *
|
GLsizeiptr length = (exec->vtx.buffer_ptr - exec->vtx.buffer_map) *
|
||||||
sizeof(float);
|
sizeof(float);
|
||||||
|
|
||||||
if (length)
|
if (length)
|
||||||
ctx->Driver.FlushMappedBufferRange(ctx, offset, length,
|
st_bufferobj_flush_mapped_range(ctx, offset, length,
|
||||||
exec->vtx.bufferobj,
|
exec->vtx.bufferobj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
exec->vtx.buffer_used += (exec->vtx.buffer_ptr -
|
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_used <= ctx->Const.glBeginEndBufferSize);
|
||||||
assert(exec->vtx.buffer_ptr != NULL);
|
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_map = NULL;
|
||||||
exec->vtx.buffer_ptr = NULL;
|
exec->vtx.buffer_ptr = NULL;
|
||||||
exec->vtx.max_vert = 0;
|
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 */
|
/* The VBO exists and there's room for more */
|
||||||
if (exec->vtx.bufferobj->Size > 0) {
|
if (exec->vtx.bufferobj->Size > 0) {
|
||||||
exec->vtx.buffer_map = (fi_type *)
|
exec->vtx.buffer_map = (fi_type *)
|
||||||
ctx->Driver.MapBufferRange(ctx,
|
st_bufferobj_map_range(ctx,
|
||||||
exec->vtx.buffer_used,
|
exec->vtx.buffer_used,
|
||||||
ctx->Const.glBeginEndBufferSize
|
ctx->Const.glBeginEndBufferSize
|
||||||
- exec->vtx.buffer_used,
|
- exec->vtx.buffer_used,
|
||||||
accessRange,
|
accessRange,
|
||||||
exec->vtx.bufferobj,
|
exec->vtx.bufferobj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
|
exec->vtx.buffer_ptr = exec->vtx.buffer_map;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -245,24 +245,24 @@ vbo_exec_vtx_map(struct vbo_exec_context *exec)
|
||||||
/* Need to allocate a new VBO */
|
/* Need to allocate a new VBO */
|
||||||
exec->vtx.buffer_used = 0;
|
exec->vtx.buffer_used = 0;
|
||||||
|
|
||||||
if (ctx->Driver.BufferData(ctx, GL_ARRAY_BUFFER_ARB,
|
if (st_bufferobj_data(ctx, GL_ARRAY_BUFFER_ARB,
|
||||||
ctx->Const.glBeginEndBufferSize,
|
ctx->Const.glBeginEndBufferSize,
|
||||||
NULL, usage,
|
NULL, usage,
|
||||||
GL_MAP_WRITE_BIT |
|
GL_MAP_WRITE_BIT |
|
||||||
(ctx->Extensions.ARB_buffer_storage ?
|
(ctx->Extensions.ARB_buffer_storage ?
|
||||||
GL_MAP_PERSISTENT_BIT |
|
GL_MAP_PERSISTENT_BIT |
|
||||||
GL_MAP_COHERENT_BIT |
|
GL_MAP_COHERENT_BIT |
|
||||||
GL_MAP_READ_BIT : 0) |
|
GL_MAP_READ_BIT : 0) |
|
||||||
GL_DYNAMIC_STORAGE_BIT |
|
GL_DYNAMIC_STORAGE_BIT |
|
||||||
GL_CLIENT_STORAGE_BIT,
|
GL_CLIENT_STORAGE_BIT,
|
||||||
exec->vtx.bufferobj)) {
|
exec->vtx.bufferobj)) {
|
||||||
/* buffer allocation worked, now map the buffer */
|
/* buffer allocation worked, now map the buffer */
|
||||||
exec->vtx.buffer_map =
|
exec->vtx.buffer_map =
|
||||||
(fi_type *)ctx->Driver.MapBufferRange(ctx,
|
(fi_type *)st_bufferobj_map_range(ctx,
|
||||||
0, ctx->Const.glBeginEndBufferSize,
|
0, ctx->Const.glBeginEndBufferSize,
|
||||||
accessRange,
|
accessRange,
|
||||||
exec->vtx.bufferobj,
|
exec->vtx.bufferobj,
|
||||||
MAP_INTERNAL);
|
MAP_INTERNAL);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "VBO allocation");
|
_mesa_error(ctx, GL_OUT_OF_MEMORY, "VBO allocation");
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@
|
||||||
#include "util/u_memory.h"
|
#include "util/u_memory.h"
|
||||||
#include "pipe/p_state.h"
|
#include "pipe/p_state.h"
|
||||||
|
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
struct minmax_cache_key {
|
struct minmax_cache_key {
|
||||||
GLintptr offset;
|
GLintptr offset;
|
||||||
|
|
@ -338,8 +339,8 @@ vbo_get_minmax_index(struct gl_context *ctx, struct gl_buffer_object *obj,
|
||||||
max_index))
|
max_index))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
indices = ctx->Driver.MapBufferRange(ctx, offset, size, GL_MAP_READ_BIT,
|
indices = st_bufferobj_map_range(ctx, offset, size, GL_MAP_READ_BIT,
|
||||||
obj, MAP_INTERNAL);
|
obj, MAP_INTERNAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
vbo_get_minmax_index_mapped(count, index_size, restart_index,
|
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) {
|
if (obj) {
|
||||||
vbo_minmax_cache_store(ctx, obj, index_size, offset, count, *min_index,
|
vbo_minmax_cache_store(ctx, obj, index_size, offset, count, *min_index,
|
||||||
*max_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_noop.h"
|
||||||
#include "vbo_private.h"
|
#include "vbo_private.h"
|
||||||
|
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
#ifdef ERROR
|
#ifdef ERROR
|
||||||
#undef ERROR
|
#undef ERROR
|
||||||
|
|
@ -776,14 +777,14 @@ compile_vertex_list(struct gl_context *ctx)
|
||||||
if (total_bytes_needed > available_bytes) {
|
if (total_bytes_needed > available_bytes) {
|
||||||
if (save->current_bo)
|
if (save->current_bo)
|
||||||
_mesa_reference_buffer_object(ctx, &save->current_bo, NULL);
|
_mesa_reference_buffer_object(ctx, &save->current_bo, NULL);
|
||||||
save->current_bo = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID + 1);
|
save->current_bo = st_bufferobj_alloc(ctx, VBO_BUF_ID + 1);
|
||||||
bool success = ctx->Driver.BufferData(ctx,
|
bool success = st_bufferobj_data(ctx,
|
||||||
GL_ELEMENT_ARRAY_BUFFER_ARB,
|
GL_ELEMENT_ARRAY_BUFFER_ARB,
|
||||||
MAX2(total_bytes_needed, VBO_SAVE_BUFFER_SIZE),
|
MAX2(total_bytes_needed, VBO_SAVE_BUFFER_SIZE),
|
||||||
NULL,
|
NULL,
|
||||||
GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
|
GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
|
||||||
MESA_GALLIUM_VERTEX_STATE_STORAGE,
|
MESA_GALLIUM_VERTEX_STATE_STORAGE,
|
||||||
save->current_bo);
|
save->current_bo);
|
||||||
if (!success) {
|
if (!success) {
|
||||||
_mesa_reference_buffer_object(ctx, &save->current_bo, NULL);
|
_mesa_reference_buffer_object(ctx, &save->current_bo, NULL);
|
||||||
_mesa_error(ctx, GL_OUT_OF_MEMORY, "IB allocation");
|
_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);
|
_mesa_reference_buffer_object(ctx, &node->cold->ib.obj, save->current_bo);
|
||||||
|
|
||||||
/* Upload the vertices first (see buffer_offset) */
|
/* Upload the vertices first (see buffer_offset) */
|
||||||
ctx->Driver.BufferSubData(ctx,
|
st_bufferobj_subdata(ctx,
|
||||||
save->current_bo_bytes_used,
|
save->current_bo_bytes_used,
|
||||||
total_vert_count * save->vertex_size * sizeof(fi_type),
|
total_vert_count * save->vertex_size * sizeof(fi_type),
|
||||||
vertex_to_index ? temp_vertices_buffer : save->vertex_store->buffer_in_ram,
|
vertex_to_index ? temp_vertices_buffer : save->vertex_store->buffer_in_ram,
|
||||||
node->cold->ib.obj);
|
node->cold->ib.obj);
|
||||||
save->current_bo_bytes_used += total_vert_count * save->vertex_size * sizeof(fi_type);
|
save->current_bo_bytes_used += total_vert_count * save->vertex_size * sizeof(fi_type);
|
||||||
|
|
||||||
if (vertex_to_index) {
|
if (vertex_to_index) {
|
||||||
|
|
@ -854,11 +855,11 @@ compile_vertex_list(struct gl_context *ctx)
|
||||||
|
|
||||||
/* Then upload the indices. */
|
/* Then upload the indices. */
|
||||||
if (node->cold->ib.obj) {
|
if (node->cold->ib.obj) {
|
||||||
ctx->Driver.BufferSubData(ctx,
|
st_bufferobj_subdata(ctx,
|
||||||
save->current_bo_bytes_used,
|
save->current_bo_bytes_used,
|
||||||
idx * sizeof(uint32_t),
|
idx * sizeof(uint32_t),
|
||||||
indices,
|
indices,
|
||||||
node->cold->ib.obj);
|
node->cold->ib.obj);
|
||||||
save->current_bo_bytes_used += idx * sizeof(uint32_t);
|
save->current_bo_bytes_used += idx * sizeof(uint32_t);
|
||||||
} else {
|
} else {
|
||||||
node->cold->vertex_count = 0;
|
node->cold->vertex_count = 0;
|
||||||
|
|
@ -909,14 +910,14 @@ end:
|
||||||
node->draw_begins = node->cold->prims[0].begin;
|
node->draw_begins = node->cold->prims[0].begin;
|
||||||
|
|
||||||
if (!save->current_bo) {
|
if (!save->current_bo) {
|
||||||
save->current_bo = ctx->Driver.NewBufferObject(ctx, VBO_BUF_ID + 1);
|
save->current_bo = st_bufferobj_alloc(ctx, VBO_BUF_ID + 1);
|
||||||
bool success = ctx->Driver.BufferData(ctx,
|
bool success = st_bufferobj_data(ctx,
|
||||||
GL_ELEMENT_ARRAY_BUFFER_ARB,
|
GL_ELEMENT_ARRAY_BUFFER_ARB,
|
||||||
VBO_SAVE_BUFFER_SIZE,
|
VBO_SAVE_BUFFER_SIZE,
|
||||||
NULL,
|
NULL,
|
||||||
GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
|
GL_STATIC_DRAW_ARB, GL_MAP_WRITE_BIT |
|
||||||
MESA_GALLIUM_VERTEX_STATE_STORAGE,
|
MESA_GALLIUM_VERTEX_STATE_STORAGE,
|
||||||
save->current_bo);
|
save->current_bo);
|
||||||
if (!success)
|
if (!success)
|
||||||
handle_out_of_memory(ctx);
|
handle_out_of_memory(ctx);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -41,6 +41,7 @@
|
||||||
|
|
||||||
#include "vbo_private.h"
|
#include "vbo_private.h"
|
||||||
|
|
||||||
|
#include "state_tracker/st_cb_bufferobjects.h"
|
||||||
|
|
||||||
static void
|
static void
|
||||||
copy_vao(struct gl_context *ctx, const struct gl_vertex_array_object *vao,
|
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)
|
const struct vbo_save_vertex_list *list)
|
||||||
{
|
{
|
||||||
struct gl_buffer_object *bo = list->cold->VAO[0]->BufferBinding[0].BufferObj;
|
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, /* ? */
|
void *buffer = st_bufferobj_map_range(ctx, 0, bo->Size, GL_MAP_READ_BIT, /* ? */
|
||||||
bo, MAP_INTERNAL);
|
bo, MAP_INTERNAL);
|
||||||
|
|
||||||
/* TODO: in this case, we shouldn't create a bo at all and instead keep
|
/* TODO: in this case, we shouldn't create a bo at all and instead keep
|
||||||
* the in-RAM buffer. */
|
* the in-RAM buffer. */
|
||||||
_vbo_loopback_vertex_list(ctx, list, 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