MCPcopy Create free account
hub / github.com/carbonengine/trinity / PatchShader

Function PatchShader

shadercompiler/EffectCompilerDX11.cpp:236–468  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

234}
235
236static 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 };

Callers 1

CompileEffectMethod · 0.70

Calls 14

FindOutputBySemanticsFunction · 0.85
IsUniformInputArgumentFunction · 0.85
FindParameterBySemanticsFunction · 0.85
PrintValuePathFunction · 0.85
GetSymbolMethod · 0.80
GetChildOrNullMethod · 0.80
GetChildrenCountMethod · 0.80
ShowMessageMethod · 0.80
GetTokenMethod · 0.80
emptyMethod · 0.80
AllocateNameMethod · 0.80
ToStringFunction · 0.70

Tested by

no test coverage detected