mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-02 06:40:22 +01:00
nouveau: adapt to gallium interface changes
This commit is contained in:
parent
274a3d9cb6
commit
b8965bee40
33 changed files with 482 additions and 635 deletions
|
|
@ -3,7 +3,6 @@
|
|||
MESA_MODULES = $(TOP)/src/mesa/libmesa.a
|
||||
|
||||
COMMON_SOURCES = \
|
||||
../../common/driverfuncs.c \
|
||||
../common/utils.c \
|
||||
../common/texmem.c \
|
||||
../common/vblank.c \
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ DRIVER_SOURCES = \
|
|||
nouveau_winsys.c \
|
||||
nouveau_winsys_pipe.c \
|
||||
nouveau_winsys_softpipe.c \
|
||||
nv04_region.c \
|
||||
nv50_region.c
|
||||
nv04_surface.c \
|
||||
nv50_surface.c
|
||||
|
||||
C_SOURCES = \
|
||||
$(COMMON_SOURCES) \
|
||||
|
|
|
|||
|
|
@ -1,18 +1,8 @@
|
|||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "extensions.h"
|
||||
|
||||
#include "tnl/tnl.h"
|
||||
#include "tnl/t_pipeline.h"
|
||||
#include "tnl/t_vertex.h"
|
||||
|
||||
#include "drivers/common/driverfuncs.h"
|
||||
|
||||
#include "drirenderbuffer.h"
|
||||
#include "main/glheader.h"
|
||||
#include "glapi/glthread.h"
|
||||
#include <GL/internal/glcore.h>
|
||||
|
||||
#include "state_tracker/st_public.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_context.h"
|
||||
|
||||
|
|
@ -130,7 +120,7 @@ nouveau_context_create(const __GLcontextModes *glVis,
|
|||
* of the front buffer handle passed to us by the DDX.
|
||||
*/
|
||||
{
|
||||
struct pipe_region *fb_region;
|
||||
struct pipe_surface *fb_surf;
|
||||
struct nouveau_bo_priv *fb_bo;
|
||||
|
||||
fb_bo = calloc(1, sizeof(struct nouveau_bo_priv));
|
||||
|
|
@ -145,14 +135,14 @@ nouveau_context_create(const __GLcontextModes *glVis,
|
|||
fb_bo->base.size = fb_bo->drm.size;
|
||||
fb_bo->base.device = nv_screen->device;
|
||||
|
||||
fb_region = calloc(1, sizeof(struct pipe_region));
|
||||
fb_region->cpp = nv_screen->front_cpp;
|
||||
fb_region->pitch = nv_screen->front_pitch / fb_region->cpp;
|
||||
fb_region->height = nv_screen->front_height;
|
||||
fb_region->refcount = 1;
|
||||
fb_region->buffer = (void *)fb_bo;
|
||||
fb_surf = calloc(1, sizeof(struct pipe_surface));
|
||||
fb_surf->cpp = nv_screen->front_cpp;
|
||||
fb_surf->pitch = nv_screen->front_pitch / fb_surf->cpp;
|
||||
fb_surf->height = nv_screen->front_height;
|
||||
fb_surf->refcount = 1;
|
||||
fb_surf->buffer = (void *)fb_bo;
|
||||
|
||||
nv->frontbuffer = fb_region;
|
||||
nv->frontbuffer = fb_surf;
|
||||
}
|
||||
|
||||
if ((ret = nouveau_grobj_alloc(nv->channel, 0x00000000, 0x30,
|
||||
|
|
@ -169,9 +159,9 @@ nouveau_context_create(const __GLcontextModes *glVis,
|
|||
}
|
||||
|
||||
if (nv->chipset < 0x50)
|
||||
ret = nouveau_region_init_nv04(nv);
|
||||
ret = nouveau_surface_init_nv04(nv);
|
||||
else
|
||||
ret = nouveau_region_init_nv50(nv);
|
||||
ret = nouveau_surface_init_nv50(nv);
|
||||
if (ret) {
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,6 @@
|
|||
#ifndef __NOUVEAU_CONTEXT_H__
|
||||
#define __NOUVEAU_CONTEXT_H__
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
|
||||
#include "dri_util.h"
|
||||
#include "xmlconfig.h"
|
||||
|
||||
|
|
@ -31,7 +28,7 @@ struct nouveau_context {
|
|||
drmLock drm_lock;
|
||||
GLboolean locked;
|
||||
struct nouveau_screen *nv_screen;
|
||||
struct pipe_region *frontbuffer;
|
||||
struct pipe_surface *frontbuffer;
|
||||
|
||||
/* Bufmgr */
|
||||
struct {
|
||||
|
|
@ -58,29 +55,22 @@ struct nouveau_context {
|
|||
uint32_t next_handle;
|
||||
uint32_t next_sequence;
|
||||
|
||||
/* pipe_region accel */
|
||||
struct pipe_region *region_src, *region_dst;
|
||||
unsigned region_src_offset, region_dst_offset;
|
||||
int (*region_copy_prep)(struct nouveau_context *,
|
||||
struct pipe_region *dst, uint32_t dst_offset,
|
||||
struct pipe_region *src, uint32_t src_offset);
|
||||
void (*region_copy)(struct nouveau_context *, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h);
|
||||
void (*region_copy_done)(struct nouveau_context *);
|
||||
int (*region_fill)(struct nouveau_context *, struct pipe_region *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned,
|
||||
unsigned);
|
||||
int (*region_data)(struct nouveau_context *, struct pipe_region *,
|
||||
unsigned, unsigned, unsigned, const void *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||
/* pipe_surface accel */
|
||||
struct pipe_surface *surf_src, *surf_dst;
|
||||
unsigned surf_src_offset, surf_dst_offset;
|
||||
int (*surface_copy_prep)(struct nouveau_context *,
|
||||
struct pipe_surface *dst,
|
||||
struct pipe_surface *src);
|
||||
void (*surface_copy)(struct nouveau_context *, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h);
|
||||
void (*surface_copy_done)(struct nouveau_context *);
|
||||
int (*surface_fill)(struct nouveau_context *, struct pipe_surface *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||
int (*surface_data)(struct nouveau_context *, struct pipe_surface *,
|
||||
unsigned, unsigned, const void *, unsigned,
|
||||
unsigned, unsigned, unsigned, unsigned);
|
||||
};
|
||||
|
||||
static INLINE struct nouveau_context *
|
||||
nouveau_context(GLcontext *ctx)
|
||||
{
|
||||
return (struct nouveau_context *)ctx;
|
||||
}
|
||||
|
||||
extern GLboolean nouveau_context_create(const __GLcontextModes *,
|
||||
__DRIcontextPrivate *, void *);
|
||||
extern void nouveau_context_destroy(__DRIcontextPrivate *);
|
||||
|
|
@ -105,7 +95,7 @@ extern int __nouveau_debug;
|
|||
extern void LOCK_HARDWARE(struct nouveau_context *);
|
||||
extern void UNLOCK_HARDWARE(struct nouveau_context *);
|
||||
|
||||
extern int nouveau_region_init_nv04(struct nouveau_context *);
|
||||
extern int nouveau_region_init_nv50(struct nouveau_context *);
|
||||
extern int nouveau_surface_init_nv04(struct nouveau_context *);
|
||||
extern int nouveau_surface_init_nv50(struct nouveau_context *);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -25,18 +25,9 @@
|
|||
*
|
||||
**************************************************************************/
|
||||
|
||||
|
||||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "extensions.h"
|
||||
|
||||
#include "state_tracker/st_public.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
|
||||
#include "drirenderbuffer.h"
|
||||
#include "vblank.h"
|
||||
#include "utils.h"
|
||||
#include "xmlpool.h" /* for symbolic values of enum-type options */
|
||||
#include "main/glheader.h"
|
||||
#include "glapi/glthread.h"
|
||||
#include <GL/internal/glcore.h>
|
||||
|
||||
#include "nouveau_context.h"
|
||||
#include "nouveau_screen.h"
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
#include "glheader.h"
|
||||
#include "context.h"
|
||||
#include "framebuffer.h"
|
||||
#include "matrix.h"
|
||||
#include "renderbuffer.h"
|
||||
#include "simple_list.h"
|
||||
#include "utils.h"
|
||||
#include "vblank.h"
|
||||
#include "xmlpool.h"
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
#include "context.h"
|
||||
#include "main/glheader.h"
|
||||
#include "glapi/glthread.h"
|
||||
#include <GL/internal/glcore.h>
|
||||
|
||||
#include "pipe/p_context.h"
|
||||
#include "state_tracker/st_public.h"
|
||||
#include "state_tracker/st_context.h"
|
||||
#include "state_tracker/st_cb_fbo.h"
|
||||
|
||||
#include "nouveau_context.h"
|
||||
|
|
@ -14,7 +17,6 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
|
|||
const drm_clip_rect_t *rect)
|
||||
{
|
||||
struct nouveau_context *nv = dPriv->driContextPriv->driverPrivate;
|
||||
struct pipe_region *p_region = surf->region;
|
||||
drm_clip_rect_t *pbox;
|
||||
int nbox, i;
|
||||
|
||||
|
|
@ -26,7 +28,7 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
|
|||
pbox = dPriv->pClipRects;
|
||||
nbox = dPriv->numClipRects;
|
||||
|
||||
nv->region_copy_prep(nv, nv->frontbuffer, 0, p_region, 0);
|
||||
nv->surface_copy_prep(nv, nv->frontbuffer, surf);
|
||||
for (i = 0; i < nbox; i++, pbox++) {
|
||||
int sx, sy, dx, dy, w, h;
|
||||
|
||||
|
|
@ -37,7 +39,7 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
|
|||
w = pbox->x2 - pbox->x1;
|
||||
h = pbox->y2 - pbox->y1;
|
||||
|
||||
nv->region_copy(nv, dx, dy, sx, sy, w, h);
|
||||
nv->surface_copy(nv, dx, dy, sx, sy, w, h);
|
||||
}
|
||||
|
||||
FIRE_RING();
|
||||
|
|
|
|||
|
|
@ -1,3 +1,5 @@
|
|||
#include "pipe/p_util.h"
|
||||
|
||||
#include "nouveau_context.h"
|
||||
#include "nouveau_winsys_pipe.h"
|
||||
|
||||
|
|
@ -128,40 +130,38 @@ nouveau_pipe_dma_kickoff(struct nouveau_channel *userchan)
|
|||
}
|
||||
|
||||
static int
|
||||
nouveau_pipe_region_copy(struct nouveau_winsys *nvws, struct pipe_region *dst,
|
||||
unsigned dst_offset, unsigned dx, unsigned dy,
|
||||
struct pipe_region *src, unsigned src_offset,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
nouveau_pipe_surface_copy(struct nouveau_winsys *nvws, struct pipe_surface *dst,
|
||||
unsigned dx, unsigned dy, struct pipe_surface *src,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
{
|
||||
struct nouveau_context *nv = nvws->nv;
|
||||
|
||||
if (nv->region_copy_prep(nv, dst, dst_offset, src, src_offset))
|
||||
if (nv->surface_copy_prep(nv, dst, src))
|
||||
return 1;
|
||||
nv->region_copy(nv, dx, dy, sx, sy, w, h);
|
||||
nv->region_copy_done(nv);
|
||||
nv->surface_copy(nv, dx, dy, sx, sy, w, h);
|
||||
nv->surface_copy_done(nv);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nouveau_pipe_region_fill(struct nouveau_winsys *nvws, struct pipe_region *dst,
|
||||
unsigned dst_offset, unsigned dx, unsigned dy,
|
||||
unsigned w, unsigned h, unsigned value)
|
||||
nouveau_pipe_surface_fill(struct nouveau_winsys *nvws, struct pipe_surface *dst,
|
||||
unsigned dx, unsigned dy, unsigned w, unsigned h,
|
||||
unsigned value)
|
||||
{
|
||||
if (nvws->nv->region_fill(nvws->nv, dst, dst_offset, dx, dy,
|
||||
w, h, value))
|
||||
if (nvws->nv->surface_fill(nvws->nv, dst, dx, dy, w, h, value))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
nouveau_pipe_region_data(struct nouveau_winsys *nvws, struct pipe_region *dst,
|
||||
unsigned dst_offset, unsigned dx, unsigned dy,
|
||||
const void *src, unsigned src_pitch,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
nouveau_pipe_surface_data(struct nouveau_winsys *nvws, struct pipe_surface *dst,
|
||||
unsigned dx, unsigned dy, const void *src,
|
||||
unsigned src_pitch, unsigned sx, unsigned sy,
|
||||
unsigned w, unsigned h)
|
||||
{
|
||||
if (nvws->nv->region_data(nvws->nv, dst, dst_offset, dx, dy, src,
|
||||
src_pitch, sx, sy, w, h))
|
||||
if (nvws->nv->surface_data(nvws->nv, dst, dx, dy, src, src_pitch, sx,
|
||||
sy, w, h))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -211,9 +211,9 @@ nouveau_pipe_create(struct nouveau_context *nv)
|
|||
nvws->notifier_retval = nouveau_notifier_return_val;
|
||||
nvws->notifier_wait = nouveau_notifier_wait_status;
|
||||
|
||||
nvws->region_copy = nouveau_pipe_region_copy;
|
||||
nvws->region_fill = nouveau_pipe_region_fill;
|
||||
nvws->region_data = nouveau_pipe_region_data;
|
||||
nvws->surface_copy = nouveau_pipe_surface_copy;
|
||||
nvws->surface_fill = nouveau_pipe_surface_fill;
|
||||
nvws->surface_data = nouveau_pipe_surface_data;
|
||||
|
||||
return hw_create(nouveau_create_pipe_winsys(nv), nvws, nv->chipset);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
#include "pipe/p_winsys.h"
|
||||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_util.h"
|
||||
|
||||
#include "nouveau_context.h"
|
||||
#include "nouveau_device.h"
|
||||
|
|
@ -33,46 +34,18 @@ nouveau_get_name(struct pipe_winsys *pws)
|
|||
return "Nouveau/DRI";
|
||||
}
|
||||
|
||||
static struct pipe_region *
|
||||
nouveau_region_alloc(struct pipe_winsys *ws, unsigned cpp,
|
||||
unsigned width, unsigned height, unsigned flags)
|
||||
static unsigned
|
||||
nouveau_surface_pitch(struct pipe_winsys *ws, unsigned cpp, unsigned width,
|
||||
unsigned flags)
|
||||
{
|
||||
struct pipe_region *region;
|
||||
unsigned pitch = width * cpp;
|
||||
|
||||
region = calloc(sizeof(*region), 1);
|
||||
region->cpp = cpp;
|
||||
region->pitch = ((cpp * width + 63) & ~63) / cpp;
|
||||
region->height = height;
|
||||
region->refcount = 1;
|
||||
region->buffer = ws->buffer_create(ws, 64);
|
||||
|
||||
ws->buffer_data(ws, region->buffer, region->pitch * cpp * height, NULL,
|
||||
PIPE_BUFFER_USAGE_PIXEL);
|
||||
return region;
|
||||
}
|
||||
|
||||
static void
|
||||
nouveau_region_release(struct pipe_winsys *pws, struct pipe_region **pregion)
|
||||
{
|
||||
struct pipe_region *region;
|
||||
|
||||
if (!pregion || !*pregion)
|
||||
return;
|
||||
region = *pregion;
|
||||
*pregion = NULL;
|
||||
|
||||
assert(region->refcount > 0);
|
||||
region->refcount--;
|
||||
|
||||
if (region->refcount == 0) {
|
||||
assert(region->map_refcount == 0);
|
||||
pws->buffer_reference(pws, ®ion->buffer, NULL);
|
||||
free(region);
|
||||
}
|
||||
pitch = (pitch + 63) & ~63;
|
||||
return pitch / cpp;
|
||||
}
|
||||
|
||||
static struct pipe_surface *
|
||||
nouveau_surface_alloc(struct pipe_winsys *pws, unsigned format)
|
||||
nouveau_surface_alloc(struct pipe_winsys *ws, unsigned format)
|
||||
{
|
||||
struct pipe_surface *surf;
|
||||
|
||||
|
|
@ -82,19 +55,19 @@ nouveau_surface_alloc(struct pipe_winsys *pws, unsigned format)
|
|||
|
||||
surf->format = format;
|
||||
surf->refcount = 1;
|
||||
surf->winsys = pws;
|
||||
|
||||
surf->winsys = ws;
|
||||
return surf;
|
||||
}
|
||||
|
||||
static void
|
||||
nouveau_surface_release(struct pipe_winsys *pws, struct pipe_surface **s)
|
||||
nouveau_surface_release(struct pipe_winsys *ws, struct pipe_surface **s)
|
||||
{
|
||||
struct pipe_surface *surf = *s; *s = NULL;
|
||||
struct pipe_surface *surf = *s;
|
||||
|
||||
if (surf->refcount-- == 0) {
|
||||
if (surf->region)
|
||||
pws->region_release(pws, &surf->region);
|
||||
*s = NULL;
|
||||
if (--surf->refcount <= 0) {
|
||||
if (surf->buffer)
|
||||
ws->buffer_reference(ws, &surf->buffer, NULL);
|
||||
free(surf);
|
||||
}
|
||||
}
|
||||
|
|
@ -229,9 +202,7 @@ nouveau_create_pipe_winsys(struct nouveau_context *nv)
|
|||
pws->flush_frontbuffer = nouveau_flush_frontbuffer;
|
||||
pws->printf = nouveau_printf;
|
||||
|
||||
pws->region_alloc = nouveau_region_alloc;
|
||||
pws->region_release = nouveau_region_release;
|
||||
|
||||
pws->surface_pitch = nouveau_surface_pitch;
|
||||
pws->surface_alloc = nouveau_surface_alloc;
|
||||
pws->surface_release = nouveau_surface_release;
|
||||
|
||||
|
|
|
|||
|
|
@ -49,9 +49,9 @@ static boolean
|
|||
nouveau_is_format_supported(struct softpipe_winsys *sws, uint format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_U_A8_R8_G8_B8:
|
||||
case PIPE_FORMAT_U_R5_G6_B5:
|
||||
case PIPE_FORMAT_S8_Z24:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
case PIPE_FORMAT_S8Z24_UNORM:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -27,15 +27,15 @@ nv04_rect_format(int cpp)
|
|||
}
|
||||
|
||||
static void
|
||||
nv04_region_copy_m2mf(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
nv04_surface_copy_m2mf(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
{
|
||||
struct pipe_region *dst = nv->region_dst;
|
||||
struct pipe_region *src = nv->region_dst;
|
||||
struct pipe_surface *dst = nv->surf_dst;
|
||||
struct pipe_surface *src = nv->surf_dst;
|
||||
unsigned dst_offset, src_offset;
|
||||
|
||||
dst_offset = nv->region_dst_offset + (dy * dst->pitch + dx) * dst->cpp;
|
||||
src_offset = nv->region_src_offset + (sy * src->pitch + sx) * src->cpp;
|
||||
|
||||
dst_offset = dst->offset + (dy * dst->pitch + dx) * dst->cpp;
|
||||
src_offset = src->offset + (sy * src->pitch + sx) * src->cpp;
|
||||
|
||||
while (h) {
|
||||
int count = (h > 2047) ? 2047 : h;
|
||||
|
|
@ -59,8 +59,8 @@ nv04_region_copy_m2mf(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
|||
}
|
||||
|
||||
static void
|
||||
nv04_region_copy_blit(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
nv04_surface_copy_blit(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
{
|
||||
BEGIN_RING(NvImageBlit, 0x0300, 3);
|
||||
OUT_RING ((sy << 16) | sx);
|
||||
|
|
@ -69,9 +69,8 @@ nv04_region_copy_blit(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
|||
}
|
||||
|
||||
static int
|
||||
nv04_region_copy_prep(struct nouveau_context *nv,
|
||||
struct pipe_region *dst, unsigned dst_offset,
|
||||
struct pipe_region *src, unsigned src_offset)
|
||||
nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst,
|
||||
struct pipe_surface *src)
|
||||
{
|
||||
int format;
|
||||
|
||||
|
|
@ -81,18 +80,16 @@ nv04_region_copy_prep(struct nouveau_context *nv,
|
|||
/* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
|
||||
* to NV_MEMORY_TO_MEMORY_FORMAT in this case.
|
||||
*/
|
||||
if ((src_offset & 63) || (dst_offset & 63)) {
|
||||
if ((src->offset & 63) || (dst->offset & 63)) {
|
||||
BEGIN_RING(NvM2MF, NV_MEMORY_TO_MEMORY_FORMAT_DMA_BUFFER_IN, 2);
|
||||
OUT_RELOCo(src->buffer, NOUVEAU_BO_GART | NOUVEAU_BO_VRAM |
|
||||
NOUVEAU_BO_RD);
|
||||
OUT_RELOCo(dst->buffer, NOUVEAU_BO_GART | NOUVEAU_BO_VRAM |
|
||||
NOUVEAU_BO_WR);
|
||||
|
||||
nv->region_copy = nv04_region_copy_m2mf;
|
||||
nv->region_dst = dst;
|
||||
nv->region_dst_offset = dst_offset;
|
||||
nv->region_src = src;
|
||||
nv->region_src_offset = src_offset;
|
||||
nv->surface_copy = nv04_surface_copy_m2mf;
|
||||
nv->surf_dst = dst;
|
||||
nv->surf_src = src;
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
@ -101,7 +98,7 @@ nv04_region_copy_prep(struct nouveau_context *nv,
|
|||
NOUVEAU_ERR("Bad cpp = %d\n", dst->cpp);
|
||||
return 1;
|
||||
}
|
||||
nv->region_copy = nv04_region_copy_blit;
|
||||
nv->surface_copy = nv04_surface_copy_blit;
|
||||
|
||||
BEGIN_RING(NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D_DMA_IMAGE_SOURCE, 2);
|
||||
OUT_RELOCo(src->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
|
|
@ -110,14 +107,14 @@ nv04_region_copy_prep(struct nouveau_context *nv,
|
|||
BEGIN_RING(NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
|
||||
OUT_RING (format);
|
||||
OUT_RING (((dst->pitch * dst->cpp) << 16) | (src->pitch * src->cpp));
|
||||
OUT_RELOCl(src->buffer, src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCl(dst->buffer, dst_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(src->buffer, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCl(dst->buffer, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nv04_region_copy_done(struct nouveau_context *nv)
|
||||
nv04_surface_copy_done(struct nouveau_context *nv)
|
||||
{
|
||||
nouveau_notifier_reset(nv->sync_notifier, 0);
|
||||
BEGIN_RING(NvGdiRect, 0x104, 1);
|
||||
|
|
@ -129,10 +126,9 @@ nv04_region_copy_done(struct nouveau_context *nv)
|
|||
}
|
||||
|
||||
static int
|
||||
nv04_region_fill(struct nouveau_context *nv,
|
||||
struct pipe_region *dst, unsigned dst_offset,
|
||||
unsigned dx, unsigned dy, unsigned w, unsigned h,
|
||||
unsigned value)
|
||||
nv04_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
|
||||
unsigned dx, unsigned dy, unsigned w, unsigned h,
|
||||
unsigned value)
|
||||
{
|
||||
int cs2d_format, gdirect_format;
|
||||
|
||||
|
|
@ -152,8 +148,8 @@ nv04_region_fill(struct nouveau_context *nv,
|
|||
BEGIN_RING(NvCtxSurf2D, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
|
||||
OUT_RING (cs2d_format);
|
||||
OUT_RING (((dst->pitch * dst->cpp) << 16) | (dst->pitch * dst->cpp));
|
||||
OUT_RELOCl(dst->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(dst->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(dst->buffer, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(dst->buffer, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
|
||||
BEGIN_RING(NvGdiRect, NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT, 1);
|
||||
OUT_RING (gdirect_format);
|
||||
|
|
@ -176,17 +172,16 @@ nv04_region_fill(struct nouveau_context *nv,
|
|||
}
|
||||
|
||||
static int
|
||||
nv04_region_data(struct nouveau_context *nv, struct pipe_region *dst,
|
||||
unsigned dst_offset, unsigned dx, unsigned dy,
|
||||
const void *src, unsigned src_pitch,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
nv04_surface_data(struct nouveau_context *nv, struct pipe_surface *dst,
|
||||
unsigned dx, unsigned dy, const void *src, unsigned src_pitch,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
{
|
||||
NOUVEAU_ERR("unimplemented!!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nouveau_region_init_nv04(struct nouveau_context *nv)
|
||||
nouveau_surface_init_nv04(struct nouveau_context *nv)
|
||||
{
|
||||
unsigned class;
|
||||
int ret;
|
||||
|
|
@ -239,11 +234,11 @@ nouveau_region_init_nv04(struct nouveau_context *nv)
|
|||
BEGIN_RING(NvGdiRect, NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT, 1);
|
||||
OUT_RING (NV04_GDI_RECTANGLE_TEXT_MONOCHROME_FORMAT_LE);
|
||||
|
||||
nv->region_copy_prep = nv04_region_copy_prep;
|
||||
nv->region_copy = nv04_region_copy_blit;
|
||||
nv->region_copy_done = nv04_region_copy_done;
|
||||
nv->region_fill = nv04_region_fill;
|
||||
nv->region_data = nv04_region_data;
|
||||
nv->surface_copy_prep = nv04_surface_copy_prep;
|
||||
nv->surface_copy = nv04_surface_copy_blit;
|
||||
nv->surface_copy_done = nv04_surface_copy_done;
|
||||
nv->surface_fill = nv04_surface_fill;
|
||||
nv->surface_data = nv04_surface_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -16,9 +16,8 @@ nv50_format(int cpp)
|
|||
}
|
||||
|
||||
static int
|
||||
nv50_region_copy_prep(struct nouveau_context *nv,
|
||||
struct pipe_region *dst, unsigned dst_offset,
|
||||
struct pipe_region *src, unsigned src_offset)
|
||||
nv50_surface_copy_prep(struct nouveau_context *nv,
|
||||
struct pipe_surface *dst, struct pipe_surface *src)
|
||||
{
|
||||
int surf_format;
|
||||
|
||||
|
|
@ -38,8 +37,8 @@ nv50_region_copy_prep(struct nouveau_context *nv,
|
|||
OUT_RING (dst->pitch * dst->cpp);
|
||||
OUT_RING (dst->pitch);
|
||||
OUT_RING (dst->height);
|
||||
OUT_RELOCh(dst->buffer, dst_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(dst->buffer, dst_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCh(dst->buffer, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(dst->buffer, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(Nv2D, NV50_2D_CLIP_X, 4);
|
||||
OUT_RING (0);
|
||||
OUT_RING (0);
|
||||
|
|
@ -53,15 +52,15 @@ nv50_region_copy_prep(struct nouveau_context *nv,
|
|||
OUT_RING (src->pitch * src->cpp);
|
||||
OUT_RING (src->pitch);
|
||||
OUT_RING (src->height);
|
||||
OUT_RELOCh(src->buffer, src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCl(src->buffer, src_offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCh(src->buffer, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
OUT_RELOCl(src->buffer, src->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_region_copy(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
nv50_surface_copy(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
{
|
||||
BEGIN_RING(Nv2D, 0x0110, 1);
|
||||
OUT_RING (0);
|
||||
|
|
@ -81,7 +80,7 @@ nv50_region_copy(struct nouveau_context *nv, unsigned dx, unsigned dy,
|
|||
}
|
||||
|
||||
static void
|
||||
nv50_region_copy_done(struct nouveau_context *nv)
|
||||
nv50_surface_copy_done(struct nouveau_context *nv)
|
||||
{
|
||||
nouveau_notifier_reset(nv->sync_notifier, 0);
|
||||
BEGIN_RING(Nv2D, 0x104, 1);
|
||||
|
|
@ -93,10 +92,9 @@ nv50_region_copy_done(struct nouveau_context *nv)
|
|||
}
|
||||
|
||||
static int
|
||||
nv50_region_fill(struct nouveau_context *nv,
|
||||
struct pipe_region *dst, unsigned dst_offset,
|
||||
unsigned dx, unsigned dy, unsigned w, unsigned h,
|
||||
unsigned value)
|
||||
nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
|
||||
unsigned dx, unsigned dy, unsigned w, unsigned h,
|
||||
unsigned value)
|
||||
{
|
||||
int surf_format, rect_format;
|
||||
|
||||
|
|
@ -117,8 +115,8 @@ nv50_region_fill(struct nouveau_context *nv,
|
|||
OUT_RING (dst->pitch * dst->cpp);
|
||||
OUT_RING (dst->pitch);
|
||||
OUT_RING (dst->height);
|
||||
OUT_RELOCh(dst->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(dst->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCh(dst->buffer, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(dst->buffer, dst->offset, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(Nv2D, NV50_2D_CLIP_X, 4);
|
||||
OUT_RING (0);
|
||||
OUT_RING (0);
|
||||
|
|
@ -148,17 +146,16 @@ nv50_region_fill(struct nouveau_context *nv,
|
|||
}
|
||||
|
||||
static int
|
||||
nv50_region_data(struct nouveau_context *nv, struct pipe_region *dst,
|
||||
unsigned dst_offset, unsigned dx, unsigned dy,
|
||||
const void *src, unsigned src_pitch,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
nv50_surface_data(struct nouveau_context *nv, struct pipe_surface *dst,
|
||||
unsigned dx, unsigned dy, const void *src, unsigned src_pitch,
|
||||
unsigned sx, unsigned sy, unsigned w, unsigned h)
|
||||
{
|
||||
NOUVEAU_ERR("unimplemented!!\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
int
|
||||
nouveau_region_init_nv50(struct nouveau_context *nv)
|
||||
nouveau_surface_init_nv50(struct nouveau_context *nv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
|
|
@ -175,11 +172,11 @@ nouveau_region_init_nv50(struct nouveau_context *nv)
|
|||
BEGIN_RING(Nv2D, NV50_2D_OPERATION, 1);
|
||||
OUT_RING (NV50_2D_OPERATION_SRCCOPY);
|
||||
|
||||
nv->region_copy_prep = nv50_region_copy_prep;
|
||||
nv->region_copy = nv50_region_copy;
|
||||
nv->region_copy_done = nv50_region_copy_done;
|
||||
nv->region_fill = nv50_region_fill;
|
||||
nv->region_data = nv50_region_data;
|
||||
nv->surface_copy_prep = nv50_surface_copy_prep;
|
||||
nv->surface_copy = nv50_surface_copy;
|
||||
nv->surface_copy_done = nv50_surface_copy_done;
|
||||
nv->surface_fill = nv50_surface_fill;
|
||||
nv->surface_data = nv50_surface_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
@ -53,15 +53,14 @@ struct nouveau_winsys {
|
|||
int (*notifier_wait)(struct nouveau_notifier *, int id,
|
||||
int status, int timeout);
|
||||
|
||||
int (*region_copy)(struct nouveau_winsys *, struct pipe_region *,
|
||||
unsigned, unsigned, unsigned, struct pipe_region *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||
int (*region_fill)(struct nouveau_winsys *, struct pipe_region *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned,
|
||||
unsigned);
|
||||
int (*region_data)(struct nouveau_winsys *, struct pipe_region *,
|
||||
unsigned, unsigned, unsigned, const void *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||
int (*surface_copy)(struct nouveau_winsys *, struct pipe_surface *,
|
||||
unsigned, unsigned, struct pipe_surface *,
|
||||
unsigned, unsigned, unsigned, unsigned);
|
||||
int (*surface_fill)(struct nouveau_winsys *, struct pipe_surface *,
|
||||
unsigned, unsigned, unsigned, unsigned, unsigned);
|
||||
int (*surface_data)(struct nouveau_winsys *, struct pipe_surface *,
|
||||
unsigned, unsigned, const void *, unsigned,
|
||||
unsigned, unsigned, unsigned, unsigned);
|
||||
};
|
||||
|
||||
extern struct pipe_context *
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ DRIVER_SOURCES = \
|
|||
nv40_fragprog.c \
|
||||
nv40_miptree.c \
|
||||
nv40_query.c \
|
||||
nv40_region.c \
|
||||
nv40_state.c \
|
||||
nv40_state_emit.c \
|
||||
nv40_state_tex.c \
|
||||
|
|
|
|||
|
|
@ -10,6 +10,5 @@ void
|
|||
nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
unsigned clearValue)
|
||||
{
|
||||
pipe->region_fill(pipe, ps->region, 0, 0, 0, ps->width, ps->height,
|
||||
clearValue);
|
||||
pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,9 +10,9 @@ static boolean
|
|||
nv40_is_format_supported(struct pipe_context *pipe, uint format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_U_A8_R8_G8_B8:
|
||||
case PIPE_FORMAT_U_R5_G6_B5:
|
||||
case PIPE_FORMAT_Z24_S8:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -267,17 +267,12 @@ nv40_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
|
|||
nv40->pipe.draw_elements = nv40_draw_elements;
|
||||
nv40->pipe.clear = nv40_clear;
|
||||
|
||||
nv40->pipe.begin_query = nv40_query_begin;
|
||||
nv40->pipe.end_query = nv40_query_end;
|
||||
nv40->pipe.wait_query = nv40_query_wait;
|
||||
|
||||
nv40->pipe.mipmap_tree_layout = nv40_miptree_layout;
|
||||
|
||||
nv40->pipe.flush = nv40_flush;
|
||||
|
||||
nv40_init_region_functions(nv40);
|
||||
nv40_init_query_functions(nv40);
|
||||
nv40_init_surface_functions(nv40);
|
||||
nv40_init_state_functions(nv40);
|
||||
nv40_init_miptree_functions(nv40);
|
||||
|
||||
nv40->draw = draw_create();
|
||||
assert(nv40->draw);
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ struct nv40_context {
|
|||
uint32_t dirty;
|
||||
|
||||
struct nv40_sampler_state *tex_sampler[PIPE_MAX_SAMPLERS];
|
||||
struct pipe_mipmap_tree *tex_miptree[PIPE_MAX_SAMPLERS];
|
||||
struct pipe_texture *tex_miptree[PIPE_MAX_SAMPLERS];
|
||||
uint32_t tex_dirty;
|
||||
|
||||
struct {
|
||||
|
|
@ -66,17 +66,14 @@ struct nv40_context {
|
|||
};
|
||||
|
||||
|
||||
extern void nv40_init_region_functions(struct nv40_context *nv40);
|
||||
extern void nv40_init_surface_functions(struct nv40_context *nv40);
|
||||
extern void nv40_init_state_functions(struct nv40_context *nv40);
|
||||
extern void nv40_init_surface_functions(struct nv40_context *nv40);
|
||||
extern void nv40_init_miptree_functions(struct nv40_context *nv40);
|
||||
extern void nv40_init_query_functions(struct nv40_context *nv40);
|
||||
|
||||
/* nv40_draw.c */
|
||||
extern struct draw_stage *nv40_draw_render_stage(struct nv40_context *nv40);
|
||||
|
||||
/* nv40_miptree.c */
|
||||
extern boolean nv40_miptree_layout(struct pipe_context *,
|
||||
struct pipe_mipmap_tree *);
|
||||
|
||||
/* nv40_vertprog.c */
|
||||
extern void nv40_vertprog_translate(struct nv40_context *,
|
||||
struct nv40_vertex_program *);
|
||||
|
|
@ -107,9 +104,4 @@ extern void nv40_vbo_arrays_update(struct nv40_context *nv40);
|
|||
extern void nv40_clear(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
unsigned clearValue);
|
||||
|
||||
/* nv40_query.c */
|
||||
extern void nv40_query_begin(struct pipe_context *, struct pipe_query_object *);
|
||||
extern void nv40_query_end(struct pipe_context *, struct pipe_query_object *);
|
||||
extern void nv40_query_wait(struct pipe_context *, struct pipe_query_object *);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,63 +4,105 @@
|
|||
|
||||
#include "nv40_context.h"
|
||||
|
||||
boolean
|
||||
nv40_miptree_layout(struct pipe_context *pipe, struct pipe_mipmap_tree *mt)
|
||||
static void
|
||||
nv40_miptree_layout(struct nv40_miptree *nv40mt)
|
||||
{
|
||||
struct pipe_texture *pt = &nv40mt->base;
|
||||
boolean swizzled = FALSE;
|
||||
uint width = mt->width0, height = mt->height0, depth = mt->depth0;
|
||||
uint offset;
|
||||
uint width = pt->width[0], height = pt->height[0], depth = pt->depth[0];
|
||||
uint offset = 0;
|
||||
int nr_faces, l, f;
|
||||
|
||||
mt->pitch = mt->width0;
|
||||
mt->total_height = 0;
|
||||
|
||||
if (mt->target == PIPE_TEXTURE_CUBE) {
|
||||
if (pt->target == PIPE_TEXTURE_CUBE) {
|
||||
nr_faces = 6;
|
||||
} else
|
||||
if (mt->target == PIPE_TEXTURE_3D) {
|
||||
nr_faces = mt->depth0;
|
||||
if (pt->target == PIPE_TEXTURE_3D) {
|
||||
nr_faces = pt->depth[0];
|
||||
} else {
|
||||
nr_faces = 1;
|
||||
}
|
||||
|
||||
for (l = pt->first_level; l <= pt->last_level; l++) {
|
||||
pt->width[l] = width;
|
||||
pt->height[l] = height;
|
||||
pt->depth[l] = depth;
|
||||
|
||||
for (l = mt->first_level; l <= mt->last_level; l++) {
|
||||
mt->level[l].width = width;
|
||||
mt->level[l].height = height;
|
||||
mt->level[l].depth = depth;
|
||||
mt->level[l].level_offset = 0;
|
||||
if (swizzled)
|
||||
nv40mt->level[l].pitch = pt->width[l] * pt->cpp;
|
||||
else
|
||||
nv40mt->level[l].pitch = pt->width[0] * pt->cpp;
|
||||
nv40mt->level[l].pitch = (nv40mt->level[l].pitch + 63) & ~63;
|
||||
|
||||
mt->level[l].nr_images = nr_faces;
|
||||
mt->level[l].image_offset = malloc(nr_faces * sizeof(unsigned));
|
||||
for (f = 0; f < nr_faces; f++)
|
||||
mt->total_height += height;
|
||||
nv40mt->level[l].image_offset =
|
||||
calloc(nr_faces, sizeof(unsigned));
|
||||
|
||||
width = MAX2(1, width >> 1);
|
||||
height = MAX2(1, height >> 1);
|
||||
depth = MAX2(1, depth >> 1);
|
||||
|
||||
}
|
||||
|
||||
offset = 0;
|
||||
for (f = 0; f < nr_faces; f++) {
|
||||
for (l = mt->first_level; l <= mt->last_level; l++) {
|
||||
if (f == 0) {
|
||||
mt->level[l].level_offset = offset;
|
||||
}
|
||||
|
||||
uint pitch;
|
||||
|
||||
if (swizzled)
|
||||
pitch = mt->level[l].width * mt->cpp;
|
||||
else
|
||||
pitch = mt->width0 * mt->cpp;
|
||||
pitch = (pitch + 63) & ~63;
|
||||
|
||||
mt->level[l].image_offset[f] =
|
||||
(offset - mt->level[l].level_offset) / mt->cpp;
|
||||
offset += pitch * mt->level[l].height;
|
||||
for (l = pt->first_level; l <= pt->last_level; l++) {
|
||||
nv40mt->level[l].image_offset[f] = offset;
|
||||
offset += nv40mt->level[l].pitch * pt->height[l];
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
nv40mt->total_size = offset;
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_miptree_create(struct pipe_context *pipe, struct pipe_texture **pt)
|
||||
{
|
||||
struct pipe_texture *mt = *pt;
|
||||
struct pipe_winsys *ws = pipe->winsys;
|
||||
struct nv40_miptree *nv40mt;
|
||||
|
||||
*pt = NULL;
|
||||
|
||||
nv40mt = calloc(1, sizeof(struct nv40_miptree));
|
||||
if (!nv40mt)
|
||||
return;
|
||||
|
||||
memcpy(&nv40mt->base, mt, sizeof(struct pipe_texture));
|
||||
nv40_miptree_layout(nv40mt);
|
||||
|
||||
nv40mt->buffer = ws->buffer_create(ws, PIPE_SURFACE_FLAG_TEXTURE);
|
||||
if (!nv40mt->buffer) {
|
||||
free(nv40mt);
|
||||
return;
|
||||
}
|
||||
|
||||
ws->buffer_data(ws, nv40mt->buffer, nv40mt->total_size, NULL,
|
||||
PIPE_BUFFER_USAGE_PIXEL);
|
||||
*pt = &nv40mt->base;
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_miptree_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
||||
{
|
||||
struct pipe_winsys *ws = pipe->winsys;
|
||||
struct pipe_texture *mt = *pt;
|
||||
|
||||
*pt = NULL;
|
||||
if (--mt->refcount <= 0) {
|
||||
struct nv40_miptree *nv40mt = (struct nv40_miptree *)mt;
|
||||
int l;
|
||||
|
||||
ws->buffer_reference(ws, &nv40mt->buffer, NULL);
|
||||
for (l = 0; l < PIPE_MAX_TEXTURE_LEVELS; l++) {
|
||||
if (nv40mt->level[l].image_offset)
|
||||
free(nv40mt->level[l].image_offset);
|
||||
}
|
||||
free(nv40mt);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
nv40_init_miptree_functions(struct nv40_context *nv40)
|
||||
{
|
||||
nv40->pipe.texture_create = nv40_miptree_create;
|
||||
nv40->pipe.texture_release = nv40_miptree_release;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ nv40_query_object_find(struct nv40_context *nv40, struct pipe_query_object *q)
|
|||
return -1;
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nv40_query_begin(struct pipe_context *pipe, struct pipe_query_object *q)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
|
|
@ -53,7 +53,24 @@ nv40_query_update(struct pipe_context *pipe, struct pipe_query_object *q)
|
|||
}
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nv40_query_wait(struct pipe_context *pipe, struct pipe_query_object *q)
|
||||
{
|
||||
nv40_query_update(pipe, q);
|
||||
if (!q->ready) {
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
int id;
|
||||
|
||||
id = nv40_query_object_find(nv40, q);
|
||||
assert(id >= 0);
|
||||
|
||||
nv40->nvws->notifier_wait(nv40->query, id, 0, 0);
|
||||
nv40_query_update(pipe, q);
|
||||
assert(q->ready);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_query_end(struct pipe_context *pipe, struct pipe_query_object *q)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
|
|
@ -80,19 +97,9 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query_object *q)
|
|||
}
|
||||
|
||||
void
|
||||
nv40_query_wait(struct pipe_context *pipe, struct pipe_query_object *q)
|
||||
nv40_init_query_functions(struct nv40_context *nv40)
|
||||
{
|
||||
nv40_query_update(pipe, q);
|
||||
if (!q->ready) {
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
int id;
|
||||
|
||||
id = nv40_query_object_find(nv40, q);
|
||||
assert(id >= 0);
|
||||
|
||||
nv40->nvws->notifier_wait(nv40->query, id, 0, 0);
|
||||
nv40_query_update(pipe, q);
|
||||
assert(q->ready);
|
||||
}
|
||||
nv40->pipe.begin_query = nv40_query_begin;
|
||||
nv40->pipe.end_query = nv40_query_end;
|
||||
nv40->pipe.wait_query = nv40_query_wait;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
|
||||
#include "nv40_context.h"
|
||||
#include "nv40_dma.h"
|
||||
|
||||
static ubyte *
|
||||
nv40_region_map(struct pipe_context *pipe, struct pipe_region *region)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct pipe_winsys *ws = nv40->pipe.winsys;
|
||||
|
||||
if (!region->map_refcount++) {
|
||||
region->map = ws->buffer_map(ws, region->buffer,
|
||||
PIPE_BUFFER_FLAG_WRITE |
|
||||
PIPE_BUFFER_FLAG_READ);
|
||||
}
|
||||
|
||||
return region->map;
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct pipe_winsys *ws = nv40->pipe.winsys;
|
||||
|
||||
if (!--region->map_refcount) {
|
||||
ws->buffer_unmap(ws, region->buffer);
|
||||
region->map = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_region_data(struct pipe_context *pipe,
|
||||
struct pipe_region *dst,
|
||||
unsigned dst_offset,
|
||||
unsigned dstx, unsigned dsty,
|
||||
const void *src, unsigned src_pitch,
|
||||
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv40->nvws;
|
||||
|
||||
nvws->region_data(nvws, dst, dst_offset, dstx, dsty,
|
||||
src, src_pitch, srcx, srcy, width, height);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nv40_region_copy(struct pipe_context *pipe, struct pipe_region *dst,
|
||||
unsigned dst_offset, unsigned dstx, unsigned dsty,
|
||||
struct pipe_region *src, unsigned src_offset,
|
||||
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv40->nvws;
|
||||
|
||||
nvws->region_copy(nvws, dst, dst_offset, dstx, dsty,
|
||||
src, src_offset, srcx, srcy, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_region_fill(struct pipe_context *pipe,
|
||||
struct pipe_region *dst, unsigned dst_offset,
|
||||
unsigned dstx, unsigned dsty,
|
||||
unsigned width, unsigned height, unsigned value)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv40->nvws;
|
||||
|
||||
nvws->region_fill(nvws, dst, dst_offset, dstx, dsty,
|
||||
width, height, value);
|
||||
}
|
||||
|
||||
void
|
||||
nv40_init_region_functions(struct nv40_context *nv40)
|
||||
{
|
||||
nv40->pipe.region_map = nv40_region_map;
|
||||
nv40->pipe.region_unmap = nv40_region_unmap;
|
||||
nv40->pipe.region_data = nv40_region_data;
|
||||
nv40->pipe.region_copy = nv40_region_copy;
|
||||
nv40->pipe.region_fill = nv40_region_fill;
|
||||
}
|
||||
|
||||
|
|
@ -549,7 +549,7 @@ nv40_set_framebuffer_state(struct pipe_context *pipe,
|
|||
const struct pipe_framebuffer_state *fb)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct pipe_region *region[4], *zregion;
|
||||
struct pipe_surface *rt[4], *zeta;
|
||||
uint32_t rt_enable, rt_format, w, h;
|
||||
int i, colour_format = 0, zeta_format = 0;
|
||||
|
||||
|
|
@ -567,7 +567,7 @@ nv40_set_framebuffer_state(struct pipe_context *pipe,
|
|||
h = fb->cbufs[i]->height;
|
||||
colour_format = fb->cbufs[i]->format;
|
||||
rt_enable |= (NV40TCL_RT_ENABLE_COLOR0 << i);
|
||||
region[i] = fb->cbufs[i]->region;
|
||||
rt[i] = fb->cbufs[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -585,7 +585,7 @@ nv40_set_framebuffer_state(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
zeta_format = fb->zbuf->format;
|
||||
zregion = fb->zbuf->region;
|
||||
zeta = fb->zbuf;
|
||||
}
|
||||
|
||||
if (fb->sbuf) {
|
||||
|
|
@ -599,21 +599,21 @@ nv40_set_framebuffer_state(struct pipe_context *pipe,
|
|||
|
||||
if (zeta_format) {
|
||||
assert(fb->sbuf->format == zeta_format);
|
||||
assert(fb->sbuf->region == zregion);
|
||||
assert(fb->sbuf == zeta);
|
||||
} else {
|
||||
zeta_format = fb->sbuf->format;
|
||||
zregion = fb->sbuf->region;
|
||||
zeta = fb->sbuf;
|
||||
}
|
||||
}
|
||||
|
||||
rt_format = NV40TCL_RT_FORMAT_TYPE_LINEAR;
|
||||
|
||||
switch (colour_format) {
|
||||
case PIPE_FORMAT_U_A8_R8_G8_B8:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
case 0:
|
||||
rt_format |= NV40TCL_RT_FORMAT_COLOR_A8R8G8B8;
|
||||
break;
|
||||
case PIPE_FORMAT_U_R5_G6_B5:
|
||||
case PIPE_FORMAT_R5G6B5_UNORM:
|
||||
rt_format |= NV40TCL_RT_FORMAT_COLOR_R5G6B5;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -621,13 +621,12 @@ nv40_set_framebuffer_state(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
switch (zeta_format) {
|
||||
case PIPE_FORMAT_U_Z16:
|
||||
case PIPE_FORMAT_Z16_UNORM:
|
||||
rt_format |= NV40TCL_RT_FORMAT_ZETA_Z16;
|
||||
break;
|
||||
case PIPE_FORMAT_Z24_S8:
|
||||
rt_format |= NV40TCL_RT_FORMAT_ZETA_Z24S8;
|
||||
break;
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
case 0:
|
||||
rt_format |= NV40TCL_RT_FORMAT_ZETA_Z24S8;
|
||||
break;
|
||||
default:
|
||||
assert(0);
|
||||
|
|
@ -635,51 +634,47 @@ nv40_set_framebuffer_state(struct pipe_context *pipe,
|
|||
|
||||
if (rt_enable & NV40TCL_RT_ENABLE_COLOR0) {
|
||||
BEGIN_RING(curie, NV40TCL_DMA_COLOR0, 1);
|
||||
OUT_RELOCo(region[0]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCo(rt[0]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(curie, NV40TCL_COLOR0_PITCH, 2);
|
||||
OUT_RING (region[0]->pitch * region[0]->cpp);
|
||||
OUT_RELOCl(region[0]->buffer, 0,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RING (rt[0]->pitch * rt[0]->cpp);
|
||||
OUT_RELOCl(rt[0]->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
}
|
||||
|
||||
if (rt_enable & NV40TCL_RT_ENABLE_COLOR1) {
|
||||
BEGIN_RING(curie, NV40TCL_DMA_COLOR1, 1);
|
||||
OUT_RELOCo(region[1]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCo(rt[1]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(curie, NV40TCL_COLOR1_OFFSET, 2);
|
||||
OUT_RELOCl(region[1]->buffer, 0,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RING (region[1]->pitch * region[1]->cpp);
|
||||
OUT_RELOCl(rt[1]->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RING (rt[1]->pitch * rt[1]->cpp);
|
||||
}
|
||||
|
||||
if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
|
||||
BEGIN_RING(curie, NV40TCL_DMA_COLOR2, 1);
|
||||
OUT_RELOCo(region[2]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCo(rt[2]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(curie, NV40TCL_COLOR2_OFFSET, 1);
|
||||
OUT_RELOCl(region[2]->buffer, 0,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(rt[2]->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(curie, NV40TCL_COLOR2_PITCH, 1);
|
||||
OUT_RING (region[2]->pitch * region[2]->cpp);
|
||||
OUT_RING (rt[2]->pitch * rt[2]->cpp);
|
||||
}
|
||||
|
||||
if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
|
||||
BEGIN_RING(curie, NV40TCL_DMA_COLOR3, 1);
|
||||
OUT_RELOCo(region[3]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCo(rt[3]->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(curie, NV40TCL_COLOR3_OFFSET, 1);
|
||||
OUT_RELOCl(region[3]->buffer, 0,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
OUT_RELOCl(rt[3]->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
|
||||
BEGIN_RING(curie, NV40TCL_COLOR3_PITCH, 1);
|
||||
OUT_RING (region[3]->pitch * region[3]->cpp);
|
||||
OUT_RING (rt[3]->pitch * rt[3]->cpp);
|
||||
}
|
||||
|
||||
if (zeta_format) {
|
||||
BEGIN_RING(curie, NV40TCL_DMA_ZETA, 1);
|
||||
OUT_RELOCo(zregion->buffer,
|
||||
OUT_RELOCo(zeta->buffer,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR | NOUVEAU_BO_RD);
|
||||
BEGIN_RING(curie, NV40TCL_ZETA_OFFSET, 1);
|
||||
OUT_RELOCl(zregion->buffer, 0,
|
||||
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR | NOUVEAU_BO_RD);
|
||||
OUT_RELOCl(zeta->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_WR |
|
||||
NOUVEAU_BO_RD);
|
||||
BEGIN_RING(curie, NV40TCL_ZETA_PITCH, 1);
|
||||
OUT_RING (zregion->pitch * zregion->cpp);
|
||||
OUT_RING (zeta->pitch * zeta->cpp);
|
||||
}
|
||||
|
||||
BEGIN_RING(curie, NV40TCL_RT_ENABLE, 1);
|
||||
|
|
@ -725,7 +720,7 @@ nv40_set_scissor_state(struct pipe_context *pipe,
|
|||
|
||||
static void
|
||||
nv40_set_texture_state(struct pipe_context *pipe, unsigned unit,
|
||||
struct pipe_mipmap_tree *miptree)
|
||||
struct pipe_texture *miptree)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
|
||||
|
|
|
|||
|
|
@ -124,4 +124,16 @@ struct nv40_depth_stencil_state {
|
|||
} stencil;
|
||||
};
|
||||
|
||||
struct nv40_miptree {
|
||||
struct pipe_texture base;
|
||||
|
||||
struct pipe_buffer_handle *buffer;
|
||||
uint total_size;
|
||||
|
||||
struct {
|
||||
uint pitch;
|
||||
uint *image_offset;
|
||||
} level[PIPE_MAX_TEXTURE_LEVELS];
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -21,18 +21,18 @@ struct nv40_texture_format {
|
|||
|
||||
static struct nv40_texture_format
|
||||
nv40_texture_formats[] = {
|
||||
_(U_A8_R8_G8_B8, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W),
|
||||
_(U_A1_R5_G5_B5, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W),
|
||||
_(U_A4_R4_G4_B4, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W),
|
||||
_(U_R5_G6_B5 , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W),
|
||||
_(U_L8 , L8 , S1, S1, S1, ONE, X, X, X, X),
|
||||
_(U_A8 , L8 , ZERO, ZERO, ZERO, S1, X, X, X, X),
|
||||
_(U_I8 , L8 , S1, S1, S1, S1, X, X, X, X),
|
||||
_(U_A8_L8 , A8L8 , S1, S1, S1, S1, Z, W, X, Y),
|
||||
// _(RGB_DXT1 , 0x86, S1, S1, S1, ONE, X, Y, Z, W, 0x00, 0x00),
|
||||
// _(RGBA_DXT1 , 0x86, S1, S1, S1, S1, X, Y, Z, W, 0x00, 0x00),
|
||||
// _(RGBA_DXT3 , 0x87, S1, S1, S1, S1, X, Y, Z, W, 0x00, 0x00),
|
||||
// _(RGBA_DXT5 , 0x88, S1, S1, S1, S1, X, Y, Z, W, 0x00, 0x00),
|
||||
_(A8R8G8B8_UNORM, A8R8G8B8, S1, S1, S1, S1, X, Y, Z, W),
|
||||
_(A1R5G5B5_UNORM, A1R5G5B5, S1, S1, S1, S1, X, Y, Z, W),
|
||||
_(A4R4G4B4_UNORM, A4R4G4B4, S1, S1, S1, S1, X, Y, Z, W),
|
||||
_(R5G6B5_UNORM , R5G6B5 , S1, S1, S1, ONE, X, Y, Z, W),
|
||||
_(U_L8 , L8 , S1, S1, S1, ONE, X, X, X, X),
|
||||
_(U_A8 , L8 , ZERO, ZERO, ZERO, S1, X, X, X, X),
|
||||
_(U_I8 , L8 , S1, S1, S1, S1, X, X, X, X),
|
||||
_(U_A8_L8 , A8L8 , S1, S1, S1, S1, Z, W, X, Y),
|
||||
// _(RGB_DXT1 , 0x86, S1, S1, S1, ONE, X, Y, Z, W, 0x00, 0x00),
|
||||
// _(RGBA_DXT1 , 0x86, S1, S1, S1, S1, X, Y, Z, W, 0x00, 0x00),
|
||||
// _(RGBA_DXT3 , 0x87, S1, S1, S1, S1, X, Y, Z, W, 0x00, 0x00),
|
||||
// _(RGBA_DXT5 , 0x88, S1, S1, S1, S1, X, Y, Z, W, 0x00, 0x00),
|
||||
{},
|
||||
};
|
||||
|
||||
|
|
@ -50,30 +50,32 @@ nv40_tex_format(uint pipe_format)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nv40_tex_unit_enable(struct nv40_context *nv40, int unit)
|
||||
{
|
||||
struct nv40_sampler_state *ps = nv40->tex_sampler[unit];
|
||||
struct pipe_mipmap_tree *mt = nv40->tex_miptree[unit];
|
||||
struct pipe_texture *pt = nv40->tex_miptree[unit];
|
||||
struct nv40_miptree *nv40mt = (struct nv40_miptree *)pt;
|
||||
struct nv40_texture_format *tf;
|
||||
uint32_t txf, txs, txp;
|
||||
int swizzled = 0; /*XXX: implement in region code? */
|
||||
|
||||
tf = nv40_tex_format(mt->format);
|
||||
tf = nv40_tex_format(pt->format);
|
||||
if (!tf || !tf->defined) {
|
||||
NOUVEAU_ERR("Unsupported texture format: 0x%x\n", mt->format);
|
||||
NOUVEAU_ERR("Unsupported texture format: 0x%x\n", pt->format);
|
||||
return;
|
||||
}
|
||||
|
||||
txf = ps->fmt;
|
||||
txf |= tf->format | 0x8000;
|
||||
txf |= ((mt->last_level - mt->first_level + 1) <<
|
||||
txf |= ((pt->last_level - pt->first_level + 1) <<
|
||||
NV40TCL_TEX_FORMAT_MIPMAP_COUNT_SHIFT);
|
||||
|
||||
if (1) /* XXX */
|
||||
txf |= NV40TCL_TEX_FORMAT_NO_BORDER;
|
||||
|
||||
switch (mt->target) {
|
||||
switch (pt->target) {
|
||||
case PIPE_TEXTURE_CUBE:
|
||||
txf |= NV40TCL_TEX_FORMAT_CUBIC;
|
||||
/* fall-through */
|
||||
|
|
@ -87,25 +89,25 @@ nv40_tex_unit_enable(struct nv40_context *nv40, int unit)
|
|||
txf |= NV40TCL_TEX_FORMAT_DIMS_1D;
|
||||
break;
|
||||
default:
|
||||
NOUVEAU_ERR("Unknown target %d\n", mt->target);
|
||||
NOUVEAU_ERR("Unknown target %d\n", pt->target);
|
||||
return;
|
||||
}
|
||||
|
||||
if (swizzled) {
|
||||
txp = 0;
|
||||
} else {
|
||||
txp = mt->pitch * mt->cpp;
|
||||
txp = nv40mt->level[0].pitch;
|
||||
txf |= NV40TCL_TEX_FORMAT_LINEAR;
|
||||
}
|
||||
|
||||
txs = tf->swizzle;
|
||||
if (mt->format == PIPE_FORMAT_U_A8_L8)
|
||||
if (pt->format == PIPE_FORMAT_U_A8_L8)
|
||||
txs |= (1<<16); /*nfi*/
|
||||
|
||||
BEGIN_RING(curie, NV40TCL_TEX_OFFSET(unit), 8);
|
||||
OUT_RELOCl(mt->region->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
|
||||
OUT_RELOCl(nv40mt->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
|
||||
NOUVEAU_BO_RD);
|
||||
OUT_RELOCd(mt->region->buffer, txf, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
|
||||
OUT_RELOCd(nv40mt->buffer, txf, NOUVEAU_BO_VRAM | NOUVEAU_BO_GART |
|
||||
NOUVEAU_BO_OR | NOUVEAU_BO_RD, NV40TCL_TEX_FORMAT_DMA0,
|
||||
NV40TCL_TEX_FORMAT_DMA1);
|
||||
OUT_RING (ps->wrap);
|
||||
|
|
@ -113,10 +115,10 @@ nv40_tex_unit_enable(struct nv40_context *nv40, int unit)
|
|||
(0x00078000) /* mipmap related? */);
|
||||
OUT_RING (txs);
|
||||
OUT_RING (ps->filt | 0x3fd6 /*voodoo*/);
|
||||
OUT_RING ((mt->width0 << NV40TCL_TEX_SIZE0_W_SHIFT) | mt->height0);
|
||||
OUT_RING ((pt->width[0] << NV40TCL_TEX_SIZE0_W_SHIFT) | pt->height[0]);
|
||||
OUT_RING (ps->bcol);
|
||||
BEGIN_RING(curie, NV40TCL_TEX_SIZE1(unit), 1);
|
||||
OUT_RING ((mt->depth0 << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
|
||||
OUT_RING ((pt->depth[0] << NV40TCL_TEX_SIZE1_DEPTH_SHIFT) | txp);
|
||||
}
|
||||
|
||||
void
|
||||
|
|
|
|||
|
|
@ -56,15 +56,15 @@ nv40_get_tile_rgba(struct pipe_context *pipe,
|
|||
uint x, uint y, uint w, uint h, float *p)
|
||||
{
|
||||
const unsigned *src
|
||||
= ((const unsigned *) (ps->region->map + ps->offset))
|
||||
+ y * ps->region->pitch + x;
|
||||
= ((const unsigned *) (ps->map + ps->offset))
|
||||
+ y * ps->pitch + x;
|
||||
unsigned i, j;
|
||||
unsigned w0 = w;
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
switch (ps->format) {
|
||||
case PIPE_FORMAT_U_A8_R8_G8_B8:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++) {
|
||||
|
|
@ -75,11 +75,11 @@ nv40_get_tile_rgba(struct pipe_context *pipe,
|
|||
pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
|
||||
pRow += 4;
|
||||
}
|
||||
src += ps->region->pitch;
|
||||
src += ps->pitch;
|
||||
p += w0 * 4;
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24_S8:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
{
|
||||
const float scale = 1.0 / (float) 0xffffff;
|
||||
for (i = 0; i < h; i++) {
|
||||
|
|
@ -92,7 +92,7 @@ nv40_get_tile_rgba(struct pipe_context *pipe,
|
|||
pRow[3] = ((pixel & 0xffffff) >> 8) * scale;
|
||||
pRow += 4;
|
||||
}
|
||||
src += ps->region->pitch;
|
||||
src += ps->pitch;
|
||||
p += w0 * 4;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,13 +122,13 @@ nv40_get_tile(struct pipe_context *pipe,
|
|||
uint x, uint y, uint w, uint h,
|
||||
void *p, int dst_stride)
|
||||
{
|
||||
const uint cpp = ps->region->cpp;
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->region->map);
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
|
|
@ -136,13 +136,13 @@ nv40_get_tile(struct pipe_context *pipe,
|
|||
dst_stride = w0 * cpp;
|
||||
}
|
||||
|
||||
pSrc = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
|
||||
pSrc = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
|
||||
pDest = (ubyte *) p;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += dst_stride;
|
||||
pSrc += ps->region->pitch * cpp;
|
||||
pSrc += ps->pitch * cpp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,13 +156,13 @@ nv40_put_tile(struct pipe_context *pipe,
|
|||
uint x, uint y, uint w, uint h,
|
||||
const void *p, int src_stride)
|
||||
{
|
||||
const uint cpp = ps->region->cpp;
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->region->map);
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
|
|
@ -171,52 +171,81 @@ nv40_put_tile(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
pSrc = (const ubyte *) p;
|
||||
pDest = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
|
||||
pDest = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += ps->region->pitch * cpp;
|
||||
pDest += ps->pitch * cpp;
|
||||
pSrc += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX note: same as code in sp_surface.c
|
||||
*/
|
||||
static struct pipe_surface *
|
||||
nv40_get_tex_surface(struct pipe_context *pipe,
|
||||
struct pipe_mipmap_tree *mt,
|
||||
struct pipe_texture *pt,
|
||||
unsigned face, unsigned level, unsigned zslice)
|
||||
{
|
||||
struct pipe_surface *ps;
|
||||
unsigned offset; /* in bytes */
|
||||
struct pipe_winsys *ws = pipe->winsys;
|
||||
struct nv40_miptree *nv40mt = (struct nv40_miptree *)pt;
|
||||
struct pipe_surface *ps;
|
||||
|
||||
offset = mt->level[level].level_offset;
|
||||
ps = ws->surface_alloc(ws, pt->format);
|
||||
if (!ps)
|
||||
return NULL;
|
||||
ws->buffer_reference(ws, &ps->buffer, nv40mt->buffer);
|
||||
ps->cpp = pt->cpp;
|
||||
ps->width = pt->width[level];
|
||||
ps->height = pt->height[level];
|
||||
ps->pitch = nv40mt->level[level].pitch / ps->cpp;
|
||||
|
||||
if (mt->target == PIPE_TEXTURE_CUBE) {
|
||||
offset += mt->level[level].image_offset[face] * mt->cpp;
|
||||
}
|
||||
else if (mt->target == PIPE_TEXTURE_3D) {
|
||||
offset += mt->level[level].image_offset[zslice] * mt->cpp;
|
||||
}
|
||||
else {
|
||||
assert(face == 0);
|
||||
assert(zslice == 0);
|
||||
}
|
||||
if (pt->target == PIPE_TEXTURE_CUBE) {
|
||||
ps->offset = nv40mt->level[level].image_offset[face];
|
||||
} else
|
||||
if (pt->target == PIPE_TEXTURE_3D) {
|
||||
ps->offset = nv40mt->level[level].image_offset[zslice];
|
||||
} else {
|
||||
ps->offset = nv40mt->level[level].image_offset[0];
|
||||
}
|
||||
|
||||
ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format);
|
||||
if (ps) {
|
||||
assert(ps->format);
|
||||
assert(ps->refcount);
|
||||
pipe_region_reference(&ps->region, mt->region);
|
||||
ps->width = mt->level[level].width;
|
||||
ps->height = mt->level[level].height;
|
||||
ps->offset = offset;
|
||||
}
|
||||
return ps;
|
||||
return ps;
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_surface_data(struct pipe_context *pipe, struct pipe_surface *dest,
|
||||
unsigned destx, unsigned desty, const void *src,
|
||||
unsigned src_stride, unsigned srcx, unsigned srcy,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv40->nvws;
|
||||
|
||||
nvws->surface_data(nvws, dest, destx, desty, src, src_stride,
|
||||
srcx, srcy, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_surface_copy(struct pipe_context *pipe, struct pipe_surface *dest,
|
||||
unsigned destx, unsigned desty, struct pipe_surface *src,
|
||||
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv40->nvws;
|
||||
|
||||
nvws->surface_copy(nvws, dest, destx, desty, src, srcx, srcy,
|
||||
width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
nv40_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
|
||||
unsigned destx, unsigned desty, unsigned width,
|
||||
unsigned height, unsigned value)
|
||||
{
|
||||
struct nv40_context *nv40 = (struct nv40_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv40->nvws;
|
||||
|
||||
nvws->surface_fill(nvws, dest, destx, desty, width, height, value);
|
||||
}
|
||||
|
||||
void
|
||||
nv40_init_surface_functions(struct nv40_context *nv40)
|
||||
|
|
@ -226,4 +255,7 @@ nv40_init_surface_functions(struct nv40_context *nv40)
|
|||
nv40->pipe.put_tile = nv40_put_tile;
|
||||
nv40->pipe.get_tile_rgba = nv40_get_tile_rgba;
|
||||
nv40->pipe.put_tile_rgba = nv40_put_tile_rgba;
|
||||
nv40->pipe.surface_data = nv40_surface_data;
|
||||
nv40->pipe.surface_copy = nv40_surface_copy;
|
||||
nv40->pipe.surface_fill = nv40_surface_fill;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,6 @@ DRIVER_SOURCES = \
|
|||
nv50_draw.c \
|
||||
nv50_miptree.c \
|
||||
nv50_query.c \
|
||||
nv50_region.c \
|
||||
nv50_state.c \
|
||||
nv50_surface.c \
|
||||
nv50_vbo.c
|
||||
|
|
|
|||
|
|
@ -10,6 +10,5 @@ void
|
|||
nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
unsigned clearValue)
|
||||
{
|
||||
pipe->region_fill(pipe, ps->region, 0, 0, 0, ps->width, ps->height,
|
||||
clearValue);
|
||||
pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ static boolean
|
|||
nv50_is_format_supported(struct pipe_context *pipe, uint format)
|
||||
{
|
||||
switch (format) {
|
||||
case PIPE_FORMAT_U_A8_R8_G8_B8:
|
||||
case PIPE_FORMAT_Z24_S8:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
return TRUE;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -193,17 +193,12 @@ nv50_create(struct pipe_winsys *pipe_winsys, struct nouveau_winsys *nvws,
|
|||
nv50->pipe.draw_elements = nv50_draw_elements;
|
||||
nv50->pipe.clear = nv50_clear;
|
||||
|
||||
nv50->pipe.begin_query = nv50_query_begin;
|
||||
nv50->pipe.end_query = nv50_query_end;
|
||||
nv50->pipe.wait_query = nv50_query_wait;
|
||||
|
||||
nv50->pipe.mipmap_tree_layout = nv50_miptree_layout;
|
||||
|
||||
nv50->pipe.flush = nv50_flush;
|
||||
|
||||
nv50_init_region_functions(nv50);
|
||||
nv50_init_miptree_functions(nv50);
|
||||
nv50_init_surface_functions(nv50);
|
||||
nv50_init_state_functions(nv50);
|
||||
nv50_init_query_functions(nv50);
|
||||
|
||||
nv50->draw = draw_create();
|
||||
assert(nv50->draw);
|
||||
|
|
|
|||
|
|
@ -30,16 +30,14 @@ struct nv50_context {
|
|||
};
|
||||
|
||||
|
||||
extern void nv50_init_region_functions(struct nv50_context *nv50);
|
||||
extern void nv50_init_miptree_functions(struct nv50_context *nv50);
|
||||
extern void nv50_init_surface_functions(struct nv50_context *nv50);
|
||||
extern void nv50_init_state_functions(struct nv50_context *nv50);
|
||||
extern void nv50_init_query_functions(struct nv50_context *nv50);
|
||||
|
||||
/* nv50_draw.c */
|
||||
extern struct draw_stage *nv50_draw_render_stage(struct nv50_context *nv50);
|
||||
|
||||
/* nv50_miptree.c */
|
||||
extern boolean nv50_miptree_layout(struct pipe_context *,
|
||||
struct pipe_mipmap_tree *);
|
||||
/* nv50_vbo.c */
|
||||
extern boolean nv50_draw_arrays(struct pipe_context *, unsigned mode,
|
||||
unsigned start, unsigned count);
|
||||
|
|
@ -53,10 +51,4 @@ extern boolean nv50_draw_elements(struct pipe_context *pipe,
|
|||
extern void nv50_clear(struct pipe_context *pipe, struct pipe_surface *ps,
|
||||
unsigned clearValue);
|
||||
|
||||
/* nv50_query.c */
|
||||
extern void nv50_query_begin(struct pipe_context *, struct pipe_query_object *);
|
||||
extern void nv50_query_end(struct pipe_context *, struct pipe_query_object *);
|
||||
extern void nv50_query_wait(struct pipe_context *, struct pipe_query_object *);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -4,10 +4,21 @@
|
|||
|
||||
#include "nv50_context.h"
|
||||
|
||||
boolean
|
||||
nv50_miptree_layout(struct pipe_context *pipe, struct pipe_mipmap_tree *mt)
|
||||
static void
|
||||
nv50_miptree_create(struct pipe_context *pipe, struct pipe_texture **pt)
|
||||
{
|
||||
NOUVEAU_ERR("unimplemented\n");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_miptree_release(struct pipe_context *pipe, struct pipe_texture **pt)
|
||||
{
|
||||
NOUVEAU_ERR("unimplemented\n");
|
||||
}
|
||||
|
||||
void
|
||||
nv50_init_miptree_functions(struct nv50_context *nv50)
|
||||
{
|
||||
nv50->pipe.texture_create = nv50_miptree_create;
|
||||
nv50->pipe.texture_release = nv50_miptree_release;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,21 +3,28 @@
|
|||
#include "nv50_context.h"
|
||||
#include "nv50_dma.h"
|
||||
|
||||
void
|
||||
static void
|
||||
nv50_query_begin(struct pipe_context *pipe, struct pipe_query_object *q)
|
||||
{
|
||||
NOUVEAU_ERR("unimplemented\n");
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nv50_query_end(struct pipe_context *pipe, struct pipe_query_object *q)
|
||||
{
|
||||
NOUVEAU_ERR("unimplemented\n");
|
||||
}
|
||||
|
||||
void
|
||||
static void
|
||||
nv50_query_wait(struct pipe_context *pipe, struct pipe_query_object *q)
|
||||
{
|
||||
NOUVEAU_ERR("unimplemented\n");
|
||||
}
|
||||
|
||||
void
|
||||
nv50_init_query_functions(struct nv50_context *nv50)
|
||||
{
|
||||
nv50->pipe.begin_query = nv50_query_begin;
|
||||
nv50->pipe.end_query = nv50_query_end;
|
||||
nv50->pipe.wait_query = nv50_query_wait;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,85 +0,0 @@
|
|||
#include "pipe/p_defines.h"
|
||||
#include "pipe/p_winsys.h"
|
||||
|
||||
#include "nv50_context.h"
|
||||
#include "nv50_dma.h"
|
||||
|
||||
static ubyte *
|
||||
nv50_region_map(struct pipe_context *pipe, struct pipe_region *region)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct pipe_winsys *ws = nv50->pipe.winsys;
|
||||
|
||||
if (!region->map_refcount++) {
|
||||
region->map = ws->buffer_map(ws, region->buffer,
|
||||
PIPE_BUFFER_FLAG_WRITE |
|
||||
PIPE_BUFFER_FLAG_READ);
|
||||
}
|
||||
|
||||
return region->map;
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct pipe_winsys *ws = nv50->pipe.winsys;
|
||||
|
||||
if (!--region->map_refcount) {
|
||||
ws->buffer_unmap(ws, region->buffer);
|
||||
region->map = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_region_data(struct pipe_context *pipe,
|
||||
struct pipe_region *dst,
|
||||
unsigned dst_offset,
|
||||
unsigned dstx, unsigned dsty,
|
||||
const void *src, unsigned src_pitch,
|
||||
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv50->nvws;
|
||||
|
||||
nvws->region_data(nvws, dst, dst_offset, dstx, dsty,
|
||||
src, src_pitch, srcx, srcy, width, height);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
nv50_region_copy(struct pipe_context *pipe, struct pipe_region *dst,
|
||||
unsigned dst_offset, unsigned dstx, unsigned dsty,
|
||||
struct pipe_region *src, unsigned src_offset,
|
||||
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv50->nvws;
|
||||
|
||||
nvws->region_copy(nvws, dst, dst_offset, dstx, dsty,
|
||||
src, src_offset, srcx, srcy, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_region_fill(struct pipe_context *pipe,
|
||||
struct pipe_region *dst, unsigned dst_offset,
|
||||
unsigned dstx, unsigned dsty,
|
||||
unsigned width, unsigned height, unsigned value)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv50->nvws;
|
||||
|
||||
nvws->region_fill(nvws, dst, dst_offset, dstx, dsty,
|
||||
width, height, value);
|
||||
}
|
||||
|
||||
void
|
||||
nv50_init_region_functions(struct nv50_context *nv50)
|
||||
{
|
||||
nv50->pipe.region_map = nv50_region_map;
|
||||
nv50->pipe.region_unmap = nv50_region_unmap;
|
||||
nv50->pipe.region_data = nv50_region_data;
|
||||
nv50->pipe.region_copy = nv50_region_copy;
|
||||
nv50->pipe.region_fill = nv50_region_fill;
|
||||
}
|
||||
|
||||
|
|
@ -169,7 +169,7 @@ nv50_set_scissor_state(struct pipe_context *pipe,
|
|||
|
||||
static void
|
||||
nv50_set_texture_state(struct pipe_context *pipe, unsigned unit,
|
||||
struct pipe_mipmap_tree *miptree)
|
||||
struct pipe_texture *pt)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,15 +56,15 @@ nv50_get_tile_rgba(struct pipe_context *pipe,
|
|||
uint x, uint y, uint w, uint h, float *p)
|
||||
{
|
||||
const unsigned *src
|
||||
= ((const unsigned *) (ps->region->map + ps->offset))
|
||||
+ y * ps->region->pitch + x;
|
||||
= ((const unsigned *) (ps->map + ps->offset))
|
||||
+ y * ps->pitch + x;
|
||||
unsigned i, j;
|
||||
unsigned w0 = w;
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
switch (ps->format) {
|
||||
case PIPE_FORMAT_U_A8_R8_G8_B8:
|
||||
case PIPE_FORMAT_A8R8G8B8_UNORM:
|
||||
for (i = 0; i < h; i++) {
|
||||
float *pRow = p;
|
||||
for (j = 0; j < w; j++) {
|
||||
|
|
@ -75,11 +75,11 @@ nv50_get_tile_rgba(struct pipe_context *pipe,
|
|||
pRow[3] = UBYTE_TO_FLOAT((pixel >> 24) & 0xff);
|
||||
pRow += 4;
|
||||
}
|
||||
src += ps->region->pitch;
|
||||
src += ps->pitch;
|
||||
p += w0 * 4;
|
||||
}
|
||||
break;
|
||||
case PIPE_FORMAT_Z24_S8:
|
||||
case PIPE_FORMAT_Z24S8_UNORM:
|
||||
{
|
||||
const float scale = 1.0 / (float) 0xffffff;
|
||||
for (i = 0; i < h; i++) {
|
||||
|
|
@ -92,7 +92,7 @@ nv50_get_tile_rgba(struct pipe_context *pipe,
|
|||
pRow[3] = ((pixel & 0xffffff) >> 8) * scale;
|
||||
pRow += 4;
|
||||
}
|
||||
src += ps->region->pitch;
|
||||
src += ps->pitch;
|
||||
p += w0 * 4;
|
||||
}
|
||||
}
|
||||
|
|
@ -122,13 +122,13 @@ nv50_get_tile(struct pipe_context *pipe,
|
|||
uint x, uint y, uint w, uint h,
|
||||
void *p, int dst_stride)
|
||||
{
|
||||
const uint cpp = ps->region->cpp;
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->region->map);
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
|
|
@ -136,13 +136,13 @@ nv50_get_tile(struct pipe_context *pipe,
|
|||
dst_stride = w0 * cpp;
|
||||
}
|
||||
|
||||
pSrc = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
|
||||
pSrc = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
|
||||
pDest = (ubyte *) p;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += dst_stride;
|
||||
pSrc += ps->region->pitch * cpp;
|
||||
pSrc += ps->pitch * cpp;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -156,13 +156,13 @@ nv50_put_tile(struct pipe_context *pipe,
|
|||
uint x, uint y, uint w, uint h,
|
||||
const void *p, int src_stride)
|
||||
{
|
||||
const uint cpp = ps->region->cpp;
|
||||
const uint cpp = ps->cpp;
|
||||
const uint w0 = w;
|
||||
const ubyte *pSrc;
|
||||
ubyte *pDest;
|
||||
uint i;
|
||||
|
||||
assert(ps->region->map);
|
||||
assert(ps->map);
|
||||
|
||||
CLIP_TILE;
|
||||
|
||||
|
|
@ -171,52 +171,60 @@ nv50_put_tile(struct pipe_context *pipe,
|
|||
}
|
||||
|
||||
pSrc = (const ubyte *) p;
|
||||
pDest = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
|
||||
pDest = ps->map + ps->offset + (y * ps->pitch + x) * cpp;
|
||||
|
||||
for (i = 0; i < h; i++) {
|
||||
memcpy(pDest, pSrc, w0 * cpp);
|
||||
pDest += ps->region->pitch * cpp;
|
||||
pDest += ps->pitch * cpp;
|
||||
pSrc += src_stride;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* XXX note: same as code in sp_surface.c
|
||||
*/
|
||||
static struct pipe_surface *
|
||||
nv50_get_tex_surface(struct pipe_context *pipe,
|
||||
struct pipe_mipmap_tree *mt,
|
||||
struct pipe_texture *pt,
|
||||
unsigned face, unsigned level, unsigned zslice)
|
||||
{
|
||||
struct pipe_surface *ps;
|
||||
unsigned offset; /* in bytes */
|
||||
|
||||
offset = mt->level[level].level_offset;
|
||||
|
||||
if (mt->target == PIPE_TEXTURE_CUBE) {
|
||||
offset += mt->level[level].image_offset[face] * mt->cpp;
|
||||
}
|
||||
else if (mt->target == PIPE_TEXTURE_3D) {
|
||||
offset += mt->level[level].image_offset[zslice] * mt->cpp;
|
||||
}
|
||||
else {
|
||||
assert(face == 0);
|
||||
assert(zslice == 0);
|
||||
}
|
||||
|
||||
ps = pipe->winsys->surface_alloc(pipe->winsys, mt->format);
|
||||
if (ps) {
|
||||
assert(ps->format);
|
||||
assert(ps->refcount);
|
||||
pipe_region_reference(&ps->region, mt->region);
|
||||
ps->width = mt->level[level].width;
|
||||
ps->height = mt->level[level].height;
|
||||
ps->offset = offset;
|
||||
}
|
||||
return ps;
|
||||
NOUVEAU_ERR("unimplemented\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_surface_data(struct pipe_context *pipe, struct pipe_surface *dest,
|
||||
unsigned destx, unsigned desty, const void *src,
|
||||
unsigned src_stride, unsigned srcx, unsigned srcy,
|
||||
unsigned width, unsigned height)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv50->nvws;
|
||||
|
||||
nvws->surface_data(nvws, dest, destx, desty, src, src_stride,
|
||||
srcx, srcy, width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_surface_copy(struct pipe_context *pipe, struct pipe_surface *dest,
|
||||
unsigned destx, unsigned desty, struct pipe_surface *src,
|
||||
unsigned srcx, unsigned srcy, unsigned width, unsigned height)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv50->nvws;
|
||||
|
||||
nvws->surface_copy(nvws, dest, destx, desty, src, srcx, srcy,
|
||||
width, height);
|
||||
}
|
||||
|
||||
static void
|
||||
nv50_surface_fill(struct pipe_context *pipe, struct pipe_surface *dest,
|
||||
unsigned destx, unsigned desty, unsigned width,
|
||||
unsigned height, unsigned value)
|
||||
{
|
||||
struct nv50_context *nv50 = (struct nv50_context *)pipe;
|
||||
struct nouveau_winsys *nvws = nv50->nvws;
|
||||
|
||||
nvws->surface_fill(nvws, dest, destx, desty, width, height, value);
|
||||
}
|
||||
|
||||
void
|
||||
nv50_init_surface_functions(struct nv50_context *nv50)
|
||||
|
|
@ -226,4 +234,7 @@ nv50_init_surface_functions(struct nv50_context *nv50)
|
|||
nv50->pipe.put_tile = nv50_put_tile;
|
||||
nv50->pipe.get_tile_rgba = nv50_get_tile_rgba;
|
||||
nv50->pipe.put_tile_rgba = nv50_put_tile_rgba;
|
||||
nv50->pipe.surface_data = nv50_surface_data;
|
||||
nv50->pipe.surface_copy = nv50_surface_copy;
|
||||
nv50->pipe.surface_fill = nv50_surface_fill;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue