Bug 89107 - [Radeonsi/Hawaii] Rendering errors when running basic opengl 3 demo
Summary: [Radeonsi/Hawaii] Rendering errors when running basic opengl 3 demo
Status: RESOLVED NOTOURBUG
Alias: None
Product: Mesa
Classification: Unclassified
Component: Mesa core (show other bugs)
Version: git
Hardware: x86-64 (AMD64) Linux (All)
: medium normal
Assignee: mesa-dev
QA Contact: mesa-dev
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2015-02-12 16:15 UTC by Sebastian Parborg
Modified: 2015-02-17 02:05 UTC (History)
1 user (show)

See Also:
i915 platform:
i915 features:


Attachments
The lab files. (128.02 KB, application/octet-stream)
2015-02-12 16:15 UTC, Sebastian Parborg
Details
Bunny render errors (23.01 KB, image/png)
2015-02-12 16:16 UTC, Sebastian Parborg
Details
glxinfo output (58.55 KB, text/plain)
2015-02-12 16:17 UTC, Sebastian Parborg
Details
The bunny on fglrx and/or the binary nvidia drivers (24.11 KB, image/png)
2015-02-16 07:10 UTC, Sebastian Parborg
Details
s/MicroGlut/freeglut/ (103.75 KB, application/octet-stream)
2015-02-16 09:34 UTC, Grigori Goronzy
Details

Description Sebastian Parborg 2015-02-12 16:15:39 UTC
Created attachment 113408 [details]
The lab files.

I'm currently taking a course in Opengl 3 graphics programming.

When doing the first lab I noticed that the bunny (and other objects) had quite severe rendering errors when using the open source driver for my graphics card.
See the attached image for how it looks.

There seems to be a problem with the facing direction of the rendered triangles. However, it doesn't do that much of a difference if I turn off culling either...

The bunny renders correctly on nvidia cards (with the closed source drivers) and on my card running fgrlx. The professor in charge of the course is running OSX, and the lab computers are running Linux (with nvidia cards). So I guess this is a problem only with Mesa (or something else in the driver stack).
I haven't tried on intel cards so I can't say if this is just a problem with radeonsi or not.

I've attached the lab code. It should run on Linux and OSX. I would really appreciate if other people could try it out so we can see if this is a general problem with mesa or not.

I haven't seen anything like this in other opengl 3 programs. So if there is a problem with the code, IE it breaks opengl spec, then please tell me so I can inform the professor about it.
Comment 1 Sebastian Parborg 2015-02-12 16:16:20 UTC
Created attachment 113409 [details]
Bunny render errors
Comment 2 Sebastian Parborg 2015-02-12 16:17:42 UTC
Created attachment 113410 [details]
glxinfo output
Comment 3 Ilia Mirkin 2015-02-12 17:40:27 UTC
FWIW just tested on nvc0, llvmpipe, and softpipe -- all give the same results. At the very least this is a gallium issues, if not a mesa one. (Classic swrast doesn't do GL3.2, don't have i965 handy.)
Comment 4 Tapani Pälli 2015-02-13 09:34:45 UTC
It looks like lab1-1.c source does not match provided binary lab1-1. If I compile sources again I get segfault at _mesa_UniformMatrix4fv.
Comment 5 Sebastian Parborg 2015-02-13 12:16:33 UTC
(In reply to Tapani Pälli from comment #4)
> It looks like lab1-1.c source does not match provided binary lab1-1. If I
> compile sources again I get segfault at _mesa_UniformMatrix4fv.

The binary should be representative of what is in the .c file. I forgot to remove the binary when I created the archive.

I do not get a segfault when recompiling. It work just like before :S
Comment 6 Tapani Pälli 2015-02-16 06:01:57 UTC
(In reply to Sebastian Parborg from comment #5)
> (In reply to Tapani Pälli from comment #4)
> > It looks like lab1-1.c source does not match provided binary lab1-1. If I
> > compile sources again I get segfault at _mesa_UniformMatrix4fv.
> 
> The binary should be representative of what is in the .c file. I forgot to
> remove the binary when I created the archive.
> 
> I do not get a segfault when recompiling. It work just like before :S

The way how you pass matrix does not seem legit with C standard. Which compiler and version are you using? Are you using C or C++ compiler?
Comment 7 Tapani Pälli 2015-02-16 06:08:24 UTC
I got it compiling and working when using '--std=c99' but even then the visual result of the app is different than what the prebuilt binary provides. For me the bunny is completely solid black (on i965 driver).
Comment 8 Sebastian Parborg 2015-02-16 06:28:00 UTC
(In reply to Tapani Pälli from comment #6)
> 
> The way how you pass matrix does not seem legit with C standard. Which
> compiler and version are you using? Are you using C or C++ compiler?

I'm using gcc 4.9. And gcc (not g++) as written in the makefile.

You you running the latest git version of the intel drivers/mesa?
Comment 9 Sebastian Parborg 2015-02-16 06:52:05 UTC
Disregard the last question. You have to use the supplied makefile!

The bunny is black for you because you didn't use the "-DGL_GLEXT_PROTOTYPES" compile flag.
Comment 10 Tapani Pälli 2015-02-16 07:01:23 UTC
(In reply to Sebastian Parborg from comment #9)
> Disregard the last question. You have to use the supplied makefile!
> 
> The bunny is black for you because you didn't use the
> "-DGL_GLEXT_PROTOTYPES" compile flag.

Yep true that's was the case, the result is same now.
Comment 11 Sebastian Parborg 2015-02-16 07:10:18 UTC
Created attachment 113518 [details]
The bunny on fglrx and/or the binary nvidia drivers

This is how it look like when using the nvidia binary drivers or fglrx.
Comment 12 Grigori Goronzy 2015-02-16 09:30:23 UTC
This seems to be related to the context creation by the included "MicroGlut". The code of this is quite messy. My guess is that something is wrong with context creation, not Mesa.

If I replace "MicroGlut" with freeglut, it works as expected.
Comment 13 Grigori Goronzy 2015-02-16 09:34:27 UTC
Created attachment 113522 [details]
s/MicroGlut/freeglut/
Comment 14 Sebastian Parborg 2015-02-16 10:20:07 UTC
(In reply to Grigori Goronzy from comment #12)
> This seems to be related to the context creation by the included
> "MicroGlut". The code of this is quite messy. My guess is that something is
> wrong with context creation, not Mesa.
> 
> If I replace "MicroGlut" with freeglut, it works as expected.

Thanks for posting a workaround/fix! I'll try it out soon. ( Now i don't have to reboot to fglrx to work on the labs, thanks to you :) )

My professors "MicroGlut" might be the cause of this problem, I agree.
The question is what it's doing wrong though. I mean, it seems to work fine on OSX and with the proprietary drivers from nvidia and amd on Linux.

So if it renders correctly with all of those then what is it doing wrong? Do all those drivers interpret faulty code the "right" way? To me it seems quite unlikely that all those drivers would interpret the faulty code the exact same way so it doesn't break on any of them.
Comment 15 Grigori Goronzy 2015-02-16 12:22:22 UTC
The call to glXChooseFBConfig in MicroGlut doesn't specify any attribute list, so a list of all configs is returned by it. Later on, the GLX context i just uses the first returned config, which can be pretty much anything. When I specify a attribute list to get a suitable FB config, it works fine.

Other drivers might get away with it because they return the FB configs in a different order, but obviously you can't count on this.
Comment 16 Sebastian Parborg 2015-02-16 14:47:51 UTC
(In reply to Grigori Goronzy from comment #15)
> The call to glXChooseFBConfig in MicroGlut doesn't specify any attribute
> list, so a list of all configs is returned by it. Later on, the GLX context
> i just uses the first returned config, which can be pretty much anything.
> When I specify a attribute list to get a suitable FB config, it works fine.
> 
> Other drivers might get away with it because they return the FB configs in a
> different order, but obviously you can't count on this.

Ah, that makes sense. It works for me now too :)

Thank you (and everyone else) for your help! I will inform my professor and hope that he includes the changes so other students doesn't have to run into the same problems as I did.

I guess this bug can be closed then? As you said, the order of the returned configs doesn't have to be in any specific order. So I guess the other drivers just got lucky.


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.