public void Apply(CommonShaderStage stage)
 {
     standardSamplers.Apply(stage);
     stage.SetConstantBuffer(ShaderSlots.EnvironmentParameters, constantBufferManager.Buffer);
     stage.SetShaderResource(ShaderSlots.DiffuseEnvironmentCube, diffuseEnvironmentCube);
     stage.SetShaderResource(ShaderSlots.GlossyEnvironmentCube, glossyEnvironmentCube);
 }
    private CommandList RecordDrawCommandList()
    {
        DeviceContext context = deferredContext;

        standardSamplers.Apply(context.PixelShader);
        context.VertexShader.SetConstantBuffer(0, viewProjectionTransformBufferManager.Buffer);

        passController.RenderAllPases(context, pass => scene.RenderPass(context, pass));

        return(context.FinishCommandList(false));
    }
    public void Display(Texture2D sourceTexture, Matrix sourceProjectionMatrix, Action renderUi)
    {
        var context = device.ImmediateContext;

        float sourceAspectRatio = sourceProjectionMatrix.M22 / sourceProjectionMatrix.M11;

        aspectRatiosBufferManager.Update(context, new AspectRatios {
            companionWindowAspectRatio = aspectRatio,
            sourceAspectRatio          = sourceAspectRatio
        });

        context.ClearState();
        context.Rasterizer.SetViewport(viewport);
        context.OutputMerger.SetRenderTargets(backBufferView);

        context.InputAssembler.PrimitiveTopology = PrimitiveTopology.TriangleStrip;
        context.VertexShader.Set(copyFromSourceVertexShader);
        context.VertexShader.SetConstantBuffer(0, aspectRatiosBufferManager.Buffer);

        context.PixelShader.Set(copyFromSourcePixelShader);
        standardSamplers.Apply(context.PixelShader);
        using (var sourceView = new ShaderResourceView(device, sourceTexture)) {
            context.PixelShader.SetShaderResource(0, sourceView);
        }

        context.Draw(4, 0);

        context.OutputMerger.SetBlendState(uiBlendState);
        renderUi();
        if (shareHmdView)
        {
            overlay.Draw(context);
        }

        swapChain.Present(0, 0);
    }