+ return svga_texture_from_handle(screen, template, whandle);
+}
+
+
+/**
+ * Check if a resource (texture, buffer) of the given size
+ * and format can be created.
+ * \Return TRUE if OK, FALSE if too large.
+ */
+static bool
+svga_can_create_resource(struct pipe_screen *screen,
+ const struct pipe_resource *res)
+{
+ struct svga_screen *svgascreen = svga_screen(screen);
+ struct svga_winsys_screen *sws = svgascreen->sws;
+ SVGA3dSurfaceFormat format;
+ SVGA3dSize base_level_size;
+ uint32 numMipLevels;
+ uint32 arraySize;
+ uint32 numSamples;
+
+ if (res->target == PIPE_BUFFER) {
+ format = SVGA3D_BUFFER;
+ base_level_size.width = res->width0;
+ base_level_size.height = 1;
+ base_level_size.depth = 1;
+ numMipLevels = 1;
+ arraySize = 1;
+ numSamples = 0;
+
+ } else {
+ if (res->target == PIPE_TEXTURE_CUBE)
+ assert(res->array_size == 6);
+
+ format = svga_translate_format(svgascreen, res->format, res->bind);
+ if (format == SVGA3D_FORMAT_INVALID)
+ return false;
+
+ base_level_size.width = res->width0;
+ base_level_size.height = res->height0;
+ base_level_size.depth = res->depth0;
+ numMipLevels = res->last_level + 1;
+ arraySize = res->array_size;
+ numSamples = res->nr_samples;
+ }
+
+ return sws->surface_can_create(sws, format, base_level_size,
+ arraySize, numMipLevels, numSamples);