示例#1
0
        public void OnWindowResize(DXManager dxman)
        {
            DisposeBuffers();

            var device = dxman.device;



            int uw = Width = dxman.backbuffer.Description.Width * SSAASampleCount;
            int uh = Height = dxman.backbuffer.Description.Height * SSAASampleCount;

            Viewport          = new ViewportF();
            Viewport.Width    = (float)uw;
            Viewport.Height   = (float)uh;
            Viewport.MinDepth = 0.0f;
            Viewport.MaxDepth = 1.0f;
            Viewport.X        = 0.0f;
            Viewport.Y        = 0.0f;


            GBuffers             = new GpuMultiTexture(device, uw, uh, 4, Format.R8G8B8A8_UNorm, true, Format.D32_Float, MSAASampleCount);
            WindowSizeVramUsage += GBuffers.VramUsage;

            SceneColour          = new GpuTexture(device, uw, uh, Format.R32G32B32A32_Float, 1, 0, true, Format.D32_Float);
            WindowSizeVramUsage += SceneColour.VramUsage;
        }
示例#2
0
        public void OnWindowResize(DXManager dxman)
        {
            DisposeBuffers();

            var device = dxman.device;


            int sc = dxman.multisamplecount;
            int sq = dxman.multisamplequality;

            Multisampled = (sc > 1);

            int uw = Width = dxman.backbuffer.Description.Width;
            int uh = Height = dxman.backbuffer.Description.Height;

            Viewport          = new ViewportF();
            Viewport.Width    = (float)uw;
            Viewport.Height   = (float)uh;
            Viewport.MinDepth = 0.0f;
            Viewport.MaxDepth = 1.0f;
            Viewport.X        = 0.0f;
            Viewport.Y        = 0.0f;


            Format f  = Format.R32G32B32A32_Float;
            Format df = Format.D32_Float;


            Primary              = new GpuTexture(device, uw, uh, f, sc, sq, true, df);
            WindowSizeVramUsage += Primary.VramUsage;


            int rc = (int)(Math.Ceiling(uw / 8.0f) * Math.Ceiling(uh / 8.0f));

            Reduction0           = new GpuBuffer <float>(device, 1, rc);
            Reduction1           = new GpuBuffer <float>(device, 1, rc);
            WindowSizeVramUsage += sizeof(float) * rc * 2;

            LumBlendResult       = new GpuBuffer <float>(device, 1, 1);
            WindowSizeVramUsage += sizeof(float); //because 4 bytes matter

            int tw = uw / 8;
            int th = uh / 8;

            rc = tw * th;
            f  = Format.R8G8B8A8_UNorm;

            Bloom0 = new GpuBuffer <Vector4>(device, 1, rc);
            Bloom1 = new GpuBuffer <Vector4>(device, 1, rc);
            WindowSizeVramUsage += /*sizeof(V4F)*/ 16 * rc * 2;

            Bloom = new GpuTexture(device, tw, th, f, 1, 0, false, df);
            WindowSizeVramUsage += Bloom.VramUsage;
        }
示例#3
0
 public void DisposeBuffers()
 {
     if (GBuffers != null)
     {
         GBuffers.Dispose();
         GBuffers = null;
     }
     if (SceneColour != null)
     {
         SceneColour.Dispose();
         SceneColour = null;
     }
     WindowSizeVramUsage = 0;
 }
示例#4
0
        public void Init(Device device, int w, int h, int count, Format f, bool depth, Format df, int multisamplecount)
        {
            Count            = count;
            VramUsage        = 0;
            UseDepth         = depth;
            MultisampleCount = multisamplecount;
            Multisampled     = (multisamplecount > 1);
            ResourceUsage               u    = ResourceUsage.Default;
            BindFlags                   b    = BindFlags.RenderTarget | BindFlags.ShaderResource;
            int                         fs   = DXUtility.ElementSize(f);
            int                         wh   = w * h;
            BindFlags                   db   = BindFlags.DepthStencil | BindFlags.ShaderResource; // D3D11_BIND_DEPTH_STENCIL;
            RenderTargetViewDimension   rtvd = RenderTargetViewDimension.Texture2D;
            ShaderResourceViewDimension srvd = ShaderResourceViewDimension.Texture2D;             // D3D11_SRV_DIMENSION_TEXTURE2D;
            DepthStencilViewDimension   dsvd = DepthStencilViewDimension.Texture2D;

            if (Multisampled)
            {
                rtvd = RenderTargetViewDimension.Texture2DMultisampled;
                srvd = ShaderResourceViewDimension.Texture2DMultisampled;
                dsvd = DepthStencilViewDimension.Texture2DMultisampled;
            }

            Textures = new Texture2D[count];
            RTVs     = new RenderTargetView[count];
            SRVs     = new ShaderResourceView[count];

            for (int i = 0; i < count; i++)
            {
                Textures[i] = DXUtility.CreateTexture2D(device, w, h, 1, 1, f, multisamplecount, 0, u, b, 0, 0);
                RTVs[i]     = DXUtility.CreateRenderTargetView(device, Textures[i], f, rtvd, 0, 0, 0);
                SRVs[i]     = DXUtility.CreateShaderResourceView(device, Textures[i], f, srvd, 1, 0, 0, 0);
                VramUsage  += (wh * fs) * multisamplecount;
            }
            if (depth)
            {
                Format dtexf = GpuTexture.GetDepthTexFormat(df);
                Format dsrvf = GpuTexture.GetDepthSrvFormat(df);
                Depth      = DXUtility.CreateTexture2D(device, w, h, 1, 1, dtexf, multisamplecount, 0, u, db, 0, 0);
                DSV        = DXUtility.CreateDepthStencilView(device, Depth, df, dsvd);
                DepthSRV   = DXUtility.CreateShaderResourceView(device, Depth, dsrvf, srvd, 1, 0, 0, 0);
                VramUsage += (wh * DXUtility.ElementSize(df)) * multisamplecount;
            }
        }
示例#5
0
 public void DisposeBuffers()
 {
     if (Bloom != null)
     {
         Bloom.Dispose();
         Bloom = null;
     }
     if (Bloom0 != null)
     {
         Bloom0.Dispose();
         Bloom0 = null;
     }
     if (Bloom1 != null)
     {
         Bloom1.Dispose();
         Bloom1 = null;
     }
     if (LumBlendResult != null)
     {
         LumBlendResult.Dispose();
         LumBlendResult = null;
     }
     if (Reduction0 != null)
     {
         Reduction0.Dispose();
         Reduction0 = null;
     }
     if (Reduction1 != null)
     {
         Reduction1.Dispose();
         Reduction1 = null;
     }
     if (Primary != null)
     {
         Primary.Dispose();
         Primary = null;
     }
     WindowSizeVramUsage = 0;
 }