| 170 | } |
| 171 | |
| 172 | static void PatchSemantics( InputStageType shaderStage, ASTNode* callNode ) |
| 173 | { |
| 174 | Symbol* entryPointSymbol = callNode->GetSymbol(); |
| 175 | if( !entryPointSymbol ) |
| 176 | { |
| 177 | return; |
| 178 | } |
| 179 | ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); |
| 180 | if( functionHeader == nullptr ) |
| 181 | { |
| 182 | return; |
| 183 | } |
| 184 | std::vector<Symbol*> targetPath; |
| 185 | switch( shaderStage ) |
| 186 | { |
| 187 | case VERTEX_STAGE: { |
| 188 | const char* semantics[] = { "position", nullptr }; |
| 189 | if( FindOutputBySemantics( functionHeader, semantics, &targetPath ) ) |
| 190 | { |
| 191 | if( targetPath.back() ) |
| 192 | { |
| 193 | targetPath.back()->semantic = MakeInlineString( "SV_Position" ); |
| 194 | } |
| 195 | else |
| 196 | { |
| 197 | entryPointSymbol->semantic = MakeInlineString( "SV_Position" ); |
| 198 | } |
| 199 | } |
| 200 | break; |
| 201 | } |
| 202 | case PIXEL_STAGE: { |
| 203 | { |
| 204 | const char* semantics[] = { "color", "color0", nullptr }; |
| 205 | if( FindOutputBySemantics( functionHeader, semantics, &targetPath ) ) |
| 206 | { |
| 207 | if( targetPath.back() ) |
| 208 | { |
| 209 | targetPath.back()->semantic = MakeInlineString( "SV_Target0" ); |
| 210 | } |
| 211 | else |
| 212 | { |
| 213 | entryPointSymbol->semantic = MakeInlineString( "SV_Target0" ); |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | { |
| 218 | const char* semantics[] = { "color1", nullptr }; |
| 219 | if( FindOutputBySemantics( functionHeader, semantics, &targetPath ) ) |
| 220 | { |
| 221 | if( targetPath.back() ) |
| 222 | { |
| 223 | targetPath.back()->semantic = MakeInlineString( "SV_Target1" ); |
| 224 | } |
| 225 | else |
| 226 | { |
| 227 | entryPointSymbol->semantic = MakeInlineString( "SV_Target1" ); |
| 228 | } |
| 229 | } |
no test coverage detected