Skip to content

Commit

Permalink
Merge branch 'pixelformat_srgba8_nowgpu' of https://github.com/allcre…
Browse files Browse the repository at this point in the history
…ater/sokol into allcreater-pixelformat_srgba8_nowgpu
  • Loading branch information
floooh committed Jan 25, 2023
2 parents 8c4f4b4 + 55ece72 commit 082d2c6
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 6 deletions.
12 changes: 6 additions & 6 deletions sokol_app.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,9 @@
where sg_pixel_format is expected). Possible values are:
23 == SG_PIXELFORMAT_RGBA8
27 == SG_PIXELFORMAT_BGRA8
41 == SG_PIXELFORMAT_DEPTH
42 == SG_PIXELFORMAT_DEPTH_STENCIL
28 == SG_PIXELFORMAT_BGRA8
42 == SG_PIXELFORMAT_DEPTH
43 == SG_PIXELFORMAT_DEPTH_STENCIL
int sapp_sample_count(void)
Return the MSAA sample count of the default framebuffer.
Expand Down Expand Up @@ -2638,9 +2638,9 @@ typedef struct {
#define _SAPP_FALLBACK_DEFAULT_WINDOW_HEIGHT (480)
/* NOTE: the pixel format values *must* be compatible with sg_pixel_format */
#define _SAPP_PIXELFORMAT_RGBA8 (23)
#define _SAPP_PIXELFORMAT_BGRA8 (27)
#define _SAPP_PIXELFORMAT_DEPTH (41)
#define _SAPP_PIXELFORMAT_DEPTH_STENCIL (42)
#define _SAPP_PIXELFORMAT_BGRA8 (28)
#define _SAPP_PIXELFORMAT_DEPTH (42)
#define _SAPP_PIXELFORMAT_DEPTH_STENCIL (43)

#if defined(_SAPP_MACOS) || defined(_SAPP_IOS)
// this is ARC compatible
Expand Down
11 changes: 11 additions & 0 deletions sokol_gfx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1143,6 +1143,7 @@ typedef enum sg_pixel_format {
SG_PIXELFORMAT_RG16SI,
SG_PIXELFORMAT_RG16F,
SG_PIXELFORMAT_RGBA8,
SG_PIXELFORMAT_SRGB8A8,
SG_PIXELFORMAT_RGBA8SN,
SG_PIXELFORMAT_RGBA8UI,
SG_PIXELFORMAT_RGBA8SI,
Expand Down Expand Up @@ -3157,6 +3158,7 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_
#define GL_NEAREST_MIPMAP_LINEAR 0x2702
#define GL_RGB10_A2 0x8059
#define GL_RGBA8 0x8058
#define GL_SRGB8_ALPHA8 0x8C43
#define GL_COLOR_ATTACHMENT1 0x8CE1
#define GL_RGBA4 0x8056
#define GL_RGB8 0x8051
Expand Down Expand Up @@ -4841,6 +4843,7 @@ _SOKOL_PRIVATE int _sg_pixelformat_bytesize(sg_pixel_format fmt) {
case SG_PIXELFORMAT_RG16SI:
case SG_PIXELFORMAT_RG16F:
case SG_PIXELFORMAT_RGBA8:
case SG_PIXELFORMAT_SRGB8A8:
case SG_PIXELFORMAT_RGBA8SN:
case SG_PIXELFORMAT_RGBA8UI:
case SG_PIXELFORMAT_RGBA8SI:
Expand Down Expand Up @@ -5671,6 +5674,7 @@ _SOKOL_PRIVATE GLenum _sg_gl_teximage_type(sg_pixel_format fmt) {
case SG_PIXELFORMAT_RG8:
case SG_PIXELFORMAT_RG8UI:
case SG_PIXELFORMAT_RGBA8:
case SG_PIXELFORMAT_SRGB8A8:
case SG_PIXELFORMAT_RGBA8UI:
case SG_PIXELFORMAT_BGRA8:
return GL_UNSIGNED_BYTE;
Expand Down Expand Up @@ -5770,6 +5774,7 @@ _SOKOL_PRIVATE GLenum _sg_gl_teximage_format(sg_pixel_format fmt) {
return GL_RG_INTEGER;
#endif
case SG_PIXELFORMAT_RGBA8:
case SG_PIXELFORMAT_SRGB8A8:
case SG_PIXELFORMAT_RGBA8SN:
case SG_PIXELFORMAT_RGBA16:
case SG_PIXELFORMAT_RGBA16SN:
Expand Down Expand Up @@ -5871,6 +5876,7 @@ _SOKOL_PRIVATE GLenum _sg_gl_teximage_internal_format(sg_pixel_format fmt) {
case SG_PIXELFORMAT_RG16SI: return GL_RG16I;
case SG_PIXELFORMAT_RG16F: return GL_RG16F;
case SG_PIXELFORMAT_RGBA8: return GL_RGBA8;
case SG_PIXELFORMAT_SRGB8A8: return GL_SRGB8_ALPHA8;
case SG_PIXELFORMAT_RGBA8SN: return GL_RGBA8_SNORM;
case SG_PIXELFORMAT_RGBA8UI: return GL_RGBA8UI;
case SG_PIXELFORMAT_RGBA8SI: return GL_RGBA8I;
Expand Down Expand Up @@ -5977,6 +5983,7 @@ _SOKOL_PRIVATE void _sg_gl_init_pixelformats(bool has_bgra) {
_sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA8]);
#if !defined(SOKOL_GLES2)
if (!_sg.gl.gles2) {
_sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_SRGB8A8]);
_sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA8SN]);
_sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8UI]);
_sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8SI]);
Expand Down Expand Up @@ -8597,6 +8604,7 @@ _SOKOL_PRIVATE DXGI_FORMAT _sg_d3d11_pixel_format(sg_pixel_format fmt) {
case SG_PIXELFORMAT_RG16SI: return DXGI_FORMAT_R16G16_SINT;
case SG_PIXELFORMAT_RG16F: return DXGI_FORMAT_R16G16_FLOAT;
case SG_PIXELFORMAT_RGBA8: return DXGI_FORMAT_R8G8B8A8_UNORM;
case SG_PIXELFORMAT_SRGB8A8: return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
case SG_PIXELFORMAT_RGBA8SN: return DXGI_FORMAT_R8G8B8A8_SNORM;
case SG_PIXELFORMAT_RGBA8UI: return DXGI_FORMAT_R8G8B8A8_UINT;
case SG_PIXELFORMAT_RGBA8SI: return DXGI_FORMAT_R8G8B8A8_SINT;
Expand Down Expand Up @@ -10158,6 +10166,7 @@ _SOKOL_PRIVATE MTLPixelFormat _sg_mtl_pixel_format(sg_pixel_format fmt) {
case SG_PIXELFORMAT_RG16SI: return MTLPixelFormatRG16Sint;
case SG_PIXELFORMAT_RG16F: return MTLPixelFormatRG16Float;
case SG_PIXELFORMAT_RGBA8: return MTLPixelFormatRGBA8Unorm;
case SG_PIXELFORMAT_SRGB8A8: return MTLPixelFormatRGBA8Unorm_sRGB;
case SG_PIXELFORMAT_RGBA8SN: return MTLPixelFormatRGBA8Snorm;
case SG_PIXELFORMAT_RGBA8UI: return MTLPixelFormatRGBA8Uint;
case SG_PIXELFORMAT_RGBA8SI: return MTLPixelFormatRGBA8Sint;
Expand Down Expand Up @@ -10653,6 +10662,7 @@ _SOKOL_PRIVATE void _sg_mtl_init_caps(void) {
_sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16SI]);
_sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16F]);
_sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA8]);
_sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_SRGB8A8]);
_sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA8SN]);
_sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8UI]);
_sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA8SI]);
Expand Down Expand Up @@ -12005,6 +12015,7 @@ _SOKOL_PRIVATE WGPUTextureFormat _sg_wgpu_textureformat(sg_pixel_format p) {
case SG_PIXELFORMAT_RG16SN:
case SG_PIXELFORMAT_RGBA16:
case SG_PIXELFORMAT_RGBA16SN:
case SG_PIXELFORMAT_SRGB8A8:
case SG_PIXELFORMAT_RGB9E5:
case SG_PIXELFORMAT_PVRTC_RGB_2BPP:
case SG_PIXELFORMAT_PVRTC_RGB_4BPP:
Expand Down
1 change: 1 addition & 0 deletions util/sokol_gfx_imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,7 @@ _SOKOL_PRIVATE const char* _sg_imgui_pixelformat_string(sg_pixel_format fmt) {
case SG_PIXELFORMAT_RG16SI: return "SG_PIXELFORMAT_RG16SI";
case SG_PIXELFORMAT_RG16F: return "SG_PIXELFORMAT_RG16F";
case SG_PIXELFORMAT_RGBA8: return "SG_PIXELFORMAT_RGBA8";
case SG_PIXELFORMAT_SRGB8A8: return "SG_PIXELFORMAT_SRGB8A8";
case SG_PIXELFORMAT_RGBA8SN: return "SG_PIXELFORMAT_RGBA8SN";
case SG_PIXELFORMAT_RGBA8UI: return "SG_PIXELFORMAT_RGBA8UI";
case SG_PIXELFORMAT_RGBA8SI: return "SG_PIXELFORMAT_RGBA8SI";
Expand Down

0 comments on commit 082d2c6

Please sign in to comment.