*/
static boolean
softpipe_resource_layout(struct pipe_screen *screen,
- struct softpipe_resource *spr)
+ struct softpipe_resource *spr,
+ boolean allocate)
{
struct pipe_resource *pt = &spr->base;
unsigned level;
depth = u_minify(depth, 1);
}
- spr->data = align_malloc(buffer_size, 16);
+ if (buffer_size > SP_MAX_TEXTURE_SIZE)
+ return FALSE;
+
+ if (allocate) {
+ spr->data = align_malloc(buffer_size, 16);
+ return spr->data != NULL;
+ }
+ else {
+ return TRUE;
+ }
+}
- return spr->data != NULL;
+
+/**
+ * Check the size of the texture specified by 'res'.
+ * \return TRUE if OK, FALSE if too large.
+ */
+static boolean
+softpipe_can_create_resource(struct pipe_screen *screen,
+ const struct pipe_resource *res)
+{
+ struct softpipe_resource spr;
+ memset(&spr, 0, sizeof(spr));
+ spr.base = *res;
+ return softpipe_resource_layout(screen, &spr, FALSE);
}
goto fail;
}
else {
- if (!softpipe_resource_layout(screen, spr))
+ if (!softpipe_resource_layout(screen, spr, TRUE))
goto fail;
}
screen->resource_destroy = softpipe_resource_destroy;
screen->resource_from_handle = softpipe_resource_from_handle;
screen->resource_get_handle = softpipe_resource_get_handle;
+ screen->can_create_resource = softpipe_can_create_resource;
}