Commit graph

12 commits

Author SHA1 Message Date
hujianwei
442f80b667 Implement support for multiple providers
* README: Document changes.
* compositor.h (struct _BufferFuncs): Rename `get_render_device'
to `get_render_devices' and make it return a list of providers.
* dmabuf.c (MakeFeedback): Send 1 tranche for each device.
(InitDrmDevice): Rename to InitDrmDevices.  Set up for multiple
devices.
(WriteFormatTable): Adjust call accordingly.

* egl.c (GetRenderDevice): Remove function.
(GetRenderDevices): New function.
(egl_buffer_funcs): Change accordingly.

* output.c (XLInitRROutputs): Require RandR 1.4.

* picture_renderer.c (GetRenderDevice): Remove calls to open.
(GetRenderDevices): New function.
(picture_buffer_funcs): Adjust accordingly.

* renderer.c (RenderGetRenderDevice): Delete function.
(RenderGetRenderDevices): New function.
2022-11-13 02:08:10 +00:00
hujianwei
f4194133f9 Better handle X server out-of-memory situations
* compositor.h (struct _RenderFuncs): Add function `set_client'.
(struct _ClientErrorData): New struct.
* icon_surface.c (XLGetIconSurface): Attach client to render
target.
* picture_renderer.c (struct _BackBuffer): Keep track of how
many pixels were allocated.
(struct _PictureTarget): Keep track of the client data.
(SetClient): New function.
(FreeBackBuffer, FreeBackBuffers, CreateBackBuffer)
(SetStandardEventMask, NoteTargetSize, DestroyRenderTarget)
(picture_render_funcs): Keep track of the number of pixels
allocated on behalf of each client.
* renderer.c (RenderSetClient): New function.
* run.c (RunStep): Disconnect clients pending disconnect.
* shm.c (InitRender): Export the render error base.
* test.c (GetTestSurface):
* xdg_surface.c (XLGetXdgSurface): Attach the client to the
render target.
* xerror.c (enum _ClientMemoryCategory): New enum.
(ReleaseClientData, HandleClientDestroy, ErrorDataForClient)
(CategorizeClients, SavePendingDisconnectClient)
(DisconnectOneClient, ProcessPendingDisconnectClients)
(HandleBadAlloc): New functions.
(ErrorHandler): Handle BadAlloc errors by disconnecting pixmap
hogs.
2022-11-08 03:37:37 +00:00
hujianwei
a05a62d9d0 Rework subcompositor damage culling and use a back buffer in the pict renderer
Note that the EGL renderer has been broken by these changes.

* compositor.h (struct _RenderFuncs): Change arguments to
`finish_render'.  Add `cancel_completion_callback'.  Remove
`cancel_presentation'.
(struct _BufferFuncs): Add `is_buffer_opaque'.
* egl.c: Note that the EGL renderer is currently broken.
* fence_ring.c (FenceFree, struct _Fence, GetFence, FenceAwait)
(FenceToXFence): Repurpose fence code as a generic allocator of
fences.
* frame_clock.c (EndFrame): Adjust calculation of even value.
* picture_renderer.c (struct _BufferActivityRecord): Remove
`fence'.
(struct _PictureBuffer): Remove unused field.
(struct _PresentCompletionCallback): Remove unused fields
linking it to the target.
(struct _BackBuffer): New structure.
(IsBufferBusy, SetBufferBusy, ClearBufferBusy): New macros.
(struct _PictureTarget): Add back buffer and GC fields.
(use_sync_fences): Remove variable.
(RecordBufferActivity): Don't take fence.
(UnlinkActivityRecord): Don't wait on fence.
(FreeBackBuffer, FreeBackBuffers, CreateBackBuffer)
(MakePresentationCallback, SwapBackBuffers)
(SwapBackBuffersWithCopy, MaybeAwaitBuffer, GetNextBackBuffer)
(EnsurePicture): New functions.
(TargetFromDrawable): Don't create picture for window targets,
and create GC for those.
(NoteTargetSize): Free back buffers instead of creating
presentation windows.
(DestroyRenderTarget): Free back buffers.
(ViewContainsExtents): Delete function.
(FinishRender): Swap back buffers and handle callbacks.
(CancelCompletionCallback): New function.
(TargetAge): Implement accordingly.
(PresentToWindow, CancelPresentationCallback): Present to the
regular window instead of a separate ``presentation window''.
(CancelPresentation): Remove function.
(picture_render_funcs): Add CancelCompletionCallback; remove
NeverAges and CancelPresentation.
(BufferFromDmaBuf, FinishDmaBufRecord, BufferFromShm): Set
opaque flag accordingly.
(IsBufferOpaque): New function.
(picture_buffer_funcs): Add IsBufferOpaque.
(HandlePresentCompleteNotify, HandlePresentIdleNotify): Handle
back buffer release.

* renderer.c (RenderFinishRender, RenderCancelCompletionCallback)
(RenderCancelPresentation, RenderIsBufferOpaque): Adjust
accordingly.
* seat.c (InterpolateAxes): Fix NULL-pointer dereference.

* subcompositor.c (SetFrozen, IsFrozen): Get rid of unused
state.
(struct _View): Cache the width and height.  Add cull_region
field.
(struct _Subcompositor): Add `render_key' field.
(ViewAfterSizeUpdate): Set cached width and height.
(ViewAttachBuffer): Correctly handle size changes.
(ViewDamage): Apply buffer damage.
(ViewDamageBuffer): use ViewDamage.
(ApplyBufferDamage): New function.:(FillBoxesWithTransparency,
ViewContainsExtents, IntersectBoxes): Delete unused functions.
(RenderCompletedCallback): New function.
(NoViewsAfter): Delete function.
(SkipSlug): New slug.
(SubcompositorUpdateAncillary, TryPresent, AnyParentUnmapped)
(DoCull, DrawBackground, CompositeSingleView, InitBackground)
(SubcompositorComposite1, SubcompositorComposite): New
functions.  Implement new redisplay logic here.
(SubcompositorUpdate, CopyRegion): New function.
(SubcompositorExpose, SubcompositorFree): Clear render callback
if set.
(SubcompositorLookupView): Use cached width and height.
(SubcompositorFreeze, SubcompositorUnfreeze): Remove unused
functions.
* time.c (InitTime): Fix use of uninitialized value initializing
the Sync extension.
* transform.c (TransformBox): Pacify compiler warning.
2022-10-29 05:21:35 +00:00
oldosfan
167001689a Fix bugs discovered by static analyzers and fix buffer damage calculation
* compositor.h (XLAssert): Make a macro.
* dnd.c (HandleCirculateNotify, HandleReparentNotify): Fix NULL
checks.
(ReadProtocolProperties): Return suitable values for windows
that aren't in the cache.
* egl.c (HaveEglExtension1): Avoid redundant assignment to n.
* fns.c (XLAssert): Delete function.
* picture_renderer.c (GetRenderDevice): Remove redundant TODO.
(BufferFromShm): Assert that pict_format is non-NULL.
(ValidateShmParams): Likewise.
* pointer_constraints.c (ApplyLines): Remove redundant
assignment to i.
* renderer.c (PickRenderer): Fix build with non-GCC compilers.
* seat.c (ComputeHotspot): Return values when surface is NULL.
(XLSeatExplicitlyGrabSurface): Don't save keyboard grab state.
* shm.c (CreatePool): Close fd and return if pool could not be
allocated.
* subcompositor.c (GetContentScale): Move earlier.
(ViewDamageBuffer, ViewGetContentScale): New functions.
(SubcompositorUpdate): Remove redundant assignment.
* surface.c (ApplyViewport): Make dest_width and dest_height
double.
(ApplyDamage): Call ViewDamageBuffer.
(ScaleToWindow):
* text_input.c (HandleNewIM):
* xdg_toplevel.c (SendDecorationConfigure1, HandleWmStateChange)
(HandleAllowedActionsChange, HandleDecorationResourceDestroy):
Avoid NULL pointer dereferences in various cases.
2022-10-17 04:44:49 +00:00
oldosfan
713eb811ea Add support for DRM leasing and significantly rework composition code
* 12to11.c (HandleCmdline): Improve messages printed during
-help.
(XLMain): Initialize DRM leasing.
* 12to11.man: Document changes.
* Imakefile (LOCAL_LIBRARIES): Add xcb-randr, xf86drm and
XPresent.
(SRCS): Add drm_lease.c.
(OBJS): Add drm_lease.o.
* atoms.c (names): Add CONNECTOR_ID.
(CONNECTOR_ID): New atom.
(XLInitAtoms): Intern CONNECTOR_ID.
* compositor.h (struct _RenderFuncs): Require event mask to be
passed to target_from_window.  New functions
`set_standard_event_mask', `present_to_window',
`cancel_presentation_callback', and `cancel_presentation'.
(struct _BufferFuncs): Move buffer release machinery here.
(enum _FrameMode): New enum.
* egl.c (TargetFromWindow, SetStandardEventMask,
egl_render_funcs): Adjust functions accordingly.
* frame_clock.c (struct _FrameClock): New fields
`end_frame_called' and `pending_sync_value'.
(HandleEndFrame, PostEndFrame, StartFrame, EndFrame): Clean up
frame synchronization code.  Do not end upon predicted
presentation time if EndFrame was not called in time.
(FreezeForValue): New function.
(XLFrameClockHandleFrameEvent): Defer actually freezing until
StartFrame happens.
(XLFrameClockGetFrameTime): New function.
* icon_surface.c (ReleaseBuffer): Use RenderWaitForIdle.
(RunFrameCallbacks, AfterFrame): Pass frame clock to callbacks.
Use frame time if available.
(XLGetIconSurface): Require wait_for_idle to work.
* output.c (change_hook): New hook.
(XLHandleOneXEventForOutputs): Run hook if set.
(XLOutputSetChangeFunction): New function.
(XLInitRROutputs): Select for RRResourceChangeNotify if
providers are supported.
* picture_renderer.c (struct _PresentRecord)
(struct _BufferActivityRecord, struct _IdleCallback)
(struct _PictureBuffer, struct _PictureTarget)
(struct _DrmFormatInfo, struct _DmaBufRecord)
(struct _PresentCompletionCallback): New record structures.
(all_formats, SendRoundtripMessage, FindBufferActivityRecord)
(RecordBufferActivity, RunIdleCallbacks, MaybeRunIdleCallbacks)
(UnlinkActivityRecord, HandleActivityEvent, InitRenderFuncs)
(TargetFromDrawable, TargetFromPixmap, TargetFromWindow)
(SetStandardEventMask, NoteTargetSize, PictureFromTarget)
(DestroyRenderTarget, FillBoxesWithTransparency)
(ServerRegionFromRegion, ClearRectangle, Composite)
(FindPresentRecord, AllocateRecord, PresentToWindow)
(CancelPresentationCallback, CancelPresentation)
(picture_render_funcs, FindSupportedModifiers, InitDrmFormats)
(PictFormatIsPresentable, BufferFromDmaBuf, FinishDmaBufRecord)
(BufferFromDmaBufAsync, BufferFromShm, BufferFromSinglePixel)
(FreeShmBuffer, FreeDmabufBuffer, FreeSinglePixelBuffer)
(AddIdleCallback, CancelIdleCallback, IsBufferIdle)
(IdleEventPredicate, WaitForIdle, SetNeedWaitForIdle)
(picture_buffer_funcs, HandlePresentCompleteNotify)
(HandlePresentIdleNotify, HandlePresentationEvent)
(HandleOneXEventForPictureRenderer, InitPictureRenderer): Allow
presenting pixmaps directly, and move buffer release tracking
machinery here.
* renderer.c (RenderTargetFromWindow): Update signature.
(RenderPresentToWindow, RenderCancelPresentationCallback)
(RenderCancelPresentation, RenderAddIdleCallback)
(RegisterStaticRenderer): New wrapper functions.
* run.c (HandleOneXEvent): Handle picture renderer events
earlier.
* seat.c (MaybeCreateCursor): Require wait_for_idle.
(ReleaseBuffer): Wait for buffer to become idle on each target
in the cursor ring.
* subcompositor.c (struct _Subcompositor): New callback
`note_frame'.
(SubcompositorSetNoteFrameCallback, NoViewsAfter)
(PresentCompletedCallback): New functions.
(SubcompositorUpdate): Try to present the buffer if possible,
and run completion callbacks.
(SubcompositorFree): Free presentation key.
* surface.c (XLSurfaceRunFrameCallbacksMs): New function.
* text_input.c: Improve commentary.
* xdg-shell.xml: Update from wayland-protocols.
* xdg_surface.c (struct _XdgRole): New fields `pending_frame',
`last_specified_serial'.
(struct _ReleaseLaterRecord): Replace free function with idle
callback key and xdg role pointers.
(RemoveRecord): Delete function.
(FreeRecords): Stop cancelling buffer destroy listener.
(ReleaseLaterExtBufferFunc): Delete function.
(RunFrameCallbacks): Use frame clock time if it is set.
(HandleReleaseLaterMessage): Delete function.
(BufferIdleCallback): New function.
(ReleaseLater): Delete function.
(XLHandleXEventForXdgSurfaces): Stop handling buffer release
events here.
(AckConfigure): Improve debug code and reject duplicate serials.
(Commit): Unfreeze earlier; also, in general...
(NoteFrame): Move frame handling implementation here.
(ReleaseBuffer, Subframe, EndSubframe, AfterFrame, ResizeForMap)
(SelectExtraEvents): Set standard event mask.
(XLGetXdgSurface, XLXdgRoleSendConfigure): ...Replace frame
clock logic with that in NoteFrame.
2022-10-12 12:53:09 +00:00
oldosfan
f2e3baad45 Add support for more resources and single pixel buffers
* 12to11.c (HandleCmdline): Handle `-xrm'.
(XLMain): Initialize single pixel buffers.
* 12to11.man: Improve documentation.
* Imakefile (SRCS): Add single_pixel_buffer.c.
(OBJS): Add single_pixel_buffer.o.
(single-pixel-buffer-v1): Add new scanner target.
* README: Document new supported protocol.
* compositor.h (struct _BufferFuncs): Add single pixel buffer
functions.
* egl.c (enum _EglBufferType): New buffer type.
(struct _EglSinglePixelBuffer): New struct.
(struct _EglBuffr): Add EglSinglePixelBuffer.
(struct _CompositeProgram): Add source_color uniform.
(EglCompileCompositeProgram): Look for both uniforms.
(EglCompileShaders): Compile single pixel shader.
(FindProgram, GetTextureTarget, Composite, UpdateTexture)
(EnsureTexture, UpdateBuffer): Handle single pixel buffers.
(BufferFromSinglePixel, FreeSinglePixelBuffer): New functions.
(egl_buffer_funcs): Add new buffer functions.
* picture_renderer.c (BufferFromSinglePixel,
FreeSinglePixelBuffer): New functions.
(picture_buffer_funcs): Add new buffer functions.
* renderer.c (RenderBufferFromSinglePixel)
(RenderUpdateBufferForDamage): New functions.
(ReadRendererResource, PickRenderer): Read resource if no
environment variable was specified.
* shaders.txt (Composite Rectangle Fragment Shader Single
Pixel): New shader.
* text_input.c (struct _TextInput, UpdatePreedit)
(PreeditStartCallback, PreeditCaretCallback): Correctly handle
caret types and style.
(XLInitTextInput): Fix failure message.
2022-10-06 10:46:54 +00:00
oldosfan
666947c94d Minor fixes to EGL renderer and toplevel resizing
* compositor.h (struct _RenderFuncs): Accept damage in
finish_render.
* egl.c (EglInitFuncs): Load eglSwapBuffersWithDamageEXT.
(FinishRender): Accept damage and swap only damaged area if
possible.
(UpdateBuffer): Always update textures.
* explicit_synchronization.c (XLSyncRelease): Fix comment.
* renderer.c (RenderFinishRender): Accept damage argument.
* subcompositor.c (ViewWidth, ViewHeight): Fix computation of
destination width and height when there is a content scale;
those values have already been adjusted into window coordinates.
(SubcompositorUpdate, SubcompositorExpose): Pass damage to
RenderFinishRender.
* surface.c (ApplyDamage): Fix some aspects of damage
calculation.
* xdg_surface.c (IsRoleMapped): Fix crash when destroying client
with subsurfaces.
(Commit, NoteBounds, ResizeForMap, XLXdgRoleSendConfigure)
(XLXdgRoleSetBoundsSize, XLXdgRoleResizeForMap): Really fix
window state reverting to maximized during unmaximization.  This
had two causes: the first was that the window geometry would be
set even before ack_configure, which was fixed by moving setting
the window geometry into NoteBounds, and the second was that
NoteBounds would sometimes resize the window back to its old
dimensions if a commit (or subsurface update) happened between
SetBoundsSize and the configure event arriving, also confusing
the window manager.
* xdg_toplevel.c (NoteConfigureTime): Fix coding style.
(HandleConfigureEvent): Call SetBoundsSize before posting the
configure event.
2022-10-01 02:50:58 +00:00
oldosfan
4d2e85d002 Implement wp_viewporter support and fix scaling for fractional values
* 12to11.c (XLMain): Initialize wp_viewporter.
* Imakefile (ETAGS): Remove unused variable.
(SRCS, OBJS): Add wp_viewporter.c and wp_viewporter.o.
(GENHEADERS): Remove unnecessary headers.
(viewporter): New scanner target.
* README: Document support for wp_viewporter.
* compositor.h (struct _ViewportExt): New forward declaration.
(struct _DrawParams): New fields for cropping and stretching.
(struct _RenderFuncs): Describe how composite works.
(struct _BufferFuncs): Make update_buffer_for_damage take
DrawParams as an argument.
(struct _State): New fields for viewporting.
(struct _Surface): New field `viewport' and associated input
delta.
(struct _XdgRoleImplementationFuncs): New field
`is_window_mapped'.  Do not commit while unmapped.
* dmabuf.c (XLInitDmabuf): Remove outdated comment.
* dnd.c (HandleMotion): Use TruncateWindowToSurface.
* egl.c (struct _EglBuffer): Add 3x3 reverse transformation
matrix.
(struct _CompositeProgram): Rename `scale' to `source'.
(Index): New macro.
(PickBetterVisual, FindVisual): Compensate for EGL picking a
non-RGBA visual.
(EglCompileCompositeProgram): Look for source, not scale.
(ComputeTransformMatrix): New function.
(Composite): Compute transformation matrix and draw using that.
(BufferFromDmaBuf, BufferFromShm): Copy identity transform and
stop setting scale.
(ReverseTransformToBox): New function.
(UpdateShmBufferIncrementally): Accept DrawParams and invert
damage according to that.
(UpdateBuffer, UpdateBufferForDamage): Pass draw params to the
incremental buffer update function.
* fns.c (XLExtendRegion): New function.
* frame_clock.c (CurrentHighPrecisionTimestamp): Delete
function.
(HighPrecisionTimestamp, HighPrecisionTimestamp32): New
functions.
(PostEndFrame): Handle X server time truncation to 32 bits.
(XLFrameClockFreeze): Remove trailing whitespace.
* picture_renderer.c (GetSourceX, GetSourceY, CompareStretch):
New functions.
(MaybeApplyTransform): Check more values before applying
transformations.  Then, handle stretch and offset.
* positioner.c (GetAdjustmentOffset, ApplyConstraintAdjustment)
(XLPositionerCalculateGeometry): Scale coordinates using new
functions.
* renderer.c (RenderUpdateBufferForDamage): Accept DrawParams
instead of scale.
* shaders.txt (Composite Rectangle Fragment Shader RGBA)
(Composite Rectangle Fragment Shader RGBX)
(Composite Rectangle Fragment Shader External): Stop
transforming texcoords.
(Composite Rectangle Vertex Shader): Transform texcoords in the
vertex shader instead.
* subcompositor.c (IsViewported, SetViewported,
ClearViewported): New functions.
(struct _View): New fields for tracking viewports and fractional
offsets.
(ViewAttachBuffer): Do not garbage upon buffer size change if a
viewport is set.
(ViewMoveFractional): New function.
(ViewDamage): Describe what the damage is and is not transformed
by.
(GetContentScale): New function.
(ViewWidth, ViewHeight): Apply viewport.
(ViewSetScale): Use ViewAfterSizeUpdate instead of duplicating
code.
(ViewSetViewport, ViewClearViewport): New functions.
(ViewComputeTransform): Compute transform for viewports.  New
arg draw; use it to determine whether or not to include a
fractional offset.
(IntersectBoxes): Fix intersection calculation.
(SubcompositorUpdate): Don't keep calling ViewWidth and
ViewHeight in a loop.
(SubcompositorExpose): Adjust for changes to buffer damage
uploading.
* subsurface.c (MoveFractional): New function.  Handle
fractional offsets after scaling.
(MaybeUpdateOutputs, AfterParentCommit, Setup, Rescale): Use
that function to move the subsurface instead.
* surface.c (ApplyScale): Update comment.
(ApplyViewport, CheckViewportValues): New functions.
(HandleScaleChanged): Apply the viewport as well upon scale
change.
(ApplyDamage): Improve damage calculation for viewported
surfaces.
(SavePendingState, InternalCommit): Save and commit viewport
state; check old values upon buffer commit.
(InitState): Initialize viewport to initial values.
(XLSurfaceRunFrameCallbacks): Handle overflows of 32-bit time at
the 49-day mark.
(SurfaceToWindow, ScaleToWindow, WindowToSurface, ScaleToSurface)
(TruncateScaleToWindow, TruncateScaleToWindow)
(TruncateWindowToSurface, TruncateScaleToSurface): New functions
for handling scale.
* xdg_popup.c (MoveWindow, IsWindowMapped, XLGetXdgPopup):
* xdg_surface.c (IsRoleMapped, Commit, Subframe)
(GetResizeDimensions, XLXdgRoleCalcNewWindowSize):
* xdg_toplevel.c (IsWindowMapped, NoteConfigureTime, SendStates)
(RecordStateSize, HandleWindowGeometryChange, NoteWindowPreResize)
(XLGetXdgToplevel): Use them instead of manually multiplying
with the factor.
2022-09-30 01:17:47 +00:00
oldosfan
7f33ba9ae3 Improve handling buffer scale factors
* compositor.h (struct _DrawParams): New structure.
(struct _RenderFuncs): Remove `apply_transform' and
`reset_transform'.  Make `composite' accept DrawParams.
(struct _BufferFuncs): Give scale to update_buffer_for_damage.
(struct _Surface): New field `factor'.
(struct _RoleFuncs): New callback `parent_rescale'.
* dnd.c (HandleMotion): Fix some aspects of scale handling.
* egl.c (struct _EglBuffer): Remove `scale' field.
(ApplyTransform): Delete function.
(Composite): Pass scale specified in params as uniform to
program.
(ResetTransform): Delete function.
(egl_render_funcs): Delete apply_transform and reset_transform.
(BufferFromDmaBuf, BufferFromShm): Stop setting scale attribute.
(UpdateBufferForDamage): Accept new arg `scale' and use it.

* picture_renderer.c (struct _PictureBuffer): New structure.
Store picture and last seen draw parameters.
(ApplyTransform): Delete function.
(GetScale): New function.
(MaybeApplyTransform): New function.
(Composite): Recompute and set pictures if draw parameters
change.
(ResetTransform): Delete function.
(picture_render_funcs): Remove unused hooks.
(BufferFromDmaBuf, FinishDmaBufRecord, BufferFromShm)
(FreeShmBuffer, FreeDmabufBuffer): Replace xid with wrapper
structure.

* positioner.c (TryFlipX, TryFlipY, GetAdjustmentOffset)
(ApplyConstraintAdjustment):
* renderer.c (RenderApplyTransform, RenderComposite)
(RenderResetTransform, RenderFinishRender)
(RenderUpdateBufferForDamage):
* seat.c (UpdateCursorOutput, ComputeHotspot, HandleRawButton)
(TransformToView, DispatchEntryExit, DispatchMotion, CancelGrab)
(DispatchButton, ForceEntry):
* subcompositor.c (GetTxTy, ViewApplyTransform, ViewHaveTransform)
(ViewComputeTransform, SubcompositorUpdate,
SubcompositorExpose):
* subsurface.c (MaybeUpdateOutputs, AfterParentCommit, Rescale)
(Teardown, GetSubsurface, XLUpdateOutputsForChildren): Use
surface-specific scale factors.
* surface.c (ApplyScale): Compute a new scale factor to convert
between window and surface scale.
(ApplyOpaqueRegion, ApplyInputRegion, HandleScaleChanged)
(ApplySurfaceDamage, InternalCommit, XLCreateSurface): Use new
factors instead.
* xdg_popup.c (MoveWindow):
* xdg_surface.c (GetResizeDimensions,
XLXdgRoleCalcNewWindowSize):
* xdg_toplevel.c (NoteConfigureTime, SendStates, RecordStateSize)
(HandleWindowGeometryChange, NoteWindowPreResize): Use
surface-specific scale factors.
2022-09-27 01:37:31 +00:00
oldosfan
ebcc957302 Implement explicit synchronization
* 12to11.c (XLMain): Initialize explicit synchronization.
* Imakefile (SRCS, OBJS): Remove generated files.
(ScannerTarget): New macro.
(clean): Clean GENSRCS as well.
(linux-dmabuf-unstable-v1.h):
(linux-dmabuf-unstable-v1.c):
(xdg-shell.h):
(xdg-shell.c):
(primary-selection-unstable-v1.h):
(primary-selection-unstable-v1.c): Remove and replace with
ScannerTarget.
* README: Announce explicit synchronization support.
* compositor.h (union _RenderFence): New union.
(struct _RenderFuncs): Add fence functions.
(struct _Surface): New fields for explicit synchronization
objects and release callbacks.
* egl.c (EglInitFuncs, EglInitGlFuncs, EglInitDisplay):
Initialize functions and extensions used for explicit
synchronization, and set render func flags.
(ImportFdFence, WaitFence, DeleteFence, HandleFenceReadable)
(GetFinishFence): New functions.
(egl_render_funcs): Add those functions.
(AddRenderFlag): New function.
* fns.c (MaybeInstallBusHandler): Fix coding style.
* picture_renderer.c (ImportFdFence, WaitFence, DeleteFence)
(GetFinishFence): New stubs.
(picture_render_funcs): Add those functions; they should never
be called.
* renderer.c (RenderImportFdFence):
(RenderWaitFence):
(RenderDeleteFence):
(RenderGetFinishFence): New wrapper functions.
* run.c (struct _PollFd, XLAddWriteFd, XLAddReadFd): Add pollfd
field to callback args.
(RunStep): Pass them to callbacks.  Also, fix a comment.
* surface.c (DoRelease): New function.
(DestroySurface): Clear release if possible.
(SavePendingState, TryEarlyRelease): Extract release code to
DoRelease.
(InternalCommit): Wait for sync fences before continuing.
(Commit): Close acquire fence and release sync release object.
(HandleSurfaceDestroy): Destroy release callback and close
acquire fence.
(XLCreateSurface): Clear acquire fence field with right initial
value.
* xdata.c (NoticeTransferWritable):
(NoticeTransferReadable):
(NoticeConversionTransferReadable):
(NoticeConversionTransferWritable): Adjust arguments for new
callback data.
2022-09-25 08:21:31 +00:00
oldosfan
459de34ca7 Implement various improvements to egl renderer
* 12to11.c (MakeColormap): Delete function.
(XLMain): Stop making colormap here.
* compositor.h (ImmediateRelease): New flag.
(struct _BufferFuncs): New field can_release_now.
(struct _State): New flag `BufferAlreadyReleased'.
* egl.c (struct _CompositeProgram): New field `invert_y'.
(EglCompileCompositeProgram): Get new uniform index.
(Composite): Apply InvertY.
(egl_render_funcs): Set ImmediateRelease flag.
(BufferFromDmaBuf): Set InvertY flag if set.
(UpdateTexture, UpdateShmBufferIncrementally): Set CanRelease
flag on SHM buffers.
(UpdateBuffer): Don't update if damage is empty.
(CanReleaseNow): New function.
(egl_buffer_funcs): Add CanReleaseNow.
* picture_renderer.c (MakeCheckWindow): New function.
(FindSupportedModifiers): Use a more similar window to look for
modifiers.
(CanReleaseNow): New function.
(picture_buffer_funcs): Add CanReleaseNow.
* renderer.c (RenderCanReleaseNow): New wrapper function.
(InstallRenderer): Create colormaps here, so the buffer init
function can get it.
* shaders.txt (Composite Rectangle Fragment Shader RGBA)
(Composite Rectangle Fragment Shader RGBX)
(Composite Rectangle Fragment Shader External): New uniform
`invert_y'.
(main): Use it.
* subcompositor.c (SubcompositorUpdate): Always update attached
buffer from damage, even if damage is empty.
* surface.c (TryEarlyRelease): New function.
(InternalCommit): Call it.  Also, do not call role
release_buffer hook if ImmediateRelease is specified by the
renderer.
(SavePendingState): Likewise, release buffers immediately if
possible.
2022-09-24 01:53:15 +00:00
oldosfan
970b60268f Check in new files for EGL support
* egl.c:
* picture_renderer.c:
* renderer.c:
* shaders.awk:
* shaders.txt: New files.  Move old XRender code to
picture_renderer.c.
2022-09-23 08:28:48 +00:00