Commit Graph

621 Commits

Author SHA1 Message Date
Hajime Hoshi
c29c423686 internal/glfwwin, internal/graphicsdriver/directx: bug fix: HRESULT and Errno are imcompatible 2022-06-03 00:41:04 +09:00
Hajime Hoshi
4a9caf8afb internal/graphicsdriver/directx: ignore higher 32bit values for Errno
Updates #2113
2022-06-02 23:01:38 +09:00
Hajime Hoshi
fb03a1e351 internal/graphicsdriver/directx: bug fix: ID3D12Resource::Unmap does not return an value
Updates #2113
2022-06-02 12:52:58 +09:00
Hajime Hoshi
4a684c4195 treat Windows error values as uint32 instead of windows.Handle
The error value are defined as windows.Handle (64bit) in
golang.org/x/sys/windows, but an actual type should be HRESULT (32bit).
This causes an issue that a returning value from a Windows API was
recognized as a non-zero error value though the value was not an error,
when the value's lower 32-bits are all zero.

See also https://github.com/golang/go/issues/48736#issuecomment-1143993096

Updates #2113
2022-06-02 12:10:21 +09:00
Hajime Hoshi
b900f83a01 internal/graphicsdriver/directx: refactoring: remove an unused member Image.numRows 2022-06-02 01:53:27 +09:00
Hajime Hoshi
0dc6e4e64e internal/graphicsdriver/directx: use ID3D12Resource instead of ID3D12Resource1
Updates #2114
2022-06-02 01:26:02 +09:00
Hajime Hoshi
c99b948df3 internal/graphicsdriver/directx: refactoring
Updates #2084
2022-05-30 03:17:15 +09:00
Hajime Hoshi
d4226659ee internal/graphicsdriver/directx: initialize a device for Xbox
Updates #1162
2022-05-30 02:10:18 +09:00
Hajime Hoshi
59798d29f4 internal/graphicsdriver/directx: defer the initialization 2022-05-29 22:02:39 +09:00
Hajime Hoshi
b4491ab94d internal/graphicsdriver/directx: unify the naming convention with glfwwin 2022-05-29 21:18:23 +09:00
Hajime Hoshi
0081fa7a47 internal/graphicsdriver/directx: add a comment 2022-05-29 20:05:37 +09:00
Hajime Hoshi
ad380a32f4 internal/glfwwin: split GDK part to a new package internal/microsoftgdk
Updates #1162
2022-05-29 19:25:26 +09:00
Hajime Hoshi
5c63c4a4aa internal/graphicsdriver/metal: support macOS 10.12 by removing packed types
From the Metal shading language specification [1] Table 2.2.3, attribute
variables in Ebitengine's vertices don't have to be packed. Then, we can
remove `packed` types.

[1] https://developer.apple.com/metal/Metal-Shading-Language-Specification.pdf

Closes #2107
2022-05-28 23:57:59 +09:00
Hajime Hoshi
d577cc5e7d internal/graphicsdriver/opengl/gl: rename files
Updates #1162
2022-05-27 18:31:40 +09:00
TotallyGamerJet
726e88e520
internal/graphics/opengl/gl: remove CGO in openGL on macOS (#2104)
Updates #1162
2022-05-27 18:26:53 +09:00
Hajime Hoshi
7030840efa internal/graphicsdriver/opengl/gl: refactoring 2022-05-25 02:24:40 +09:00
Hajime Hoshi
3745c0a2e0 internal/graphicsdriver/opengl/gl: remove an unused function GetBufferSubData
This is basically a revert of 86a0c7aa82
2022-05-24 20:45:45 +09:00
Hajime Hoshi
a1370a4791 internal/graphicsdriver/opengl: remove an unused member gl.getBufferSubData 2022-05-24 20:40:53 +09:00
Hajime Hoshi
f888b7868b internal/graphicsdriver/opengl: fix the error message when GenFramebufferEXT fails 2022-05-23 22:25:40 +09:00
Hajime Hoshi
0577a28aed all: add struct members for go-vet
Updates #1306
2022-05-22 22:05:40 +09:00
Hajime Hoshi
4396785829 Revert "internal/graphicsdriver/opengl: remove CGO in opengl for macOS (#2091)"
This reverts commit f7e21983cf.

Reason: test failures (#2102)

Closes #2102
2022-05-22 01:24:48 +09:00
TotallyGamerJet
f7e21983cf
internal/graphicsdriver/opengl: remove CGO in opengl for macOS (#2091)
Updates #1162
2022-05-22 00:58:45 +09:00
Hajime Hoshi
fef79f4d3e internal/graphicsdriver/metal: update the minimum version of macOS
Updates #2095
2022-05-18 00:09:04 +09:00
Hajime Hoshi
7409f01b17 internal/graphicsdriver/metal/mtl: bug fix: specify the language version explicitly
Updates #2086
2022-05-05 23:50:48 +09:00
Hajime Hoshi
a0e1d08123 internal/graphicsdriver/directx: update comments
Updates #2081
2022-04-26 11:20:48 +09:00
Hajime Hoshi
7321e86a6b internal/graphicsdriver/directx: bug fix: the screen image can be nil when resizing the window
Closes #2081
2022-04-26 11:19:48 +09:00
Hajime Hoshi
736d77e0d2 internal/graphicsdriver: remove Graphics.NDCYDirection 2022-04-04 03:03:44 +09:00
Hajime Hoshi
02db3bad53 internal/graphicscommand: remove the dependency on a graphics driver from compileShader
Updates #2035
2022-04-04 02:09:08 +09:00
Hajime Hoshi
9be454ef25 internal/graphicsdriver: remove an old comment 2022-04-03 02:53:43 +09:00
Hajime Hoshi
3fafc05411 internal/graphicsdriver: remove Graphics.HasHighPrecisionFloat
Updates #879
2022-04-02 05:19:30 +09:00
Hajime Hoshi
6bd3c81e27 internal/graphicsdriver/directx, internal/graphicsdriver/metal: bug fix: uniform matrix-array variables were passed wrongly
Updates #2036
2022-03-27 00:32:30 +09:00
Hajime Hoshi
eaad959472 internal/graphicsdriver/metal: remove println 2022-03-27 00:12:34 +09:00
Hajime Hoshi
f6d87f6ee8 internal/graphicsdriver/directx, internal/graphicsdriver/metal: bug fix: uniform matrix variables were passed wrongly
Updates #2036
2022-03-26 23:58:48 +09:00
Hajime Hoshi
79e93d3b12 internal/graphicsdriver: introduce the DirectX driver
Closes #1007
2022-03-26 20:09:34 +09:00
Hajime Hoshi
eeb5687b73 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to pointers
On second thought, returning pointers is more natural. Handling
nil is a caller's responsibility.
2022-03-24 13:20:36 +09:00
Hajime Hoshi
7bb7e45522 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: change the return type to interface
Converting a nil with a pointer type to an interface type is no longer
a nil-nil interface, and then comparing with nil causes an unexpected
results.
2022-03-24 03:24:58 +09:00
Hajime Hoshi
09b0a0ffaf internal/ui: refactoring: simplify the selection of graphics libraries 2022-03-23 02:21:53 +09:00
Hajime Hoshi
a74e7b1578 Revert "internal/graphicsdriver/metal: refactoring"
This reverts commit 1c57393393.

Reason: nothing is rendered on iOS.

Closes #2022
2022-03-23 01:22:39 +09:00
Hajime Hoshi
cd57bccbfc internal/graphicsdriver: let some functions return an error
This is a preparation for the DirectX driver.

Updates #1007
2022-03-21 22:23:12 +09:00
Hajime Hoshi
0dcf43b350 internal/graphicsdriver: reorder the member 2022-03-21 22:05:21 +09:00
Hajime Hoshi
5fe6791b5d internal/graphicscommand: add a new paramter 'mask' to ReplacePixels 2022-03-21 01:11:01 +09:00
Hajime Hoshi
2e6bb8c4e2 internal/graphicsdriver/metal: add comments 2022-03-14 22:02:44 +09:00
Hajime Hoshi
7d0f95e9be internal/graphicsdriver: refactoring: replace Uniform with []float32
Closes #2016
2022-03-13 03:42:13 +09:00
Hajime Hoshi
35a5c88901 internal/graphics: rename constants 2022-03-12 04:01:48 +09:00
Hajime Hoshi
6f00221051 internal/shaderir/msl: rename the package name
Updates #2010
2022-03-10 16:25:11 +09:00
Hajime Hoshi
47bfd0db9e internal/shaderir/metal: rename to msl
Closes #2010
2022-03-10 00:14:06 +09:00
Hajime Hoshi
c37ffecafd internal/graphicsdriver/metal: reorder uniform variables
This might improve memory allocations.

This makes the code more consistent with HLSL's packing rule [1]

[1] https://docs.microsoft.com/en-us/windows/win32/direct3dhlsl/dx-graphics-hlsl-packing-rules
2022-03-05 22:12:08 +09:00
Hajime Hoshi
d4d4b9c070 internal/graphicsdriver/metal, internal/graphicsdriver/opengl: more efficient modulo 2022-03-04 03:47:55 +09:00
Hajime Hoshi
b22309a0e5 internal/graphicsdriver: replace Pixels with ReadPixels
Now preparing a byte slice is the caller's responsibility.
2022-02-27 20:03:13 +09:00
Hajime Hoshi
566957dc1c internal/graphicsdriver/metal: invert Y at the vertex shader
Instead of using a negative height in the viewport, invert the Y direction
at the vertex shader. This is a little more readable as a negative height
is hacky.

This is a preparation for DirectX 12. DirectX 12's coodination system
is very similar to Metal, but doesn't treat a negative height in its
viewport unfortunately.

Updates #1007
2022-02-27 01:53:03 +09:00
divVerent
f2209a0b51
internal/atlas: optimization: send premultiplied alpha from vertex to fragment shader. (#1996)
Note that this applies only to the builtin shaders - interface for Kage stays
unchanged for compatibility.

Minor compatibility delta: when interpolating alpha values, previous code has
created nonsense values, such as, when interpolating from
fully-transparent-black (0,0,0,0) to opaque-white (1,1,1,1), something like
half-transparent-grey (0.25,0.25,0.25,0.5) where half-transparent-white
(0.5,0.5,0.5,0.5) is used by the new code.

I assume this is a strict improvement, however this may warrant some testing.

Possible later improvement could be moving the premultiplication from fragment
shader to CPU. Did not do this as it makes the code rather inconsistent of Kage
vs built-in shader usage.

Updates #1772
2022-02-24 02:27:50 +09:00
Hajime Hoshi
8b7273b74a internal/graphicsdriver/metal: call PresentDrawable only when necessary 2022-02-22 01:37:13 +09:00
Hajime Hoshi
ee911fd892 internal/graphicsdriver/metal: fix an error message 2022-02-20 22:01:36 +09:00
Hajime Hoshi
ab1ad2c72f .github/workflow: add a test to build with the build tag ebitencbackend 2022-02-13 16:57:48 +09:00
Hajime Hoshi
1c57393393 internal/graphicsdriver/metal: refactoring 2022-02-13 01:00:20 +09:00
Hajime Hoshi
162f62f54e internal/graphicsdriver/metal/mtl: bug fix: test compile error 2022-02-11 23:23:22 +09:00
Hajime Hoshi
176e984a58 internal/ui: refactoring: remove dependency on the package mtl 2022-02-11 23:11:49 +09:00
Hajime Hoshi
6f3c6d6c1b internal/graphicsdriver/meta: rename function 2022-02-11 22:47:13 +09:00
Hajime Hoshi
cc4e2f08be internal/graphicsdriver/metal: rename files 2022-02-11 21:49:05 +09:00
Hajime Hoshi
4c6c31e384 all: reorder build tags in an alphabetical order 2022-02-08 15:49:15 +09:00
Hajime Hoshi
df60c4c92d internal/driver: rename to internal/graphicsdriver 2022-02-06 20:41:32 +09:00
Hajime Hoshi
84e53d4c61 internal/graphicsdriver/opengl, internal/uidriver/glfw: treat Win32 API errors correctly
The returned errors from syscall.Syscall* and windows.LazyProc.Call come
from GetLastError. The value of GetLastError is not reliable when the
function succeeds.

This change fixes the usages of error values. The error value is now
used only when the API explicitly fails.
2022-01-30 15:54:24 +09:00
Hajime Hoshi
d0a6ce6567 internal/graphicsdriver/metal: disable presentsWithTransaction in the fullscreen mode
Updates #1745
Closes #1974
2022-01-26 03:55:14 +09:00
Hajime Hoshi
cdf2335f5a refactoring: better error handlings on Windows 2022-01-23 18:30:40 +09:00
Hajime Hoshi
1b498a03cc Revert "internal/graphicsdriver/metal: Bug fix: Vsync didn't work on macOS"
This reverts commit 1dd13ae06e.

Reason: This caused FPS drop on macOS 12.0.1

Updates #1885
Closes #1939
2022-01-09 01:02:53 +09:00
Hajime Hoshi
3b0ce21a56 Revert "internal/graphicsdriver: bug fix: render semi-transparent vectors correctly"
This reverts commit 202f642395.

Reason: TestImageEvenOdd failed

Updates #1933
2022-01-06 03:19:46 +09:00
Hajime Hoshi
202f642395 internal/graphicsdriver: bug fix: render semi-transparent vectors correctly
Closes #1933
2022-01-06 03:00:25 +09:00
Hajime Hoshi
6b34ddecfa internal/graphicsdriver/opengl/gles: add GLES_SILENCE_DEPRECATION to suppress warnings 2022-01-05 01:54:00 +09:00
Hajime Hoshi
1799ed0b28 add a build tag 'ebitencbackend' and internal/cbackend
This enables to create a C archive with Ebiten without an actual driver
implementation. This enables Ebiten work on a platform Go doesn't support.
See also Hitsumabushi project: github.com/hajimehoshi/hitsumabushi.

The backend C API is not stable and might change later. Then, the build
tag 'ebitencbackend' is not documented on purpose.

Closes #1900
2021-12-22 21:12:48 +09:00
Hajime Hoshi
1dd13ae06e internal/graphicsdriver/metal: Bug fix: Vsync didn't work on macOS
This fix works only for Metal. There is not a good solution for
OpenGL so far unfortunately.

Closes #1885
2021-11-27 02:52:48 +09:00
Hajime Hoshi
00e2b15e2a shaderir: Bug fix: A wrong argument for fmt.Sprintf
This change also improves the result of espcae analysis.

Closes #1863
2021-11-02 00:05:07 +09:00
Hajime Hoshi
7661147e31 internal/graphicsdriver/opengl: Avoid allocations by escaping to heap 2021-10-31 22:34:14 +09:00
Hajime Hoshi
15f62bfeb5 internal/graphicsdriver/opengl: Optimization: Cache texture variable names 2021-10-31 05:40:44 +09:00
Hajime Hoshi
9d51356eef internal/graphicsdriver/opengl: Optimization 2021-10-31 05:17:23 +09:00
Hajime Hoshi
b74a4a0275 internal/graphicsdriver/opengl: Optimization: Avoid heap allocations 2021-10-31 02:10:44 +09:00
Hajime Hoshi
7b7791156c internal/graphicsdriver/opengl: Remove unreached return 2021-10-31 01:38:01 +09:00
Hajime Hoshi
98083ccd0a internal/graphicsdriver/opengl: Avoid heap allocation of a local variable
If a variable is passed to an argument interface{}, the variable might be
allocated on the heap unexpectedly.
2021-10-31 01:11:12 +09:00
Hajime Hoshi
a082db04fd internal/jsutil: Optimization: Avoid using empty interface{} conversions 2021-10-30 18:53:21 +09:00
Hajime Hoshi
a826ecb29b internal/jsutil: Move a function to internal/graphicsdriver/opengl 2021-10-30 18:33:43 +09:00
Hajime Hoshi
06f4142ca0 internal/driver: Optimization: Replace interface{} with driver.Uniform
Converting a value from/to interface{} can create a value in heap
and this is not efficient.
2021-10-30 02:58:28 +09:00
Hajime Hoshi
1f82bb297c internal/graphicsdriver/opengl: Optimization: Avoid the empty interface 2021-10-30 02:28:57 +09:00
Hajime Hoshi
60f2c7ace6 internal/graphicsdriver/opengl: Optimization: Avoid creating slices for every frame (uniform variables) 2021-10-30 00:22:31 +09:00
Hajime Hoshi
b4f45edff8 internal/graphicsdriver/opengl: Optimization: Avoid creating slices for every frame 2021-10-30 00:13:57 +09:00
Hajime Hoshi
76324254c1 internal/graphicsdriver/opengl: Avoid creating objects for debugging 2021-10-30 00:04:03 +09:00
Hajime Hoshi
d3ac199aa9 internal/graphicsdriver/opengl: Optimization: Avoid fmt.Sprintf 2021-10-29 21:43:40 +09:00
Hajime Hoshi
3c1f8da7f8 internal/graphicsdriver/opengl: Optimization: Avoid interface conversion 2021-10-29 21:35:40 +09:00
Hajime Hoshi
99bfdef416 internal/graphicsdriver/opengl/gl: Support OpenBSD 2021-10-24 15:09:16 +09:00
Hajime Hoshi
ef62f407d1 Clean up build tags 2021-10-24 15:05:36 +09:00
Hajime Hoshi
878831b842 internal/graphicsdriver/opengl: Bug fix: compile error 2021-10-24 14:55:50 +09:00
Hajime Hoshi
a5198275fa internal/graphicsdriver/opengl/gl: Remove an unused file 2021-10-24 14:46:38 +09:00
Hajime Hoshi
3f5d1762bb internal/graphicsdriver/opengl: Return an error when initializing OpenGL fails
Updates #1838
2021-10-06 00:38:47 +09:00
Hajime Hoshi
7be00d79e8 internal/uidriver/glfw: Fix unstable FPS on fullscreen on macOS
FPS was unstable on fullscreen mode i.e., when the view size is the
same as the monitor size.

By using a little different size view, FPS becomes stable.

Updates #1745
2021-09-18 19:22:09 +09:00
Hajime Hoshi
11b9a4b161 internal/graphicsdriver/metal: Refactoring 2021-09-18 17:24:03 +09:00
Hajime Hoshi
65943d4bad internal/graphicsdriver/metal: Disable presentsWithTransaction on iOS
Closes #1799
2021-09-07 00:02:58 +09:00
Hajime Hoshi
58ea710a84 internal/affine: Rename UnsafeElements -> Elements as this is no longer unsafe 2021-09-04 18:08:27 +09:00
Hajime Hoshi
df710a5c63 internal/affine: Change UnsafeElements to take arguments
This will enable to suppress unnecessary array allocations in the
future.

Updates #1796
2021-09-04 17:38:30 +09:00
Hajime Hoshi
d1c764640d internal/glfw, internal/graphicsdriver/opengl/gl: Use the last byte to detect a bool
When a C function returns a bool value, only the first byte of a
uintptr value matters. When we want to get a bool value from a C
function, filter this for sefety.
2021-08-25 02:09:55 +09:00
Hajime Hoshi
35deb53624 internal/graphicsdriver/metal: Rename files to remove +build comments 2021-08-23 02:06:09 +09:00
Hajime Hoshi
6c8a7d1079 internal/graphicsdriver/opengl: Bug fix: A location cache map must be reset when a program is deleted
Closes #1753
2021-08-15 04:54:20 +09:00
Hajime Hoshi
da08577095 internal/graphicsdriver/opengl: Refactoring 2021-08-14 04:05:18 +09:00
Hajime Hoshi
ce8fc39451 internal/graphicsdriver/opengl: Bug fix: the current program must be reset
Updates #1751
2021-08-13 23:44:30 +09:00
Hajime Hoshi
15ac69b8d5 internal/graphicsdriver/metal: Bug fix: Disable presentsWithTransaction on fullscreen
Closes #1745
2021-08-08 17:40:37 +09:00
Hajime Hoshi
ec26b1a43b internal/graphicsdriver/metal: Refactoring: Remove vsyncInited 2021-08-08 15:30:13 +09:00
Hajime Hoshi
cc1accc32a internal/uidriver/glfw: Bug fix: Disable vsync when resizing the window
Closes #1740
2021-08-06 03:08:04 +09:00
Hajime Hoshi
8967384dac internal/graphicsdriver: Bug fix: getting a WebGL2 context might fail even though WebGL2RenderingContext exists
Closes #1738
2021-08-01 22:00:47 +09:00
Hajime Hoshi
e4329d0349 internal/driver: Refactoring: Reduce dependencies on affine 2021-07-27 12:19:50 +09:00
Hajime Hoshi
21aa96f9f5 internal/affine: Refactoring: Make ColorM interface 2021-07-27 12:10:22 +09:00
Hajime Hoshi
7e5b259dd2 internal/affine: Use a pointer of an array for UnsafeElements 2021-07-26 21:19:53 +09:00
Hajime Hoshi
50d2d7ed61 internal/graphicsdriver/opengl: Remove unused code using PBO
Updates #1678
2021-07-14 21:51:27 +09:00
Hajime Hoshi
b0106e95b9 internal/restorable: Bug fix: Test failed on macOS (Metal) 2021-07-09 20:21:04 +09:00
Hajime Hoshi
4573883b03 internal/graphicsdriver/metal: Make FPS stable by 'presentsWithTransaction'
Closes #1196
2021-07-08 18:11:19 +09:00
Hajime Hoshi
ae0e30196b internal/graphicsdriver/metal: Bug fix: The store action must always be 'store'
Closes #1700
2021-07-08 17:39:37 +09:00
Hajime Hoshi
337d8d5113 internal/graphicsdriver/metal: Separate GCing the buffers
Updates #1196
2021-07-08 02:10:26 +09:00
Hajime Hoshi
edc2f8b961 internal/graphicsdriver/metal: Delay to get a texture for nextDrawable
See https://developer.apple.com/documentation/quartzcore/cametallayer

> To avoid stalls in your app, request a new drawable only when you
> need it, and release any references to it as quickly as possible
> after you’re done with it.

Updates #1196
2021-07-08 01:56:14 +09:00
Hajime Hoshi
b314b6b9b6 Revert "internal/graphicsdriver/metal: Do not retain MTLCommandBuffer for MTLBuffer"
This reverts commit e0fbfc2bb0.

Reason: Rendering issue

Closes #1699
2021-07-08 00:27:33 +09:00
Hajime Hoshi
6213c17abc internal/driver: Add Graphics.Initialize 2021-07-07 13:58:42 +09:00
Hajime Hoshi
e0fbfc2bb0 internal/graphicsdriver/metal: Do not retain MTLCommandBuffer for MTLBuffer
Before this change, a command buffer is retained indirectly by
a buffer, and this might extend the life of drawable unexpectedly.

This change stops using command buffers as a key of the buffers pool,
and use a counter increated by nextDrawable calls.

Updates #1196
2021-07-07 02:52:04 +09:00
Hajime Hoshi
80ac0646d5 internal/graphicsdriver/metal: Optimize the screen writing 2021-07-07 02:07:09 +09:00
Hajime Hoshi
38ce325958 internal/graphicsdriver/metal: Skip clearing the screen on Metal 2021-07-07 01:45:51 +09:00
Hajime Hoshi
9cb1ff9cea internal/graphicsdriver/metal: Set framebufferOnly true
Updates #1196
2021-07-07 00:38:55 +09:00
Hajime Hoshi
bd3f16dbba internal/graphicsdriver/metal: Change the order of GCed buffers
As a big buffer is likely reused, we should remove smaller buffers
first.

Updates #1196
2021-07-06 21:56:27 +09:00
Hajime Hoshi
09bd8b6f4a internal/graphicsdriver/metal: Remove println
Updates #1196
2021-07-06 21:51:57 +09:00
Hajime Hoshi
ee2f891fcc internal/graphicsdriver/metal: Reuse MTLBuffer objects
In Metal, MTLBuffer objects are not 'transient' and are expensive
to create. Reuse them whenever possible.

See also: https://developer.apple.com/library/archive/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Cmd-Submiss/Cmd-Submiss.html

Updates #1196
2021-07-06 21:48:54 +09:00
Hajime Hoshi
be1a0e90e7 internal/graphicsdriver/metal: Bug fix: TestImageEvenOdd failed
RenderCommandEncoder must be reset whenever the stencil mode is
'prepareStencil' in order to clear the stencil buffer.
2021-07-06 15:11:23 +09:00
Hajime Hoshi
3670b7dd62 internal/graphicsdriver/metal: Reuse DepthStencilState objects
In Metal, *State objects are not 'transient' and are expensive to
create. Reuse them whenever possible.

See also: https://developer.apple.com/library/archive/documentation/Miscellaneous/Conceptual/MetalProgrammingGuide/Cmd-Submiss/Cmd-Submiss.html
2021-07-06 15:10:05 +09:00
Hajime Hoshi
ab26312108 internal/graphicsdriver/metal: Release objects appropriately 2021-07-06 14:20:19 +09:00
Hajime Hoshi
17d8cb5311 internal/graphicsdriver/metal: Bug fix: Crashed with METAL_DEVICE_WRAPPER_TYPE=1
Closes #1697
2021-07-06 14:06:06 +09:00
Hajime Hoshi
63a00f6171 internal/graphicsdriver/metal/mtl: Bug fix: Test failure
Closes #1696
2021-07-05 21:28:25 +09:00
Hajime Hoshi
674802d2f5 ebiten: Bug fix: Draw commands with EvenOdd should not be merged
Updates #1684
2021-07-05 18:08:55 +09:00
Hajime Hoshi
daa883d799 ebiten: Bug fix: Stencil buffers should not be cleared until all the vertices are rendered
Updates #1684
2021-07-05 17:41:06 +09:00
Hajime Hoshi
b466a0cbd7 ebiten: Add EvenOdd to DrawTrianglesOptions and DrawShaderTrianglesOptions
Updates #844
Closes #1684
2021-07-05 03:35:55 +09:00
Hajime Hoshi
5c4d3325f6 internal/graphicsdriver/opengl: Add APIs for stencil buffers
Updates #1684
2021-07-05 00:24:44 +09:00
Hajime Hoshi
b8bf277825 internal/graphicsdriver/metal/mtl: Add APIs for stencil buffers
Updates #1684
2021-07-05 00:11:25 +09:00
Hajime Hoshi
19f034e818 internal/graphicsdriver/metal: Refactoring 2021-07-04 20:35:56 +09:00
Hajime Hoshi
3ec02f767b internal/graphicsdriver/metal: Refactoring 2021-07-04 18:37:14 +09:00
Hajime Hoshi
7f86761dde internal/graphicsdriver/metal: Reuse RenderCommandEncoder when possible 2021-07-04 18:13:18 +09:00
Hajime Hoshi
7668052a6b internal/graphicsdriver/metal: Update the view only when necessary 2021-07-04 17:24:39 +09:00
Hajime Hoshi
f6e210e086 internal/graphicsdriver/opengl: Refactoring: Remove redundant conversions 2021-07-03 22:39:48 +09:00
Hajime Hoshi
56f4e6b2d0 internal/graphicsdriver/opengl: Refactoring: Rename a variable 2021-07-03 02:41:37 +09:00
Hajime Hoshi
269ea7c489 internal/graphicsdriver/opengl: Refactoring: Reorder functions
glPixelStorei affects the result of glTexImage2D. This change makes
this fact more explicit.
2021-07-03 02:09:47 +09:00
Hajime Hoshi
6b95dd0d4d internal/graphicsdriver/metal: Refactoring: Unify two drawTriangles* functions 2021-07-02 00:25:43 +09:00
Hajime Hoshi
ff2dd6fe7e internal/graphicsdriver/opengl: Refactoring: Unify two drawTriangles* functions 2021-07-02 00:02:21 +09:00
Hajime Hoshi
e9b6237f61 internal/driver: Refactoring: Merge two Draw* functions 2021-07-01 15:55:48 +09:00
Hajime Hoshi
b9d52c0267 internal/driver: Change InvalidImageID/InvalidShaderID to 0 2021-07-01 14:58:55 +09:00
Hajime Hoshi
73bf1f36e5 internal/driver: Define InvalidImageID / InvalidShaderID 2021-07-01 13:56:42 +09:00
Hajime Hoshi
067e3c004d Remove internal/web 2021-06-26 17:04:00 +09:00
Hajime Hoshi
8ff42f55a1 internal/graphicsdriver/opengl: Give up restorign on browsers
Using restorable images is expensive as this sometimes requires to
load pixels from GPU. On browsers, just reloading the application
should be fine when the context lost happens.

Closes #1603
2021-06-26 16:54:21 +09:00
Hajime Hoshi
2a8e8d0eb6 internal/graphicsdriver/opengl: Stop using PBO
PBO was introduced to improve the performance at ReplacePixels,
but we found that PBO can degrades the performance. Also, now
multiple glTexImage2Ds are called successively like a batch, so
the situation is now different from that time when PBO was
introduced.

Let's remove PBO usages and wait and see.

Closes #1678
2021-06-24 21:20:58 +09:00
Hajime Hoshi
7f60cd41eb internal/graphicsdriver/opengl: Refactoring: Remove unused arguments from texSubImage2D 2021-06-24 12:06:28 +09:00
Hajime Hoshi
584c6524ee internal/graphicsdriver/opengl: Refactring 2021-06-13 14:19:33 +09:00
Hajime Hoshi
b54ad73a2b Add go:build comments with go1.17beta1 fmt 2021-06-11 01:11:46 +09:00
Hajime Hoshi
a627c41217 Remove support of Go 1.13 and Go 1.14
Updates #1258
Updates #1415
Updates #1462
2021-06-07 21:44:22 +09:00
Hajime Hoshi
6fe6543b4b internal/graphicsdriver/opengl: Bug fix: getBufferSubData was available only with WebGL2 2021-04-06 00:11:51 +09:00
Hajime Hoshi
bd8367588e internal/graphicsdriver/opengl: Prepare function objects by bind
Passing a Go string to the JS world is expensive. This change reduces
this cost by preparing function objects by bind.

Closes #1438
2021-04-05 23:53:21 +09:00
Hajime Hoshi
77b198211c internal/graphicsdriver/metal: Add a comment 2021-02-27 04:04:25 +09:00
Hajime Hoshi
53352cf2b3 internal/graphicsdriver/metal: Use the smallest temporary texture
Updates #1517
2021-02-27 03:45:19 +09:00
Hajime Hoshi
673627c4d4 internal/graphicsdriver/metal: Optimization 2021-02-27 02:30:20 +09:00
Hajime Hoshi
6b3c51921c internal/driver: Remove Image.Sync
Syncing is no longer needed for Metal, and additionally, OpenGL's sync
implementation was mock.

Updates #1508
2021-02-26 23:16:28 +09:00
Hajime Hoshi
969964cb46 internal/graphicsdriver/opengl/gl: Bug fix: Remove unsafe reflect usage
Closes #1495
2021-02-14 21:27:30 +09:00
Hajime Hoshi
b8694aa66a internal/graphicsdriver/opengl: Optimization 2021-01-26 00:45:17 +09:00
Hajime Hoshi
f77c514598 graphicsdriver/opengl: Refactoring 2021-01-05 02:07:30 +09:00
Hajime Hoshi
b7abde7f00 graphicsdriver/opengl: Bug fix: getBufferSubData did not work correctly on JS 2021-01-03 19:44:29 +09:00
Hajime Hoshi
7e32075abd jsutil: Avoid creating Uint8Array when copying bytes from Go to JS
Updates #1435
2020-12-16 01:50:05 +09:00
Hajime Hoshi
49b86843c3 jsutil: Avoid creating Uint8Array at TemporaryUint8Array
Updates #1435
2020-12-16 01:21:13 +09:00
Hajime Hoshi
146357c298 jsutil: Enable to specify length at Uint8ArrayToSlice 2020-12-15 01:13:15 +09:00
Hajime Hoshi
e5c1151cc5 jsutil: Avoid creating Float32Array at TemporaryFloat32Array
Updates #1435
2020-12-15 00:40:43 +09:00
Hajime Hoshi
f440e368b3 graphicsdriver/opengl: Use WebGL2 API on go2cpp 2020-12-14 02:02:45 +09:00
Hajime Hoshi
718273c2d7 ebiten: Add a new shader function imageDstRegionOnTexture
Updates #1428
2020-12-09 11:36:29 +09:00
Hajime Hoshi
66d12722ae graphicsdriver/opengl: Remove comments 2020-12-06 03:24:08 +09:00
Hajime Hoshi
2c31156a34 graphicsdriver/opengl: Reduce allocations of Float32Array on go2cpp
Updates #1426
2020-12-06 03:23:09 +09:00
Hajime Hoshi
d4a2433643 Revert "graphicsdriver/opengl: Reduce creation of Float32Array"
This reverts commit 3c28bcf3c4.

Reason: Tests failed: https://github.com/hajimehoshi/ebiten/runs/1496602911
2020-12-04 12:10:15 +09:00
Hajime Hoshi
3c28bcf3c4 graphicsdriver/opengl: Reduce creation of Float32Array
Updates #1426
2020-12-02 22:58:36 +09:00
Hajime Hoshi
44e2455c65 graphicsdriver/opengl: Avoid unnecessary creation of Uint16Array/Float32Array
Updates #1426
2020-12-02 20:40:28 +09:00
Hajime Hoshi
5897e1ab7c Implement some preparation code for go2cpp
Updates #744
2020-11-30 23:18:42 +09:00
Hajime Hoshi
912e13071f graphicsdriver/opengl: Refactoring 2020-11-29 23:04:00 +09:00
Hajime Hoshi
526a92256b graphicsdriver/opengl: Refactoring: Remove shaderType 2020-11-21 23:33:25 +09:00
Hajime Hoshi
8dba7b7722 graphicsdriver/opengl: Refactoring: Remove dataType 2020-11-21 23:14:43 +09:00
Hajime Hoshi
c9060d2fa8 graphicsdriver/opengl: Remove bufferType 2020-11-21 23:07:11 +09:00
Hajime Hoshi
9c014a281a graphicsdriver/opengl: Refactoring 2020-11-21 23:00:57 +09:00
Hajime Hoshi
859d247093 graphicsdriver/opengl: Refactoring 2020-11-21 22:49:49 +09:00
Hajime Hoshi
ddc8115b51 graphicsdriver/opengl: Refactoring: remove ensureGL 2020-11-21 22:09:58 +09:00
Hajime Hoshi
dd46221968 graphicsdriver/opengl: Enable dFdx for mobiles
Fixes #1404
2020-11-21 19:40:11 +09:00
Hajime Hoshi
b1d7a5f595 shaderir/glsl: Enable dFdx for WebGL
With WebGL1, an extension is required for dFdx. On the other hand,
with WebGL2, GLSL ES 300 is required and the extension is forbidden.
This change fixes shaderir/glsl to switch the output depends on the
WebGL version.

This change also adds a new build tag 'ebitenwebgl1' forcing WebGL 1.

Updates #1404
2020-11-21 19:07:54 +09:00
Hajime Hoshi
2097312a8b graphicsdriver/opengl: Refactoring 2020-11-21 16:44:49 +09:00
Hajime Hoshi
4df958c9fd Avoid comparing to js.Undefined() for consistency 2020-11-21 14:25:17 +09:00
Hajime Hoshi
ed494dbf59 restorable: Reland: Do not record pixels if restoring is not requried
This change also remove the restrictions of operations on
graphicscommand.Image. For example, now DrawTriangles and
ReplacePixels can be mixed on the same image.

Fixes #1022
2020-11-14 15:00:16 +09:00
Hajime Hoshi
86a0c7aa82 graphicsdriver/opengl: Use PBO when retrieving pixels 2020-11-13 09:10:56 +09:00
Hajime Hoshi
ddfb8adbc4 graphicsdriver/metal: Asynchronous sending pixels
Fixes #1418
2020-11-10 22:48:03 +09:00
Hajime Hoshi
5705dc79fb graphicsdriver/metal: Do not need to wait until flushing at Sync 2020-11-10 22:12:26 +09:00
Hajime Hoshi
99b4a3096a graphicsdriver/opengl: Use Go const values instead of getting them dynamically 2020-11-08 19:23:32 +09:00
Hajime Hoshi
e09f3aa286 graphicsdriver/metal/mtl: Bug fix: Fix the guard range 2020-11-08 04:44:43 +09:00
Hajime Hoshi
aaff18ecf7 graphicsdriver/metal/mtl: Bug fix: Guard the handler map by a mutex
The handler is invoked in another thread than the main thread.
2020-11-08 04:40:13 +09:00
Hajime Hoshi
ed028110cf ebiten: Allow rendering on a sub-image by scissor test
Fixes #1255
2020-11-08 00:58:44 +09:00
Hajime Hoshi
e4e8e7254e graphicsdriver/metal/mtl: Refactoring: Specify struct member names explicitly 2020-11-07 23:46:07 +09:00
Hajime Hoshi
a8f96ee9af graphicsdriver/metal: Add Sync to sync CPU and GPU asynchronously
Fixes #1414
2020-11-07 04:09:47 +09:00
Hajime Hoshi
6e3cbe2e33 graphicsdriver/metal/mtl: Refactoring 2020-11-07 03:26:35 +09:00
Hajime Hoshi
8da5ad2c4f graphicsdriver/metal: Misspelling 2020-11-03 23:44:40 +09:00
Hajime Hoshi
f611b48c71 graphicsdriver/opengl: Use native GLES functions for mobiles
After this change, GL functions for mobiles, especially Android, are
native ones instead of golang.org/x/mobile/gl functions in order to
reduce goroutine context switches.

On gomobile-build, golang.org/x/mobile/gl functions are still used.

Fixes #1387
2020-10-19 03:51:20 +09:00
Hajime Hoshi
2740938460 graphicsdriver/opengl: Fix the error message again 2020-10-18 22:55:37 +09:00
Hajime Hoshi
b755a1f970 graphicsdriver/opengl: Fix the error message 2020-10-18 22:12:39 +09:00