mesa/bufferobj: move invalidate buffer to optional feature
Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14133>
This commit is contained in:
@@ -5179,13 +5179,35 @@ _mesa_BindBuffersBase(GLenum target, GLuint first, GLsizei count,
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Called via glInvalidateBuffer(Sub)Data.
|
||||
*/
|
||||
static void
|
||||
bufferobj_invalidate(struct gl_context *ctx,
|
||||
struct gl_buffer_object *obj,
|
||||
GLintptr offset,
|
||||
GLsizeiptr size)
|
||||
{
|
||||
struct pipe_context *pipe = ctx->pipe;
|
||||
|
||||
/* We ignore partial invalidates. */
|
||||
if (offset != 0 || size != obj->Size)
|
||||
return;
|
||||
|
||||
/* If the buffer is mapped, we can't invalidate it. */
|
||||
if (!obj->buffer || _mesa_bufferobj_mapped(obj, MAP_USER))
|
||||
return;
|
||||
|
||||
pipe->invalidate_resource(pipe, obj->buffer);
|
||||
}
|
||||
|
||||
static ALWAYS_INLINE void
|
||||
invalidate_buffer_subdata(struct gl_context *ctx,
|
||||
struct gl_buffer_object *bufObj, GLintptr offset,
|
||||
GLsizeiptr length)
|
||||
{
|
||||
if (ctx->Driver.InvalidateBufferSubData)
|
||||
ctx->Driver.InvalidateBufferSubData(ctx, bufObj, offset, length);
|
||||
if (ctx->has_invalidate_buffer)
|
||||
bufferobj_invalidate(ctx, bufObj, offset, length);
|
||||
}
|
||||
|
||||
void GLAPIENTRY
|
||||
|
||||
@@ -5577,6 +5577,7 @@ struct gl_context
|
||||
struct pipe_context *pipe;
|
||||
struct st_config_options *st_opts;
|
||||
struct cso_context *cso_context;
|
||||
bool has_invalidate_buffer;
|
||||
/*@}*/
|
||||
|
||||
/**
|
||||
|
||||
@@ -995,6 +995,9 @@ st_create_context(gl_api api, struct pipe_context *pipe,
|
||||
if (debug_get_option_mesa_mvp_dp4())
|
||||
ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS = GL_TRUE;
|
||||
|
||||
if (pipe->screen->get_param(pipe->screen, PIPE_CAP_INVALIDATE_BUFFER))
|
||||
ctx->has_invalidate_buffer = true;
|
||||
|
||||
st = st_create_context_priv(ctx, pipe, options, no_error);
|
||||
if (!st) {
|
||||
_mesa_free_context_data(ctx, true);
|
||||
|
||||
Reference in New Issue
Block a user