Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Last modification | View Log | RSS feed

  1. /*
  2.  * Copyright (C) 2009 Francisco Jerez.
  3.  * All Rights Reserved.
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining
  6.  * a copy of this software and associated documentation files (the
  7.  * "Software"), to deal in the Software without restriction, including
  8.  * without limitation the rights to use, copy, modify, merge, publish,
  9.  * distribute, sublicense, and/or sell copies of the Software, and to
  10.  * permit persons to whom the Software is furnished to do so, subject to
  11.  * the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice (including the
  14.  * next paragraph) shall be included in all copies or substantial
  15.  * portions of the Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  18.  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  19.  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  20.  * IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  21.  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  22.  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  23.  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  24.  *
  25.  */
  26.  
  27. #include "nouveau_driver.h"
  28. #include "nouveau_context.h"
  29. #include "nouveau_gldefs.h"
  30. #include "nouveau_util.h"
  31. #include "nv10_3d.xml.h"
  32. #include "nv10_driver.h"
  33.  
  34. #include "main/stencil.h"
  35.  
  36. void
  37. nv10_emit_alpha_func(struct gl_context *ctx, int emit)
  38. {
  39.         struct nouveau_pushbuf *push = context_push(ctx);
  40.  
  41.         BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_ENABLE), 1);
  42.         PUSH_DATAb(push, ctx->Color.AlphaEnabled);
  43.  
  44.         BEGIN_NV04(push, NV10_3D(ALPHA_FUNC_FUNC), 2);
  45.         PUSH_DATA (push, nvgl_comparison_op(ctx->Color.AlphaFunc));
  46.         PUSH_DATA (push, FLOAT_TO_UBYTE(ctx->Color.AlphaRef));
  47. }
  48.  
  49. void
  50. nv10_emit_blend_color(struct gl_context *ctx, int emit)
  51. {
  52.         struct nouveau_pushbuf *push = context_push(ctx);
  53.  
  54.         BEGIN_NV04(push, NV10_3D(BLEND_COLOR), 1);
  55.         PUSH_DATA (push, FLOAT_TO_UBYTE(ctx->Color.BlendColor[3]) << 24 |
  56.                  FLOAT_TO_UBYTE(ctx->Color.BlendColor[0]) << 16 |
  57.                  FLOAT_TO_UBYTE(ctx->Color.BlendColor[1]) << 8 |
  58.                  FLOAT_TO_UBYTE(ctx->Color.BlendColor[2]) << 0);
  59. }
  60.  
  61. void
  62. nv10_emit_blend_equation(struct gl_context *ctx, int emit)
  63. {
  64.         struct nouveau_pushbuf *push = context_push(ctx);
  65.  
  66.         BEGIN_NV04(push, NV10_3D(BLEND_FUNC_ENABLE), 1);
  67.         PUSH_DATAb(push, ctx->Color.BlendEnabled);
  68.  
  69.         BEGIN_NV04(push, NV10_3D(BLEND_EQUATION), 1);
  70.         PUSH_DATA (push, nvgl_blend_eqn(ctx->Color.Blend[0].EquationRGB));
  71. }
  72.  
  73. void
  74. nv10_emit_blend_func(struct gl_context *ctx, int emit)
  75. {
  76.         struct nouveau_pushbuf *push = context_push(ctx);
  77.  
  78.         BEGIN_NV04(push, NV10_3D(BLEND_FUNC_SRC), 2);
  79.         PUSH_DATA (push, nvgl_blend_func(ctx->Color.Blend[0].SrcRGB));
  80.         PUSH_DATA (push, nvgl_blend_func(ctx->Color.Blend[0].DstRGB));
  81. }
  82.  
  83. void
  84. nv10_emit_color_mask(struct gl_context *ctx, int emit)
  85. {
  86.         struct nouveau_pushbuf *push = context_push(ctx);
  87.  
  88.         BEGIN_NV04(push, NV10_3D(COLOR_MASK), 1);
  89.         PUSH_DATA (push, ((ctx->Color.ColorMask[0][3] ? 1 << 24 : 0) |
  90.                         (ctx->Color.ColorMask[0][0] ? 1 << 16 : 0) |
  91.                         (ctx->Color.ColorMask[0][1] ? 1 << 8 : 0) |
  92.                         (ctx->Color.ColorMask[0][2] ? 1 << 0 : 0)));
  93. }
  94.  
  95. void
  96. nv10_emit_depth(struct gl_context *ctx, int emit)
  97. {
  98.         struct nouveau_pushbuf *push = context_push(ctx);
  99.  
  100.         BEGIN_NV04(push, NV10_3D(DEPTH_TEST_ENABLE), 1);
  101.         PUSH_DATAb(push, ctx->Depth.Test);
  102.         BEGIN_NV04(push, NV10_3D(DEPTH_WRITE_ENABLE), 1);
  103.         PUSH_DATAb(push, ctx->Depth.Mask);
  104.         BEGIN_NV04(push, NV10_3D(DEPTH_FUNC), 1);
  105.         PUSH_DATA (push, nvgl_comparison_op(ctx->Depth.Func));
  106. }
  107.  
  108. void
  109. nv10_emit_dither(struct gl_context *ctx, int emit)
  110. {
  111.         struct nouveau_pushbuf *push = context_push(ctx);
  112.  
  113.         BEGIN_NV04(push, NV10_3D(DITHER_ENABLE), 1);
  114.         PUSH_DATAb(push, ctx->Color.DitherFlag);
  115. }
  116.  
  117. void
  118. nv10_emit_logic_opcode(struct gl_context *ctx, int emit)
  119. {
  120.         struct nouveau_pushbuf *push = context_push(ctx);
  121.  
  122.         assert(!ctx->Color.ColorLogicOpEnabled
  123.                || context_chipset(ctx) >= 0x11);
  124.  
  125.         BEGIN_NV04(push, NV11_3D(COLOR_LOGIC_OP_ENABLE), 2);
  126.         PUSH_DATAb(push, ctx->Color.ColorLogicOpEnabled);
  127.         PUSH_DATA (push, nvgl_logicop_func(ctx->Color.LogicOp));
  128. }
  129.  
  130. void
  131. nv10_emit_shade_model(struct gl_context *ctx, int emit)
  132. {
  133.         struct nouveau_pushbuf *push = context_push(ctx);
  134.  
  135.         BEGIN_NV04(push, NV10_3D(SHADE_MODEL), 1);
  136.         PUSH_DATA (push, ctx->Light.ShadeModel == GL_SMOOTH ?
  137.                  NV10_3D_SHADE_MODEL_SMOOTH : NV10_3D_SHADE_MODEL_FLAT);
  138. }
  139.  
  140. void
  141. nv10_emit_stencil_func(struct gl_context *ctx, int emit)
  142. {
  143.         struct nouveau_pushbuf *push = context_push(ctx);
  144.  
  145.         BEGIN_NV04(push, NV10_3D(STENCIL_ENABLE), 1);
  146.         PUSH_DATAb(push, ctx->Stencil.Enabled);
  147.  
  148.         BEGIN_NV04(push, NV10_3D(STENCIL_FUNC_FUNC), 3);
  149.         PUSH_DATA (push, nvgl_comparison_op(ctx->Stencil.Function[0]));
  150.         PUSH_DATA (push, _mesa_get_stencil_ref(ctx, 0));
  151.         PUSH_DATA (push, ctx->Stencil.ValueMask[0]);
  152. }
  153.  
  154. void
  155. nv10_emit_stencil_mask(struct gl_context *ctx, int emit)
  156. {
  157.         struct nouveau_pushbuf *push = context_push(ctx);
  158.  
  159.         BEGIN_NV04(push, NV10_3D(STENCIL_MASK), 1);
  160.         PUSH_DATA (push, ctx->Stencil.WriteMask[0]);
  161. }
  162.  
  163. void
  164. nv10_emit_stencil_op(struct gl_context *ctx, int emit)
  165. {
  166.         struct nouveau_pushbuf *push = context_push(ctx);
  167.  
  168.         BEGIN_NV04(push, NV10_3D(STENCIL_OP_FAIL), 3);
  169.         PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.FailFunc[0]));
  170.         PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.ZFailFunc[0]));
  171.         PUSH_DATA (push, nvgl_stencil_op(ctx->Stencil.ZPassFunc[0]));
  172. }
  173.