-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Downgrading webGL precision if target hardware does not support highest #4433
Conversation
src/filters/base_filter.class.js
Outdated
@@ -20,6 +20,8 @@ fabric.Image.filters.BaseFilter = fabric.util.createClass(/** @lends fabric.Imag | |||
*/ | |||
type: 'BaseFilter', | |||
|
|||
webGlPrecision: 'highp', |
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.
can we make this fabric global property? as we have fabric.webGlprecision. texture size is also there
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.
on it
src/filters/webgl_backend.class.js
Outdated
@@ -19,6 +37,19 @@ | |||
if (gl) { | |||
fabric.maxTextureSize = gl.getParameter(gl.MAX_TEXTURE_SIZE); | |||
isSupported = fabric.maxTextureSize >= tileSize; | |||
var precision; | |||
var precisions = ['highp', 'mediump', 'lowp']; |
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.
are there outside implementation that works but do not support lowp? how do they work at all?
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.
I don't know actually - I just wrote it to be as safe as possible for any scenario.
Do you have any webgl skill that go beyond the complete beginner that i am? |
} | ||
return true; | ||
} | ||
|
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.
unsure about the position of this function.
fabric.isWebglSupported can be overridden by a dev with something more fancy.
testPrecision is here with a jsdoc, but will not be catched is not attached to any object, and can't be used from outside or from an overridden isWebglSupported. can you think of something better than calling it fabric.testPrecision?
does not block merging
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.
Sorry, I don't follow. Do you want to move testPrecision to fabric object as well?
Like all developers, I am not good at naming things :D
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.
Maybe I should move the testprecision function inside isWebGlSupported function?
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.
no i would leave it here. i was just wondering if it makes sense to have a non accessible function that can't be reused if a dev change the implementation of isWebglSupported
. not a problem at all.
I changed a bit, now I am no longer handling a scenario where none of the precision are supported - I think if it passes the isWebGlSupported test, at least one precision should be supported as well. When it comes to WebGL skill, then my entire contact with webgl is from reading your source... |
oh ok, so consider this is my first webgl experience before reusing this code. i have been helped lot from @plainview ( fifty fifty maybe ? ) |
everything looks good. i ll wait some minute and merge, just in case you spot something else. |
Maybe I should move the testprecision function inside isWebGlSupported function since it's not used anywhere else as you say? EDIT: nvm, saw your response |
that is not a big deal. there is added value here, is fine as it is. |
Do you want a fabricjs sticker? do you work with other devs that would stick it on some laptop/hardware? |
Absolutely! 2 other devs beside me... |
Hey @ozooner did you consider already the gl.getShaderPrecisionFormat() method? Was it unsuitable for this use-case? https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getShaderPrecisionFormat |
Good catch, I'll try it out! |
what is the performance of that mali gpu anyway? what it can actually filter and at what speed? |
@plainview - so this is what the hardware in question returns for that function:
As you can see, I could use that function to detect if returnObject.precision === 0. But if I go down that path, I don't know if there could be any hardware that would return 0 for @asturur Amazon is using this GPU, because it is highly optimized for h264 decoding. For fabric I am just using tint filter to paint SVG's once, so it is not a problem for me. I am also using animations - certain animations, such as rotate/scaleX/scaleY work around 20 fps, but animating position properties (left/top) is rather laggy |
According to pyalot a precision of It will also always be 0 for integer types but I don't believe that is something we need to worry about here. I am no expert on this though. |
let's keep what we have. This if fine and introduce the added knowledge that this thing must be checked. i would like to understand what those numbers mean before using them. @ozooner if you send me an address i ll send some stickers as soon as i cumulate some shipping ( a whopping 5 request for now, not worth a travel to post office ). |
E-mailed my address |
…st (fabricjs#4433) * Downgrading webGL precision if target hardware does not support highest * moved webGlPrecision to fabric property
So there are multiple ways to go about fixing the precision change, this is the one I came up with and like the most. If you think there's more elegant way of doing it - let me know and I can refactor and test it.