pt->width[l] = width;
pt->height[l] = height;
pt->depth[l] = depth;
+ pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
+ pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
if (swizzled)
- nv10mt->level[l].pitch = pt->width[l] * pt->cpp;
+ nv10mt->level[l].pitch = pt->nblocksx[l] * pt->block.size;
else
- nv10mt->level[l].pitch = pt->width[0] * pt->cpp;
+ nv10mt->level[l].pitch = pt->nblocksx[0] * pt->block.size;
nv10mt->level[l].pitch = (nv10mt->level[l].pitch + 63) & ~63;
nv10mt->level[l].image_offset =
return NULL;
pipe_buffer_reference(ws, &ps->buffer, nv10mt->buffer);
ps->format = pt->format;
- ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->pitch = nv10mt->level[level].pitch / ps->cpp;
+ ps->block = pt->block;
+ ps->nblocksx = pt->nblocksx[level];
+ ps->nblocksy = pt->nblocksy[level];
+ ps->stride = nv10mt->level[level].pitch;
if (pt->target == PIPE_TEXTURE_CUBE) {
ps->offset = nv10mt->level[level].image_offset[face];
if (zeta) {
BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
- OUT_RING ( (rt->pitch * rt->cpp) | ( (zeta->pitch * zeta->cpp) << 16) );
+ OUT_RING (rt->stride | (zeta->stride << 16));
} else {
BEGIN_RING(celsius, NV10TCL_RT_PITCH, 1);
- OUT_RING ( (rt->pitch * rt->cpp) | ( (rt->pitch * rt->cpp) << 16) );
+ OUT_RING (rt->stride | (rt->stride << 16));
}
nv10->rt[0] = rt->buffer;
pt->width[l] = width;
pt->height[l] = height;
pt->depth[l] = depth;
+ pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
+ pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
if (swizzled)
pitch = pt->width[l];
pitch = (pitch + 63) & ~63;
- nv30mt->level[l].pitch = pitch * pt->cpp;
+ nv30mt->level[l].pitch = pitch * pt->block.size;
nv30mt->level[l].image_offset =
CALLOC(nr_faces, sizeof(unsigned));
return NULL;
pipe_buffer_reference(ws, &ps->buffer, nv30mt->buffer);
ps->format = pt->format;
- ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->pitch = nv30mt->level[level].pitch / ps->cpp;
+ ps->nblocksx = pt->nblocksx[level];
+ ps->nblocksy = pt->nblocksy[level];
+ ps->block = pt->block;
+ ps->stride = nv30mt->level[level].pitch;
if (pt->target == PIPE_TEXTURE_CUBE) {
ps->offset = nv30mt->level[level].image_offset[face];
}
if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) {
- uint32_t pitch = rt[0]->pitch * rt[0]->cpp;
+ uint32_t pitch = rt[0]->stride;
if (zeta) {
- pitch |= (zeta->pitch * zeta->cpp)<<16;
+ pitch |= (zeta->stride << 16);
} else {
- pitch |= pitch<<16;
+ pitch |= (pitch << 16);
}
BEGIN_RING(rankine, NV34TCL_COLOR0_PITCH, 1);
- OUT_RING ( pitch );
+ OUT_RING (pitch);
nv30->rt[0] = rt[0]->buffer;
}
if (rt_enable & NV34TCL_RT_ENABLE_COLOR1) {
BEGIN_RING(rankine, NV34TCL_COLOR1_PITCH, 1);
- OUT_RING (rt[1]->pitch * rt[1]->cpp);
+ OUT_RING (rt[1]->stride);
nv30->rt[1] = rt[1]->buffer;
}
}
if (rt_enable & NV34TCL_RT_ENABLE_COLOR0) {
- uint32_t pitch = rt[0]->pitch * rt[0]->cpp;
+ uint32_t pitch = rt[0]->stride;
if (zeta) {
- pitch |= (zeta->pitch * zeta->cpp)<<16;
+ pitch |= (zeta->stride << 16);
} else {
- pitch |= pitch<<16;
+ pitch |= (pitch << 16);
}
so_method(so, nv30->screen->rankine, NV34TCL_DMA_COLOR0, 1);
so_method(so, nv30->screen->rankine, NV34TCL_COLOR1_OFFSET, 2);
so_reloc (so, rt[1]->buffer, rt[1]->offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
- so_data (so, rt[1]->pitch * rt[1]->cpp);
+ so_data (so, rt[1]->stride);
}
/*
if (rt_enable & NV34TCL_RT_ENABLE_COLOR2) {
pt->width[l] = width;
pt->height[l] = height;
pt->depth[l] = depth;
+ pt->nblocksx[l] = pf_get_nblocksx(&pt->block, width);
+ pt->nblocksy[l] = pf_get_nblocksy(&pt->block, height);
if (swizzled)
- pitch = pt->width[l];
- pitch = (pitch + 63) & ~63;
+ pitch = pt->nblocksx[l];
+ pitch = align_int(pitch, 64);
- nv40mt->level[l].pitch = pitch * pt->cpp;
+ nv40mt->level[l].pitch = pitch * pt->block.size;
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);
-
}
for (f = 0; f < nr_faces; f++) {
struct nv40_miptree *nv40mt = (struct nv40_miptree *)pt;
struct pipe_surface *ps;
- ps = ws->surface_alloc(ws);
+ ps = CALLOC_STRUCT(pipe_surface);
if (!ps)
return NULL;
+ pipe_texture_reference(&ps->texture, pt);
pipe_buffer_reference(ws, &ps->buffer, nv40mt->buffer);
ps->format = pt->format;
- ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->pitch = nv40mt->level[level].pitch / ps->cpp;
+ ps->block = pt->block;
+ ps->nblocksx = pt->nblocksx[level];
+ ps->nblocksy = pt->nblocksy[level];
+ ps->stride = nv40mt->level[level].pitch;
+ ps->usage = flags;
+ ps->status = PIPE_SURFACE_STATUS_DEFINED;
if (pt->target == PIPE_TEXTURE_CUBE) {
ps->offset = nv40mt->level[level].image_offset[face];
nv40_miptree_surface_del(struct pipe_screen *pscreen,
struct pipe_surface **psurface)
{
+ struct pipe_surface *ps = *psurface;
+
+ *psurface = NULL;
+ if (--ps->refcount > 0)
+ return;
+
+ pipe_texture_reference(&ps->texture, NULL);
+ pipe_buffer_reference(pscreen->winsys, &ps->buffer, NULL);
+ FREE(ps);
}
void
nv40->nvws->channel->vram->handle,
nv40->nvws->channel->gart->handle);
so_method(so, nv40->screen->curie, NV40TCL_COLOR0_PITCH, 2);
- so_data (so, rt[0]->pitch * rt[0]->cpp);
+ so_data (so, rt[0]->stride);
so_reloc (so, rt[0]->buffer, rt[0]->offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
}
so_method(so, nv40->screen->curie, NV40TCL_COLOR1_OFFSET, 2);
so_reloc (so, rt[1]->buffer, rt[1]->offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
- so_data (so, rt[1]->pitch * rt[1]->cpp);
+ so_data (so, rt[1]->stride);
}
if (rt_enable & NV40TCL_RT_ENABLE_COLOR2) {
so_reloc (so, rt[2]->buffer, rt[2]->offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
so_method(so, nv40->screen->curie, NV40TCL_COLOR2_PITCH, 1);
- so_data (so, rt[2]->pitch * rt[2]->cpp);
+ so_data (so, rt[2]->stride);
}
if (rt_enable & NV40TCL_RT_ENABLE_COLOR3) {
so_reloc (so, rt[3]->buffer, rt[3]->offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
so_method(so, nv40->screen->curie, NV40TCL_COLOR3_PITCH, 1);
- so_data (so, rt[3]->pitch * rt[3]->cpp);
+ so_data (so, rt[3]->stride);
}
if (zeta_format) {
so_reloc (so, zeta->buffer, zeta->offset, rt_flags |
NOUVEAU_BO_LOW, 0, 0);
so_method(so, nv40->screen->curie, NV40TCL_ZETA_PITCH, 1);
- so_data (so, zeta->pitch * zeta->cpp);
+ so_data (so, zeta->stride);
}
so_method(so, nv40->screen->curie, NV40TCL_RT_ENABLE, 1);
#include "util/p_tile.h"
static void
-nv40_surface_copy(struct pipe_context *pipe, unsigned do_flip,
+nv40_surface_copy(struct pipe_context *pipe, boolean do_flip,
struct pipe_surface *dest, unsigned destx, unsigned desty,
struct pipe_surface *src, unsigned srcx, unsigned srcy,
unsigned width, unsigned height)
pipe_buffer_reference(ws, &ps->buffer, mt->buffer);
ps->format = pt->format;
- ps->cpp = pt->cpp;
ps->width = pt->width[level];
ps->height = pt->height[level];
- ps->pitch = ps->width;
+ ps->block = pt->block;
+ ps->nblocksx = pt->nblocksx[level];
+ ps->nblocksy = pt->nblocksy[level];
+ ps->stride = ps->width * ps->block.size;
ps->offset = 0;
return ps;
fb_buf->bo = &fb_bo->base;
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;
+ if (nv_screen->front_cpp == 2)
+ fb_surf->format = PIPE_FORMAT_R5G6B5_UNORM;
+ else
+ fb_surf->format = PIPE_FORMAT_A8R8G8B8_UNORM;
+ pf_get_block(fb_surf->format, &fb_surf->block);
+ fb_surf->width = nv_screen->front_pitch / nv_screen->front_cpp;
fb_surf->height = nv_screen->front_height;
+ fb_surf->stride = fb_surf->width * fb_surf->block.size;
fb_surf->refcount = 1;
fb_surf->buffer = &fb_buf->base;
GLX_NONE, GLX_SWAP_UNDEFINED_OML, GLX_SWAP_COPY_OML
};
- u_int8_t depth_bits_array[4] = { 0, 16, 24, 24 };
- u_int8_t stencil_bits_array[4] = { 0, 0, 0, 8 };
+ uint8_t depth_bits_array[4] = { 0, 16, 24, 24 };
+ uint8_t stencil_bits_array[4] = { 0, 0, 0, 8 };
+ uint8_t msaa_samples_array[1] = { 0 };
depth_buffer_factor = 4;
back_buffer_factor = (have_back_buffer) ? 3 : 1;
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
+ msaa_samples_array, 1,
GLX_TRUE_COLOR)) {
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
__func__, __LINE__ );
depth_buffer_factor,
back_buffer_modes,
back_buffer_factor,
+ msaa_samples_array, 1,
GLX_DIRECT_COLOR)) {
fprintf( stderr, "[%s:%u] Error creating FBConfig!\n",
__func__, __LINE__ );
#include "pipe/p_context.h"
+#include "pipe/p_format.h"
#include "nouveau_context.h"
static INLINE int
-nv04_surface_format(int cpp)
+nv04_surface_format(enum pipe_format format)
{
- switch (cpp) {
- case 1: return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
- case 2: return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
- case 4: return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
+ switch (format) {
+ case PIPE_FORMAT_A8_UNORM:
+ return NV04_CONTEXT_SURFACES_2D_FORMAT_Y8;
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ return NV04_CONTEXT_SURFACES_2D_FORMAT_R5G6B5;
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return NV04_CONTEXT_SURFACES_2D_FORMAT_Y32;
default:
return -1;
}
}
static INLINE int
-nv04_rect_format(int cpp)
+nv04_rect_format(enum pipe_format format)
{
- switch (cpp) {
- case 1: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
- case 2: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
- case 4: return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
+ switch (format) {
+ case PIPE_FORMAT_A8_UNORM:
+ return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A16R5G6B5;
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return NV04_GDI_RECTANGLE_TEXT_COLOR_FORMAT_A8R8G8B8;
default:
return -1;
}
struct pipe_surface *src = nv->surf_src;
unsigned dst_offset, src_offset;
- dst_offset = dst->offset + (dy * dst->pitch + dx) * dst->cpp;
- src_offset = src->offset + (sy * src->pitch + sx) * src->cpp;
+ dst_offset = dst->offset + (dy * dst->stride) + (dx * dst->block.size);
+ src_offset = src->offset + (sy * src->stride) + (sx * src->block.size);
while (h) {
int count = (h > 2047) ? 2047 : h;
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_RD);
OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst_offset,
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART | NOUVEAU_BO_WR);
- OUT_RING (chan, src->pitch * src->cpp);
- OUT_RING (chan, dst->pitch * dst->cpp);
- OUT_RING (chan, w * src->cpp);
+ OUT_RING (chan, src->stride);
+ OUT_RING (chan, dst->stride);
+ OUT_RING (chan, w * src->block.size);
OUT_RING (chan, count);
OUT_RING (chan, 0x0101);
OUT_RING (chan, 0);
h -= count;
- src_offset += src->pitch * src->cpp * count;
- dst_offset += dst->pitch * dst->cpp * count;
+ src_offset += src->stride * count;
+ dst_offset += dst->stride * count;
}
}
struct nouveau_channel *chan = nv->nvc->channel;
int format;
- if (src->cpp != dst->cpp)
+ if (src->format != dst->format)
return 1;
/* NV_CONTEXT_SURFACES_2D has buffer alignment restrictions, fallback
}
- if ((format = nv04_surface_format(dst->cpp)) < 0) {
- NOUVEAU_ERR("Bad cpp = %d\n", dst->cpp);
+ if ((format = nv04_surface_format(dst->format)) < 0) {
+ NOUVEAU_ERR("Bad surface format 0x%x\n", dst->format);
return 1;
}
nv->surface_copy = nv04_surface_copy_blit;
BEGIN_RING(chan, nv->nvc->NvCtxSurf2D,
NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
OUT_RING (chan, format);
- OUT_RING (chan, ((dst->pitch * dst->cpp) << 16) |
- (src->pitch * src->cpp));
+ OUT_RING (chan, (dst->stride << 16) | src->stride);
OUT_RELOCl(chan, nouveau_buffer(src->buffer)->bo, src->offset,
NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
struct nouveau_grobj *rect = nv->nvc->NvGdiRect;
int cs2d_format, gdirect_format;
- if ((cs2d_format = nv04_surface_format(dst->cpp)) < 0) {
- NOUVEAU_ERR("Bad cpp = %d\n", dst->cpp);
+ if ((cs2d_format = nv04_surface_format(dst->format)) < 0) {
+ NOUVEAU_ERR("Bad format = %d\n", dst->format);
return 1;
}
- if ((gdirect_format = nv04_rect_format(dst->cpp)) < 0) {
- NOUVEAU_ERR("Bad cpp = %d\n", dst->cpp);
+ if ((gdirect_format = nv04_rect_format(dst->format)) < 0) {
+ NOUVEAU_ERR("Bad format = %d\n", dst->format);
return 1;
}
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, surf2d, NV04_CONTEXT_SURFACES_2D_FORMAT, 4);
OUT_RING (chan, cs2d_format);
- OUT_RING (chan, ((dst->pitch * dst->cpp) << 16) |
- (dst->pitch * dst->cpp));
+ OUT_RING (chan, (dst->stride << 16) | dst->stride);
OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
OUT_RELOCl(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
#include "pipe/p_context.h"
+#include "pipe/p_format.h"
#include "nouveau_context.h"
static INLINE int
-nv50_format(int cpp)
+nv50_format(enum pipe_format format)
{
- switch (cpp) {
- case 4: return NV50_2D_DST_FORMAT_32BPP;
- case 3: return NV50_2D_DST_FORMAT_24BPP;
- case 2: return NV50_2D_DST_FORMAT_16BPP;
- case 1: return NV50_2D_DST_FORMAT_8BPP;
+ switch (format) {
+ case PIPE_FORMAT_A8R8G8B8_UNORM:
+ case PIPE_FORMAT_Z24S8_UNORM:
+ return NV50_2D_DST_FORMAT_32BPP;
+ case PIPE_FORMAT_X8R8G8B8_UNORM:
+ return NV50_2D_DST_FORMAT_24BPP;
+ case PIPE_FORMAT_R5G6B5_UNORM:
+ return NV50_2D_DST_FORMAT_16BPP;
+ case PIPE_FORMAT_A8_UNORM:
+ return NV50_2D_DST_FORMAT_8BPP;
default:
return -1;
}
struct nouveau_grobj *eng2d = nv->nvc->Nv2D;
int surf_format;
- assert(src->cpp == dst->cpp);
+ assert(src->format == dst->format);
- surf_format = nv50_format(dst->cpp);
+ surf_format = nv50_format(dst->format);
assert(surf_format >= 0);
BEGIN_RING(chan, eng2d, NV50_2D_DMA_IN_MEMORY0, 2);
OUT_RING (chan, surf_format);
OUT_RING (chan, 1);
BEGIN_RING(chan, eng2d, NV50_2D_DST_PITCH, 5);
- OUT_RING (chan, dst->pitch * dst->cpp);
- OUT_RING (chan, dst->pitch);
+ OUT_RING (chan, dst->stride);
+ OUT_RING (chan, dst->width);
OUT_RING (chan, dst->height);
OUT_RELOCh(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, eng2d, NV50_2D_CLIP_X, 4);
OUT_RING (chan, 0);
OUT_RING (chan, 0);
- OUT_RING (chan, dst->pitch);
+ OUT_RING (chan, dst->width);
OUT_RING (chan, dst->height);
BEGIN_RING(chan, eng2d, NV50_2D_SRC_FORMAT, 2);
OUT_RING (chan, surf_format);
OUT_RING (chan, 1);
BEGIN_RING(chan, eng2d, NV50_2D_SRC_PITCH, 5);
- OUT_RING (chan, src->pitch * src->cpp);
- OUT_RING (chan, src->pitch);
+ OUT_RING (chan, src->stride);
+ OUT_RING (chan, src->width);
OUT_RING (chan, src->height);
OUT_RELOCh(chan, nouveau_buffer(src->buffer)->bo, src->offset,
NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
struct nouveau_grobj *eng2d = nv->nvc->Nv2D;
int surf_format, rect_format;
- surf_format = nv50_format(dst->cpp);
+ surf_format = nv50_format(dst->format);
if (surf_format < 0)
return 1;
- rect_format = nv50_format(dst->cpp);
+ rect_format = nv50_format(dst->format);
if (rect_format < 0)
return 1;
OUT_RING (chan, surf_format);
OUT_RING (chan, 1);
BEGIN_RING(chan, eng2d, NV50_2D_DST_PITCH, 5);
- OUT_RING (chan, dst->pitch * dst->cpp);
- OUT_RING (chan, dst->pitch);
+ OUT_RING (chan, dst->stride);
+ OUT_RING (chan, dst->width);
OUT_RING (chan, dst->height);
OUT_RELOCh(chan, nouveau_buffer(dst->buffer)->bo, dst->offset,
NOUVEAU_BO_VRAM | NOUVEAU_BO_WR);
BEGIN_RING(chan, eng2d, NV50_2D_CLIP_X, 4);
OUT_RING (chan, 0);
OUT_RING (chan, 0);
- OUT_RING (chan, dst->pitch);
+ OUT_RING (chan, dst->width);
OUT_RING (chan, dst->height);
BEGIN_RING(chan, eng2d, 0x0580, 3);