summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/i915simple
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe/i915simple')
-rw-r--r--src/mesa/pipe/i915simple/i915_clear.c9
-rw-r--r--src/mesa/pipe/i915simple/i915_regions.c172
-rw-r--r--src/mesa/pipe/i915simple/i915_state_emit.c25
-rw-r--r--src/mesa/pipe/i915simple/i915_surface.c185
4 files changed, 189 insertions, 202 deletions
diff --git a/src/mesa/pipe/i915simple/i915_clear.c b/src/mesa/pipe/i915simple/i915_clear.c
index e8087df5a47..cde69daacc0 100644
--- a/src/mesa/pipe/i915simple/i915_clear.c
+++ b/src/mesa/pipe/i915simple/i915_clear.c
@@ -43,12 +43,5 @@ void
i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
unsigned clearValue)
{
- int x, y, w, h;
-
- x = 0;
- y = 0;
- w = ps->width;
- h = ps->height;
-
- pipe->region_fill(pipe, ps->region, 0, x, y, w, h, clearValue);
+ pipe->surface_fill(pipe, ps, 0, 0, ps->width, ps->height, clearValue);
}
diff --git a/src/mesa/pipe/i915simple/i915_regions.c b/src/mesa/pipe/i915simple/i915_regions.c
index e8c4c92bc88..82fdec83d09 100644
--- a/src/mesa/pipe/i915simple/i915_regions.c
+++ b/src/mesa/pipe/i915simple/i915_regions.c
@@ -34,7 +34,6 @@
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "i915_context.h"
-#include "i915_blit.h"
@@ -70,181 +69,10 @@ i915_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
}
-/*
- * XXX Move this into core Mesa?
- */
-static void
-_mesa_copy_rect(ubyte * dst,
- unsigned cpp,
- unsigned dst_pitch,
- unsigned dst_x,
- unsigned dst_y,
- unsigned width,
- unsigned height,
- const ubyte * src,
- unsigned src_pitch,
- unsigned src_x,
- unsigned src_y)
-{
- unsigned i;
-
- dst_pitch *= cpp;
- src_pitch *= cpp;
- dst += dst_x * cpp;
- src += src_x * cpp;
- dst += dst_y * dst_pitch;
- src += src_y * dst_pitch;
- width *= cpp;
-
- if (width == dst_pitch && width == src_pitch)
- memcpy(dst, src, height * width);
- else {
- for (i = 0; i < height; i++) {
- memcpy(dst, src, width);
- dst += dst_pitch;
- src += src_pitch;
- }
- }
-}
-
-
-/* Upload data to a rectangular sub-region. Lots of choices how to do this:
- *
- * - memcpy by span to current destination
- * - upload data as new buffer and blit
- *
- * Currently always memcpy.
- */
-static void
-i915_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)
-{
- _mesa_copy_rect(pipe->region_map(pipe, dst) + dst_offset,
- dst->cpp,
- dst->pitch,
- dstx, dsty, width, height, src, src_pitch, srcx, srcy);
-
- pipe->region_unmap(pipe, dst);
-}
-
-
-/* Assumes all values are within bounds -- no checking at this level -
- * do it higher up if required.
- */
-static void
-i915_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)
-{
- assert( dst != src );
- assert( dst->cpp == src->cpp );
-
- if (0) {
- _mesa_copy_rect(pipe->region_map(pipe, dst) + dst_offset,
- dst->cpp,
- dst->pitch,
- dstx, dsty,
- width, height,
- pipe->region_map(pipe, src) + src_offset,
- src->pitch,
- srcx, srcy);
-
- pipe->region_unmap(pipe, src);
- pipe->region_unmap(pipe, dst);
- }
- else {
- i915_copy_blit( i915_context(pipe),
- dst->cpp,
- (short) src->pitch, src->buffer, src_offset,
- (short) dst->pitch, dst->buffer, dst_offset,
- (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
- }
-}
-
-/* Fill a rectangular sub-region. Need better logic about when to
- * push buffers into AGP - will currently do so whenever possible.
- */
-static ubyte *
-get_pointer(struct pipe_region *dst, unsigned x, unsigned y)
-{
- return dst->map + (y * dst->pitch + x) * dst->cpp;
-}
-
-
-static void
-i915_region_fill(struct pipe_context *pipe,
- struct pipe_region *dst,
- unsigned dst_offset,
- unsigned dstx, unsigned dsty,
- unsigned width, unsigned height, unsigned value)
-{
- if (0) {
- unsigned i, j;
-
- (void)pipe->region_map(pipe, dst);
-
- switch (dst->cpp) {
- case 1: {
- ubyte *row = get_pointer(dst, dstx, dsty);
- for (i = 0; i < height; i++) {
- memset(row, value, width);
- row += dst->pitch;
- }
- }
- break;
- case 2: {
- ushort *row = (ushort *) get_pointer(dst, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = (ushort) value;
- row += dst->pitch;
- }
- }
- break;
- case 4: {
- unsigned *row = (unsigned *) get_pointer(dst, dstx, dsty);
- for (i = 0; i < height; i++) {
- for (j = 0; j < width; j++)
- row[j] = value;
- row += dst->pitch;
- }
- }
- break;
- default:
- assert(0);
- break;
- }
- }
- else {
- i915_fill_blit( i915_context(pipe),
- dst->cpp,
- (short) dst->pitch,
- dst->buffer, dst_offset,
- (short) dstx, (short) dsty,
- (short) width, (short) height,
- value );
- }
-}
-
-
-
-
-
void
i915_init_region_functions(struct i915_context *i915)
{
i915->pipe.region_map = i915_region_map;
i915->pipe.region_unmap = i915_region_unmap;
- i915->pipe.region_data = i915_region_data;
- i915->pipe.region_copy = i915_region_copy;
- i915->pipe.region_fill = i915_region_fill;
}
diff --git a/src/mesa/pipe/i915simple/i915_state_emit.c b/src/mesa/pipe/i915simple/i915_state_emit.c
index d793e92a14d..900a91d8963 100644
--- a/src/mesa/pipe/i915simple/i915_state_emit.c
+++ b/src/mesa/pipe/i915simple/i915_state_emit.c
@@ -208,10 +208,11 @@ i915_emit_hardware_state(struct i915_context *i915 )
/* 8 dwords, 2 relocs */
if (i915->hardware_dirty & I915_HW_STATIC)
{
- if (i915->framebuffer.cbufs[0]) {
- struct pipe_region *cbuf_region = i915->framebuffer.cbufs[0]->region;
- unsigned pitch = (cbuf_region->pitch *
- cbuf_region->cpp);
+ struct pipe_surface *cbuf_surface = i915->framebuffer.cbufs[0];
+ struct pipe_surface *depth_surface = i915->framebuffer.zbuf;
+
+ if (cbuf_surface) {
+ unsigned pitch = (cbuf_surface->pitch * cbuf_surface->cpp);
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
@@ -219,17 +220,15 @@ i915_emit_hardware_state(struct i915_context *i915 )
BUF_3D_PITCH(pitch) | /* pitch in bytes */
BUF_3D_USE_FENCE);
- OUT_RELOC(cbuf_region->buffer,
+ OUT_RELOC(cbuf_surface->region->buffer,
I915_BUFFER_ACCESS_WRITE,
0);
}
/* What happens if no zbuf??
*/
- if (i915->framebuffer.zbuf) {
- struct pipe_region *depth_region = i915->framebuffer.zbuf->region;
- unsigned zpitch = (depth_region->pitch *
- depth_region->cpp);
+ if (depth_surface) {
+ unsigned zpitch = (depth_surface->pitch * depth_surface->cpp);
OUT_BATCH(_3DSTATE_BUF_INFO_CMD);
@@ -237,7 +236,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
BUF_3D_PITCH(zpitch) | /* pitch in bytes */
BUF_3D_USE_FENCE);
- OUT_RELOC(depth_region->buffer,
+ OUT_RELOC(depth_surface->region->buffer,
I915_BUFFER_ACCESS_WRITE,
0);
}
@@ -245,13 +244,13 @@ i915_emit_hardware_state(struct i915_context *i915 )
{
unsigned cformat, zformat = 0;
- if (i915->framebuffer.cbufs[0])
- cformat = i915->framebuffer.cbufs[0]->format;
+ if (cbuf_surface)
+ cformat = cbuf_surface->format;
else
cformat = PIPE_FORMAT_U_A8_R8_G8_B8; /* arbitrary */
cformat = translate_format(cformat);
- if (i915->framebuffer.zbuf)
+ if (depth_surface)
zformat = translate_depth_format( i915->framebuffer.zbuf->format );
OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD);
diff --git a/src/mesa/pipe/i915simple/i915_surface.c b/src/mesa/pipe/i915simple/i915_surface.c
index bec7ddb7319..e4a5de00d77 100644
--- a/src/mesa/pipe/i915simple/i915_surface.c
+++ b/src/mesa/pipe/i915simple/i915_surface.c
@@ -26,6 +26,7 @@
**************************************************************************/
#include "i915_context.h"
+#include "i915_blit.h"
#include "i915_state.h"
#include "pipe/p_defines.h"
#include "pipe/p_util.h"
@@ -57,7 +58,7 @@ i915_get_tile_rgba(struct pipe_context *pipe,
{
const unsigned *src
= ((const unsigned *) (ps->region->map + ps->offset))
- + y * ps->region->pitch + x;
+ + y * ps->pitch + x;
unsigned i, j;
unsigned w0 = w;
@@ -75,7 +76,7 @@ i915_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;
@@ -92,7 +93,7 @@ i915_get_tile_rgba(struct pipe_context *pipe,
pRow[3] = (pixel & 0xffffff) * scale;
pRow += 4;
}
- src += ps->region->pitch;
+ src += ps->pitch;
p += w0 * 4;
}
}
@@ -122,7 +123,7 @@ i915_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;
@@ -136,13 +137,13 @@ i915_get_tile(struct pipe_context *pipe,
dst_stride = w0 * cpp;
}
- pSrc = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+ pSrc = ps->region->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,7 +157,7 @@ i915_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;
@@ -171,11 +172,11 @@ i915_put_tile(struct pipe_context *pipe,
}
pSrc = (const ubyte *) p;
- pDest = ps->region->map + ps->offset + (y * ps->region->pitch + x) * cpp;
+ pDest = ps->region->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;
}
}
@@ -210,14 +211,177 @@ i915_get_tex_surface(struct pipe_context *pipe,
assert(ps->format);
assert(ps->refcount);
pipe_region_reference(&ps->region, mt->region);
+ ps->cpp = mt->cpp;
ps->width = mt->level[level].width;
ps->height = mt->level[level].height;
+ ps->pitch = mt->pitch;
ps->offset = offset;
}
return ps;
}
+/*
+ * XXX Move this into core Mesa?
+ */
+static void
+_mesa_copy_rect(ubyte * dst,
+ unsigned cpp,
+ unsigned dst_pitch,
+ unsigned dst_x,
+ unsigned dst_y,
+ unsigned width,
+ unsigned height,
+ const ubyte * src,
+ unsigned src_pitch,
+ unsigned src_x,
+ unsigned src_y)
+{
+ unsigned i;
+
+ dst_pitch *= cpp;
+ src_pitch *= cpp;
+ dst += dst_x * cpp;
+ src += src_x * cpp;
+ dst += dst_y * dst_pitch;
+ src += src_y * dst_pitch;
+ width *= cpp;
+
+ if (width == dst_pitch && width == src_pitch)
+ memcpy(dst, src, height * width);
+ else {
+ for (i = 0; i < height; i++) {
+ memcpy(dst, src, width);
+ dst += dst_pitch;
+ src += src_pitch;
+ }
+ }
+}
+
+
+/* Upload data to a rectangular sub-region. Lots of choices how to do this:
+ *
+ * - memcpy by span to current destination
+ * - upload data as new buffer and blit
+ *
+ * Currently always memcpy.
+ */
+static void
+i915_surface_data(struct pipe_context *pipe,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ const void *src, unsigned src_pitch,
+ unsigned srcx, unsigned srcy, unsigned width, unsigned height)
+{
+ _mesa_copy_rect(pipe->region_map(pipe, dst->region) + dst->offset,
+ dst->cpp,
+ dst->pitch,
+ dstx, dsty, width, height, src, src_pitch, srcx, srcy);
+
+ pipe->region_unmap(pipe, dst->region);
+}
+
+
+/* Assumes all values are within bounds -- no checking at this level -
+ * do it higher up if required.
+ */
+static void
+i915_surface_copy(struct pipe_context *pipe,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ struct pipe_surface *src,
+ unsigned srcx, unsigned srcy, unsigned width, unsigned height)
+{
+ assert( dst != src );
+ assert( dst->cpp == src->cpp );
+
+ if (0) {
+ _mesa_copy_rect(pipe->region_map(pipe, dst->region) + dst->offset,
+ dst->cpp,
+ dst->pitch,
+ dstx, dsty,
+ width, height,
+ pipe->region_map(pipe, src->region) + src->offset,
+ src->pitch,
+ srcx, srcy);
+
+ pipe->region_unmap(pipe, src->region);
+ pipe->region_unmap(pipe, dst->region);
+ }
+ else {
+ i915_copy_blit( i915_context(pipe),
+ dst->cpp,
+ (short) src->pitch, src->region->buffer, src->offset,
+ (short) dst->pitch, dst->region->buffer, dst->offset,
+ (short) srcx, (short) srcy, (short) dstx, (short) dsty, (short) width, (short) height );
+ }
+}
+
+/* Fill a rectangular sub-region. Need better logic about when to
+ * push buffers into AGP - will currently do so whenever possible.
+ */
+static ubyte *
+get_pointer(struct pipe_surface *dst, unsigned x, unsigned y)
+{
+ return dst->region->map + (y * dst->pitch + x) * dst->cpp;
+}
+
+
+static void
+i915_surface_fill(struct pipe_context *pipe,
+ struct pipe_surface *dst,
+ unsigned dstx, unsigned dsty,
+ unsigned width, unsigned height, unsigned value)
+{
+ if (0) {
+ unsigned i, j;
+
+ (void)pipe->region_map(pipe, dst->region);
+
+ switch (dst->cpp) {
+ case 1: {
+ ubyte *row = get_pointer(dst, dstx, dsty);
+ for (i = 0; i < height; i++) {
+ memset(row, value, width);
+ row += dst->pitch;
+ }
+ }
+ break;
+ case 2: {
+ ushort *row = (ushort *) get_pointer(dst, dstx, dsty);
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ row[j] = (ushort) value;
+ row += dst->pitch;
+ }
+ }
+ break;
+ case 4: {
+ unsigned *row = (unsigned *) get_pointer(dst, dstx, dsty);
+ for (i = 0; i < height; i++) {
+ for (j = 0; j < width; j++)
+ row[j] = value;
+ row += dst->pitch;
+ }
+ }
+ break;
+ default:
+ assert(0);
+ break;
+ }
+ }
+ else {
+ i915_fill_blit( i915_context(pipe),
+ dst->cpp,
+ (short) dst->pitch,
+ dst->region->buffer, dst->offset,
+ (short) dstx, (short) dsty,
+ (short) width, (short) height,
+ value );
+ }
+}
+
+
void
i915_init_surface_functions(struct i915_context *i915)
{
@@ -226,4 +390,7 @@ i915_init_surface_functions(struct i915_context *i915)
i915->pipe.put_tile = i915_put_tile;
i915->pipe.get_tile_rgba = i915_get_tile_rgba;
i915->pipe.put_tile_rgba = i915_put_tile_rgba;
+ i915->pipe.surface_data = i915_surface_data;
+ i915->pipe.surface_copy = i915_surface_copy;
+ i915->pipe.surface_fill = i915_surface_fill;
}