templ.target = PIPE_TEXTURE_2D;
map->staging = crocus_resource_create(pscreen, &templ);
- assert(map->staging);
+
+ /* If we fail to create a staging resource, the caller will fallback
+ * to mapping directly on the CPU.
+ */
+ if (!map->staging)
+ return;
if (templ.target != PIPE_BUFFER) {
struct isl_surf *surf = &((struct crocus_resource *) map->staging)->surf;
map->batch = &ice->batches[CROCUS_BATCH_RENDER];
map->blorp = &ice->blorp;
crocus_map_copy_region(map);
- } else {
- /* Otherwise we're free to map on the CPU. */
+ }
+ /* If we've requested a direct mapping, or crocus_map_copy_region failed
+ * to create a staging resource, then map it directly on the CPU.
+ */
+ if (!map->ptr) {
if (resource->target != PIPE_BUFFER) {
crocus_resource_access_raw(ice, res,
level, box->z, box->depth,