| 234 | } |
| 235 | |
| 236 | static PatchAction PatchShader( InputStageType shaderStage, ASTNode* callNode, ParserState& state, CodeStream& os, std::string& entryPointName ) |
| 237 | { |
| 238 | ZoneScoped; |
| 239 | |
| 240 | // 1. wrap uniforms |
| 241 | // 2. fix VPOS |
| 242 | |
| 243 | bool wrapUniforms = false; |
| 244 | bool fixVPOS = false; |
| 245 | bool fixVPOSType = false; |
| 246 | |
| 247 | Symbol* entryPointSymbol = callNode->GetSymbol(); |
| 248 | |
| 249 | if( entryPointSymbol == nullptr || entryPointSymbol->definition == nullptr ) |
| 250 | { |
| 251 | return PATCH_ERROR; |
| 252 | } |
| 253 | |
| 254 | ASTNode* functionHeader = entryPointSymbol->definition->GetChildOrNull( 0 ); |
| 255 | if( functionHeader == nullptr ) |
| 256 | { |
| 257 | return PATCH_ERROR; |
| 258 | } |
| 259 | |
| 260 | std::vector<Symbol*> targetPath; |
| 261 | std::vector<Symbol*> outPositionPath; |
| 262 | std::vector<Symbol*> vfacePath; |
| 263 | |
| 264 | if( shaderStage == VERTEX_STAGE ) |
| 265 | { |
| 266 | const char* position[] = { "position", "sv_position", nullptr }; |
| 267 | FindOutputBySemantics( functionHeader, position, &outPositionPath ); |
| 268 | } |
| 269 | |
| 270 | |
| 271 | // check for uniform parameters |
| 272 | if( callNode->GetChildrenCount() ) |
| 273 | { |
| 274 | unsigned count = 0; |
| 275 | for( unsigned i = 0; i < functionHeader->GetChildrenCount(); ++i ) |
| 276 | { |
| 277 | if( IsUniformInputArgument( functionHeader->GetChild( i ) ) ) |
| 278 | { |
| 279 | ++count; |
| 280 | } |
| 281 | } |
| 282 | if( count != callNode->GetChildrenCount() ) |
| 283 | { |
| 284 | state.ShowMessage( callNode->GetLocation(), EC_NO_OVERRIDE, ToString( functionHeader->GetToken()->stringValue ).c_str(), "" ); |
| 285 | return PATCH_ERROR; |
| 286 | } |
| 287 | wrapUniforms = true; |
| 288 | } |
| 289 | |
| 290 | // find VPOS+POSITION parameters |
| 291 | std::vector<Symbol*> positionPath; |
| 292 | std::vector<Symbol*> vposPath; |
| 293 | const char* vpos[] = { "vpos", nullptr }; |
no test coverage detected