Created attachment 142804 [details]
example (needs GLFW and GLEW)
I noticed that it seems impossible to read from multisampled textures using texelFetch() if the texture uses an integral format (like GL_R8UI).
I attached a small test for this, where a GL_TEXTURE_2D_MULTISAMPLE is written to by a fragment shader, and then read from in another fragment shader.
I'm using a "uint" output in the writing shader, and "usampler2DMS" in the reading shader - so in my opinion, everything is set up correctly. I haven't got a lot of experience in the OpenGL world, so there might be something I'm missing.
The code works on NVidia drivers, though.
Using Mesa (tested on i965 and nouveau), the test fails - we always obtain zeros from texelFetch().
Most interestingly, it works if I (incorrectly) use GL_R32F as the texture type, even though the shaders both expect integers.
To compile the sample, use:
g++ -std=c++11 -o intel_multisample intel_multisample.cpp -lglfw -lGL -lGLEW
Then run it:
./intel_multisample GL_R8UI # fails
./intel_multisample GL_R32F # works
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 530 (rev 06)
02:00.0 3D controller: NVIDIA Corporation GM108M [GeForce 940MX] (rev a2)
I'd be glad to help with further debugging if it turns out to be a real bug.
Some further information from glGetIntegerv():
Supported sample counts per internal format:
- GL_R16UI: 16 8 4 2
- GL_R32F: 16 8 4 2
- GL_R32UI: 16 8 4 2
- GL_R8UI: 16 8 4 2
Both reported on the intel card.
Here is potential fix on review: https://gitlab.freedesktop.org/mesa/mesa/merge_requests/177
Don't you mind if we will convert your sample to piglit-test?
indeed, that PR fixes my issue. Thanks for cross-referencing!
> Don't you mind if we will convert your sample to piglit-test?
No, I don't mind. Go ahead :-)
> No, I don't mind. Go ahead :-)
Thanks, will do soon
Piglit test that shows how texelfetch() works with all possible internal types: https://patchwork.freedesktop.org/patch/285599/
Should be fixed by:
Author: Illia Iorin <email@example.com>
Date: Thu Feb 28 12:33:50 2019 +0200
mesa/main: Fix multisample texture initialize
Sampler of Multisample textures wasn't initialized correct. So when
texture object created as multisample its sampler is initialized in a
individual case. We change the initial state of TEXTURE_MIN_FILTER and
TEXTURE_MAG_FILTER to NEAREST.
These changes are approved by KhronosGroup.
Signed-off-by: Sergii Romantsov <firstname.lastname@example.org>
Signed-off-by: Illia Iorin <email@example.com>
Reviewed-by: Eric Anholt <firstname.lastname@example.org>
Reviewed-by: Marek Olšák <email@example.com>
Illia can you please update the piglit test as per the review comments. Thanks.