3333
3434// Make sure Common.hpp is the first include file (to make the error message as helpful as possible when disabled)
3535#include < FslBase/Attributes.hpp>
36+ #include < FslBase/Span/ReadOnlySpan.hpp>
3637#include < FslUtil/OpenCL1_2/Common.hpp>
3738#include < RapidOpenCL1/Context.hpp>
3839#include < CL/cl.h>
@@ -71,6 +72,16 @@ namespace Fsl::OpenCL
7172 // NOLINTNEXTLINE(misc-misplaced-const)
7273 explicit ContextEx (const cl_device_type deviceType, cl_device_id* pDeviceId = nullptr , const bool allowFallback = true );
7374
75+ // ! @brief Create the requested resource
76+ // ! @param contextPropertiesSpan the context properties to use (supply a empty one to use the default).
77+ // ! If this span is not empty and contains a CL_CONTEXT_PLATFORM entry that is 0, then the entry will be patched with the right platformId.
78+ // ! If this span is not empty and does not contain a CL_CONTEXT_PLATFORM then a CL_CONTEXT_PLATFORM entry will be added.
79+ // ! @param pDeviceId the chosen device id (if nullptr this is ignored, else it will be assigned the chosen deviceId)
80+ // ! @param allowFallback if the specified device type can't be found allow using a fallback of CL_DEVICE_TYPE_ALL
81+ // NOLINTNEXTLINE(misc-misplaced-const)
82+ explicit ContextEx (const ReadOnlySpan<cl_context_properties> contextPropertiesSpan, const cl_device_type deviceType,
83+ cl_device_id* pDeviceId = nullptr , const bool allowFallback = true );
84+
7485 // ! @brief returns the managed handle and releases the ownership.
7586 [[nodiscard]] cl_context Release ()
7687 {
@@ -99,6 +110,16 @@ namespace Fsl::OpenCL
99110 // NOLINTNEXTLINE(misc-misplaced-const)
100111 void Reset (const cl_device_type deviceType, cl_device_id* pDeviceId = nullptr , const bool allowFallback = true );
101112
113+ // ! @brief Destroys any owned resources and then creates the requested one
114+ // ! @param contextPropertiesSpan the context properties to use (supply a empty one to use the default).
115+ // ! If this span is not empty and contains a CL_CONTEXT_PLATFORM entry that is 0, then the entry will be patched with the right platformId.
116+ // ! If this span is not empty and does not contain a CL_CONTEXT_PLATFORM then a CL_CONTEXT_PLATFORM entry will be added.
117+ // ! @param pDeviceId the chosen device id (if nullptr this is ignored, else it will be assigned the chosen deviceId)
118+ // ! @param allowFallback if the specified device type can't be found allow using a fallback of CL_DEVICE_TYPE_ALL
119+ // NOLINTNEXTLINE(misc-misplaced-const)
120+ void Reset (const ReadOnlySpan<cl_context_properties> contextPropertiesSpan, const cl_device_type deviceType, cl_device_id* pDeviceId = nullptr ,
121+ const bool allowFallback = true );
122+
102123 // ! @brief Get the associated resource handle
103124 cl_platform_id GetPlatformId () const
104125 {
@@ -118,7 +139,9 @@ namespace Fsl::OpenCL
118139 }
119140
120141 private:
121- void SelectDevice (cl_platform_id platformId, const std::vector<cl_device_id>& deviceIds, cl_device_id* pDeviceId);
142+ void SelectDevice (const ReadOnlySpan<cl_context_properties> contextPropertiesSpan, cl_platform_id platformId,
143+ const std::vector<cl_device_id>& deviceIds, cl_device_id* pDeviceId);
144+ std::vector<cl_context_properties> PatchProperties (cl_platform_id platformId, const ReadOnlySpan<cl_context_properties> contextPropertiesSpan);
122145 };
123146}
124147
0 commit comments