@@ -606,17 +606,26 @@ class CV_EXPORTS Program
606
606
607
607
bool create (const ProgramSource& src,
608
608
const String& buildflags, String& errmsg);
609
- bool read (const String& buf, const String& buildflags);
610
- bool write (String& buf) const ;
609
+ bool read (const String& buf, const String& buildflags); // deprecated
610
+ bool write (String& buf) const ; // deprecated
611
611
612
- const ProgramSource& source () const ;
612
+ const ProgramSource& source () const ; // deprecated
613
613
void * ptr () const ;
614
614
615
- String getPrefix () const ;
616
- static String getPrefix (const String& buildflags);
615
+ String getPrefix () const ; // deprecated
616
+ static String getPrefix (const String& buildflags); // deprecated
617
617
618
618
619
- struct Impl ;
619
+ /* *
620
+ * @brief Query device-specific program binary.
621
+ *
622
+ * @sa ProgramSource::fromBinary
623
+ *
624
+ * @param[out] binary output buffer
625
+ */
626
+ void getBinary (std::vector<char >& binary) const ;
627
+
628
+ struct Impl ; friend struct Impl ;
620
629
inline Impl* getImpl () const { return (Impl*)p; }
621
630
protected:
622
631
Impl* p;
@@ -636,10 +645,59 @@ class CV_EXPORTS ProgramSource
636
645
ProgramSource (const ProgramSource& prog);
637
646
ProgramSource& operator = (const ProgramSource& prog);
638
647
639
- const String& source () const ;
648
+ const String& source () const ; // deprecated
640
649
hash_t hash () const ; // deprecated
641
650
642
- struct Impl ;
651
+
652
+ /* * @brief Describe OpenCL program binary.
653
+ * Do not call clCreateProgramWithBinary() and/or clBuildProgram().
654
+ *
655
+ * Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies).
656
+ *
657
+ * This kind of binary is not portable between platforms in general - it is specific to OpenCL vendor / device / driver version.
658
+ *
659
+ * @param module name of program owner module
660
+ * @param name unique name of program (module+name is used as key for OpenCL program caching)
661
+ * @param binary buffer address. See buffer lifetime requirement in description.
662
+ * @param size buffer size
663
+ * @param buildOptions additional program-related build options passed to clBuildProgram()
664
+ * @return created ProgramSource object
665
+ */
666
+ static ProgramSource fromBinary (const String& module , const String& name,
667
+ const unsigned char * binary, const size_t size,
668
+ const cv::String& buildOptions = cv::String());
669
+
670
+ /* * @brief Describe OpenCL program in SPIR format.
671
+ * Do not call clCreateProgramWithBinary() and/or clBuildProgram().
672
+ *
673
+ * Supports SPIR 1.2 by default (pass '-spir-std=X.Y' in buildOptions to override this behavior)
674
+ *
675
+ * Caller should guarantee binary buffer lifetime greater than ProgramSource object (and any of its copies).
676
+ *
677
+ * Programs in this format are portable between OpenCL implementations with 'khr_spir' extension:
678
+ * https://www.khronos.org/registry/OpenCL/sdk/2.0/docs/man/xhtml/cl_khr_spir.html
679
+ * (but they are not portable between different platforms: 32-bit / 64-bit)
680
+ *
681
+ * Note: these programs can't support vendor specific extensions, like 'cl_intel_subgroups'.
682
+ *
683
+ * @param module name of program owner module
684
+ * @param name unique name of program (module+name is used as key for OpenCL program caching)
685
+ * @param binary buffer address. See buffer lifetime requirement in description.
686
+ * @param size buffer size
687
+ * @param buildOptions additional program-related build options passed to clBuildProgram()
688
+ * (these options are added automatically: '-x spir' and '-spir-std=1.2')
689
+ * @return created ProgramSource object.
690
+ */
691
+ static ProgramSource fromSPIR (const String& module , const String& name,
692
+ const unsigned char * binary, const size_t size,
693
+ const cv::String& buildOptions = cv::String());
694
+
695
+ // OpenCL 2.1+ only
696
+ // static Program fromSPIRV(const String& module, const String& name,
697
+ // const unsigned char* binary, const size_t size,
698
+ // const cv::String& buildOptions = cv::String());
699
+
700
+ struct Impl ; friend struct Impl ;
643
701
inline Impl* getImpl () const { return (Impl*)p; }
644
702
protected:
645
703
Impl* p;
0 commit comments