summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Hellstrom <[email protected]>2011-06-27 10:09:21 +0200
committerThomas Hellstrom <[email protected]>2011-06-27 10:14:39 +0200
commit9a0c5b46344740dbc9ffa5cbf574a7812425237c (patch)
tree9b26cc260d0251d4e444b6f1ea5ddd44ba68b1db /src
parentab3587f70d9af5eada0c52defe1de13d77f556a6 (diff)
st/xa: Add a function to check for supported formats
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 <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/state_trackers/xa/Makefile2
-rw-r--r--src/gallium/state_trackers/xa/xa_symbols1
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.c30
-rw-r--r--src/gallium/state_trackers/xa/xa_tracker.h10
-rw-r--r--src/gallium/targets/xa-vmwgfx/Makefile2
5 files changed, 36 insertions, 9 deletions
diff --git a/src/gallium/state_trackers/xa/Makefile b/src/gallium/state_trackers/xa/Makefile
index 92edfd09340..a31db6eb370 100644
--- a/src/gallium/state_trackers/xa/Makefile
+++ b/src/gallium/state_trackers/xa/Makefile
@@ -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
diff --git a/src/gallium/state_trackers/xa/xa_symbols b/src/gallium/state_trackers/xa/xa_symbols
index f1eabea1cfb..6da701f9702 100644
--- a/src/gallium/state_trackers/xa/xa_symbols
+++ b/src/gallium/state_trackers/xa/xa_symbols
@@ -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
diff --git a/src/gallium/state_trackers/xa/xa_tracker.c b/src/gallium/state_trackers/xa/xa_tracker.c
index 8d58e5a6f13..50922d38378 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.c
+++ b/src/gallium/state_trackers/xa/xa_tracker.c
@@ -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;
}
diff --git a/src/gallium/state_trackers/xa/xa_tracker.h b/src/gallium/state_trackers/xa/xa_tracker.h
index 8c9dd5e167d..62f8a210fb6 100644
--- a/src/gallium/state_trackers/xa/xa_tracker.h
+++ b/src/gallium/state_trackers/xa/xa_tracker.h
@@ -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);
diff --git a/src/gallium/targets/xa-vmwgfx/Makefile b/src/gallium/targets/xa-vmwgfx/Makefile
index cfd32797202..fecdba695c7 100644
--- a/src/gallium/targets/xa-vmwgfx/Makefile
+++ b/src/gallium/targets/xa-vmwgfx/Makefile
@@ -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