示例#1
0
        public override void UpdateSurface(CommandList commandList, Texture texture)
        {
            OculusOvr.SetQuadLayerParams(OverlayPtr, ref Position, ref Rotation, ref SurfaceSize, FollowHeadRotation);
            var index = OculusOvr.GetCurrentQuadLayerTargetIndex(ovrSession, OverlayPtr);

            commandList.Copy(texture, textures[index]);
        }
示例#2
0
        public override void Commit(CommandList commandList, Texture renderFrame)
        {
            var index = OculusOvr.GetCurrentTargetIndex(ovrSession);

            commandList.Copy(renderFrame, textures[index]);
            overlayPtrs = overlays.Where(x => x.Enabled).Select(x => x.OverlayPtr).ToArray();
            OculusOvr.CommitFrame(ovrSession, overlayPtrs.Length, overlayPtrs);
        }
示例#3
0
 public override void EndDraw(CommandList commandList, bool present)
 {
 }
示例#4
0
 /// <summary>
 /// Copies the content an array of data on CPU memory to this buffer into GPU memory.
 /// </summary>
 /// <typeparam name="TData">The type of the T data.</typeparam>
 /// <param name="device">The <see cref="GraphicsDevice"/>.</param>
 /// <param name="fromData">The data to copy from.</param>
 /// <param name="offsetInBytes">The offset in bytes to write to.</param>
 /// <exception cref="System.ArgumentException"></exception>
 /// <remarks>
 /// See the unmanaged documentation about Map/UnMap for usage and restrictions.
 /// </remarks>
 public unsafe void SetData <TData>(CommandList commandList, TData[] fromData, int offsetInBytes = 0) where TData : struct
 {
     SetData(commandList, new DataPointer(Interop.Fixed(fromData), (fromData.Length * Utilities.SizeOf <TData>())), offsetInBytes);
 }
示例#5
0
 public override void BeginDraw(CommandList commandList)
 {
     // Backbuffer needs to be cleared
     backbuffer.IsInitialized = false;
 }
示例#6
0
 /// <summary>
 /// Draws a quad. The effect must have been applied before calling this method with pixel shader having the signature float2:TEXCOORD.
 /// </summary>
 /// <param name="texture"></param>
 public void Draw(CommandList commandList)
 {
     commandList.SetVertexBuffer(0, sharedData.VertexBuffer.Buffer, sharedData.VertexBuffer.Offset, sharedData.VertexBuffer.Stride);
     commandList.Draw(QuadCount);
 }
示例#7
0
 /// <summary>
 /// Copies the content of this buffer from GPU memory to an array of data on CPU memory using a specific staging resource.
 /// </summary>
 /// <typeparam name="TData">The type of the T data.</typeparam>
 /// <param name="stagingTexture">The staging buffer used to transfer the buffer.</param>
 /// <param name="toData">To data.</param>
 /// <exception cref="System.ArgumentException">When strides is different from optimal strides, and TData is not the same size as the pixel format, or Width * Height != toData.Length</exception>
 /// <remarks>
 /// This method is only working when called from the main thread that is accessing the main <see cref="GraphicsDevice"/>.
 /// </remarks>
 public unsafe void GetData <TData>(CommandList commandList, Buffer stagingTexture, TData[] toData) where TData : struct
 {
     GetData(commandList, stagingTexture, new DataPointer(Interop.Fixed(toData), toData.Length * Utilities.SizeOf <TData>()));
 }
示例#8
0
 private void InitializePostFeatures()
 {
     // Create the main command list
     InternalMainCommandList = new CommandList(this);
 }
 public override void BeginDraw(CommandList commandList)
 {
 }
示例#10
0
        internal void Apply(CommandList commandList, PipelineState previousPipeline)
        {
            var nativeDeviceContext = commandList.NativeDeviceContext;

            if (rootSignature != previousPipeline.rootSignature)
            {
                //rootSignature.Apply
            }

            if (effectBytecode != previousPipeline.effectBytecode)
            {
                if (computeShader != previousPipeline.computeShader)
                {
                    nativeDeviceContext.ComputeShader.Set(computeShader);
                }
                if (vertexShader != previousPipeline.vertexShader)
                {
                    nativeDeviceContext.VertexShader.Set(vertexShader);
                }
                if (pixelShader != previousPipeline.pixelShader)
                {
                    nativeDeviceContext.PixelShader.Set(pixelShader);
                }
                if (hullShader != previousPipeline.hullShader)
                {
                    nativeDeviceContext.HullShader.Set(hullShader);
                }
                if (domainShader != previousPipeline.domainShader)
                {
                    nativeDeviceContext.DomainShader.Set(domainShader);
                }
                if (geometryShader != previousPipeline.geometryShader)
                {
                    nativeDeviceContext.GeometryShader.Set(geometryShader);
                }
            }

            if (blendState != previousPipeline.blendState || sampleMask != previousPipeline.sampleMask)
            {
                nativeDeviceContext.OutputMerger.SetBlendState(blendState, nativeDeviceContext.OutputMerger.BlendFactor, sampleMask);
            }

            if (rasterizerState != previousPipeline.rasterizerState)
            {
                nativeDeviceContext.Rasterizer.State = rasterizerState;
            }

            if (depthStencilState != previousPipeline.depthStencilState)
            {
                nativeDeviceContext.OutputMerger.DepthStencilState = depthStencilState;
            }

            if (inputLayout != previousPipeline.inputLayout)
            {
                nativeDeviceContext.InputAssembler.InputLayout = inputLayout;
            }

            if (primitiveTopology != previousPipeline.primitiveTopology)
            {
                nativeDeviceContext.InputAssembler.PrimitiveTopology = primitiveTopology;
            }
        }
示例#11
0
        private void ForEachGlyph <T>(CommandList commandList, ref StringProxy text, ref Vector2 requestedFontSize, GlyphAction <T> action, ref T parameters,
                                      TextAlignment scanOrder, TextVerticalAlignment vertAlign, bool updateGpuResources, Vector2?textBoxSize = null, float lineSpaceAdjustment = 0f)
        {
            float rawYSpacing = GetTotalLineSpacing(requestedFontSize.Y);
            float yStart, ySpacing = rawYSpacing + lineSpaceAdjustment;

            if (textBoxSize.HasValue && vertAlign != TextVerticalAlignment.Top)
            {
                int   extraLines = text.LineCount - 1;
                float lineHeight = rawYSpacing + extraLines * ySpacing;
                switch (vertAlign)
                {
                default:
                case TextVerticalAlignment.Center:
                    yStart = textBoxSize.Value.Y * 0.5f - (lineHeight * 0.5f);
                    break;

                case TextVerticalAlignment.Bottom:
                    yStart = textBoxSize.Value.Y - lineHeight;
                    break;
                }
            }
            else
            {
                yStart = 0f;
            }

            // prepare color tag stack, if needed
            Stack <Color4> colorstack = null;

            if (scanOrder == TextAlignment.Left)
            {
                // scan the whole text only one time following the text letter order
                ForGlyph(commandList, ref text, ref requestedFontSize, action, ref parameters, 0, text.Length, updateGpuResources, ref colorstack, 0f, yStart, vertAlign, ySpacing);
            }
            else
            {
                // scan the text line by line incrementing y start position

                // measure the whole string in order to be able to determine xStart
                var wholeSize = textBoxSize ?? MeasureString(ref text, ref requestedFontSize);

                // scan the text line by line
                var startIndex = 0;
                var endIndex   = FindCariageReturn(ref text, 0);
                while (startIndex < text.Length)
                {
                    // measure the size of the current line
                    var lineSize = Vector2.Zero;
                    ForGlyph(commandList, ref text, ref requestedFontSize, MeasureStringGlyph, ref lineSize, startIndex, endIndex, updateGpuResources, ref colorstack, 0f, 0f, vertAlign, ySpacing, true);

                    // Determine the start position of the line along the x axis
                    // We round this value to the closest integer to force alignment of all characters to the same pixels
                    // Otherwise the starting offset can fall just in between two pixels and due to float imprecision
                    // some characters can be aligned to the pixel before and others to the pixel after, resulting in gaps and character overlapping
                    var xStart = (scanOrder == TextAlignment.Center) ? (wholeSize.X - lineSize.X) / 2 : wholeSize.X - lineSize.X;
                    xStart = (float)Math.Round(xStart);

                    // scan the line
                    ForGlyph(commandList, ref text, ref requestedFontSize, action, ref parameters, startIndex, endIndex, updateGpuResources, ref colorstack, xStart, yStart, vertAlign, ySpacing);

                    // update variable before going to next line
                    yStart    += ySpacing;
                    startIndex = endIndex + 1;
                    endIndex   = FindCariageReturn(ref text, startIndex);
                }
            }
        }
示例#12
0
 /// <summary>
 /// Return the glyph associated to provided character at the given size.
 /// </summary>
 /// <param name="commandList">The command list in case we upload gpu resources</param>
 /// <param name="character">The character we want the glyph of</param>
 /// <param name="fontSize">The font size in pixel</param>
 /// <param name="uploadGpuResources">Indicate if the GPU resource should be uploaded or not.</param>
 /// <param name="auxiliaryScaling">If the requested font size isn't available, the closest one is chosen and an auxiliary scaling is returned</param>
 /// <returns>The glyph corresponding to the request or null if not existing</returns>
 protected virtual Glyph GetGlyph(CommandList commandList, char character, ref Vector2 fontSize, bool uploadGpuResources, out Vector2 auxiliaryScaling)
 {
     auxiliaryScaling = Vector2.One;
     return(null);
 }