From: Francisco Jerez Date: Mon, 15 Nov 2010 15:48:29 +0000 (+0100) Subject: dri/nouveau: Kill a bunch of ternary operators. X-Git-Tag: 062012170305~8904 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=88850b3e4f5f2692bf77d46fab031bd573f4d642;p=profile%2Fivi%2Fmesa.git dri/nouveau: Kill a bunch of ternary operators. --- diff --git a/src/mesa/drivers/dri/nouveau/nouveau_util.h b/src/mesa/drivers/dri/nouveau/nouveau_util.h index 8df8867..6d01934 100644 --- a/src/mesa/drivers/dri/nouveau/nouveau_util.h +++ b/src/mesa/drivers/dri/nouveau/nouveau_util.h @@ -164,6 +164,12 @@ get_viewport_translate(struct gl_context *ctx, float a[4]) } static inline void +OUT_RINGb(struct nouveau_channel *chan, GLboolean x) +{ + OUT_RING(chan, x ? 1 : 0); +} + +static inline void OUT_RINGm(struct nouveau_channel *chan, float m[16]) { int i, j; diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c index 63f5f74..056054e 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_fb.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_fb.c @@ -27,9 +27,9 @@ #include "nouveau_driver.h" #include "nouveau_context.h" #include "nouveau_fbo.h" +#include "nouveau_util.h" #include "nv_object.xml.h" #include "nv10_3d.xml.h" -#include "nouveau_util.h" #include "nv10_driver.h" static inline unsigned @@ -205,7 +205,7 @@ nv10_emit_zclear(struct gl_context *ctx, int emit) if (nfb->hierz.bo) { BEGIN_RING(chan, celsius, NV17_3D_ZCLEAR_ENABLE, 2); - OUT_RING(chan, nctx->hierz.clear_blocked ? 0 : 1); + OUT_RINGb(chan, !nctx->hierz.clear_blocked); OUT_RING(chan, nfb->hierz.clear_value | (nctx->hierz.clear_seq & 0xff)); } else { diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c b/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c index f0f7dd2..3f80790 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_polygon.c @@ -27,6 +27,7 @@ #include "nouveau_driver.h" #include "nouveau_context.h" #include "nouveau_gldefs.h" +#include "nouveau_util.h" #include "nv10_3d.xml.h" #include "nv10_driver.h" @@ -38,7 +39,7 @@ nv10_emit_cull_face(struct gl_context *ctx, int emit) GLenum mode = ctx->Polygon.CullFaceMode; BEGIN_RING(chan, celsius, NV10_3D_CULL_FACE_ENABLE, 1); - OUT_RING(chan, ctx->Polygon.CullFlag ? 1 : 0); + OUT_RINGb(chan, ctx->Polygon.CullFlag); BEGIN_RING(chan, celsius, NV10_3D_CULL_FACE, 1); OUT_RING(chan, (mode == GL_FRONT ? NV10_3D_CULL_FACE_FRONT : @@ -69,7 +70,7 @@ nv10_emit_line_mode(struct gl_context *ctx, int emit) OUT_RING(chan, MAX2(smooth ? 0 : 1, ctx->Line.Width) * 8); BEGIN_RING(chan, celsius, NV10_3D_LINE_SMOOTH_ENABLE, 1); - OUT_RING(chan, smooth ? 1 : 0); + OUT_RINGb(chan, smooth); } void @@ -87,7 +88,7 @@ nv10_emit_point_mode(struct gl_context *ctx, int emit) OUT_RING(chan, (uint32_t)(ctx->Point.Size * 8)); BEGIN_RING(chan, celsius, NV10_3D_POINT_SMOOTH_ENABLE, 1); - OUT_RING(chan, ctx->Point.SmoothFlag ? 1 : 0); + OUT_RINGb(chan, ctx->Point.SmoothFlag); } void @@ -101,7 +102,7 @@ nv10_emit_polygon_mode(struct gl_context *ctx, int emit) OUT_RING(chan, nvgl_polygon_mode(ctx->Polygon.BackMode)); BEGIN_RING(chan, celsius, NV10_3D_POLYGON_SMOOTH_ENABLE, 1); - OUT_RING(chan, ctx->Polygon.SmoothFlag ? 1 : 0); + OUT_RINGb(chan, ctx->Polygon.SmoothFlag); } void @@ -111,9 +112,9 @@ nv10_emit_polygon_offset(struct gl_context *ctx, int emit) struct nouveau_grobj *celsius = context_eng3d(ctx); BEGIN_RING(chan, celsius, NV10_3D_POLYGON_OFFSET_POINT_ENABLE, 3); - OUT_RING(chan, ctx->Polygon.OffsetPoint ? 1 : 0); - OUT_RING(chan, ctx->Polygon.OffsetLine ? 1 : 0); - OUT_RING(chan, ctx->Polygon.OffsetFill ? 1 : 0); + OUT_RINGb(chan, ctx->Polygon.OffsetPoint); + OUT_RINGb(chan, ctx->Polygon.OffsetLine); + OUT_RINGb(chan, ctx->Polygon.OffsetFill); BEGIN_RING(chan, celsius, NV10_3D_POLYGON_OFFSET_FACTOR, 2); OUT_RINGf(chan, ctx->Polygon.OffsetFactor); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c index 9215391..bb1084e 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_raster.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_raster.c @@ -27,6 +27,7 @@ #include "nouveau_driver.h" #include "nouveau_context.h" #include "nouveau_gldefs.h" +#include "nouveau_util.h" #include "nv10_3d.xml.h" #include "nv10_driver.h" @@ -37,7 +38,7 @@ nv10_emit_alpha_func(struct gl_context *ctx, int emit) struct nouveau_grobj *celsius = context_eng3d(ctx); BEGIN_RING(chan, celsius, NV10_3D_ALPHA_FUNC_ENABLE, 1); - OUT_RING(chan, ctx->Color.AlphaEnabled ? 1 : 0); + OUT_RINGb(chan, ctx->Color.AlphaEnabled); BEGIN_RING(chan, celsius, NV10_3D_ALPHA_FUNC_FUNC, 2); OUT_RING(chan, nvgl_comparison_op(ctx->Color.AlphaFunc)); @@ -64,7 +65,7 @@ nv10_emit_blend_equation(struct gl_context *ctx, int emit) struct nouveau_grobj *celsius = context_eng3d(ctx); BEGIN_RING(chan, celsius, NV10_3D_BLEND_FUNC_ENABLE, 1); - OUT_RING(chan, ctx->Color.BlendEnabled ? 1 : 0); + OUT_RINGb(chan, ctx->Color.BlendEnabled); BEGIN_RING(chan, celsius, NV10_3D_BLEND_EQUATION, 1); OUT_RING(chan, nvgl_blend_eqn(ctx->Color.BlendEquationRGB)); @@ -101,9 +102,9 @@ nv10_emit_depth(struct gl_context *ctx, int emit) struct nouveau_grobj *celsius = context_eng3d(ctx); BEGIN_RING(chan, celsius, NV10_3D_DEPTH_TEST_ENABLE, 1); - OUT_RING(chan, ctx->Depth.Test ? 1 : 0); + OUT_RINGb(chan, ctx->Depth.Test); BEGIN_RING(chan, celsius, NV10_3D_DEPTH_WRITE_ENABLE, 1); - OUT_RING(chan, ctx->Depth.Mask ? 1 : 0); + OUT_RINGb(chan, ctx->Depth.Mask); BEGIN_RING(chan, celsius, NV10_3D_DEPTH_FUNC, 1); OUT_RING(chan, nvgl_comparison_op(ctx->Depth.Func)); } @@ -115,7 +116,7 @@ nv10_emit_dither(struct gl_context *ctx, int emit) struct nouveau_grobj *celsius = context_eng3d(ctx); BEGIN_RING(chan, celsius, NV10_3D_DITHER_ENABLE, 1); - OUT_RING(chan, ctx->Color.DitherFlag ? 1 : 0); + OUT_RINGb(chan, ctx->Color.DitherFlag); } void @@ -128,7 +129,7 @@ nv10_emit_logic_opcode(struct gl_context *ctx, int emit) || context_chipset(ctx) >= 0x11); BEGIN_RING(chan, celsius, NV11_3D_COLOR_LOGIC_OP_ENABLE, 2); - OUT_RING(chan, ctx->Color.ColorLogicOpEnabled ? 1 : 0); + OUT_RINGb(chan, ctx->Color.ColorLogicOpEnabled); OUT_RING(chan, nvgl_logicop_func(ctx->Color.LogicOp)); } @@ -150,7 +151,7 @@ nv10_emit_stencil_func(struct gl_context *ctx, int emit) struct nouveau_grobj *celsius = context_eng3d(ctx); BEGIN_RING(chan, celsius, NV10_3D_STENCIL_ENABLE, 1); - OUT_RING(chan, ctx->Stencil.Enabled ? 1 : 0); + OUT_RINGb(chan, ctx->Stencil.Enabled); BEGIN_RING(chan, celsius, NV10_3D_STENCIL_FUNC_FUNC, 3); OUT_RING(chan, nvgl_comparison_op(ctx->Stencil.Function[0])); diff --git a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c index b9d07c1..e8bd12e 100644 --- a/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv10_state_tnl.c @@ -136,7 +136,7 @@ nv10_emit_fog(struct gl_context *ctx, int emit) BEGIN_RING(chan, celsius, NV10_3D_FOG_MODE, 4); OUT_RING(chan, get_fog_mode(f->Mode)); OUT_RING(chan, get_fog_source(source)); - OUT_RING(chan, f->Enabled ? 1 : 0); + OUT_RINGb(chan, f->Enabled); OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); BEGIN_RING(chan, celsius, NV10_3D_FOG_COEFF(0), 3); @@ -181,9 +181,9 @@ nv10_emit_light_enable(struct gl_context *ctx, int emit) BEGIN_RING(chan, celsius, NV10_3D_ENABLED_LIGHTS, 1); OUT_RING(chan, en_lights); BEGIN_RING(chan, celsius, NV10_3D_LIGHTING_ENABLE, 1); - OUT_RING(chan, ctx->Light.Enabled ? 1 : 0); + OUT_RINGb(chan, ctx->Light.Enabled); BEGIN_RING(chan, celsius, NV10_3D_NORMALIZE_ENABLE, 1); - OUT_RING(chan, ctx->Transform.Normalize ? 1 : 0); + OUT_RINGb(chan, ctx->Transform.Normalize); } void @@ -194,7 +194,7 @@ nv10_emit_light_model(struct gl_context *ctx, int emit) struct gl_lightmodel *m = &ctx->Light.Model; BEGIN_RING(chan, celsius, NV10_3D_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RING(chan, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR ? 1 : 0); + OUT_RINGb(chan, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR); BEGIN_RING(chan, celsius, NV10_3D_LIGHT_MODEL, 1); OUT_RING(chan, ((m->LocalViewer ? diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_raster.c b/src/mesa/drivers/dri/nouveau/nv20_state_raster.c index 4716952..3fb4eca 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_raster.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_raster.c @@ -27,6 +27,7 @@ #include "nouveau_driver.h" #include "nouveau_context.h" #include "nouveau_gldefs.h" +#include "nouveau_util.h" #include "nv20_3d.xml.h" #include "nv20_driver.h" @@ -37,6 +38,6 @@ nv20_emit_logic_opcode(struct gl_context *ctx, int emit) struct nouveau_grobj *kelvin = context_eng3d(ctx); BEGIN_RING(chan, kelvin, NV20_3D_COLOR_LOGIC_OP_ENABLE, 2); - OUT_RING(chan, ctx->Color.ColorLogicOpEnabled ? 1 : 0); + OUT_RINGb(chan, ctx->Color.ColorLogicOpEnabled); OUT_RING(chan, nvgl_logicop_func(ctx->Color.LogicOp)); } diff --git a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c index 2874584..4677198 100644 --- a/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c +++ b/src/mesa/drivers/dri/nouveau/nv20_state_tnl.c @@ -157,7 +157,7 @@ nv20_emit_fog(struct gl_context *ctx, int emit) get_fog_mode_signed(f->Mode) : get_fog_mode_unsigned(f->Mode))); OUT_RING(chan, get_fog_source(source)); - OUT_RING(chan, f->Enabled ? 1 : 0); + OUT_RINGb(chan, f->Enabled); OUT_RING(chan, pack_rgba_f(MESA_FORMAT_RGBA8888_REV, f->Color)); BEGIN_RING(chan, kelvin, NV20_3D_FOG_COEFF(0), 3); @@ -172,7 +172,7 @@ nv20_emit_light_model(struct gl_context *ctx, int emit) struct gl_lightmodel *m = &ctx->Light.Model; BEGIN_RING(chan, kelvin, NV20_3D_SEPARATE_SPECULAR_ENABLE, 1); - OUT_RING(chan, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR ? 1 : 0); + OUT_RINGb(chan, m->ColorControl == GL_SEPARATE_SPECULAR_COLOR); BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_MODEL, 1); OUT_RING(chan, ((m->LocalViewer ? @@ -183,7 +183,7 @@ nv20_emit_light_model(struct gl_context *ctx, int emit) 0))); BEGIN_RING(chan, kelvin, NV20_3D_LIGHT_MODEL_TWO_SIDE_ENABLE, 1); - OUT_RING(chan, ctx->Light.Model.TwoSide ? 1 : 0); + OUT_RINGb(chan, ctx->Light.Model.TwoSide); } void