Merge branch '7.8'
[mesa.git] / src / mesa / state_tracker / st_texture.h
index 28c2f580f682405be3d581fe05dbf93c88e16a28..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;
@@ -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;
 };
 
 
@@ -100,6 +115,35 @@ st_get_stobj_texture(struct st_texture_object *stObj)
 }
 
 
+static INLINE struct pipe_sampler_view *
+st_sampler_view_from_texture(struct pipe_context *pipe,
+                             struct pipe_texture *texture)
+{
+   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;
+}
+
+
 extern struct pipe_texture *
 st_texture_create(struct st_context *st,
                   enum pipe_texture_target target,
@@ -108,7 +152,6 @@ st_texture_create(struct st_context *st,
                   GLuint width0,
                   GLuint height0,
                   GLuint depth0,
-                  GLuint compress_byte,
                   GLuint tex_usage );
 
 
@@ -157,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);
@@ -171,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