Beispiel #1
0
        /// <summary>Initializes a new instance of the <see cref="GraphicsBuffer" /> class.</summary>
        /// <param name="kind">The buffer kind.</param>
        /// <param name="graphicsHeap">The graphics heap on which the buffer was created.</param>
        /// <param name="offset">The offset, in bytes, of the buffer in relation to <paramref name="graphicsHeap" />.</param>
        /// <param name="size">The size, in bytes, of the buffer.</param>
        /// <param name="stride">The size, in bytes, of the elements contained by the buffer.</param>
        /// <exception cref="ArgumentNullException"><paramref name="graphicsHeap" /> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="kind" /> is <see cref="GraphicsBufferKind.Index" /> and <paramref name="stride" /> is not <c>2</c> or <c>4</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException"><paramref name="kind" /> is <see cref="GraphicsBufferKind.Staging" /> and <paramref name="graphicsHeap" /> is not <see cref="GraphicsHeapCpuAccess.Write" />.</exception>
        protected GraphicsBuffer(GraphicsBufferKind kind, GraphicsHeap graphicsHeap, ulong offset, ulong size, ulong stride)
            : base(graphicsHeap, offset, size)
        {
            switch (kind)
            {
            case GraphicsBufferKind.Index:
            {
                if ((stride != 2) && (stride != 4))
                {
                    ThrowArgumentOutOfRangeException(nameof(stride), stride);
                }
                break;
            }

            case GraphicsBufferKind.Staging:
            {
                if (graphicsHeap.CpuAccess != GraphicsHeapCpuAccess.Write)
                {
                    ThrowArgumentOutOfRangeException(nameof(graphicsHeap), graphicsHeap);
                }
                break;
            }
            }

            _stride = stride;
            _kind   = kind;
        }
Beispiel #2
0
 /// <summary>Initializes a new instance of the <see cref="GraphicsTexture" /> class.</summary>
 /// <param name="kind">The texture kind.</param>
 /// <param name="graphicsHeap">The graphics heap on which the texture was created.</param>
 /// <param name="offset">The offset, in bytes, of the texture in relation to <paramref name="graphicsHeap" />.</param>
 /// <param name="size">The size, in bytes, of the texture.</param>
 /// <param name="width">The width, in pixels, of the texture.</param>
 /// <param name="height">The height, in pixels, of the texture.</param>
 /// <param name="depth">The depth, in pixels, of the texture.</param>
 /// <exception cref="ArgumentNullException"><paramref name="graphicsHeap" /> is <c>null</c>.</exception>
 protected GraphicsTexture(GraphicsTextureKind kind, GraphicsHeap graphicsHeap, ulong offset, ulong size, ulong width, uint height, ushort depth)
     : base(graphicsHeap, offset, size)
 {
     _width  = width;
     _height = height;
     _depth  = depth;
     _kind   = kind;
 }
Beispiel #3
0
        /// <summary>Initializes a new instance of the <see cref="GraphicsResource" /> class.</summary>
        /// <param name="graphicsHeap">The graphics heap on which the resource was created.</param>
        /// <param name="offset">The offset, in bytes, of the resource in relation to <paramref name="graphicsHeap" />.</param>
        /// <param name="size">The size, in bytes, of the resource.</param>
        /// <exception cref="ArgumentNullException"><paramref name="graphicsHeap" /> is <c>null</c>.</exception>
        private protected GraphicsResource(GraphicsHeap graphicsHeap, ulong offset, ulong size)
        {
            ThrowIfNull(graphicsHeap, nameof(graphicsHeap));

            _graphicsHeap = graphicsHeap;
            _offset       = offset;
            _size         = size;
        }