28
28
#include "i915_context.h"
29
29
#include "i915_state.h"
30
30
#include "i915_screen.h"
31
#include "i915_surface.h"
31
32
#include "i915_batch.h"
33
#include "i915_resource.h"
33
35
#include "draw/draw_context.h"
34
36
#include "pipe/p_defines.h"
46
i915_draw_range_elements(struct pipe_context *pipe,
47
struct pipe_buffer *indexBuffer,
51
unsigned prim, unsigned start, unsigned count)
48
i915_draw_vbo(struct pipe_context *pipe, const struct pipe_draw_info *info)
53
50
struct i915_context *i915 = i915_context(pipe);
54
51
struct draw_context *draw = i915->draw;
52
void *mapped_indices = NULL;
61
59
* Map vertex buffers
63
61
for (i = 0; i < i915->num_vertex_buffers; i++) {
64
void *buf = pipe_buffer_map(pipe->screen, i915->vertex_buffer[i].buffer,
65
PIPE_BUFFER_USAGE_CPU_READ);
62
void *buf = i915_buffer(i915->vertex_buffer[i].buffer)->data;
66
63
draw_set_mapped_vertex_buffer(draw, i, buf);
70
67
* Map index buffer, if present
73
void *mapped_indexes = pipe_buffer_map(pipe->screen, indexBuffer,
74
PIPE_BUFFER_USAGE_CPU_READ);
75
draw_set_mapped_element_buffer_range(draw, indexSize,
80
draw_set_mapped_element_buffer(draw, 0, NULL);
69
if (info->indexed && i915->index_buffer.buffer)
70
mapped_indices = i915_buffer(i915->index_buffer.buffer)->data;
71
draw_set_mapped_index_buffer(draw, mapped_indices);
84
73
draw_set_mapped_constant_buffer(draw, PIPE_SHADER_VERTEX, 0,
85
74
i915->current.constants[PIPE_SHADER_VERTEX],
92
draw_arrays(i915->draw, prim, start, count);
81
draw_vbo(i915->draw, info);
95
84
* unmap vertex/index buffers
97
86
for (i = 0; i < i915->num_vertex_buffers; i++) {
98
pipe_buffer_unmap(pipe->screen, i915->vertex_buffer[i].buffer);
99
87
draw_set_mapped_vertex_buffer(draw, i, NULL);
103
pipe_buffer_unmap(pipe->screen, indexBuffer);
104
draw_set_mapped_element_buffer_range(draw, 0, start, start + count - 1, NULL);
109
i915_draw_elements(struct pipe_context *pipe,
110
struct pipe_buffer *indexBuffer,
112
unsigned prim, unsigned start, unsigned count)
114
i915_draw_range_elements(pipe, indexBuffer,
121
i915_draw_arrays(struct pipe_context *pipe,
122
unsigned prim, unsigned start, unsigned count)
124
i915_draw_elements(pipe, NULL, 0, prim, start, count);
129
* Is referenced functions
134
i915_is_texture_referenced(struct pipe_context *pipe,
135
struct pipe_texture *texture,
136
unsigned face, unsigned level)
139
* FIXME: Return the corrent result. We can't alays return referenced
140
* since it causes a double flush within the vbo module.
143
return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
150
i915_is_buffer_referenced(struct pipe_context *pipe,
151
struct pipe_buffer *buf)
154
* Since we never expose hardware buffers to the state tracker
155
* they can never be referenced, so this isn't a lie
91
draw_set_mapped_index_buffer(draw, NULL);
201
135
i915->base.clear = i915_clear;
203
i915->base.draw_arrays = i915_draw_arrays;
204
i915->base.draw_elements = i915_draw_elements;
205
i915->base.draw_range_elements = i915_draw_range_elements;
207
i915->base.is_texture_referenced = i915_is_texture_referenced;
208
i915->base.is_buffer_referenced = i915_is_buffer_referenced;
137
i915->base.draw_vbo = i915_draw_vbo;
211
140
* Create drawing context and plug our rendering stage into it.
221
150
i915_init_surface_functions(i915);
222
151
i915_init_state_functions(i915);
223
152
i915_init_flush_functions(i915);
153
i915_init_resource_functions(i915);
225
155
draw_install_aaline_stage(i915->draw, &i915->base);
226
156
draw_install_aapoint_stage(i915->draw, &i915->base);