Commit Graph

127 Commits

Author SHA1 Message Date
Hajime Hoshi
534370f7b1 internal/graphics: enable to specify regions for each source image
This is a preparation to specify different sizes of source images.

Updates #1870
2023-08-27 21:15:01 +09:00
Hajime Hoshi
a9d9143d90 internal/atlas: replace a map with a set with a slice
Updates #2601
2023-08-19 15:08:49 +09:00
Hajime Hoshi
3b2251a858 internal/atlas: refactoring: improve a comment 2023-08-19 05:24:20 +09:00
Hajime Hoshi
be68f50f96 internal/atlas: refactoring: rename a variable 2023-08-19 05:20:39 +09:00
Hajime Hoshi
3c49f81b5c internal/atlas: replace a global map with a member
This should be a pure performance improvement.

Updates #2601
2023-08-19 05:02:35 +09:00
Hajime Hoshi
32f1436576 internal/atlas: refactoring: remove (probably) unnecessary logics 2023-08-19 04:36:40 +09:00
Hajime Hoshi
1e2a4cb4b1 internal/atlas: refactoring: remove unnecessary logics
Updates #2601
2023-08-19 04:06:43 +09:00
Hajime Hoshi
e1041ea20e internal/atlas: replace a global map with a struct member
This should be a pure performance improvement.

Updates #2586
Updates #2601
2023-08-19 03:25:17 +09:00
Hajime Hoshi
ea1f596cda internal/atlas: bug fix: possible overflowing on 32bit machines 2023-08-19 01:19:15 +09:00
Hajime Hoshi
98cb77d94f internal/atlas: refactoring 2023-08-06 16:03:57 +09:00
Hajime Hoshi
32ed22f91c internal/atlas: refactoring 2023-08-06 15:59:15 +09:00
Hajime Hoshi
0433dfac99 internal/atlas: reland: clarify the logic when to update usedAsDestination
This is a reland of 2c9f5d9dad.

As the name is `usedAsDestination`, this should be updated whenever
the image is used as a rendering destination.

Confirmed that this change didn't cause a performance regression
like #2586.

Updates #2586
Updates #2676
2023-08-06 15:59:11 +09:00
Hajime Hoshi
dcc8794883 Revert "internal/atlas: clarify the logic when to update usedAsDestination"
This reverts commit 2c9f5d9dad.

Reason: test failures
2023-08-06 15:25:55 +09:00
Hajime Hoshi
2c9f5d9dad internal/atlas: clarify the logic when to update usedAsDestination
As the name is `usedAsDestination`, this should be updated whenever
the image is used as a rendering destination.

Confirmed that this change didn't cause a performance regression
like #2586.

Updates #2586
Updates #2676
2023-08-06 15:23:19 +09:00
Hajime Hoshi
a50d9e6291 internal/atlas: check overflows 2023-08-06 13:46:41 +09:00
Hajime Hoshi
1ae5e022b6 internal/atlas: change when to count up usedAsDestinationCount
An image has a counter to count how many times an image is used.

Before this change, the counter was updated only when an image was moved
from a source backend to a destination backend. This seemed not enough,
and an image was likely moved to a source backend more often than
necessary (#2676).

However, there was also an issue that the counter was updated too
aggressively and the image was unlikely moved from a destination to
a source image (#2586).

In order to resolve this dilemma, let's adopt an intermediate way:
count up the counter at most once per frame.

Updates #2586
Updates #2676
2023-08-06 13:27:28 +09:00
Hajime Hoshi
63df6168d9 internal/shader: use plural forms for Kage compiler directives
This change renames

```
//kage:unit texel
//kage:unit pixel
```

to

```
//kage:unit texels
//kage:unit pixels
```

.

Closes #2717
2023-08-01 11:41:38 +09:00
Hajime Hoshi
ce25583438 internal/atlas: refactoring: move temporaryBytes to internal/graphicscommand 2023-08-01 00:11:40 +09:00
Hajime Hoshi
0fb1cdcfbd internal/atlas: bug fix: there should be multiple temporaryBytes objects for pipelining
Closes #2716
2023-07-31 16:18:17 +09:00
Hajime Hoshi
3869e2e4f6 internal/ui: refactoring: integrate the render thread usages into internal/graphicscommand
Updates #2664
2023-07-30 03:50:49 +09:00
Hajime Hoshi
20edb04e5e internal/restorable: refactoring: add EndFrame 2023-05-08 01:09:25 +09:00
Hajime Hoshi
b32258ab8c internal/atlas: refactoring 2023-04-29 13:41:39 +09:00
Hajime Hoshi
d2c991b774 all: refactoring: use image.Rectangle 2023-04-28 01:03:38 +09:00
Hajime Hoshi
cdcffd7d4f internal/restorable: refactoring: use image.Rectangle 2023-04-28 00:42:40 +09:00
Hajime Hoshi
d9a2b0922d internal/atlas: refactoring: remove unnecessary calculations 2023-04-28 00:26:09 +09:00
Hajime Hoshi
9e61b52a70 internal/atlas: refactoring: use image.Rectangle 2023-04-27 23:55:11 +09:00
Hajime Hoshi
82c7436be5 internal/packing: refactoring: use image.Rectangle 2023-04-27 23:45:57 +09:00
Hajime Hoshi
6c5477adea internal/atlas: remove borders at the upper and the left sides
Updates #2657
2023-04-27 09:06:05 +09:00
Hajime Hoshi
49582519c1 all: add a compiler directive kage:unit
This change adds a new compiler directive 'kage:unit' to Kage. This
takes one of these two values: 'pixel' and 'texel'. The default value
is 'texel'.

With the pixel-unit mode, all the built-in functions treats pixels
instead of texels, and the texCoord argument of Fragment is in pixels.
This simplifies shader programs as programs no longer have the notion
of texels.

With the texel-unit mode, the behavior is the same as the current
behavior.

Closes #1431
2023-04-23 22:11:57 +09:00
Hajime Hoshi
2f55bb1b3d internal/atlas, internal/graphicscommand: refactoring 2023-04-19 21:43:08 +09:00
Hajime Hoshi
1c09ec5e44 internal/atlas: bug fix: too aggressive counting up destinationCount
Closes #2586
2023-03-02 18:58:29 +09:00
Hajime Hoshi
7c10e48afd internal/atlas: add an assertion
Updates #2586
2023-03-02 18:24:22 +09:00
Hajime Hoshi
7c0fbce0cf internal/atlas: use texture atlases for rendering destinations
Before this change, texture atlases are created only for rendreing
sources.

This change enables to use texture atlases even for rendering
destinations, so that the number of textures will be drastically
reduced.

Closes #2581
2023-03-01 02:47:01 +09:00
Hajime Hoshi
110ba5403d internal/buffered: remove redundant pixel data if possible 2023-02-26 01:55:43 +09:00
Hajime Hoshi
d947cf0da0 internal/atlas: refactoring: use moveTo to make an image isolated
This reduces backend allocations by &backend{...}.

Updates #2581
2023-02-23 02:23:03 +09:00
Hajime Hoshi
0720ec2251 internal/packing: allow initialization with a rectangle size
Updates #2327
2023-02-23 00:45:42 +09:00
Pierre Curto
4de807cc44
all: fix typos (#2558)
Signed-off-by: Pierre Curto <pierre.curto@gmail.com>
2023-01-28 19:06:38 +09:00
Hajime Hoshi
4d270de75e internal/atlas: renmae functions
Updates #2519
2023-01-02 20:18:05 +09:00
Hajime Hoshi
bb1021a549 internal/atlas: ensure the given sizes must be power of 2
Updates #2519
2023-01-02 19:17:27 +09:00
Hajime Hoshi
0a6813c17f internal/graphics: use flatten []float32 slice instead of [][]float32
Closes #2479
2022-12-03 20:23:58 +09:00
Hajime Hoshi
61f1d8b69f internal/graphics: remove the common vertices backend
It was actually impossible to use the common vertices backend in a
thread-safe manner, and actually this caused race conditions.

This changes fixes the issue by giving up a central backend, and
letting images have their own vertices buffer.

Closes #2473
2022-12-03 01:02:23 +09:00
Hajime Hoshi
419bb4c1e9 all: use uint32 instead of float32 for uniform values
This is a preparation for other types of uniform values.

Updates #2305
2022-11-12 20:28:07 +09:00
Hajime Hoshi
fde964312c internal/packing: reland: refactoring
This change basically relands these commits:

 * e08078d84a
 * 8fa36cc7ef

but with a fix internal/restorable not to create too many images.

Updates #2327
2022-11-11 21:55:11 +09:00
Hajime Hoshi
f593725bf9 Revert "internal/packing: refactoring"
This reverts these commits

* 8fa36cc7ef.
* e08078d84a

Reason: test failures

Updates #2327
2022-11-11 19:35:13 +09:00
Hajime Hoshi
e08078d84a internal/packing: refactoring
Now pages are automatically extended by Alloc.

Updates #2327
2022-11-11 19:12:23 +09:00
Hajime Hoshi
2855095ac9 all: unify terms for buffers and flushing 2022-10-16 19:47:00 +09:00
Hajime Hoshi
475dc6394f internal/atlas: remove an unnecessary mutex
Updates #2390
2022-10-16 15:29:02 +09:00
Hajime Hoshi
27cb149475 internal/graphicscommand: bug fix: resolve unsent WritePixels commands
(*Image).WritePixels doens't send a command to the queue immediately
but caches commands internally. However, the package atlas assumed
that pixel data was sent to the cache every end of a frame. Then, byte
slices for pixels were corrupted.

This change fixes the issue by resolving all the images when flushing
commands.

Closes #2390
2022-10-16 15:19:25 +09:00
Hajime Hoshi
09a7d39874 internal/graphicsdriver: add Blend struct
This is a preparation to specify blend factors and blend operators.

Updates #2382
2022-10-16 01:08:26 +09:00
Hajime Hoshi
daf349ab72 internal/graphicscommand: bug fix: present at the end of the frame explicitly
Before this change, presenting happened when the rendering destination
was the final screen. Now this assumption is wrong as the final screen
might be used in the middle of the commands due to DrawFinalScreen.

Instead, this change adds a new argument `present` to FlushCommands to
present the screen explicitly at the end of the frame.

Closes #2386
2022-10-15 01:54:46 +09:00