Bug 58498 - WebGL should create a single-sample context if creating multisampled context fails
Summary: WebGL should create a single-sample context if creating multisampled context ...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebGL (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-04-13 17:25 PDT by Zhenyao Mo
Modified: 2024-01-17 00:51 PST (History)
6 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Zhenyao Mo 2011-04-13 17:25:45 PDT
For example, in Chrome, ATI's multisampling on Mac is blocked, so creating a multimsampled context will fail, however, we should try to create a single-sample context and set attributes.antialias to false.
Comment 1 Naoki Takano 2011-06-17 11:29:36 PDT
I want to start looking into the bug. But sill I'm very new about WebGL area. So I have a question.

So does this mean anti-alias feature on GPU?

Could you tell me more how I can reproduce the problem?

For example, pseudo code would be very helpful.

Thanks,
Comment 2 Zhenyao Mo 2011-06-17 12:09:34 PDT
One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.

In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.

Currently that code path doesn't recover from error.  So what we need to do is

1) check if creation of multisampled FBO succeeds or not.
2) if it failed, set m_attrs.antialias = false, and try again.

One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.

Hope this helps.
Comment 3 Naoki Takano 2011-06-17 12:31:46 PDT
Thanks, Mo.

So can we reproduce on any Mac environment?
Do we need any specific hardware configuration, such as GPU type?

(In reply to comment #2)
> One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.
> 
> In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.
> 
> Currently that code path doesn't recover from error.  So what we need to do is
> 
> 1) check if creation of multisampled FBO succeeds or not.
> 2) if it failed, set m_attrs.antialias = false, and try again.
> 
> One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.
> 
> Hope this helps.
Comment 4 Zhenyao Mo 2011-06-17 12:33:59 PDT
We don't exactly know on which hardware the multisampled FBO creation might fail.  You'll have to emulate failure in the multisampled path to test the recovering and fallback to non-multisampled path.

(In reply to comment #3)
> Thanks, Mo.
> 
> So can we reproduce on any Mac environment?
> Do we need any specific hardware configuration, such as GPU type?
> 
> (In reply to comment #2)
> > One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.
> > 
> > In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.
> > 
> > Currently that code path doesn't recover from error.  So what we need to do is
> > 
> > 1) check if creation of multisampled FBO succeeds or not.
> > 2) if it failed, set m_attrs.antialias = false, and try again.
> > 
> > One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.
> > 
> > Hope this helps.
Comment 5 Naoki Takano 2011-06-18 22:28:43 PDT
Mo,

Sorry for bothering you.

But I want to make sure the source code you suggested.

Right now, I'm mainly working on Chromium source code base. And even after I change something in GraphicsContext3DOpenGL.cpp, I cannot see anything when I run 'make'. As you know, if we change anything for the source code, we should be able to see compile process when 'make'.

I checked on Linux and Mac. But I cannot see any compilation on both platforms.

Is this source cod used by Chromium port? Or do I need to set extra build setting to use this portion?

Thanks,

(In reply to comment #4)
> We don't exactly know on which hardware the multisampled FBO creation might fail.  You'll have to emulate failure in the multisampled path to test the recovering and fallback to non-multisampled path.
> 
> (In reply to comment #3)
> > Thanks, Mo.
> > 
> > So can we reproduce on any Mac environment?
> > Do we need any specific hardware configuration, such as GPU type?
> > 
> > (In reply to comment #2)
> > > One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.
> > > 
> > > In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.
> > > 
> > > Currently that code path doesn't recover from error.  So what we need to do is
> > > 
> > > 1) check if creation of multisampled FBO succeeds or not.
> > > 2) if it failed, set m_attrs.antialias = false, and try again.
> > > 
> > > One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.
> > > 
> > > Hope this helps.
Comment 6 Zhenyao Mo 2011-06-20 10:17:20 PDT
Ah sorry for confusing you.

GraphicsContext3DOpenGL.cpp is used by webkit Mac port (Safari).

For chromium, the in-process port is in chromium tree under src/webkit/gpu/webgraphicscontext3d_in_process_impl.cc:reshape();

the command buffer port is under the same folder, but you need to dig deeper into the command buffer code to add the behavior, and reshape function is the entry.



(In reply to comment #5)
> Mo,
> 
> Sorry for bothering you.
> 
> But I want to make sure the source code you suggested.
> 
> Right now, I'm mainly working on Chromium source code base. And even after I change something in GraphicsContext3DOpenGL.cpp, I cannot see anything when I run 'make'. As you know, if we change anything for the source code, we should be able to see compile process when 'make'.
> 
> I checked on Linux and Mac. But I cannot see any compilation on both platforms.
> 
> Is this source cod used by Chromium port? Or do I need to set extra build setting to use this portion?
> 
> Thanks,
> 
> (In reply to comment #4)
> > We don't exactly know on which hardware the multisampled FBO creation might fail.  You'll have to emulate failure in the multisampled path to test the recovering and fallback to non-multisampled path.
> > 
> > (In reply to comment #3)
> > > Thanks, Mo.
> > > 
> > > So can we reproduce on any Mac environment?
> > > Do we need any specific hardware configuration, such as GPU type?
> > > 
> > > (In reply to comment #2)
> > > > One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.
> > > > 
> > > > In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.
> > > > 
> > > > Currently that code path doesn't recover from error.  So what we need to do is
> > > > 
> > > > 1) check if creation of multisampled FBO succeeds or not.
> > > > 2) if it failed, set m_attrs.antialias = false, and try again.
> > > > 
> > > > One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.
> > > > 
> > > > Hope this helps.
Comment 7 Naoki Takano 2011-06-20 10:54:14 PDT
I see, I'll look into it more.

BTW, this is a quite a bit different question. But do you know SKIA_GPU flag? Is the bug related to this flag? If so, how can I turn it on?

Thanks,

(In reply to comment #6)
> Ah sorry for confusing you.
> 
> GraphicsContext3DOpenGL.cpp is used by webkit Mac port (Safari).
> 
> For chromium, the in-process port is in chromium tree under src/webkit/gpu/webgraphicscontext3d_in_process_impl.cc:reshape();
> 
> the command buffer port is under the same folder, but you need to dig deeper into the command buffer code to add the behavior, and reshape function is the entry.
> 
> 
> 
> (In reply to comment #5)
> > Mo,
> > 
> > Sorry for bothering you.
> > 
> > But I want to make sure the source code you suggested.
> > 
> > Right now, I'm mainly working on Chromium source code base. And even after I change something in GraphicsContext3DOpenGL.cpp, I cannot see anything when I run 'make'. As you know, if we change anything for the source code, we should be able to see compile process when 'make'.
> > 
> > I checked on Linux and Mac. But I cannot see any compilation on both platforms.
> > 
> > Is this source cod used by Chromium port? Or do I need to set extra build setting to use this portion?
> > 
> > Thanks,
> > 
> > (In reply to comment #4)
> > > We don't exactly know on which hardware the multisampled FBO creation might fail.  You'll have to emulate failure in the multisampled path to test the recovering and fallback to non-multisampled path.
> > > 
> > > (In reply to comment #3)
> > > > Thanks, Mo.
> > > > 
> > > > So can we reproduce on any Mac environment?
> > > > Do we need any specific hardware configuration, such as GPU type?
> > > > 
> > > > (In reply to comment #2)
> > > > > One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.
> > > > > 
> > > > > In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.
> > > > > 
> > > > > Currently that code path doesn't recover from error.  So what we need to do is
> > > > > 
> > > > > 1) check if creation of multisampled FBO succeeds or not.
> > > > > 2) if it failed, set m_attrs.antialias = false, and try again.
> > > > > 
> > > > > One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.
> > > > > 
> > > > > Hope this helps.
Comment 8 Zhenyao Mo 2011-06-20 11:03:24 PDT
(In reply to comment #7)
> I see, I'll look into it more.
> 
> BTW, this is a quite a bit different question. But do you know SKIA_GPU flag? Is the bug related to this flag? If so, how can I turn it on?

It's on by default on the trunk so if you sync and build your own chromium, you don't need to do anything.  Also, it has nothing to do with this bug.

> 
> Thanks,
> 
> (In reply to comment #6)
> > Ah sorry for confusing you.
> > 
> > GraphicsContext3DOpenGL.cpp is used by webkit Mac port (Safari).
> > 
> > For chromium, the in-process port is in chromium tree under src/webkit/gpu/webgraphicscontext3d_in_process_impl.cc:reshape();
> > 
> > the command buffer port is under the same folder, but you need to dig deeper into the command buffer code to add the behavior, and reshape function is the entry.
> > 
> > 
> > 
> > (In reply to comment #5)
> > > Mo,
> > > 
> > > Sorry for bothering you.
> > > 
> > > But I want to make sure the source code you suggested.
> > > 
> > > Right now, I'm mainly working on Chromium source code base. And even after I change something in GraphicsContext3DOpenGL.cpp, I cannot see anything when I run 'make'. As you know, if we change anything for the source code, we should be able to see compile process when 'make'.
> > > 
> > > I checked on Linux and Mac. But I cannot see any compilation on both platforms.
> > > 
> > > Is this source cod used by Chromium port? Or do I need to set extra build setting to use this portion?
> > > 
> > > Thanks,
> > > 
> > > (In reply to comment #4)
> > > > We don't exactly know on which hardware the multisampled FBO creation might fail.  You'll have to emulate failure in the multisampled path to test the recovering and fallback to non-multisampled path.
> > > > 
> > > > (In reply to comment #3)
> > > > > Thanks, Mo.
> > > > > 
> > > > > So can we reproduce on any Mac environment?
> > > > > Do we need any specific hardware configuration, such as GPU type?
> > > > > 
> > > > > (In reply to comment #2)
> > > > > > One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.
> > > > > > 
> > > > > > In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.
> > > > > > 
> > > > > > Currently that code path doesn't recover from error.  So what we need to do is
> > > > > > 
> > > > > > 1) check if creation of multisampled FBO succeeds or not.
> > > > > > 2) if it failed, set m_attrs.antialias = false, and try again.
> > > > > > 
> > > > > > One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.
> > > > > > 
> > > > > > Hope this helps.
Comment 9 Naoki Takano 2011-06-20 21:29:41 PDT
Mo,

Still I suspect the source file you suggested was wrong.

The correct one is
content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.cc
isn't it?


(In reply to comment #6)
> Ah sorry for confusing you.
> 
> GraphicsContext3DOpenGL.cpp is used by webkit Mac port (Safari).
> 
> For chromium, the in-process port is in chromium tree under src/webkit/gpu/webgraphicscontext3d_in_process_impl.cc:reshape();
> 
> the command buffer port is under the same folder, but you need to dig deeper into the command buffer code to add the behavior, and reshape function is the entry.
> 
> 
> 
> (In reply to comment #5)
> > Mo,
> > 
> > Sorry for bothering you.
> > 
> > But I want to make sure the source code you suggested.
> > 
> > Right now, I'm mainly working on Chromium source code base. And even after I change something in GraphicsContext3DOpenGL.cpp, I cannot see anything when I run 'make'. As you know, if we change anything for the source code, we should be able to see compile process when 'make'.
> > 
> > I checked on Linux and Mac. But I cannot see any compilation on both platforms.
> > 
> > Is this source cod used by Chromium port? Or do I need to set extra build setting to use this portion?
> > 
> > Thanks,
> > 
> > (In reply to comment #4)
> > > We don't exactly know on which hardware the multisampled FBO creation might fail.  You'll have to emulate failure in the multisampled path to test the recovering and fallback to non-multisampled path.
> > > 
> > > (In reply to comment #3)
> > > > Thanks, Mo.
> > > > 
> > > > So can we reproduce on any Mac environment?
> > > > Do we need any specific hardware configuration, such as GPU type?
> > > > 
> > > > (In reply to comment #2)
> > > > > One place you can look at is webcore/platform/graphics/opengl/GraphicsContext3DOpenGL.cpp, reshape function.
> > > > > 
> > > > > In that function, if m_attrs.antialias is true, then we try to create a multisampled FBO for rendering.
> > > > > 
> > > > > Currently that code path doesn't recover from error.  So what we need to do is
> > > > > 
> > > > > 1) check if creation of multisampled FBO succeeds or not.
> > > > > 2) if it failed, set m_attrs.antialias = false, and try again.
> > > > > 
> > > > > One thing unclear to me is that it seems attributes.antialias might change in the lifetime of a context.  I am not sure if it's OK or not.
> > > > > 
> > > > > Hope this helps.
Comment 10 Zhenyao Mo 2011-06-20 23:57:50 PDT
OK, I must have looked at an out-of-sync code base.  Yeah there is only one such file, so that should be it.  Sorry about the wrong location.
Comment 11 Zhenyao Mo 2011-06-23 10:45:02 PDT
I just realized I implemented this behavior in command buffer port while trying to implementing the feature that internal drawing buffer could be smaller size if we fail to create using the requested canvas size.

So if the original drawing buffer is multisampled, we first fallback to a non-multisampled drawing buffer with the same size, and if it fails again, we fallback to smaller size.

See codereview.chromium.org/7238008
Comment 12 Zhenyao Mo 2011-06-23 10:46:17 PDT
(In reply to comment #11)
> I just realized I implemented this behavior in command buffer port while trying to implementing the feature that internal drawing buffer could be smaller size if we fail to create using the requested canvas size.
> 
> So if the original drawing buffer is multisampled, we first fallback to a non-multisampled drawing buffer with the same size, and if it fails again, we fallback to smaller size.
> 
> See codereview.chromium.org/7238008

This is an effort trying to pass webgl conformance test conformance/drawingbuffer-test.html and conformance/drawingbuffer-static-canvas-test.html
Comment 13 Naoki Takano 2011-06-24 20:11:25 PDT
So do you mean I don't have to do anything for Chromium port?

(In reply to comment #12)
> (In reply to comment #11)
> > I just realized I implemented this behavior in command buffer port while trying to implementing the feature that internal drawing buffer could be smaller size if we fail to create using the requested canvas size.
> > 
> > So if the original drawing buffer is multisampled, we first fallback to a non-multisampled drawing buffer with the same size, and if it fails again, we fallback to smaller size.
> > 
> > See codereview.chromium.org/7238008
> 
> This is an effort trying to pass webgl conformance test conformance/drawingbuffer-test.html and conformance/drawingbuffer-static-canvas-test.html
Comment 14 Zhenyao Mo 2011-06-27 11:45:13 PDT
(In reply to comment #13)
> So do you mean I don't have to do anything for Chromium port?

No need for the chromium command-buffer port, but the in-process-webgl and webkit/safari port still need to be implemented.

> 
> (In reply to comment #12)
> > (In reply to comment #11)
> > > I just realized I implemented this behavior in command buffer port while trying to implementing the feature that internal drawing buffer could be smaller size if we fail to create using the requested canvas size.
> > > 
> > > So if the original drawing buffer is multisampled, we first fallback to a non-multisampled drawing buffer with the same size, and if it fails again, we fallback to smaller size.
> > > 
> > > See codereview.chromium.org/7238008
> > 
> > This is an effort trying to pass webgl conformance test conformance/drawingbuffer-test.html and conformance/drawingbuffer-static-canvas-test.html
Comment 15 Kimmo Kinnunen 2024-01-17 00:51:14 PST
Likmly not relevant anymore. WebGL2 must respect the requested configuration. WebGL1 should probably not get the feature if it hasn't been implemented today.