diff --git a/internal/graphicscommand/command.go b/internal/graphicscommand/command.go index ec1a6b069..dae55d6b4 100644 --- a/internal/graphicscommand/command.go +++ b/internal/graphicscommand/command.go @@ -362,24 +362,6 @@ func (c *newShaderCommand) NeedsSync() bool { return true } -type isInvalidatedCommand struct { - result bool - image *Image -} - -func (c *isInvalidatedCommand) String() string { - return fmt.Sprintf("is-invalidated: image: %d", c.image.id) -} - -func (c *isInvalidatedCommand) Exec(commandQueue *commandQueue, graphicsDriver graphicsdriver.Graphics, indexOffset int) error { - c.result = c.image.image.IsInvalidated() - return nil -} - -func (c *isInvalidatedCommand) NeedsSync() bool { - return true -} - // InitializeGraphicsDriverState initialize the current graphics driver state. func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error) { runOnRenderThread(func() { diff --git a/internal/graphicscommand/image.go b/internal/graphicscommand/image.go index 562712e7e..64ff0abbd 100644 --- a/internal/graphicscommand/image.go +++ b/internal/graphicscommand/image.go @@ -167,28 +167,6 @@ func (i *Image) WritePixels(pixels *graphics.ManagedBytes, region image.Rectangl }) } -func (i *Image) IsInvalidated(graphicsDriver graphicsdriver.Graphics) (bool, error) { - if i.screen { - // The screen image might not have a texture, and in this case it is impossible to detect whether - // the image is invalidated or not. - return false, fmt.Errorf("graphicscommand: IsInvalidated cannot be called on the screen image") - } - - // i.image can be nil before initializing. - if i.image == nil { - return false, nil - } - - c := &isInvalidatedCommand{ - image: i, - } - theCommandQueueManager.enqueueCommand(c) - if err := theCommandQueueManager.flush(graphicsDriver, false); err != nil { - return false, err - } - return c.result, nil -} - func (i *Image) dumpName(path string) string { return strings.ReplaceAll(path, "*", strconv.Itoa(i.id)) } diff --git a/internal/graphicsdriver/directx/image11_windows.go b/internal/graphicsdriver/directx/image11_windows.go index 01831019d..1b3adb150 100644 --- a/internal/graphicsdriver/directx/image11_windows.go +++ b/internal/graphicsdriver/directx/image11_windows.go @@ -76,10 +76,6 @@ func (i *image11) disposeBuffers() { } } -func (i *image11) IsInvalidated() bool { - return false -} - func (i *image11) ReadPixels(args []graphicsdriver.PixelsArgs) error { var unionRegion image.Rectangle for _, a := range args { diff --git a/internal/graphicsdriver/directx/image12_windows.go b/internal/graphicsdriver/directx/image12_windows.go index 431ef6e81..aab796833 100644 --- a/internal/graphicsdriver/directx/image12_windows.go +++ b/internal/graphicsdriver/directx/image12_windows.go @@ -68,10 +68,6 @@ func (i *image12) disposeImpl() { } } -func (*image12) IsInvalidated() bool { - return false -} - func (i *image12) ReadPixels(args []graphicsdriver.PixelsArgs) error { if i.screen { return errors.New("directx: Pixels cannot be called on the screen") diff --git a/internal/graphicsdriver/graphics.go b/internal/graphicsdriver/graphics.go index a43710f36..d15d5defb 100644 --- a/internal/graphicsdriver/graphics.go +++ b/internal/graphicsdriver/graphics.go @@ -78,7 +78,6 @@ type Resetter interface { type Image interface { ID() ImageID Dispose() - IsInvalidated() bool ReadPixels(args []PixelsArgs) error WritePixels(args []PixelsArgs) error } diff --git a/internal/graphicsdriver/metal/graphics_darwin.go b/internal/graphicsdriver/metal/graphics_darwin.go index 216fbd098..98960248c 100644 --- a/internal/graphicsdriver/metal/graphics_darwin.go +++ b/internal/graphicsdriver/metal/graphics_darwin.go @@ -817,13 +817,6 @@ func (i *Image) Dispose() { i.graphics.removeImage(i) } -func (i *Image) IsInvalidated() bool { - // TODO: Does Metal cause context lost? - // https://developer.apple.com/documentation/metal/mtlresource/1515898-setpurgeablestate - // https://developer.apple.com/documentation/metal/mtldevicenotificationhandler - return false -} - func (i *Image) syncTexture() { i.graphics.flushRenderCommandEncoderIfNeeded() diff --git a/internal/graphicsdriver/opengl/image.go b/internal/graphicsdriver/opengl/image.go index a46081bed..11862411b 100644 --- a/internal/graphicsdriver/opengl/image.go +++ b/internal/graphicsdriver/opengl/image.go @@ -47,10 +47,6 @@ func (i *Image) ID() graphicsdriver.ImageID { return i.id } -func (i *Image) IsInvalidated() bool { - return !i.graphics.context.ctx.IsTexture(uint32(i.texture)) -} - func (i *Image) Dispose() { if i.framebuffer != nil { i.graphics.context.deleteFramebuffer(i.framebuffer.native) diff --git a/internal/graphicsdriver/playstation5/graphics_playstation5.go b/internal/graphicsdriver/playstation5/graphics_playstation5.go index 432f59fa3..af0d5fa20 100644 --- a/internal/graphicsdriver/playstation5/graphics_playstation5.go +++ b/internal/graphicsdriver/playstation5/graphics_playstation5.go @@ -135,10 +135,6 @@ func (i *Image) Dispose() { C.ebitengine_DisposeImage(C.int(i.id)) } -func (i *Image) IsInvalidated() bool { - return false -} - func (i *Image) ReadPixels(args []graphicsdriver.PixelsArgs) error { // TODO: Implement this return nil diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 749fa5074..d0370bbda 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -616,14 +616,6 @@ func (i *Image) Dispose() { i.staleRegions = i.staleRegions[:0] } -// isInvalidated returns a boolean value indicating whether the image is invalidated. -// -// If an image is invalidated, GL context is lost and all the images should be restored asap. -func (i *Image) isInvalidated(graphicsDriver graphicsdriver.Graphics) (bool, error) { - // IsInvalidated flushes the commands internally. - return i.image.IsInvalidated(graphicsDriver) -} - func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackbg bool, rect image.Rectangle) (string, error) { return i.image.Dump(graphicsDriver, path, blackbg, rect) }