/* Set image access qualifiers */
enum gl_access_qualifier image_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;
if (state->current_var->data.bindless) {
for (unsigned j = sh->Program->sh.NumBindlessImages;
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;
for (unsigned i = image_index;
i < MIN2(state->next_image_index, MAX_IMAGE_UNIFORMS); i++) {
- sh->Program->sh.ImageAccess[i] = access;
+ sh->Program->sh.image_access[i] = image_access;
}
}
blob_write_uint32(metadata, glprog->ExternalSamplersUsed);
blob_write_uint32(metadata, glprog->sh.ShaderStorageBlocksWriteAccess);
- blob_write_bytes(metadata, glprog->sh.ImageAccess,
- sizeof(glprog->sh.ImageAccess));
+ blob_write_bytes(metadata, glprog->sh.image_access,
+ sizeof(glprog->sh.image_access));
blob_write_bytes(metadata, glprog->sh.ImageUnits,
sizeof(glprog->sh.ImageUnits));
glprog->ExternalSamplersUsed = blob_read_uint32(metadata);
glprog->sh.ShaderStorageBlocksWriteAccess = blob_read_uint32(metadata);
- blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageAccess,
- sizeof(glprog->sh.ImageAccess));
+ blob_copy_bytes(metadata, (uint8_t *) glprog->sh.image_access,
+ sizeof(glprog->sh.image_access));
blob_copy_bytes(metadata, (uint8_t *) glprog->sh.ImageUnits,
sizeof(glprog->sh.ImageUnits));
*/
GLubyte ImageUnits[MAX_IMAGE_UNIFORMS];
- /**
- * 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.
+ /** Access qualifier from linked shader
*/
- GLenum16 ImageAccess[MAX_IMAGE_UNIFORMS];
+ enum gl_access_qualifier image_access[MAX_IMAGE_UNIFORMS];
GLuint NumUniformBlocks;
struct gl_uniform_block **UniformBlocks;
/** Whether this bindless image is bound to a unit. */
GLboolean bound;
- /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY, or
- * GL_NONE to indicate both read-only and write-only)
+ /** Access qualifier from linked shader
*/
- GLenum16 access;
+ enum gl_access_qualifier image_access;
/** Pointer to the base of the data. */
GLvoid *data;
/* Request a new image handle from the driver. */
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);
if (!handle) {
mtx_unlock(&ctx->Shared->HandlesMutex);
*/
void
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;
unreachable("bad gl_image_unit::Access");
}
- switch (shader_access) {
- case GL_NONE:
- img->shader_access = 0;
- break;
- case GL_READ_ONLY:
- 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");
- }
+ img->shader_access = 0;
+ if (!(shader_access & ACCESS_NON_READABLE))
+ img->shader_access |= PIPE_IMAGE_ACCESS_READ;
+ if (!(shader_access & ACCESS_NON_WRITEABLE))
+ img->shader_access |= PIPE_IMAGE_ACCESS_WRITE;
if (stObj->Target == GL_TEXTURE_BUFFER) {
struct gl_buffer_object *stbuf = stObj->BufferObject;
st_convert_image_from_unit(const struct st_context *st,
struct pipe_image_view *img,
GLuint imgUnit,
- unsigned shader_access)
+ enum gl_access_qualifier image_access)
{
struct gl_image_unit *u = &st->ctx->ImageUnits[imgUnit];
return;
}
- st_convert_image(st, u, img, shader_access);
+ st_convert_image(st, u, img, image_access);
}
static void
struct pipe_image_view *img = &images[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_image_view *img = &images[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;
if (!res)
struct pipe_context *pipe = st->pipe;
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);
}