nouveau: implement is_{texture,buffer}_referenced properly

This commit is contained in:
Ben Skeggs 2009-10-19 09:28:59 +10:00
parent 869d3eea37
commit 35b98e2884
15 changed files with 72 additions and 169 deletions

View file

@ -3,6 +3,7 @@ include $(TOP)/configs/current
LIBNAME = nouveau
C_SOURCES = nouveau_screen.c
C_SOURCES = nouveau_screen.c \
nouveau_context.c
include ../../Makefile.template

View file

@ -0,0 +1,41 @@
#include <pipe/p_defines.h>
#include <pipe/p_context.h>
#include "nouveau/nouveau_screen.h"
#include "nouveau/nouveau_context.h"
#include "nouveau/nouveau_bo.h"
static unsigned int
nouveau_reference_flags(struct nouveau_bo *bo)
{
uint32_t bo_flags;
int flags = 0;
bo_flags = nouveau_bo_pending(bo);
if (bo_flags & NOUVEAU_BO_RD)
flags |= PIPE_REFERENCED_FOR_READ;
if (bo_flags & NOUVEAU_BO_WR)
flags |= PIPE_REFERENCED_FOR_WRITE;
return flags;
}
unsigned int
nouveau_is_texture_referenced(struct pipe_context *pipe,
struct pipe_texture *pt,
unsigned face, unsigned level)
{
struct nouveau_miptree *mt = nouveau_miptree(pt);
return nouveau_reference_flags(mt->bo);
}
unsigned int
nouveau_is_buffer_referenced(struct pipe_context *pipe, struct pipe_buffer *pb)
{
struct nouveau_bo *bo = nouveau_bo(pb);
return nouveau_reference_flags(bo);
}

View file

@ -0,0 +1,11 @@
#ifndef __NOUVEAU_CONTEXT_H__
#define __NOUVEAU_CONTEXT_H__
unsigned int
nouveau_is_texture_referenced(struct pipe_context *, struct pipe_texture *,
unsigned face, unsigned level);
unsigned int
nouveau_is_buffer_referenced(struct pipe_context *, struct pipe_buffer *);
#endif

View file

@ -64,30 +64,6 @@ nv04_init_hwctx(struct nv04_context *nv04)
return TRUE;
}
static unsigned int
nv04_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv04_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -113,8 +89,8 @@ nv04_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv04->pipe.clear = nv04_clear;
nv04->pipe.flush = nv04_flush;
nv04->pipe.is_texture_referenced = nv04_is_texture_referenced;
nv04->pipe.is_buffer_referenced = nv04_is_buffer_referenced;
nv04->pipe.is_texture_referenced = nouveau_is_texture_referenced;
nv04->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv04_init_surface_functions(nv04);
nv04_init_state_functions(nv04);

View file

@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv04_screen *ctx = nv04->screen

View file

@ -257,29 +257,6 @@ nv10_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
static unsigned int
nv10_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv10_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -305,8 +282,8 @@ nv10_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv10->pipe.clear = nv10_clear;
nv10->pipe.flush = nv10_flush;
nv10->pipe.is_texture_referenced = nv10_is_texture_referenced;
nv10->pipe.is_buffer_referenced = nv10_is_buffer_referenced;
nv10->pipe.is_texture_referenced = nouveau_is_texture_referenced;
nv10->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv10_init_surface_functions(nv10);
nv10_init_state_functions(nv10);

View file

@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv10_screen *ctx = nv10->screen

View file

@ -380,30 +380,6 @@ nv20_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
static unsigned int
nv20_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv20_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -429,8 +405,8 @@ nv20_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv20->pipe.clear = nv20_clear;
nv20->pipe.flush = nv20_flush;
nv20->pipe.is_texture_referenced = nv20_is_texture_referenced;
nv20->pipe.is_buffer_referenced = nv20_is_buffer_referenced;
nv20->pipe.is_texture_referenced = nouveau_is_texture_referenced;
nv20->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv20_init_surface_functions(nv20);
nv20_init_state_functions(nv20);

View file

@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv20_screen *ctx = nv20->screen

View file

@ -31,37 +31,6 @@ nv30_destroy(struct pipe_context *pipe)
FREE(nv30);
}
static unsigned int
nv30_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Return the corrent result. We can't alays return referenced
* since it causes a double flush within the vbo module.
*/
#if 0
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
#else
return 0;
#endif
}
static unsigned int
nv30_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Return the corrent result. We can't alays return referenced
* since it causes a double flush within the vbo module.
*/
#if 0
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
#else
return 0;
#endif
}
struct pipe_context *
nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -86,8 +55,8 @@ nv30_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv30->pipe.clear = nv30_clear;
nv30->pipe.flush = nv30_flush;
nv30->pipe.is_texture_referenced = nv30_is_texture_referenced;
nv30->pipe.is_buffer_referenced = nv30_is_buffer_referenced;
nv30->pipe.is_texture_referenced = nouveau_is_texture_referenced;
nv30->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv30_init_query_functions(nv30);
nv30_init_surface_functions(nv30);

View file

@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv30_screen *ctx = nv30->screen

View file

@ -31,37 +31,6 @@ nv40_destroy(struct pipe_context *pipe)
FREE(nv40);
}
static unsigned int
nv40_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Return the correct result. We can't always return referenced
* since it causes a double flush within the vbo module.
*/
#if 0
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
#else
return 0;
#endif
}
static unsigned int
nv40_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Return the correct result. We can't always return referenced
* since it causes a double flush within the vbo module.
*/
#if 0
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
#else
return 0;
#endif
}
struct pipe_context *
nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -86,8 +55,8 @@ nv40_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv40->pipe.clear = nv40_clear;
nv40->pipe.flush = nv40_flush;
nv40->pipe.is_texture_referenced = nv40_is_texture_referenced;
nv40->pipe.is_buffer_referenced = nv40_is_buffer_referenced;
nv40->pipe.is_texture_referenced = nouveau_is_texture_referenced;
nv40->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
nv40_init_query_functions(nv40);
nv40_init_surface_functions(nv40);

View file

@ -13,6 +13,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_context.h"
#define NOUVEAU_PUSH_CONTEXT(ctx) \
struct nv40_screen *ctx = nv40->screen

View file

@ -60,29 +60,6 @@ nv50_set_edgeflags(struct pipe_context *pipe, const unsigned *bitfield)
{
}
static unsigned int
nv50_is_texture_referenced( struct pipe_context *pipe,
struct pipe_texture *texture,
unsigned face, unsigned level)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
static unsigned int
nv50_is_buffer_referenced( struct pipe_context *pipe,
struct pipe_buffer *buf)
{
/**
* FIXME: Optimize.
*/
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
}
struct pipe_context *
nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
{
@ -108,8 +85,8 @@ nv50_create(struct pipe_screen *pscreen, unsigned pctx_id)
nv50->pipe.flush = nv50_flush;
nv50->pipe.is_texture_referenced = nv50_is_texture_referenced;
nv50->pipe.is_buffer_referenced = nv50_is_buffer_referenced;
nv50->pipe.is_texture_referenced = nouveau_is_texture_referenced;
nv50->pipe.is_buffer_referenced = nouveau_is_buffer_referenced;
screen->base.channel->user_private = nv50;
screen->base.channel->flush_notify = nv50_state_flush_notify;

View file

@ -14,6 +14,7 @@
#include "nouveau/nouveau_winsys.h"
#include "nouveau/nouveau_gldefs.h"
#include "nouveau/nouveau_stateobj.h"
#include "nouveau/nouveau_context.h"
#include "nv50_screen.h"
#include "nv50_program.h"