i915g: Cleanup i915_context.c

This commit is contained in:
Jakob Bornecrantz
2009-08-30 21:03:43 +01:00
parent 7864b0e717
commit 1b5f46a3b8

View File

@@ -40,17 +40,9 @@
#include "pipe/p_screen.h" #include "pipe/p_screen.h"
static void i915_destroy( struct pipe_context *pipe ) /*
{ * Draw functions
struct i915_context *i915 = i915_context( pipe ); */
draw_destroy( i915->draw );
if(i915->winsys->destroy)
i915->winsys->destroy(i915->winsys);
FREE( i915 );
}
static boolean static boolean
@@ -72,24 +64,22 @@ i915_draw_range_elements(struct pipe_context *pipe,
* Map vertex buffers * Map vertex buffers
*/ */
for (i = 0; i < i915->num_vertex_buffers; i++) { for (i = 0; i < i915->num_vertex_buffers; i++) {
void *buf void *buf = pipe_buffer_map(pipe->screen, i915->vertex_buffer[i].buffer,
= pipe_buffer_map(pipe->screen,
i915->vertex_buffer[i].buffer,
PIPE_BUFFER_USAGE_CPU_READ); PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_vertex_buffer(draw, i, buf); draw_set_mapped_vertex_buffer(draw, i, buf);
} }
/* Map index buffer, if present */
/*
* Map index buffer, if present
*/
if (indexBuffer) { if (indexBuffer) {
void *mapped_indexes void *mapped_indexes = pipe_buffer_map(pipe->screen, indexBuffer,
= pipe_buffer_map(pipe->screen, indexBuffer,
PIPE_BUFFER_USAGE_CPU_READ); PIPE_BUFFER_USAGE_CPU_READ);
draw_set_mapped_element_buffer_range(draw, indexSize, draw_set_mapped_element_buffer_range(draw, indexSize,
min_index, min_index,
max_index, max_index,
mapped_indexes); mapped_indexes);
} } else {
else {
/* no index/element buffer */
draw_set_mapped_element_buffer(draw, 0, NULL); draw_set_mapped_element_buffer(draw, 0, NULL);
} }
@@ -99,7 +89,9 @@ i915_draw_range_elements(struct pipe_context *pipe,
(i915->current.num_user_constants[PIPE_SHADER_VERTEX] * (i915->current.num_user_constants[PIPE_SHADER_VERTEX] *
4 * sizeof(float))); 4 * sizeof(float)));
/* draw! */ /*
* Do the drawing
*/
draw_arrays(i915->draw, prim, start, count); 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); pipe_buffer_unmap(pipe->screen, i915->vertex_buffer[i].buffer);
draw_set_mapped_vertex_buffer(draw, i, NULL); draw_set_mapped_vertex_buffer(draw, i, NULL);
} }
if (indexBuffer) { if (indexBuffer) {
pipe_buffer_unmap(pipe->screen, indexBuffer); pipe_buffer_unmap(pipe->screen, indexBuffer);
draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL); draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL);
@@ -129,13 +122,19 @@ i915_draw_elements( struct pipe_context *pipe,
prim, start, count); prim, start, count);
} }
static boolean i915_draw_arrays( struct pipe_context *pipe, static boolean
i915_draw_arrays(struct pipe_context *pipe,
unsigned prim, unsigned start, unsigned count) unsigned prim, unsigned start, unsigned count)
{ {
return i915_draw_elements(pipe, NULL, 0, prim, start, count); return i915_draw_elements(pipe, NULL, 0, prim, start, count);
} }
/*
* Is referenced functions
*/
static unsigned int static unsigned int
i915_is_texture_referenced(struct pipe_context *pipe, i915_is_texture_referenced(struct pipe_context *pipe,
struct pipe_texture *texture, struct pipe_texture *texture,
@@ -168,7 +167,25 @@ i915_is_buffer_referenced( struct pipe_context *pipe,
} }
struct pipe_context *i915_create_context( struct pipe_screen *screen, /*
* 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 pipe_winsys *pipe_winsys,
struct i915_winsys *i915_winsys) struct i915_winsys *i915_winsys)
{ {
@@ -186,7 +203,6 @@ struct pipe_context *i915_create_context( struct pipe_screen *screen,
i915->base.clear = i915_clear; i915->base.clear = i915_clear;
i915->base.draw_arrays = i915_draw_arrays; i915->base.draw_arrays = i915_draw_arrays;
i915->base.draw_elements = i915_draw_elements; i915->base.draw_elements = i915_draw_elements;
i915->base.draw_range_elements = i915_draw_range_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); assert(i915->draw);
if (!debug_get_bool_option("I915_NO_VBUF", FALSE)) { if (!debug_get_bool_option("I915_NO_VBUF", FALSE)) {
draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915)); draw_set_rasterize_stage(i915->draw, i915_draw_vbuf_stage(i915));
} } else {
else {
draw_set_rasterize_stage(i915->draw, i915_draw_render_stage(i915)); 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; return &i915->base;
} }