mesa/st: Track complete access qualifier for images
Don't turn gl_access_qualifier coming from NIR back into GL enums, losing information in the process. Signed-off-by: Rob Clark <robdclark@chromium.org> Reviewed-by: Marek Olšák <marek.olsak@amd.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20612>
This commit is contained in:
@@ -830,12 +830,6 @@ update_uniforms_shader_info(struct gl_shader_program *prog,
|
|||||||
/* Set image access qualifiers */
|
/* Set image access qualifiers */
|
||||||
enum gl_access_qualifier image_access =
|
enum gl_access_qualifier image_access =
|
||||||
state->current_var->data.access;
|
state->current_var->data.access;
|
||||||
const GLenum access =
|
|
||||||
(image_access & ACCESS_NON_WRITEABLE) ?
|
|
||||||
((image_access & ACCESS_NON_READABLE) ? GL_NONE :
|
|
||||||
GL_READ_ONLY) :
|
|
||||||
((image_access & ACCESS_NON_READABLE) ? GL_WRITE_ONLY :
|
|
||||||
GL_READ_WRITE);
|
|
||||||
|
|
||||||
int image_index;
|
int image_index;
|
||||||
if (state->current_var->data.bindless) {
|
if (state->current_var->data.bindless) {
|
||||||
@@ -850,7 +844,7 @@ update_uniforms_shader_info(struct gl_shader_program *prog,
|
|||||||
|
|
||||||
for (unsigned j = sh->Program->sh.NumBindlessImages;
|
for (unsigned j = sh->Program->sh.NumBindlessImages;
|
||||||
j < state->next_bindless_image_index; j++) {
|
j < state->next_bindless_image_index; j++) {
|
||||||
sh->Program->sh.BindlessImages[j].access = access;
|
sh->Program->sh.BindlessImages[j].image_access = image_access;
|
||||||
}
|
}
|
||||||
|
|
||||||
sh->Program->sh.NumBindlessImages = state->next_bindless_image_index;
|
sh->Program->sh.NumBindlessImages = state->next_bindless_image_index;
|
||||||
@@ -866,7 +860,7 @@ update_uniforms_shader_info(struct gl_shader_program *prog,
|
|||||||
|
|
||||||
for (unsigned i = image_index;
|
for (unsigned i = image_index;
|
||||||
i < MIN2(state->next_image_index, MAX_IMAGE_UNIFORMS); i++) {
|
i < MIN2(state->next_image_index, MAX_IMAGE_UNIFORMS); i++) {
|
||||||
sh->Program->sh.ImageAccess[i] = access;
|
sh->Program->sh.image_access[i] = image_access;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -1111,8 +1111,8 @@ write_shader_metadata(struct blob *metadata, gl_linked_shader *shader)
|
|||||||
blob_write_uint32(metadata, glprog->ExternalSamplersUsed);
|
blob_write_uint32(metadata, glprog->ExternalSamplersUsed);
|
||||||
blob_write_uint32(metadata, glprog->sh.ShaderStorageBlocksWriteAccess);
|
blob_write_uint32(metadata, glprog->sh.ShaderStorageBlocksWriteAccess);
|
||||||
|
|
||||||
blob_write_bytes(metadata, glprog->sh.ImageAccess,
|
blob_write_bytes(metadata, glprog->sh.image_access,
|
||||||
sizeof(glprog->sh.ImageAccess));
|
sizeof(glprog->sh.image_access));
|
||||||
blob_write_bytes(metadata, glprog->sh.ImageUnits,
|
blob_write_bytes(metadata, glprog->sh.ImageUnits,
|
||||||
sizeof(glprog->sh.ImageUnits));
|
sizeof(glprog->sh.ImageUnits));
|
||||||
|
|
||||||
@@ -1163,8 +1163,8 @@ read_shader_metadata(struct blob_reader *metadata,
|
|||||||
glprog->ExternalSamplersUsed = blob_read_uint32(metadata);
|
glprog->ExternalSamplersUsed = blob_read_uint32(metadata);
|
||||||
glprog->sh.ShaderStorageBlocksWriteAccess = blob_read_uint32(metadata);
|
glprog->sh.ShaderStorageBlocksWriteAccess = blob_read_uint32(metadata);
|
||||||
|
|
||||||
blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageAccess,
|
blob_copy_bytes(metadata, (uint8_t *) glprog->sh.image_access,
|
||||||
sizeof(glprog->sh.ImageAccess));
|
sizeof(glprog->sh.image_access));
|
||||||
blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageUnits,
|
blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageUnits,
|
||||||
sizeof(glprog->sh.ImageUnits));
|
sizeof(glprog->sh.ImageUnits));
|
||||||
|
|
||||||
|
@@ -604,16 +604,9 @@ struct gl_program
|
|||||||
*/
|
*/
|
||||||
GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
|
GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
|
||||||
|
|
||||||
/**
|
/** Access qualifier from linked shader
|
||||||
* Access qualifier specified in the shader for each image uniform
|
|
||||||
* index. Either \c GL_READ_ONLY, \c GL_WRITE_ONLY, \c
|
|
||||||
* GL_READ_WRITE, or \c GL_NONE to indicate both read-only and
|
|
||||||
* write-only.
|
|
||||||
*
|
|
||||||
* It may be different, though only more strict than the value of
|
|
||||||
* \c gl_image_unit::Access for the corresponding image unit.
|
|
||||||
*/
|
*/
|
||||||
GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
|
enum gl_access_qualifier image_access[MAX_IMAGE_UNIFORMS];
|
||||||
|
|
||||||
GLuint NumUniformBlocks;
|
GLuint NumUniformBlocks;
|
||||||
struct gl_uniform_block **UniformBlocks;
|
struct gl_uniform_block **UniformBlocks;
|
||||||
@@ -924,10 +917,9 @@ struct gl_bindless_image
|
|||||||
/** Whether this bindless image is bound to a unit. */
|
/** Whether this bindless image is bound to a unit. */
|
||||||
GLboolean bound;
|
GLboolean bound;
|
||||||
|
|
||||||
/** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY, or
|
/** Access qualifier from linked shader
|
||||||
* GL_NONE to indicate both read-only and write-only)
|
|
||||||
*/
|
*/
|
||||||
GLenum16 access;
|
enum gl_access_qualifier image_access;
|
||||||
|
|
||||||
/** Pointer to the base of the data. */
|
/** Pointer to the base of the data. */
|
||||||
GLvoid *data;
|
GLvoid *data;
|
||||||
|
@@ -365,7 +365,7 @@ get_image_handle(struct gl_context *ctx, struct gl_texture_object *texObj,
|
|||||||
|
|
||||||
/* Request a new image handle from the driver. */
|
/* Request a new image handle from the driver. */
|
||||||
struct pipe_image_view image;
|
struct pipe_image_view image;
|
||||||
st_convert_image(st_context(ctx), &imgObj, &image, GL_READ_WRITE);
|
st_convert_image(st_context(ctx), &imgObj, &image, 0);
|
||||||
handle = ctx->pipe->create_image_handle(ctx->pipe, &image);
|
handle = ctx->pipe->create_image_handle(ctx->pipe, &image);
|
||||||
if (!handle) {
|
if (!handle) {
|
||||||
mtx_unlock(&ctx->Shared->HandlesMutex);
|
mtx_unlock(&ctx->Shared->HandlesMutex);
|
||||||
|
@@ -49,7 +49,7 @@
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
||||||
struct pipe_image_view *img, unsigned shader_access)
|
struct pipe_image_view *img, enum gl_access_qualifier shader_access)
|
||||||
{
|
{
|
||||||
struct gl_texture_object *stObj = u->TexObj;
|
struct gl_texture_object *stObj = u->TexObj;
|
||||||
|
|
||||||
@@ -69,22 +69,11 @@ st_convert_image(const struct st_context *st, const struct gl_image_unit *u,
|
|||||||
unreachable("bad gl_image_unit::Access");
|
unreachable("bad gl_image_unit::Access");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (shader_access) {
|
img->shader_access = 0;
|
||||||
case GL_NONE:
|
if (!(shader_access & ACCESS_NON_READABLE))
|
||||||
img->shader_access = 0;
|
img->shader_access |= PIPE_IMAGE_ACCESS_READ;
|
||||||
break;
|
if (!(shader_access & ACCESS_NON_WRITEABLE))
|
||||||
case GL_READ_ONLY:
|
img->shader_access |= PIPE_IMAGE_ACCESS_WRITE;
|
||||||
img->shader_access = PIPE_IMAGE_ACCESS_READ;
|
|
||||||
break;
|
|
||||||
case GL_WRITE_ONLY:
|
|
||||||
img->shader_access = PIPE_IMAGE_ACCESS_WRITE;
|
|
||||||
break;
|
|
||||||
case GL_READ_WRITE:
|
|
||||||
img->shader_access = PIPE_IMAGE_ACCESS_READ_WRITE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
unreachable("bad gl_image_unit::Access");
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stObj->Target == GL_TEXTURE_BUFFER) {
|
if (stObj->Target == GL_TEXTURE_BUFFER) {
|
||||||
struct gl_buffer_object *stbuf = stObj->BufferObject;
|
struct gl_buffer_object *stbuf = stObj->BufferObject;
|
||||||
@@ -141,7 +130,7 @@ void
|
|||||||
st_convert_image_from_unit(const struct st_context *st,
|
st_convert_image_from_unit(const struct st_context *st,
|
||||||
struct pipe_image_view *img,
|
struct pipe_image_view *img,
|
||||||
GLuint imgUnit,
|
GLuint imgUnit,
|
||||||
unsigned shader_access)
|
enum gl_access_qualifier image_access)
|
||||||
{
|
{
|
||||||
struct gl_image_unit *u = &st->ctx->ImageUnits[imgUnit];
|
struct gl_image_unit *u = &st->ctx->ImageUnits[imgUnit];
|
||||||
|
|
||||||
@@ -150,7 +139,7 @@ st_convert_image_from_unit(const struct st_context *st,
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
st_convert_image(st, u, img, shader_access);
|
st_convert_image(st, u, img, image_access);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@@ -169,7 +158,7 @@ st_bind_images(struct st_context *st, struct gl_program *prog,
|
|||||||
struct pipe_image_view *img = &images[i];
|
struct pipe_image_view *img = &images[i];
|
||||||
|
|
||||||
st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i],
|
st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i],
|
||||||
prog->sh.ImageAccess[i]);
|
prog->sh.image_access[i]);
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
|
@@ -355,7 +355,7 @@ st_feedback_draw_vbo(struct gl_context *ctx,
|
|||||||
struct pipe_image_view *img = &images[i];
|
struct pipe_image_view *img = &images[i];
|
||||||
|
|
||||||
st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i],
|
st_convert_image_from_unit(st, img, prog->sh.ImageUnits[i],
|
||||||
prog->sh.ImageAccess[i]);
|
prog->sh.image_access[i]);
|
||||||
|
|
||||||
struct pipe_resource *res = img->resource;
|
struct pipe_resource *res = img->resource;
|
||||||
if (!res)
|
if (!res)
|
||||||
|
@@ -550,7 +550,7 @@ st_create_image_handle_from_unit(struct st_context *st,
|
|||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
struct pipe_image_view img;
|
struct pipe_image_view img;
|
||||||
|
|
||||||
st_convert_image_from_unit(st, &img, imgUnit, GL_READ_WRITE);
|
st_convert_image_from_unit(st, &img, imgUnit, 0);
|
||||||
|
|
||||||
return pipe->create_image_handle(pipe, &img);
|
return pipe->create_image_handle(pipe, &img);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user