Opened 16 years ago

Closed 15 years ago

#5324 closed patch (fixed)

OpenGLVideo patches

Reported by: mark.kendall@… Owned by: danielk
Priority: minor Milestone: 0.22
Component: mythtv Version: head
Severity: medium Keywords:
Cc: Ticket locked: no

Description

1 Remove OpenGLVideo::ReInit?

This is only used in one place (PiP) and will become increasingly tricky to maintain. Simply delete and recreate instead.

2 Remove offscreen rendering code

Unlikely to be used and just complicating the source.

3 Rename variables

Rename key variables in line with VideoOutput? to make opengl code easier to follow.

4 Remove an unnecessary #ifdef

5 Move OpenGL state management to OpenGLContext

The opengl state logically sits with the context and allows us to avoid some state thrashing.

6 FramebufferObject? Memory fix

On slower systems, I would get intermittent failures/crashes when switching between different opengl deinterlacers. FramebufferObject? creation was failing with out of memory errors when framebuffers were deleted and re-created in quick succession. Flushing the pipeline appears to fix the issue - this ties up with the ogl spec where it is recommended that we ensure any resource has actually been created (or released) before using it. For completeness I've added some flushing around other resource creation/deletion (textures, frag progs etc) and left some glCheck's in CreateFramebuffer? to catch any other fbo issues (fbo's appear to tricky at the best of times). N.B. glFlush doesn't actually guarantee execution of the pipeline. I'm looking at implementing NV_FENCE to help.

7 HD fix

Ensure sources that report 1088 frame height are rendered correctly.

8 Thread safety/locking.

This implements a fairly comprehensive thread safety 'policy' to fix stability issues. gl_context_lock is created as a recursive qmutex. This is used by itself when creating and deleting gl_context. It is then passed to gl_context which uses the mutex in combination with MakeCurrent? to ensure only one thread can access the context - i.e. the one it is current to. By tracking the lock, we also avoid unnecessary calls to glxMakeCurrent and do not release the context early (which has caught me out a number of times!). We then ensure that all public members of OpenGLContext and OpenGLVideo are wrapped by a MakeCurrent? 'pair'. Finally ContextLocker? is provided as a convenience class (as the folks at Trolltech would say).

9 Simplify OpenGLVideo::Teardown

10 Implement PixelBufferObject? support

Uploading video frame data is currently a significant bottleneck for opengl performance. In the current code, the driver will take the luminance and chroma information and pad them internally to 4 bytes per 'pixel' before sending them to the gpu. We then have to access 3 different textures to retrieve all of our video data. Hence there is overhead at every stage (300% overhead on data transfer alone) PixelBufferObjects? are optimised for data transfer/streaming when the texture format is BGRA. So we pack the YUV data into one texture, tell the driver it is BGRA, use a PBO to transfer the data and then we only need to access one texture on the GPU. Performance is further improved by using some mmx optimisations to pack the video frame into one texture. For reference, some test code I have will blit a video sequence at 440 fps using the current (trunk) opengl code. This a 720x576 frame size dispayed at 720x576 (i.e no scaling) with no audio and all vsync's turned off (using an 8800GT). The same code will run at 660 fps using the XVideo renderer. With pbo support (and using mmx), the opengl renderer will run at 590 fps.

11 Picture controls

Move the picture control code from OpenGLVideo to OpenGLContext so that the picture attributes can be shared between the main video, PiP and osd. I couldn't decide whether to apply picture controls to the osd but in the end enabled them for consistency with the Xv renderer.

12 glx1.3 fixes

glx1.2 calls aren't deprecated but their use is not recommended. Will also facilitate moving xvmc-opengl code into OpenGLVideo/OpenGLContext.

Attachments (29)

openglvid_1.diff (3.9 KB) - added by anonymous 16 years ago.
openglvid_2.diff (12.7 KB) - added by anonymous 16 years ago.
openglvid_3.diff (12.6 KB) - added by anonymous 16 years ago.
openglvid_4.diff (1.3 KB) - added by anonymous 16 years ago.
openglvid_5.diff (6.4 KB) - added by anonymous 16 years ago.
openglvid_6.diff (1.7 KB) - added by anonymous 16 years ago.
openglvid_7.diff (4.7 KB) - added by anonymous 16 years ago.
openglvid_8.diff (18.2 KB) - added by anonymous 16 years ago.
openglvid_9.diff (1.2 KB) - added by anonymous 16 years ago.
openglvid_10.diff (32.6 KB) - added by anonymous 16 years ago.
openglvid_11.diff (9.7 KB) - added by anonymous 16 years ago.
openglvid_12.diff (1.1 KB) - added by anonymous 16 years ago.
openglvid_13.diff (695 bytes) - added by anonymous 16 years ago.
Missed in patch 2
openglvid_14.diff (8.2 KB) - added by anonymous 16 years ago.
openglvid_15.diff (499 bytes) - added by anonymous 16 years ago.
mythtv-vid-16.diff (2.9 KB) - added by mark_kendall@… 16 years ago.
Tidy up some locking and ensure GL_PACK_ALIGNMENT is set to the correct value.
mythtv-vid-17.diff (22.8 KB) - added by mark.kendall@… 16 years ago.
Tidy up YV12 packing code and add proper packing/upsampling of interlaced YV12 frames
mythtv-vid-18.diff (48.3 KB) - added by mark.kendall@… 16 years ago.
Re-write of texture handling. Default to packing all video textures, even if we don't have PixelBufferObjects? (still as fast as existing code and makes fragment program code much easier to handle). Much tighter control over texture properties - needed for bicubic filter. Fixes some FrameBufferObject? instability.
mythtv-vid-18a.diff (2.5 KB) - added by mark.kendall@… 16 years ago.
Don't try and upsample interlaced frames when using software bobdeint.
mythtv-vid-19.diff (44.0 KB) - added by mark.kendall@… 16 years ago.
Rewrite of deinterlacing code. Combine YUV2RGB and deinterlacing. Use 3 different fragment programs for progressive, top field and bottom field. Now properly deinterlaces luma and chroma channels and much faster. FrameBufferObjects? no longer a requirement.
mythtv-vid-20.diff (9.5 KB) - added by mark.kendall@… 16 years ago.
Add a GPU based YADIF deinterlacer
mythtv-vid-21.diff (9.8 KB) - added by mark.kendall@… 16 years ago.
Add bicubic upsampling filter.
mythtv-vid-22.diff (840 bytes) - added by mark.kendall@… 16 years ago.
Fix a seg fault and memory leak.
mythtv-vid-23.diff (13.0 KB) - added by mark.kendall@… 16 years ago.
Add ability to switch on bicubic by adding openglbicubic to filters in display profile. Also adds some opengl options.
mythtv-vid-24.diff (2.1 KB) - added by mark.kendall@… 16 years ago.
Add DisableTextures? method for mythtv-vid functionality
mythtv-vid-25.diff (7.4 KB) - added by mark.kendall@… 16 years ago.
Use mmx for the bulk of YV12 packing if OSD frame width is not divisible by 8 and fall back to c for the rest.
mythtv-vid-26.diff (4.7 KB) - added by mark.kendall@… 16 years ago.
Use an extra resize stage when downscaling and deinterlacing (denterlacing doesn't work otherwise), remove it when not deinterlacing.
mythtv-vid-27.diff (909 bytes) - added by anonymous 16 years ago.
Small fix when using bobdeint and opengl renderer (get the fields the right way around)
mythtv-vid-28.diff (1.0 KB) - added by mark.kendall@… 15 years ago.
A couple of small QT4 fixes

Download all attachments as: .zip

Change History (55)

Changed 16 years ago by anonymous

Attachment: openglvid_1.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_2.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_3.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_4.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_5.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_6.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_7.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_8.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_9.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_10.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_11.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_12.diff added

Changed 16 years ago by anonymous

Attachment: openglvid_13.diff added

Missed in patch 2

comment:1 Changed 16 years ago by mark.kendall@…

14 Implement GL_NV_fence support

glFlush does not guarantee all pipeline instructions have been executed before completion. glFinish does guarantee this but may block until the next vertical sync. NV_fence allows us to guarantee completion of the pipeline without potential blocking.

Changed 16 years ago by anonymous

Attachment: openglvid_14.diff added

comment:2 Changed 16 years ago by mark.kendall@…

15 Small ATI fix

Ref patch 10 (pbo support) - ensure we pick up the correct extension

Changed 16 years ago by anonymous

Attachment: openglvid_15.diff added

comment:3 Changed 16 years ago by skamithi

(In [17394]) Refs #2287, Refs #5324. mythtv-vid: commit patch(1) This is only used in one place (PiP) and will become increasingly tricky to maintain. Simply delete and recreate instead.

comment:4 Changed 16 years ago by skamithi

(In [17395]) Refs #5324, Refs #2287, mythtv-vid: commit patch(2): Remove offscreen rendering code

comment:5 Changed 16 years ago by skamithi

(In [17396]) Refs #5324, Refs #2287. mythtv-vid: commit patch (3) of #5324. Rename key variables in line with VideoOutput?? to make opengl code easier to follow.

comment:6 Changed 16 years ago by skamithi

(In [17397]) Refs #5324, Refs #2287. fix compilation issues when opengl video is disabled. incorporates patch(4) of #5324 by providing a better fix then [13916]

comment:7 Changed 16 years ago by skamithi

(In [17414]) Refs #5324, Refs #2287. mythtv-vid: commit patch(5) and patch(13). Move OpenGL state management to OpenGLContext remove [15453] as patch(5) resolves this issue in a better way.

comment:8 Changed 16 years ago by skamithi

(In [17419]) Refs #5324, Refs #2287. mythtv-vid: commit patch(7). opengl HD fix.

comment:9 Changed 16 years ago by skamithi

(In [17430]) Refs #5324, Refs #2287. mythtv-vid: opengl thread safety locking improvements. patch(8)

comment:10 Changed 16 years ago by skamithi

(In [17431]) Refs #5324, Refs #2287. mythtv-vid: simplify openglvideo::teardown, implement pixelbufferobject support. commits patch (9),(10),(15)

comment:11 Changed 16 years ago by skamithi

(In [17521]) Refs #5324 , Refs #2287, mythtv-vid: opengl renderer. Move the picture control code from OpenGLVideo to OpenGLContext so that the picture attributes can be shared between the main video, PiP and osd. (patch 11)

Changed 16 years ago by mark_kendall@…

Attachment: mythtv-vid-16.diff added

Tidy up some locking and ensure GL_PACK_ALIGNMENT is set to the correct value.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-17.diff added

Tidy up YV12 packing code and add proper packing/upsampling of interlaced YV12 frames

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-18.diff added

Re-write of texture handling. Default to packing all video textures, even if we don't have PixelBufferObjects? (still as fast as existing code and makes fragment program code much easier to handle). Much tighter control over texture properties - needed for bicubic filter. Fixes some FrameBufferObject? instability.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-18a.diff added

Don't try and upsample interlaced frames when using software bobdeint.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-19.diff added

Rewrite of deinterlacing code. Combine YUV2RGB and deinterlacing. Use 3 different fragment programs for progressive, top field and bottom field. Now properly deinterlaces luma and chroma channels and much faster. FrameBufferObjects? no longer a requirement.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-20.diff added

Add a GPU based YADIF deinterlacer

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-21.diff added

Add bicubic upsampling filter.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-22.diff added

Fix a seg fault and memory leak.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-23.diff added

Add ability to switch on bicubic by adding openglbicubic to filters in display profile. Also adds some opengl options.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-24.diff added

Add DisableTextures? method for mythtv-vid functionality

comment:12 Changed 16 years ago by skamithi

(In [17765]) Refs #5324, Refs #2287. mythtv-vid. Tidy up some locking and ensure GL_PACK_ALIGNMENT is set to the correct value.

comment:13 Changed 16 years ago by skamithi

(In [17775]) Refs #5324 , Refs #2287. mythtv-vid. patch(17) Tidy up YV12 packing code and add proper packing/upsampling of interlaced YV12 frames

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-25.diff added

Use mmx for the bulk of YV12 packing if OSD frame width is not divisible by 8 and fall back to c for the rest.

Changed 16 years ago by mark.kendall@…

Attachment: mythtv-vid-26.diff added

Use an extra resize stage when downscaling and deinterlacing (denterlacing doesn't work otherwise), remove it when not deinterlacing.

comment:14 Changed 16 years ago by skamithi

(In [18013]) Refs #5324, Refs #2287. apply patch 19. Rewrite of deinterlacing code. Combine YUV2RGB and deinterlacing. Use 3 different fragment programs for progressive, top field and bottom field. Now properly deinterlaces luma and chroma channels and much faster. FrameBufferObjects?? no longer a requirement. patch 18 and 18a, are already applied. this was done through [17954].

comment:15 Changed 16 years ago by skamithi

(In [18050]) Refs #5324, Refs #2287. mythtv-vid: Add a GPU based YADIF deinterlacer .patch(20)

Changed 16 years ago by anonymous

Attachment: mythtv-vid-27.diff added

Small fix when using bobdeint and opengl renderer (get the fields the right way around)

comment:16 Changed 15 years ago by elkin@…

I have been running these patches for nearly 8 weeks without a single problem. Any chance of getting them into 0.21-fixes?

comment:17 in reply to:  16 Changed 15 years ago by Janne Grunau

Replying to elkin@elkin.de:

I have been running these patches for nearly 8 weeks without a single problem. Any chance of getting them into 0.21-fixes?

that ought to be a joke, right?

comment:18 Changed 15 years ago by elkin@…

Hi Janne, why a joke?

Changed 15 years ago by mark.kendall@…

Attachment: mythtv-vid-28.diff added

A couple of small QT4 fixes

comment:19 Changed 15 years ago by danielk

Milestone: unknown0.22
Owner: changed from Isaac Richards to danielk
Status: newassigned
Version: unknownhead

comment:20 Changed 15 years ago by danielk

(In [18919]) Refs #5324. Refs #2287. Applies Mark's mythtv-vid-22 patch, with some modifications.

comment:21 Changed 15 years ago by danielk

(In [19032]) Refs #2287. Refs #5324. Applies Mark Kendal's bicubic filter patch #22 to mythtv-vid.

comment:22 Changed 15 years ago by danielk

(In [19033]) Refs #2287. Refs #5324. Applies Mark Kendal's disable textures patch #24 to mythtv-vid; this adds a DisableTextures? method to OpenGLContext to match the EnableTextures? method and uses it in openglvideo instead of raw OpenGL.

comment:23 Changed 15 years ago by danielk

(In [19034]) Refs #2287. Refs #5324. Applies Mark Kendal's mmx packing patch (no.25), this lets mythtv use MMX more often when it's available for the OSD YV12 packing.

comment:24 Changed 15 years ago by danielk

(In [19035]) Refs #2287. Refs #5324. Applies Mark Kendal's resize stage patch (no.26), this allows deinterlacing to work with resized opengl video frames.

comment:25 Changed 15 years ago by danielk

(In [19036]) Refs #2287. Refs #5324. Correct field reversal that was making OpenGL bobdeint look bad. (patch 27 from Mark Kendal)

comment:26 Changed 15 years ago by danielk

Resolution: fixed
Status: assignedclosed

All patches have been applied, closing as fixed. Lets start a new ticket for any refactoring of the OpenGL video output...

Note: See TracTickets for help on using tickets.