summaryrefslogtreecommitdiff
path: root/src/mesa/state_tracker/st_texture.h
diff options
context:
space:
mode:
authorMichal Krol <michal@vmware.com>2010-03-12 14:37:36 +0100
committerMichal Krol <michal@vmware.com>2010-03-12 14:38:23 +0100
commitb8030c6561e019e079b5be2fe64ec804df4bfa03 (patch)
treee3bfe141407636ac9942fc3b890dc03ae5ef0ae4 /src/mesa/state_tracker/st_texture.h
parent08f89988c8738029c60e89c61c9da0522bd53087 (diff)
st/mesa: Associate a sampler view with an st texture object.
Lazily create a sampler view when the texture is being bound for the first time.
Diffstat (limited to 'src/mesa/state_tracker/st_texture.h')
-rw-r--r--src/mesa/state_tracker/st_texture.h39
1 files changed, 39 insertions, 0 deletions
diff --git a/src/mesa/state_tracker/st_texture.h b/src/mesa/state_tracker/st_texture.h
index 60868ce067..c62f7f2cc0 100644
--- a/src/mesa/state_tracker/st_texture.h
+++ b/src/mesa/state_tracker/st_texture.h
@@ -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,6 +71,13 @@ 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
@@ -105,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,