| 3874 | } |
| 3875 | |
| 3876 | bool GetStageDataForNode( ParserState& state, StageData& stage, ASTNode* functionHeader, std::map<StringReference, ParameterAnnotation>& annotations ) |
| 3877 | { |
| 3878 | for( size_t i = 0, n = functionHeader->GetChildrenCount(); i < n; ++i ) |
| 3879 | { |
| 3880 | ASTNode* child = functionHeader->GetChild( i ); |
| 3881 | assert( child ); |
| 3882 | |
| 3883 | Symbol* symbol = child->GetSymbol(); |
| 3884 | assert( symbol ); |
| 3885 | |
| 3886 | const Type& type = child->GetType(); |
| 3887 | |
| 3888 | assert( !symbol->registerSpecifier.empty() ); |
| 3889 | const RegisterSpecifier& reg = symbol->registerSpecifier.cbegin()->second; |
| 3890 | |
| 3891 | switch( reg.registerType ) |
| 3892 | { |
| 3893 | case MetalRegister::CBuffer: { |
| 3894 | stage.registerInputs.push_back( { RT_CONSTANT_BUFFER, (uint32_t)reg.registerNumber, 1, 0 } ); |
| 3895 | } |
| 3896 | continue; |
| 3897 | default: |
| 3898 | break; |
| 3899 | } |
| 3900 | |
| 3901 | if( type.arrayDimensions > 0 ) |
| 3902 | { |
| 3903 | assert( reg.registerType == MetalRegister::SRV || reg.registerType == MetalRegister::UAV ); |
| 3904 | |
| 3905 | if( symbol->used ) |
| 3906 | { |
| 3907 | if( reg.registerType == MetalRegister::SRV ) |
| 3908 | { |
| 3909 | if( type.IsSampler() ) |
| 3910 | { |
| 3911 | stage.registerInputs.push_back( { RT_SAMPLER, (uint32_t)reg.registerNumber, (uint32_t)type.arraySizes[0], 0 } ); |
| 3912 | |
| 3913 | Sampler sampler = {}; |
| 3914 | |
| 3915 | auto globalSamplerSymbol = state.GetSymbolTable().LookupGlobal( ToString( symbol->name ).c_str() ); |
| 3916 | if( !GetSamplerState( state, globalSamplerSymbol->definition, sampler ) ) |
| 3917 | { |
| 3918 | return false; |
| 3919 | } |
| 3920 | |
| 3921 | if( sampler.addressU == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressV == D3D11_TEXTURE_ADDRESS_BORDER || sampler.addressW == D3D11_TEXTURE_ADDRESS_BORDER ) |
| 3922 | { |
| 3923 | auto& c = sampler.borderColor; |
| 3924 | if( ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 0 ) && |
| 3925 | ( c.x != 0 || c.y != 0 || c.z != 0 || c.w != 1 ) && |
| 3926 | ( c.x != 1 || c.y != 1 || c.z != 1 || c.w != 1 ) ) |
| 3927 | { |
| 3928 | state.ShowMessage( globalSamplerSymbol->definition->GetLocation(), EC_CUSTOM_ERROR, "sampler border color is not one of colors supported by Metal" ); |
| 3929 | return false; |
| 3930 | } |
| 3931 | } |
| 3932 | |
| 3933 | sampler.name = g_stringTable.AddString( symbol->name ); |
no test coverage detected