mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-11 19:48:54 +01:00
parent
a19f079da8
commit
48e3c766f7
@ -362,24 +362,6 @@ func (c *newShaderCommand) NeedsSync() bool {
|
|||||||
return true
|
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.
|
// InitializeGraphicsDriverState initialize the current graphics driver state.
|
||||||
func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error) {
|
func InitializeGraphicsDriverState(graphicsDriver graphicsdriver.Graphics) (err error) {
|
||||||
runOnRenderThread(func() {
|
runOnRenderThread(func() {
|
||||||
|
@ -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 {
|
func (i *Image) dumpName(path string) string {
|
||||||
return strings.ReplaceAll(path, "*", strconv.Itoa(i.id))
|
return strings.ReplaceAll(path, "*", strconv.Itoa(i.id))
|
||||||
}
|
}
|
||||||
|
@ -76,10 +76,6 @@ func (i *image11) disposeBuffers() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *image11) IsInvalidated() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *image11) ReadPixels(args []graphicsdriver.PixelsArgs) error {
|
func (i *image11) ReadPixels(args []graphicsdriver.PixelsArgs) error {
|
||||||
var unionRegion image.Rectangle
|
var unionRegion image.Rectangle
|
||||||
for _, a := range args {
|
for _, a := range args {
|
||||||
|
@ -68,10 +68,6 @@ func (i *image12) disposeImpl() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*image12) IsInvalidated() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *image12) ReadPixels(args []graphicsdriver.PixelsArgs) error {
|
func (i *image12) ReadPixels(args []graphicsdriver.PixelsArgs) error {
|
||||||
if i.screen {
|
if i.screen {
|
||||||
return errors.New("directx: Pixels cannot be called on the screen")
|
return errors.New("directx: Pixels cannot be called on the screen")
|
||||||
|
@ -78,7 +78,6 @@ type Resetter interface {
|
|||||||
type Image interface {
|
type Image interface {
|
||||||
ID() ImageID
|
ID() ImageID
|
||||||
Dispose()
|
Dispose()
|
||||||
IsInvalidated() bool
|
|
||||||
ReadPixels(args []PixelsArgs) error
|
ReadPixels(args []PixelsArgs) error
|
||||||
WritePixels(args []PixelsArgs) error
|
WritePixels(args []PixelsArgs) error
|
||||||
}
|
}
|
||||||
|
@ -817,13 +817,6 @@ func (i *Image) Dispose() {
|
|||||||
i.graphics.removeImage(i)
|
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() {
|
func (i *Image) syncTexture() {
|
||||||
i.graphics.flushRenderCommandEncoderIfNeeded()
|
i.graphics.flushRenderCommandEncoderIfNeeded()
|
||||||
|
|
||||||
|
@ -47,10 +47,6 @@ func (i *Image) ID() graphicsdriver.ImageID {
|
|||||||
return i.id
|
return i.id
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) IsInvalidated() bool {
|
|
||||||
return !i.graphics.context.ctx.IsTexture(uint32(i.texture))
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *Image) Dispose() {
|
func (i *Image) Dispose() {
|
||||||
if i.framebuffer != nil {
|
if i.framebuffer != nil {
|
||||||
i.graphics.context.deleteFramebuffer(i.framebuffer.native)
|
i.graphics.context.deleteFramebuffer(i.framebuffer.native)
|
||||||
|
@ -135,10 +135,6 @@ func (i *Image) Dispose() {
|
|||||||
C.ebitengine_DisposeImage(C.int(i.id))
|
C.ebitengine_DisposeImage(C.int(i.id))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Image) IsInvalidated() bool {
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func (i *Image) ReadPixels(args []graphicsdriver.PixelsArgs) error {
|
func (i *Image) ReadPixels(args []graphicsdriver.PixelsArgs) error {
|
||||||
// TODO: Implement this
|
// TODO: Implement this
|
||||||
return nil
|
return nil
|
||||||
|
@ -616,14 +616,6 @@ func (i *Image) Dispose() {
|
|||||||
i.staleRegions = i.staleRegions[:0]
|
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) {
|
func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackbg bool, rect image.Rectangle) (string, error) {
|
||||||
return i.image.Dump(graphicsDriver, path, blackbg, rect)
|
return i.image.Dump(graphicsDriver, path, blackbg, rect)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user