public void Update(DX11RenderContext context, int w, int h, SampleDescription sd)
        {
            if (this.currentmode == eDepthBufferMode.Standard)
            {
                DX11DepthStencil ds;
                if (this.NeedReset || !this.depthoutputpin.IOObject[0].Data.ContainsKey(context))
                {
                    if (this.depthoutputpin.IOObject[0] != null)
                    {
                        this.depthoutputpin.IOObject[0].Dispose(context);
                    }

                    if (sd.Count > 1)
                    {
                        if (!context.IsAtLeast101)
                        {
                            host.Log(TLogType.Warning, "Device Feature Level Needs at least 10.1 to create Multisampled Depth Buffer, rolling back to 1");
                            sd.Count = 1;
                        }
                    }

                    ds = new DX11DepthStencil(context, w, h, sd, DeviceFormatHelper.GetFormat(this.depthformatpin.IOObject[0].Name));
                    #if DEBUG
                    ds.Resource.DebugName = "DepthStencil";
                    #endif
                    this.depthoutputpin.IOObject[0][context] = ds;
                }
            }
        }
        public void Update(DX11RenderContext context)
        {
            Device device = context.Device;

            if (this.spmax == 0)
            {
                return;
            }

            if (this.updateddevices.Contains(context))
            {
                return;
            }

            if (!this.FOutTexture[0].Contains(context))
            {
                for (int i = 0; i < this.FInElementCount[0]; i++)
                {
                    var rt = new DX11RenderTarget2D(context, (int)this.FInSize[i].X, (int)this.FInSize[i].Y, new SampleDescription(1, 0), DeviceFormatHelper.GetFormat(this.FInFormat[i]), this.FInMips[i], 0, false, false);
                    this.FOutTexture[i][context] = rt;
                    if (this.FInDepthBuffer[0])
                    {
                        Format depthfmt = DeviceFormatHelper.GetFormat(this.depthformatpin[0].Name);
                        var    db       = new DX11DepthStencil(context, (int)this.FInSize[i].X, (int)this.FInSize[i].Y, new SampleDescription(1, 0), depthfmt);
                        this.FOutDepthTexture[i][context] = db;
                    }
                }
            }
            this.updateddevices.Add(context);
        }
        public void Update(DX11RenderContext context)
        {
            Device device = context.Device;

            if (this.spmax == 0)
            {
                return;
            }

            if (this.updateddevices.Contains(context))
            {
                return;
            }

            if (!this.FOutTexture[0].Contains(context))
            {
                Format depthfmt = DeviceFormatHelper.GetFormat(this.depthformatpin[0].Name);

                var result = new DX11RenderTextureArray(context, (int)this.FInSize[0].X, (int)this.FInSize[0].Y, this.FInElementCount[0], DeviceFormatHelper.GetFormat(this.FInFormat[0]), true, this.FInMips[0] ? 0 : 1, this.FInAllowUAV[0]);
                this.FOutTexture[0][context]      = result;
                this.FOutDepthTexture[0][context] = new DX11DepthTextureArray(context, (int)this.FInSize[0].X, (int)this.FInSize[0].Y, this.FInElementCount[0], depthfmt, true);
                for (int i = 0; i < this.FInElementCount[0]; i++)
                {
                    DX11Texture2D slice = DX11Texture2D.FromTextureAndSRV(context, result.Resource, result.SliceRTV[i].SRV);
                    this.FOutSliceTextures[i][context] = slice;
                }
            }

            this.updateddevices.Add(context);
        }
Example #4
0
 public static void CreateNullDeviceFormat()
 {
     if (FNullDeviceFormats == null)
     {
         FNullDeviceFormats = new DeviceFormatHelper(NullRenderDevice.Device);
     }
 }
        protected override void OnUpdate(DX11RenderContext context)
        {
            if (this.resetbuffers || !this.FOutTexture[0].Contains(context))
            {
                this.DisposeBuffers(context);

                DX11CubeRenderTarget rt = new DX11CubeRenderTarget(context, this.size, new SampleDescription(1, 0),
                                                                   DeviceFormatHelper.GetFormat(this.FInFormat[0].Name), this.genmipmap, this.mipmaplevel);

                this.FOutTexture[0][context] = rt;
            }
        }
Example #6
0
        protected override void PreRender()
        {
            target = TexturePoolManager.GetPool(VDX11.Device).GetTempRenderTarget(
                this.width, this.height, DeviceFormatHelper.GetFormat(this.FInFormat[0]), new SampleDescription(1, 0), this.FInDoMipMaps[0], this.FInMipLevel[0]);

            if (this.FInDepthBuffer[0])
            {
                this.SetTargets(this.FDepthManager.DSV, target.RTV);
            }
            else
            {
                this.SetTargets(null, target.RTV);
            }
        }
Example #7
0
        public unsafe void Update(DX11RenderContext context)
        {
            if (this.FTextureOutput.SliceCount == 0)
            {
                return;
            }

            if (this.FInvalidate)
            {
                int index = 0;
                var data  = this.FInData[index];

                if (this.FTextureOutput[0].Contains(context))
                {
                    this.FTextureOutput[0].Dispose(context);
                }

                if (this.FInData.IsConnected && data != null)
                {
                    int width  = this.FInWidth[index];
                    int height = this.FInHeight[index];
                    var fmt    = this.FInFormat[index];

                    int pixelSize = DeviceFormatHelper.GetPixelSizeInBytes(fmt);

                    int stride = this.FInStride[index];
                    stride = stride <= 0 ? pixelSize * width : stride;

                    //Normally spread implementation, afaik , doesn't downsize the buffer
                    byteSpread.SliceCount = stride * pixelSize;

                    data.Position = this.FInDataLocation[0];
                    data.Read(byteSpread.Stream.Buffer, 0, stride * height);
                    data.Position = 0;

                    using (SlimDX.DataStream dataStream = new DataStream(byteSpread.Stream.Buffer, true, true))
                    {
                        DX11Texture2D texture = DX11Texture2D.CreateImmutable(context, width, height, fmt, stride, dataStream);
                        this.FTextureOutput[0][context] = texture;
                    }
                }
                this.FInvalidate = false;
            }
        }
Example #8
0
        protected override void OnUpdate(DX11RenderContext context)
        {
            if (this.resetbuffers || !this.FOutBuffers[0].Contains(context))
            {
                this.DisposeBuffers(context);

                for (int i = 0; i < this.FInTargetCount[0]; i++)
                {
                    DX11RenderTarget2D rt = new DX11RenderTarget2D(context, this.width, this.height,
                                                                   this.sd, DeviceFormatHelper.GetFormat(this.FInFormat[i].Name), this.genmipmap, this.mipmaplevel);

                    #if DEBUG
                    rt.Resource.DebugName = "MRTRenderTexture";
                    #endif

                    this.FOutBuffers[i][context] = rt;
                }
            }
        }
Example #9
0
        public void Update(DX11RenderContext context, int w, int h, SampleDescription sd)
        {
            if (this.currentmode == eDepthBufferMode.Standard)
            {
                DX11DepthStencil ds;
                if (this.NeedReset || !this.depthoutputpin.IOObject[0].Contains(context))
                {
                    if (this.depthoutputpin.IOObject[0] != null)
                    {
                        this.depthoutputpin.IOObject[0].Dispose(context);
                    }

                    Format depthfmt = DeviceFormatHelper.GetFormat(this.depthformatpin.IOObject[0].Name);

                    sd = this.TrySampleDescription(context, sd);

                    ds = new DX11DepthStencil(context, w, h, sd, depthfmt);
                    #if DEBUG
                    ds.Resource.DebugName = "DepthStencil";
                    #endif
                    this.depthoutputpin.IOObject[0][context] = ds;
                }
            }

            if (this.currentmode == eDepthBufferMode.WriteOnly)
            {
                DX11WriteOnlyDepthStencil ds;
                if (this.NeedReset || !this.writeOnlyDepth.Contains(context))
                {
                    this.writeOnlyDepth.Dispose(context);

                    Format depthfmt = DeviceFormatHelper.GetFormat(this.depthformatpin.IOObject[0].Name);

                    sd = this.TrySampleDescription(context, sd);

                    ds = new DX11WriteOnlyDepthStencil(context, w, h, sd, depthfmt);
                    this.writeOnlyDepth[context] = ds;
                }
            }
        }
Example #10
0
        private SampleDescription TrySampleDescription(DX11RenderContext context, SampleDescription sd)
        {
            if (sd.Count > 1)
            {
                if (!context.IsAtLeast101)
                {
                    host.Log(TLogType.Warning, "Device Feature Level Needs at least 10.1 to create Multisampled Depth Buffer, rolling back to 1");
                    sd.Count = 1;
                }
            }

            Format depthfmt = DeviceFormatHelper.GetFormat(this.depthformatpin.IOObject[0].Name);

            List <SampleDescription> sds = context.GetMultisampleFormatInfo(depthfmt);
            int maxlevels = sds[sds.Count - 1].Count;

            if (sd.Count > maxlevels)
            {
                host.Log(TLogType.Warning, "Multisample count too high for this depth format, reverted to: " + maxlevels);
                sd.Count = maxlevels;
            }

            return(sd);
        }
Example #11
0
        public void Update(DX11RenderContext context)
        {
            if (this.currentBufferCount == 0)
            {
                return;
            }

            if (this.updateddevices.Contains(context))
            {
                return;
            }
            if (this.invalidate || this.outputBuffer[0] == null)
            {
                this.DisposeBuffers(context);

                bool all           = this.FInLayoutsElementCount[0] == -1;
                int  currentOffset = 0;

                bool attachIndex = this.FAttachIndexBuffer[0];

                if (all)
                {
                    for (int index = 0; index < this.currentBufferCount; index++)
                    {
                        this.outputBuffer[index] = new StreamOutputBufferWithRawSupport(context, DeviceFormatHelper.ComputeVertexSize(this.FInVSize[index], this.FInLayouts.ToArray()), this.FInElemCount[index],
                                                                                        this.FinOutputDrawMode[index], attachIndex, this.FInLayouts.ToArray());
                        this.FOutSlices[index][context] = this.outputBuffer[index].VertexGeometry;
                        this.FOutBuffer[index][context] = this.outputBuffer[index].RawBuffer;
                        if (!attachIndex)
                        {
                            this.FOutput[index][context] = this.outputBuffer[index].VertexGeometry;
                        }
                    }
                }
                else
                {
                    for (int index = 0; index < this.currentBufferCount; index++)
                    {
                        int elemCount = this.FInLayoutsElementCount[index];
                        elemCount = elemCount < 0 ? this.FInLayouts.SliceCount : elemCount;

                        InputElement[] elems = new InputElement[elemCount];
                        for (int j = 0; j < elems.Length; j++)
                        {
                            elems[j] = this.FInLayouts[currentOffset++];
                        }

                        this.outputBuffer[index] = new StreamOutputBufferWithRawSupport(context, DeviceFormatHelper.ComputeVertexSize(this.FInVSize[index], elems),
                                                                                        this.FInElemCount[index], this.FinOutputDrawMode[index], attachIndex, elems);
                        this.FOutSlices[index][context] = this.outputBuffer[index].VertexGeometry;
                        this.FOutBuffer[index][context] = this.outputBuffer[index].RawBuffer;
                        if (!attachIndex)
                        {
                            this.FOutput[index][context] = this.outputBuffer[index].VertexGeometry;
                        }
                    }
                }

                if (attachIndex)
                {
                    //Construct output binding instead, as a tuple v/i from slice max
                    int mx = SpreadUtils.SpreadMax(this.FInVertexBufferBinding, this.FInIndexBufferBinding);
                    for (int i = 0; i < mx; i++)
                    {
                        var vbo = this.outputBuffer[VMath.Zmod(this.FInVertexBufferBinding[i], this.currentBufferCount)];
                        var ibo = this.outputBuffer[VMath.Zmod(this.FInIndexBufferBinding[i], this.currentBufferCount)];

                        DX11IndexedGeometry ig = new DX11IndexedGeometry(context);
                        ig.HasBoundingBox = false;
                        ig.IndexBuffer    = ibo.IndexBuffer;
                        ig.InputLayout    = vbo.VertexGeometry.InputLayout;
                        ig.Topology       = PrimitiveTopology.TriangleList;
                        ig.VertexBuffer   = vbo.D3DBuffer;
                        ig.VertexSize     = vbo.VertexGeometry.VertexSize;
                        ig.VerticesCount  = vbo.VertexGeometry.VerticesCount;

                        this.FOutput[i][context] = ig;
                    }
                }
            }

            this.updateddevices.Add(context);
        }
Example #12
0
        public TexInfo GetRenderTarget(DX11RenderContext context)
        {
            TexInfo ti = new TexInfo();

            if (this.currentmode == eRenderFormatMode.Inherit)
            {
                if (this.texinputpin.IOObject.PluginIO.IsConnected)
                {
                    DX11Texture2D t = this.texinputpin.IOObject[0][context];

                    if (t.Resource != null)
                    {
                        ti.w = t.Width;
                        ti.h = t.Height;
                        if (DX11EnumFormatHelper.NullDeviceFormats.GetAllowedFormats(FormatSupport.RenderTarget).Contains(t.Format.ToString()))
                        {
                            ti.format = t.Format;
                        }
                        else
                        {
                            ti.format = DeviceFormatHelper.GetFormat(this.FInFormat.IOObject[0]);
                        }
                    }
                    else
                    {
                        ti.w      = (int)this.FInTextureSize.IOObject[0].x;
                        ti.h      = (int)this.FInTextureSize.IOObject[0].y;
                        ti.format = DeviceFormatHelper.GetFormat(this.FInFormat.IOObject[0]);
                    }
                }
                else
                {
                    ti.w      = (int)this.FInTextureSize.IOObject[0].x;
                    ti.h      = (int)this.FInTextureSize.IOObject[0].y;
                    ti.format = DeviceFormatHelper.GetFormat(this.FInFormat.IOObject[0]);
                }
            }

            if (this.currentmode == eRenderFormatMode.InheritSize)
            {
                if (this.texinputpin.IOObject.PluginIO.IsConnected)
                {
                    DX11Texture2D t = this.texinputpin.IOObject[0][context];

                    if (t.Resource != null)
                    {
                        ti.w = t.Width;
                        ti.h = t.Height;
                    }
                    else
                    {
                        ti.w = (int)this.FInTextureSize.IOObject[0].x;
                        ti.h = (int)this.FInTextureSize.IOObject[0].y;
                    }
                }
                else
                {
                    ti.w = (int)this.FInTextureSize.IOObject[0].x;
                    ti.h = (int)this.FInTextureSize.IOObject[0].y;
                }

                ti.format = DeviceFormatHelper.GetFormat(this.FInFormat.IOObject[0]);
            }

            if (this.currentmode == eRenderFormatMode.Manual)
            {
                ti.w      = (int)this.FInTextureSize.IOObject[0].x;
                ti.h      = (int)this.FInTextureSize.IOObject[0].y;
                ti.format = DeviceFormatHelper.GetFormat(this.FInFormat.IOObject[0]);
            }

            ti.w = Convert.ToInt32((double)ti.w * this.FInTextureScale.IOObject[0].x);
            ti.h = Convert.ToInt32((double)ti.h * this.FInTextureScale.IOObject[0].y);

            return(ti);
        }
Example #13
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            Device device = context.Device;

            if (this.spmax == 0)
            {
                return;
            }

            if (this.updateddevices.Contains(context))
            {
                return;
            }

            if (!this.FOutCubeTexture[0].Contains(context))
            {
                this.FOutCubeTexture[0][context]      = new DX11CubeRenderTarget(context, this.FInSize[0], this.sd, DeviceFormatHelper.GetFormat(this.FInFormat[0].Name), false, 1);
                this.FOutCubeDepthTexture[0][context] = new DX11CubeDepthStencil(context, this.FInSize[0], this.sd, Format.D24_UNorm_S8_UInt);
            }

            this.updateddevices.Add(context);
        }
Example #14
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            if (reset || !this.FOutBuffers[0].Contains(context))
            {
                this.DisposeBuffers(context);

                DX11RenderTexture3D rt = new DX11RenderTexture3D(context, width, height, depth, DeviceFormatHelper.GetFormat(this.FInFormat[0].Name));

                this.FOutBuffers[0][context] = rt;
            }

            this.updateddevices.Add(context);
        }
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            Device device = context.Device;

            if (this.spmax == 0)
            {
                return;
            }

            if (this.updateddevices.Contains(context))
            {
                return;
            }

            if (!this.FOutTexture[0].Contains(context))
            {
                this.FOutTexture[0][context] = new DX11WriteableTexture1d(context, this.FInSize[0], DeviceFormatHelper.GetFormat(this.FInFormat[0].Name));
            }

            this.updateddevices.Add(context);
        }
Example #16
0
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            Device device = context.Device;

            if (this.spmax == 0)
            {
                return;
            }

            if (this.updateddevices.Contains(context))
            {
                return;
            }

            if (!this.FOutTexture[0].Contains(context))
            {
                this.FOutTexture[0][context]      = new DX11RenderTextureArray(context, (int)this.FInSize[0].X, (int)this.FInSize[0].Y, this.FInElementCount[0], DeviceFormatHelper.GetFormat(this.FInFormat[0]), true);
                this.FOutDepthTexture[0][context] = new DX11DepthTextureArray(context, (int)this.FInSize[0].X, (int)this.FInSize[0].Y, this.FInElementCount[0], Format.R32_Float, true);
            }

            this.updateddevices.Add(context);
        }
        public void Update(IPluginIO pin, DX11RenderContext context)
        {
            Device device = context.Device;

            if (this.spmax == 0)
            {
                return;
            }

            if (this.updateddevices.Contains(context))
            {
                return;
            }

            if (!this.FOutCubeTexture[0].Contains(context))
            {
                var cube = new DX11CubeRenderTarget(context, this.FInSize[0], this.sd, DeviceFormatHelper.GetFormat(this.FInFormat[0].Name), false, 1);
                this.FOutCubeTexture[0][context]      = cube;
                this.FOutCubeDepthTexture[0][context] = new DX11CubeDepthStencil(context, this.FInSize[0], this.sd, Format.D24_UNorm_S8_UInt);
                for (int i = 0; i < 6; i++)
                {
                    this.FOutSliceTextures[i][context] = DX11Texture2D.FromTextureAndSRV(context, cube.Resource, cube.SliceRTV[i].SRV);
                }
            }

            this.updateddevices.Add(context);
        }