static void evergreenTranslateAttrib(struct gl_context *ctx, GLuint unLoc, int count, const struct gl_client_array *input) { context_t *context = EVERGREEN_CONTEXT(ctx); StreamDesc * pStreamDesc = &(context->stream_desc[context->nNumActiveAos]); GLuint stride; stride = (input->StrideB == 0) ? evergreen_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 || evergreen_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 = (evergreen_getTypeSize(input->Type) * input->Size + 3)/ 4; if (!input->BufferObj->Name) { if (input->StrideB == 0) { pStreamDesc->stride = 0; } else { pStreamDesc->stride = (evergreen_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++; }
/** * Convert attribute data type to float * If the attribute uses named buffer object replace the bo with newly allocated bo */ static void evergreenConvertAttrib(GLcontext *ctx, int count, const struct gl_client_array *input, struct StreamDesc *attr) { context_t *context = R700_CONTEXT(ctx); const GLvoid *src_ptr; GLboolean mapped_named_bo = GL_FALSE; GLfloat *dst_ptr; GLuint stride; stride = (input->StrideB == 0) ? evergreen_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(&context->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); 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); } }