mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 02:10:11 +01:00
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 <thellstrom@vmware.com>
This commit is contained in:
parent
ab3587f70d
commit
9a0c5b4634
5 changed files with 36 additions and 9 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue