public SimpleClassifierBuilder(IClassificationAlgorithmBuilder classificationAlgorithmBuilder, IFeatureSelector featureSelector, ISampler sampler, ITextDocumentConverter textDocumentConverter)
 {
     this.classificationAlgorithmBuilder = classificationAlgorithmBuilder;
     this.featureSelector = featureSelector;
     this.textDocumentConverter = textDocumentConverter;
     this.sampler = sampler;
 }
示例#2
0
        public static Mesh Create(Vector3 position, Quaternion rotation, float edge, Shader shader, ISampler normalSampler)
        {
            float h = edge / 2;
            var vertices = new[]
            {
                new Vector3(-h, h, -h),
                new Vector3(h, h, -h),
                new Vector3(h, h, h),
                new Vector3(-h, h, h),
                new Vector3(-h, -h, -h),
                new Vector3(h, -h, -h),
                new Vector3(h, -h, h),
                new Vector3(-h, -h, h)
            };
            var triangles = new[]
            {
                new Triangle(0, 1, 2),
                new Triangle(2, 3, 0),
                new Triangle(0, 3, 7),
                new Triangle(0, 7, 4),
                new Triangle(1, 0, 4),
                new Triangle(1, 4, 5),
                new Triangle(2, 1, 5),
                new Triangle(2, 5, 6),
                new Triangle(3, 2, 6),
                new Triangle(3, 6, 7),
                new Triangle(4, 6, 5),
                new Triangle(4, 7, 6)
            };

            return new Mesh(vertices, triangles, position, rotation, shader, normalSampler);
        }
示例#3
0
 public PsSample(ISampler sampler) : base(sampler)
 {
     this.sampler = (PsMltSampler)sampler;
     sampleData = new float[this.sampler.MaxSampleDimension];
     PrevSamples = new float[this.sampler.MaxSampleDimension];
     MaxDimPrev = 0;
 }
        protected void Init(IIntersectionEngine device, bool lowLatency, IImageFilm pixelDevice, ISampler sampler,
                            SurfaceSampler ss)
        {
            this.intersectionDevice = device;
            // Sample buffer
            var sampleBufferSize = lowLatency ? (this.SAMPLE_BUFFER_SIZE / 4) : this.SAMPLE_BUFFER_SIZE;
            this.sampleBuffer = new SampleBuffer(sampleBufferSize);

            this.width = sampler.Width;
            this.height = sampler.Height;
            var rayBufferSize = lowLatency ? (RayBuffer.RayBufferSize / 8) : RayBuffer.RayBufferSize;
            this.sampler = sampler;
            this._pathRayProcessors = new PathBufferBase[DeviceRenderBufferCount];
            this.rayBuffers = new RayBuffer[DeviceRenderBufferCount];
            this.pixelDevice = pixelDevice;
            for (int i = 0; i < DeviceRenderBufferCount; i++)
            {
                this.rayBuffers[i] = new RayBuffer(rayBufferSize);
                this.rayBuffers[i].UserData = this.threadIndex;

                this._pathRayProcessors[i] = this.CreatePathBuffer(this.scene.MaxPaths, this.scene, pixelDevice, sampler, ss);
                this._pathRayProcessors[i].ThreadId = this.threadIndex;
            }

            this.renderThread = null;
        }
        /// <summary>
        ///     Creates triangle approximation of a sphere
        /// </summary>
        /// <param name="position">Center of the sphere</param>
        /// <param name="rotation">Spheres rotation</param>
        /// <param name="radius">Radius of the sphere</param>
        /// <param name="rings">Nummber of horizontal vertex rings approximating the sphere. Poles not included</param>
        /// <param name="segments">Number of segments per ring</param>
        /// <param name="shader">Shader to use for the mesh</param>
        /// <param name="normalSampler">Normal sampler to use for the mesh</param>
        public static Mesh Create(Vector3 position, Quaternion rotation, double radius, int rings, int segments, Shader shader,
            ISampler normalSampler)
        {
            Vector3[] vertices = BuildVertices(radius, segments, rings);
            Triangle[] triangles = BuildTriangles(segments, rings);

            return new Mesh(vertices, triangles, position, rotation, shader, normalSampler);
        }
示例#6
0
 public Mesh(Vector3[] vertices, Triangle[] triangles, Vector3 position, Quaternion rotation, Shader shader, ISampler normalSampler)
 {
     Vertices = vertices;
     _triangles = triangles;
     Shader = shader;
     Position = position;
     Rotation = rotation;
     _normalSampler = normalSampler;
     Init();
 }
 protected DeviceRenderThreadBase(int index,
                                  IIntersectionEngine device,
                                  RayEngineScene scn,
                                  bool lowLatency,
                                  IImageFilm pixelDevice,
                                  ISampler sampler, SurfaceSampler ss)
     : base(index, scn)
 {
     this.Init(device, lowLatency, pixelDevice, sampler, ss);
 }
示例#8
0
        public static Mesh Create(Vector3 position, Quaternion rotation, Vector3 forward, Vector3 right, float edge, Shader shader,
            ISampler normalSampler)
        {
            float halfEdge = edge / 2;
            var vertices = new[]
            {
                (forward + right) * halfEdge,
                (forward - right) * halfEdge,
                (right - forward) * halfEdge,
                (-1 * forward - right) * halfEdge
            };
            var triangles = new[]
            {
                new Triangle(0, 1, 2),
                new Triangle(1, 3, 2)
            };

            return new Mesh(vertices, triangles, position, rotation, shader, normalSampler);
        }
示例#9
0
        public NativeRenderThread(int index, CpuBvhIntersectionEngine device, RayEngineScene scn, bool lowLatency, ImageFilm pixelDevice, ISampler sampler, SurfaceSampler ss)
            : base(index, scn) {
            intersectionDevice = device;

            // Allocate buffers

            // Sample buffer
            var sampleBufferSize = lowLatency ? (SAMPLE_BUFFER_SIZE / 4) : SAMPLE_BUFFER_SIZE;
            sampleBuffer = new SampleBuffer(sampleBufferSize);

            // Ray buffer (small buffers work well with CPU)
            var rayBufferSize = 1024;

            this.sampler = sampler;


            _pathRayProcessor = new PathBuffer(scn.MaxPaths, scn, pixelDevice, new SamplingContext() { PrimarySpaceSampler = sampler, SurfaceSampler = ss, LightSampler = new LightSampler(scn)});
            this.pixelDevice = pixelDevice;

            rayBuffer = new RayBuffer(rayBufferSize);

            renderThread = null;
        }
示例#10
0
 public BaseTableHelper(IEnumerable <T> rows, IEnumerable <ColumnMetadata> metadata, ISampler <T> sampler)
 => (Rows, Metadatas, Sampler) = (new ReadOnlyCollection <T>(rows.ToList()), metadata, sampler);
示例#11
0
 public override ISpanBuilder SetSampler(ISampler sampler)
 {
     return(this);
 }
        internal Tracer(TracerSettings settings, IAgentWriter agentWriter, ISampler sampler, IScopeManager scopeManager, IStatsd statsd)
        {
            // update the count of Tracer instances
            Interlocked.Increment(ref _liveTracerCount);

            Settings = settings ?? TracerSettings.FromDefaultSources();

            // if not configured, try to determine an appropriate service name
            DefaultServiceName = Settings.ServiceName ??
                                 GetApplicationName() ??
                                 UnknownServiceName;

            // only set DogStatsdClient if tracer metrics are enabled
            if (Settings.TracerMetricsEnabled)
            {
                // Run this first in case the port override is ready
                TracingProcessManager.SubscribeToDogStatsDPortOverride(
                    port =>
                {
                    Log.Debug("Attempting to override dogstatsd port with {0}", port);
                    Statsd = CreateDogStatsdClient(Settings, DefaultServiceName, port);
                });

                Statsd = statsd ?? CreateDogStatsdClient(Settings, DefaultServiceName, Settings.DogStatsdPort);
            }

            IApi apiClient = null;

            if (agentWriter == null)
            {
                if (Settings.ApiType.ToLower().Equals("zipkin"))
                {
                    apiClient = new ZipkinApi(Settings, delegatingHandler: null);
                }
            }

            _agentWriter  = agentWriter ?? new AgentWriter(apiClient, Statsd, Settings.SynchronousSend);
            _scopeManager = scopeManager ?? new AsyncLocalScopeManager();
            Sampler       = sampler ?? new RuleBasedSampler(new RateLimiter(Settings.MaxTracesSubmittedPerSecond));

            if (!string.IsNullOrWhiteSpace(Settings.CustomSamplingRules))
            {
                // User has opted in, ensure rate limiter is used
                RuleBasedSampler.OptInTracingWithoutLimits();

                foreach (var rule in CustomSamplingRule.BuildFromConfigurationString(Settings.CustomSamplingRules))
                {
                    Sampler.RegisterRule(rule);
                }
            }

            if (Settings.GlobalSamplingRate != null)
            {
                var globalRate = (float)Settings.GlobalSamplingRate;

                if (globalRate < 0f || globalRate > 1f)
                {
                    Log.Warning("{0} configuration of {1} is out of range", ConfigurationKeys.GlobalSamplingRate, Settings.GlobalSamplingRate);
                }
                else
                {
                    Sampler.RegisterRule(new GlobalSamplingRule(globalRate));
                }
            }

            // Register callbacks to make sure we flush the traces before exiting
            AppDomain.CurrentDomain.ProcessExit        += CurrentDomain_ProcessExit;
            AppDomain.CurrentDomain.DomainUnload       += CurrentDomain_DomainUnload;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            Console.CancelKeyPress += Console_CancelKeyPress;

            // start the heartbeat loop
            _heartbeatTimer = new Timer(HeartbeatCallback, state: null, dueTime: TimeSpan.Zero, period: TimeSpan.FromMinutes(1));

            // If configured, add/remove the correlation identifiers into the
            // LibLog logging context when a scope is activated/closed
            if (Settings.LogsInjectionEnabled)
            {
                InitializeLibLogScopeEventSubscriber(_scopeManager);
            }
        }
        public void ProbabilitySampler_SampleBasedOnTraceId()
        {
            ISampler defaultProbability = ProbabilitySampler.Create(0.0001);
            // This traceId will not be sampled by the ProbabilitySampler because the first 8 bytes as long
            // is not less than probability * Long.MAX_VALUE;
            var notSampledtraceId =
                ActivityTraceId.CreateFromBytes(
                    new byte[]
            {
                0x8F,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
            });

            Assert.False(
                defaultProbability.ShouldSample(
                    null,
                    notSampledtraceId,
                    ActivitySpanId.CreateRandom(),
                    SPAN_NAME,
                    null));
            // This traceId will be sampled by the ProbabilitySampler because the first 8 bytes as long
            // is less than probability * Long.MAX_VALUE;
            var sampledtraceId =
                ActivityTraceId.CreateFromBytes(
                    new byte[]
            {
                0x00,
                0x00,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
            });

            Assert.True(
                defaultProbability.ShouldSample(
                    null,
                    sampledtraceId,
                    ActivitySpanId.CreateRandom(),
                    SPAN_NAME,
                    null));
        }
        protected override void RenderAnalysis(LookupViolationCollection violations, IEnumerable <ColumnMetadata> metadata, ISampler <DataRow> sampler, ColumnMappingCollection keyMappings, ColumnMappingCollection valueMappings, JsonWriter writer)
        {
            writer.WriteStartObject();
            writer.WritePropertyName("unexpected");
            var rows = violations.Values.Where(x => x is LookupExistsViolationInformation)
                       .Cast <LookupExistsViolationInformation>()
                       .SelectMany(x => x.CandidateRows);

            sampler.Build(rows);
            var tableHelper = new StandardTableHelperJson(rows, metadata, sampler);

            tableHelper.Render(writer);
            writer.WriteEndObject();
        }
示例#15
0
 /// <summary>
 /// Configures sampler.
 /// </summary>
 /// <param name="sampler">Sampler instance.</param>
 public TracerBuilder SetSampler(ISampler sampler)
 {
     this.Sampler = sampler ?? throw new ArgumentNullException(nameof(sampler));
     return(this);
 }
示例#16
0
 public Tracer(ISpanRecorder spanRecorder, ISampler sampler = null, ISpanContextFactory spanContextFactory = null)
 {
     _spanRecorder       = spanRecorder ?? throw new ArgumentNullException(nameof(spanRecorder));
     _sampler            = sampler ?? new FullSampler();
     _spanContextFactory = spanContextFactory ?? new SpanContextFactory();
 }
示例#17
0
 public void DrawTexture(ITexture texture, ISampler sampler, Extents2DF srcRegion, Extents2DF dstRegion)
 {
     _renderer.New <DrawTextureCommand>().Set(Ref(texture), Ref(sampler), srcRegion, dstRegion);
     _renderer.QueueCommand();
 }
示例#18
0
 public void SetTextureAndSampler(ShaderStage stage, int binding, ITexture texture, ISampler sampler)
 {
     _renderer.New <SetTextureAndSamplerCommand>().Set(stage, binding, Ref(texture), Ref(sampler));
     _renderer.QueueCommand();
 }
示例#19
0
        private Tracer(
            string serviceName,
            IReporter reporter,
            ISampler sampler,
            PropagationRegistry registry,
            IClock clock,
            IMetrics metrics,
            ILoggerFactory loggerFactory,
            Dictionary <string, object> tags,
            bool zipkinSharedRpcSpan,
            IScopeManager scopeManager,
            IBaggageRestrictionManager baggageRestrictionManager,
            bool expandExceptionLogs,
            bool useTraceId128Bit)
        {
            ServiceName         = serviceName;
            Reporter            = reporter;
            Sampler             = sampler;
            Registry            = registry;
            Clock               = clock;
            Metrics             = metrics;
            Logger              = loggerFactory.CreateLogger <Tracer>();
            ZipkinSharedRpcSpan = zipkinSharedRpcSpan;
            ScopeManager        = scopeManager;
            _baggageSetter      = new BaggageSetter(baggageRestrictionManager, metrics);
            ExpandExceptionLogs = expandExceptionLogs;
            UseTraceId128Bit    = useTraceId128Bit;

            Version = LoadVersion();
            tags[Constants.JaegerClientVersionTagKey] = Version;

            string hostname = GetHostName();

            if (!tags.ContainsKey(Constants.TracerHostnameTagKey))
            {
                if (hostname != null)
                {
                    tags[Constants.TracerHostnameTagKey] = hostname;
                }
            }

            if (tags.TryGetValue(Constants.TracerIpTagKey, out object ipTag))
            {
                try
                {
                    IPv4 = Utils.IpToInt(ipTag as string);
                }
                catch
                {
                }
            }
            else
            {
                try
                {
                    IPAddress hostIPv4 = Dns.GetHostAddresses(hostname).First(ip => ip.AddressFamily == AddressFamily.InterNetwork);

                    tags[Constants.TracerIpTagKey] = hostIPv4.ToString();
                    IPv4 = Utils.IpToInt(hostIPv4);
                }
                catch
                {
                }
            }

            Tags = tags;
        }
示例#20
0
 public Builder WithSampler(ISampler sampler)
 {
     _sampler = sampler;
     return(this);
 }
        public static void DrainSession(ISpan parentSpan, IEnumerable <IProfiledCommand> sessionCommands, ISampler sampler, ICollection <SpanData> spans)
        {
            var parentContext = parentSpan?.Context ?? SpanContext.Blank;

            foreach (var command in sessionCommands)
            {
                var name = command.Command; // Example: SET;
                if (string.IsNullOrEmpty(name))
                {
                    name = "name";
                }

                if (ShouldSample(parentContext, name, sampler, out var context, out var parentSpanId))
                {
                    var sd = ProfiledCommandToSpanData(context, name, parentSpanId, command);
                    spans.Add(sd);
                }
            }
        }
        private Sample Mutate(Sample s, int mc, ISampler rnd)
        {

            if (mc > 1 && rnd.NextFloat() > 0.5f)
            {
                if (rnd.NextFloat() > 0.5f)
                {
                    s.imageX = Mutate(s.imageX, rnd.NextFloat(), rnd.NextFloat());
                    //if (rnd.NextFloat() > 0.5f)
                    s.imageY = Mutate(s.imageY, rnd.NextFloat(), rnd.NextFloat());
                }
                //return s;
                //if (rnd.NextFloat() > 0.5f)return;
            }

            for (int i = 0; i < s.sampleData.Length; i++)
            {
                s.sampleData[i] = Mutate(s.sampleData[i], rnd.NextFloat(), rnd.NextFloat());
            }
            return s;
        }
示例#23
0
        private ISpan StartSpanInternal(
            ISpanContext parent,
            bool hasRemoteParent,
            string name,
            ISampler sampler,
            IEnumerable <ISpan> parentLinks,
            bool recordEvents,
            Timer timestampConverter)
        {
            ITraceParams        activeTraceParams = this.Options.TraceConfig.ActiveTraceParams;
            IRandomGenerator    random            = this.Options.RandomHandler;
            ITraceId            traceId;
            ISpanId             spanId       = SpanId.GenerateRandomId(random);
            ISpanId             parentSpanId = null;
            TraceOptionsBuilder traceOptionsBuilder;

            if (parent == null || !parent.IsValid)
            {
                // New root span.
                traceId             = TraceId.GenerateRandomId(random);
                traceOptionsBuilder = TraceOptions.Builder();

                // This is a root span so no remote or local parent.
                // hasRemoteParent = null;
                hasRemoteParent = false;
            }
            else
            {
                // New child span.
                traceId             = parent.TraceId;
                parentSpanId        = parent.SpanId;
                traceOptionsBuilder = TraceOptions.Builder(parent.TraceOptions);
            }

            traceOptionsBuilder.SetIsSampled(
                MakeSamplingDecision(
                    parent,
                    hasRemoteParent,
                    name,
                    sampler,
                    parentLinks,
                    traceId,
                    spanId,
                    activeTraceParams));
            TraceOptions traceOptions = traceOptionsBuilder.Build();
            SpanOptions  spanOptions  = SpanOptions.None;

            if (traceOptions.IsSampled || recordEvents)
            {
                spanOptions = SpanOptions.RecordEvents;
            }

            ISpan span = Span.StartSpan(
                SpanContext.Create(traceId, spanId, traceOptions, parent?.Tracestate ?? Tracestate.Empty),
                spanOptions,
                name,
                parentSpanId,
                hasRemoteParent,
                activeTraceParams,
                this.Options.StartEndHandler,
                timestampConverter);

            LinkSpans(span, parentLinks);
            span.Kind = this.Kind;
            return(span);
        }
示例#24
0
 public NormalIntegrator(
     ICamera camera,
     ISampler sampler,
     in PixelArea pixelBounds)
示例#25
0
        public override void Initialize()
        {
            var vertexBuffer = Context.Create.Buffer(BufferTarget.Array, 4 * 8 * sizeof(float), BufferUsageHint.StaticDraw, new[]
            {
                new Vertex(-1f, -1f, 0f, 1f),
                new Vertex(-1f, 1f, 0f, 0f),
                new Vertex(1f, 1f, 1f, 0f),
                new Vertex(1f, -1f, 1f, 1f),
            });

            var indexBuffer = Context.Create.Buffer(BufferTarget.ElementArray, 6 * sizeof(ushort), BufferUsageHint.StaticDraw, new ushort[]
            {
                0, 1, 2, 0, 2, 3
            });

            vertexArray = Context.Create.VertexArray();
            vertexArray.SetElementArrayBuffer(indexBuffer);
            vertexArray.SetVertexAttributeF(0, vertexBuffer, VertexAttributeDimension.Four, VertexAttribPointerType.Float, false, 32, 0);
            vertexArray.SetVertexAttributeF(1, vertexBuffer, VertexAttributeDimension.Four, VertexAttribPointerType.Float, false, 32, 16);

            using (var textureLoader = new TextureLoader("../Textures/Chess256.png"))
            {
                diffuseMap = Context.Create.Texture2D(textureLoader.Width, textureLoader.Height, TextureHelper.CalculateMipCount(textureLoader.Width, textureLoader.Height, 1), Format.Srgb8Alpha8);
                for (int i = 0; i < diffuseMap.MipCount; i++)
                    diffuseMap.SetData(i, textureLoader.GetMipData(i), FormatColor.Rgba, FormatType.UnsignedByte);
            }

            sampler = Context.Create.Sampler();
            sampler.SetMagFilter(TextureMagFilter.Linear);
            sampler.SetMinFilter(TextureMinFilter.LinearMipmapLinear);
            sampler.SetMaxAnisotropy(16f);

            var vsh = Context.Create.VertexShader(VertexShaderText);
            var fsh = Context.Create.FragmentShader(FragmentShaderText);
            program = Context.Create.Program(new ShaderProgramDescription
            {
                VertexShaders = new[] {vsh},
                FragmentShaders = new[] {fsh},
                VertexAttributeNames = new[] {"in_position", "in_tex_coord"},
                SamplerNames = new[] {"DiffuseMap"}
            });
        }
示例#26
0
文件: Monitor.cs 项目: petxo/HermEsb
 /// <summary>
 /// Adds the sampler.
 /// </summary>
 /// <param name="sampler">The sampler.</param>
 public void AddSampler(ISampler sampler)
 {
     _samplers.Add(sampler);
     sampler.MonitoringSender = this;
     if (_stateMachine.CurrentState  == MonitorStatus.Started)
     {
         sampler.Start();
     }
 }
示例#27
0
        /// <summary>
        /// Initializes a new instance of the <see cref="DependenciesCollector"/> class.
        /// </summary>
        /// <param name="options">Configuration options for dependencies collector.</param>
        /// <param name="tracer">Tracer to record traced with.</param>
        /// <param name="sampler">Sampler to use to sample dependnecy calls.</param>
        public DependenciesCollector(DependenciesCollectorOptions options, ITracer tracer, ISampler sampler)
        {
            this.diagnosticSourceSubscriber = new DiagnosticSourceSubscriber <HttpRequestMessage>(
                new Dictionary <string, Func <ITracer, Func <HttpRequestMessage, ISampler>, ListenerHandler <HttpRequestMessage> > >()
            {
                { "HttpHandlerDiagnosticListener", (t, s) => new HttpHandlerDiagnosticListener(t, s) },
                { "Azure.Clients", (t, s) => new AzureSdkDiagnosticListener("Azure.Clients", t, sampler) },
                { "Azure.Pipeline", (t, s) => new AzureSdkDiagnosticListener("Azure.Pipeline", t, sampler) },
            },
                tracer,
                x =>
            {
                ISampler s = null;
                try
                {
                    s = options.CustomSampler(x);
                }
                catch (Exception e)
                {
                    s = null;
                    CollectorEventSource.Log.ExceptionInCustomSampler(e);
                }

                return(s ?? sampler);
            });
            this.diagnosticSourceSubscriber.Subscribe();
        }
示例#28
0
        private Uniform Add(string typeString, string name, OpenTK.Graphics.OpenGL.ActiveUniformType type, ISampler sampler)
        {
            var uniform = new Uniform(name, -1, 1, type);

            uniform.Sampler = sampler;
            sb.Append("uniform ").Append(typeString).Append(" ").Append(name).Append(";\n");
            uniform.TextureUnitIndex = samplers.Count;
            samplers.Add(uniform);
            samplerDictionary[name] = uniform;
            return(uniform);
        }
示例#29
0
 public TracerConfiguration(ISampler sampler)
     : this(sampler, DefaultSpanMaxNumAttributes, DefaultSpanMaxNumEvents, DefaultSpanMaxNumLinks)
 {
 }
示例#30
0
 public Uniform AddSampler1D(string name, ISampler sampler)
 {
     return(Add("sampler1D", name, OpenTK.Graphics.OpenGL.ActiveUniformType.Sampler1D, sampler));
 }
 public DiagnosticSourceSubscriber(Dictionary <string, Func <ITracer, ISampler, ListenerHandler> > handlers, ITracer tracer, ISampler sampler)
 {
     this.subscriptions = new ConcurrentDictionary <string, DiagnosticSourceListener>();
     this.handlers      = handlers;
     this.tracer        = tracer;
     this.sampler       = sampler;
 }
示例#32
0
 public Uniform AddSampler2DMultisampleArray(string name, ISampler sampler)
 {
     return(Add("sampler2DMultisampleArray", name, OpenTK.Graphics.OpenGL.ActiveUniformType.Sampler2DMultisampleArray, sampler));
 }
示例#33
0
        /// <summary>
        /// Ensures that the texture bindings are visible to the host GPU.
        /// Note: this actually performs the binding using the host graphics API.
        /// </summary>
        /// <param name="pool">The current texture pool</param>
        /// <param name="stage">The shader stage using the textures to be bound</param>
        /// <param name="stageIndex">The stage number of the specified shader stage</param>
        private void CommitTextureBindings(TexturePool pool, ShaderStage stage, int stageIndex)
        {
            if (_textureBindings[stageIndex] == null || _textureBindings[stageIndex].Length == 0)
            {
                return;
            }

            var samplerPool = _samplerPool;

            if (pool == null)
            {
                Logger.Error?.Print(LogClass.Gpu, $"Shader stage \"{stage}\" uses textures, but texture pool was not set.");
                return;
            }

            if (samplerPool == null)
            {
                Logger.Error?.Print(LogClass.Gpu, $"Shader stage \"{stage}\" uses textures, but sampler pool was not set.");
                return;
            }

            for (int index = 0; index < _textureBindings[stageIndex].Length; index++)
            {
                TextureBindingInfo bindingInfo = _textureBindings[stageIndex][index];

                int textureBufferIndex;
                int samplerBufferIndex;

                if (bindingInfo.CbufSlot < 0)
                {
                    textureBufferIndex = _textureBufferIndex;
                    samplerBufferIndex = textureBufferIndex;
                }
                else
                {
                    textureBufferIndex = bindingInfo.CbufSlot & SlotMask;
                    samplerBufferIndex = ((bindingInfo.CbufSlot >> SlotHigh) != 0) ? (bindingInfo.CbufSlot >> SlotHigh) - 1 : textureBufferIndex;
                }

                int packedId  = ReadPackedId(stageIndex, bindingInfo.Handle, textureBufferIndex, samplerBufferIndex);
                int textureId = UnpackTextureId(packedId);
                int samplerId;

                if (_samplerIndex == SamplerIndex.ViaHeaderIndex)
                {
                    samplerId = textureId;
                }
                else
                {
                    samplerId = UnpackSamplerId(packedId);
                }

                Texture texture = pool.Get(textureId);

                ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);

                if (_textureState[stageIndex][index].Texture != hostTexture || _rebind)
                {
                    if (UpdateScale(texture, bindingInfo, index, stage))
                    {
                        hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
                    }

                    _textureState[stageIndex][index].Texture = hostTexture;

                    _context.Renderer.Pipeline.SetTexture(bindingInfo.Binding, hostTexture);
                }

                if (hostTexture != null && texture.Target == Target.TextureBuffer)
                {
                    // Ensure that the buffer texture is using the correct buffer as storage.
                    // Buffers are frequently re-created to accomodate larger data, so we need to re-bind
                    // to ensure we're not using a old buffer that was already deleted.
                    _channel.BufferManager.SetBufferTextureStorage(hostTexture, texture.Range.GetSubRange(0).Address, texture.Size, bindingInfo, bindingInfo.Format, false);
                }

                Sampler sampler = samplerPool.Get(samplerId);

                ISampler hostSampler = sampler?.HostSampler;

                if (_textureState[stageIndex][index].Sampler != hostSampler || _rebind)
                {
                    _textureState[stageIndex][index].Sampler = hostSampler;

                    _context.Renderer.Pipeline.SetSampler(bindingInfo.Binding, hostSampler);
                }
            }
        }
示例#34
0
 public Uniform AddSampler2DRectShadow(string name, ISampler sampler)
 {
     return(Add("sampler2DRectShadow", name, OpenTK.Graphics.OpenGL.ActiveUniformType.Sampler2DRectShadow, sampler));
 }
示例#35
0
 public CITracerManager(ImmutableTracerSettings settings, IAgentWriter agentWriter, ISampler sampler, IScopeManager scopeManager, IDogStatsd statsd, RuntimeMetricsWriter runtimeMetricsWriter, DirectLogSubmissionManager logSubmissionManager, ITelemetryController telemetry, string defaultServiceName)
     : base(settings, agentWriter, sampler, scopeManager, statsd, runtimeMetricsWriter, logSubmissionManager, telemetry, defaultServiceName, new Trace.Processors.ITraceProcessor[]
 {
     new Trace.Processors.NormalizerTraceProcessor(),
     new Trace.Processors.TruncatorTraceProcessor(),
     new Processors.OriginTagTraceProcessor(settings.Exporter.PartialFlushEnabled, agentWriter is CIAgentlessWriter),
 })
 {
 }
示例#36
0
        /// <summary>
        /// Initializes a new instance of the <see cref="StackExchangeRedisCallsCollector"/> class.
        /// </summary>
        /// <param name="options">Configuration options for dependencies collector.</param>
        /// <param name="tracer">Tracer to record traced with.</param>
        /// <param name="sampler">Sampler to use to sample dependnecy calls.</param>
        /// <param name="exportComponent">TEMPORARY: handler to send data to.</param>
        public StackExchangeRedisCallsCollector(StackExchangeRedisCallsCollectorOptions options, ITracer tracer, ISampler sampler, IExportComponent exportComponent)
        {
            this.tracer   = tracer;
            this.exporter = exportComponent;
            this.sampler  = sampler;

            this.cancellationTokenSource = new CancellationTokenSource();
            this.cancellationToken       = this.cancellationTokenSource.Token;
            Task.Factory.StartNew(this.DumpEntries, TaskCreationOptions.LongRunning, this.cancellationToken);
        }
示例#37
0
 /// <summary>
 /// Sets sempler to use.
 /// </summary>
 /// <param name="sampler">Sampler to use.</param>
 /// <returns>Builder to chain operations.</returns>
 public TraceParamsBuilder SetSampler(ISampler sampler)
 {
     this.sampler = sampler ?? throw new ArgumentNullException("Null sampler");
     return(this);
 }
        public void ProbabilitySampler_SampleBasedOnTraceId()
        {
            ISampler defaultProbability = ProbabilitySampler.Create(0.0001);
            // This traceId will not be sampled by the ProbabilitySampler because the first 8 bytes as long
            // is not less than probability * Long.MAX_VALUE;
            TraceId notSampledtraceId =
                TraceId.FromBytes(
                    new byte[]
            {
                0x8F,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
            });

            Assert.False(
                defaultProbability.ShouldSample(
                    null,
                    notSampledtraceId,
                    SpanId.GenerateRandomId(random),
                    SPAN_NAME,
                    new List <ISpan>()));
            // This traceId will be sampled by the ProbabilitySampler because the first 8 bytes as long
            // is less than probability * Long.MAX_VALUE;
            TraceId sampledtraceId =
                TraceId.FromBytes(
                    new byte[]
            {
                0x00,
                0x00,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0xFF,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
                0,
            });

            Assert.True(
                defaultProbability.ShouldSample(
                    null,
                    sampledtraceId,
                    SpanId.GenerateRandomId(random),
                    SPAN_NAME,
                    new List <ISpan>()));
        }
 public Builder WithInitialSampler(ISampler initialSampler)
 {
     InitialSampler = initialSampler ?? throw new ArgumentNullException(nameof(initialSampler));
     return(this);
 }
示例#40
0
 public LookupTableHelperJson(IEnumerable <LookupMatchesViolationComposite> composites, IEnumerable <ColumnMetadata> metadatas, ISampler <LookupMatchesViolationComposite> sampler)
     : base(composites, metadatas, sampler)
 {
 }
 public DiffuseShader(ISampler textureSampler)
 {
     _textureSampler = textureSampler;
 }
示例#42
0
 protected abstract PathBufferBase CreatePathBuffer(int maxPath, IRayEngineScene scene, IImageFilm pixelDevice,
                                                    ISampler sampler, SurfaceSampler ss);
示例#43
0
 public TestShader(ISampler sampler)
 {
     _sampler = sampler;
 }
示例#44
0
 public GpuDebugger(IPclWorkarounds pclWorkarounds, IClientSettings settings, IContext context)
 {
     this.pclWorkarounds = pclWorkarounds;
     fullTextureProcessor = new FullTextureProcessor(settings, context, FragmentShaderText, new[] { "Texture0", "Texture1" });
     framebuffer = context.Create.Framebuffer();
     mipInfoBuffer = context.Create.Buffer(BufferTarget.UniformBuffer, 16, BufferUsageHint.DynamicDraw);
     sampler = context.Create.Sampler();
 }
示例#45
0
        public override void Initialize()
        {
            var vertexBuffer = Context.Create.Buffer(BufferTarget.Array, 4 * 8 * sizeof(float), BufferUsageHint.StaticDraw, new[]
            {
                new Vertex(-1f, -1f, 0f, 1f),
                new Vertex(-1f, 1f, 0f, 0f),
                new Vertex(1f, 1f, 1f, 0f),
                new Vertex(1f, -1f, 1f, 1f),
            });

            var indexBuffer = Context.Create.Buffer(BufferTarget.ElementArray, 6 * sizeof(ushort), BufferUsageHint.StaticDraw, new ushort[]
            {
                0, 1, 2, 0, 2, 3
            });

            vertexArray = Context.Create.VertexArray();
            vertexArray.SetElementArrayBuffer(indexBuffer);
            vertexArray.SetVertexAttributeF(0, vertexBuffer, VertexAttributeDimension.Four, VertexAttribPointerType.Float, false, 32, 0);
            vertexArray.SetVertexAttributeF(1, vertexBuffer, VertexAttributeDimension.Four, VertexAttribPointerType.Float, false, 32, 16);

            pixelUnpackBuffer = Context.Create.Buffer(BufferTarget.PixelUnpack, 1024 * 1024 * 4, BufferUsageHint.StreamDraw);

            data = Enumerable.Range(0, 1024 * 1024 * 4 * 2).Select(x => (byte)(128.0 + 128.0 * Math.Sin((2.0 / 3.0) * Math.PI * (x % 4) + (double)x / 4 / 11111))).ToArray();

            diffuseMap = Context.Create.Texture2D(640, 360, 1, Format.Rgba8);

            sampler = Context.Create.Sampler();
            sampler.SetMagFilter(TextureMagFilter.Nearest);
            sampler.SetMinFilter(TextureMinFilter.Nearest);
            sampler.SetMaxAnisotropy(16f);

            var vsh = Context.Create.VertexShader(VertexShaderText);
            var fsh = Context.Create.FragmentShader(FragmentShaderText);
            program = Context.Create.Program(new ShaderProgramDescription
            {
                VertexShaders = new[] {vsh},
                FragmentShaders = new[] {fsh},
                VertexAttributeNames = new[] {"in_position", "in_tex_coord"},
                SamplerNames = new[] {"DiffuseMap"}
            });
        }
示例#46
0
 public GpuFinalDecoder(IPclWorkarounds pclWorkarounds, IClientSettings settings, IContext context)
 {
     this.pclWorkarounds = pclWorkarounds;
     fullTextureProcessor = new FullTextureProcessor(settings, context, FragmentShaderText, new[] { "DiffTexture", "PrevTextureDetailed", "PrevTextureMip" });
     framebuffer = context.Create.Framebuffer();
     mipInfoBuffer = context.Create.Buffer(BufferTarget.UniformBuffer, 16, BufferUsageHint.DynamicDraw);
     sampler = context.Create.Sampler();
 }
示例#47
0
        public Color Integrate(Ray ray, IIntersectable objects, List <ILight> lights, ISampler sampler, List <List <Sample> > subPathSamples, LightSample lightSample)
        {
            HitRecord record = objects.Intersect(ray);

            Color returnColor = new Color(0, 0, 0);

            if (record != null)
            {
                foreach (ILight light in lights)
                {
                    Vector3 lightDirection = light.GetLightDirection(record.IntersectionPoint);
                    Vector3 hitPos         = record.IntersectionPoint;
                    Vector3 offset         = record.RayDirection;
                    offset  = -offset;
                    offset *= 0.001f;
                    hitPos += offset;
                    Ray       shadowRay = new Ray(hitPos, lightDirection);
                    HitRecord shadowHit = objects.Intersect(shadowRay);
                    Vector3   distance  = Vector3.Subtract(light.Position, hitPos);

                    //DEBUGGING

                    /*if (shadowHit != null && (shadowHit.Distance > distance.Length))
                     * {
                     *  returnColor.Append(record.HitObject.Material.Shade(record, light.GetLightDirection(record.IntersectionPoint)).Mult(light.GetIncidentColor(record.IntersectionPoint)));
                     * }*/
                    returnColor.Append(record.HitObject.Material.Shade(record, light.GetLightDirection(record.IntersectionPoint)).Mult(light.GetIncidentColor(record.IntersectionPoint)));
                }
            }
            return(returnColor);
        }
示例#48
0
 public ISpan StartSpan(string spanName, string serviceName, SpanType spanType, ISampler sampler)
 {
     return tracer.StartSpan(spanName, serviceName, spanType, sampler);
 }
示例#49
0
        public CursorRenderer(IClientSettings settings, IContext context, ITextureLoader textureLoader)
        {
            var header = settings.IsEs ? EsHeader : DesktopHeader;
            var vertexShader = context.Create.VertexShader(header + VertexShaderText);
            var fragmentShader = context.Create.FragmentShader(header + FragmentShaderText);
            program = context.Create.Program(new ShaderProgramDescription
            {
                VertexShaders = new[] { vertexShader },
                FragmentShaders = new[] { fragmentShader },
                VertexAttributeNames = new[] { "in_position", "in_tex_coord" },
                SamplerNames = new[] { "DiffTexture" }
            });

            var vertexBuffer = context.Create.Buffer(BufferTarget.ArrayBuffer, 4 * Vertex.Size, BufferUsageHint.StaticDraw, new[]
            {
                new Vertex(-1f, 1f, 0f, 0f),
                new Vertex(1f, 1f, 1f, 0f),
                new Vertex(1f, -1f, 1f, 1f),
                new Vertex(-1f, -1f, 0f, 1f)
            });

            var indexBuffer = context.Create.Buffer(BufferTarget.ElementArrayBuffer, 6 * sizeof(ushort), BufferUsageHint.StaticDraw, new ushort[]
            {
                0, 1, 2, 0, 2, 3
            });

            vertexArray = context.Create.VertexArray();
            vertexArray.SetVertexAttributeF(0, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, Vertex.Size, 0);
            vertexArray.SetVertexAttributeF(1, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, Vertex.Size, 2 * sizeof(float));
            vertexArray.SetElementArrayBuffer(indexBuffer);

            texture = textureLoader.LoadTexture(context, "Cursor.png");
            sampler = context.Create.Sampler();
            sampler.SetMagFilter(TextureMagFilter.Nearest);
        }
 public AzureSdkDiagnosticListener(string sourceName, ITracer tracer, ISampler sampler)
     : base(sourceName, tracer, null)
 {
     this.sampler = sampler;
 }
 public PointCloundConverter(ISampler sampler)
 {
     _sampler = sampler;
 }
示例#52
0
 public PPMDeviceRenderThread(int index, IIntersectionEngine device, RayEngineScene scn, bool lowLatency, IImageFilm pixelDevice, ISampler sampler, SurfaceSampler ss, PPMContext ctx, IFrameManager frameManager)
     : base(index, scn)
 {
     this.context = ctx;
     Init(device, lowLatency, pixelDevice, sampler, ss);
 }
示例#53
0
        public override void Initialize()
        {
            renderTarget = Context.Create.Texture2D(RenderTargetSize, RenderTargetSize, TextureHelper.CalculateMipCount(RenderTargetSize, 1, 1), Format.Rgba8);
            depthStencil = Context.Create.Renderbuffer(RenderTargetSize, RenderTargetSize, Format.Depth24Stencil8);

            framebuffer = Context.Create.Framebuffer();
            framebuffer.AttachTextureImage(FramebufferAttachmentPoint.Color0, renderTarget, 0);
            framebuffer.AttachRenderbuffer(FramebufferAttachmentPoint.DepthStencil, depthStencil);

            var vertexBuffer = Context.Create.Buffer(BufferTarget.Array, 24 * 8 * sizeof(float), BufferUsageHint.StaticDraw, new[]
            {
                new Vertex(1f, -1f, 1f, 1f, 0f, 0f, 0f, 0f),
                new Vertex(1f, 1f, 1f, 1f, 0f, 0f, 1f, 0f),
                new Vertex(1f, 1f, -1f, 1f, 0f, 0f, 1f, 1f),
                new Vertex(1f, -1f, -1f, 1f, 0f, 0f, 0f, 1f),

                new Vertex(1f, 1f, 1f, 0f, 1f, 0f, 0f, 0f),
                new Vertex(-1f, 1f, 1f, 0f, 1f, 0f, 1f, 0f),
                new Vertex(-1f, 1f, -1f, 0f, 1f, 0f, 1f, 1f),
                new Vertex(1f, 1f, -1f, 0f, 1f, 0f, 0f, 1f),

                new Vertex(-1f, 1f, 1f, -1f, 0f, 0f, 0f, 0f),
                new Vertex(-1f, -1f, 1f, -1f, 0f, 0f, 1f, 0f),
                new Vertex(-1f, -1f, -1f, -1f, 0f, 0f, 1f, 1f),
                new Vertex(-1f, 1f, -1f, -1f, 0f, 0f, 0f, 1f),

                new Vertex(-1f, -1f, 1f, 0f, -1f, 0f, 0f, 0f),
                new Vertex(1f, -1f, 1f, 0f, -1f, 0f, 1f, 0f),
                new Vertex(1f, -1f, -1f, 0f, -1f, 0f, 1f, 1f),
                new Vertex(-1f, -1f, -1f, 0f, -1f, 0f, 0f, 1f),

                new Vertex(-1f, -1f, 1f, 0f, 0f, 1f, 0f, 0f),
                new Vertex(-1f, 1f, 1f, 0f, 0f, 1f, 1f, 0f),
                new Vertex(1f, 1f, 1f, 0f, 0f, 1f, 1f, 1f),
                new Vertex(1f, -1f, 1f, 0f, 0f, 1f, 0f, 1f),

                new Vertex(-1f, 1f, -1f, 0f, 0f, -1f, 0f, 0f),
                new Vertex(-1f, -1f, -1f, 0f, 0f, -1f, 1f, 0f),
                new Vertex(1f, -1f, -1f, 0f, 0f, -1f, 1f, 1f),
                new Vertex(1f, 1f, -1f, 0f, 0f, -1f, 0f, 1f)
            });

            var indexBuffer = Context.Create.Buffer(BufferTarget.ElementArray, 36 * sizeof(ushort), BufferUsageHint.StaticDraw, new ushort[]
            {
                0, 1, 2, 0, 2, 3,
                4, 5, 6, 4, 6, 7,
                8, 9, 10, 8, 10, 11,
                12, 13, 14, 12, 14, 15,
                16, 17, 18, 16, 18, 19,
                20, 21, 22, 20, 22, 23
            });

            vertexArray = Context.Create.VertexArray();
            vertexArray.SetElementArrayBuffer(indexBuffer);
            vertexArray.SetVertexAttributeF(0, vertexBuffer, VertexAttributeDimension.Three, VertexAttribPointerType.Float, false, 32, 0);
            vertexArray.SetVertexAttributeF(1, vertexBuffer, VertexAttributeDimension.Three, VertexAttribPointerType.Float, false, 32, 12);
            vertexArray.SetVertexAttributeF(2, vertexBuffer, VertexAttributeDimension.Two, VertexAttribPointerType.Float, false, 32, 24);

            transformBuffer = Context.Create.Buffer(BufferTarget.Uniform, 64, BufferUsageHint.DynamicDraw);
            cameraBuffer = Context.Create.Buffer(BufferTarget.Uniform, 64, BufferUsageHint.DynamicDraw);
            #if INTEL_WORKAROUND
            cameraOutsideBuffer = Context.Create.Buffer(BufferTarget.Uniform, 64, BufferUsageHint.DynamicDraw);
            #endif
            cameraExtraBuffer = Context.Create.Buffer(BufferTarget.Uniform, 12, BufferUsageHint.DynamicDraw);
            lightBuffer = Context.Create.Buffer(BufferTarget.Uniform, 12, BufferUsageHint.DynamicDraw);

            using (var textureLoader = new TextureLoader("../Textures/DiffuseTest.png"))
            {
                diffuseMap = Context.Create.Texture2D(textureLoader.Width, textureLoader.Height, TextureHelper.CalculateMipCount(textureLoader.Width, textureLoader.Height, 1), Format.Rgba8);
                for (int i = 0; i < diffuseMap.MipCount; i++)
                    diffuseMap.SetData(i, textureLoader.GetMipData(i), FormatColor.Rgba, FormatType.UnsignedByte);
            }

            sampler = Context.Create.Sampler();
            sampler.SetMagFilter(TextureMagFilter.Linear);
            sampler.SetMinFilter(TextureMinFilter.LinearMipmapLinear);
            sampler.SetMaxAnisotropy(16f);

            IVertexShader vsh = Context.Create.VertexShader(VertexShaderText);
            IFragmentShader fsh = Context.Create.FragmentShader(FragmentShaderText);
            program = Context.Create.Program(new ShaderProgramDescription
            {
                VertexShaders = new[] {vsh},
                FragmentShaders = new[] {fsh},
                VertexAttributeNames = new[] {"in_position", "in_normal", "in_tex_coord"},
                UniformBufferNames = new[] {"Transform", "Camera", "Light"},
                SamplerNames = new[] {"DiffuseMap"}
            });
        }
示例#54
0
 protected override PathBufferBase CreatePathBuffer(int maxPath, IRayEngineScene scene, IImageFilm pixelDevice, ISampler sampler, SurfaceSampler ss)
 {
     var pathBuffer = new  PPMPathBuffer(context);
     pathBuffer.Init(maxPath, (RayEngineScene)scene, pixelDevice, new SamplingContext() { SurfaceSampler = ss, PrimarySpaceSampler = sampler, LightSampler = new LightSampler((RayEngineScene)scene)});
     return pathBuffer;
 }