Allow "reinterpretation" of framebuffer/zeta formats (#418)
* (Re)Implement format reinterpretation, other changes * Implement writeback to guest memory, some refactoring * More refactoring, implement reinterpretation the old way again * Clean up * Some fixes on M2MF (old Dma engine), added partial support for P2MF, fix conditional ssy, add Z24S8 zeta format, other fixes * nit: Formatting * Address PR feedback
This commit is contained in:
parent
bec95cacc1
commit
d4187aaa9d
52 changed files with 1594 additions and 1979 deletions
|
@ -288,7 +288,8 @@ namespace Ryujinx.HLE.HOS.Kernel
|
|||
//Fail for info not available on older Kernel versions.
|
||||
if (InfoType == 18 ||
|
||||
InfoType == 19 ||
|
||||
InfoType == 20)
|
||||
InfoType == 20 ||
|
||||
InfoType == 21)
|
||||
{
|
||||
ThreadState.X0 = MakeError(ErrorModule.Kernel, KernelErr.InvalidEnumValue);
|
||||
|
||||
|
|
|
@ -3,7 +3,6 @@ using Ryujinx.HLE.HOS.Ipc;
|
|||
using Ryujinx.HLE.HOS.SystemState;
|
||||
using Ryujinx.HLE.Logging;
|
||||
using Ryujinx.HLE.Utilities;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
|
|
|
@ -13,7 +13,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
|
||||
public override IReadOnlyDictionary<int, ServiceProcessRequest> Commands => m_Commands;
|
||||
|
||||
private KEvent ReleaseEvent;
|
||||
private KEvent BinderEvent;
|
||||
|
||||
private NvFlinger Flinger;
|
||||
|
||||
|
@ -27,9 +27,11 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
{ 3, TransactParcelAuto }
|
||||
};
|
||||
|
||||
ReleaseEvent = new KEvent();
|
||||
BinderEvent = new KEvent();
|
||||
|
||||
Flinger = new NvFlinger(Renderer, ReleaseEvent);
|
||||
BinderEvent.WaitEvent.Set();
|
||||
|
||||
Flinger = new NvFlinger(Renderer, BinderEvent);
|
||||
}
|
||||
|
||||
public long TransactParcel(ServiceCtx Context)
|
||||
|
@ -75,7 +77,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
int Id = Context.RequestData.ReadInt32();
|
||||
uint Unk = Context.RequestData.ReadUInt32();
|
||||
|
||||
int Handle = Context.Process.HandleTable.OpenHandle(ReleaseEvent);
|
||||
int Handle = Context.Process.HandleTable.OpenHandle(BinderEvent);
|
||||
|
||||
Context.Response.HandleDesc = IpcHandleDesc.MakeMove(Handle);
|
||||
|
||||
|
@ -91,7 +93,7 @@ namespace Ryujinx.HLE.HOS.Services.Vi
|
|||
{
|
||||
if (Disposing)
|
||||
{
|
||||
ReleaseEvent.Dispose();
|
||||
BinderEvent.Dispose();
|
||||
|
||||
Flinger.Dispose();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using Ryujinx.Graphics.Gal;
|
||||
using Ryujinx.Graphics.Texture;
|
||||
using Ryujinx.Graphics.Memory;
|
||||
using Ryujinx.HLE.HOS.Kernel;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvGpuAS;
|
||||
using Ryujinx.HLE.HOS.Services.Nv.NvMap;
|
||||
using Ryujinx.HLE.Logging;
|
||||
using System;
|
||||
|
@ -19,7 +20,7 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
|||
|
||||
private Dictionary<(string, int), ServiceProcessParcel> Commands;
|
||||
|
||||
private KEvent ReleaseEvent;
|
||||
private KEvent BinderEvent;
|
||||
|
||||
private IGalRenderer Renderer;
|
||||
|
||||
|
@ -67,7 +68,7 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
|||
|
||||
private bool Disposed;
|
||||
|
||||
public NvFlinger(IGalRenderer Renderer, KEvent ReleaseEvent)
|
||||
public NvFlinger(IGalRenderer Renderer, KEvent BinderEvent)
|
||||
{
|
||||
Commands = new Dictionary<(string, int), ServiceProcessParcel>()
|
||||
{
|
||||
|
@ -82,8 +83,8 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
|||
{ ("android.gui.IGraphicBufferProducer", 0xe), GbpPreallocBuffer }
|
||||
};
|
||||
|
||||
this.Renderer = Renderer;
|
||||
this.ReleaseEvent = ReleaseEvent;
|
||||
this.Renderer = Renderer;
|
||||
this.BinderEvent = BinderEvent;
|
||||
|
||||
BufferQueue = new BufferEntry[0x40];
|
||||
|
||||
|
@ -301,42 +302,41 @@ namespace Ryujinx.HLE.HOS.Services.Android
|
|||
bool FlipX = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipX);
|
||||
bool FlipY = BufferQueue[Slot].Transform.HasFlag(HalTransform.FlipY);
|
||||
|
||||
//Rotation is being ignored
|
||||
//Note: Rotation is being ignored.
|
||||
|
||||
int Top = Crop.Top;
|
||||
int Left = Crop.Left;
|
||||
int Right = Crop.Right;
|
||||
int Bottom = Crop.Bottom;
|
||||
|
||||
Renderer.QueueAction(() => Renderer.RenderTarget.SetTransform(FlipX, FlipY, Top, Left, Right, Bottom));
|
||||
NvGpuVmm Vmm = NvGpuASIoctl.GetASCtx(Context).Vmm;
|
||||
|
||||
//TODO: Support double buffering here aswell, it is broken for GPU
|
||||
//frame buffers because it seems to be completely out of sync.
|
||||
if (Context.Device.Gpu.Engine3d.IsFrameBufferPosition(FbAddr))
|
||||
Renderer.QueueAction(() =>
|
||||
{
|
||||
//Frame buffer is rendered to by the GPU, we can just
|
||||
//bind the frame buffer texture, it's not necessary to read anything.
|
||||
Renderer.QueueAction(() => Renderer.RenderTarget.Set(FbAddr));
|
||||
}
|
||||
else
|
||||
{
|
||||
//Frame buffer is not set on the GPU registers, in this case
|
||||
//assume that the app is manually writing to it.
|
||||
TextureInfo Texture = new TextureInfo(FbAddr, FbWidth, FbHeight);
|
||||
if (!Renderer.Texture.TryGetImage(FbAddr, out GalImage Image))
|
||||
{
|
||||
Image = new GalImage(
|
||||
FbWidth,
|
||||
FbHeight, 1, 16,
|
||||
GalMemoryLayout.BlockLinear,
|
||||
GalImageFormat.A8B8G8R8 | GalImageFormat.Unorm);
|
||||
}
|
||||
|
||||
byte[] Data = TextureReader.Read(Context.Memory, Texture);
|
||||
Context.Device.Gpu.ResourceManager.ClearPbCache();
|
||||
Context.Device.Gpu.ResourceManager.SendTexture(Vmm, FbAddr, Image);
|
||||
|
||||
Renderer.QueueAction(() => Renderer.RenderTarget.Set(Data, FbWidth, FbHeight));
|
||||
}
|
||||
Renderer.RenderTarget.SetTransform(FlipX, FlipY, Top, Left, Right, Bottom);
|
||||
Renderer.RenderTarget.Set(FbAddr);
|
||||
|
||||
Context.Device.Gpu.Renderer.QueueAction(() => ReleaseBuffer(Slot));
|
||||
ReleaseBuffer(Slot);
|
||||
});
|
||||
}
|
||||
|
||||
private void ReleaseBuffer(int Slot)
|
||||
{
|
||||
BufferQueue[Slot].State = BufferState.Free;
|
||||
|
||||
ReleaseEvent.WaitEvent.Set();
|
||||
BinderEvent.WaitEvent.Set();
|
||||
|
||||
lock (WaitBufferFree)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue