Skip to content

Instantly share code, notes, and snippets.

@raedwulf
Created January 25, 2018 12:06
Show Gist options
  • Save raedwulf/dffebb332281501313929e33df5833c8 to your computer and use it in GitHub Desktop.
Save raedwulf/dffebb332281501313929e33df5833c8 to your computer and use it in GitHub Desktop.
/* See LICENSE file for copyright and license details.
* Generated by mkmatcher.awk
*/
#include <stddef.h>
#include <stdint.h>
/* headers included using headers= parameter */
#include <GL/gl.h>
#include <GL/glext.h>
int
glrmatch(const char *s, size_t l)
{
const char *p = s;
switch (l) {
case 19:
if (*(const uint64_t *)&p[0] == 0x4f435f4854504544ull && *(const uint64_t *)&p[8] == 0x33544e454e4f504dull && *(const uint16_t *)&p[16] == 0x4632u && *(const uint8_t *)&p[18] == 0x00u) /* '' */
return GL_DEPTH_COMPONENT32F;
return -1;
case 18:
if (*(const uint32_t *)&p[0] == 0x54504544u && *(const uint8_t *)&p[4] == 0x48u) { /* 'H' */
p += 5; goto l17_1;
}
return -1;
l17_1:
if (*(const uint64_t *)&p[0] == 0x454e4f504d4f435full && *(const uint16_t *)&p[8] == 0x544eu) { /* 'NT' */
p += 10; goto l17_4;
}
if (*(const uint64_t *)&p[0] == 0x4e4554535f463233ull && *(const uint32_t *)&p[8] == 0x384c4943u && *(const uint8_t *)&p[12] == 0x00u) /* '' */
return GL_DEPTH32F_STENCIL8;
return -1;
l17_4:
if (*(const uint16_t *)&p[0] == 0x3631u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_DEPTH_COMPONENT16;
if (*(const uint16_t *)&p[0] == 0x3432u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_DEPTH_COMPONENT24;
return -1;
case 17:
if (*(const uint64_t *)&p[0] == 0x5f34324854504544ull && *(const uint64_t *)&p[8] == 0x384c49434e455453ull && *(const uint8_t *)&p[16] == 0x00u) /* '' */
return GL_DEPTH24_STENCIL8;
return -1;
case 15:
if (*(const uint64_t *)&p[0] == 0x3131475f46313152ull && *(const uint32_t *)&p[8] == 0x31425f46u && *(const uint16_t *)&p[12] == 0x4630u && *(const uint8_t *)&p[14] == 0x00u) /* '' */
return GL_R11F_G11F_B10F;
return -1;
case 13:
if (*(const uint64_t *)&p[0] == 0x4c415f3842475253ull && *(const uint32_t *)&p[8] == 0x38414850u && *(const uint8_t *)&p[12] == 0x00u) /* '' */
return GL_SRGB8_ALPHA8;
return -1;
case 12:
if (*(const uint64_t *)&p[0] == 0x4e535f3841424752ull && *(const uint32_t *)&p[8] == 0x004d524fu) /* 'ORM' */
return GL_RGBA8_SNORM;
return -1;
case 11:
if (*(const uint16_t *)&p[0] == 0x4752u && *(const uint8_t *)&p[2] == 0x42u) { /* 'B' */
p += 3; goto l10_1;
}
return -1;
l10_1:
if (*(const uint64_t *)&p[0] == 0x00495532415f3031ull) /* '10_A2UI' */
return GL_RGB10_A2UI;
if (*(const uint64_t *)&p[0] == 0x004d524f4e535f38ull) /* '8_SNORM' */
return GL_RGB8_SNORM;
return -1;
case 10:
if (*(const uint64_t *)&p[0] == 0x524f4e535f384752ull && *(const uint16_t *)&p[8] == 0x004du) /* 'M' */
return GL_RG8_SNORM;
return -1;
case 9:
if (*(const uint8_t *)&p[0] == 0x52u) { /* 'R' */
p += 1; goto l8_1;
}
return -1;
l8_1:
if (*(const uint16_t *)&p[0] == 0x4247u) { /* 'GB' */
p += 2; goto l8_6;
}
if (*(const uint64_t *)&p[0] == 0x004d524f4e535f38ull) /* '8_SNORM' */
return GL_R8_SNORM;
return -1;
l8_3:
if (*(const uint32_t *)&p[0] == 0x49553631u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RGBA16UI;
if (*(const uint32_t *)&p[0] == 0x49553233u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RGBA32UI;
return -1;
l8_6:
if (*(const uint32_t *)&p[0] == 0x415f3031u && *(const uint16_t *)&p[4] == 0x0032u) /* '2' */
return GL_RGB10_A2;
if (*(const uint8_t *)&p[0] == 0x41u) { /* 'A' */
p += 1; goto l8_3;
}
return -1;
case 8:
if (*(const uint16_t *)&p[0] == 0x4752u && *(const uint8_t *)&p[2] == 0x42u) { /* 'B' */
p += 3; goto l7_1;
}
return -1;
l7_1:
if (*(const uint32_t *)&p[0] == 0x31415f35u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RGB5_A1;
if (*(const uint8_t *)&p[0] == 0x41u) { /* 'A' */
p += 1; goto l7_3;
}
if (*(const uint32_t *)&p[0] == 0x35455f39u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RGB9_E5;
if (*(const uint32_t *)&p[0] == 0x49553631u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RGB16UI;
if (*(const uint32_t *)&p[0] == 0x49553233u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RGB32UI;
return -1;
l7_3:
if (*(const uint16_t *)&p[0] == 0x3631u) { /* '16' */
p += 2; goto l7_4;
}
if (*(const uint16_t *)&p[0] == 0x3233u) { /* '32' */
p += 2; goto l7_5;
}
if (*(const uint32_t *)&p[0] == 0x00495538u) /* '8UI' */
return GL_RGBA8UI;
return -1;
l7_4:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_RGBA16F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_RGBA16I;
return -1;
l7_5:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_RGBA32F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_RGBA32I;
return -1;
case 7:
if (*(const uint16_t *)&p[0] == 0x4752u) { /* 'RG' */
p += 2; goto l6_1;
}
return -1;
l6_1:
if (*(const uint8_t *)&p[0] == 0x42u) { /* 'B' */
p += 1; goto l6_11;
}
if (*(const uint32_t *)&p[0] == 0x49553631u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RG16UI;
if (*(const uint32_t *)&p[0] == 0x49553233u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_RG32UI;
return -1;
l6_4:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_RGB16F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_RGB16I;
return -1;
l6_5:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_RGB32F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_RGB32I;
return -1;
l6_11:
if (*(const uint32_t *)&p[0] == 0x00493841u) /* 'A8I' */
return GL_RGBA8I;
if (*(const uint32_t *)&p[0] == 0x00353635u) /* '565' */
return GL_RGB565;
if (*(const uint16_t *)&p[0] == 0x3631u) { /* '16' */
p += 2; goto l6_4;
}
if (*(const uint16_t *)&p[0] == 0x3233u) { /* '32' */
p += 2; goto l6_5;
}
if (*(const uint32_t *)&p[0] == 0x00495538u) /* '8UI' */
return GL_RGB8UI;
return -1;
case 6:
if (*(const uint8_t *)&p[0] == 0x52u) { /* 'R' */
p += 1; goto l5_1;
}
if (*(const uint32_t *)&p[0] == 0x42475253u && *(const uint16_t *)&p[4] == 0x0038u) /* '8' */
return GL_SRGB8;
return -1;
l5_1:
if (*(const uint8_t *)&p[0] == 0x47u) { /* 'G' */
p += 1; goto l5_15;
}
if (*(const uint32_t *)&p[0] == 0x49553631u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_R16UI;
if (*(const uint32_t *)&p[0] == 0x49553233u && *(const uint8_t *)&p[4] == 0x00u) /* '' */
return GL_R32UI;
return -1;
l5_5:
if (*(const uint16_t *)&p[0] == 0x0038u) /* '8' */
return GL_RGBA8;
if (*(const uint16_t *)&p[0] == 0x0034u) /* '4' */
return GL_RGBA4;
return -1;
l5_7:
if (*(const uint8_t *)&p[0] == 0x41u) { /* 'A' */
p += 1; goto l5_5;
}
if (*(const uint16_t *)&p[0] == 0x4938u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_RGB8I;
return -1;
l5_8:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_RG16F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_RG16I;
return -1;
l5_9:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_RG32F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_RG32I;
return -1;
l5_15:
if (*(const uint8_t *)&p[0] == 0x42u) { /* 'B' */
p += 1; goto l5_7;
}
if (*(const uint16_t *)&p[0] == 0x3631u) { /* '16' */
p += 2; goto l5_8;
}
if (*(const uint16_t *)&p[0] == 0x3233u) { /* '32' */
p += 2; goto l5_9;
}
if (*(const uint32_t *)&p[0] == 0x00495538u) /* '8UI' */
return GL_RG8UI;
return -1;
case 5:
if (*(const uint8_t *)&p[0] == 0x52u) { /* 'R' */
p += 1; goto l4_1;
}
return -1;
l4_1:
if (*(const uint8_t *)&p[0] == 0x47u) { /* 'G' */
p += 1; goto l4_4;
}
if (*(const uint16_t *)&p[0] == 0x3631u) { /* '16' */
p += 2; goto l4_5;
}
if (*(const uint16_t *)&p[0] == 0x3233u) { /* '32' */
p += 2; goto l4_6;
}
if (*(const uint32_t *)&p[0] == 0x00495538u) /* '8UI' */
return GL_R8UI;
return -1;
l4_4:
if (*(const uint16_t *)&p[0] == 0x3842u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_RGB8;
if (*(const uint16_t *)&p[0] == 0x4938u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_RG8I;
return -1;
l4_5:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_R16F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_R16I;
return -1;
l4_6:
if (*(const uint16_t *)&p[0] == 0x0046u) /* 'F' */
return GL_R32F;
if (*(const uint16_t *)&p[0] == 0x0049u) /* 'I' */
return GL_R32I;
return -1;
case 4:
if (*(const uint8_t *)&p[0] == 0x52u) { /* 'R' */
p += 1; goto l3_1;
}
return -1;
l3_1:
if (*(const uint16_t *)&p[0] == 0x3847u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_RG8;
if (*(const uint16_t *)&p[0] == 0x4938u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_R8I;
return -1;
case 3:
if (*(const uint16_t *)&p[0] == 0x3852u && *(const uint8_t *)&p[2] == 0x00u) /* '' */
return GL_R8;
return -1;
default: return -1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment