예제 #1
0
        public virtual void Cleanup()
        {
            Context?.ClearState();
            Context?.Flush();

            BackBuffer?.Dispose();
            BackBuffer = null;
            ZBuffer?.Dispose();
            ZBuffer = null;

            RenderTargetViewRef?.Dispose();
            RenderTargetViewRef = null;

            DepthStencilSRVRef?.Dispose();
            DepthStencilSRVRef = null;

            DepthStencilViewRef?.Dispose();
            DepthStencilViewRef = null;

            FactoryDWrite?.Dispose();
            FactoryDWrite = null;
            Factory2D?.Dispose();
            Factory2D = null;
            RenderTarget2D?.Dispose();
            RenderTarget2D = null;

            Context?.Dispose();
            DeviceRef?.Dispose();
            DeviceRef = null;
        }
예제 #2
0
        public void InitRenderTargetSurface(IntPtr Resource)
        {
            ZBuffer?.Dispose();
            DepthStencilViewRef?.Dispose();
            RenderTargetViewRef?.Dispose();
            RenderTarget2D?.Dispose();

            SharpDX.DXGI.Resource dxgiResource;
            using (var r = new SharpDX.ComObject(Resource)) {
                dxgiResource = r.QueryInterface <SharpDX.DXGI.Resource>();
            }

            Texture2D OutputResource = DeviceRef.OpenSharedResource <Texture2D>(dxgiResource.SharedHandle);

            using (var surface = DeviceRef.OpenSharedResource <Surface>(dxgiResource.SharedHandle)) {
                RenderTarget2D = new RenderTarget(Factory2D, surface, RenderTarget2DProperites);
            }

            //Crash everything
            //dxgiResource.Dispose();

            RenderTarget2D.AntialiasMode     = AntialiasMode.PerPrimitive;
            RenderTarget2D.TextAntialiasMode = TextAntialiasMode.Cleartype;

            RenderTargetViewRef = new RenderTargetView(DeviceRef, OutputResource);

            Texture2DDescription OutputDesc = OutputResource.Description;

            if (OutputDesc.Width != Width || OutputDesc.Height != Height)
            {
                Width  = OutputDesc.Width;
                Height = OutputDesc.Height;
                SetUpViewport();
            }

            ZBufferTextureDescription.Width  = Width;
            ZBufferTextureDescription.Height = Height;
            ZBuffer = new Texture2D(DeviceRef, ZBufferTextureDescription);

            DepthStencilViewRef = new DepthStencilView(DeviceRef, ZBuffer, new DepthStencilViewDescription {
                Format    = Format.D32_Float,
                Dimension = DepthStencilViewDimension.Texture2D,
                Flags     = DepthStencilViewFlags.None,
            });

            Context.OutputMerger.SetRenderTargets(DepthStencilViewRef, RenderTargetViewRef);
            OnInitRenderTarget?.Invoke();
            OutputResource?.Dispose();
        }
예제 #3
0
        /// <summary>
        /// Created a list of device definitions from the passed in reference. Needs work....
        /// </summary>
        /// <param name="InputReference"></param>
        /// <param name="InLocalTempDir"></param>
        /// <param name="ObeyConstraints"></param>
        public void AddDevices(UnrealTargetPlatform DefaultPlatform, string InputReference, bool ObeyConstraints = true)
        {
            lock (LockObject)
            {
                List <ITargetDevice> NewDevices = new List <ITargetDevice>();

                int SlashIndex = InputReference.IndexOf("\\") >= 0 ? InputReference.IndexOf("\\") : InputReference.IndexOf("/");

                bool PossibleFileName = InputReference.IndexOfAny(Path.GetInvalidPathChars()) < 0 &&
                                        (InputReference.IndexOf(":") == -1 || (InputReference.IndexOf(":") == SlashIndex - 1));
                // Did they specify a file?
                if (PossibleFileName && File.Exists(InputReference))
                {
                    Gauntlet.Log.Info("Adding devices from {0}", InputReference);
                    List <DeviceDefinition> DeviceDefinitions = JsonConvert.DeserializeObject <List <DeviceDefinition> >(File.ReadAllText(InputReference));

                    foreach (DeviceDefinition Def in DeviceDefinitions)
                    {
                        Gauntlet.Log.Info("Adding {0}", Def);

                        // use Legacy field if it exists
                        if (Def.Platform == null)
                        {
                            Def.Platform = Def.Type;
                        }

                        // check for an availability constraint
                        if (string.IsNullOrEmpty(Def.Available) == false && ObeyConstraints)
                        {
                            // check whether disabled
                            if (String.Compare(Def.Available, "disabled", true) == 0)
                            {
                                Gauntlet.Log.Info("Skipping {0} due to being disabled", Def.Name);
                                continue;
                            }

                            // availability is specified as a range, e.g 21:00-09:00.
                            Match M = Regex.Match(Def.Available, @"(\d{1,2}:\d\d)\s*-\s*(\d{1,2}:\d\d)");

                            if (M.Success)
                            {
                                DateTime From, To;

                                if (DateTime.TryParse(M.Groups[1].Value, out From) && DateTime.TryParse(M.Groups[2].Value, out To))
                                {
                                    // these are just times so when parsed will have todays date. If the To time is less than
                                    // From (22:00-06:00) time it spans midnight so move it to the next day
                                    if (To < From)
                                    {
                                        To = To.AddDays(1);
                                    }

                                    // if From is in the future (e.g. it's 01:00 and range is 22:00-08:00) we may be in the previous days window,
                                    // so move them both back a day
                                    if (From > DateTime.Now)
                                    {
                                        From = From.AddDays(-1);
                                        To   = To.AddDays(-1);
                                    }

                                    if (DateTime.Now < From || DateTime.Now > To)
                                    {
                                        Gauntlet.Log.Info("Skipping {0} due to availability constraint {1}", Def.Name, Def.Available);
                                        continue;
                                    }
                                }
                                else
                                {
                                    Gauntlet.Log.Warning("Failed to parse availability {0} for {1}", Def.Available, Def.Name);
                                }
                            }
                        }

                        Def.RemoveOnShutdown = true;

                        if (Def.Platform == null)
                        {
                            Def.Platform = DefaultPlatform;
                        }

                        UnprovisionedDevices.Add(Def);
                    }

                    // randomize devices so if there's a bad device st the start so we don't always hit it (or we do if its later)
                    UnprovisionedDevices = UnprovisionedDevices.OrderBy(D => Guid.NewGuid()).ToList();
                }
                else
                {
                    if (string.IsNullOrEmpty(InputReference) == false)
                    {
                        string[] DevicesList = InputReference.Split(',');

                        foreach (string DeviceRef in DevicesList)
                        {
                            // check for <platform>:<address>:<port>|<model>. We pass address:port to device constructor
                            Match M = Regex.Match(DeviceRef, @"(.+?):(.+)");

                            UnrealTargetPlatform DevicePlatform = DefaultPlatform;
                            string DeviceAddress = DeviceRef;
                            string Model         = string.Empty;

                            // when using device service, skip adding local non-desktop devices to pool
                            bool IsDesktop = UnrealBuildTool.Utils.GetPlatformsInClass(UnrealPlatformClass.Desktop).Contains(DevicePlatform);
                            if (!IsDesktop && DeviceRef.Equals("default", StringComparison.OrdinalIgnoreCase) && !String.IsNullOrEmpty(DeviceURL))
                            {
                                continue;
                            }

                            if (M.Success)
                            {
                                if (!UnrealTargetPlatform.TryParse(M.Groups[1].ToString(), out DevicePlatform))
                                {
                                    throw new AutomationException("platform {0} is not a recognized device type", M.Groups[1].ToString());
                                }

                                DeviceAddress = M.Groups[2].ToString();

                                // parse device model
                                if (DeviceAddress.Contains("|"))
                                {
                                    string[] Components = DeviceAddress.Split(new char[] { '|' });
                                    DeviceAddress = Components[0];
                                    Model         = Components[1];
                                }
                            }

                            Log.Info("Added device {0}:{1} to pool", DevicePlatform, DeviceAddress);
                            DeviceDefinition Def = new DeviceDefinition();
                            Def.Address  = DeviceAddress;
                            Def.Name     = DeviceAddress;
                            Def.Platform = DevicePlatform;
                            Def.Model    = Model;
                            UnprovisionedDevices.Add(Def);
                        }
                    }
                }
            }
        }
예제 #4
0
 protected void CheckFeatures()
 {
     ShaderDoubles = DeviceRef.CheckFeatureSupport(SharpDX.Direct3D11.Feature.ShaderDoubles);
 }