/* * Mesa 3-D graphics library * * Copyright (C) 1999-2008 Brian Paul All Rights Reserved. * Copyright (C) 2009 VMware, Inc. 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 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. */ #ifndef SHADER_ENUMS_H #define SHADER_ENUMS_H #ifndef __OPENCL_VERSION__ #include #include "util/macros.h" #include "util/u_debug.h" #else #define ENUM_PACKED #define BITFIELD_BIT(b) (1u << (b)) #define debug_printf(x, ...) #endif /* Project-wide (GL and Vulkan) maximum. */ #define MAX_DRAW_BUFFERS 8 #ifdef __cplusplus extern "C" { #endif /** * Shader stages. * * The order must match how shaders are ordered in the pipeline. * The GLSL linker assumes that if i is the maximum number of * invocations in a sub-group. The maximum * supported in this extension is 64." * * The spec defines this as a uniform. However, it's highly unlikely that * implementations actually treat it as a uniform (which is loaded from a * constant buffer). Most likely, this is an implementation-wide constant, * or perhaps something that depends on the shader stage. */ SYSTEM_VALUE_SUBGROUP_SIZE, /** * From the GL_ARB_shader_ballot spec: * * "The variable holds the index of the * invocation within sub-group. This variable is in the range 0 to * -1, where is the total * number of invocations in a sub-group." */ SYSTEM_VALUE_SUBGROUP_INVOCATION, /** * From the GL_ARB_shader_ballot spec: * * "The variables provide a bitmask for all * invocations, with one bit per invocation starting with the least * significant bit, according to the following table, * * variable equation for bit values * -------------------- ------------------------------------ * gl_SubGroupEqMaskARB bit index == gl_SubGroupInvocationARB * gl_SubGroupGeMaskARB bit index >= gl_SubGroupInvocationARB * gl_SubGroupGtMaskARB bit index > gl_SubGroupInvocationARB * gl_SubGroupLeMaskARB bit index <= gl_SubGroupInvocationARB * gl_SubGroupLtMaskARB bit index < gl_SubGroupInvocationARB */ SYSTEM_VALUE_SUBGROUP_EQ_MASK, SYSTEM_VALUE_SUBGROUP_GE_MASK, SYSTEM_VALUE_SUBGROUP_GT_MASK, SYSTEM_VALUE_SUBGROUP_LE_MASK, SYSTEM_VALUE_SUBGROUP_LT_MASK, /*@}*/ /** * Builtin variables added by VK_KHR_subgroups */ /*@{*/ SYSTEM_VALUE_NUM_SUBGROUPS, SYSTEM_VALUE_SUBGROUP_ID, /*@}*/ /*@}*/ /** * \name Vertex shader system values */ /*@{*/ /** * OpenGL-style vertex ID. * * Section 2.11.7 (Shader Execution), subsection Shader Inputs, of the * OpenGL 3.3 core profile spec says: * * "gl_VertexID holds the integer index i implicitly passed by * DrawArrays or one of the other drawing commands defined in section * 2.8.3." * * Section 2.8.3 (Drawing Commands) of the same spec says: * * "The commands....are equivalent to the commands with the same base * name (without the BaseVertex suffix), except that the ith element * transferred by the corresponding draw call will be taken from * element indices[i] + basevertex of each enabled array." * * Additionally, the overview in the GL_ARB_shader_draw_parameters spec * says: * * "In unextended GL, vertex shaders have inputs named gl_VertexID and * gl_InstanceID, which contain, respectively the index of the vertex * and instance. The value of gl_VertexID is the implicitly passed * index of the vertex being processed, which includes the value of * baseVertex, for those commands that accept it." * * gl_VertexID gets basevertex added in. This differs from DirectX where * SV_VertexID does \b not get basevertex added in. * * \note * If all system values are available, \c SYSTEM_VALUE_VERTEX_ID will be * equal to \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus * \c SYSTEM_VALUE_BASE_VERTEX. * * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_BASE_VERTEX */ SYSTEM_VALUE_VERTEX_ID, /** * Instanced ID as supplied to gl_InstanceID * * Values assigned to gl_InstanceID always begin with zero, regardless of * the value of baseinstance. * * Section 11.1.3.9 (Shader Inputs) of the OpenGL 4.4 core profile spec * says: * * "gl_InstanceID holds the integer instance number of the current * primitive in an instanced draw call (see section 10.5)." * * Through a big chain of pseudocode, section 10.5 describes that * baseinstance is not counted by gl_InstanceID. In that section, notice * * "If an enabled vertex attribute array is instanced (it has a * non-zero divisor as specified by VertexAttribDivisor), the element * index that is transferred to the GL, for all vertices, is given by * * floor(instance/divisor) + baseinstance * * If an array corresponding to an attribute required by a vertex * shader is not enabled, then the corresponding element is taken from * the current attribute state (see section 10.2)." * * Note that baseinstance is \b not included in the value of instance. */ SYSTEM_VALUE_INSTANCE_ID, /** * Vulkan InstanceIndex. * * InstanceIndex = gl_InstanceID + gl_BaseInstance */ SYSTEM_VALUE_INSTANCE_INDEX, /** * DirectX-style vertex ID. * * Unlike \c SYSTEM_VALUE_VERTEX_ID, this system value does \b not include * the value of basevertex. * * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_BASE_VERTEX */ SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, /** * Value of \c basevertex passed to \c glDrawElementsBaseVertex and similar * functions. * * \sa SYSTEM_VALUE_VERTEX_ID, SYSTEM_VALUE_VERTEX_ID_ZERO_BASE */ SYSTEM_VALUE_BASE_VERTEX, /** * Depending on the type of the draw call (indexed or non-indexed), * is the value of \c basevertex passed to \c glDrawElementsBaseVertex and * similar, or is the value of \c first passed to \c glDrawArrays and * similar. * * \note * It can be used to calculate the \c SYSTEM_VALUE_VERTEX_ID as * \c SYSTEM_VALUE_VERTEX_ID_ZERO_BASE plus \c SYSTEM_VALUE_FIRST_VERTEX. * * \sa SYSTEM_VALUE_VERTEX_ID_ZERO_BASE, SYSTEM_VALUE_VERTEX_ID */ SYSTEM_VALUE_FIRST_VERTEX, /** * If the Draw command used to start the rendering was an indexed draw * or not (~0/0). Useful to calculate \c SYSTEM_VALUE_BASE_VERTEX as * \c SYSTEM_VALUE_IS_INDEXED_DRAW & \c SYSTEM_VALUE_FIRST_VERTEX. */ SYSTEM_VALUE_IS_INDEXED_DRAW, /** * Value of \c baseinstance passed to instanced draw entry points * * \sa SYSTEM_VALUE_INSTANCE_ID */ SYSTEM_VALUE_BASE_INSTANCE, /** * From _ARB_shader_draw_parameters: * * "Additionally, this extension adds a further built-in variable, * gl_DrawID to the shading language. This variable contains the index * of the draw currently being processed by a Multi* variant of a * drawing command (such as MultiDrawElements or * MultiDrawArraysIndirect)." * * If GL_ARB_multi_draw_indirect is not supported, this is always 0. */ SYSTEM_VALUE_DRAW_ID, /*@}*/ /** * \name Geometry shader system values */ /*@{*/ SYSTEM_VALUE_INVOCATION_ID, /**< (Also in Tessellation Control shader) */ /*@}*/ /** * \name Fragment shader system values */ /*@{*/ SYSTEM_VALUE_FRAG_COORD, SYSTEM_VALUE_POINT_COORD, SYSTEM_VALUE_LINE_COORD, /**< Coord along axis perpendicular to line */ SYSTEM_VALUE_FRONT_FACE, SYSTEM_VALUE_SAMPLE_ID, SYSTEM_VALUE_SAMPLE_POS, SYSTEM_VALUE_SAMPLE_POS_OR_CENTER, SYSTEM_VALUE_SAMPLE_MASK_IN, SYSTEM_VALUE_LAYER_ID, SYSTEM_VALUE_HELPER_INVOCATION, SYSTEM_VALUE_COLOR0, SYSTEM_VALUE_COLOR1, /*@}*/ /** * \name Tessellation Evaluation shader system values */ /*@{*/ SYSTEM_VALUE_TESS_COORD, SYSTEM_VALUE_VERTICES_IN, /**< Tessellation vertices in input patch */ SYSTEM_VALUE_PRIMITIVE_ID, SYSTEM_VALUE_TESS_LEVEL_OUTER, /**< TES input */ SYSTEM_VALUE_TESS_LEVEL_INNER, /**< TES input */ SYSTEM_VALUE_TESS_LEVEL_OUTER_DEFAULT, /**< TCS input for passthru TCS */ SYSTEM_VALUE_TESS_LEVEL_INNER_DEFAULT, /**< TCS input for passthru TCS */ /*@}*/ /** * \name Compute shader system values */ /*@{*/ SYSTEM_VALUE_LOCAL_INVOCATION_ID, SYSTEM_VALUE_LOCAL_INVOCATION_INDEX, SYSTEM_VALUE_GLOBAL_INVOCATION_ID, SYSTEM_VALUE_BASE_GLOBAL_INVOCATION_ID, SYSTEM_VALUE_GLOBAL_INVOCATION_INDEX, SYSTEM_VALUE_WORKGROUP_ID, SYSTEM_VALUE_BASE_WORKGROUP_ID, SYSTEM_VALUE_WORKGROUP_INDEX, SYSTEM_VALUE_NUM_WORKGROUPS, SYSTEM_VALUE_WORKGROUP_SIZE, SYSTEM_VALUE_GLOBAL_GROUP_SIZE, SYSTEM_VALUE_WORK_DIM, SYSTEM_VALUE_USER_DATA_AMD, /*@}*/ /** Required for VK_KHR_device_group */ SYSTEM_VALUE_DEVICE_INDEX, /** Required for VK_KHX_multiview */ SYSTEM_VALUE_VIEW_INDEX, /** * Driver internal vertex-count, used (for example) for drivers to * calculate stride for stream-out outputs. Not externally visible. */ SYSTEM_VALUE_VERTEX_CNT, /** * Required for AMD_shader_explicit_vertex_parameter and also used for * varying-fetch instructions. * * The _SIZE value is "primitive size", used to scale i/j in primitive * space to pixel space. */ SYSTEM_VALUE_BARYCENTRIC_PERSP_PIXEL, SYSTEM_VALUE_BARYCENTRIC_PERSP_SAMPLE, SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTROID, SYSTEM_VALUE_BARYCENTRIC_PERSP_CENTER_RHW, SYSTEM_VALUE_BARYCENTRIC_LINEAR_PIXEL, SYSTEM_VALUE_BARYCENTRIC_LINEAR_CENTROID, SYSTEM_VALUE_BARYCENTRIC_LINEAR_SAMPLE, SYSTEM_VALUE_BARYCENTRIC_PULL_MODEL, /** * \name VK_KHR_fragment_shader_barycentric */ /*@{*/ SYSTEM_VALUE_BARYCENTRIC_PERSP_COORD, SYSTEM_VALUE_BARYCENTRIC_LINEAR_COORD, /*@}*/ /** * \name Ray tracing shader system values */ /*@{*/ SYSTEM_VALUE_RAY_LAUNCH_ID, SYSTEM_VALUE_RAY_LAUNCH_SIZE, SYSTEM_VALUE_RAY_WORLD_ORIGIN, SYSTEM_VALUE_RAY_WORLD_DIRECTION, SYSTEM_VALUE_RAY_OBJECT_ORIGIN, SYSTEM_VALUE_RAY_OBJECT_DIRECTION, SYSTEM_VALUE_RAY_T_MIN, SYSTEM_VALUE_RAY_T_MAX, SYSTEM_VALUE_RAY_OBJECT_TO_WORLD, SYSTEM_VALUE_RAY_WORLD_TO_OBJECT, SYSTEM_VALUE_RAY_HIT_KIND, SYSTEM_VALUE_RAY_FLAGS, SYSTEM_VALUE_RAY_GEOMETRY_INDEX, SYSTEM_VALUE_RAY_INSTANCE_CUSTOM_INDEX, SYSTEM_VALUE_CULL_MASK, SYSTEM_VALUE_RAY_TRIANGLE_VERTEX_POSITIONS, /*@}*/ /** * \name Task/Mesh shader system values */ /*@{*/ SYSTEM_VALUE_MESH_VIEW_COUNT, SYSTEM_VALUE_MESH_VIEW_INDICES, /*@}*/ /** * IR3 specific geometry shader and tesselation control shader system * values that packs invocation id, thread id and vertex id. Having this * as a nir level system value lets us do the unpacking in nir. */ SYSTEM_VALUE_GS_HEADER_IR3, SYSTEM_VALUE_TCS_HEADER_IR3, /* IR3 specific system value that contains the patch id for the current * subdraw. */ SYSTEM_VALUE_REL_PATCH_ID_IR3, /** * Fragment shading rate used for KHR_fragment_shading_rate (Vulkan). */ SYSTEM_VALUE_FRAG_SHADING_RATE, /* * Rasterized fragment is fully covered by the generating primitive * (SPV_EXT_fragment_fully_covered). */ SYSTEM_VALUE_FULLY_COVERED, /* * Fragment size and invocation count used for * EXT_fragment_invocation_density (Vulkan). */ SYSTEM_VALUE_FRAG_SIZE, SYSTEM_VALUE_FRAG_INVOCATION_COUNT, /* SPV_AMDX_shader_enqueue */ SYSTEM_VALUE_SHADER_INDEX, SYSTEM_VALUE_COALESCED_INPUT_COUNT, /* SPV_NV_shader_sm_builtins */ SYSTEM_VALUE_WARPS_PER_SM_NV, SYSTEM_VALUE_SM_COUNT_NV, SYSTEM_VALUE_WARP_ID_NV, SYSTEM_VALUE_SM_ID_NV, SYSTEM_VALUE_MAX /**< Number of values */ } gl_system_value; const char *gl_system_value_name(gl_system_value sysval); /** * The possible interpolation qualifiers that can be applied to a fragment * shader input in GLSL. * * Note: INTERP_MODE_NONE must be 0 so that memsetting the * ir_variable data structure to 0 causes the default behavior. */ enum glsl_interp_mode { INTERP_MODE_NONE = 0, INTERP_MODE_SMOOTH, INTERP_MODE_FLAT, INTERP_MODE_NOPERSPECTIVE, INTERP_MODE_EXPLICIT, INTERP_MODE_COUNT /**< Number of interpolation qualifiers */ }; enum glsl_interface_packing { GLSL_INTERFACE_PACKING_STD140, GLSL_INTERFACE_PACKING_SHARED, GLSL_INTERFACE_PACKING_PACKED, GLSL_INTERFACE_PACKING_STD430 }; const char *glsl_interp_mode_name(enum glsl_interp_mode qual); /** * Fragment program results */ typedef enum { FRAG_RESULT_DEPTH = 0, FRAG_RESULT_STENCIL = 1, /* If a single color should be written to all render targets, this * register is written. No FRAG_RESULT_DATAn will be written. */ FRAG_RESULT_COLOR = 2, FRAG_RESULT_SAMPLE_MASK = 3, /* FRAG_RESULT_DATAn are the per-render-target (GLSL gl_FragData[n] * or ARB_fragment_program fragment.color[n]) color results. If * any are written, FRAG_RESULT_COLOR will not be written. * FRAG_RESULT_DATA1 and up are simply for the benefit of * gl_frag_result_name() and not to be construed as an upper bound */ FRAG_RESULT_DATA0 = 4, FRAG_RESULT_DATA1, FRAG_RESULT_DATA2, FRAG_RESULT_DATA3, FRAG_RESULT_DATA4, FRAG_RESULT_DATA5, FRAG_RESULT_DATA6, FRAG_RESULT_DATA7, } gl_frag_result; const char *gl_frag_result_name(gl_frag_result result); #define FRAG_RESULT_MAX (FRAG_RESULT_DATA0 + MAX_DRAW_BUFFERS) /** * \brief Layout qualifiers for gl_FragDepth. * * Extension AMD_conservative_depth allows gl_FragDepth to be redeclared with * a layout qualifier. * * \see enum ir_depth_layout */ enum gl_frag_depth_layout { FRAG_DEPTH_LAYOUT_NONE, /**< No layout is specified. */ FRAG_DEPTH_LAYOUT_ANY, FRAG_DEPTH_LAYOUT_GREATER, FRAG_DEPTH_LAYOUT_LESS, FRAG_DEPTH_LAYOUT_UNCHANGED }; /** * \brief Layout qualifiers for AMD_shader_early_and_late_fragment_tests. */ enum gl_frag_stencil_layout { FRAG_STENCIL_LAYOUT_NONE, /**< No layout is specified. */ FRAG_STENCIL_LAYOUT_ANY, FRAG_STENCIL_LAYOUT_GREATER, FRAG_STENCIL_LAYOUT_LESS, FRAG_STENCIL_LAYOUT_UNCHANGED }; /** * \brief Memory access qualifiers */ enum gl_access_qualifier { /** * This means that the memory scope is the current device. It indicates * that reads and writes are coherent with reads and writes from other * shader invocations and other workgroups. */ ACCESS_COHERENT = (1 << 0), /** * This means non-aliased. It indicates that the accessed address is not * accessible through any other memory resource in the shader. */ ACCESS_RESTRICT = (1 << 1), /** * The access cannot be eliminated, duplicated, or combined with other * accesses. */ ACCESS_VOLATILE = (1 << 2), /* The memory used by the access/variable is not read. */ ACCESS_NON_READABLE = (1 << 3), /* The memory used by the access/variable is not written. */ ACCESS_NON_WRITEABLE = (1 << 4), /** * The access may use a non-uniform buffer or image index. * * This is not allowed in either OpenGL or OpenGL ES, or Vulkan unless * VK_EXT_descriptor_indexing is supported and the appropriate capability is * enabled. * * Some GL spec archaeology justifying this: * * Up through at least GLSL ES 3.20 and GLSL 4.50, "Opaque Types" says "When * aggregated into arrays within a shader, opaque types can only be indexed * with a dynamically uniform integral expression (see section 3.9.3) unless * otherwise noted; otherwise, results are undefined." * * The original GL_AB_shader_image_load_store specification for desktop GL * didn't have this restriction ("Images may be aggregated into arrays within * a shader (using square brackets [ ]) and can be indexed with general * integer expressions.") At the same time, * GL_ARB_shader_storage_buffer_objects *did* have the uniform restriction * ("A uniform or shader storage block array can only be indexed with a * dynamically uniform integral expression, otherwise results are * undefined"), just like ARB_gpu_shader5 did when it first introduced a * non-constant indexing of an opaque type with samplers. So, we assume that * this was an oversight in the original image_load_store spec, and was * considered a correction in the merge to core. */ ACCESS_NON_UNIFORM = (1 << 5), /* This has the same semantics as NIR_INTRINSIC_CAN_REORDER, only to be * used with loads. In other words, it means that the load can be * arbitrarily reordered, or combined with other loads to the same address. * It is implied by ACCESS_NON_WRITEABLE and a lack of ACCESS_VOLATILE. */ ACCESS_CAN_REORDER = (1 << 6), /** * Hints that the accessed address is not likely to be accessed again * in the near future. This reduces data retention in caches. */ ACCESS_NON_TEMPORAL = (1 << 7), /** Execute instruction also in helpers. */ ACCESS_INCLUDE_HELPERS = (1 << 8), /** * Whether the address bits are swizzled by the hw. This practically means * that loads can't be vectorized and must be exactly 32 bits on some chips. * The swizzle amount is determined by the descriptor. */ ACCESS_IS_SWIZZLED_AMD = (1 << 9), /** * Whether an AMD-specific buffer intrinsic uses a format conversion. * * If unset, the intrinsic will access raw memory without any conversion. * * If set, the memory opcode performs a format conversion according to * the format determined by the descriptor (in a manner identical to image * buffers and sampler buffers). */ ACCESS_USES_FORMAT_AMD = (1 << 10), /** * Whether a multi sample image load intrinsic uses sample index extracted * from fragment mask buffer. */ ACCESS_FMASK_LOWERED_AMD = (1 << 11), /** * Whether it is safe to speculatively execute this load. This allows * hoisting loads out of conditional control flow (including out of software * bounds checks). Setting this optimally depends on knowledge of the * hardware. Speculation is safe if out-of-bounds access does not trigger * undefined behaviour (even though the returned value of the speculated load * is bogus). This is the case if there is hardware-level bounds checking, or * if MMU faults are suppressed for the load. */ ACCESS_CAN_SPECULATE = (1 << 12), /** * Whether coherency with CP (command processor) or GE (geometry engine) * is required. */ ACCESS_CP_GE_COHERENT_AMD = (1 << 13), /* Guarantee that an image_load is in bounds so we can skip robustness code * on AGX, used for some internal shaders. */ ACCESS_IN_BOUNDS_AGX = (1 << 14), /** * Disallow vectorization. * * On some hw (AMD), sparse buffer loads return 0 for all components if * a sparse load starts on a non-resident page, crosses the page boundary, * and ends on a resident page. Sometimes we want it to return 0 only for * the portion of the load that's non-resident, and load values for * the portion that's resident. The workaround is to scalarize such loads * and disallow vectorization. This is used by an internal copy_buffer * shader where the API wants to copy all bytes that are resident. */ ACCESS_KEEP_SCALAR = (1 << 15), }; /** * \brief Blend support qualifiers */ enum gl_advanced_blend_mode { BLEND_NONE = 0, BLEND_MULTIPLY, BLEND_SCREEN, BLEND_OVERLAY, BLEND_DARKEN, BLEND_LIGHTEN, BLEND_COLORDODGE, BLEND_COLORBURN, BLEND_HARDLIGHT, BLEND_SOFTLIGHT, BLEND_DIFFERENCE, BLEND_EXCLUSION, BLEND_HSL_HUE, BLEND_HSL_SATURATION, BLEND_HSL_COLOR, BLEND_HSL_LUMINOSITY, }; enum gl_tess_spacing { TESS_SPACING_UNSPECIFIED, TESS_SPACING_EQUAL, TESS_SPACING_FRACTIONAL_ODD, TESS_SPACING_FRACTIONAL_EVEN, }; enum tess_primitive_mode { TESS_PRIMITIVE_UNSPECIFIED, TESS_PRIMITIVE_TRIANGLES, TESS_PRIMITIVE_QUADS, TESS_PRIMITIVE_ISOLINES, }; static inline void mesa_count_tess_level_components(const enum tess_primitive_mode mode, unsigned *outer, unsigned *inner) { switch (mode) { case TESS_PRIMITIVE_ISOLINES: *outer = 2; *inner = 0; break; case TESS_PRIMITIVE_TRIANGLES: *outer = 3; *inner = 1; break; case TESS_PRIMITIVE_QUADS: default: *outer = 4; *inner = 2; break; } } /** * Mesa primitive types for both GL and Vulkan: */ enum ENUM_PACKED mesa_prim { MESA_PRIM_POINTS, MESA_PRIM_LINES, MESA_PRIM_LINE_LOOP, MESA_PRIM_LINE_STRIP, MESA_PRIM_TRIANGLES, MESA_PRIM_TRIANGLE_STRIP, MESA_PRIM_TRIANGLE_FAN, MESA_PRIM_QUADS, MESA_PRIM_QUAD_STRIP, MESA_PRIM_POLYGON, MESA_PRIM_LINES_ADJACENCY, MESA_PRIM_LINE_STRIP_ADJACENCY, MESA_PRIM_TRIANGLES_ADJACENCY, MESA_PRIM_TRIANGLE_STRIP_ADJACENCY, MESA_PRIM_PATCHES, MESA_PRIM_MAX = MESA_PRIM_PATCHES, MESA_PRIM_COUNT = MESA_PRIM_MAX +1, MESA_PRIM_UNKNOWN = (MESA_PRIM_MAX * 2), }; /** * Number of vertices per primitive as seen by a geometry or mesh shader. */ static inline unsigned mesa_vertices_per_prim(enum mesa_prim prim) { switch(prim) { case MESA_PRIM_POINTS: return 1; case MESA_PRIM_LINES: case MESA_PRIM_LINE_LOOP: case MESA_PRIM_LINE_STRIP: return 2; case MESA_PRIM_TRIANGLES: case MESA_PRIM_TRIANGLE_STRIP: case MESA_PRIM_TRIANGLE_FAN: return 3; case MESA_PRIM_LINES_ADJACENCY: case MESA_PRIM_LINE_STRIP_ADJACENCY: return 4; case MESA_PRIM_TRIANGLES_ADJACENCY: case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY: return 6; case MESA_PRIM_QUADS: case MESA_PRIM_QUAD_STRIP: /* These won't be seen from geometry shaders but prim assembly might for * prim id. */ return 4; /* The following primitives should never be used with geometry or mesh * shaders and their size is undefined. */ case MESA_PRIM_POLYGON: default: debug_printf("Unrecognized geometry or mesh shader primitive"); return 3; } } /** * Returns the number of decomposed primitives for the given * vertex count. * Parts of the pipline are invoked once for each triangle in * triangle strip, triangle fans and triangles and once * for each line in line strip, line loop, lines. Also * statistics depend on knowing the exact number of decomposed * primitives for a set of vertices. */ static inline unsigned u_decomposed_prims_for_vertices(enum mesa_prim primitive, int vertices) { switch (primitive) { case MESA_PRIM_POINTS: return vertices; case MESA_PRIM_LINES: return vertices / 2; case MESA_PRIM_LINE_LOOP: return (vertices >= 2) ? vertices : 0; case MESA_PRIM_LINE_STRIP: return (vertices >= 2) ? vertices - 1 : 0; case MESA_PRIM_TRIANGLES: return vertices / 3; case MESA_PRIM_TRIANGLE_STRIP: return (vertices >= 3) ? vertices - 2 : 0; case MESA_PRIM_TRIANGLE_FAN: return (vertices >= 3) ? vertices - 2 : 0; case MESA_PRIM_LINES_ADJACENCY: return vertices / 4; case MESA_PRIM_LINE_STRIP_ADJACENCY: return (vertices >= 4) ? vertices - 3 : 0; case MESA_PRIM_TRIANGLES_ADJACENCY: return vertices / 6; case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY: return (vertices >= 6) ? 1 + (vertices - 6) / 2 : 0; case MESA_PRIM_QUADS: return vertices / 4; case MESA_PRIM_QUAD_STRIP: return (vertices >= 4) ? (vertices - 2) / 2 : 0; /* Polygons can't be decomposed * because the number of their vertices isn't known so * for them and whatever else we don't recognize just * return 1 if the number of vertices is greater than * or equal to 3 and zero otherwise */ case MESA_PRIM_POLYGON: default: debug_printf("Invalid decomposition primitive!\n"); return (vertices >= 3) ? 1 : 0; } } /** * Decompose a primitive that is a loop, a strip, or a fan. Return the * original primitive if it is already decomposed. */ static inline enum mesa_prim u_decomposed_prim(enum mesa_prim prim) { switch (prim) { case MESA_PRIM_LINE_LOOP: case MESA_PRIM_LINE_STRIP: return MESA_PRIM_LINES; case MESA_PRIM_TRIANGLE_STRIP: case MESA_PRIM_TRIANGLE_FAN: return MESA_PRIM_TRIANGLES; case MESA_PRIM_QUAD_STRIP: return MESA_PRIM_QUADS; case MESA_PRIM_LINE_STRIP_ADJACENCY: return MESA_PRIM_LINES_ADJACENCY; case MESA_PRIM_TRIANGLE_STRIP_ADJACENCY: return MESA_PRIM_TRIANGLES_ADJACENCY; default: return prim; } } /** * Reduce a primitive to one of MESA_PRIM_POINTS, MESA_PRIM_LINES, and * MESA_PRIM_TRIANGLES. */ static inline enum mesa_prim u_reduced_prim(enum mesa_prim prim) { switch (prim) { case MESA_PRIM_POINTS: return MESA_PRIM_POINTS; case MESA_PRIM_LINES: case MESA_PRIM_LINE_LOOP: case MESA_PRIM_LINE_STRIP: case MESA_PRIM_LINES_ADJACENCY: case MESA_PRIM_LINE_STRIP_ADJACENCY: return MESA_PRIM_LINES; default: return MESA_PRIM_TRIANGLES; } } /** * A compare function enum for use in compiler lowering passes. This is in * the same order as GL's compare functions (shifted down by GL_NEVER), and is * exactly the same as gallium's PIPE_FUNC_*. */ enum compare_func { COMPARE_FUNC_NEVER, COMPARE_FUNC_LESS, COMPARE_FUNC_EQUAL, COMPARE_FUNC_LEQUAL, COMPARE_FUNC_GREATER, COMPARE_FUNC_NOTEQUAL, COMPARE_FUNC_GEQUAL, COMPARE_FUNC_ALWAYS, }; /** * Arrangements for grouping invocations from NV_compute_shader_derivatives. * * The extension provides new layout qualifiers that support two different * arrangements of compute shader invocations for the purpose of derivative * computation. When specifying * * layout(derivative_group_quadsNV) in; * * compute shader invocations are grouped into 2x2x1 arrays whose four local * invocation ID values follow the pattern: * * +-----------------+------------------+ * | (2x+0, 2y+0, z) | (2x+1, 2y+0, z) | * +-----------------+------------------+ * | (2x+0, 2y+1, z) | (2x+1, 2y+1, z) | * +-----------------+------------------+ * * where Y increases from bottom to top. When specifying * * layout(derivative_group_linearNV) in; * * compute shader invocations are grouped into 2x2x1 arrays whose four local * invocation index values follow the pattern: * * +------+------+ * | 4n+0 | 4n+1 | * +------+------+ * | 4n+2 | 4n+3 | * +------+------+ * * If neither layout qualifier is specified, derivatives in compute shaders * return zero, which is consistent with the handling of built-in texture * functions like texture() in GLSL 4.50 compute shaders. */ enum gl_derivative_group { DERIVATIVE_GROUP_NONE = 0, DERIVATIVE_GROUP_QUADS, DERIVATIVE_GROUP_LINEAR, }; enum float_controls { /* The order of these matters. For float_controls2, only the first 9 bits * are used and stored per-instruction in nir_alu_instr::fp_fast_math. * Any changes in this enum need to be synchronized with that. */ FLOAT_CONTROLS_DEFAULT_FLOAT_CONTROL_MODE = 0, FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP16 = BITFIELD_BIT(0), FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP32 = BITFIELD_BIT(1), FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP64 = BITFIELD_BIT(2), FLOAT_CONTROLS_INF_PRESERVE_FP16 = BITFIELD_BIT(3), FLOAT_CONTROLS_INF_PRESERVE_FP32 = BITFIELD_BIT(4), FLOAT_CONTROLS_INF_PRESERVE_FP64 = BITFIELD_BIT(5), FLOAT_CONTROLS_NAN_PRESERVE_FP16 = BITFIELD_BIT(6), FLOAT_CONTROLS_NAN_PRESERVE_FP32 = BITFIELD_BIT(7), FLOAT_CONTROLS_NAN_PRESERVE_FP64 = BITFIELD_BIT(8), FLOAT_CONTROLS_DENORM_PRESERVE_FP16 = BITFIELD_BIT(9), FLOAT_CONTROLS_DENORM_PRESERVE_FP32 = BITFIELD_BIT(10), FLOAT_CONTROLS_DENORM_PRESERVE_FP64 = BITFIELD_BIT(11), FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP16 = BITFIELD_BIT(12), FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP32 = BITFIELD_BIT(13), FLOAT_CONTROLS_DENORM_FLUSH_TO_ZERO_FP64 = BITFIELD_BIT(14), FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP16 = BITFIELD_BIT(15), FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP32 = BITFIELD_BIT(16), FLOAT_CONTROLS_ROUNDING_MODE_RTE_FP64 = BITFIELD_BIT(17), FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP16 = BITFIELD_BIT(18), FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP32 = BITFIELD_BIT(19), FLOAT_CONTROLS_ROUNDING_MODE_RTZ_FP64 = BITFIELD_BIT(20), FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP16 = FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP16 | FLOAT_CONTROLS_INF_PRESERVE_FP16 | FLOAT_CONTROLS_NAN_PRESERVE_FP16, FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP32 = FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP32 | FLOAT_CONTROLS_INF_PRESERVE_FP32 | FLOAT_CONTROLS_NAN_PRESERVE_FP32, FLOAT_CONTROLS_SIGNED_ZERO_INF_NAN_PRESERVE_FP64 = FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP64 | FLOAT_CONTROLS_INF_PRESERVE_FP64 | FLOAT_CONTROLS_NAN_PRESERVE_FP64, FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE = FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP16 | FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP32 | FLOAT_CONTROLS_SIGNED_ZERO_PRESERVE_FP64, FLOAT_CONTROLS_INF_PRESERVE = FLOAT_CONTROLS_INF_PRESERVE_FP16 | FLOAT_CONTROLS_INF_PRESERVE_FP32 | FLOAT_CONTROLS_INF_PRESERVE_FP64, FLOAT_CONTROLS_NAN_PRESERVE = FLOAT_CONTROLS_NAN_PRESERVE_FP16 | FLOAT_CONTROLS_NAN_PRESERVE_FP32 | FLOAT_CONTROLS_NAN_PRESERVE_FP64, }; /** * Enums to describe sampler properties used by OpenCL's inline constant samplers. * These values match the meanings described in the SPIR-V spec. */ enum cl_sampler_addressing_mode { SAMPLER_ADDRESSING_MODE_NONE = 0, SAMPLER_ADDRESSING_MODE_CLAMP_TO_EDGE = 1, SAMPLER_ADDRESSING_MODE_CLAMP = 2, SAMPLER_ADDRESSING_MODE_REPEAT = 3, SAMPLER_ADDRESSING_MODE_REPEAT_MIRRORED = 4, }; enum cl_sampler_filter_mode { SAMPLER_FILTER_MODE_NEAREST = 0, SAMPLER_FILTER_MODE_LINEAR = 1, }; /** * \name Bit flags used for updating material values. */ /*@{*/ #define MAT_ATTRIB_FRONT_AMBIENT 0 #define MAT_ATTRIB_BACK_AMBIENT 1 #define MAT_ATTRIB_FRONT_DIFFUSE 2 #define MAT_ATTRIB_BACK_DIFFUSE 3 #define MAT_ATTRIB_FRONT_SPECULAR 4 #define MAT_ATTRIB_BACK_SPECULAR 5 #define MAT_ATTRIB_FRONT_EMISSION 6 #define MAT_ATTRIB_BACK_EMISSION 7 #define MAT_ATTRIB_FRONT_SHININESS 8 #define MAT_ATTRIB_BACK_SHININESS 9 #define MAT_ATTRIB_FRONT_INDEXES 10 #define MAT_ATTRIB_BACK_INDEXES 11 #define MAT_ATTRIB_MAX 12 #define MAT_ATTRIB_AMBIENT(f) (MAT_ATTRIB_FRONT_AMBIENT+(f)) #define MAT_ATTRIB_DIFFUSE(f) (MAT_ATTRIB_FRONT_DIFFUSE+(f)) #define MAT_ATTRIB_SPECULAR(f) (MAT_ATTRIB_FRONT_SPECULAR+(f)) #define MAT_ATTRIB_EMISSION(f) (MAT_ATTRIB_FRONT_EMISSION+(f)) #define MAT_ATTRIB_SHININESS(f)(MAT_ATTRIB_FRONT_SHININESS+(f)) #define MAT_ATTRIB_INDEXES(f) (MAT_ATTRIB_FRONT_INDEXES+(f)) #define MAT_BIT_FRONT_AMBIENT (1<