#include "main/formats.h" /* MESA_FORMAT_COUNT */
#include "compiler/glsl/list.h"
#include "util/bitscan.h"
+#include "util/simple_mtx.h"
#include "util/u_dynarray.h"
#endif
+/** Set a single bit */
+#define BITFIELD_BIT(b) ((GLbitfield)1 << (b))
+/** Set all bits up to excluding bit b */
+#define BITFIELD_MASK(b) \
+ ((b) == 32 ? (~(GLbitfield)0) : BITFIELD_BIT(b) - 1)
+/** Set count bits starting from bit b */
+#define BITFIELD_RANGE(b, count) \
+ (BITFIELD_MASK((b) + (count)) & ~BITFIELD_MASK(b))
+
+
/**
* \name 64-bit extension of GLbitfield.
*/
struct gl_uniform_storage;
struct prog_instruction;
struct gl_program_parameter_list;
+struct gl_shader_spirv_data;
struct set;
-struct set_entry;
struct vbo_context;
/*@}*/
*/
struct gl_sampler_object
{
- mtx_t Mutex;
+ simple_mtx_t Mutex;
GLuint Name;
GLint RefCount;
GLchar *Label; /**< GL_KHR_debug */
GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
/** GL_ARB_bindless_texture */
- struct util_dynarray Handles;
bool HandleAllocated;
+ struct util_dynarray Handles;
};
*/
struct gl_texture_object
{
- mtx_t Mutex; /**< for thread safety */
+ simple_mtx_t Mutex; /**< for thread safety */
GLint RefCount; /**< reference count */
GLuint Name; /**< the user-visible texture object ID */
GLchar *Label; /**< GL_KHR_debug */
struct gl_sampler_object Sampler;
GLenum DepthMode; /**< GL_ARB_depth_texture */
- bool StencilSampling; /**< Should we sample stencil instead of depth? */
GLfloat Priority; /**< in [0,1] */
GLint BaseLevel; /**< min mipmap level, OpenGL 1.2 */
GLboolean Immutable; /**< GL_ARB_texture_storage */
GLboolean _IsFloat; /**< GL_OES_float_texture */
GLboolean _IsHalfFloat; /**< GL_OES_half_float_texture */
+ bool StencilSampling; /**< Should we sample stencil instead of depth? */
+ bool HandleAllocated; /**< GL_ARB_bindless_texture */
GLuint MinLevel; /**< GL_ARB_texture_view */
GLuint MinLayer; /**< GL_ARB_texture_view */
GLuint NumLevels; /**< GL_ARB_texture_view */
GLuint NumLayers; /**< GL_ARB_texture_view */
+ /** GL_EXT_memory_object */
+ GLenum TextureTiling;
+
/** Actual texture images, indexed by [cube face] and [mipmap level] */
struct gl_texture_image *Image[MAX_FACES][MAX_TEXTURE_LEVELS];
/** GL_ARB_shader_image_load_store */
GLenum ImageFormatCompatibilityType;
- /** GL_EXT_memory_object */
- GLenum TextureTiling;
-
/** GL_ARB_bindless_texture */
struct util_dynarray SamplerHandles;
struct util_dynarray ImageHandles;
- bool HandleAllocated;
};
*/
struct gl_buffer_object
{
- mtx_t Mutex;
+ simple_mtx_t Mutex;
GLint RefCount;
GLuint Name;
GLchar *Label; /**< GL_KHR_debug */
GLsizei Stride; /**< User-specified stride */
GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
struct gl_buffer_object *BufferObj; /**< GL_ARB_vertex_buffer_object */
- GLbitfield64 _BoundArrays; /**< Arrays bound to this binding point */
+ GLbitfield _BoundArrays; /**< Arrays bound to this binding point */
};
struct gl_vertex_buffer_binding BufferBinding[VERT_ATTRIB_MAX];
/** Mask indicating which vertex arrays have vertex buffer associated. */
- GLbitfield64 VertexAttribBufferMask;
+ GLbitfield VertexAttribBufferMask;
/** Mask of VERT_BIT_* values indicating which arrays are enabled */
- GLbitfield64 _Enabled;
+ GLbitfield _Enabled;
/** Mask of VERT_BIT_* values indicating changed/dirty arrays */
- GLbitfield64 NewArrays;
+ GLbitfield NewArrays;
/** The index buffer (also known as the element array buffer in OpenGL). */
struct gl_buffer_object *IndexBufferObj;
/** Post-link transform feedback info. */
struct gl_transform_feedback_info
{
+ /* Was xfb enabled via the api or in shader layout qualifiers */
+ bool api_enabled;
+
unsigned NumOutputs;
/* Bitmask of active buffer indices. */
/** Texture unit (set by glUniform1()). */
GLubyte unit;
- /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
- gl_texture_index target;
-
/** Whether this bindless sampler is bound to a unit. */
GLboolean bound;
+ /** Texture Target (TEXTURE_1D/2D/3D/etc_INDEX). */
+ gl_texture_index target;
+
/** Pointer to the base of the data. */
GLvoid *data;
};
/** Image unit (set by glUniform1()). */
GLubyte unit;
- /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
- GLenum access;
-
/** Whether this bindless image is bound to a unit. */
GLboolean bound;
+ /** Access qualifier (GL_READ_WRITE, GL_READ_ONLY, GL_WRITE_ONLY) */
+ GLenum access;
+
/** Pointer to the base of the data. */
GLvoid *data;
};
PROGRAM_BUFFER, /**< for shader buffers, compile-time only */
PROGRAM_MEMORY, /**< for shared, global and local memory */
PROGRAM_IMAGE, /**< for shader images, compile-time only */
+ PROGRAM_HW_ATOMIC, /**< for hw atomic counters, compile-time only */
PROGRAM_FILE_MAX
} gl_register_file;
struct nir_shader *nir;
+ /* Saved and restored with metadata. Freed with ralloc. */
+ void *driver_cache_blob;
+ size_t driver_cache_blob_size;
+
bool is_arb_asm; /** Is this an ARB assembly-style program */
/** Is this program written to on disk shader cache */
GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
+ /** Should fixed-function T&L be implemented with a vertex prog? */
+ GLboolean _MaintainTnlProgram;
+
struct gl_program *Current; /**< User-bound vertex program */
/** Currently enabled and valid vertex program (including internal
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
- /** Should fixed-function T&L be implemented with a vertex prog? */
- GLboolean _MaintainTnlProgram;
-
/** Program to emulate fixed-function T&L (see above) */
struct gl_program *_TnlProgram;
struct gl_fragment_program_state
{
GLboolean Enabled; /**< User-set fragment program enable flag */
+ /** Should fixed-function texturing be implemented with a fragment prog? */
+ GLboolean _MaintainTexEnvProgram;
+
struct gl_program *Current; /**< User-bound fragment program */
/** Currently enabled and valid fragment program (including internal
GLfloat Parameters[MAX_PROGRAM_ENV_PARAMS][4]; /**< Env params */
- /** Should fixed-function texturing be implemented with a fragment prog? */
- GLboolean _MaintainTexEnvProgram;
-
/** Program to emulate fixed-function texture env/combine (see above) */
struct gl_program *_TexEnvProgram;
GLubyte numArithInstr[2];
GLubyte regsAssigned[2];
GLubyte NumPasses; /**< 1 or 2 */
+ /** Current compile stage: 0 setup pass1, 1 arith pass1, 2 setup pass2, 3 arith pass2 */
GLubyte cur_pass;
GLubyte last_optype;
GLboolean interpinp1;
GLboolean isValid;
+ /** Array of 2 bit values for each tex unit to remember whether
+ * STR or STQ swizzle was used
+ */
GLuint swizzlerq;
struct gl_program *Program;
};
struct glsl_symbol_table *symbols;
};
-static inline GLbitfield gl_external_samplers(struct gl_program *prog)
+
+static inline GLbitfield
+gl_external_samplers(const struct gl_program *prog)
{
GLbitfield external_samplers = 0;
GLbitfield mask = prog->SamplersUsed;
return external_samplers;
}
+
/**
* Compile status enum. compile_skipped is used to indicate the compile
* was skipped due to the shader matching one that's been seen before by
GLchar *Label; /**< GL_KHR_debug */
unsigned char sha1[20]; /**< SHA1 hash of pre-processed source */
GLboolean DeletePending;
- enum gl_compile_status CompileStatus;
bool IsES; /**< True if this shader uses GLSL ES */
+ enum gl_compile_status CompileStatus;
+
#ifdef DEBUG
unsigned SourceChecksum; /**< for debug/logging purposes */
#endif
unsigned Version; /**< GLSL version used for linking */
- struct exec_list *ir;
- struct glsl_symbol_table *symbols;
-
/**
* A bitmask of gl_advanced_blend_mode values
*/
GLbitfield BlendSupport;
+ struct exec_list *ir;
+ struct glsl_symbol_table *symbols;
+
/**
* Whether early fragment tests are enabled as defined by
* ARB_shader_image_load_store.
GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS];
struct gl_shader_info info;
+
+ /* ARB_gl_spirv related data */
+ struct gl_shader_spirv_data *spirv_data;
};
struct gl_uniform_storage *UniformStorage;
unsigned NumUniformBlocks;
- struct gl_uniform_block *UniformBlocks;
-
unsigned NumShaderStorageBlocks;
+
+ struct gl_uniform_block *UniformBlocks;
struct gl_uniform_block *ShaderStorageBlocks;
struct gl_active_atomic_buffer *AtomicBuffers;
unsigned NumUniformDataSlots;
union gl_constant_value *UniformDataSlots;
- bool cache_fallback;
-
- /* TODO: This used by Gallium drivers to skip the cache on tgsi fallback.
- * All structures (gl_program, uniform storage, etc) will get recreated
- * even though we have already loaded them from cache. Once the i965 cache
- * lands we should switch to using the cache_fallback support.
+ /* Used to hold initial uniform values for program binary restores.
+ *
+ * From the ARB_get_program_binary spec:
+ *
+ * "A successful call to ProgramBinary will reset all uniform
+ * variables to their initial values. The initial value is either
+ * the value of the variable's initializer as specified in the
+ * original shader source, or 0 if no initializer was present.
*/
- bool skip_cache;
+ union gl_constant_value *UniformDataDefaults;
+
+ GLboolean Validated;
/** List of all active resources after linking. */
struct gl_program_resource *ProgramResourceList;
unsigned NumProgramResourceList;
enum gl_link_status LinkStatus; /**< GL_LINK_STATUS */
- GLboolean Validated;
GLchar *InfoLog;
unsigned Version; /**< GLSL version used for linking */
struct gl_sync_object
{
GLuint Name; /**< Fence name */
- GLchar *Label; /**< GL_KHR_debug */
GLint RefCount; /**< Reference count */
+ GLchar *Label; /**< GL_KHR_debug */
GLboolean DeletePending; /**< Object was deleted while there were still
* live references (e.g., sync not yet finished)
*/
*/
struct gl_shared_state
{
- mtx_t Mutex; /**< for thread safety */
+ simple_mtx_t Mutex; /**< for thread safety */
GLint RefCount; /**< Reference count */
struct _mesa_HashTable *DisplayList; /**< Display lists hash table */
struct _mesa_HashTable *BitmapAtlas; /**< For optimized glBitmap text */
/** EXT_external_objects */
struct _mesa_HashTable *MemoryObjects;
+ /**
+ * Some context in this share group was affected by a disjoint
+ * operation. This operation can be anything that has effects on
+ * values of timer queries in such manner that they become invalid for
+ * performance metrics. As example gpu reset, counter overflow or gpu
+ * frequency changes.
+ */
+ bool DisjointOperation;
};
*/
struct gl_renderbuffer
{
- mtx_t Mutex; /**< for thread safety */
+ simple_mtx_t Mutex; /**< for thread safety */
GLuint ClassID; /**< Useful for drivers */
GLuint Name;
GLchar *Label; /**< GL_KHR_debug */
*/
struct gl_framebuffer
{
- mtx_t Mutex; /**< for thread safety */
+ simple_mtx_t Mutex; /**< for thread safety */
/**
* If zero, this is a window system framebuffer. If non-zero, this
* is a FBO framebuffer; note that for some devices (i.e. those with
/** Computed from ColorDraw/ReadBuffer above */
GLuint _NumColorDrawBuffers;
- GLint _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS]; /**< BUFFER_x or -1 */
- GLint _ColorReadBufferIndex; /* -1 = None */
+ gl_buffer_index _ColorDrawBufferIndexes[MAX_DRAW_BUFFERS];
+ gl_buffer_index _ColorReadBufferIndex;
struct gl_renderbuffer *_ColorDrawBuffers[MAX_DRAW_BUFFERS];
struct gl_renderbuffer *_ColorReadBuffer;
GLuint MaxShaderStorageBlocks;
};
-
/**
* Constants which may be overridden by device driver during context creation
* but are never changed after that.
*/
GLboolean AllowGLSLBuiltinVariableRedeclaration;
+ /**
+ * Allow GLSL interpolation qualifier mismatch across shader stages.
+ */
+ GLboolean AllowGLSLCrossStageInterpolationMismatch;
+
/**
* Allow creating a higher compat profile (version 3.1+) for apps that
* request it. Be careful when adding that driconf option because some
GLuint MaxTessPatchComponents;
GLuint MaxTessControlTotalOutputComponents;
bool LowerTessLevel; /**< Lower gl_TessLevel* from float[n] to vecn? */
- bool LowerTCSPatchVerticesIn; /**< Lower gl_PatchVerticesIn to a uniform */
- bool LowerTESPatchVerticesIn; /**< Lower gl_PatchVerticesIn to a uniform */
bool PrimitiveRestartForPatches;
bool LowerCsDerivedVariables; /**< Lower gl_GlobalInvocationID and
* gl_LocalInvocationIndex based on
/** When drivers are OK with mapped buffers during draw and other calls. */
bool AllowMappedBuffersDuringExecution;
+
+ /** GL_ARB_get_program_binary */
+ GLuint NumProgramBinaryFormats;
};
GLboolean ARB_enhanced_layouts;
GLboolean ARB_explicit_attrib_location;
GLboolean ARB_explicit_uniform_location;
+ GLboolean ARB_gl_spirv;
GLboolean ARB_gpu_shader5;
GLboolean ARB_gpu_shader_fp64;
GLboolean ARB_gpu_shader_int64;
GLboolean EXT_blend_func_separate;
GLboolean EXT_blend_minmax;
GLboolean EXT_depth_bounds_test;
+ GLboolean EXT_disjoint_timer_query;
GLboolean EXT_draw_buffers2;
GLboolean EXT_framebuffer_multisample;
GLboolean EXT_framebuffer_multisample_blit_scaled;
GLboolean EXT_texture_sRGB;
GLboolean EXT_texture_sRGB_decode;
GLboolean EXT_texture_swizzle;
+ GLboolean EXT_texture_type_2_10_10_10_REV;
GLboolean EXT_transform_feedback;
GLboolean EXT_timer_query;
GLboolean EXT_vertex_array_bgra;
GLboolean KHR_texture_compression_astc_hdr;
GLboolean KHR_texture_compression_astc_ldr;
GLboolean KHR_texture_compression_astc_sliced_3d;
+ GLboolean MESA_tile_raster_order;
GLboolean MESA_pack_invert;
GLboolean MESA_shader_framebuffer_fetch;
GLboolean MESA_shader_framebuffer_fetch_non_coherent;
* while meta is in progress.
*/
GLubyte Version;
+ /**
+ * Force-enabled, yet unrecognized, extensions.
+ * See _mesa_one_time_init_extension_overrides()
+ */
+#define MAX_UNRECOGNIZED_EXTENSIONS 16
+ const char *unrecognized_extensions[MAX_UNRECOGNIZED_EXTENSIONS];
};
struct gl_display_list
{
GLuint Name;
- GLchar *Label; /**< GL_KHR_debug */
GLbitfield Flags; /**< DLIST_x flags */
+ GLchar *Label; /**< GL_KHR_debug */
/** The dlist commands are in a linked list of nodes */
union gl_dlist_node *Head;
};
*/
struct gl_dlist_state
{
- GLuint CallDepth; /**< Current recursion calling depth */
-
struct gl_display_list *CurrentList; /**< List currently being compiled */
union gl_dlist_node *CurrentBlock; /**< Pointer to current block of nodes */
GLuint CurrentPos; /**< Index into current block of nodes */
+ GLuint CallDepth; /**< Current recursion calling depth */
GLvertexformat ListVtxfmt;
/** gl_context::RasterDiscard */
uint64_t NewRasterizerDiscard;
+ /** gl_context::TileRasterOrder* */
+ uint64_t NewTileRasterOrder;
+
/**
* gl_context::UniformBufferBindings
* gl_shader_program::UniformBlocks
uint64_t NewShaderConstants[MESA_SHADER_STAGES];
};
-struct gl_uniform_buffer_binding
+struct gl_buffer_binding
{
struct gl_buffer_object *BufferObject;
/** Start of uniform block data in the buffer */
GLboolean AutomaticSize;
};
-struct gl_shader_storage_buffer_binding
-{
- struct gl_buffer_object *BufferObject;
- /** Start of shader storage block data in the buffer */
- GLintptr Offset;
- /** Size of data allowed to be referenced from the buffer (in bytes) */
- GLsizeiptr Size;
- /**
- * glBindBufferBase() indicates that the Size should be ignored and only
- * limited by the current size of the BufferObject.
- */
- GLboolean AutomaticSize;
-};
-
/**
* ARB_shader_image_load_store image unit.
*/
};
-/**
- * Binding point for an atomic counter buffer object.
- */
-struct gl_atomic_buffer_binding
-{
- struct gl_buffer_object *BufferObject;
- GLintptr Offset;
- GLsizeiptr Size;
-};
-
/**
* Shader subroutines storage
*/
* associated with uniform blocks by glUniformBlockBinding()'s state in the
* shader program.
*/
- struct gl_uniform_buffer_binding
+ struct gl_buffer_binding
UniformBufferBindings[MAX_COMBINED_UNIFORM_BUFFERS];
/**
* glBindBufferBase(). They are associated with shader storage blocks by
* glShaderStorageBlockBinding()'s state in the shader program.
*/
- struct gl_shader_storage_buffer_binding
+ struct gl_buffer_binding
ShaderStorageBufferBindings[MAX_COMBINED_SHADER_STORAGE_BUFFERS];
/**
/**
* Array of atomic counter buffer binding points.
*/
- struct gl_atomic_buffer_binding
+ struct gl_buffer_binding
AtomicBufferBindings[MAX_COMBINED_ATOMIC_BUFFERS];
/**
GLuint ErrorDebugCount;
/* GL_ARB_debug_output/GL_KHR_debug */
- mtx_t DebugMutex;
+ simple_mtx_t DebugMutex;
struct gl_debug_state *Debug;
GLenum RenderMode; /**< either GL_RENDER, GL_SELECT, GL_FEEDBACK */
GLboolean ViewportInitialized; /**< has viewport size been initialized? */
- GLbitfield64 varying_vp_inputs; /**< mask of VERT_BIT_* flags */
+ GLbitfield varying_vp_inputs; /**< mask of VERT_BIT_* flags */
/** \name Derived state */
GLbitfield _ImageTransferState;/**< bitwise-or of IMAGE_*_BIT flags */
GLfloat _EyeZDir[3];
- GLfloat _ModelViewInvScale;
+ GLfloat _ModelViewInvScale; /* may be for model- or eyespace lighting */
+ GLfloat _ModelViewInvScaleEyespace; /* always factor defined in spec */
GLboolean _NeedEyeCoords;
GLboolean _ForceEyeCoords;
*/
GLboolean HasConfig;
- /** software compression/decompression supported or not */
- GLboolean Mesa_DXTn;
-
GLboolean TextureFormatSupported[MESA_FORMAT_COUNT];
GLboolean RasterDiscard; /**< GL_RASTERIZER_DISCARD */
/** Does glVertexAttrib(0) alias glVertex()? */
bool _AttribZeroAliasesVertex;
+ /**
+ * When set, TileRasterOrderIncreasingX/Y control the order that a tiled
+ * renderer's tiles should be excecuted, to meet the requirements of
+ * GL_MESA_tile_raster_order.
+ */
+ GLboolean TileRasterOrderFixed;
+ GLboolean TileRasterOrderIncreasingX;
+ GLboolean TileRasterOrderIncreasingY;
+
/**
* \name Hooks for module contexts.
*