They're not required to be the same as the access flag on the image unit. For hardware that does shader image lowering based on the qualifier (Intel), it may be required for state setup. v2: (by Kenneth Graunke, incorporating feedback from Marek Olšák) - Reduce both access and shader_access to uint16_t to avoid making the pipe_image_view structure larger. Reviewed-by: Marek Olšák <marek.olsak@amd.com>tags/18.3-branchpoint
{ | { | ||||
struct pipe_resource *resource; /**< resource into which this is a view */ | struct pipe_resource *resource; /**< resource into which this is a view */ | ||||
enum pipe_format format; /**< typed PIPE_FORMAT_x */ | enum pipe_format format; /**< typed PIPE_FORMAT_x */ | ||||
unsigned access; /**< PIPE_IMAGE_ACCESS_x */ | |||||
uint16_t access; /**< PIPE_IMAGE_ACCESS_x */ | |||||
uint16_t shader_access; /**< PIPE_IMAGE_ACCESS_x */ | |||||
union { | union { | ||||
struct { | struct { |
*/ | */ | ||||
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) | |||||
struct pipe_image_view *img, unsigned shader_access) | |||||
{ | { | ||||
struct st_texture_object *stObj = st_texture_object(u->TexObj); | struct st_texture_object *stObj = st_texture_object(u->TexObj); | ||||
unreachable("bad gl_image_unit::Access"); | 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"); | |||||
} | |||||
if (stObj->base.Target == GL_TEXTURE_BUFFER) { | if (stObj->base.Target == GL_TEXTURE_BUFFER) { | ||||
struct st_buffer_object *stbuf = | struct st_buffer_object *stbuf = | ||||
st_buffer_object(stObj->base.BufferObject); | st_buffer_object(stObj->base.BufferObject); | ||||
void | 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) | |||||
{ | { | ||||
struct gl_image_unit *u = &st->ctx->ImageUnits[imgUnit]; | struct gl_image_unit *u = &st->ctx->ImageUnits[imgUnit]; | ||||
return; | return; | ||||
} | } | ||||
st_convert_image(st, u, img); | |||||
st_convert_image(st, u, img, shader_access); | |||||
} | } | ||||
static void | static void | ||||
for (i = 0; i < prog->info.num_images; i++) { | for (i = 0; i < prog->info.num_images; i++) { | ||||
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]); | |||||
} | } | ||||
cso_set_shader_images(st->cso_context, shader_type, 0, | cso_set_shader_images(st->cso_context, shader_type, 0, | ||||
prog->info.num_images, images); | prog->info.num_images, images); |
struct pipe_context *pipe = st->pipe; | struct pipe_context *pipe = st->pipe; | ||||
struct pipe_image_view image; | struct pipe_image_view image; | ||||
st_convert_image(st, imgObj, &image); | |||||
st_convert_image(st, imgObj, &image, GL_READ_WRITE); | |||||
return pipe->create_image_handle(pipe, &image); | return pipe->create_image_handle(pipe, &image); | ||||
} | } |
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); | |||||
st_convert_image_from_unit(st, &img, imgUnit, GL_READ_WRITE); | |||||
return pipe->create_image_handle(pipe, &img); | return pipe->create_image_handle(pipe, &img); | ||||
} | } |
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); | |||||
struct pipe_image_view *img, unsigned shader_access); | |||||
void | 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); | |||||
void | void | ||||
st_convert_sampler(const struct st_context *st, | st_convert_sampler(const struct st_context *st, |