mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-28 03:50:13 +01:00
iris: Avoid croaking when trying to create FBO surfaces with bad formats
create_surface happens before st_validate_attachment, which actually does the "hey, this is a render target now, is that OK?" check Fixes asserts in ./bin/arb_texture_view-rendering-formats, allowing the rest of the tests to run.
This commit is contained in:
parent
8da91ebb68
commit
c9f9a6f61b
1 changed files with 15 additions and 2 deletions
|
|
@ -1091,6 +1091,7 @@ iris_create_surface(struct pipe_context *ctx,
|
|||
{
|
||||
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;
|
||||
struct iris_surface *surf = calloc(1, sizeof(struct iris_surface));
|
||||
struct pipe_surface *psurf = &surf->pipe;
|
||||
struct iris_resource *res = (struct iris_resource *) tex;
|
||||
|
|
@ -1109,16 +1110,28 @@ 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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
surf->view = (struct isl_view) {
|
||||
.format = iris_isl_format_for_pipe_format(tmpl->format),
|
||||
.format = isl_format,
|
||||
.base_level = tmpl->u.tex.level,
|
||||
.levels = 1,
|
||||
.base_array_layer = tmpl->u.tex.first_layer,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue