Exemple #1
0
        public DX11MipSliceRenderTarget(DX11RenderContext context, DX11Texture3D texture, int mipindex, int w, int h, int d)
        {
            this.context = context;

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                Dimension       = RenderTargetViewDimension.Texture3D,
                Format          = texture.Format,
                MipSlice        = mipindex,
                DepthSliceCount = d
            };

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription();

            srvd.Dimension       = ShaderResourceViewDimension.Texture3D;
            srvd.MipLevels       = 1;
            srvd.MostDetailedMip = mipindex;
            srvd.Format          = texture.Format;

            this.RTV = new RenderTargetView(context.Device, texture.Resource, rtd);
            this.SRV = new ShaderResourceView(context.Device, texture.Resource, srvd);

            this.Width  = w;
            this.Height = h;
            this.Depth  = d;
        }
Exemple #2
0
        public static DX11Texture3D FromReference(DxDevice device, Texture3D texture, ShaderResourceView view)
        {
            DX11Texture3D result = new DX11Texture3D();

            result.description = texture.Description;
            result.ShaderView  = view;
            result.Texture     = texture;
            return(result);
        }
Exemple #3
0
        public static DX11Texture3D FromResource(DX11RenderContext context, Texture3D tex, ShaderResourceView srv)
        {
            DX11Texture3D res = new DX11Texture3D(context);

            res.Resource = tex;
            res.SRV      = srv;


            Texture3DDescription desc = res.Resource.Description;

            res.Width  = desc.Width;
            res.Height = desc.Height;
            res.Format = desc.Format;
            res.Depth  = desc.Depth;

            return(res);
        }
Exemple #4
0
        public DX11MipSliceRenderTarget3D(DX11RenderContext context, DX11Texture3D texture, int mipindex, int w, int h, int d) : base(context)
        {
            this.Resource = texture.Resource;

            RenderTargetViewDescription rtd = new RenderTargetViewDescription()
            {
                Dimension       = RenderTargetViewDimension.Texture3D,
                Format          = texture.Format,
                MipSlice        = mipindex,
                DepthSliceCount = d
            };


            UnorderedAccessViewDescription uavd = new UnorderedAccessViewDescription()
            {
                Dimension       = UnorderedAccessViewDimension.Texture3D,
                Format          = texture.Format,
                MipSlice        = mipindex,
                FirstDepthSlice = 0,
                DepthSliceCount = d
            };

            ShaderResourceViewDescription srvd = new ShaderResourceViewDescription();

            srvd.Dimension       = ShaderResourceViewDimension.Texture3D;
            srvd.MipLevels       = 1;
            srvd.MostDetailedMip = mipindex;
            srvd.Format          = texture.Format;
            srvd.ArraySize       = d;
            srvd.FirstArraySlice = 0;



            this.RTV = new RenderTargetView(context.Device, texture.Resource, rtd);
            this.SRV = new ShaderResourceView(context.Device, texture.Resource, srvd);
            this.UAV = new UnorderedAccessView(context.Device, texture.Resource, uavd);

            this.Width  = w;
            this.Height = h;
            this.Depth  = d;
        }
Exemple #5
0
        public static DX11Texture3D FromFile(DX11RenderContext context, string path, ImageLoadInformation loadinfo)
        {
            DX11Texture3D res = new DX11Texture3D(context);

            try
            {
                res.Resource = Texture3D.FromFile(context.Device, path, loadinfo);

                res.SRV = new ShaderResourceView(context.Device, res.Resource);

                Texture3DDescription desc = res.Resource.Description;

                res.Width  = desc.Width;
                res.Height = desc.Height;
                res.Format = desc.Format;
                res.Depth  = desc.Depth;
            }
            catch
            {
            }
            return(res);
        }
Exemple #6
0
        public static DX11Texture3D LoadTexture3D(DxDevice device, string path)
        {
            IntPtr resource;
            long   retcode = NativeMethods.LoadTextureFromFile(device.Device.NativePointer, path, out resource, 1);

            if (retcode == 0)
            {
                Resource r = Resource.FromPointer <Resource>(resource);
                if (r.Dimension != ResourceDimension.Texture3D)
                {
                    r.Dispose();
                    throw new Exception("Texture is not a 3D Texture");
                }

                Texture3D          texture = Texture3D.FromPointer <Texture3D>(resource);
                ShaderResourceView srv     = new ShaderResourceView(device, texture);
                return(DX11Texture3D.FromReference(device, texture, srv));
            }
            else
            {
                throw new Exception("Failed to load texture");
            }
        }