#include "main/formats.h" /* MESA_FORMAT_COUNT */
#include "compiler/glsl/list.h"
#include "util/bitscan.h"
+#include "util/u_dynarray.h"
#ifdef __cplusplus
BUFFER_COLOR5,
BUFFER_COLOR6,
BUFFER_COLOR7,
- BUFFER_COUNT
+ BUFFER_COUNT,
+ BUFFER_NONE = -1,
} gl_buffer_index;
/**
BUFFER_BIT_COLOR6 | \
BUFFER_BIT_COLOR7)
+/* Mask of bits for depth+stencil buffers */
+#define BUFFER_BITS_DEPTH_STENCIL (BUFFER_BIT_DEPTH | BUFFER_BIT_STENCIL)
+
/**
* Framebuffer configuration (aka visual / pixelformat)
* Note: some of these fields should be boolean, but it appears that
};
+/**
+ * Compressed fog mode.
+ */
+enum gl_fog_mode
+{
+ FOG_NONE,
+ FOG_LINEAR,
+ FOG_EXP,
+ FOG_EXP2,
+};
+
+
/**
* Fog attribute group (GL_FOG_BIT).
*/
{
GLboolean Enabled; /**< Fog enabled flag */
GLboolean ColorSumEnabled;
+ uint8_t _PackedMode; /**< Fog mode as 2 bits */
+ uint8_t _PackedEnabledMode; /**< Masked CompressedMode */
GLfloat ColorUnclamped[4]; /**< Fog color */
GLfloat Color[4]; /**< Fog color */
GLfloat Density; /**< Density >= 0.0 */
/* ARB_texture_multisample / GL3.2 additions */
GLboolean SampleMask;
- GLfloat SampleCoverageValue;
- GLfloat MinSampleShadingValue;
+ GLfloat SampleCoverageValue; /**< In range [0, 1] */
+ GLfloat MinSampleShadingValue; /**< In range [0, 1] */
/** The GL spec defines this as an array but >32x MSAA is madness */
GLbitfield SampleMaskValue;
GLenum FrontFace; /**< Either GL_CW or GL_CCW */
GLenum FrontMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
GLenum BackMode; /**< Either GL_POINT, GL_LINE or GL_FILL */
- GLboolean _FrontBit; /**< 0=GL_CCW, 1=GL_CW */
GLboolean CullFlag; /**< Culling on/off flag */
GLboolean SmoothFlag; /**< True if GL_POLYGON_SMOOTH is enabled */
GLboolean StippleFlag; /**< True if GL_POLYGON_STIPPLE is enabled */
GLboolean Enabled; /**< Enabled flag */
GLboolean TestTwoSide; /**< GL_EXT_stencil_two_side */
GLubyte ActiveFace; /**< GL_EXT_stencil_two_side (0 or 2) */
- GLboolean _Enabled; /**< Enabled and stencil buffer present */
- GLboolean _WriteEnabled; /**< _Enabled and non-zero writemasks */
- GLboolean _TestTwoSide;
GLubyte _BackFace; /**< Current back stencil state (1 or 2) */
GLenum Function[3]; /**< Stencil function */
GLenum FailFunc[3]; /**< Fail function */
GLenum CompareFunc; /**< GL_ARB_shadow */
GLenum sRGBDecode; /**< GL_DECODE_EXT or GL_SKIP_DECODE_EXT */
GLboolean CubeMapSeamless; /**< GL_AMD_seamless_cubemap_per_texture */
+
+ /** GL_ARB_bindless_texture */
+ struct util_dynarray Handles;
+ bool HandleAllocated;
};
/** GL_ARB_shader_image_load_store */
GLenum ImageFormatCompatibilityType;
+
+ /** GL_ARB_bindless_texture */
+ struct util_dynarray SamplerHandles;
+ struct util_dynarray ImageHandles;
+ bool HandleAllocated;
};
};
+/** Compressed TexEnv effective Combine mode */
+enum gl_tex_env_mode
+{
+ TEXENV_MODE_REPLACE, /* r = a0 */
+ TEXENV_MODE_MODULATE, /* r = a0 * a1 */
+ TEXENV_MODE_ADD, /* r = a0 + a1 */
+ TEXENV_MODE_ADD_SIGNED, /* r = a0 + a1 - 0.5 */
+ TEXENV_MODE_INTERPOLATE, /* r = a0 * a2 + a1 * (1 - a2) */
+ TEXENV_MODE_SUBTRACT, /* r = a0 - a1 */
+ TEXENV_MODE_DOT3_RGB, /* r = a0 . a1 */
+ TEXENV_MODE_DOT3_RGB_EXT, /* r = a0 . a1 */
+ TEXENV_MODE_DOT3_RGBA, /* r = a0 . a1 */
+ TEXENV_MODE_DOT3_RGBA_EXT, /* r = a0 . a1 */
+ TEXENV_MODE_MODULATE_ADD_ATI, /* r = a0 * a2 + a1 */
+ TEXENV_MODE_MODULATE_SIGNED_ADD_ATI, /* r = a0 * a2 + a1 - 0.5 */
+ TEXENV_MODE_MODULATE_SUBTRACT_ATI, /* r = a0 * a2 - a1 */
+ TEXENV_MODE_ADD_PRODUCTS_NV, /* r = a0 * a1 + a2 * a3 */
+ TEXENV_MODE_ADD_PRODUCTS_SIGNED_NV, /* r = a0 * a1 + a2 * a3 - 0.5 */
+};
+
+
+/** Compressed TexEnv Combine source */
+enum gl_tex_env_source
+{
+ TEXENV_SRC_TEXTURE0,
+ TEXENV_SRC_TEXTURE1,
+ TEXENV_SRC_TEXTURE2,
+ TEXENV_SRC_TEXTURE3,
+ TEXENV_SRC_TEXTURE4,
+ TEXENV_SRC_TEXTURE5,
+ TEXENV_SRC_TEXTURE6,
+ TEXENV_SRC_TEXTURE7,
+ TEXENV_SRC_TEXTURE,
+ TEXENV_SRC_PREVIOUS,
+ TEXENV_SRC_PRIMARY_COLOR,
+ TEXENV_SRC_CONSTANT,
+ TEXENV_SRC_ZERO,
+ TEXENV_SRC_ONE,
+};
+
+
+/** Compressed TexEnv Combine operand */
+enum gl_tex_env_operand
+{
+ TEXENV_OPR_COLOR,
+ TEXENV_OPR_ONE_MINUS_COLOR,
+ TEXENV_OPR_ALPHA,
+ TEXENV_OPR_ONE_MINUS_ALPHA,
+};
+
+
+/** Compressed TexEnv Combine argument */
+struct gl_tex_env_argument
+{
+#ifdef __GNUC__
+ __extension__ uint8_t Source:4; /**< TEXENV_SRC_x */
+ __extension__ uint8_t Operand:2; /**< TEXENV_OPR_x */
+#else
+ uint8_t Source; /**< SRC_x */
+ uint8_t Operand; /**< OPR_x */
+#endif
+};
+
+
+/***
+ * Compressed TexEnv Combine state.
+ */
+struct gl_tex_env_combine_packed
+{
+ uint32_t ModeRGB:4; /**< Effective mode for RGB as 4 bits */
+ uint32_t ModeA:4; /**< Effective mode for RGB as 4 bits */
+ uint32_t ScaleShiftRGB:2; /**< 0, 1 or 2 */
+ uint32_t ScaleShiftA:2; /**< 0, 1 or 2 */
+ uint32_t NumArgsRGB:3; /**< Number of inputs used for the RGB combiner */
+ uint32_t NumArgsA:3; /**< Number of inputs used for the A combiner */
+ /** Source arguments in a packed manner */
+ struct gl_tex_env_argument ArgsRGB[MAX_COMBINER_TERMS];
+ struct gl_tex_env_argument ArgsA[MAX_COMBINER_TERMS];
+};
+
+
/**
* TexGenEnabled flags.
*/
/** Points to highest priority, complete and enabled texture object */
struct gl_texture_object *_Current;
+ /** Current compressed TexEnv & Combine state */
+ struct gl_tex_env_combine_packed _CurrentCombinePacked;
};
unsigned MinMaxCacheHitIndices;
unsigned MinMaxCacheMissIndices;
bool MinMaxCacheDirty;
+
+ bool HandleAllocated; /**< GL_ARB_bindless_texture */
};
/**
- * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+,
- * GL_ARB_vertex_array_object, or the original GL_APPLE_vertex_array_object
- * extension.
+ * A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
+ * the GL_ARB_vertex_array_object extension.
*/
struct gl_vertex_array_object
{
GLchar *Label; /**< GL_KHR_debug */
- mtx_t Mutex;
-
- /**
- * Does the VAO use ARB semantics or Apple semantics?
- *
- * There are several ways in which ARB_vertex_array_object and
- * APPLE_vertex_array_object VAOs have differing semantics. At the very
- * least,
- *
- * - ARB VAOs require that all array data be sourced from vertex buffer
- * objects, but Apple VAOs do not.
- *
- * - ARB VAOs require that names come from GenVertexArrays.
- *
- * This flag notes which behavior governs this VAO.
- */
- GLboolean ARBsemantics;
-
/**
* Has this array object been bound?
*/
*/
struct gl_array_attrib
{
- /** Currently bound array object. See _mesa_BindVertexArrayAPPLE() */
+ /** Currently bound array object. */
struct gl_vertex_array_object *VAO;
/** The default vertex array object */
/** The last VAO accessed by a DSA function */
struct gl_vertex_array_object *LastLookedUpVAO;
- /** Array objects (GL_ARB/APPLE_vertex_array_object) */
+ /** Array objects (GL_ARB_vertex_array_object) */
struct _mesa_HashTable *Objects;
GLint ActiveTexture; /**< Client Active Texture */
};
+/**
+ * A bindless sampler object.
+ */
+struct gl_bindless_sampler
+{
+ /** 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;
+
+ /** Pointer to the base of the data. */
+ GLvoid *data;
+};
+
+/**
+ * A bindless image object.
+ */
+struct gl_bindless_image
+{
+ /** 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;
+
+ /** Pointer to the base of the data. */
+ GLvoid *data;
+};
+
/**
* Names of the various vertex/fragment program register files, etc.
*
*/
gl_texture_index SamplerTargets[MAX_SAMPLERS];
+ /**
+ * Number of samplers declared with the bindless_sampler layout
+ * qualifier as specified by ARB_bindless_texture.
+ */
+ GLuint NumBindlessSamplers;
+ GLboolean HasBoundBindlessSampler;
+ struct gl_bindless_sampler *BindlessSamplers;
+
+ /**
+ * Number of images declared with the bindless_image layout qualifier
+ * as specified by ARB_bindless_texture.
+ */
+ GLuint NumBindlessImages;
+ GLboolean HasBoundBindlessImage;
+ struct gl_bindless_image *BindlessImages;
+
union {
struct {
/**
struct gl_vertex_program_state
{
GLboolean Enabled; /**< User-set GL_VERTEX_PROGRAM_ARB/NV flag */
- GLboolean _Enabled; /**< Enabled and _valid_ user program? */
GLboolean PointSizeEnabled; /**< GL_VERTEX_PROGRAM_POINT_SIZE_ARB/NV */
GLboolean TwoSideEnabled; /**< GL_VERTEX_PROGRAM_TWO_SIDE_ARB/NV */
- /** Computed two sided lighting for fixed function/programs. */
- GLboolean _TwoSideEnabled;
struct gl_program *Current; /**< User-bound vertex program */
/** Currently enabled and valid vertex program (including internal
struct gl_fragment_program_state
{
GLboolean Enabled; /**< User-set fragment program enable flag */
- GLboolean _Enabled; /**< Enabled and _valid_ user program? */
struct gl_program *Current; /**< User-bound fragment program */
/** Currently enabled and valid fragment program (including internal
struct gl_ati_fragment_shader_state
{
GLboolean Enabled;
- GLboolean _Enabled; /**< enabled and valid shader? */
GLboolean Compiling;
GLfloat GlobalConstants[8][4];
struct ati_fragment_shader *Current;
{
compile_failure = 0,
compile_success,
- compile_skipped
+ compile_skipped,
+ compiled_no_opts
};
/**
bool origin_upper_left;
bool pixel_center_integer;
+ /**
+ * Whether bindless_sampler/bindless_image, and respectively
+ * bound_sampler/bound_image are declared at global scope as defined by
+ * ARB_bindless_texture.
+ */
+ bool bindless_sampler;
+ bool bindless_image;
+ bool bound_sampler;
+ bool bound_image;
+
/** Global xfb_stride out qualifier if any */
GLuint TransformFeedbackBufferStride[MAX_FEEDBACK_BUFFERS];
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.
+ */
+ bool skip_cache;
+
/** List of all active resources after linking. */
struct gl_program_resource *ProgramResourceList;
unsigned NumProgramResourceList;
#define GLSL_REPORT_ERRORS 0x40 /**< Print compilation errors */
#define GLSL_DUMP_ON_ERROR 0x80 /**< Dump shaders to stderr on compile error */
#define GLSL_CACHE_INFO 0x100 /**< Print debug information about shader cache */
+#define GLSL_CACHE_FALLBACK 0x200 /**< Force shader cache fallback paths */
/**
GLint RefCount;
- mtx_t Mutex;
-
GLchar *Label; /**< GL_KHR_debug */
/**
struct gl_shader_program *ReferencedPrograms[MESA_SHADER_STAGES];
- struct gl_program *_CurrentFragmentProgram;
-
/**
* Program used by glUniform calls.
*
{
/** Driver-selectable options: */
GLboolean EmitNoLoops;
- GLboolean EmitNoFunctions;
GLboolean EmitNoCont; /**< Emit CONT opcode? */
GLboolean EmitNoMainReturn; /**< Emit CONT/RET opcodes? */
GLboolean EmitNoPow; /**< Emit POW opcodes? */
/** GL_ARB_sampler_objects */
struct _mesa_HashTable *SamplerObjects;
+ /* GL_ARB_bindless_texture */
+ struct hash_table_u64 *TextureHandles;
+ struct hash_table_u64 *ImageHandles;
+ mtx_t HandlesMutex; /**< For texture/image handles safety */
+
/**
* Some context in this share group was affected by a GPU reset
*
*/
GLboolean AllowGLSLExtensionDirectiveMidShader;
+ /**
+ * Allow GLSL built-in variables to be redeclared verbatim
+ */
+ GLboolean AllowGLSLBuiltinVariableRedeclaration;
+
/**
* Allow creating a higher compat profile (version 3.1+) for apps that
* request it. Be careful when adding that driconf option because some
/** Used as an input for sha1 generation in the on-disk shader cache */
unsigned char *dri_config_options_sha1;
+
+ /** When drivers are OK with mapped buffers during draw and other calls. */
+ bool AllowMappedBuffersDuringExecution;
};
GLboolean ARB_ES3_2_compatibility;
GLboolean ARB_arrays_of_arrays;
GLboolean ARB_base_instance;
+ GLboolean ARB_bindless_texture;
GLboolean ARB_blend_func_extended;
GLboolean ARB_buffer_storage;
GLboolean ARB_clear_texture;
GLboolean ARB_seamless_cube_map;
GLboolean ARB_shader_atomic_counter_ops;
GLboolean ARB_shader_atomic_counters;
+ GLboolean ARB_shader_ballot;
GLboolean ARB_shader_bit_encoding;
GLboolean ARB_shader_clock;
GLboolean ARB_shader_draw_parameters;
GLboolean ARB_shader_precision;
GLboolean ARB_shader_stencil_export;
GLboolean ARB_shader_storage_buffer_object;
- GLboolean ARB_shader_subroutine;
GLboolean ARB_shader_texture_image_samples;
GLboolean ARB_shader_texture_lod;
GLboolean ARB_shader_viewport_layer_array;
* gl_context::IntelConservativeRasterization
*/
uint64_t NewIntelConservativeRasterization;
+
+ /**
+ * gl_context::Scissor::WindowRects
+ */
+ uint64_t NewWindowRectangles;
+
+ /** gl_context::Color::sRGBEnabled */
+ uint64_t NewFramebufferSRGB;
+
+ /** gl_context::Scissor::EnableFlags */
+ uint64_t NewScissorTest;
+
+ /** gl_context::Scissor::ScissorArray */
+ uint64_t NewScissorRect;
+
+ /** gl_context::Stencil */
+ uint64_t NewStencil;
};
struct gl_uniform_buffer_binding
GLuint *IndexPtr;
};
+struct gl_texture_handle_object
+{
+ struct gl_texture_object *texObj;
+ struct gl_sampler_object *sampObj;
+ GLuint64 handle;
+};
+
+struct gl_image_handle_object
+{
+ struct gl_image_unit imgObj;
+ GLuint64 handle;
+};
+
/**
* Mesa rendering context.
*
GLfloat PrimitiveBoundingBox[8];
struct disk_cache *Cache;
+
+ /**
+ * \name GL_ARB_bindless_texture
+ */
+ /*@{*/
+ struct hash_table_u64 *ResidentTextureHandles;
+ struct hash_table_u64 *ResidentImageHandles;
+ /*@}*/
};
/**