[Mesa-dev] [PATCH 1/6] gallium: use enums in p_defines.h
Marek Olšák
maraeo at gmail.com
Sat Apr 16 12:50:07 UTC 2016
From: Marek Olšák <marek.olsak at amd.com>
and remove number assignments which are consecutive
---
src/gallium/include/pipe/p_defines.h | 378 +++++++++++++++++++----------------
1 file changed, 205 insertions(+), 173 deletions(-)
diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
index 1aef21d..6bb180d 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -51,49 +51,56 @@ enum pipe_error
/* TODO */
};
+enum {
+ PIPE_BLENDFACTOR_ONE = 1,
+ PIPE_BLENDFACTOR_SRC_COLOR,
+ PIPE_BLENDFACTOR_SRC_ALPHA,
+ PIPE_BLENDFACTOR_DST_ALPHA,
+ PIPE_BLENDFACTOR_DST_COLOR,
+ PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE,
+ PIPE_BLENDFACTOR_CONST_COLOR,
+ PIPE_BLENDFACTOR_CONST_ALPHA,
+ PIPE_BLENDFACTOR_SRC1_COLOR,
+ PIPE_BLENDFACTOR_SRC1_ALPHA,
+
+ PIPE_BLENDFACTOR_ZERO = 0x11,
+ PIPE_BLENDFACTOR_INV_SRC_COLOR,
+ PIPE_BLENDFACTOR_INV_SRC_ALPHA,
+ PIPE_BLENDFACTOR_INV_DST_ALPHA,
+ PIPE_BLENDFACTOR_INV_DST_COLOR,
+
+ PIPE_BLENDFACTOR_INV_CONST_COLOR = 0x17,
+ PIPE_BLENDFACTOR_INV_CONST_ALPHA,
+ PIPE_BLENDFACTOR_INV_SRC1_COLOR,
+ PIPE_BLENDFACTOR_INV_SRC1_ALPHA,
+};
+
+enum {
+ PIPE_BLEND_ADD,
+ PIPE_BLEND_SUBTRACT,
+ PIPE_BLEND_REVERSE_SUBTRACT,
+ PIPE_BLEND_MIN,
+ PIPE_BLEND_MAX,
+};
-#define PIPE_BLENDFACTOR_ONE 0x1
-#define PIPE_BLENDFACTOR_SRC_COLOR 0x2
-#define PIPE_BLENDFACTOR_SRC_ALPHA 0x3
-#define PIPE_BLENDFACTOR_DST_ALPHA 0x4
-#define PIPE_BLENDFACTOR_DST_COLOR 0x5
-#define PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE 0x6
-#define PIPE_BLENDFACTOR_CONST_COLOR 0x7
-#define PIPE_BLENDFACTOR_CONST_ALPHA 0x8
-#define PIPE_BLENDFACTOR_SRC1_COLOR 0x9
-#define PIPE_BLENDFACTOR_SRC1_ALPHA 0x0A
-#define PIPE_BLENDFACTOR_ZERO 0x11
-#define PIPE_BLENDFACTOR_INV_SRC_COLOR 0x12
-#define PIPE_BLENDFACTOR_INV_SRC_ALPHA 0x13
-#define PIPE_BLENDFACTOR_INV_DST_ALPHA 0x14
-#define PIPE_BLENDFACTOR_INV_DST_COLOR 0x15
-#define PIPE_BLENDFACTOR_INV_CONST_COLOR 0x17
-#define PIPE_BLENDFACTOR_INV_CONST_ALPHA 0x18
-#define PIPE_BLENDFACTOR_INV_SRC1_COLOR 0x19
-#define PIPE_BLENDFACTOR_INV_SRC1_ALPHA 0x1A
-
-#define PIPE_BLEND_ADD 0
-#define PIPE_BLEND_SUBTRACT 1
-#define PIPE_BLEND_REVERSE_SUBTRACT 2
-#define PIPE_BLEND_MIN 3
-#define PIPE_BLEND_MAX 4
-
-#define PIPE_LOGICOP_CLEAR 0
-#define PIPE_LOGICOP_NOR 1
-#define PIPE_LOGICOP_AND_INVERTED 2
-#define PIPE_LOGICOP_COPY_INVERTED 3
-#define PIPE_LOGICOP_AND_REVERSE 4
-#define PIPE_LOGICOP_INVERT 5
-#define PIPE_LOGICOP_XOR 6
-#define PIPE_LOGICOP_NAND 7
-#define PIPE_LOGICOP_AND 8
-#define PIPE_LOGICOP_EQUIV 9
-#define PIPE_LOGICOP_NOOP 10
-#define PIPE_LOGICOP_OR_INVERTED 11
-#define PIPE_LOGICOP_COPY 12
-#define PIPE_LOGICOP_OR_REVERSE 13
-#define PIPE_LOGICOP_OR 14
-#define PIPE_LOGICOP_SET 15
+enum {
+ PIPE_LOGICOP_CLEAR,
+ PIPE_LOGICOP_NOR,
+ PIPE_LOGICOP_AND_INVERTED,
+ PIPE_LOGICOP_COPY_INVERTED,
+ PIPE_LOGICOP_AND_REVERSE,
+ PIPE_LOGICOP_INVERT,
+ PIPE_LOGICOP_XOR,
+ PIPE_LOGICOP_NAND,
+ PIPE_LOGICOP_AND,
+ PIPE_LOGICOP_EQUIV,
+ PIPE_LOGICOP_NOOP,
+ PIPE_LOGICOP_OR_INVERTED,
+ PIPE_LOGICOP_COPY,
+ PIPE_LOGICOP_OR_REVERSE,
+ PIPE_LOGICOP_OR,
+ PIPE_LOGICOP_SET,
+};
#define PIPE_MASK_R 0x1
#define PIPE_MASK_G 0x2
@@ -110,19 +117,23 @@ enum pipe_error
* Inequality functions. Used for depth test, stencil compare, alpha
* test, shadow compare, etc.
*/
-#define PIPE_FUNC_NEVER 0
-#define PIPE_FUNC_LESS 1
-#define PIPE_FUNC_EQUAL 2
-#define PIPE_FUNC_LEQUAL 3
-#define PIPE_FUNC_GREATER 4
-#define PIPE_FUNC_NOTEQUAL 5
-#define PIPE_FUNC_GEQUAL 6
-#define PIPE_FUNC_ALWAYS 7
+enum {
+ PIPE_FUNC_NEVER,
+ PIPE_FUNC_LESS,
+ PIPE_FUNC_EQUAL,
+ PIPE_FUNC_LEQUAL,
+ PIPE_FUNC_GREATER,
+ PIPE_FUNC_NOTEQUAL,
+ PIPE_FUNC_GEQUAL,
+ PIPE_FUNC_ALWAYS,
+};
/** Polygon fill mode */
-#define PIPE_POLYGON_MODE_FILL 0
-#define PIPE_POLYGON_MODE_LINE 1
-#define PIPE_POLYGON_MODE_POINT 2
+enum {
+ PIPE_POLYGON_MODE_FILL,
+ PIPE_POLYGON_MODE_LINE,
+ PIPE_POLYGON_MODE_POINT,
+};
/** Polygon face specification, eg for culling */
#define PIPE_FACE_NONE 0
@@ -131,60 +142,72 @@ enum pipe_error
#define PIPE_FACE_FRONT_AND_BACK (PIPE_FACE_FRONT | PIPE_FACE_BACK)
/** Stencil ops */
-#define PIPE_STENCIL_OP_KEEP 0
-#define PIPE_STENCIL_OP_ZERO 1
-#define PIPE_STENCIL_OP_REPLACE 2
-#define PIPE_STENCIL_OP_INCR 3
-#define PIPE_STENCIL_OP_DECR 4
-#define PIPE_STENCIL_OP_INCR_WRAP 5
-#define PIPE_STENCIL_OP_DECR_WRAP 6
-#define PIPE_STENCIL_OP_INVERT 7
+enum {
+ PIPE_STENCIL_OP_KEEP,
+ PIPE_STENCIL_OP_ZERO,
+ PIPE_STENCIL_OP_REPLACE,
+ PIPE_STENCIL_OP_INCR,
+ PIPE_STENCIL_OP_DECR,
+ PIPE_STENCIL_OP_INCR_WRAP,
+ PIPE_STENCIL_OP_DECR_WRAP,
+ PIPE_STENCIL_OP_INVERT,
+};
/** Texture types.
* See the documentation for info on PIPE_TEXTURE_RECT vs PIPE_TEXTURE_2D
*/
enum pipe_texture_target
{
- PIPE_BUFFER = 0,
- PIPE_TEXTURE_1D = 1,
- PIPE_TEXTURE_2D = 2,
- PIPE_TEXTURE_3D = 3,
- PIPE_TEXTURE_CUBE = 4,
- PIPE_TEXTURE_RECT = 5,
- PIPE_TEXTURE_1D_ARRAY = 6,
- PIPE_TEXTURE_2D_ARRAY = 7,
- PIPE_TEXTURE_CUBE_ARRAY = 8,
- PIPE_MAX_TEXTURE_TYPES
-};
-
-#define PIPE_TEX_FACE_POS_X 0
-#define PIPE_TEX_FACE_NEG_X 1
-#define PIPE_TEX_FACE_POS_Y 2
-#define PIPE_TEX_FACE_NEG_Y 3
-#define PIPE_TEX_FACE_POS_Z 4
-#define PIPE_TEX_FACE_NEG_Z 5
-#define PIPE_TEX_FACE_MAX 6
-
-#define PIPE_TEX_WRAP_REPEAT 0
-#define PIPE_TEX_WRAP_CLAMP 1
-#define PIPE_TEX_WRAP_CLAMP_TO_EDGE 2
-#define PIPE_TEX_WRAP_CLAMP_TO_BORDER 3
-#define PIPE_TEX_WRAP_MIRROR_REPEAT 4
-#define PIPE_TEX_WRAP_MIRROR_CLAMP 5
-#define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE 6
-#define PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER 7
+ PIPE_BUFFER,
+ PIPE_TEXTURE_1D,
+ PIPE_TEXTURE_2D,
+ PIPE_TEXTURE_3D,
+ PIPE_TEXTURE_CUBE,
+ PIPE_TEXTURE_RECT,
+ PIPE_TEXTURE_1D_ARRAY,
+ PIPE_TEXTURE_2D_ARRAY,
+ PIPE_TEXTURE_CUBE_ARRAY,
+ PIPE_MAX_TEXTURE_TYPES,
+};
+
+enum {
+ PIPE_TEX_FACE_POS_X,
+ PIPE_TEX_FACE_NEG_X,
+ PIPE_TEX_FACE_POS_Y,
+ PIPE_TEX_FACE_NEG_Y,
+ PIPE_TEX_FACE_POS_Z,
+ PIPE_TEX_FACE_NEG_Z,
+ PIPE_TEX_FACE_MAX,
+};
+
+enum {
+ PIPE_TEX_WRAP_REPEAT,
+ PIPE_TEX_WRAP_CLAMP,
+ PIPE_TEX_WRAP_CLAMP_TO_EDGE,
+ PIPE_TEX_WRAP_CLAMP_TO_BORDER,
+ PIPE_TEX_WRAP_MIRROR_REPEAT,
+ PIPE_TEX_WRAP_MIRROR_CLAMP,
+ PIPE_TEX_WRAP_MIRROR_CLAMP_TO_EDGE,
+ PIPE_TEX_WRAP_MIRROR_CLAMP_TO_BORDER,
+};
/** Between mipmaps, ie mipfilter */
-#define PIPE_TEX_MIPFILTER_NEAREST 0
-#define PIPE_TEX_MIPFILTER_LINEAR 1
-#define PIPE_TEX_MIPFILTER_NONE 2
+enum {
+ PIPE_TEX_MIPFILTER_NEAREST,
+ PIPE_TEX_MIPFILTER_LINEAR,
+ PIPE_TEX_MIPFILTER_NONE,
+};
/** Within a mipmap, ie min/mag filter */
-#define PIPE_TEX_FILTER_NEAREST 0
-#define PIPE_TEX_FILTER_LINEAR 1
+enum {
+ PIPE_TEX_FILTER_NEAREST,
+ PIPE_TEX_FILTER_LINEAR,
+};
-#define PIPE_TEX_COMPARE_NONE 0
-#define PIPE_TEX_COMPARE_R_TO_TEXTURE 1
+enum {
+ PIPE_TEX_COMPARE_NONE,
+ PIPE_TEX_COMPARE_R_TO_TEXTURE,
+};
/**
* Clear buffer bits
@@ -430,98 +453,107 @@ enum pipe_flush_flags
* Hint about the expected lifecycle of a resource.
* Sorted according to GPU vs CPU access.
*/
-#define PIPE_USAGE_DEFAULT 0 /* fast GPU access */
-#define PIPE_USAGE_IMMUTABLE 1 /* fast GPU access, immutable */
-#define PIPE_USAGE_DYNAMIC 2 /* uploaded data is used multiple times */
-#define PIPE_USAGE_STREAM 3 /* uploaded data is used once */
-#define PIPE_USAGE_STAGING 4 /* fast CPU access */
-
+enum {
+ PIPE_USAGE_DEFAULT, /* fast GPU access */
+ PIPE_USAGE_IMMUTABLE, /* fast GPU access, immutable */
+ PIPE_USAGE_DYNAMIC, /* uploaded data is used multiple times */
+ PIPE_USAGE_STREAM, /* uploaded data is used once */
+ PIPE_USAGE_STAGING, /* fast CPU access */
+};
/**
* Shaders
*/
-#define PIPE_SHADER_VERTEX 0
-#define PIPE_SHADER_FRAGMENT 1
-#define PIPE_SHADER_GEOMETRY 2
-#define PIPE_SHADER_TESS_CTRL 3
-#define PIPE_SHADER_TESS_EVAL 4
-#define PIPE_SHADER_COMPUTE 5
-#define PIPE_SHADER_TYPES 6
-
+enum {
+ PIPE_SHADER_VERTEX,
+ PIPE_SHADER_FRAGMENT,
+ PIPE_SHADER_GEOMETRY,
+ PIPE_SHADER_TESS_CTRL,
+ PIPE_SHADER_TESS_EVAL,
+ PIPE_SHADER_COMPUTE,
+ PIPE_SHADER_TYPES,
+};
/**
* Primitive types:
*/
-#define PIPE_PRIM_POINTS 0
-#define PIPE_PRIM_LINES 1
-#define PIPE_PRIM_LINE_LOOP 2
-#define PIPE_PRIM_LINE_STRIP 3
-#define PIPE_PRIM_TRIANGLES 4
-#define PIPE_PRIM_TRIANGLE_STRIP 5
-#define PIPE_PRIM_TRIANGLE_FAN 6
-#define PIPE_PRIM_QUADS 7
-#define PIPE_PRIM_QUAD_STRIP 8
-#define PIPE_PRIM_POLYGON 9
-#define PIPE_PRIM_LINES_ADJACENCY 10
-#define PIPE_PRIM_LINE_STRIP_ADJACENCY 11
-#define PIPE_PRIM_TRIANGLES_ADJACENCY 12
-#define PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY 13
-#define PIPE_PRIM_PATCHES 14
-#define PIPE_PRIM_MAX 15
-
+enum {
+ PIPE_PRIM_POINTS,
+ PIPE_PRIM_LINES,
+ PIPE_PRIM_LINE_LOOP,
+ PIPE_PRIM_LINE_STRIP,
+ PIPE_PRIM_TRIANGLES,
+ PIPE_PRIM_TRIANGLE_STRIP,
+ PIPE_PRIM_TRIANGLE_FAN,
+ PIPE_PRIM_QUADS,
+ PIPE_PRIM_QUAD_STRIP,
+ PIPE_PRIM_POLYGON,
+ PIPE_PRIM_LINES_ADJACENCY,
+ PIPE_PRIM_LINE_STRIP_ADJACENCY,
+ PIPE_PRIM_TRIANGLES_ADJACENCY,
+ PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY,
+ PIPE_PRIM_PATCHES,
+ PIPE_PRIM_MAX,
+};
/**
* Tessellator spacing types
*/
-#define PIPE_TESS_SPACING_FRACTIONAL_ODD 0
-#define PIPE_TESS_SPACING_FRACTIONAL_EVEN 1
-#define PIPE_TESS_SPACING_EQUAL 2
+enum {
+ PIPE_TESS_SPACING_FRACTIONAL_ODD,
+ PIPE_TESS_SPACING_FRACTIONAL_EVEN,
+ PIPE_TESS_SPACING_EQUAL,
+};
/**
* Query object types
*/
-#define PIPE_QUERY_OCCLUSION_COUNTER 0
-#define PIPE_QUERY_OCCLUSION_PREDICATE 1
-#define PIPE_QUERY_TIMESTAMP 2
-#define PIPE_QUERY_TIMESTAMP_DISJOINT 3
-#define PIPE_QUERY_TIME_ELAPSED 4
-#define PIPE_QUERY_PRIMITIVES_GENERATED 5
-#define PIPE_QUERY_PRIMITIVES_EMITTED 6
-#define PIPE_QUERY_SO_STATISTICS 7
-#define PIPE_QUERY_SO_OVERFLOW_PREDICATE 8
-#define PIPE_QUERY_GPU_FINISHED 9
-#define PIPE_QUERY_PIPELINE_STATISTICS 10
-#define PIPE_QUERY_TYPES 11
-/* start of driver queries, see pipe_screen::get_driver_query_info */
-#define PIPE_QUERY_DRIVER_SPECIFIC 256
-
+enum {
+ PIPE_QUERY_OCCLUSION_COUNTER,
+ PIPE_QUERY_OCCLUSION_PREDICATE,
+ PIPE_QUERY_TIMESTAMP,
+ PIPE_QUERY_TIMESTAMP_DISJOINT,
+ PIPE_QUERY_TIME_ELAPSED,
+ PIPE_QUERY_PRIMITIVES_GENERATED,
+ PIPE_QUERY_PRIMITIVES_EMITTED,
+ PIPE_QUERY_SO_STATISTICS,
+ PIPE_QUERY_SO_OVERFLOW_PREDICATE,
+ PIPE_QUERY_GPU_FINISHED,
+ PIPE_QUERY_PIPELINE_STATISTICS,
+ PIPE_QUERY_TYPES,
+ /* start of driver queries, see pipe_screen::get_driver_query_info */
+ PIPE_QUERY_DRIVER_SPECIFIC = 256,
+};
/**
* Conditional rendering modes
*/
-#define PIPE_RENDER_COND_WAIT 0
-#define PIPE_RENDER_COND_NO_WAIT 1
-#define PIPE_RENDER_COND_BY_REGION_WAIT 2
-#define PIPE_RENDER_COND_BY_REGION_NO_WAIT 3
-
+enum {
+ PIPE_RENDER_COND_WAIT,
+ PIPE_RENDER_COND_NO_WAIT,
+ PIPE_RENDER_COND_BY_REGION_WAIT,
+ PIPE_RENDER_COND_BY_REGION_NO_WAIT,
+};
/**
* Point sprite coord modes
*/
-#define PIPE_SPRITE_COORD_UPPER_LEFT 0
-#define PIPE_SPRITE_COORD_LOWER_LEFT 1
-
+enum {
+ PIPE_SPRITE_COORD_UPPER_LEFT,
+ PIPE_SPRITE_COORD_LOWER_LEFT,
+};
/**
* Texture swizzles
*/
-#define PIPE_SWIZZLE_RED 0
-#define PIPE_SWIZZLE_GREEN 1
-#define PIPE_SWIZZLE_BLUE 2
-#define PIPE_SWIZZLE_ALPHA 3
-#define PIPE_SWIZZLE_ZERO 4
-#define PIPE_SWIZZLE_ONE 5
-
+enum {
+ PIPE_SWIZZLE_RED,
+ PIPE_SWIZZLE_GREEN,
+ PIPE_SWIZZLE_BLUE,
+ PIPE_SWIZZLE_ALPHA,
+ PIPE_SWIZZLE_ZERO,
+ PIPE_SWIZZLE_ONE,
+};
#define PIPE_TIMEOUT_INFINITE 0xffffffffffffffffull
@@ -531,10 +563,10 @@ enum pipe_flush_flags
*/
enum pipe_reset_status
{
- PIPE_NO_RESET = 0,
- PIPE_GUILTY_CONTEXT_RESET = 1,
- PIPE_INNOCENT_CONTEXT_RESET = 2,
- PIPE_UNKNOWN_CONTEXT_RESET = 3
+ PIPE_NO_RESET,
+ PIPE_GUILTY_CONTEXT_RESET,
+ PIPE_INNOCENT_CONTEXT_RESET,
+ PIPE_UNKNOWN_CONTEXT_RESET,
};
@@ -903,13 +935,13 @@ union pipe_color_union
enum pipe_driver_query_type
{
- PIPE_DRIVER_QUERY_TYPE_UINT64 = 0,
- PIPE_DRIVER_QUERY_TYPE_UINT = 1,
- PIPE_DRIVER_QUERY_TYPE_FLOAT = 2,
- PIPE_DRIVER_QUERY_TYPE_PERCENTAGE = 3,
- PIPE_DRIVER_QUERY_TYPE_BYTES = 4,
- PIPE_DRIVER_QUERY_TYPE_MICROSECONDS = 5,
- PIPE_DRIVER_QUERY_TYPE_HZ = 6,
+ PIPE_DRIVER_QUERY_TYPE_UINT64,
+ PIPE_DRIVER_QUERY_TYPE_UINT,
+ PIPE_DRIVER_QUERY_TYPE_FLOAT,
+ PIPE_DRIVER_QUERY_TYPE_PERCENTAGE,
+ PIPE_DRIVER_QUERY_TYPE_BYTES,
+ PIPE_DRIVER_QUERY_TYPE_MICROSECONDS,
+ PIPE_DRIVER_QUERY_TYPE_HZ,
};
/* Whether an average value per frame or a cumulative value should be
@@ -917,8 +949,8 @@ enum pipe_driver_query_type
*/
enum pipe_driver_query_result_type
{
- PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE = 0,
- PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE = 1,
+ PIPE_DRIVER_QUERY_RESULT_TYPE_AVERAGE,
+ PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE,
};
/**
--
2.5.0
More information about the mesa-dev
mailing list