mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
graphicsdriver/metal: Bug fix: Sync textures before replacing a region
Updates #1213
This commit is contained in:
parent
7b6182d05a
commit
2bc1475a15
@ -440,7 +440,7 @@ func (g *Graphics) NewImage(width, height int) (driver.Image, error) {
|
|||||||
Width: graphics.InternalImageSize(width),
|
Width: graphics.InternalImageSize(width),
|
||||||
Height: graphics.InternalImageSize(height),
|
Height: graphics.InternalImageSize(height),
|
||||||
StorageMode: storageMode,
|
StorageMode: storageMode,
|
||||||
Usage: textureUsage,
|
Usage: mtl.TextureUsageShaderRead | mtl.TextureUsageRenderTarget,
|
||||||
}
|
}
|
||||||
var t mtl.Texture
|
var t mtl.Texture
|
||||||
g.t.Call(func() error {
|
g.t.Call(func() error {
|
||||||
@ -873,6 +873,10 @@ func (i *Image) ReplacePixels(args []*driver.ReplacePixelsArgs) {
|
|||||||
if g.drawCalled {
|
if g.drawCalled {
|
||||||
g.flush(true, false)
|
g.flush(true, false)
|
||||||
g.drawCalled = false
|
g.drawCalled = false
|
||||||
|
|
||||||
|
// When mtl.TextureUsageRenderTarget is specified, synchronizing the texture memory before replacing
|
||||||
|
// a region seems necessary (#1213).
|
||||||
|
i.syncTexture()
|
||||||
}
|
}
|
||||||
|
|
||||||
g.t.Call(func() error {
|
g.t.Call(func() error {
|
||||||
|
@ -58,8 +58,6 @@ func (v *view) update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
textureUsage = mtl.TextureUsageShaderRead | mtl.TextureUsageRenderTarget
|
|
||||||
|
|
||||||
storageMode = mtl.StorageModeShared
|
storageMode = mtl.StorageModeShared
|
||||||
resourceStorageMode = mtl.ResourceStorageModeShared
|
resourceStorageMode = mtl.ResourceStorageModeShared
|
||||||
)
|
)
|
||||||
|
@ -46,9 +46,6 @@ func (v *view) update() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
// MTLTextureUsageRenderTarget might cause a problematic render result. Not sure the reason.
|
|
||||||
textureUsage = mtl.TextureUsageShaderRead
|
|
||||||
|
|
||||||
storageMode = mtl.StorageModeManaged
|
storageMode = mtl.StorageModeManaged
|
||||||
resourceStorageMode = mtl.ResourceStorageModeManaged
|
resourceStorageMode = mtl.ResourceStorageModeManaged
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user