public bool Init(bool noPixelShader, bool noPixelWrite, EPlatformType platforms) { RName noPsShader = RName.GetRName("Shaders/ShadingEnv/Sys/NoPixelShader.shadingenv"); var rc = CEngine.Instance.RenderContext; var shaderDesc = rc.CreateShaderDesc(noPsShader, "PS_Main", EShaderType.EST_PixelShader, new CShaderDefinitions(), platforms); if (shaderDesc == null) { return(false); } var ps = rc.CreatePixelShader(shaderDesc); SDK_GraphicsProfiler_SetEmptyPixelShader(CoreObject, ps.CoreObject); if (noPixelWrite) { CFrameBuffersDesc FBDesc = new CFrameBuffersDesc(); FBDesc.IsSwapChainBuffer = vBOOL.FromBoolean(false); FBDesc.UseDSV = vBOOL.FromBoolean(false); var mFrameBuffer = rc.CreateFrameBuffers(FBDesc); if (mFrameBuffer == null) { return(false); } CTexture2DDesc TexDesc = new CTexture2DDesc(); TexDesc.Init(); TexDesc.Width = 1; TexDesc.Height = 1; TexDesc.Format = EPixelFormat.PXF_R8G8B8A8_UNORM; TexDesc.BindFlags = (UInt32)(EBindFlags.BF_SHADER_RES | EBindFlags.BF_RENDER_TARGET); var Tex2D = rc.CreateTexture2D(TexDesc); CShaderResourceViewDesc SRVDesc = new CShaderResourceViewDesc(); SRVDesc.mTexture2D = Tex2D.CoreObject; var SRV = rc.CreateShaderResourceView(SRVDesc); mFrameBuffer.BindSRV_RT((UInt32)0, SRV); CRenderTargetViewDesc RTVDesc = new CRenderTargetViewDesc(); RTVDesc.mTexture2D = Tex2D.CoreObject; var RTV = rc.CreateRenderTargetView(RTVDesc); mFrameBuffer.BindRenderTargetView((UInt32)0, RTV); //depth stencil view; CDepthStencilViewDesc mDSVDesc = new CDepthStencilViewDesc(); mDSVDesc.Width = 1; mDSVDesc.Height = 1; var mDepthStencilView = rc.CreateDepthStencilView(mDSVDesc); mFrameBuffer.BindDepthStencilView(mDepthStencilView); SDK_GraphicsProfiler_SetOnePixelFrameBuffers(CoreObject, mFrameBuffer.CoreObject); } NoPixelShader = noPixelShader; NoPixelWrite = noPixelWrite; return(true); }
public CFrameBuffer CreateFrameBuffers(CFrameBuffersDesc desc) { unsafe { var obj = SDK_IRenderContext_CreateFrameBuffers(CoreObject, &desc); if (obj.Pointer == IntPtr.Zero) { return(null); } return(new CFrameBuffer(obj)); } }