Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kitty multiframe with annihilations can't properly rebuild using composing animations #2143

Closed
dankamongmen opened this issue Sep 5, 2021 · 35 comments · Fixed by #2159
Closed
Assignees
Labels
bitmaps bitmapped graphics (sixel, kitty, mmap) bug Something isn't working
Milestone

Comments

@dankamongmen
Copy link
Owner

see #2142 for more info. kitty 0.19.3 works fine with bitmapstates. current kitty, however, breaks on three states:

"full square on right" is empty square on right
"ought see 16*s" empty square below and to right, very off
"full square on right" is once again an empty square

these states involve a move + restore. working fine on old kitty suggests a problem using the animation protocol to restore. it only happens when there's movement, though. i dimly recall seeing something like this before...?

@dankamongmen dankamongmen added the bug Something isn't working label Sep 5, 2021
@dankamongmen dankamongmen added this to the 2.4.0 milestone Sep 5, 2021
@dankamongmen dankamongmen self-assigned this Sep 5, 2021
@dankamongmen dankamongmen modified the milestones: 2.4.0, 3.0.0 Sep 6, 2021
@dankamongmen
Copy link
Owner Author

i think the issue here is just that we're calling init_sprixel_animation() on each entry into kitty_rebuild_selfref(), and that's resetting the fbuf. we want to make sure it's reset only once, ideally whenever we write it.

@dankamongmen
Copy link
Owner Author

that was done in #2150 aka 2a04eff

@dankamongmen
Copy link
Owner Author

so we need the reset in kitty_blit_core(), but don't want it in any of the other callsites, methinks...

@dankamongmen
Copy link
Owner Author

wait hrmmm if you hit init_sprixel_animation() and you've already marked it animating, it exits immediately.

@dankamongmen
Copy link
Owner Author

"ought see 16*s" empty square below and to right, very off

this was resolved by 831a65a (#2155)

@dankamongmen
Copy link
Owner Author

we're also seeing the 4th state, "should now see empty square", come back as a full square. i think this is due to the wipe not reaching down far enough. in the second stage we see a lot of:

NEEDS TO WIPE 4/1
sprite_wipe:205:wiping 0x55a4cc19c4b0 25 4/1
DOING SPRIXEL ANIMATION! 1
kitty_wipe_selfref:422:Wiping sprixel 9127379 at 4/1

but the fourth stage is just a lot of:

NEEDS TO WIPE 2/4

@dankamongmen
Copy link
Owner Author

so we're coming in on the wipe and they're showing SPRIXCELL_TRANSPARENT, which is definitely wrong. points at a failure to reset sprixcells in kitty_restore_selfref().

@dankamongmen
Copy link
Owner Author

yep, that looks to be the case!

@dankamongmen
Copy link
Owner Author

hrmmm...they're coming into kitty_rebuild_selfref() in state 5, SPRIXCELL_ANNIHILATED, which is correct.

@dankamongmen
Copy link
Owner Author

and yeah, on exit we've got SPRIXCELL_TRANSPARENT. we're copying in the wrong value here:

memcpy(&s->n->tam[tyx].state, auxvec, sizeof(s->n->tam[tyx].state));

@dankamongmen
Copy link
Owner Author

auxvec incoming is 0, so we're setting it up wrong, or passing the wrong one in. setup is going to take place in wipe and initial blit.

@dankamongmen
Copy link
Owner Author

i think we're failing to set up ... yep, setting up state into the auxvector remedies the problem mentioned above. the empty squares at end still stand.

@dankamongmen
Copy link
Owner Author

wait, we shouldn't be seeing a full square on the right, from what i can tell:

  emit(notcurses_stdplane(nc), "Ought *still* see 16 *s");                                                       
  notcurses_debug(nc, stderr);                                                                                   
  notcurses_render(nc);                                                                                          
  sleep(2);                                                                                                      
                                                                                                                 
  ncplane_move_yx(n, 0, 7);                                                                                      
  emit(notcurses_stdplane(nc), "Full square on right");                                                          
  notcurses_debug(nc, stderr);                                                                                   
  notcurses_render(nc);                                                                                          
  sleep(2);                                                                                                      
                                                                                                                 
  ncplane_move_yx(n, 0, 0);                                                                                      
  emit(notcurses_stdplane(nc), "Ought see 16 *s");                                                               
  notcurses_debug(nc, stderr);                                                                                   
  notcurses_render(nc);                                                                                          
  sleep(2);                                                                                                      
                                                                                                                 
  ncplane_move_yx(n, 0, 7);                                                                                      
  emit(notcurses_stdplane(nc), "Full square on right");                                                          
  notcurses_debug(nc, stderr);                                                                                   
  notcurses_render(nc);                                                                                          
  sleep(2);                                                                                                      

we're never filling that square. are we seeing a full square on other terminals?

@dankamongmen
Copy link
Owner Author

we are, and we should not be, from what i can tell!

@dankamongmen
Copy link
Owner Author

well wait, there's right above that:

  if(ncvisual_render(nc, ncv, &vopts) == NULL){                                                                  
    return -1;                                                                                                   
  }

so yeah, we've got it rerendered, but the asterisks are on top. when we move it, we ought get rebuilds across the covered part. but we are not. ahhhhh.

@dankamongmen
Copy link
Owner Author

so rebulding is triggered in paint_sprixel() when we hit a sprixcell in the ANNIHILATED* states. it looks like we're coming in on SPRIXCELL_OPAQUE_KITTY. which would suggest we're failing to update the state when wiping...

@dankamongmen
Copy link
Owner Author

but we're setting SPIXCELL_ANNIHILATED in sprite_wipe()...

@dankamongmen
Copy link
Owner Author

nvm, we are coming in on 5...

Full square on right
 -------------------------- notcurses debug state -----------------------------
  *************************        0x4eafe50 pile ****************************
0000 off y:   0 x:   0 geom y:  70 x: 113 curs y:   6 x:  20 0x4e90e50 std
 bound 0x4e90e500x4eafe60 → (nil) binds 0x4f8d450
0001 off y:   0 x:   7 geom y:   6 x:   6 curs y:   0 x:   0 0x4f8d450 bmap
 bound 0x4e90e500x4e90ec0 → (nil) binds (nil)
 ______________________________________________________________________________
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 5
sprite_rebuild:764:rebuilding 9127382 1/1
kitty_rebuild_selfref:914:rematerializing 9127382 at 1/1 (20x10)
CHECING FOR REBUILD STATE: 5
sprite_rebuild:764:rebuilding 9127382 1/2
kitty_rebuild_selfref:914:rematerializing 9127382 at 1/2 (20x10)
CHECING FOR REBUILD STATE: 5
sprite_rebuild:764:rebuilding 9127382 1/3
kitty_rebuild_selfref:914:rematerializing 9127382 at 1/3 (20x10)
CHECING FOR REBUILD STATE: 5
sprite_rebuild:764:rebuilding 9127382 1/4
kitty_rebuild_selfref:914:rematerializing 9127382 at 1/4 (20x10)
CHECING FOR REBUILD STATE: 2
CHECING FOR REBUILD STATE: 2

@dankamongmen
Copy link
Owner Author

it seems odd that we're coming in in SPRIXEL_INVALIDATED rather than SPRIXEL_MOVED...but we are moving...

@dankamongmen
Copy link
Owner Author

but i suspect what's happening here is we're writing all the animations, then resetting the fbuf, then writing the move. we ought be able to check this by looking at our actual output, and seeing whether the reanimations are there.

@dankamongmen
Copy link
Owner Author

hrmmm we do seem to see a lot of animations prior to the presentation:

_Ga=c,x=30,y=80,X=30,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;
_Ga=c,x=40,y=80,X=40,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;
_Ga=p,i=9127382,p=1,q=2,C=1

and they look pretty much correct, too...

@dankamongmen
Copy link
Owner Author

_Gf=32,s=60,v=120,i=9127382,p=1,a=t,o=z,q=2;eF7tkkGKA0EQw/b/n84mZ10MCmgINZBLYWPL6dfrvlvgFrgFboFb4Ba4BW6B

writes 9127382. _Ga=d,d=i,i=9127379 had deleted 9127379. we'd also deleted 80 and 81. we delete 81 immediately after presenting 82. 82 is defined with a series of +joLlmWbDZ2lyWz1Dg6ukuWJZuN3WXJLDWOju6SZclmY3dZMkuNo6O7ZFmy2dhdlsxS, not the all-As we'd expect from having any cells removed...

@dankamongmen
Copy link
Owner Author

^[[7;11H16 *s                                                                                                                                                                                                                                                                                                                                          
^[[1;1H^[_Ga=p,i=9127381,p=1,q=2,C=1^[\                                                                                                                                                                                                                                                                                                                
^[[2;2H****^[[3;2H****^[[4;2H****^[[5;2H****                                                                                                                                                                                                                                                                                                           
^[[7;11H^[_Gf=32,s=60,v=120,i=9127382,p=1,a=t,o=z,q=2;eF7tkkGKA0EQw/b/n84mZ10MCmgINZBLYWPL6dfrvlvgFrgFboFb4Ba4BW6BW+AWuAVugVvgFrgFboFb4CcW+HtTPPn37ZGfzPrp9u3veJ/1vu//dQvce773XL4B93rpLlmWbDZ2lyWz1Dg6ukuWJZuN3WXJLDWOju6SZclmY3dZMkuNo6O7ZFmy2dhdlsxS4+joLlmWbDZ2lyWz1Dg6ukuWJZuN3WXJLDWOju6SZclmY3dZMkuNo6O7ZFmy2dhdlsxS4+joLlmWbDZ2lyWz1Dg6ukuWJZuN3
^[[7;7H*still* ^[[16Gee 16 *s                                                                                                                                                                                                                                                                                                                          
^[[1;1H^[_Ga=p,i=9127382,p=1,q=2,C=1^[\                                                                                                                                                                                                                                                                                                                
^[_Ga=d,d=i,i=9127381^[\                                                                                                                                                                                                                                                                                                                               
^[[2;2H****^[[3;2H****^[[4;2H****^[[5;2H****^[[7;16H                                                                                                                                                                                                                                                                                                   
^[_Ga=c,x=10,y=20,X=10,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=20,X=20,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=20,X=30,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=20,X=40,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=10,y=40,X=10,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=40,X=20,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=40,X=30,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=40,X=40,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=10,y=60,X=10,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=60,X=20,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=60,X=30,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=60,X=40,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=10,y=80,X=10,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=80,X=20,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=80,X=30,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=80,X=40,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[[7;1HF^[[3Gll square on right                                                                                                                                                                                                                                                                                                                        
^[[1;8H^[_Ga=p,i=9127382,p=1,q=2,C=1^[\                                                                                                                                                                                                                                                                                                                
^[[7;16H                                                                                                                                                                                                                                                                                                                                               
^[[1;1H^[_Ga=p,i=9127382,p=1,q=2,C=1^[\                                                                                                                                                                                                                                                                                                                
^[[7;1HO^[[3Gght see 16 *s     ^[[16G                                                                                                                                                                                                                                                                                                                  
^[_Ga=c,x=10,y=20,X=10,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=20,X=20,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=20,X=30,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=20,X=40,Y=20,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=10,y=40,X=10,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=40,X=20,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=40,X=30,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=40,X=40,Y=40,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=10,y=60,X=10,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=60,X=20,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=60,X=30,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=60,X=40,Y=60,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=10,y=80,X=10,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=20,y=80,X=20,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=30,y=80,X=30,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[_Ga=c,x=40,y=80,X=40,Y=80,w=10,h=20,i=9127382,r=1,c=2,q=2;^[\                                                                                                                                                                                                                                                                                        
^[[7;1HF^[[3Gll square on right                                                                                                                                                                                                                                                                                                                        
^[[1;8H^[_Ga=p,i=9127382,p=1,q=2,C=1^[\                                                                                                                                                                                                                                                                                                                
^[[7;16H                                                                                                                                                                                                                                                                                                                                               
^[[?1002;1006l^[[#Q^[[39;49m^[(B^[[m^[]104^G^[[?1l^[[?12h^[[?25h   

@dankamongmen
Copy link
Owner Author

so we're definitely sending the reflective compositions....what's odd here is that we're not sending wipes when we move it back over to the left. we should be, assuming we're in OPAQUE, which we ought be following the compositions.

and we furthermore have no wipes between the load and the initial compositions.

it's almost as if we're loading with transparent regions. but we know(?) we're not, looking at the actual inline load data. right?

@dankamongmen
Copy link
Owner Author

perhaps we're copying over from the old TAM? if we were copying over ANNIHILATED, that would explain this...and would point at not correcting the sprixcell state during rebuild, right?

@dankamongmen
Copy link
Owner Author

yeah, we're copying over annihilated states. that's exactly what's going on. we don't rebuild at the time because we're underneath the asterisks. we move and rebuild, no longer being annihilated, and we pop ANNIHILATED into our state. no, wait...

we blit with STATE_ANNIHILATED in the old tam, which we write to the auxvec. our states all become STATE_ANNIHILATED inside the core:

COPYING ANNIHILATED! 5 4/4
ncplane_resize_internal:753:6x6 @ 0/0 → 6/6 @ 0/0 (keeping 6x6 from 0/0)
Ought *still* see 16 *s
 -------------------------- notcurses debug state -----------------------------
  *************************   0x5582d1656aa0 pile ****************************
0000 off y:   0 x:   0 geom y:  70 x: 113 curs y:   6 x:  23 0x5582d16569c0 std
 bound 0x5582d16569c0 ← 0x5582d1656ab0 → (nil) binds 0x5582d16570d0
0001 off y:   0 x:   0 geom y:   6 x:   6 curs y:   0 x:   0 0x5582d16570d0 bmap
 bound 0x5582d16569c0 ← 0x5582d1656a30 → (nil) binds (nil)
 ______________________________________________________________________________
CHECKING FOR REBUILD STATE: 2 0/0
CHECKING FOR REBUILD STATE: 2 0/1
CHECKING FOR REBUILD STATE: 2 0/2
CHECKING FOR REBUILD STATE: 2 0/3
CHECKING FOR REBUILD STATE: 2 0/4
CHECKING FOR REBUILD STATE: 2 0/5
CHECKING FOR REBUILD STATE: 2 1/0
CHECKING FOR REBUILD STATE: 2 1/5

note that we only have rebuilds around the perimeter. we're OPAQUE, so we don't rebuild. in our core, we're all 5s. it seems we ought be writing all AAAAAs here. are we not? we don't seem to be. but either way we're getting ANNIHILATED directly from the blit:

CACHED WIPE 9127382 1/1                                                                                                                                       
CACHED WIPE 9127382 1/2                                                                                                                                       
CACHED WIPE 9127382 1/3                                                                                                                                       
CACHED WIPE 9127382 1/4          

the asterisks then annihilate several, but there is no wiping going on, due to this TAM. and yet we do indeed display the asterisks(!)...

we move to the right:

CHECKING FOR REBUILD STATE: 2 0/0                                                                                                                             
CHECKING FOR REBUILD STATE: 2 0/1                                                                                                                             
CHECKING FOR REBUILD STATE: 2 0/2                                                                                                                             
CHECKING FOR REBUILD STATE: 2 0/3                                                                                                                             
CHECKING FOR REBUILD STATE: 2 0/4                                                                                                                             
CHECKING FOR REBUILD STATE: 2 0/5                                                                                                                             
CHECKING FOR REBUILD STATE: 2 1/0                                                                                                                             
CHECKING FOR REBUILD STATE: 5 1/1                                                                                                                             
sprite_rebuild:764:rebuilding 9127382 1/1                                                                                                                     
kitty_rebuild_selfref:915:rematerializing 9127382 at 1/1 (20x10)                                                                                              
STATE FOLLOWING REBUILD: 5                                                                                                                                    
CHECKING FOR REBUILD STATE: 5 1/2                                                                                                                             
sprite_rebuild:764:rebuilding 9127382 1/2                                                                                                                     
kitty_rebuild_selfref:915:rematerializing 9127382 at 1/2 (20x10)                                                                                              
STATE FOLLOWING REBUILD: 5                                                                                                                                    
CHECKING FOR REBUILD STATE: 5 1/3                                                                                                                             
sprite_rebuild:764:rebuilding 9127382 1/3        

we are rebuilding as expected, and we are emitting the compositions, as demonstrated above. yet we are empty. this realllllly seems to suggest that we're not writing ...

wait.

maybe we're writing 0 alpha from the kitty_core_blit(), but not all 0s? yes indeed we surely are. so we're writing 0 alphas. as we would actually expect. but then when we go to reflect, we're reflecting all 0s, and don't put anything back.

that's exactly what's happening. fuck!

mystery resolved. how to fix this without flicker? i guess we could write the data as loaded, and then replay the wipes? ugh, that sounds like the only way to do it. so long as it's all done at once, we oughtn't see any flicker; we'll load them all and only then do the presentation. hopefully that works with kitty. if it does, it ought solve this problem.

@dankamongmen dankamongmen changed the title problem with kitty animations + move kitty multiframe with annihilations can't properly rebuild using composing animations Sep 10, 2021
@dankamongmen
Copy link
Owner Author

so tl;dr:

  • movement has nothing to do with it
  • the issue is that we can't compose for rebuilding if we load the initial image with 0 alphas...
  • which we do when we have a multiframe (which we do in bitmapstates)...
  • that has annihilations

to prove this, we could do an experiment where we cleared the asterisks instead of moving the square. i expect we would get an empty square. i'm sufficiently certain about the problem that i feel this unnecessary.

@dankamongmen dankamongmen added the bitmaps bitmapped graphics (sixel, kitty, mmap) label Sep 10, 2021
@dankamongmen
Copy link
Owner Author

confirmed. i'm now drawing the original load with alphas intact, then writing the nulls out, then displaying. this is working perfectly for the problem frames mentioned.

unfortunately, we now have one new problem frame: the frame between these two, where the full square is moved back to the left, is now only showing the square -- i.e., there's no wiping going on when we move back to the left. i've verified that in the logs. so let's get this last bit squeezed out, and we'll be done.

@dankamongmen
Copy link
Owner Author

looking at sprixel_debug(), it looks like we're staying in that annihilated state falsely following the rebuild:

Full square on right
 -------------------------- notcurses debug state -----------------------------
  *************************       0x163e2e80 pile ****************************
0000 off y:   0 x:   0 geom y:  58 x: 101 curs y:   6 x:  20 0x163cbec0 std
 bound 0x163cbec0 ← 0x163e2e90 → (nil) binds 0x164e1660
0001 off y:   0 x:   7 geom y:   6 x:   6 curs y:   0 x:   0 0x164e1660 bmap
 bound 0x163cbec0 ← 0x163cbf30 → (nil) binds (nil)
 ______________________________________________________________________________
sprite_rebuild:764:rebuilding 13002558 1/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 1/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 1/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 1/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/4 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/4 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/4 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/4 (18x9)
notcurses_rasterize_inner:1190:pile 0x163e2e80 ymax: 58 xmax: 101
notcurses_rasterize_inner:1200:Sprixel phase 1
clean_sprixels:826:Phase 1 sprixel 13002558 state 3 loc 0/7
Sprixel 13002558 (0x1657c840) 968B 6x6 (108x54) @0/7 state: 3
222222
255552
255552
255552
255552
222222
007] 0x1652ef10
008] 0x1652ef60
009] 0x1652efb0
010] 0x1652f000
013] 0x1652f0f0
014] 0x1652f140
015] 0x1652f190
016] 0x1652f1e0
019] 0x1652f2d0
020] 0x1652f320
021] 0x1652f370
022] 0x1652f3c0
025] 0x1652f4b0
026] 0x1652f500
027] 0x1652f550
028] 0x1652f5a0
sprite_redraw:730:sprixel 13002558 state 3
kitty_draw:1192:Writing out 968b for 13002558
notcurses_rasterize_inner:1205:Glyph phase 1
notcurses_rasterize_inner:1209:Sprixel phase 2
kitty_commit:569:Committing Kitty graphic id 13002558
notcurses_rasterize_inner:1218:Glyph phase 2



Ought see 16 *s
 -------------------------- notcurses debug state -----------------------------
  *************************       0x163e2e80 pile ****************************
0000 off y:   0 x:   0 geom y:  58 x: 101 curs y:   6 x:  15 0x163cbec0 std
 bound 0x163cbec0 ← 0x163e2e90 → (nil) binds 0x164e1660
0001 off y:   0 x:   0 geom y:   6 x:   6 curs y:   0 x:   0 0x164e1660 bmap
 bound 0x163cbec0 ← 0x163cbf30 → (nil) binds (nil)
 ______________________________________________________________________________
notcurses_rasterize_inner:1190:pile 0x163e2e80 ymax: 58 xmax: 101
notcurses_rasterize_inner:1200:Sprixel phase 1
clean_sprixels:826:Phase 1 sprixel 13002558 state 5 loc 0/0
Sprixel 13002558 (0x1657c840) 0B 6x6 (108x54) @0/0 state: 5
222222
255552
255552
255552
255552
222222
007] 0x1652ef10
008] 0x1652ef60
009] 0x1652efb0
010] 0x1652f000
013] 0x1652f0f0
014] 0x1652f140
015] 0x1652f190
016] 0x1652f1e0
019] 0x1652f2d0
020] 0x1652f320
021] 0x1652f370
022] 0x1652f3c0
025] 0x1652f4b0
026] 0x1652f500
027] 0x1652f550
028] 0x1652f5a0
sprite_redraw:730:sprixel 13002558 state 5
notcurses_rasterize_inner:1205:Glyph phase 1
notcurses_rasterize_inner:1209:Sprixel phase 2
notcurses_rasterize_inner:1218:Glyph phase 2



Full square on right
 -------------------------- notcurses debug state -----------------------------
  *************************       0x163e2e80 pile ****************************
0000 off y:   0 x:   0 geom y:  58 x: 101 curs y:   6 x:  20 0x163cbec0 std
 bound 0x163cbec0 ← 0x163e2e90 → (nil) binds 0x164e1660
0001 off y:   0 x:   7 geom y:   6 x:   6 curs y:   0 x:   0 0x164e1660 bmap
 bound 0x163cbec0 ← 0x163cbf30 → (nil) binds (nil)
 ______________________________________________________________________________
sprite_rebuild:764:rebuilding 13002558 1/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 1/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 1/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 1/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 1/4 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 2/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 2/4 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 3/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 3/4 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/1
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/1 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/2
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/2 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/3
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/3 (18x9)
sprite_rebuild:764:rebuilding 13002558 4/4
kitty_rebuild_selfref:961:rematerializing 13002558 at 4/4 (18x9)
notcurses_rasterize_inner:1190:pile 0x163e2e80 ymax: 58 xmax: 101
notcurses_rasterize_inner:1200:Sprixel phase 1
clean_sprixels:826:Phase 1 sprixel 13002558 state 3 loc 0/7
Sprixel 13002558 (0x1657c840) 968B 6x6 (108x54) @0/7 state: 3
222222
255552
255552
255552
255552
222222
007] 0x1652ef10
008] 0x1652ef60
009] 0x1652efb0
010] 0x1652f000
013] 0x1652f0f0
014] 0x1652f140
015] 0x1652f190
016] 0x1652f1e0
019] 0x1652f2d0
020] 0x1652f320
021] 0x1652f370
022] 0x1652f3c0
025] 0x1652f4b0
026] 0x1652f500
027] 0x1652f550
028] 0x1652f5a0
sprite_redraw:730:sprixel 13002558 state 3
kitty_draw:1192:Writing out 968b for 13002558
notcurses_rasterize_inner:1205:Glyph phase 1
notcurses_rasterize_inner:1209:Sprixel phase 2
kitty_commit:569:Committing Kitty graphic id 13002558
notcurses_rasterize_inner:1218:Glyph phase 2
ncplane_destroy:874:Destroying 6x6 plane "bmap" @ 0x7
sprixel_hide:90:Marking sprixel 13002558 hidden
sprixel_free:40:Destroying sprixel 13002558

@dankamongmen
Copy link
Owner Author

yep, im rebuild we're reloading 5 from the auxvec. pretty clear.

@dankamongmen
Copy link
Owner Author

so yeah we come in and have ANNIHILATED as our state. auxvec holds the true state of frame 1. we will have a new true state of frame 2. it needs go in the auxvec, and we need to keep ANNIHILATED as our state. then, on the rebuild, we'll pop true frame 2 state from the auxvec. auxvec ought never have ANNIHILATED.

@dankamongmen
Copy link
Owner Author

memcpy(tam[tyx].auxvector, &tam[tyx].state, sizeof(tam[tyx].state)); that's where it gets it. that gets blown away by the wipe normally. but we won't have a wipe on frame 2, and thus we need to load it with the true new state.

@dankamongmen
Copy link
Owner Author

in the selfref model, auxvec only ever serves to retain the old state when a cell is annihilated. they're all allocated at the beginning, because they're small and who cares, but those are dont-cares until an actual wipe happens.

so on a reload, we can freely blow them away. they're invalidated.

so just keep a running state in the ANNIHILATED stanza matching what you keep below, assigning it to auxvec, for the selfref case only.

@dankamongmen
Copy link
Owner Author

i think i might have it....testing...

@dankamongmen
Copy link
Owner Author

kitty 0.23.1 now runs bitmapstates perfectly =] =] =]

dankamongmen added a commit that referenced this issue Sep 11, 2021
When using the reflexive composition extension to the
Kitty graphics protocol, we refer to the previously-
blitted image to rebuild cells, and thus don't have to
keep a copy of the image ourselves. We just blit null-
alpha cells to wipe, and then execute a reflective
composition to rebuild. The auxvector is a single word,
holding the state we were in before the wipe, since we
don't have a copy of the image to look at to determine
the state afresh (and caching it is more efficient
anyway). Good, good.

Except. When we reload the plane, we want to carry over
those wipe cells, yes? I.e. if there was a plane above
the graphic before, and we replace the graphic, that
plane still better be above it. And that means editing
the cell out of the new graphic that we blit up, on the
fly. Which we were doing. Problem is, if we later need
to rebuild that cell, and we reflexively compose using
this new image, *we reflexively compose the edited-out
cell*, and thus remain wiped (our RGB values get set
properly, but we have all 0 alphas). No good!

So instead, in KITTY_SELFREF (the most advanced kitty
implementation, corresponding to reflexive composition),
do a pass at the end and send AAAAA wipes for any
ANNIHILATED{_TRANS} sprixcells. We don't present until
both have hit (since we're using a new image ID), so
there's no flicker, though there is some bandwidth cost.

That handles rebuilding. Problem is, if we then need to
wipe these same sprixcells *again*, our auxvecs were
set to ANNIHILATED{_TRANS}, and thus no wipe takes place.
Rather than blindly propagating the auxvec across the
frames, properly reset the auxvec according to the new
blit. This handles wiping post rebuild, closing the cycle.

Kitty 0.22.0+ now runs the bitmapstates PoC perfectly.
Closes #2143.  woo-hah!
dankamongmen added a commit that referenced this issue Sep 11, 2021
When using the reflexive composition extension to the
Kitty graphics protocol, we refer to the previously-
blitted image to rebuild cells, and thus don't have to
keep a copy of the image ourselves. We just blit null-
alpha cells to wipe, and then execute a reflective
composition to rebuild. The auxvector is a single word,
holding the state we were in before the wipe, since we
don't have a copy of the image to look at to determine
the state afresh (and caching it is more efficient
anyway). Good, good.

Except. When we reload the plane, we want to carry over
those wipe cells, yes? I.e. if there was a plane above
the graphic before, and we replace the graphic, that
plane still better be above it. And that means editing
the cell out of the new graphic that we blit up, on the
fly. Which we were doing. Problem is, if we later need
to rebuild that cell, and we reflexively compose using
this new image, *we reflexively compose the edited-out
cell*, and thus remain wiped (our RGB values get set
properly, but we have all 0 alphas). No good!

So instead, in KITTY_SELFREF (the most advanced kitty
implementation, corresponding to reflexive composition),
do a pass at the end and send AAAAA wipes for any
ANNIHILATED{_TRANS} sprixcells. We don't present until
both have hit (since we're using a new image ID), so
there's no flicker, though there is some bandwidth cost.

That handles rebuilding. Problem is, if we then need to
wipe these same sprixcells *again*, our auxvecs were
set to ANNIHILATED{_TRANS}, and thus no wipe takes place.
Rather than blindly propagating the auxvec across the
frames, properly reset the auxvec according to the new
blit. This handles wiping post rebuild, closing the cycle.

Kitty 0.22.0+ now runs the bitmapstates PoC perfectly.
Closes #2143.  woo-hah!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bitmaps bitmapped graphics (sixel, kitty, mmap) bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant