summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Bornecrantz <wallbraker@gmail.com>2009-08-30 20:49:01 +0100
committerJakob Bornecrantz <wallbraker@gmail.com>2009-09-01 00:47:02 +0100
commitd2110064c2075a8537d4b7f87ba894ebaa6ccb33 (patch)
tree7d08142c3a3fc44e2cf3b349e5d4e325eb0ab524
parentdd040753d7703ac5edbf1aeb336c0093862a2486 (diff)
i915g: Switch from pipe_winsys to intel_winsys
Also includes moving lots of functions from i915_batch.h into intel_batchbuffer.h
-rw-r--r--src/gallium/drivers/i915simple/i915_batch.h89
-rw-r--r--src/gallium/drivers/i915simple/i915_blit.c13
-rw-r--r--src/gallium/drivers/i915simple/i915_blit.h6
-rw-r--r--src/gallium/drivers/i915simple/i915_context.c17
-rw-r--r--src/gallium/drivers/i915simple/i915_context.h20
-rw-r--r--src/gallium/drivers/i915simple/i915_debug.c3
-rw-r--r--src/gallium/drivers/i915simple/i915_debug.h4
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_emit.c1
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_vbuf.c43
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c73
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.h5
-rw-r--r--src/gallium/drivers/i915simple/i915_state_emit.c18
-rw-r--r--src/gallium/drivers/i915simple/i915_state_sampler.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c109
-rw-r--r--src/gallium/drivers/i915simple/i915_winsys.h144
-rw-r--r--src/gallium/drivers/i915simple/intel_batchbuffer.h87
16 files changed, 294 insertions, 340 deletions
diff --git a/src/gallium/drivers/i915simple/i915_batch.h b/src/gallium/drivers/i915simple/i915_batch.h
index 1e58c5b2a8..b813784723 100644
--- a/src/gallium/drivers/i915simple/i915_batch.h
+++ b/src/gallium/drivers/i915simple/i915_batch.h
@@ -28,89 +28,20 @@
#ifndef I915_BATCH_H
#define I915_BATCH_H
-#include "i915_winsys.h"
+#include "intel_batchbuffer.h"
-struct i915_batchbuffer
-{
- struct pipe_buffer *buffer;
- struct i915_winsys *winsys;
+#define BEGIN_BATCH(dwords, relocs) \
+ (intel_batchbuffer_check(i915->batch, dwords, relocs))
- unsigned char *map;
- unsigned char *ptr;
+#define OUT_BATCH(dword) \
+ intel_batchbuffer_dword(i915->batch, dword)
- size_t size;
- size_t actual_size;
+#define OUT_RELOC(buf, usage, offset) \
+ intel_batchbuffer_reloc(i915->batch, buf, usage, offset)
- size_t relocs;
- size_t max_relocs;
-};
-
-static INLINE boolean
-i915_batchbuffer_check( struct i915_batchbuffer *batch,
- size_t dwords,
- size_t relocs )
-{
- return dwords * 4 <= batch->size - (batch->ptr - batch->map) &&
- relocs <= (batch->max_relocs - batch->relocs);
-}
-
-static INLINE size_t
-i915_batchbuffer_space( struct i915_batchbuffer *batch )
-{
- return batch->size - (batch->ptr - batch->map);
-}
-
-static INLINE void
-i915_batchbuffer_dword( struct i915_batchbuffer *batch,
- unsigned dword )
-{
- if (i915_batchbuffer_space(batch) < 4)
- return;
-
- *(unsigned *)batch->ptr = dword;
- batch->ptr += 4;
-}
-
-static INLINE void
-i915_batchbuffer_write( struct i915_batchbuffer *batch,
- void *data,
- size_t size )
-{
- if (i915_batchbuffer_space(batch) < size)
- return;
-
- memcpy(data, batch->ptr, size);
- batch->ptr += size;
-}
-
-static INLINE void
-i915_batchbuffer_reloc( struct i915_batchbuffer *batch,
- struct pipe_buffer *buffer,
- size_t flags,
- size_t offset )
-{
- batch->winsys->batch_reloc( batch->winsys, buffer, flags, offset );
-}
-
-static INLINE void
-i915_batchbuffer_flush( struct i915_batchbuffer *batch,
- struct pipe_fence_handle **fence )
-{
- batch->winsys->batch_flush( batch->winsys, fence );
-}
-
-#define BEGIN_BATCH( dwords, relocs ) \
- (i915_batchbuffer_check( i915->batch, dwords, relocs ))
-
-#define OUT_BATCH( dword ) \
- i915_batchbuffer_dword( i915->batch, dword )
-
-#define OUT_RELOC( buf, flags, delta ) \
- i915_batchbuffer_reloc( i915->batch, buf, flags, delta )
-
-#define FLUSH_BATCH(fence) do { \
- i915_batchbuffer_flush( i915->batch, fence ); \
- i915->hardware_dirty = ~0; \
+#define FLUSH_BATCH(fence) do { \
+ intel_batchbuffer_flush(i915->batch, fence); \
+ i915->hardware_dirty = ~0; \
} while (0)
#endif
diff --git a/src/gallium/drivers/i915simple/i915_blit.c b/src/gallium/drivers/i915simple/i915_blit.c
index 63e9ed83d2..83dfc33528 100644
--- a/src/gallium/drivers/i915simple/i915_blit.c
+++ b/src/gallium/drivers/i915simple/i915_blit.c
@@ -26,7 +26,6 @@
**************************************************************************/
-#include "i915_winsys.h"
#include "i915_blit.h"
#include "i915_reg.h"
#include "i915_batch.h"
@@ -38,7 +37,7 @@ void
i915_fill_blit(struct i915_context *i915,
unsigned cpp,
unsigned short dst_pitch,
- struct pipe_buffer *dst_buffer,
+ struct intel_buffer *dst_buffer,
unsigned dst_offset,
short x, short y,
short w, short h,
@@ -78,7 +77,7 @@ i915_fill_blit(struct i915_context *i915,
OUT_BATCH(BR13);
OUT_BATCH((y << 16) | x);
OUT_BATCH(((y + h) << 16) | (x + w));
- OUT_RELOC(dst_buffer, I915_BUFFER_ACCESS_WRITE, dst_offset);
+ OUT_RELOC(dst_buffer, INTEL_USAGE_2D_TARGET, dst_offset);
OUT_BATCH(color);
FLUSH_BATCH(NULL);
}
@@ -88,10 +87,10 @@ i915_copy_blit(struct i915_context *i915,
unsigned do_flip,
unsigned cpp,
unsigned short src_pitch,
- struct pipe_buffer *src_buffer,
+ struct intel_buffer *src_buffer,
unsigned src_offset,
unsigned short dst_pitch,
- struct pipe_buffer *dst_buffer,
+ struct intel_buffer *dst_buffer,
unsigned dst_offset,
short src_x, short src_y,
short dst_x, short dst_y,
@@ -144,9 +143,9 @@ i915_copy_blit(struct i915_context *i915,
OUT_BATCH(BR13);
OUT_BATCH((dst_y << 16) | dst_x);
OUT_BATCH((dst_y2 << 16) | dst_x2);
- OUT_RELOC(dst_buffer, I915_BUFFER_ACCESS_WRITE, dst_offset);
+ OUT_RELOC(dst_buffer, INTEL_USAGE_2D_TARGET, dst_offset);
OUT_BATCH((src_y << 16) | src_x);
OUT_BATCH(((int) src_pitch & 0xffff));
- OUT_RELOC(src_buffer, I915_BUFFER_ACCESS_READ, src_offset);
+ OUT_RELOC(src_buffer, INTEL_USAGE_2D_SOURCE, src_offset);
FLUSH_BATCH(NULL);
}
diff --git a/src/gallium/drivers/i915simple/i915_blit.h b/src/gallium/drivers/i915simple/i915_blit.h
index 2dba57eef0..8ce3220cfd 100644
--- a/src/gallium/drivers/i915simple/i915_blit.h
+++ b/src/gallium/drivers/i915simple/i915_blit.h
@@ -34,10 +34,10 @@ extern void i915_copy_blit(struct i915_context *i915,
unsigned do_flip,
unsigned cpp,
unsigned short src_pitch,
- struct pipe_buffer *src_buffer,
+ struct intel_buffer *src_buffer,
unsigned src_offset,
unsigned short dst_pitch,
- struct pipe_buffer *dst_buffer,
+ struct intel_buffer *dst_buffer,
unsigned dst_offset,
short srcx, short srcy,
short dstx, short dsty,
@@ -46,7 +46,7 @@ extern void i915_copy_blit(struct i915_context *i915,
extern void i915_fill_blit(struct i915_context *i915,
unsigned cpp,
unsigned short dst_pitch,
- struct pipe_buffer *dst_buffer,
+ struct intel_buffer *dst_buffer,
unsigned dst_offset,
short x, short y,
short w, short h, unsigned color);
diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c
index 0f99b1c1b6..b43f735245 100644
--- a/src/gallium/drivers/i915simple/i915_context.c
+++ b/src/gallium/drivers/i915simple/i915_context.c
@@ -26,8 +26,8 @@
**************************************************************************/
#include "i915_context.h"
-#include "i915_winsys.h"
#include "i915_state.h"
+#include "i915_screen.h"
#include "i915_batch.h"
#include "i915_texture.h"
#include "i915_reg.h"
@@ -178,16 +178,14 @@ static void i915_destroy(struct pipe_context *pipe)
draw_destroy(i915->draw);
- if(i915->winsys->destroy)
- i915->winsys->destroy(i915->winsys);
+ if(i915->batch)
+ i915->iws->batchbuffer_destroy(i915->batch);
FREE(i915);
}
struct pipe_context *
-i915_create_context(struct pipe_screen *screen,
- struct pipe_winsys *pipe_winsys,
- struct i915_winsys *i915_winsys)
+i915_create_context(struct pipe_screen *screen)
{
struct i915_context *i915;
@@ -195,8 +193,8 @@ i915_create_context(struct pipe_screen *screen,
if (i915 == NULL)
return NULL;
- i915->winsys = i915_winsys;
- i915->base.winsys = pipe_winsys;
+ i915->iws = i915_screen(screen)->iws;
+ i915->base.winsys = NULL;
i915->base.screen = screen;
i915->base.destroy = i915_destroy;
@@ -233,8 +231,7 @@ i915_create_context(struct pipe_screen *screen,
/* Batch stream debugging is a bit hacked up at the moment:
*/
- i915->batch = i915_winsys->batch_get(i915_winsys);
- i915->batch->winsys = i915_winsys;
+ i915->batch = i915->iws->batchbuffer_create(i915->iws);
return &i915->base;
}
diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h
index 76aec4cd93..234b441ce6 100644
--- a/src/gallium/drivers/i915simple/i915_context.h
+++ b/src/gallium/drivers/i915simple/i915_context.h
@@ -38,6 +38,11 @@
#include "tgsi/tgsi_scan.h"
+struct intel_winsys;
+struct intel_buffer;
+struct intel_batchbuffer;
+
+
#define I915_TEX_UNITS 8
#define I915_DYNAMIC_MODES4 0
@@ -182,7 +187,6 @@ struct i915_sampler_state {
unsigned maxlod;
};
-
struct i915_texture {
struct pipe_texture base;
@@ -192,7 +196,8 @@ struct i915_texture {
unsigned depth_stride; /* per-image on i945? */
unsigned total_nblocksy;
- unsigned tiled;
+ unsigned sw_tiled; /**< tiled with software flags */
+ unsigned hw_tiled; /**< tiled with hardware fences */
unsigned nr_images[PIPE_MAX_TEXTURE_LEVELS];
@@ -206,16 +211,15 @@ struct i915_texture {
/* The data is held here:
*/
- struct pipe_buffer *buffer;
+ struct intel_buffer *buffer;
};
-struct i915_batchbuffer;
-
struct i915_context
{
struct pipe_context base;
- struct i915_winsys *winsys;
+ struct intel_winsys *iws;
+
struct draw_context *draw;
/* The most recent drawing state as set by the driver:
@@ -244,10 +248,10 @@ struct i915_context
unsigned num_vertex_elements;
unsigned num_vertex_buffers;
- struct i915_batchbuffer *batch;
+ struct intel_batchbuffer *batch;
/** Vertex buffer */
- struct pipe_buffer *vbo;
+ struct intel_buffer *vbo;
size_t vbo_offset;
unsigned vbo_flushed;
diff --git a/src/gallium/drivers/i915simple/i915_debug.c b/src/gallium/drivers/i915simple/i915_debug.c
index e08582efab..ce92d1af9a 100644
--- a/src/gallium/drivers/i915simple/i915_debug.c
+++ b/src/gallium/drivers/i915simple/i915_debug.c
@@ -27,7 +27,6 @@
#include "i915_reg.h"
#include "i915_context.h"
-#include "i915_winsys.h"
#include "i915_debug.h"
#include "i915_batch.h"
#include "pipe/internal/p_winsys_screen.h"
@@ -864,7 +863,7 @@ static boolean i915_debug_packet( struct debug_stream *stream )
void
-i915_dump_batchbuffer( struct i915_batchbuffer *batch )
+i915_dump_batchbuffer( struct intel_batchbuffer *batch )
{
struct debug_stream stream;
unsigned *start = (unsigned*)batch->map;
diff --git a/src/gallium/drivers/i915simple/i915_debug.h b/src/gallium/drivers/i915simple/i915_debug.h
index 16ca7277c7..dd9b86e17b 100644
--- a/src/gallium/drivers/i915simple/i915_debug.h
+++ b/src/gallium/drivers/i915simple/i915_debug.h
@@ -104,9 +104,9 @@ I915_DBG(
#endif
-struct i915_batchbuffer;
+struct intel_batchbuffer;
-void i915_dump_batchbuffer( struct i915_batchbuffer *i915 );
+void i915_dump_batchbuffer( struct intel_batchbuffer *i915 );
void i915_debug_init( struct i915_context *i915 );
diff --git a/src/gallium/drivers/i915simple/i915_prim_emit.c b/src/gallium/drivers/i915simple/i915_prim_emit.c
index 8f1f58b2dd..d9a5c40ab9 100644
--- a/src/gallium/drivers/i915simple/i915_prim_emit.c
+++ b/src/gallium/drivers/i915simple/i915_prim_emit.c
@@ -32,7 +32,6 @@
#include "util/u_pack_color.h"
#include "i915_context.h"
-#include "i915_winsys.h"
#include "i915_reg.h"
#include "i915_state.h"
#include "i915_batch.h"
diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
index 656333d897..508f4560e4 100644
--- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
@@ -42,13 +42,11 @@
#include "draw/draw_vbuf.h"
#include "util/u_debug.h"
#include "pipe/p_inlines.h"
-#include "pipe/internal/p_winsys_screen.h"
#include "util/u_math.h"
#include "util/u_memory.h"
#include "i915_context.h"
#include "i915_reg.h"
-#include "i915_winsys.h"
#include "i915_batch.h"
#include "i915_state.h"
@@ -74,7 +72,7 @@ struct i915_vbuf_render {
unsigned fallback;
/* Stuff for the vbo */
- struct pipe_buffer *vbo;
+ struct intel_buffer *vbo;
size_t vbo_size;
size_t vbo_offset;
void *vbo_ptr;
@@ -114,7 +112,7 @@ i915_vbuf_render_allocate_vertices(struct vbuf_render *render,
{
struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
struct i915_context *i915 = i915_render->i915;
- struct pipe_screen *screen = i915->base.screen;
+ struct intel_winsys *iws = i915->iws;
size_t size = (size_t)vertex_size * (size_t)nr_vertices;
/* FIXME: handle failure */
@@ -123,17 +121,17 @@ i915_vbuf_render_allocate_vertices(struct vbuf_render *render,
if (i915_render->vbo_size > size + i915_render->vbo_offset && !i915->vbo_flushed) {
} else {
i915->vbo_flushed = 0;
- if (i915_render->vbo)
- pipe_buffer_reference(&i915_render->vbo, NULL);
+ if (i915_render->vbo) {
+ iws->buffer_destroy(iws, i915_render->vbo);
+ i915_render->vbo = NULL;
+ }
}
if (!i915_render->vbo) {
i915_render->vbo_size = MAX2(size, i915_render->vbo_alloc_size);
i915_render->vbo_offset = 0;
- i915_render->vbo = pipe_buffer_create(screen,
- 64,
- I915_BUFFER_USAGE_LIT_VERTEX,
- i915_render->vbo_size);
+ i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
+ INTEL_NEW_VERTEX);
}
@@ -152,14 +150,12 @@ i915_vbuf_render_map_vertices(struct vbuf_render *render)
{
struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
struct i915_context *i915 = i915_render->i915;
- struct pipe_screen *screen = i915->base.screen;
+ struct intel_winsys *iws = i915->iws;
if (i915->vbo_flushed)
debug_printf("%s bad vbo flush occured stalling on hw\n");
- i915_render->vbo_ptr = pipe_buffer_map(screen,
- i915_render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
+ i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, TRUE);
return (unsigned char *)i915_render->vbo_ptr + i915->vbo_offset;
}
@@ -171,10 +167,10 @@ i915_vbuf_render_unmap_vertices(struct vbuf_render *render,
{
struct i915_vbuf_render *i915_render = i915_vbuf_render(render);
struct i915_context *i915 = i915_render->i915;
- struct pipe_screen *screen = i915->base.screen;
+ struct intel_winsys *iws = i915->iws;
i915_render->vbo_max_used = MAX2(i915_render->vbo_max_used, i915_render->vertex_size * (max_index + 1));
- pipe_buffer_unmap(screen, i915_render->vbo);
+ iws->buffer_unmap(iws, i915_render->vbo);
}
static boolean
@@ -507,7 +503,7 @@ static struct vbuf_render *
i915_vbuf_render_create(struct i915_context *i915)
{
struct i915_vbuf_render *i915_render = CALLOC_STRUCT(i915_vbuf_render);
- struct pipe_screen *screen = i915->base.screen;
+ struct intel_winsys *iws = i915->iws;
i915_render->i915 = i915;
@@ -531,14 +527,11 @@ i915_vbuf_render_create(struct i915_context *i915)
i915_render->vbo_alloc_size = 128 * 4096;
i915_render->vbo_size = i915_render->vbo_alloc_size;
i915_render->vbo_offset = 0;
- i915_render->vbo = pipe_buffer_create(screen,
- 64,
- I915_BUFFER_USAGE_LIT_VERTEX,
- i915_render->vbo_size);
- i915_render->vbo_ptr = pipe_buffer_map(screen,
- i915_render->vbo,
- PIPE_BUFFER_USAGE_CPU_WRITE);
- pipe_buffer_unmap(screen, i915_render->vbo);
+ i915_render->vbo = iws->buffer_create(iws, i915_render->vbo_size, 64,
+ INTEL_NEW_VERTEX);
+ /* TODO JB: is this realy needed? */
+ i915_render->vbo_ptr = iws->buffer_map(iws, i915_render->vbo, TRUE);
+ iws->buffer_unmap(iws, i915_render->vbo);
return &i915_render->base;
}
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index a03d740b1b..9f017a14cc 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -26,17 +26,21 @@
**************************************************************************/
-#include "util/u_memory.h"
-#include "util/u_simple_screen.h"
-#include "pipe/internal/p_winsys_screen.h"
#include "pipe/p_inlines.h"
+#include "util/u_memory.h"
#include "util/u_string.h"
#include "i915_reg.h"
#include "i915_context.h"
#include "i915_screen.h"
+#include "i915_buffer.h"
#include "i915_texture.h"
-#include "i915_winsys.h"
+#include "intel_winsys.h"
+
+
+/*
+ * Probe functions
+ */
static const char *
@@ -187,22 +191,64 @@ i915_is_format_supported(struct pipe_screen *screen,
return FALSE;
}
+
+/*
+ * Fence functions
+ */
+
+
+static void
+i915_fence_reference(struct pipe_screen *screen,
+ struct pipe_fence_handle **ptr,
+ struct pipe_fence_handle *fence)
+{
+ struct i915_screen *is = i915_screen(screen);
+
+ is->iws->fence_reference(is->iws, ptr, fence);
+}
+
+static int
+i915_fence_signalled(struct pipe_screen *screen,
+ struct pipe_fence_handle *fence,
+ unsigned flags)
+{
+ struct i915_screen *is = i915_screen(screen);
+
+ return is->iws->fence_signalled(is->iws, fence);
+}
+
+static int
+i915_fence_finish(struct pipe_screen *screen,
+ struct pipe_fence_handle *fence,
+ unsigned flags)
+{
+ struct i915_screen *is = i915_screen(screen);
+
+ return is->iws->fence_finish(is->iws, fence);
+}
+
+
+/*
+ * Generic functions
+ */
+
+
static void
i915_destroy_screen(struct pipe_screen *screen)
{
- struct pipe_winsys *winsys = screen->winsys;
+ struct i915_screen *is = i915_screen(screen);
- if(winsys->destroy)
- winsys->destroy(winsys);
+ if (is->iws)
+ is->iws->destroy(is->iws);
- FREE(screen);
+ FREE(is);
}
/**
* Create a new i915_screen object
*/
struct pipe_screen *
-i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
+i915_create_screen(struct intel_winsys *iws, uint pci_id)
{
struct i915_screen *is = CALLOC_STRUCT(i915_screen);
@@ -231,8 +277,9 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
}
is->pci_id = pci_id;
+ is->iws = iws;
- is->base.winsys = winsys;
+ is->base.winsys = NULL;
is->base.destroy = i915_destroy_screen;
@@ -242,8 +289,12 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
is->base.get_paramf = i915_get_paramf;
is->base.is_format_supported = i915_is_format_supported;
+ is->base.fence_reference = i915_fence_reference;
+ is->base.fence_signalled = i915_fence_signalled;
+ is->base.fence_finish = i915_fence_finish;
+
i915_init_screen_texture_functions(is);
- u_simple_screen_init(&is->base);
+ i915_init_screen_buffer_functions(is);
return &is->base;
}
diff --git a/src/gallium/drivers/i915simple/i915_screen.h b/src/gallium/drivers/i915simple/i915_screen.h
index 757baa76b8..5126485caa 100644
--- a/src/gallium/drivers/i915simple/i915_screen.h
+++ b/src/gallium/drivers/i915simple/i915_screen.h
@@ -32,6 +32,9 @@
#include "pipe/p_screen.h"
+struct intel_winsys;
+
+
/**
* Subclass of pipe_screen
*/
@@ -39,6 +42,8 @@ struct i915_screen
{
struct pipe_screen base;
+ struct intel_winsys *iws;
+
boolean is_i945;
uint pci_id;
};
diff --git a/src/gallium/drivers/i915simple/i915_state_emit.c b/src/gallium/drivers/i915simple/i915_state_emit.c
index ab361e3d4b..a3d4e3b04e 100644
--- a/src/gallium/drivers/i915simple/i915_state_emit.c
+++ b/src/gallium/drivers/i915simple/i915_state_emit.c
@@ -28,7 +28,6 @@
#include "i915_reg.h"
#include "i915_context.h"
-#include "i915_winsys.h"
#include "i915_batch.h"
#include "i915_reg.h"
@@ -183,7 +182,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
if(i915->vbo)
OUT_RELOC(i915->vbo,
- I915_BUFFER_ACCESS_READ,
+ INTEL_USAGE_VERTEX,
i915->current.immediate[I915_IMMEDIATE_S0]);
else
/* FIXME: we should not do this */
@@ -216,7 +215,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
cbuf_surface->texture;
assert(tex);
- if (tex && tex->tiled) {
+ if (tex && tex->sw_tiled) {
ctile = BUF_3D_TILED_SURFACE;
}
@@ -227,7 +226,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
ctile);
OUT_RELOC(tex->buffer,
- I915_BUFFER_ACCESS_WRITE,
+ INTEL_USAGE_RENDER,
cbuf_surface->offset);
}
@@ -239,7 +238,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
depth_surface->texture;
assert(tex);
- if (tex && tex->tiled) {
+ if (tex && tex->sw_tiled) {
ztile = BUF_3D_TILED_SURFACE;
}
@@ -250,7 +249,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
ztile);
OUT_RELOC(tex->buffer,
- I915_BUFFER_ACCESS_WRITE,
+ INTEL_USAGE_RENDER,
depth_surface->offset);
}
@@ -290,16 +289,13 @@ i915_emit_hardware_state(struct i915_context *i915 )
OUT_BATCH(enabled);
for (unit = 0; unit < I915_TEX_UNITS; unit++) {
if (enabled & (1 << unit)) {
- struct pipe_buffer *buf =
- i915->texture[unit]->buffer;
+ struct intel_buffer *buf = i915->texture[unit]->buffer;
uint offset = 0;
assert(buf);
count++;
- OUT_RELOC(buf,
- I915_BUFFER_ACCESS_READ,
- offset);
+ OUT_RELOC(buf, INTEL_USAGE_SAMPLER, offset);
OUT_BATCH(i915->current.texbuffer[unit][0]); /* MS3 */
OUT_BATCH(i915->current.texbuffer[unit][1]); /* MS4 */
}
diff --git a/src/gallium/drivers/i915simple/i915_state_sampler.c b/src/gallium/drivers/i915simple/i915_state_sampler.c
index 3667ed1afa..c5e9084d12 100644
--- a/src/gallium/drivers/i915simple/i915_state_sampler.c
+++ b/src/gallium/drivers/i915simple/i915_state_sampler.c
@@ -247,7 +247,7 @@ i915_update_texture(struct i915_context *i915,
assert(format);
assert(pitch);
- if (tex->tiled) {
+ if (tex->sw_tiled) {
assert(!((pitch - 1) & pitch));
tiled = MS3_TILED_SURFACE;
}
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 5cb62b164f..6a6c654271 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -42,7 +42,7 @@
#include "i915_texture.h"
#include "i915_debug.h"
#include "i915_screen.h"
-#include "i915_winsys.h"
+#include "intel_winsys.h"
/*
@@ -173,27 +173,22 @@ i915_scanout_layout(struct i915_texture *tex)
1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
-#if 0 /* TODO use this code when backend is smarter */
if (tex->base.width[0] >= 240) {
tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
-#else
- if (tex->base.width[0] >= 240) {
- tex->stride = 2048 * 4;
- tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
-#endif
+ tex->hw_tiled = INTEL_TILE_X;
} else if (tex->base.width[0] == 64 && tex->base.height[0] == 64) {
tex->stride = power_of_two(tex->base.nblocksx[0] * pt->block.size);
tex->total_nblocksy = round_up(tex->base.nblocksy[0], 8);
} else {
- return 0;
+ return FALSE;
}
debug_printf("%s size: %d,%d,%d offset %d,%d (0x%x)\n", __FUNCTION__,
tex->base.width[0], tex->base.height[0], pt->block.size,
tex->stride, tex->total_nblocksy, tex->stride * tex->total_nblocksy);
- return 1;
+ return TRUE;
}
static void
@@ -596,7 +591,8 @@ static struct pipe_texture *
i915_texture_create(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
- struct i915_screen *i915screen = i915_screen(screen);
+ struct i915_screen *is = i915_screen(screen);
+ struct intel_winsys *iws = is->iws;
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
size_t tex_size;
unsigned buf_usage = 0;
@@ -611,7 +607,7 @@ i915_texture_create(struct pipe_screen *screen,
tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
tex->base.nblocksy[0] = pf_get_nblocksy(&tex->base.block, tex->base.height[0]);
- if (i915screen->is_i945) {
+ if (is->is_i945) {
if (!i945_miptree_layout(tex))
goto fail;
} else {
@@ -621,17 +617,25 @@ i915_texture_create(struct pipe_screen *screen,
tex_size = tex->stride * tex->total_nblocksy;
- buf_usage = PIPE_BUFFER_USAGE_PIXEL;
- /* for scanouts and cursors, cursors don't have the scanout tag */
- if (templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY && templat->width[0] != 64)
- buf_usage |= I915_BUFFER_USAGE_SCANOUT;
- tex->buffer = screen->buffer_create(screen, 64, buf_usage, tex_size);
+ /* for scanouts and cursors, cursors arn't scanouts */
+ if (templat->tex_usage & PIPE_TEXTURE_USAGE_PRIMARY && templat->width[0] != 64)
+ buf_usage = INTEL_NEW_SCANOUT;
+ else
+ buf_usage = INTEL_NEW_TEXTURE;
+ tex->buffer = iws->buffer_create(iws, tex_size, 64, buf_usage);
if (!tex->buffer)
goto fail;
+ /* setup any hw fences */
+ if (tex->hw_tiled) {
+ assert(tex->sw_tiled == INTEL_TILE_NONE);
+ iws->buffer_set_fence_reg(iws, tex->buffer, tex->stride, tex->hw_tiled);
+ }
+
+
#if 0
void *ptr = ws->buffer_map(ws, tex->buffer,
PIPE_BUFFER_USAGE_CPU_WRITE);
@@ -652,6 +656,7 @@ i915_texture_blanket(struct pipe_screen * screen,
const unsigned *stride,
struct pipe_buffer *buffer)
{
+#if 0
struct i915_texture *tex;
assert(screen);
@@ -678,19 +683,23 @@ i915_texture_blanket(struct pipe_screen * screen,
pipe_buffer_reference(&tex->buffer, buffer);
return &tex->base;
+#else
+ return NULL;
+#endif
}
static void
i915_texture_destroy(struct pipe_texture *pt)
{
struct i915_texture *tex = (struct i915_texture *)pt;
+ struct intel_winsys *iws = i915_screen(pt->screen)->iws;
uint i;
/*
DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- pipe_buffer_reference(&tex->buffer, NULL);
+ iws->buffer_destroy(iws, tex->buffer);
for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
if (tex->image_offset[i])
@@ -799,23 +808,17 @@ i915_transfer_map(struct pipe_screen *screen,
struct pipe_transfer *transfer)
{
struct i915_texture *tex = (struct i915_texture *)transfer->texture;
+ struct intel_winsys *iws = i915_screen(tex->base.screen)->iws;
char *map;
- unsigned flags = 0;
-
- if (transfer->usage != PIPE_TRANSFER_WRITE)
- flags |= PIPE_BUFFER_USAGE_CPU_READ;
+ boolean write = FALSE;
if (transfer->usage != PIPE_TRANSFER_READ)
- flags |= PIPE_BUFFER_USAGE_CPU_WRITE;
+ write = TRUE;
- map = pipe_buffer_map(screen, tex->buffer, flags);
+ map = iws->buffer_map(iws, tex->buffer, write);
if (map == NULL)
return NULL;
- if (flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
- /* XXX Do something to notify contexts of a texture change. */
- }
-
return map + i915_transfer(transfer)->offset +
transfer->y / transfer->block.height * transfer->stride +
transfer->x / transfer->block.width * transfer->block.size;
@@ -826,7 +829,8 @@ i915_transfer_unmap(struct pipe_screen *screen,
struct pipe_transfer *transfer)
{
struct i915_texture *tex = (struct i915_texture *)transfer->texture;
- pipe_buffer_unmap(screen, tex->buffer);
+ struct intel_winsys *iws = i915_screen(tex->base.screen)->iws;
+ iws->buffer_unmap(iws, tex->buffer);
}
static void
@@ -856,19 +860,52 @@ i915_init_screen_texture_functions(struct i915_screen *is)
is->base.tex_transfer_destroy = i915_tex_transfer_destroy;
}
-boolean i915_get_texture_buffer(struct pipe_texture *texture,
- struct pipe_buffer **buf,
- unsigned *stride)
+struct pipe_texture *
+i915_texture_blanket_intel(struct pipe_screen *screen,
+ struct pipe_texture *base,
+ unsigned stride,
+ struct intel_buffer *buffer)
{
- struct i915_texture *tex = (struct i915_texture *)texture;
+ struct i915_texture *tex;
+ assert(screen);
+ /* Only supports one type */
+ if (base->target != PIPE_TEXTURE_2D ||
+ base->last_level != 0 ||
+ base->depth[0] != 1) {
+ return NULL;
+ }
+
+ tex = CALLOC_STRUCT(i915_texture);
if (!tex)
- return FALSE;
+ return NULL;
+
+ tex->base = *base;
+ pipe_reference_init(&tex->base.reference, 1);
+ tex->base.screen = screen;
- pipe_buffer_reference(buf, tex->buffer);
+ tex->stride = stride;
+
+ i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
+ i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
+
+ tex->buffer = buffer;
+
+ return &tex->base;
+}
+
+boolean
+i915_get_texture_buffer_intel(struct pipe_texture *texture,
+ struct intel_buffer **buffer,
+ unsigned *stride)
+{
+ struct i915_texture *tex = (struct i915_texture *)texture;
+
+ if (!texture)
+ return FALSE;
- if (stride)
- *stride = tex->stride;
+ *stride = tex->stride;
+ *buffer = tex->buffer;
return TRUE;
}
diff --git a/src/gallium/drivers/i915simple/i915_winsys.h b/src/gallium/drivers/i915simple/i915_winsys.h
deleted file mode 100644
index 711db91c36..0000000000
--- a/src/gallium/drivers/i915simple/i915_winsys.h
+++ /dev/null
@@ -1,144 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
- * All Rights Reserved.
- *
- * Permission is hereby granted, free of charge, to any person obtaining a
- * copy of this software and associated documentation files (the
- * "Software"), to deal in the Software without restriction, including
- * without limitation the rights to use, copy, modify, merge, publish,
- * distribute, sub license, and/or sell copies of the Software, and to
- * permit persons to whom the Software is furnished to do so, subject to
- * the following conditions:
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
- * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
- * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
- * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
- * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- **************************************************************************/
-
-/**
- * \file
- * This is the interface that i915simple requires any window system
- * hosting it to implement. This is the only include file in i915simple
- * which is public.
- *
- * This isn't currently true as the winsys needs i915_batchbuffer.h
- */
-
-#ifndef I915_WINSYS_H
-#define I915_WINSYS_H
-
-
-#include "pipe/p_defines.h"
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-
-/* Pipe drivers are independent of both GL and the window system.
- * The window system provides a buffer manager and a set of additional
- * hooks for things like command buffer submission, etc.
- *
- * There clearly has to be some agreement between the window system
- * driver and the hardware driver about the format of command buffers,
- * etc.
- */
-
-struct i915_batchbuffer;
-struct pipe_texture;
-struct pipe_buffer;
-struct pipe_fence_handle;
-struct pipe_winsys;
-struct pipe_screen;
-
-
-/**
- * Additional winsys interface for i915simple.
- *
- * It is an over-simple batchbuffer mechanism. Will want to improve the
- * performance of this, perhaps based on the cmdstream stuff. It
- * would be pretty impossible to implement swz on top of this
- * interface.
- *
- * Will also need additions/changes to implement static/dynamic
- * indirect state.
- */
-struct i915_winsys {
-
- void (*destroy)( struct i915_winsys *sws );
-
- /**
- * Get the current batch buffer from the winsys.
- */
- struct i915_batchbuffer *(*batch_get)( struct i915_winsys *sws );
-
- /**
- * Emit a relocation to a buffer.
- *
- * Used not only when the buffer addresses are not pinned, but also to
- * ensure refered buffers will not be destroyed until the current batch
- * buffer execution is finished.
- *
- * The access flags is a combination of I915_BUFFER_ACCESS_WRITE and
- * I915_BUFFER_ACCESS_READ macros.
- */
- void (*batch_reloc)( struct i915_winsys *sws,
- struct pipe_buffer *buf,
- unsigned access_flags,
- unsigned delta );
-
- /**
- * Flush the batch.
- */
- void (*batch_flush)( struct i915_winsys *sws,
- struct pipe_fence_handle **fence );
-};
-
-#define I915_BUFFER_ACCESS_WRITE 0x1
-#define I915_BUFFER_ACCESS_READ 0x2
-
-#define I915_BUFFER_USAGE_LIT_VERTEX (PIPE_BUFFER_USAGE_CUSTOM << 0)
-#define I915_BUFFER_USAGE_SCANOUT (PIPE_BUFFER_USAGE_CUSTOM << 1)
-
-
-/**
- * Create i915 pipe_screen.
- */
-struct pipe_screen *i915_create_screen( struct pipe_winsys *winsys,
- uint pci_id );
-
-/**
- * Create a i915 pipe_context.
- */
-struct pipe_context *i915_create_context( struct pipe_screen *screen,
- struct pipe_winsys *winsys,
- struct i915_winsys *i915 );
-
-/**
- * Used for the winsys to get the buffer used for a texture
- * and also the stride used for the texture.
- *
- * Buffer is referenced for you so you need to unref after use.
- *
- * This is needed for example kms.
- */
-boolean i915_get_texture_buffer( struct pipe_texture *texture,
- struct pipe_buffer **buf,
- unsigned *stride );
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
diff --git a/src/gallium/drivers/i915simple/intel_batchbuffer.h b/src/gallium/drivers/i915simple/intel_batchbuffer.h
new file mode 100644
index 0000000000..db12dfd2ac
--- /dev/null
+++ b/src/gallium/drivers/i915simple/intel_batchbuffer.h
@@ -0,0 +1,87 @@
+/**************************************************************************
+ *
+ * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the
+ * "Software"), to deal in the Software without restriction, including
+ * without limitation the rights to use, copy, modify, merge, publish,
+ * distribute, sub license, and/or sell copies of the Software, and to
+ * permit persons to whom the Software is furnished to do so, subject to
+ * the following conditions:
+ *
+ * The above copyright notice and this permission notice (including the
+ * next paragraph) shall be included in all copies or substantial portions
+ * of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+ * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
+ * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+ * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+ * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ **************************************************************************/
+
+#ifndef INTEL_BATCH_H
+#define INTEL_BATCH_H
+
+#include "intel_winsys.h"
+
+static INLINE boolean
+intel_batchbuffer_check(struct intel_batchbuffer *batch,
+ size_t dwords,
+ size_t relocs)
+{
+ return dwords * 4 <= batch->size - (batch->ptr - batch->map) &&
+ relocs <= (batch->max_relocs - batch->relocs);
+}
+
+static INLINE size_t
+intel_batchbuffer_space(struct intel_batchbuffer *batch)
+{
+ return batch->size - (batch->ptr - batch->map);
+}
+
+static INLINE void
+intel_batchbuffer_dword(struct intel_batchbuffer *batch,
+ unsigned dword)
+{
+ if (intel_batchbuffer_space(batch) < 4)
+ return;
+
+ *(unsigned *)batch->ptr = dword;
+ batch->ptr += 4;
+}
+
+static INLINE void
+intel_batchbuffer_write(struct intel_batchbuffer *batch,
+ void *data,
+ size_t size)
+{
+ if (intel_batchbuffer_space(batch) < size)
+ return;
+
+ memcpy(data, batch->ptr, size);
+ batch->ptr += size;
+}
+
+static INLINE int
+intel_batchbuffer_reloc(struct intel_batchbuffer *batch,
+ struct intel_buffer *buffer,
+ enum intel_buffer_usage usage,
+ size_t offset)
+{
+ return batch->iws->batchbuffer_reloc(batch, buffer, usage, offset);
+}
+
+static INLINE void
+intel_batchbuffer_flush(struct intel_batchbuffer *batch,
+ struct pipe_fence_handle **fence)
+{
+ batch->iws->batchbuffer_flush(batch, fence);
+}
+
+#endif