Merge branch '7.8'
[mesa.git] / src / mesa / state_tracker / st_texture.h
index 31f66ad52cf5abe4d6f726e4b22b44c3a57a5ffe..c62f7f2cc0d172834e519f3bddee0a72c08e5c35 100644 (file)
@@ -29,6 +29,9 @@
 #define ST_TEXTURE_H
 
 
+#include "pipe/p_context.h"
+#include "util/u_sampler.h"
+
 #include "main/mtypes.h"
 
 struct pipe_context;
@@ -50,7 +53,7 @@ struct st_texture_image
     */
    struct pipe_texture *pt;
 
-   struct pipe_surface *surface;
+   struct pipe_transfer *transfer;
 };
 
 
@@ -68,7 +71,19 @@ struct st_texture_object
     */
    struct pipe_texture *pt;
 
+   /* Default sampler view attached to this texture object. Created lazily
+    * on first binding.
+    */
+   struct pipe_sampler_view *sampler_view;
+
+   struct pipe_context *pipe;
+
    GLboolean teximage_realloc;
+
+   /* True if there is/was a surface bound to this texture object.  It helps
+    * track whether the texture object is surface based or not.
+    */
+   GLboolean surface_based;
 };
 
 
@@ -99,10 +114,33 @@ st_get_stobj_texture(struct st_texture_object *stObj)
    return stObj ? stObj->pt : NULL;
 }
 
-static INLINE GLboolean pf_is_depth_stencil( enum pipe_format format )
+
+static INLINE struct pipe_sampler_view *
+st_sampler_view_from_texture(struct pipe_context *pipe,
+                             struct pipe_texture *texture)
 {
-   return (pf_get_component_bits( format, PIPE_FORMAT_COMP_Z ) +
-           pf_get_component_bits( format, PIPE_FORMAT_COMP_S )) != 0;
+   struct pipe_sampler_view templ;
+
+   u_sampler_view_default_template(&templ,
+                                   texture,
+                                   texture->format);
+
+   return pipe->create_sampler_view(pipe, texture, &templ);
+}
+
+
+static INLINE struct pipe_sampler_view *
+st_get_stobj_sampler_view(struct st_texture_object *stObj)
+{
+   if (!stObj || !stObj->pt) {
+      return NULL;
+   }
+
+   if (!stObj->sampler_view) {
+      stObj->sampler_view = st_sampler_view_from_texture(stObj->pipe, stObj->pt);
+   }
+
+   return stObj->sampler_view;
 }
 
 
@@ -114,7 +152,6 @@ st_texture_create(struct st_context *st,
                   GLuint width0,
                   GLuint height0,
                   GLuint depth0,
-                  GLuint compress_byte,
                   GLuint tex_usage );
 
 
@@ -132,7 +169,9 @@ extern GLubyte *
 st_texture_image_map(struct st_context *st,
                      struct st_texture_image *stImage,
                     GLuint zoffset,
-                     GLuint flags);
+                     enum pipe_transfer_usage usage,
+                     unsigned x, unsigned y,
+                     unsigned w, unsigned h);
 
 extern void
 st_texture_image_unmap(struct st_context *st,
@@ -161,7 +200,7 @@ st_texture_texel_offset(const struct pipe_texture * pt,
 /* Upload an image into a texture
  */
 extern void
-st_texture_image_data(struct pipe_context *pipe,
+st_texture_image_data(struct st_context *st,
                       struct pipe_texture *dst,
                       GLuint face, GLuint level, void *src,
                       GLuint src_row_pitch, GLuint src_image_pitch);
@@ -175,5 +214,10 @@ st_texture_image_copy(struct pipe_context *pipe,
                       struct pipe_texture *src,
                       GLuint face);
 
-
+extern void
+st_teximage_flush_before_map(struct st_context *st,
+                            struct pipe_texture *pt,
+                            unsigned int face,
+                            unsigned int level,
+                            enum pipe_transfer_usage usage);
 #endif