public static DX11RawBuffer CreateStaging(DX11RawBuffer buffer) { BufferDescription bd = buffer.Description; bd.CpuAccessFlags = CpuAccessFlags.Read | CpuAccessFlags.Write; bd.OptionFlags = ResourceOptionFlags.None; bd.Usage = ResourceUsage.Staging; bd.BindFlags = BindFlags.None; return(new DX11RawBuffer(buffer.device, bd, IntPtr.Zero, false)); }
public static DX11IndexBuffer CreateFromRawBuffer(DxDevice device, DX11RawBuffer rawbuffer) { if (!rawbuffer.Description.BindFlags.HasFlag(BindFlags.IndexBuffer)) { throw new ArgumentException("RawBuffer was not created with IndexBuffer bind flags"); } int indicescount = rawbuffer.Size / 4; DX11IndexBuffer result = new DX11IndexBuffer(device, indicescount, rawbuffer.Buffer); return(result); }
public void Update(IPluginIO pin, DX11RenderContext context) { Device device = context.Device; DeviceContext ctx = context.CurrentDeviceContext; if (!this.FOutBuffer[0].Contains(context)) { DX11RawBuffer rb = new DX11RawBuffer(device, 16); this.FOutBuffer[0][context] = rb; } if (this.FInBuffer.IsConnected) { UnorderedAccessView uav = this.FInBuffer[0][context].UAV; ctx.CopyStructureCount(uav, this.FOutBuffer[0][context].Buffer, 0); } }
public void Update(IPluginIO pin, DX11RenderContext context) { if (this.updateddevices.Contains(context)) { return; } if (reset || !this.FOutBuffers[0].Contains(context)) { this.DisposeBuffers(context); DX11RawBuffer rb = new DX11RawBuffer(context.Device, this.size, this.flags); this.FOutBuffers[0][context] = rb; } this.updateddevices.Add(context); }
public void Update(IPluginIO pin, DX11RenderContext context) { if (this.FInvalidate || this.FEmpty) { for (int i = 0; i < this.scenes.Count; i++) { if (scenes[i] != null) { AssimpScene scene = scenes[i]; for (int j = 0; j < scene.MeshCount; j++) { AssimpMesh assimpmesh = scene.Meshes[j]; List<int> inds = assimpmesh.Indices; if (inds.Count > 0 && assimpmesh.VerticesCount > 0) { var indexstream = new DataStream(inds.Count * 4, true, true); indexstream.WriteRange(inds.ToArray()); indexstream.Position = 0; DX11IndexOnlyGeometry geom = new DX11IndexOnlyGeometry(context); geom.IndexBuffer = new DX11IndexBuffer(context, indexstream, false, true); geom.InputLayout = assimpmesh.GetInputElements().ToArray(); geom.Topology = PrimitiveTopology.TriangleList; geom.HasBoundingBox = true; geom.BoundingBox = assimpmesh.BoundingBox; DX11DynamicStructuredBuffer<Vector3> p = new DX11DynamicStructuredBuffer<Vector3>(context, assimpmesh.PositionPointer, assimpmesh.VerticesCount); DX11DynamicStructuredBuffer<Vector3> n = new DX11DynamicStructuredBuffer<Vector3>(context, assimpmesh.NormalsPointer, assimpmesh.VerticesCount); if (assimpmesh.UvChannelCount > 0) { DX11DynamicStructuredBuffer<Vector3> u = new DX11DynamicStructuredBuffer<Vector3>(context, assimpmesh.GetUvPointer(0), assimpmesh.VerticesCount); this.FOutUvs[i][j][context] = u; } DX11RawBuffer rb = new DX11RawBuffer(context, geom.IndexBuffer.Buffer); this.FOutPosition[i][j][context] = p; this.FOutNormals[i][j][context] = n; this.FOutGeom[i][j][context] = geom; this.FOutIndices[i][j][context] = rb; } } } } this.FInvalidate = false; this.FEmpty = false; } }
public static DX11VertexBuffer CreateFromRawBuffer(DxDevice device, int verticesCount, int vertexSize, DX11RawBuffer buffer) { if (!buffer.Description.BindFlags.HasFlag(BindFlags.VertexBuffer)) { throw new ArgumentException("Raw Buffer does not have Vertex Buffer Bind flag"); } DX11VertexBuffer vbo = new DX11VertexBuffer(device); vbo.Buffer = buffer.Buffer; vbo.desc = buffer.Description; vbo.VertexSize = vertexSize; vbo.VerticesCount = verticesCount; return(vbo); }
public void Update(IPluginIO pin, DX11RenderContext context) { if (this.FOutGeom.SliceCount == 0) { return; } if (this.generateShader == null) { this.generateShader = ShaderUtils.GetShader(context, "GenerateDispatch1D"); this.dispatchBuffer = new DispatchIndirectBuffer(context); this.countBuffer = new DX11RawBuffer(context.Device, 16); } if (!this.FOutGeom[0].Contains(context)) { this.indirectDispatch = new DX11NullIndirectDispatcher(); this.indirectDispatch.IndirectArgs = this.dispatchBuffer; DX11NullGeometry nullgeom = new DX11NullGeometry(context); nullgeom.AssignDrawer(this.indirectDispatch); this.FOutGeom[0][context] = nullgeom; this.FOutCounter[0][context] = this.dispatchBuffer.RWBuffer; } var countuav = this.FInArgBuffer[0][context]; context.CurrentDeviceContext.CopyStructureCount(countuav.UAV, this.countBuffer.Buffer, 0); this.generateShader.SetBySemantic("WARPSIZE", this.FInWarpX[0]); this.generateShader.SetBySemantic("COUNTERBUFFER", this.countBuffer.SRV); this.generateShader.SetBySemantic("RWDISPATCHBUFFER", this.dispatchBuffer.UAV); this.generateShader.ApplyPass(0); context.CurrentDeviceContext.Dispatch(1, 1, 1); this.generateShader.CleanUp(); this.dispatchBuffer.UpdateBuffer(); }
private void CheckBufferSupport() { try { DX11RawBuffer raw = new DX11RawBuffer(this.Device, 16); raw.Dispose(); this.computesupport = true; } catch { this.computesupport = false; } }