Exemplo n.º 1
0
        private void PlatformSetStructuredBuffer <T>(int index, StaticBuffer <T> buffer)
            where T : struct
        {
            var deviceResource = buffer?.DeviceBuffer;

            var description = new ShaderResourceViewDescription
            {
                Shader4ComponentMapping = ComponentMappingUtility.DefaultComponentMapping(),
                Format = buffer != null
                    ? SharpDX.DXGI.Format.Unknown
                    : SharpDX.DXGI.Format.R32_UInt,
                Dimension = ShaderResourceViewDimension.Buffer,
                Buffer    =
                {
                    FirstElement        =                                      0,
                    ElementCount        = (int)(buffer?.ElementCount ?? 0),
                    StructureByteStride = (int)(buffer?.ElementSizeInBytes ?? 0),
                    Flags               = BufferShaderResourceViewFlags.None
                }
            };

            GraphicsDevice.Device.CreateShaderResourceView(
                deviceResource,
                description,
                _cbvUavSrvPoolEntry.GetCpuHandle(index));
        }
Exemplo n.º 2
0
        private void PlatformDrawIndexed(
            PrimitiveType primitiveType,
            uint indexCount,
            StaticBuffer <ushort> indexBuffer,
            uint indexBufferOffset)
        {
            _commandList.PrimitiveTopology = primitiveType.ToPrimitiveTopology();

            _commandList.SetIndexBuffer(new IndexBufferView
            {
                BufferLocation = indexBuffer.DeviceBuffer.GPUVirtualAddress,
                Format         = SharpDX.DXGI.Format.R16_UInt,
                SizeInBytes    = (int)indexBuffer.DeviceBuffer.Description.Width
            });

            _commandList.DrawIndexedInstanced(
                (int)indexCount,
                1,
                (int)indexBufferOffset,
                0,
                0);
        }