u_inlines: add function to initialize pipe_surface
authorLuca Barbieri <luca@luca-barbieri.com>
Sun, 18 Apr 2010 12:53:25 +0000 (14:53 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Sun, 18 Apr 2010 14:23:11 +0000 (16:23 +0200)
src/gallium/auxiliary/util/u_inlines.h

index c2f4f05990bb271f00a973fed70ede90ee6de9ce..b2a0408a60ed33474aaa3e977c022036bc5f8cb8 100644 (file)
@@ -35,6 +35,7 @@
 #include "util/u_debug.h"
 #include "util/u_atomic.h"
 #include "util/u_box.h"
+#include "util/u_math.h"
 
 
 #ifdef __cplusplus
@@ -121,6 +122,20 @@ pipe_sampler_view_reference(struct pipe_sampler_view **ptr, struct pipe_sampler_
    *ptr = view;
 }
 
+/* you have to call pipe_reference_init(&ps->reference, 1) yourself if it is just allocated */
+static INLINE void
+pipe_surface_init(struct pipe_surface* ps, struct pipe_resource *pt,
+               unsigned face, unsigned level, unsigned zslice, unsigned flags)
+{
+   pipe_resource_reference(&ps->texture, pt);
+   ps->format = pt->format;
+   ps->width = u_minify(pt->width0, level);
+   ps->height = u_minify(pt->height0, level);
+   ps->usage = flags;
+   ps->face = face;
+   ps->level = level;
+   ps->zslice = zslice;
+}
 
 /*
  * Convenience wrappers for screen buffer functions.