Example #1
0
        private void HandleEffectCompilerRequestedPacket(RemoteEffectCompilerEffectRequested packet, PackageViewModel package)
        {
            // Received a shader requested notification, add it to list of "pending shaders", and update count in UI

            dispatcher.InvokeAsync(() =>
            {
                CheckEffectLogAsset(package);

                // Try to decode request
                try
                {
                    // Deserialize as an object
                    var binaryReader = new BinarySerializationReader(new MemoryStream(packet.Request));
                    EffectCompileRequest effectCompileRequest = null;
                    binaryReader.Context.SerializerSelector   = SerializerSelector.AssetWithReuse;
                    binaryReader.SerializeExtended(ref effectCompileRequest, ArchiveMode.Deserialize, null);

                    // Record in list of pending effects and check if it would result in a new shader
                    // (it is still recorded in list of pending effect, in case EffectLog asset is deleted in the meantime)
                    if (pendingEffects.Add(effectCompileRequest) && !effectLogStore.Contains(effectCompileRequest))
                    {
                        UpdateImportEffectLogPendingCount(session.ImportEffectLogPendingCount + 1);
                    }
                }
                catch
                {
                    // TODO Log error
                    //Log.Warning("Received an effect compilation request which could not be decoded. Make sure Windows project compiled successfully and is up to date.");
                }
            });
        }
 public void NotifyEffectUsed(EffectCompileRequest effectCompileRequest)
 {
     Task.Run(async () =>
     {
         // Send any effect request remotely (should fail if not connected)
         var socketMessageLayer = await GetOrCreateConnection();
         await socketMessageLayer.Send(new RemoteEffectCompilerEffectRequested { Request = effectCompileRequest });
     });
 }
        public void NotifyEffectUsed(EffectCompileRequest effectCompileRequest)
        {
            Task.Run(async () =>
            {
                // Silently fails if connection already failed previously
                var socketMessageLayerTask = GetOrCreateConnection();
                if (socketMessageLayerTask.IsFaulted)
                    return;

                // Send any effect request remotely (should fail if not connected)
                var socketMessageLayer = await socketMessageLayerTask;
                await socketMessageLayer.Send(new RemoteEffectCompilerEffectRequested { Request = effectCompileRequest });
            });
        }
        public void NotifyEffectUsed(EffectCompileRequest effectCompileRequest)
        {
            Task.Run(async () =>
            {
                // Silently fails if connection already failed previously
                var socketMessageLayerTask = GetOrCreateConnection();
                if (socketMessageLayerTask.IsFaulted)
                    return;

                // Send any effect request remotely (should fail if not connected)
                var socketMessageLayer = await socketMessageLayerTask;

                var memoryStream = new MemoryStream();
                var binaryWriter = new BinarySerializationWriter(memoryStream);
                binaryWriter.Context.SerializerSelector = SerializerSelector.AssetWithReuse;
                binaryWriter.SerializeExtended(effectCompileRequest, ArchiveMode.Serialize, null);

                await socketMessageLayer.Send(new RemoteEffectCompilerEffectRequested { Request = memoryStream.ToArray() });
            });
        }
Example #5
0
        public static BuildStep FromRequest(AssetCompilerContext context, Package package, UDirectory urlRoot, EffectCompileRequest effectCompileRequest)
        {
            var compilerParameters = new CompilerParameters(effectCompileRequest.UsedParameters);

            compilerParameters.EffectParameters.Platform = context.GetGraphicsPlatform(package);
            compilerParameters.EffectParameters.Profile  = context.GetGameSettingsAsset().GetOrCreate <RenderingSettings>(context.Platform).DefaultGraphicsProfile;
            compilerParameters.EffectParameters.ApplyCompilationMode(context.GetCompilationMode());

            return(new CommandBuildStep(new EffectCompileCommand(context, urlRoot, effectCompileRequest.EffectName, compilerParameters, package)));
        }
Example #6
0
        private CompilerResults GetCompilerResults(string effectName, CompilerParameters compilerParameters)
        {
            compilerParameters.Profile = GraphicsDevice.ShaderProfile.HasValue ? GraphicsDevice.ShaderProfile.Value : GraphicsDevice.Features.Profile;
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLCORE
            compilerParameters.Platform = GraphicsPlatform.OpenGL;
#endif
#if SILICONSTUDIO_PARADOX_GRAPHICS_API_OPENGLES
            compilerParameters.Platform = GraphicsPlatform.OpenGLES;
#endif

            // Compile shader
            var isPdxfx = ShaderMixinManager.Contains(effectName);

            // getting the effect from the used parameters only makes sense when the source files are the same
            // TODO: improve this by updating earlyCompilerCache - cache can still be relevant

            CompilerResults compilerResult = null;

            if (isPdxfx)
            {
                // perform an early test only based on the parameters
                compilerResult = GetShaderFromParameters(effectName, compilerParameters);
            }

            if (compilerResult == null)
            {
                var source = isPdxfx ? new ShaderMixinGeneratorSource(effectName) : (ShaderSource) new ShaderClassSource(effectName);
                compilerResult = compiler.Compile(source, compilerParameters);

#if SILICONSTUDIO_PLATFORM_WINDOWS_DESKTOP
                // If enabled, request this effect compile
                // TODO: For now we save usedParameters, but ideally we probably want to have a list of everything that might be use by a given
                //       pdxfx and filter against this, so that branches not taken on a specific situation/platform can still be reproduced on another.
                // Alternatively, we could save full compilerParameters, but we would have to ignore certain things that are not serializable, such as Texture.
                lock (effectCompileRecordLock)
                {
                    if (recordedEffectCompile != null)
                    {
                        var effectCompileRequest = new EffectCompileRequest(effectName, compilerResult.UsedParameters);
                        if (!recordedEffectCompile.Contains(effectCompileRequest))
                        {
                            recordedEffectCompile[effectCompileRequest] = true;
                        }
                    }
                }
#endif

                if (!compilerResult.HasErrors && isPdxfx)
                {
                    lock (earlyCompilerCache)
                    {
                        List <CompilerResults> effectCompilerResults;
                        if (!earlyCompilerCache.TryGetValue(effectName, out effectCompilerResults))
                        {
                            effectCompilerResults = new List <CompilerResults>();
                            earlyCompilerCache.Add(effectName, effectCompilerResults);
                        }

                        // Register bytecode used parameters so that they are checked when another effect is instanced
                        effectCompilerResults.Add(compilerResult);
                    }
                }
            }

            foreach (var message in compilerResult.Messages)
            {
                Log.Log(message);
            }

            return(compilerResult);
        }
 public static BuildStep FromRequest(AssetCompilerContext context, Package package, UDirectory urlRoot, EffectCompileRequest effectCompileRequest)
 {
     var compilerParameters = new CompilerParameters(effectCompileRequest.UsedParameters);
     compilerParameters.EffectParameters.Platform = context.GetGraphicsPlatform(package);
     compilerParameters.EffectParameters.Profile = context.GetGameSettingsAsset().Get<RenderingSettings>(context.Platform).DefaultGraphicsProfile;
     compilerParameters.EffectParameters.ApplyCompilationMode(context.GetCompilationMode());
     return new CommandBuildStep(new EffectCompileCommand(context, urlRoot, effectCompileRequest.EffectName, compilerParameters, package));
 }