From 66e3810ef8213a75724735ec2114b604d20911d4 Mon Sep 17 00:00:00 2001 From: plutooo Date: Sun, 25 Mar 2018 18:45:24 +0200 Subject: [PATCH] Sketching on cmd generation --- nx/include/switch/nvidia/gpu/cmd_list.h | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/nx/include/switch/nvidia/gpu/cmd_list.h b/nx/include/switch/nvidia/gpu/cmd_list.h index ea35e4bc..efceafb9 100644 --- a/nx/include/switch/nvidia/gpu/cmd_list.h +++ b/nx/include/switch/nvidia/gpu/cmd_list.h @@ -14,3 +14,20 @@ iova_t nvCmdListGetGpuAddr(NvCmdList* c); u64 nvCmdListGetListSize(NvCmdList* c); u32* nvCmdListInsert(NvCmdList* c, size_t num_cmds); + +#define NvCmd(cmd_list, ...) do { \ + u32 _[] = { __VA_ARGS__ }; \ + memcpy(nvCmdListInsert(cmd_list, sizeof(_)/4), _, sizeof(_)); \ + } while (0) + +#define NvImm(reg, subc, val) \ + (0x80000000 | (reg) | ((subc) << 13) | ((val) << 16)) + +#define NvRep(reg, subc, ...) \ + (0x60000000 | ((reg) | ((subc) << 13) | ((sizeof((u32[]) { __VA_ARGS__ })) << 16))), __VA_ARGS__ + +#define NvIncr(reg, subc, ...) \ + (0x20000000 | ((reg) | ((subc) << 13) | ((sizeof((u32[]) { __VA_ARGS__ })) << 16))), __VA_ARGS__ + +#define NvIncrOnce(reg, subc, ...) \ + (0xA0000000 | ((reg) | ((subc) << 13) | ((sizeof((u32[]) { __VA_ARGS__ })) << 16))), __VA_ARGS__