st/xa: Add a function to check for supported formats
authorThomas Hellstrom <thellstrom@vmware.com>
Mon, 27 Jun 2011 08:09:21 +0000 (10:09 +0200)
committerThomas Hellstrom <thellstrom@vmware.com>
Mon, 27 Jun 2011 08:14:39 +0000 (10:14 +0200)
Typically this was done by having a surface creation function fail if
the format was not supported.
However, in some situations when changing hardware surface formats,
it's desirable to do this check before attempting costly readback operations.

Also updated the surface_redefine interface.

Bump minor.

Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
src/gallium/state_trackers/xa/Makefile
src/gallium/state_trackers/xa/xa_symbols
src/gallium/state_trackers/xa/xa_tracker.c
src/gallium/state_trackers/xa/xa_tracker.h
src/gallium/targets/xa-vmwgfx/Makefile

index 92edfd093400d725e0cce9243d1b505c929b9926..a31db6eb3705b2e0b330e47103bf39c1678cdbd2 100644 (file)
@@ -4,7 +4,7 @@ include $(TOP)/configs/current
 ##### MACROS #####
 
 XA_MAJOR = 0
-XA_MINOR = 3
+XA_MINOR = 4
 XA_TINY = 0
 XA_CFLAGS = -g -fPIC -Wall
 
index f1eabea1cfb98ac74cc4bb9c4061260943d35a3b..6da701f9702eab7465f7d75954a3cb8482dca4fc 100644 (file)
@@ -9,6 +9,7 @@ xa_surface_map
 xa_surface_unmap
 xa_surface_format
 xa_surface_handle
+xa_format_check_supported
 xa_context_default
 xa_context_create
 xa_context_destroy
index 8d58e5a6f139115f37ca5bf421d42d2a50cd40e0..50922d38378671af282852b89572667eb24e2065 100644 (file)
@@ -248,6 +248,29 @@ xa_get_format_stype_depth(struct xa_tracker *xa,
     return fdesc;
 }
 
+int
+xa_format_check_supported(struct xa_tracker *xa,
+                         enum xa_formats xa_format, unsigned int flags)
+{
+    struct xa_format_descriptor fdesc = xa_get_pipe_format(xa_format);
+    unsigned int bind;
+
+    if (fdesc.xa_format == xa_format_unknown)
+       return -XA_ERR_INVAL;
+
+    bind = stype_bind[xa_format_type(fdesc.xa_format)];
+    if (flags & XA_FLAG_SHARED)
+       bind |= PIPE_BIND_SHARED;
+    if (flags & XA_FLAG_RENDER_TARGET)
+       bind |= PIPE_BIND_RENDER_TARGET;
+
+    if (!xa->screen->is_format_supported(xa->screen, fdesc.format,
+                                        PIPE_TEXTURE_2D, 0, bind))
+       return -XA_ERR_INVAL;
+
+    return XA_ERR_NONE;
+}
+
 struct xa_surface *
 xa_surface_create(struct xa_tracker *xa,
                  int width,
@@ -309,8 +332,8 @@ xa_surface_redefine(struct xa_surface *srf,
                    int depth,
                    enum xa_surface_type stype,
                    enum xa_formats xa_format,
-                   unsigned int add_flags,
-                   unsigned int remove_flags, int copy_contents)
+                   unsigned int new_flags,
+                   int copy_contents)
 {
     struct pipe_resource *template = &srf->template;
     struct pipe_resource *texture;
@@ -318,7 +341,6 @@ xa_surface_redefine(struct xa_surface *srf,
     struct xa_tracker *xa = srf->xa;
     int save_width;
     int save_height;
-    unsigned int new_flags = (srf->flags | add_flags) & ~(remove_flags);
     struct xa_format_descriptor fdesc;
 
     if (xa_format == xa_format_unknown)
@@ -422,5 +444,5 @@ xa_surface_handle(struct xa_surface *srf,
 enum xa_formats
 xa_surface_format(const struct xa_surface *srf)
 {
-    return srf->fdesc.format;
+    return srf->fdesc.xa_format;
 }
index 8c9dd5e167d821af3095331008001c4ba01cae9f..62f8a210fb6ab7d07f2bf84a8de5a16bac738df0 100644 (file)
@@ -37,7 +37,7 @@
 #include <stdint.h>
 
 #define XA_TRACKER_VERSION_MAJOR 0
-#define XA_TRACKER_VERSION_MINOR 3
+#define XA_TRACKER_VERSION_MINOR 4
 #define XA_TRACKER_VERSION_PATCH 0
 
 #define XA_FLAG_SHARED         (1 << 0)
@@ -147,6 +147,10 @@ extern struct xa_tracker *xa_tracker_create(int drm_fd);
 
 extern void xa_tracker_destroy(struct xa_tracker *xa);
 
+extern int xa_format_check_supported(struct xa_tracker *xa,
+                                    enum xa_formats xa_format,
+                                    unsigned int flags);
+
 extern struct xa_surface *xa_surface_create(struct xa_tracker *xa,
                                            int width,
                                            int height,
@@ -165,8 +169,8 @@ extern int xa_surface_redefine(struct xa_surface *srf,
                               int depth,
                               enum xa_surface_type stype,
                               enum xa_formats rgb_format,
-                              unsigned int add_flags,
-                              unsigned int remove_flags, int copy_contents);
+                              unsigned int new_flags,
+                              int copy_contents);
 
 extern int xa_surface_handle(struct xa_surface *srf,
                             uint32_t * handle, unsigned int *byte_stride);
index cfd3279720240c2ec16bf689d3d86ed93f80d8de..fecdba695c7b0b2ff7ff05d6e1e57318334a24d6 100644 (file)
@@ -4,7 +4,7 @@ include $(TOP)/configs/current
 ##### MACROS #####
 
 XA_MAJOR = 0
-XA_MINOR = 3
+XA_MINOR = 4
 XA_TINY = 0
 XA_CFLAGS = -g -fPIC