static void gen2_emit_invariant(struct intel_batchbuffer *batch)
{
	int i;

	for (i = 0; i < 4; i++) {
		OUT_BATCH(_3DSTATE_MAP_CUBE | MAP_UNIT(i));
		OUT_BATCH(_3DSTATE_MAP_TEX_STREAM_CMD | MAP_UNIT(i) |
			  DISABLE_TEX_STREAM_BUMP |
			  ENABLE_TEX_STREAM_COORD_SET | TEX_STREAM_COORD_SET(i) |
			  ENABLE_TEX_STREAM_MAP_IDX | TEX_STREAM_MAP_IDX(i));
		OUT_BATCH(_3DSTATE_MAP_COORD_TRANSFORM);
		OUT_BATCH(DISABLE_TEX_TRANSFORM | TEXTURE_SET(i));
	}

	OUT_BATCH(_3DSTATE_MAP_COORD_SETBIND_CMD);
	OUT_BATCH(TEXBIND_SET3(TEXCOORDSRC_VTXSET_3) |
		  TEXBIND_SET2(TEXCOORDSRC_VTXSET_2) |
		  TEXBIND_SET1(TEXCOORDSRC_VTXSET_1) |
		  TEXBIND_SET0(TEXCOORDSRC_VTXSET_0));

	OUT_BATCH(_3DSTATE_SCISSOR_ENABLE_CMD | DISABLE_SCISSOR_RECT);

	OUT_BATCH(_3DSTATE_VERTEX_TRANSFORM);
	OUT_BATCH(DISABLE_VIEWPORT_TRANSFORM | DISABLE_PERSPECTIVE_DIVIDE);

	OUT_BATCH(_3DSTATE_W_STATE_CMD);
	OUT_BATCH(MAGIC_W_STATE_DWORD1);
	OUT_BATCH(0x3f800000 /* 1.0 in IEEE float */ );

	OUT_BATCH(_3DSTATE_INDPT_ALPHA_BLEND_CMD |
		  DISABLE_INDPT_ALPHA_BLEND |
		  ENABLE_ALPHA_BLENDFUNC | ABLENDFUNC_ADD);

	OUT_BATCH(_3DSTATE_CONST_BLEND_COLOR_CMD);
	OUT_BATCH(0);

	OUT_BATCH(_3DSTATE_MODES_1_CMD |
		  ENABLE_COLR_BLND_FUNC | BLENDFUNC_ADD |
		  ENABLE_SRC_BLND_FACTOR | SRC_BLND_FACT(BLENDFACTOR_ONE) |
		  ENABLE_DST_BLND_FACTOR | DST_BLND_FACT(BLENDFACTOR_ZERO));

	OUT_BATCH(_3DSTATE_ENABLES_1_CMD |
		  DISABLE_LOGIC_OP |
		  DISABLE_STENCIL_TEST |
		  DISABLE_DEPTH_BIAS |
		  DISABLE_SPEC_ADD |
		  DISABLE_FOG |
		  DISABLE_ALPHA_TEST |
		  DISABLE_DEPTH_TEST |
		  ENABLE_COLOR_BLEND);

	OUT_BATCH(_3DSTATE_ENABLES_2_CMD |
		  DISABLE_STENCIL_WRITE |
		  DISABLE_DITHER |
		  DISABLE_DEPTH_WRITE |
		  ENABLE_COLOR_MASK |
		  ENABLE_COLOR_WRITE |
		  ENABLE_TEX_CACHE);
}
コード例 #2
0
ファイル: i830_tex.c プロジェクト: DavidGriffith/finx
intelTextureObjectPtr i830AllocTexObj( struct gl_texture_object *texObj )
{
   i830TextureObjectPtr t = CALLOC_STRUCT( i830_texture_object );
   if ( !t ) 
      return NULL;

   texObj->DriverData = t;
   t->intel.base.tObj = texObj;
   t->intel.dirty = I830_UPLOAD_TEX_ALL;
   make_empty_list( &t->intel.base );

   t->Setup[I830_TEXREG_TM0LI] = 0; /* not used */
   t->Setup[I830_TEXREG_TM0S0] = 0;
   t->Setup[I830_TEXREG_TM0S1] = 0;
   t->Setup[I830_TEXREG_TM0S2] = 0;
   t->Setup[I830_TEXREG_TM0S3] = 0;
   t->Setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
				MAP_UNIT(0) |
				ENABLE_TEXCOORD_PARAMS |
				TEXCOORDS_ARE_NORMAL |
				TEXCOORDTYPE_CARTESIAN |
				ENABLE_ADDR_V_CNTL |
				TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) |
				ENABLE_ADDR_U_CNTL |
				TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));

   
   i830SetTexWrapping( t, texObj->WrapS, texObj->WrapT );
   i830SetTexFilter( t, texObj->MinFilter, texObj->MagFilter, 
		     texObj->MaxAnisotropy );
   i830SetTexBorderColor( t, texObj->_BorderChan );

   return &t->intel;
}
コード例 #3
0
ファイル: i830_metaops.c プロジェクト: Magister/x11rdp_xorg71
/* Set up an arbitary piece of memory as a rectangular texture
 * (including the front or back buffer).
 */
static void set_tex_rect_source( i830ContextPtr i830,
				 GLuint offset,
				 GLuint width, 
				 GLuint height,
				 GLuint pitch, /* in bytes */
				 GLuint textureFormat )
{
   GLint numLevels = 1;
   GLuint *setup = i830->meta.Tex[0];

/*    fprintf(stderr, "%s: offset: %x w: %d h: %d pitch %d format %x\n", */
/* 	   __FUNCTION__, offset, width, height, pitch, textureFormat ); */

   setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 | 
			       (LOAD_TEXTURE_MAP0 << 0) | 4);
   setup[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | offset);
   setup[I830_TEXREG_TM0S1] = (((height - 1) << TM0S1_HEIGHT_SHIFT) |
			       ((width - 1) << TM0S1_WIDTH_SHIFT) |
			       textureFormat);
   setup[I830_TEXREG_TM0S2] = ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT));   
   setup[I830_TEXREG_TM0S3] &= ~TM0S3_MAX_MIP_MASK;
   setup[I830_TEXREG_TM0S3] &= ~TM0S3_MIN_MIP_MASK;
   setup[I830_TEXREG_TM0S3] |= ((numLevels - 1)*4) << TM0S3_MIN_MIP_SHIFT;

   setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
			     MAP_UNIT(0) |
			     ENABLE_TEXCOORD_PARAMS |
			     TEXCOORDS_ARE_IN_TEXELUNITS |
			     TEXCOORDTYPE_CARTESIAN |
			     ENABLE_ADDR_V_CNTL |
			     TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) |
			     ENABLE_ADDR_U_CNTL |
			     TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));

   i830->meta.emitted &= ~I830_UPLOAD_TEX(0);
}
コード例 #4
0
/* Set up an arbitary piece of memory as a rectangular texture
 * (including the front or back buffer).
 */
static GLboolean
set_tex_rect_source(struct intel_context *intel,
                    dri_bo *buffer,
                    GLuint offset,
                    GLuint pitch, GLuint height, GLenum format, GLenum type)
{
   struct i830_context *i830 = i830_context(&intel->ctx);
   GLuint *setup = i830->meta.Tex[0];
   GLint numLevels = 1;
   GLuint textureFormat;
   GLuint cpp;

   /* A full implementation of this would do the upload through
    * glTexImage2d, and get all the conversion operations at that
    * point.  We are restricted, but still at least have access to the
    * fragment program swizzle.
    */
   switch (format) {
   case GL_BGRA:
      switch (type) {
      case GL_UNSIGNED_INT_8_8_8_8_REV:
      case GL_UNSIGNED_BYTE:
         textureFormat = (MAPSURF_32BIT | MT_32BIT_ARGB8888);
         cpp = 4;
         break;
      default:
         return GL_FALSE;
      }
      break;
   case GL_RGBA:
      switch (type) {
      case GL_UNSIGNED_INT_8_8_8_8_REV:
      case GL_UNSIGNED_BYTE:
         textureFormat = (MAPSURF_32BIT | MT_32BIT_ABGR8888);
         cpp = 4;
         break;
      default:
         return GL_FALSE;
      }
      break;
   case GL_BGR:
      switch (type) {
      case GL_UNSIGNED_SHORT_5_6_5_REV:
         textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
         cpp = 2;
         break;
      default:
         return GL_FALSE;
      }
      break;
   case GL_RGB:
      switch (type) {
      case GL_UNSIGNED_SHORT_5_6_5:
         textureFormat = (MAPSURF_16BIT | MT_16BIT_RGB565);
         cpp = 2;
         break;
      default:
         return GL_FALSE;
      }
      break;

   default:
      return GL_FALSE;
   }

   i830->meta.tex_buffer[0] = buffer;
   i830->meta.tex_offset[0] = offset;

   setup[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
                               (LOAD_TEXTURE_MAP0 << 0) | 4);
   setup[I830_TEXREG_TM0S1] = (((height - 1) << TM0S1_HEIGHT_SHIFT) |
                               ((pitch - 1) << TM0S1_WIDTH_SHIFT) |
                               textureFormat);
   setup[I830_TEXREG_TM0S2] =
      (((((pitch * cpp) / 4) -
         1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);

   setup[I830_TEXREG_TM0S3] =
      ((((numLevels -
          1) *
         4) << TM0S3_MIN_MIP_SHIFT) | (FILTER_NEAREST <<
                                       TM0S3_MIN_FILTER_SHIFT) |
       (MIPFILTER_NONE << TM0S3_MIP_FILTER_SHIFT) | (FILTER_NEAREST <<
                                                     TM0S3_MAG_FILTER_SHIFT));

   setup[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(0));

   setup[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
                             MAP_UNIT(0) |
                             ENABLE_TEXCOORD_PARAMS |
                             TEXCOORDS_ARE_IN_TEXELUNITS |
                             TEXCOORDTYPE_CARTESIAN |
                             ENABLE_ADDR_V_CNTL |
                             TEXCOORD_ADDR_V_MODE(TEXCOORDMODE_WRAP) |
                             ENABLE_ADDR_U_CNTL |
                             TEXCOORD_ADDR_U_MODE(TEXCOORDMODE_WRAP));

   i830->meta.emitted &= ~I830_UPLOAD_TEX(0);
   return GL_TRUE;
}
コード例 #5
0
/* Recalculate all state from scratch.  Perhaps not the most
 * efficient, but this has gotten complex enough that we need
 * something which is understandable and reliable.
 */
static GLboolean
i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
{
   GLcontext *ctx = &intel->ctx;
   struct i830_context *i830 = i830_context(ctx);
   struct gl_texture_object *tObj = ctx->Texture.Unit[unit]._Current;
   struct intel_texture_object *intelObj = intel_texture_object(tObj);
   struct gl_texture_image *firstImage;
   GLuint *state = i830->state.Tex[unit], format, pitch;

   memset(state, 0, sizeof(state));

   /*We need to refcount these. */

   if (i830->state.tex_buffer[unit] != NULL) {
       dri_bo_unreference(i830->state.tex_buffer[unit]);
       i830->state.tex_buffer[unit] = NULL;
   }

   if (!intelObj->imageOverride && !intel_finalize_mipmap_tree(intel, unit))
      return GL_FALSE;

   /* Get first image here, since intelObj->firstLevel will get set in
    * the intel_finalize_mipmap_tree() call above.
    */
   firstImage = tObj->Image[0][intelObj->firstLevel];

   if (intelObj->imageOverride) {
      i830->state.tex_buffer[unit] = NULL;
      i830->state.tex_offset[unit] = intelObj->textureOffset;

      switch (intelObj->depthOverride) {
      case 32:
	 format = MAPSURF_32BIT | MT_32BIT_ARGB8888;
	 break;
      case 24:
      default:
	 format = MAPSURF_32BIT | MT_32BIT_XRGB8888;
	 break;
      case 16:
	 format = MAPSURF_16BIT | MT_16BIT_RGB565;
	 break;
      }

      pitch = intelObj->pitchOverride;
   } else {
      dri_bo_reference(intelObj->mt->region->buffer);
      i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
      i830->state.tex_offset[unit] = intel_miptree_image_offset(intelObj->mt,
								0, intelObj->
								firstLevel);

      format = translate_texture_format(firstImage->TexFormat->MesaFormat);
      pitch = intelObj->mt->pitch * intelObj->mt->cpp;
   }

   state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
                               (LOAD_TEXTURE_MAP0 << unit) | 4);

/*    state[I830_TEXREG_TM0S0] = (TM0S0_USE_FENCE | */
/* 			       t->intel.TextureOffset); */


   state[I830_TEXREG_TM0S1] =
      (((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
       ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);

   state[I830_TEXREG_TM0S2] =
      ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);

   {
      if (tObj->Target == GL_TEXTURE_CUBE_MAP)
         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit) |
                                    CUBE_NEGX_ENABLE |
                                    CUBE_POSX_ENABLE |
                                    CUBE_NEGY_ENABLE |
                                    CUBE_POSY_ENABLE |
                                    CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE);
      else
         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit));
   }




   {
      GLuint minFilt, mipFilt, magFilt;

      switch (tObj->MinFilter) {
      case GL_NEAREST:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_NONE;
         break;
      case GL_LINEAR:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_NONE;
         break;
      case GL_NEAREST_MIPMAP_NEAREST:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_NEAREST;
         break;
      case GL_LINEAR_MIPMAP_NEAREST:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_NEAREST;
         break;
      case GL_NEAREST_MIPMAP_LINEAR:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_LINEAR;
         break;
      case GL_LINEAR_MIPMAP_LINEAR:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_LINEAR;
         break;
      default:
         return GL_FALSE;
      }

      if (tObj->MaxAnisotropy > 1.0) {
         minFilt = FILTER_ANISOTROPIC;
         magFilt = FILTER_ANISOTROPIC;
      }
      else {
         switch (tObj->MagFilter) {
         case GL_NEAREST:
            magFilt = FILTER_NEAREST;
            break;
         case GL_LINEAR:
            magFilt = FILTER_LINEAR;
            break;
         default:
            return GL_FALSE;
         }
      }

      state[I830_TEXREG_TM0S3] = i830->lodbias_tm0s3[unit];

#if 0
      /* YUV conversion:
       */
      if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR ||
          firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV)
         state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION;
#endif

      state[I830_TEXREG_TM0S3] |= ((intelObj->lastLevel -
                                    intelObj->firstLevel) *
                                   4) << TM0S3_MIN_MIP_SHIFT;

      state[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
                                   (mipFilt << TM0S3_MIP_FILTER_SHIFT) |
                                   (magFilt << TM0S3_MAG_FILTER_SHIFT));
   }

   {
      GLenum ws = tObj->WrapS;
      GLenum wt = tObj->WrapT;


      /* 3D textures not available on i830
       */
      if (tObj->Target == GL_TEXTURE_3D)
         return GL_FALSE;

      state[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
                                MAP_UNIT(unit) |
                                ENABLE_TEXCOORD_PARAMS |
                                ss3 |
                                ENABLE_ADDR_V_CNTL |
                                TEXCOORD_ADDR_V_MODE(translate_wrap_mode(wt))
                                | ENABLE_ADDR_U_CNTL |
                                TEXCOORD_ADDR_U_MODE(translate_wrap_mode
                                                     (ws)));
   }


   state[I830_TEXREG_TM0S4] = INTEL_PACKCOLOR8888(tObj->_BorderChan[0],
                                                  tObj->_BorderChan[1],
                                                  tObj->_BorderChan[2],
                                                  tObj->_BorderChan[3]);


   I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE);
   /* memcmp was already disabled, but definitely won't work as the
    * region might now change and that wouldn't be detected:
    */
   I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
   return GL_TRUE;
}
コード例 #6
0
ファイル: bn_artmap.cpp プロジェクト: cbergmeir/RSNNS
/*****************************************************************************
  FUNCTION : bn_artmap_createNet

  PURPOSE  : Generation of the ARTMAP network using SNNS kernel functions.
  NOTES    :

  UPDATE   : 20.1.1993
******************************************************************************/
krui_err SnnsCLib::bn_artmap_createNet(int f1aUnits, int f1aRows, int f2aUnits, 
				    int f2aRows, int f1bUnits, int f1bRows, 
				    int f2bUnits, int f2bRows)

{
   krui_err          ret_code   = KRERR_NO_ERROR;

   int               NoOfSites;

   char              **SiteName, **SiteFunc;

   int               i, j;

   /* Allocate memory for the to pointer Arrays for site names
      and sitefunc names
   */
   SiteName      = (char **) malloc (2*sizeof(char *));
   SiteFunc      = (char **) malloc (2*sizeof(char *));

   if ((SiteName == NULL) || (SiteFunc == NULL)) {
      return (KRERR_INSUFFICIENT_MEM);
   } /*if*/
   /* Allocate memory to save Site names and Sitefunc names */
   *SiteName     = (char *)malloc (STRING_LENGTH);
   *(SiteName+1) = (char *)malloc (STRING_LENGTH);
   *SiteFunc     = (char *)malloc (STRING_LENGTH);
   *(SiteFunc+1) = (char *)malloc (STRING_LENGTH);

   if ((*SiteName == NULL) || (*(SiteName+1) == NULL) ||
       (*SiteFunc == NULL) || (*(SiteFunc+1) == NULL)
      )
   {
      return (KRERR_INSUFFICIENT_MEM);
   } /*if*/


   /********* create ARTa units ******************/

   /* create Input Layer for ARTa */
   ret_code = bn_artmap_make_layer (f1aUnits, f1aRows, F1a_COLS, INPa_X, INPa_Y, const_cast<char*>("inpa"),
                                    INPUT, ACTF_INPa, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create Comparison Layer for ARTa */
   ret_code = bn_artmap_make_layer (f1aUnits, f1aRows, F1a_COLS, CMPa_X, CMPa_Y, const_cast<char*>("cmpa"),
                                    HIDDEN, ACTF_CMPa, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create Recognition Layer for ARTa */
   ret_code = bn_artmap_make_layer (f2aUnits, f2aRows, F2a_COLS, RECa_X, RECa_Y, const_cast<char*>("reca"),
                                    SPECIAL, ACTF_RECa, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create Delay Layer for ARTa */
   ret_code = bn_artmap_make_layer (f2aUnits, f2aRows, F2a_COLS, DELa_X, DELa_Y, const_cast<char*>("dela"),
                                    HIDDEN, ACTF_DELa, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create d1a */
   ret_code = bn_artmap_make_layer (1, 1, 1, D1a_X, D1a_Y, const_cast<char*>("d1a"), HIDDEN, ACTF_Da,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create d2a */
   ret_code = bn_artmap_make_layer (1, 1, 1, D2a_X, D2a_Y, const_cast<char*>("d2a"), HIDDEN, ACTF_Da,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create d3a */
   ret_code = bn_artmap_make_layer (1, 1, 1, D3a_X, D3a_Y, const_cast<char*>("d3a"), HIDDEN, ACTF_Da,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create local reset layer */
   NoOfSites = 2;
   strcpy(*SiteName,     SITE_NAME_RSTa_SELF);
   strcpy(*(SiteName+1), SITE_NAME_RSTa_SIGNAL);
   strcpy(*SiteFunc,     SITE_FUNC_RSTa_SELF);
   strcpy(*(SiteFunc+1), SITE_FUNC_RSTa_SIGNAL);

   ret_code = bn_artmap_make_layer (f2aUnits, f2aRows, F2a_COLS, RSTa_X, RSTa_Y, const_cast<char*>("rsta"),
                                    HIDDEN, ACTF_RSTa, OUTFUNC, NoOfSites, SiteName,
                                    SiteFunc);
   CHECK_RETURN (ret_code);


   /* create g1a */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_REC_G1a);
   strcpy(*(SiteName+1), SITE_NAME_INP_G1a);
   strcpy(*SiteFunc    , SITE_FUNC_REC_G1a);
   strcpy(*(SiteFunc+1), SITE_FUNC_INP_G1a);

   ret_code = bn_artmap_make_layer (1, 1, 1, G1a_X, G1a_Y, const_cast<char*>("g1a"), HIDDEN, ACTF_G1a,
                                    OUTFUNC, NoOfSites, SiteName, SiteFunc);
   CHECK_RETURN (ret_code);

   /* create ria */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_INP_RIa);
   strcpy(*(SiteName+1), SITE_NAME_RHO_RIa);
   strcpy(*SiteFunc    , SITE_FUNC_INP_RIa);
   strcpy(*(SiteFunc+1), SITE_FUNC_RHO_RIa);

   ret_code = bn_artmap_make_layer (1, 1, 1, RIa_X, RIa_Y, const_cast<char*>("ria"), HIDDEN, ACTF_RIa,
                                    OUTFUNC, NoOfSites, SiteName, SiteFunc);
   CHECK_RETURN (ret_code);

   /* create rca */
   ret_code = bn_artmap_make_layer (1, 1, 1, RCa_X, RCa_Y, const_cast<char*>("rca"), HIDDEN, ACTF_RCa,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);


   /* create rga */
   ret_code = bn_artmap_make_layer (1, 1, 1, RGa_X, RGa_Y, const_cast<char*>("rga"), HIDDEN, ACTF_RGa,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create cla */
   ret_code = bn_artmap_make_layer (1, 1, 1, CLa_X, CLa_Y, const_cast<char*>("cla"), HIDDEN, ACTF_CLa,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create nca */
   ret_code = bn_artmap_make_layer (1, 1, 1, NCa_X, NCa_Y, const_cast<char*>("nca"), HIDDEN, ACTF_NCa,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create rhoa */
   ret_code = bn_artmap_make_layer (1, 1, 1, RHOa_X, RHOa_Y, const_cast<char*>("rhoa"), HIDDEN, ACTF_RHOa,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create g2a */
   ret_code = bn_artmap_make_layer (1, 1, 1, G2a_X, G2a_Y, const_cast<char*>("g2a"), HIDDEN, ACTF_G2a,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);



   /********* create MAP-Field units ******************/

   /* create map layer */
   ret_code = bn_artmap_make_layer (f2bUnits, f2bRows, F2b_COLS, MAP_X, MAP_Y, const_cast<char*>("map"), HIDDEN,
                                    ACTF_MAP, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create d1 unit */
   ret_code = bn_artmap_make_layer (1, 1, 1, D1_X, D1_Y, const_cast<char*>("d1"), HIDDEN, ACTF_D1, OUTFUNC,
                                    0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create G unit */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_ARTa_G);
   strcpy(*(SiteName+1), SITE_NAME_ARTb_G);
   strcpy(*SiteFunc    , SITE_FUNC_ARTa_G);
   strcpy(*(SiteFunc+1), SITE_FUNC_ARTb_G);

   ret_code = bn_artmap_make_layer (1, 1, 1, G_X, G_Y, const_cast<char*>("G"), HIDDEN, ACTF_G, OUTFUNC,
                                    NoOfSites, SiteName, SiteFunc);
   CHECK_RETURN (ret_code);

   /* create rb unit */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_B_RB);
   strcpy(*(SiteName+1), SITE_NAME_RHO_RB);
   strcpy(*SiteFunc    , SITE_FUNC_B_RB);
   strcpy(*(SiteFunc+1), SITE_FUNC_RHO_RB);

   ret_code = bn_artmap_make_layer (1, 1, 1, RB_X, RB_Y, const_cast<char*>("rb"), HIDDEN, ACTF_RB, OUTFUNC,
                                    NoOfSites, SiteName, SiteFunc);
   CHECK_RETURN (ret_code);

   /* create rm unit */
   ret_code = bn_artmap_make_layer (1, 1, 1, RM_X, RM_Y, const_cast<char*>("rm"), HIDDEN, ACTF_RM, OUTFUNC,
                                    0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create rg unit */
   ret_code = bn_artmap_make_layer (1, 1, 1, RG_X, RG_Y, const_cast<char*>("rg"), HIDDEN, ACTF_RG, OUTFUNC,
                                    0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create cl unit */
   ret_code = bn_artmap_make_layer (1, 1, 1, CL_X, CL_Y, const_cast<char*>("cl"), HIDDEN, ACTF_CL, OUTFUNC,
                                    0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create nc unit */
   ret_code = bn_artmap_make_layer (1, 1, 1, NC_X, NC_Y, const_cast<char*>("nc"), HIDDEN, ACTF_NC, OUTFUNC,
                                    0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create rho unit */
   ret_code = bn_artmap_make_layer (1, 1, 1, RHO_X, RHO_Y, const_cast<char*>("rho"), HIDDEN, ACTF_RHO, OUTFUNC,
                                    0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create qu unit */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_INPa_QU);
   strcpy(*(SiteName+1), SITE_NAME_CMPa_QU);
   strcpy(*SiteFunc    , SITE_FUNC_INPa_QU);
   strcpy(*(SiteFunc+1), SITE_FUNC_CMPa_QU);

   ret_code = bn_artmap_make_layer (1, 1, 1, QU_X, QU_Y, const_cast<char*>("qu"), HIDDEN, ACTF_QU, OUTFUNC,
                                    NoOfSites, SiteName, SiteFunc);
   CHECK_RETURN (ret_code);

   /* create drho unit */
   ret_code = bn_artmap_make_layer (1, 1, 1, DRHO_X, DRHO_Y, const_cast<char*>("drho"), HIDDEN, ACTF_DRHO, OUTFUNC,
                                    0, NULL, NULL);
   CHECK_RETURN (ret_code);



   /********* create ARTb units ******************/


   /* create Input Layer for ARTb */
   ret_code = bn_artmap_make_layer (f1bUnits, f1bRows, F1b_COLS, INPb_X, INPb_Y, const_cast<char*>("inpb"),
                                    INPUT, ACTF_INPb, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create Comparison Layer for ARTb */
   ret_code = bn_artmap_make_layer (f1bUnits, f1bRows, F1b_COLS, CMPb_X, CMPb_Y, const_cast<char*>("cmpb"),
                                    HIDDEN, ACTF_CMPb, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create Recognition Layer for ARTb */
   ret_code = bn_artmap_make_layer (f2bUnits, f2bRows, F2b_COLS, RECb_X, RECb_Y, const_cast<char*>("recb"),
                                    SPECIAL, ACTF_RECb, OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create Delay Layer for ARTa */
   ret_code = bn_artmap_make_layer (f2bUnits, f2bRows, F2b_COLS, DELb_X, DELb_Y, const_cast<char*>("delb"),
                                    HIDDEN, ACTF_DELb, OUTFUNC, 0, NULL, NULL);

   /* create d1b */
   ret_code = bn_artmap_make_layer (1, 1, 1, D1b_X, D1b_Y, const_cast<char*>("d1b"), HIDDEN, ACTF_Db,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create d2b */
   ret_code = bn_artmap_make_layer (1, 1, 1, D2b_X, D2b_Y, const_cast<char*>("d2b"), HIDDEN, ACTF_Db,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create d3b */
   ret_code = bn_artmap_make_layer (1, 1, 1, D3b_X, D3b_Y, const_cast<char*>("d3b"), HIDDEN, ACTF_Db,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create local reset layer */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_RSTb_SELF);
   strcpy(*(SiteName+1), SITE_NAME_RSTb_SIGNAL);
   strcpy(*SiteFunc    , SITE_FUNC_RSTb_SELF);
   strcpy(*(SiteFunc+1), SITE_FUNC_RSTb_SIGNAL);

   ret_code = bn_artmap_make_layer (f2bUnits, f2bRows, F2b_COLS, RSTb_X, RSTb_Y, const_cast<char*>("rstb"),
                                    HIDDEN, ACTF_RSTb, OUTFUNC, NoOfSites, SiteName,
                                    SiteFunc);
   CHECK_RETURN (ret_code);


   /* create g1b */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_REC_G1b);
   strcpy(*(SiteName+1), SITE_NAME_INP_G1b);
   strcpy(*SiteFunc    , SITE_FUNC_REC_G1b);
   strcpy(*(SiteFunc+1), SITE_FUNC_INP_G1b);

   ret_code = bn_artmap_make_layer (1, 1, 1, G1b_X, G1b_Y, const_cast<char*>("g1b"), HIDDEN, ACTF_G1b,
                                    OUTFUNC, NoOfSites, SiteName, SiteFunc);
   CHECK_RETURN (ret_code);

   /* create rib */
   NoOfSites = 2;
   strcpy(*SiteName    , SITE_NAME_INP_RIb);
   strcpy(*(SiteName+1), SITE_NAME_RHO_RIb);
   strcpy(*SiteFunc    , SITE_FUNC_INP_RIb);
   strcpy(*(SiteFunc+1), SITE_FUNC_RHO_RIb);

   ret_code = bn_artmap_make_layer (1, 1, 1, RIb_X, RIb_Y, const_cast<char*>("rib"), HIDDEN, ACTF_RIb,
                                    OUTFUNC, NoOfSites, SiteName, SiteFunc);
   CHECK_RETURN (ret_code);

   /* create rcb */
   ret_code = bn_artmap_make_layer (1, 1, 1, RCb_X, RCb_Y, const_cast<char*>("rcb"), HIDDEN, ACTF_RCb,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);


   /* create rgb */
   ret_code = bn_artmap_make_layer (1, 1, 1, RGb_X, RGb_Y, const_cast<char*>("rgb"), HIDDEN, ACTF_RGb,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create clb */
   ret_code = bn_artmap_make_layer (1, 1, 1, CLb_X, CLb_Y, const_cast<char*>("clb"), HIDDEN, ACTF_CLb,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create ncb */
   ret_code = bn_artmap_make_layer (1, 1, 1, NCb_X, NCb_Y, const_cast<char*>("ncb"), HIDDEN, ACTF_NCb,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create rhob */
   ret_code = bn_artmap_make_layer (1, 1, 1, RHOb_X, RHOb_Y, const_cast<char*>("rhob"), HIDDEN, ACTF_RHOb,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);

   /* create g2b */
   ret_code = bn_artmap_make_layer (1, 1, 1, G2b_X, G2b_Y, const_cast<char*>("g2b"), HIDDEN, ACTF_G2b,
                                    OUTFUNC, 0, NULL, NULL);
   CHECK_RETURN (ret_code);



   /* Make Connections now */


   /********* Create Links **************************************/


   /********* Links to ARTa units ***********************/

   /* TO cmpa units */
   for (i=1; i<=f1aUnits; i++) {

      ret_code = krui_setCurrentUnit (CMPa_UNIT(i));
      CHECK_RETURN (ret_code);

      /* FROM inpa units */
      ret_code = krui_createLink (INPa_UNIT(i),0.0);
      CHECK_RETURN (ret_code);

      /* FROM g1a unit */
      ret_code = krui_createLink (G1a_UNIT, 0.0);
      CHECK_RETURN (ret_code);

      /* FROM dela units */
      for (j=1; j<=f2aUnits; j++) {
         ret_code = krui_createLink (DELa_UNIT(j), 0.0);
         CHECK_RETURN (ret_code);
      } /*for*/

   } /*for*/


   /* TO reca units */
   for (i=1; i<=f2aUnits; i++) {

      ret_code = krui_setCurrentUnit (RECa_UNIT(i));
      CHECK_RETURN (ret_code);

      /* FROM cmpa units */
      for (j=1; j<=f1aUnits; j++) {
         ret_code = krui_createLink (CMPa_UNIT(j), 0.0);
         CHECK_RETURN (ret_code);
      } /*for*/

      /* FROM rga unit */
      ret_code = krui_createLink (RGa_UNIT, 0.0);
      CHECK_RETURN (ret_code);

      /* FROM rsta units */
      ret_code = krui_createLink (RSTa_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* FROM g2a unit */
      ret_code = krui_createLink (G2a_UNIT, 0.0);
      CHECK_RETURN (ret_code);

   } /*for*/


   /* TO dela units */
   for (i=1; i<=f2aUnits; i++) {

      ret_code = krui_setCurrentUnit (DELa_UNIT(i));
      CHECK_RETURN (ret_code);

      /* FROM reca units */
      ret_code = krui_createLink (RECa_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

   } /*for*/


   /* TO rsta units */
   for (i=1; i<=f2aUnits; i++) {

      ret_code = krui_setCurrentUnit (RSTa_UNIT(i));
      CHECK_RETURN (ret_code);

      /* first Site */
      ret_code = krui_setSite (SITE_NAME_RSTa_SELF);
      CHECK_RETURN (ret_code);

      /* FROM itself */
      ret_code = krui_createLink (RSTa_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* second Site */
      ret_code = krui_setSite (SITE_NAME_RSTa_SIGNAL);
      CHECK_RETURN (ret_code);

      /* FROM dela units */
      ret_code = krui_createLink (DELa_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* FROM rga unit */
      ret_code = krui_createLink (RGa_UNIT, 0.0);
      CHECK_RETURN (ret_code);


   } /*for*/


   /* TO d1a unit */
   ret_code = krui_setCurrentUnit (Da_UNIT(1));
   CHECK_RETURN (ret_code);

   /* FROM dela units */
   for (j=1; j<=f2aUnits; j++) {
      ret_code = krui_createLink (DELa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO d2a unit */
   ret_code = krui_setCurrentUnit (Da_UNIT(2));
   CHECK_RETURN (ret_code);

   /* FROM d1a unit */
   ret_code = krui_createLink (Da_UNIT(1), 0.0);
   CHECK_RETURN (ret_code);


   /* TO d3a unit */
   ret_code = krui_setCurrentUnit (Da_UNIT(3));
   CHECK_RETURN (ret_code);

   /* FROM d2a unit */
   ret_code = krui_createLink (Da_UNIT(2), 0.0);
   CHECK_RETURN (ret_code);


   /* TO g1a unit */
   ret_code = krui_setCurrentUnit (G1a_UNIT);
   CHECK_RETURN (ret_code);

   /* first Site */
   ret_code = krui_setSite (SITE_NAME_REC_G1a);
   CHECK_RETURN (ret_code);

   /* FROM reca units */
   for (j=1; j<=f2aUnits; j++) {
      ret_code = krui_createLink (RECa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/

   /* second Site */
   ret_code = krui_setSite (SITE_NAME_INP_G1a);
   CHECK_RETURN (ret_code);

   /* FROM inpa units */
   for (j=1; j<=f1aUnits; j++) {
      ret_code = krui_createLink (INPa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO ria unit */
   ret_code = krui_setCurrentUnit (RIa_UNIT);
   CHECK_RETURN (ret_code);

   /* first Site */
   ret_code = krui_setSite (SITE_NAME_INP_RIa);
   CHECK_RETURN (ret_code);

   /* FROM inpa units */
   for (j=1; j<=f1aUnits; j++) {
      ret_code = krui_createLink (INPa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/

   /* second Site */
   ret_code = krui_setSite (SITE_NAME_RHO_RIa);
   CHECK_RETURN (ret_code);

   /* from rhoa unit */
   ret_code = krui_createLink (RHOa_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO rca unit */
   ret_code = krui_setCurrentUnit (RCa_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM cmpa units */
   for (j=1; j<=f1aUnits; j++) {
      ret_code = krui_createLink (CMPa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO rga unit */
   ret_code = krui_setCurrentUnit (RGa_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM ria unit */
   ret_code = krui_createLink (RIa_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM rca unit */
   ret_code = krui_createLink (RCa_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO cla unit */
   ret_code = krui_setCurrentUnit (CLa_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM d3a unit */
   ret_code = krui_createLink (Da_UNIT(3), 0.0);
   CHECK_RETURN (ret_code);

   /* FROM rga unit */
   ret_code = krui_createLink (RGa_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM g2a unit */
   ret_code = krui_createLink (G2a_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO nca unit */
   ret_code = krui_setCurrentUnit (NCa_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM rsta units */
   for (j=1; j<=f2aUnits; j++) {
      ret_code = krui_createLink (RSTa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/

   /* TO rhoa unit */
   ret_code = krui_setCurrentUnit (RHOa_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM itself */
   ret_code = krui_createLink (RHOa_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM drho unit */
   ret_code = krui_createLink (DRHO_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO g2a unit */
   ret_code = krui_setCurrentUnit (G2a_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM inpa units */
   for (j = 1; j <= f1aUnits; j++) {
      ret_code = krui_createLink (INPa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /********* Links to MAP Fiels units ***********************/

   /* TO map units */
   for (i=1; i<=f2bUnits; i++) {

      ret_code = krui_setCurrentUnit (MAP_UNIT(i));
      CHECK_RETURN (ret_code);

      /* FROM dela units */
      for (j=1; j<=f2aUnits; j++) {
         ret_code = krui_createLink (DELa_UNIT(j), 0.0);
         CHECK_RETURN (ret_code);
      } /*for*/

      /* FROM delb unit */
      ret_code = krui_createLink (DELb_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* FROM G unit */
      ret_code = krui_createLink (G_UNIT, 0.0);
      CHECK_RETURN (ret_code);

   } /*for*/


   /* TO d1 unit */
   ret_code = krui_setCurrentUnit (D1_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM delb units */
   for (j=1; j<=f2bUnits; j++) {
      ret_code = krui_createLink (DELb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO G unit */
   ret_code = krui_setCurrentUnit (G_UNIT);
   CHECK_RETURN (ret_code);

   /* first Site */
   ret_code = krui_setSite (SITE_NAME_ARTa_G);
   CHECK_RETURN (ret_code);

   /* FROM reca units */
   for (j=1; j<=f2aUnits; j++) {
      ret_code = krui_createLink (RECa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/

   /* second Site */
   ret_code = krui_setSite (SITE_NAME_ARTb_G);
   CHECK_RETURN (ret_code);

   /* FROM recb units */
   for (j=1; j<=f2bUnits; j++) {
      ret_code = krui_createLink (RECb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO rb unit */
   ret_code = krui_setCurrentUnit (RB_UNIT);
   CHECK_RETURN (ret_code);

   /* first Site */
   ret_code = krui_setSite (SITE_NAME_B_RB);
   CHECK_RETURN (ret_code);

   /* FROM d1 unit */
   ret_code = krui_createLink (D1_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* second Site */
   ret_code = krui_setSite (SITE_NAME_RHO_RB);
   CHECK_RETURN (ret_code);

   /* from rho unit */
   ret_code = krui_createLink (RHO_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO rm unit */
   ret_code = krui_setCurrentUnit (RM_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM map units */
   for (j=1; j<=f2bUnits; j++) {
      ret_code = krui_createLink (MAP_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO rg unit */
   ret_code = krui_setCurrentUnit (RG_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM rb unit */
   ret_code = krui_createLink (RB_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM rm unit */
   ret_code = krui_createLink (RM_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO cl unit */
   ret_code = krui_setCurrentUnit (CL_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM cla unit */
   ret_code = krui_createLink (CLa_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM clb unit */
   ret_code = krui_createLink (CLb_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM rg unit */
   ret_code = krui_createLink (RG_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO nc unit */
   ret_code = krui_setCurrentUnit (NC_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM nca unit */
   ret_code = krui_createLink (NCa_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM ncb unit */
   ret_code = krui_createLink (NCb_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* TO rho unit */
   ret_code = krui_setCurrentUnit (RHO_UNIT);
   CHECK_RETURN (ret_code);

   /* from itself */
   ret_code = krui_createLink (RHO_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO qu unit */
   ret_code = krui_setCurrentUnit (QU_UNIT);
   CHECK_RETURN (ret_code);

   /* first Site */
   ret_code = krui_setSite (SITE_NAME_INPa_QU);
   CHECK_RETURN (ret_code);

   /* FROM inpa units */
   for (j=1; j <= f1aUnits; j++) {
      ret_code = krui_createLink (INPa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/

   /* second Site */
   ret_code = krui_setSite (SITE_NAME_CMPa_QU);
   CHECK_RETURN (ret_code);

   /* from cmpa units */
   for (j=1; j<=f1aUnits; j++) {
      ret_code = krui_createLink (CMPa_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO drho unit */
   ret_code = krui_setCurrentUnit (DRHO_UNIT);
   CHECK_RETURN (ret_code);

   /* from itself */
   ret_code = krui_createLink (DRHO_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* from rg unit */
   ret_code = krui_createLink (RG_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* from qu unit */
   ret_code = krui_createLink (QU_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* from rhoa unit */
   ret_code = krui_createLink (RHOa_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* from rga unit */
   ret_code = krui_createLink (RGa_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* from clb unit */
   ret_code = krui_createLink (CLb_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /********* Links to ARTb units ***********************/

   /* TO cmpb units */
   for (i=1; i<=f1bUnits; i++) {

      ret_code = krui_setCurrentUnit (CMPb_UNIT(i));
      CHECK_RETURN (ret_code);

      /* FROM inpb units */
      ret_code = krui_createLink (INPb_UNIT(i),0.0);
      CHECK_RETURN (ret_code);

      /* FROM g1b unit */
      ret_code = krui_createLink (G1b_UNIT, 0.0);
      CHECK_RETURN (ret_code);

      /* FROM delb units */
      for (j=1; j<=f2bUnits; j++) {
         ret_code = krui_createLink (DELb_UNIT(j), 0.0);
         CHECK_RETURN (ret_code);
      } /*for*/

   } /*for*/


   /* TO recb units */
   for (i=1; i<=f2bUnits; i++) {

      ret_code = krui_setCurrentUnit (RECb_UNIT(i));
      CHECK_RETURN (ret_code);

      /* FROM cmpb units */
      for (j=1; j<=f1bUnits; j++) {
         ret_code = krui_createLink (CMPb_UNIT(j), 0.0);
         CHECK_RETURN (ret_code);
      } /*for*/

      /* FROM rgb unit */
      ret_code = krui_createLink (RGb_UNIT, 0.0);
      CHECK_RETURN (ret_code);

      /* FROM rstb units */
      ret_code = krui_createLink (RSTb_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* FROM g2b unit */
      ret_code = krui_createLink (G2b_UNIT, 0.0);
      CHECK_RETURN (ret_code);

   } /*for*/


   /* TO delb units */
   for (i=1; i<=f2bUnits; i++) {

      ret_code = krui_setCurrentUnit (DELb_UNIT(i));
      CHECK_RETURN (ret_code);

      /* FROM recb units */
      ret_code = krui_createLink (RECb_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* FROM map units */
      ret_code = krui_createLink (MAP_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

   } /*for*/


   /* TO rstb units */
   for (i=1; i<=f2bUnits; i++) {

      ret_code = krui_setCurrentUnit (RSTb_UNIT(i));
      CHECK_RETURN (ret_code);

      /* first Site */
      ret_code = krui_setSite (SITE_NAME_RSTb_SELF);
      CHECK_RETURN (ret_code);

      /* FROM itself */
      ret_code = krui_createLink (RSTb_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* second Site */
      ret_code = krui_setSite (SITE_NAME_RSTb_SIGNAL);
      CHECK_RETURN (ret_code);

      /* FROM delb units */
      ret_code = krui_createLink (DELb_UNIT(i), 0.0);
      CHECK_RETURN (ret_code);

      /* FROM rgb unit */
      ret_code = krui_createLink (RGb_UNIT, 0.0);
      CHECK_RETURN (ret_code);

   } /*for*/


   /* TO d1b unit */
   ret_code = krui_setCurrentUnit (Db_UNIT(1));
   CHECK_RETURN (ret_code);

   /* FROM delb units */
   for (j=1; j<=f2bUnits; j++) {
      ret_code = krui_createLink (DELb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO d2b unit */
   ret_code = krui_setCurrentUnit (Db_UNIT(2));
   CHECK_RETURN (ret_code);

   /* FROM d1b unit */
   ret_code = krui_createLink (Db_UNIT(1), 0.0);
   CHECK_RETURN (ret_code);


   /* TO d3b unit */
   ret_code = krui_setCurrentUnit (Db_UNIT(3));
   CHECK_RETURN (ret_code);

   /* FROM d2b unit */
   ret_code = krui_createLink (Db_UNIT(2), 0.0);
   CHECK_RETURN (ret_code);


   /* TO g1b unit */
   ret_code = krui_setCurrentUnit (G1b_UNIT);
   CHECK_RETURN (ret_code);

   /* first Site */
   ret_code = krui_setSite (SITE_NAME_REC_G1b);
   CHECK_RETURN (ret_code);

   /* FROM recb units */
   for (j=1; j<=f2bUnits; j++) {
      ret_code = krui_createLink (RECb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/

   /* second Site */
   ret_code = krui_setSite (SITE_NAME_INP_G1b);
   CHECK_RETURN (ret_code);

   /* FROM inpb units */
   for (j=1; j<=f1bUnits; j++) {
      ret_code = krui_createLink (INPb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO rib unit */
   ret_code = krui_setCurrentUnit (RIb_UNIT);
   CHECK_RETURN (ret_code);

   /* first Site */
   ret_code = krui_setSite (SITE_NAME_INP_RIb);
   CHECK_RETURN (ret_code);

   /* FROM inpb units */
   for (j=1; j<=f1bUnits; j++) {
      ret_code = krui_createLink (INPb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/

   /* second Site */
   ret_code = krui_setSite (SITE_NAME_RHO_RIb);
   CHECK_RETURN (ret_code);

   /* from rhob unit */
   ret_code = krui_createLink (RHOb_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO rcb unit */
   ret_code = krui_setCurrentUnit (RCb_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM cmpb units */
   for (j=1; j<=f1bUnits; j++) {
      ret_code = krui_createLink (CMPb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO rgb unit */
   ret_code = krui_setCurrentUnit (RGb_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM rib unit */
   ret_code = krui_createLink (RIb_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM rcb unit */
   ret_code = krui_createLink (RCb_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO clb unit */
   ret_code = krui_setCurrentUnit (CLb_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM d3b unit */
   ret_code = krui_createLink (Db_UNIT(3), 0.0);
   CHECK_RETURN (ret_code);

   /* FROM rgb unit */
   ret_code = krui_createLink (RGb_UNIT, 0.0);
   CHECK_RETURN (ret_code);

   /* FROM g2b unit */
   ret_code = krui_createLink (G2b_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO ncb unit */
   ret_code = krui_setCurrentUnit (NCb_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM rstb units */
   for (j=1; j<=f2bUnits; j++) {
      ret_code = krui_createLink (RSTb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


   /* TO rhob unit */
   ret_code = krui_setCurrentUnit (RHOb_UNIT);
   CHECK_RETURN (ret_code);

   /* from itself */
   ret_code = krui_createLink (RHOb_UNIT, 0.0);
   CHECK_RETURN (ret_code);


   /* TO g2b unit */
   ret_code = krui_setCurrentUnit (G2b_UNIT);
   CHECK_RETURN (ret_code);

   /* FROM inpb units */
   for (j = 1; j <= f1bUnits; j++) {
      ret_code = krui_createLink (INPb_UNIT(j), 0.0);
      CHECK_RETURN (ret_code);
   } /*for*/


  /*  set the update function  */
  ret_code = krui_setUpdateFunc (UPDATE_FUNC_NAME);
  CHECK_RETURN( ret_code );

  /* set the learning function */
  ret_code = krui_setLearnFunc (LEARN_FUNC_NAME);

   //ui_NumberOfLearnParamsChanged();
   //ui_NumberOfUpdateParamsChanged();
   return (ret_code);
}
コード例 #7
0
/* Recalculate all state from scratch.  Perhaps not the most
 * efficient, but this has gotten complex enough that we need
 * something which is understandable and reliable.
 */
static bool
i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
{
   struct gl_context *ctx = &intel->ctx;
   struct i830_context *i830 = i830_context(ctx);
   struct gl_texture_unit *tUnit = &ctx->Texture.Unit[unit];
   struct gl_texture_object *tObj = tUnit->_Current;
   struct intel_texture_object *intelObj = intel_texture_object(tObj);
   struct gl_texture_image *firstImage;
   struct gl_sampler_object *sampler = _mesa_get_samplerobj(ctx, unit);
   GLuint *state = i830->state.Tex[unit], format, pitch;
   GLint lodbias;
   GLubyte border[4];
   GLuint dst_x, dst_y;

   memset(state, 0, sizeof(*state));

   /*We need to refcount these. */

   if (i830->state.tex_buffer[unit] != NULL) {
       drm_intel_bo_unreference(i830->state.tex_buffer[unit]);
       i830->state.tex_buffer[unit] = NULL;
   }

   if (!intel_finalize_mipmap_tree(intel, unit))
      return false;

   /* Get first image here, since intelObj->firstLevel will get set in
    * the intel_finalize_mipmap_tree() call above.
    */
   firstImage = tObj->Image[0][tObj->BaseLevel];

   intel_miptree_get_image_offset(intelObj->mt, tObj->BaseLevel, 0,
				  &dst_x, &dst_y);

   drm_intel_bo_reference(intelObj->mt->region->bo);
   i830->state.tex_buffer[unit] = intelObj->mt->region->bo;
   pitch = intelObj->mt->region->pitch;

   /* XXX: This calculation is probably broken for tiled images with
    * a non-page-aligned offset.
    */
   i830->state.tex_offset[unit] = dst_x * intelObj->mt->cpp + dst_y * pitch;

   format = translate_texture_format(firstImage->TexFormat);

   state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
                               (LOAD_TEXTURE_MAP0 << unit) | 4);

   state[I830_TEXREG_TM0S1] =
      (((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
       ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);

   if (intelObj->mt->region->tiling != I915_TILING_NONE) {
      state[I830_TEXREG_TM0S1] |= TM0S1_TILED_SURFACE;
      if (intelObj->mt->region->tiling == I915_TILING_Y)
	 state[I830_TEXREG_TM0S1] |= TM0S1_TILE_WALK;
   }

   state[I830_TEXREG_TM0S2] =
      ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);

   {
      if (tObj->Target == GL_TEXTURE_CUBE_MAP)
         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit) |
                                    CUBE_NEGX_ENABLE |
                                    CUBE_POSX_ENABLE |
                                    CUBE_NEGY_ENABLE |
                                    CUBE_POSY_ENABLE |
                                    CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE);
      else
         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit));
   }




   {
      GLuint minFilt, mipFilt, magFilt;
      float maxlod;
      uint32_t minlod_fixed, maxlod_fixed;

      switch (sampler->MinFilter) {
      case GL_NEAREST:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_NONE;
         break;
      case GL_LINEAR:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_NONE;
         break;
      case GL_NEAREST_MIPMAP_NEAREST:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_NEAREST;
         break;
      case GL_LINEAR_MIPMAP_NEAREST:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_NEAREST;
         break;
      case GL_NEAREST_MIPMAP_LINEAR:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_LINEAR;
         break;
      case GL_LINEAR_MIPMAP_LINEAR:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_LINEAR;
         break;
      default:
         return false;
      }

      if (sampler->MaxAnisotropy > 1.0) {
         minFilt = FILTER_ANISOTROPIC;
         magFilt = FILTER_ANISOTROPIC;
      }
      else {
         switch (sampler->MagFilter) {
         case GL_NEAREST:
            magFilt = FILTER_NEAREST;
            break;
         case GL_LINEAR:
            magFilt = FILTER_LINEAR;
            break;
         default:
            return false;
         }
      }

      lodbias = (int) ((tUnit->LodBias + sampler->LodBias) * 16.0);
      if (lodbias < -64)
          lodbias = -64;
      if (lodbias > 63)
          lodbias = 63;
      
      state[I830_TEXREG_TM0S3] = ((lodbias << TM0S3_LOD_BIAS_SHIFT) & 
                                  TM0S3_LOD_BIAS_MASK);
#if 0
      /* YUV conversion:
       */
      if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR ||
          firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV)
         state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION;
#endif

      /* We get one field with fraction bits for the maximum
       * addressable (smallest resolution) LOD.  Use it to cover both
       * MAX_LEVEL and MAX_LOD.
       */
      minlod_fixed = U_FIXED(CLAMP(sampler->MinLod, 0.0, 11), 4);
      maxlod = MIN2(sampler->MaxLod, tObj->_MaxLevel - tObj->BaseLevel);
      if (intel->intelScreen->deviceID == PCI_CHIP_I855_GM ||
	  intel->intelScreen->deviceID == PCI_CHIP_I865_G) {
	 maxlod_fixed = U_FIXED(CLAMP(maxlod, 0.0, 11.75), 2);
	 maxlod_fixed = MAX2(maxlod_fixed, (minlod_fixed + 3) >> 2);
	 state[I830_TEXREG_TM0S3] |= maxlod_fixed << TM0S3_MIN_MIP_SHIFT;
	 state[I830_TEXREG_TM0S2] |= TM0S2_LOD_PRECLAMP;
      } else {
コード例 #8
0
/* Recalculate all state from scratch.  Perhaps not the most
 * efficient, but this has gotten complex enough that we need
 * something which is understandable and reliable.
 */
static GLboolean
i830_update_tex_unit(struct intel_context *intel, GLuint unit, GLuint ss3)
{
   GLcontext *ctx = &intel->ctx;
   struct i830_context *i830 = i830_context(ctx);
   struct gl_texture_unit *tUnit = &ctx->Texture.Unit[unit];
   struct gl_texture_object *tObj = tUnit->_Current;
   struct intel_texture_object *intelObj = intel_texture_object(tObj);
   struct gl_texture_image *firstImage;
   GLuint *state = i830->state.Tex[unit], format, pitch;
   GLint lodbias;
   GLubyte border[4];
   GLuint dst_x, dst_y;

   memset(state, 0, sizeof(state));

   /*We need to refcount these. */

   if (i830->state.tex_buffer[unit] != NULL) {
       drm_intel_bo_unreference(i830->state.tex_buffer[unit]);
       i830->state.tex_buffer[unit] = NULL;
   }

   if (!intel_finalize_mipmap_tree(intel, unit))
      return GL_FALSE;

   /* Get first image here, since intelObj->firstLevel will get set in
    * the intel_finalize_mipmap_tree() call above.
    */
   firstImage = tObj->Image[0][intelObj->firstLevel];

   intel_miptree_get_image_offset(intelObj->mt, intelObj->firstLevel, 0, 0,
				  &dst_x, &dst_y);

   drm_intel_bo_reference(intelObj->mt->region->buffer);
   i830->state.tex_buffer[unit] = intelObj->mt->region->buffer;
   pitch = intelObj->mt->region->pitch * intelObj->mt->cpp;

   /* XXX: This calculation is probably broken for tiled images with
    * a non-page-aligned offset.
    */
   i830->state.tex_offset[unit] = dst_x * intelObj->mt->cpp + dst_y * pitch;

   format = translate_texture_format(firstImage->TexFormat,
				     firstImage->InternalFormat);

   state[I830_TEXREG_TM0LI] = (_3DSTATE_LOAD_STATE_IMMEDIATE_2 |
                               (LOAD_TEXTURE_MAP0 << unit) | 4);

   state[I830_TEXREG_TM0S1] =
      (((firstImage->Height - 1) << TM0S1_HEIGHT_SHIFT) |
       ((firstImage->Width - 1) << TM0S1_WIDTH_SHIFT) | format);

   if (intelObj->mt->region->tiling != I915_TILING_NONE) {
      state[I830_TEXREG_TM0S1] |= TM0S1_TILED_SURFACE;
      if (intelObj->mt->region->tiling == I915_TILING_Y)
	 state[I830_TEXREG_TM0S1] |= TM0S1_TILE_WALK;
   }

   state[I830_TEXREG_TM0S2] =
      ((((pitch / 4) - 1) << TM0S2_PITCH_SHIFT) | TM0S2_CUBE_FACE_ENA_MASK);

   {
      if (tObj->Target == GL_TEXTURE_CUBE_MAP)
         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit) |
                                    CUBE_NEGX_ENABLE |
                                    CUBE_POSX_ENABLE |
                                    CUBE_NEGY_ENABLE |
                                    CUBE_POSY_ENABLE |
                                    CUBE_NEGZ_ENABLE | CUBE_POSZ_ENABLE);
      else
         state[I830_TEXREG_CUBE] = (_3DSTATE_MAP_CUBE | MAP_UNIT(unit));
   }




   {
      GLuint minFilt, mipFilt, magFilt;

      switch (tObj->MinFilter) {
      case GL_NEAREST:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_NONE;
         break;
      case GL_LINEAR:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_NONE;
         break;
      case GL_NEAREST_MIPMAP_NEAREST:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_NEAREST;
         break;
      case GL_LINEAR_MIPMAP_NEAREST:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_NEAREST;
         break;
      case GL_NEAREST_MIPMAP_LINEAR:
         minFilt = FILTER_NEAREST;
         mipFilt = MIPFILTER_LINEAR;
         break;
      case GL_LINEAR_MIPMAP_LINEAR:
         minFilt = FILTER_LINEAR;
         mipFilt = MIPFILTER_LINEAR;
         break;
      default:
         return GL_FALSE;
      }

      if (tObj->MaxAnisotropy > 1.0) {
         minFilt = FILTER_ANISOTROPIC;
         magFilt = FILTER_ANISOTROPIC;
      }
      else {
         switch (tObj->MagFilter) {
         case GL_NEAREST:
            magFilt = FILTER_NEAREST;
            break;
         case GL_LINEAR:
            magFilt = FILTER_LINEAR;
            break;
         default:
            return GL_FALSE;
         }
      }

      lodbias = (int) ((tUnit->LodBias + tObj->LodBias) * 16.0);
      if (lodbias < -64)
          lodbias = -64;
      if (lodbias > 63)
          lodbias = 63;
      
      state[I830_TEXREG_TM0S3] = ((lodbias << TM0S3_LOD_BIAS_SHIFT) & 
                                  TM0S3_LOD_BIAS_MASK);
#if 0
      /* YUV conversion:
       */
      if (firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR ||
          firstImage->TexFormat->MesaFormat == MESA_FORMAT_YCBCR_REV)
         state[I830_TEXREG_TM0S3] |= SS2_COLORSPACE_CONVERSION;
#endif

      state[I830_TEXREG_TM0S3] |= ((intelObj->lastLevel -
                                    intelObj->firstLevel) *
                                   4) << TM0S3_MIN_MIP_SHIFT;

      state[I830_TEXREG_TM0S3] |= ((minFilt << TM0S3_MIN_FILTER_SHIFT) |
                                   (mipFilt << TM0S3_MIP_FILTER_SHIFT) |
                                   (magFilt << TM0S3_MAG_FILTER_SHIFT));
   }

   {
      GLenum ws = tObj->WrapS;
      GLenum wt = tObj->WrapT;


      /* 3D textures not available on i830
       */
      if (tObj->Target == GL_TEXTURE_3D)
         return GL_FALSE;

      state[I830_TEXREG_MCS] = (_3DSTATE_MAP_COORD_SET_CMD |
                                MAP_UNIT(unit) |
                                ENABLE_TEXCOORD_PARAMS |
                                ss3 |
                                ENABLE_ADDR_V_CNTL |
                                TEXCOORD_ADDR_V_MODE(translate_wrap_mode(wt))
                                | ENABLE_ADDR_U_CNTL |
                                TEXCOORD_ADDR_U_MODE(translate_wrap_mode
                                                     (ws)));
   }

   /* convert border color from float to ubyte */
   CLAMPED_FLOAT_TO_UBYTE(border[0], tObj->BorderColor.f[0]);
   CLAMPED_FLOAT_TO_UBYTE(border[1], tObj->BorderColor.f[1]);
   CLAMPED_FLOAT_TO_UBYTE(border[2], tObj->BorderColor.f[2]);
   CLAMPED_FLOAT_TO_UBYTE(border[3], tObj->BorderColor.f[3]);

   state[I830_TEXREG_TM0S4] = PACK_COLOR_8888(border[3],
					      border[0],
					      border[1],
					      border[2]);

   I830_ACTIVESTATE(i830, I830_UPLOAD_TEX(unit), GL_TRUE);
   /* memcmp was already disabled, but definitely won't work as the
    * region might now change and that wouldn't be detected:
    */
   I830_STATECHANGE(i830, I830_UPLOAD_TEX(unit));
   return GL_TRUE;
}