Commit Graph

493 Commits

Author SHA1 Message Date
Hajime Hoshi
c9f49efd41 graphics: Add VertexFlaotNum 2018-11-06 02:34:52 +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
bd1fc4439a graphicsutil: Avoid passing NaN to shaders experimentally (#696) 2018-10-04 02:02:19 +09:00
Hajime Hoshi
fad65f2f5d graphics: Use the viewport size same as the framebuffer size
Fixes #691
2018-09-29 19:53:22 +09:00
Hajime Hoshi
8827520d4a graphics: Bug fix: avoid jaggy rendering on macOS by adjusting texels (#669) 2018-08-30 00:17:03 +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
e46f9c6305 graphics: Bug fix: compile error 2018-08-10 03:10:57 +09:00
Hajime Hoshi
a03b335c24 graphics: Add logging when 'ebitendebug' tag is specified
Fixes #563
2018-08-10 02:39:07 +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
5a9235aaf9
graphics: Embed color matrices values to vertices (#655)
Fixes #531
2018-07-26 11:37:27 +09:00
Hajime Hoshi
6c8b7f8e9c graphics: Refactoring: Reduce error propagations 2018-07-12 03:08:50 +09:00
Hajime Hoshi
a9a21132ae graphics: Refactoring: Add pixelCommand 2018-07-12 02:40:06 +09:00
Hajime Hoshi
f6b7a6be73 graphics: Use copy function in appendVertices 2018-06-17 01:09:05 +09:00
Hajime Hoshi
c782380a1c restorable: Specify indices from restorable package 2018-06-10 18:17:58 +09:00
Hajime Hoshi
2853895e6b graphics: Refactoring: Rename functions 2018-06-10 17:53:57 +09:00
Hajime Hoshi
32ac3840a7 graphics: Add comments 2018-06-10 17:10:11 +09:00
Hajime Hoshi
4e21bfd005 graphics: Rename elements -> indices 2018-06-10 17:06:40 +09:00
Hajime Hoshi
8a268e871f graphics: Specify indices before commands 2018-06-10 17:04:58 +09:00
Hajime Hoshi
e6d0943366 graphics: Rename color_matrix -> color_matrix_body 2018-06-06 02:46:54 +09:00
Hajime Hoshi
b86860abcc graphics: Call BindBuffer only when the program was null 2018-06-04 00:13:23 +09:00
Hajime Hoshi
fac639f9b7 graphics: Refactoring: Remove drawImageCommand.quadsNum 2018-06-03 23:58:08 +09:00
Hajime Hoshi
c9dd04d471 graphics: Refactoring: Remove command groups 2018-06-03 23:13:01 +09:00
Hajime Hoshi
9d87622a19 graphics: Set elements for every EnqueueDrawImageCommand 2018-06-03 20:42:45 +09:00
Hajime Hoshi
525ad04568 graphics: Split the notion of vertices and elements 2018-06-03 16:07:26 +09:00
Hajime Hoshi
25f2dfc677 graphics: Refactoring 2018-06-03 01:43:10 +09:00
Hajime Hoshi
03e3f0f5f7 graphics: Call glBufferSubData for element array buffer every frame
This is a preparation for more flexible drawing commands.
2018-05-31 00:53:05 +09:00
Hajime Hoshi
5e93d75ae0 graphics: Fix comments 2018-05-28 02:38:26 +09:00
Hajime Hoshi
399f965729 opengl: Add BindBuffer accepting both element-array-buffer and array-buffer
This change is a pure refactoring to clarify that array buffer is
binded before its usage.
2018-05-28 00:34:00 +09:00
Hajime Hoshi
d7d892f2d6 graphics: Allow a little margin for edge pixels 2018-05-13 23:00:06 +09:00
Hajime Hoshi
a1dd7b39a3 graphics: Remove roundTexel function
Actually, at least 704d4cf464,
examples/moire doesn't work well without roundTexel on MacBook Pro.
However, now other parts are fixed (e.g. highp is used), it looks
like roundTexel is no longer needed.
2018-05-13 22:30:22 +09:00
Hajime Hoshi
b402cddd01 graphics: Bug fix: wrong refactoring in shader 2018-05-13 14:20:54 +09:00
Hajime Hoshi
efaa5aa17a graphics: Refactor shader 2018-05-13 03:31:28 +09:00
Hajime Hoshi
3ccfe087d9 Refactoring 2018-05-12 15:25:01 +09:00
Hajime Hoshi
0e19aa558a graphics: Remove unneeded GL calls 2018-05-02 01:12:17 +09:00
Hajime Hoshi
1571e04753 Revert "graphics: Call glFlush after glTexSubImage2D for MacBook Pro"
This reverts commit 7f5719fadd.

Reason: This didn't change the situation
2018-04-22 22:06:38 +09:00
Hajime Hoshi
b691e73342 Revert "graphics: Experimental fix: call glFlush always after glTexSubImage2D"
This reverts commit d2da77eb96.

Reason: This doesn't solve the issue on MacBook Late 2013.
2018-04-14 23:16:26 +09:00
Hajime Hoshi
d2da77eb96 graphics: Experimental fix: call glFlush always after glTexSubImage2D 2018-04-14 23:06:20 +09:00
Hajime Hoshi
7f5719fadd graphics: Call glFlush after glTexSubImage2D for MacBook Pro 2018-04-14 17:59:10 +09:00
Hajime Hoshi
ab7a3e1ab3 graphics: Remove unneeded mutex 2018-03-25 23:55:38 +09:00
Hajime Hoshi
9009b293e5 graphics: Remove type assertion 2018-03-21 16:51:27 +09:00
Hajime Hoshi
23c2fc0134 Revert "graphics: Remove type assertion"
This reverts commit ff331d031a.

Compile error
2018-03-21 16:48:51 +09:00
Hajime Hoshi
ff331d031a graphics: Remove type assertion 2018-03-21 16:45:57 +09:00
Hajime Hoshi
09166a6c42 graphics: Fix shaders cleaner way 2018-03-21 03:36:36 +09:00
Hajime Hoshi
0a5deab0a2 graphics: Reland Bug fix: More strict calculation for the nearest filter (#558)
Better version of bae8f9d874
2018-03-21 02:40:26 +09:00
Hajime Hoshi
b157f2d6d0 Revert "graphics: Bug fix: More strict calculation for the nearest filter (#558)"
This reverts commit bae8f9d874.

Reason: TravisCI failed
2018-03-20 04:16:37 +09:00
Hajime Hoshi
a40dc5cf22 graphics: Refactoring shader 2018-03-20 04:05:09 +09:00
Hajime Hoshi
bae8f9d874 graphics: Bug fix: More strict calculation for the nearest filter (#558) 2018-03-20 04:05:03 +09:00
Hajime Hoshi
927a4388b5 graphics: Bug fix: rounding texels is required even on the nearest filter
Fixes #558
2018-03-19 10:37:18 +09:00
Hajime Hoshi
efea65ee58 graphics: Bug fix: wrong texels were used (#546) 2018-03-11 04:11:49 +09:00
Hajime Hoshi
e977019d2f graphics: Detect maximum texture size for each environment
Fixes #537, #539

See also #541
2018-03-09 11:47:23 +09:00
Hajime Hoshi
0418ce0761 graphics: Refactoring: Remove duplication of checking image size 2018-03-09 11:04:02 +09:00
Hajime Hoshi
4628154478 graphics: Remove unused flipY member 2018-03-09 03:26:14 +09:00
Hajime Hoshi
2c62e64a9e Revert "internal/graphics: increase defaultViewportSize to 8192 (#538)"
This reverts commit a60976f260 Per #541.
2018-03-09 02:13:44 +09:00
Andrew Gerrand
a60976f260 internal/graphics: increase defaultViewportSize to 8192 (#538)
This makes it possible to run ebiten applications in full screen on 5k
displays, such as Apple's 27" iMac.

Fix issue #537
2018-03-08 11:53:49 +09:00
Hajime Hoshi
8d98f297f2 graphics: Refactoring: Avoid type switch 2018-03-05 00:00:25 +09:00
Hajime Hoshi
3479b80f1c opengl: Use unsafe-way to convert []float32/[]uint16 to []byte; Remove internal/endian 2018-03-04 18:06:35 +09:00
Hajime Hoshi
e5089934db graphics: Bug fix: Don't delete buffers on browsers (#526) 2018-03-02 01:06:21 +09:00
Hajime Hoshi
db738676ce restorable: Refactoring: clearIfVolatile 2018-03-01 23:13:23 +09:00
Hajime Hoshi
127f6c09c8 graphics: Specify rect to glTexSubImage2D 2018-03-01 01:58:09 +09:00
Hajime Hoshi
9f6fd0db9a graphics: Use the original width/height for glTexSubImage2D 2018-03-01 00:47:37 +09:00
Hajime Hoshi
15d2e6b82b graphics: Fix comments 2018-02-28 23:40:43 +09:00
Hajime Hoshi
c624359163 graphics: Remove glClear before glTexSubImage2D, that is no longer needed 2018-02-28 23:35:05 +09:00
Hajime Hoshi
9db042ae9e graphics: Refactoring: easier way to clear framebuffer 2018-02-28 22:46:57 +09:00
Hajime Hoshi
8c8e512059 affine: User nillable pattern for ColorM 2018-02-28 02:14:06 +09:00
Hajime Hoshi
86671f3337 opengl: Remove pixels argument from NewTexture 2018-02-25 23:34:34 +09:00
Hajime Hoshi
85b133dad0 graphics: Remove NewImageFromImage command 2018-02-25 23:22:49 +09:00
Hajime Hoshi
a2d40e0908 graphics: Remove offsetX/offsetY from framebuffer 2018-02-24 23:35:55 +09:00
Hajime Hoshi
c5d1f11d95 graphics: Remove unused argument from projectionMatrix 2018-02-24 23:33:28 +09:00
Hajime Hoshi
9da5099060 graphics: Refactoring: Flip Y by geometry matrix instead of projection matrix 2018-02-24 23:32:36 +09:00
Hajime Hoshi
b58dc26832 graphics: Remove fillCommand 2018-02-24 16:19:43 +09:00
Hajime Hoshi
af64f8689a graphics: Fix screen filter calculation 2018-02-24 04:25:07 +09:00
Hajime Hoshi
9fba60ca03 Revert "graphics: Adjust texel positions for consitency"
This reverts commit 816fb314a4.
2018-02-24 01:52:49 +09:00
Hajime Hoshi
816fb314a4 graphics: Adjust texel positions for consitency
On second thought, given pixel coords represent a center of texels...
2018-02-24 01:52:05 +09:00
Hajime Hoshi
7c66d884d4 graphics: Adjusting position is no longer needed
Now pixel position is treated as left-upper in linear filter
2018-02-24 01:32:48 +09:00
Hajime Hoshi
e5a2cf29c0 graphics: Bug fix: pixel coord is upper-left by default 2018-02-24 01:16:32 +09:00
Hajime Hoshi
c76ff5ceb2 graphics: Bug fix: fix screen filter calculation
Fixes #512
2018-02-23 23:13:20 +09:00
Hajime Hoshi
b036cac616 graphics: Fix screen filter calculation 2018-02-23 02:36:12 +09:00
Hajime Hoshi
591e0ad995 graphics: Add 'screen' filter for fast rendering (#509) 2018-02-23 01:28:35 +09:00
Hajime Hoshi
092cb2f3f6 graphics: Reset source size parameter just in case 2018-02-22 11:27:15 +09:00
Hajime Hoshi
30e48d5c3c graphics: Stop unnecessary copy of elements (projection matrix) 2018-02-20 01:36:56 +09:00
Hajime Hoshi
40b1948baa graphics: Stop unnecessary copy of elements 2018-02-20 01:17:21 +09:00
Hajime Hoshi
f1f7e5bcec affine: Transpose ColorM implementation for optimization 2018-02-20 00:53:53 +09:00
Hajime Hoshi
9b361086d7 affine: Use float32 inside of ColorM 2018-02-20 00:33:56 +09:00
Hajime Hoshi
2db1753503 opengl: Remove struct usages to avoid copying (texture) 2018-02-19 02:49:00 +09:00
Hajime Hoshi
6ef4bbde2d graphics: Add FilterDefault; Make DrawImageOptions specify Filter (#453) 2018-02-14 02:59:44 +09:00
Hajime Hoshi
95480d0644 affine: Separate ColorM impl into two slices
This fix avoids unnecessary allocating arrays.
2018-02-12 19:01:01 +09:00
Hajime Hoshi
24d7487fc7 graphics: Bug fix: TestImageTooManyFill didin't pass on some machines (reland)
Fixes #492
2018-02-03 23:03:18 +09:00
Hajime Hoshi
9ece27e7e8 Revert "graphics: Bug fix: TestImageTooManyFill didin't pass on some machines"
This reverts commit 7cb7b7b4ff.
2018-02-03 20:39:33 +09:00
Hajime Hoshi
7cb7b7b4ff graphics: Bug fix: TestImageTooManyFill didin't pass on some machines
Fixes #492
2018-02-03 20:36:16 +09:00
Hajime Hoshi
4bbb4b0445 graphics: Remove unneeded comments (#491) 2018-02-03 03:32:03 +09:00
Hajime Hoshi
52350c1b1b graphics: Bug fix: TestImageEdge failed on MacBook Pro (#491) 2018-02-03 03:30:09 +09:00
Hajime Hoshi
beaa060ce3 graphics: Adjust texel values that can be exactly on the edges of the source rect (#491) 2018-02-03 02:07:46 +09:00
Hajime Hoshi
80596820cf graphics: Replace []uint8 with []byte 2018-01-28 22:40:36 +09:00
seebs
0b7ba8e573 Do GeoM projection on CPU (#477)
Handling GeoM projection on CPU may seem like a weird choice, given
how fast GPU is, but it pays off:

* You only have to do a very small subset of the actual matrix
  multiply.
* You don't have to construct a matrix in the vertex shader.
* Six fewer float32 values per vertex.
* You do still have to do the matrix computation for each vertex,
  though.

Signed-off-by: Seebs <seebs@seebs.net>
2018-01-14 16:01:55 +09:00
Hajime Hoshi
5d4c4f1283 graphics: Bug fix: Don't delete the screen framebuffer (iOS) 2017-12-31 20:55:04 +09:00