• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**************************************************************************
2  *
3  * Copyright 2009 VMware, Inc.
4  * All Rights Reserved.
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sub license, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the
15  * next paragraph) shall be included in all copies or substantial portions
16  * of the Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21  * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25  *
26  **************************************************************************/
27 
28 /**
29  * @file
30  * C - JIT interfaces
31  *
32  * @author Jose Fonseca <jfonseca@vmware.com>
33  */
34 
35 #include <llvm/Config/llvm-config.h>
36 
37 #include "util/u_memory.h"
38 #include "gallivm/lp_bld_init.h"
39 #include "gallivm/lp_bld_debug.h"
40 #include "gallivm/lp_bld_format.h"
41 #include "lp_context.h"
42 #include "lp_jit.h"
43 
44 static LLVMTypeRef
create_jit_texture_type(struct gallivm_state * gallivm)45 create_jit_texture_type(struct gallivm_state *gallivm)
46 {
47    LLVMContextRef lc = gallivm->context;
48    LLVMTypeRef texture_type;
49    LLVMTypeRef elem_types[LP_JIT_TEXTURE_NUM_FIELDS];
50 
51    /* struct lp_jit_texture */
52    elem_types[LP_JIT_TEXTURE_WIDTH]  =
53    elem_types[LP_JIT_TEXTURE_HEIGHT] =
54    elem_types[LP_JIT_TEXTURE_DEPTH] =
55    elem_types[LP_JIT_TEXTURE_NUM_SAMPLES] =
56    elem_types[LP_JIT_TEXTURE_SAMPLE_STRIDE] =
57    elem_types[LP_JIT_TEXTURE_FIRST_LEVEL] =
58    elem_types[LP_JIT_TEXTURE_LAST_LEVEL] = LLVMInt32TypeInContext(lc);
59    elem_types[LP_JIT_TEXTURE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
60    elem_types[LP_JIT_TEXTURE_ROW_STRIDE] =
61    elem_types[LP_JIT_TEXTURE_IMG_STRIDE] =
62    elem_types[LP_JIT_TEXTURE_MIP_OFFSETS] =
63       LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TEXTURE_LEVELS);
64 
65    texture_type = LLVMStructTypeInContext(lc, elem_types,
66                                           ARRAY_SIZE(elem_types), 0);
67 
68    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, width,
69                           gallivm->target, texture_type,
70                           LP_JIT_TEXTURE_WIDTH);
71    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, height,
72                           gallivm->target, texture_type,
73                           LP_JIT_TEXTURE_HEIGHT);
74    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, depth,
75                           gallivm->target, texture_type,
76                           LP_JIT_TEXTURE_DEPTH);
77    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, base,
78                           gallivm->target, texture_type,
79                           LP_JIT_TEXTURE_BASE);
80    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, row_stride,
81                           gallivm->target, texture_type,
82                           LP_JIT_TEXTURE_ROW_STRIDE);
83    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, img_stride,
84                           gallivm->target, texture_type,
85                           LP_JIT_TEXTURE_IMG_STRIDE);
86    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, first_level,
87                           gallivm->target, texture_type,
88                           LP_JIT_TEXTURE_FIRST_LEVEL);
89    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, last_level,
90                           gallivm->target, texture_type,
91                           LP_JIT_TEXTURE_LAST_LEVEL);
92    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, mip_offsets,
93                           gallivm->target, texture_type,
94                           LP_JIT_TEXTURE_MIP_OFFSETS);
95    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, num_samples,
96                           gallivm->target, texture_type,
97                           LP_JIT_TEXTURE_NUM_SAMPLES);
98    LP_CHECK_MEMBER_OFFSET(struct lp_jit_texture, sample_stride,
99                           gallivm->target, texture_type,
100                           LP_JIT_TEXTURE_SAMPLE_STRIDE);
101    LP_CHECK_STRUCT_SIZE(struct lp_jit_texture,
102                         gallivm->target, texture_type);
103    return texture_type;
104 }
105 
106 static LLVMTypeRef
create_jit_sampler_type(struct gallivm_state * gallivm)107 create_jit_sampler_type(struct gallivm_state *gallivm)
108 {
109    LLVMContextRef lc = gallivm->context;
110    LLVMTypeRef sampler_type;
111    LLVMTypeRef elem_types[LP_JIT_SAMPLER_NUM_FIELDS];
112    elem_types[LP_JIT_SAMPLER_MIN_LOD] =
113    elem_types[LP_JIT_SAMPLER_MAX_LOD] =
114    elem_types[LP_JIT_SAMPLER_LOD_BIAS] = LLVMFloatTypeInContext(lc);
115    elem_types[LP_JIT_SAMPLER_BORDER_COLOR] =
116       LLVMArrayType(LLVMFloatTypeInContext(lc), 4);
117 
118    sampler_type = LLVMStructTypeInContext(lc, elem_types,
119                                           ARRAY_SIZE(elem_types), 0);
120 
121    LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, min_lod,
122                           gallivm->target, sampler_type,
123                           LP_JIT_SAMPLER_MIN_LOD);
124    LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, max_lod,
125                           gallivm->target, sampler_type,
126                           LP_JIT_SAMPLER_MAX_LOD);
127    LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, lod_bias,
128                           gallivm->target, sampler_type,
129                           LP_JIT_SAMPLER_LOD_BIAS);
130    LP_CHECK_MEMBER_OFFSET(struct lp_jit_sampler, border_color,
131                           gallivm->target, sampler_type,
132                           LP_JIT_SAMPLER_BORDER_COLOR);
133    LP_CHECK_STRUCT_SIZE(struct lp_jit_sampler,
134                         gallivm->target, sampler_type);
135    return sampler_type;
136 }
137 
138 static LLVMTypeRef
create_jit_image_type(struct gallivm_state * gallivm)139 create_jit_image_type(struct gallivm_state *gallivm)
140 {
141    LLVMContextRef lc = gallivm->context;
142    LLVMTypeRef image_type;
143    LLVMTypeRef elem_types[LP_JIT_IMAGE_NUM_FIELDS];
144    elem_types[LP_JIT_IMAGE_WIDTH] =
145    elem_types[LP_JIT_IMAGE_HEIGHT] =
146    elem_types[LP_JIT_IMAGE_DEPTH] = LLVMInt32TypeInContext(lc);
147    elem_types[LP_JIT_IMAGE_BASE] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
148    elem_types[LP_JIT_IMAGE_ROW_STRIDE] =
149    elem_types[LP_JIT_IMAGE_IMG_STRIDE] =
150    elem_types[LP_JIT_IMAGE_NUM_SAMPLES] =
151    elem_types[LP_JIT_IMAGE_SAMPLE_STRIDE] = LLVMInt32TypeInContext(lc);
152 
153    image_type = LLVMStructTypeInContext(lc, elem_types,
154                                         ARRAY_SIZE(elem_types), 0);
155    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, width,
156                           gallivm->target, image_type,
157                           LP_JIT_IMAGE_WIDTH);
158    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, height,
159                           gallivm->target, image_type,
160                           LP_JIT_IMAGE_HEIGHT);
161    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, depth,
162                           gallivm->target, image_type,
163                           LP_JIT_IMAGE_DEPTH);
164    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, base,
165                           gallivm->target, image_type,
166                           LP_JIT_IMAGE_BASE);
167    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, row_stride,
168                           gallivm->target, image_type,
169                           LP_JIT_IMAGE_ROW_STRIDE);
170    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, img_stride,
171                           gallivm->target, image_type,
172                           LP_JIT_IMAGE_IMG_STRIDE);
173    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, num_samples,
174                           gallivm->target, image_type,
175                           LP_JIT_IMAGE_NUM_SAMPLES);
176    LP_CHECK_MEMBER_OFFSET(struct lp_jit_image, sample_stride,
177                           gallivm->target, image_type,
178                           LP_JIT_IMAGE_SAMPLE_STRIDE);
179    return image_type;
180 }
181 
182 static void
lp_jit_create_types(struct lp_fragment_shader_variant * lp)183 lp_jit_create_types(struct lp_fragment_shader_variant *lp)
184 {
185    struct gallivm_state *gallivm = lp->gallivm;
186    LLVMContextRef lc = gallivm->context;
187    LLVMTypeRef viewport_type, texture_type, sampler_type, image_type;
188 
189    /* struct lp_jit_viewport */
190    {
191       LLVMTypeRef elem_types[LP_JIT_VIEWPORT_NUM_FIELDS];
192 
193       elem_types[LP_JIT_VIEWPORT_MIN_DEPTH] =
194       elem_types[LP_JIT_VIEWPORT_MAX_DEPTH] = LLVMFloatTypeInContext(lc);
195 
196       viewport_type = LLVMStructTypeInContext(lc, elem_types,
197                                               ARRAY_SIZE(elem_types), 0);
198 
199       LP_CHECK_MEMBER_OFFSET(struct lp_jit_viewport, min_depth,
200                              gallivm->target, viewport_type,
201                              LP_JIT_VIEWPORT_MIN_DEPTH);
202       LP_CHECK_MEMBER_OFFSET(struct lp_jit_viewport, max_depth,
203                              gallivm->target, viewport_type,
204                              LP_JIT_VIEWPORT_MAX_DEPTH);
205       LP_CHECK_STRUCT_SIZE(struct lp_jit_viewport,
206                            gallivm->target, viewport_type);
207    }
208 
209    texture_type = create_jit_texture_type(gallivm);
210    sampler_type = create_jit_sampler_type(gallivm);
211    image_type = create_jit_image_type(gallivm);
212 
213    /* struct lp_jit_context */
214    {
215       LLVMTypeRef elem_types[LP_JIT_CTX_COUNT];
216       LLVMTypeRef context_type;
217 
218       elem_types[LP_JIT_CTX_CONSTANTS] =
219          LLVMArrayType(LLVMPointerType(LLVMFloatTypeInContext(lc), 0), LP_MAX_TGSI_CONST_BUFFERS);
220       elem_types[LP_JIT_CTX_NUM_CONSTANTS] =
221             LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_CONST_BUFFERS);
222       elem_types[LP_JIT_CTX_TEXTURES] = LLVMArrayType(texture_type,
223                                                       PIPE_MAX_SHADER_SAMPLER_VIEWS);
224       elem_types[LP_JIT_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
225                                                       PIPE_MAX_SAMPLERS);
226       elem_types[LP_JIT_CTX_IMAGES] = LLVMArrayType(image_type,
227                                                     PIPE_MAX_SHADER_IMAGES);
228       elem_types[LP_JIT_CTX_ALPHA_REF] = LLVMFloatTypeInContext(lc);
229       elem_types[LP_JIT_CTX_SAMPLE_MASK] =
230       elem_types[LP_JIT_CTX_STENCIL_REF_FRONT] =
231       elem_types[LP_JIT_CTX_STENCIL_REF_BACK] = LLVMInt32TypeInContext(lc);
232       elem_types[LP_JIT_CTX_U8_BLEND_COLOR] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
233       elem_types[LP_JIT_CTX_F_BLEND_COLOR] = LLVMPointerType(LLVMFloatTypeInContext(lc), 0);
234       elem_types[LP_JIT_CTX_VIEWPORTS] = LLVMPointerType(viewport_type, 0);
235       elem_types[LP_JIT_CTX_SSBOS] =
236          LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS);
237       elem_types[LP_JIT_CTX_NUM_SSBOS] =
238             LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_SHADER_BUFFERS);
239       context_type = LLVMStructTypeInContext(lc, elem_types,
240                                              ARRAY_SIZE(elem_types), 0);
241 
242       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, constants,
243                              gallivm->target, context_type,
244                              LP_JIT_CTX_CONSTANTS);
245       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, num_constants,
246                              gallivm->target, context_type,
247                              LP_JIT_CTX_NUM_CONSTANTS);
248       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, textures,
249                              gallivm->target, context_type,
250                              LP_JIT_CTX_TEXTURES);
251       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, samplers,
252                              gallivm->target, context_type,
253                              LP_JIT_CTX_SAMPLERS);
254       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, images,
255                              gallivm->target, context_type,
256                              LP_JIT_CTX_IMAGES);
257       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, alpha_ref_value,
258                              gallivm->target, context_type,
259                              LP_JIT_CTX_ALPHA_REF);
260       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_front,
261                              gallivm->target, context_type,
262                              LP_JIT_CTX_STENCIL_REF_FRONT);
263       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, stencil_ref_back,
264                              gallivm->target, context_type,
265                              LP_JIT_CTX_STENCIL_REF_BACK);
266       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, u8_blend_color,
267                              gallivm->target, context_type,
268                              LP_JIT_CTX_U8_BLEND_COLOR);
269       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, f_blend_color,
270                              gallivm->target, context_type,
271                              LP_JIT_CTX_F_BLEND_COLOR);
272       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, viewports,
273                              gallivm->target, context_type,
274                              LP_JIT_CTX_VIEWPORTS);
275       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, ssbos,
276                              gallivm->target, context_type,
277                              LP_JIT_CTX_SSBOS);
278       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, num_ssbos,
279                              gallivm->target, context_type,
280                              LP_JIT_CTX_NUM_SSBOS);
281       LP_CHECK_MEMBER_OFFSET(struct lp_jit_context, sample_mask,
282                              gallivm->target, context_type,
283                              LP_JIT_CTX_SAMPLE_MASK);
284       LP_CHECK_STRUCT_SIZE(struct lp_jit_context,
285                            gallivm->target, context_type);
286 
287       lp->jit_context_ptr_type = LLVMPointerType(context_type, 0);
288    }
289 
290    /* struct lp_jit_thread_data */
291    {
292       LLVMTypeRef elem_types[LP_JIT_THREAD_DATA_COUNT];
293       LLVMTypeRef thread_data_type;
294 
295       elem_types[LP_JIT_THREAD_DATA_CACHE] =
296             LLVMPointerType(lp_build_format_cache_type(gallivm), 0);
297       elem_types[LP_JIT_THREAD_DATA_COUNTER] = LLVMInt64TypeInContext(lc);
298       elem_types[LP_JIT_THREAD_DATA_INVOCATIONS] = LLVMInt64TypeInContext(lc);
299       elem_types[LP_JIT_THREAD_DATA_RASTER_STATE_VIEWPORT_INDEX] =
300             LLVMInt32TypeInContext(lc);
301 
302       thread_data_type = LLVMStructTypeInContext(lc, elem_types,
303                                                  ARRAY_SIZE(elem_types), 0);
304 
305       lp->jit_thread_data_ptr_type = LLVMPointerType(thread_data_type, 0);
306    }
307 
308    if (gallivm_debug & GALLIVM_DEBUG_IR) {
309       char *str = LLVMPrintModuleToString(gallivm->module);
310       fprintf(stderr, "%s", str);
311       LLVMDisposeMessage(str);
312    }
313 }
314 
315 
316 void
lp_jit_screen_cleanup(struct llvmpipe_screen * screen)317 lp_jit_screen_cleanup(struct llvmpipe_screen *screen)
318 {
319    /* nothing */
320 }
321 
322 
323 boolean
lp_jit_screen_init(struct llvmpipe_screen * screen)324 lp_jit_screen_init(struct llvmpipe_screen *screen)
325 {
326    return lp_build_init();
327 }
328 
329 
330 void
lp_jit_init_types(struct lp_fragment_shader_variant * lp)331 lp_jit_init_types(struct lp_fragment_shader_variant *lp)
332 {
333    if (!lp->jit_context_ptr_type)
334       lp_jit_create_types(lp);
335 }
336 
337 static void
lp_jit_create_cs_types(struct lp_compute_shader_variant * lp)338 lp_jit_create_cs_types(struct lp_compute_shader_variant *lp)
339 {
340    struct gallivm_state *gallivm = lp->gallivm;
341    LLVMContextRef lc = gallivm->context;
342    LLVMTypeRef texture_type, sampler_type, image_type;
343 
344    texture_type = create_jit_texture_type(gallivm);
345    sampler_type = create_jit_sampler_type(gallivm);
346    image_type = create_jit_image_type(gallivm);
347 
348    /* struct lp_jit_cs_thread_data */
349    {
350       LLVMTypeRef elem_types[LP_JIT_CS_THREAD_DATA_COUNT];
351       LLVMTypeRef thread_data_type;
352 
353       elem_types[LP_JIT_CS_THREAD_DATA_CACHE] =
354             LLVMPointerType(lp_build_format_cache_type(gallivm), 0);
355 
356       elem_types[LP_JIT_CS_THREAD_DATA_SHARED] = LLVMPointerType(LLVMInt32TypeInContext(lc), 0);
357       thread_data_type = LLVMStructTypeInContext(lc, elem_types,
358                                                  ARRAY_SIZE(elem_types), 0);
359 
360       lp->jit_cs_thread_data_ptr_type = LLVMPointerType(thread_data_type, 0);
361    }
362 
363    /* struct lp_jit_cs_context */
364    {
365       LLVMTypeRef elem_types[LP_JIT_CS_CTX_COUNT];
366       LLVMTypeRef cs_context_type;
367 
368       elem_types[LP_JIT_CS_CTX_CONSTANTS] =
369          LLVMArrayType(LLVMPointerType(LLVMFloatTypeInContext(lc), 0), LP_MAX_TGSI_CONST_BUFFERS);
370       elem_types[LP_JIT_CS_CTX_NUM_CONSTANTS] =
371             LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_CONST_BUFFERS);
372       elem_types[LP_JIT_CS_CTX_TEXTURES] = LLVMArrayType(texture_type,
373                                                       PIPE_MAX_SHADER_SAMPLER_VIEWS);
374       elem_types[LP_JIT_CS_CTX_SAMPLERS] = LLVMArrayType(sampler_type,
375                                                       PIPE_MAX_SAMPLERS);
376       elem_types[LP_JIT_CS_CTX_IMAGES] = LLVMArrayType(image_type,
377                                                        PIPE_MAX_SHADER_IMAGES);
378       elem_types[LP_JIT_CS_CTX_SSBOS] =
379          LLVMArrayType(LLVMPointerType(LLVMInt32TypeInContext(lc), 0), LP_MAX_TGSI_SHADER_BUFFERS);
380       elem_types[LP_JIT_CS_CTX_NUM_SSBOS] =
381             LLVMArrayType(LLVMInt32TypeInContext(lc), LP_MAX_TGSI_SHADER_BUFFERS);
382 
383       elem_types[LP_JIT_CS_CTX_SHARED_SIZE] = LLVMInt32TypeInContext(lc);
384 
385       elem_types[LP_JIT_CS_CTX_KERNEL_ARGS] = LLVMPointerType(LLVMInt8TypeInContext(lc), 0);
386 
387       cs_context_type = LLVMStructTypeInContext(lc, elem_types,
388                                              ARRAY_SIZE(elem_types), 0);
389 
390       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, constants,
391                              gallivm->target, cs_context_type,
392                              LP_JIT_CS_CTX_CONSTANTS);
393       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, num_constants,
394                              gallivm->target, cs_context_type,
395                              LP_JIT_CS_CTX_NUM_CONSTANTS);
396       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, textures,
397                              gallivm->target, cs_context_type,
398                              LP_JIT_CS_CTX_TEXTURES);
399       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, samplers,
400                              gallivm->target, cs_context_type,
401                              LP_JIT_CS_CTX_SAMPLERS);
402       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, images,
403                              gallivm->target, cs_context_type,
404                              LP_JIT_CS_CTX_IMAGES);
405       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, ssbos,
406                              gallivm->target, cs_context_type,
407                              LP_JIT_CS_CTX_SSBOS);
408       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, num_ssbos,
409                              gallivm->target, cs_context_type,
410                              LP_JIT_CS_CTX_NUM_SSBOS);
411       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, shared_size,
412                              gallivm->target, cs_context_type,
413                              LP_JIT_CS_CTX_SHARED_SIZE);
414       LP_CHECK_MEMBER_OFFSET(struct lp_jit_cs_context, kernel_args,
415                              gallivm->target, cs_context_type,
416                              LP_JIT_CS_CTX_KERNEL_ARGS);
417       LP_CHECK_STRUCT_SIZE(struct lp_jit_cs_context,
418                            gallivm->target, cs_context_type);
419 
420       lp->jit_cs_context_ptr_type = LLVMPointerType(cs_context_type, 0);
421    }
422 
423    if (gallivm_debug & GALLIVM_DEBUG_IR) {
424       char *str = LLVMPrintModuleToString(gallivm->module);
425       fprintf(stderr, "%s", str);
426       LLVMDisposeMessage(str);
427    }
428 }
429 
430 void
lp_jit_init_cs_types(struct lp_compute_shader_variant * lp)431 lp_jit_init_cs_types(struct lp_compute_shader_variant *lp)
432 {
433    if (!lp->jit_cs_context_ptr_type)
434       lp_jit_create_cs_types(lp);
435 }
436