Exemple #1
0
        internal OverlayModel(ImageModelTextureCache cache)
        {
            this.cache     = cache;
            cache.Changed += CacheOnChanged;
            Overlays.CollectionChanged += OverlaysOnCollectionChanged;

            var blendDesc = new BlendStateDescription
            {
                AlphaToCoverageEnable  = false,
                IndependentBlendEnable = false
            };

            blendDesc.RenderTarget[0].IsBlendEnabled        = true;
            blendDesc.RenderTarget[0].RenderTargetWriteMask = ColorWriteMaskFlags.All;

            // C' = a_src * c_src + (1.0 - a_src) * a_dst
            blendDesc.RenderTarget[0].BlendOperation   = BlendOperation.Add;
            blendDesc.RenderTarget[0].SourceBlend      = BlendOption.SourceAlpha;
            blendDesc.RenderTarget[0].DestinationBlend = BlendOption.InverseSourceAlpha;

            // A' = (1.0 - a_src) * a_dst (inverse alpha, render target starts with a == 1)
            blendDesc.RenderTarget[0].AlphaBlendOperation   = BlendOperation.Add;
            blendDesc.RenderTarget[0].SourceAlphaBlend      = BlendOption.Zero;
            blendDesc.RenderTarget[0].DestinationAlphaBlend = BlendOption.InverseSourceAlpha;

            blendState = new BlendState(Device.Get().Handle, blendDesc);
        }
        //private readonly SamplerState maxSampler;
        //private readonly SamplerState minSampler;

        public SmoothVolumeShader(ModelsEx models)
            : base(models, GetPixelSource(), "SmoothVolumeShader")
        {
            var clamp = TextureAddressMode.Clamp;

            sampler = new SamplerState(Device.Get().Handle, new SamplerStateDescription
            {
                //AddressU = TextureAddressMode.Border,
                //AddressV = TextureAddressMode.Border,
                //AddressW = TextureAddressMode.Border,
                AddressU    = clamp,
                AddressV    = clamp,
                AddressW    = clamp,
                Filter      = Filter.MinMagMipLinear,
                BorderColor = new RawColor4(0.0f, 0.0f, 0.0f, 0.0f),
            });

            /*maxSampler = new SamplerState(Device.Get().Handle, new SamplerStateDescription
             * {
             *  AddressU = clamp,
             *  AddressV = clamp,
             *  AddressW = clamp,
             *  Filter = Filter.MaximumMinMagMipLinear
             * });
             *
             * minSampler = new SamplerState(Device.Get().Handle, new SamplerStateDescription
             * {
             *  AddressU = clamp,
             *  AddressV = clamp,
             *  AddressW = clamp,
             *  Filter = Filter.MinimumMinMagMipLinear
             * });*/
        }
Exemple #3
0
        public override void Draw(int id, ITexture texture)
        {
            if (texture == null)
            {
                return;
            }

            base.Draw(id, texture);

            var dev = Device.Get();

            dev.OutputMerger.BlendState = models.ViewData.AlphaDarkenState;

            if (models.Display.LinearInterpolation)
            {
                shader.Run(models.Display.ClientAspectRatio, GetWorldToImage(), CalcFarplane(),
                           texture.GetSrView(models.Display.ActiveLayerMipmap), helpTextures[id].GetSrView(models.Display.ActiveMipmap));
            }
            else
            {
                marchingShader.Run(models.Display.ClientAspectRatio, GetWorldToImage(), CalcFarplane(),
                                   displayEx.FlatShading, texture.GetSrView(models.Display.ActiveLayerMipmap), helpTextures[id].GetSrView(models.Display.ActiveMipmap));
            }

            dev.OutputMerger.BlendState = models.ViewData.DefaultBlendState;
        }
        public void Run(Matrix transform, ShaderResourceView texture, ShaderResourceView overlay, int xaxis, int yaxis, int zvalue)
        {
            var v = models.ViewData;

            v.Buffer.SetData(new BufferData
            {
                Common    = GetCommonData(overlay),
                Transform = transform,
                XAxis     = xaxis,
                YAxis     = yaxis,
                ZValue    = zvalue
            });

            var dev = Device.Get();

            BindShader(dev);

            dev.Vertex.SetConstantBuffer(0, v.Buffer.Handle);
            dev.Pixel.SetConstantBuffer(0, v.Buffer.Handle);

            dev.Pixel.SetShaderResource(0, texture);
            dev.Pixel.SetShaderResource(1, overlay);
            dev.Pixel.SetSampler(0, v.GetSampler());

            dev.DrawQuad();

            // unbind
            dev.Pixel.SetShaderResource(0, null);
            dev.Pixel.SetShaderResource(1, null);
            UnbindShader(dev);
        }
        public DownloadBuffer(int byteSize)
        {
            ByteSize = Utility.Utility.AlignTo(byteSize, 16);

            var viewDesc = new UnorderedAccessViewDescription
            {
                Dimension = UnorderedAccessViewDimension.Buffer,
                Format    = Format.Unknown,
                Buffer    = new UnorderedAccessViewDescription.BufferResource
                {
                    ElementCount = 1,
                    FirstElement = 0,
                    Flags        = UnorderedAccessViewBufferFlags.None
                }
            };

            var stageDesc = new BufferDescription
            {
                BindFlags           = BindFlags.None,
                CpuAccessFlags      = CpuAccessFlags.Read,
                OptionFlags         = ResourceOptionFlags.None,
                SizeInBytes         = ByteSize,
                StructureByteStride = 0,
                Usage = ResourceUsage.Staging
            };

            stageBuffer = new Buffer(Device.Get().Handle, stageDesc);
        }
Exemple #6
0
        /// converts a cubemap texture to a lat long map
        public TextureArray2D ConvertToLatLong(TextureArray2D cube, int resolution)
        {
            Debug.Assert(cube.NumLayers == 6);

            var dst = new TextureArray2D(LayerMipmapCount.One, new Size3(resolution, Math.Max(resolution / 2, 1)), Format.R32G32B32A32_Float, false);

            var dev = Device.Get();

            quad.Bind(false);
            dev.Pixel.Set(toLatLong.Pixel);

            var dim = dst.Size;

            dev.Pixel.SetShaderResource(0, cube.GetCubeView(0));
            dev.Pixel.SetSampler(0, sampler);
            dev.OutputMerger.SetRenderTargets(dst.GetRtView(LayerMipmapSlice.Mip0));
            dev.SetViewScissors(dim.Width, dim.Height);
            dev.DrawQuad();

            dev.Pixel.SetShaderResource(0, null);
            dev.Pixel.SetSampler(0, null);
            dev.OutputMerger.SetRenderTargets((RenderTargetView)null);
            quad.Unbind();

            return(dst);
        }
Exemple #7
0
        public Size3 GetIntersection(Matrix transform, Vector2 mousePos, ShaderResourceView emptySpaceTex)
        {
            // transform mousePos to ray direction
            var v = models.ViewData;

            v.Buffer.SetData(new CoordBufferData
            {
                Common = GetCommonData(transform, models.Display.ClientAspectRatioScalar),
                Ray    = GetRayDirFromCanonical(transform, mousePos),
            });

            var dev = Device.Get();

            dev.Compute.Set(coordShader.Compute);
            dev.Compute.SetConstantBuffer(0, v.Buffer.Handle);
            dev.Compute.SetShaderResource(0, emptySpaceTex);
            dev.Compute.SetUnorderedAccessView(0, coordDstBuffer.View);

            dev.Dispatch(1, 1);

            // unbind
            dev.Compute.SetShaderResource(0, null);
            dev.Compute.SetUnorderedAccessView(0, null);

            // obtain data
            var read = models.SharedModel.Download;

            read.CopyFrom(coordDstBuffer, Marshal.SizeOf(typeof(Size3)));
            return(read.GetData <Size3>());
        }
        public void Unbind()
        {
            var dev = Device.Get();

            dev.InputAssembler.InputLayout = null;
            dev.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(null, 0, 0));
        }
Exemple #9
0
        // converts a lat long texture to a cubemap
        public TextureArray2D ConvertToCube(TextureArray2D latlong, int resolution)
        {
            Debug.Assert(latlong.NumLayers == 1);

            var dst = new TextureArray2D(new LayerMipmapCount(6, 1), new Size3(resolution, resolution), Format.R32G32B32A32_Float, false);

            var dev = Device.Get();

            quad.Bind(false);
            dev.Pixel.Set(toCube.Pixel);

            dev.Pixel.SetShaderResource(0, latlong.GetSrView(LayerMipmapSlice.Mip0));
            dev.Pixel.SetSampler(0, sampler);
            dev.OutputMerger.SetRenderTargets(null,
                                              dst.GetRtView(new LayerMipmapSlice(0, 0)),
                                              dst.GetRtView(new LayerMipmapSlice(1, 0)),
                                              dst.GetRtView(new LayerMipmapSlice(2, 0)),
                                              dst.GetRtView(new LayerMipmapSlice(3, 0)),
                                              dst.GetRtView(new LayerMipmapSlice(4, 0)),
                                              dst.GetRtView(new LayerMipmapSlice(5, 0)));
            dev.SetViewScissors(resolution, resolution);
            dev.DrawQuad();

            dev.Pixel.SetShaderResource(0, null);
            dev.Pixel.SetSampler(0, null);
            dev.OutputMerger.SetRenderTargets((RenderTargetView)null);
            quad.Unbind();

            return(dst);
        }
Exemple #10
0
        public T CloneT()
        {
            var newTex = CreateT(LayerMipmap, Size, Format, uaViews != null);

            Device.Get().CopyResource(GetHandle(), newTex.GetHandle());
            return(newTex);
        }
Exemple #11
0
        public void Run(ShaderResourceView left, ShaderResourceView right, RenderTargetView dst, int borderSize, int borderLocation, int width, int height)
        {
            Debug.Assert(borderLocation >= 0);
            Debug.Assert(borderLocation < width);

            quad.Bind(false);
            var dev = Device.Get();

            dev.Pixel.Set(pixel.Pixel);

            // update buffer
            cbuffer.SetData(new BufferData
            {
                BorderLocation = borderLocation,
                BorderSize     = borderSize
            });

            // bind and draw
            dev.Pixel.SetConstantBuffer(0, cbuffer.Handle);
            dev.Pixel.SetShaderResource(0, left);
            dev.Pixel.SetShaderResource(1, right);
            dev.OutputMerger.SetRenderTargets(dst);
            dev.SetViewScissors(width, height);
            dev.DrawQuad();

            // unbind
            dev.Pixel.SetShaderResource(0, null);
            dev.Pixel.SetShaderResource(1, null);
            dev.OutputMerger.SetRenderTargets((RenderTargetView)null);
            quad.Unbind();
        }
Exemple #12
0
        protected override SharpDX.Direct3D11.Resource GetStagingTexture(LayerMipmapSlice lm)
        {
            Debug.Assert(IO.SupportedFormats.Contains(Format));

            var newSize = Size.GetMip(lm.Mipmap);

            var desc = new Texture2DDescription
            {
                ArraySize         = 1,
                BindFlags         = BindFlags.None,
                CpuAccessFlags    = CpuAccessFlags.Read,
                Format            = Format,
                Height            = newSize.Height,
                Width             = newSize.Width,
                MipLevels         = 1,
                OptionFlags       = ResourceOptionFlags.None,
                SampleDescription = new SampleDescription(1, 0),
                Usage             = ResourceUsage.Staging
            };

            // create staging texture
            var staging = new Texture2D(Device.Get().Handle, desc);

            // copy data to staging resource
            Device.Get().CopySubresource(handle, staging,
                                         GetSubresourceIndex(lm), 0,
                                         newSize
                                         );

            return(staging);
        }
Exemple #13
0
        public TextureArray2D(ImageLoader.Image image)
        {
            Size = image.GetSize(0);
            Debug.Assert(Size.Depth == 1);
            NumMipmaps = image.NumMipmaps;
            NumLayers  = image.NumLayers;
            Format     = image.Format.DxgiFormat;

            var data = new DataRectangle[NumLayers * NumMipmaps];

            for (int curLayer = 0; curLayer < NumLayers; ++curLayer)
            {
                for (int curMipmap = 0; curMipmap < NumMipmaps; ++curMipmap)
                {
                    var mip = image.Layers[curLayer].Mipmaps[curMipmap];
                    var idx = GetSubresourceIndex(curLayer, curMipmap);
                    data[idx].DataPointer = mip.Bytes;
                    // The distance (in bytes) from the beginning of one line of a texture to the next line.
                    data[idx].Pitch = (int)(mip.Size / mip.Height);
                }
            }

            handle = new Texture2D(Device.Get().Handle, CreateTextureDescription(false), data);

            CreateTextureViews(false);
        }
Exemple #14
0
        /// <summary>
        /// copies the values of the +4th mipmap into the specified mipmap
        /// </summary>
        /// <param name="tex"></param>
        /// <param name="lm">dst layer/mipmap</param>
        /// <param name="upload"></param>
        public void RunCopy(ITexture tex, LayerMipmapSlice lm, UploadBuffer upload)
        {
            var size     = tex.Size.GetMip(lm.SingleMipmap);
            var nMipmaps = tex.NumMipmaps - lm.Mipmap;

            if (nMipmaps == 1)
            {
                return;                // already finished
            }
            upload.SetData(new BufferData
            {
                Layer = lm.SingleLayer,
                Size  = size
            });
            var dev = Device.Get();

            var builder = tex.Is3D ? ShaderBuilder.Builder3D : ShaderBuilder.Builder2D;

            dev.Compute.Set(tex.Is3D ? CopyShader3D.Compute : CopyShader.Compute);
            dev.Compute.SetConstantBuffer(0, upload.Handle);
            dev.Compute.SetSampler(0, sampler);

            dev.Compute.SetUnorderedAccessView(0, tex.GetUaView(lm.Mipmap));
            dev.Compute.SetShaderResource(0, tex.GetSrView(lm.AddMipmap(Math.Min(4, nMipmaps - 1))));

            dev.Dispatch(
                Utility.Utility.DivideRoundUp(size.X, builder.LocalSizeX),
                Utility.Utility.DivideRoundUp(size.Y, builder.LocalSizeY),
                Utility.Utility.DivideRoundUp(size.Z, builder.LocalSizeZ)
                );

            dev.Compute.SetShaderResource(0, null);
            dev.Compute.SetUnorderedAccessView(0, null);
        }
        public void Run(Matrix transform, float farplane, ShaderResourceView texture, ShaderResourceView overlay)
        {
            var v = models.ViewData;

            v.Buffer.SetData(new BufferData
            {
                Common    = GetCommonData(overlay),
                Transform = transform,
                Farplane  = farplane,
            });

            var dev = Device.Get();

            BindShader(dev);

            dev.Vertex.SetConstantBuffer(0, v.Buffer.Handle);
            dev.Pixel.SetConstantBuffer(0, v.Buffer.Handle);

            dev.Pixel.SetShaderResource(0, texture);
            dev.Pixel.SetShaderResource(1, overlay);
            dev.Pixel.SetSampler(0, v.GetSampler());

            dev.DrawQuad();

            // unbind
            dev.Pixel.SetShaderResource(0, null);
            dev.Pixel.SetShaderResource(1, null);
            UnbindShader(dev);
        }
Exemple #16
0
        public void Run(UploadBuffer buffer, Matrix transform, Vector4 crop, float multiplier, bool useAbs,
                        ShaderResourceView texture, SamplerState sampler, int xaxis = 0, int yaxis = 1, int zvalue = 0)
        {
            buffer.SetData(new ViewBufferData
            {
                Transform  = transform,
                Crop       = crop,
                Multiplier = multiplier,
                UseAbs     = useAbs?1:0,
                XAxis      = xaxis,
                YAxis      = yaxis,
                ZValue     = zvalue
            });

            var dev = Device.Get();

            BindShader(dev);

            dev.Vertex.SetConstantBuffer(0, buffer.Handle);
            dev.Pixel.SetConstantBuffer(0, buffer.Handle);

            dev.Pixel.SetShaderResource(0, texture);
            dev.Pixel.SetSampler(0, sampler);

            dev.DrawQuad();

            // unbind
            dev.Pixel.SetShaderResource(0, null);
            UnbindShader(dev);
        }
Exemple #17
0
        /// <summary>
        /// returns a uav views with the specified offset
        /// </summary>
        UnorderedAccessView GetView(int offset)
        {
            Debug.Assert(offset < ElementCount);
            if (views == null)
            {
                views = new Dictionary <int, UnorderedAccessView>();
            }

            if (views.TryGetValue(offset, out var hashedView))
            {
                return(hashedView);
            }

            var newView = new UnorderedAccessView(Device.Get().Handle, Handle, new UnorderedAccessViewDescription
            {
                Dimension = UnorderedAccessViewDimension.Buffer,
                Format    = Format.Unknown,
                Buffer    = new UnorderedAccessViewDescription.BufferResource
                {
                    FirstElement = offset,
                    ElementCount = ElementCount - offset,
                    Flags        = UnorderedAccessViewBufferFlags.None
                }
            });

            views[offset] = newView;
            return(newView);
        }
        public void Run(Matrix rayTransform, Matrix worldToImage, float farplane, ShaderResourceView texture, ShaderResourceView emptySpaceTex)
        {
            var v = models.ViewData;

            v.Buffer.SetData(new BufferData
            {
                Common       = GetCommonData(null),
                Transform    = rayTransform,
                WorldToImage = worldToImage,
                Farplane     = farplane,
            });

            var dev = Device.Get();

            BindShader(dev);

            dev.Vertex.SetConstantBuffer(0, v.Buffer.Handle);
            dev.Pixel.SetConstantBuffer(0, v.Buffer.Handle);

            dev.Pixel.SetShaderResource(0, texture);
            dev.Pixel.SetSampler(0, sampler);
            dev.Pixel.SetShaderResource(1, emptySpaceTex);

            dev.DrawQuad();

            // unbind
            dev.Pixel.SetShaderResource(0, null);
            dev.Pixel.SetShaderResource(1, null);
            UnbindShader(dev);
        }
Exemple #19
0
        public void Run(UploadBuffer buffer, Matrix transform, float multiplier, float farplane, bool useAbs, ShaderResourceView texture, SamplerState sampler)
        {
            buffer.SetData(new ViewBufferData
            {
                Transform  = transform,
                Multiplier = multiplier,
                Farplane   = farplane,
                UseAbs     = useAbs ? 1 : 0
            });

            var dev = Device.Get();

            BindShader(dev);

            dev.Vertex.SetConstantBuffer(0, buffer.Handle);
            dev.Pixel.SetConstantBuffer(0, buffer.Handle);

            dev.Pixel.SetShaderResource(0, texture);
            dev.Pixel.SetSampler(0, sampler);

            dev.DrawQuad();

            // unbind
            dev.Pixel.SetShaderResource(0, null);
            UnbindShader(dev);
        }
        private void Apply(TextureArray2D src, TextureArray2D dst, int dirX, int dirY)
        {
            quad.Bind(false);
            var dev = Device.Get();

            dev.Pixel.Set(shader.Pixel);

            cbuffer.SetData(new DirSizeData
            {
                DirX  = dirX,
                DirY  = dirY,
                SizeX = src.Size.Width,
                SizeY = src.Size.Height
            });

            dev.Pixel.SetConstantBuffer(0, cbuffer.Handle);
            dev.SetViewScissors(dst.Size.Width, dst.Size.Height);

            foreach (var lm in src.LayerMipmap.LayersOfMipmap(0))
            {
                dev.Pixel.SetShaderResource(0, src.GetSrView(lm));
                dev.OutputMerger.SetRenderTargets(dst.GetRtView(lm));
                dev.DrawQuad();
            }

            dev.Pixel.SetShaderResource(0, null);
            dev.OutputMerger.SetRenderTargets((RenderTargetView)null);
            quad.Unbind();
        }
Exemple #21
0
        public void Run(Matrix transform, bool useFlatShading, ShaderResourceView texture, ShaderResourceView emptySpaceTex)
        {
            var v = models.ViewData;

            v.Buffer.SetData(new BufferData
            {
                Common         = GetCommonData(transform, models.Display.ClientAspectRatioScalar),
                UseFlatShading = useFlatShading ? 1 : 0
            });

            var dev = Device.Get();

            BindShader(dev);

            dev.Vertex.SetConstantBuffer(0, v.Buffer.Handle);
            dev.Pixel.SetConstantBuffer(0, v.Buffer.Handle);

            dev.Pixel.SetShaderResource(0, texture);
            dev.Pixel.SetShaderResource(1, emptySpaceTex);

            dev.DrawQuad();

            // unbind
            dev.Pixel.SetShaderResource(0, null);
            dev.Pixel.SetShaderResource(1, null);
            UnbindShader(dev);
        }
Exemple #22
0
        public void DdsDirectXCubemapCompability()
        {
            // load cubemap
            var model = new Models(1);

            model.AddImageFromFile(TestData.Directory + "cubemap.dds");
            model.Apply();

            // export
            var desc = new ExportDescription(model.Pipelines[0].Image, ExportDir + "tmp", "dds");

            desc.FileFormat = GliFormat.RGBA8_SRGB;
            model.Export.Export(desc);

            // try loading with dds loader
            DDSTextureLoader.CreateDDSTextureFromFile(Device.Get().Handle, Device.Get().ContextHandle, ExportDir + "tmp.dds",
                                                      out var resource, out var resourceView, 0, out var alphaMode);

            Assert.AreEqual(ResourceDimension.Texture2D, resource.Dimension);
            Assert.IsTrue(resource is Texture2D);
            var tex2D = resource as Texture2D;

            Assert.AreEqual(model.Images.Size.Width, tex2D.Description.Width);
            Assert.AreEqual(model.Images.Size.Height, tex2D.Description.Height);
            Assert.AreEqual(model.Images.NumLayers, tex2D.Description.ArraySize);
            Assert.AreEqual(model.Images.NumMipmaps, tex2D.Description.MipLevels);
        }
Exemple #23
0
        protected override Resource GetStagingTexture(LayerMipmapSlice lm)
        {
            Debug.Assert(IO.SupportedFormats.Contains(Format) || Format == Format.R8_UInt);

            Debug.Assert(lm.Layer == 0);
            Debug.Assert(lm.IsIn(LayerMipmap));

            var mipDim = Size.GetMip(lm.Mipmap);
            var desc   = new Texture3DDescription
            {
                Width          = mipDim.Width,
                Height         = mipDim.Height,
                Depth          = mipDim.Depth,
                Format         = Format,
                MipLevels      = 1,
                BindFlags      = BindFlags.None,
                CpuAccessFlags = CpuAccessFlags.Read,
                OptionFlags    = ResourceOptionFlags.None,
                Usage          = ResourceUsage.Staging
            };

            // create staging texture
            var staging = new SharpDX.Direct3D11.Texture3D(Device.Get().Handle, desc);

            // copy data to staging texture
            Device.Get().CopySubresource(handle, staging, GetSubresourceIndex(lm), 0, mipDim);

            return(staging);
        }
        public T[] GetData <T>(int count) where T : struct
        {
            var res = new T[count];

            Debug.Assert(Marshal.SizeOf(typeof(T)) * count <= ByteSize);
            Device.Get().GetData(stageBuffer, ref res);
            return(res);
        }
        public T GetData <T>() where T : struct
        {
            var res = new T[1];

            Debug.Assert(Marshal.SizeOf(typeof(T)) <= ByteSize);
            Device.Get().GetData(stageBuffer, ref res);
            return(res[0]);
        }
        public void Dds3DDirectXCompability()
        {
            var model = new Models(1);

            model.AddImageFromFile(TestData.Directory + "checkers3d.dds");
            model.Apply();
            model.Export.Quality = 100;
            var origTex    = (Texture3D)model.Pipelines[0].Image;
            var origColors = origTex.GetPixelColors(0, 0);

            Color[] newColors = null;

            var    eFmt      = model.Export.Formats.First(fmt => fmt.Extension == "dds");
            string errors    = "";
            int    numErrors = 0;
            int    nFormats  = 0;

            foreach (var format in eFmt.Formats)
            {
                if (format.IsExcludedFrom3DExport())
                {
                    continue;
                }
                nFormats++;
                try
                {
                    // export to dds
                    var desc = new ExportDescription(ExportDir + "tmp", "dds", model.Export);
                    desc.FileFormat = format;
                    model.Export.Export(origTex, desc);

                    // load with directx dds loader
                    DDSTextureLoader.CreateDDSTextureFromFile(Device.Get().Handle, Device.Get().ContextHandle, ExportDir + "tmp.dds",
                                                              out var resource, out var resourceView, 0, out var alphaMode);

                    // convert to obtain color data
                    using (var newTex = model.Export.convert.ConvertFromRaw3D(resourceView, origTex.Size, Format.R32G32B32A32_Float))
                    {
                        resourceView.Dispose();
                        resource.Dispose();

                        newColors = newTex.GetPixelColors(0, 0);
                        // only compare with red channel since some formats only store red
                        TestData.CompareColors(origColors, newColors, Color.Channel.R, 0.1f);
                    }
                }
                catch (Exception e)
                {
                    errors += $"{format}: {e.Message}\n";
                    ++numErrors;
                }
            }

            if (errors.Length > 0)
            {
                throw new Exception($"directX compability failed for {numErrors}/{nFormats} formats:\n" + errors);
            }
        }
Exemple #27
0
        private void BindTextureParameters(ImagesModel image, LayerMipmapSlice lm)
        {
            var texSlot = TextureBindingStart;

            foreach (var texParam in parent.TextureParameters)
            {
                Device.Get().Compute.SetShaderResource(texSlot++, image.Images[texParam.Source].Image.GetSrView(lm));
            }
        }
Exemple #28
0
 public Color[] GetPixelColors(LayerMipmapSlice lm)
 {
     // create staging texture
     using (var staging = GetStagingTexture(lm))
     {
         // obtain data from staging resource
         return(Device.Get().GetColorData(staging, Format, 0, Size.GetMip(lm.Mipmap)));
     }
 }
Exemple #29
0
        private void UnbindTextureParameters()
        {
            var texSlot = TextureBindingStart;

            foreach (var texParam in parent.TextureParameters)
            {
                Device.Get().Compute.SetShaderResource(texSlot++, null);
            }
        }
Exemple #30
0
 public void CopyPixels(LayerMipmapSlice lm, IntPtr destination, uint size)
 {
     // create staging texture
     using (var staging = GetStagingTexture(lm))
     {
         // obtain data from staging resource
         Device.Get().GetData(staging, Format, 0, Size.GetMip(lm.Mipmap), destination, size);
     }
 }