private AThreadState SingleOpcode(uint Opcode, ulong X0 = 0, ulong X1 = 0, ulong X2 = 0, AVec V0 = new AVec(), AVec V1 = new AVec(), AVec V2 = new AVec()) { Memory.WriteUInt32(0x1000, Opcode); Memory.WriteUInt32(0x1004, 0xD4200000); // BRK #0 Memory.WriteUInt32(0x1008, 0xD65F03C0); // RET AThread Thread = new AThread(Memory, ThreadPriority.Normal, 0x1000); Thread.ThreadState.X0 = X0; Thread.ThreadState.X1 = X1; Thread.ThreadState.X2 = X2; Thread.ThreadState.V0 = V0; Thread.ThreadState.V1 = V1; Thread.ThreadState.V2 = V2; Execute(Thread); return(Thread.ThreadState); }
public void ProcessPushBuffer(NsGpuPBEntry[] PushBuffer, AMemory Memory) { bool HasQuery = false; foreach (NsGpuPBEntry Entry in PushBuffer) { if (Entry.Arguments.Count == 1) { SetRegister(Entry.Register, (uint)Entry.Arguments[0]); } switch (Entry.Register) { case NsGpuRegister.BindChannel: if (Entry.Arguments.Count > 0) { SubChannels[Entry.SubChannel] = (NsGpuEngine)Entry.Arguments[0]; } break; case NsGpuRegister._3dVertexArray0Fetch: SendVertexBuffers(Memory); break; case NsGpuRegister._3dCbData0: if (GetRegister(NsGpuRegister._3dCbPos) == 0x20) { SendTexture(Memory); } break; case NsGpuRegister._3dQueryAddressHigh: case NsGpuRegister._3dQueryAddressLow: case NsGpuRegister._3dQuerySequence: case NsGpuRegister._3dQueryGet: HasQuery = true; break; case NsGpuRegister._3dSetShader: uint ShaderPrg = (uint)Entry.Arguments[0]; uint ShaderId = (uint)Entry.Arguments[1]; uint CodeAddr = (uint)Entry.Arguments[2]; uint ShaderType = (uint)Entry.Arguments[3]; uint CodeEnd = (uint)Entry.Arguments[4]; SendShader( Memory, ShaderPrg, ShaderId, CodeAddr, ShaderType, CodeEnd); break; } } if (HasQuery) { long Position = (long)GetRegister(NsGpuRegister._3dQueryAddressHigh) << 32 | (long)GetRegister(NsGpuRegister._3dQueryAddressLow) << 0; uint Seq = GetRegister(NsGpuRegister._3dQuerySequence); uint Get = GetRegister(NsGpuRegister._3dQueryGet); uint Mode = Get & 3; if (Mode == 0) { //Write Position = Gpu.MemoryMgr.GetCpuAddr(Position); if (Position != -1) { Gpu.Renderer.QueueAction(delegate() { Memory.WriteUInt32(Position, Seq); }); } } } }