Tom Stellard <t...@stellard.net> writes:

> From: Tom Stellard <thomas.stell...@amd.com>
>
Hi Tom.  This should probably leave out any devices that don't match the
type argument.  To avoid duplicating the type-matching logic I think the
best would be to keep it implemented in terms of clGetDeviceIDs, just
call it twice to get the number of vector elements you need to allocate.

> ---
>  src/gallium/state_trackers/clover/api/context.cpp | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
>
> diff --git a/src/gallium/state_trackers/clover/api/context.cpp 
> b/src/gallium/state_trackers/clover/api/context.cpp
> index 3717441..e0fed31 100644
> --- a/src/gallium/state_trackers/clover/api/context.cpp
> +++ b/src/gallium/state_trackers/clover/api/context.cpp
> @@ -22,6 +22,7 @@
>  
>  #include "api/util.hpp"
>  #include "core/context.hpp"
> +#include "core/platform.hpp"
>  
>  using namespace clover;
>  
> @@ -63,18 +64,22 @@ clCreateContextFromType(const cl_context_properties 
> *props,
>                          void *user_data, cl_int *errcode_ret) try {
>     cl_platform_id platform;
>     cl_uint num_platforms;
> -   cl_device_id dev;
>     cl_int ret;
> +   std::vector<cl_device_id> devs;
>  
>     ret = clGetPlatformIDs(1, &platform, &num_platforms);
>     if (ret || !num_platforms)
>        throw error(CL_INVALID_PLATFORM);
>  
> -   ret = clGetDeviceIDs(platform, type, 1, &dev, 0);
> -   if (ret)
> +   if (platform->begin() == platform->end())
>        throw error(CL_DEVICE_NOT_FOUND);
>  
> -   return clCreateContext(props, 1, &dev, pfn_notify, user_data, 
> errcode_ret);
> +   for (clover::platform::iterator i = platform->begin(), e = 
> platform->end();
> +                                                         i != e; ++i) {
> +      devs.push_back(&*i);
> +   }
> +
> +   return clCreateContext(props, devs.size(), devs.data(), pfn_notify, 
> user_data, errcode_ret);
>  
>  } catch(error &e) {
>     ret_error(errcode_ret, e);

Attachment: pgpM3fGIsBEIm.pgp
Description: PGP signature

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to