Module: Mesa
Branch: gallium-0.2
Commit: e6372853c221a5d64494ce75a6a323c479c55a86
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=e6372853c221a5d64494ce75a6a323c479c55a86

Author: Pekka Paalanen <[email protected]>
Date:   Thu Feb  5 20:12:04 2009 +0200

nv20: copy miptree flags from nv40

nv20_miptree_create() should set various flags.
Copy stuff over from nv40.

trivial/tri does not abort on nv04 swizzled copy anymore.
I still miss my triangle.

Signed-off-by: Pekka Paalanen <[email protected]>

---

 src/gallium/drivers/nv20/nv20_miptree.c |   31 +++++++++++++++++++++++++++++--
 1 files changed, 29 insertions(+), 2 deletions(-)

diff --git a/src/gallium/drivers/nv20/nv20_miptree.c 
b/src/gallium/drivers/nv20/nv20_miptree.c
index 89a4058..c115568 100644
--- a/src/gallium/drivers/nv20/nv20_miptree.c
+++ b/src/gallium/drivers/nv20/nv20_miptree.c
@@ -79,6 +79,8 @@ nv20_miptree_create(struct pipe_screen *screen, const struct 
pipe_texture *pt)
 {
        struct pipe_winsys *ws = screen->winsys;
        struct nv20_miptree *mt;
+       unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
+                            NOUVEAU_BUFFER_USAGE_TEXTURE;
 
        mt = MALLOC(sizeof(struct nv20_miptree));
        if (!mt)
@@ -87,10 +89,35 @@ nv20_miptree_create(struct pipe_screen *screen, const 
struct pipe_texture *pt)
        mt->base.refcount = 1;
        mt->base.screen = screen;
 
+       /* Swizzled textures must be POT */
+       if (pt->width[0] & (pt->width[0] - 1) ||
+           pt->height[0] & (pt->height[0] - 1))
+               mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+       else
+       if (pt->tex_usage & (PIPE_TEXTURE_USAGE_PRIMARY |
+                            PIPE_TEXTURE_USAGE_DISPLAY_TARGET))
+               mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+       else
+       if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
+               mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+       else {
+               switch (pt->format) {
+               /* TODO: Figure out which formats can be swizzled */
+               case PIPE_FORMAT_A8R8G8B8_UNORM:
+               case PIPE_FORMAT_X8R8G8B8_UNORM:
+               case PIPE_FORMAT_R16_SNORM:
+                       break;
+               default:
+                       mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
+               }
+       }
+
+       if (pt->tex_usage & PIPE_TEXTURE_USAGE_DYNAMIC)
+               buf_usage |= PIPE_BUFFER_USAGE_CPU_READ_WRITE;
+
        nv20_miptree_layout(mt);
 
-       mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL,
-                                          mt->total_size);
+       mt->buffer = ws->buffer_create(ws, 256, buf_usage, mt->total_size);
        if (!mt->buffer) {
                FREE(mt);
                return NULL;

_______________________________________________
mesa-commit mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to