15a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#include "rs_core.rsh" 25a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#include "rs_graphics.rsh" 35a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines#include "rs_structs.h" 45a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 55a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines/** 65a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines* Element 75a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines*/ 85a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) 95a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetSubElementCount(rs_element e) { 105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL) { 125a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0; 135a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 145a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.fieldsCount; 155a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 165a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 175a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern rs_element __attribute__((overloadable)) 185a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetSubElement(rs_element e, uint32_t index) { 195a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 205a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL || index >= element->mHal.state.fieldsCount) { 215a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rs_element nullElem = {0}; 225a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return nullElem; 235a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 245a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rs_element returnElem = {element->mHal.state.fields[index]}; 255a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return returnElem; 265a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 275a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 285a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) 295a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetSubElementNameLength(rs_element e, uint32_t index) { 305a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 315a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL || index >= element->mHal.state.fieldsCount) { 325a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0; 335a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 345a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.fieldNameLengths[index]; 355a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 365a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 375a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) 385a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetSubElementName(rs_element e, uint32_t index, char *name, uint32_t nameLength) { 395a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 405a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL || index >= element->mHal.state.fieldsCount || 415a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines nameLength == 0 || name == 0) { 425a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0; 435a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 445a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 455a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines uint32_t numToCopy = element->mHal.state.fieldNameLengths[index]; 465a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (nameLength < numToCopy) { 475a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines numToCopy = nameLength; 485a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 495a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines // Place the null terminator manually, in case of partial string 505a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines numToCopy --; 515a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines name[numToCopy] = '\0'; 525a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines const char *nameSource = element->mHal.state.fieldNames[index]; 535a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines for (uint32_t i = 0; i < numToCopy; i ++) { 545a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines name[i] = nameSource[i]; 555a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 565a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return numToCopy; 575a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 585a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 595a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) 605a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetSubElementArraySize(rs_element e, uint32_t index) { 615a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 625a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL || index >= element->mHal.state.fieldsCount) { 635a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0; 645a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 655a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.fieldArraySizes[index]; 665a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 675a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 685a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) 695a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetSubElementOffsetBytes(rs_element e, uint32_t index) { 705a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 715a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL || index >= element->mHal.state.fieldsCount) { 725a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0; 735a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 745a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.fieldOffsetBytes[index]; 755a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 765a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 775a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) 785a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetBytesSize(rs_element e) { 795a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 805a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL) { 815a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0; 825a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 835a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.elementSizeBytes; 845a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 855a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 865a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern rs_data_type __attribute__((overloadable)) 875a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetDataType(rs_element e) { 885a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 895a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL) { 905a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return RS_TYPE_INVALID; 915a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 925a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.dataType; 935a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 945a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 955a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern rs_data_kind __attribute__((overloadable)) 965a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetDataKind(rs_element e) { 975a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 985a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL) { 995a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return RS_KIND_INVALID; 1005a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 1015a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.dataKind; 1025a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 1035a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines 1045a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hinesextern uint32_t __attribute__((overloadable)) 1055a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines rsElementGetVectorSize(rs_element e) { 1065a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines Element_t *element = (Element_t *)e.p; 1075a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines if (element == NULL) { 1085a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return 0; 1095a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines } 1105a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines return element->mHal.state.vectorSize; 1115a47020542c52af3e879c1cd67674ca979ff0a18Stephen Hines} 112