diff options
author | Kenneth Graunke <[email protected]> | 2018-08-13 16:41:19 -0700 |
---|---|---|
committer | Kenneth Graunke <[email protected]> | 2019-02-21 10:26:08 -0800 |
commit | ea19d359ccfff6db0aef0a234e90d6855e094ab8 (patch) | |
tree | 754a37bfaef89f77fd6cfbe9d6a895c5025f77f8 | |
parent | 906becec7068d06e8a0947be951658a9c8a6083d (diff) |
iris: Convert RGBX to RGBA for rendering.
Fixes a bunch of RGB bugs.
-rw-r--r-- | src/gallium/drivers/iris/iris_formats.c | 20 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_resource.h | 3 | ||||
-rw-r--r-- | src/gallium/drivers/iris/iris_state.c | 25 |
3 files changed, 36 insertions, 12 deletions
diff --git a/src/gallium/drivers/iris/iris_formats.c b/src/gallium/drivers/iris/iris_formats.c index 7bb227175e0..06c48a5583b 100644 --- a/src/gallium/drivers/iris/iris_formats.c +++ b/src/gallium/drivers/iris/iris_formats.c @@ -398,6 +398,26 @@ iris_isl_format_for_pipe_format(enum pipe_format pf) return table[pf]; } +enum isl_format +iris_isl_format_for_usage(const struct gen_device_info *devinfo, + enum pipe_format pformat, + isl_surf_usage_flags_t usage) +{ + enum isl_format format = iris_isl_format_for_pipe_format(pformat); + + /* Convert RGBX into RGBA for rendering or typed image access. */ + if (isl_format_is_rgbx(format) && + (((usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) && + !isl_format_supports_rendering(devinfo, format)) || + ((usage & ISL_SURF_USAGE_STORAGE_BIT) && + !(isl_format_supports_typed_writes(devinfo, format) && + isl_format_supports_typed_reads(devinfo, format))))) { + format = isl_format_rgbx_to_rgba(format); + } + + return format; +} + /** * The pscreen->is_format_supported() driver hook. * diff --git a/src/gallium/drivers/iris/iris_resource.h b/src/gallium/drivers/iris/iris_resource.h index c6e1e1de174..d34b28aae17 100644 --- a/src/gallium/drivers/iris/iris_resource.h +++ b/src/gallium/drivers/iris/iris_resource.h @@ -87,6 +87,9 @@ iris_resource_bo(struct pipe_resource *p_res) } enum isl_format iris_isl_format_for_pipe_format(enum pipe_format pf); +enum isl_format iris_isl_format_for_usage(const struct gen_device_info *, + enum pipe_format, + isl_surf_usage_flags_t usage); struct pipe_resource *iris_resource_get_separate_stencil(struct pipe_resource *); diff --git a/src/gallium/drivers/iris/iris_state.c b/src/gallium/drivers/iris/iris_state.c index c8ae43fa01d..115b2d34655 100644 --- a/src/gallium/drivers/iris/iris_state.c +++ b/src/gallium/drivers/iris/iris_state.c @@ -1328,24 +1328,25 @@ iris_create_surface(struct pipe_context *ctx, psurf->u.tex.last_layer = tmpl->u.tex.last_layer; psurf->u.tex.level = tmpl->u.tex.level; - enum isl_format isl_format = iris_isl_format_for_pipe_format(psurf->format); - - unsigned usage = 0; + isl_surf_usage_flags_t usage = 0; if (tmpl->writable) usage = ISL_SURF_USAGE_STORAGE_BIT; else if (util_format_is_depth_or_stencil(tmpl->format)) usage = ISL_SURF_USAGE_DEPTH_BIT; - else { + else usage = ISL_SURF_USAGE_RENDER_TARGET_BIT; - if (!isl_format_supports_rendering(devinfo, isl_format)) { - /* Framebuffer validation will reject this invalid case, but it - * hasn't had the opportunity yet. In the meantime, we need to - * avoid hitting ISL asserts about unsupported formats below. - */ - free(surf); - return NULL; - } + enum isl_format isl_format = + iris_isl_format_for_usage(devinfo, psurf->format, usage); + + if ((usage & ISL_SURF_USAGE_RENDER_TARGET_BIT) && + !isl_format_supports_rendering(devinfo, isl_format)) { + /* Framebuffer validation will reject this invalid case, but it + * hasn't had the opportunity yet. In the meantime, we need to + * avoid hitting ISL asserts about unsupported formats below. + */ + free(surf); + return NULL; } surf->view = (struct isl_view) { |