From ad25d450ec2a0f04f628c58f89fe9f2c7b4d3bf3 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 29 Aug 2009 11:32:32 +0100 Subject: i915g: Rename screen field on screen to base --- src/gallium/drivers/i915simple/i915_screen.c | 28 ++++++++++++++-------------- src/gallium/drivers/i915simple/i915_screen.h | 3 ++- 2 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c index a3de38d586..c9a9e90f0e 100644 --- a/src/gallium/drivers/i915simple/i915_screen.c +++ b/src/gallium/drivers/i915simple/i915_screen.c @@ -328,22 +328,22 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id) i915screen->pci_id = pci_id; - i915screen->screen.winsys = winsys; + i915screen->base.winsys = winsys; - i915screen->screen.destroy = i915_destroy_screen; + i915screen->base.destroy = i915_destroy_screen; - i915screen->screen.get_name = i915_get_name; - i915screen->screen.get_vendor = i915_get_vendor; - i915screen->screen.get_param = i915_get_param; - i915screen->screen.get_paramf = i915_get_paramf; - i915screen->screen.is_format_supported = i915_is_format_supported; - i915screen->screen.get_tex_transfer = i915_get_tex_transfer; - i915screen->screen.tex_transfer_destroy = i915_tex_transfer_destroy; - i915screen->screen.transfer_map = i915_transfer_map; - i915screen->screen.transfer_unmap = i915_transfer_unmap; + i915screen->base.get_name = i915_get_name; + i915screen->base.get_vendor = i915_get_vendor; + i915screen->base.get_param = i915_get_param; + i915screen->base.get_paramf = i915_get_paramf; + i915screen->base.is_format_supported = i915_is_format_supported; + i915screen->base.get_tex_transfer = i915_get_tex_transfer; + i915screen->base.tex_transfer_destroy = i915_tex_transfer_destroy; + i915screen->base.transfer_map = i915_transfer_map; + i915screen->base.transfer_unmap = i915_transfer_unmap; - i915_init_screen_texture_functions(&i915screen->screen); - u_simple_screen_init(&i915screen->screen); + i915_init_screen_texture_functions(&i915screen->base); + u_simple_screen_init(&i915screen->base); - return &i915screen->screen; + return &i915screen->base; } diff --git a/src/gallium/drivers/i915simple/i915_screen.h b/src/gallium/drivers/i915simple/i915_screen.h index 5284c32595..7d5f0f05a5 100644 --- a/src/gallium/drivers/i915simple/i915_screen.h +++ b/src/gallium/drivers/i915simple/i915_screen.h @@ -30,6 +30,7 @@ #define I915_SCREEN_H +#include "pipe/p_state.h" #include "pipe/p_screen.h" @@ -43,7 +44,7 @@ extern "C" { */ struct i915_screen { - struct pipe_screen screen; + struct pipe_screen base; boolean is_i945; uint pci_id; -- cgit v1.2.3 From e1741dbe45ef1f43432457fab088275ecf953d17 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 29 Aug 2009 11:46:46 +0100 Subject: i915g: Rename pipe field on context to base --- src/gallium/drivers/i915simple/i915_context.c | 24 ++++----- src/gallium/drivers/i915simple/i915_context.h | 3 +- src/gallium/drivers/i915simple/i915_flush.c | 2 +- src/gallium/drivers/i915simple/i915_prim_vbuf.c | 8 +-- src/gallium/drivers/i915simple/i915_state.c | 68 ++++++++++++------------- src/gallium/drivers/i915simple/i915_surface.c | 4 +- 6 files changed, 55 insertions(+), 54 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index bf69c8e9f5..132ed31f38 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -179,20 +179,20 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, return NULL; i915->winsys = i915_winsys; - i915->pipe.winsys = pipe_winsys; - i915->pipe.screen = screen; + i915->base.winsys = pipe_winsys; + i915->base.screen = screen; - i915->pipe.destroy = i915_destroy; + i915->base.destroy = i915_destroy; - i915->pipe.clear = i915_clear; + i915->base.clear = i915_clear; - i915->pipe.draw_arrays = i915_draw_arrays; - i915->pipe.draw_elements = i915_draw_elements; - i915->pipe.draw_range_elements = i915_draw_range_elements; + i915->base.draw_arrays = i915_draw_arrays; + i915->base.draw_elements = i915_draw_elements; + i915->base.draw_range_elements = i915_draw_range_elements; - i915->pipe.is_texture_referenced = i915_is_texture_referenced; - i915->pipe.is_buffer_referenced = i915_is_buffer_referenced; + i915->base.is_texture_referenced = i915_is_texture_referenced; + i915->base.is_buffer_referenced = i915_is_buffer_referenced; /* * Create drawing context and plug our rendering stage into it. @@ -211,8 +211,8 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, i915_init_flush_functions(i915); i915_init_texture_functions(i915); - draw_install_aaline_stage(i915->draw, &i915->pipe); - draw_install_aapoint_stage(i915->draw, &i915->pipe); + draw_install_aaline_stage(i915->draw, &i915->base); + draw_install_aapoint_stage(i915->draw, &i915->base); i915->dirty = ~0; i915->hardware_dirty = ~0; @@ -222,6 +222,6 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, i915->batch = i915_winsys->batch_get(i915_winsys); i915->batch->winsys = i915_winsys; - return &i915->pipe; + return &i915->base; } diff --git a/src/gallium/drivers/i915simple/i915_context.h b/src/gallium/drivers/i915simple/i915_context.h index b6983ba86e..76aec4cd93 100644 --- a/src/gallium/drivers/i915simple/i915_context.h +++ b/src/gallium/drivers/i915simple/i915_context.h @@ -213,7 +213,8 @@ struct i915_batchbuffer; struct i915_context { - struct pipe_context pipe; + struct pipe_context base; + struct i915_winsys *winsys; struct draw_context *draw; diff --git a/src/gallium/drivers/i915simple/i915_flush.c b/src/gallium/drivers/i915simple/i915_flush.c index 472e0ab774..b223dadab6 100644 --- a/src/gallium/drivers/i915simple/i915_flush.c +++ b/src/gallium/drivers/i915simple/i915_flush.c @@ -74,5 +74,5 @@ static void i915_flush( struct pipe_context *pipe, void i915_init_flush_functions( struct i915_context *i915 ) { - i915->pipe.flush = i915_flush; + i915->base.flush = i915_flush; } diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c index 9bdd91f288..3ab09b58d7 100644 --- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c @@ -116,7 +116,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->pipe.screen; + struct pipe_screen *screen = i915->base.screen; size_t size = (size_t)vertex_size * (size_t)nr_vertices; /* FIXME: handle failure */ @@ -155,7 +155,7 @@ 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->pipe.screen; + struct pipe_screen *screen = i915->base.screen; if (i915->vbo_flushed) debug_printf("%s bad vbo flush occured stalling on hw\n"); @@ -174,7 +174,7 @@ 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->pipe.screen; + struct pipe_screen *screen = i915->base.screen; 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); @@ -515,7 +515,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->pipe.screen; + struct pipe_screen *screen = i915->base.screen; i915_render->i915 = i915; diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c index 273e74002a..272c1b1338 100644 --- a/src/gallium/drivers/i915simple/i915_state.c +++ b/src/gallium/drivers/i915simple/i915_state.c @@ -751,38 +751,38 @@ static void i915_set_edgeflags(struct pipe_context *pipe, void i915_init_state_functions( struct i915_context *i915 ) { - i915->pipe.set_edgeflags = i915_set_edgeflags; - i915->pipe.create_blend_state = i915_create_blend_state; - i915->pipe.bind_blend_state = i915_bind_blend_state; - i915->pipe.delete_blend_state = i915_delete_blend_state; - - i915->pipe.create_sampler_state = i915_create_sampler_state; - i915->pipe.bind_sampler_states = i915_bind_sampler_states; - i915->pipe.delete_sampler_state = i915_delete_sampler_state; - - i915->pipe.create_depth_stencil_alpha_state = i915_create_depth_stencil_state; - i915->pipe.bind_depth_stencil_alpha_state = i915_bind_depth_stencil_state; - i915->pipe.delete_depth_stencil_alpha_state = i915_delete_depth_stencil_state; - - i915->pipe.create_rasterizer_state = i915_create_rasterizer_state; - i915->pipe.bind_rasterizer_state = i915_bind_rasterizer_state; - i915->pipe.delete_rasterizer_state = i915_delete_rasterizer_state; - i915->pipe.create_fs_state = i915_create_fs_state; - i915->pipe.bind_fs_state = i915_bind_fs_state; - i915->pipe.delete_fs_state = i915_delete_fs_state; - i915->pipe.create_vs_state = i915_create_vs_state; - i915->pipe.bind_vs_state = i915_bind_vs_state; - i915->pipe.delete_vs_state = i915_delete_vs_state; - - i915->pipe.set_blend_color = i915_set_blend_color; - i915->pipe.set_clip_state = i915_set_clip_state; - i915->pipe.set_constant_buffer = i915_set_constant_buffer; - i915->pipe.set_framebuffer_state = i915_set_framebuffer_state; - - i915->pipe.set_polygon_stipple = i915_set_polygon_stipple; - i915->pipe.set_scissor_state = i915_set_scissor_state; - i915->pipe.set_sampler_textures = i915_set_sampler_textures; - i915->pipe.set_viewport_state = i915_set_viewport_state; - i915->pipe.set_vertex_buffers = i915_set_vertex_buffers; - i915->pipe.set_vertex_elements = i915_set_vertex_elements; + i915->base.set_edgeflags = i915_set_edgeflags; + i915->base.create_blend_state = i915_create_blend_state; + i915->base.bind_blend_state = i915_bind_blend_state; + i915->base.delete_blend_state = i915_delete_blend_state; + + i915->base.create_sampler_state = i915_create_sampler_state; + i915->base.bind_sampler_states = i915_bind_sampler_states; + i915->base.delete_sampler_state = i915_delete_sampler_state; + + i915->base.create_depth_stencil_alpha_state = i915_create_depth_stencil_state; + i915->base.bind_depth_stencil_alpha_state = i915_bind_depth_stencil_state; + i915->base.delete_depth_stencil_alpha_state = i915_delete_depth_stencil_state; + + i915->base.create_rasterizer_state = i915_create_rasterizer_state; + i915->base.bind_rasterizer_state = i915_bind_rasterizer_state; + i915->base.delete_rasterizer_state = i915_delete_rasterizer_state; + i915->base.create_fs_state = i915_create_fs_state; + i915->base.bind_fs_state = i915_bind_fs_state; + i915->base.delete_fs_state = i915_delete_fs_state; + i915->base.create_vs_state = i915_create_vs_state; + i915->base.bind_vs_state = i915_bind_vs_state; + i915->base.delete_vs_state = i915_delete_vs_state; + + i915->base.set_blend_color = i915_set_blend_color; + i915->base.set_clip_state = i915_set_clip_state; + i915->base.set_constant_buffer = i915_set_constant_buffer; + i915->base.set_framebuffer_state = i915_set_framebuffer_state; + + i915->base.set_polygon_stipple = i915_set_polygon_stipple; + i915->base.set_scissor_state = i915_set_scissor_state; + i915->base.set_sampler_textures = i915_set_sampler_textures; + i915->base.set_viewport_state = i915_set_viewport_state; + i915->base.set_vertex_buffers = i915_set_vertex_buffers; + i915->base.set_vertex_elements = i915_set_vertex_elements; } diff --git a/src/gallium/drivers/i915simple/i915_surface.c b/src/gallium/drivers/i915simple/i915_surface.c index 09b2c499b8..ab8331f3e6 100644 --- a/src/gallium/drivers/i915simple/i915_surface.c +++ b/src/gallium/drivers/i915simple/i915_surface.c @@ -89,6 +89,6 @@ i915_surface_fill(struct pipe_context *pipe, void i915_init_surface_functions(struct i915_context *i915) { - i915->pipe.surface_copy = i915_surface_copy; - i915->pipe.surface_fill = i915_surface_fill; + i915->base.surface_copy = i915_surface_copy; + i915->base.surface_fill = i915_surface_fill; } -- cgit v1.2.3 From 4224bda684aaee92d27e09c5545a7094cda0ae76 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sat, 29 Aug 2009 22:02:49 +0100 Subject: i915g: Cleanup texture init functions a bit --- src/gallium/drivers/i915simple/i915_context.c | 1 - src/gallium/drivers/i915simple/i915_screen.c | 2 +- src/gallium/drivers/i915simple/i915_texture.c | 18 ++++++------------ src/gallium/drivers/i915simple/i915_texture.h | 11 ++--------- 4 files changed, 9 insertions(+), 23 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index 132ed31f38..b77a831ca0 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -209,7 +209,6 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, i915_init_surface_functions(i915); i915_init_state_functions(i915); i915_init_flush_functions(i915); - i915_init_texture_functions(i915); draw_install_aaline_stage(i915->draw, &i915->base); draw_install_aapoint_stage(i915->draw, &i915->base); diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c index c9a9e90f0e..a7a95edaa0 100644 --- a/src/gallium/drivers/i915simple/i915_screen.c +++ b/src/gallium/drivers/i915simple/i915_screen.c @@ -342,7 +342,7 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id) i915screen->base.transfer_map = i915_transfer_map; i915screen->base.transfer_unmap = i915_transfer_unmap; - i915_init_screen_texture_functions(&i915screen->base); + i915_init_screen_texture_functions(i915screen); u_simple_screen_init(&i915screen->base); return &i915screen->base; diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c index 0dc6a54746..975602a166 100644 --- a/src/gallium/drivers/i915simple/i915_texture.c +++ b/src/gallium/drivers/i915simple/i915_texture.c @@ -718,12 +718,6 @@ i915_texture_blanket(struct pipe_screen * screen, return &tex->base; } -void -i915_init_texture_functions(struct i915_context *i915) -{ -// i915->pipe.texture_update = i915_texture_update; -} - static void i915_tex_surface_destroy(struct pipe_surface *surf) { @@ -732,13 +726,13 @@ i915_tex_surface_destroy(struct pipe_surface *surf) } void -i915_init_screen_texture_functions(struct pipe_screen *screen) +i915_init_screen_texture_functions(struct i915_screen *is) { - screen->texture_create = i915_texture_create; - screen->texture_destroy = i915_texture_destroy; - screen->get_tex_surface = i915_get_tex_surface; - screen->texture_blanket = i915_texture_blanket; - screen->tex_surface_destroy = i915_tex_surface_destroy; + is->base.texture_create = i915_texture_create; + is->base.texture_destroy = i915_texture_destroy; + is->base.get_tex_surface = i915_get_tex_surface; + is->base.texture_blanket = i915_texture_blanket; + is->base.tex_surface_destroy = i915_tex_surface_destroy; } boolean i915_get_texture_buffer( struct pipe_texture *texture, diff --git a/src/gallium/drivers/i915simple/i915_texture.h b/src/gallium/drivers/i915simple/i915_texture.h index 7225016a9f..51a1dd984c 100644 --- a/src/gallium/drivers/i915simple/i915_texture.h +++ b/src/gallium/drivers/i915simple/i915_texture.h @@ -28,16 +28,9 @@ #ifndef I915_TEXTURE_H #define I915_TEXTURE_H -struct i915_context; -struct pipe_screen; - +struct i915_screen; extern void -i915_init_texture_functions(struct i915_context *i915); - - -extern void -i915_init_screen_texture_functions(struct pipe_screen *screen); - +i915_init_screen_texture_functions(struct i915_screen *is); #endif /* I915_TEXTURE_H */ -- cgit v1.2.3 From 00b07280948fc7608fdede4be73c504499247f17 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 13:57:37 +0100 Subject: i915g: Cleanup i915_texture.c --- src/gallium/drivers/i915simple/i915_texture.c | 36 +++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c index 975602a166..d363962889 100644 --- a/src/gallium/drivers/i915simple/i915_texture.c +++ b/src/gallium/drivers/i915simple/i915_texture.c @@ -133,7 +133,7 @@ i915_miptree_set_level_info(struct i915_texture *tex, static void i915_miptree_set_image_offset(struct i915_texture *tex, - unsigned level, unsigned img, unsigned x, unsigned y) + unsigned level, unsigned img, unsigned x, unsigned y) { if (img == 0 && level == 0) assert(x == 0 && y == 0); @@ -165,11 +165,11 @@ i915_scanout_layout(struct i915_texture *tex) if (pt->last_level > 0 || pt->block.size != 4) return 0; - i915_miptree_set_level_info( tex, 0, 1, - tex->base.width[0], - tex->base.height[0], - 1 ); - i915_miptree_set_image_offset( tex, 0, 0, 0, 0 ); + i915_miptree_set_level_info(tex, 0, 1, + tex->base.width[0], + tex->base.height[0], + 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) { @@ -195,7 +195,7 @@ i915_scanout_layout(struct i915_texture *tex) } static void -i945_miptree_layout_2d( struct i915_texture *tex ) +i945_miptree_layout_2d(struct i915_texture *tex) { struct pipe_texture *pt = &tex->base; const int align_x = 2, align_y = 4; @@ -210,7 +210,7 @@ i945_miptree_layout_2d( struct i915_texture *tex ) /* used for scanouts that need special layouts */ if (tex->base.tex_usage & PIPE_TEXTURE_USAGE_PRIMARY) if (i915_scanout_layout(tex)) - return; + return; tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4); @@ -221,11 +221,11 @@ i945_miptree_layout_2d( struct i915_texture *tex ) */ if (pt->last_level > 0) { unsigned mip1_nblocksx - = align(pf_get_nblocksx(&pt->block, minify(width)), align_x) + = align(pf_get_nblocksx(&pt->block, minify(width)), align_x) + pf_get_nblocksx(&pt->block, minify(minify(width))); if (mip1_nblocksx > nblocksx) - tex->stride = mip1_nblocksx * pt->block.size; + tex->stride = mip1_nblocksx * pt->block.size; } /* Pitch must be a whole number of dwords @@ -247,10 +247,10 @@ i945_miptree_layout_2d( struct i915_texture *tex ) /* Layout_below: step right after second mipmap level. */ if (level == 1) { - x += align(nblocksx, align_x); + x += align(nblocksx, align_x); } else { - y += nblocksy; + y += nblocksy; } width = minify(width); @@ -468,7 +468,7 @@ i915_miptree_layout(struct i915_texture * tex) nblocksy = round_up(MAX2(2, nblocksy), 2); - tex->total_nblocksy += nblocksy; + tex->total_nblocksy += nblocksy; width = minify(width); height = minify(height); @@ -596,10 +596,10 @@ i915_texture_create(struct pipe_screen *screen, if (i915screen->is_i945) { if (!i945_miptree_layout(tex)) - goto fail; + goto fail; } else { if (!i915_miptree_layout(tex)) - goto fail; + goto fail; } tex_size = tex->stride * tex->total_nblocksy; @@ -735,9 +735,9 @@ i915_init_screen_texture_functions(struct i915_screen *is) is->base.tex_surface_destroy = i915_tex_surface_destroy; } -boolean i915_get_texture_buffer( struct pipe_texture *texture, - struct pipe_buffer **buf, - unsigned *stride ) +boolean i915_get_texture_buffer(struct pipe_texture *texture, + struct pipe_buffer **buf, + unsigned *stride) { struct i915_texture *tex = (struct i915_texture *)texture; -- cgit v1.2.3 From 5d929366aac54e815e1ecacd7349700989d76b03 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 15:42:10 +0100 Subject: i915g: Cleanup i915_state_emit.c --- src/gallium/drivers/i915simple/i915_state_emit.c | 154 +++++++++++------------ 1 file changed, 77 insertions(+), 77 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_state_emit.c b/src/gallium/drivers/i915simple/i915_state_emit.c index 1e1fb968b4..ab361e3d4b 100644 --- a/src/gallium/drivers/i915simple/i915_state_emit.c +++ b/src/gallium/drivers/i915simple/i915_state_emit.c @@ -107,7 +107,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) 6 ) * 3/2; /* plus 50% margin */ const unsigned relocs = ( I915_TEX_UNITS + - 3 + 3 ) * 3/2; /* plus 50% margin */ #if 0 @@ -123,9 +123,9 @@ i915_emit_hardware_state(struct i915_context *i915 ) if (i915->hardware_dirty & I915_HW_INVARIENT) { OUT_BATCH(_3DSTATE_AA_CMD | - AA_LINE_ECAAR_WIDTH_ENABLE | - AA_LINE_ECAAR_WIDTH_1_0 | - AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); + AA_LINE_ECAAR_WIDTH_ENABLE | + AA_LINE_ECAAR_WIDTH_1_0 | + AA_LINE_REGION_WIDTH_ENABLE | AA_LINE_REGION_WIDTH_1_0); OUT_BATCH(_3DSTATE_DFLT_DIFFUSE_CMD); OUT_BATCH(0); @@ -137,24 +137,24 @@ i915_emit_hardware_state(struct i915_context *i915 ) OUT_BATCH(0); OUT_BATCH(_3DSTATE_COORD_SET_BINDINGS | - CSB_TCB(0, 0) | - CSB_TCB(1, 1) | - CSB_TCB(2, 2) | - CSB_TCB(3, 3) | - CSB_TCB(4, 4) | - CSB_TCB(5, 5) | - CSB_TCB(6, 6) | - CSB_TCB(7, 7)); + CSB_TCB(0, 0) | + CSB_TCB(1, 1) | + CSB_TCB(2, 2) | + CSB_TCB(3, 3) | + CSB_TCB(4, 4) | + CSB_TCB(5, 5) | + CSB_TCB(6, 6) | + CSB_TCB(7, 7)); OUT_BATCH(_3DSTATE_RASTER_RULES_CMD | - ENABLE_POINT_RASTER_RULE | - OGL_POINT_RASTER_RULE | - ENABLE_LINE_STRIP_PROVOKE_VRTX | - ENABLE_TRI_FAN_PROVOKE_VRTX | - LINE_STRIP_PROVOKE_VRTX(1) | - TRI_FAN_PROVOKE_VRTX(2) | - ENABLE_TEXKILL_3D_4D | - TEXKILL_4D); + ENABLE_POINT_RASTER_RULE | + OGL_POINT_RASTER_RULE | + ENABLE_LINE_STRIP_PROVOKE_VRTX | + ENABLE_TRI_FAN_PROVOKE_VRTX | + LINE_STRIP_PROVOKE_VRTX(1) | + TRI_FAN_PROVOKE_VRTX(2) | + ENABLE_TEXKILL_3D_4D | + TEXKILL_4D); /* Need to initialize this to zero. */ @@ -173,21 +173,21 @@ i915_emit_hardware_state(struct i915_context *i915 ) if (i915->hardware_dirty & I915_HW_IMMEDIATE) { OUT_BATCH(_3DSTATE_LOAD_STATE_IMMEDIATE_1 | - I1_LOAD_S(0) | - I1_LOAD_S(1) | - I1_LOAD_S(2) | - I1_LOAD_S(4) | - I1_LOAD_S(5) | - I1_LOAD_S(6) | - (5)); + I1_LOAD_S(0) | + I1_LOAD_S(1) | + I1_LOAD_S(2) | + I1_LOAD_S(4) | + I1_LOAD_S(5) | + I1_LOAD_S(6) | + (5)); if(i915->vbo) OUT_RELOC(i915->vbo, I915_BUFFER_ACCESS_READ, i915->current.immediate[I915_IMMEDIATE_S0]); else - /* FIXME: we should not do this */ - OUT_BATCH(0); + /* FIXME: we should not do this */ + OUT_BATCH(0); OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S1]); OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S2]); OUT_BATCH(i915->current.immediate[I915_IMMEDIATE_S4]); @@ -200,7 +200,7 @@ i915_emit_hardware_state(struct i915_context *i915 ) { int i; for (i = 0; i < I915_MAX_DYNAMIC; i++) { - OUT_BATCH(i915->current.dynamic[i]); + OUT_BATCH(i915->current.dynamic[i]); } } @@ -211,68 +211,68 @@ i915_emit_hardware_state(struct i915_context *i915 ) struct pipe_surface *depth_surface = i915->framebuffer.zsbuf; if (cbuf_surface) { - unsigned ctile = BUF_3D_USE_FENCE; + unsigned ctile = BUF_3D_USE_FENCE; struct i915_texture *tex = (struct i915_texture *) cbuf_surface->texture; assert(tex); - if (tex && tex->tiled) { - ctile = BUF_3D_TILED_SURFACE; - } + if (tex && tex->tiled) { + ctile = BUF_3D_TILED_SURFACE; + } - OUT_BATCH(_3DSTATE_BUF_INFO_CMD); + OUT_BATCH(_3DSTATE_BUF_INFO_CMD); - OUT_BATCH(BUF_3D_ID_COLOR_BACK | - BUF_3D_PITCH(tex->stride) | /* pitch in bytes */ - ctile); + OUT_BATCH(BUF_3D_ID_COLOR_BACK | + BUF_3D_PITCH(tex->stride) | /* pitch in bytes */ + ctile); - OUT_RELOC(tex->buffer, - I915_BUFFER_ACCESS_WRITE, - cbuf_surface->offset); + OUT_RELOC(tex->buffer, + I915_BUFFER_ACCESS_WRITE, + cbuf_surface->offset); } /* What happens if no zbuf?? */ if (depth_surface) { - unsigned ztile = BUF_3D_USE_FENCE; + unsigned ztile = BUF_3D_USE_FENCE; struct i915_texture *tex = (struct i915_texture *) depth_surface->texture; assert(tex); - if (tex && tex->tiled) { - ztile = BUF_3D_TILED_SURFACE; - } + if (tex && tex->tiled) { + ztile = BUF_3D_TILED_SURFACE; + } - OUT_BATCH(_3DSTATE_BUF_INFO_CMD); + OUT_BATCH(_3DSTATE_BUF_INFO_CMD); - OUT_BATCH(BUF_3D_ID_DEPTH | - BUF_3D_PITCH(tex->stride) | /* pitch in bytes */ - ztile); + OUT_BATCH(BUF_3D_ID_DEPTH | + BUF_3D_PITCH(tex->stride) | /* pitch in bytes */ + ztile); - OUT_RELOC(tex->buffer, - I915_BUFFER_ACCESS_WRITE, - depth_surface->offset); + OUT_RELOC(tex->buffer, + I915_BUFFER_ACCESS_WRITE, + depth_surface->offset); } { - unsigned cformat, zformat = 0; + unsigned cformat, zformat = 0; - if (cbuf_surface) + if (cbuf_surface) cformat = cbuf_surface->format; else cformat = PIPE_FORMAT_A8R8G8B8_UNORM; /* arbitrary */ cformat = translate_format(cformat); - if (depth_surface) - zformat = translate_depth_format( i915->framebuffer.zsbuf->format ); + if (depth_surface) + zformat = translate_depth_format( i915->framebuffer.zsbuf->format ); - OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD); - OUT_BATCH(DSTORG_HORT_BIAS(0x8) | /* .5 */ - DSTORG_VERT_BIAS(0x8) | /* .5 */ - LOD_PRECLAMP_OGL | - TEX_DEFAULT_COLOR_OGL | - cformat | - zformat ); + OUT_BATCH(_3DSTATE_DST_BUF_VARS_CMD); + OUT_BATCH(DSTORG_HORT_BIAS(0x8) | /* .5 */ + DSTORG_VERT_BIAS(0x8) | /* .5 */ + LOD_PRECLAMP_OGL | + TEX_DEFAULT_COLOR_OGL | + cformat | + zformat ); } } @@ -315,20 +315,20 @@ i915_emit_hardware_state(struct i915_context *i915 ) if (i915->hardware_dirty & I915_HW_SAMPLER) { if (i915->current.sampler_enable_nr) { - int i; - - OUT_BATCH( _3DSTATE_SAMPLER_STATE | - (3 * i915->current.sampler_enable_nr) ); - - OUT_BATCH( i915->current.sampler_enable_flags ); - - for (i = 0; i < I915_TEX_UNITS; i++) { - if (i915->current.sampler_enable_flags & (1<current.sampler[i][0] ); - OUT_BATCH( i915->current.sampler[i][1] ); - OUT_BATCH( i915->current.sampler[i][2] ); - } - } + int i; + + OUT_BATCH( _3DSTATE_SAMPLER_STATE | + (3 * i915->current.sampler_enable_nr) ); + + OUT_BATCH( i915->current.sampler_enable_flags ); + + for (i = 0; i < I915_TEX_UNITS; i++) { + if (i915->current.sampler_enable_flags & (1<current.sampler[i][0] ); + OUT_BATCH( i915->current.sampler[i][1] ); + OUT_BATCH( i915->current.sampler[i][2] ); + } + } } } #endif -- cgit v1.2.3 From 7864b0e717755a26688891195e85a62714d50baa Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 20:41:00 +0100 Subject: i915g: Cleanup i915_blit.[c|h] --- src/gallium/drivers/i915simple/i915_blit.c | 75 ++++++++++++++---------------- src/gallium/drivers/i915simple/i915_blit.h | 32 ++++++------- 2 files changed, 50 insertions(+), 57 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_blit.c b/src/gallium/drivers/i915simple/i915_blit.c index 448a4708ce..63e9ed83d2 100644 --- a/src/gallium/drivers/i915simple/i915_blit.c +++ b/src/gallium/drivers/i915simple/i915_blit.c @@ -26,7 +26,6 @@ **************************************************************************/ -#include "i915_context.h" #include "i915_winsys.h" #include "i915_blit.h" #include "i915_reg.h" @@ -37,33 +36,33 @@ void i915_fill_blit(struct i915_context *i915, - unsigned cpp, - unsigned short dst_pitch, - struct pipe_buffer *dst_buffer, - unsigned dst_offset, - short x, short y, - short w, short h, - unsigned color) + unsigned cpp, + unsigned short dst_pitch, + struct pipe_buffer *dst_buffer, + unsigned dst_offset, + short x, short y, + short w, short h, + unsigned color) { unsigned BR13, CMD; I915_DBG(i915, - "%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", - __FUNCTION__, - dst_buffer, dst_pitch, dst_offset, x, y, w, h); + "%s dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", + __FUNCTION__, + dst_buffer, dst_pitch, dst_offset, x, y, w, h); switch (cpp) { case 1: case 2: case 3: BR13 = (((int) dst_pitch) & 0xffff) | - (0xF0 << 16) | (1 << 24); + (0xF0 << 16) | (1 << 24); CMD = XY_COLOR_BLT_CMD; break; case 4: BR13 = (((int) dst_pitch) & 0xffff) | - (0xF0 << 16) | (1 << 24) | (1 << 25); + (0xF0 << 16) | (1 << 24) | (1 << 25); CMD = (XY_COLOR_BLT_CMD | XY_COLOR_BLT_WRITE_ALPHA | XY_COLOR_BLT_WRITE_RGB); break; @@ -79,25 +78,24 @@ 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, I915_BUFFER_ACCESS_WRITE, dst_offset); OUT_BATCH(color); FLUSH_BATCH(NULL); } - void -i915_copy_blit( struct i915_context *i915, - unsigned do_flip, - unsigned cpp, - unsigned short src_pitch, - struct pipe_buffer *src_buffer, - unsigned src_offset, - unsigned short dst_pitch, - struct pipe_buffer *dst_buffer, - unsigned dst_offset, - short src_x, short src_y, - short dst_x, short dst_y, - short w, short h ) +i915_copy_blit(struct i915_context *i915, + unsigned do_flip, + unsigned cpp, + unsigned short src_pitch, + struct pipe_buffer *src_buffer, + unsigned src_offset, + unsigned short dst_pitch, + struct pipe_buffer *dst_buffer, + unsigned dst_offset, + short src_x, short src_y, + short dst_x, short dst_y, + short w, short h) { unsigned CMD, BR13; int dst_y2 = dst_y + h; @@ -105,32 +103,30 @@ i915_copy_blit( struct i915_context *i915, I915_DBG(i915, - "%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", - __FUNCTION__, - src_buffer, src_pitch, src_offset, src_x, src_y, - dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h); + "%s src:buf(%p)/%d+%d %d,%d dst:buf(%p)/%d+%d %d,%d sz:%dx%d\n", + __FUNCTION__, + src_buffer, src_pitch, src_offset, src_x, src_y, + dst_buffer, dst_pitch, dst_offset, dst_x, dst_y, w, h); switch (cpp) { case 1: case 2: case 3: BR13 = (((int) dst_pitch) & 0xffff) | - (0xCC << 16) | (1 << 24); + (0xCC << 16) | (1 << 24); CMD = XY_SRC_COPY_BLT_CMD; break; case 4: BR13 = (((int) dst_pitch) & 0xffff) | - (0xCC << 16) | (1 << 24) | (1 << 25); - CMD = - (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | - XY_SRC_COPY_BLT_WRITE_RGB); + (0xCC << 16) | (1 << 24) | (1 << 25); + CMD = (XY_SRC_COPY_BLT_CMD | XY_SRC_COPY_BLT_WRITE_ALPHA | + XY_SRC_COPY_BLT_WRITE_RGB); break; default: return; } - if (dst_y2 < dst_y || - dst_x2 < dst_x) { + if (dst_y2 < dst_y || dst_x2 < dst_x) { return; } @@ -140,7 +136,6 @@ i915_copy_blit( struct i915_context *i915, */ assert (dst_pitch > 0 && src_pitch > 0); - if (!BEGIN_BATCH(8, 2)) { FLUSH_BATCH(NULL); assert(BEGIN_BATCH(8, 2)); @@ -155,5 +150,3 @@ i915_copy_blit( struct i915_context *i915, OUT_RELOC(src_buffer, I915_BUFFER_ACCESS_READ, src_offset); FLUSH_BATCH(NULL); } - - diff --git a/src/gallium/drivers/i915simple/i915_blit.h b/src/gallium/drivers/i915simple/i915_blit.h index 0bb3453861..2dba57eef0 100644 --- a/src/gallium/drivers/i915simple/i915_blit.h +++ b/src/gallium/drivers/i915simple/i915_blit.h @@ -32,24 +32,24 @@ extern void i915_copy_blit(struct i915_context *i915, unsigned do_flip, - unsigned cpp, - unsigned short src_pitch, - struct pipe_buffer *src_buffer, - unsigned src_offset, - unsigned short dst_pitch, - struct pipe_buffer *dst_buffer, - unsigned dst_offset, - short srcx, short srcy, - short dstx, short dsty, - short w, short h ); + unsigned cpp, + unsigned short src_pitch, + struct pipe_buffer *src_buffer, + unsigned src_offset, + unsigned short dst_pitch, + struct pipe_buffer *dst_buffer, + unsigned dst_offset, + short srcx, short srcy, + short dstx, short dsty, + short w, short h); extern void i915_fill_blit(struct i915_context *i915, - unsigned cpp, - unsigned short dst_pitch, - struct pipe_buffer *dst_buffer, - unsigned dst_offset, - short x, short y, - short w, short h, unsigned color); + unsigned cpp, + unsigned short dst_pitch, + struct pipe_buffer *dst_buffer, + unsigned dst_offset, + short x, short y, + short w, short h, unsigned color); #endif -- cgit v1.2.3 From 1b5f46a3b8d1d1ffa7cbb60b557deb8c2c448a3a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 21:03:43 +0100 Subject: i915g: Cleanup i915_context.c --- src/gallium/drivers/i915simple/i915_context.c | 128 ++++++++++++++------------ 1 file changed, 71 insertions(+), 57 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_context.c b/src/gallium/drivers/i915simple/i915_context.c index b77a831ca0..0f99b1c1b6 100644 --- a/src/gallium/drivers/i915simple/i915_context.c +++ b/src/gallium/drivers/i915simple/i915_context.c @@ -40,66 +40,58 @@ #include "pipe/p_screen.h" -static void i915_destroy( struct pipe_context *pipe ) -{ - struct i915_context *i915 = i915_context( pipe ); - - draw_destroy( i915->draw ); - - if(i915->winsys->destroy) - i915->winsys->destroy(i915->winsys); - - FREE( i915 ); -} +/* + * Draw functions + */ static boolean i915_draw_range_elements(struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned min_index, - unsigned max_index, - unsigned prim, unsigned start, unsigned count) + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned min_index, + unsigned max_index, + unsigned prim, unsigned start, unsigned count) { - struct i915_context *i915 = i915_context( pipe ); + struct i915_context *i915 = i915_context(pipe); struct draw_context *draw = i915->draw; unsigned i; if (i915->dirty) - i915_update_derived( i915 ); + i915_update_derived(i915); /* * Map vertex buffers */ for (i = 0; i < i915->num_vertex_buffers; i++) { - void *buf - = pipe_buffer_map(pipe->screen, - i915->vertex_buffer[i].buffer, - PIPE_BUFFER_USAGE_CPU_READ); + void *buf = pipe_buffer_map(pipe->screen, i915->vertex_buffer[i].buffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_vertex_buffer(draw, i, buf); } - /* Map index buffer, if present */ + + /* + * Map index buffer, if present + */ if (indexBuffer) { - void *mapped_indexes - = pipe_buffer_map(pipe->screen, indexBuffer, - PIPE_BUFFER_USAGE_CPU_READ); + void *mapped_indexes = pipe_buffer_map(pipe->screen, indexBuffer, + PIPE_BUFFER_USAGE_CPU_READ); draw_set_mapped_element_buffer_range(draw, indexSize, - min_index, - max_index, - mapped_indexes); - } - else { - /* no index/element buffer */ + min_index, + max_index, + mapped_indexes); + } else { draw_set_mapped_element_buffer(draw, 0, NULL); } draw_set_mapped_constant_buffer(draw, i915->current.constants[PIPE_SHADER_VERTEX], - ( i915->current.num_user_constants[PIPE_SHADER_VERTEX] * - 4 * sizeof(float) )); + (i915->current.num_user_constants[PIPE_SHADER_VERTEX] * + 4 * sizeof(float))); - /* draw! */ + /* + * Do the drawing + */ draw_arrays(i915->draw, prim, start, count); /* @@ -109,6 +101,7 @@ i915_draw_range_elements(struct pipe_context *pipe, pipe_buffer_unmap(pipe->screen, i915->vertex_buffer[i].buffer); draw_set_mapped_vertex_buffer(draw, i, NULL); } + if (indexBuffer) { pipe_buffer_unmap(pipe->screen, indexBuffer); draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL); @@ -118,28 +111,34 @@ i915_draw_range_elements(struct pipe_context *pipe, } static boolean -i915_draw_elements( struct pipe_context *pipe, - struct pipe_buffer *indexBuffer, - unsigned indexSize, - unsigned prim, unsigned start, unsigned count) +i915_draw_elements(struct pipe_context *pipe, + struct pipe_buffer *indexBuffer, + unsigned indexSize, + unsigned prim, unsigned start, unsigned count) { - return i915_draw_range_elements( pipe, indexBuffer, - indexSize, - 0, 0xffffffff, - prim, start, count ); + return i915_draw_range_elements(pipe, indexBuffer, + indexSize, + 0, 0xffffffff, + prim, start, count); } -static boolean i915_draw_arrays( struct pipe_context *pipe, - unsigned prim, unsigned start, unsigned count) +static boolean +i915_draw_arrays(struct pipe_context *pipe, + unsigned prim, unsigned start, unsigned count) { return i915_draw_elements(pipe, NULL, 0, prim, start, count); } +/* + * Is referenced functions + */ + + static unsigned int -i915_is_texture_referenced( struct pipe_context *pipe, - struct pipe_texture *texture, - unsigned face, unsigned level) +i915_is_texture_referenced(struct pipe_context *pipe, + struct pipe_texture *texture, + unsigned face, unsigned level) { /** * FIXME: Return the corrent result. We can't alays return referenced @@ -153,8 +152,8 @@ i915_is_texture_referenced( struct pipe_context *pipe, } static unsigned int -i915_is_buffer_referenced( struct pipe_context *pipe, - struct pipe_buffer *buf) +i915_is_buffer_referenced(struct pipe_context *pipe, + struct pipe_buffer *buf) { /** * FIXME: Return the corrent result. We can't alays return referenced @@ -168,9 +167,27 @@ i915_is_buffer_referenced( struct pipe_context *pipe, } -struct pipe_context *i915_create_context( struct pipe_screen *screen, - struct pipe_winsys *pipe_winsys, - struct i915_winsys *i915_winsys ) +/* + * Generic context functions + */ + + +static void i915_destroy(struct pipe_context *pipe) +{ + struct i915_context *i915 = i915_context(pipe); + + draw_destroy(i915->draw); + + if(i915->winsys->destroy) + i915->winsys->destroy(i915->winsys); + + FREE(i915); +} + +struct pipe_context * +i915_create_context(struct pipe_screen *screen, + struct pipe_winsys *pipe_winsys, + struct i915_winsys *i915_winsys) { struct i915_context *i915; @@ -186,7 +203,6 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, i915->base.clear = i915_clear; - i915->base.draw_arrays = i915_draw_arrays; i915->base.draw_elements = i915_draw_elements; i915->base.draw_range_elements = i915_draw_range_elements; @@ -201,8 +217,7 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, assert(i915->draw); if (!debug_get_bool_option("I915_NO_VBUF", FALSE)) { draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915)); - } - else { + } else { draw_set_rasterize_stage(i915->draw, i915_draw_render_stage(i915)); } @@ -223,4 +238,3 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen, return &i915->base; } - -- cgit v1.2.3 From 1bb3a2c648e0d6feea12bfff7f739159339f034a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 21:10:36 +0100 Subject: i915g: Cleanup i915_screen.[c|h] --- src/gallium/drivers/i915simple/i915_screen.c | 65 ++++++++++++---------------- src/gallium/drivers/i915simple/i915_screen.h | 20 +++------ 2 files changed, 34 insertions(+), 51 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c index a7a95edaa0..dccd0e287b 100644 --- a/src/gallium/drivers/i915simple/i915_screen.c +++ b/src/gallium/drivers/i915simple/i915_screen.c @@ -40,19 +40,18 @@ static const char * -i915_get_vendor( struct pipe_screen *pscreen ) +i915_get_vendor(struct pipe_screen *screen) { return "Tungsten Graphics, Inc."; } - static const char * -i915_get_name( struct pipe_screen *pscreen ) +i915_get_name(struct pipe_screen *screen) { static char buffer[128]; const char *chipset; - switch (i915_screen(pscreen)->pci_id) { + switch (i915_screen(screen)->pci_id) { case PCI_CHIP_I915_G: chipset = "915G"; break; @@ -86,7 +85,6 @@ i915_get_name( struct pipe_screen *pscreen ) return buffer; } - static int i915_get_param(struct pipe_screen *screen, int param) { @@ -122,7 +120,6 @@ i915_get_param(struct pipe_screen *screen, int param) } } - static float i915_get_paramf(struct pipe_screen *screen, int param) { @@ -148,13 +145,12 @@ i915_get_paramf(struct pipe_screen *screen, int param) } } - static boolean -i915_is_format_supported( struct pipe_screen *screen, - enum pipe_format format, - enum pipe_texture_target target, - unsigned tex_usage, - unsigned geom_flags ) +i915_is_format_supported(struct pipe_screen *screen, + enum pipe_format format, + enum pipe_texture_target target, + unsigned tex_usage, + unsigned geom_flags) { static const enum pipe_format tex_supported[] = { PIPE_FORMAT_R8G8B8A8_UNORM, @@ -173,7 +169,6 @@ i915_is_format_supported( struct pipe_screen *screen, PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_S8Z24_UNORM, - /*PIPE_FORMAT_R16G16B16A16_SNORM,*/ PIPE_FORMAT_NONE /* list terminator */ }; const enum pipe_format *list; @@ -192,9 +187,8 @@ i915_is_format_supported( struct pipe_screen *screen, return FALSE; } - static void -i915_destroy_screen( struct pipe_screen *screen ) +i915_destroy_screen(struct pipe_screen *screen) { struct pipe_winsys *winsys = screen->winsys; @@ -204,7 +198,6 @@ i915_destroy_screen( struct pipe_screen *screen ) FREE(screen); } - static struct pipe_transfer* i915_get_tex_transfer(struct pipe_screen *screen, struct pipe_texture *texture, @@ -292,23 +285,21 @@ i915_transfer_unmap(struct pipe_screen *screen, pipe_buffer_unmap( screen, tex->buffer ); } - - /** * Create a new i915_screen object */ struct pipe_screen * i915_create_screen(struct pipe_winsys *winsys, uint pci_id) { - struct i915_screen *i915screen = CALLOC_STRUCT(i915_screen); + struct i915_screen *is = CALLOC_STRUCT(i915_screen); - if (!i915screen) + if (!is) return NULL; switch (pci_id) { case PCI_CHIP_I915_G: case PCI_CHIP_I915_GM: - i915screen->is_i945 = FALSE; + is->is_i945 = FALSE; break; case PCI_CHIP_I945_G: @@ -317,7 +308,7 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id) case PCI_CHIP_G33_G: case PCI_CHIP_Q33_G: case PCI_CHIP_Q35_G: - i915screen->is_i945 = TRUE; + is->is_i945 = TRUE; break; default: @@ -326,24 +317,24 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id) return NULL; } - i915screen->pci_id = pci_id; + is->pci_id = pci_id; - i915screen->base.winsys = winsys; + is->base.winsys = winsys; - i915screen->base.destroy = i915_destroy_screen; + is->base.destroy = i915_destroy_screen; - i915screen->base.get_name = i915_get_name; - i915screen->base.get_vendor = i915_get_vendor; - i915screen->base.get_param = i915_get_param; - i915screen->base.get_paramf = i915_get_paramf; - i915screen->base.is_format_supported = i915_is_format_supported; - i915screen->base.get_tex_transfer = i915_get_tex_transfer; - i915screen->base.tex_transfer_destroy = i915_tex_transfer_destroy; - i915screen->base.transfer_map = i915_transfer_map; - i915screen->base.transfer_unmap = i915_transfer_unmap; + is->base.get_name = i915_get_name; + is->base.get_vendor = i915_get_vendor; + is->base.get_param = i915_get_param; + is->base.get_paramf = i915_get_paramf; + is->base.is_format_supported = i915_is_format_supported; + is->base.get_tex_transfer = i915_get_tex_transfer; + is->base.tex_transfer_destroy = i915_tex_transfer_destroy; + is->base.transfer_map = i915_transfer_map; + is->base.transfer_unmap = i915_transfer_unmap; - i915_init_screen_texture_functions(i915screen); - u_simple_screen_init(&i915screen->base); + i915_init_screen_texture_functions(is); + u_simple_screen_init(&is->base); - return &i915screen->base; + return &is->base; } diff --git a/src/gallium/drivers/i915simple/i915_screen.h b/src/gallium/drivers/i915simple/i915_screen.h index 7d5f0f05a5..757baa76b8 100644 --- a/src/gallium/drivers/i915simple/i915_screen.h +++ b/src/gallium/drivers/i915simple/i915_screen.h @@ -25,20 +25,13 @@ * **************************************************************************/ - #ifndef I915_SCREEN_H #define I915_SCREEN_H - #include "pipe/p_state.h" #include "pipe/p_screen.h" -#ifdef __cplusplus -extern "C" { -#endif - - /** * Subclass of pipe_screen */ @@ -50,7 +43,6 @@ struct i915_screen uint pci_id; }; - /** * Subclass of pipe_transfer */ @@ -62,7 +54,11 @@ struct i915_transfer }; -/** cast wrappers */ +/* + * Cast wrappers + */ + + static INLINE struct i915_screen * i915_screen(struct pipe_screen *pscreen) { @@ -70,14 +66,10 @@ i915_screen(struct pipe_screen *pscreen) } static INLINE struct i915_transfer * -i915_transfer( struct pipe_transfer *transfer ) +i915_transfer(struct pipe_transfer *transfer) { return (struct i915_transfer *)transfer; } -#ifdef __cplusplus -} -#endif - #endif /* I915_SCREEN_H */ -- cgit v1.2.3 From bd0c51874f6dc7610b87d55c182b696517358dbe Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Mon, 31 Aug 2009 00:36:24 +0100 Subject: i915g: Cleanup i915_prim_vbuf.c --- src/gallium/drivers/i915simple/i915_prim_vbuf.c | 203 +++++++++++------------- 1 file changed, 97 insertions(+), 106 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c index 3ab09b58d7..656333d897 100644 --- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c +++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c @@ -59,7 +59,7 @@ struct i915_vbuf_render { struct vbuf_render base; - struct i915_context *i915; + struct i915_context *i915; /** Vertex size in bytes */ size_t vertex_size; @@ -87,32 +87,30 @@ struct i915_vbuf_render { * Basically a cast wrapper. */ static INLINE struct i915_vbuf_render * -i915_vbuf_render( struct vbuf_render *render ) +i915_vbuf_render(struct vbuf_render *render) { assert(render); return (struct i915_vbuf_render *)render; } - static const struct vertex_info * -i915_vbuf_render_get_vertex_info( struct vbuf_render *render ) +i915_vbuf_render_get_vertex_info(struct vbuf_render *render) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; if (i915->dirty) { /* make sure we have up to date vertex layout */ - i915_update_derived( i915 ); + i915_update_derived(i915); } return &i915->current.vertex_info; } - static boolean -i915_vbuf_render_allocate_vertices( struct vbuf_render *render, - ushort vertex_size, - ushort nr_vertices ) +i915_vbuf_render_allocate_vertices(struct vbuf_render *render, + ushort vertex_size, + ushort nr_vertices) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -149,9 +147,8 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render, return TRUE; } - static void * -i915_vbuf_render_map_vertices( struct vbuf_render *render ) +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; @@ -168,9 +165,9 @@ i915_vbuf_render_map_vertices( struct vbuf_render *render ) } static void -i915_vbuf_render_unmap_vertices( struct vbuf_render *render, - ushort min_index, - ushort max_index ) +i915_vbuf_render_unmap_vertices(struct vbuf_render *render, + ushort min_index, + ushort max_index) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -181,8 +178,8 @@ i915_vbuf_render_unmap_vertices( struct vbuf_render *render, } static boolean -i915_vbuf_render_set_primitive( struct vbuf_render *render, - unsigned prim ) +i915_vbuf_render_set_primitive(struct vbuf_render *render, + unsigned prim) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); i915_render->prim = prim; @@ -234,15 +231,13 @@ i915_vbuf_render_set_primitive( struct vbuf_render *render, } } - - /** * Used for fallbacks in draw_arrays */ static void -draw_arrays_generate_indices( struct vbuf_render *render, - unsigned start, uint nr, - unsigned type ) +draw_arrays_generate_indices(struct vbuf_render *render, + unsigned start, uint nr, + unsigned type) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -251,29 +246,29 @@ draw_arrays_generate_indices( struct vbuf_render *render, switch(type) { case 0: for (i = start; i+1 < end; i += 2) - OUT_BATCH( (i+0) | (i+1) << 16 ); + OUT_BATCH((i+0) | (i+1) << 16); if (i < end) - OUT_BATCH( i ); + OUT_BATCH(i); break; case PIPE_PRIM_LINE_LOOP: if (nr >= 2) { - for (i = start + 1; i < end; i++) - OUT_BATCH( (i-0) | (i+0) << 16 ); - OUT_BATCH( (i-0) | ( start) << 16 ); + for (i = start + 1; i < end; i++) + OUT_BATCH((i-0) | (i+0) << 16); + OUT_BATCH((i-0) | ( start) << 16); } break; case PIPE_PRIM_QUADS: for (i = start; i + 3 < end; i += 4) { - OUT_BATCH( (i+0) | (i+1) << 16 ); - OUT_BATCH( (i+3) | (i+1) << 16 ); - OUT_BATCH( (i+2) | (i+3) << 16 ); + OUT_BATCH((i+0) | (i+1) << 16); + OUT_BATCH((i+3) | (i+1) << 16); + OUT_BATCH((i+2) | (i+3) << 16); } break; case PIPE_PRIM_QUAD_STRIP: for (i = start; i + 3 < end; i += 2) { - OUT_BATCH( (i+0) | (i+1) << 16 ); - OUT_BATCH( (i+3) | (i+2) << 16 ); - OUT_BATCH( (i+0) | (i+3) << 16 ); + OUT_BATCH((i+0) | (i+1) << 16); + OUT_BATCH((i+3) | (i+2) << 16); + OUT_BATCH((i+0) | (i+3) << 16); } break; default: @@ -282,16 +277,16 @@ draw_arrays_generate_indices( struct vbuf_render *render, } static unsigned -draw_arrays_calc_nr_indices( uint nr, unsigned type ) +draw_arrays_calc_nr_indices(uint nr, unsigned type) { switch (type) { case 0: return nr; case PIPE_PRIM_LINE_LOOP: if (nr >= 2) - return nr * 2; + return nr * 2; else - return 0; + return 0; case PIPE_PRIM_QUADS: return (nr / 4) * 6; case PIPE_PRIM_QUAD_STRIP: @@ -303,64 +298,64 @@ draw_arrays_calc_nr_indices( uint nr, unsigned type ) } static void -draw_arrays_fallback( struct vbuf_render *render, - unsigned start, - uint nr ) +draw_arrays_fallback(struct vbuf_render *render, + unsigned start, + uint nr) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; unsigned nr_indices; if (i915->dirty) - i915_update_derived( i915 ); + i915_update_derived(i915); if (i915->hardware_dirty) - i915_emit_hardware_state( i915 ); + i915_emit_hardware_state(i915); - nr_indices = draw_arrays_calc_nr_indices( nr, i915_render->fallback ); + nr_indices = draw_arrays_calc_nr_indices(nr, i915_render->fallback); if (!nr_indices) return; - if (!BEGIN_BATCH( 1 + (nr_indices + 1)/2, 1 )) { + if (!BEGIN_BATCH(1 + (nr_indices + 1)/2, 1)) { FLUSH_BATCH(NULL); /* Make sure state is re-emitted after a flush: */ - i915_update_derived( i915 ); - i915_emit_hardware_state( i915 ); + i915_update_derived(i915); + i915_emit_hardware_state(i915); i915->vbo_flushed = 1; - if (!BEGIN_BATCH( 1 + (nr_indices + 1)/2, 1 )) { - assert(0); - goto out; + if (!BEGIN_BATCH(1 + (nr_indices + 1)/2, 1)) { + assert(0); + goto out; } } - OUT_BATCH( _3DPRIMITIVE | - PRIM_INDIRECT | - i915_render->hwprim | - PRIM_INDIRECT_ELTS | - nr_indices ); + OUT_BATCH(_3DPRIMITIVE | + PRIM_INDIRECT | + i915_render->hwprim | + PRIM_INDIRECT_ELTS | + nr_indices); - draw_arrays_generate_indices( render, start, nr, i915_render->fallback ); + draw_arrays_generate_indices(render, start, nr, i915_render->fallback); out: return; } static void -i915_vbuf_render_draw_arrays( struct vbuf_render *render, - unsigned start, - uint nr ) +i915_vbuf_render_draw_arrays(struct vbuf_render *render, + unsigned start, + uint nr) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); if (i915_render->fallback) { - draw_arrays_fallback( render, start, nr ); + draw_arrays_fallback(render, start, nr); return; } /* JB: TODO submit direct cmds */ - draw_arrays_fallback( render, start, nr ); + draw_arrays_fallback(render, start, nr); } /** @@ -368,10 +363,10 @@ i915_vbuf_render_draw_arrays( struct vbuf_render *render, * If type is zero normal operation assumed. */ static void -draw_generate_indices( struct vbuf_render *render, - const ushort *indices, - uint nr_indices, - unsigned type ) +draw_generate_indices(struct vbuf_render *render, + const ushort *indices, + uint nr_indices, + unsigned type) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -380,31 +375,31 @@ draw_generate_indices( struct vbuf_render *render, switch(type) { case 0: for (i = 0; i + 1 < nr_indices; i += 2) { - OUT_BATCH( indices[i] | indices[i+1] << 16 ); + OUT_BATCH(indices[i] | indices[i+1] << 16); } if (i < nr_indices) { - OUT_BATCH( indices[i] ); + OUT_BATCH(indices[i]); } break; case PIPE_PRIM_LINE_LOOP: if (nr_indices >= 2) { - for (i = 1; i < nr_indices; i++) - OUT_BATCH( indices[i-1] | indices[i] << 16 ); - OUT_BATCH( indices[i-1] | indices[0] << 16 ); + for (i = 1; i < nr_indices; i++) + OUT_BATCH(indices[i-1] | indices[i] << 16); + OUT_BATCH(indices[i-1] | indices[0] << 16); } break; case PIPE_PRIM_QUADS: for (i = 0; i + 3 < nr_indices; i += 4) { - OUT_BATCH( indices[i+0] | indices[i+1] << 16 ); - OUT_BATCH( indices[i+3] | indices[i+1] << 16 ); - OUT_BATCH( indices[i+2] | indices[i+3] << 16 ); + OUT_BATCH(indices[i+0] | indices[i+1] << 16); + OUT_BATCH(indices[i+3] | indices[i+1] << 16); + OUT_BATCH(indices[i+2] | indices[i+3] << 16); } break; case PIPE_PRIM_QUAD_STRIP: for (i = 0; i + 3 < nr_indices; i += 2) { - OUT_BATCH( indices[i+0] | indices[i+1] << 16 ); - OUT_BATCH( indices[i+3] | indices[i+2] << 16 ); - OUT_BATCH( indices[i+0] | indices[i+3] << 16 ); + OUT_BATCH(indices[i+0] | indices[i+1] << 16); + OUT_BATCH(indices[i+3] | indices[i+2] << 16); + OUT_BATCH(indices[i+0] | indices[i+3] << 16); } break; default: @@ -414,16 +409,16 @@ draw_generate_indices( struct vbuf_render *render, } static unsigned -draw_calc_nr_indices( uint nr_indices, unsigned type ) +draw_calc_nr_indices(uint nr_indices, unsigned type) { switch (type) { case 0: return nr_indices; case PIPE_PRIM_LINE_LOOP: if (nr_indices >= 2) - return nr_indices * 2; + return nr_indices * 2; else - return 0; + return 0; case PIPE_PRIM_QUADS: return (nr_indices / 4) * 6; case PIPE_PRIM_QUAD_STRIP: @@ -435,9 +430,9 @@ draw_calc_nr_indices( uint nr_indices, unsigned type ) } static void -i915_vbuf_render_draw( struct vbuf_render *render, - const ushort *indices, - uint nr_indices) +i915_vbuf_render_draw(struct vbuf_render *render, + const ushort *indices, + uint nr_indices) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -445,48 +440,47 @@ i915_vbuf_render_draw( struct vbuf_render *render, save_nr_indices = nr_indices; - nr_indices = draw_calc_nr_indices( nr_indices, i915_render->fallback ); + nr_indices = draw_calc_nr_indices(nr_indices, i915_render->fallback); if (!nr_indices) return; if (i915->dirty) - i915_update_derived( i915 ); + i915_update_derived(i915); if (i915->hardware_dirty) - i915_emit_hardware_state( i915 ); + i915_emit_hardware_state(i915); - if (!BEGIN_BATCH( 1 + (nr_indices + 1)/2, 1 )) { + if (!BEGIN_BATCH(1 + (nr_indices + 1)/2, 1)) { FLUSH_BATCH(NULL); /* Make sure state is re-emitted after a flush: */ - i915_update_derived( i915 ); - i915_emit_hardware_state( i915 ); + i915_update_derived(i915); + i915_emit_hardware_state(i915); i915->vbo_flushed = 1; - if (!BEGIN_BATCH( 1 + (nr_indices + 1)/2, 1 )) { - assert(0); - goto out; + if (!BEGIN_BATCH(1 + (nr_indices + 1)/2, 1)) { + assert(0); + goto out; } } - OUT_BATCH( _3DPRIMITIVE | - PRIM_INDIRECT | - i915_render->hwprim | - PRIM_INDIRECT_ELTS | - nr_indices ); - draw_generate_indices( render, - indices, - save_nr_indices, - i915_render->fallback ); + OUT_BATCH(_3DPRIMITIVE | + PRIM_INDIRECT | + i915_render->hwprim | + PRIM_INDIRECT_ELTS | + nr_indices); + draw_generate_indices(render, + indices, + save_nr_indices, + i915_render->fallback); out: return; } - static void -i915_vbuf_render_release_vertices( struct vbuf_render *render ) +i915_vbuf_render_release_vertices(struct vbuf_render *render) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); struct i915_context *i915 = i915_render->i915; @@ -499,20 +493,18 @@ i915_vbuf_render_release_vertices( struct vbuf_render *render ) i915->dirty |= I915_NEW_VBO; } - static void -i915_vbuf_render_destroy( struct vbuf_render *render ) +i915_vbuf_render_destroy(struct vbuf_render *render) { struct i915_vbuf_render *i915_render = i915_vbuf_render(render); FREE(i915_render); } - /** * Create a new primitive render. */ static struct vbuf_render * -i915_vbuf_render_create( struct i915_context *i915 ) +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; @@ -551,11 +543,10 @@ i915_vbuf_render_create( struct i915_context *i915 ) return &i915_render->base; } - /** * Create a new primitive vbuf/render stage. */ -struct draw_stage *i915_draw_vbuf_stage( struct i915_context *i915 ) +struct draw_stage *i915_draw_vbuf_stage(struct i915_context *i915) { struct vbuf_render *render; struct draw_stage *stage; @@ -564,7 +555,7 @@ struct draw_stage *i915_draw_vbuf_stage( struct i915_context *i915 ) if(!render) return NULL; - stage = draw_vbuf_stage( i915->draw, render ); + stage = draw_vbuf_stage(i915->draw, render); if(!stage) { render->destroy(render); return NULL; -- cgit v1.2.3 From f26065215317b1d320d11f636c65d4903788b431 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 17:45:47 +0100 Subject: i915g: Don't use winsys directly in the driver --- src/gallium/drivers/i915simple/i915_batch.h | 2 +- src/gallium/drivers/i915simple/i915_state.c | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_batch.h b/src/gallium/drivers/i915simple/i915_batch.h index c6e68ea38a..1e58c5b2a8 100644 --- a/src/gallium/drivers/i915simple/i915_batch.h +++ b/src/gallium/drivers/i915simple/i915_batch.h @@ -109,7 +109,7 @@ i915_batchbuffer_flush( struct i915_batchbuffer *batch, i915_batchbuffer_reloc( i915->batch, buf, flags, delta ) #define FLUSH_BATCH(fence) do { \ - i915->winsys->batch_flush( i915->winsys, fence ); \ + i915_batchbuffer_flush( i915->batch, fence ); \ i915->hardware_dirty = ~0; \ } while (0) diff --git a/src/gallium/drivers/i915simple/i915_state.c b/src/gallium/drivers/i915simple/i915_state.c index 272c1b1338..0087dfa410 100644 --- a/src/gallium/drivers/i915simple/i915_state.c +++ b/src/gallium/drivers/i915simple/i915_state.c @@ -518,7 +518,7 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, const struct pipe_constant_buffer *buf) { struct i915_context *i915 = i915_context(pipe); - struct pipe_winsys *ws = pipe->winsys; + struct pipe_screen *screen = pipe->screen; draw_flush(i915->draw); assert(shader < PIPE_SHADER_TYPES); @@ -536,10 +536,10 @@ static void i915_set_constant_buffer(struct pipe_context *pipe, if (buf) { void *mapped; if (buf->buffer && buf->buffer->size && - (mapped = ws->buffer_map(ws, buf->buffer, + (mapped = pipe_buffer_map(screen, buf->buffer, PIPE_BUFFER_USAGE_CPU_READ))) { memcpy(i915->current.constants[shader], mapped, buf->buffer->size); - ws->buffer_unmap(ws, buf->buffer); + pipe_buffer_unmap(screen, buf->buffer); i915->current.num_user_constants[shader] = buf->buffer->size / (4 * sizeof(float)); } -- cgit v1.2.3 From 5374aff56f1ebd161f11b5469f7427ea73c09a41 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 19:20:45 +0100 Subject: i915g: Reorg texture code a bit --- src/gallium/drivers/i915simple/i915_texture.c | 89 ++++++++++++++++----------- 1 file changed, 53 insertions(+), 36 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c index d363962889..1ed38563a0 100644 --- a/src/gallium/drivers/i915simple/i915_texture.c +++ b/src/gallium/drivers/i915simple/i915_texture.c @@ -44,10 +44,12 @@ #include "i915_screen.h" #include "i915_winsys.h" + /* * Helper function and arrays */ + /** * Initial offset for Cube map. */ @@ -487,7 +489,6 @@ i915_miptree_layout(struct i915_texture * tex) return TRUE; } - static boolean i945_miptree_layout(struct i915_texture * tex) { @@ -575,6 +576,11 @@ i945_miptree_layout(struct i915_texture * tex) } +/* + * Screen texture functions + */ + + static struct pipe_texture * i915_texture_create(struct pipe_screen *screen, const struct pipe_texture *templat) @@ -629,6 +635,39 @@ fail: return NULL; } +static struct pipe_texture * +i915_texture_blanket(struct pipe_screen * screen, + const struct pipe_texture *base, + const unsigned *stride, + struct pipe_buffer *buffer) +{ + 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 NULL; + + tex->base = *base; + pipe_reference_init(&tex->base.reference, 1); + tex->base.screen = screen; + + tex->stride = stride[0]; + + 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); + + pipe_buffer_reference(&tex->buffer, buffer); + + return &tex->base; +} static void i915_texture_destroy(struct pipe_texture *pt) @@ -649,6 +688,12 @@ i915_texture_destroy(struct pipe_texture *pt) FREE(tex); } + +/* + * Screen surface functions + */ + + static struct pipe_surface * i915_get_tex_surface(struct pipe_screen *screen, struct pipe_texture *pt, @@ -684,40 +729,6 @@ i915_get_tex_surface(struct pipe_screen *screen, return ps; } -static struct pipe_texture * -i915_texture_blanket(struct pipe_screen * screen, - const struct pipe_texture *base, - const unsigned *stride, - struct pipe_buffer *buffer) -{ - 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 NULL; - - tex->base = *base; - pipe_reference_init(&tex->base.reference, 1); - tex->base.screen = screen; - - tex->stride = stride[0]; - - 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); - - pipe_buffer_reference(&tex->buffer, buffer); - - return &tex->base; -} - static void i915_tex_surface_destroy(struct pipe_surface *surf) { @@ -725,13 +736,19 @@ i915_tex_surface_destroy(struct pipe_surface *surf) FREE(surf); } + +/* + * Other texture functions + */ + + void i915_init_screen_texture_functions(struct i915_screen *is) { is->base.texture_create = i915_texture_create; + is->base.texture_blanket = i915_texture_blanket; is->base.texture_destroy = i915_texture_destroy; is->base.get_tex_surface = i915_get_tex_surface; - is->base.texture_blanket = i915_texture_blanket; is->base.tex_surface_destroy = i915_tex_surface_destroy; } -- cgit v1.2.3 From 761c8c7076f23e044fcbc9987c95d5178482e846 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 19:31:14 +0100 Subject: i915g: Move transfer functions into i915_texture.c --- src/gallium/drivers/i915simple/i915_screen.c | 91 -------------------------- src/gallium/drivers/i915simple/i915_texture.c | 93 +++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 91 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c index dccd0e287b..a03d740b1b 100644 --- a/src/gallium/drivers/i915simple/i915_screen.c +++ b/src/gallium/drivers/i915simple/i915_screen.c @@ -198,93 +198,6 @@ i915_destroy_screen(struct pipe_screen *screen) FREE(screen); } -static struct pipe_transfer* -i915_get_tex_transfer(struct pipe_screen *screen, - struct pipe_texture *texture, - unsigned face, unsigned level, unsigned zslice, - enum pipe_transfer_usage usage, unsigned x, unsigned y, - unsigned w, unsigned h) -{ - struct i915_texture *tex = (struct i915_texture *)texture; - struct i915_transfer *trans; - unsigned offset; /* in bytes */ - - if (texture->target == PIPE_TEXTURE_CUBE) { - offset = tex->image_offset[level][face]; - } - else if (texture->target == PIPE_TEXTURE_3D) { - offset = tex->image_offset[level][zslice]; - } - else { - offset = tex->image_offset[level][0]; - assert(face == 0); - assert(zslice == 0); - } - - trans = CALLOC_STRUCT(i915_transfer); - if (trans) { - pipe_texture_reference(&trans->base.texture, texture); - trans->base.format = trans->base.format; - trans->base.x = x; - trans->base.y = y; - trans->base.width = w; - trans->base.height = h; - trans->base.block = texture->block; - trans->base.nblocksx = texture->nblocksx[level]; - trans->base.nblocksy = texture->nblocksy[level]; - trans->base.stride = tex->stride; - trans->offset = offset; - trans->base.usage = usage; - } - return &trans->base; -} - -static void -i915_tex_transfer_destroy(struct pipe_transfer *trans) -{ - pipe_texture_reference(&trans->texture, NULL); - FREE(trans); -} - -static void * -i915_transfer_map( struct pipe_screen *screen, - struct pipe_transfer *transfer ) -{ - struct i915_texture *tex = (struct i915_texture *)transfer->texture; - char *map; - unsigned flags = 0; - - if (transfer->usage != PIPE_TRANSFER_WRITE) - flags |= PIPE_BUFFER_USAGE_CPU_READ; - - if (transfer->usage != PIPE_TRANSFER_READ) - flags |= PIPE_BUFFER_USAGE_CPU_WRITE; - - map = pipe_buffer_map( screen, tex->buffer, flags ); - if (map == NULL) - return NULL; - - if (transfer->texture && - (flags & PIPE_BUFFER_USAGE_CPU_WRITE)) - { - /* Do something to notify contexts of a texture change. - */ - /* i915_screen(screen)->timestamp++; */ - } - - return map + i915_transfer(transfer)->offset + - transfer->y / transfer->block.height * transfer->stride + - transfer->x / transfer->block.width * transfer->block.size; -} - -static void -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 ); -} - /** * Create a new i915_screen object */ @@ -328,10 +241,6 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id) is->base.get_param = i915_get_param; is->base.get_paramf = i915_get_paramf; is->base.is_format_supported = i915_is_format_supported; - is->base.get_tex_transfer = i915_get_tex_transfer; - is->base.tex_transfer_destroy = i915_tex_transfer_destroy; - is->base.transfer_map = i915_transfer_map; - is->base.transfer_unmap = i915_transfer_unmap; i915_init_screen_texture_functions(is); u_simple_screen_init(&is->base); diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c index 1ed38563a0..7f0a4dbd93 100644 --- a/src/gallium/drivers/i915simple/i915_texture.c +++ b/src/gallium/drivers/i915simple/i915_texture.c @@ -737,6 +737,95 @@ i915_tex_surface_destroy(struct pipe_surface *surf) } +/* + * Screen transfer functions + */ + + +static struct pipe_transfer* +i915_get_tex_transfer(struct pipe_screen *screen, + struct pipe_texture *texture, + unsigned face, unsigned level, unsigned zslice, + enum pipe_transfer_usage usage, unsigned x, unsigned y, + unsigned w, unsigned h) +{ + struct i915_texture *tex = (struct i915_texture *)texture; + struct i915_transfer *trans; + unsigned offset; /* in bytes */ + + if (texture->target == PIPE_TEXTURE_CUBE) { + offset = tex->image_offset[level][face]; + } + else if (texture->target == PIPE_TEXTURE_3D) { + offset = tex->image_offset[level][zslice]; + } + else { + offset = tex->image_offset[level][0]; + assert(face == 0); + assert(zslice == 0); + } + + trans = CALLOC_STRUCT(i915_transfer); + if (trans) { + pipe_texture_reference(&trans->base.texture, texture); + trans->base.format = trans->base.format; + trans->base.x = x; + trans->base.y = y; + trans->base.width = w; + trans->base.height = h; + trans->base.block = texture->block; + trans->base.nblocksx = texture->nblocksx[level]; + trans->base.nblocksy = texture->nblocksy[level]; + trans->base.stride = tex->stride; + trans->offset = offset; + trans->base.usage = usage; + } + return &trans->base; +} + +static void * +i915_transfer_map(struct pipe_screen *screen, + struct pipe_transfer *transfer) +{ + struct i915_texture *tex = (struct i915_texture *)transfer->texture; + char *map; + unsigned flags = 0; + + if (transfer->usage != PIPE_TRANSFER_WRITE) + flags |= PIPE_BUFFER_USAGE_CPU_READ; + + if (transfer->usage != PIPE_TRANSFER_READ) + flags |= PIPE_BUFFER_USAGE_CPU_WRITE; + + map = pipe_buffer_map(screen, tex->buffer, flags); + 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; +} + +static void +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); +} + +static void +i915_tex_transfer_destroy(struct pipe_transfer *trans) +{ + pipe_texture_reference(&trans->texture, NULL); + FREE(trans); +} + + /* * Other texture functions */ @@ -750,6 +839,10 @@ i915_init_screen_texture_functions(struct i915_screen *is) is->base.texture_destroy = i915_texture_destroy; is->base.get_tex_surface = i915_get_tex_surface; is->base.tex_surface_destroy = i915_tex_surface_destroy; + is->base.get_tex_transfer = i915_get_tex_transfer; + is->base.transfer_map = i915_transfer_map; + is->base.transfer_unmap = i915_transfer_unmap; + is->base.tex_transfer_destroy = i915_tex_transfer_destroy; } boolean i915_get_texture_buffer(struct pipe_texture *texture, -- cgit v1.2.3 From 5f7b46ae5fc7854ec68f7003c2a69672c19b3464 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 20:25:17 +0100 Subject: i915g: Reorg texture layout code --- src/gallium/drivers/i915simple/i915_texture.c | 403 +++++++++++++------------- 1 file changed, 207 insertions(+), 196 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c index 7f0a4dbd93..5cb62b164f 100644 --- a/src/gallium/drivers/i915simple/i915_texture.c +++ b/src/gallium/drivers/i915simple/i915_texture.c @@ -152,7 +152,7 @@ i915_miptree_set_image_offset(struct i915_texture *tex, /* - * Layout functions + * i915 layout functions, some used by i945 */ @@ -196,6 +196,148 @@ i915_scanout_layout(struct i915_texture *tex) return 1; } +static void +i915_miptree_layout_2d(struct i915_texture *tex) +{ + struct pipe_texture *pt = &tex->base; + unsigned level; + unsigned width = pt->width[0]; + unsigned height = pt->height[0]; + unsigned nblocksx = pt->nblocksx[0]; + unsigned nblocksy = pt->nblocksy[0]; + + tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4); + tex->total_nblocksy = 0; + + for (level = 0; level <= pt->last_level; level++) { + i915_miptree_set_level_info(tex, level, 1, width, height, 1); + i915_miptree_set_image_offset(tex, level, 0, 0, tex->total_nblocksy); + + nblocksy = round_up(MAX2(2, nblocksy), 2); + + tex->total_nblocksy += nblocksy; + + width = minify(width); + height = minify(height); + nblocksx = pf_get_nblocksx(&pt->block, width); + nblocksy = pf_get_nblocksy(&pt->block, height); + } +} + +static void +i915_miptree_layout_3d(struct i915_texture *tex) +{ + struct pipe_texture *pt = &tex->base; + unsigned level; + + unsigned width = pt->width[0]; + unsigned height = pt->height[0]; + unsigned depth = pt->depth[0]; + unsigned nblocksx = pt->nblocksx[0]; + unsigned nblocksy = pt->nblocksy[0]; + unsigned stack_nblocksy = 0; + + /* Calculate the size of a single slice. + */ + tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4); + + /* XXX: hardware expects/requires 9 levels at minimum. + */ + for (level = 0; level <= MAX2(8, pt->last_level); level++) { + i915_miptree_set_level_info(tex, level, depth, width, height, depth); + + stack_nblocksy += MAX2(2, nblocksy); + + width = minify(width); + height = minify(height); + depth = minify(depth); + nblocksx = pf_get_nblocksx(&pt->block, width); + nblocksy = pf_get_nblocksy(&pt->block, height); + } + + /* Fixup depth image_offsets: + */ + depth = pt->depth[0]; + for (level = 0; level <= pt->last_level; level++) { + unsigned i; + for (i = 0; i < depth; i++) + i915_miptree_set_image_offset(tex, level, i, 0, i * stack_nblocksy); + + depth = minify(depth); + } + + /* Multiply slice size by texture depth for total size. It's + * remarkable how wasteful of memory the i915 texture layouts + * are. They are largely fixed in the i945. + */ + tex->total_nblocksy = stack_nblocksy * pt->depth[0]; +} + +static void +i915_miptree_layout_cube(struct i915_texture *tex) +{ + struct pipe_texture *pt = &tex->base; + unsigned width = pt->width[0], height = pt->height[0]; + const unsigned nblocks = pt->nblocksx[0]; + unsigned level; + unsigned face; + + assert(width == height); /* cubemap images are square */ + + /* double pitch for cube layouts */ + tex->stride = round_up(nblocks * pt->block.size * 2, 4); + tex->total_nblocksy = nblocks * 4; + + for (level = 0; level <= pt->last_level; level++) { + i915_miptree_set_level_info(tex, level, 6, width, height, 1); + width /= 2; + height /= 2; + } + + for (face = 0; face < 6; face++) { + unsigned x = initial_offsets[face][0] * nblocks; + unsigned y = initial_offsets[face][1] * nblocks; + unsigned d = nblocks; + + for (level = 0; level <= pt->last_level; level++) { + i915_miptree_set_image_offset(tex, level, face, x, y); + d >>= 1; + x += step_offsets[face][0] * d; + y += step_offsets[face][1] * d; + } + } +} + +static boolean +i915_miptree_layout(struct i915_texture * tex) +{ + struct pipe_texture *pt = &tex->base; + + switch (pt->target) { + case PIPE_TEXTURE_1D: + case PIPE_TEXTURE_2D: + i915_miptree_layout_2d(tex); + break; + case PIPE_TEXTURE_3D: + i915_miptree_layout_3d(tex); + break; + case PIPE_TEXTURE_CUBE: + i915_miptree_layout_cube(tex); + break; + default: + assert(0); + return FALSE; + } + + return TRUE; +} + + +/* + * i945 layout functions + */ + + static void i945_miptree_layout_2d(struct i915_texture *tex) { @@ -262,6 +404,63 @@ i945_miptree_layout_2d(struct i915_texture *tex) } } +static void +i945_miptree_layout_3d(struct i915_texture *tex) +{ + struct pipe_texture *pt = &tex->base; + unsigned width = pt->width[0]; + unsigned height = pt->height[0]; + unsigned depth = pt->depth[0]; + unsigned nblocksx = pt->nblocksx[0]; + unsigned nblocksy = pt->nblocksy[0]; + unsigned pack_x_pitch, pack_x_nr; + unsigned pack_y_pitch; + unsigned level; + + tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4); + tex->total_nblocksy = 0; + + pack_y_pitch = MAX2(pt->nblocksy[0], 2); + pack_x_pitch = tex->stride / pt->block.size; + pack_x_nr = 1; + + for (level = 0; level <= pt->last_level; level++) { + int x = 0; + int y = 0; + unsigned q, j; + + i915_miptree_set_level_info(tex, level, depth, width, height, depth); + + for (q = 0; q < depth;) { + for (j = 0; j < pack_x_nr && q < depth; j++, q++) { + i915_miptree_set_image_offset(tex, level, q, x, y + tex->total_nblocksy); + x += pack_x_pitch; + } + + x = 0; + y += pack_y_pitch; + } + + tex->total_nblocksy += y; + + if (pack_x_pitch > 4) { + pack_x_pitch >>= 1; + pack_x_nr <<= 1; + assert(pack_x_pitch * pack_x_nr * pt->block.size <= tex->stride); + } + + if (pack_y_pitch > 2) { + pack_y_pitch >>= 1; + } + + width = minify(width); + height = minify(height); + depth = minify(depth); + nblocksx = pf_get_nblocksx(&pt->block, width); + nblocksy = pf_get_nblocksy(&pt->block, height); + } +} + static void i945_miptree_layout_cube(struct i915_texture *tex) { @@ -363,215 +562,27 @@ i945_miptree_layout_cube(struct i915_texture *tex) } } -static boolean -i915_miptree_layout(struct i915_texture * tex) -{ - struct pipe_texture *pt = &tex->base; - unsigned level; - - switch (pt->target) { - case PIPE_TEXTURE_CUBE: { - const unsigned nblocks = pt->nblocksx[0]; - unsigned face; - unsigned width = pt->width[0], height = pt->height[0]; - - assert(width == height); /* cubemap images are square */ - - /* double pitch for cube layouts */ - tex->stride = round_up(nblocks * pt->block.size * 2, 4); - tex->total_nblocksy = nblocks * 4; - - for (level = 0; level <= pt->last_level; level++) { - i915_miptree_set_level_info(tex, level, 6, - width, height, - 1); - width /= 2; - height /= 2; - } - - for (face = 0; face < 6; face++) { - unsigned x = initial_offsets[face][0] * nblocks; - unsigned y = initial_offsets[face][1] * nblocks; - unsigned d = nblocks; - - for (level = 0; level <= pt->last_level; level++) { - i915_miptree_set_image_offset(tex, level, face, x, y); - d >>= 1; - x += step_offsets[face][0] * d; - y += step_offsets[face][1] * d; - } - } - break; - } - case PIPE_TEXTURE_3D:{ - unsigned width = pt->width[0]; - unsigned height = pt->height[0]; - unsigned depth = pt->depth[0]; - unsigned nblocksx = pt->nblocksx[0]; - unsigned nblocksy = pt->nblocksy[0]; - unsigned stack_nblocksy = 0; - - /* Calculate the size of a single slice. - */ - tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4); - - /* XXX: hardware expects/requires 9 levels at minimum. - */ - for (level = 0; level <= MAX2(8, pt->last_level); - level++) { - i915_miptree_set_level_info(tex, level, depth, - width, height, depth); - - - stack_nblocksy += MAX2(2, nblocksy); - - width = minify(width); - height = minify(height); - depth = minify(depth); - nblocksx = pf_get_nblocksx(&pt->block, width); - nblocksy = pf_get_nblocksy(&pt->block, height); - } - - /* Fixup depth image_offsets: - */ - depth = pt->depth[0]; - for (level = 0; level <= pt->last_level; level++) { - unsigned i; - for (i = 0; i < depth; i++) - i915_miptree_set_image_offset(tex, level, i, - 0, i * stack_nblocksy); - - depth = minify(depth); - } - - - /* Multiply slice size by texture depth for total size. It's - * remarkable how wasteful of memory the i915 texture layouts - * are. They are largely fixed in the i945. - */ - tex->total_nblocksy = stack_nblocksy * pt->depth[0]; - break; - } - - default:{ - unsigned width = pt->width[0]; - unsigned height = pt->height[0]; - unsigned nblocksx = pt->nblocksx[0]; - unsigned nblocksy = pt->nblocksy[0]; - - tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4); - tex->total_nblocksy = 0; - - for (level = 0; level <= pt->last_level; level++) { - i915_miptree_set_level_info(tex, level, 1, - width, height, 1); - i915_miptree_set_image_offset(tex, level, 0, - 0, tex->total_nblocksy); - - nblocksy = round_up(MAX2(2, nblocksy), 2); - - tex->total_nblocksy += nblocksy; - - width = minify(width); - height = minify(height); - nblocksx = pf_get_nblocksx(&pt->block, width); - nblocksy = pf_get_nblocksy(&pt->block, height); - } - break; - } - } - /* - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - tex->pitch, - tex->total_nblocksy, pt->block.size, tex->stride * tex->total_nblocksy); - */ - - return TRUE; -} - static boolean i945_miptree_layout(struct i915_texture * tex) { struct pipe_texture *pt = &tex->base; - unsigned level; switch (pt->target) { + case PIPE_TEXTURE_1D: + case PIPE_TEXTURE_2D: + i945_miptree_layout_2d(tex); + break; + case PIPE_TEXTURE_3D: + i945_miptree_layout_3d(tex); + break; case PIPE_TEXTURE_CUBE: i945_miptree_layout_cube(tex); break; - case PIPE_TEXTURE_3D:{ - unsigned width = pt->width[0]; - unsigned height = pt->height[0]; - unsigned depth = pt->depth[0]; - unsigned nblocksx = pt->nblocksx[0]; - unsigned nblocksy = pt->nblocksy[0]; - unsigned pack_x_pitch, pack_x_nr; - unsigned pack_y_pitch; - - tex->stride = round_up(pt->nblocksx[0] * pt->block.size, 4); - tex->total_nblocksy = 0; - - pack_y_pitch = MAX2(pt->nblocksy[0], 2); - pack_x_pitch = tex->stride / pt->block.size; - pack_x_nr = 1; - - for (level = 0; level <= pt->last_level; level++) { - unsigned nr_images = pt->target == PIPE_TEXTURE_3D ? depth : 6; - int x = 0; - int y = 0; - unsigned q, j; - - i915_miptree_set_level_info(tex, level, nr_images, - width, height, depth); - - for (q = 0; q < nr_images;) { - for (j = 0; j < pack_x_nr && q < nr_images; j++, q++) { - i915_miptree_set_image_offset(tex, level, q, x, y + tex->total_nblocksy); - x += pack_x_pitch; - } - - x = 0; - y += pack_y_pitch; - } - - - tex->total_nblocksy += y; - - if (pack_x_pitch > 4) { - pack_x_pitch >>= 1; - pack_x_nr <<= 1; - assert(pack_x_pitch * pack_x_nr * pt->block.size <= tex->stride); - } - - if (pack_y_pitch > 2) { - pack_y_pitch >>= 1; - } - - width = minify(width); - height = minify(height); - depth = minify(depth); - nblocksx = pf_get_nblocksx(&pt->block, width); - nblocksy = pf_get_nblocksy(&pt->block, height); - } - break; - } - - case PIPE_TEXTURE_1D: - case PIPE_TEXTURE_2D: -// case PIPE_TEXTURE_RECTANGLE: - i945_miptree_layout_2d(tex); - break; default: assert(0); return FALSE; } - /* - DBG("%s: %dx%dx%d - sz 0x%x\n", __FUNCTION__, - tex->pitch, - tex->total_nblocksy, pt->block.size, tex->stride * tex->total_nblocksy); - */ - return TRUE; } -- cgit v1.2.3 From 105e4b093e28d6cd9e8ec2db9dbc23980d265796 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 16:26:01 +0100 Subject: i915g: Add new buffer code not yet hocked up --- src/gallium/drivers/i915simple/Makefile | 1 + src/gallium/drivers/i915simple/SConscript | 1 + src/gallium/drivers/i915simple/i915_buffer.c | 136 +++++++++++++++++++++++++++ src/gallium/drivers/i915simple/i915_buffer.h | 31 ++++++ 4 files changed, 169 insertions(+) create mode 100644 src/gallium/drivers/i915simple/i915_buffer.c create mode 100644 src/gallium/drivers/i915simple/i915_buffer.h (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/Makefile b/src/gallium/drivers/i915simple/Makefile index 8870b39866..fb533c1796 100644 --- a/src/gallium/drivers/i915simple/Makefile +++ b/src/gallium/drivers/i915simple/Makefile @@ -5,6 +5,7 @@ LIBNAME = i915simple C_SOURCES = \ i915_blit.c \ + i915_buffer.c \ i915_clear.c \ i915_flush.c \ i915_context.c \ diff --git a/src/gallium/drivers/i915simple/SConscript b/src/gallium/drivers/i915simple/SConscript index 2366e1247f..778c4ed0fd 100644 --- a/src/gallium/drivers/i915simple/SConscript +++ b/src/gallium/drivers/i915simple/SConscript @@ -6,6 +6,7 @@ i915simple = env.ConvenienceLibrary( target = 'i915simple', source = [ 'i915_blit.c', + 'i915_buffer.c', 'i915_clear.c', 'i915_context.c', 'i915_debug.c', diff --git a/src/gallium/drivers/i915simple/i915_buffer.c b/src/gallium/drivers/i915simple/i915_buffer.c new file mode 100644 index 0000000000..effeba1297 --- /dev/null +++ b/src/gallium/drivers/i915simple/i915_buffer.c @@ -0,0 +1,136 @@ +/************************************************************************** + * + * Copyright © 2009 Jakob Bornecrantz + * + * 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, sublicense, + * 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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. + * + **************************************************************************/ + +#include "util/u_memory.h" +#include "i915_screen.h" +#include "i915_buffer.h" + +struct intel_buffer; + +struct i915_buffer +{ + struct pipe_buffer base; + + struct intel_buffer *ibuf; /** hw buffer */ + + void *data; /**< user and malloc data */ + boolean own; /**< we own the data incase of malloc */ +}; + +static INLINE struct i915_buffer * +i915_buffer(struct pipe_buffer *buffer) +{ + return (struct i915_buffer *)buffer; +} + +static struct pipe_buffer * +i915_buffer_create(struct pipe_screen *screen, + unsigned alignment, + unsigned usage, + unsigned size) +{ + struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer); + + if (!buf) + return NULL; + + pipe_reference_init(&buf->base.reference, 1); + buf->base.alignment = alignment; + buf->base.screen = screen; + buf->base.usage = usage; + buf->base.size = size; + buf->data = MALLOC(size); + buf->own = TRUE; + + if (!buf->data) + goto err; + + return &buf->base; + +err: + FREE(buf); + return NULL; +} + +static struct pipe_buffer * +i915_user_buffer_create(struct pipe_screen *screen, + void *ptr, + unsigned bytes) +{ + struct i915_buffer *buf = CALLOC_STRUCT(i915_buffer); + + if (!buf) + return NULL; + + pipe_reference_init(&buf->base.reference, 1); + buf->base.alignment = 0; + buf->base.screen = screen; + buf->base.usage = 0; + buf->base.size = bytes; + buf->data = ptr; + buf->own = FALSE; + + return &buf->base; +} + +static void * +i915_buffer_map(struct pipe_screen *screen, + struct pipe_buffer *buffer, + unsigned usage) +{ + struct i915_buffer *buf = i915_buffer(buffer); + assert(!buf->ibuf); + return buf->data; +} + +static void +i915_buffer_unmap(struct pipe_screen *screen, + struct pipe_buffer *buffer) +{ + struct i915_buffer *buf = i915_buffer(buffer); + assert(!buf->ibuf); +} + +static void +i915_buffer_destroy(struct pipe_buffer *buffer) +{ + struct i915_buffer *buf = i915_buffer(buffer); + assert(!buf->ibuf); + + if (buf->own) + FREE(buf->data); + FREE(buf); +} + +void i915_init_screen_buffer_functions(struct i915_screen *screen) +{ + screen->base.buffer_create = i915_buffer_create; + screen->base.user_buffer_create = i915_user_buffer_create; + screen->base.buffer_map = i915_buffer_map; + screen->base.buffer_map_range = NULL; + screen->base.buffer_flush_mapped_range = NULL; + screen->base.buffer_unmap = i915_buffer_unmap; + screen->base.buffer_destroy = i915_buffer_destroy; +} diff --git a/src/gallium/drivers/i915simple/i915_buffer.h b/src/gallium/drivers/i915simple/i915_buffer.h new file mode 100644 index 0000000000..80fda7c62f --- /dev/null +++ b/src/gallium/drivers/i915simple/i915_buffer.h @@ -0,0 +1,31 @@ +/************************************************************************** + * + * Copyright © 2009 Jakob Bornecrantz + * + * 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, sublicense, + * 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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 I915_BUFFER_H +#define I915_BUFFER_H + +void i915_init_screen_buffer_functions(struct i915_screen *screen); + +#endif -- cgit v1.2.3 From dd040753d7703ac5edbf1aeb336c0093862a2486 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 18:30:35 +0100 Subject: i915g: Add header file for new winsys interface --- src/gallium/drivers/i915simple/intel_winsys.h | 219 ++++++++++++++++++++++++++ 1 file changed, 219 insertions(+) create mode 100644 src/gallium/drivers/i915simple/intel_winsys.h (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/intel_winsys.h b/src/gallium/drivers/i915simple/intel_winsys.h new file mode 100644 index 0000000000..e123c32d88 --- /dev/null +++ b/src/gallium/drivers/i915simple/intel_winsys.h @@ -0,0 +1,219 @@ +/************************************************************************** + * + * Copyright © 2009 Jakob Bornecrantz + * + * 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, sublicense, + * 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 NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS 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_WINSYS_H +#define INTEL_WINSYS_H + +#include "pipe/p_compiler.h" + +struct intel_winsys; +struct intel_buffer; +struct intel_batchbuffer; +struct pipe_texture; +struct pipe_fence_handle; + +enum intel_buffer_usage +{ + /* use on textures */ + INTEL_USAGE_RENDER = 0x01, + INTEL_USAGE_SAMPLER = 0x02, + INTEL_USAGE_2D_TARGET = 0x04, + INTEL_USAGE_2D_SOURCE = 0x08, + /* use on vertex */ + INTEL_USAGE_VERTEX = 0x10, +}; + +enum intel_buffer_type +{ + INTEL_NEW_TEXTURE, + INTEL_NEW_SCANOUT, /**< a texture used for scanning out from */ + INTEL_NEW_VERTEX, +}; + +enum intel_buffer_tile +{ + INTEL_TILE_NONE, + INTEL_TILE_X, + INTEL_TILE_Y, +}; + +struct intel_batchbuffer { + + struct intel_winsys *iws; + + /** + * Values exported to speed up the writing the batchbuffer, + * instead of having to go trough a accesor function for + * each dword written. + */ + /*{@*/ + void *map; + void *ptr; + size_t size; + + size_t relocs; + size_t max_relocs; + /*@}*/ +}; + +struct intel_winsys { + + /** + * Batchbuffer functions. + */ + /*@{*/ + /** + * Create a new batchbuffer. + */ + struct intel_batchbuffer *(*batchbuffer_create)(struct intel_winsys *iws); + + /** + * Emit a relocation to a buffer. + * Target position in batchbuffer is the same as ptr. + * + * @batch + * @reloc buffer address to be inserted into target. + * @usage how is the hardware going to use the buffer. + * @offset add this to the reloc buffers address + * @target buffer where to write the address, null for batchbuffer. + */ + int (*batchbuffer_reloc)(struct intel_batchbuffer *batch, + struct intel_buffer *reloc, + enum intel_buffer_usage usage, + unsigned offset); + + /** + * Flush a bufferbatch. + */ + void (*batchbuffer_flush)(struct intel_batchbuffer *batch, + struct pipe_fence_handle **fence); + + /** + * Destroy a batchbuffer. + */ + void (*batchbuffer_destroy)(struct intel_batchbuffer *batch); + /*@}*/ + + + /** + * Buffer functions. + */ + /*@{*/ + /** + * Create a buffer. + */ + struct intel_buffer *(*buffer_create)(struct intel_winsys *iws, + unsigned size, unsigned alignment, + enum intel_buffer_type type); + + /** + * Fence a buffer with a fence reg. + * Not to be confused with pipe_fence_handle. + */ + int (*buffer_set_fence_reg)(struct intel_winsys *iws, + struct intel_buffer *buffer, + unsigned stride, + enum intel_buffer_tile tile); + + /** + * Map a buffer. + */ + void *(*buffer_map)(struct intel_winsys *iws, + struct intel_buffer *buffer, + boolean write); + + /** + * Unmap a buffer. + */ + void (*buffer_unmap)(struct intel_winsys *iws, + struct intel_buffer *buffer); + + void (*buffer_destroy)(struct intel_winsys *iws, + struct intel_buffer *buffer); + /*@}*/ + + + /** + * Fence functions. + */ + /*@{*/ + /** + * Reference fence and set ptr to fence. + */ + void (*fence_reference)(struct intel_winsys *iws, + struct pipe_fence_handle **ptr, + struct pipe_fence_handle *fence); + + /** + * Check if a fence has finished. + */ + int (*fence_signalled)(struct intel_winsys *iws, + struct pipe_fence_handle *fence); + + /** + * Wait on a fence to finish. + */ + int (*fence_finish)(struct intel_winsys *iws, + struct pipe_fence_handle *fence); + /*@}*/ + + + /** + * Destroy the winsys. + */ + void (*destroy)(struct intel_winsys *iws); +}; + + +/** + * Create i915 pipe_screen. + */ +struct pipe_screen *i915_create_screen(struct intel_winsys *iws, unsigned pci_id); + +/** + * Create a i915 pipe_context. + */ +struct pipe_context *i915_create_context(struct pipe_screen *screen); + +/** + * Get the intel_winsys buffer backing the texture. + * + * TODO UGLY + */ +boolean i915_get_texture_buffer_intel(struct pipe_texture *texture, + struct intel_buffer **buffer, + unsigned *stride); + +/** + * Wrap a intel_winsys buffer with a texture blanket. + * + * TODO UGLY + */ +struct pipe_texture * i915_texture_blanket_intel(struct pipe_screen *screen, + struct pipe_texture *tmplt, + unsigned pitch, + struct intel_buffer *buffer); + +#endif -- cgit v1.2.3 From d2110064c2075a8537d4b7f87ba894ebaa6ccb33 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Sun, 30 Aug 2009 20:49:01 +0100 Subject: i915g: Switch from pipe_winsys to intel_winsys Also includes moving lots of functions from i915_batch.h into intel_batchbuffer.h --- src/gallium/drivers/i915simple/i915_batch.h | 89 ++----------- src/gallium/drivers/i915simple/i915_blit.c | 13 +- src/gallium/drivers/i915simple/i915_blit.h | 6 +- src/gallium/drivers/i915simple/i915_context.c | 17 +-- src/gallium/drivers/i915simple/i915_context.h | 20 +-- src/gallium/drivers/i915simple/i915_debug.c | 3 +- src/gallium/drivers/i915simple/i915_debug.h | 4 +- src/gallium/drivers/i915simple/i915_prim_emit.c | 1 - src/gallium/drivers/i915simple/i915_prim_vbuf.c | 43 +++--- src/gallium/drivers/i915simple/i915_screen.c | 73 +++++++++-- src/gallium/drivers/i915simple/i915_screen.h | 5 + src/gallium/drivers/i915simple/i915_state_emit.c | 18 +-- .../drivers/i915simple/i915_state_sampler.c | 2 +- src/gallium/drivers/i915simple/i915_texture.c | 109 ++++++++++------ src/gallium/drivers/i915simple/i915_winsys.h | 144 --------------------- src/gallium/drivers/i915simple/intel_batchbuffer.h | 87 +++++++++++++ 16 files changed, 294 insertions(+), 340 deletions(-) delete mode 100644 src/gallium/drivers/i915simple/i915_winsys.h create mode 100644 src/gallium/drivers/i915simple/intel_batchbuffer.h (limited to 'src/gallium/drivers/i915simple') 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 -- cgit v1.2.3 From 87a4fa56ae473946b84233fda59d40dd479a4d64 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 3 Sep 2009 19:28:38 +0100 Subject: i915g: Don't send flush flags to HW --- src/gallium/drivers/i915simple/i915_flush.c | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/i915_flush.c b/src/gallium/drivers/i915simple/i915_flush.c index b223dadab6..1582168eba 100644 --- a/src/gallium/drivers/i915simple/i915_flush.c +++ b/src/gallium/drivers/i915simple/i915_flush.c @@ -45,6 +45,7 @@ static void i915_flush( struct pipe_context *pipe, draw_flush(i915->draw); +#if 0 /* Do we need to emit an MI_FLUSH command to flush the hardware * caches? */ @@ -63,6 +64,13 @@ static void i915_flush( struct pipe_context *pipe, } OUT_BATCH( flush ); } +#endif + +#if 0 + if (i915->batch->map == i915->batch->ptr) { + return; + } +#endif /* If there are no flags, just flush pending commands to hardware: */ -- cgit v1.2.3 From 65c79c9cbd58b164a61b72f7ffe13031c33485cf Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 4 Sep 2009 10:27:17 +0100 Subject: i915g: Fix warnings in scons build by using byte pointers scons build complained about void pointer math --- src/gallium/drivers/i915simple/intel_winsys.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/gallium/drivers/i915simple') diff --git a/src/gallium/drivers/i915simple/intel_winsys.h b/src/gallium/drivers/i915simple/intel_winsys.h index e123c32d88..f949f52a9c 100644 --- a/src/gallium/drivers/i915simple/intel_winsys.h +++ b/src/gallium/drivers/i915simple/intel_winsys.h @@ -69,8 +69,8 @@ struct intel_batchbuffer { * each dword written. */ /*{@*/ - void *map; - void *ptr; + uint8_t *map; + uint8_t *ptr; size_t size; size_t relocs; -- cgit v1.2.3