~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/state_tracker/st_cb_bufferobjects.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
58
58
   if (!st_obj)
59
59
      return NULL;
60
60
 
61
 
   _mesa_initialize_buffer_object(&st_obj->Base, name, target);
 
61
   _mesa_initialize_buffer_object(ctx, &st_obj->Base, name, target);
62
62
 
63
63
   return &st_obj->Base;
64
64
}
93
93
 */
94
94
static void
95
95
st_bufferobj_subdata(struct gl_context *ctx,
96
 
                     GLenum target,
97
96
                     GLintptrARB offset,
98
97
                     GLsizeiptrARB size,
99
98
                     const GLvoid * data, struct gl_buffer_object *obj)
116
115
   if (!data)
117
116
      return;
118
117
 
 
118
   if (!st_obj->buffer) {
 
119
      /* we probably ran out of memory during buffer allocation */
 
120
      return;
 
121
   }
 
122
 
119
123
   /* Now that transfers are per-context, we don't have to figure out
120
124
    * flushing here.  Usually drivers won't need to flush in this case
121
125
    * even if the buffer is currently referenced by hardware - they
133
137
 */
134
138
static void
135
139
st_bufferobj_get_subdata(struct gl_context *ctx,
136
 
                         GLenum target,
137
140
                         GLintptrARB offset,
138
141
                         GLsizeiptrARB size,
139
142
                         GLvoid * data, struct gl_buffer_object *obj)
148
151
   if (!size)
149
152
      return;
150
153
 
 
154
   if (!st_obj->buffer) {
 
155
      /* we probably ran out of memory during buffer allocation */
 
156
      return;
 
157
   }
 
158
 
151
159
   pipe_buffer_read(st_context(ctx)->pipe, st_obj->buffer,
152
160
                    offset, size, data);
153
161
}
218
226
                                          pipe_usage, size);
219
227
 
220
228
      if (!st_obj->buffer) {
 
229
         /* out of memory */
 
230
         st_obj->Base.Size = 0;
221
231
         return GL_FALSE;
222
232
      }
223
233
 
231
241
 
232
242
 
233
243
/**
234
 
 * Dummy data whose's pointer is used for zero size buffers or ranges.
235
 
 */
236
 
static long st_bufferobj_zero_length = 0;
237
 
 
238
 
 
239
 
 
240
 
/**
241
 
 * Called via glMapBufferARB().
242
 
 */
243
 
static void *
244
 
st_bufferobj_map(struct gl_context *ctx, GLenum target, GLenum access,
245
 
                 struct gl_buffer_object *obj)
246
 
{
247
 
   struct st_buffer_object *st_obj = st_buffer_object(obj);
248
 
   uint flags;
249
 
 
250
 
   switch (access) {
251
 
   case GL_WRITE_ONLY:
252
 
      flags = PIPE_TRANSFER_WRITE;
253
 
      break;
254
 
   case GL_READ_ONLY:
255
 
      flags = PIPE_TRANSFER_READ;
256
 
      break;
257
 
   case GL_READ_WRITE:
258
 
   default:
259
 
      flags = PIPE_TRANSFER_READ_WRITE;
260
 
      break;      
261
 
   }
262
 
 
263
 
   /* Handle zero-size buffers here rather than in drivers */
264
 
   if (obj->Size == 0) {
265
 
      obj->Pointer = &st_bufferobj_zero_length;
266
 
   }
267
 
   else {
268
 
      obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe,
269
 
                                     st_obj->buffer,
270
 
                                     flags,
271
 
                                     &st_obj->transfer);
272
 
   }
273
 
 
274
 
   if (obj->Pointer) {
275
 
      obj->Offset = 0;
276
 
      obj->Length = obj->Size;
277
 
   }
278
 
   return obj->Pointer;
279
 
}
280
 
 
281
 
 
282
 
/**
283
244
 * Called via glMapBufferRange().
284
245
 */
285
246
static void *
286
 
st_bufferobj_map_range(struct gl_context *ctx, GLenum target, 
 
247
st_bufferobj_map_range(struct gl_context *ctx,
287
248
                       GLintptr offset, GLsizeiptr length, GLbitfield access,
288
249
                       struct gl_buffer_object *obj)
289
250
{
324
285
   assert(offset < obj->Size);
325
286
   assert(offset + length <= obj->Size);
326
287
 
327
 
   /*
328
 
    * We go out of way here to hide the degenerate yet valid case of zero
329
 
    * length range from the pipe driver.
330
 
    */
331
 
   if (!length) {
332
 
      obj->Pointer = &st_bufferobj_zero_length;
333
 
   }
334
 
   else {
335
 
      obj->Pointer = pipe_buffer_map_range(pipe, 
336
 
                                           st_obj->buffer,
337
 
                                           offset, length,
338
 
                                           flags,
339
 
                                           &st_obj->transfer);
340
 
      if (obj->Pointer) {
341
 
         obj->Pointer = (ubyte *) obj->Pointer + offset;
342
 
      }
343
 
   }
344
 
   
 
288
   obj->Pointer = pipe_buffer_map_range(pipe,
 
289
                                        st_obj->buffer,
 
290
                                        offset, length,
 
291
                                        flags,
 
292
                                        &st_obj->transfer);
345
293
   if (obj->Pointer) {
346
294
      obj->Offset = offset;
347
295
      obj->Length = length;
353
301
 
354
302
 
355
303
static void
356
 
st_bufferobj_flush_mapped_range(struct gl_context *ctx, GLenum target, 
 
304
st_bufferobj_flush_mapped_range(struct gl_context *ctx,
357
305
                                GLintptr offset, GLsizeiptr length,
358
306
                                struct gl_buffer_object *obj)
359
307
{
378
326
 * Called via glUnmapBufferARB().
379
327
 */
380
328
static GLboolean
381
 
st_bufferobj_unmap(struct gl_context *ctx, GLenum target, struct gl_buffer_object *obj)
 
329
st_bufferobj_unmap(struct gl_context *ctx, struct gl_buffer_object *obj)
382
330
{
383
331
   struct pipe_context *pipe = st_context(ctx)->pipe;
384
332
   struct st_buffer_object *st_obj = st_buffer_object(obj);
444
392
   functions->BufferData = st_bufferobj_data;
445
393
   functions->BufferSubData = st_bufferobj_subdata;
446
394
   functions->GetBufferSubData = st_bufferobj_get_subdata;
447
 
   functions->MapBuffer = st_bufferobj_map;
448
395
   functions->MapBufferRange = st_bufferobj_map_range;
449
396
   functions->FlushMappedBufferRange = st_bufferobj_flush_mapped_range;
450
397
   functions->UnmapBuffer = st_bufferobj_unmap;