gallium: add PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY

With the current UAPI we only support user pointers from the compute
engines, so we need a way to express that in gallium.

v2: fix typos
v3: add allows_user_pointers helper

Signed-off-by: Karol Herbst <kherbst@redhat.com>
Reviewed-by: Pierre Moreau <dev@pmoreau.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/5906>
This commit is contained in:
Karol Herbst 2020-05-05 15:09:50 +02:00 committed by Marge Bot
parent 08ceba943d
commit c0f7f833eb
6 changed files with 14 additions and 5 deletions

View File

@ -275,6 +275,9 @@ The integer capabilities:
existing user memory into the device address space for direct device access.
The create function is pipe_screen::resource_from_user_memory. The address
and size must be page-aligned.
* ``PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY``: Same as
``PIPE_CAP_RESOURCE_FROM_USER_MEMORY`` but indicates it is only supported from
the compute engines.
* ``PIPE_CAP_DEVICE_RESET_STATUS_QUERY``:
Whether pipe_context::get_device_reset_status is implemented.
* ``PIPE_CAP_MAX_SHADER_PATCH_VARYINGS``:

View File

@ -214,6 +214,7 @@ u_pipe_screen_get_param_defaults(struct pipe_screen *pscreen,
case PIPE_CAP_POLYGON_OFFSET_CLAMP:
case PIPE_CAP_MULTISAMPLE_Z_RESOLVE:
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY:
case PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY:
case PIPE_CAP_DEVICE_RESET_STATUS_QUERY:
case PIPE_CAP_MAX_SHADER_PATCH_VARYINGS:
case PIPE_CAP_TEXTURE_FLOAT_LINEAR:

View File

@ -238,8 +238,7 @@ device::svm_support() const {
//
// Another unsolvable scenario is a cl_mem object passed by cl_mem reference
// and SVM pointer into the same kernel at the same time.
if (pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY) &&
pipe->get_param(pipe, PIPE_CAP_SYSTEM_SVM))
if (allows_user_pointers() && pipe->get_param(pipe, PIPE_CAP_SYSTEM_SVM))
// we can emulate all lower levels if we support fine grain system
return CL_DEVICE_SVM_FINE_GRAIN_SYSTEM |
CL_DEVICE_SVM_COARSE_GRAIN_BUFFER |
@ -247,6 +246,12 @@ device::svm_support() const {
return 0;
}
bool
device::allows_user_pointers() const {
return pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY) ||
pipe->get_param(pipe, PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY);
}
std::vector<size_t>
device::max_block_size() const {
auto v = get_compute_param<uint64_t>(pipe, ir_format(),

View File

@ -72,6 +72,7 @@ namespace clover {
bool has_unified_memory() const;
size_t mem_base_addr_align() const;
cl_device_svm_capabilities svm_support() const;
bool allows_user_pointers() const;
std::vector<size_t> max_block_size() const;
cl_uint subgroup_size() const;

View File

@ -127,8 +127,6 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj,
command_queue &q, const std::string &data) :
resource(dev, obj) {
pipe_resource info {};
const bool user_ptr_support = dev.pipe->get_param(dev.pipe,
PIPE_CAP_RESOURCE_FROM_USER_MEMORY);
if (image *img = dynamic_cast<image *>(&obj)) {
info.format = translate_format(img->format());
@ -147,7 +145,7 @@ root_resource::root_resource(clover::device &dev, memory_obj &obj,
PIPE_BIND_COMPUTE_RESOURCE |
PIPE_BIND_GLOBAL);
if (obj.flags() & CL_MEM_USE_HOST_PTR && user_ptr_support) {
if (obj.flags() & CL_MEM_USE_HOST_PTR && dev.allows_user_pointers()) {
// Page alignment is normally required for this, just try, hope for the
// best and fall back if it fails.
pipe = dev.pipe->resource_from_user_memory(dev.pipe, &info, obj.host_ptr());

View File

@ -811,6 +811,7 @@ enum pipe_cap
PIPE_CAP_POLYGON_OFFSET_CLAMP,
PIPE_CAP_MULTISAMPLE_Z_RESOLVE,
PIPE_CAP_RESOURCE_FROM_USER_MEMORY,
PIPE_CAP_RESOURCE_FROM_USER_MEMORY_COMPUTE_ONLY,
PIPE_CAP_DEVICE_RESET_STATUS_QUERY,
PIPE_CAP_MAX_SHADER_PATCH_VARYINGS,
PIPE_CAP_TEXTURE_FLOAT_LINEAR,