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

Function PatchSemantics

shadercompiler/EffectCompilerDX11.cpp:172–234  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

170}
171
172static 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 }

Callers 1

CompileEffectMethod · 0.85

Calls 4

FindOutputBySemanticsFunction · 0.85
MakeInlineStringFunction · 0.85
GetSymbolMethod · 0.80
GetChildOrNullMethod · 0.80

Tested by

no test coverage detected