Пример #1
0
    /// <summary>Initializes the GUI for this sample.</summary>
    /// <param name="application">The hosting <see cref="Application" />.</param>
    /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
    /// <param name="windowLocation">The <see cref="Vector2" /> that defines the initial window location.</param>
    /// <param name="windowSize">The <see cref="Vector2" /> that defines the initial window client rectangle size.</param>
    public override void Initialize(Application application, TimeSpan timeout, Vector2?windowLocation, Vector2?windowSize)
    {
        base.Initialize(application, timeout, windowLocation, windowSize);

        var graphicsDevice = GraphicsDevice;

        _constantBuffer = graphicsDevice.CreateConstantBuffer(64 * 1024, GraphicsCpuAccess.Write);
        _texture2D      = graphicsDevice.CreateTexture2D(GraphicsFormat.R8G8B8A8_UNORM, 256, 256);
        _uploadBuffer   = graphicsDevice.CreateUploadBuffer(1 * 1024 * 1024);
        _vertexBuffer   = graphicsDevice.CreateVertexBuffer(64 * 1024);

        var copyCommandQueue = graphicsDevice.CopyCommandQueue;
        var copyContext      = copyCommandQueue.RentContext();

        {
            copyContext.Reset();
            {
                _trianglePrimitive = CreateTrianglePrimitive(copyContext);
            }
            copyContext.Close();
            copyContext.Execute();
        }
        copyCommandQueue.ReturnContext(copyContext);

        _uploadBuffer.DisposeAllViews();
    }
Пример #2
0
    /// <summary>Initializes the GUI for this sample.</summary>
    /// <param name="application">The hosting <see cref="Application" />.</param>
    /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
    /// <param name="windowLocation">The <see cref="Vector2" /> that defines the initial window location.</param>
    /// <param name="windowSize">The <see cref="Vector2" /> that defines the initial window client rectangle size.</param>
    public override void Initialize(Application application, TimeSpan timeout, Vector2?windowLocation, Vector2?windowSize)
    {
        base.Initialize(application, timeout, windowLocation, windowSize);

        var graphicsDevice = GraphicsDevice;

        var verticeCount = 2 * 12 * (nuint)MathF.Pow(4, _recursionDepth);

        _constantBuffer = graphicsDevice.CreateConstantBuffer(64 * 1024, GraphicsCpuAccess.Write);
        _indexBuffer    = graphicsDevice.CreateIndexBuffer(verticeCount * SizeOf <uint>());
        _texture3D      = graphicsDevice.CreateTexture3D(GraphicsFormat.R8G8B8A8_UNORM, 256, 256, 256);
        _uploadBuffer   = graphicsDevice.CreateUploadBuffer(128 * 1024 * 1024);
        _vertexBuffer   = graphicsDevice.CreateVertexBuffer(verticeCount * SizeOf <PosNormTex3DVertex>());

        var copyCommandQueue = graphicsDevice.CopyCommandQueue;
        var copyContext      = copyCommandQueue.RentContext();

        {
            copyContext.Reset();
            {
                _sierpinskiPrimitive = CreateSierpinskiPrimitive(copyContext);
            }
            copyContext.Close();
            copyContext.Execute();
        }
        copyCommandQueue.ReturnContext(copyContext);

        _uploadBuffer.DisposeAllViews();
    }
Пример #3
0
    /// <summary>Initializes the GUI for this sample.</summary>
    /// <param name="application">The hosting <see cref="Application" />.</param>
    /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
    /// <param name="windowLocation">The <see cref="Vector2" /> that defines the initial window location.</param>
    /// <param name="windowSize">The <see cref="Vector2" /> that defines the initial window client rectangle size.</param>
    public override void Initialize(Application application, TimeSpan timeout, Vector2?windowLocation, Vector2?windowSize)
    {
        base.Initialize(application, timeout, windowLocation, windowSize);

        var graphicsDevice = GraphicsDevice;

        _indexBuffer  = graphicsDevice.CreateIndexBuffer(64 * 1024);
        _uploadBuffer = graphicsDevice.CreateUploadBuffer(64 * 1024);
        _vertexBuffer = graphicsDevice.CreateVertexBuffer(64 * 1024);

        var copyCommandQueue = graphicsDevice.CopyCommandQueue;
        var copyContext      = copyCommandQueue.RentContext();

        {
            copyContext.Reset();
            {
                _quadPrimitive = CreateQuadPrimitive(copyContext);
            }
            copyContext.Close();
            copyContext.Execute();
        }
        copyCommandQueue.ReturnContext(copyContext);

        _uploadBuffer.DisposeAllViews();
    }
Пример #4
0
    /// <summary>Initializes the GUI for this sample.</summary>
    /// <param name="application">The hosting <see cref="Application" />.</param>
    /// <param name="timeout">The <see cref="TimeSpan" /> after which this sample should stop running.</param>
    /// <param name="windowLocation">The <see cref="Vector2" /> that defines the initial window location.</param>
    /// <param name="windowSize">The <see cref="Vector2" /> that defines the initial window client rectangle size.</param>
    public override void Initialize(Application application, TimeSpan timeout, Vector2?windowLocation, Vector2?windowSize)
    {
        base.Initialize(application, timeout, windowLocation, windowSize);

        var graphicsDevice = GraphicsDevice;

        _constantBuffer = graphicsDevice.CreateConstantBuffer(64 * 1024, GraphicsCpuAccess.Write);
        _uploadBuffer   = graphicsDevice.CreateUploadBuffer(64 * 1024);
        _vertexBuffer   = graphicsDevice.CreateVertexBuffer(64 * 1024);

        var copyCommandQueue = graphicsDevice.CopyCommandQueue;
        var copyContext      = copyCommandQueue.RentContext();

        {
            copyContext.Reset();
            {
                _trianglePrimitive               = CreateInstancedTrianglePrimitive(copyContext, InstanceCount);
                _trianglePrimitiveTransforms     = new UnmanagedArray <AffineTransform>(InstanceCount);
                _trianglePrimitivePerSecondDelta = new UnmanagedArray <AffineTransform>(InstanceCount);

                var triangleTransform = AffineTransform.Identity;

                for (var index = 0u; index < InstanceCount; index++)
                {
                    triangleTransform.Translation = Vector3.Create(
                        GetRandomInBoundsSingle(),
                        GetRandomInBoundsSingle(),
                        0.0f
                        );

                    _trianglePrimitiveTransforms[index] = triangleTransform;

                    triangleTransform.Translation = Vector3.Create(
                        GetRandomInBoundsSingle(),
                        GetRandomInBoundsSingle(),
                        0.0f
                        );

                    triangleTransform.Scale = Vector3.One;

                    triangleTransform.Rotation = Quaternion.CreateFromAxisAngle(
                        Vector3.Create(GetRandomInBoundsSingle(), GetRandomInBoundsSingle(), 0.0f),
                        _rng.NextSingle()
                        );

                    _trianglePrimitivePerSecondDelta[index] = triangleTransform;
                }
            }
            copyContext.Close();
            copyContext.Execute();
        }
        copyCommandQueue.ReturnContext(copyContext);

        _uploadBuffer.DisposeAllViews();
    }