return usage;
}
+enum isl_format
+iris_image_view_get_format(struct iris_context *ice,
+ const struct pipe_image_view *img)
+{
+ struct iris_screen *screen = (struct iris_screen *)ice->ctx.screen;
+ const struct gen_device_info *devinfo = &screen->devinfo;
+
+ isl_surf_usage_flags_t usage = ISL_SURF_USAGE_STORAGE_BIT;
+ enum isl_format isl_fmt =
+ iris_format_for_usage(devinfo, img->format, usage).fmt;
+
+ if (img->shader_access & PIPE_IMAGE_ACCESS_READ) {
+ /* On Gen8, try to use typed surfaces reads (which support a
+ * limited number of formats), and if not possible, fall back
+ * to untyped reads.
+ */
+ if (devinfo->gen == 8 &&
+ !isl_has_matching_typed_storage_image_format(devinfo, isl_fmt))
+ return ISL_FORMAT_RAW;
+ else
+ return isl_lower_storage_image_format(devinfo, isl_fmt);
+ }
+
+ return isl_fmt;
+}
+
struct pipe_resource *
iris_resource_get_separate_stencil(struct pipe_resource *p_res)
{
enum isl_aux_usage iris_image_view_aux_usage(struct iris_context *ice,
const struct pipe_image_view *pview,
const struct shader_info *info);
+enum isl_format iris_image_view_get_format(struct iris_context *ice,
+ const struct pipe_image_view *img);
static inline bool
iris_resource_unfinished_aux_import(struct iris_resource *res)
{
struct iris_context *ice = (struct iris_context *) ctx;
struct iris_screen *screen = (struct iris_screen *)ctx->screen;
- const struct gen_device_info *devinfo = &screen->devinfo;
gl_shader_stage stage = stage_from_pipe(p_stage);
struct iris_shader_state *shs = &ice->state.shaders[stage];
#if GEN_GEN == 8
res->bind_history |= PIPE_BIND_SHADER_IMAGE;
res->bind_stages |= 1 << stage;
- isl_surf_usage_flags_t usage = ISL_SURF_USAGE_STORAGE_BIT;
- enum isl_format isl_fmt =
- iris_format_for_usage(devinfo, img->format, usage).fmt;
-
- bool untyped_fallback = false;
-
- if (img->shader_access & PIPE_IMAGE_ACCESS_READ) {
- /* On Gen8, try to use typed surfaces reads (which support a
- * limited number of formats), and if not possible, fall back
- * to untyped reads.
- */
- untyped_fallback = GEN_GEN == 8 &&
- !isl_has_matching_typed_storage_image_format(devinfo, isl_fmt);
-
- if (untyped_fallback)
- isl_fmt = ISL_FORMAT_RAW;
- else
- isl_fmt = isl_lower_storage_image_format(devinfo, isl_fmt);
- }
+ enum isl_format isl_fmt = iris_image_view_get_format(ice, img);
alloc_surface_states(&iv->surface_state, 1 << ISL_AUX_USAGE_NONE);
iv->surface_state.bo_address = res->bo->gtt_offset;
.base_array_layer = img->u.tex.first_layer,
.array_len = img->u.tex.last_layer - img->u.tex.first_layer + 1,
.swizzle = ISL_SWIZZLE_IDENTITY,
- .usage = usage,
+ .usage = ISL_SURF_USAGE_STORAGE_BIT,
};
- if (untyped_fallback) {
+ /* If using untyped fallback. */
+ if (isl_fmt == ISL_FORMAT_RAW) {
fill_buffer_surface_state(&screen->isl_dev, res, map,
isl_fmt, ISL_SWIZZLE_IDENTITY,
0, res->bo->size);