<blockquote>
  <p>I use sampler objects to set texture filtering not <code>glTexParameteri</code> functions. </p>
</blockquote>

<p>No, you do not. <a href="https://www.opengl.org/wiki/Image_Load_Store" rel="nofollow noreferrer">Image Load/Store</a> doesn't use samplers, so you cannot be using sampler objects to set the texture's filtering, when you're using the texture with Image Load/Store.</p>

<p>Sure, Image Load/Store doesn't use the <a href="https://www.opengl.org/wiki/Texture#Texture_Objects" rel="nofollow noreferrer">built-in sampler data stored in a texture object</a> <em>either</em>. However, those parameters <em>do</em> have an effect. They can determine if a texture is <em>complete</em>.</p>

<p>And <em>whether you're using those parameters or not</em>, if a texture is not complete, you can't access the texture from the GPU. Among the texture completeness rules is that the texture's sampling parameters must be valid, with respect to the texture's image format.</p>

<p>The default filtering parameters for textures are some form of LINEAR filtering; OpenGL does not change these defaults based on the image format. Therefore, a fresh texture with an integer image format will be incomplete <em>unless</em> you explicitly set the mag/min filters to <code>GL_NEAREST</code> (or <code>NEAREST_MIPMAP_NEAREST</code> for min).</p>

<p>You can get away with what you have when using the texture with <a href="https://www.opengl.org/wiki/Sampler_Object" rel="nofollow noreferrer">sampler objects</a> because their parameters override the completeness check. But as previously mentioned, Image Load/Store doesn't care about the bound sampler objects. Therefore, the completeness check must look at the texture's sampling parameters.</p>

<p>This is regardless of the fact that Image Load/Store itself doesn't actually <em>use</em> those parameters. So it's pointless, but you've gotta do it.</p>

CC BY-SA 3.0
2016-11-14T17:44:24.810Z
That's quite a clarified explanation for that somewhat tricky problem.
mdkdy
CC BY-SA 3.0
2016-11-14T16:01:54.830Z
2016-11-14T18:06:49.460Z
2016-11-14T18:06:49.460Z
Nicol Bolas
<p>Made a new question as suggested, follow up to that <a href="https://computergraphics.stackexchange.com/questions/4197/setting-up-integer-texture-and-binding-as-image">one</a>.</p>

<p>I was experimenting with texture declaration to find solution and thats how I done that before (<code>unsigned int</code>):</p>

<pre><code>glGenTextures(1, &amp;m_texture);
glBindTexture(GL_TEXTURE_3D, m_texture);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, width, height, depth, 0, GL_RGBA_INTEGER, 
GL_UNSIGNED_INT, NULL);
glGenerateMipap(GL_TEXTURE_3D);

glGenSamplers(1, &amp;m_sampler);
glSamplerParameteri(m_sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
</code></pre>

<p>And for that using <code>imagestore</code> for <code>int</code>/<code>unsigned int</code> didnt work despite correct binding for writing as <code>uimage</code> , <code>rgba32ui</code>, <code>uvec4</code> format and for reading as <code>usampler</code>, <code>uvec4</code> format. Of course also binding <code>sampler</code> object for reading.</p>

<p>But I added two lines:</p>

<pre><code>glGenTextures(1, &amp;m_texture);
glBindTexture(GL_TEXTURE_3D, m_texture);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, width, height, depth, 0, GL_RGBA_INTEGER, 
GL_UNSIGNED_INT, NULL);

glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); //
glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); //

glGenerateMipmap(GL_TEXTURE_3D);

glGenSamplers(1, &amp;m_sampler);
glSamplerParameteri(m_sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
</code></pre>

<p>And now it seems to work. Still need to bind <code>sampler</code> thought. But I fail to see any logic in this. I use <a href="https://www.opengl.org/wiki/Sampler_Object" rel="nofollow noreferrer">sampler</a> objects to set texture filtering not <code>glTexParameteri</code> functions. </p>

<p><code>Float</code> textures work with <code>sampler</code> objects as in first block of code. Anyone can explain?</p>

<opengl><texture>
setting up integer texture and binding as image pt. 2
mdkdy
# setting up integer texture and binding as image pt. 2

(Asked by: username_0 on 2016-11-13)

Made a new question as suggested, follow up to that [one](https://computergraphics.stackexchange.com/questions/4197/setting-up-integer-texture-and-binding-as-image).

I was experimenting with texture declaration to find solution and thats how I done that before (`unsigned int`):

```
glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_3D, m_texture);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, width, height, depth, 0, GL_RGBA_INTEGER, 
GL_UNSIGNED_INT, NULL);
glGenerateMipap(GL_TEXTURE_3D);

glGenSamplers(1, &m_sampler);
glSamplerParameteri(m_sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

```

And for that using `imagestore` for `int`/`unsigned int` didnt work despite correct binding for writing as `uimage` , `rgba32ui`, `uvec4` format and for reading as `usampler`, `uvec4` format. Of course also binding `sampler` object for reading.

But I added two lines:

```
glGenTextures(1, &m_texture);
glBindTexture(GL_TEXTURE_3D, m_texture);
glTexImage3D(GL_TEXTURE_3D, 0, GL_RGBA32UI, width, height, depth, 0, GL_RGBA_INTEGER, 
GL_UNSIGNED_INT, NULL);

glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST ); //
glTexParameteri( GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST ); //

glGenerateMipmap(GL_TEXTURE_3D);

glGenSamplers(1, &m_sampler);
glSamplerParameteri(m_sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
glSamplerParameteri(m_sampler, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);

```

And now it seems to work. Still need to bind `sampler` thought. But I fail to see any logic in this. I use [sampler](https://www.opengl.org/wiki/Sampler_Object) objects to set texture filtering not `glTexParameteri` functions.

`Float` textures work with `sampler` objects as in first block of code. Anyone can explain?

**Tags:** opengl, texture


---

## 1 answers

### Answer by username_1 on 2016-11-14. Score: 2 | Accepted answer

> I use sampler objects to set texture filtering not `glTexParameteri` functions.

No, you do not. [Image Load/Store](https://www.opengl.org/wiki/Image_Load_Store) doesn't use samplers, so you cannot be using sampler objects to set the texture's filtering, when you're using the texture with Image Load/Store.

Sure, Image Load/Store doesn't use the [built-in sampler data stored in a texture object](https://www.opengl.org/wiki/Texture#Texture_Objects) *either*. However, those parameters *do* have an effect. They can determine if a texture is *complete*.

And *whether you're using those parameters or not*, if a texture is not complete, you can't access the texture from the GPU. Among the texture completeness rules is that the texture's sampling parameters must be valid, with respect to the texture's image format.

The default filtering parameters for textures are some form of LINEAR filtering; OpenGL does not change these defaults based on the image format. Therefore, a fresh texture with an integer image format will be incomplete *unless* you explicitly set the mag/min filters to `GL_NEAREST` (or `NEAREST_MIPMAP_NEAREST` for min).

You can get away with what you have when using the texture with [sampler objects](https://www.opengl.org/wiki/Sampler_Object) because their parameters override the completeness check. But as previously mentioned, Image Load/Store doesn't care about the bound sampler objects. Therefore, the completeness check must look at the texture's sampling parameters.

This is regardless of the fact that Image Load/Store itself doesn't actually *use* those parameters. So it's pointless, but you've gotta do it.

> **Comments:**
> **username_0**: That's quite a clarified explanation for that somewhat tricky problem.  

---

