X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fgallium%2Fdrivers%2Fsvga%2Fsvga_resource_texture.h;h=1ff42fabab9d86a8d55b3d85741c622e7a093f28;hb=52381a7ffba908410f7a53855f082401fca7293a;hp=631937f2eb099d961797ef565f9a44886df4f10c;hpb=8f3bdeaad610d7d5a5c6e73e1e9c721219595754;p=mesa.git diff --git a/src/gallium/drivers/svga/svga_resource_texture.h b/src/gallium/drivers/svga/svga_resource_texture.h index 631937f2eb0..1ff42fabab9 100644 --- a/src/gallium/drivers/svga/svga_resource_texture.h +++ b/src/gallium/drivers/svga/svga_resource_texture.h @@ -30,6 +30,7 @@ #include "pipe/p_compiler.h" #include "pipe/p_state.h" #include "util/u_inlines.h" +#include "util/u_memory.h" #include "util/u_transfer.h" #include "svga_screen_cache.h" @@ -75,6 +76,11 @@ struct svga_texture * to this texture and never destroy this handle directly. */ struct svga_winsys_surface *handle; + + unsigned size; /**< Approximate size in bytes */ + + /** array indexed by cube face or 3D/array slice, one bit per mipmap level */ + ushort *rendered_to; }; @@ -85,6 +91,8 @@ struct svga_transfer { struct pipe_transfer base; + unsigned face; + struct svga_winsys_buffer *hwbuf; /* Height of the hardware buffer in pixel blocks */ @@ -93,6 +101,8 @@ struct svga_transfer /* Temporary malloc buffer when we can't allocate a hardware buffer * big enough */ void *swbuf; + + boolean use_direct_map; }; @@ -112,6 +122,87 @@ svga_transfer(struct pipe_transfer *transfer) } +/** + * Increment the age of a view into a texture + * This is used to track updates to textures when we draw into + * them via a surface. + */ +static INLINE void +svga_age_texture_view(struct svga_texture *tex, unsigned level) +{ + assert(level < Elements(tex->view_age)); + tex->view_age[level] = ++(tex->age); +} + + +/** + * Mark the given texture face/level as being defined. + */ +static INLINE void +svga_define_texture_level(struct svga_texture *tex, + unsigned face,unsigned level) +{ + assert(face < Elements(tex->defined)); + assert(level < Elements(tex->defined[0])); + tex->defined[face][level] = TRUE; +} + + +static INLINE bool +svga_is_texture_level_defined(const struct svga_texture *tex, + unsigned face, unsigned level) +{ + assert(face < Elements(tex->defined)); + assert(level < Elements(tex->defined[0])); + return tex->defined[face][level]; +} + + +/** For debugging, check that face and level are legal */ +static inline void +check_face_level(const struct svga_texture *tex, + unsigned face, unsigned level) +{ + if (tex->b.b.target == PIPE_TEXTURE_CUBE) { + assert(face < 6); + } + else if (tex->b.b.target == PIPE_TEXTURE_3D) { + assert(face < tex->b.b.depth0); + } + else { + assert(face < tex->b.b.array_size); + } + + assert(level < 8 * sizeof(tex->rendered_to[0])); +} + + +static INLINE void +svga_set_texture_rendered_to(struct svga_texture *tex, + unsigned face, unsigned level) +{ + check_face_level(tex, face, level); + tex->rendered_to[face] |= 1 << level; +} + + +static INLINE void +svga_clear_texture_rendered_to(struct svga_texture *tex, + unsigned face, unsigned level) +{ + check_face_level(tex, face, level); + tex->rendered_to[face] &= ~(1 << level); +} + + +static INLINE boolean +svga_was_texture_rendered_to(const struct svga_texture *tex, + unsigned face, unsigned level) +{ + check_face_level(tex, face, level); + return !!(tex->rendered_to[face] & (1 << level)); +} + struct pipe_resource * svga_texture_create(struct pipe_screen *screen, @@ -124,11 +215,5 @@ svga_texture_from_handle(struct pipe_screen * screen, -enum SVGA3dSurfaceFormat -svga_translate_format(enum pipe_format format); - -enum SVGA3dSurfaceFormat -svga_translate_format_render(enum pipe_format format); - #endif /* SVGA_TEXTURE_H */