You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.3 KiB
C
61 lines
1.3 KiB
C
#ifndef GUARD_OPPOSABLY_UNRETICENT_POGAMOGGAN_UNMAIDENS_2195
|
|
#define GUARD_OPPOSABLY_UNRETICENT_POGAMOGGAN_UNMAIDENS_2195
|
|
#pragma once
|
|
|
|
#include <stddef.h>
|
|
#include <stdint.h>
|
|
|
|
// wine/dlls/windowscodecs/ddsformat.c
|
|
// I'm sure you can find it somewhere in microsoft's uberbloat sdks somewhere...
|
|
typedef struct
|
|
{
|
|
uint32_t size;
|
|
uint32_t flags;
|
|
char four_cc[4];
|
|
uint32_t rgb_bit_count;
|
|
uint32_t r_bit_mask;
|
|
uint32_t g_bit_mask;
|
|
uint32_t b_bit_mask;
|
|
uint32_t a_bit_mask;
|
|
} DDS_PIXELFORMAT;
|
|
|
|
typedef struct
|
|
{
|
|
char magic[4];
|
|
|
|
uint32_t size;
|
|
uint32_t flags;
|
|
uint32_t height;
|
|
uint32_t width;
|
|
uint32_t pitch_or_linear_size;
|
|
uint32_t depth;
|
|
uint32_t mip_map_count;
|
|
uint32_t reserved1[11];
|
|
DDS_PIXELFORMAT ddspf;
|
|
uint32_t caps;
|
|
uint32_t caps2;
|
|
uint32_t caps3;
|
|
uint32_t caps4;
|
|
uint32_t reserved2;
|
|
} DDS;
|
|
|
|
static void swizzle_1024_512(size_t i, size_t* x, size_t* y)
|
|
{
|
|
// https://fgiesen.wordpress.com/2009/12/13/decoding-morton-codes/
|
|
// modified to 1024x512
|
|
size_t srcx = (i >> 1) & 0x1555;
|
|
srcx = (srcx ^ (srcx >> 1)) & 0x3333;
|
|
srcx = (srcx ^ (srcx >> 2)) & 0x0f0f;
|
|
srcx = (srcx ^ (srcx >> 4)) & 0x00ff;
|
|
srcx |= (i & 0x4000) >> 7;
|
|
|
|
size_t srcy = i & 0x1555;
|
|
srcy = (srcy ^ (srcy >> 1)) & 0x3333;
|
|
srcy = (srcy ^ (srcy >> 2)) & 0x0f0f;
|
|
srcy = (srcy ^ (srcy >> 4)) & 0x00ff;
|
|
|
|
*x = srcx; *y = srcy;
|
|
}
|
|
|
|
#endif
|