From b237cabf4574b0d6a689eb78a2184646ed042c57 Mon Sep 17 00:00:00 2001 From: epbk Date: Tue, 11 Jun 2024 12:23:53 +0200 Subject: [PATCH] MP1-5214: Add PixelShader support: If the MediaInfo is not available then pick the profile later from EVR callback --- mediaportal/Core/Player/PlaneScene.cs | 39 ++++++++++++++++++++------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/mediaportal/Core/Player/PlaneScene.cs b/mediaportal/Core/Player/PlaneScene.cs index 185e23602e1..011826a15da 100644 --- a/mediaportal/Core/Player/PlaneScene.cs +++ b/mediaportal/Core/Player/PlaneScene.cs @@ -128,6 +128,7 @@ public class PlaneScene : IVMR9PresentCallback, IRenderLayer private readonly System.Diagnostics.Stopwatch _PixelShaderClock = new System.Diagnostics.Stopwatch(); private long _PixelShaderCounter = 0; private Texture[] _PixelShaderTexturesTemp = null; + private bool _PixelShaderInitialized = false; #endregion @@ -392,26 +393,38 @@ public void Init() { string strProfile = PixelShaderCollection.SHADER_PROFILE_DEFAULT; - //Profile: based on video width + //Profile: based on video size; if MediaInfo is not available(online video), then load the profile during the rendering process later if (g_Player.MediaInfo != null && g_Player.MediaInfo.Width > 0) - { - if (g_Player.MediaInfo.Width > 1920) - strProfile = "UHD"; - else if (g_Player.MediaInfo.Width >= 1440) - strProfile = "HD"; - else - strProfile = "SD"; - } + strProfile = SelectPixelShaderProfile(g_Player.MediaInfo.Width, g_Player.MediaInfo.Height); GUIGraphicsContext.VideoPixelShaders.Load(strProfile); } else + { GUIGraphicsContext.VideoPixelShaders.Clear(); //not supported with MadVR + this._PixelShaderInitialized = true; + } this._PixelShaderClock.Start(); #endregion } + private string SelectPixelShaderProfile(int iVideoWidth, int iVideoHeight) + { + string strProfile; + + if (iVideoWidth > 1920 || iVideoHeight > 1080) + strProfile = "UHD"; + else if (iVideoWidth >= 1440 || iVideoHeight >= 720) + strProfile = "HD"; + else + strProfile = "SD"; + + this._PixelShaderInitialized = true; + + return strProfile; + } + /// /// OnMessage. /// Handles received GUIMessage's from graphics context. @@ -2056,6 +2069,13 @@ private void PresentScene(bool bIsRepaint) private void DrawTextureSegment(VertexBuffer vertexBuffer, float srcX, float srcY, float srcWidth, float srcHeight, float dstX, float dstY, float dstWidth, float dstHeight, long lColorDiffuse) { + if (!this._PixelShaderInitialized) + { + //Pixel shaders not initialized yet; MediaInfo was not available upon initialization + GUIGraphicsContext.VideoPixelShaders.Load(this.SelectPixelShaderProfile((int)srcWidth, (int)srcHeight)); + this._PixelShaderInitialized = true; + } + unsafe { CustomVertex.TransformedColoredTextured* verts = (CustomVertex.TransformedColoredTextured*)vertexBuffer.LockToPointer(0, 0, this._vertexBufferLock); @@ -2115,7 +2135,6 @@ private void DrawTextureSegment(VertexBuffer vertexBuffer, float srcX, float src vertexBuffer.Unlock(); GUIGraphicsContext.DX9Device.SetStreamSource(0, vertexBuffer, 0, CustomVertex.TransformedColoredTextured.StrideSize); - if (GUIGraphicsContext.VideoPixelShaders.Count > 0) {