Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
2135b6a51a | ||
|
00e35d9bf6 | ||
|
6dfb6ccf8c | ||
|
e87e8b012c | ||
|
e8f1ca8427 |
@@ -4,6 +4,11 @@ namespace ARMeilleure.CodeGen.X86
|
||||
{
|
||||
partial class Assembler
|
||||
{
|
||||
public static bool SupportsVexPrefix(X86Instruction inst)
|
||||
{
|
||||
return _instTable[(int)inst].Flags.HasFlag(InstructionFlags.Vex);
|
||||
}
|
||||
|
||||
private const int BadOp = 0;
|
||||
|
||||
[Flags]
|
||||
|
@@ -1297,11 +1297,15 @@ namespace ARMeilleure.CodeGen.X86
|
||||
{
|
||||
if (IsIntrinsic(operation.Instruction))
|
||||
{
|
||||
IntrinsicInfo info = IntrinsicTable.GetInfo(operation.Intrinsic);
|
||||
|
||||
bool hasVex = HardwareCapabilities.SupportsVexEncoding && Assembler.SupportsVexPrefix(info.Inst);
|
||||
|
||||
bool isUnary = operation.SourcesCount < 2;
|
||||
|
||||
bool hasVecDest = operation.Destination != default && operation.Destination.Type == OperandType.V128;
|
||||
|
||||
return !HardwareCapabilities.SupportsVexEncoding && !isUnary && hasVecDest;
|
||||
return !hasVex && !isUnary && hasVecDest;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
@@ -553,7 +553,7 @@ namespace Ryujinx.Graphics.Gpu.Image
|
||||
|
||||
specStateMatches &= specState.MatchesTexture(stage, index, descriptor);
|
||||
|
||||
Sampler sampler = _samplerPool?.Get(samplerId);
|
||||
Sampler sampler = samplerPool?.Get(samplerId);
|
||||
|
||||
ITexture hostTexture = texture?.GetTargetTexture(bindingInfo.Target);
|
||||
ISampler hostSampler = sampler?.GetHostSampler(texture);
|
||||
|
@@ -236,7 +236,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
return;
|
||||
}
|
||||
|
||||
PreDraw();
|
||||
PreDraw(vertexCount);
|
||||
|
||||
if (_primitiveType == PrimitiveType.Quads && !HwCapabilities.SupportsQuads)
|
||||
{
|
||||
@@ -354,7 +354,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
return;
|
||||
}
|
||||
|
||||
PreDraw();
|
||||
PreDrawVbUnbounded();
|
||||
|
||||
int indexElemSize = 1;
|
||||
|
||||
@@ -686,7 +686,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
return;
|
||||
}
|
||||
|
||||
PreDraw();
|
||||
PreDrawVbUnbounded();
|
||||
|
||||
GL.BindBuffer((BufferTarget)All.DrawIndirectBuffer, indirectBuffer.Handle.ToInt32());
|
||||
GL.BindBuffer((BufferTarget)All.ParameterBuffer, parameterBuffer.Handle.ToInt32());
|
||||
@@ -709,7 +709,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
return;
|
||||
}
|
||||
|
||||
PreDraw();
|
||||
PreDrawVbUnbounded();
|
||||
|
||||
_vertexArray.SetRangeOfIndexBuffer();
|
||||
|
||||
@@ -1515,11 +1515,22 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
_supportBuffer.Commit();
|
||||
}
|
||||
|
||||
private void PreDraw(int vertexCount)
|
||||
{
|
||||
_vertexArray.PreDraw(vertexCount);
|
||||
PreDraw();
|
||||
}
|
||||
|
||||
private void PreDrawVbUnbounded()
|
||||
{
|
||||
_vertexArray.PreDrawVbUnbounded();
|
||||
PreDraw();
|
||||
}
|
||||
|
||||
private void PreDraw()
|
||||
{
|
||||
DrawCount++;
|
||||
|
||||
_vertexArray.Validate();
|
||||
_unit0Texture?.Bind(0);
|
||||
_supportBuffer.Commit();
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using OpenTK.Graphics.OpenGL;
|
||||
using Ryujinx.Graphics.GAL;
|
||||
using System;
|
||||
using System.Numerics;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Ryujinx.Graphics.OpenGL
|
||||
@@ -16,12 +17,16 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
|
||||
private int _vertexAttribsCount;
|
||||
private int _vertexBuffersCount;
|
||||
private int _minVertexCount;
|
||||
|
||||
private uint _vertexAttribsInUse;
|
||||
private uint _vertexBuffersInUse;
|
||||
private uint _vertexBuffersLimited;
|
||||
|
||||
private BufferRange _indexBuffer;
|
||||
private BufferHandle _tempIndexBuffer;
|
||||
private BufferHandle _tempVertexBuffer;
|
||||
private int _tempVertexBufferSize;
|
||||
|
||||
public VertexArray()
|
||||
{
|
||||
@@ -40,6 +45,8 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
|
||||
public void SetVertexBuffers(ReadOnlySpan<VertexBufferDescriptor> vertexBuffers)
|
||||
{
|
||||
int minVertexCount = int.MaxValue;
|
||||
|
||||
int bindingIndex;
|
||||
for (bindingIndex = 0; bindingIndex < vertexBuffers.Length; bindingIndex++)
|
||||
{
|
||||
@@ -47,6 +54,12 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
|
||||
if (vb.Buffer.Handle != BufferHandle.Null)
|
||||
{
|
||||
int vertexCount = vb.Stride <= 0 ? 0 : vb.Buffer.Size / vb.Stride;
|
||||
if (minVertexCount > vertexCount)
|
||||
{
|
||||
minVertexCount = vertexCount;
|
||||
}
|
||||
|
||||
GL.BindVertexBuffer(bindingIndex, vb.Buffer.Handle.ToInt32(), (IntPtr)vb.Buffer.Offset, vb.Stride);
|
||||
GL.VertexBindingDivisor(bindingIndex, vb.Divisor);
|
||||
_vertexBuffersInUse |= 1u << bindingIndex;
|
||||
@@ -64,6 +77,7 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
}
|
||||
|
||||
_vertexBuffersCount = bindingIndex;
|
||||
_minVertexCount = minVertexCount;
|
||||
_needsAttribsUpdate = true;
|
||||
}
|
||||
|
||||
@@ -143,6 +157,101 @@ namespace Ryujinx.Graphics.OpenGL
|
||||
GL.BindBuffer(BufferTarget.ElementArrayBuffer, _indexBuffer.Handle.ToInt32());
|
||||
}
|
||||
|
||||
public void PreDraw(int vertexCount)
|
||||
{
|
||||
LimitVertexBuffers(vertexCount);
|
||||
Validate();
|
||||
}
|
||||
|
||||
public void PreDrawVbUnbounded()
|
||||
{
|
||||
UnlimitVertexBuffers();
|
||||
Validate();
|
||||
}
|
||||
|
||||
public void LimitVertexBuffers(int vertexCount)
|
||||
{
|
||||
// Is it possible for the draw to fetch outside the bounds of any vertex buffer currently bound?
|
||||
|
||||
if (vertexCount <= _minVertexCount)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the draw can fetch out of bounds, let's ensure that it will only fetch zeros rather than memory garbage.
|
||||
|
||||
int currentTempVbOffset = 0;
|
||||
uint buffersInUse = _vertexBuffersInUse;
|
||||
|
||||
while (buffersInUse != 0)
|
||||
{
|
||||
int vbIndex = BitOperations.TrailingZeroCount(buffersInUse);
|
||||
|
||||
ref var vb = ref _vertexBuffers[vbIndex];
|
||||
|
||||
int requiredSize = vertexCount * vb.Stride;
|
||||
|
||||
if (vb.Buffer.Size < requiredSize)
|
||||
{
|
||||
BufferHandle tempVertexBuffer = EnsureTempVertexBufferSize(currentTempVbOffset + requiredSize);
|
||||
|
||||
Buffer.Copy(vb.Buffer.Handle, tempVertexBuffer, vb.Buffer.Offset, currentTempVbOffset, vb.Buffer.Size);
|
||||
Buffer.Clear(tempVertexBuffer, currentTempVbOffset + vb.Buffer.Size, requiredSize - vb.Buffer.Size, 0);
|
||||
|
||||
GL.BindVertexBuffer(vbIndex, tempVertexBuffer.ToInt32(), (IntPtr)currentTempVbOffset, vb.Stride);
|
||||
|
||||
currentTempVbOffset += requiredSize;
|
||||
_vertexBuffersLimited |= 1u << vbIndex;
|
||||
}
|
||||
|
||||
buffersInUse &= ~(1u << vbIndex);
|
||||
}
|
||||
}
|
||||
|
||||
private BufferHandle EnsureTempVertexBufferSize(int size)
|
||||
{
|
||||
BufferHandle tempVertexBuffer = _tempVertexBuffer;
|
||||
|
||||
if (_tempVertexBufferSize < size)
|
||||
{
|
||||
_tempVertexBufferSize = size;
|
||||
|
||||
if (tempVertexBuffer == BufferHandle.Null)
|
||||
{
|
||||
tempVertexBuffer = Buffer.Create(size);
|
||||
_tempVertexBuffer = tempVertexBuffer;
|
||||
return tempVertexBuffer;
|
||||
}
|
||||
|
||||
Buffer.Resize(_tempVertexBuffer, size);
|
||||
}
|
||||
|
||||
return tempVertexBuffer;
|
||||
}
|
||||
|
||||
public void UnlimitVertexBuffers()
|
||||
{
|
||||
uint buffersLimited = _vertexBuffersLimited;
|
||||
|
||||
if (buffersLimited == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
while (buffersLimited != 0)
|
||||
{
|
||||
int vbIndex = BitOperations.TrailingZeroCount(buffersLimited);
|
||||
|
||||
ref var vb = ref _vertexBuffers[vbIndex];
|
||||
|
||||
GL.BindVertexBuffer(vbIndex, vb.Buffer.Handle.ToInt32(), (IntPtr)vb.Buffer.Offset, vb.Stride);
|
||||
|
||||
buffersLimited &= ~(1u << vbIndex);
|
||||
}
|
||||
|
||||
_vertexBuffersLimited = 0;
|
||||
}
|
||||
|
||||
public void Validate()
|
||||
{
|
||||
for (int attribIndex = 0; attribIndex < _vertexAttribsCount; attribIndex++)
|
||||
|
@@ -1,19 +0,0 @@
|
||||
using Ryujinx.Graphics.GAL;
|
||||
|
||||
namespace Ryujinx.Graphics.OpenGL
|
||||
{
|
||||
struct VertexBuffer
|
||||
{
|
||||
public BufferRange Range { get; }
|
||||
|
||||
public int Divisor { get; }
|
||||
public int Stride { get; }
|
||||
|
||||
public VertexBuffer(BufferRange range, int divisor, int stride)
|
||||
{
|
||||
Range = range;
|
||||
Divisor = divisor;
|
||||
Stride = stride;
|
||||
}
|
||||
}
|
||||
}
|
@@ -72,9 +72,16 @@ namespace Ryujinx.HLE.HOS.Applets
|
||||
|
||||
int playerMin = argHeader.PlayerCountMin;
|
||||
int playerMax = argHeader.PlayerCountMax;
|
||||
bool singleMode = argHeader.EnableSingleMode != 0;
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceHid, $"ControllerApplet Arg {playerMin} {playerMax} {argHeader.EnableTakeOverConnection} {argHeader.EnableSingleMode}");
|
||||
|
||||
if (singleMode)
|
||||
{
|
||||
// Applications can set an arbitrary player range even with SingleMode, so clamp it
|
||||
playerMin = playerMax = 1;
|
||||
}
|
||||
|
||||
int configuredCount = 0;
|
||||
PlayerIndex primaryIndex = PlayerIndex.Unknown;
|
||||
while (!_system.Device.Hid.Npads.Validate(playerMin, playerMax, (ControllerType)privateArg.NpadStyleSet, out configuredCount, out primaryIndex))
|
||||
|
@@ -224,6 +224,17 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandHipc(62)] // 4.0.0+
|
||||
// GetHdcpAuthenticationState() -> s32 state
|
||||
public ResultCode GetHdcpAuthenticationState(ServiceCtx context)
|
||||
{
|
||||
context.ResponseData.Write(0);
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceAm);
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandHipc(66)] // 6.0.0+
|
||||
// SetCpuBoostMode(u32 cpu_boost_mode)
|
||||
public ResultCode SetCpuBoostMode(ServiceCtx context)
|
||||
|
@@ -2,6 +2,7 @@ using Ryujinx.Common.Logging;
|
||||
using Ryujinx.HLE.HOS.Ipc;
|
||||
using Ryujinx.HLE.HOS.Kernel.Common;
|
||||
using Ryujinx.HLE.HOS.Kernel.Threading;
|
||||
using Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy.Types;
|
||||
using System;
|
||||
|
||||
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy
|
||||
@@ -316,6 +317,22 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandHipc(80)] // 4.0.0+
|
||||
// SetWirelessPriorityMode(s32 wireless_priority_mode)
|
||||
public ResultCode SetWirelessPriorityMode(ServiceCtx context)
|
||||
{
|
||||
WirelessPriorityMode wirelessPriorityMode = (WirelessPriorityMode)context.RequestData.ReadInt32();
|
||||
|
||||
if (wirelessPriorityMode > WirelessPriorityMode.Unknown2)
|
||||
{
|
||||
return ResultCode.InvalidParameters;
|
||||
}
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { wirelessPriorityMode });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandHipc(90)] // 6.0.0+
|
||||
// GetAccumulatedSuspendedTickValue() -> u64
|
||||
public ResultCode GetAccumulatedSuspendedTickValue(ServiceCtx context)
|
||||
@@ -356,5 +373,21 @@ namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.Sys
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
|
||||
[CommandHipc(120)] // 11.0.0+
|
||||
// SaveCurrentScreenshot(s32 album_report_option)
|
||||
public ResultCode SaveCurrentScreenshot(ServiceCtx context)
|
||||
{
|
||||
AlbumReportOption albumReportOption = (AlbumReportOption)context.RequestData.ReadInt32();
|
||||
|
||||
if (albumReportOption > AlbumReportOption.Unknown3)
|
||||
{
|
||||
return ResultCode.InvalidParameters;
|
||||
}
|
||||
|
||||
Logger.Stub?.PrintStub(LogClass.ServiceAm, new { albumReportOption });
|
||||
|
||||
return ResultCode.Success;
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,10 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy.Types
|
||||
{
|
||||
enum AlbumReportOption
|
||||
{
|
||||
OverlayNotDisplayed,
|
||||
OverlayDisplayed,
|
||||
Unknown2,
|
||||
Unknown3
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
namespace Ryujinx.HLE.HOS.Services.Am.AppletAE.AllSystemAppletProxiesService.SystemAppletProxy.Types
|
||||
{
|
||||
enum WirelessPriorityMode
|
||||
{
|
||||
Default,
|
||||
OptimizedForWlan,
|
||||
Unknown2
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user