1 /*
2  * Copyright � 2014 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the
6  * "Software"), to deal in the Software without restriction, including
7  * without limitation the rights to use, copy, modify, merge, publish,
8  * distribute, sub license, and/or sell copies of the Software, and to
9  * permit persons to whom the Software is furnished to do so, subject to
10  * the following conditions:
11  *
12  * The above copyright notice and this permission notice (including the
13  * next paragraph) shall be included in all copies or substantial portions
14  * of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
19  * IN NO EVENT SHALL PRECISION INSIGHT AND/OR ITS SUPPLIERS BE LIABLE FOR
20  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  *
24  * Authors:
25  *     Wei Lin<wei.w.lin@intel.com>
26  *     Yuting Yang<yuting.yang@intel.com>
27  *     Lina Sun<lina.sun@intel.com>
28  */
29 
30 #pragma once
31 #include "cm_def.h"
32 
33 class CmDevice_RT;
34 
35 #include "cm_program_base.h"
36 
37 class CmProgram_RT : public CmProgram {
38  public:
39 	static INT Create(CmDevice_RT * pCmDev, void *pCISACode,
40 			  const UINT uiCISACodeSize, void *pGenCode,
41 			  const UINT uiGenCodeSize, CmProgram_RT * &pProgram,
42 			  const char *options, const UINT programId);
43 	static INT Destroy(CmProgram_RT * &pProgram);
44 
45 	INT GetCommonISACode(void *&pCommonISACode, UINT & size);
46 	INT GetKernelCount(UINT & kernelCount);
47 	INT GetKernelInfo(UINT index, CM_KERNEL_INFO * &pKernelInfo);
48 	INT GetIsaFileName(char *&kernelName);
49 	INT GetKernelOptions(char *&kernelOptions);
50 
51 	UINT GetSurfaceCount(void);
52 	INT SetSurfaceCount(UINT count);
53 
IsJitterEnabled(void)54 	BOOL IsJitterEnabled(void) {
55 		return m_IsJitterEnabled;
56 	} BOOL IsHwDebugEnabled(void) {
57 		return m_IsHwDebugEnabled;
58 	}
59 
60 	UINT AcquireKernelInfo(UINT index);
61 	UINT ReleaseKernelInfo(UINT index);
62 	INT GetKernelInfoRefCount(UINT index, UINT & refCount);
63 
64 	INT GetCISAVersion(UINT & majorVersion, UINT & minorVersion);
65 
66 	INT Acquire(void);
67 	INT SafeRelease(void);
68 
69 	UINT GetProgramIndex();
70 
71  protected:
72 	CmProgram_RT(CmDevice_RT * pCmDev, UINT programId);
73 	~CmProgram_RT(void);
74 
75 	INT Initialize(void *pCISACode, const UINT uiCISACodeSize,
76 		       void *pGenCode, const UINT uiGenCodeSize,
77 		       const char *options);
78 
79 	CmDevice_RT *m_pCmDev;
80 
81 	UINT m_ProgramCodeSize;
82 	BYTE *m_pProgramCode;
83 	char *m_Options;
84 	char m_IsaFileName[CM_MAX_ISA_FILE_NAME_SIZE_IN_BYTE];
85 	UINT m_SurfaceCount;
86 
87 	UINT m_KernelCount;
88 	CmDynamicArray m_pKernelInfo;
89 
90 	BOOL m_IsJitterEnabled;
91 	BOOL m_IsHwDebugEnabled;
92 
93 	UINT m_refCount;
94 
95 	UINT m_programIndex;
96 
97 	pJITCompile m_fJITCompile;
98 	pFreeBlock m_fFreeBlock;
99 	pJITVersion m_fJITVersion;
100 
101  public:
102 	DWORD m_CISA_magicNumber;
103 	BYTE m_CISA_majorVersion;
104 	BYTE m_CISA_minorVersion;
105 
106  private:
107 	CmProgram_RT(const CmProgram_RT & other);
108 	CmProgram_RT & operator=(const CmProgram_RT & other);
109 };
110