aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/swr/rasterizer/jitter/jit_api.h
blob: 8a08031f25364aeae5a8fb86184fa9d4174dddde (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
/****************************************************************************
* Copyright (C) 2014-2015 Intel Corporation.   All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
* @file jit_api.h
*
* @brief Platform independent JIT interface
*
* Notes:
*
******************************************************************************/
#pragma once
#include "common/os.h"
#include "core/utils.h"

#include "fetch_jit.h"
#include "streamout_jit.h"
#include "blend_jit.h"

#include <stdlib.h>

#if defined(_WIN32)
#define EXCEPTION_PRINT_STACK(ret) ret
#endif // _WIN32

#if defined(_WIN32)
#define JITCALL __stdcall
#else
#define JITCALL
#endif



struct ShaderInfo;

//////////////////////////////////////////////////////////////////////////
/// Jit Compile Info Input
//////////////////////////////////////////////////////////////////////////
struct JIT_COMPILE_INPUT
{
    SWR_SHADER_TYPE type;

    const void* pIR;        ///< Pointer to LLVM IR text.

    bool enableJitSampler;
};

extern "C"
{

//////////////////////////////////////////////////////////////////////////
/// @brief Create JIT context.
HANDLE JITCALL JitCreateContext(uint32_t targetSimdWidth, const char* arch, const char* core);

//////////////////////////////////////////////////////////////////////////
/// @brief Destroy JIT context.
void JITCALL JitDestroyContext(HANDLE hJitContext);

//////////////////////////////////////////////////////////////////////////
/// @brief JIT compile shader.
/// @param hJitContext - Jit Context
/// @param input  - Input containing LLVM IR and other information
/// @param output - Output containing information about JIT shader
ShaderInfo* JITCALL JitCompileShader(
    HANDLE hJitContext,
    const JIT_COMPILE_INPUT& input);

//////////////////////////////////////////////////////////////////////////
/// @brief JIT destroy shader.
/// @param hJitContext - Jit Context
/// @param pShaderInfo  - pointer to shader object.
void JITCALL JitDestroyShader(
    HANDLE hJitContext,
    ShaderInfo*& pShaderInfo);

//////////////////////////////////////////////////////////////////////////
/// @brief JIT compiles fetch shader
/// @param hJitContext - Jit Context
/// @param state   - Fetch state to build function from
PFN_FETCH_FUNC JITCALL JitCompileFetch(HANDLE hJitContext, const FETCH_COMPILE_STATE& state);

//////////////////////////////////////////////////////////////////////////
/// @brief JIT compiles streamout shader
/// @param hJitContext - Jit Context
/// @param state   - SO state to build function from
PFN_SO_FUNC JITCALL JitCompileStreamout(HANDLE hJitContext, const STREAMOUT_COMPILE_STATE& state);

//////////////////////////////////////////////////////////////////////////
/// @brief JIT compiles blend shader
/// @param hJitContext - Jit Context
/// @param state   - blend state to build function from
PFN_BLEND_JIT_FUNC JITCALL JitCompileBlend(HANDLE hJitContext, const BLEND_COMPILE_STATE& state);

}