summaryrefslogtreecommitdiffstats
path: root/src/mesa/pipe/i915simple
diff options
context:
space:
mode:
authorKeith Whitwell <[email protected]>2007-08-10 15:31:26 +0100
committerKeith Whitwell <[email protected]>2007-08-10 15:35:48 +0100
commit47fc2c4349746997704a7f81dffadd22363e0ff1 (patch)
treeda53b452a03ad6909a1b9b95db565fa7a73a511e /src/mesa/pipe/i915simple
parent12e3bb1a65bbff82dabc64110249c57a711501c1 (diff)
Lift common winsys functions into pipe's new p_winsys.
Diffstat (limited to 'src/mesa/pipe/i915simple')
-rw-r--r--src/mesa/pipe/i915simple/Makefile1
-rw-r--r--src/mesa/pipe/i915simple/i915_buffer.c121
-rw-r--r--src/mesa/pipe/i915simple/i915_context.c17
-rw-r--r--src/mesa/pipe/i915simple/i915_context.h3
-rw-r--r--src/mesa/pipe/i915simple/i915_debug.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_debug.h10
-rw-r--r--src/mesa/pipe/i915simple/i915_debug_fp.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_flush.c7
-rw-r--r--src/mesa/pipe/i915simple/i915_regions.c26
-rw-r--r--src/mesa/pipe/i915simple/i915_state.c2
-rw-r--r--src/mesa/pipe/i915simple/i915_winsys.h58
11 files changed, 38 insertions, 211 deletions
diff --git a/src/mesa/pipe/i915simple/Makefile b/src/mesa/pipe/i915simple/Makefile
index 5b919e3bed6..28fe70d0693 100644
--- a/src/mesa/pipe/i915simple/Makefile
+++ b/src/mesa/pipe/i915simple/Makefile
@@ -6,7 +6,6 @@ LIBNAME = i915simple
DRIVER_SOURCES = \
i915_blit.c \
- i915_buffer.c \
i915_clear.c \
i915_flush.c \
i915_context.c \
diff --git a/src/mesa/pipe/i915simple/i915_buffer.c b/src/mesa/pipe/i915simple/i915_buffer.c
deleted file mode 100644
index 680213182b4..00000000000
--- a/src/mesa/pipe/i915simple/i915_buffer.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/**************************************************************************
- *
- * Copyright 2006 Tungsten Graphics, Inc., Bismarck, ND., USA
- * 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 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
- * THE COPYRIGHT HOLDERS, AUTHORS 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.
- *
- * The above copyright notice and this permission notice (including the
- * next paragraph) shall be included in all copies or substantial portions
- * of the Software.
- *
- *
- **************************************************************************/
-/*
- * Authors: Keith Whitwell <keithw-at-tungstengraphics-dot-com>
- */
-
-#include <stdlib.h>
-#include "i915_context.h"
-#include "i915_winsys.h"
-
-
-
-/* Most callbacks map direcly onto winsys operations at the moment,
- * but this may change, especially as state_trackers and winsys's
- * evolve in separate directions... Don't try and remove this yet.
- */
-static struct pipe_buffer_handle *
-i915_buffer_create(struct pipe_context *pipe,
- unsigned alignment,
- unsigned flags)
-{
- struct i915_context *i915 = i915_context( pipe );
- return i915->winsys->buffer_create( i915->winsys, alignment );
-}
-
-static void *i915_buffer_map(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned flags )
-{
- struct i915_context *i915 = i915_context( pipe );
- return i915->winsys->buffer_map( i915->winsys, buf );
-}
-
-static void i915_buffer_unmap(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_unmap( i915->winsys, buf );
-}
-
-static struct pipe_buffer_handle *
-i915_buffer_reference(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf)
-{
- struct i915_context *i915 = i915_context( pipe );
- return i915->winsys->buffer_reference( i915->winsys, buf );
-}
-
-static void i915_buffer_unreference(struct pipe_context *pipe,
- struct pipe_buffer_handle **buf)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_unreference( i915->winsys, buf );
-}
-
-static void i915_buffer_data(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data )
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_data( i915->winsys, buf, size, data );
-}
-
-static void i915_buffer_subdata(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_subdata( i915->winsys, buf, offset, size, data );
-}
-
-static void i915_buffer_get_subdata(struct pipe_context *pipe,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data)
-{
- struct i915_context *i915 = i915_context( pipe );
- i915->winsys->buffer_get_subdata( i915->winsys, buf, offset, size, data );
-}
-
-
-void
-i915_init_buffer_functions( struct i915_context *i915 )
-{
- i915->pipe.create_buffer = i915_buffer_create;
- i915->pipe.buffer_map = i915_buffer_map;
- i915->pipe.buffer_unmap = i915_buffer_unmap;
- i915->pipe.buffer_reference = i915_buffer_reference;
- i915->pipe.buffer_unreference = i915_buffer_unreference;
- i915->pipe.buffer_data = i915_buffer_data;
- i915->pipe.buffer_subdata = i915_buffer_subdata;
- i915->pipe.buffer_get_subdata = i915_buffer_get_subdata;
-}
diff --git a/src/mesa/pipe/i915simple/i915_context.c b/src/mesa/pipe/i915simple/i915_context.c
index d8e54f02ee8..ee6cfe2ed48 100644
--- a/src/mesa/pipe/i915simple/i915_context.c
+++ b/src/mesa/pipe/i915simple/i915_context.c
@@ -29,10 +29,12 @@
#include "i915_context.h"
#include "i915_winsys.h"
#include "i915_state.h"
+#include "i915_batch.h"
#include "i915_tex_layout.h"
#include "pipe/draw/draw_context.h"
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#define PCI_CHIP_I915_G 0x2582
#define PCI_CHIP_I915_GM 0x2592
@@ -152,7 +154,8 @@ i915_draw_vertices(struct pipe_context *pipe,
-struct pipe_context *i915_create( struct i915_winsys *winsys,
+struct pipe_context *i915_create( struct pipe_winsys *pipe_winsys,
+ struct i915_winsys *i915_winsys,
unsigned pci_id )
{
struct i915_context *i915;
@@ -175,8 +178,9 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
break;
default:
- winsys->printf(winsys, "%s: unknown pci id 0x%x, cannot create context\n",
- __FUNCTION__, pci_id);
+ pipe_winsys->printf(pipe_winsys,
+ "%s: unknown pci id 0x%x, cannot create context\n",
+ __FUNCTION__, pci_id);
return NULL;
}
@@ -184,6 +188,9 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
if (i915 == NULL)
return NULL;
+ i915->winsys = i915_winsys;
+ i915->pipe.winsys = pipe_winsys;
+
i915->pipe.destroy = i915_destroy;
i915->pipe.supported_formats = i915_supported_formats;
i915->pipe.draw_vb = i915_draw_vb;
@@ -192,7 +199,6 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
i915->pipe.reset_occlusion_counter = NULL; /* no support */
i915->pipe.get_occlusion_counter = NULL;
- i915->winsys = winsys;
/*
* Create drawing context and plug our rendering stage into it.
@@ -201,7 +207,6 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
assert(i915->draw);
draw_set_setup_stage(i915->draw, i915_draw_render_stage(i915));
- i915_init_buffer_functions(i915);
i915_init_region_functions(i915);
i915_init_surface_functions(i915);
i915_init_state_functions(i915);
@@ -219,7 +224,7 @@ struct pipe_context *i915_create( struct i915_winsys *winsys,
/* Batch stream debugging is a bit hacked up at the moment:
*/
- i915->batch_start = winsys->batch_start( winsys, 0, 0 );
+ i915->batch_start = BEGIN_BATCH(0, 0);
/*
* XXX we could plug GL selection/feedback into the drawing pipeline
diff --git a/src/mesa/pipe/i915simple/i915_context.h b/src/mesa/pipe/i915simple/i915_context.h
index e8db2b7c363..7a73a8d8d07 100644
--- a/src/mesa/pipe/i915simple/i915_context.h
+++ b/src/mesa/pipe/i915simple/i915_context.h
@@ -182,9 +182,8 @@ void i915_clear(struct pipe_context *pipe, struct pipe_surface *ps,
/***********************************************************************
- * i915_buffer.c:
+ * i915_region.c:
*/
-void i915_init_buffer_functions( struct i915_context *i915 );
void i915_init_region_functions( struct i915_context *i915 );
void i915_init_surface_functions( struct i915_context *i915 );
void i915_init_state_functions( struct i915_context *i915 );
diff --git a/src/mesa/pipe/i915simple/i915_debug.c b/src/mesa/pipe/i915simple/i915_debug.c
index 0ea6f03e494..8050eb0bf5d 100644
--- a/src/mesa/pipe/i915simple/i915_debug.c
+++ b/src/mesa/pipe/i915simple/i915_debug.c
@@ -423,7 +423,7 @@ i915_dump_batchbuffer( struct i915_context *i915,
stream.offset = 0;
stream.ptr = (char *)start;
stream.print_addresses = 0;
- stream.winsys = i915->winsys;
+ stream.winsys = i915->pipe.winsys;
while (!done &&
stream.offset < bytes &&
diff --git a/src/mesa/pipe/i915simple/i915_debug.h b/src/mesa/pipe/i915simple/i915_debug.h
index f0f72780d3e..0ea131171ef 100644
--- a/src/mesa/pipe/i915simple/i915_debug.h
+++ b/src/mesa/pipe/i915simple/i915_debug.h
@@ -39,7 +39,7 @@ struct debug_stream
char *ptr; /* pointer to gtt offset zero */
char *end; /* pointer to gtt offset zero */
unsigned print_addresses;
- struct i915_winsys *winsys;
+ struct pipe_winsys *winsys;
};
@@ -68,9 +68,11 @@ void i915_print_ureg(const char *msg, unsigned ureg);
#define DEBUG_WINSYS 0x4000
#ifdef DEBUG
-#include "i915_winsys.h"
-#define DBG( i915, ... ) \
- if ((i915)->debug & FILE_DEBUG_FLAG) (i915)->winsys->printf( (i915)->winsys, __VA_ARGS__ )
+#include "pipe/p_winsys.h"
+#define DBG( i915, ... ) do { \
+ if ((i915)->debug & FILE_DEBUG_FLAG) \
+ (i915)->pipe.winsys->printf( (i915)->pipe.winsys, __VA_ARGS__ ); \
+} while(0)
#else
#define DBG( i915, ... ) \
(void)i915
diff --git a/src/mesa/pipe/i915simple/i915_debug_fp.c b/src/mesa/pipe/i915simple/i915_debug_fp.c
index 95476d3c559..d99c609d483 100644
--- a/src/mesa/pipe/i915simple/i915_debug_fp.c
+++ b/src/mesa/pipe/i915simple/i915_debug_fp.c
@@ -29,7 +29,7 @@
#include "i915_reg.h"
#include "i915_debug.h"
-#include "i915_winsys.h"
+#include "pipe/p_winsys.h"
//#include "i915_fpc.h"
#include "shader/program.h"
#include "shader/prog_instruction.h"
diff --git a/src/mesa/pipe/i915simple/i915_flush.c b/src/mesa/pipe/i915simple/i915_flush.c
index 8af4ce770cf..9a31342cbd3 100644
--- a/src/mesa/pipe/i915simple/i915_flush.c
+++ b/src/mesa/pipe/i915simple/i915_flush.c
@@ -66,16 +66,9 @@ static void i915_flush( struct pipe_context *pipe,
FLUSH_BATCH();
}
-static void i915_wait_idle(struct pipe_context *pipe)
-{
- struct i915_context *i915 = i915_context(pipe);
-
- i915->winsys->batch_wait_idle( i915->winsys );
-}
void i915_init_flush_functions( struct i915_context *i915 )
{
i915->pipe.flush = i915_flush;
- i915->pipe.wait_idle = i915_wait_idle;
}
diff --git a/src/mesa/pipe/i915simple/i915_regions.c b/src/mesa/pipe/i915simple/i915_regions.c
index 886b0895061..9b7cddb58dc 100644
--- a/src/mesa/pipe/i915simple/i915_regions.c
+++ b/src/mesa/pipe/i915simple/i915_regions.c
@@ -32,8 +32,8 @@
*/
#include "pipe/p_defines.h"
+#include "pipe/p_winsys.h"
#include "i915_context.h"
-#include "i915_winsys.h"
#include "i915_blit.h"
@@ -50,8 +50,10 @@ i915_region_map(struct pipe_context *pipe, struct pipe_region *region)
struct i915_context *i915 = i915_context( pipe );
if (!region->map_refcount++) {
- region->map = i915->winsys->buffer_map( i915->winsys,
- region->buffer );
+ region->map = i915->pipe.winsys->buffer_map( i915->pipe.winsys,
+ region->buffer,
+ PIPE_BUFFER_FLAG_WRITE |
+ PIPE_BUFFER_FLAG_READ);
}
return region->map;
@@ -63,8 +65,8 @@ i915_region_unmap(struct pipe_context *pipe, struct pipe_region *region)
struct i915_context *i915 = i915_context( pipe );
if (!--region->map_refcount) {
- i915->winsys->buffer_unmap( i915->winsys,
- region->buffer );
+ i915->pipe.winsys->buffer_unmap( i915->pipe.winsys,
+ region->buffer );
region->map = NULL;
}
}
@@ -97,12 +99,12 @@ i915_region_alloc(struct pipe_context *pipe,
region->height = height; /* needed? */
region->refcount = 1;
- region->buffer = i915->winsys->buffer_create( i915->winsys, alignment );
+ region->buffer = i915->pipe.winsys->buffer_create( i915->pipe.winsys, alignment );
- i915->winsys->buffer_data( i915->winsys,
- region->buffer,
- pitch * cpp * height,
- NULL );
+ i915->pipe.winsys->buffer_data( i915->pipe.winsys,
+ region->buffer,
+ pitch * cpp * height,
+ NULL );
return region;
}
@@ -121,8 +123,8 @@ i915_region_release(struct pipe_context *pipe, struct pipe_region **region)
if ((*region)->refcount == 0) {
assert((*region)->map_refcount == 0);
- i915->winsys->buffer_unreference( i915->winsys,
- (*region)->buffer );
+ i915->pipe.winsys->buffer_unreference( i915->pipe.winsys,
+ (*region)->buffer );
free(*region);
}
*region = NULL;
diff --git a/src/mesa/pipe/i915simple/i915_state.c b/src/mesa/pipe/i915simple/i915_state.c
index ab00cbc822f..22a5bf68b4c 100644
--- a/src/mesa/pipe/i915simple/i915_state.c
+++ b/src/mesa/pipe/i915simple/i915_state.c
@@ -148,7 +148,7 @@ static void i915_set_texture_state(struct pipe_context *pipe,
static void i915_set_framebuffer_state(struct pipe_context *pipe,
- const struct pipe_framebuffer_state *fb)
+ const struct pipe_framebuffer_state *fb)
{
struct i915_context *i915 = i915_context(pipe);
diff --git a/src/mesa/pipe/i915simple/i915_winsys.h b/src/mesa/pipe/i915simple/i915_winsys.h
index a3dadbfd3d6..803ee9073c2 100644
--- a/src/mesa/pipe/i915simple/i915_winsys.h
+++ b/src/mesa/pipe/i915simple/i915_winsys.h
@@ -47,57 +47,10 @@
*/
struct pipe_buffer_handle;
+struct pipe_winsys;
struct i915_winsys {
- /* Do any special operations to ensure frontbuffer contents are
- * displayed, eg copy fake frontbuffer.
- */
- void (*flush_frontbuffer)( struct i915_winsys *sws );
-
-
- /* debug output
- */
- void (*printf)( struct i915_winsys *sws,
- const char *, ... );
-
- /* Many of the winsys's are probably going to have a similar
- * buffer-manager interface, as something almost identical is
- * currently exposed in the pipe interface. Probably want to avoid
- * endless repetition of this code somehow.
- */
- struct pipe_buffer_handle *(*buffer_create)(struct i915_winsys *sws,
- unsigned alignment );
-
- void *(*buffer_map)( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- void (*buffer_unmap)( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- struct pipe_buffer_handle *(*buffer_reference)( struct i915_winsys *sws,
- struct pipe_buffer_handle *buf );
-
- void (*buffer_unreference)( struct i915_winsys *sws,
- struct pipe_buffer_handle **buf );
-
- void (*buffer_data)(struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned size, const void *data );
-
- void (*buffer_subdata)(struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- const void *data);
-
- void (*buffer_get_subdata)(struct i915_winsys *sws,
- struct pipe_buffer_handle *buf,
- unsigned long offset,
- unsigned long size,
- void *data);
-
-
/* 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
@@ -116,20 +69,15 @@ struct i915_winsys {
unsigned access_flags,
unsigned delta );
void (*batch_flush)( struct i915_winsys *sws );
- void (*batch_wait_idle)( struct i915_winsys *sws );
-
- /* Printf???
- */
- void (*dpf)( const char *fmt, ... );
-
};
#define I915_BUFFER_ACCESS_WRITE 0x1
#define I915_BUFFER_ACCESS_READ 0x2
-struct pipe_context *i915_create( struct i915_winsys *,
+struct pipe_context *i915_create( struct pipe_winsys *,
+ struct i915_winsys *,
unsigned pci_id );