-
Notifications
You must be signed in to change notification settings - Fork 3.5k
vo/opengl/formats: use R8 and RG8 formats on GL2.1 and ES2 if available #18264
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,6 +24,15 @@ const struct gl_format gl_formats[] = { | |
| // Specifically not color-renderable. | ||
| {"rgb16", GL_RGB16, GL_RGB, T_U16, F_TF | F_EXT16}, | ||
|
|
||
| // GL 2.1 with GL_ARB/EXT_texture_rg, but without requiring FBOs or float | ||
| // textures (unlike F_GL2F). Upload/filtering only. | ||
| {"r8", GL_R8, GL_RED, T_U8, F_TF | F_GL2RG}, | ||
| {"rg8", GL_RG8, GL_RG, T_U8, F_TF | F_GL2RG}, | ||
|
|
||
| // ES2 with GL_EXT_texture_rg. ES2 requires unsized internal formats. | ||
| {"r", GL_RED, GL_RED, T_U8, F_TF | F_ES2RG}, | ||
| {"rg", GL_RG, GL_RG, T_U8, F_TF | F_ES2RG}, | ||
|
|
||
| // GL2 legacy. Ignores possibly present FBO extensions (no CF flag set). | ||
| {"l8", GL_LUMINANCE8, GL_LUMINANCE, T_U8, F_TF | F_GL2}, | ||
| {"la8", GL_LUMINANCE8_ALPHA8, GL_LUMINANCE_ALPHA, T_U8, F_TF | F_GL2}, | ||
|
|
@@ -104,7 +113,7 @@ const struct gl_format gl_formats[] = { | |
| // Return an or-ed combination of all F_ flags that apply. | ||
| int gl_format_feature_flags(GL *gl) | ||
| { | ||
| return (gl->version == 210 ? F_GL2 : 0) | ||
| int flags = (gl->version == 210 ? F_GL2 : 0) | ||
| | (gl->version >= 300 ? F_GL3 : 0) | ||
| | (gl->es == 200 ? F_ES2 : 0) | ||
| | (gl->es >= 300 ? F_ES3 : 0) | ||
|
|
@@ -116,7 +125,15 @@ int gl_format_feature_flags(GL *gl) | |
| (gl->mpgl_caps & MPGL_CAP_ARB_FLOAT) && | ||
| (gl->mpgl_caps & MPGL_CAP_TEX_RG) && | ||
| (gl->mpgl_caps & MPGL_CAP_FB)) ? F_GL2F : 0) | ||
| | ((gl->version == 210 && | ||
| (gl->mpgl_caps & MPGL_CAP_TEX_RG)) ? F_GL2RG : 0) | ||
| | ((gl->es == 200 && | ||
| (gl->mpgl_caps & MPGL_CAP_TEX_RG)) ? F_ES2RG : 0) | ||
| | (gl->mpgl_caps & MPGL_CAP_APPLE_RGB_422 ? F_APPL : 0); | ||
| // F_GL2RG is a subset of F_GL2F; avoid duplicate format entries. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why? What is this fixing?
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PR adds new entries for r8/rg8 formats (and r/rg for GLES2). Since F_GL2RG is a subset of F_GL2F (which is F_GL2RG + float textures + ARB_framebuffer_object), that would result in two r8/rg8 formats registered twice. This particular line enforces mutual exclusivity - i.e. full color-renderable will be used with F_GL2F hardware, while filter-only fallback is only used on F_GL2RG
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The logic is "clear F_GL2RG is F_GL2F is set", I hope it makes sense.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The format lookup always prefer formats higher on the lists. It's priority list of formats. So there is no issue in having lesser formats down the list. We already have duplication on master between F_GL2 and F_GL2F. Either way, it's fine, just something that is rather not focused on main change. |
||
| if (flags & F_GL2F) | ||
| flags &= ~F_GL2RG; | ||
| return flags; | ||
| } | ||
|
|
||
| int gl_format_type(const struct gl_format *format) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need
!p->main_fbcheck here?GL_FRAMEBUFFER_ATTACHMENT_GREEN_SIZEis itself a GL 3.0 / ARB_framebuffer_object. So if libmpv api user provides FBO we would still try to query it and fail. So we can early exit. no?