protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.colpoints, 1920 * 1080 * 8);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.depthread, 1920 * 1080 * 4);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData<int>(this.playerimage);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData(this.depthread, 512 * 424 * 2);
     }
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         texture.WriteData<byte>(this.rawdepth);
     }
 }
        protected override void CopyData(DX11DynamicTexture2D texture)
        {
            lock (m_lock)
            {
                for (int i = 0; i < this.colpoints.Length; i++)
                {
                    if (FRelativeLookup[0])
                    {
                        this.colorimage[i * 2] = (float)VMath.Map(colpoints[i].X - i % 1920, 0, 1920, 0, 1, TMapMode.Float);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y - VMath.Abs(i / 1920), 0, 1080, 0, 1, TMapMode.Float);
                    }
                    else
                    {

                        this.colorimage[i * 2] = (float)VMath.Map(colpoints[i].X, 0, 1920, 0, 1, TMapMode.Clamp);
                        this.colorimage[i * 2 + 1] = (float)VMath.Map(colpoints[i].Y, 0, 1080, 0, 1, TMapMode.Clamp);
                    }
                }

                fixed (float* f = &this.colorimage[0])
                {
                    IntPtr ptr = new IntPtr(f);
                    texture.WriteData(ptr, this.width * this.height * 8);
                }
            }
        }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     fixed (float* f = &world1[0])
     {
         IntPtr ptr = new IntPtr(f);
         texture.WriteData(ptr, this.width * this.height * 4 * 4);
     }
        // texture.WriteData<float>(world1);
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_depthlock)
     {
         fixed (Vector4* cp = &this.colorread[0])
         {
             IntPtr ptr = new IntPtr(cp);
             texture.WriteData(ptr, 512 * 424 * 16);
         }
     }
 }
				public ResourcePool(DX11RenderContext context, int width, int height)
				{
					FFrontTexture = new DX11DynamicTexture2D(context, width, height, SlimDX.DXGI.Format.R8_UNorm);
					byte[] black = new byte[width * height];
					for(int i=0; i<width * height; i++)
					{
						black[i] = 0;
					}
					FFrontTexture.WriteData(black);
					FContext = context;
				}
Example #10
0
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     lock (m_lock)
     {
         fixed (SkeletonPoint* f = &this.skelpoints[0])
         {
             IntPtr ptr = new IntPtr(f);
             texture.WriteData(ptr, this.width * this.height * 16);
         }
     }
 }
        public void Update(IPluginIO pin, FeralTic.DX11.DX11RenderContext context)
        {
            for (int i = 0; i < this.FTextureOut.SliceCount; i++)
            {
                if (!this.FTextureOut[i].Contains(context))
                {
                    Bitmap bmp = ComputeQRCode(i);

                    DX11DynamicTexture2D tex = new DX11DynamicTexture2D(context, bmp.Width, bmp.Height, SlimDX.DXGI.Format.R8G8B8A8_UNorm);

                    int pitch = tex.GetRowPitch();

                    var data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, bmp.PixelFormat);

                    if (pitch != bmp.Width * 4)
                    {
                        tex.WriteDataPitch(data.Scan0, bmp.Width * bmp.Height * 4);
                    }
                    else
                    {
                        tex.WriteData(data.Scan0, bmp.Width * bmp.Height * 4);
                    }

                    this.FTextureOut[i][context] = tex;

                }
            }
        }
Example #12
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            Stopwatch w = Stopwatch.StartNew();

            int cnt = 0;
            foreach (VlcPlayer vlc in this.players)
            {

                if (vlc != null)
                {
                    if (vlc.IsValid)
                    {
                        DX11DynamicTexture2D t;
                        if (!this.FTextureOut[cnt].Contains(context))
                        {
                            t = new DX11DynamicTexture2D(context, vlc.Width, vlc.Height, SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                            #if DEBUG
                            t.Resource.DebugName = "Vlc";
                            #endif
                            this.FTextureOut[cnt][context] = t;
                        }
                        else
                        {
                            t = this.FTextureOut[cnt][context];
                            if (t.Width != vlc.Width || t.Height != vlc.Height)
                            {
                                this.FTextureOut[cnt].Dispose(context);
                                DX11DynamicTexture2D t2 = new DX11DynamicTexture2D(context, vlc.Width, vlc.Height, SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                                #if DEBUG
                                t2.Resource.DebugName = "Vlc";
                                #endif
                                this.FTextureOut[cnt][context] = t2;
                                t = t2;
                            }
                        }

                        if (vlc.Play)
                        {
                            IntPtr ptr = vlc.frontBuffer;

                            if (vlc.Width * 4 == t.GetRowPitch())
                            {
                                t.WriteData(ptr, vlc.Width * vlc.Height * 4);
                            }
                            else
                            {
                                t.WriteDataPitch(ptr, vlc.Width * vlc.Height * 4);
                            }
                        }
                    }
                    else
                    {
                        this.FTextureOut[cnt].Dispose(context);
                    }
                }
                cnt++;
            }

            w.Stop();
            this.FPinOutCopyTime.SetValue(0, w.ElapsedMilliseconds);
        }
		void CheckTextureAllocation(DX11RenderContext context)
		{
			//check if the texture we've got allocated for this context doesn't meet the current image attributes
			//this coule be on an OnImageAttributesChanged, but perhaps lazy reallocation is best
			if (FTextures.ContainsKey(context))
			{
				var tex = FTextures[context].Texture;
				if (tex.Width != this.Width || tex.Height != this.Height || tex.Format != GetFormat(FBuffer.ImageAttributes.ColorFormat))
				{
					tex.Dispose();
					FTextures.Remove(context);
				}
			}

			//check if we've not currently got a texture allocated for this context
			if (!FTextures.ContainsKey(context))
			{
				var tex = new DX11DynamicTexture2D(context, Width, Height, GetFormat(FBuffer.ImageAttributes.ColorFormat));
				var resource = new Resource()
				{
					Texture = tex,
					NeedsRefresh = this.FInput.Allocated,
				};
				FTextures[context] = resource;
				this.OutputSlice[context] = tex;
			}
		}
 protected abstract void CopyData(DX11DynamicTexture2D texture);
Example #15
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (c != null)
            {
                if (this.invalidate || !this.FTextureOutput[0].Contains(context))
                {
                    try
                    {
                        if (this.FTextureOutput[0].Contains(context))
                        {
                            this.FTextureOutput[0].Dispose(context);
                        }

                        DX11DynamicTexture2D t = new DX11DynamicTexture2D(context, this.FInW[0], this.FInH[0], SlimDX.DXGI.Format.B8G8R8A8_UNorm);

                        this.FTextureOutput[0][context] = t;
                    }
                    catch
                    {

                    }
                }

                if (this.copyframe && this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0][context].WriteData(this.rgbadata, this.size);
                }
            }
        }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteData<ColorSpacePoint>(this.points);
 }
Example #17
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (this.reset)
            {
                if (this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0].Dispose(context);
                }

                DX11DynamicTexture2D t = new DX11DynamicTexture2D(context, this.videoin.GetWidth(), this.videoin.GetHeight(), SlimDX.DXGI.Format.B8G8R8A8_UNorm);
                this.FTextureOutput[0][context] = t;
                this.reset = false;
            }

            if (this.invalidate)
            {
                this.FTextureOutput[0][context].WriteData(this.videoin.frontBuffer, this.videoin.size);
                this.invalidate = false;
            }
        }
Example #18
0
 public void Dispose()
 {
     if (this.blacktex != null) { this.blacktex.Dispose(); this.blacktex = null; }
     if (this.whitetex != null) { this.whitetex.Dispose(); this.whitetex = null; }
 }
		public void Update(DX11Resource<DX11DynamicTexture2D> textureSlice, DX11RenderContext context)
		{
			if (!this.Running || !FDataNewForTexture)
			{
				return;
			}
			FDataNewForTexture = false;

			DX11DynamicTexture2D tex;

			//create texture if necessary
			//should also check if properties (width,height) changed
			if (!textureSlice.Contains(context))
			{
				tex = new DX11DynamicTexture2D(context, FFrameWidth, FFrameHeight, SlimDX.DXGI.Format.R8_UNorm);
				textureSlice[context] = tex;
			}
			else if (textureSlice[context].Width != this.FFrameWidth || textureSlice[context].Height != this.FFrameHeight)
			{
				textureSlice[context].Dispose();
				tex = new DX11DynamicTexture2D(context, FFrameWidth, FFrameHeight, SlimDX.DXGI.Format.R8_UNorm);
				textureSlice[context] = tex;
			}
			else
			{
				tex = textureSlice[context];
			}

			FDoubleBuffer.LockFront.AcquireReaderLock(100);
			try
			{
				//write data to surface
				if (FFrameWidth == tex.GetRowPitch())
				{
					tex.WriteData(FDoubleBuffer.Front);
				}
				else
				{
					GCHandle pinnedArray = GCHandle.Alloc(FDoubleBuffer.Front, GCHandleType.Pinned);
					tex.WriteDataPitch(pinnedArray.AddrOfPinnedObject(), FDoubleBuffer.Front.Length);
					pinnedArray.Free();
				}
			}
			catch
			{
			}
			finally
			{
				FDoubleBuffer.LockFront.ReleaseReaderLock();
			}
		}
Example #20
0
			unsafe void ThreadedFunction()
			{
				Random random = new Random();
				Thread.Sleep((int)(random.NextDouble() * 1000.0));

				while(FRunningThread)
				{
					try
					{
						if (FNeedsRelist)
						{
							try
							{
								var filenames = Directory.GetFiles(FPath, FMask);
								lock (FMemoryPoolLock)
								{
									FMemoryPool.Clear();
									foreach (var filename in filenames)
									{
										var image = new Image();
										image.Filename = filename;
										FMemoryPool.Add(image);
									}
								}
							}
							catch (Exception e)
							{
								FLogger.Log(e);
							}
							FNeedsRelist = false;
						}

						lock (FMemoryPoolLock)
						{
							int imageIndex = 0;
							foreach (var image in FMemoryPool)
							{
								try
								{
									if (!image.LoadedCPU)
									{
										var bitmap = new Bitmap(image.Filename);
										image.Data = new byte[FWidth * FHeight];
										var bitmapData = bitmap.LockBits(new Rectangle(0, 0, FWidth, FHeight), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
										Exception e3 = null;
										try
										{
											byte* input = (byte*)bitmapData.Scan0;
											fixed (byte* outputFixed = &image.Data[0])
											{
												byte* output = outputFixed;
												for (int i = 0; i < FWidth * FHeight; i++)
												{
													input++; //a

													int pixelData = 0;
													pixelData += *input++;
													pixelData += *input++;
													pixelData += *input++;

													*output++ = (byte)(pixelData / 3);
												}
											}

											image.LoadedCPU = true;
										}
										catch (Exception e2)
										{
											e3 = e2;
										}
										finally
										{
											bitmap.UnlockBits(bitmapData);
										}
										if (e3 != null)
										{
											throw (e3);
										}
										//we've done enough work for this cycle
										break;
									}

									lock (FTexturePoolLock)
									{
										foreach (var resourcePool in FTexturePool)
										{
											lock(FLockCreation)// make sure all threads don't go crazy at the same time
											{
												var context = resourcePool.Key;
												var texturePool = resourcePool.Value.FTextures;
												if (texturePool.Count <= imageIndex)
												{
													var texture = new DX11DynamicTexture2D(context, FWidth, FHeight, SlimDX.DXGI.Format.R8_UNorm);

													GCHandle pinnedArray = GCHandle.Alloc(image.Data, GCHandleType.Pinned);
													IntPtr pointer = pinnedArray.AddrOfPinnedObject();
													texture.WriteDataPitch(pointer, image.Data.Length, FWidth);
													pinnedArray.Free();

													texturePool.Add(texture);
												}
											}
											//we've done enough work for this cycle
											break;
										}
									}
								}
								catch (Exception e)
								{
									FLogger.Log(e);
								}
								imageIndex++;
							}
						}
					}
					catch(Exception e)
					{

					}
					Thread.Sleep(10);
				}
			}
Example #21
0
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteData<byte>(this.colorimage);
 }
 protected override void CopyData(DX11DynamicTexture2D texture)
 {
     texture.WriteDataStride(this.rawdepth);
 }