gallium/tests: Update UTIL_FORMAT_MAX_* defines.
[mesa.git] / src / gallium / auxiliary / util / u_sampler.c
index 4d8f861ce49047f6d1123235241d49c486c5b03e..86799fdd5590256c9e8438d8de2fdf7a2bb383d2 100644 (file)
 #include "u_sampler.h"
 
 
+/**
+ * Initialize a pipe_sampler_view.  'view' is considered to have
+ * uninitialized contents.
+ */
 static void
 default_template(struct pipe_sampler_view *view,
-                 const struct pipe_texture *texture,
+                 const struct pipe_resource *texture,
                  enum pipe_format format,
                  unsigned expand_green_blue)
 {
+   memset(view, 0, sizeof(*view));
+
    /* XXX: Check if format is compatible with texture->format.
     */
 
+   view->target = texture->target;
    view->format = format;
-   view->first_level = 0;
-   view->last_level = texture->last_level;
+   view->u.tex.first_level = 0;
+   view->u.tex.last_level = texture->last_level;
+   view->u.tex.first_layer = 0;
+   view->u.tex.last_layer = texture->target == PIPE_TEXTURE_3D ?
+                               texture->depth0 - 1 : texture->array_size - 1;
    view->swizzle_r = PIPE_SWIZZLE_RED;
    view->swizzle_g = PIPE_SWIZZLE_GREEN;
    view->swizzle_b = PIPE_SWIZZLE_BLUE;
@@ -77,7 +87,7 @@ default_template(struct pipe_sampler_view *view,
 
 void
 u_sampler_view_default_template(struct pipe_sampler_view *view,
-                                const struct pipe_texture *texture,
+                                const struct pipe_resource *texture,
                                 enum pipe_format format)
 {
    /* Expand to (0, 0, 0, 1) */
@@ -89,7 +99,7 @@ u_sampler_view_default_template(struct pipe_sampler_view *view,
 
 void
 u_sampler_view_default_dx9_template(struct pipe_sampler_view *view,
-                                    const struct pipe_texture *texture,
+                                    const struct pipe_resource *texture,
                                     enum pipe_format format)
 {
    /* Expand to (1, 1, 1, 1) */