File: gl.rst

package info (click to toggle)
pycuda 2016.1.2%2Bgit20161024-1
  • links: PTS, VCS
  • area: contrib
  • in suites: stretch
  • size: 1,560 kB
  • ctags: 2,268
  • sloc: python: 11,951; cpp: 9,839; makefile: 139; sh: 1
file content (144 lines) | stat: -rw-r--r-- 3,603 bytes parent folder | download | duplicates (5)
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
.. _gl-interop:

OpenGL
======

.. module:: pycuda.gl

.. function :: make_context(dev, flags=0)

    Create and return a :class:`pycuda.driver.Context` that has GL interoperability
    enabled.

    .. warning ::

        This will fail with a rather unhelpful error message if you don't already 
        have a GL context created and active.

.. class :: graphics_map_flags

    Usage of OpenGL object from CUDA.

    .. attribute :: NONE

        Read and write access to mapped OpenGL object from CUDA code.

    .. attribute :: READ_ONLY

        Read only access to mapped OpenGL object from CUDA code.

    .. attribute :: WRITE_DISCARD

        Write only access to mapped OpenGL object from CUDA code. Reading
        is prohibited.

.. class :: RegisteredBuffer(bufobj, flags = CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)

    Object managing mapping of OpenGL buffers to CUDA. Cannot be used to
    map images.

    .. method :: gl_handle()
    .. method :: unregister()
    .. method :: map(stream=None)

        Return a :class:`RegisteredMapping`.

.. class :: RegisteredImage(bufobj, target, flags = CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE)

    Object managing mapping of OpenGL textures and render buffers to CUDA.

    *target* must be be one of:

     * `GL_TEXTURE_2D`
     * `GL_TEXTURE_RECTANGLE`
     * `GL_TEXTURE_CUBE_MAP`
     * `GL_TEXTURE_3D`
     * `GL_TEXTURE_2D_ARRAY`
     * `GL_RENDERBUFFER`

    (see PyOpenGL docs)

    .. method :: gl_handle()
    .. method :: unregister()
    .. method :: map(stream=None)

        Return a :class:`RegisteredMapping`.

.. class :: RegisteredMapping

    .. method :: unmap(stream=None)

        If no stream is specified, the unmap will use the same stream as the original
        mapping.

    .. method :: device_ptr_and_size()

        Return a tuple *(dev_pointer, size)*.

        .. versionadded: 2011.1

    .. method :: array(index, level)

        Return an array for mapped image object for given array index and MIP level.

Automatic Initialization
------------------------

.. module:: pycuda.gl.autoinit

.. warning ::

    Importing :mod:`pycuda.gl.autoinit` will fail with a rather unhelpful error 
    message if you don't already have a GL context created and active.

.. data:: device
.. data:: context

Old-style (pre-CUDA 3.0) API
----------------------------

.. function :: init()

    Enable GL interoperability for the already-created (so far non-GL)
    and currently active :class:`pycuda.driver.Context`.

    According to the forum post referenced in the note below, this will succeed 
    on Windows XP and Linux, but it will not work on Windows Vista. There you 
    *have* to create the GL-enabled context using :func:`make_context`.

    .. warning ::

        This function is deprecated since CUDA 3.0 and PyCUDA 2011.1.

    .. warning ::

        This will fail with a rather unhelpful error message if you don't already 
        have a GL context created and active.

.. note ::

    See this `post <http://forums.nvidia.com/index.php?showtopic=88152>`_ on the
    Nvidia forums for a discussion of problems and solutions with the GL interop
    interface.

.. class :: BufferObject(bufobj)

    .. warning ::

        This class is deprecated since CUDA 3.0 and PyCUDA 2011.1.

    .. method :: unregister()
    .. attribute :: handle()
    .. method :: map()

.. class :: BufferObjectMapping

    .. warning ::

        This class is deprecated since CUDA 3.0 and PyCUDA 2011.1.
        It will be removed in PyCUDA 0.96.

    .. method :: unmap()
    .. method :: device_ptr()
    .. method :: size()