summaryrefslogtreecommitdiffstats
path: root/src/gallium/winsys
diff options
context:
space:
mode:
authorBen Skeggs <[email protected]>2008-06-29 13:26:04 +1000
committerBen Skeggs <[email protected]>2008-06-29 15:00:28 +1000
commitb6478021d572d9ec30212d6e6992496ee4cf347d (patch)
tree99fd64089ed7dff15f5a6a7c60c17f4bad3a3e45 /src/gallium/winsys
parentcc8e628563a1cfb26752bc014a75f3087cd8986d (diff)
nouveau: adapt to cpp->pf_block changes
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/dri/nouveau/nouveau_context.c9
-rw-r--r--src/gallium/winsys/dri/nouveau/nouveau_screen.c7
-rw-r--r--src/gallium/winsys/dri/nouveau/nv04_surface.c63
-rw-r--r--src/gallium/winsys/dri/nouveau/nv50_surface.c42
4 files changed, 71 insertions, 50 deletions
diff --git a/src/gallium/winsys/dri/nouveau/nouveau_context.c b/src/gallium/winsys/dri/nouveau/nouveau_context.c
index ef5fb7ec0d3..74413c408f3 100644
--- a/src/gallium/winsys/dri/nouveau/nouveau_context.c
+++ b/src/gallium/winsys/dri/nouveau/nouveau_context.c
@@ -167,9 +167,14 @@ nouveau_context_create(const __GLcontextModes *glVis,
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;
diff --git a/src/gallium/winsys/dri/nouveau/nouveau_screen.c b/src/gallium/winsys/dri/nouveau/nouveau_screen.c
index 9041275a88f..b15ee7509cc 100644
--- a/src/gallium/winsys/dri/nouveau/nouveau_screen.c
+++ b/src/gallium/winsys/dri/nouveau/nouveau_screen.c
@@ -209,8 +209,9 @@ nouveau_fill_in_modes(unsigned pixel_bits, unsigned depth_bits,
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;
@@ -229,6 +230,7 @@ nouveau_fill_in_modes(unsigned pixel_bits, unsigned depth_bits,
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__ );
@@ -242,6 +244,7 @@ nouveau_fill_in_modes(unsigned pixel_bits, unsigned depth_bits,
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__ );
diff --git a/src/gallium/winsys/dri/nouveau/nv04_surface.c b/src/gallium/winsys/dri/nouveau/nv04_surface.c
index 83c790db17a..0085b1c345d 100644
--- a/src/gallium/winsys/dri/nouveau/nv04_surface.c
+++ b/src/gallium/winsys/dri/nouveau/nv04_surface.c
@@ -1,26 +1,35 @@
#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;
}
@@ -35,8 +44,8 @@ nv04_surface_copy_m2mf(struct nouveau_context *nv, unsigned dx, unsigned dy,
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;
@@ -47,16 +56,16 @@ nv04_surface_copy_m2mf(struct nouveau_context *nv, unsigned dx, unsigned dy,
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;
}
}
@@ -79,7 +88,7 @@ nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst,
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
@@ -100,8 +109,8 @@ nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst,
}
- 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;
@@ -116,8 +125,7 @@ nv04_surface_copy_prep(struct nouveau_context *nv, struct pipe_surface *dst,
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,
@@ -142,13 +150,13 @@ nv04_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
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;
}
@@ -159,8 +167,7 @@ nv04_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
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,
diff --git a/src/gallium/winsys/dri/nouveau/nv50_surface.c b/src/gallium/winsys/dri/nouveau/nv50_surface.c
index d6da116b774..cf76d76cf52 100644
--- a/src/gallium/winsys/dri/nouveau/nv50_surface.c
+++ b/src/gallium/winsys/dri/nouveau/nv50_surface.c
@@ -1,15 +1,21 @@
#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;
}
@@ -23,9 +29,9 @@ nv50_surface_copy_prep(struct nouveau_context *nv,
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);
@@ -38,8 +44,8 @@ nv50_surface_copy_prep(struct nouveau_context *nv,
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);
@@ -48,15 +54,15 @@ nv50_surface_copy_prep(struct nouveau_context *nv,
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);
@@ -105,11 +111,11 @@ nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
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;
@@ -120,8 +126,8 @@ nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
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);
@@ -130,7 +136,7 @@ nv50_surface_fill(struct nouveau_context *nv, struct pipe_surface *dst,
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);