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

Add WebGL impl and enable access to Outline, Contour and Scene #256

Closed
wants to merge 19 commits into from

Conversation

@s3bk
Copy link
Contributor

s3bk commented Jan 31, 2020

This is a squashed commit of my cleaned up collected modifications.

@@ -33,7 +33,7 @@ void computeVaryings() {
vec2 origin = vec2(aTileOrigin.xy) + vec2(aTileOrigin.z & 15u, aTileOrigin.z >> 4u) * 256.0;
vec2 position = (origin + vec2(aTessCoord)) * uTileSize;
vec2 maskTexCoordOrigin = computeTileOffset(uint(aTileIndex), uStencilTextureSize.x);
vec2 maskTexCoord = maskTexCoordOrigin + aTessCoord * uTileSize;
vec2 maskTexCoord = maskTexCoordOrigin + vec2(aTessCoord) * uTileSize;

This comment has been minimized.

@s3bk

s3bk Jan 31, 2020

Author Contributor

The implicit cast turned out to make WebGL very unhappy, so I made it explicit.

}
}

pub struct EmbeddedResourceLoader;

This comment has been minimized.

@s3bk

s3bk Jan 31, 2020

Author Contributor

This can probably use some tuning in the future to only include the files actually needed. But it works for now.

This comment has been minimized.

@pcwalton

pcwalton Jan 31, 2020

Collaborator

Won't this cause a rebuild when changing the shaders? One of the benefits of the FilesystemResourceLoader is live shader editing without rebuilding. I know it's not possible to use the filesystem in WebAssembly, but maybe we should make this enabled on the wasm target only for now.

This comment has been minimized.

@s3bk

s3bk Feb 1, 2020

Author Contributor

I moved the EmbeddedResourceLoader into pathfinder_resources and added a bunch of feature flags to control what gets included.
The demo runs.

@@ -53,6 +58,7 @@ impl<'a> SceneBuilder<'a> {
}

pub fn build<E>(&mut self, executor: &E) where E: Executor {
#[cfg(not(target_arch = "wasm32"))]
let start_time = Instant::now();

This comment has been minimized.

@s3bk

s3bk Jan 31, 2020

Author Contributor

caused a panic in wasm

@@ -17,6 +17,7 @@ use pathfinder_geometry::transform3d::Perspective;
use pathfinder_geometry::vector::{Vector2F, Vector4F};
use pathfinder_content::clip::PolygonClipper3D;

// FIXME: Can this use &mut self ? (Sebastian Köln)

This comment has been minimized.

@s3bk

s3bk Jan 31, 2020

Author Contributor

The idea is to make it a bit faster…

self.flush_current_contour();
self.outline.transform(transform);
self
}

This comment has been minimized.

@s3bk

s3bk Jan 31, 2020

Author Contributor

These functions are used by vector

@pcwalton
Copy link
Collaborator

pcwalton commented Jan 31, 2020

Hmm. Maybe we should move the WebGL code into pathfinder_gl, so that we can avoid duplicating helper functions like flip_y? We can use #[cfg] directives to choose the right implementation.

@s3bk
Copy link
Contributor Author

s3bk commented Jan 31, 2020

flip_y doesn't actually appear to be used

@s3bk s3bk force-pushed the s3bk:PR branch from 7552bf1 to 91a1b44 Jan 31, 2020
@s3bk
Copy link
Contributor Author

s3bk commented Jan 31, 2020

hm. actually that broke something.

@s3bk
Copy link
Contributor Author

s3bk commented Jan 31, 2020

So the EmbeddedResourceLoader is broken and I am not sure why. I didn't change anything from when it was working…
Apparently updating phf to 0.8 caused it.

@s3bk s3bk force-pushed the s3bk:PR branch from 91a1b44 to 4d0e36c Jan 31, 2020
@s3bk s3bk force-pushed the s3bk:PR branch from 4d0e36c to 79b6993 Jan 31, 2020
@s3bk
Copy link
Contributor Author

s3bk commented Jan 31, 2020

working again.

@s3bk s3bk force-pushed the s3bk:PR branch from 0c8782f to 7a5a437 Feb 1, 2020
Put the DebugUiPresenter behind the debug_ui feature flag
@s3bk s3bk force-pushed the s3bk:PR branch from d54c3d8 to 09d940e Feb 1, 2020
@s3bk
Copy link
Contributor Author

s3bk commented Feb 1, 2020

As a side effect of adding fine control over what gets embedded, my wasm is now less than half the size.

@s3bk
Copy link
Contributor Author

s3bk commented Feb 22, 2020

The latest commit is not actually WebGL specific. However it fixed glitches that appear to originate from the tile background texture lookup.

@Dollab
Copy link

Dollab commented Feb 25, 2020

This is really cool ! Would be awesome to merge this !

s3bk added 4 commits Feb 25, 2020
let travis build pathfinder_webgl
@pcwalton
Copy link
Collaborator

pcwalton commented Feb 28, 2020

Reviewing this now.

@pcwalton
Copy link
Collaborator

pcwalton commented Feb 28, 2020

WebGL backend is merged: e2fbde8

@s3bk s3bk closed this Feb 28, 2020
@pcwalton
Copy link
Collaborator

pcwalton commented Feb 28, 2020

Made the WebGL fixes, I believe: ee6c7e0

@zimond
Copy link
Contributor

zimond commented Feb 29, 2020

@pcwalton seems pathfinder_resources is not declared as a dep of pathfinder_webgl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.