mesa/st: drop some bindless wrappers

Just call directly into pipe

Reviewed-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14632>
This commit is contained in:
Dave Airlie 2021-12-21 13:51:50 +10:00 committed by Marge Bot
parent 8467047f6d
commit 78d13fdbb2
3 changed files with 39 additions and 97 deletions

View File

@ -36,7 +36,10 @@
#include "util/u_memory.h"
#include "api_exec_decl.h"
#include "state_tracker/st_context.h"
#include "state_tracker/st_cb_texture.h"
#include "state_tracker/st_texture.h"
#include "state_tracker/st_sampler_view.h"
/**
* Return the gl_texture_handle_object for a given 64-bit handle.
@ -80,7 +83,7 @@ delete_texture_handle(struct gl_context *ctx, GLuint64 id)
_mesa_hash_table_u64_remove(ctx->Shared->TextureHandles, id);
mtx_unlock(&ctx->Shared->HandlesMutex);
st_DeleteTextureHandle(ctx, id);
ctx->pipe->delete_texture_handle(ctx->pipe, id);
}
/**
@ -93,7 +96,7 @@ delete_image_handle(struct gl_context *ctx, GLuint64 id)
_mesa_hash_table_u64_remove(ctx->Shared->ImageHandles, id);
mtx_unlock(&ctx->Shared->HandlesMutex);
st_DeleteImageHandle(ctx, id);
ctx->pipe->delete_image_handle(ctx->pipe, id);
}
/**
@ -134,7 +137,7 @@ make_texture_handle_resident(struct gl_context *ctx,
_mesa_hash_table_u64_insert(ctx->ResidentTextureHandles, handle,
texHandleObj);
st_MakeTextureHandleResident(ctx, handle, GL_TRUE);
ctx->pipe->make_texture_handle_resident(ctx->pipe, handle, GL_TRUE);
/* Reference the texture object (and the separate sampler if needed) to
* be sure it won't be deleted until it is not bound anywhere and there
@ -148,7 +151,7 @@ make_texture_handle_resident(struct gl_context *ctx,
_mesa_hash_table_u64_remove(ctx->ResidentTextureHandles, handle);
st_MakeTextureHandleResident(ctx, handle, GL_FALSE);
ctx->pipe->make_texture_handle_resident(ctx->pipe, handle, GL_FALSE);
/* Unreference the texture object but keep the pointer intact, if
* refcount hits zero, the texture and all handles will be deleted.
@ -183,7 +186,7 @@ make_image_handle_resident(struct gl_context *ctx,
_mesa_hash_table_u64_insert(ctx->ResidentImageHandles, handle,
imgHandleObj);
st_MakeImageHandleResident(ctx, handle, access, GL_TRUE);
ctx->pipe->make_image_handle_resident(ctx->pipe, handle, access, GL_TRUE);
/* Reference the texture object to be sure it won't be deleted until it
* is not bound anywhere and there are no handles using the object that
@ -195,7 +198,7 @@ make_image_handle_resident(struct gl_context *ctx,
_mesa_hash_table_u64_remove(ctx->ResidentImageHandles, handle);
st_MakeImageHandleResident(ctx, handle, access, GL_FALSE);
ctx->pipe->make_image_handle_resident(ctx->pipe, handle, access, GL_FALSE);
/* Unreference the texture object but keep the pointer intact, if
* refcount hits zero, the texture and all handles will be deleted.
@ -217,6 +220,31 @@ find_texhandleobj(struct gl_texture_object *texObj,
return NULL;
}
static GLuint64
new_texture_handle(struct gl_context *ctx, struct gl_texture_object *texObj,
struct gl_sampler_object *sampObj)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = ctx->pipe;
struct pipe_sampler_view *view;
struct pipe_sampler_state sampler = {0};
if (texObj->Target != GL_TEXTURE_BUFFER) {
if (!st_finalize_texture(ctx, pipe, texObj, 0))
return 0;
st_convert_sampler(st, texObj, sampObj, 0, &sampler, false);
/* TODO: Clarify the interaction of ARB_bindless_texture and EXT_texture_sRGB_decode */
view = st_get_texture_sampler_view_from_stobj(st, texObj, sampObj, 0,
true, false);
} else {
view = st_get_buffer_sampler_view_from_stobj(st, texObj, false);
}
return pipe->create_texture_handle(pipe, view, &sampler);
}
static GLuint64
get_texture_handle(struct gl_context *ctx, struct gl_texture_object *texObj,
struct gl_sampler_object *sampObj)
@ -240,7 +268,7 @@ get_texture_handle(struct gl_context *ctx, struct gl_texture_object *texObj,
}
/* Request a new texture handle from the driver. */
handle = st_NewTextureHandle(ctx, texObj, sampObj);
handle = new_texture_handle(ctx, texObj, sampObj);
if (!handle) {
mtx_unlock(&ctx->Shared->HandlesMutex);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetTexture*HandleARB()");
@ -335,7 +363,9 @@ get_image_handle(struct gl_context *ctx, struct gl_texture_object *texObj,
}
/* Request a new image handle from the driver. */
handle = st_NewImageHandle(ctx, &imgObj);
struct pipe_image_view image;
st_convert_image(st_context(ctx), &imgObj, &image, GL_READ_WRITE);
handle = ctx->pipe->create_image_handle(ctx->pipe, &image);
if (!handle) {
mtx_unlock(&ctx->Shared->HandlesMutex);
_mesa_error(ctx, GL_OUT_OF_MEMORY, "glGetImageHandleARB()");

View File

@ -3514,86 +3514,6 @@ st_SetTextureStorageForMemoryObject(struct gl_context *ctx,
memObj, offset);
}
GLuint64
st_NewTextureHandle(struct gl_context *ctx, struct gl_texture_object *texObj,
struct gl_sampler_object *sampObj)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
struct pipe_sampler_view *view;
struct pipe_sampler_state sampler = {0};
if (texObj->Target != GL_TEXTURE_BUFFER) {
if (!st_finalize_texture(ctx, pipe, texObj, 0))
return 0;
st_convert_sampler(st, texObj, sampObj, 0, &sampler, false);
/* TODO: Clarify the interaction of ARB_bindless_texture and EXT_texture_sRGB_decode */
view = st_get_texture_sampler_view_from_stobj(st, texObj, sampObj, 0,
true, false);
} else {
view = st_get_buffer_sampler_view_from_stobj(st, texObj, false);
}
return pipe->create_texture_handle(pipe, view, &sampler);
}
void
st_DeleteTextureHandle(struct gl_context *ctx, GLuint64 handle)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
pipe->delete_texture_handle(pipe, handle);
}
void
st_MakeTextureHandleResident(struct gl_context *ctx, GLuint64 handle,
bool resident)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
pipe->make_texture_handle_resident(pipe, handle, resident);
}
GLuint64
st_NewImageHandle(struct gl_context *ctx, struct gl_image_unit *imgObj)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
struct pipe_image_view image;
st_convert_image(st, imgObj, &image, GL_READ_WRITE);
return pipe->create_image_handle(pipe, &image);
}
void
st_DeleteImageHandle(struct gl_context *ctx, GLuint64 handle)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
pipe->delete_image_handle(pipe, handle);
}
void
st_MakeImageHandleResident(struct gl_context *ctx, GLuint64 handle,
GLenum access, bool resident)
{
struct st_context *st = st_context(ctx);
struct pipe_context *pipe = st->pipe;
pipe->make_image_handle_resident(pipe, handle, access, resident);
}
GLboolean
st_GetSparseTextureVirtualPageSize(struct gl_context *ctx,
GLenum target, mesa_format format,

View File

@ -117,15 +117,7 @@ GLboolean st_SetTextureStorageForMemoryObject(struct gl_context *ctx,
GLsizei levels, GLsizei width,
GLsizei height, GLsizei depth,
GLuint64 offset);
GLuint64 st_NewTextureHandle(struct gl_context *ctx, struct gl_texture_object *texObj,
struct gl_sampler_object *sampObj);
void st_DeleteTextureHandle(struct gl_context *ctx, GLuint64 handle);
void st_MakeTextureHandleResident(struct gl_context *ctx, GLuint64 handle,
bool resident);
GLuint64 st_NewImageHandle(struct gl_context *ctx, struct gl_image_unit *imgObj);
void st_DeleteImageHandle(struct gl_context *ctx, GLuint64 handle);
void st_MakeImageHandleResident(struct gl_context *ctx, GLuint64 handle,
GLenum access, bool resident);
GLboolean st_GetSparseTextureVirtualPageSize(struct gl_context *ctx,
GLenum target, mesa_format format,
unsigned index, int *x, int *y, int *z);