idgaf just use Blt()
This commit is contained in:
1 parent
aaf823bae5
commit
b040b78379
3 files changed
+18
-56
No files matched your search
Binary file not shown.
Binary file not shown.
@@ -191,47 +191,6 @@ bool LoadBinkDLL(EFI_FILE_HANDLE volume) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Blit_AVX2_NT(
|
|
||||||
EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop,
|
|
||||||
uint32_t *src,
|
|
||||||
UINTN src_width, UINTN src_height
|
|
||||||
) {
|
|
||||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info = Gop->Mode->Info;
|
|
||||||
UINTN fb_width = info->HorizontalResolution;
|
|
||||||
UINTN fb_height = info->VerticalResolution;
|
|
||||||
UINTN stride = info->PixelsPerScanLine;
|
|
||||||
|
|
||||||
uint32_t *fb = (uint32_t *)Gop->Mode->FrameBufferBase;
|
|
||||||
|
|
||||||
// Center offsets
|
|
||||||
UINTN x0 = (fb_width - src_width) / 2;
|
|
||||||
UINTN y0 = (fb_height - src_height) / 2;
|
|
||||||
|
|
||||||
for (UINTN y = 0; y < src_height; y++) {
|
|
||||||
uint32_t *dst = fb + (y0 + y) * stride + x0;
|
|
||||||
uint32_t *s = src + y * src_width;
|
|
||||||
|
|
||||||
UINTN x = 0;
|
|
||||||
|
|
||||||
// Align destination pointer to 32-byte boundary for AVX2 streaming
|
|
||||||
for (; ((uintptr_t)(dst + x) & 31) && x < src_width; x++)
|
|
||||||
dst[x] = s[x];
|
|
||||||
|
|
||||||
// Copy 8 pixels (32 bytes) at a time using AVX2 non-temporal stores
|
|
||||||
for (; x + 7 < src_width; x += 8) {
|
|
||||||
__m256i data = _mm256_loadu_si256((__m256i *)(s + x));
|
|
||||||
_mm256_stream_si256((__m256i *)(dst + x), data);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy any remaining pixels
|
|
||||||
for (; x < src_width; x++)
|
|
||||||
dst[x] = s[x];
|
|
||||||
}
|
|
||||||
|
|
||||||
// Ensure non-temporal stores are flushed to memory
|
|
||||||
_mm_sfence();
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS SetMaxResolution(EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop) {
|
EFI_STATUS SetMaxResolution(EFI_GRAPHICS_OUTPUT_PROTOCOL *Gop) {
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MaxModeInfo;
|
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *MaxModeInfo;
|
||||||
@@ -413,7 +372,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
|
|
||||||
printf("BinkSet* called\n");
|
printf("BinkSet* called\n");
|
||||||
|
|
||||||
void* video_file = LoadFile(volume, L"idk.bk2");
|
void* video_file = LoadFile(volume, L"video.bk2");
|
||||||
|
|
||||||
printf("Video file loaded into memory\n");
|
printf("Video file loaded into memory\n");
|
||||||
|
|
||||||
@@ -437,7 +396,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
printf("Framebuffer allocated!\n");
|
printf("Framebuffer allocated!\n");
|
||||||
|
|
||||||
EFI_INPUT_KEY key;
|
EFI_INPUT_KEY key;
|
||||||
bool paused = false;
|
bool paused = true;
|
||||||
uint64_t skipped = 0;
|
uint64_t skipped = 0;
|
||||||
|
|
||||||
// start the decode loop
|
// start the decode loop
|
||||||
@@ -467,15 +426,17 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Wait for the next frame
|
// Wait for the next frame
|
||||||
while (pBinkWait(bink)) {
|
if (pBinkWait(bink)) {
|
||||||
_mm_pause(); // don't burn CPU cycles
|
_mm_pause(); // don't burn CPU cycles
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if we should skip the frame
|
// Check if we should skip the frame
|
||||||
while (pBinkShouldSkip(bink)) {
|
if (pBinkShouldSkip(bink)) {
|
||||||
pBinkNextFrame(bink);
|
pBinkNextFrame(bink);
|
||||||
pBinkDoFrame(bink);
|
pBinkDoFrame(bink);
|
||||||
skipped++;
|
skipped++;
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int code = pBinkDoFrame(bink);
|
int code = pBinkDoFrame(bink);
|
||||||
@@ -490,7 +451,7 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Copy frame to our buffer
|
// Copy frame to our buffer
|
||||||
code = pBinkCopyToBuffer(
|
pBinkCopyToBuffer(
|
||||||
bink,
|
bink,
|
||||||
framebuffer,
|
framebuffer,
|
||||||
width * 4,
|
width * 4,
|
||||||
@@ -499,19 +460,20 @@ EFI_STATUS efi_main(EFI_HANDLE ImageHandle, EFI_SYSTEM_TABLE* SystemTable) {
|
|||||||
0,
|
0,
|
||||||
BINKSURFACE32 | BINKCOPYALL
|
BINKSURFACE32 | BINKCOPYALL
|
||||||
);
|
);
|
||||||
if (code != 0 && code != 1) { // who knows what they mean
|
|
||||||
printf("BinkCopyToBuffer failed!\n");
|
|
||||||
pBinkClose(bink);
|
|
||||||
Free(video_file);
|
|
||||||
Free(framebuffer);
|
|
||||||
gBS->Stall(5 * 1000 * 1000);
|
|
||||||
gST->RuntimeServices->ResetSystem(EfiResetShutdown, EFI_SUCCESS, 0, NULL);
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
pBinkNextFrame(bink);
|
pBinkNextFrame(bink);
|
||||||
|
|
||||||
Blit_AVX2_NT(gop, framebuffer, width, height);
|
gop->Blt(
|
||||||
|
gop,
|
||||||
|
(EFI_GRAPHICS_OUTPUT_BLT_PIXEL *)framebuffer,
|
||||||
|
EfiBltBufferToVideo,
|
||||||
|
0, 0,
|
||||||
|
(gop->Mode->Info->HorizontalResolution - width) / 2,
|
||||||
|
(gop->Mode->Info->VerticalResolution - height) / 2,
|
||||||
|
width,
|
||||||
|
height,
|
||||||
|
0
|
||||||
|
);
|
||||||
|
|
||||||
if (bink->FrameNum % 10 == 0)
|
if (bink->FrameNum % 10 == 0)
|
||||||
printf("\rframe %d done ", bink->FrameNum);
|
printf("\rframe %d done ", bink->FrameNum);
|
||||||
|
|||||||
Reference in new issue
Block a user