コード例 #1
0
 public PixelValueShader(SharedModel shared)
 {
     shader2D   = new DirectX.Shader(DirectX.Shader.Type.Compute, GetSource(ShaderBuilder.Builder2D), "PixelValueShader");
     shader3D   = new DirectX.Shader(DirectX.Shader.Type.Compute, GetSource(ShaderBuilder.Builder3D), "PixelValueShader");
     readBuffer = shared.Download;
     cbuffer    = shared.Upload;
     dstBuffer  = new GpuBuffer(4 * 4, 1);
 }
コード例 #2
0
ファイル: StatisticsShader.cs プロジェクト: lypvc/ImageViewer
        /// <summary>
        /// shader used for statistics calculation
        /// </summary>
        /// <param name="returnValue">one of the values declared above this function (*Value)</param>
        public StatisticsShader(UploadBuffer upload, string returnValue)
        {
            this.returnValue = returnValue;
            cbuffer          = upload;

            shader   = new DirectX.Shader(DirectX.Shader.Type.Compute, GetSource(ShaderBuilder.Builder2D), "StatisticsShader");
            shader3d = new DirectX.Shader(DirectX.Shader.Type.Compute, GetSource(ShaderBuilder.Builder3D), "StatisticsShader");
        }
コード例 #3
0
        public ConvertFormatShader(QuadShader quad, UploadBuffer upload)
        {
            var dev = DirectX.Device.Get();

            convert2D = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(ShaderBuilder.Builder2D), "ConvertFormatShader2D");
            convert3D = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(ShaderBuilder.Builder3D), "ConvertFormatShader3D");
            this.quad = quad;
            cbuffer   = upload;
        }
コード例 #4
0
ファイル: ReduceShader.cs プロジェクト: lypvc/ImageViewer
        public ReduceShader(UploadBuffer upload, string reduceOp = "a+b", string defaultValue = "0.0", string type = "float")
        {
            this.type         = type;
            this.reduceOp     = reduceOp;
            this.defaultValue = defaultValue;

            shader    = new DirectX.Shader(DirectX.Shader.Type.Compute, GetSource(), "ReduceShader");
            numBuffer = upload;
        }
コード例 #5
0
 public FilterShader(FilterModel parent, string source, int groupSize, FilterLoader.Type kernel, IShaderBuilder builder)
 {
     localSize   = groupSize;
     this.parent = parent;
     is3D        = builder.Is3D;
     shader      = new DirectX.Shader(DirectX.Shader.Type.Compute, GetShaderHeader(kernel, builder) + "\n#line 1\n" + source, parent.Filename);
     if (parent.Parameters.Count != 0)
     {
         paramBuffer = new UploadBuffer(4 * parent.Parameters.Count);
         UpdateParamBuffer();
     }
 }
コード例 #6
0
        public BoxOverlayShader()
        {
            vertex = new DirectX.Shader(DirectX.Shader.Type.Vertex, GetVertexSource(), "BoxOverlayVertex", out var bytecode);
            pixel  = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetPixelSource(), "BoxOverlayPixel");

            var dev = Device.Get();

            input = new InputLayout(dev.Handle, bytecode, new InputElement[]
            {
                new InputElement("POSITION", 0, Format.R32G32_Float, 0)
            });
        }
コード例 #7
0
 public ConvertPolarShader(QuadShader quad)
 {
     this.quad = quad;
     toCube    = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetCubeSource(), "ConvertToCube");
     toLatLong = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetLatLongSource(), "CovertToLatLong");
     sampler   = new SamplerState(Device.Get().Handle, new SamplerStateDescription
     {
         AddressU          = TextureAddressMode.Wrap,
         AddressV          = TextureAddressMode.Wrap,
         AddressW          = TextureAddressMode.Wrap,
         Filter            = SharpDX.Direct3D11.Filter.Anisotropic,
         MaximumAnisotropy = 16
     });
 }
コード例 #8
0
        /// <summary>
        /// for unit testing purposes. Converts naked srv to TextureArray2D
        /// </summary>
        internal Texture3D ConvertFromRaw3D(SharpDX.Direct3D11.ShaderResourceView srv, Size3 size, SharpDX.DXGI.Format dstFormat, bool isInteger)
        {
            var res = new Texture3D(1, size, dstFormat, false);

            var dev = DirectX.Device.Get();

            quad.Bind(true);
            if (isInteger)
            {
                if (convert3DInt == null)
                {
                    convert3DInt = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(new ShaderBuilder3D("int4")), "ConvertInt");
                }
                dev.Pixel.Set(convert3DInt.Pixel);
            }
            else
            {
                dev.Pixel.Set(convert3D.Pixel);
            }

            dev.Pixel.SetShaderResource(0, srv);

            cbuffer.SetData(new LayerLevelOffsetData
            {
                Layer      = 0,
                Level      = 0,
                Xoffset    = 0,
                Yoffset    = 0,
                Multiplier = 1.0f,
                UseOverlay = 0,
                Scale      = 1
            });

            dev.Pixel.SetConstantBuffer(0, cbuffer.Handle);
            dev.OutputMerger.SetRenderTargets(res.GetRtView(LayerMipmapSlice.Mip0));
            dev.SetViewScissors(size.Width, size.Height);
            dev.DrawFullscreenTriangle(size.Depth);

            // remove bindings
            dev.Pixel.SetShaderResource(0, null);
            dev.OutputMerger.SetRenderTargets((RenderTargetView)null);
            quad.Unbind();

            return(res);
        }
コード例 #9
0
        public ThumbnailModel(QuadShader quad)
        {
            this.quad = quad;
            convert2D = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(ShaderBuilder.Builder2D), "ThumbnailPixelShader2D");
            convert3D = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(ShaderBuilder.Builder3D), "ThumbnailPixelShader3D");
            var samplerDesc = new SamplerStateDescription
            {
                AddressU           = TextureAddressMode.Clamp,
                AddressV           = TextureAddressMode.Clamp,
                AddressW           = TextureAddressMode.Clamp,
                BorderColor        = new RawColor4(),
                ComparisonFunction = Comparison.Never,
                Filter             = SharpDX.Direct3D11.Filter.MinLinearMagMipPoint,
                MaximumAnisotropy  = 1,
                MaximumLod         = float.MaxValue,
                MinimumLod         = 0,
                MipLodBias         = 0
            };

            sampler = new SamplerState(Device.Get().Handle, samplerDesc);
        }
コード例 #10
0
 public PaddingShader()
 {
     shader   = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(ShaderBuilder.Builder2D), "PaddingShader");
     shader3D = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(ShaderBuilder.Builder3D), "PaddingShader3D");
     sampler  = new SamplerState[]
     {
         new SamplerState(Device.Get().Handle, new SamplerStateDescription
         {
             AddressU    = TextureAddressMode.Border,
             AddressV    = TextureAddressMode.Border,
             AddressW    = TextureAddressMode.Border,
             BorderColor = new RawColor4(0.0f, 0.0f, 0.0f, 1.0f),
             Filter      = SharpDX.Direct3D11.Filter.MinMagMipPoint
         }),
         new SamplerState(Device.Get().Handle, new SamplerStateDescription
         {
             AddressU    = TextureAddressMode.Border,
             AddressV    = TextureAddressMode.Border,
             AddressW    = TextureAddressMode.Border,
             BorderColor = new RawColor4(1.0f, 1.0f, 1.0f, 1.0f),
             Filter      = SharpDX.Direct3D11.Filter.MinMagMipPoint
         }),
         new SamplerState(Device.Get().Handle, new SamplerStateDescription
         {
             AddressU    = TextureAddressMode.Border,
             AddressV    = TextureAddressMode.Border,
             AddressW    = TextureAddressMode.Border,
             BorderColor = new RawColor4(0.0f, 0.0f, 0.0f, 0.0f),
             Filter      = SharpDX.Direct3D11.Filter.MinMagMipPoint
         }),
         new SamplerState(Device.Get().Handle, new SamplerStateDescription
         {
             AddressU = TextureAddressMode.Clamp,
             AddressV = TextureAddressMode.Clamp,
             AddressW = TextureAddressMode.Clamp,
             Filter   = SharpDX.Direct3D11.Filter.MinMagMipPoint
         }),
     };
 }
コード例 #11
0
 public MitchellNetravaliScaleShader(QuadShader quad, UploadBuffer upload)
 {
     this.quad = quad;
     shader    = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(), "MitchellNetravaliScale");
     cbuffer   = upload;
 }
コード例 #12
0
 public ImageCombineShader(string colorFormula, string alphaFormula, int numImages, IShaderBuilder builder)
 {
     this.builder = builder;
     shader       = new DirectX.Shader(DirectX.Shader.Type.Compute,
                                       GetShaderSource(colorFormula, alphaFormula, Math.Max(numImages, 1), builder), "ImageCombineShader");
 }
コード例 #13
0
 public ConvertTo3DShader(QuadShader quad)
 {
     this.quad   = quad;
     shader3D    = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource3D(), "ArrayTo3DShader");
     shaderLayer = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSourceLayer(), "3DToArrayShader");
 }
コード例 #14
0
 public GifShader(QuadShader quad, UploadBuffer upload)
 {
     this.quad = quad;
     pixel     = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(), "GifPixelShader");
     cbuffer   = upload;
 }
コード例 #15
0
 public GifShader()
 {
     pixel = new DirectX.Shader(DirectX.Shader.Type.Pixel, GetSource(), "GifPixelShader");
 }
コード例 #16
0
 public QuadShader()
 {
     shader = new DirectX.Shader(DirectX.Shader.Type.Vertex, GetSource(), "QuadShader");
     geo    = new DirectX.Shader(DirectX.Shader.Type.Geometry, GetGeoSource(), "QuadGeoShader");
 }