| 1703 | } |
| 1704 | |
| 1705 | void GetThreadGroupSize( StageInput& stage, ParserState& state, ASTNode* callNode ) |
| 1706 | { |
| 1707 | stage.threadGroupSize[0] = 1; |
| 1708 | stage.threadGroupSize[1] = 1; |
| 1709 | stage.threadGroupSize[2] = 1; |
| 1710 | |
| 1711 | if( stage.type != COMPUTE_STAGE ) |
| 1712 | { |
| 1713 | return; |
| 1714 | } |
| 1715 | |
| 1716 | Symbol* entryPointSymbol = callNode->GetSymbol(); |
| 1717 | if( !entryPointSymbol || !entryPointSymbol->definition ) |
| 1718 | { |
| 1719 | return; |
| 1720 | } |
| 1721 | |
| 1722 | ASTNode* attribList = entryPointSymbol->definition->GetChildOrNull( 2 ); |
| 1723 | if( attribList && attribList->GetNodeType() == NT_FUNCTION_ATTRIBUTE_LIST ) |
| 1724 | { |
| 1725 | // Find [numthreads(X, Y, Z)] attribute. |
| 1726 | for( size_t i = 0, n = attribList->GetChildrenCount(); i < n; ++i ) |
| 1727 | { |
| 1728 | ASTNode* attribute = attribList->GetChild( i ); |
| 1729 | assert( attribute->GetNodeType() == NT_FUNCTION_ATTRIBUTE ); |
| 1730 | |
| 1731 | if( attribute->GetToken()->stringValue != "numthreads" ) |
| 1732 | { |
| 1733 | continue; |
| 1734 | } |
| 1735 | |
| 1736 | for( size_t j = 0; j < 3; ++j ) |
| 1737 | { |
| 1738 | ASTNode* child = attribute->GetChildOrNull( j ); |
| 1739 | |
| 1740 | InlineString valueString = ( child && child->GetToken() ) ? child->GetToken()->stringValue : InlineString{ nullptr, nullptr }; |
| 1741 | unsigned long value = valueString ? std::strtoul( valueString.start, nullptr, 10 ) : 1; |
| 1742 | |
| 1743 | stage.threadGroupSize[j] = (uint32_t)value; |
| 1744 | } |
| 1745 | |
| 1746 | if( stage.threadGroupSize[0] * stage.threadGroupSize[1] * stage.threadGroupSize[2] > 512 ) |
| 1747 | { |
| 1748 | state.ShowMessage( attribute->GetLocation(), EC_CUSTOM_WARNING, "number of threads per group exceeds Intel limit of 512; computer shader invoketion will fail on Intel macs" ); |
| 1749 | } |
| 1750 | } |
| 1751 | } |
| 1752 | } |
| 1753 | |
| 1754 | bool AutoAssignRegistersForNode( ParserState& state, ASTNode* functionHeader, const FileLocation& messageLocation ) |
| 1755 | { |
no test coverage detected