Cosmos/source/Cosmos.Core/MemoryOperations.cs
fanoI db5b713090 CGS is finally ready to be used! Let's merge it...
- To solve the slowness of the MemoryBlock Fill() method when the block has a big size I've created a new class for this MemoryOperations that for now contains only the method Fill() with a part implemented in ASM and with some overloads to semplify its usage from managed code. In future in this class will be added other methods to operate fast on memory for example Cmp() and Copy().
- Adding (not passing) test of the Color struct to the BoxingTest kernel
- Removed BoxingTest kernel inside BCL test: it was a duplicate of the BoxingTest kernel
- Restored correct TestKernelSets
- In the CGS Test kernel the last rectangle is now LimeGreen instead of another type of red (more clear that is working correctly)
- Added to X# the generation of the instruction Shuftps
- Added to X# the generation of the instruction MoveUPS
- Modified Guess Demo to wait for a key press to terminate (it closed suddenly in case the number was guessed)
- The VBE IOMemoryBlock has again size of 1920x1200 (the max usable)
- Added CGS Demo
- Code clean up
2017-03-05 20:32:55 +01:00

113 lines
3.5 KiB
C#

#define COSMOSDEBUG
using System.Runtime.CompilerServices;
namespace Cosmos.Core
{
public unsafe class MemoryOperations
{
public static unsafe void Fill16Blocks(byte* dest, int value, int BlocksNum)
{
// Plugged
}
unsafe public static void Fill(byte* dest, int value, int size)
{
// Plugged
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(uint* dest, uint value, int size)
{
Fill((byte*)dest, (int)value, size);
}
unsafe public static void Fill(int* dest, int value, int size)
{
Fill((byte*)dest, value, size);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(uint[] dest, uint value)
{
fixed (uint* destPtr = dest)
{
Fill(destPtr, value, dest.Length * 4);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(int[] dest, int value)
{
fixed (int* destPtr = dest)
{
Fill(destPtr, value, dest.Length * 4);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(ushort* dest, ushort value, int size)
{
/* Broadcast 'value' to fill all the integer register (0x42 --> 0x42424242) */
int valueFiller = value * 0x10001;
Fill((byte*)dest, valueFiller, size);
}
unsafe public static void Fill(short* dest, short value, int size)
{
/* Broadcast 'value' to fill all the integer register (0x42 --> 0x42424242) */
int valueFiller = (ushort)value * 0x10001;
Fill((byte*)dest, valueFiller, size);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(ushort[] dest, ushort value)
{
fixed (ushort* destPtr = dest)
{
Fill(destPtr, value, dest.Length * 2);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(short[] dest, short value)
{
fixed (short* destPtr = dest)
{
Fill(destPtr, value, dest.Length * 2);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(byte* dest, byte value, int size)
{
/* Broadcast 'value' fill all the integer register (0x42 --> 0x42424242) */
int valueFiller = value * 0x1010101;
Fill(dest, valueFiller, size);
}
unsafe public static void Fill(sbyte* dest, sbyte value, int size)
{
/* Broadcast 'value' fill all the integer register (0x42 --> 0x42424242) */
int valueFiller = (byte)value * 0x1010101;
Fill((byte*)dest, valueFiller, size);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(byte[] dest, byte value)
{
fixed (byte* destPtr = dest)
{
Fill(destPtr, value, dest.Length);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
unsafe public static void Fill(sbyte[] dest, sbyte value)
{
fixed (sbyte* destPtr = dest)
{
Fill(destPtr, value, dest.Length);
}
}
}
}