1848b8605Smrg/************************************************************************** 2848b8605Smrg * 3848b8605Smrg * Copyright 2010 VMware, Inc. 4848b8605Smrg * All Rights Reserved. 5848b8605Smrg * 6848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 7848b8605Smrg * copy of this software and associated documentation files (the 8848b8605Smrg * "Software"), to deal in the Software without restriction, including 9848b8605Smrg * without limitation the rights to use, copy, modify, merge, publish, 10848b8605Smrg * distribute, sub license, and/or sell copies of the Software, and to 11848b8605Smrg * permit persons to whom the Software is furnished to do so, subject to 12848b8605Smrg * the following conditions: 13848b8605Smrg * 14848b8605Smrg * The above copyright notice and this permission notice (including the 15848b8605Smrg * next paragraph) shall be included in all copies or substantial portions 16848b8605Smrg * of the Software. 17848b8605Smrg * 18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 19848b8605Smrg * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 20848b8605Smrg * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 21848b8605Smrg * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 22848b8605Smrg * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 23848b8605Smrg * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 24848b8605Smrg * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 25848b8605Smrg * 26848b8605Smrg **************************************************************************/ 27848b8605Smrg 28848b8605Smrg#ifndef DRAW_LLVM_H 29848b8605Smrg#define DRAW_LLVM_H 30848b8605Smrg 31848b8605Smrg#include "draw/draw_private.h" 32848b8605Smrg 33848b8605Smrg#include "draw/draw_vs.h" 34848b8605Smrg#include "draw/draw_gs.h" 35848b8605Smrg 36848b8605Smrg#include "gallivm/lp_bld_sample.h" 37848b8605Smrg#include "gallivm/lp_bld_limits.h" 38848b8605Smrg 39848b8605Smrg#include "pipe/p_context.h" 40b8e80941Smrg#include "util/simple_list.h" 41848b8605Smrg 42848b8605Smrg 43848b8605Smrgstruct draw_llvm; 44848b8605Smrgstruct llvm_vertex_shader; 45848b8605Smrgstruct llvm_geometry_shader; 46848b8605Smrg 47848b8605Smrgstruct draw_jit_texture 48848b8605Smrg{ 49848b8605Smrg uint32_t width; 50848b8605Smrg uint32_t height; 51848b8605Smrg uint32_t depth; 52848b8605Smrg uint32_t first_level; 53848b8605Smrg uint32_t last_level; 54848b8605Smrg const void *base; 55848b8605Smrg uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS]; 56848b8605Smrg uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS]; 57848b8605Smrg uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]; 58848b8605Smrg}; 59848b8605Smrg 60848b8605Smrg 61848b8605Smrgstruct draw_sampler_static_state 62848b8605Smrg{ 63848b8605Smrg /* 64848b8605Smrg * These attributes are effectively interleaved for more sane key handling. 65848b8605Smrg * However, there might be lots of null space if the amount of samplers and 66848b8605Smrg * textures isn't the same. 67848b8605Smrg */ 68848b8605Smrg struct lp_static_sampler_state sampler_state; 69848b8605Smrg struct lp_static_texture_state texture_state; 70848b8605Smrg}; 71848b8605Smrg 72848b8605Smrg 73848b8605Smrgstruct draw_jit_sampler 74848b8605Smrg{ 75848b8605Smrg float min_lod; 76848b8605Smrg float max_lod; 77848b8605Smrg float lod_bias; 78848b8605Smrg float border_color[4]; 79848b8605Smrg}; 80848b8605Smrg 81848b8605Smrg 82848b8605Smrgenum { 83848b8605Smrg DRAW_JIT_TEXTURE_WIDTH = 0, 84848b8605Smrg DRAW_JIT_TEXTURE_HEIGHT, 85848b8605Smrg DRAW_JIT_TEXTURE_DEPTH, 86848b8605Smrg DRAW_JIT_TEXTURE_FIRST_LEVEL, 87848b8605Smrg DRAW_JIT_TEXTURE_LAST_LEVEL, 88848b8605Smrg DRAW_JIT_TEXTURE_BASE, 89848b8605Smrg DRAW_JIT_TEXTURE_ROW_STRIDE, 90848b8605Smrg DRAW_JIT_TEXTURE_IMG_STRIDE, 91848b8605Smrg DRAW_JIT_TEXTURE_MIP_OFFSETS, 92848b8605Smrg DRAW_JIT_TEXTURE_NUM_FIELDS /* number of fields above */ 93848b8605Smrg}; 94848b8605Smrg 95848b8605Smrg 96848b8605Smrgenum { 97848b8605Smrg DRAW_JIT_SAMPLER_MIN_LOD, 98848b8605Smrg DRAW_JIT_SAMPLER_MAX_LOD, 99848b8605Smrg DRAW_JIT_SAMPLER_LOD_BIAS, 100848b8605Smrg DRAW_JIT_SAMPLER_BORDER_COLOR, 101848b8605Smrg DRAW_JIT_SAMPLER_NUM_FIELDS /* number of fields above */ 102848b8605Smrg}; 103848b8605Smrg 104848b8605Smrg 105848b8605Smrgenum { 106848b8605Smrg DRAW_JIT_VERTEX_VERTEX_ID = 0, 107b8e80941Smrg DRAW_JIT_VERTEX_CLIP_POS, 108848b8605Smrg DRAW_JIT_VERTEX_DATA 109848b8605Smrg}; 110848b8605Smrg 111848b8605Smrg/** 112848b8605Smrg * This structure is passed directly to the generated vertex shader. 113848b8605Smrg * 114848b8605Smrg * It contains the derived state. 115848b8605Smrg * 116848b8605Smrg * Changes here must be reflected in the draw_jit_context_* macros. 117848b8605Smrg * Changes to the ordering should be avoided. 118848b8605Smrg * 119848b8605Smrg * Only use types with a clear size and padding here, in particular prefer the 120848b8605Smrg * stdint.h types to the basic integer types. 121848b8605Smrg */ 122848b8605Smrgstruct draw_jit_context 123848b8605Smrg{ 124848b8605Smrg const float *vs_constants[LP_MAX_TGSI_CONST_BUFFERS]; 125848b8605Smrg int num_vs_constants[LP_MAX_TGSI_CONST_BUFFERS]; 126848b8605Smrg float (*planes) [DRAW_TOTAL_CLIP_PLANES][4]; 127b8e80941Smrg struct pipe_viewport_state *viewports; 128848b8605Smrg 129848b8605Smrg struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS]; 130848b8605Smrg struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS]; 131848b8605Smrg}; 132848b8605Smrg 133848b8605Smrgenum { 134848b8605Smrg DRAW_JIT_CTX_CONSTANTS = 0, 135848b8605Smrg DRAW_JIT_CTX_NUM_CONSTANTS = 1, 136848b8605Smrg DRAW_JIT_CTX_PLANES = 2, 137848b8605Smrg DRAW_JIT_CTX_VIEWPORT = 3, 138848b8605Smrg DRAW_JIT_CTX_TEXTURES = 4, 139848b8605Smrg DRAW_JIT_CTX_SAMPLERS = 5, 140848b8605Smrg DRAW_JIT_CTX_NUM_FIELDS 141848b8605Smrg}; 142848b8605Smrg 143848b8605Smrg#define draw_jit_context_vs_constants(_gallivm, _ptr) \ 144848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_CONSTANTS, "vs_constants") 145848b8605Smrg 146848b8605Smrg#define draw_jit_context_num_vs_constants(_gallivm, _ptr) \ 147848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_NUM_CONSTANTS, "num_vs_constants") 148848b8605Smrg 149848b8605Smrg#define draw_jit_context_planes(_gallivm, _ptr) \ 150848b8605Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_CTX_PLANES, "planes") 151848b8605Smrg 152b8e80941Smrg#define draw_jit_context_viewports(_gallivm, _ptr) \ 153b8e80941Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_CTX_VIEWPORT, "viewports") 154848b8605Smrg 155848b8605Smrg#define draw_jit_context_textures(_gallivm, _ptr) \ 156848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_TEXTURES, "textures") 157848b8605Smrg 158848b8605Smrg#define draw_jit_context_samplers(_gallivm, _ptr) \ 159848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_CTX_SAMPLERS, "samplers") 160848b8605Smrg 161848b8605Smrg#define draw_jit_header_id(_gallivm, _ptr) \ 162848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_VERTEX_VERTEX_ID, "id") 163848b8605Smrg 164b8e80941Smrg#define draw_jit_header_clip_pos(_gallivm, _ptr) \ 165b8e80941Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_VERTEX_CLIP_POS, "clip_pos") 166848b8605Smrg 167848b8605Smrg#define draw_jit_header_data(_gallivm, _ptr) \ 168848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_JIT_VERTEX_DATA, "data") 169848b8605Smrg 170848b8605Smrg 171848b8605Smrg#define draw_jit_vbuffer_stride(_gallivm, _ptr) \ 172848b8605Smrg lp_build_struct_get(_gallivm, _ptr, 0, "stride") 173848b8605Smrg 174848b8605Smrg#define draw_jit_vbuffer_offset(_gallivm, _ptr) \ 175b8e80941Smrg lp_build_struct_get(_gallivm, _ptr, 2, "buffer_offset") 176848b8605Smrg 177848b8605Smrgenum { 178848b8605Smrg DRAW_JIT_DVBUFFER_MAP = 0, 179848b8605Smrg DRAW_JIT_DVBUFFER_SIZE, 180848b8605Smrg DRAW_JIT_DVBUFFER_NUM_FIELDS /* number of fields above */ 181848b8605Smrg}; 182848b8605Smrg 183848b8605Smrg#define draw_jit_dvbuffer_map(_gallivm, _ptr) \ 184848b8605Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_DVBUFFER_MAP, "map") 185848b8605Smrg 186848b8605Smrg#define draw_jit_dvbuffer_size(_gallivm, _ptr) \ 187848b8605Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_JIT_DVBUFFER_SIZE, "size") 188848b8605Smrg 189848b8605Smrg 190848b8605Smrg/** 191848b8605Smrg * This structure is passed directly to the generated geometry shader. 192848b8605Smrg * 193848b8605Smrg * It contains the derived state. 194848b8605Smrg * 195848b8605Smrg * Changes here must be reflected in the draw_gs_jit_context_* macros. 196848b8605Smrg * Changes to the ordering should be avoided. 197848b8605Smrg * 198848b8605Smrg * Only use types with a clear size and padding here, in particular prefer the 199848b8605Smrg * stdint.h types to the basic integer types. 200848b8605Smrg */ 201848b8605Smrgstruct draw_gs_jit_context 202848b8605Smrg{ 203848b8605Smrg const float *constants[LP_MAX_TGSI_CONST_BUFFERS]; 204848b8605Smrg int num_constants[LP_MAX_TGSI_CONST_BUFFERS]; 205848b8605Smrg float (*planes) [DRAW_TOTAL_CLIP_PLANES][4]; 206b8e80941Smrg struct pipe_viewport_state *viewports; 207848b8605Smrg 208848b8605Smrg /* There two need to be exactly at DRAW_JIT_CTX_TEXTURES and 209848b8605Smrg * DRAW_JIT_CTX_SAMPLERS positions in the struct */ 210848b8605Smrg struct draw_jit_texture textures[PIPE_MAX_SHADER_SAMPLER_VIEWS]; 211848b8605Smrg struct draw_jit_sampler samplers[PIPE_MAX_SAMPLERS]; 212848b8605Smrg 213848b8605Smrg int **prim_lengths; 214848b8605Smrg int *emitted_vertices; 215848b8605Smrg int *emitted_prims; 216848b8605Smrg}; 217848b8605Smrg 218848b8605Smrgenum { 219848b8605Smrg DRAW_GS_JIT_CTX_CONSTANTS = 0, 220848b8605Smrg DRAW_GS_JIT_CTX_NUM_CONSTANTS = 1, 221848b8605Smrg DRAW_GS_JIT_CTX_PLANES = 2, 222848b8605Smrg DRAW_GS_JIT_CTX_VIEWPORT = 3, 223848b8605Smrg /* Textures and samples are reserved for DRAW_JIT_CTX_TEXTURES 224848b8605Smrg * and DRAW_JIT_CTX_SAMPLERS, because they both need 225848b8605Smrg * to be at exactly the same locations as they are in the 226848b8605Smrg * VS ctx structure for sampling to work. */ 227848b8605Smrg DRAW_GS_JIT_CTX_TEXTURES = DRAW_JIT_CTX_TEXTURES, 228848b8605Smrg DRAW_GS_JIT_CTX_SAMPLERS = DRAW_JIT_CTX_SAMPLERS, 229848b8605Smrg DRAW_GS_JIT_CTX_PRIM_LENGTHS = 6, 230848b8605Smrg DRAW_GS_JIT_CTX_EMITTED_VERTICES = 7, 231848b8605Smrg DRAW_GS_JIT_CTX_EMITTED_PRIMS = 8, 232848b8605Smrg DRAW_GS_JIT_CTX_NUM_FIELDS = 9 233848b8605Smrg}; 234848b8605Smrg 235848b8605Smrg#define draw_gs_jit_context_constants(_gallivm, _ptr) \ 236848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_CONSTANTS, "constants") 237848b8605Smrg 238848b8605Smrg#define draw_gs_jit_context_num_constants(_gallivm, _ptr) \ 239848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_NUM_CONSTANTS, "num_constants") 240848b8605Smrg 241848b8605Smrg#define draw_gs_jit_context_planes(_gallivm, _ptr) \ 242848b8605Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_PLANES, "planes") 243848b8605Smrg 244b8e80941Smrg#define draw_gs_jit_context_viewports(_gallivm, _ptr) \ 245b8e80941Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_VIEWPORT, "viewports") 246848b8605Smrg 247848b8605Smrg#define draw_gs_jit_context_textures(_gallivm, _ptr) \ 248848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_TEXTURES, "textures") 249848b8605Smrg 250848b8605Smrg#define draw_gs_jit_context_samplers(_gallivm, _ptr) \ 251848b8605Smrg lp_build_struct_get_ptr(_gallivm, _ptr, DRAW_GS_JIT_CTX_SAMPLERS, "samplers") 252848b8605Smrg 253848b8605Smrg#define draw_gs_jit_prim_lengths(_gallivm, _ptr) \ 254848b8605Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_PRIM_LENGTHS, "prim_lengths") 255848b8605Smrg 256848b8605Smrg#define draw_gs_jit_emitted_vertices(_gallivm, _ptr) \ 257848b8605Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_EMITTED_VERTICES, "emitted_vertices") 258848b8605Smrg 259848b8605Smrg#define draw_gs_jit_emitted_prims(_gallivm, _ptr) \ 260848b8605Smrg lp_build_struct_get(_gallivm, _ptr, DRAW_GS_JIT_CTX_EMITTED_PRIMS, "emitted_prims") 261848b8605Smrg 262848b8605Smrg 263848b8605Smrg 264b8e80941Smrgtypedef boolean 265848b8605Smrg(*draw_jit_vert_func)(struct draw_jit_context *context, 266848b8605Smrg struct vertex_header *io, 267848b8605Smrg const struct draw_vertex_buffer vbuffers[PIPE_MAX_ATTRIBS], 268848b8605Smrg unsigned count, 269b8e80941Smrg unsigned start_or_maxelt, 270848b8605Smrg unsigned stride, 271848b8605Smrg struct pipe_vertex_buffer *vertex_buffers, 272848b8605Smrg unsigned instance_id, 273b8e80941Smrg unsigned vertex_id_offset, 274b8e80941Smrg unsigned start_instance, 275b8e80941Smrg const unsigned *fetch_elts); 276848b8605Smrg 277848b8605Smrg 278848b8605Smrgtypedef int 279848b8605Smrg(*draw_gs_jit_func)(struct draw_gs_jit_context *context, 280848b8605Smrg float inputs[6][PIPE_MAX_SHADER_INPUTS][TGSI_NUM_CHANNELS][TGSI_NUM_CHANNELS], 281848b8605Smrg struct vertex_header *output, 282848b8605Smrg unsigned num_prims, 283848b8605Smrg unsigned instance_id, 284b8e80941Smrg int *prim_ids, 285b8e80941Smrg unsigned invocation_id); 286848b8605Smrg 287848b8605Smrgstruct draw_llvm_variant_key 288848b8605Smrg{ 289848b8605Smrg unsigned nr_vertex_elements:8; 290848b8605Smrg unsigned nr_samplers:8; 291848b8605Smrg unsigned nr_sampler_views:8; 292848b8605Smrg unsigned clamp_vertex_color:1; 293848b8605Smrg unsigned clip_xy:1; 294848b8605Smrg unsigned clip_z:1; 295848b8605Smrg unsigned clip_user:1; 296848b8605Smrg unsigned clip_halfz:1; 297848b8605Smrg unsigned bypass_viewport:1; 298848b8605Smrg unsigned need_edgeflags:1; 299848b8605Smrg unsigned has_gs:1; 300848b8605Smrg unsigned num_outputs:8; 301848b8605Smrg unsigned ucp_enable:PIPE_MAX_CLIP_PLANES; 302b8e80941Smrg /* note padding here - must use memset */ 303848b8605Smrg 304848b8605Smrg /* Variable number of vertex elements: 305848b8605Smrg */ 306848b8605Smrg struct pipe_vertex_element vertex_element[1]; 307848b8605Smrg 308848b8605Smrg /* Followed by variable number of samplers: 309848b8605Smrg */ 310848b8605Smrg/* struct draw_sampler_static_state sampler; */ 311848b8605Smrg}; 312848b8605Smrg 313848b8605Smrgstruct draw_gs_llvm_variant_key 314848b8605Smrg{ 315848b8605Smrg unsigned nr_samplers:8; 316848b8605Smrg unsigned nr_sampler_views:8; 317848b8605Smrg unsigned num_outputs:8; 318b8e80941Smrg /* note padding here - must use memset */ 319848b8605Smrg 320848b8605Smrg struct draw_sampler_static_state samplers[1]; 321848b8605Smrg}; 322848b8605Smrg 323848b8605Smrg#define DRAW_LLVM_MAX_VARIANT_KEY_SIZE \ 324848b8605Smrg (sizeof(struct draw_llvm_variant_key) + \ 325848b8605Smrg PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state) + \ 326848b8605Smrg (PIPE_MAX_ATTRIBS-1) * sizeof(struct pipe_vertex_element)) 327848b8605Smrg 328848b8605Smrg#define DRAW_GS_LLVM_MAX_VARIANT_KEY_SIZE \ 329848b8605Smrg (sizeof(struct draw_gs_llvm_variant_key) + \ 330848b8605Smrg PIPE_MAX_SHADER_SAMPLER_VIEWS * sizeof(struct draw_sampler_static_state)) 331848b8605Smrg 332848b8605Smrg 333b8e80941Smrgstatic inline size_t 334848b8605Smrgdraw_llvm_variant_key_size(unsigned nr_vertex_elements, 335848b8605Smrg unsigned nr_samplers) 336848b8605Smrg{ 337848b8605Smrg return (sizeof(struct draw_llvm_variant_key) + 338848b8605Smrg nr_samplers * sizeof(struct draw_sampler_static_state) + 339848b8605Smrg (nr_vertex_elements - 1) * sizeof(struct pipe_vertex_element)); 340848b8605Smrg} 341848b8605Smrg 342848b8605Smrg 343b8e80941Smrgstatic inline size_t 344848b8605Smrgdraw_gs_llvm_variant_key_size(unsigned nr_samplers) 345848b8605Smrg{ 346848b8605Smrg return (sizeof(struct draw_gs_llvm_variant_key) + 347848b8605Smrg (nr_samplers - 1) * sizeof(struct draw_sampler_static_state)); 348848b8605Smrg} 349848b8605Smrg 350848b8605Smrg 351b8e80941Smrgstatic inline struct draw_sampler_static_state * 352848b8605Smrgdraw_llvm_variant_key_samplers(struct draw_llvm_variant_key *key) 353848b8605Smrg{ 354848b8605Smrg return (struct draw_sampler_static_state *) 355848b8605Smrg &key->vertex_element[key->nr_vertex_elements]; 356848b8605Smrg} 357848b8605Smrg 358848b8605Smrg 359848b8605Smrgstruct draw_llvm_variant_list_item 360848b8605Smrg{ 361848b8605Smrg struct draw_llvm_variant *base; 362848b8605Smrg struct draw_llvm_variant_list_item *next, *prev; 363848b8605Smrg}; 364848b8605Smrg 365848b8605Smrgstruct draw_gs_llvm_variant_list_item 366848b8605Smrg{ 367848b8605Smrg struct draw_gs_llvm_variant *base; 368848b8605Smrg struct draw_gs_llvm_variant_list_item *next, *prev; 369848b8605Smrg}; 370848b8605Smrg 371848b8605Smrg 372848b8605Smrgstruct draw_llvm_variant 373848b8605Smrg{ 374848b8605Smrg struct gallivm_state *gallivm; 375848b8605Smrg 376848b8605Smrg /* LLVM JIT builder types */ 377848b8605Smrg LLVMTypeRef context_ptr_type; 378848b8605Smrg LLVMTypeRef buffer_ptr_type; 379848b8605Smrg LLVMTypeRef vb_ptr_type; 380848b8605Smrg LLVMTypeRef vertex_header_ptr_type; 381848b8605Smrg 382848b8605Smrg LLVMValueRef function; 383848b8605Smrg draw_jit_vert_func jit_func; 384848b8605Smrg 385848b8605Smrg struct llvm_vertex_shader *shader; 386848b8605Smrg 387848b8605Smrg struct draw_llvm *llvm; 388848b8605Smrg struct draw_llvm_variant_list_item list_item_global; 389848b8605Smrg struct draw_llvm_variant_list_item list_item_local; 390848b8605Smrg 391848b8605Smrg /* key is variable-sized, must be last */ 392848b8605Smrg struct draw_llvm_variant_key key; 393848b8605Smrg}; 394848b8605Smrg 395848b8605Smrg 396848b8605Smrgstruct draw_gs_llvm_variant 397848b8605Smrg{ 398848b8605Smrg struct gallivm_state *gallivm; 399848b8605Smrg 400848b8605Smrg /* LLVM JIT builder types */ 401848b8605Smrg LLVMTypeRef context_ptr_type; 402848b8605Smrg LLVMTypeRef vertex_header_ptr_type; 403848b8605Smrg LLVMTypeRef input_array_type; 404848b8605Smrg 405848b8605Smrg LLVMValueRef context_ptr; 406848b8605Smrg LLVMValueRef io_ptr; 407848b8605Smrg LLVMValueRef num_prims; 408848b8605Smrg LLVMValueRef function; 409848b8605Smrg draw_gs_jit_func jit_func; 410848b8605Smrg 411848b8605Smrg struct llvm_geometry_shader *shader; 412848b8605Smrg 413848b8605Smrg struct draw_llvm *llvm; 414848b8605Smrg struct draw_gs_llvm_variant_list_item list_item_global; 415848b8605Smrg struct draw_gs_llvm_variant_list_item list_item_local; 416848b8605Smrg 417848b8605Smrg /* key is variable-sized, must be last */ 418848b8605Smrg struct draw_gs_llvm_variant_key key; 419848b8605Smrg}; 420848b8605Smrg 421848b8605Smrgstruct llvm_vertex_shader { 422848b8605Smrg struct draw_vertex_shader base; 423848b8605Smrg 424848b8605Smrg unsigned variant_key_size; 425848b8605Smrg struct draw_llvm_variant_list_item variants; 426848b8605Smrg unsigned variants_created; 427848b8605Smrg unsigned variants_cached; 428848b8605Smrg}; 429848b8605Smrg 430848b8605Smrgstruct llvm_geometry_shader { 431848b8605Smrg struct draw_geometry_shader base; 432848b8605Smrg 433848b8605Smrg unsigned variant_key_size; 434848b8605Smrg struct draw_gs_llvm_variant_list_item variants; 435848b8605Smrg unsigned variants_created; 436848b8605Smrg unsigned variants_cached; 437848b8605Smrg}; 438848b8605Smrg 439848b8605Smrg 440848b8605Smrgstruct draw_llvm { 441848b8605Smrg struct draw_context *draw; 442848b8605Smrg 443b8e80941Smrg LLVMContextRef context; 444b8e80941Smrg boolean context_owned; 445b8e80941Smrg 446848b8605Smrg struct draw_jit_context jit_context; 447848b8605Smrg struct draw_gs_jit_context gs_jit_context; 448848b8605Smrg 449848b8605Smrg struct draw_llvm_variant_list_item vs_variants_list; 450848b8605Smrg int nr_variants; 451848b8605Smrg 452848b8605Smrg struct draw_gs_llvm_variant_list_item gs_variants_list; 453848b8605Smrg int nr_gs_variants; 454848b8605Smrg}; 455848b8605Smrg 456848b8605Smrg 457b8e80941Smrgstatic inline struct llvm_vertex_shader * 458848b8605Smrgllvm_vertex_shader(struct draw_vertex_shader *vs) 459848b8605Smrg{ 460848b8605Smrg return (struct llvm_vertex_shader *)vs; 461848b8605Smrg} 462848b8605Smrg 463b8e80941Smrgstatic inline struct llvm_geometry_shader * 464848b8605Smrgllvm_geometry_shader(struct draw_geometry_shader *gs) 465848b8605Smrg{ 466848b8605Smrg return (struct llvm_geometry_shader *)gs; 467848b8605Smrg} 468848b8605Smrg 469848b8605Smrg 470848b8605Smrg 471848b8605Smrg 472848b8605Smrgstruct draw_llvm * 473b8e80941Smrgdraw_llvm_create(struct draw_context *draw, LLVMContextRef llvm_context); 474848b8605Smrg 475848b8605Smrgvoid 476848b8605Smrgdraw_llvm_destroy(struct draw_llvm *llvm); 477848b8605Smrg 478848b8605Smrgstruct draw_llvm_variant * 479848b8605Smrgdraw_llvm_create_variant(struct draw_llvm *llvm, 480848b8605Smrg unsigned num_vertex_header_attribs, 481848b8605Smrg const struct draw_llvm_variant_key *key); 482848b8605Smrg 483848b8605Smrgvoid 484848b8605Smrgdraw_llvm_destroy_variant(struct draw_llvm_variant *variant); 485848b8605Smrg 486848b8605Smrgstruct draw_llvm_variant_key * 487848b8605Smrgdraw_llvm_make_variant_key(struct draw_llvm *llvm, char *store); 488848b8605Smrg 489848b8605Smrgvoid 490848b8605Smrgdraw_llvm_dump_variant_key(struct draw_llvm_variant_key *key); 491848b8605Smrg 492848b8605Smrg 493848b8605Smrgstruct draw_gs_llvm_variant * 494848b8605Smrgdraw_gs_llvm_create_variant(struct draw_llvm *llvm, 495848b8605Smrg unsigned num_vertex_header_attribs, 496848b8605Smrg const struct draw_gs_llvm_variant_key *key); 497848b8605Smrg 498848b8605Smrgvoid 499848b8605Smrgdraw_gs_llvm_destroy_variant(struct draw_gs_llvm_variant *variant); 500848b8605Smrg 501848b8605Smrgstruct draw_gs_llvm_variant_key * 502848b8605Smrgdraw_gs_llvm_make_variant_key(struct draw_llvm *llvm, char *store); 503848b8605Smrg 504848b8605Smrgvoid 505848b8605Smrgdraw_gs_llvm_dump_variant_key(struct draw_gs_llvm_variant_key *key); 506848b8605Smrg 507848b8605Smrgstruct lp_build_sampler_soa * 508b8e80941Smrgdraw_llvm_sampler_soa_create(const struct draw_sampler_static_state *static_state); 509848b8605Smrg 510848b8605Smrgvoid 511b8e80941Smrgdraw_llvm_set_sampler_state(struct draw_context *draw, 512b8e80941Smrg enum pipe_shader_type shader_stage); 513848b8605Smrg 514848b8605Smrgvoid 515848b8605Smrgdraw_llvm_set_mapped_texture(struct draw_context *draw, 516b8e80941Smrg enum pipe_shader_type shader_stage, 517848b8605Smrg unsigned sview_idx, 518848b8605Smrg uint32_t width, uint32_t height, uint32_t depth, 519848b8605Smrg uint32_t first_level, uint32_t last_level, 520848b8605Smrg const void *base_ptr, 521848b8605Smrg uint32_t row_stride[PIPE_MAX_TEXTURE_LEVELS], 522848b8605Smrg uint32_t img_stride[PIPE_MAX_TEXTURE_LEVELS], 523848b8605Smrg uint32_t mip_offsets[PIPE_MAX_TEXTURE_LEVELS]); 524848b8605Smrg 525848b8605Smrg#endif 526