gallium: Basic compute interface.

Define an interface that exposes the minimal functionality required to
implement some of the popular compute APIs.  This commit adds entry
points to set the grid layout and other state required to keep track
of the usual address spaces employed in compute APIs, to bind a
compute program, and execute it on the device.

Reviewed-by: Marek Olšák <maraeo@gmail.com>
This commit is contained in:
Francisco Jerez
2012-04-25 22:15:16 +02:00
parent c2f1fbf912
commit d9d82dcd00
7 changed files with 185 additions and 2 deletions

View File

@@ -542,3 +542,42 @@ These flags control the behavior of a transfer object.
``PIPE_TRANSFER_FLUSH_EXPLICIT``
Written ranges will be notified later with :ref:`transfer_flush_region`.
Cannot be used with ``PIPE_TRANSFER_READ``.
Compute kernel execution
^^^^^^^^^^^^^^^^^^^^^^^^
A compute program can be defined, bound or destroyed using
``create_compute_state``, ``bind_compute_state`` or
``destroy_compute_state`` respectively.
Any of the subroutines contained within the compute program can be
executed on the device using the ``launch_grid`` method. This method
will execute as many instances of the program as elements in the
specified N-dimensional grid, hopefully in parallel.
The compute program has access to four special resources:
* ``GLOBAL`` represents a memory space shared among all the threads
running on the device. An arbitrary buffer created with the
``PIPE_BIND_GLOBAL`` flag can be mapped into it using the
``set_global_binding`` method.
* ``LOCAL`` represents a memory space shared among all the threads
running in the same working group. The initial contents of this
resource are undefined.
* ``PRIVATE`` represents a memory space local to a single thread.
The initial contents of this resource are undefined.
* ``INPUT`` represents a read-only memory space that can be
initialized at ``launch_grid`` time.
These resources use a byte-based addressing scheme, and they can be
accessed from the compute program by means of the LOAD/STORE TGSI
opcodes.
In addition, normal texture sampling is allowed from the compute
program: ``bind_compute_sampler_states`` may be used to set up texture
samplers for the compute stage and ``set_compute_sampler_views`` may
be used to bind a number of sampler views to it.

View File

@@ -110,7 +110,8 @@ The integer capabilities:
* ``PIPE_CAP_VERTEX_ELEMENT_SRC_OFFSET_4BYTE_ALIGNED_ONLY``: This CAP describes
a hw limitation. If true, pipe_vertex_element::src_offset must always be
aligned to 4. If false, there are no restrictions on src_offset.
* ``PIPE_CAP_COMPUTE``: Whether the implementation supports the
compute entry points defined in pipe_context and pipe_screen.
.. _pipe_capf:
@@ -186,6 +187,29 @@ to be 0.
samplers.
.. _pipe_compute_cap:
PIPE_COMPUTE_CAP_*
^^^^^^^^^^^^^^^^^^
Compute-specific capabilities. They can be queried using
pipe_screen::get_compute_param.
* ``PIPE_COMPUTE_CAP_GRID_DIMENSION``: Number of supported dimensions
for grid and block coordinates. Value type: ``uint64_t``.
* ``PIPE_COMPUTE_CAP_MAX_GRID_SIZE``: Maximum grid size in block
units. Value type: ``uint64_t []``.
* ``PIPE_COMPUTE_CAP_MAX_BLOCK_SIZE``: Maximum block size in thread
units. Value type: ``uint64_t []``.
* ``PIPE_COMPUTE_CAP_MAX_GLOBAL_SIZE``: Maximum size of the GLOBAL
resource. Value type: ``uint64_t``.
* ``PIPE_COMPUTE_CAP_MAX_LOCAL_SIZE``: Maximum size of the LOCAL
resource. Value type: ``uint64_t``.
* ``PIPE_COMPUTE_CAP_MAX_PRIVATE_SIZE``: Maximum size of the PRIVATE
resource. Value type: ``uint64_t``.
* ``PIPE_COMPUTE_CAP_MAX_INPUT_SIZE``: Maximum size of the INPUT
resource. Value type: ``uint64_t``.
.. _pipe_bind:
PIPE_BIND_*
@@ -223,6 +247,8 @@ resources might be created and handled quite differently.
* ``PIPE_BIND_SCANOUT``: A front color buffer or scanout buffer.
* ``PIPE_BIND_SHARED``: A sharable buffer that can be given to another
process.
* ``PIPE_BIND_GLOBAL``: A buffer that can be mapped into the global
address space of a compute program.
.. _pipe_usage: