Пример #1
0
        public GpuTexture2D(
            Size size,
            GpuPixelFormat pixelFormat,
            GpuDevice device,
            GpuResourceInfo resourceInfo) :
            base(device, size.Width * size.Height * GpuConvert.SizeOfInBytes(pixelFormat), resourceInfo)
        {
            Size        = new Size(size.Width, size.Height);
            PixelFormat = pixelFormat;

            mRowPitch = Size.Width * GpuConvert.SizeOfInBytes(PixelFormat);

            mResource = new SharpDX.Direct3D11.Texture2D(GpuDevice.Device, new SharpDX.Direct3D11.Texture2DDescription()
            {
                ArraySize         = 1,
                BindFlags         = GpuConvert.ToBindUsage(ResourceInfo.BindUsage),
                CpuAccessFlags    = GpuConvert.ToCpuAccessFlag(ResourceInfo.CpuAccessFlag),
                Format            = GpuConvert.ToPixelFormat(PixelFormat),
                Width             = Size.Width,
                Height            = Size.Height,
                MipLevels         = 1,
                OptionFlags       = SharpDX.Direct3D11.ResourceOptionFlags.None,
                SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
                Usage             = GpuConvert.ToHeapType(ResourceInfo.HeapType)
            });
        }
Пример #2
0
        public GpuBufferArray(
            int elementSize,
            int elementCount,
            GpuDevice device,
            GpuResourceInfo resourceInfo) : base(device, elementCount * elementSize, resourceInfo)
        {
            ElementSize  = elementSize;
            ElementCount = elementCount;

            mResource = new SharpDX.Direct3D11.Buffer(GpuDevice.Device,
                                                      new SharpDX.Direct3D11.BufferDescription()
            {
                BindFlags           = GpuConvert.ToBindUsage(ResourceInfo.BindUsage),
                CpuAccessFlags      = GpuConvert.ToCpuAccessFlag(ResourceInfo.CpuAccessFlag),
                OptionFlags         = SharpDX.Direct3D11.ResourceOptionFlags.BufferStructured,
                SizeInBytes         = SizeInBytes,
                StructureByteStride = ElementSize,
                Usage = GpuConvert.ToHeapType(ResourceInfo.HeapType)
            });
        }
Пример #3
0
        public GpuBuffer(
            int bufferSize,
            int elementSize,
            GpuDevice device,
            GpuResourceInfo resourceInfo) : base(device, bufferSize, resourceInfo)
        {
            ElementSize = elementSize;

            mResource = new SharpDX.Direct3D11.Buffer(GpuDevice.Device,
                                                      new SharpDX.Direct3D11.BufferDescription()
            {
                BindFlags           = GpuConvert.ToBindUsage(ResourceInfo.BindUsage),
                CpuAccessFlags      = GpuConvert.ToCpuAccessFlag(ResourceInfo.CpuAccessFlag),
                OptionFlags         = SharpDX.Direct3D11.ResourceOptionFlags.None,
                SizeInBytes         = SizeInBytes,
                StructureByteStride = ElementSize,
                Usage = GpuConvert.ToHeapType(ResourceInfo.HeapType)
            });

            Debug.Assert(bufferSize % elementSize == 0);
        }