Subversion Repositories Kolibri OS

Rev

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

  1. /* -*- mode: C; c-file-style: "k&r"; tab-width 4; indent-tabs-mode: t; -*- */
  2.  
  3. /*
  4.  * Copyright (C) 2012 Rob Clark <robclark@freedesktop.org>
  5.  *
  6.  * Permission is hereby granted, free of charge, to any person obtaining a
  7.  * copy of this software and associated documentation files (the "Software"),
  8.  * to deal in the Software without restriction, including without limitation
  9.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  10.  * and/or sell copies of the Software, and to permit persons to whom the
  11.  * Software is furnished to do so, subject to the following conditions:
  12.  *
  13.  * The above copyright notice and this permission notice (including the next
  14.  * paragraph) shall be included in all copies or substantial portions of the
  15.  * Software.
  16.  *
  17.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  18.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  20.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  21.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  22.  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  23.  * SOFTWARE.
  24.  *
  25.  * Authors:
  26.  *    Rob Clark <robclark@freedesktop.org>
  27.  */
  28.  
  29. #include "pipe/p_defines.h"
  30. #include "util/u_format.h"
  31.  
  32. #include "freedreno_util.h"
  33.  
  34. enum adreno_rb_depth_format
  35. fd_pipe2depth(enum pipe_format format)
  36. {
  37.         switch (format) {
  38.         case PIPE_FORMAT_Z16_UNORM:
  39.                 return DEPTHX_16;
  40.         case PIPE_FORMAT_Z24X8_UNORM:
  41.         case PIPE_FORMAT_Z24_UNORM_S8_UINT:
  42.         case PIPE_FORMAT_X8Z24_UNORM:
  43.         case PIPE_FORMAT_S8_UINT_Z24_UNORM:
  44.                 return DEPTHX_24_8;
  45.         default:
  46.                 return ~0;
  47.         }
  48. }
  49.  
  50. enum pc_di_index_size
  51. fd_pipe2index(enum pipe_format format)
  52. {
  53.         switch (format) {
  54.         case PIPE_FORMAT_I8_UINT:
  55.                 return INDEX_SIZE_8_BIT;
  56.         case PIPE_FORMAT_I16_UINT:
  57.                 return INDEX_SIZE_16_BIT;
  58.         case PIPE_FORMAT_I32_UINT:
  59.                 return INDEX_SIZE_32_BIT;
  60.         default:
  61.                 return ~0;
  62.         }
  63. }
  64.  
  65.  
  66. enum adreno_rb_blend_factor
  67. fd_blend_factor(unsigned factor)
  68. {
  69.         switch (factor) {
  70.         case PIPE_BLENDFACTOR_ONE:
  71.                 return FACTOR_ONE;
  72.         case PIPE_BLENDFACTOR_SRC_COLOR:
  73.                 return FACTOR_SRC_COLOR;
  74.         case PIPE_BLENDFACTOR_SRC_ALPHA:
  75.                 return FACTOR_SRC_ALPHA;
  76.         case PIPE_BLENDFACTOR_DST_ALPHA:
  77.                 return FACTOR_DST_ALPHA;
  78.         case PIPE_BLENDFACTOR_DST_COLOR:
  79.                 return FACTOR_DST_COLOR;
  80.         case PIPE_BLENDFACTOR_SRC_ALPHA_SATURATE:
  81.                 return FACTOR_SRC_ALPHA_SATURATE;
  82.         case PIPE_BLENDFACTOR_CONST_COLOR:
  83.                 return FACTOR_CONSTANT_COLOR;
  84.         case PIPE_BLENDFACTOR_CONST_ALPHA:
  85.                 return FACTOR_CONSTANT_ALPHA;
  86.         case PIPE_BLENDFACTOR_ZERO:
  87.         case 0:
  88.                 return FACTOR_ZERO;
  89.         case PIPE_BLENDFACTOR_INV_SRC_COLOR:
  90.                 return FACTOR_ONE_MINUS_SRC_COLOR;
  91.         case PIPE_BLENDFACTOR_INV_SRC_ALPHA:
  92.                 return FACTOR_ONE_MINUS_SRC_ALPHA;
  93.         case PIPE_BLENDFACTOR_INV_DST_ALPHA:
  94.                 return FACTOR_ONE_MINUS_DST_ALPHA;
  95.         case PIPE_BLENDFACTOR_INV_DST_COLOR:
  96.                 return FACTOR_ONE_MINUS_DST_COLOR;
  97.         case PIPE_BLENDFACTOR_INV_CONST_COLOR:
  98.                 return FACTOR_ONE_MINUS_CONSTANT_COLOR;
  99.         case PIPE_BLENDFACTOR_INV_CONST_ALPHA:
  100.                 return FACTOR_ONE_MINUS_CONSTANT_ALPHA;
  101.         case PIPE_BLENDFACTOR_INV_SRC1_COLOR:
  102.         case PIPE_BLENDFACTOR_INV_SRC1_ALPHA:
  103.         case PIPE_BLENDFACTOR_SRC1_COLOR:
  104.         case PIPE_BLENDFACTOR_SRC1_ALPHA:
  105.                 /* I don't think these are supported */
  106.         default:
  107.                 DBG("invalid blend factor: %x", factor);
  108.                 return 0;
  109.         }
  110. }
  111.  
  112. enum adreno_rb_blend_opcode
  113. fd_blend_func(unsigned func)
  114. {
  115.         switch (func) {
  116.         case PIPE_BLEND_ADD:
  117.                 return BLEND_DST_PLUS_SRC;
  118.         case PIPE_BLEND_MIN:
  119.                 return BLEND_MIN_DST_SRC;
  120.         case PIPE_BLEND_MAX:
  121.                 return BLEND_MAX_DST_SRC;
  122.         case PIPE_BLEND_SUBTRACT:
  123.                 return BLEND_SRC_MINUS_DST;
  124.         case PIPE_BLEND_REVERSE_SUBTRACT:
  125.                 return BLEND_DST_MINUS_SRC;
  126.         default:
  127.                 DBG("invalid blend func: %x", func);
  128.                 return 0;
  129.         }
  130. }
  131.  
  132. enum adreno_pa_su_sc_draw
  133. fd_polygon_mode(unsigned mode)
  134. {
  135.         switch (mode) {
  136.         case PIPE_POLYGON_MODE_POINT:
  137.                 return PC_DRAW_POINTS;
  138.         case PIPE_POLYGON_MODE_LINE:
  139.                 return PC_DRAW_LINES;
  140.         case PIPE_POLYGON_MODE_FILL:
  141.                 return PC_DRAW_TRIANGLES;
  142.         default:
  143.                 DBG("invalid polygon mode: %u", mode);
  144.                 return 0;
  145.         }
  146. }
  147.  
  148. enum adreno_stencil_op
  149. fd_stencil_op(unsigned op)
  150. {
  151.         switch (op) {
  152.         case PIPE_STENCIL_OP_KEEP:
  153.                 return STENCIL_KEEP;
  154.         case PIPE_STENCIL_OP_ZERO:
  155.                 return STENCIL_ZERO;
  156.         case PIPE_STENCIL_OP_REPLACE:
  157.                 return STENCIL_REPLACE;
  158.         case PIPE_STENCIL_OP_INCR:
  159.                 return STENCIL_INCR_CLAMP;
  160.         case PIPE_STENCIL_OP_DECR:
  161.                 return STENCIL_DECR_CLAMP;
  162.         case PIPE_STENCIL_OP_INCR_WRAP:
  163.                 return STENCIL_INCR_WRAP;
  164.         case PIPE_STENCIL_OP_DECR_WRAP:
  165.                 return STENCIL_DECR_WRAP;
  166.         case PIPE_STENCIL_OP_INVERT:
  167.                 return STENCIL_INVERT;
  168.         default:
  169.                 DBG("invalid stencil op: %u", op);
  170.                 return 0;
  171.         }
  172. }
  173.