gallium: add sparse buffer interface and capability

v2:
- explain the resource_commit interface in more detail

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Nicolai Hähnle 2017-02-02 21:10:44 +01:00
parent 4e6feacf6a
commit d6e6fa01a5
19 changed files with 58 additions and 0 deletions

View File

@ -618,6 +618,31 @@ are set.
.. _resource_commit:
resource_commit
%%%%%%%%%%%%%%%
This function changes the commit state of a part of a sparse resource. Sparse
resources are created by setting the ``PIPE_RESOURCE_FLAG_SPARSE`` flag when
calling ``resource_create``. Initially, sparse resources only reserve a virtual
memory region that is not backed by memory (i.e., it is uncommitted). The
``resource_commit`` function can be called to commit or uncommit parts (or all)
of a resource. The driver manages the underlying backing memory.
The contents of newly committed memory regions are undefined. Calling this
function to commit an already committed memory region is allowed and leaves its
content unchanged. Similarly, calling this function to uncommit an already
uncommitted memory region is allowed.
For buffers, the given box must be aligned to multiples of
``PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE``. As an exception to this rule, if the size
of the buffer is not a multiple of the page size, changing the commit state of
the last (partial) page requires a box that ends at the end of the buffer
(i.e., box->x + box->width == buffer->width0).
.. _pipe_transfer:
PIPE_TRANSFER

View File

@ -381,6 +381,9 @@ The integer capabilities:
PIPE_POLYGON_MODE_FILL_RECTANGLE mode is supported for
``pipe_rasterizer_state::fill_front`` and
``pipe_rasterizer_state::fill_back``.
* ``PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE``: The page size of sparse buffers in
bytes, or 0 if sparse buffers are not supported. The page size must be at
most 64KB.
.. _pipe_capf:

View File

@ -247,6 +247,7 @@ etna_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
/* Stream output. */

View File

@ -304,6 +304,7 @@ fd_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_MAX_VIEWPORTS:

View File

@ -303,6 +303,7 @@ i915_get_param(struct pipe_screen *screen, enum pipe_cap cap)
case PIPE_CAP_INT64_DIVMOD:
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_MAX_VIEWPORTS:

View File

@ -349,6 +349,7 @@ llvmpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_MUL_ZERO_WINS:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
}
/* should only get here on unhandled cases */

View File

@ -213,6 +213,7 @@ nv30_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_VENDOR_ID:

View File

@ -265,6 +265,7 @@ nv50_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_INT64_DIVMOD:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_VENDOR_ID:

View File

@ -288,6 +288,7 @@ nvc0_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_GLSL_OPTIMIZE_CONSERVATIVELY:
case PIPE_CAP_INT64_DIVMOD:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_VENDOR_ID:

View File

@ -235,6 +235,7 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
/* SWTCL-only features. */

View File

@ -383,6 +383,7 @@ static int r600_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_DOUBLES:

View File

@ -493,6 +493,7 @@ static int si_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_MUL_ZERO_WINS:
case PIPE_CAP_UMA:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_QUERY_BUFFER_OBJECT:

View File

@ -299,6 +299,7 @@ softpipe_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_MUL_ZERO_WINS:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_SHADER_BUFFER_OFFSET_ALIGNMENT:
return 4;

View File

@ -429,6 +429,7 @@ svga_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
}

View File

@ -321,6 +321,7 @@ swr_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_VENDOR_ID:

View File

@ -249,6 +249,7 @@ vc4_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
/* Stream output. */

View File

@ -258,6 +258,7 @@ virgl_get_param(struct pipe_screen *screen, enum pipe_cap param)
case PIPE_CAP_TGSI_TEX_TXF_LZ:
case PIPE_CAP_TGSI_CLOCK:
case PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE:
case PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE:
return 0;
case PIPE_CAP_VENDOR_ID:
return 0x1af4;

View File

@ -584,6 +584,19 @@ struct pipe_context {
*/
void (*memory_barrier)(struct pipe_context *, unsigned flags);
/**
* Change the commitment status of a part of the given resource, which must
* have been created with the PIPE_RESOURCE_FLAG_SPARSE bit.
*
* \param level The texture level whose commitment should be changed.
* \param box The region of the resource whose commitment should be changed.
* \param commit Whether memory should be committed or un-committed.
*
* \return false if out of memory, true on success.
*/
bool (*resource_commit)(struct pipe_context *, struct pipe_resource *,
unsigned level, struct pipe_box *box, bool commit);
/**
* Creates a video codec for a specific video format/profile
*/

View File

@ -459,6 +459,7 @@ enum pipe_flush_flags
#define PIPE_RESOURCE_FLAG_MAP_PERSISTENT (1 << 0)
#define PIPE_RESOURCE_FLAG_MAP_COHERENT (1 << 1)
#define PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY (1 << 2)
#define PIPE_RESOURCE_FLAG_SPARSE (1 << 3)
#define PIPE_RESOURCE_FLAG_DRV_PRIV (1 << 16) /* driver/winsys private */
#define PIPE_RESOURCE_FLAG_ST_PRIV (1 << 24) /* state-tracker/winsys private */
@ -758,6 +759,7 @@ enum pipe_cap
PIPE_CAP_TGSI_TEX_TXF_LZ,
PIPE_CAP_TGSI_CLOCK,
PIPE_CAP_POLYGON_MODE_FILL_RECTANGLE,
PIPE_CAP_SPARSE_BUFFER_PAGE_SIZE,
};
#define PIPE_QUIRK_TEXTURE_BORDER_COLOR_SWIZZLE_NV50 (1 << 0)