Subversion Repositories Kolibri OS

Rev

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

  1. /*
  2.  Copyright (C) Intel Corp.  2006.  All Rights Reserved.
  3.  Intel funded Tungsten Graphics (http://www.tungstengraphics.com) to
  4.  develop this 3D driver.
  5.  
  6.  Permission is hereby granted, free of charge, to any person obtaining
  7.  a copy of this software and associated documentation files (the
  8.  "Software"), to deal in the Software without restriction, including
  9.  without limitation the rights to use, copy, modify, merge, publish,
  10.  distribute, sublicense, and/or sell copies of the Software, and to
  11.  permit persons to whom the Software is furnished to do so, subject to
  12.  the following conditions:
  13.  
  14.  The above copyright notice and this permission notice (including the
  15.  next paragraph) shall be included in all copies or substantial
  16.  portions of the Software.
  17.  
  18.  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  19.  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  20.  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  21.  IN NO EVENT SHALL THE COPYRIGHT OWNER(S) AND/OR ITS SUPPLIERS BE
  22.  LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  23.  OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  24.  WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  25.  
  26.  **********************************************************************/
  27.  /*
  28.   * Authors:
  29.   *   Keith Whitwell <keith@tungstengraphics.com>
  30.   */
  31.  
  32. #include "brw_eu.h"
  33.  
  34. #include <string.h>
  35. #include <stdlib.h>
  36.  
  37. /* Returns the corresponding conditional mod for swapping src0 and
  38.  * src1 in e.g. CMP.
  39.  */
  40. uint32_t
  41. brw_swap_cmod(uint32_t cmod)
  42. {
  43.         switch (cmod) {
  44.         case BRW_CONDITIONAL_Z:
  45.         case BRW_CONDITIONAL_NZ:
  46.                 return cmod;
  47.         case BRW_CONDITIONAL_G:
  48.                 return BRW_CONDITIONAL_LE;
  49.         case BRW_CONDITIONAL_GE:
  50.                 return BRW_CONDITIONAL_L;
  51.         case BRW_CONDITIONAL_L:
  52.                 return BRW_CONDITIONAL_GE;
  53.         case BRW_CONDITIONAL_LE:
  54.                 return BRW_CONDITIONAL_G;
  55.         default:
  56.                 return ~0;
  57.         }
  58. }
  59.  
  60. /* How does predicate control work when execution_size != 8?  Do I
  61.  * need to test/set for 0xffff when execution_size is 16?
  62.  */
  63. void brw_set_predicate_control_flag_value( struct brw_compile *p, unsigned value )
  64. {
  65.         p->current->header.predicate_control = BRW_PREDICATE_NONE;
  66.  
  67.         if (value != 0xff) {
  68.                 if (value != p->flag_value) {
  69.                         brw_MOV(p, brw_flag_reg(), brw_imm_uw(value));
  70.                         p->flag_value = value;
  71.                 }
  72.  
  73.                 p->current->header.predicate_control = BRW_PREDICATE_NORMAL;
  74.         }
  75. }
  76.  
  77. void brw_set_compression_control(struct brw_compile *p,
  78.                                  enum brw_compression compression_control)
  79. {
  80.         p->compressed = (compression_control == BRW_COMPRESSION_COMPRESSED);
  81.  
  82.         if (p->gen >= 060) {
  83.                 /* Since we don't use the 32-wide support in gen6, we translate
  84.                  * the pre-gen6 compression control here.
  85.                  */
  86.                 switch (compression_control) {
  87.                 case BRW_COMPRESSION_NONE:
  88.                         /* This is the "use the first set of bits of dmask/vmask/arf
  89.                          * according to execsize" option.
  90.                          */
  91.                         p->current->header.compression_control = GEN6_COMPRESSION_1Q;
  92.                         break;
  93.                 case BRW_COMPRESSION_2NDHALF:
  94.                         /* For 8-wide, this is "use the second set of 8 bits." */
  95.                         p->current->header.compression_control = GEN6_COMPRESSION_2Q;
  96.                         break;
  97.                 case BRW_COMPRESSION_COMPRESSED:
  98.                         /* For 16-wide instruction compression, use the first set of 16 bits
  99.                          * since we don't do 32-wide dispatch.
  100.                          */
  101.                         p->current->header.compression_control = GEN6_COMPRESSION_1H;
  102.                         break;
  103.                 default:
  104.                         assert(!"not reached");
  105.                         p->current->header.compression_control = GEN6_COMPRESSION_1H;
  106.                         break;
  107.                 }
  108.         } else {
  109.                 p->current->header.compression_control = compression_control;
  110.         }
  111. }
  112.  
  113. void brw_push_insn_state( struct brw_compile *p )
  114. {
  115.         assert(p->current != &p->stack[BRW_EU_MAX_INSN_STACK-1]);
  116.         memcpy(p->current+1, p->current, sizeof(struct brw_instruction));
  117.         p->compressed_stack[p->current - p->stack] = p->compressed;
  118.         p->current++;
  119. }
  120.  
  121. void brw_pop_insn_state( struct brw_compile *p )
  122. {
  123.         assert(p->current != p->stack);
  124.         p->current--;
  125.         p->compressed = p->compressed_stack[p->current - p->stack];
  126. }
  127.  
  128. void brw_compile_init(struct brw_compile *p, int gen, void *store)
  129. {
  130.         assert(gen);
  131.  
  132.         p->gen = gen;
  133.         p->store = store;
  134.  
  135.         p->nr_insn = 0;
  136.         p->current = p->stack;
  137.         p->compressed = false;
  138.         memset(p->current, 0, sizeof(p->current[0]));
  139.  
  140.         /* Some defaults?
  141.         */
  142.         brw_set_mask_control(p, BRW_MASK_ENABLE); /* what does this do? */
  143.         brw_set_saturate(p, 0);
  144.         brw_set_compression_control(p, BRW_COMPRESSION_NONE);
  145.         brw_set_predicate_control_flag_value(p, 0xff);
  146.  
  147.         p->if_stack_depth = 0;
  148.         p->if_stack_array_size = 0;
  149.         p->if_stack = NULL;
  150. }
  151.