1 /****************************************************************************
2 * Copyright (C) 2015 Intel Corporation. All Rights Reserved.
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:
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
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
22 ***************************************************************************/
24 #include "JitManager.h"
26 #include "state_llvm.h"
29 #include "llvm-c/Core.h"
30 #include "llvm/Support/CBindingWrapping.h"
32 #include "tgsi/tgsi_strings.h"
33 #include "gallivm/lp_bld_init.h"
34 #include "gallivm/lp_bld_flow.h"
35 #include "gallivm/lp_bld_struct.h"
36 #include "gallivm/lp_bld_tgsi.h"
38 #include "swr_context.h"
39 #include "swr_context_llvm.h"
40 #include "swr_state.h"
41 #include "swr_screen.h"
43 bool operator==(const swr_jit_key
&lhs
, const swr_jit_key
&rhs
)
45 return !memcmp(&lhs
, &rhs
, sizeof(lhs
));
49 swr_generate_fs_key(struct swr_jit_key
&key
,
50 struct swr_context
*ctx
,
51 swr_fragment_shader
*swr_fs
)
53 key
.nr_cbufs
= ctx
->framebuffer
.nr_cbufs
;
54 key
.light_twoside
= ctx
->rasterizer
->light_twoside
;
55 memcpy(&key
.vs_output_semantic_name
,
56 &ctx
->vs
->info
.base
.output_semantic_name
,
57 sizeof(key
.vs_output_semantic_name
));
58 memcpy(&key
.vs_output_semantic_idx
,
59 &ctx
->vs
->info
.base
.output_semantic_index
,
60 sizeof(key
.vs_output_semantic_idx
));
62 key
.nr_samplers
= swr_fs
->info
.base
.file_max
[TGSI_FILE_SAMPLER
] + 1;
64 for (unsigned i
= 0; i
< key
.nr_samplers
; i
++) {
65 if (swr_fs
->info
.base
.file_mask
[TGSI_FILE_SAMPLER
] & (1 << i
)) {
66 lp_sampler_static_sampler_state(
67 &key
.sampler
[i
].sampler_state
,
68 ctx
->samplers
[PIPE_SHADER_FRAGMENT
][i
]);
73 * XXX If TGSI_FILE_SAMPLER_VIEW exists assume all texture opcodes
74 * are dx10-style? Can't really have mixed opcodes, at least not
75 * if we want to skip the holes here (without rescanning tgsi).
77 if (swr_fs
->info
.base
.file_max
[TGSI_FILE_SAMPLER_VIEW
] != -1) {
78 key
.nr_sampler_views
=
79 swr_fs
->info
.base
.file_max
[TGSI_FILE_SAMPLER_VIEW
] + 1;
80 for (unsigned i
= 0; i
< key
.nr_sampler_views
; i
++) {
81 if (swr_fs
->info
.base
.file_mask
[TGSI_FILE_SAMPLER_VIEW
] & (1 << i
)) {
82 lp_sampler_static_texture_state(
83 &key
.sampler
[i
].texture_state
,
84 ctx
->sampler_views
[PIPE_SHADER_FRAGMENT
][i
]);
88 key
.nr_sampler_views
= key
.nr_samplers
;
89 for (unsigned i
= 0; i
< key
.nr_sampler_views
; i
++) {
90 if (swr_fs
->info
.base
.file_mask
[TGSI_FILE_SAMPLER
] & (1 << i
)) {
91 lp_sampler_static_texture_state(
92 &key
.sampler
[i
].texture_state
,
93 ctx
->sampler_views
[PIPE_SHADER_FRAGMENT
][i
]);
99 struct BuilderSWR
: public Builder
{
100 BuilderSWR(JitManager
*pJitMgr
)
103 pJitMgr
->SetupNewModule();
107 CompileVS(struct pipe_context
*ctx
, swr_vertex_shader
*swr_vs
);
108 PFN_PIXEL_KERNEL
CompileFS(struct swr_context
*ctx
, swr_jit_key
&key
);
112 BuilderSWR::CompileVS(struct pipe_context
*ctx
, swr_vertex_shader
*swr_vs
)
114 swr_vs
->linkageMask
= 0;
116 for (unsigned i
= 0; i
< swr_vs
->info
.base
.num_outputs
; i
++) {
117 switch (swr_vs
->info
.base
.output_semantic_name
[i
]) {
118 case TGSI_SEMANTIC_POSITION
:
121 swr_vs
->linkageMask
|= (1 << i
);
126 // tgsi_dump(swr_vs->pipe.tokens, 0);
128 struct gallivm_state
*gallivm
=
129 gallivm_create("VS", wrap(&JM()->mContext
));
130 gallivm
->module
= wrap(JM()->mpCurrentModule
);
132 LLVMValueRef inputs
[PIPE_MAX_SHADER_INPUTS
][TGSI_NUM_CHANNELS
];
133 LLVMValueRef outputs
[PIPE_MAX_SHADER_OUTPUTS
][TGSI_NUM_CHANNELS
];
135 memset(outputs
, 0, sizeof(outputs
));
137 AttrBuilder attrBuilder
;
138 attrBuilder
.addStackAlignmentAttr(JM()->mVWidth
* sizeof(float));
139 AttributeSet attrSet
= AttributeSet::get(
140 JM()->mContext
, AttributeSet::FunctionIndex
, attrBuilder
);
142 std::vector
<Type
*> vsArgs
{PointerType::get(Gen_swr_draw_context(JM()), 0),
143 PointerType::get(Gen_SWR_VS_CONTEXT(JM()), 0)};
144 FunctionType
*vsFuncType
=
145 FunctionType::get(Type::getVoidTy(JM()->mContext
), vsArgs
, false);
147 // create new vertex shader function
148 auto pFunction
= Function::Create(vsFuncType
,
149 GlobalValue::ExternalLinkage
,
151 JM()->mpCurrentModule
);
152 pFunction
->addAttributes(AttributeSet::FunctionIndex
, attrSet
);
154 BasicBlock
*block
= BasicBlock::Create(JM()->mContext
, "entry", pFunction
);
155 IRB()->SetInsertPoint(block
);
156 LLVMPositionBuilderAtEnd(gallivm
->builder
, wrap(block
));
158 auto argitr
= pFunction
->arg_begin();
159 Value
*hPrivateData
= &*argitr
++;
160 hPrivateData
->setName("hPrivateData");
161 Value
*pVsCtx
= &*argitr
++;
162 pVsCtx
->setName("vsCtx");
164 Value
*consts_ptr
= GEP(hPrivateData
, {C(0), C(swr_draw_context_constantVS
)});
166 consts_ptr
->setName("vs_constants");
167 Value
*const_sizes_ptr
=
168 GEP(hPrivateData
, {0, swr_draw_context_num_constantsVS
});
169 const_sizes_ptr
->setName("num_vs_constants");
171 Value
*vtxInput
= LOAD(pVsCtx
, {0, SWR_VS_CONTEXT_pVin
});
173 for (uint32_t attrib
= 0; attrib
< PIPE_MAX_SHADER_INPUTS
; attrib
++) {
174 const unsigned mask
= swr_vs
->info
.base
.input_usage_mask
[attrib
];
175 for (uint32_t channel
= 0; channel
< TGSI_NUM_CHANNELS
; channel
++) {
176 if (mask
& (1 << channel
)) {
177 inputs
[attrib
][channel
] =
178 wrap(LOAD(vtxInput
, {0, 0, attrib
, channel
}));
183 struct lp_bld_tgsi_system_values system_values
;
184 memset(&system_values
, 0, sizeof(system_values
));
185 system_values
.instance_id
= wrap(LOAD(pVsCtx
, {0, SWR_VS_CONTEXT_InstanceID
}));
186 system_values
.vertex_id
= wrap(LOAD(pVsCtx
, {0, SWR_VS_CONTEXT_VertexID
}));
188 lp_build_tgsi_soa(gallivm
,
190 lp_type_float_vec(32, 32 * 8),
193 wrap(const_sizes_ptr
),
197 NULL
, // wrap(hPrivateData), (sampler context)
201 NULL
); // geometry shader face
203 IRB()->SetInsertPoint(unwrap(LLVMGetInsertBlock(gallivm
->builder
)));
205 Value
*vtxOutput
= LOAD(pVsCtx
, {0, SWR_VS_CONTEXT_pVout
});
207 for (uint32_t channel
= 0; channel
< TGSI_NUM_CHANNELS
; channel
++) {
208 for (uint32_t attrib
= 0; attrib
< PIPE_MAX_SHADER_OUTPUTS
; attrib
++) {
209 if (!outputs
[attrib
][channel
])
212 Value
*val
= LOAD(unwrap(outputs
[attrib
][channel
]));
214 uint32_t outSlot
= attrib
;
215 if (swr_vs
->info
.base
.output_semantic_name
[attrib
] == TGSI_SEMANTIC_PSIZE
)
216 outSlot
= VERTEX_POINT_SIZE_SLOT
;
217 STORE(val
, vtxOutput
, {0, 0, outSlot
, channel
});
223 gallivm_verify_function(gallivm
, wrap(pFunction
));
224 gallivm_compile_module(gallivm
);
226 // lp_debug_dump_value(func);
228 PFN_VERTEX_FUNC pFunc
=
229 (PFN_VERTEX_FUNC
)gallivm_jit_function(gallivm
, wrap(pFunction
));
231 debug_printf("vert shader %p\n", pFunc
);
232 assert(pFunc
&& "Error: VertShader = NULL");
234 #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR >= 5)
235 JM()->mIsModuleFinalized
= true;
242 swr_compile_vs(struct pipe_context
*ctx
, swr_vertex_shader
*swr_vs
)
245 reinterpret_cast<JitManager
*>(swr_screen(ctx
->screen
)->hJitMgr
));
246 return builder
.CompileVS(ctx
, swr_vs
);
250 locate_linkage(ubyte name
, ubyte index
, struct tgsi_shader_info
*info
)
252 for (int i
= 0; i
< PIPE_MAX_SHADER_OUTPUTS
; i
++) {
253 if ((info
->output_semantic_name
[i
] == name
)
254 && (info
->output_semantic_index
[i
] == index
)) {
255 return i
- 1; // position is not part of the linkage
259 if (name
== TGSI_SEMANTIC_COLOR
) { // BCOLOR fallback
260 for (int i
= 0; i
< PIPE_MAX_SHADER_OUTPUTS
; i
++) {
261 if ((info
->output_semantic_name
[i
] == TGSI_SEMANTIC_BCOLOR
)
262 && (info
->output_semantic_index
[i
] == index
)) {
263 return i
- 1; // position is not part of the linkage
272 BuilderSWR::CompileFS(struct swr_context
*ctx
, swr_jit_key
&key
)
274 struct swr_fragment_shader
*swr_fs
= ctx
->fs
;
276 // tgsi_dump(swr_fs->pipe.tokens, 0);
278 struct gallivm_state
*gallivm
=
279 gallivm_create("FS", wrap(&JM()->mContext
));
280 gallivm
->module
= wrap(JM()->mpCurrentModule
);
282 LLVMValueRef inputs
[PIPE_MAX_SHADER_INPUTS
][TGSI_NUM_CHANNELS
];
283 LLVMValueRef outputs
[PIPE_MAX_SHADER_OUTPUTS
][TGSI_NUM_CHANNELS
];
285 memset(inputs
, 0, sizeof(inputs
));
286 memset(outputs
, 0, sizeof(outputs
));
288 struct lp_build_sampler_soa
*sampler
= NULL
;
290 AttrBuilder attrBuilder
;
291 attrBuilder
.addStackAlignmentAttr(JM()->mVWidth
* sizeof(float));
292 AttributeSet attrSet
= AttributeSet::get(
293 JM()->mContext
, AttributeSet::FunctionIndex
, attrBuilder
);
295 std::vector
<Type
*> fsArgs
{PointerType::get(Gen_swr_draw_context(JM()), 0),
296 PointerType::get(Gen_SWR_PS_CONTEXT(JM()), 0)};
297 FunctionType
*funcType
=
298 FunctionType::get(Type::getVoidTy(JM()->mContext
), fsArgs
, false);
300 auto pFunction
= Function::Create(funcType
,
301 GlobalValue::ExternalLinkage
,
303 JM()->mpCurrentModule
);
304 pFunction
->addAttributes(AttributeSet::FunctionIndex
, attrSet
);
306 BasicBlock
*block
= BasicBlock::Create(JM()->mContext
, "entry", pFunction
);
307 IRB()->SetInsertPoint(block
);
308 LLVMPositionBuilderAtEnd(gallivm
->builder
, wrap(block
));
310 auto args
= pFunction
->arg_begin();
311 Value
*hPrivateData
= &*args
++;
312 hPrivateData
->setName("hPrivateData");
313 Value
*pPS
= &*args
++;
314 pPS
->setName("psCtx");
316 Value
*consts_ptr
= GEP(hPrivateData
, {0, swr_draw_context_constantFS
});
317 consts_ptr
->setName("fs_constants");
318 Value
*const_sizes_ptr
=
319 GEP(hPrivateData
, {0, swr_draw_context_num_constantsFS
});
320 const_sizes_ptr
->setName("num_fs_constants");
322 // xxx should check for flat shading versus interpolation
325 // load *pAttribs, *pPerspAttribs
326 Value
*pRawAttribs
= LOAD(pPS
, {0, SWR_PS_CONTEXT_pAttribs
}, "pRawAttribs");
327 Value
*pPerspAttribs
=
328 LOAD(pPS
, {0, SWR_PS_CONTEXT_pPerspAttribs
}, "pPerspAttribs");
330 swr_fs
->constantMask
= 0;
331 swr_fs
->pointSpriteMask
= 0;
333 for (int attrib
= 0; attrib
< PIPE_MAX_SHADER_INPUTS
; attrib
++) {
334 const unsigned mask
= swr_fs
->info
.base
.input_usage_mask
[attrib
];
335 const unsigned interpMode
= swr_fs
->info
.base
.input_interpolate
[attrib
];
336 const unsigned interpLoc
= swr_fs
->info
.base
.input_interpolate_loc
[attrib
];
342 Value
*vi
= nullptr, *vj
= nullptr;
344 case TGSI_INTERPOLATE_LOC_CENTER
:
345 vi
= LOAD(pPS
, {0, SWR_PS_CONTEXT_vI
, PixelPositions_center
}, "i");
346 vj
= LOAD(pPS
, {0, SWR_PS_CONTEXT_vJ
, PixelPositions_center
}, "j");
348 case TGSI_INTERPOLATE_LOC_CENTROID
:
349 vi
= LOAD(pPS
, {0, SWR_PS_CONTEXT_vI
, PixelPositions_centroid
}, "i");
350 vj
= LOAD(pPS
, {0, SWR_PS_CONTEXT_vJ
, PixelPositions_centroid
}, "j");
352 case TGSI_INTERPOLATE_LOC_SAMPLE
:
353 vi
= LOAD(pPS
, {0, SWR_PS_CONTEXT_vI
, PixelPositions_sample
}, "i");
354 vj
= LOAD(pPS
, {0, SWR_PS_CONTEXT_vJ
, PixelPositions_sample
}, "j");
359 Value
*vw
= nullptr, *pAttribs
;
360 if (interpMode
== TGSI_INTERPOLATE_PERSPECTIVE
) {
361 pAttribs
= pPerspAttribs
;
363 case TGSI_INTERPOLATE_LOC_CENTER
:
364 vw
= VRCP(LOAD(pPS
, {0, SWR_PS_CONTEXT_vOneOverW
, PixelPositions_center
}));
366 case TGSI_INTERPOLATE_LOC_CENTROID
:
367 vw
= VRCP(LOAD(pPS
, {0, SWR_PS_CONTEXT_vOneOverW
, PixelPositions_centroid
}));
369 case TGSI_INTERPOLATE_LOC_SAMPLE
:
370 vw
= VRCP(LOAD(pPS
, {0, SWR_PS_CONTEXT_vOneOverW
, PixelPositions_sample
}));
374 pAttribs
= pRawAttribs
;
380 ubyte semantic_name
= swr_fs
->info
.base
.input_semantic_name
[attrib
];
381 ubyte semantic_idx
= swr_fs
->info
.base
.input_semantic_index
[attrib
];
383 if (semantic_name
== TGSI_SEMANTIC_FACE
) {
385 UI_TO_FP(LOAD(pPS
, {0, SWR_PS_CONTEXT_frontFace
}), mFP32Ty
);
386 ff
= FSUB(FMUL(ff
, C(2.0f
)), C(1.0f
));
387 ff
= VECTOR_SPLAT(JM()->mVWidth
, ff
, "vFrontFace");
389 inputs
[attrib
][0] = wrap(ff
);
390 inputs
[attrib
][1] = wrap(VIMMED1(0.0f
));
391 inputs
[attrib
][2] = wrap(VIMMED1(0.0f
));
392 inputs
[attrib
][3] = wrap(VIMMED1(1.0f
));
394 } else if (semantic_name
== TGSI_SEMANTIC_POSITION
) { // gl_FragCoord
395 inputs
[attrib
][0] = wrap(LOAD(pPS
, {0, SWR_PS_CONTEXT_vX
, PixelPositions_center
}, "vX"));
396 inputs
[attrib
][1] = wrap(LOAD(pPS
, {0, SWR_PS_CONTEXT_vY
, PixelPositions_center
}, "vY"));
397 inputs
[attrib
][2] = wrap(LOAD(pPS
, {0, SWR_PS_CONTEXT_vZ
}, "vZ"));
399 wrap(LOAD(pPS
, {0, SWR_PS_CONTEXT_vOneOverW
, PixelPositions_center
}, "vOneOverW"));
401 } else if (semantic_name
== TGSI_SEMANTIC_PRIMID
) {
402 Value
*primID
= LOAD(pPS
, {0, SWR_PS_CONTEXT_primID
}, "primID");
403 inputs
[attrib
][0] = wrap(VECTOR_SPLAT(JM()->mVWidth
, primID
));
404 inputs
[attrib
][1] = wrap(VIMMED1(0));
405 inputs
[attrib
][2] = wrap(VIMMED1(0));
406 inputs
[attrib
][3] = wrap(VIMMED1(0));
410 unsigned linkedAttrib
=
411 locate_linkage(semantic_name
, semantic_idx
, &ctx
->vs
->info
.base
);
412 if (linkedAttrib
== 0xFFFFFFFF) {
413 // not found - check for point sprite
414 if (ctx
->rasterizer
->sprite_coord_enable
) {
415 linkedAttrib
= ctx
->vs
->info
.base
.num_outputs
- 1;
416 swr_fs
->pointSpriteMask
|= (1 << linkedAttrib
);
420 tgsi_semantic_names
[semantic_name
],
422 assert(0 && "attribute linkage not found");
426 if (interpMode
== TGSI_INTERPOLATE_CONSTANT
) {
427 swr_fs
->constantMask
|= 1 << linkedAttrib
;
430 for (int channel
= 0; channel
< TGSI_NUM_CHANNELS
; channel
++) {
431 if (mask
& (1 << channel
)) {
432 Value
*indexA
= C(linkedAttrib
* 12 + channel
);
433 Value
*indexB
= C(linkedAttrib
* 12 + channel
+ 4);
434 Value
*indexC
= C(linkedAttrib
* 12 + channel
+ 8);
436 if ((semantic_name
== TGSI_SEMANTIC_COLOR
)
437 && ctx
->rasterizer
->light_twoside
) {
438 unsigned bcolorAttrib
= locate_linkage(
439 TGSI_SEMANTIC_BCOLOR
, semantic_idx
, &ctx
->vs
->info
.base
);
441 unsigned diff
= 12 * (bcolorAttrib
- linkedAttrib
);
444 XOR(C(1), LOAD(pPS
, {0, SWR_PS_CONTEXT_frontFace
}), "backFace");
446 Value
*offset
= MUL(back
, C(diff
));
447 offset
->setName("offset");
449 indexA
= ADD(indexA
, offset
);
450 indexB
= ADD(indexB
, offset
);
451 indexC
= ADD(indexC
, offset
);
453 if (interpMode
== TGSI_INTERPOLATE_CONSTANT
) {
454 swr_fs
->constantMask
|= 1 << bcolorAttrib
;
458 Value
*va
= VBROADCAST(LOAD(GEP(pAttribs
, indexA
)));
459 Value
*vb
= VBROADCAST(LOAD(GEP(pAttribs
, indexB
)));
460 Value
*vc
= VBROADCAST(LOAD(GEP(pAttribs
, indexC
)));
462 if (interpMode
== TGSI_INTERPOLATE_CONSTANT
) {
463 inputs
[attrib
][channel
] = wrap(va
);
465 Value
*vk
= FSUB(FSUB(VIMMED1(1.0f
), vi
), vj
);
469 Value
*interp
= FMUL(va
, vi
);
470 Value
*interp1
= FMUL(vb
, vj
);
471 interp
= FADD(interp
, interp1
);
472 interp
= FADD(interp
, vc
);
473 if (interpMode
== TGSI_INTERPOLATE_PERSPECTIVE
)
474 interp
= FMUL(interp
, vw
);
475 inputs
[attrib
][channel
] = wrap(interp
);
481 sampler
= swr_sampler_soa_create(key
.sampler
);
483 struct lp_bld_tgsi_system_values system_values
;
484 memset(&system_values
, 0, sizeof(system_values
));
486 struct lp_build_mask_context mask
;
488 if (swr_fs
->info
.base
.uses_kill
) {
489 Value
*mask_val
= LOAD(pPS
, {0, SWR_PS_CONTEXT_activeMask
}, "activeMask");
491 &mask
, gallivm
, lp_type_float_vec(32, 32 * 8), wrap(mask_val
));
494 lp_build_tgsi_soa(gallivm
,
496 lp_type_float_vec(32, 32 * 8),
497 swr_fs
->info
.base
.uses_kill
? &mask
: NULL
, // mask
499 wrap(const_sizes_ptr
),
507 NULL
); // geometry shader face
509 IRB()->SetInsertPoint(unwrap(LLVMGetInsertBlock(gallivm
->builder
)));
511 for (uint32_t attrib
= 0; attrib
< swr_fs
->info
.base
.num_outputs
;
513 switch (swr_fs
->info
.base
.output_semantic_name
[attrib
]) {
514 case TGSI_SEMANTIC_POSITION
: {
517 LLVMBuildLoad(gallivm
->builder
, outputs
[attrib
][2], "");
518 STORE(unwrap(outZ
), pPS
, {0, SWR_PS_CONTEXT_vZ
});
521 case TGSI_SEMANTIC_COLOR
: {
522 for (uint32_t channel
= 0; channel
< TGSI_NUM_CHANNELS
; channel
++) {
523 if (!outputs
[attrib
][channel
])
527 LLVMBuildLoad(gallivm
->builder
, outputs
[attrib
][channel
], "");
528 if (swr_fs
->info
.base
.properties
[TGSI_PROPERTY_FS_COLOR0_WRITES_ALL_CBUFS
]) {
529 for (uint32_t rt
= 0; rt
< key
.nr_cbufs
; rt
++) {
532 {0, SWR_PS_CONTEXT_shaded
, rt
, channel
});
538 SWR_PS_CONTEXT_shaded
,
539 swr_fs
->info
.base
.output_semantic_index
[attrib
],
547 "unknown output from FS %s[%d]\n",
548 tgsi_semantic_names
[swr_fs
->info
.base
549 .output_semantic_name
[attrib
]],
550 swr_fs
->info
.base
.output_semantic_index
[attrib
]);
556 LLVMValueRef mask_result
= 0;
557 if (swr_fs
->info
.base
.uses_kill
) {
558 mask_result
= lp_build_mask_end(&mask
);
561 IRB()->SetInsertPoint(unwrap(LLVMGetInsertBlock(gallivm
->builder
)));
563 if (swr_fs
->info
.base
.uses_kill
) {
564 STORE(unwrap(mask_result
), pPS
, {0, SWR_PS_CONTEXT_activeMask
});
569 gallivm_verify_function(gallivm
, wrap(pFunction
));
571 gallivm_compile_module(gallivm
);
573 PFN_PIXEL_KERNEL kernel
=
574 (PFN_PIXEL_KERNEL
)gallivm_jit_function(gallivm
, wrap(pFunction
));
575 debug_printf("frag shader %p\n", kernel
);
576 assert(kernel
&& "Error: FragShader = NULL");
578 #if (LLVM_VERSION_MAJOR == 3) && (LLVM_VERSION_MINOR >= 5)
579 JM()->mIsModuleFinalized
= true;
586 swr_compile_fs(struct swr_context
*ctx
, swr_jit_key
&key
)
589 reinterpret_cast<JitManager
*>(swr_screen(ctx
->pipe
.screen
)->hJitMgr
));
590 return builder
.CompileFS(ctx
, key
);