Skip to content

Instantly share code, notes, and snippets.

@averne
Created February 6, 2022 18:03
Show Gist options
  • Save averne/1e42c698426272d4c07f5fb811edf924 to your computer and use it in GitHub Desktop.
Save averne/1e42c698426272d4c07f5fb811edf924 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <switch.h>
#include <deko3d.h>
int main(int argc, char **argv) {
consoleInit(NULL);
padConfigureInput(1, HidNpadStyleSet_NpadStandard);
PadState pad;
padInitializeDefault(&pad);
DkDeviceMaker device_maker;
dkDeviceMakerDefaults(&device_maker);
DkDevice device = dkDeviceCreate(&device_maker);
DkMemBlockMaker memblock_maker;
dkMemBlockMakerDefaults(&memblock_maker, device, 0x100000);
memblock_maker.flags = DkMemBlockFlags_CpuUncached | DkMemBlockFlags_GpuCached;
// memblock_maker.flags = DkMemBlockFlags_CpuCached | DkMemBlockFlags_GpuCached;
DkMemBlock memblock = dkMemBlockCreate(&memblock_maker);
u64 tick_start = armGetSystemTick();
for (int i = 0; i < 100; ++i) {
memset(dkMemBlockGetCpuAddr(memblock), 0, dkMemBlockGetSize(memblock));
// dkMemBlockFlushCpuCache(memblock, 0, dkMemBlockGetSize(memblock));
}
printf("Took %fus\n", (float)armTicksToNs(armGetSystemTick() - tick_start) / 1.0e3f);
while (appletMainLoop()) {
padUpdate(&pad);
if (padGetButtonsDown(&pad) & HidNpadButton_Plus)
break;
consoleUpdate(NULL);
}
dkMemBlockDestroy(memblock);
dkDeviceDestroy(device);
consoleExit(NULL);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment