Beispiel #1
0
        public void BindAsImage(int unit, bool read, bool write)
        {
            SizedInternalFormat format = SizedInternalFormat.Rgba32f;

            if (InternalFormat == PixelInternalFormat.Rgba16f || InternalFormat == PixelInternalFormat.Rgb16f)
            {
                format = SizedInternalFormat.Rgba16f;
            }
            else if (InternalFormat == PixelInternalFormat.Rgb || InternalFormat == PixelInternalFormat.Rgba ||
                     InternalFormat == PixelInternalFormat.Rgb8 || InternalFormat == PixelInternalFormat.Rgba8)
            {
                format = SizedInternalFormat.Rgba8;
            }
            else if (InternalFormat == PixelInternalFormat.R32f)
            {
                format = SizedInternalFormat.R32f;
            }
            else if (InternalFormat == PixelInternalFormat.R16f)
            {
                format = SizedInternalFormat.R16f;
            }

            TextureAccess access = TextureAccess.ReadWrite;

            if (read && !write)
            {
                access = TextureAccess.ReadOnly;
            }
            else if (write && !read)
            {
                access = TextureAccess.WriteOnly;
            }

            IGL.Primary.BindImageTexture(unit, Id, 0, false, 0, (int)access, (int)format);
        }
Beispiel #2
0
 public static extern Texture SDL_CreateTexture(
     Renderer renderer,
     UInt32 format,
     TextureAccess access,
     int w,
     int h
     );
Beispiel #3
0
        public void bindImageUnit(int texture_uniform, int index, TextureAccess access, int level, int layer)
        {
            bool layered = false;

            switch (_target)
            {
            case TextureTarget.Texture2DArray:
            case TextureTarget.TextureCubeMap:
            case TextureTarget.TextureCubeMapArray:
            case TextureTarget.Texture3D:
                layered = true;
                break;
            }

            GL.ActiveTexture(TextureUnit.Texture0 + index);
            GL.BindImageTexture(
                index,
                _id,
                level,
                layered,
                layer,
                access,
                (SizedInternalFormat)_pif);
            GL.Uniform1(texture_uniform, index);
        }
Beispiel #4
0
 public BindImagebufferCommand(int bufferId, int location, TextureAccess access, SizedInternalFormat format) : base()
 {
     myBufferId = bufferId;
     myLocation = location;
     myAccess   = access;
     myFormat   = format;
 }
Beispiel #5
0
 public ImageTextureBinding(Texture source, TextureUnit textureSlot, TextureAccess access, SizedInternalFormat format)
 {
     texture       = source;
     textureUnit   = textureSlot;
     bindingAccess = access;
     bindingFormat = format;
 }
Beispiel #6
0
        public static void UnbindAsImage(int unit)
        {
            SizedInternalFormat format = SizedInternalFormat.Rgba32f;
            TextureAccess       access = TextureAccess.ReadWrite;

            IGL.Primary.BindImageTexture(unit, 0, 0, false, 0, (int)access, (int)format);
        }
Beispiel #7
0
 public void createShaderAccessPoint(uint bindPoint, TextureAccess access)
 {
     OgrePINVOKE.TexturePtr_createShaderAccessPoint__SWIG_3(swigCPtr, bindPoint, (int)access);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #8
0
 public virtual void createShaderAccessPoint(uint bindPoint, TextureAccess access, int mipmapLevel)
 {
     OgrePINVOKE.Texture_createShaderAccessPoint__SWIG_2(swigCPtr, bindPoint, (int)access, mipmapLevel);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #9
0
 public virtual void createShaderAccessPoint(uint bindPoint, TextureAccess access, int mipmapLevel, int textureArrayIndex, PixelFormat format)
 {
     OgrePINVOKE.Texture_createShaderAccessPoint__SWIG_0(swigCPtr, bindPoint, (int)access, mipmapLevel, textureArrayIndex, (int)format);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #10
0
 public void createShaderAccessPoint(uint bindPoint, TextureAccess access, int mipmapLevel, int textureArrayIndex)
 {
     OgrePINVOKE.TexturePtr_createShaderAccessPoint__SWIG_1(swigCPtr, bindPoint, (int)access, mipmapLevel, textureArrayIndex);
     if (OgrePINVOKE.SWIGPendingException.Pending)
     {
         throw OgrePINVOKE.SWIGPendingException.Retrieve();
     }
 }
Beispiel #11
0
        public void setImageBuffer(int id, int location, TextureAccess access, SizedInternalFormat format)
        {
            currentImageBuffer++;
            ImageInfo ii;

            ii.id       = id;
            ii.location = location;
            ii.access   = access;
            ii.format   = format;
            myImageBuffers[currentImageBuffer] = ii;
        }
Beispiel #12
0
 public SdlTexture(IRenderWindow window, IBuffer source, bool isPrimary = false, uint? pixelFormat = null)
 {
     Initialize(window, isPrimary);
     Initialize(source.Width, source.Height);
     Renderer = SdlFactory.GetRenderer(window.Handle);
     textureAccess = TextureAccess.Static;
     this.pixelFormat = pixelFormat;
     if (Renderer == IntPtr.Zero)
         Renderer = SdlFactory.CreateRenderer(window.Handle, -1, window.RendererFlags);
     Handle = SdlFactory.CreateTexture(Renderer, source);
     SdlFactory.SetTextureBlendMod(Handle, BlendMode.None);
 }
Beispiel #13
0
 public SdlTexture(IRenderWindow window, int? w = null, int? h = null, bool isPrimary = false, uint? pixelFormat = null)
 {
     Initialize(window, isPrimary);
     Initialize(w ?? window.Width, window.Height);
     Renderer = SdlFactory.GetRenderer(window.Handle);
     this.pixelFormat = pixelFormat;
     textureAccess = TextureAccess.Streaming;
     if (Renderer == IntPtr.Zero)
         Renderer = SdlFactory.CreateRenderer(window.Handle, -1, window.RendererFlags);
     Handle = SdlFactory.CreateTexture(Renderer,
         pixelFormat ?? Factory.PixelFormat, textureAccess, Width, Height);
     SdlFactory.SetTextureBlendMod(Handle, BlendMode.None);
 }
Beispiel #14
0
        public void ShouldCreateTexturesWithSpecifiedParameters(
            TextureAccess access,
            PixelFormat format
            )
        {
            var width   = 20;
            var height  = 10;
            var texture = graphics.CreateTexture(width, height,
                                                 format: format, access: access);

            texture.Width.Should().Be(width);
            texture.Height.Should().Be(height);
            texture.Format.Should().Be(format);
            texture.Access.Should().Be(access);
        }
Beispiel #15
0
        /// <summary>
        /// Creates a texture with the specified dimensions, format and access
        /// type.
        /// </summary>
        /// <param name="w">Width in pixels</param>
        /// <param name="h">Height in pixels</param>
        /// <param name="quality">Filtering quality when texture is scaled</param>
        /// <param name="format">Pixel format</param>
        /// <param name="access">Texture access type</param>
        public Texture CreateTexture(int w, int h,
                                     TextureScalingQuality quality = TextureScalingQuality.Nearest,
                                     PixelFormat format            = PixelFormat.Format_ARGB8888,
                                     TextureAccess access          = TextureAccess.Static)
        {
            Try(() =>
                SDL_SetHint(SDL_HINT_RENDER_SCALE_QUALITY, quality.AsHint()),
                "SDL_SetHint");
            var texture = SDL_CreateTexture(Handle, (uint)format, (int)access, w, h);

            if (texture == IntPtr.Zero)
            {
                throw new ImaginiException($"Could not create texture: {SDL_GetError()}");
            }
            return(new Texture(texture, this));
        }
Beispiel #16
0
        public void bindImageBuffer(int bufferId, int location, TextureAccess access, SizedInternalFormat format)
        {
            if (access == 0)
            {
                access = TextureAccess.ReadOnly;
            }
            if (format == 0)
            {
                format = SizedInternalFormat.R32f;
            }

            if (myBoundImageBuffers[location] != bufferId)
            {
                GL.BindImageTexture(location, bufferId, 0, false, 0, access, format);
                myBoundImageBuffers[location] = bufferId;
            }
        }
Beispiel #17
0
        public void ShouldNotAllowLockingNonStreamingTextures(TextureAccess access)
        {
            var texture = graphics.CreateTexture(1, 1, access: access);

            Assert.ThrowsAny <ImaginiException>(() => texture.Lock(out _, out _));
        }
Beispiel #18
0
 /// <summary>
 /// Binds a Image3D for use in shaders using image load store.
 /// </summary>
 /// <param name="unit">Image unit to bind the texture to</param>
 /// <param name="texture">The texture object to bind, can be null to unbind a texture</param>
 /// <param name="access">Texture access mode</param>
 /// <param name="level">The mip level of the texture to bind</param>
 public void BindImage3D(int unit, Texture texture, TextureAccess access, int level = 0)
 {
     BindImage(unit, texture, access, true, level, 0);
 }
Beispiel #19
0
 private void BindImage(int unit, Texture texture, TextureAccess access, bool layered, int level, int layer)
 {
     GL.BindImageTexture(unit, texture?.Handle ?? 0, level, layered, layer, access, (SizedInternalFormat)(texture != null ? texture.Format : SizedInternalFormatGlob.R32UI));
 }
Beispiel #20
0
 /// <summary>
 /// Bind image/texture to image load/store unit.
 /// </summary>
 /// <param name="unit">binding unit</param>
 /// <param name="level">level of the texture/image to be bound</param>
 /// <param name="layered">is the texture layered (e.g. like a cube map is)</param>
 /// <param name="layer">layer of the layered texture to be bound</param>
 /// <param name="access">how shaders can access the texture resource</param>
 /// <param name="format">texture format of the texture</param>
 /// <param name="glname">texture/image to be bound</param>
 public static void BindImg(int unit, int level, bool layered, int layer,
     TextureAccess access, GpuFormat format, int glname)
 {
     // bind image to image load/store unit
     if ((imgUnits[unit].glname = glname) > 0)
     {
         imgUnits[unit].access = access;
         imgUnits[unit].format = (SizedInternalFormat)format;
     }
     GL.BindImageTexture(unit, glname, level, layered, Math.Max(layer, 0),
         imgUnits[unit].access, imgUnits[unit].format);
 }
Beispiel #21
0
 /// <summary>
 /// Binds a Image2D for use in shaders using image load store.
 /// </summary>
 /// <param name="unit">Image unit to bind the texture to</param>
 /// <param name="texture">The texture object to bind, can be null to unbind a texture</param>
 /// <param name="access">Texture access mode</param>
 /// <param name="level">The mip level of the texture to bind</param>
 /// <param name="layer">The layer of the texture to bind - only relevant when binding a single layer of a 2D array or 3D texture as a 2D image.</param>
 public void BindImage2D(int unit, Texture texture, TextureAccess access, int level = 0, int layer = 0)
 {
     BindImage(unit, texture, access, false, level, layer);
 }
Beispiel #22
0
 /// <summary>
 /// Binds a single face of the given texture level to an image unit.<br/>
 /// Calculates the index of the layer-face as 6 * arrayLayer + face.
 /// </summary>
 /// <param name="imageUnit">The image unit to use.</param>
 /// <param name="texture">The texture to bind.</param>
 /// <param name="level">The mipmap level to bind.</param>
 /// <param name="arrayLayer">The layer of the texture to bind.</param>
 /// <param name="face">The cube map face to bind.</param>
 /// <param name="access">Specifies the type of access allowed on the image.</param>
 public void Bind(int imageUnit, TextureCubemapArray texture, int level, int arrayLayer, int face, TextureAccess access)
 {
     // note: the layer parameter indexes the layer-faces, hence the multiplication of the array-layer by 6
     Bind(imageUnit, texture, level, false, 6 * arrayLayer + face, access);
 }
Beispiel #23
0
 /// <summary>
 /// Bind texture to compute-image unit.
 /// </summary>
 /// <param name="unit">Image unit.</param>
 /// <param name="tex">Texture object.</param>
 /// <param name="level">Texture mipmap level.</param>
 /// <param name="layer">Texture array index or texture depth.</param>
 /// <param name="access">How the texture will be accessed by the shader.</param>
 /// <param name="format">Pixel format of texture pixels.</param>
 public static void BindImg(int unit, GLTexture tex, int level = 0, int layer = 0,
     TextureAccess access = TextureAccess.ReadOnly, GpuFormat format = GpuFormat.Rgba8)
     => FxDebugger.BindImg(unit, level, tex?.glImg?.Length > 0, layer, access, format, tex?.glname ?? 0);
Beispiel #24
0
 public void addImage(Texture t, TextureAccess access, int bindPoint)
 {
     renderState.setImageBuffer((int)t.id(), bindPoint, access, (SizedInternalFormat)t.pixelFormat);
 }
Beispiel #25
0
 /// <summary>
 /// Binds an entire level of the given texture to an image unit.<br/>
 /// The mipmap level defaults to zero.
 /// </summary>
 /// <param name="imageUnit">The image unit to use.</param>
 /// <param name="texture">The texture to bind.</param>
 /// <param name="access">Specifies the type of access allowed on the image.</param>
 public void Bind(int imageUnit, Texture texture, TextureAccess access)
 {
     Bind(imageUnit, texture, 0, true, 0, access);
 }
Beispiel #26
0
 public void BindImageUnit(int unit, TextureAccess access, SizedInternalFormat format)
 {
     Generate();
     GL.BindImageTexture(unit, Handle, 0, true, 0, access, format);
 }
Beispiel #27
0
 public Texture(Renderer renderer, PixelFormat format,
                TextureAccess access, int w, int h)
     : base(SDL_CreateTexture(renderer.handle, format, access, w, h))
 {
 }
Beispiel #28
0
 private static extern IntPtr SDL_CreateTexture(
     IntPtr renderer, PixelFormat format, TextureAccess access,
     int w, int h);
Beispiel #29
0
 /// <summary>
 /// Binds a single face of the given texture level to an image unit.
 /// </summary>
 /// <param name="imageUnit">The image unit to use.</param>
 /// <param name="texture">The texture to bind.</param>
 /// <param name="level">The mipmap level to bind.</param>
 /// <param name="face">The cube map face to bind.</param>
 /// <param name="access">Specifies the type of access allowed on the image.</param>
 public void Bind(int imageUnit, TextureCubemap texture, int level, int face, TextureAccess access)
 {
     Bind(imageUnit, texture, level, false, face, access);
 }
Beispiel #30
0
 /// <summary>
 /// Binds a single layer of the given texture level to an image unit.<br/>
 /// Note that for cube maps and cube map arrays the <paramref name="layer"/> parameter actually indexes the layer-faces.<br/>
 /// Thus for cube maps the layer parameter equals the face to be bound.<br/>
 /// For cube map arrays the layer parameter can be calculated as 6 * arrayLayer + face, which is done automatically when using
 /// the corresponding overload <see cref="Bind(int,TextureCubemapArray,int,int,int,OpenTK.Graphics.OpenGL.TextureAccess)"/>.
 /// </summary>
 /// <param name="imageUnit">The image unit to use.</param>
 /// <param name="texture">The texture to bind.</param>
 /// <param name="level">The mipmap level to bind.</param>
 /// <param name="layer">The layer of the texture to bind.</param>
 /// <param name="access">Specifies the type of access allowed on the image.</param>
 public void Bind(int imageUnit, LayeredTexture texture, int level, int layer, TextureAccess access)
 {
     Bind(imageUnit, texture, level, false, layer, access);
 }
Beispiel #31
0
 public void bindImageUnit(int texture_uniform, int index, TextureAccess access, int level)
 {
     bindImageUnit(texture_uniform, index, access, level, 0);
 }
Beispiel #32
0
 public void Bind(int location, TextureAccess access)
 {
     texture.BindImage(location, access, SizedInternalFormat.Rgba16f);
 }