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

basic sRGB sampling with SG_PIXELFORMAT_SRGB8A8 format #758

Merged
merged 1 commit into from
Jan 26, 2023
Merged
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
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 @@ -1141,6 +1141,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 @@ -3153,6 +3154,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 @@ -4833,6 +4835,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 @@ -5657,6 +5660,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 @@ -5756,6 +5760,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 @@ -5857,6 +5862,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 @@ -5963,6 +5969,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 @@ -8581,6 +8588,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 @@ -10138,6 +10146,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 @@ -10633,6 +10642,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 @@ -11965,6 +11975,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