I am using the file InstancedModel.fx from the instancing sample and I am trying to use different variations for differnet objects, so I am trying to add the choice of a pixelshader in the techniques:
| int ShaderIndex = 0; |
| |
| PixelShader PSArray[2] = |
| { |
| compile ps_3_0 PSOne(), |
| compile ps_3_0 PSTwo(), |
| }; |
| |
| // Xbox instancing technique. |
| technique VFetchInstancing |
| { |
| pass Pass1 |
{
|
| VertexShader = compile vs_3_0 VFetchInstancingVertexShader(); |
| PixelShader = compile ps_3_0 PSOne();//(PSArray[ShaderIndex]); |
| } |
| } |
You are looking at the version that is working fine. But as soon as I delete "compile..." and use the
(PSArray[ShaderIndex]); which is now commented out, I get the following error:
Building content threw AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
at CompileEffectFromSourceForXBox(String effectSource, CompilerMacro[] preprocessorDefines, CompilerIncludeHandler includeHandler, CompilerOptions options)
at Microsoft.Xna.Framework.Graphics.Effect.CompileEffectFromSource(String effectFileSource, CompilerMacro[] preprocessorDefines, CompilerIncludeHandler includeHandler, CompilerOptions options, TargetPlatform platform)
at Microsoft.Xna.Framework.Content.Pipeline.Processors.EffectProcessor.Process(EffectContent input, ContentProcessorContext context)
at Microsoft.Xna.Framework.Content.Pipeline.ContentProcessor`2.Microsoft.Xna.Framework.Content.Pipeline.IContentProcessor.Process(Object input, ContentProcessorContext context)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAssetWorker(BuildItem item)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.BuildAsset(BuildItem item)
at Microsoft.Xna.Framework.Content.Pipeline.BuildCoordinator.RunTheBuild()
at Microsoft.Xna.Framework.Content.Pipeline.Tasks.BuildContent.RemoteProxy.RunTheBuild(BuildCoordinatorSettings settings, TimestampCache timestampCache, ITaskItem[] sourceAssets, String[]& outputContent, String[]& rebuiltContent, String[]& intermediates, Dictionary`2& dependencyTimestamps, KeyValuePair`2[]& warnings)
The code should just work because I simply copied it from BasicEffect-sample?! Any help greatly appreciated...
EDIT: Exception occurs only when building for Xbox. On Windows everything works just fine...