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

MP1-5214: Add PixelShader support: If the MediaInfo is not available then pick the profile later from EVR callback #318

Merged
merged 1 commit into from
Jun 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 29 additions & 10 deletions mediaportal/Core/Player/PlaneScene.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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;
}

/// <summary>
/// OnMessage.
/// Handles received GUIMessage's from graphics context.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down
Loading