示例#1
0
        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);
        }
示例#2
0
 public CTexture2D CreateTexture2D(CTexture2DDesc desc)
 {
     unsafe
     {
         var obj = SDK_IRenderContext_CreateTexture2D(CoreObject, &desc);
         if (obj.Pointer == IntPtr.Zero)
         {
             return(null);
         }
         return(new CTexture2D(obj));
     }
 }