forked from jsgf/pspgl
-
Notifications
You must be signed in to change notification settings - Fork 0
/
glMapBufferARB.c
43 lines (31 loc) · 1002 Bytes
/
glMapBufferARB.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "pspgl_internal.h"
#include "pspgl_buffers.h"
GLvoid *glMapBufferARB(GLenum target, GLenum access)
{
struct pspgl_bufferobj *buf, **bufp;
void *p;
bufp = __pspgl_bufferobj_for_target(target);
if (bufp == NULL)
return NULL;
buf = *bufp;
if (unlikely(buf == NULL) || unlikely(buf->data == NULL) || unlikely(buf->mapped))
goto out_error;
/* If we're writing the buffer or the hardware is writing to
the buffer, wait for the hardware to finish with it. (The
CPU and graphics hardware are allowed to read
concurrently.) */
if (access != GL_READ_ONLY_ARB ||
(buf->data->flags & BF_PINNED_WR))
__pspgl_buffer_dlist_sync(buf->data);
buf->access = access;
buf->mapped = GL_TRUE;
p = __pspgl_buffer_map(buf->data, access);
psp_log("mapped buf %p data %p -> %p\n",
buf, buf->data->base, p);
return p;
out_error:
GLERROR(GL_INVALID_OPERATION);
return NULL;
}
GLvoid *glMapBuffer(GLenum target, GLenum access)
__attribute__((alias("glMapBufferARB")));