Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add R8_UNORM and R16_UNORM extended surface formats #228

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions include/FNA3D.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ typedef enum FNA3D_SurfaceFormat
FNA3D_SURFACEFORMAT_DXT5SRGB_EXT,
FNA3D_SURFACEFORMAT_BC7_EXT,
FNA3D_SURFACEFORMAT_BC7SRGB_EXT,
FNA3D_SURFACEFORMAT_BYTE_EXT,
FNA3D_SURFACEFORMAT_USHORT_EXT,
} FNA3D_SurfaceFormat;

typedef enum FNA3D_DepthFormat
Expand Down
4 changes: 4 additions & 0 deletions src/FNA3D_Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ static inline int32_t Texture_GetBlockSize(
case FNA3D_SURFACEFORMAT_VECTOR2:
case FNA3D_SURFACEFORMAT_HDRBLENDABLE:
case FNA3D_SURFACEFORMAT_VECTOR4:
case FNA3D_SURFACEFORMAT_USHORT_EXT:
case FNA3D_SURFACEFORMAT_BYTE_EXT:
return 1;
default:
FNA3D_LogError(
Expand All @@ -147,12 +149,14 @@ static inline int32_t Texture_GetFormatSize(
case FNA3D_SURFACEFORMAT_BC7SRGB_EXT:
return 16;
case FNA3D_SURFACEFORMAT_ALPHA8:
case FNA3D_SURFACEFORMAT_BYTE_EXT:
return 1;
case FNA3D_SURFACEFORMAT_BGR565:
case FNA3D_SURFACEFORMAT_BGRA4444:
case FNA3D_SURFACEFORMAT_BGRA5551:
case FNA3D_SURFACEFORMAT_HALFSINGLE:
case FNA3D_SURFACEFORMAT_NORMALIZEDBYTE2:
case FNA3D_SURFACEFORMAT_USHORT_EXT:
return 2;
case FNA3D_SURFACEFORMAT_COLOR:
case FNA3D_SURFACEFORMAT_SINGLE:
Expand Down
2 changes: 2 additions & 0 deletions src/FNA3D_Driver_D3D11.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,8 @@ static DXGI_FORMAT XNAToD3D_TextureFormat[] =
DXGI_FORMAT_BC3_UNORM_SRGB, /* SurfaceFormat.Dxt5SrgbEXT */
DXGI_FORMAT_BC7_UNORM, /* SurfaceFormat.BC7EXT */
DXGI_FORMAT_BC7_UNORM_SRGB, /* SurfaceFormat.BC7SrgbEXT */
DXGI_FORMAT_R8_UNORM, /* SurfaceFormat.NormalizedByteEXT */
DXGI_FORMAT_R16_UNORM, /* SurfaceFormat.NormalizedUShortEXT */
};

static DXGI_FORMAT XNAToD3D_DepthFormat[] =
Expand Down
6 changes: 6 additions & 0 deletions src/FNA3D_Driver_OpenGL.c
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,8 @@ static int32_t XNAToGL_TextureFormat[] =
GL_COMPRESSED_TEXTURE_FORMATS, /* SurfaceFormat.Dxt5SrgbEXT */
GL_COMPRESSED_TEXTURE_FORMATS, /* SurfaceFormat.Bc7EXT */
GL_COMPRESSED_TEXTURE_FORMATS, /* SurfaceFormat.Bc7SrgbEXT */
GL_RED, /* SurfaceFormat.NormalizedByteEXT */
GL_RED, /* SurfaceFormat.NormalizedUShortEXT */
};

static int32_t XNAToGL_TextureInternalFormat[] =
Expand Down Expand Up @@ -385,6 +387,8 @@ static int32_t XNAToGL_TextureInternalFormat[] =
GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, /* SurfaceFormat.Dxt5SrgbEXT */
GL_COMPRESSED_RGBA_BPTC_UNORM_EXT, /* SurfaceFormat.BC7EXT */
GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT,/* SurfaceFormat.BC7SrgbEXT */
GL_R8, /* SurfaceFormat.NormalizedByteEXT */
GL_R16, /* SurfaceFormat.NormalizedUShortEXT */
};

static int32_t XNAToGL_TextureDataType[] =
Expand Down Expand Up @@ -414,6 +418,8 @@ static int32_t XNAToGL_TextureDataType[] =
GL_ZERO, /* NOPE */
GL_ZERO, /* NOPE */
GL_ZERO, /* NOPE */
GL_UNSIGNED_BYTE, /* SurfaceFormat.NormalizedByteEXT */
GL_UNSIGNED_SHORT, /* SurfaceFormat.NormalizedUShortEXT */
};

static int32_t XNAToGL_BlendMode[] =
Expand Down
4 changes: 4 additions & 0 deletions src/FNA3D_Driver_OpenGL.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,10 @@ typedef unsigned char GLboolean;
#define GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT 0x8C4F
#define GL_COMPRESSED_RGBA_BPTC_UNORM_EXT 0x8E8C
#define GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM_EXT 0x8E8D
#define GL_R8UI 0x8232
#define GL_R16UI 0x8234
#define GL_R8 0x8229
#define GL_R16 0x822A

/* EXT_framebuffer_sRGB */
#define GL_FRAMEBUFFER_SRGB_EXT 0x8DB9
Expand Down
4 changes: 3 additions & 1 deletion src/FNA3D_Driver_SDL.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,9 @@ static SDL_GPUTextureFormat XNAToSDL_SurfaceFormat[] =
SDL_GPU_TEXTUREFORMAT_R8G8B8A8_UNORM_SRGB, /* SurfaceFormat.ColorSrgbEXT */
SDL_GPU_TEXTUREFORMAT_BC3_RGBA_UNORM_SRGB, /* SurfaceFormat.Dxt5SrgbEXT */
SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM, /* SurfaceFormat.Bc7EXT */
SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB /* SurfaceFormat.Bc7SrgbEXT */
SDL_GPU_TEXTUREFORMAT_BC7_RGBA_UNORM_SRGB, /* SurfaceFormat.Bc7SrgbEXT */
SDL_GPU_TEXTUREFORMAT_R8_UNORM, /* SurfaceFormat.NormalizedByteEXT */
SDL_GPU_TEXTUREFORMAT_R16_UNORM, /* SurfaceFormat.NormalizedUShortEXT */
};

static SDL_GPUPrimitiveType XNAToSDL_PrimitiveType[] =
Expand Down
Loading