Commit Graph

94 Commits

Author SHA1 Message Date
Hajime Hoshi
a3eddeb50f Improve panic messages 2019-02-06 23:43:03 -10:00
Hajime Hoshi
d3d56c076d shareable: Use CopyPixels
CopyPixels is basically Pixels and ReplacePixels, but executed
lazily while Pixels reads pixels from GPU immediately. Thanks to
this, restorable.Image no longer need to keep pixel data if not
needed.
2019-02-03 02:51:56 +09:00
Hajime Hoshi
107dfe5074 graphics: Improve Set speed
On GopherJS, copying a struct is very heavy. This change avoids
copying (color) structs when possible.
2019-01-14 04:25:43 +09:00
Hajime Hoshi
1e1f309a1c shareable: Add Fill
Before introducing Fill, filling an image with a solid color was
implemented by ReplacePixels. When an offscreen image is used, the
offscreen image is not fully cleared or filled with a color and
out of (0,0)-(width,height) region. This causes a glitch thin line
on mobile platforms.

This change adds (*shareable.Image).Fill to fill the whole
framebuffer region of the image.
2019-01-13 02:12:47 +09:00
Hajime Hoshi
b34834a895 graphicscommand: Explicitly forbide ReplacePixels for a part after DrawImage 2019-01-06 05:15:27 +09:00
Hajime Hoshi
b5c9cd6253 shareable: Fix comments 2019-01-06 03:15:32 +09:00
Hajime Hoshi
fbf7007056 restorable: Pixels() should return immediately when it doesn't have to access GPU
Fixes #763
2018-12-26 20:25:40 +09:00
Hajime Hoshi
f1582c2d73 graphics: Add Address representing a sampler address mode
Fixes #761
2018-12-24 17:29:31 +09:00
Hajime Hoshi
189b8a17e9 graphics: Use source-border check even at DrawTriangles
DrawTriangles can now take a sub-image.
2018-12-23 03:24:39 +09:00
Hajime Hoshi
e809991c9f shareable: Bug fix: Image invalidation by ReplacePixels
ReplacePixels on a part of image might invalidate the other part of
the image on MacBook Pro 2013, especially when the other part is
rendered by DrawImage.

Fixes #593 #758
2018-12-21 11:50:10 +09:00
Hajime Hoshi
ff62876552 Add Metal implementation
Fixes #621
2018-12-20 02:37:10 +09:00
Hajime Hoshi
155ee828b8 Fix misspelling 2018-12-03 18:23:25 +01:00
Hajime Hoshi
c6dd0a75d9 graphicscommand: Optimize replace-image calls
Now ReplacePixels command is called only when necessary.

This also ensures that DrawImage must be called after ReplacePixels
is called since there is a potential problem that rendering images
on a texture without initializing by replacing pixels might cause
problems (escpecially on Metal. Perhaps #593 might be related).
2018-12-01 21:36:47 +01:00
Hajime Hoshi
e799a0c6a8 shareable: Fix wrong variable names 2018-12-01 11:31:32 +01:00
Hajime Hoshi
1a54ff34e6 graphics: Forbid nil at ReplacePixels explicitly 2018-11-28 22:26:34 +01:00
Hajime Hoshi
bc3ca38f76 opengl: Rename ResetGLState -> Reset and other functions 2018-11-01 03:02:08 +09:00
seebs
74e204d952 graphics: Speed up DrawTriangles (#723)
DrawTriangles is expensive and slow because of massive memory
allocation and garbage collection costs. This patch moves from ~47TPS
on my laptop (with ~24k triangles) to 60TPS. The first part
is just allocating the right size of vertex buffer up front; that
got to about 55TPS. The second part replaces the frequent
allocations of []float32 in Vertex() calls with writing the
desired values into a provided destination slice.

Time spent in drawing triangles for 1,000 frames:
	13.07s	baseline
	11.09s	preallocate whole buffer to avoid resizing
	6.13s	use new PutVertex function

This might need some cleanup, but I think it's good evidence that
the design change is viable.
2018-10-31 10:53:17 +09:00
Hajime Hoshi
ce1c616f69 Merge graphics and graphicsutil 2018-10-28 23:03:06 +09:00
Hajime Hoshi
ff54d3b681 Move CompositeMode to graphics package 2018-10-28 21:49:47 +09:00
Hajime Hoshi
06f2052817 Add graphics package and move Filter to graphics 2018-10-28 20:25:52 +09:00
Hajime Hoshi
2da5192510 Rename graphics -> graphicscommand 2018-10-28 20:10:05 +09:00
Hajime Hoshi
2360b2930f graphics: Add DrawTriangles
Fixes #624
2018-08-14 01:23:14 +09:00
Hajime Hoshi
690c3cf981 graphics: Embed 'scale' part of the color matrix
If the color matrix includes only 'scale' part, they are embedded
into vertices in order to reduce draw calls.

Fixes #662
2018-08-10 23:20:55 +09:00
Hajime Hoshi
3daaef2cab restorable: Refactoring: Use ReplacePixels(nil, ...) for clearing an image 2018-08-09 01:16:46 +09:00
Hajime Hoshi
c68c36b0b7 restoreable: Add ClearState to clear the state explicitly
Fixes #566
2018-08-09 00:12:45 +09:00
Hajime Hoshi
cdc408d2c2 shareable: Suspend re-using shared images
Fixes #661
2018-08-08 18:40:52 +09:00
Hajime Hoshi
77e905eb25 Revert "graphics: Embed color matrices values to vertices (#655)"
This reverts commit 5a9235aaf9.
2018-08-06 01:44:31 +09:00
Hajime Hoshi
18d77d3f6e shareable: Rename variables 2018-08-03 02:50:11 +09:00
Hajime Hoshi
d7d02e6d6a Reland: graphics: mipmap images should be volatile when the base image is volatile
This is not a bug fix, but should improve performance.
2018-07-30 00:26:36 +09:00
Hajime Hoshi
5be58086b5 Revert "graphics: Bug fix: mipmap images should be volatile when the base image is volatile"
This reverts commit 0f82330009.
2018-07-29 23:58:46 +09:00
Hajime Hoshi
0f82330009 graphics: Bug fix: mipmap images should be volatile when the base image is volatile 2018-07-29 23:54:46 +09:00
Hajime Hoshi
0bf62f392f shareable: Bug fix: forceShared should allocate backend as shareable 2018-07-29 23:49:53 +09:00
Hajime Hoshi
056ed1c6db shareable: Return color.RGBA instead of color.Color 2018-07-29 21:59:18 +09:00
Hajime Hoshi
5a9235aaf9
graphics: Embed color matrices values to vertices (#655)
Fixes #531
2018-07-26 11:37:27 +09:00
Hajime Hoshi
5beaf843a6 shareable: Bug fix: volatile or screen must not use shareable texture 2018-07-24 22:25:15 +09:00
Hajime Hoshi
b2a4ddf853 shareable: Refactoring: Add moveTo 2018-07-22 06:29:31 +09:00
Hajime Hoshi
693116ffd6 shareable: Bug fix: Double free 2018-07-22 05:52:11 +09:00
Hajime Hoshi
6687ffe8ba shareable: Bug fix: SetFinalizer must not be reset at dispose(false) 2018-07-22 05:40:04 +09:00
Hajime Hoshi
09dcba40ab shareable: Rename variables 2018-07-22 04:32:36 +09:00
Hajime Hoshi
a6edb90898 shareable: Use the shared backend again in some conditions
Fixes #633
2018-07-22 04:03:35 +09:00
Hajime Hoshi
9047e54ae6 shareable: Remove comments 2018-07-21 03:43:12 +09:00
Hajime Hoshi
5249afc06b graphicsutil: Add QuadIndices 2018-07-21 03:40:37 +09:00
Hajime Hoshi
2e7745044d shareable: Fix Image.DrawImage to accept vertices and indices 2018-07-21 03:30:27 +09:00
Hajime Hoshi
6c8b7f8e9c graphics: Refactoring: Reduce error propagations 2018-07-12 03:08:50 +09:00
Hajime Hoshi
abdf52bc74 shareable: Bug fix: Call SetFinalizer whenever a new image is created
Fixes #637
2018-06-28 22:23:07 +09:00
Hajime Hoshi
dec921809b shareable: Refactoring 2018-06-26 01:59:12 +09:00
Hajime Hoshi
55d832fc63 shareable: Don't extend textures on macOS
Fixes #593
2018-06-20 11:57:39 +09:00
Hajime Hoshi
840c4d24df graphicsutil: Accept matrix parameters directly for performance 2018-06-19 00:19:32 +09:00
Hajime Hoshi
a3c754d2cc graphics: Restrict QuadVertices to allow only power of 2 sizes
Now QuadVertices can skip calculating power of 2 values.
2018-06-17 23:05:19 +09:00
Hajime Hoshi
ac24a8382f graphicsutil: Extract matrix applying for performance 2018-06-17 19:45:09 +09:00