Bug 109057 - texelFetch from GL_TEXTURE_2D_MULTISAMPLE with integer format fails
Summary: texelFetch from GL_TEXTURE_2D_MULTISAMPLE with integer format fails
Alias: None
Product: Mesa
Classification: Unclassified
Component: Drivers/DRI/i965 (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium minor
Assignee: Intel 3D Bugs Mailing List
QA Contact: Intel 3D Bugs Mailing List
Depends on:
Reported: 2018-12-13 19:03 UTC by Max Schwarz
Modified: 2019-04-05 00:32 UTC (History)
0 users

See Also:
i915 platform:
i915 features:

example (needs GLFW and GLEW) (7.13 KB, text/x-c++src)
2018-12-13 19:03 UTC, Max Schwarz

Description Max Schwarz 2018-12-13 19:03:03 UTC
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

My hardware:
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.
Comment 1 Max Schwarz 2018-12-13 21:06:19 UTC
Some further information from glGetIntegerv():


And glGetInternalformativ():
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.
Comment 2 Sergii Romantsov 2019-01-31 07:17:49 UTC
Hello, Max.
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?
Comment 3 Max Schwarz 2019-02-02 12:18:59 UTC
Hi Sergii,

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 :-)
Comment 4 Sergii Romantsov 2019-02-04 07:41:19 UTC
> No, I don't mind. Go ahead :-)
Thanks, will do soon
Comment 5 Illia Iorin 2019-02-12 13:09:49 UTC
Piglit test that shows how texelfetch() works with all possible internal types: https://patchwork.freedesktop.org/patch/285599/
Comment 6 Timothy Arceri 2019-04-05 00:32:27 UTC
Should be fixed by:

commit a113a42e7369a4e43a1db1c9a7a35a3f7175615e
Author: Illia Iorin <illia.iorin@globallogic.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
    These changes are approved by KhronosGroup.
    Signed-off-by: Sergii Romantsov <sergii.romantsov@globallogic.com>
    Signed-off-by: Illia Iorin <illia.iorin@globallogic.com>
    Reviewed-by: Eric Anholt <eric@anholt.net>
    Reviewed-by: Marek Olšák <marek.olsak@amd.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=109057

Illia can you please update the piglit test as per the review comments. Thanks.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.