Merge branch 'master' into pptc_and_pool_enhancements

This commit is contained in:
LDj3SNuD 2021-02-08 03:48:40 +01:00
commit 5697d047fb
15 changed files with 198 additions and 185 deletions

View file

@ -519,19 +519,50 @@ namespace ARMeilleure.CodeGen.X86
Operand src1 = operation.GetSource(0); Operand src1 = operation.GetSource(0);
Operand src2 = operation.GetSource(1); Operand src2 = operation.GetSource(1);
ValidateBinOp(dest, src1, src2);
if (dest.Type.IsInteger()) if (dest.Type.IsInteger())
{ {
context.Assembler.Add(dest, src2, dest.Type); // If Destination and Source 1 Operands are the same, perform a standard add as there are no benefits to using LEA.
if (dest.Kind == src1.Kind && dest.Value == src1.Value)
{
ValidateBinOp(dest, src1, src2);
context.Assembler.Add(dest, src2, dest.Type);
}
else
{
EnsureSameType(dest, src1, src2);
int offset;
Operand index;
if (src2.Kind == OperandKind.Constant)
{
offset = src2.AsInt32();
index = null;
}
else
{
offset = 0;
index = src2;
}
MemoryOperand memOp = MemoryOp(dest.Type, src1, index, Multiplier.x1, offset);
context.Assembler.Lea(dest, memOp, dest.Type);
}
} }
else if (dest.Type == OperandType.FP32) else
{ {
context.Assembler.Addss(dest, src1, src2); ValidateBinOp(dest, src1, src2);
}
else /* if (dest.Type == OperandType.FP64) */ if (dest.Type == OperandType.FP32)
{ {
context.Assembler.Addsd(dest, src1, src2); context.Assembler.Addss(dest, src1, src2);
}
else /* if (dest.Type == OperandType.FP64) */
{
context.Assembler.Addsd(dest, src1, src2);
}
} }
} }

View file

@ -1273,6 +1273,7 @@ namespace ARMeilleure.CodeGen.X86
switch (operation.Instruction) switch (operation.Instruction)
{ {
case Instruction.Add: case Instruction.Add:
return !HardwareCapabilities.SupportsVexEncoding && !operation.Destination.Type.IsInteger();
case Instruction.Multiply: case Instruction.Multiply:
case Instruction.Subtract: case Instruction.Subtract:
return !HardwareCapabilities.SupportsVexEncoding || operation.Destination.Type.IsInteger(); return !HardwareCapabilities.SupportsVexEncoding || operation.Destination.Type.IsInteger();

View file

@ -33,5 +33,10 @@ namespace ARMeilleure.Translation
{ {
return !HighCq && Interlocked.Increment(ref _callCount) == MinCallsForRejit; return !HighCq && Interlocked.Increment(ref _callCount) == MinCallsForRejit;
} }
public void ResetCallCount()
{
Interlocked.Exchange(ref _callCount, 0);
}
} }
} }

View file

@ -397,33 +397,10 @@ namespace ARMeilleure.Translation
public void InvalidateJitCacheRegion(ulong address, ulong size) public void InvalidateJitCacheRegion(ulong address, ulong size)
{ {
static bool OverlapsWith(ulong funcAddress, ulong funcSize, ulong address, ulong size) // If rejit is running, stop it as it may be trying to rejit a function on the invalidated region.
{ ClearRejitQueue(allowRequeue: true);
return funcAddress < address + size && address < funcAddress + funcSize;
}
// Make a copy of all overlapping functions, as we can't otherwise // TODO: Completely remove functions overlapping the specified range from the cache.
// remove elements from the collection we are iterating.
// Doing that before clearing the rejit queue is fine, even
// if a function is translated after this, it would only replace
// a existing function, as rejit is only triggered on functions
// that were already executed before.
var toDelete = _funcs.Where(x => OverlapsWith(x.Key, x.Value.GuestSize, address, size)).ToArray();
if (toDelete.Length != 0)
{
// If rejit is running, stop it as it may be trying to rejit the functions we are
// supposed to remove.
ClearRejitQueue();
}
foreach (var kv in toDelete)
{
if (_funcs.TryRemove(kv.Key, out TranslatedFunction func))
{
EnqueueForDeletion(kv.Key, func);
}
}
} }
private void EnqueueForDeletion(ulong guestAddress, TranslatedFunction func) private void EnqueueForDeletion(ulong guestAddress, TranslatedFunction func)
@ -434,7 +411,7 @@ namespace ARMeilleure.Translation
private void ClearJitCache() private void ClearJitCache()
{ {
// Ensure no attempt will be made to compile new functions due to rejit. // Ensure no attempt will be made to compile new functions due to rejit.
ClearRejitQueue(); ClearRejitQueue(allowRequeue: false);
foreach (var kv in _funcs) foreach (var kv in _funcs)
{ {
@ -449,10 +426,25 @@ namespace ARMeilleure.Translation
} }
} }
private void ClearRejitQueue() private void ClearRejitQueue(bool allowRequeue)
{ {
_backgroundTranslatorLock.AcquireWriterLock(Timeout.Infinite); _backgroundTranslatorLock.AcquireWriterLock(Timeout.Infinite);
_backgroundStack.Clear();
if (allowRequeue)
{
while (_backgroundStack.TryPop(out var request))
{
if (_funcs.TryGetValue(request.Address, out var func))
{
func.ResetCallCount();
}
}
}
else
{
_backgroundStack.Clear();
}
_backgroundTranslatorLock.ReleaseWriterLock(); _backgroundTranslatorLock.ReleaseWriterLock();
} }
} }

View file

@ -82,7 +82,9 @@ namespace Ryujinx.Graphics.GAL
Bc7Srgb, Bc7Srgb,
Bc6HSfloat, Bc6HSfloat,
Bc6HUfloat, Bc6HUfloat,
Etc2RgbUnorm,
Etc2RgbaUnorm, Etc2RgbaUnorm,
Etc2RgbSrgb,
Etc2RgbaSrgb, Etc2RgbaSrgb,
R8Uscaled, R8Uscaled,
R8Sscaled, R8Sscaled,

View file

@ -78,7 +78,9 @@ namespace Ryujinx.Graphics.Gpu.Image
{ 0xa4917, new FormatInfo(Format.Bc7Srgb, 4, 4, 16, 4) }, { 0xa4917, new FormatInfo(Format.Bc7Srgb, 4, 4, 16, 4) },
{ 0x7ff90, new FormatInfo(Format.Bc6HSfloat, 4, 4, 16, 4) }, { 0x7ff90, new FormatInfo(Format.Bc6HSfloat, 4, 4, 16, 4) },
{ 0x7ff91, new FormatInfo(Format.Bc6HUfloat, 4, 4, 16, 4) }, { 0x7ff91, new FormatInfo(Format.Bc6HUfloat, 4, 4, 16, 4) },
{ 0x24906, new FormatInfo(Format.Etc2RgbUnorm, 4, 4, 8, 3) },
{ 0x2490b, new FormatInfo(Format.Etc2RgbaUnorm, 4, 4, 16, 4) }, { 0x2490b, new FormatInfo(Format.Etc2RgbaUnorm, 4, 4, 16, 4) },
{ 0xa4906, new FormatInfo(Format.Etc2RgbSrgb, 4, 4, 8, 3) },
{ 0xa490b, new FormatInfo(Format.Etc2RgbaSrgb, 4, 4, 16, 4) }, { 0xa490b, new FormatInfo(Format.Etc2RgbaSrgb, 4, 4, 16, 4) },
{ 0x24940, new FormatInfo(Format.Astc4x4Unorm, 4, 4, 16, 4) }, { 0x24940, new FormatInfo(Format.Astc4x4Unorm, 4, 4, 16, 4) },
{ 0x24950, new FormatInfo(Format.Astc5x4Unorm, 5, 4, 16, 4) }, { 0x24950, new FormatInfo(Format.Astc5x4Unorm, 5, 4, 16, 4) },

View file

@ -280,7 +280,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
} }
} }
// Transformation feedback // Transform feedback
if (tfd != null) if (tfd != null)
{ {
foreach (TransformFeedbackDescriptor transform in tfd) foreach (TransformFeedbackDescriptor transform in tfd)
@ -311,7 +311,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
/// <param name="data">The raw guest transform feedback descriptors</param> /// <param name="data">The raw guest transform feedback descriptors</param>
/// <param name="header">The guest shader program header</param> /// <param name="header">The guest shader program header</param>
/// <returns>The transform feedback descriptors read from guest</returns> /// <returns>The transform feedback descriptors read from guest</returns>
public static TransformFeedbackDescriptor[] ReadTransformationFeedbackInformations(ref ReadOnlySpan<byte> data, GuestShaderCacheHeader header) public static TransformFeedbackDescriptor[] ReadTransformFeedbackInformation(ref ReadOnlySpan<byte> data, GuestShaderCacheHeader header)
{ {
if (header.TransformFeedbackCount != 0) if (header.TransformFeedbackCount != 0)
{ {
@ -376,9 +376,11 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
/// <returns>Guest shader cahe entries from the runtime contexts</returns> /// <returns>Guest shader cahe entries from the runtime contexts</returns>
public static GuestShaderCacheEntry[] CreateShaderCacheEntries(MemoryManager memoryManager, ReadOnlySpan<TranslatorContext> shaderContexts) public static GuestShaderCacheEntry[] CreateShaderCacheEntries(MemoryManager memoryManager, ReadOnlySpan<TranslatorContext> shaderContexts)
{ {
GuestShaderCacheEntry[] entries = new GuestShaderCacheEntry[shaderContexts.Length]; int startIndex = shaderContexts.Length > 1 ? 1 : 0;
for (int i = 0; i < shaderContexts.Length; i++) GuestShaderCacheEntry[] entries = new GuestShaderCacheEntry[shaderContexts.Length - startIndex];
for (int i = startIndex; i < shaderContexts.Length; i++)
{ {
TranslatorContext context = shaderContexts[i]; TranslatorContext context = shaderContexts[i];
@ -387,15 +389,17 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
continue; continue;
} }
int sizeA = context.AddressA == 0 ? 0 : context.SizeA; TranslatorContext translatorContext2 = i == 1 ? shaderContexts[0] : null;
int sizeA = translatorContext2 != null ? translatorContext2.Size : 0;
byte[] code = new byte[context.Size + sizeA]; byte[] code = new byte[context.Size + sizeA];
memoryManager.GetSpan(context.Address, context.Size).CopyTo(code); memoryManager.GetSpan(context.Address, context.Size).CopyTo(code);
if (context.AddressA != 0) if (translatorContext2 != null)
{ {
memoryManager.GetSpan(context.AddressA, context.SizeA).CopyTo(code.AsSpan().Slice(context.Size, context.SizeA)); memoryManager.GetSpan(translatorContext2.Address, sizeA).CopyTo(code.AsSpan().Slice(context.Size, sizeA));
} }
GuestGpuAccessorHeader gpuAccessorHeader = CreateGuestGpuAccessorCache(context.GpuAccessor); GuestGpuAccessorHeader gpuAccessorHeader = CreateGuestGpuAccessorCache(context.GpuAccessor);
@ -421,7 +425,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
} }
} }
entries[i] = entry; entries[i - startIndex] = entry;
} }
return entries; return entries;

View file

@ -103,7 +103,7 @@ namespace Ryujinx.Graphics.Gpu.Shader.Cache
ReadOnlySpan<GuestShaderCacheEntry> cachedShaderEntries = GuestShaderCacheEntry.Parse(ref guestProgramReadOnlySpan, out GuestShaderCacheHeader fileHeader); ReadOnlySpan<GuestShaderCacheEntry> cachedShaderEntries = GuestShaderCacheEntry.Parse(ref guestProgramReadOnlySpan, out GuestShaderCacheHeader fileHeader);
TransformFeedbackDescriptor[] tfd = CacheHelper.ReadTransformationFeedbackInformations(ref guestProgramReadOnlySpan, fileHeader); TransformFeedbackDescriptor[] tfd = CacheHelper.ReadTransformFeedbackInformation(ref guestProgramReadOnlySpan, fileHeader);
Hash128 newHash = CacheHelper.ComputeGuestHashFromCache(cachedShaderEntries, tfd); Hash128 newHash = CacheHelper.ComputeGuestHashFromCache(cachedShaderEntries, tfd);

View file

@ -128,7 +128,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
// Reconstruct code holder. // Reconstruct code holder.
if (isHostProgramValid) if (isHostProgramValid)
{ {
program = new ShaderProgram(entry.Header.Stage, "", entry.Header.Size, entry.Header.SizeA); program = new ShaderProgram(entry.Header.Stage, "");
shaderProgramInfo = hostShaderEntries[0].ToShaderProgramInfo(); shaderProgramInfo = hostShaderEntries[0].ToShaderProgramInfo();
} }
else else
@ -176,7 +176,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
ShaderCodeHolder[] shaders = new ShaderCodeHolder[cachedShaderEntries.Length]; ShaderCodeHolder[] shaders = new ShaderCodeHolder[cachedShaderEntries.Length];
List<ShaderProgram> shaderPrograms = new List<ShaderProgram>(); List<ShaderProgram> shaderPrograms = new List<ShaderProgram>();
TransformFeedbackDescriptor[] tfd = CacheHelper.ReadTransformationFeedbackInformations(ref guestProgramReadOnlySpan, fileHeader); TransformFeedbackDescriptor[] tfd = CacheHelper.ReadTransformFeedbackInformation(ref guestProgramReadOnlySpan, fileHeader);
TranslationFlags flags = DefaultFlags; TranslationFlags flags = DefaultFlags;
@ -217,14 +217,17 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (isHostProgramValid) if (isHostProgramValid)
{ {
program = new ShaderProgram(entry.Header.Stage, "", entry.Header.Size, entry.Header.SizeA); program = new ShaderProgram(entry.Header.Stage, "");
shaderProgramInfo = hostShaderEntries[i].ToShaderProgramInfo(); shaderProgramInfo = hostShaderEntries[i].ToShaderProgramInfo();
} }
else else
{ {
IGpuAccessor gpuAccessor = new CachedGpuAccessor(_context, entry.Code, entry.Header.GpuAccessorHeader, entry.TextureDescriptors); IGpuAccessor gpuAccessor = new CachedGpuAccessor(_context, entry.Code, entry.Header.GpuAccessorHeader, entry.TextureDescriptors);
program = Translator.CreateContext((ulong)entry.Header.Size, 0, gpuAccessor, flags, counts).Translate(out shaderProgramInfo); TranslatorContext translatorContext = Translator.CreateContext(0, gpuAccessor, flags, counts);
TranslatorContext translatorContext2 = Translator.CreateContext((ulong)entry.Header.Size, gpuAccessor, flags | TranslationFlags.VertexA, counts);
program = translatorContext.Translate(out shaderProgramInfo, translatorContext2);
} }
// NOTE: Vertex B comes first in the shader cache. // NOTE: Vertex B comes first in the shader cache.
@ -239,7 +242,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (isHostProgramValid) if (isHostProgramValid)
{ {
program = new ShaderProgram(entry.Header.Stage, "", entry.Header.Size, entry.Header.SizeA); program = new ShaderProgram(entry.Header.Stage, "");
shaderProgramInfo = hostShaderEntries[i].ToShaderProgramInfo(); shaderProgramInfo = hostShaderEntries[i].ToShaderProgramInfo();
} }
else else
@ -446,7 +449,7 @@ namespace Ryujinx.Graphics.Gpu.Shader
} }
} }
TranslatorContext[] shaderContexts = new TranslatorContext[Constants.ShaderStages]; TranslatorContext[] shaderContexts = new TranslatorContext[Constants.ShaderStages + 1];
TransformFeedbackDescriptor[] tfd = GetTransformFeedbackDescriptors(state); TransformFeedbackDescriptor[] tfd = GetTransformFeedbackDescriptors(state);
@ -461,17 +464,14 @@ namespace Ryujinx.Graphics.Gpu.Shader
if (addresses.VertexA != 0) if (addresses.VertexA != 0)
{ {
shaderContexts[0] = DecodeGraphicsShader(state, counts, flags, ShaderStage.Vertex, addresses.Vertex, addresses.VertexA); shaderContexts[0] = DecodeGraphicsShader(state, counts, flags | TranslationFlags.VertexA, ShaderStage.Vertex, addresses.VertexA);
}
else
{
shaderContexts[0] = DecodeGraphicsShader(state, counts, flags, ShaderStage.Vertex, addresses.Vertex);
} }
shaderContexts[1] = DecodeGraphicsShader(state, counts, flags, ShaderStage.TessellationControl, addresses.TessControl); shaderContexts[1] = DecodeGraphicsShader(state, counts, flags, ShaderStage.Vertex, addresses.Vertex);
shaderContexts[2] = DecodeGraphicsShader(state, counts, flags, ShaderStage.TessellationEvaluation, addresses.TessEvaluation); shaderContexts[2] = DecodeGraphicsShader(state, counts, flags, ShaderStage.TessellationControl, addresses.TessControl);
shaderContexts[3] = DecodeGraphicsShader(state, counts, flags, ShaderStage.Geometry, addresses.Geometry); shaderContexts[3] = DecodeGraphicsShader(state, counts, flags, ShaderStage.TessellationEvaluation, addresses.TessEvaluation);
shaderContexts[4] = DecodeGraphicsShader(state, counts, flags, ShaderStage.Fragment, addresses.Fragment); shaderContexts[4] = DecodeGraphicsShader(state, counts, flags, ShaderStage.Geometry, addresses.Geometry);
shaderContexts[5] = DecodeGraphicsShader(state, counts, flags, ShaderStage.Fragment, addresses.Fragment);
bool isShaderCacheEnabled = _cacheManager != null; bool isShaderCacheEnabled = _cacheManager != null;
bool isShaderCacheReadOnly = false; bool isShaderCacheReadOnly = false;
@ -501,11 +501,11 @@ namespace Ryujinx.Graphics.Gpu.Shader
// The shader isn't currently cached, translate it and compile it. // The shader isn't currently cached, translate it and compile it.
ShaderCodeHolder[] shaders = new ShaderCodeHolder[Constants.ShaderStages]; ShaderCodeHolder[] shaders = new ShaderCodeHolder[Constants.ShaderStages];
shaders[0] = TranslateShader(shaderContexts[0]); shaders[0] = TranslateShader(shaderContexts[1], shaderContexts[0]);
shaders[1] = TranslateShader(shaderContexts[1]); shaders[1] = TranslateShader(shaderContexts[2]);
shaders[2] = TranslateShader(shaderContexts[2]); shaders[2] = TranslateShader(shaderContexts[3]);
shaders[3] = TranslateShader(shaderContexts[3]); shaders[3] = TranslateShader(shaderContexts[4]);
shaders[4] = TranslateShader(shaderContexts[4]); shaders[4] = TranslateShader(shaderContexts[5]);
List<IShader> hostShaders = new List<IShader>(); List<IShader> hostShaders = new List<IShader>();
@ -696,15 +696,13 @@ namespace Ryujinx.Graphics.Gpu.Shader
/// <param name="flags">Flags that controls shader translation</param> /// <param name="flags">Flags that controls shader translation</param>
/// <param name="stage">Shader stage</param> /// <param name="stage">Shader stage</param>
/// <param name="gpuVa">GPU virtual address of the shader code</param> /// <param name="gpuVa">GPU virtual address of the shader code</param>
/// <param name="gpuVaA">Optional GPU virtual address of the "Vertex A" shader code</param>
/// <returns>The generated translator context</returns> /// <returns>The generated translator context</returns>
private TranslatorContext DecodeGraphicsShader( private TranslatorContext DecodeGraphicsShader(
GpuState state, GpuState state,
TranslationCounts counts, TranslationCounts counts,
TranslationFlags flags, TranslationFlags flags,
ShaderStage stage, ShaderStage stage,
ulong gpuVa, ulong gpuVa)
ulong gpuVaA = 0)
{ {
if (gpuVa == 0) if (gpuVa == 0)
{ {
@ -713,37 +711,31 @@ namespace Ryujinx.Graphics.Gpu.Shader
GpuAccessor gpuAccessor = new GpuAccessor(_context, state, (int)stage - 1); GpuAccessor gpuAccessor = new GpuAccessor(_context, state, (int)stage - 1);
if (gpuVaA != 0) return Translator.CreateContext(gpuVa, gpuAccessor, flags, counts);
{
return Translator.CreateContext(gpuVaA, gpuVa, gpuAccessor, flags, counts);
}
else
{
return Translator.CreateContext(gpuVa, gpuAccessor, flags, counts);
}
} }
/// <summary> /// <summary>
/// Translates a previously generated translator context to something that the host API accepts. /// Translates a previously generated translator context to something that the host API accepts.
/// </summary> /// </summary>
/// <param name="translatorContext">Current translator context to translate</param> /// <param name="translatorContext">Current translator context to translate</param>
/// <param name="translatorContext2">Optional translator context of the shader that should be combined</param>
/// <returns>Compiled graphics shader code</returns> /// <returns>Compiled graphics shader code</returns>
private ShaderCodeHolder TranslateShader(TranslatorContext translatorContext) private ShaderCodeHolder TranslateShader(TranslatorContext translatorContext, TranslatorContext translatorContext2 = null)
{ {
if (translatorContext == null) if (translatorContext == null)
{ {
return null; return null;
} }
if (translatorContext.AddressA != 0) if (translatorContext2 != null)
{ {
byte[] codeA = _context.MemoryManager.GetSpan(translatorContext.AddressA, translatorContext.SizeA).ToArray(); byte[] codeA = _context.MemoryManager.GetSpan(translatorContext2.Address, translatorContext2.Size).ToArray();
byte[] codeB = _context.MemoryManager.GetSpan(translatorContext.Address, translatorContext.Size).ToArray(); byte[] codeB = _context.MemoryManager.GetSpan(translatorContext.Address, translatorContext.Size).ToArray();
_dumper.Dump(codeA, compute: false, out string fullPathA, out string codePathA); _dumper.Dump(codeA, compute: false, out string fullPathA, out string codePathA);
_dumper.Dump(codeB, compute: false, out string fullPathB, out string codePathB); _dumper.Dump(codeB, compute: false, out string fullPathB, out string codePathB);
ShaderProgram program = translatorContext.Translate(out ShaderProgramInfo shaderProgramInfo); ShaderProgram program = translatorContext.Translate(out ShaderProgramInfo shaderProgramInfo, translatorContext2);
if (fullPathA != null && fullPathB != null && codePathA != null && codePathB != null) if (fullPathA != null && fullPathB != null && codePathA != null && codePathB != null)
{ {

View file

@ -80,24 +80,26 @@ namespace Ryujinx.Graphics.OpenGL
Add(Format.R10G10B10A2Uint, new FormatInfo(4, false, false, All.Rgb10A2ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt2101010Reversed)); Add(Format.R10G10B10A2Uint, new FormatInfo(4, false, false, All.Rgb10A2ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt2101010Reversed));
Add(Format.R11G11B10Float, new FormatInfo(3, false, false, All.R11fG11fB10f, PixelFormat.Rgb, PixelType.UnsignedInt10F11F11FRev)); Add(Format.R11G11B10Float, new FormatInfo(3, false, false, All.R11fG11fB10f, PixelFormat.Rgb, PixelType.UnsignedInt10F11F11FRev));
Add(Format.R9G9B9E5Float, new FormatInfo(3, false, false, All.Rgb9E5, PixelFormat.Rgb, PixelType.UnsignedInt5999Rev)); Add(Format.R9G9B9E5Float, new FormatInfo(3, false, false, All.Rgb9E5, PixelFormat.Rgb, PixelType.UnsignedInt5999Rev));
Add(Format.Bc1RgbUnorm, new FormatInfo(2, true, false, All.CompressedRgbS3tcDxt1Ext)); Add(Format.Bc1RgbUnorm, new FormatInfo(3, true, false, All.CompressedRgbS3tcDxt1Ext));
Add(Format.Bc1RgbaUnorm, new FormatInfo(1, true, false, All.CompressedRgbaS3tcDxt1Ext)); Add(Format.Bc1RgbaUnorm, new FormatInfo(4, true, false, All.CompressedRgbaS3tcDxt1Ext));
Add(Format.Bc2Unorm, new FormatInfo(1, true, false, All.CompressedRgbaS3tcDxt3Ext)); Add(Format.Bc2Unorm, new FormatInfo(4, true, false, All.CompressedRgbaS3tcDxt3Ext));
Add(Format.Bc3Unorm, new FormatInfo(1, true, false, All.CompressedRgbaS3tcDxt5Ext)); Add(Format.Bc3Unorm, new FormatInfo(4, true, false, All.CompressedRgbaS3tcDxt5Ext));
Add(Format.Bc1RgbSrgb, new FormatInfo(2, false, false, All.CompressedSrgbS3tcDxt1Ext)); Add(Format.Bc1RgbSrgb, new FormatInfo(3, false, false, All.CompressedSrgbS3tcDxt1Ext));
Add(Format.Bc1RgbaSrgb, new FormatInfo(1, true, false, All.CompressedSrgbAlphaS3tcDxt1Ext)); Add(Format.Bc1RgbaSrgb, new FormatInfo(4, true, false, All.CompressedSrgbAlphaS3tcDxt1Ext));
Add(Format.Bc2Srgb, new FormatInfo(1, false, false, All.CompressedSrgbAlphaS3tcDxt3Ext)); Add(Format.Bc2Srgb, new FormatInfo(4, false, false, All.CompressedSrgbAlphaS3tcDxt3Ext));
Add(Format.Bc3Srgb, new FormatInfo(1, false, false, All.CompressedSrgbAlphaS3tcDxt5Ext)); Add(Format.Bc3Srgb, new FormatInfo(4, false, false, All.CompressedSrgbAlphaS3tcDxt5Ext));
Add(Format.Bc4Unorm, new FormatInfo(1, true, false, All.CompressedRedRgtc1)); Add(Format.Bc4Unorm, new FormatInfo(1, true, false, All.CompressedRedRgtc1));
Add(Format.Bc4Snorm, new FormatInfo(1, true, false, All.CompressedSignedRedRgtc1)); Add(Format.Bc4Snorm, new FormatInfo(1, true, false, All.CompressedSignedRedRgtc1));
Add(Format.Bc5Unorm, new FormatInfo(1, true, false, All.CompressedRgRgtc2)); Add(Format.Bc5Unorm, new FormatInfo(2, true, false, All.CompressedRgRgtc2));
Add(Format.Bc5Snorm, new FormatInfo(1, true, false, All.CompressedSignedRgRgtc2)); Add(Format.Bc5Snorm, new FormatInfo(2, true, false, All.CompressedSignedRgRgtc2));
Add(Format.Bc7Unorm, new FormatInfo(1, true, false, All.CompressedRgbaBptcUnorm)); Add(Format.Bc7Unorm, new FormatInfo(4, true, false, All.CompressedRgbaBptcUnorm));
Add(Format.Bc7Srgb, new FormatInfo(1, false, false, All.CompressedSrgbAlphaBptcUnorm)); Add(Format.Bc7Srgb, new FormatInfo(4, false, false, All.CompressedSrgbAlphaBptcUnorm));
Add(Format.Bc6HSfloat, new FormatInfo(1, false, false, All.CompressedRgbBptcSignedFloat)); Add(Format.Bc6HSfloat, new FormatInfo(4, false, false, All.CompressedRgbBptcSignedFloat));
Add(Format.Bc6HUfloat, new FormatInfo(1, false, false, All.CompressedRgbBptcUnsignedFloat)); Add(Format.Bc6HUfloat, new FormatInfo(4, false, false, All.CompressedRgbBptcUnsignedFloat));
Add(Format.Etc2RgbaUnorm, new FormatInfo(1, false, false, All.CompressedRgba8Etc2Eac)); Add(Format.Etc2RgbUnorm, new FormatInfo(3, false, false, All.CompressedRgb8Etc2));
Add(Format.Etc2RgbaSrgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Etc2Eac)); Add(Format.Etc2RgbaUnorm, new FormatInfo(4, false, false, All.CompressedRgba8Etc2Eac));
Add(Format.Etc2RgbSrgb, new FormatInfo(3, false, false, All.CompressedSrgb8Etc2));
Add(Format.Etc2RgbaSrgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Etc2Eac));
Add(Format.R8Uscaled, new FormatInfo(1, false, true, All.R8ui, PixelFormat.RedInteger, PixelType.UnsignedByte)); Add(Format.R8Uscaled, new FormatInfo(1, false, true, All.R8ui, PixelFormat.RedInteger, PixelType.UnsignedByte));
Add(Format.R8Sscaled, new FormatInfo(1, false, true, All.R8i, PixelFormat.RedInteger, PixelType.Byte)); Add(Format.R8Sscaled, new FormatInfo(1, false, true, All.R8i, PixelFormat.RedInteger, PixelType.Byte));
Add(Format.R16Uscaled, new FormatInfo(1, false, true, All.R16ui, PixelFormat.RedInteger, PixelType.UnsignedShort)); Add(Format.R16Uscaled, new FormatInfo(1, false, true, All.R16ui, PixelFormat.RedInteger, PixelType.UnsignedShort));
@ -138,34 +140,34 @@ namespace Ryujinx.Graphics.OpenGL
Add(Format.R32G32B32X32Float, new FormatInfo(4, false, false, All.Rgb32f, PixelFormat.Rgba, PixelType.Float)); Add(Format.R32G32B32X32Float, new FormatInfo(4, false, false, All.Rgb32f, PixelFormat.Rgba, PixelType.Float));
Add(Format.R32G32B32X32Uint, new FormatInfo(4, false, false, All.Rgb32ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt)); Add(Format.R32G32B32X32Uint, new FormatInfo(4, false, false, All.Rgb32ui, PixelFormat.RgbaInteger, PixelType.UnsignedInt));
Add(Format.R32G32B32X32Sint, new FormatInfo(4, false, false, All.Rgb32i, PixelFormat.RgbaInteger, PixelType.Int)); Add(Format.R32G32B32X32Sint, new FormatInfo(4, false, false, All.Rgb32i, PixelFormat.RgbaInteger, PixelType.Int));
Add(Format.Astc4x4Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc4X4Khr)); Add(Format.Astc4x4Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc4X4Khr));
Add(Format.Astc5x4Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc5X4Khr)); Add(Format.Astc5x4Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc5X4Khr));
Add(Format.Astc5x5Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc5X5Khr)); Add(Format.Astc5x5Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc5X5Khr));
Add(Format.Astc6x5Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc6X5Khr)); Add(Format.Astc6x5Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc6X5Khr));
Add(Format.Astc6x6Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc6X6Khr)); Add(Format.Astc6x6Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc6X6Khr));
Add(Format.Astc8x5Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc8X5Khr)); Add(Format.Astc8x5Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc8X5Khr));
Add(Format.Astc8x6Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc8X6Khr)); Add(Format.Astc8x6Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc8X6Khr));
Add(Format.Astc8x8Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc8X8Khr)); Add(Format.Astc8x8Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc8X8Khr));
Add(Format.Astc10x5Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc10X5Khr)); Add(Format.Astc10x5Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc10X5Khr));
Add(Format.Astc10x6Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc10X6Khr)); Add(Format.Astc10x6Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc10X6Khr));
Add(Format.Astc10x8Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc10X8Khr)); Add(Format.Astc10x8Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc10X8Khr));
Add(Format.Astc10x10Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc10X10Khr)); Add(Format.Astc10x10Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc10X10Khr));
Add(Format.Astc12x10Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc12X10Khr)); Add(Format.Astc12x10Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc12X10Khr));
Add(Format.Astc12x12Unorm, new FormatInfo(1, true, false, All.CompressedRgbaAstc12X12Khr)); Add(Format.Astc12x12Unorm, new FormatInfo(4, true, false, All.CompressedRgbaAstc12X12Khr));
Add(Format.Astc4x4Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc4X4Khr)); Add(Format.Astc4x4Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc4X4Khr));
Add(Format.Astc5x4Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc5X4Khr)); Add(Format.Astc5x4Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc5X4Khr));
Add(Format.Astc5x5Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc5X5Khr)); Add(Format.Astc5x5Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc5X5Khr));
Add(Format.Astc6x5Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc6X5Khr)); Add(Format.Astc6x5Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc6X5Khr));
Add(Format.Astc6x6Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc6X6Khr)); Add(Format.Astc6x6Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc6X6Khr));
Add(Format.Astc8x5Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc8X5Khr)); Add(Format.Astc8x5Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc8X5Khr));
Add(Format.Astc8x6Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc8X6Khr)); Add(Format.Astc8x6Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc8X6Khr));
Add(Format.Astc8x8Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc8X8Khr)); Add(Format.Astc8x8Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc8X8Khr));
Add(Format.Astc10x5Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc10X5Khr)); Add(Format.Astc10x5Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc10X5Khr));
Add(Format.Astc10x6Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc10X6Khr)); Add(Format.Astc10x6Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc10X6Khr));
Add(Format.Astc10x8Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc10X8Khr)); Add(Format.Astc10x8Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc10X8Khr));
Add(Format.Astc10x10Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc10X10Khr)); Add(Format.Astc10x10Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc10X10Khr));
Add(Format.Astc12x10Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc12X10Khr)); Add(Format.Astc12x10Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc12X10Khr));
Add(Format.Astc12x12Srgb, new FormatInfo(1, false, false, All.CompressedSrgb8Alpha8Astc12X12Khr)); Add(Format.Astc12x12Srgb, new FormatInfo(4, false, false, All.CompressedSrgb8Alpha8Astc12X12Khr));
Add(Format.B5G6R5Unorm, new FormatInfo(3, true, false, All.Rgb565, PixelFormat.Rgb, PixelType.UnsignedShort565)); Add(Format.B5G6R5Unorm, new FormatInfo(3, true, false, All.Rgb565, PixelFormat.Rgb, PixelType.UnsignedShort565));
Add(Format.B5G5R5X1Unorm, new FormatInfo(4, true, false, All.Rgb5, PixelFormat.Bgra, PixelType.UnsignedShort5551)); Add(Format.B5G5R5X1Unorm, new FormatInfo(4, true, false, All.Rgb5, PixelFormat.Bgra, PixelType.UnsignedShort5551));
Add(Format.B5G5R5A1Unorm, new FormatInfo(4, true, false, All.Rgb5A1, PixelFormat.Bgra, PixelType.UnsignedShort5551)); Add(Format.B5G5R5A1Unorm, new FormatInfo(4, true, false, All.Rgb5A1, PixelFormat.Bgra, PixelType.UnsignedShort5551));

View file

@ -8,15 +8,10 @@ namespace Ryujinx.Graphics.Shader
public string Code { get; private set; } public string Code { get; private set; }
public int SizeA { get; } public ShaderProgram(ShaderStage stage, string code)
public int Size { get; }
public ShaderProgram(ShaderStage stage, string code, int size, int sizeA)
{ {
Stage = stage; Stage = stage;
Code = code; Code = code;
SizeA = sizeA;
Size = size;
} }
public void Prepend(string line) public void Prepend(string line)

View file

@ -36,22 +36,7 @@ namespace Ryujinx.Graphics.Shader.Translation
return new TranslatorContext(address, cfg, config); return new TranslatorContext(address, cfg, config);
} }
public static TranslatorContext CreateContext( internal static ShaderProgram Translate(FunctionCode[] functions, ShaderConfig config, out ShaderProgramInfo shaderProgramInfo)
ulong addressA,
ulong addressB,
IGpuAccessor gpuAccessor,
TranslationFlags flags,
TranslationCounts counts = null)
{
counts ??= new TranslationCounts();
Block[][] cfgA = DecodeShader(addressA, gpuAccessor, flags | TranslationFlags.VertexA, counts, out ShaderConfig configA);
Block[][] cfgB = DecodeShader(addressB, gpuAccessor, flags, counts, out ShaderConfig configB);
return new TranslatorContext(addressA, addressB, cfgA, cfgB, configA, configB);
}
internal static ShaderProgram Translate(FunctionCode[] functions, ShaderConfig config, out ShaderProgramInfo shaderProgramInfo, int sizeA = 0)
{ {
var cfgs = new ControlFlowGraph[functions.Length]; var cfgs = new ControlFlowGraph[functions.Length];
var frus = new RegisterUsage.FunctionRegisterUsage[functions.Length]; var frus = new RegisterUsage.FunctionRegisterUsage[functions.Length];
@ -113,7 +98,7 @@ namespace Ryujinx.Graphics.Shader.Translation
string glslCode = program.Code; string glslCode = program.Code;
return new ShaderProgram(config.Stage, glslCode, config.Size, sizeA); return new ShaderProgram(config.Stage, glslCode);
} }
private static Block[][] DecodeShader( private static Block[][] DecodeShader(

View file

@ -10,16 +10,12 @@ namespace Ryujinx.Graphics.Shader.Translation
public class TranslatorContext public class TranslatorContext
{ {
private readonly Block[][] _cfg; private readonly Block[][] _cfg;
private readonly Block[][] _cfgA;
private ShaderConfig _config; private ShaderConfig _config;
private ShaderConfig _configA;
public ulong Address { get; } public ulong Address { get; }
public ulong AddressA { get; }
public ShaderStage Stage => _config.Stage; public ShaderStage Stage => _config.Stage;
public int Size => _config.Size; public int Size => _config.Size;
public int SizeA => _configA != null ? _configA.Size : 0;
public HashSet<int> TextureHandlesForCache => _config.TextureHandlesForCache; public HashSet<int> TextureHandlesForCache => _config.TextureHandlesForCache;
@ -27,22 +23,9 @@ namespace Ryujinx.Graphics.Shader.Translation
internal TranslatorContext(ulong address, Block[][] cfg, ShaderConfig config) internal TranslatorContext(ulong address, Block[][] cfg, ShaderConfig config)
{ {
Address = address; Address = address;
AddressA = 0; _config = config;
_config = config; _cfg = cfg;
_configA = null;
_cfg = cfg;
_cfgA = null;
}
internal TranslatorContext(ulong addressA, ulong addressB, Block[][] cfgA, Block[][] cfgB, ShaderConfig configA, ShaderConfig configB)
{
Address = addressB;
AddressA = addressA;
_config = configB;
_configA = configA;
_cfg = cfgB;
_cfgA = cfgA;
} }
private static bool IsUserAttribute(Operand operand) private static bool IsUserAttribute(Operand operand)
@ -141,20 +124,19 @@ namespace Ryujinx.Graphics.Shader.Translation
return output; return output;
} }
public ShaderProgram Translate(out ShaderProgramInfo shaderProgramInfo) public ShaderProgram Translate(out ShaderProgramInfo shaderProgramInfo, TranslatorContext other = null)
{ {
FunctionCode[] code = EmitShader(_cfg, _config); FunctionCode[] code = EmitShader(_cfg, _config);
if (_configA != null) if (other != null)
{ {
FunctionCode[] codeA = EmitShader(_cfgA, _configA); _config.SetUsedFeature(other._config.UsedFeatures);
TextureHandlesForCache.UnionWith(other.TextureHandlesForCache);
_config.SetUsedFeature(_configA.UsedFeatures); code = Combine(EmitShader(other._cfg, other._config), code);
code = Combine(codeA, code);
} }
return Translator.Translate(code, _config, out shaderProgramInfo, SizeA); return Translator.Translate(code, _config, out shaderProgramInfo);
} }
} }
} }

View file

@ -1506,15 +1506,33 @@ namespace Ryujinx.HLE.HOS.Kernel.Memory
{ {
KProcess currentProcess = KernelStatic.GetCurrentProcess(); KProcess currentProcess = KernelStatic.GetCurrentProcess();
serverAddress = currentProcess.MemoryManager.GetDramAddressFromVa(serverAddress); while (size > 0)
{
ulong copySize = Math.Min(PageSize - (serverAddress & (PageSize - 1)), PageSize - (clientAddress & (PageSize - 1)));
if (toServer) if (copySize > size)
{ {
_context.Memory.Copy(serverAddress, GetDramAddressFromVa(clientAddress), size); copySize = size;
} }
else
{ ulong serverDramAddr = currentProcess.MemoryManager.GetDramAddressFromVa(serverAddress);
_context.Memory.Copy(GetDramAddressFromVa(clientAddress), serverAddress, size); ulong clientDramAddr = GetDramAddressFromVa(clientAddress);
if (serverDramAddr != clientDramAddr)
{
if (toServer)
{
_context.Memory.Copy(serverDramAddr, clientDramAddr, copySize);
}
else
{
_context.Memory.Copy(clientDramAddr, serverDramAddr, copySize);
}
}
serverAddress += copySize;
clientAddress += copySize;
size -= copySize;
} }
return KernelResult.Success; return KernelResult.Success;

View file

@ -5,6 +5,7 @@ using Ryujinx.Ui;
using System; using System;
using System.Diagnostics; using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Ryujinx.Modules namespace Ryujinx.Modules
@ -32,6 +33,7 @@ namespace Ryujinx.Modules
_mainWindow = mainWindow; _mainWindow = mainWindow;
_buildUrl = buildUrl; _buildUrl = buildUrl;
Icon = new Gdk.Pixbuf(Assembly.GetExecutingAssembly(), "Ryujinx.Ui.Resources.Logo_Ryujinx.png");
MainText.Text = "Do you want to update Ryujinx to the latest version?"; MainText.Text = "Do you want to update Ryujinx to the latest version?";
SecondaryText.Text = $"{Program.Version} -> {newVersion}"; SecondaryText.Text = $"{Program.Version} -> {newVersion}";
@ -86,4 +88,4 @@ namespace Ryujinx.Modules
Dispose(); Dispose();
} }
} }
} }