• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /****************************************************************************
2 * Copyright (C) 2014-2015 Intel Corporation.   All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice (including the next
12 * paragraph) shall be included in all copies or substantial portions of the
13 * Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 * IN THE SOFTWARE.
22 *
23 * @file jit_api.h
24 *
25 * @brief Platform independent JIT interface
26 *
27 * Notes:
28 *
29 ******************************************************************************/
30 #pragma once
31 #include "common/os.h"
32 #include "core/utils.h"
33 
34 #include "fetch_jit.h"
35 #include "streamout_jit.h"
36 #include "blend_jit.h"
37 
38 #include <stdlib.h>
39 
40 #if defined(_WIN32)
41 #define EXCEPTION_PRINT_STACK(ret) ret
42 #endif // _WIN32
43 
44 #if defined(_WIN32)
45 #define JITCALL __stdcall
46 #else
47 #define JITCALL
48 #endif
49 
50 
51 
52 struct ShaderInfo;
53 
54 //////////////////////////////////////////////////////////////////////////
55 /// Jit Compile Info Input
56 //////////////////////////////////////////////////////////////////////////
57 struct JIT_COMPILE_INPUT
58 {
59     SWR_SHADER_TYPE type;
60     uint32_t        crc;
61 
62     const void* pIR;        ///< Pointer to LLVM IR text.
63     size_t irLength;
64 
65     bool enableJitSampler;
66 
67 };
68 
69 extern "C"
70 {
71 
72 //////////////////////////////////////////////////////////////////////////
73 /// @brief Create JIT context.
74 HANDLE JITCALL JitCreateContext(uint32_t targetSimdWidth, const char* arch, const char* core);
75 
76 //////////////////////////////////////////////////////////////////////////
77 /// @brief Destroy JIT context.
78 void JITCALL JitDestroyContext(HANDLE hJitContext);
79 
80 //////////////////////////////////////////////////////////////////////////
81 /// @brief JIT compile shader.
82 /// @param hJitContext - Jit Context
83 /// @param input  - Input containing LLVM IR and other information
84 /// @param output - Output containing information about JIT shader
85 ShaderInfo* JITCALL JitCompileShader(
86     HANDLE hJitContext,
87     const JIT_COMPILE_INPUT& input);
88 
89 //////////////////////////////////////////////////////////////////////////
90 /// @brief JIT destroy shader.
91 /// @param hJitContext - Jit Context
92 /// @param pShaderInfo  - pointer to shader object.
93 void JITCALL JitDestroyShader(
94     HANDLE hJitContext,
95     ShaderInfo*& pShaderInfo);
96 
97 //////////////////////////////////////////////////////////////////////////
98 /// @brief JIT compiles fetch shader
99 /// @param hJitContext - Jit Context
100 /// @param state   - Fetch state to build function from
101 PFN_FETCH_FUNC JITCALL JitCompileFetch(HANDLE hJitContext, const FETCH_COMPILE_STATE& state);
102 
103 //////////////////////////////////////////////////////////////////////////
104 /// @brief JIT compiles streamout shader
105 /// @param hJitContext - Jit Context
106 /// @param state   - SO state to build function from
107 PFN_SO_FUNC JITCALL JitCompileStreamout(HANDLE hJitContext, const STREAMOUT_COMPILE_STATE& state);
108 
109 //////////////////////////////////////////////////////////////////////////
110 /// @brief JIT compiles blend shader
111 /// @param hJitContext - Jit Context
112 /// @param state   - blend state to build function from
113 PFN_BLEND_JIT_FUNC JITCALL JitCompileBlend(HANDLE hJitContext, const BLEND_COMPILE_STATE& state);
114 
115 }
116 
117