yuq / mesa-lima

Deprecated, new place: https://gitlab.freedesktop.org/lima
https://github.com/yuq/mesa-lima/wiki
165 stars 18 forks source link

Scissor support #15

Closed PabloPL closed 6 years ago

PabloPL commented 6 years ago

This commit adds scissor support.

It was tested with following sample https://github.com/PabloPL/gfx/tree/scissor-test/gbm-surface-scissor It's just a copy of gbm-surface-move where it should display following data:

Also during testing it's good to change this order, so first is zero scissor and later non zero, with previous implementation (where we're just skipping all in draw_vbo) this was not working (displaying the same image as in previous frame).

yuq commented 6 years ago

So with the following order: frame0: full image frame1: zero scissor what will show in frame1 with the current implementation, a black screen or the frame0 content?

BTW. what about the glclear issue you mentioned before?

PabloPL commented 6 years ago

what will show in frame1 with the current implementation, a black screen or the frame0 content?

It'll be empty screen (because glClear is set to 0,0,0,0. If it would be set to for example green, it would be green). I got exactly the same result when running this code on my intel gpu.

yuq commented 6 years ago

But I remember that you did some experiment that the glClear will also be scissored so frame1 will be the same as frame0. It can also be find in the glClear spec that: The scissor box bounds the cleared region.

Oh, seems it relate to the order of calling glClear and glScissor. In your gbm-surface-scissor, the glClear happens before glScissor, so the frame1 should be empty (glClear not scissored), but if glClear happens after glScissor, frame1 will be the same as frame0.

PabloPL commented 6 years ago

About glclear issue. In some piglit tests, where i was looking for test code (for example https://github.com/mesa3d/piglit/blob/master/tests/spec/gl-1.0/scissor-clear.c#L45), they're not calling swapbuffers/flush. In this case i was getting info that test failed and after that saw on console/got breakpoint hit that lima_flush got called and job submited to kernel. Sometimes it wasn't even submited.

I'm rebuilding mesa (on my h3 device, so it takes some time..), but will check this again. Maybe in this case it shoud be some kind of waiting for gpu to finish processing? I have somewhere fence support, based on vc4 code, using lima_submit_wait).

Edit 1: After changing order (so scissor is before clear) there is error with clear (it is not clipped to scissor region), but this could be handled when working on clear support (also mentioned on wiki).