public void CopyResource(FeralTic.DX11.Resources.DX11ResourceTexture2D texture) { SlimDX.Direct3D11.DeviceContext ctx = texture.Context.CurrentDeviceContext; SlimDX.DataBox db = ctx.MapSubresource(texture.WritableResource, 0, SlimDX.Direct3D11.MapMode.WriteDiscard, SlimDX.Direct3D11.MapFlags.None); bmpImage.CopyPixels(Int32Rect.Empty, db.Data.DataPointer, stride * bmpImage.PixelHeight, stride); ctx.UnmapSubresource(texture.WritableResource, 0); }
/// <summary> /// コンスタントバッファコンスタントバッファ更新 /// </summary> /// <param name="inst"></param> public void UpdateConstantBuffer() { byte[] data = cbInst_.Buffer; SlimDX.DataStream s = new SlimDX.DataStream(data, true, true); SlimDX.DataBox box = new SlimDX.DataBox(0, 0, s); GraphicsCore.D3D11ImmediateContext.UpdateSubresource(box, constantBuffer_, 0); s.Close(); }
public static string GetDebugString(DeviceContext context) { string outString = ""; if (m_GPUDebugOn) { int count = m_DebugAppendBuffer.GetAppendStructureCount(context); SlimDX.DataBox db = m_DebugAppendBuffer.LockBuffer(context); for (uint i = 0; i < count; ++i) { uint x = (uint)db.Data.Read <float>(); uint y = (uint)db.Data.Read <float>(); float z = db.Data.Read <float>(); uint compCount = (uint)db.Data.Read <float>(); float xV = db.Data.Read <float>(); float yV = db.Data.Read <float>(); float zV = db.Data.Read <float>(); float wV = db.Data.Read <float>(); if (Math.Floor((double)z) == (double)z) { outString += String.Format("pos {0,-4} {1,-4} {2,-4} || ", x, y, (uint)z); } else { outString += String.Format("pos {0,-4} {1,-4} {2,-8:F4} || ", x, y, z); } switch (compCount) { case 1: outString += String.Format("{0,-7:F4}", xV); break; case 2: outString += String.Format("{0,-7:F4} {1,-7:F4}", xV, yV); break; case 3: outString += String.Format("{0,-7:F4} {1,-7:F4} {2,-7:F4}", xV, yV, zV); break; case 4: outString += String.Format("{0,-7:F4} {1,-7:F4} {2,-7:F4} {3:F4}", xV, yV, zV, wV); break; } outString += System.Environment.NewLine; } m_DebugAppendBuffer.UnlockBuffer(context); } m_FirstCallThisFrame = true; return(outString); }
public void CopyResource(FeralTic.DX11.Resources.DX11ResourceTexture2D texture) { SlimDX.Direct3D11.DeviceContext ctx = texture.Context.CurrentDeviceContext; SlimDX.DataBox db = ctx.MapSubresource(texture.WritableResource, 0, SlimDX.Direct3D11.MapMode.WriteDiscard, SlimDX.Direct3D11.MapFlags.None); unsafe { Memory.Copy(db.Data.DataPointer, bitmapData.Scan0, (uint)(bitmapData.Stride * bitmapData.Height)); } ctx.UnmapSubresource(texture.WritableResource, 0); }
void SetupDataAndInfo() { int PageTableSizeLog2 = MathExtensions.Log2(info.PageTableSize); tabledata = new SlimDX.DataBox[PageTableSizeLog2+1]; regions = new D3D10.ResourceRegion[PageTableSizeLog2+1]; data = new SimpleImage[PageTableSizeLog2+1]; for( int i = 0; i < PageTableSizeLog2+1; ++i ) { int size = info.PageTableSize >> i; SlimDX.DataStream stream = new SlimDX.DataStream( size * size * VirtualTexture.ChannelCount, false, true ); tabledata[i] = new SlimDX.DataBox( size * VirtualTexture.ChannelCount, size * size * VirtualTexture.ChannelCount, stream ); D3D10.ResourceRegion region = new D3D10.ResourceRegion(); region.Left = 0; region.Right = size; region.Top = 0; region.Bottom = size; region.Front = 0; region.Back = 1; regions[i] = region; data[i] = new SimpleImage( size, size, VirtualTexture.ChannelCount ); } }