forked from sin365/AxibugEmuOnline
优化数组拷贝的性能
This commit is contained in:
parent
8f683b0c3c
commit
c7445147b4
@ -1 +1 @@
|
||||
Subproject commit 8b0f0be28a7697597e9d416fa90a8ba62182bfa4
|
||||
Subproject commit 1acd8341ce457e66d172834dfb909569db309c33
|
@ -107,6 +107,8 @@
|
||||
|
||||
mapUV.x = lerp(start,end, mapUV.x);
|
||||
|
||||
|
||||
|
||||
half4 color = tex2D(_MainTex,mapUV);
|
||||
|
||||
float rawIndex = color.b;
|
||||
|
@ -1,5 +1,7 @@
|
||||
using System;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Runtime.InteropServices;
|
||||
using Unity.Collections.LowLevel.Unsafe;
|
||||
|
||||
namespace VirtualNes.Core
|
||||
{
|
||||
@ -19,27 +21,25 @@ namespace VirtualNes.Core
|
||||
memset(array, 0, value, length);
|
||||
}
|
||||
|
||||
public static void memset(uint[] array, uint value, int length)
|
||||
public unsafe static void memset(byte[] array, int offset, byte value, int length)
|
||||
{
|
||||
fixed (byte* ptr = array)
|
||||
{
|
||||
var offsetptr = ptr + offset;
|
||||
|
||||
Unsafe.InitBlock(offsetptr, value, (uint)length);
|
||||
}
|
||||
}
|
||||
|
||||
public unsafe static void memset(uint[] array, int offset, byte value, int length)
|
||||
{
|
||||
fixed (uint* ptr = array)
|
||||
{
|
||||
var offsetptr = ptr + offset;
|
||||
for (int i = 0; i < length; i++)
|
||||
{
|
||||
array[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void memset(byte[] array, int offset, byte value, int length)
|
||||
{
|
||||
for (int i = offset; i < length; i++)
|
||||
{
|
||||
array[i] = value;
|
||||
}
|
||||
}
|
||||
|
||||
public static void memset(uint[] array, int offset, uint value, int length)
|
||||
{
|
||||
for (int i = offset; i < length; i++)
|
||||
{
|
||||
array[i] = value;
|
||||
offsetptr[i] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ namespace VirtualNes.Core
|
||||
loopy_shift = 0;
|
||||
|
||||
if (lpScreen != null)
|
||||
MemoryUtility.memset(lpScreen, 0x3F, SCREEN_WIDTH * SCREEN_HEIGHT);
|
||||
MemoryUtility.memset(lpScreen, 0, 0x3F, SCREEN_WIDTH * SCREEN_HEIGHT);
|
||||
if (lpColormode != null)
|
||||
MemoryUtility.memset(lpColormode, 0, SCREEN_HEIGHT);
|
||||
}
|
||||
@ -376,7 +376,7 @@ namespace VirtualNes.Core
|
||||
|
||||
if (lpScreen != null)
|
||||
{
|
||||
MemoryUtility.memset(lpScreen, 0x3F, SCREEN_WIDTH);
|
||||
MemoryUtility.memset(lpScreen, 0, 0x3F, SCREEN_WIDTH);
|
||||
}
|
||||
if (lpColormode != null)
|
||||
{
|
||||
|
@ -4,7 +4,7 @@
|
||||
"references": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"allowUnsafeCode": true,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": false,
|
||||
|
Loading…
Reference in New Issue
Block a user