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]); }
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); }
public void Apply(CommandList commandList) { var GL = commandList.GL; #if !STRIDE_GRAPHICS_API_OPENGLES if (commandList.RasterizerBoundState.PolygonMode != State.PolygonMode) { commandList.RasterizerBoundState.PolygonMode = State.PolygonMode; GL.PolygonMode(MaterialFace.FrontAndBack, State.PolygonMode); } #endif if (commandList.RasterizerBoundState.DepthBias != State.DepthBias || commandList.RasterizerBoundState.SlopeScaleDepthBias != State.SlopeScaleDepthBias) { commandList.RasterizerBoundState.DepthBias = State.DepthBias; commandList.RasterizerBoundState.SlopeScaleDepthBias = State.SlopeScaleDepthBias; GL.PolygonOffset(State.DepthBias, State.SlopeScaleDepthBias); } if (commandList.RasterizerBoundState.FrontFaceDirection != State.FrontFaceDirection) { commandList.RasterizerBoundState.FrontFaceDirection = State.FrontFaceDirection; GL.FrontFace(State.FrontFaceDirection); } if (commandList.GraphicsDevice.HasDepthClamp) { if (commandList.RasterizerBoundState.DepthClamp != State.DepthClamp) { commandList.RasterizerBoundState.DepthClamp = State.DepthClamp; if (State.DepthClamp) { GL.Enable(EnableCap.DepthClamp); } else { GL.Disable(EnableCap.DepthClamp); } } } if (commandList.RasterizerBoundState.NeedCulling != State.NeedCulling) { commandList.RasterizerBoundState.NeedCulling = State.NeedCulling; if (State.NeedCulling) { GL.Enable(EnableCap.CullFace); } else { GL.Disable(EnableCap.CullFace); } } if (commandList.RasterizerBoundState.CullMode != State.CullMode) { commandList.RasterizerBoundState.CullMode = State.CullMode; GL.CullFace(State.CullMode); } if (commandList.RasterizerBoundState.ScissorTestEnable != State.ScissorTestEnable) { commandList.RasterizerBoundState.ScissorTestEnable = State.ScissorTestEnable; if (State.ScissorTestEnable) { GL.Enable(EnableCap.ScissorTest); } else { GL.Disable(EnableCap.ScissorTest); } } }
public override void BeginDraw(CommandList commandList) { }
public override void EndDraw(CommandList commandList, bool present) { }
/// <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); }
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; } }
private Vector3 GetCurrentResolution(CommandList commandList) { return(VirtualResolution.HasValue ? VirtualResolution.Value : new Vector3(commandList.Viewport.Width, commandList.Viewport.Height, DefaultDepth)); }
private void UpdateDefaultProjectionMatrix(CommandList commandList) { var resolution = GetCurrentResolution(commandList); CalculateDefaultProjection(ref resolution, out defaultProjectionMatrix); }
/// <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); }
/// <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>())); }
public override void BeginDraw(CommandList commandList) { // Backbuffer needs to be cleared backbuffer.IsInitialized = false; }