1bf215546Sopenharmony_ci/************************************************************************** 2bf215546Sopenharmony_ci * 3bf215546Sopenharmony_ci * Copyright 2007-2008 VMware, Inc. 4bf215546Sopenharmony_ci * All Rights Reserved. 5bf215546Sopenharmony_ci * Copyright 2009-2010 VMware, Inc. All rights Reserved. 6bf215546Sopenharmony_ci * 7bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a 8bf215546Sopenharmony_ci * copy of this software and associated documentation files (the 9bf215546Sopenharmony_ci * "Software"), to deal in the Software without restriction, including 10bf215546Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish, 11bf215546Sopenharmony_ci * distribute, sub license, and/or sell copies of the Software, and to 12bf215546Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to 13bf215546Sopenharmony_ci * the following conditions: 14bf215546Sopenharmony_ci * 15bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the 16bf215546Sopenharmony_ci * next paragraph) shall be included in all copies or substantial portions 17bf215546Sopenharmony_ci * of the Software. 18bf215546Sopenharmony_ci * 19bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 20bf215546Sopenharmony_ci * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21bf215546Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. 22bf215546Sopenharmony_ci * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR 23bf215546Sopenharmony_ci * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, 24bf215546Sopenharmony_ci * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE 25bf215546Sopenharmony_ci * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26bf215546Sopenharmony_ci * 27bf215546Sopenharmony_ci **************************************************************************/ 28bf215546Sopenharmony_ci 29bf215546Sopenharmony_ci#ifndef TGSI_EXEC_H 30bf215546Sopenharmony_ci#define TGSI_EXEC_H 31bf215546Sopenharmony_ci 32bf215546Sopenharmony_ci#include "pipe/p_compiler.h" 33bf215546Sopenharmony_ci#include "pipe/p_state.h" 34bf215546Sopenharmony_ci#include "pipe/p_shader_tokens.h" 35bf215546Sopenharmony_ci 36bf215546Sopenharmony_ci#if defined __cplusplus 37bf215546Sopenharmony_ciextern "C" { 38bf215546Sopenharmony_ci#endif 39bf215546Sopenharmony_ci 40bf215546Sopenharmony_ci#define TGSI_CHAN_X 0 41bf215546Sopenharmony_ci#define TGSI_CHAN_Y 1 42bf215546Sopenharmony_ci#define TGSI_CHAN_Z 2 43bf215546Sopenharmony_ci#define TGSI_CHAN_W 3 44bf215546Sopenharmony_ci 45bf215546Sopenharmony_ci#define TGSI_NUM_CHANNELS 4 /* R,G,B,A */ 46bf215546Sopenharmony_ci#define TGSI_QUAD_SIZE 4 /* 4 pixel/quad */ 47bf215546Sopenharmony_ci 48bf215546Sopenharmony_ci#define TGSI_FOR_EACH_CHANNEL( CHAN )\ 49bf215546Sopenharmony_ci for (CHAN = 0; CHAN < TGSI_NUM_CHANNELS; CHAN++) 50bf215546Sopenharmony_ci 51bf215546Sopenharmony_ci#define TGSI_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\ 52bf215546Sopenharmony_ci ((INST)->Dst[0].Register.WriteMask & (1 << (CHAN))) 53bf215546Sopenharmony_ci 54bf215546Sopenharmony_ci#define TGSI_IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN )\ 55bf215546Sopenharmony_ci if (TGSI_IS_DST0_CHANNEL_ENABLED( INST, CHAN )) 56bf215546Sopenharmony_ci 57bf215546Sopenharmony_ci#define TGSI_FOR_EACH_DST0_ENABLED_CHANNEL( INST, CHAN )\ 58bf215546Sopenharmony_ci TGSI_FOR_EACH_CHANNEL( CHAN )\ 59bf215546Sopenharmony_ci TGSI_IF_IS_DST0_CHANNEL_ENABLED( INST, CHAN ) 60bf215546Sopenharmony_ci 61bf215546Sopenharmony_ci#define TGSI_IS_DST1_CHANNEL_ENABLED( INST, CHAN )\ 62bf215546Sopenharmony_ci ((INST)->Dst[1].Register.WriteMask & (1 << (CHAN))) 63bf215546Sopenharmony_ci 64bf215546Sopenharmony_ci#define TGSI_IF_IS_DST1_CHANNEL_ENABLED( INST, CHAN )\ 65bf215546Sopenharmony_ci if (TGSI_IS_DST1_CHANNEL_ENABLED( INST, CHAN )) 66bf215546Sopenharmony_ci 67bf215546Sopenharmony_ci#define TGSI_FOR_EACH_DST1_ENABLED_CHANNEL( INST, CHAN )\ 68bf215546Sopenharmony_ci TGSI_FOR_EACH_CHANNEL( CHAN )\ 69bf215546Sopenharmony_ci TGSI_IF_IS_DST1_CHANNEL_ENABLED( INST, CHAN ) 70bf215546Sopenharmony_ci 71bf215546Sopenharmony_ci/** 72bf215546Sopenharmony_ci * Registers may be treated as float, signed int or unsigned int. 73bf215546Sopenharmony_ci */ 74bf215546Sopenharmony_ciunion tgsi_exec_channel 75bf215546Sopenharmony_ci{ 76bf215546Sopenharmony_ci float f[TGSI_QUAD_SIZE]; 77bf215546Sopenharmony_ci int i[TGSI_QUAD_SIZE]; 78bf215546Sopenharmony_ci unsigned u[TGSI_QUAD_SIZE]; 79bf215546Sopenharmony_ci} ALIGN16; 80bf215546Sopenharmony_ci 81bf215546Sopenharmony_ci/** 82bf215546Sopenharmony_ci * A vector[RGBA] of channels[4 pixels] 83bf215546Sopenharmony_ci */ 84bf215546Sopenharmony_cistruct ALIGN16 tgsi_exec_vector 85bf215546Sopenharmony_ci{ 86bf215546Sopenharmony_ci union tgsi_exec_channel xyzw[TGSI_NUM_CHANNELS]; 87bf215546Sopenharmony_ci}; 88bf215546Sopenharmony_ci 89bf215546Sopenharmony_ci/** 90bf215546Sopenharmony_ci * For fragment programs, information for computing fragment input 91bf215546Sopenharmony_ci * values from plane equation of the triangle/line. 92bf215546Sopenharmony_ci */ 93bf215546Sopenharmony_cistruct tgsi_interp_coef 94bf215546Sopenharmony_ci{ 95bf215546Sopenharmony_ci float a0[TGSI_NUM_CHANNELS]; /* in an xyzw layout */ 96bf215546Sopenharmony_ci float dadx[TGSI_NUM_CHANNELS]; 97bf215546Sopenharmony_ci float dady[TGSI_NUM_CHANNELS]; 98bf215546Sopenharmony_ci}; 99bf215546Sopenharmony_ci 100bf215546Sopenharmony_cienum tgsi_sampler_control 101bf215546Sopenharmony_ci{ 102bf215546Sopenharmony_ci TGSI_SAMPLER_LOD_NONE, 103bf215546Sopenharmony_ci TGSI_SAMPLER_LOD_BIAS, 104bf215546Sopenharmony_ci TGSI_SAMPLER_LOD_EXPLICIT, 105bf215546Sopenharmony_ci TGSI_SAMPLER_LOD_ZERO, 106bf215546Sopenharmony_ci TGSI_SAMPLER_DERIVS_EXPLICIT, 107bf215546Sopenharmony_ci TGSI_SAMPLER_GATHER, 108bf215546Sopenharmony_ci}; 109bf215546Sopenharmony_ci 110bf215546Sopenharmony_cistruct tgsi_image_params { 111bf215546Sopenharmony_ci unsigned unit; 112bf215546Sopenharmony_ci unsigned tgsi_tex_instr; 113bf215546Sopenharmony_ci enum pipe_format format; 114bf215546Sopenharmony_ci unsigned execmask; 115bf215546Sopenharmony_ci}; 116bf215546Sopenharmony_ci 117bf215546Sopenharmony_cistruct tgsi_image { 118bf215546Sopenharmony_ci /* image interfaces */ 119bf215546Sopenharmony_ci void (*load)(const struct tgsi_image *image, 120bf215546Sopenharmony_ci const struct tgsi_image_params *params, 121bf215546Sopenharmony_ci const int s[TGSI_QUAD_SIZE], 122bf215546Sopenharmony_ci const int t[TGSI_QUAD_SIZE], 123bf215546Sopenharmony_ci const int r[TGSI_QUAD_SIZE], 124bf215546Sopenharmony_ci const int sample[TGSI_QUAD_SIZE], 125bf215546Sopenharmony_ci float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]); 126bf215546Sopenharmony_ci 127bf215546Sopenharmony_ci void (*store)(const struct tgsi_image *image, 128bf215546Sopenharmony_ci const struct tgsi_image_params *params, 129bf215546Sopenharmony_ci const int s[TGSI_QUAD_SIZE], 130bf215546Sopenharmony_ci const int t[TGSI_QUAD_SIZE], 131bf215546Sopenharmony_ci const int r[TGSI_QUAD_SIZE], 132bf215546Sopenharmony_ci const int sample[TGSI_QUAD_SIZE], 133bf215546Sopenharmony_ci float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]); 134bf215546Sopenharmony_ci 135bf215546Sopenharmony_ci void (*op)(const struct tgsi_image *image, 136bf215546Sopenharmony_ci const struct tgsi_image_params *params, 137bf215546Sopenharmony_ci enum tgsi_opcode opcode, 138bf215546Sopenharmony_ci const int s[TGSI_QUAD_SIZE], 139bf215546Sopenharmony_ci const int t[TGSI_QUAD_SIZE], 140bf215546Sopenharmony_ci const int r[TGSI_QUAD_SIZE], 141bf215546Sopenharmony_ci const int sample[TGSI_QUAD_SIZE], 142bf215546Sopenharmony_ci float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE], 143bf215546Sopenharmony_ci float rgba2[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]); 144bf215546Sopenharmony_ci 145bf215546Sopenharmony_ci void (*get_dims)(const struct tgsi_image *image, 146bf215546Sopenharmony_ci const struct tgsi_image_params *params, 147bf215546Sopenharmony_ci int dims[4]); 148bf215546Sopenharmony_ci}; 149bf215546Sopenharmony_ci 150bf215546Sopenharmony_cistruct tgsi_buffer_params { 151bf215546Sopenharmony_ci unsigned unit; 152bf215546Sopenharmony_ci unsigned execmask; 153bf215546Sopenharmony_ci unsigned writemask; 154bf215546Sopenharmony_ci}; 155bf215546Sopenharmony_ci 156bf215546Sopenharmony_ci/* SSBO interfaces */ 157bf215546Sopenharmony_cistruct tgsi_buffer { 158bf215546Sopenharmony_ci void *(*lookup)(const struct tgsi_buffer *buffer, 159bf215546Sopenharmony_ci uint32_t unit, uint32_t *size); 160bf215546Sopenharmony_ci}; 161bf215546Sopenharmony_ci 162bf215546Sopenharmony_ci/** 163bf215546Sopenharmony_ci * Information for sampling textures, which must be implemented 164bf215546Sopenharmony_ci * by code outside the TGSI executor. 165bf215546Sopenharmony_ci */ 166bf215546Sopenharmony_cistruct tgsi_sampler 167bf215546Sopenharmony_ci{ 168bf215546Sopenharmony_ci /** Get samples for four fragments in a quad */ 169bf215546Sopenharmony_ci /* this interface contains 5 sets of channels that vary 170bf215546Sopenharmony_ci * depending on the sampler. 171bf215546Sopenharmony_ci * s - the first texture coordinate for sampling. 172bf215546Sopenharmony_ci * t - the second texture coordinate for sampling - unused for 1D, 173bf215546Sopenharmony_ci layer for 1D arrays. 174bf215546Sopenharmony_ci * r - the third coordinate for sampling for 3D, cube, cube arrays, 175bf215546Sopenharmony_ci * layer for 2D arrays. Compare value for 1D/2D shadows. 176bf215546Sopenharmony_ci * c0 - Compare value for shadow cube and shadow 2d arrays, 177bf215546Sopenharmony_ci * layer for cube arrays. 178bf215546Sopenharmony_ci * derivs - explicit derivatives. 179bf215546Sopenharmony_ci * offset - texel offsets 180bf215546Sopenharmony_ci * lod - lod value, except for shadow cube arrays (compare value there). 181bf215546Sopenharmony_ci */ 182bf215546Sopenharmony_ci void (*get_samples)(struct tgsi_sampler *sampler, 183bf215546Sopenharmony_ci const unsigned sview_index, 184bf215546Sopenharmony_ci const unsigned sampler_index, 185bf215546Sopenharmony_ci const float s[TGSI_QUAD_SIZE], 186bf215546Sopenharmony_ci const float t[TGSI_QUAD_SIZE], 187bf215546Sopenharmony_ci const float r[TGSI_QUAD_SIZE], 188bf215546Sopenharmony_ci const float c0[TGSI_QUAD_SIZE], 189bf215546Sopenharmony_ci const float c1[TGSI_QUAD_SIZE], 190bf215546Sopenharmony_ci float derivs[3][2][TGSI_QUAD_SIZE], 191bf215546Sopenharmony_ci const int8_t offset[3], 192bf215546Sopenharmony_ci enum tgsi_sampler_control control, 193bf215546Sopenharmony_ci float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]); 194bf215546Sopenharmony_ci void (*get_dims)(struct tgsi_sampler *sampler, 195bf215546Sopenharmony_ci const unsigned sview_index, 196bf215546Sopenharmony_ci int level, int dims[4]); 197bf215546Sopenharmony_ci void (*get_texel)(struct tgsi_sampler *sampler, 198bf215546Sopenharmony_ci const unsigned sview_index, 199bf215546Sopenharmony_ci const int i[TGSI_QUAD_SIZE], 200bf215546Sopenharmony_ci const int j[TGSI_QUAD_SIZE], const int k[TGSI_QUAD_SIZE], 201bf215546Sopenharmony_ci const int lod[TGSI_QUAD_SIZE], const int8_t offset[3], 202bf215546Sopenharmony_ci float rgba[TGSI_NUM_CHANNELS][TGSI_QUAD_SIZE]); 203bf215546Sopenharmony_ci void (*query_lod)(const struct tgsi_sampler *tgsi_sampler, 204bf215546Sopenharmony_ci const unsigned sview_index, 205bf215546Sopenharmony_ci const unsigned sampler_index, 206bf215546Sopenharmony_ci const float s[TGSI_QUAD_SIZE], 207bf215546Sopenharmony_ci const float t[TGSI_QUAD_SIZE], 208bf215546Sopenharmony_ci const float p[TGSI_QUAD_SIZE], 209bf215546Sopenharmony_ci const float c0[TGSI_QUAD_SIZE], 210bf215546Sopenharmony_ci const enum tgsi_sampler_control control, 211bf215546Sopenharmony_ci float mipmap[TGSI_QUAD_SIZE], 212bf215546Sopenharmony_ci float lod[TGSI_QUAD_SIZE]); 213bf215546Sopenharmony_ci}; 214bf215546Sopenharmony_ci 215bf215546Sopenharmony_ci#define TGSI_EXEC_NUM_TEMPS 4096 216bf215546Sopenharmony_ci 217bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_NESTING 32 218bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_COND_NESTING TGSI_EXEC_MAX_NESTING 219bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_LOOP_NESTING TGSI_EXEC_MAX_NESTING 220bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_SWITCH_NESTING TGSI_EXEC_MAX_NESTING 221bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_CALL_NESTING TGSI_EXEC_MAX_NESTING 222bf215546Sopenharmony_ci 223bf215546Sopenharmony_ci/* The maximum number of input attributes per vertex. For 2D 224bf215546Sopenharmony_ci * input register files, this is the stride between two 1D 225bf215546Sopenharmony_ci * arrays. 226bf215546Sopenharmony_ci */ 227bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_INPUT_ATTRIBS 32 228bf215546Sopenharmony_ci 229bf215546Sopenharmony_ci/* The maximum number of bytes per constant buffer. 230bf215546Sopenharmony_ci */ 231bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_CONST_BUFFER_SIZE (4096 * sizeof(float[4])) 232bf215546Sopenharmony_ci 233bf215546Sopenharmony_ci/* The maximum number of vertices per primitive */ 234bf215546Sopenharmony_ci#define TGSI_MAX_PRIM_VERTICES 6 235bf215546Sopenharmony_ci 236bf215546Sopenharmony_ci/* The maximum number of primitives to be generated */ 237bf215546Sopenharmony_ci#define TGSI_MAX_PRIMITIVES 64 238bf215546Sopenharmony_ci 239bf215546Sopenharmony_ci/* The maximum total number of vertices */ 240bf215546Sopenharmony_ci#define TGSI_MAX_TOTAL_VERTICES (TGSI_MAX_PRIM_VERTICES * TGSI_MAX_PRIMITIVES * PIPE_MAX_ATTRIBS) 241bf215546Sopenharmony_ci 242bf215546Sopenharmony_ci#define TGSI_MAX_MISC_INPUTS 8 243bf215546Sopenharmony_ci 244bf215546Sopenharmony_ci#define TGSI_MAX_VERTEX_STREAMS 4 245bf215546Sopenharmony_ci 246bf215546Sopenharmony_ci/** function call/activation record */ 247bf215546Sopenharmony_cistruct tgsi_call_record 248bf215546Sopenharmony_ci{ 249bf215546Sopenharmony_ci uint CondStackTop; 250bf215546Sopenharmony_ci uint LoopStackTop; 251bf215546Sopenharmony_ci uint ContStackTop; 252bf215546Sopenharmony_ci int SwitchStackTop; 253bf215546Sopenharmony_ci int BreakStackTop; 254bf215546Sopenharmony_ci uint ReturnAddr; 255bf215546Sopenharmony_ci}; 256bf215546Sopenharmony_ci 257bf215546Sopenharmony_ci 258bf215546Sopenharmony_ci/* Switch-case block state. */ 259bf215546Sopenharmony_cistruct tgsi_switch_record { 260bf215546Sopenharmony_ci uint mask; /**< execution mask */ 261bf215546Sopenharmony_ci union tgsi_exec_channel selector; /**< a value case statements are compared to */ 262bf215546Sopenharmony_ci uint defaultMask; /**< non-execute mask for default case */ 263bf215546Sopenharmony_ci}; 264bf215546Sopenharmony_ci 265bf215546Sopenharmony_ci 266bf215546Sopenharmony_cienum tgsi_break_type { 267bf215546Sopenharmony_ci TGSI_EXEC_BREAK_INSIDE_LOOP, 268bf215546Sopenharmony_ci TGSI_EXEC_BREAK_INSIDE_SWITCH 269bf215546Sopenharmony_ci}; 270bf215546Sopenharmony_ci 271bf215546Sopenharmony_ci 272bf215546Sopenharmony_ci#define TGSI_EXEC_MAX_BREAK_STACK (TGSI_EXEC_MAX_LOOP_NESTING + TGSI_EXEC_MAX_SWITCH_NESTING) 273bf215546Sopenharmony_ci 274bf215546Sopenharmony_citypedef float float4[4]; 275bf215546Sopenharmony_ci 276bf215546Sopenharmony_cistruct tgsi_exec_machine; 277bf215546Sopenharmony_ci 278bf215546Sopenharmony_citypedef void (* apply_sample_offset_func)( 279bf215546Sopenharmony_ci const struct tgsi_exec_machine *mach, 280bf215546Sopenharmony_ci unsigned attrib, 281bf215546Sopenharmony_ci unsigned chan, 282bf215546Sopenharmony_ci float ofs_x, 283bf215546Sopenharmony_ci float ofs_y, 284bf215546Sopenharmony_ci union tgsi_exec_channel *out_chan); 285bf215546Sopenharmony_ci 286bf215546Sopenharmony_ci/** 287bf215546Sopenharmony_ci * Run-time virtual machine state for executing TGSI shader. 288bf215546Sopenharmony_ci */ 289bf215546Sopenharmony_cistruct ALIGN16 tgsi_exec_machine 290bf215546Sopenharmony_ci{ 291bf215546Sopenharmony_ci /* Total = program temporaries + internal temporaries 292bf215546Sopenharmony_ci */ 293bf215546Sopenharmony_ci struct tgsi_exec_vector Temps[TGSI_EXEC_NUM_TEMPS]; 294bf215546Sopenharmony_ci 295bf215546Sopenharmony_ci unsigned ImmsReserved; 296bf215546Sopenharmony_ci float4 *Imms; 297bf215546Sopenharmony_ci 298bf215546Sopenharmony_ci struct tgsi_exec_vector *Inputs; 299bf215546Sopenharmony_ci struct tgsi_exec_vector *Outputs; 300bf215546Sopenharmony_ci apply_sample_offset_func *InputSampleOffsetApply; 301bf215546Sopenharmony_ci 302bf215546Sopenharmony_ci /* System values */ 303bf215546Sopenharmony_ci unsigned SysSemanticToIndex[TGSI_SEMANTIC_COUNT]; 304bf215546Sopenharmony_ci struct tgsi_exec_vector SystemValue[TGSI_MAX_MISC_INPUTS]; 305bf215546Sopenharmony_ci 306bf215546Sopenharmony_ci struct tgsi_exec_vector Addrs[3]; 307bf215546Sopenharmony_ci 308bf215546Sopenharmony_ci struct tgsi_sampler *Sampler; 309bf215546Sopenharmony_ci 310bf215546Sopenharmony_ci struct tgsi_image *Image; 311bf215546Sopenharmony_ci struct tgsi_buffer *Buffer; 312bf215546Sopenharmony_ci unsigned ImmLimit; 313bf215546Sopenharmony_ci 314bf215546Sopenharmony_ci const void *Consts[PIPE_MAX_CONSTANT_BUFFERS]; 315bf215546Sopenharmony_ci unsigned ConstsSize[PIPE_MAX_CONSTANT_BUFFERS]; 316bf215546Sopenharmony_ci 317bf215546Sopenharmony_ci const struct tgsi_token *Tokens; /**< Declarations, instructions */ 318bf215546Sopenharmony_ci enum pipe_shader_type ShaderType; /**< PIPE_SHADER_x */ 319bf215546Sopenharmony_ci 320bf215546Sopenharmony_ci /* GEOMETRY processor only. */ 321bf215546Sopenharmony_ci /* Number of vertices emitted per emitted primitive. */ 322bf215546Sopenharmony_ci unsigned *Primitives[TGSI_MAX_VERTEX_STREAMS]; 323bf215546Sopenharmony_ci /* Offsets in ->Outputs of the primitives' vertex output data */ 324bf215546Sopenharmony_ci unsigned *PrimitiveOffsets[TGSI_MAX_VERTEX_STREAMS]; 325bf215546Sopenharmony_ci unsigned NumOutputs; 326bf215546Sopenharmony_ci unsigned MaxOutputVertices; 327bf215546Sopenharmony_ci /* Offset in ->Outputs for the current vertex to be emitted. */ 328bf215546Sopenharmony_ci unsigned OutputVertexOffset; 329bf215546Sopenharmony_ci /* Number of primitives emitted. */ 330bf215546Sopenharmony_ci unsigned OutputPrimCount[TGSI_MAX_VERTEX_STREAMS]; 331bf215546Sopenharmony_ci 332bf215546Sopenharmony_ci /* FRAGMENT processor only. */ 333bf215546Sopenharmony_ci const struct tgsi_interp_coef *InterpCoefs; 334bf215546Sopenharmony_ci struct tgsi_exec_vector QuadPos; 335bf215546Sopenharmony_ci float Face; /**< +1 if front facing, -1 if back facing */ 336bf215546Sopenharmony_ci bool flatshade_color; 337bf215546Sopenharmony_ci 338bf215546Sopenharmony_ci /* Compute Only */ 339bf215546Sopenharmony_ci void *LocalMem; 340bf215546Sopenharmony_ci unsigned LocalMemSize; 341bf215546Sopenharmony_ci 342bf215546Sopenharmony_ci /* See GLSL 4.50 specification for definition of helper invocations */ 343bf215546Sopenharmony_ci uint NonHelperMask; /**< non-helpers */ 344bf215546Sopenharmony_ci /* Conditional execution masks */ 345bf215546Sopenharmony_ci uint CondMask; /**< For IF/ELSE/ENDIF */ 346bf215546Sopenharmony_ci uint LoopMask; /**< For BGNLOOP/ENDLOOP */ 347bf215546Sopenharmony_ci uint ContMask; /**< For loop CONT statements */ 348bf215546Sopenharmony_ci uint FuncMask; /**< For function calls */ 349bf215546Sopenharmony_ci uint ExecMask; /**< = CondMask & LoopMask */ 350bf215546Sopenharmony_ci uint KillMask; /**< Mask of channels killed in the current shader execution */ 351bf215546Sopenharmony_ci 352bf215546Sopenharmony_ci /* Current switch-case state. */ 353bf215546Sopenharmony_ci struct tgsi_switch_record Switch; 354bf215546Sopenharmony_ci 355bf215546Sopenharmony_ci /* Current break type. */ 356bf215546Sopenharmony_ci enum tgsi_break_type BreakType; 357bf215546Sopenharmony_ci 358bf215546Sopenharmony_ci /** Condition mask stack (for nested conditionals) */ 359bf215546Sopenharmony_ci uint CondStack[TGSI_EXEC_MAX_COND_NESTING]; 360bf215546Sopenharmony_ci int CondStackTop; 361bf215546Sopenharmony_ci 362bf215546Sopenharmony_ci /** Loop mask stack (for nested loops) */ 363bf215546Sopenharmony_ci uint LoopStack[TGSI_EXEC_MAX_LOOP_NESTING]; 364bf215546Sopenharmony_ci int LoopStackTop; 365bf215546Sopenharmony_ci 366bf215546Sopenharmony_ci /** Loop label stack */ 367bf215546Sopenharmony_ci uint LoopLabelStack[TGSI_EXEC_MAX_LOOP_NESTING]; 368bf215546Sopenharmony_ci int LoopLabelStackTop; 369bf215546Sopenharmony_ci 370bf215546Sopenharmony_ci /** Loop continue mask stack (see comments in tgsi_exec.c) */ 371bf215546Sopenharmony_ci uint ContStack[TGSI_EXEC_MAX_LOOP_NESTING]; 372bf215546Sopenharmony_ci int ContStackTop; 373bf215546Sopenharmony_ci 374bf215546Sopenharmony_ci /** Switch case stack */ 375bf215546Sopenharmony_ci struct tgsi_switch_record SwitchStack[TGSI_EXEC_MAX_SWITCH_NESTING]; 376bf215546Sopenharmony_ci int SwitchStackTop; 377bf215546Sopenharmony_ci 378bf215546Sopenharmony_ci enum tgsi_break_type BreakStack[TGSI_EXEC_MAX_BREAK_STACK]; 379bf215546Sopenharmony_ci int BreakStackTop; 380bf215546Sopenharmony_ci 381bf215546Sopenharmony_ci /** Function execution mask stack (for executing subroutine code) */ 382bf215546Sopenharmony_ci uint FuncStack[TGSI_EXEC_MAX_CALL_NESTING]; 383bf215546Sopenharmony_ci int FuncStackTop; 384bf215546Sopenharmony_ci 385bf215546Sopenharmony_ci /** Function call stack for saving/restoring the program counter */ 386bf215546Sopenharmony_ci struct tgsi_call_record CallStack[TGSI_EXEC_MAX_CALL_NESTING]; 387bf215546Sopenharmony_ci int CallStackTop; 388bf215546Sopenharmony_ci 389bf215546Sopenharmony_ci struct tgsi_full_instruction *Instructions; 390bf215546Sopenharmony_ci uint NumInstructions; 391bf215546Sopenharmony_ci 392bf215546Sopenharmony_ci struct tgsi_full_declaration *Declarations; 393bf215546Sopenharmony_ci uint NumDeclarations; 394bf215546Sopenharmony_ci 395bf215546Sopenharmony_ci struct tgsi_declaration_sampler_view 396bf215546Sopenharmony_ci SamplerViews[PIPE_MAX_SHADER_SAMPLER_VIEWS]; 397bf215546Sopenharmony_ci 398bf215546Sopenharmony_ci boolean UsedGeometryShader; 399bf215546Sopenharmony_ci 400bf215546Sopenharmony_ci int pc; 401bf215546Sopenharmony_ci}; 402bf215546Sopenharmony_ci 403bf215546Sopenharmony_cistruct tgsi_exec_machine * 404bf215546Sopenharmony_citgsi_exec_machine_create(enum pipe_shader_type shader_type); 405bf215546Sopenharmony_ci 406bf215546Sopenharmony_civoid 407bf215546Sopenharmony_citgsi_exec_machine_destroy(struct tgsi_exec_machine *mach); 408bf215546Sopenharmony_ci 409bf215546Sopenharmony_ci 410bf215546Sopenharmony_civoid 411bf215546Sopenharmony_citgsi_exec_machine_bind_shader( 412bf215546Sopenharmony_ci struct tgsi_exec_machine *mach, 413bf215546Sopenharmony_ci const struct tgsi_token *tokens, 414bf215546Sopenharmony_ci struct tgsi_sampler *sampler, 415bf215546Sopenharmony_ci struct tgsi_image *image, 416bf215546Sopenharmony_ci struct tgsi_buffer *buffer); 417bf215546Sopenharmony_ci 418bf215546Sopenharmony_ciuint 419bf215546Sopenharmony_citgsi_exec_machine_run( 420bf215546Sopenharmony_ci struct tgsi_exec_machine *mach, int start_pc ); 421bf215546Sopenharmony_ci 422bf215546Sopenharmony_ci 423bf215546Sopenharmony_civoid 424bf215546Sopenharmony_citgsi_exec_machine_free_data(struct tgsi_exec_machine *mach); 425bf215546Sopenharmony_ci 426bf215546Sopenharmony_ci 427bf215546Sopenharmony_ciextern void 428bf215546Sopenharmony_citgsi_exec_set_constant_buffers(struct tgsi_exec_machine *mach, 429bf215546Sopenharmony_ci unsigned num_bufs, 430bf215546Sopenharmony_ci const void **bufs, 431bf215546Sopenharmony_ci const unsigned *buf_sizes); 432bf215546Sopenharmony_ci 433bf215546Sopenharmony_ci 434bf215546Sopenharmony_cistatic inline int 435bf215546Sopenharmony_citgsi_exec_get_shader_param(enum pipe_shader_cap param) 436bf215546Sopenharmony_ci{ 437bf215546Sopenharmony_ci switch(param) { 438bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INSTRUCTIONS: 439bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_ALU_INSTRUCTIONS: 440bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INSTRUCTIONS: 441bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEX_INDIRECTIONS: 442bf215546Sopenharmony_ci return INT_MAX; 443bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONTROL_FLOW_DEPTH: 444bf215546Sopenharmony_ci return TGSI_EXEC_MAX_NESTING; 445bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_INPUTS: 446bf215546Sopenharmony_ci return TGSI_EXEC_MAX_INPUT_ATTRIBS; 447bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_OUTPUTS: 448bf215546Sopenharmony_ci return 32; 449bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFER0_SIZE: 450bf215546Sopenharmony_ci return TGSI_EXEC_MAX_CONST_BUFFER_SIZE; 451bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_CONST_BUFFERS: 452bf215546Sopenharmony_ci return PIPE_MAX_CONSTANT_BUFFERS; 453bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEMPS: 454bf215546Sopenharmony_ci return TGSI_EXEC_NUM_TEMPS; 455bf215546Sopenharmony_ci case PIPE_SHADER_CAP_CONT_SUPPORTED: 456bf215546Sopenharmony_ci return 1; 457bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: 458bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_OUTPUT_ADDR: 459bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_TEMP_ADDR: 460bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INDIRECT_CONST_ADDR: 461bf215546Sopenharmony_ci return 1; 462bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUBROUTINES: 463bf215546Sopenharmony_ci return 1; 464bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INTEGERS: 465bf215546Sopenharmony_ci return 1; 466bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT64_ATOMICS: 467bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16: 468bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_DERIVATIVES: 469bf215546Sopenharmony_ci case PIPE_SHADER_CAP_FP16_CONST_BUFFERS: 470bf215546Sopenharmony_ci case PIPE_SHADER_CAP_INT16: 471bf215546Sopenharmony_ci case PIPE_SHADER_CAP_GLSL_16BIT_CONSTS: 472bf215546Sopenharmony_ci return 0; 473bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_TEXTURE_SAMPLERS: 474bf215546Sopenharmony_ci return PIPE_MAX_SAMPLERS; 475bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SAMPLER_VIEWS: 476bf215546Sopenharmony_ci return PIPE_MAX_SHADER_SAMPLER_VIEWS; 477bf215546Sopenharmony_ci case PIPE_SHADER_CAP_PREFERRED_IR: 478bf215546Sopenharmony_ci return PIPE_SHADER_IR_TGSI; 479bf215546Sopenharmony_ci case PIPE_SHADER_CAP_SUPPORTED_IRS: 480bf215546Sopenharmony_ci return 1 << PIPE_SHADER_IR_TGSI; 481bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_SQRT_SUPPORTED: 482bf215546Sopenharmony_ci return 1; 483bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DFRACEXP_DLDEXP_SUPPORTED: 484bf215546Sopenharmony_ci case PIPE_SHADER_CAP_LDEXP_SUPPORTED: 485bf215546Sopenharmony_ci case PIPE_SHADER_CAP_TGSI_ANY_INOUT_DECL_RANGE: 486bf215546Sopenharmony_ci return 1; 487bf215546Sopenharmony_ci case PIPE_SHADER_CAP_DROUND_SUPPORTED: 488bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTERS: 489bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_HW_ATOMIC_COUNTER_BUFFERS: 490bf215546Sopenharmony_ci return 0; 491bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS: 492bf215546Sopenharmony_ci return PIPE_MAX_SHADER_BUFFERS; 493bf215546Sopenharmony_ci case PIPE_SHADER_CAP_MAX_SHADER_IMAGES: 494bf215546Sopenharmony_ci return PIPE_MAX_SHADER_IMAGES; 495bf215546Sopenharmony_ci } 496bf215546Sopenharmony_ci /* if we get here, we missed a shader cap above (and should have seen 497bf215546Sopenharmony_ci * a compiler warning.) 498bf215546Sopenharmony_ci */ 499bf215546Sopenharmony_ci return 0; 500bf215546Sopenharmony_ci} 501bf215546Sopenharmony_ci 502bf215546Sopenharmony_ci#if defined __cplusplus 503bf215546Sopenharmony_ci} /* extern "C" */ 504bf215546Sopenharmony_ci#endif 505bf215546Sopenharmony_ci 506bf215546Sopenharmony_ci#endif /* TGSI_EXEC_H */ 507