Пример #1
0
/*-----------------------------------------------------------------------*/
pNXDS createNXDataset(int rank, int typecode, int64_t dim[]){
  pNXDS pNew = NULL;
  int64_t length;
  int i;

  pNew = (pNXDS)malloc(sizeof(NXDS));
  if(pNew == NULL){
    return NULL;
  }

  pNew->dim = (int64_t *)malloc(rank*sizeof(int64_t));
  for(i = 0, length = 1; i < rank; i++){
    length *= dim[i];
  }
  /* add +1 in case of string NULL termination */
  pNew->u.ptr = malloc((size_t)length*getTypeSize(typecode)+1);

  if(pNew->dim == NULL || pNew->u.ptr == NULL){
    free(pNew);
    return NULL;
  }
  pNew->rank = rank;
  pNew->type = typecode;
  pNew->format = NULL;
  for(i = 0; i < rank; i++){
    pNew->dim[i] = dim[i];
  }
  pNew->magic = MAGIC;
  /* add +1 in case of string NULL termination  - see above */
  memset(pNew->u.ptr,0,(size_t)length*getTypeSize(typecode)+1);
  return pNew;
}
Пример #2
0
/*-----------------------------------------------------------------------*/
pNXDS createNXDataset(int rank, int typecode, int dim[]){
  pNXDS pNew = NULL;
  int i, length;

  pNew = (pNXDS)malloc(sizeof(NXDS));
  if(pNew == NULL){
    return NULL;
  }

  pNew->dim = (int *)malloc(rank*sizeof(int));
  for(i = 0, length = 1; i < rank; i++){
    length *= dim[i];
  }
  pNew->u.ptr = malloc(length*getTypeSize(typecode));

  if(pNew->dim == NULL || pNew->u.ptr == NULL){
    free(pNew);
    return NULL;
  }
  pNew->rank = rank;
  pNew->type = typecode;
  pNew->format = NULL;
  for(i = 0; i < rank; i++){
    pNew->dim[i] = dim[i];
  }
  pNew->magic = MAGIC;
  memset(pNew->u.ptr,0,length*getTypeSize(typecode));
  return pNew;
}
Пример #3
0
CSymbol* CData::addConstant (const std::string &name, const int &type, int size, const int &address)
{
   if (size == 0) {
      size = getTypeSize(type);
   }

   CSymbol *symbol = new CSymbol (CSymbol::GLOBAL, name, type, size, CSymbol::CONST, address);

   _symbols.push_back(symbol);

   //_data += symbol->getBinary();
   if (type == CSymbol::STRING) {
      // Para strings constantes e variaveis eh necessario indicar a categoria
      std::cout << "String constante [" << name << "] indicado o tipo..." << std::endl;
      writeByte(CSymbol::CONST);
      writeString(name, false);
   } else if (type == CSymbol::INT) {
      writeInt(atoi(name.c_str()));
   } else if (type == CSymbol::BOOL) {
      writeInt(atoi(name.c_str()));
   } else if (type == CSymbol::REAL) {
      writeReal(atof(name.c_str()));
   } else if (type == CSymbol::CHAR) {
      writeInt(toUTF8Char(name));
   } else {
     std::cout << "Ta faltando algum tipo ???" << endl;
     abort();
   }

   return symbol;
}
Пример #4
0
		void VertexArray::drawRange(GLuint begin, GLuint end, ePrimitives mode_) {
			bind();

			assert(end >= begin);

			GLenum mode = static_cast<GLenum>(mode_);
			GLsizei count = end - begin;
			GLvoid* offset = (GLvoid*)(getTypeSize(mIndexBufferType) * begin);

			if (mIndexBufferType == 0)
				glDrawArrays(
					mode,
					begin,
					count
				);
			else
				glDrawRangeElements(
					mode,
					0,
					mVertexBufferSize,
					count,
					mIndexBufferType,
					offset
				);

			unbind();
		}
Пример #5
0
 /**
  * @brief
  */
 virtual void byteSwapElements()
 {
   char* ptr = (char*)(m_Array);
   char t[8];
   size_t size = getTypeSize();
   for (uint64_t var = 0; var < m_Size; ++var)
   {
     if (sizeof(T) == 2)
     {
       mxa_bswap(0, 1, t);
     }
     else if (sizeof(T) == 4)
     {
       mxa_bswap(0, 3, t);
       mxa_bswap(1, 2, t);
     }
     else if (sizeof(T) == 8)
     {
       mxa_bswap(0, 7, t);
       mxa_bswap(1, 6, t);
       mxa_bswap(2, 5, t);
       mxa_bswap(3, 4, t);
     }
     ptr += size; // increment the pointer
   }
 }
Пример #6
0
static void evergreenSetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
{
    context_t *context = EVERGREEN_CONTEXT(ctx);

    if (!mesa_ind_buf) {
        context->ind_buf.bo = NULL;
        return;
    }

#if MESA_BIG_ENDIAN
    if (mesa_ind_buf->type == GL_UNSIGNED_INT)
#else
    if (mesa_ind_buf->type != GL_UNSIGNED_BYTE)
#endif
    {
        const GLvoid *src_ptr;
        GLvoid *dst_ptr;
        GLboolean mapped_named_bo = GL_FALSE;

        if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer)
        {
	        ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
	        assert(mesa_ind_buf->obj->Pointer != NULL);
	        mapped_named_bo = GL_TRUE;
        }

        src_ptr = ADD_POINTERS(mesa_ind_buf->obj->Pointer, mesa_ind_buf->ptr);

        const GLuint size = mesa_ind_buf->count * getTypeSize(mesa_ind_buf->type);

	radeonAllocDmaRegion(&context->radeon, &context->ind_buf.bo,
			     &context->ind_buf.bo_offset, size, 4);
	radeon_bo_map(context->ind_buf.bo, 1);
	assert(context->ind_buf.bo->ptr != NULL);
	dst_ptr = ADD_POINTERS(context->ind_buf.bo->ptr, context->ind_buf.bo_offset);

        memcpy(dst_ptr, src_ptr, size);

	radeon_bo_unmap(context->ind_buf.bo);
        context->ind_buf.is_32bit = (mesa_ind_buf->type == GL_UNSIGNED_INT);
        context->ind_buf.count = mesa_ind_buf->count;

        if (mapped_named_bo)
        {
	        ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, mesa_ind_buf->obj);
        }
    }
    else
    {
	    evergreenFixupIndexBuffer(ctx, mesa_ind_buf);
    }
}
Пример #7
0
static void evergreenAlignDataToDword(GLcontext *ctx, 
                                 const struct gl_client_array *input, 
                                 int count, 
                                 struct StreamDesc *attr)
{
    context_t *context = EVERGREEN_CONTEXT(ctx);
    const int dst_stride = (input->StrideB + 3) & ~3;
    const int size = getTypeSize(input->Type) * input->Size * count;
    GLboolean mapped_named_bo = GL_FALSE;

    radeonAllocDmaRegion(&context->radeon, &attr->bo, &attr->bo_offset, size, 32);

    radeon_bo_map(attr->bo, 1);

    if (!input->BufferObj->Pointer) 
    {
        ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY_ARB, input->BufferObj);
        mapped_named_bo = GL_TRUE;
    }

    {
        GLvoid *src_ptr = ADD_POINTERS(input->BufferObj->Pointer, input->Ptr);
        GLvoid *dst_ptr = ADD_POINTERS(attr->bo->ptr, attr->bo_offset);
        int i;

        for (i = 0; i < count; ++i) 
        {
            memcpy(dst_ptr, src_ptr, input->StrideB);
            src_ptr += input->StrideB;
            dst_ptr += dst_stride;
        }
    }

    radeon_bo_unmap(attr->bo);
    if (mapped_named_bo) 
    {
        ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, input->BufferObj);
    }

    attr->stride = dst_stride;
}
Пример #8
0
CSymbol* CData::addVariable (const int &scope, const std::string &name, const int &type, int size, const int &address)
{
   if (size == 0) {
      size = getTypeSize(type);
   }

   CSymbol *symbol = new CSymbol (scope, name, type, size, CSymbol::VAR, address);

   _symbols.push_back(symbol);

   if (type == CSymbol::STRING) {
      // Para strings constantes e variaveis eh necessario indicar a categoria
      writeByte(CSymbol::VAR);
   }

   //_data += symbol->getBinary();
   for (int i=0; i < symbol->getTypeSize(); i++) {
      // TODO: horrivel :-)
      writeByte ('\0');
   }

   return symbol;
}
Пример #9
0
    void Texture::update() {
        glBindTexture(GL_TEXTURE_2D, _handle);

        _data.resize(_width * _height * getTypeSize(_type) * getElementCount(_format));
        std::generate(_data.begin(), _data.end(), randbyte);
        glTexImage2D(
            GL_TEXTURE_2D, 0, _internalFormat, _width, _height,
            _border, _format, _type, &_data[0]);

        tpf(GL_TEXTURE_MIN_FILTER, _minFilter);
        tpf(GL_TEXTURE_MAG_FILTER, _magFilter);
        tpf(GL_TEXTURE_MIN_LOD,    _minLOD);
        tpf(GL_TEXTURE_MAX_LOD,    _maxLOD);
        tpi(GL_TEXTURE_BASE_LEVEL, _baseLevel);
        tpi(GL_TEXTURE_MAX_LEVEL,  _maxLevel);
        tpf(GL_TEXTURE_WRAP_S,     _wrapS);
        tpf(GL_TEXTURE_WRAP_T,     _wrapT);
        tpf(GL_TEXTURE_WRAP_R,     _wrapR);
        tpfv(GL_TEXTURE_BORDER_COLOR, _borderColor.getData());
        tpf(GL_TEXTURE_PRIORITY,   _priority);

        glBindTexture(GL_TEXTURE_2D, 0);
    }
Пример #10
0
static void r300AlignDataToDword(GLcontext *ctx, const struct gl_client_array *input, int count, struct vertex_attribute *attr)
{
	r300ContextPtr r300 = R300_CONTEXT(ctx);
	const int dst_stride = (input->StrideB + 3) & ~3;
	const int size = getTypeSize(input->Type) * input->Size * count;
	GLboolean mapped_named_bo = GL_FALSE;

	radeonAllocDmaRegion(&r300->radeon, &attr->bo, &attr->bo_offset, size, 32);

	radeon_bo_map(attr->bo, 1);

	if (!input->BufferObj->Pointer) {
		ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY_ARB, input->BufferObj);
		mapped_named_bo = GL_TRUE;
	}

	radeon_print(RADEON_FALLBACKS, RADEON_IMPORTANT, "%s. Vertex alignment doesn't match hw requirements.\n", __func__);

	{
		GLvoid *src_ptr = ADD_POINTERS(input->BufferObj->Pointer, input->Ptr);
		GLvoid *dst_ptr = ADD_POINTERS(attr->bo->ptr, attr->bo_offset);
		int i;

		for (i = 0; i < count; ++i) {
			memcpy(dst_ptr, src_ptr, input->StrideB);
			src_ptr += input->StrideB;
			dst_ptr += dst_stride;
		}
	}

	if (mapped_named_bo) {
		ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, input->BufferObj);
	}

	radeon_bo_unmap(attr->bo);
	attr->stride = dst_stride;
}
Пример #11
0
static void r700TranslateAttrib(struct gl_context *ctx, GLuint unLoc, int count, const struct gl_client_array *input)
{
    context_t *context = R700_CONTEXT(ctx);
    
    StreamDesc * pStreamDesc = &(context->stream_desc[context->nNumActiveAos]);

	GLuint stride;

	stride = (input->StrideB == 0) ? getTypeSize(input->Type) * input->Size 
                                   : input->StrideB;

    if (input->Type == GL_DOUBLE || input->Type == GL_UNSIGNED_INT || input->Type == GL_INT
#if MESA_BIG_ENDIAN
        || getTypeSize(input->Type) != 4
#endif
       ) 
    {
        pStreamDesc->type = GL_FLOAT;

        if (input->StrideB == 0) 
        {
	        pStreamDesc->stride = 0;
        } 
        else 
        {
	        pStreamDesc->stride = sizeof(GLfloat) * input->Size;
        }
        pStreamDesc->dwords = input->Size;
        pStreamDesc->is_named_bo = GL_FALSE;
    } 
    else 
    {
        pStreamDesc->type = input->Type;
        pStreamDesc->dwords = (getTypeSize(input->Type) * input->Size + 3)/ 4;
        if (!input->BufferObj->Name) 
        {
            if (input->StrideB == 0) 
            {
                pStreamDesc->stride = 0;
            } 
            else 
            {
                pStreamDesc->stride = (getTypeSize(pStreamDesc->type) * input->Size + 3) & ~3;
            }

            pStreamDesc->is_named_bo = GL_FALSE;
        }
    }

	pStreamDesc->size = input->Size;
	pStreamDesc->dst_loc = context->nNumActiveAos;
	pStreamDesc->element = unLoc;
	pStreamDesc->format = input->Format;

	switch (pStreamDesc->type) 
	{ //GetSurfaceFormat
	case GL_FLOAT:
		pStreamDesc->_signed = 0;
		pStreamDesc->normalize = GL_FALSE;
		break;
	case GL_SHORT:
		pStreamDesc->_signed = 1;
		pStreamDesc->normalize = input->Normalized;
		break;
	case GL_BYTE:
		pStreamDesc->_signed = 1;
		pStreamDesc->normalize = input->Normalized;
		break;
	case GL_UNSIGNED_SHORT:
		pStreamDesc->_signed = 0;
		pStreamDesc->normalize = input->Normalized;
		break;
	case GL_UNSIGNED_BYTE:
		pStreamDesc->_signed = 0;
		pStreamDesc->normalize = input->Normalized;
		break;
	default:
	case GL_INT:
	case GL_UNSIGNED_INT:
	case GL_DOUBLE: 
		assert(0);
		break;
	}
	context->nNumActiveAos++;
}
Пример #12
0
static void r700SetupVTXConstants(GLcontext  * ctx,
				  void *       pAos,
				  StreamDesc * pStreamDesc)
{
    context_t *context = R700_CONTEXT(ctx);
    struct radeon_aos * paos = (struct radeon_aos *)pAos;
    unsigned int nVBsize;
    BATCH_LOCALS(&context->radeon);

    unsigned int uSQ_VTX_CONSTANT_WORD0_0;
    unsigned int uSQ_VTX_CONSTANT_WORD1_0;
    unsigned int uSQ_VTX_CONSTANT_WORD2_0 = 0;
    unsigned int uSQ_VTX_CONSTANT_WORD3_0 = 0;
    unsigned int uSQ_VTX_CONSTANT_WORD6_0 = 0;

    if (!paos->bo)
	    return;

    if ((context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV610) ||
	(context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV620) ||
	(context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RS780) ||
	(context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RS880) ||
	(context->radeon.radeonScreen->chip_family == CHIP_FAMILY_RV710))
	    r700SyncSurf(context, paos->bo, RADEON_GEM_DOMAIN_GTT, 0, TC_ACTION_ENA_bit);
    else
	    r700SyncSurf(context, paos->bo, RADEON_GEM_DOMAIN_GTT, 0, VC_ACTION_ENA_bit);

    if(0 == pStreamDesc->stride)
    {
        nVBsize = paos->count * pStreamDesc->size * getTypeSize(pStreamDesc->type);
    }
    else
    {
        nVBsize = (paos->count - 1) * pStreamDesc->stride
                  + pStreamDesc->size * getTypeSize(pStreamDesc->type);
    }

    uSQ_VTX_CONSTANT_WORD0_0 = paos->offset;
    uSQ_VTX_CONSTANT_WORD1_0 = nVBsize - 1;

    SETfield(uSQ_VTX_CONSTANT_WORD2_0, 0, BASE_ADDRESS_HI_shift, BASE_ADDRESS_HI_mask); /* TODO */
    SETfield(uSQ_VTX_CONSTANT_WORD2_0, pStreamDesc->stride, SQ_VTX_CONSTANT_WORD2_0__STRIDE_shift,
	     SQ_VTX_CONSTANT_WORD2_0__STRIDE_mask);
    SETfield(uSQ_VTX_CONSTANT_WORD2_0, GetSurfaceFormat(pStreamDesc->type, pStreamDesc->size, NULL),
	     SQ_VTX_CONSTANT_WORD2_0__DATA_FORMAT_shift,
	     SQ_VTX_CONSTANT_WORD2_0__DATA_FORMAT_mask); /* TODO : trace back api for initial data type, not only GL_FLOAT */
    
    if(GL_TRUE == pStreamDesc->normalize)
    {
        SETfield(uSQ_VTX_CONSTANT_WORD2_0, SQ_NUM_FORMAT_NORM,
	             SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_shift, SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_mask);
    }
    else
    {
        SETfield(uSQ_VTX_CONSTANT_WORD2_0, SQ_NUM_FORMAT_SCALED,
	             SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_shift, SQ_VTX_CONSTANT_WORD2_0__NUM_FORMAT_ALL_mask);
    }

    if(1 == pStreamDesc->_signed)
    {
        SETbit(uSQ_VTX_CONSTANT_WORD2_0, SQ_VTX_CONSTANT_WORD2_0__FORMAT_COMP_ALL_bit);
    }

    SETfield(uSQ_VTX_CONSTANT_WORD3_0, 1, MEM_REQUEST_SIZE_shift, MEM_REQUEST_SIZE_mask);
    SETfield(uSQ_VTX_CONSTANT_WORD6_0, SQ_TEX_VTX_VALID_BUFFER,
	     SQ_TEX_RESOURCE_WORD6_0__TYPE_shift, SQ_TEX_RESOURCE_WORD6_0__TYPE_mask);

    BEGIN_BATCH_NO_AUTOSTATE(9 + 2);

    R600_OUT_BATCH(CP_PACKET3(R600_IT_SET_RESOURCE, 7));
    R600_OUT_BATCH((pStreamDesc->element + SQ_FETCH_RESOURCE_VS_OFFSET) * FETCH_RESOURCE_STRIDE);
    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD0_0);
    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD1_0);
    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD2_0);
    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD3_0);
    R600_OUT_BATCH(0);
    R600_OUT_BATCH(0);
    R600_OUT_BATCH(uSQ_VTX_CONSTANT_WORD6_0);
    R600_OUT_BATCH_RELOC(uSQ_VTX_CONSTANT_WORD0_0,
                         paos->bo,
                         uSQ_VTX_CONSTANT_WORD0_0,
                         RADEON_GEM_DOMAIN_GTT, 0, 0);
    END_BATCH();
    COMMIT_BATCH();

}
Пример #13
0
int main (int argc, char**argv)
{
	int32_t first_Error = 0;
	ResetProperties();
	UpdateNumberOfRawAndColomn();
	// check error
	if (argc < 2) {
		printf("You set more than 3 argument at the commande line\n");
		usage();
		return -1;
	}
	bool directCheckFiles = false;
	int basicIDParsing = 1;
	if (0==strcmp("-d",argv[1])) {
		basicIDParsing++;
		directCheckFiles = true;
	}
	// one file
	if (basicIDParsing+1 <= argc) {
		strcpy(fileProp[0].name, argv[basicIDParsing]);
		fileProp[0].availlable = true;
	}
	// a second file
	if (basicIDParsing+2 <= argc) {
		strcpy(fileProp[1].name, argv[basicIDParsing+1]);
		fileProp[1].availlable = true;
	}
	// open the files
	OpenFiles();
	
	// user requested to have the direct error ID of the file...
	if (directCheckFiles==true) {
		
		float dividor = 1;
		int32_t maxSlot = (fileProp[0].slotSize>fileProp[1].slotSize)?fileProp[0].slotSize:fileProp[1].slotSize;
		if (0!=maxSlot) {
			dividor = maxSlot;
		}
		
		int32_t idError = findFirstDiff();
		int minSizeFile = ((fileProp[0].size<fileProp[1].size)?fileProp[0].size:fileProp[1].size) - abs(getPaddingOffsetFile());
		if (minSizeFile<=idError) {
			printf(" --- slot=%3d nb frame=%d", (int32_t)dividor, (int32_t)(idError/dividor));
			CloseFiles();
			// 0 : no error
			return 0;
		} else {
			int32_t sizeElement = 1;
			showTypeSize_te tmpType = getTypeSize();
			switch(tmpType)
			{
				default:
				case SHOW_TYPE_SIZE_8:
					sizeElement = 1;
					break;
				case SHOW_TYPE_SIZE_16:
					sizeElement = 2;
					break;
				case SHOW_TYPE_SIZE_FLOAT:
				case SHOW_TYPE_SIZE_32:
					sizeElement = 4;
					break;
				case SHOW_TYPE_SIZE_DOUBLE:
				case SHOW_TYPE_SIZE_64:
					sizeElement = 8;
					break;
			}
			int32_t elementIDError = idError/sizeElement;
			float frameRatio = (float)elementIDError/dividor;
			int32_t idFrame = frameRatio;
			int32_t idFrameElement = (frameRatio-idFrame)*dividor;
			printf("%9d / frame=%9.2f ==> frame=%5d element=%5d slot=%3d", elementIDError, frameRatio, idFrame, idFrameElement, (int32_t)dividor);
			CloseFiles();
			return idError;
		}
	}
	// rendre la lecture des données non canonique
	system("stty -icanon");
	// supression de l'écho des caractères
	system("stty -echo");
	// enable mouse event ...
	printf(MOUSE_REPORTING_ENABLE);
	// hide cursor ...
	printf(CURSOR_DISPLAY_DISABLE);
	system("clear");
	CleanDisplay();


	int ret = 0;
	pthread_t HangleThreadDisplay;

	ret = pthread_create ( & HangleThreadDisplay, NULL, threadDisplay, NULL );
	if (! ret)
	{
		while (1)
		{
			int32_t inputValue;
			inputValue = getc(stdin);
			switch(inputValue)
			{
				case 'q':
				case 'Q':
					goto exit_programme;
					break;
				//case 0x1B:
				case '\e':
					inputValue = getc (stdin);
					//printf("\n get data : 0x%08x ..... : \n", (unsigned int)inputValue);
					// [ == 0x5B
					if (inputValue == '[')
					{
						inputValue = getc (stdin);
						char charValue = inputValue;
						// printf("\n get data : 0x%08x ..... : \\e[%c\n", (unsigned int)inputValue, charValue);
						if (    charValue == 'A' //0x41 ==> UP
						     || charValue == 'B' //0x42 ==> DOWN
						     || charValue == 'C' //0x43 ==> RIGHT
						     || charValue == 'D' //0x44 ==> LEFT
						   )
						{
							//printf("\n get data :\\e[%c ==> MoveKey \n", charValue);
							if (charValue == 'A') {
								upDownOfsetFile(-5);
							} else if ( charValue == 'B') {
								upDownOfsetFile(5);
							} else if ( charValue == 'C') {
								upDownOfsetFile((GetNumberOfRaw()-NB_HEARDER_RAW));
							} else if ( charValue == 'D') {
								upDownOfsetFile(-(GetNumberOfRaw()-NB_HEARDER_RAW));
							}
						} else if (charValue == 'M' ) { //0x4d ==> mouse
							//printf("\n get data :\\e[%c ==> Mouse \n", charValue);
							int32_t button = getc(stdin);
							int32_t xPos = getc(stdin);
							xPos -= 0x20;
							int32_t yPos = getc(stdin);
							yPos -= 0x20;
							
							int32_t bt=0;
							switch (button) {
								case 97:
									bt = 4;
									break;
								case 96:
									bt = 5;
									break;
								case 32:
									bt = 1;
									break;
								case 33:
									bt = 3;
									break;
							}
							//printf("     bt=%#x=%d \n", button, bt);
							//printf("     x=%d y=%d\n", xPos, yPos);
							if (bt == 4) {
								upDownOfsetFile(5);
							} else if (bt == 5) {
								upDownOfsetFile(-5);
							}
						}
					}
					
					break;
				// change the type of interpretation the file
				case 't':
				case 'T':
					nextType();
					break;
				// change the size of showing the file
				case 's':
				case 'S':
					nextTypeSize();
					break;
				// find the first ERROR
				case 'f':
				case 'F':
					// try to find the first error...
					first_Error = findFirstDiff();
					setOfsetFile((first_Error/16)*16 - 128);
					needRedraw();
					break;
				// find the first ERROR
				case 'a':
				case 'A':
					setOfsetFile(0);
					break;
				// go to the end of the file (File 1 and next File 2)
				case 'z':
				case 'Z':
					{
						UpdateFilesSize();
						static bool whichElement = false;
						if (whichElement == false) {
							whichElement = true;
							setOfsetFile((fileProp[0].size/16)*16 - 256);
						} else {
							whichElement = false;
							setOfsetFile((fileProp[1].size/16)*16 - 256);
						}
					}
					break;
				// Reload the 2 files
				case 'r':
				case 'R':
					CloseFiles();
					UpdateNumberOfRawAndColomn();
					CleanDisplay();
					OpenFiles();
					needRedraw();
					break;
				// Display Slot mode :
				case 'j':
				case 'J':
					setSlotDisplayMode((getSlotDisplayMode()==true)?false:true);
					needRedraw();
					break;
				case 'U':
					setSlotSize(getSlotSize()-9);
				case 'u':
					setSlotSize(getSlotSize()-1);
					needRedraw();
					break;
				case 'I':
					setSlotSize(getSlotSize()+9);
				case 'i':
					setSlotSize(getSlotSize()+1);
					needRedraw();
					break;
				case 'k':
				case 'K':
					setSlotSize(0);
					setSlotDisplayMode(false);
					needRedraw();
					break;
				// Add padding offset between left an right file
				case 'o':
					displayPaddingOffset(-1);
					break;
				case 'O':
					displayPaddingOffset(-16);
					break;
				case 'p':
					displayPaddingOffset(1);
					break;
				case 'P':
					displayPaddingOffset(16);
					break;
				// Clear the padding
				case 'm':
				case 'M':
					displayPaddingOffsetClear();
					break;
				case 'c':
				case 'C':
					AutoSetPadding();
					break;
				case 'h':
				case 'H':
					setHelpDisplay((getHelpDisplay()==true)?false:true);
					needRedraw();
					break;
			}
		}
	} else {
Пример #14
0
static void evergreenSetupStreams(GLcontext *ctx, const struct gl_client_array *input[], int count)
{
	context_t *context = EVERGREEN_CONTEXT(ctx);
    GLuint stride;
    int ret;
    int i, index;

    EVERGREEN_STATECHANGE(context, vtx);

    for(index = 0; index < context->nNumActiveAos; index++) 
    {
        struct radeon_aos *aos = &context->radeon.tcl.aos[index];
        i = context->stream_desc[index].element;

        stride = (input[i]->StrideB == 0) ? getTypeSize(input[i]->Type) * input[i]->Size : input[i]->StrideB;

        if (input[i]->Type == GL_DOUBLE || input[i]->Type == GL_UNSIGNED_INT || input[i]->Type == GL_INT
#if MESA_BIG_ENDIAN
            || getTypeSize(input[i]->Type) != 4
#endif
	   )
        {
            evergreenConvertAttrib(ctx, count, input[i], &context->stream_desc[index]);
        } 
        else 
        {
            if (input[i]->BufferObj->Name) 
            {
		    context->stream_desc[index].stride = input[i]->StrideB;
		    context->stream_desc[index].bo_offset = (intptr_t) input[i]->Ptr;
		    context->stream_desc[index].bo = get_radeon_buffer_object(input[i]->BufferObj)->bo;
		    context->stream_desc[index].is_named_bo = GL_TRUE;
            } 
            else 
            {
                int size;
                int local_count = count;
                uint32_t *dst;

                if (input[i]->StrideB == 0) 
                {
                    size = getTypeSize(input[i]->Type) * input[i]->Size;
                    local_count = 1;
                } 
                else 
                {
                    size = getTypeSize(input[i]->Type) * input[i]->Size * local_count;
                }

                radeonAllocDmaRegion(&context->radeon, &context->stream_desc[index].bo, 
                                     &context->stream_desc[index].bo_offset, size, 32);

                radeon_bo_map(context->stream_desc[index].bo, 1);
                assert(context->stream_desc[index].bo->ptr != NULL);


                dst = (uint32_t *)ADD_POINTERS(context->stream_desc[index].bo->ptr, 
                                               context->stream_desc[index].bo_offset);

                switch (context->stream_desc[index].dwords) 
                {
                case 1:                       
                    radeonEmitVec4(dst, input[i]->Ptr, input[i]->StrideB, local_count);
                    break;
                case 2:                     
                    radeonEmitVec8(dst, input[i]->Ptr, input[i]->StrideB, local_count); 
                    break;
                case 3:                     
                    radeonEmitVec12(dst, input[i]->Ptr, input[i]->StrideB, local_count); 
                    break;
                case 4:                     
                    radeonEmitVec16(dst, input[i]->Ptr, input[i]->StrideB, local_count); 
                    break;
                default: 
                    assert(0); 
                    break;
                }

                radeon_bo_unmap(context->stream_desc[index].bo);
            }
        }

        aos->count = context->stream_desc[index].stride == 0 ? 1 : count;
        aos->stride = context->stream_desc[index].stride / sizeof(float);
        aos->components = context->stream_desc[index].dwords;
        aos->bo = context->stream_desc[index].bo;
        aos->offset = context->stream_desc[index].bo_offset;

        if(context->stream_desc[index].is_named_bo) 
        {
            radeon_cs_space_add_persistent_bo(context->radeon.cmdbuf.cs, 
                                              context->stream_desc[index].bo, 
                                              RADEON_GEM_DOMAIN_GTT, 0);
        }
    }

    ret = radeon_cs_space_check_with_bo(context->radeon.cmdbuf.cs, 
                                        first_elem(&context->radeon.dma.reserved)->bo, 
                                        RADEON_GEM_DOMAIN_GTT, 0);    
}
Пример #15
0
 std::size_t TypeSizeMapping::sizeOfOp(BuiltInType bitype) {
   ROSE_ASSERT(bitype<_mapping.size());
   return getTypeSize(bitype);
 }
Пример #16
0
static void r300SetupIndexBuffer(GLcontext *ctx, const struct _mesa_index_buffer *mesa_ind_buf)
{
	r300ContextPtr r300 = R300_CONTEXT(ctx);

	if (!mesa_ind_buf) {
		r300->ind_buf.bo = NULL;
		return;
	}
	radeon_print(RADEON_RENDER, RADEON_TRACE, "%s\n", __func__);

#if MESA_BIG_ENDIAN
	if (mesa_ind_buf->type == GL_UNSIGNED_INT) {
#else
	if (mesa_ind_buf->type != GL_UNSIGNED_BYTE) {
#endif
		const GLvoid *src_ptr;
		GLvoid *dst_ptr;
		GLboolean mapped_named_bo = GL_FALSE;

		if (mesa_ind_buf->obj->Name && !mesa_ind_buf->obj->Pointer) {
			ctx->Driver.MapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, GL_READ_ONLY_ARB, mesa_ind_buf->obj);
			assert(mesa_ind_buf->obj->Pointer != NULL);
			mapped_named_bo = GL_TRUE;
		}

		src_ptr = ADD_POINTERS(mesa_ind_buf->obj->Pointer, mesa_ind_buf->ptr);

		const GLuint size = mesa_ind_buf->count * getTypeSize(mesa_ind_buf->type);

		radeonAllocDmaRegion(&r300->radeon, &r300->ind_buf.bo, &r300->ind_buf.bo_offset, size, 4);

		radeon_bo_map(r300->ind_buf.bo, 1);
		assert(r300->ind_buf.bo->ptr != NULL);
		dst_ptr = ADD_POINTERS(r300->ind_buf.bo->ptr, r300->ind_buf.bo_offset);
		memcpy(dst_ptr, src_ptr, size);

		radeon_bo_unmap(r300->ind_buf.bo);
		r300->ind_buf.is_32bit = (mesa_ind_buf->type == GL_UNSIGNED_INT);
		r300->ind_buf.count = mesa_ind_buf->count;

		if (mapped_named_bo) {
			ctx->Driver.UnmapBuffer(ctx, GL_ELEMENT_ARRAY_BUFFER, mesa_ind_buf->obj);
		}
	} else {
		r300FixupIndexBuffer(ctx, mesa_ind_buf);
	}
}

#define CONVERT( TYPE, MACRO ) do {		\
	GLuint i, j, sz;				\
	sz = input->Size;				\
	if (input->Normalized) {			\
		for (i = 0; i < count; i++) {		\
			const TYPE *in = (TYPE *)src_ptr;		\
			for (j = 0; j < sz; j++) {		\
				*dst_ptr++ = MACRO(*in);		\
				in++;				\
			}					\
			src_ptr += stride;			\
		}						\
	} else {					\
		for (i = 0; i < count; i++) {		\
			const TYPE *in = (TYPE *)src_ptr;		\
			for (j = 0; j < sz; j++) {		\
				*dst_ptr++ = (GLfloat)(*in);		\
				in++;				\
			}					\
			src_ptr += stride;			\
		}						\
	}						\
} while (0)

/**
 * Convert attribute data type to float
 * If the attribute uses named buffer object replace the bo with newly allocated bo
 */
static void r300ConvertAttrib(GLcontext *ctx, int count, const struct gl_client_array *input, struct vertex_attribute *attr)
{
	r300ContextPtr r300 = R300_CONTEXT(ctx);
	const GLvoid *src_ptr;
	GLboolean mapped_named_bo = GL_FALSE;
	GLfloat *dst_ptr;
	GLuint stride;

	stride = (input->StrideB == 0) ? getTypeSize(input->Type) * input->Size : input->StrideB;

	/* Convert value for first element only */
	if (input->StrideB == 0)
		count = 1;

	if (input->BufferObj->Name) {
		if (!input->BufferObj->Pointer) {
			ctx->Driver.MapBuffer(ctx, GL_ARRAY_BUFFER, GL_READ_ONLY_ARB, input->BufferObj);
			mapped_named_bo = GL_TRUE;
		}

		src_ptr = ADD_POINTERS(input->BufferObj->Pointer, input->Ptr);
	} else {
		src_ptr = input->Ptr;
	}

	radeonAllocDmaRegion(&r300->radeon, &attr->bo, &attr->bo_offset, sizeof(GLfloat) * input->Size * count, 32);
	radeon_bo_map(attr->bo, 1);
	dst_ptr = (GLfloat *)ADD_POINTERS(attr->bo->ptr, attr->bo_offset);

	radeon_print(RADEON_FALLBACKS, RADEON_IMPORTANT,
			"%s: Converting vertex attributes, attribute data format %x,"
			"stride %d, components %d\n"
			, __FUNCTION__, input->Type
			, stride, input->Size);

	assert(src_ptr != NULL);

	switch (input->Type) {
		case GL_DOUBLE:
			CONVERT(GLdouble, (GLfloat));
			break;
		case GL_UNSIGNED_INT:
			CONVERT(GLuint, UINT_TO_FLOAT);
			break;
		case GL_INT:
			CONVERT(GLint, INT_TO_FLOAT);
			break;
		case GL_UNSIGNED_SHORT:
			CONVERT(GLushort, USHORT_TO_FLOAT);
			break;
		case GL_SHORT:
			CONVERT(GLshort, SHORT_TO_FLOAT);
			break;
		case GL_UNSIGNED_BYTE:
			assert(input->Format != GL_BGRA);
			CONVERT(GLubyte, UBYTE_TO_FLOAT);
			break;
		case GL_BYTE:
			CONVERT(GLbyte, BYTE_TO_FLOAT);
			break;
		default:
			assert(0);
			break;
	}

	radeon_bo_unmap(attr->bo);
	if (mapped_named_bo) {
		ctx->Driver.UnmapBuffer(ctx, GL_ARRAY_BUFFER, input->BufferObj);
	}
}
Пример #17
0
/**
 * \brief
 * do constant folding
 *
 * @param expr
 *      target node
 * @param[out] result
 *      result value
 * @return
 *      0:is not constant, 1:constant
 */
int
getConstNumValue(CExpr *expr, CNumValueWithType *result)
{
    memset(result, 0, sizeof(CNumValueWithType));

    if(EXPR_ISNULL(expr) || EXPR_ISERROR(expr)) {
        result->nvt_numValue.ll = 0;
        result->nvt_basicType = BT_INT;
        result->nvt_numKind = getNumValueKind(result->nvt_basicType);
        return 1;
    }

    if(EXPR_CODE(expr) == EC_XMP_DESC_OF) return 0; /* not constant */

    CNumValueWithType n1, n2, n3;
    int use2 = 0, use3 = 0, isConst2 = 0, isConst3 = 0;

    switch(EXPR_STRUCT(expr)) {
    case STRUCT_CExprOfUnaryNode: {
            CExpr *node = EXPR_U(expr)->e_node;

            if(EXPR_CODE(expr) == EC_SIZE_OF || 
	       EXPR_CODE(expr) == EC_GCC_ALIGN_OF) {
                CExprOfTypeDesc *td = resolveType(node);

                if(td == NULL)
                    return 0;

                result->nvt_isConstButMutable = 1;
                result->nvt_basicType = BT_INT;
                result->nvt_numKind = getNumValueKind(result->nvt_basicType);
                if(EXPR_CODE(expr) == EC_SIZE_OF)
                    result->nvt_numValue.ll = getTypeSize(td);
                else {
                    assertExpr((CExpr*)td, getTypeAlign(td));
                    result->nvt_numValue.ll = getTypeAlign(td);
                }
                return 1;
            }

            if(getConstNumValue(node, &n1) == 0) {
                mergeConstFlag(result, &n1);
                return 0;
            }
        }
        break;

    case STRUCT_CExprOfBinaryNode: {
            if(isUnreducableConst(expr, 1)) {
                result->nvt_isConstButUnreducable = 1;
                return 0;
            }

            CExpr *node1 = EXPR_B(expr)->e_nodes[0];
            CExpr *node2 = EXPR_B(expr)->e_nodes[1];

            if(EXPR_CODE(node1) == EC_TYPE_DESC) {
                if(getConstNumValue(node2, &n2) == 0)
                    return 0;
                else
                    n1 = n2;
            } else {
                if(getConstNumValue(node1, &n1) == 0) {
                    mergeConstFlag(result, &n1);
                    return 0;
                }

                if(getConstNumValue(node2, &n2) == 0) {
                    mergeConstFlag(result, &n1);
                    mergeConstFlag(result, &n2);
                    return 0;
                }
                use2 = 1;
            }
        }
        break;

    case STRUCT_CExprOfList:
        if(EXPR_CODE(expr) == EC_CONDEXPR) {
            if(getConstNumValue(exprListNextNData(expr, 0), &n1) == 0) {
                mergeConstFlag(result, &n1);
                return 0;
            }
            isConst2 = getConstNumValue(exprListNextNData(expr, 1), &n2);
            isConst3 = getConstNumValue(exprListNextNData(expr, 2), &n3);
            use2 = use3 = 1;
        } else {
            //maybe comma expr
            if(getConstNumValue(exprListTailData(expr), &n1) == 0) {
                mergeConstFlag(result, &n1);
                return 0;
            }
        }
        break;

    case STRUCT_CExprOfCharConst:
        //wide char is not supported
        result->nvt_numValue.ll = EXPR_CHARCONST(expr)->e_token[0];
        result->nvt_basicType = BT_CHAR;
        result->nvt_numKind = getNumValueKind(result->nvt_basicType);
        return 1;

    case STRUCT_CExprOfNumberConst:
        constToNumValueWithType(EXPR_NUMBERCONST(expr), result);
        return 1;

    case STRUCT_CExprOfSymbol: {
            CExprOfSymbol *tsym = findSymbolByGroup(EXPR_SYMBOL(expr)->e_symName, STB_IDENT);
            if(tsym == NULL || (tsym->e_symType != ST_ENUM) ||
                tsym->e_isConstButUnreducable ||
                (tsym && getConstNumValue(tsym->e_valueExpr, &n1) == 0)) {
                if(tsym && tsym->e_isConstButUnreducable)
                    result->nvt_isConstButUnreducable = 1;
                mergeConstFlag(result, &n1);
                return 0;
            }
        }
        break;

    case STRUCT_CExprOfArrayDecl:
    case STRUCT_CExprOfTypeDesc:
    case STRUCT_CExprOfErrorNode:
    case STRUCT_CExprOfGeneralCode:
    case STRUCT_CExprOfNull:
        return 0;

    default:
        assertExpr(expr, 0);
        ABORT();
    }

    int r = 1;
    int isCondExpr = (EXPR_CODE(expr) == EC_CONDEXPR);
    //for lshift/rshift
    int ni2 = 0;
    mergeConstFlag(result, &n1);
    
    if(use2) {
        ni2 = (int)getCastedLongValue(&n2);
        if(fixNumValueType(&n1, &n2) == 0 && isCondExpr == 0)
            return 0;
        mergeConstFlag(result, &n2);
    }

    if(use3) {
        if(fixNumValueType(&n1, &n3) == 0 && isCondExpr == 0)
            return 0;
        mergeConstFlag(result, &n3);
    }

    //now n1/n2/n3 have same basicType and numKind
    CNumValueKind nk = n1.nvt_numKind;
    CNumValue *nvr = &result->nvt_numValue;
    CNumValue *nv1 = &n1.nvt_numValue;
    CNumValue *nv2 = &n2.nvt_numValue;
    CNumValue *nv3 = &n3.nvt_numValue;

    switch(EXPR_CODE(expr)) {
    case EC_EXPRS:
        //last expression
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll; break;
        case NK_ULL: nvr->ull = nv1->ull; break;
        case NK_LD:  nvr->ld  = nv1->ld; break;
        }
        break;
    case EC_BRACED_EXPR:
    case EC_IDENT: // enumerator
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll; break;
        case NK_ULL: nvr->ull = nv1->ull; break;
        case NK_LD:  nvr->ld  = nv1->ld; break;
        }
        break;
    case EC_UNARY_MINUS:
        switch(nk) {
        case NK_LL:  nvr->ll  = -nv1->ll; break;
        case NK_ULL: nvr->ull = -nv1->ull; break;
        case NK_LD:  nvr->ld  = -nv1->ld; break;
        }
        break;
    case EC_BIT_NOT:
        switch(nk) {
        case NK_LL:  nvr->ll  = ~nv1->ll; break;
        case NK_ULL: nvr->ull = ~nv1->ull; break;
        case NK_LD:  return 0;
        }
        break;
    case EC_LOG_NOT:
        switch(nk) {
        case NK_LL:  nvr->ll  = !nv1->ll; break;
        case NK_ULL: nvr->ull = !nv1->ull; break;
        case NK_LD:  nvr->ld  = !nv1->ld; break;
        }
        break;
    case EC_CAST: {
            CExprOfTypeDesc *td = resolveType(EXPR_B(expr)->e_nodes[0]);
            if(td == NULL)
                return 0;
            CExprOfTypeDesc *tdo = getRefType(td);
            if(castNumValue(&n1, tdo->e_basicType) == 0) {
                addError(expr, CERR_016);
                EXPR_ISERROR(expr) = 1;
                return 0;
            }
            switch(n1.nvt_numKind) {
            case NK_LL:  nvr->ll  = nv1->ll;  break;
            case NK_ULL: nvr->ull = nv1->ull; break;
            case NK_LD:  nvr->ld  = nv1->ld;  break;
            }
        }
        break;
    case EC_LSHIFT:
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  << ni2; break;
        case NK_ULL: nvr->ull = nv1->ull << ni2; break;
        case NK_LD:  return 0;
        }
        break;
    case EC_RSHIFT:
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  >> ni2; break;
        case NK_ULL: nvr->ull = nv1->ull >> ni2; break;
        case NK_LD:  return 0;
        }
        break;
    case EC_PLUS:
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  + nv2->ll; break;
        case NK_ULL: nvr->ull = nv1->ull + nv2->ull; break;
        case NK_LD:  nvr->ld  = nv1->ld  + nv2->ld; break;
        }
        break;
    case EC_MINUS:
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  - nv2->ll; break;
        case NK_ULL: nvr->ull = nv1->ull - nv2->ull; break;
        case NK_LD:  nvr->ld  = nv1->ld  - nv2->ld; break;
        }
        break;
    case EC_MUL:
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  * nv2->ll; break;
        case NK_ULL: nvr->ull = nv1->ull * nv2->ull; break;
        case NK_LD:  nvr->ld  = nv1->ld  * nv2->ld; break;
        }
        break;
    case EC_DIV:
        if(checkDivisionByZero(expr, nk, nv2))
            return 0;
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  / nv2->ll; break;
        case NK_ULL: nvr->ull = nv1->ull / nv2->ull; break;
        case NK_LD:  nvr->ld  = nv1->ld  / nv2->ld; break;
        }
        break;
    case EC_MOD:
        if(checkDivisionByZero(expr, nk, nv2))
            return 0;
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  % nv2->ll; break;
        case NK_ULL: nvr->ull = nv1->ull % nv2->ull; break;
        case NK_LD:  return 0;
        }
        break;
    case EC_ARITH_EQ:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  == nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull == nv2->ull); break;
        case NK_LD:  nvr->ld  = (nv1->ld  == nv2->ld); break;
        }
        break;
    case EC_ARITH_NE:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  != nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull != nv2->ull); break;
        case NK_LD:  nvr->ld  = (nv1->ld  != nv2->ld); break;
        }
        break;
    case EC_ARITH_GE:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  >= nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull >= nv2->ull); break;
        case NK_LD:  nvr->ld  = (nv1->ld  >= nv2->ld); break;
        }
        break;
    case EC_ARITH_GT:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  > nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull > nv2->ull); break;
        case NK_LD:  nvr->ld  = (nv1->ld  > nv2->ld); break;
        }
        break;
    case EC_ARITH_LE:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  <= nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull <= nv2->ull); break;
        case NK_LD:  nvr->ld  = (nv1->ld  <= nv2->ld); break;
        }
        break;
    case EC_ARITH_LT:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  < nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull < nv2->ull); break;
        case NK_LD:  nvr->ld  = (nv1->ld  < nv2->ld); break;
        }
        break;
    case EC_LOG_AND:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  && nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull && nv2->ull); break;
        case NK_LD:  return 0;
        }
        break;
    case EC_LOG_OR:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  || nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull || nv2->ull); break;
        case NK_LD:  return 0;
        }
        break;
    case EC_BIT_AND:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  & nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull & nv2->ull); break;
        case NK_LD:  return 0;
        }
        break;
    case EC_BIT_OR:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  | nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull | nv2->ull); break;
        case NK_LD:  return 0;
        }
        break;
    case EC_BIT_XOR:
        switch(nk) {
        case NK_LL:  nvr->ll  = (nv1->ll  ^ nv2->ll); break;
        case NK_ULL: nvr->ull = (nv1->ull ^ nv2->ull); break;
        case NK_LD:  return 0;
        }
        break;
    case EC_CONDEXPR:
        switch(nk) {
        case NK_LL:  nvr->ll  = nv1->ll  ? nv2->ll  : nv3->ll;
            r = (nv1->ll) ? isConst2 : isConst3; break;
        case NK_ULL: nvr->ull = nv1->ull ? nv2->ull : nv3->ull;
            r = (nv1->ull) ? isConst2 : isConst3; break;
        case NK_LD:  nvr->ld  = nv1->ld  ? nv2->ld  : nv3->ld;
            r = (nv1->ld) ? isConst2 : isConst3; break;
        }
        break;
    default:
        return 0;
    }

    result->nvt_basicType = n1.nvt_basicType;
    result->nvt_numKind = n1.nvt_numKind;

    return r;
}
Пример #18
0
/*---------------------------------------------------------------------*/
int getNXDatasetByteLength(pNXDS dataset){
  return getNXDatasetLength(dataset)*getTypeSize(dataset->type);
}
Пример #19
0
CFunction::CFunction(const char* description)
{
	char desc[512];
	char* c;

	memset(&m_args, 0, sizeof m_args);
	m_valid = false;
	m_thiscall = strstr(description, "__thiscall") != NULL;

	strncpy(desc, description, sizeof desc - 1);
	desc[sizeof desc - 1] = '\0';

	for (size_t i = 0; i < ARRAYSIZE(g_callingConventions); i++)
	{
		c = desc;
		while ((c = strstr(c, g_callingConventions[i])) != NULL)
		{
			char* from = c + strlen(g_callingConventions[i]);
			memmove(c, from, strlen(from) + 1);
		}
	}

	char* args_start = strchr(desc, '(');
	if (!args_start)
	{
		setError("Function description must contain arguments in ()");
		return;
	}
	*args_start++ = '\0';

	c = strchr(args_start, ')');
	if (!c)
	{
		setError("Function description must contain arguments in ()");
		return;
	}
	*c = '\0';

	char* name = strrchr(desc, ' ');

	if (!name)
	{
		setError("Function without name");
		return;
	}

	do name++;
	while (*name && !isalpha(*name));
	*name = '\0';

	m_rettype = getBaseForType(desc, &m_retptr);

	switch (m_rettype)
	{
	case bt_float:
	case bt_double:
		m_retreg = r_st0;
		break;

	case bt_int:
	case bt_short:
	case bt_word:
	case bt_char:
	case bt_byte:
	case bt_cbase:
	case bt_entvars:
	case bt_edict:
	case bt_client:
	case bt_string:
		m_retreg = r_eax;
		break;

	case bt_void:
		m_retreg = r_unknown;
		m_rettype = bt_void;
		break;

	default:
		Log_Error(NULL, "Invalid function return type '%s', assumed void", desc);
		m_retreg = r_unknown;
		m_rettype = bt_void;
	}

	/*char* retreg = NULL;
	if ((retreg = strchr(name, '@')) != NULL)
		*retreg++ = NULL;*/

	char* args[16];
	m_argscount = parse(args_start, args, sizeof args - 1, ',');
	m_cdecl = true;

	for (int i = 0; i < m_argscount; i++)
	{
		auto arg = &m_args[i];

		trim(args[i]);

		char* reg;
		if ((reg = strchr(args[i], '@')) != NULL)
		{
			*reg++ = '\0';
			arg->reg = getRegByName(reg);
		}
		else
			arg->reg = r_unknown;

		if (arg->reg != r_unknown)
			m_cdecl = false;

		c = strchr(args[i], '[');

		if (c)
		{
			*c++ = '\0';
			char* e = strchr(c, ']');
			if (!e)
			{
				setError("Unclosed array bracket [");
				return;
			}
			*e = '\0';
			arg->count = atoi(c);
		}
		else
			arg->count = 1;

		char* arg_name = strrchr(args[i], ' ');

		if (!arg_name)
		{
			setError("Argument %i name missed.", i + 1);
			return;
		}

		do arg_name++;
		while (*arg_name && !isalpha(*arg_name));
		*arg_name = '\0';

		arg->type = getBaseForType(args[i], &arg->ptr);

		if (arg->type == bt_unknown && !arg->ptr)
		{
			setError("Unsupportable argument %i type name %s.", i + 1, args[i]);
			return;
		}

		if (arg->count > 1)
		{
			size_t arg_size = getTypeSize(arg->type);

			if (arg_size == sizeof(double) && arg->type != bt_double)
			{
				setError("Only double allowed as 64 bit array element.");
				return;
			}

			// simplify type
			switch (arg_size)
			{
			case sizeof(char) :
				arg->type = bt_char; break;
			case sizeof(short) :
				arg->type = bt_short; break;
			case sizeof(int) :
				arg->type = bt_int; break;
			case sizeof(double) :
				arg->type = bt_double; break;
			}
		}

		switch (arg->reg)
		{
		case r_eax:
		case r_ebx:
		case r_ecx:
		case r_edx:
		case r_esi:
		case r_edi:
		case r_ebp:
		case r_esp:
			if (arg->type == bt_double)
			{
				setError("Argument %i type 'double' can't be passed to function via 32-bit register.", i);
				return;
			}
			break;

		case r_st0:
			if (arg->type != bt_float && arg->type != bt_double)
			{
				setError("Only 'float' and 'double' types can be passed to function via st0 register (arg %i).", i);
				return;
			}
			break;

		case r_st1:
		case r_st2:
		case r_st3:
		case r_st4:
		case r_st5:
		case r_st6:
		case r_st7:
			setError("Only st0 fpu register can be used in fastcall (arg %i).", i);
			return;

		case r_xmm0:
		case r_xmm1:
		case r_xmm2:
		case r_xmm3:
		case r_xmm4:
		case r_xmm5:
		case r_xmm6:
		case r_xmm7:
			if (arg->type != bt_int && arg->type != bt_float)
			{
				setError("Only 'int' and 'float' types can be passed to function via xmm register (arg %i).", i);
				return;
			}
			break;

		case r_ax:
		case r_bx:
		case r_cx:
		case r_dx:
			if (getTypeSize(arg->type) != sizeof(short))
			{
				setError("Incompatible type and register size %i/%i (arg %i).", getTypeSize(arg->type), sizeof(short));
				return;
			}
			break;

		case r_al:
		case r_ah:
		case r_bl:
		case r_bh:
		case r_cl:
		case r_ch:
		case r_dl:
		case r_dh:
			if (getTypeSize(arg->type) != sizeof(char))
			{
				setError("Incompatible type and register size %i/%i (arg %i).", getTypeSize(arg->type), sizeof(char));
				return;
			}
			break;
		}
	}

	if (m_thiscall)
	{
		if (!m_argscount)
		{
			setError("__thiscall function without arguments.");
			return;
		}

		m_args[0].reg = r_ecx;
	}

	m_valid = true;
}
Пример #20
0
int ConfigFile::parseOptions(char * filename)
{
  FILE * fin = fopen(filename,"r");
  if (!fin)
  {
    printf("Error: could not open option file %s\n",filename);
    return 1;
  }

  int count = 0;
  char line[4096];
  while (fgets(line,4096,fin) != NULL)
  {
    count++;

    removeTrailingCharacters(line,'\n');
    removeTrailingCharacters(line,' ');

    // ignore blank lines and comments
    if ((line[0] == '#') || (line[0] == '\0'))
      continue;

    if (line[0] != '*')
    {
      printf("Error: invalid line %d: %s\n",count,line);
      fclose(fin);
      return 1; 
    }

    int index = seekOption(&line[1]);
    //printf("Read entry: %s . Option index: %d .\n", &line[1], index);
    if (index == -1)
    {
      if (!suppressWarnings_)
        printf("Warning: unknown option on line %d: %s\n",count,&line[1]);

      // eat next line
      do
      {
        if (fgets(line,4096,fin) == NULL)
        {
          printf("Error: EOF reached without specifying option value.\n");
          fclose(fin);
          return 1;
        }
        count++;
      }
      while (line[0] == '#'); // ignore comments

      continue;
    }

    // parse next line to get the data
    char dataEntry[4096];
    do
    {
      if (fgets(dataEntry,4096,fin) == NULL)
      {
        printf("Error: EOF reached without specifying option value.\n");
        fclose(fin);
        return 1;
      }
      count++;
    }
    while (dataEntry[0] == '#'); // ignore comments

    char typeFormatSpecifier[4];
    getTypeFormatSpecifier(optionTypes[index],typeFormatSpecifier);

    // remove any trailing line feed and carriage return
    if (dataEntry[strlen(dataEntry)-1] == 10)
      dataEntry[strlen(dataEntry)-1] = 0;
    if (dataEntry[strlen(dataEntry)-1] == 13)
      dataEntry[strlen(dataEntry)-1] = 0;

    if (optionTypes[index] != OPT_STR)
    {
      char buffer[4096];
      if (sscanf(dataEntry,typeFormatSpecifier,buffer) == 0)
      {
        printf("Error: invalid dataline for option %s: %s\n", optionNames[index].c_str(), dataEntry);
        fclose(fin);
        return 1;
      }

      // convert from string to true/false
      if (optionTypes[index] == OPT_BOOL)
      {
        //printf("Option type: boolean.\n");
        if (strncmp(buffer,"true",4) == 0)
        {
          bool * target = (bool*) buffer;
          *target = true;
        }
        else
          if (strncmp(buffer,"false",5) == 0)
          {
            bool * target = (bool*) buffer;
            *target = false;
          }
          else
          {
            bool * target = (bool*) buffer;
            *target = true;
            printf("Error: invalid boolean specification: line %d: %s\n",count,dataEntry);
            fclose(fin);
            return 1;
          }
      }
      memcpy(destLocations[index], buffer, getTypeSize(optionTypes[index]));
    }
    else
    {
      // this is a string option
      strcpy((char*)destLocations[index], dataEntry);
    }

    optionSet[index] = true;
  }

  fclose(fin);

  for(unsigned int i=0; i<optionNames.size(); i++)
  {
    if(!optionSet[i])
    {
      printf("Error: option %s didn't have an entry in the config file.\n",optionNames[i].c_str());
      return 1;
    }
  }

  return 0;
}
Пример #21
0
void OpenFiles(void)
{
	int32_t iii=0;
	for (iii=0; iii<2; iii++) {
		if (true == fileProp[iii].availlable) {
			// Open file 1
			fileProp[iii].pointer = fopen(fileProp[iii].name, "rb");
			if ( NULL == fileProp[iii].pointer) {
				//printf("Can not Open [File_1] = %s\n", fileName[0]);
			}
		}
		if (fileProp[iii].pointer==NULL) {
			continue;
		}
		// check if file has specifi header : 
		char dataheader[128];
		if(16 == fread(&dataheader, sizeof(uint8_t), 16, fileProp[iii].pointer)) {
			// parse header
			if(    dataheader[0]=='#'
			    && dataheader[1]=='M'
			    && dataheader[2]=='E'
			    && dataheader[3]=='T') {
				
				//    ==> "#MET %c %s %04d "
				// type unused ...
				if(    dataheader[5] == 'I'
				    || dataheader[5] == 'F'
				    || dataheader[5] == 'D') {
					fileProp[iii].type = SHOW_TYPE_DECIMAL_SIGNED;
				} else if (dataheader[5] == 'U') {
					fileProp[iii].type = SHOW_TYPE_DECIMAL_UNSIGNED;
				} else if (dataheader[5] == 'U') {
					fileProp[iii].type = SHOW_TYPE_HEX;
				} else {
					printf("Error while parsing the header ... \n");
					fileProp[iii].type = SHOW_TYPE_UNKNOW;
				}
				if (strncmp(&dataheader[6], "08", 2)==0) {
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_8;
				} else if (strncmp(&dataheader[6], "16", 2)==0) {
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_16;
				} else if (strncmp(&dataheader[6], "32", 2)==0) {
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_32;
				} else if (strncmp(&dataheader[6], "64", 2)==0) {
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_64;
				} else if (strncmp(&dataheader[6], "28", 2)==0) {
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_128;
				} else if (strncmp(&dataheader[6], "LO", 2)==0) {
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_FLOAT;
				} else if (strncmp(&dataheader[6], "OU", 2)==0) {
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_DOUBLE;
				} else {
					printf("Error while parsing the header ... \n");
					fileProp[iii].typeSize = SHOW_TYPE_SIZE_UNKNOW;
				}
				char tmpVal[5];
				tmpVal[0] = dataheader[8];
				tmpVal[1] = dataheader[9];
				tmpVal[2] = dataheader[10];
				tmpVal[3] = dataheader[11];
				tmpVal[4] = '\0';
				sscanf(tmpVal, "%04d", &fileProp[iii].slotSize);
				
				sscanf(&dataheader[12], "%04d", &fileProp[iii].delta);
				//printf("slot size [%d]=%d\n", iii, fileProp[iii].slotSize);
				// ofset of the header : 
				fileProp[iii].fileBasicOffset = 16;
			}
		} // else : no header present ==> raw file
		fseek ( fileProp[iii].pointer , fileProp[iii].fileBasicOffset , SEEK_SET );
	}
	// check internal properties : 
	if (fileProp[0].fileBasicOffset!=0 && fileProp[1].fileBasicOffset!=0) {
		if (fileProp[0].typeSize == fileProp[1].typeSize) {
			setTypeSize(fileProp[0].typeSize);
		} else {
			printf("Error The 2 files has not the same header typeSize properties header ... \n");
		}
		if (fileProp[0].type == fileProp[1].type) {
			setType(fileProp[0].type);
		} else {
			printf("Error The 2 files has not the same header type properties header ... \n");
		}
		if (fileProp[0].slotSize == fileProp[1].slotSize) {
			setSlotSize(fileProp[0].slotSize);
			if (fileProp[0].slotSize>0) {
				setSlotDisplayMode(true);
			}
		} else {
			printf("Error The 2 files has not the same header slotSize properties header ... \n");
		}
	} else if (fileProp[0].fileBasicOffset!=0) {
		setTypeSize(fileProp[0].typeSize);
		setType(fileProp[0].type);
		setSlotSize(fileProp[0].slotSize);
		if (fileProp[0].slotSize>0) {
			setSlotDisplayMode(true);
		}
	} else if (fileProp[1].fileBasicOffset!=0) {
		setTypeSize(fileProp[1].typeSize);
		setType(fileProp[1].type);
		setSlotSize(fileProp[1].slotSize);
		if (fileProp[1].slotSize>0) {
			setSlotDisplayMode(true);
		}
	}
	int32_t sizeElement=1;
	showTypeSize_te tmpType = getTypeSize();
	switch(tmpType)
	{
		default:
		case SHOW_TYPE_SIZE_8:
			sizeElement = 1;
			break;
		case SHOW_TYPE_SIZE_16:
			sizeElement = 2;
			break;
		case SHOW_TYPE_SIZE_FLOAT:
		case SHOW_TYPE_SIZE_32:
			sizeElement = 4;
			break;
		case SHOW_TYPE_SIZE_DOUBLE:
		case SHOW_TYPE_SIZE_64:
			sizeElement = 8;
			break;
	}
	int32_t tmpDela = (fileProp[1].delta - fileProp[0].delta) * sizeElement;
	displayPaddingOffset(tmpDela);
	
	
	UpdateFilesSize();
}
Пример #22
0
static void r300AllocDmaRegions(GLcontext *ctx, const struct gl_client_array *input[], int count)
{
	r300ContextPtr r300 = R300_CONTEXT(ctx);
	struct r300_vertex_buffer *vbuf = &r300->vbuf;
	GLuint stride;
	int ret;
	int i, index;
	radeon_print(RADEON_RENDER, RADEON_VERBOSE,
			"%s: count %d num_attribs %d\n",
			__func__, count, vbuf->num_attribs);

	for (index = 0; index < vbuf->num_attribs; index++) {
		struct radeon_aos *aos = &r300->radeon.tcl.aos[index];
		i = vbuf->attribs[index].element;

		stride = (input[i]->StrideB == 0) ? getTypeSize(input[i]->Type) * input[i]->Size : input[i]->StrideB;

		if (input[i]->Type == GL_DOUBLE || input[i]->Type == GL_UNSIGNED_INT || input[i]->Type == GL_INT ||
#if MESA_BIG_ENDIAN
				getTypeSize(input[i]->Type) != 4 ||
#endif
				stride < 4) {

			r300ConvertAttrib(ctx, count, input[i], &vbuf->attribs[index]);
		} else {
			if (input[i]->BufferObj->Name) {
				if (stride % 4 != 0 || (intptr_t)input[i]->Ptr % 4 != 0) {
					r300AlignDataToDword(ctx, input[i], count, &vbuf->attribs[index]);
					vbuf->attribs[index].is_named_bo = GL_FALSE;
				} else {
					vbuf->attribs[index].stride = input[i]->StrideB;
					vbuf->attribs[index].bo_offset = (intptr_t) input[i]->Ptr;
					vbuf->attribs[index].bo = get_radeon_buffer_object(input[i]->BufferObj)->bo;
					vbuf->attribs[index].is_named_bo = GL_TRUE;
				}
			} else {

				int size;
				int local_count = count;
				uint32_t *dst;

				if (input[i]->StrideB == 0) {
					size = getTypeSize(input[i]->Type) * input[i]->Size;
					local_count = 1;
				} else {
					size = getTypeSize(input[i]->Type) * input[i]->Size * local_count;
				}

				radeonAllocDmaRegion(&r300->radeon, &vbuf->attribs[index].bo, &vbuf->attribs[index].bo_offset, size, 32);
				radeon_bo_map(vbuf->attribs[index].bo, 1);
				assert(vbuf->attribs[index].bo->ptr != NULL);
				dst = (uint32_t *)ADD_POINTERS(vbuf->attribs[index].bo->ptr, vbuf->attribs[index].bo_offset);
				switch (vbuf->attribs[index].dwords) {
					case 1: radeonEmitVec4(dst, input[i]->Ptr, input[i]->StrideB, local_count); break;
					case 2: radeonEmitVec8(dst, input[i]->Ptr, input[i]->StrideB, local_count); break;
					case 3: radeonEmitVec12(dst, input[i]->Ptr, input[i]->StrideB, local_count); break;
					case 4: radeonEmitVec16(dst, input[i]->Ptr, input[i]->StrideB, local_count); break;
					default: assert(0); break;
				}
				radeon_bo_unmap(vbuf->attribs[index].bo);

			}
		}

		aos->count = vbuf->attribs[index].stride == 0 ? 1 : count;
		aos->stride = vbuf->attribs[index].stride / sizeof(float);
		aos->components = vbuf->attribs[index].dwords;
		aos->bo = vbuf->attribs[index].bo;
		aos->offset = vbuf->attribs[index].bo_offset;

		if (vbuf->attribs[index].is_named_bo) {
			radeon_cs_space_add_persistent_bo(r300->radeon.cmdbuf.cs, r300->vbuf.attribs[index].bo, RADEON_GEM_DOMAIN_GTT, 0);
		}
	}

	r300->radeon.tcl.aos_count = vbuf->num_attribs;
	ret = radeon_cs_space_check_with_bo(r300->radeon.cmdbuf.cs, first_elem(&r300->radeon.dma.reserved)->bo, RADEON_GEM_DOMAIN_GTT, 0);
	r300SwitchFallback(ctx, R300_FALLBACK_INVALID_BUFFERS, ret);

}
Пример #23
0
static void r300TranslateAttrib(GLcontext *ctx, GLuint attr, int count, const struct gl_client_array *input)
{
	r300ContextPtr r300 = R300_CONTEXT(ctx);
	struct r300_vertex_buffer *vbuf = &r300->vbuf;
	struct vertex_attribute r300_attr = { 0 };
	GLenum type;
	GLuint stride;

	radeon_print(RADEON_RENDER, RADEON_TRACE, "%s\n", __func__);
	stride = (input->StrideB == 0) ? getTypeSize(input->Type) * input->Size : input->StrideB;

	if (input->Type == GL_DOUBLE || input->Type == GL_UNSIGNED_INT || input->Type == GL_INT ||
#if MESA_BIG_ENDIAN
	    getTypeSize(input->Type) != 4 ||
#endif
	    stride < 4) {

		type = GL_FLOAT;

		if (input->StrideB == 0) {
			r300_attr.stride = 0;
		} else {
			r300_attr.stride = sizeof(GLfloat) * input->Size;
		}
		r300_attr.dwords = input->Size;
		r300_attr.is_named_bo = GL_FALSE;
	} else {
		type = input->Type;
		r300_attr.dwords = (getTypeSize(type) * input->Size + 3)/ 4;
		if (!input->BufferObj->Name) {

			if (input->StrideB == 0) {
				r300_attr.stride = 0;
			} else {
				r300_attr.stride = (getTypeSize(type) * input->Size + 3) & ~3;
			}

			r300_attr.is_named_bo = GL_FALSE;
		}
	}

	r300_attr.size = input->Size;
	r300_attr.element = attr;
	r300_attr.dst_loc = vbuf->num_attribs;

	switch (type) {
		case GL_FLOAT:
			switch (input->Size) {
				case 1: r300_attr.data_type = R300_DATA_TYPE_FLOAT_1; break;
				case 2: r300_attr.data_type = R300_DATA_TYPE_FLOAT_2; break;
				case 3: r300_attr.data_type = R300_DATA_TYPE_FLOAT_3; break;
				case 4: r300_attr.data_type = R300_DATA_TYPE_FLOAT_4; break;
			}
			r300_attr._signed = 0;
			r300_attr.normalize = 0;
			break;
		case GL_HALF_FLOAT:
			switch (input->Size) {
				case 1:
				case 2:
					r300_attr.data_type = R300_DATA_TYPE_FLT16_2;
					break;
				case 3:
				case 4:
					r300_attr.data_type = R300_DATA_TYPE_FLT16_4;
					break;
			}
			break;
		case GL_SHORT:
			r300_attr._signed = 1;
			r300_attr.normalize = input->Normalized;
			switch (input->Size) {
				case 1:
				case 2:
					r300_attr.data_type = R300_DATA_TYPE_SHORT_2;
					break;
				case 3:
				case 4:
					r300_attr.data_type = R300_DATA_TYPE_SHORT_4;
					break;
			}
			break;
		case GL_BYTE:
			r300_attr._signed = 1;
			r300_attr.normalize = input->Normalized;
			r300_attr.data_type = R300_DATA_TYPE_BYTE;
			break;
		case GL_UNSIGNED_SHORT:
			r300_attr._signed = 0;
			r300_attr.normalize = input->Normalized;
			switch (input->Size) {
				case 1:
				case 2:
					r300_attr.data_type = R300_DATA_TYPE_SHORT_2;
					break;
				case 3:
				case 4:
					r300_attr.data_type = R300_DATA_TYPE_SHORT_4;
					break;
			}
			break;
		case GL_UNSIGNED_BYTE:
			r300_attr._signed = 0;
			r300_attr.normalize = input->Normalized;
			if (input->Format == GL_BGRA)
				r300_attr.data_type = R300_DATA_TYPE_D3DCOLOR;
			else
				r300_attr.data_type = R300_DATA_TYPE_BYTE;
			break;

		default:
		case GL_DOUBLE:
		case GL_INT:
		case GL_UNSIGNED_INT:
			assert(0);
			break;
	}

	switch (input->Size) {
		case 4:
			r300_attr.swizzle = SWIZZLE_XYZW;
			break;
		case 3:
			r300_attr.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_Z, SWIZZLE_ONE);
			break;
		case 2:
			r300_attr.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_Y, SWIZZLE_ZERO, SWIZZLE_ONE);
			break;
		case 1:
			r300_attr.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_ZERO, SWIZZLE_ZERO, SWIZZLE_ONE);
			break;
	}

	r300_attr.write_mask = MASK_XYZW;

	vbuf->attribs[vbuf->num_attribs] = r300_attr;
	++vbuf->num_attribs;
}