Squashed commit of the following:
[mesa.git] / src / gallium / drivers / nvfx / nv04_surface_2d.c
index 6784170c00e74dd35f3015bae6840814120f838e..005d72b30c7fcc740b3b1b23cd9bca322a2002f7 100644 (file)
@@ -125,8 +125,8 @@ nv04_surface_copy_swizzle(struct nv04_surface_2d *ctx,
        struct nouveau_channel *chan = ctx->swzsurf->channel;
        struct nouveau_grobj *swzsurf = ctx->swzsurf;
        struct nouveau_grobj *sifm = ctx->sifm;
-       struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
-       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+       struct nouveau_bo *src_bo = ctx->buf(src);
+       struct nouveau_bo *dst_bo = ctx->buf(dst);
        const unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
         /* Max width & height may not be the same on all HW, but must be POT */
        const unsigned max_w = 1024;
@@ -205,8 +205,8 @@ nv04_surface_copy_m2mf(struct nv04_surface_2d *ctx,
 {
        struct nouveau_channel *chan = ctx->m2mf->channel;
        struct nouveau_grobj *m2mf = ctx->m2mf;
-       struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
-       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+       struct nouveau_bo *src_bo = ctx->buf(src);
+       struct nouveau_bo *dst_bo = ctx->buf(dst);
        unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
        unsigned dst_offset = dst->offset + dy * dst_pitch +
@@ -252,8 +252,8 @@ nv04_surface_copy_blit(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
        struct nouveau_channel *chan = ctx->surf2d->channel;
        struct nouveau_grobj *surf2d = ctx->surf2d;
        struct nouveau_grobj *blit = ctx->blit;
-       struct nouveau_bo *src_bo = nouveau_bo(ctx->buf(src));
-       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+       struct nouveau_bo *src_bo = ctx->buf(src);
+       struct nouveau_bo *dst_bo = ctx->buf(dst);
        unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
        int format;
@@ -287,8 +287,8 @@ nv04_surface_copy(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
 {
        unsigned src_pitch = ((struct nv04_surface *)src)->pitch;
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
-       int src_linear = src->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
-       int dst_linear = dst->texture->tex_usage & NOUVEAU_TEXTURE_USAGE_LINEAR;
+       int src_linear = src->texture->flags & NVFX_RESOURCE_FLAG_LINEAR;
+       int dst_linear = dst->texture->flags & NVFX_RESOURCE_FLAG_LINEAR;
 
        assert(src->format == dst->format);
 
@@ -317,7 +317,7 @@ nv04_surface_fill(struct nv04_surface_2d *ctx, struct pipe_surface *dst,
        struct nouveau_channel *chan = ctx->surf2d->channel;
        struct nouveau_grobj *surf2d = ctx->surf2d;
        struct nouveau_grobj *rect = ctx->rect;
-       struct nouveau_bo *dst_bo = nouveau_bo(ctx->buf(dst));
+       struct nouveau_bo *dst_bo = ctx->buf(dst);
        unsigned dst_pitch = ((struct nv04_surface *)dst)->pitch;
        int cs2d_format, gdirect_format;
 
@@ -501,26 +501,19 @@ nv04_surface_2d_init(struct nouveau_screen *screen)
 }
 
 struct nv04_surface*
-nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
+nv04_surface_wrap_for_render(struct pipe_screen *pscreen,
+                            struct nv04_surface_2d* eng2d, struct nv04_surface* ns)
 {
        int temp_flags;
 
-       // printf("creating temp, flags is %i!\n", flags);
+       temp_flags = (ns->base.usage |
+                     PIPE_BIND_BLIT_SOURCE |
+                     PIPE_BIND_BLIT_DESTINATION);
 
-       if(ns->base.usage & PIPE_BUFFER_USAGE_DISCARD)
-       {
-               temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ;
-               ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_DISCARD;
-       }
-       else
-       {
-               temp_flags = ns->base.usage | PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
-               ns->base.usage = PIPE_BUFFER_USAGE_GPU_WRITE | NOUVEAU_BUFFER_USAGE_NO_RENDER | PIPE_BUFFER_USAGE_GPU_READ;
-       }
-
-       ns->base.usage = PIPE_BUFFER_USAGE_GPU_READ | PIPE_BUFFER_USAGE_GPU_WRITE;
+       ns->base.usage = (PIPE_BIND_BLIT_SOURCE |
+                        PIPE_BIND_BLIT_DESTINATION);
 
-       struct pipe_texture templ;
+       struct pipe_resource templ;
        memset(&templ, 0, sizeof(templ));
        templ.format = ns->base.texture->format;
        templ.target = PIPE_TEXTURE_2D;
@@ -532,14 +525,16 @@ nv04_surface_wrap_for_render(struct pipe_screen *pscreen, struct nv04_surface_2d
        // TODO: this is probably wrong and we should specifically handle multisampling somehow once it is implemented
        templ.nr_samples = ns->base.texture->nr_samples;
 
-       templ.tex_usage = ns->base.texture->tex_usage | PIPE_TEXTURE_USAGE_RENDER_TARGET;
+       templ.bind = ns->base.texture->bind | PIPE_BIND_RENDER_TARGET;
 
-       struct pipe_texture* temp_tex = pscreen->texture_create(pscreen, &templ);
+       struct pipe_resource* temp_tex = pscreen->resource_create(pscreen, &templ);
        struct nv04_surface* temp_ns = (struct nv04_surface*)pscreen->get_tex_surface(pscreen, temp_tex, 0, 0, 0, temp_flags);
        temp_ns->backing = ns;
 
-       if(ns->base.usage & PIPE_BUFFER_USAGE_GPU_READ)
-               eng2d->copy(eng2d, &temp_ns->backing->base, 0, 0, &ns->base, 0, 0, ns->base.width, ns->base.height);
+       if(ns->base.usage & PIPE_BIND_BLIT_SOURCE)
+               eng2d->copy(eng2d, &temp_ns->backing->base,
+                           0, 0, &ns->base,
+                           0, 0, ns->base.width, ns->base.height);
 
        return temp_ns;
 }