Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GLControl #3386

Merged
merged 25 commits into from
May 11, 2020
Merged

GLControl #3386

merged 25 commits into from
May 11, 2020

Conversation

kekekeks
Copy link
Member

@kekekeks kekekeks commented Dec 22, 2019

disco3

Note there is a bug in ANGLE that prevents us from using stencil buffer on software-rendered DirectX (Microsoft Basic Render Device). I have a patch to fix that, but it will be shipped with our angle nuget separately.

@ahopper
Copy link
Contributor

ahopper commented Dec 24, 2019

runs on an elderly windows laptop here, I had to add .0 to the float literals in the shaders and mediump to the shared uDisco and uTime.

@kekekeks
Copy link
Member Author

kekekeks commented Mar 4, 2020

PR should be ready for review

@kekekeks kekekeks changed the title [WIP] GLControl GLControl Mar 4, 2020
@gulek
Copy link

gulek commented Mar 7, 2020

I used this to embedd libmpv into Avalonia. Worked like a charm, but I had a weird resize issue. The video from mpv would resize, the control would resize, but the visible part would stay exactly the size it was during OnOpenGlInit.
I got it working by binding the texture before resizeing it in OpenGlControlBase.Render:

if (_oldSize != GetPixelSize()) {
    gl.BindTexture(GL_TEXTURE_2D, _texture);
    ResizeTexture(gl);
}

@kekekeks
Copy link
Member Author

kekekeks commented Mar 8, 2020

@gulek
Do you have the same issue with the teapot example from the control catalog?

@kekekeks
Copy link
Member Author

kekekeks commented Mar 8, 2020

Ah, it seems that your code changes the current texture binding and doesn't restore it back.
I think we should also reset the texture binding back to zero to avoid unnecessary confusion.

@dfkeenan
Copy link

Will this be compatible with libraries like OpenTK (4.0)?

@kekekeks
Copy link
Member Author

@dfkeenan that entirely depends on the library. If it's capable of using an external OpenGL context and external glGetProcAddress and isn't afraid of the context being of different types (EGL for Win32, desktop GL for Linux/OSX), it should work.

@kekekeks
Copy link
Member Author

kekekeks commented May 3, 2020

WARP allows interop with other DirectX-based APIs which is kinda important for WPF integration and future support for advanced features like DirectComposition.

Copy link
Collaborator

@MarchingCube MarchingCube left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did a quick check of this PR, I would need to see how this affects other custom GPU implementations as well.


namespace Avalonia.Rendering
{
public class ManagedDeferredRendererLock : IDeferredRendererLock
public class ManagedDeferredRendererLock : DisposableLock, IDeferredRendererLock
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kinda weird - you derive from DisposableLock but all methods here are just hiding base implementation and it ends up having two different locks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since DisposableLock class contents are copy-pasted from ManagedDeferredRendererLock, it's most likely an unfinished attempt to extract disposable lock logic to a different class

100);
var data = "#version " + version + "\n";
if (DisplayType == GlDisplayType.OpenGLES)
data += "precision mediump float\n";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing semicolon after float will cause shader compilation error.

CheckError(GL);

// Create the vertex buffer object (VBO) for the vertex data.
_vertexBufferObject = GL.GenBuffer();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This fails for me on Win32 ANGLE that supports only GLES 2.0.

@ahopper ahopper mentioned this pull request May 4, 2020
Copy link
Member

@danwalmsley danwalmsley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarchingCube has tested it, things were fixed it looks good,

@danwalmsley, @grokys and @kekekeks agreed this is a YOLO merge.

@danwalmsley danwalmsley merged commit ceb2f09 into master May 11, 2020
@danwalmsley danwalmsley deleted the glcontrol branch May 11, 2020 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants