public static Convert ( BlendOp op ) : BlendOperation | ||
op | BlendOp | |
리턴 | BlendOperation |
/// <summary> /// /// </summary> /// <param name="structureStride"></param> /// <param name="structureCount"></param> void Create(GraphicsDevice device, VertexFormat format, int elementsCount, StructuredBufferFlags flags) { Capacity = elementsCount; Stride = Converter.SizeOf(format); Width = elementsCount; Height = 0; Depth = 0; // create staging buffer : var bufferDesc = new BufferDescription { BindFlags = BindFlags.None, Usage = ResourceUsage.Staging, CpuAccessFlags = CpuAccessFlags.Write | CpuAccessFlags.Read, OptionFlags = ResourceOptionFlags.None, SizeInBytes = Capacity * Stride, }; bufferStaging = new Buffer(device.Device, bufferDesc); // create count buffer : bufferDesc = new BufferDescription { BindFlags = BindFlags.None, Usage = ResourceUsage.Staging, CpuAccessFlags = CpuAccessFlags.Write | CpuAccessFlags.Read, OptionFlags = ResourceOptionFlags.None, SizeInBytes = 4, }; bufferCount = new Buffer(device.Device, bufferDesc); // create GPU buffer : bufferDesc = new BufferDescription { BindFlags = BindFlags.UnorderedAccess | BindFlags.ShaderResource, Usage = ResourceUsage.Default, CpuAccessFlags = CpuAccessFlags.None, OptionFlags = ResourceOptionFlags.None, SizeInBytes = Capacity * Stride, }; bufferGpu = new Buffer(device.Device, bufferDesc); var uavFlag = UnorderedAccessViewBufferFlags.None; if (flags == StructuredBufferFlags.None) { uavFlag = UnorderedAccessViewBufferFlags.None; } if (flags == StructuredBufferFlags.Append) { uavFlag = UnorderedAccessViewBufferFlags.Append; } if (flags == StructuredBufferFlags.Counter) { uavFlag = UnorderedAccessViewBufferFlags.Counter; } // create UAV : var uavDesc = new UnorderedAccessViewDescription { Format = Converter.Convert(format), Dimension = UnorderedAccessViewDimension.Buffer, Buffer = new UnorderedAccessViewDescription.BufferResource { ElementCount = Capacity, FirstElement = 0, Flags = uavFlag } }; uav = new UnorderedAccessView(device.Device, BufferGPU, uavDesc); // create SRV : var srvDesc = new ShaderResourceViewDescription { Format = Converter.Convert(format), Buffer = { ElementCount = Capacity, FirstElement = 0 }, Dimension = ShaderResourceViewDimension.Buffer }; SRV = new ShaderResourceView(device.Device, BufferGPU, srvDesc); }
/// <summary> /// Creates texture /// </summary> /// <param name="device"></param> public Texture2D(GraphicsDevice device, int width, int height, ColorFormat format, int mipCount, bool srgb) : base(device) { this.Width = width; this.Height = height; this.Depth = 1; this.format = format; this.mipCount = mipCount; var texDesc = new Texture2DDescription(); texDesc.ArraySize = 1; texDesc.BindFlags = BindFlags.ShaderResource; texDesc.CpuAccessFlags = CpuAccessFlags.None; texDesc.Format = srgb ? MakeSRgb(Converter.Convert(format)) : Converter.Convert(format); texDesc.Height = Height; texDesc.MipLevels = mipCount; texDesc.OptionFlags = ResourceOptionFlags.None; texDesc.SampleDescription.Count = 1; texDesc.SampleDescription.Quality = 0; texDesc.Usage = ResourceUsage.Default; texDesc.Width = Width; lock (device.DeviceContext) { tex2D = new D3D.Texture2D(device.Device, texDesc); SRV = new ShaderResourceView(device.Device, tex2D); } }
/// <summary> /// /// </summary> /// <param name="source"></param> /// <param name="destination"></param> public void Resolve(RenderTargetSurface source, RenderTargetSurface destination) { if (source.Width != destination.Width || source.Height != destination.Height) { throw new GraphicsException("Could not resolve: source and destination are not the same size"); } if (source.SampleCount <= 1) { throw new GraphicsException("Could not resolve: source surface is not multisampled"); } if (destination.SampleCount > 1) { throw new GraphicsException("Could not resolve: destination surface is multisampled"); } lock (deviceContext) { deviceContext.ResolveSubresource(source.Resource, source.Subresource, destination.Resource, destination.Subresource, Converter.Convert(source.Format)); } }