diff options
| -rw-r--r-- | CHANGELOG.md | 40 | ||||
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | sokol_app.h | 92 | ||||
| -rw-r--r-- | sokol_gfx.h | 1492 | ||||
| -rw-r--r-- | sokol_glue.h | 1 | ||||
| -rw-r--r-- | tests/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | tests/CMakePresets.json | 28 | ||||
| -rw-r--r-- | tests/functional/force_dummy_backend.h | 4 | ||||
| -rwxr-xr-x | tests/test_emscripten.sh | 2 | ||||
| -rw-r--r-- | util/sokol_debugtext.h | 91 | ||||
| -rw-r--r-- | util/sokol_fontstash.h | 107 | ||||
| -rw-r--r-- | util/sokol_gfx_imgui.h | 6 | ||||
| -rw-r--r-- | util/sokol_gl.h | 105 | ||||
| -rw-r--r-- | util/sokol_imgui.h | 88 | ||||
| -rw-r--r-- | util/sokol_nuklear.h | 88 | ||||
| -rw-r--r-- | util/sokol_spine.h | 108 |
16 files changed, 852 insertions, 1409 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe7cced..5d33af58 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,45 @@ ## Updates +- **29-Apr-2023**: GLES2/WebGL1 support has been removed from the sokol headers (now that + all browsers support WebGL2, and WebGPU is around the corner I feel like it's finally + time to ditch GLES2. + + This is a breaking API change in sokol_gfx.h and sokol_app.h. + + Common changes across all headers: + - (breaking change) the `SOKOL_GLES2` config macro is no longer accepted and will cause a compile error + (use `SOKOL_GLES3` instead) + - (breaking change) on Emscripten use the linker option `-s USE_WEBGL2=1` + - any embedded GLES shaders have been updated from glsl100 to glsl300es (but glsl100 shaders + still work fine with the GLES3 backend) + + Changes in sokol_gfx.h: + - (breaking change) the following `sg_feature` members have been removed (because those features + are no longer optional, but guaranteed across all backends): + - `sg_feature.instancing` + - `sg_feature.multiple_render_targets` + - `sg_feature.msaa_render_targets` + - `imagetype_3d` + - `imagetype_array` + - (breaking change) the struct `sg_gl_context_desc` and its embedded instance `sg_desc.gl` have been removed + - `sg_image` objects with `SG_PIXELFORMAT_DEPTH` or `SG_PIXELFORMAT_DEPTH_STENCIL` with + a `sample_count == 1` are now regular textures in the GL backend (this is not true + for MSAA depth textures unfortunately, those are still GL render buffer objects) + - in the GL backend, `SG_PIXELFORMAT_DEPTH` now resolves to `GL_DEPTH_COMPONENT32F` (same + as in the other backends), previously it was `GL_DEPTH_COMPONENT16` + - in `sg_begin_pass()`, the GL backend now only uses the new `glClearBuffer*` functions, the + old GLES2 clear functions have been removed + - in `sg_end_pass()`, the GLES3 backend now invalidates MSAA render buffers after they have + been resolved (via `glInvalidateFramebuffer`) - more control over this will come soon-ish + when this ticket is implemented: https://github.com/floooh/sokol/issues/816 + - the instanced rendering functions are no longer wrapped in C macros in the GL backend + + Changes in sokol_app.h: + - (breaking) the config item `sapp_desc.gl_force_gles2` has been removed + - (breaking) the function `sapp_gles2()` has been removed + - any fallback logic from GLES3 to GLES2 has been removed (in the Emscripten, Android and + iOS backends) + - **20-Feb-2023**: sokol_gfx.h has a new set of functions to get a 'best-effort' desc struct with the creation parameters of a specific resource object: @@ -4,8 +4,7 @@ Simple [STB-style](https://github.com/nothings/stb/blob/master/docs/stb_howto.txt) cross-platform libraries for C and C++, written in C. -[**See what's new**](https://github.com/floooh/sokol/blob/master/CHANGELOG.md) (**20-Feb-2023** a new set of functions in sokol_gfx.h -to get a pre-filled 'desc struct' for a resource) +[**See what's new**](https://github.com/floooh/sokol/blob/master/CHANGELOG.md) (**29-Apr-2023** breaking change: GLES2/WebGL1 support has been removed!) [](/../../actions/workflows/main.yml) [](/../../actions/workflows/gen_bindings.yml) [](https://github.com/floooh/sokol-zig/actions/workflows/main.yml) [](https://github.com/floooh/sokol-nim/actions/workflows/main.yml) [](https://github.com/floooh/sokol-odin/actions/workflows/main.yml)[](https://github.com/floooh/sokol-rust/actions/workflows/main.yml) @@ -87,7 +86,7 @@ A blog post with more background info: [A Tour of sokol_gfx.h](http://floooh.git # sokol_gfx.h: -- simple, modern wrapper around GLES2/WebGL, GLES3/WebGL2, GL3.3, D3D11 and Metal +- simple, modern wrapper around GLES3/WebGL2, GL3.3, D3D11 and Metal - buffers, images, shaders, pipeline-state-objects and render-passes - does *not* handle window creation or 3D API context initialization - does *not* provide shader dialect cross-translation (**BUT** there's now an 'official' shader-cross-compiler solution which @@ -200,7 +199,7 @@ A minimal cross-platform application-wrapper library: - 3D context initialization - event-based keyboard, mouse and touch input - supported platforms: Win32, MacOS, Linux (X11), iOS, WASM, Android, UWP -- supported 3D-APIs: GL3.3 (GLX/WGL), Metal, D3D11, GLES2/WebGL, GLES3/WebGL2 +- supported 3D-APIs: GL3.3 (GLX/WGL), Metal, D3D11, GLES3/WebGL2 A simple clear-loop sample using sokol_app.h and sokol_gfx.h (does not include separate sokol.c/.m implementation file which is necessary diff --git a/sokol_app.h b/sokol_app.h index 4b3d62cc..602df0df 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -19,7 +19,6 @@ project): #define SOKOL_GLCORE33 - #define SOKOL_GLES2 #define SOKOL_GLES3 #define SOKOL_D3D11 #define SOKOL_METAL @@ -88,14 +87,13 @@ - makes the rendered frame visible - provides keyboard-, mouse- and low-level touch-events - platforms: MacOS, iOS, HTML5, Win32, Linux/RaspberryPi, Android - - 3D-APIs: Metal, D3D11, GL3.2, GLES2, GLES3, WebGL, WebGL2 + - 3D-APIs: Metal, D3D11, GL3.2, GLES3, WebGL, WebGL2 FEATURE/PLATFORM MATRIX ======================= | Windows | macOS | Linux | iOS | Android | HTML5 --------------------+---------+-------+-------+-------+---------+-------- gl 3.x | YES | YES | YES | --- | --- | --- - gles2/webgl | --- | --- | YES(2)| YES | YES | YES gles3/webgl2 | --- | --- | YES(2)| YES | YES | YES metal | --- | YES | --- | YES | --- | --- d3d11 | YES | --- | --- | --- | --- | --- @@ -267,11 +265,6 @@ int sapp_sample_count(void) Return the MSAA sample count of the default framebuffer. - bool sapp_gles2(void) - Returns true if a GLES2 or WebGL context has been created. This - is useful when a GLES3/WebGL2 context was requested but is not - available so that sokol_app.h had to fallback to GLES2/WebGL. - const void* sapp_metal_get_device(void) const void* sapp_metal_get_renderpass_descriptor(void) const void* sapp_metal_get_drawable(void) @@ -1641,7 +1634,6 @@ typedef struct sapp_desc { sapp_logger logger; // logging callback override (default: NO LOGGING!) /* backend-specific options */ - bool gl_force_gles2; // if true, setup GLES2/WebGL even if GLES3/WebGL2 is available int gl_major_version; // override GL major and minor version (the default GL version is 3.2) int gl_minor_version; bool win32_console_utf8; // if true, set the output console codepage to UTF-8 @@ -1780,9 +1772,6 @@ SOKOL_APP_API_DECL const void* sapp_egl_get_display(void); /* EGL: get EGLContext object */ SOKOL_APP_API_DECL const void* sapp_egl_get_context(void); -/* GL: return true when GLES2 fallback is active (to detect fallback from GLES3) */ -SOKOL_APP_API_DECL bool sapp_gles2(void); - /* HTML5: enable or disable the hardwired "Leave Site?" dialog box */ SOKOL_APP_API_DECL void sapp_html5_ask_leave_site(bool ask); /* HTML5: get byte size of a dropped file */ @@ -1889,8 +1878,8 @@ inline void sapp_run(const sapp_desc& desc) { return sapp_run(&desc); } #elif defined(__EMSCRIPTEN__) /* emscripten (asm.js or wasm) */ #define _SAPP_EMSCRIPTEN (1) - #if !defined(SOKOL_GLES3) && !defined(SOKOL_GLES2) && !defined(SOKOL_WGPU) - #error("sokol_app.h: unknown 3D API selected for emscripten, must be SOKOL_GLES3, SOKOL_GLES2 or SOKOL_WGPU") + #if !defined(SOKOL_GLES3) && !defined(SOKOL_WGPU) + #error("sokol_app.h: unknown 3D API selected for emscripten, must be SOKOL_GLES3 or SOKOL_WGPU") #endif #elif defined(_WIN32) /* Windows (D3D11 or GL) */ @@ -1901,8 +1890,8 @@ inline void sapp_run(const sapp_desc& desc) { return sapp_run(&desc); } #elif defined(__ANDROID__) /* Android */ #define _SAPP_ANDROID (1) - #if !defined(SOKOL_GLES3) && !defined(SOKOL_GLES2) - #error("sokol_app.h: unknown 3D API selected for Android, must be SOKOL_GLES3 or SOKOL_GLES2") + #if !defined(SOKOL_GLES3) + #error("sokol_app.h: unknown 3D API selected for Android, must be SOKOL_GLES3") #endif #if defined(SOKOL_NO_ENTRY) #error("sokol_app.h: SOKOL_NO_ENTRY is not supported on Android") @@ -1914,8 +1903,8 @@ inline void sapp_run(const sapp_desc& desc) { return sapp_run(&desc); } #if !defined(SOKOL_FORCE_EGL) #define _SAPP_GLX (1) #endif - #elif !defined(SOKOL_GLES3) && !defined(SOKOL_GLES2) - #error("sokol_app.h: unknown 3D API selected for Linux, must be SOKOL_GLCORE33, SOKOL_GLES3 or SOKOL_GLES2") + #elif !defined(SOKOL_GLES3) + #error("sokol_app.h: unknown 3D API selected for Linux, must be SOKOL_GLCORE33, SOKOL_GLES3") #endif #else #error "sokol_app.h: Unknown platform" @@ -2746,7 +2735,6 @@ typedef struct { sapp_desc desc; bool valid; bool fullscreen; - bool gles2_fallback; bool first_frame; bool init_called; bool cleanup_called; @@ -4430,17 +4418,7 @@ _SOKOL_PRIVATE void _sapp_ios_show_keyboard(bool shown) { _sapp.ios.view_ctrl.view = _sapp.ios.view; _sapp.ios.window.rootViewController = _sapp.ios.view_ctrl; #else - if (_sapp.desc.gl_force_gles2) { - _sapp.ios.eagl_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - _sapp.gles2_fallback = true; - } - else { - _sapp.ios.eagl_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; - if (_sapp.ios.eagl_ctx == nil) { - _sapp.ios.eagl_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES2]; - _sapp.gles2_fallback = true; - } - } + _sapp.ios.eagl_ctx = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES3]; _sapp.ios.view = [[_sapp_ios_view alloc] initWithFrame:screen_rect]; _sapp.ios.view.drawableColorFormat = GLKViewDrawableColorFormatRGBA8888; _sapp.ios.view.drawableDepthFormat = GLKViewDrawableDepthFormat24; @@ -5542,7 +5520,7 @@ _SOKOL_PRIVATE EM_BOOL _sapp_emsc_blur_cb(int emsc_type, const EmscriptenFocusEv return true; } -#if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) +#if defined(SOKOL_GLES3) _SOKOL_PRIVATE EM_BOOL _sapp_emsc_webgl_context_cb(int emsc_type, const void* reserved, void* user_data) { _SOKOL_UNUSED(reserved); _SOKOL_UNUSED(user_data); @@ -5569,21 +5547,9 @@ _SOKOL_PRIVATE void _sapp_emsc_webgl_init(void) { attrs.premultipliedAlpha = _sapp.desc.html5_premultiplied_alpha; attrs.preserveDrawingBuffer = _sapp.desc.html5_preserve_drawing_buffer; attrs.enableExtensionsByDefault = true; - #if defined(SOKOL_GLES3) - if (_sapp.desc.gl_force_gles2) { - attrs.majorVersion = 1; - _sapp.gles2_fallback = true; - } - else { - attrs.majorVersion = 2; - } - #endif + attrs.majorVersion = 2; EMSCRIPTEN_WEBGL_CONTEXT_HANDLE ctx = emscripten_webgl_create_context(_sapp.html5_canvas_selector, &attrs); - if (!ctx) { - attrs.majorVersion = 1; - ctx = emscripten_webgl_create_context(_sapp.html5_canvas_selector, &attrs); - _sapp.gles2_fallback = true; - } + // FIXME: error message? emscripten_webgl_make_context_current(ctx); /* some WebGL extension are not enabled automatically by emscripten */ @@ -5726,7 +5692,7 @@ _SOKOL_PRIVATE void _sapp_emsc_register_eventhandlers(void) { if (_sapp.drop.enabled) { sapp_js_add_dragndrop_listeners(&_sapp.html5_canvas_selector[1]); } - #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + #if defined(SOKOL_GLES3) emscripten_set_webglcontextlost_callback(_sapp.html5_canvas_selector, 0, true, _sapp_emsc_webgl_context_cb); emscripten_set_webglcontextrestored_callback(_sapp.html5_canvas_selector, 0, true, _sapp_emsc_webgl_context_cb); #endif @@ -5757,7 +5723,7 @@ _SOKOL_PRIVATE void _sapp_emsc_unregister_eventhandlers() { if (_sapp.drop.enabled) { sapp_js_remove_dragndrop_listeners(&_sapp.html5_canvas_selector[1]); } - #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + #if defined(SOKOL_GLES3) emscripten_set_webglcontextlost_callback(_sapp.html5_canvas_selector, 0, true, 0); emscripten_set_webglcontextrestored_callback(_sapp.html5_canvas_selector, 0, true, 0); #endif @@ -5830,7 +5796,7 @@ _SOKOL_PRIVATE void _sapp_emsc_run(const sapp_desc* desc) { _sapp.framebuffer_width = (int)roundf(w * _sapp.dpi_scale); _sapp.framebuffer_height = (int)roundf(h * _sapp.dpi_scale); emscripten_set_canvas_element_size(_sapp.html5_canvas_selector, _sapp.framebuffer_width, _sapp.framebuffer_height); - #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + #if defined(SOKOL_GLES3) _sapp_emsc_webgl_init(); #elif defined(SOKOL_WGPU) sapp_js_wgpu_init(); @@ -7853,16 +7819,10 @@ _SOKOL_PRIVATE bool _sapp_android_init_egl(void) { if (eglInitialize(display, NULL, NULL) == EGL_FALSE) { return false; } - _sapp.gles2_fallback = _sapp.desc.gl_force_gles2; - EGLint alpha_size = _sapp.desc.alpha ? 8 : 0; const EGLint cfg_attributes[] = { EGL_SURFACE_TYPE, EGL_WINDOW_BIT, - #if defined(SOKOL_GLES3) - EGL_RENDERABLE_TYPE, _sapp.desc.gl_force_gles2?EGL_OPENGL_ES2_BIT:EGL_OPENGL_ES3_BIT, - #else - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, - #endif + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, EGL_BLUE_SIZE, 8, @@ -7899,11 +7859,7 @@ _SOKOL_PRIVATE bool _sapp_android_init_egl(void) { } EGLint ctx_attributes[] = { - #if defined(SOKOL_GLES3) - EGL_CONTEXT_CLIENT_VERSION, _sapp.desc.gl_force_gles2 ? 2 : 3, - #else - EGL_CONTEXT_CLIENT_VERSION, 2, - #endif + EGL_CONTEXT_CLIENT_VERSION, 3, EGL_NONE, }; EGLContext context = eglCreateContext(display, config, EGL_NO_CONTEXT, ctx_attributes); @@ -10758,9 +10714,7 @@ _SOKOL_PRIVATE void _sapp_egl_init(void) { #if defined(SOKOL_GLCORE33) EGL_RENDERABLE_TYPE, EGL_OPENGL_BIT, #elif defined(SOKOL_GLES3) - EGL_RENDERABLE_TYPE, _sapp.desc.gl_force_gles2 ? EGL_OPENGL_ES2_BIT : EGL_OPENGL_ES3_BIT, - #else - EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT, + EGL_RENDERABLE_TYPE, EGL_OPENGL_ES3_BIT, #endif EGL_RED_SIZE, 8, EGL_GREEN_SIZE, 8, @@ -10825,9 +10779,7 @@ _SOKOL_PRIVATE void _sapp_egl_init(void) { EGL_CONTEXT_MINOR_VERSION, _sapp.desc.gl_minor_version, EGL_CONTEXT_OPENGL_PROFILE_MASK, EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT, #elif defined(SOKOL_GLES3) - EGL_CONTEXT_CLIENT_VERSION, _sapp.desc.gl_force_gles2 ? 2 : 3, - #else - EGL_CONTEXT_CLIENT_VERSION, 2, + EGL_CONTEXT_CLIENT_VERSION, 3, #endif EGL_NONE, }; @@ -10842,10 +10794,6 @@ _SOKOL_PRIVATE void _sapp_egl_init(void) { } eglSwapInterval(_sapp.egl.display, _sapp.swap_interval); - -#if defined(SOKOL_GLES3) - _sapp.gles2_fallback = _sapp.desc.gl_force_gles2; -#endif } _SOKOL_PRIVATE void _sapp_egl_destroy(void) { @@ -11091,10 +11039,6 @@ SOKOL_APP_IMPL const void* sapp_egl_get_context(void) { #endif } -SOKOL_API_IMPL bool sapp_gles2(void) { - return _sapp.gles2_fallback; -} - SOKOL_API_IMPL void sapp_show_keyboard(bool show) { #if defined(_SAPP_IOS) _sapp_ios_show_keyboard(show); diff --git a/sokol_gfx.h b/sokol_gfx.h index ecd79d9b..f9daaab0 100644 --- a/sokol_gfx.h +++ b/sokol_gfx.h @@ -18,7 +18,6 @@ In the same place define one of the following to select the rendering backend: #define SOKOL_GLCORE33 - #define SOKOL_GLES2 #define SOKOL_GLES3 #define SOKOL_D3D11 #define SOKOL_METAL @@ -346,8 +345,7 @@ to sokol_gfx.h internals, and may change more often than other public API functions and structs. - --- you can ask at runtime what backend sokol_gfx.h has been compiled - for, or whether the GLES3 backend had to fall back to GLES2 with: + --- you can ask at runtime what backend sokol_gfx.h has been compiled for: sg_backend sg_query_backend(void) @@ -509,7 +507,7 @@ .vs.uniform_blocks[0] = { ... }, - // one texture on the fragment-shader-stage, GLES2/WebGL needs name and image type + // one texture on the fragment-shader-stage (name is optional) .fs.images[0] = { .name="tex", .type=SG_IMAGETYPE_ARRAY } ... }; @@ -524,8 +522,8 @@ ... }; - --- when creating a shader object, GLES2/WebGL need to know the vertex - attribute names as used in the vertex shader: + --- when creating a shader object, vertex attribute names may be provided + for the GL backends: sg_shader_desc desc = { .attrs = { @@ -687,13 +685,7 @@ - SG_VERTEXFORMAT_SHORT2 - SG_VERTEXFORMAT_SHORT4 - - WebGL/GLES2 cannot use integer vertex shader inputs (int or ivecn) or the following: - - - SG_VERTEXFORMAT_UINT10_N2 - - SG_VERTEXFORMAT_HALF2, SG_VERTEXFORMAT_HALF4 - (commonly supported extension: OES_vertex_half_float) - - So for a vertex input layout which works on all platforms, only use the following + For a vertex input layout which works on all platforms, only use the following vertex formats, and if needed "expand" the normalized vertex shader inputs in the vertex shader by multiplying with 127.0, 255.0, 32767.0 or 65535.0: @@ -708,7 +700,9 @@ - SG_VERTEXFORMAT_USHORT2N - SG_VERTEXFORMAT_SHORT4N, - SG_VERTEXFORMAT_USHORT4N - + - SG_VERTEXFORMAT_UINT10_N2 + - SG_VERTEXFORMAT_HALF2 + - SG_VERTEXFORMAT_HALF4 MEMORY ALLOCATION OVERRIDE ========================== @@ -1090,7 +1084,7 @@ enum { SG_MAX_SHADERSTAGE_IMAGES = 12, SG_MAX_SHADERSTAGE_UBS = 4, SG_MAX_UB_MEMBERS = 16, - SG_MAX_VERTEX_ATTRIBUTES = 16, /* NOTE: actual max vertex attrs can be less on GLES2, see sg_limits! */ + SG_MAX_VERTEX_ATTRIBUTES = 16, SG_MAX_MIPMAPS = 16, SG_MAX_TEXTUREARRAY_LAYERS = 128 }; @@ -1107,14 +1101,9 @@ typedef struct sg_color { float r, g, b, a; } sg_color; The active 3D-API backend, use the function sg_query_backend() to get the currently active backend. - - NOTE that SG_BACKEND_GLES2 will be returned if sokol-gfx was - compiled with SOKOL_GLES3, but the runtime platform doesn't support - GLES3/WebGL2 and sokol-gfx had to fallback to GLES2/WebGL. */ typedef enum sg_backend { SG_BACKEND_GLCORE33, - SG_BACKEND_GLES2, SG_BACKEND_GLES3, SG_BACKEND_D3D11, SG_BACKEND_METAL_IOS, @@ -1128,10 +1117,9 @@ typedef enum sg_backend { sg_pixel_format sokol_gfx.h basically uses the same pixel formats as WebGPU, since these - are supported on most newer GPUs. GLES2 and WebGL only supports a much - smaller subset of actually available pixel formats. Call - sg_query_pixelformat() to check at runtime if a pixel format supports the - desired features. + are supported on most newer GPUs. smaller subset of actually available + pixel formCall sg_query_pixelformat() to check at runtime if a pixel format + supports the desired features. A pixelformat name consist of three parts: @@ -1159,11 +1147,6 @@ typedef enum sg_backend { pixelformat for render targets - depth: the pixelformat can be used for depth-stencil attachments - When targeting GLES2/WebGL, the only safe formats to use - as texture are SG_PIXELFORMAT_R8 and SG_PIXELFORMAT_RGBA8. For rendering - in GLES2/WebGL, only SG_PIXELFORMAT_RGBA8 is safe. All other formats - must be checked via sg_query_pixelformats(). - The default pixel format for texture images is SG_PIXELFORMAT_RGBA8. The default pixel format for render target images is platform-dependent: @@ -1274,12 +1257,7 @@ typedef struct sg_pixelformat_info { returned by sg_query_features() */ typedef struct sg_features { - bool instancing; // hardware instancing supported bool origin_top_left; // framebuffer and texture origin is in top left corner - bool multiple_render_targets; // offscreen render passes can have multiple render targets attached - bool msaa_render_targets; // offscreen render passes support MSAA antialiasing - bool imagetype_3d; // creation of SG_IMAGETYPE_3D images is supported - bool imagetype_array; // creation of SG_IMAGETYPE_ARRAY images is supported bool image_clamp_to_border; // border color and clamp-to-border UV-wrap mode is supported bool mrt_independent_blend_state; // multiple-render-target rendering can use per-render-target blend state bool mrt_independent_write_mask; // multiple-render-target rendering can use per-render-target color write masks @@ -1297,7 +1275,7 @@ typedef struct sg_limits { int max_image_size_3d; // max width/height/depth of SG_IMAGETYPE_3D images int max_image_size_array; // max width/height of SG_IMAGETYPE_ARRAY images int max_image_array_layers; // max number of layers in SG_IMAGETYPE_ARRAY images - int max_vertex_attrs; // <= SG_MAX_VERTEX_ATTRIBUTES or less (on some GLES2 impls) + int max_vertex_attrs; // max number of vertex attributes, clamped to SG_MAX_VERTEX_ATTRIBUTES int gl_max_vertex_uniform_vectors; // <= GL_MAX_VERTEX_UNIFORM_VECTORS (only on GL backends) int gl_max_combined_texture_image_units; // <= GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS (only on GL backends) } sg_limits; @@ -1411,11 +1389,9 @@ typedef enum sg_index_type { sg_image_type Indicates the basic type of an image object (2D-texture, cubemap, - 3D-texture or 2D-array-texture). 3D- and array-textures are not supported - on the GLES2/WebGL backend (use sg_query_features().imagetype_3d and - sg_query_features().imagetype_array to check for support). The image type - is used in the sg_image_desc.type member when creating an image, and - in sg_shader_image_desc when describing a shader's texture sampler binding. + 3D-texture or 2D-array-texture). Used in the sg_image_desc.type member when + creating an image, and in sg_shader_image_desc when describing a shader's + texture sampler binding. The default image type when creating an image is SG_IMAGETYPE_2D. */ @@ -1546,7 +1522,7 @@ typedef enum sg_filter { Platforms which do not support clamp-to-border: - - GLES2/3 and WebGL/WebGL2 + - GLES3 and WebGL2 - Metal on iOS */ typedef enum sg_wrap { @@ -2108,11 +2084,6 @@ typedef struct sg_image_data { NOTE: - SG_IMAGETYPE_ARRAY and SG_IMAGETYPE_3D are not supported on WebGL/GLES2, - use sg_query_features().imagetype_array and - sg_query_features().imagetype_3d at runtime to check if array- and - 3D-textures are supported. - Images with usage SG_USAGE_IMMUTABLE must be fully initialized by providing a valid .data member which points to initialization data. @@ -2180,7 +2151,7 @@ typedef struct sg_image_desc { programs, used as input to the sg_make_shader() function: - reflection information for vertex attributes (vertex shader inputs): - - vertex attribute name (required for GLES2, optional for GLES3 and GL) + - vertex attribute name (only optionally used by GLES3 and GL) - a semantic name and index (required for D3D11) - for each shader-stage (vertex and fragment): - the shader source or bytecode @@ -2197,7 +2168,7 @@ typedef struct sg_image_desc { - reflection info for the texture images used by the shader stage: - the image type (SG_IMAGETYPE_xxx) - the sampler type (SG_SAMPLERTYPE_xxx, default is SG_SAMPLERTYPE_FLOAT) - - the name of the texture sampler (required for GLES2, optional everywhere else) + - the name of the texture sampler (optional) For all GL backends, shader source-code must be provided. For D3D11 and Metal, either shader source-code or byte-code can be provided. @@ -2209,7 +2180,7 @@ typedef struct sg_image_desc { vertex shader stage and "ps_4_0" for the pixel shader stage. */ typedef struct sg_shader_attr_desc { - const char* name; // GLSL vertex attribute name (only strictly required for GLES2) + const char* name; // GLSL vertex attribute name (optional) const char* sem_name; // HLSL semantic name int sem_index; // HLSL semantic index } sg_shader_attr_desc; @@ -2691,14 +2662,12 @@ typedef struct sg_pass_info { _SG_LOGITEM_XMACRO(VALIDATE_SHADERDESC_UB_STD140_ARRAY_TYPE, "uniform arrays only allowed for FLOAT4, INT4, MAT4 in std140 layout") \ _SG_LOGITEM_XMACRO(VALIDATE_SHADERDESC_NO_CONT_IMGS, "shader images must occupy continuous slots") \ _SG_LOGITEM_XMACRO(VALIDATE_SHADERDESC_IMG_NAME, "GL backend requires uniform block member names") \ - _SG_LOGITEM_XMACRO(VALIDATE_SHADERDESC_ATTR_NAMES, "GLES2 backend requires vertex attribute names") \ _SG_LOGITEM_XMACRO(VALIDATE_SHADERDESC_ATTR_SEMANTICS, "D3D11 backend requires vertex attribute semantics") \ _SG_LOGITEM_XMACRO(VALIDATE_SHADERDESC_ATTR_STRING_TOO_LONG, "vertex attribute name/semantic string too long (max len 16)") \ _SG_LOGITEM_XMACRO(VALIDATE_PIPELINEDESC_CANARY, "sg_pipeline_desc not initialized") \ _SG_LOGITEM_XMACRO(VALIDATE_PIPELINEDESC_SHADER, "sg_pipeline_desc.shader missing or invalid") \ _SG_LOGITEM_XMACRO(VALIDATE_PIPELINEDESC_NO_ATTRS, "sg_pipeline_desc.layout.attrs is empty or not continuous") \ _SG_LOGITEM_XMACRO(VALIDATE_PIPELINEDESC_LAYOUT_STRIDE4, "sg_pipeline_desc.layout.buffers[].stride must be multiple of 4") \ - _SG_LOGITEM_XMACRO(VALIDATE_PIPELINEDESC_ATTR_NAME, "GLES2/WebGL missing vertex attribute name in shader") \ _SG_LOGITEM_XMACRO(VALIDATE_PIPELINEDESC_ATTR_SEMANTICS, "D3D11 missing vertex attribute semantics in shader") \ _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_CANARY, "sg_pass_desc not initialized") \ _SG_LOGITEM_XMACRO(VALIDATE_PASSDESC_NO_COLOR_ATTS, "sg_pass_desc.color_attachments[0] must be valid") \ @@ -2800,12 +2769,6 @@ typedef enum sg_log_item { .context.depth_format SG_PIXELFORMAT_DEPTH_STENCIL .context.sample_count 1 - GL specific: - .context.gl.force_gles2 - if this is true the GL backend will act in "GLES2 fallback mode" even - when compiled with SOKOL_GLES3, this is useful to fall back - to traditional WebGL if a browser doesn't support a WebGL2 context - Metal specific: (NOTE: All Objective-C object references are transferred through a bridged (const void*) to sokol_gfx, which will use a unretained @@ -2879,10 +2842,6 @@ typedef enum sg_log_item { a completely initialized sg_context_desc struct with information provided by sokol_app.h. */ -typedef struct sg_gl_context_desc { - bool force_gles2; -} sg_gl_context_desc; - typedef struct sg_metal_context_desc { const void* device; const void* (*renderpass_descriptor_cb)(void); @@ -2917,7 +2876,6 @@ typedef struct sg_context_desc { sg_pixel_format color_format; sg_pixel_format depth_format; int sample_count; - sg_gl_context_desc gl; sg_metal_context_desc metal; sg_d3d11_context_desc d3d11; sg_wgpu_context_desc wgpu; @@ -3159,8 +3117,8 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_ #ifdef SOKOL_GFX_IMPL #define SOKOL_GFX_IMPL_INCLUDED (1) -#if !(defined(SOKOL_GLCORE33)||defined(SOKOL_GLES2)||defined(SOKOL_GLES3)||defined(SOKOL_D3D11)||defined(SOKOL_METAL)||defined(SOKOL_WGPU)||defined(SOKOL_DUMMY_BACKEND)) -#error "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND" +#if !(defined(SOKOL_GLCORE33)||defined(SOKOL_GLES3)||defined(SOKOL_D3D11)||defined(SOKOL_METAL)||defined(SOKOL_WGPU)||defined(SOKOL_DUMMY_BACKEND)) +#error "Please select a backend with SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND" #endif #if defined(SOKOL_MALLOC) || defined(SOKOL_CALLOC) || defined(SOKOL_FREE) #error "SOKOL_MALLOC/CALLOC/FREE macros are no longer supported, please use sg_desc.allocator to override memory allocation functions" @@ -3280,7 +3238,7 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_ #else #include <dawn/webgpu.h> #endif -#elif defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3) +#elif defined(SOKOL_GLCORE33) || defined(SOKOL_GLES3) #define _SOKOL_ANY_GL (1) // include platform specific GL headers (or on Win32: use an embedded GL loader) @@ -3311,12 +3269,6 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_ #elif defined(__EMSCRIPTEN__) || defined(__ANDROID__) #if defined(SOKOL_GLES3) #include <GLES3/gl3.h> - #elif defined(SOKOL_GLES2) - #ifndef GL_EXT_PROTOTYPES - #define GL_GLEXT_PROTOTYPES - #endif - #include <GLES2/gl2.h> - #include <GLES2/gl2ext.h> #endif #elif defined(__linux__) || defined(__unix__) #define GL_GLEXT_PROTOTYPES @@ -3357,13 +3309,12 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_ typedef void GLvoid; typedef int64_t GLint64; typedef float GLfloat; - typedef struct __GLsync * GLsync; typedef int GLint; #define GL_INT_2_10_10_10_REV 0x8D9F #define GL_R32F 0x822E #define GL_PROGRAM_POINT_SIZE 0x8642 - #define GL_STENCIL_ATTACHMENT 0x8D20 #define GL_DEPTH_ATTACHMENT 0x8D00 + #define GL_DEPTH_STENCIL_ATTACHMENT 0x821A #define GL_COLOR_ATTACHMENT2 0x8CE2 #define GL_COLOR_ATTACHMENT0 0x8CE0 #define GL_R16F 0x822D @@ -3472,7 +3423,7 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_ #define GL_LEQUAL 0x0203 #define GL_STENCIL_TEST 0x0B90 #define GL_DITHER 0x0BD0 - #define GL_DEPTH_COMPONENT16 0x81A5 + #define GL_DEPTH_COMPONENT32F 0x8CAC #define GL_EQUAL 0x0202 #define GL_FRAMEBUFFER 0x8D40 #define GL_RGB5 0x8050 @@ -3648,27 +3599,6 @@ inline int sg_append_buffer(sg_buffer buf_id, const sg_range& data) { return sg_ #ifndef GL_LUMINANCE #define GL_LUMINANCE 0x1909 #endif - - #ifdef SOKOL_GLES2 - #ifdef GL_ANGLE_instanced_arrays - #define _SOKOL_GL_INSTANCING_ENABLED - #define glDrawArraysInstanced(mode, first, count, instancecount) glDrawArraysInstancedANGLE(mode, first, count, instancecount) - #define glDrawElementsInstanced(mode, count, type, indices, instancecount) glDrawElementsInstancedANGLE(mode, count, type, indices, instancecount) - #define glVertexAttribDivisor(index, divisor) glVertexAttribDivisorANGLE(index, divisor) - #elif defined(GL_EXT_draw_instanced) && defined(GL_EXT_instanced_arrays) - #define _SOKOL_GL_INSTANCING_ENABLED - #define glDrawArraysInstanced(mode, first, count, instancecount) glDrawArraysInstancedEXT(mode, first, count, instancecount) - #define glDrawElementsInstanced(mode, count, type, indices, instancecount) glDrawElementsInstancedEXT(mode, count, type, indices, instancecount) - #define glVertexAttribDivisor(index, divisor) glVertexAttribDivisorEXT(index, divisor) - #else - #define _SOKOL_GLES2_INSTANCING_ERROR "Select GL_ANGLE_instanced_arrays or (GL_EXT_draw_instanced & GL_EXT_instanced_arrays) to enable instancing in GLES2" - #define glDrawArraysInstanced(mode, first, count, instancecount) SOKOL_ASSERT(0 && _SOKOL_GLES2_INSTANCING_ERROR) - #define glDrawElementsInstanced(mode, count, type, indices, instancecount) SOKOL_ASSERT(0 && _SOKOL_GLES2_INSTANCING_ERROR) - #define glVertexAttribDivisor(index, divisor) SOKOL_ASSERT(0 && _SOKOL_GLES2_INSTANCING_ERROR) - #endif - #else - #define _SOKOL_GL_INSTANCING_ENABLED - #endif #define _SG_GL_CHECK_ERROR() { SOKOL_ASSERT(glGetError() == GL_NO_ERROR); } #endif @@ -3995,7 +3925,6 @@ typedef struct { _sg_image_common_t cmn; struct { GLenum target; - GLuint depth_render_buffer; GLuint msaa_render_buffer; GLuint tex[SG_NUM_INFLIGHT_FRAMES]; bool ext_textures; /* if true, external textures were injected with sg_image_desc.gl_textures */ @@ -4087,9 +4016,7 @@ typedef _sg_pass_attachment_common_t _sg_pass_attachment_t; typedef struct { _sg_slot_t slot; - #if !defined(SOKOL_GLES2) GLuint vao; - #endif GLuint default_framebuffer; } _sg_gl_context_t; typedef _sg_gl_context_t _sg_context_t; @@ -4135,7 +4062,6 @@ typedef struct { typedef struct { bool valid; - bool gles2; bool in_pass; int cur_pass_width; int cur_pass_height; @@ -5563,7 +5489,6 @@ _SOKOL_PRIVATE void _sg_dummy_update_image(_sg_image_t* img, const sg_image_data _SG_XMACRO(glTexImage3D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLsizei depth, GLint border, GLenum format, GLenum type, const void * pixels)) \ _SG_XMACRO(glCreateShader, GLuint, (GLenum type)) \ _SG_XMACRO(glTexSubImage2D, void, (GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const void * pixels)) \ - _SG_XMACRO(glClearDepth, void, (GLdouble depth)) \ _SG_XMACRO(glFramebufferTexture2D, void, (GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level)) \ _SG_XMACRO(glCreateProgram, GLuint, (void)) \ _SG_XMACRO(glViewport, void, (GLint x, GLint y, GLsizei width, GLsizei height)) \ @@ -5579,7 +5504,6 @@ _SOKOL_PRIVATE void _sg_dummy_update_image(_sg_image_t* img, const sg_image_data _SG_XMACRO(glDeleteVertexArrays, void, (GLsizei n, const GLuint * arrays)) \ _SG_XMACRO(glDepthMask, void, (GLboolean flag)) \ _SG_XMACRO(glDrawArraysInstanced, void, (GLenum mode, GLint first, GLsizei count, GLsizei instancecount)) \ - _SG_XMACRO(glClearStencil, void, (GLint s)) \ _SG_XMACRO(glScissor, void, (GLint x, GLint y, GLsizei width, GLsizei height)) \ _SG_XMACRO(glGenRenderbuffers, void, (GLsizei n, GLuint * renderbuffers)) \ _SG_XMACRO(glBufferData, void, (GLenum target, GLsizeiptr size, const void * data, GLenum usage)) \ @@ -5591,7 +5515,6 @@ _SOKOL_PRIVATE void _sg_dummy_update_image(_sg_image_t* img, const sg_image_data _SG_XMACRO(glStencilMask, void, (GLuint mask)) \ _SG_XMACRO(glAttachShader, void, (GLuint program, GLuint shader)) \ _SG_XMACRO(glGetError, GLenum, (void)) \ - _SG_XMACRO(glClearColor, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) \ _SG_XMACRO(glBlendColor, void, (GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha)) \ _SG_XMACRO(glTexParameterf, void, (GLenum target, GLenum pname, GLfloat param)) \ _SG_XMACRO(glTexParameterfv, void, (GLenum target, GLenum pname, const GLfloat* params)) \ @@ -5602,8 +5525,6 @@ _SOKOL_PRIVATE void _sg_dummy_update_image(_sg_image_t* img, const sg_image_data _SG_XMACRO(glEnableVertexAttribArray, void, (GLuint index)) \ _SG_XMACRO(glBlendFunc, void, (GLenum sfactor, GLenum dfactor)) \ _SG_XMACRO(glReadBuffer, void, (GLenum src)) \ - _SG_XMACRO(glReadPixels, void, (GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, void * data)) \ - _SG_XMACRO(glClear, void, (GLbitfield mask)) \ _SG_XMACRO(glTexImage2D, void, (GLenum target, GLint level, GLint internalformat, GLsizei width, GLsizei height, GLint border, GLenum format, GLenum type, const void * pixels)) \ _SG_XMACRO(glGenVertexArrays, void, (GLsizei n, GLuint * arrays)) \ _SG_XMACRO(glFrontFace, void, (GLenum mode)) \ @@ -5663,10 +5584,8 @@ _SOKOL_PRIVATE GLenum _sg_gl_texture_target(sg_image_type t) { switch (t) { case SG_IMAGETYPE_2D: return GL_TEXTURE_2D; case SG_IMAGETYPE_CUBE: return GL_TEXTURE_CUBE_MAP; - #if !defined(SOKOL_GLES2) case SG_IMAGETYPE_3D: return GL_TEXTURE_3D; case SG_IMAGETYPE_ARRAY: return GL_TEXTURE_2D_ARRAY; - #endif default: SOKOL_UNREACHABLE; return 0; } } @@ -5909,16 +5828,14 @@ _SOKOL_PRIVATE GLenum _sg_gl_teximage_type(sg_pixel_format fmt) { case SG_PIXELFORMAT_RG32F: case SG_PIXELFORMAT_RGBA32F: return GL_FLOAT; - #if !defined(SOKOL_GLES2) case SG_PIXELFORMAT_RGB10A2: return GL_UNSIGNED_INT_2_10_10_10_REV; case SG_PIXELFORMAT_RG11B10F: return GL_UNSIGNED_INT_10F_11F_11F_REV; case SG_PIXELFORMAT_RGB9E5: return GL_UNSIGNED_INT_5_9_9_9_REV; - #endif case SG_PIXELFORMAT_DEPTH: - return GL_UNSIGNED_SHORT; + return GL_FLOAT; case SG_PIXELFORMAT_DEPTH_STENCIL: return GL_UNSIGNED_INT_24_8; default: @@ -5934,39 +5851,28 @@ _SOKOL_PRIVATE GLenum _sg_gl_teximage_format(sg_pixel_format fmt) { case SG_PIXELFORMAT_R16SN: case SG_PIXELFORMAT_R16F: case SG_PIXELFORMAT_R32F: - #if defined(SOKOL_GLES2) - return GL_LUMINANCE; - #else - if (_sg.gl.gles2) { - return GL_LUMINANCE; - } - else { - return GL_RED; - } - #endif - #if !defined(SOKOL_GLES2) - case SG_PIXELFORMAT_R8UI: - case SG_PIXELFORMAT_R8SI: - case SG_PIXELFORMAT_R16UI: - case SG_PIXELFORMAT_R16SI: - case SG_PIXELFORMAT_R32UI: - case SG_PIXELFORMAT_R32SI: - return GL_RED_INTEGER; - case SG_PIXELFORMAT_RG8: - case SG_PIXELFORMAT_RG8SN: - case SG_PIXELFORMAT_RG16: - case SG_PIXELFORMAT_RG16SN: - case SG_PIXELFORMAT_RG16F: - case SG_PIXELFORMAT_RG32F: - return GL_RG; - case SG_PIXELFORMAT_RG8UI: - case SG_PIXELFORMAT_RG8SI: - case SG_PIXELFORMAT_RG16UI: - case SG_PIXELFORMAT_RG16SI: - case SG_PIXELFORMAT_RG32UI: - case SG_PIXELFORMAT_RG32SI: - return GL_RG_INTEGER; - #endif + return GL_RED; + case SG_PIXELFORMAT_R8UI: + case SG_PIXELFORMAT_R8SI: + case SG_PIXELFORMAT_R16UI: + case SG_PIXELFORMAT_R16SI: + case SG_PIXELFORMAT_R32UI: + case SG_PIXELFORMAT_R32SI: + return GL_RED_INTEGER; + case SG_PIXELFORMAT_RG8: + case SG_PIXELFORMAT_RG8SN: + case SG_PIXELFORMAT_RG16: + case SG_PIXELFORMAT_RG16SN: + case SG_PIXELFORMAT_RG16F: + case SG_PIXELFORMAT_RG32F: + return GL_RG; + case SG_PIXELFORMAT_RG8UI: + case SG_PIXELFORMAT_RG8SI: + case SG_PIXELFORMAT_RG16UI: + case SG_PIXELFORMAT_RG16SI: + case SG_PIXELFORMAT_RG32UI: + case SG_PIXELFORMAT_RG32SI: + return GL_RG_INTEGER; case SG_PIXELFORMAT_RGBA8: case SG_PIXELFORMAT_SRGB8A8: case SG_PIXELFORMAT_RGBA8SN: @@ -5976,15 +5882,13 @@ _SOKOL_PRIVATE GLenum _sg_gl_teximage_format(sg_pixel_format fmt) { case SG_PIXELFORMAT_RGBA32F: case SG_PIXELFORMAT_RGB10A2: return GL_RGBA; - #if !defined(SOKOL_GLES2) - case SG_PIXELFORMAT_RGBA8UI: - case SG_PIXELFORMAT_RGBA8SI: - case SG_PIXELFORMAT_RGBA16UI: - case SG_PIXELFORMAT_RGBA16SI: - case SG_PIXELFORMAT_RGBA32UI: - case SG_PIXELFORMAT_RGBA32SI: - return GL_RGBA_INTEGER; - #endif + case SG_PIXELFORMAT_RGBA8UI: + case SG_PIXELFORMAT_RGBA8SI: + case SG_PIXELFORMAT_RGBA16UI: + case SG_PIXELFORMAT_RGBA16SI: + case SG_PIXELFORMAT_RGBA32UI: + case SG_PIXELFORMAT_RGBA32SI: + return GL_RGBA_INTEGER; case SG_PIXELFORMAT_RG11B10F: case SG_PIXELFORMAT_RGB9E5: return GL_RGB; @@ -6036,85 +5940,76 @@ _SOKOL_PRIVATE GLenum _sg_gl_teximage_format(sg_pixel_format fmt) { } _SOKOL_PRIVATE GLenum _sg_gl_teximage_internal_format(sg_pixel_format fmt) { - #if defined(SOKOL_GLES2) - return _sg_gl_teximage_format(fmt); - #else - if (_sg.gl.gles2) { - return _sg_gl_teximage_format(fmt); - } - else { - switch (fmt) { - case SG_PIXELFORMAT_R8: return GL_R8; - case SG_PIXELFORMAT_R8SN: return GL_R8_SNORM; - case SG_PIXELFORMAT_R8UI: return GL_R8UI; - case SG_PIXELFORMAT_R8SI: return GL_R8I; - #if !defined(SOKOL_GLES3) - case SG_PIXELFORMAT_R16: return GL_R16; - case SG_PIXELFORMAT_R16SN: return GL_R16_SNORM; - #endif - case SG_PIXELFORMAT_R16UI: return GL_R16UI; - case SG_PIXELFORMAT_R16SI: return GL_R16I; - case SG_PIXELFORMAT_R16F: return GL_R16F; - case SG_PIXELFORMAT_RG8: return GL_RG8; - case SG_PIXELFORMAT_RG8SN: return GL_RG8_SNORM; - case SG_PIXELFORMAT_RG8UI: return GL_RG8UI; - case SG_PIXELFORMAT_RG8SI: return GL_RG8I; - case SG_PIXELFORMAT_R32UI: return GL_R32UI; - case SG_PIXELFORMAT_R32SI: return GL_R32I; - case SG_PIXELFORMAT_R32F: return GL_R32F; - #if !defined(SOKOL_GLES3) - case SG_PIXELFORMAT_RG16: return GL_RG16; - case SG_PIXELFORMAT_RG16SN: return GL_RG16_SNORM; - #endif - case SG_PIXELFORMAT_RG16UI: return GL_RG16UI; - 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; - case SG_PIXELFORMAT_RGB10A2: return GL_RGB10_A2; - case SG_PIXELFORMAT_RG11B10F: return GL_R11F_G11F_B10F; - case SG_PIXELFORMAT_RGB9E5: return GL_RGB9_E5; - case SG_PIXELFORMAT_RG32UI: return GL_RG32UI; - case SG_PIXELFORMAT_RG32SI: return GL_RG32I; - case SG_PIXELFORMAT_RG32F: return GL_RG32F; - #if !defined(SOKOL_GLES3) - case SG_PIXELFORMAT_RGBA16: return GL_RGBA16; - case SG_PIXELFORMAT_RGBA16SN: return GL_RGBA16_SNORM; - #endif - case SG_PIXELFORMAT_RGBA16UI: return GL_RGBA16UI; - case SG_PIXELFORMAT_RGBA16SI: return GL_RGBA16I; - case SG_PIXELFORMAT_RGBA16F: return GL_RGBA16F; - case SG_PIXELFORMAT_RGBA32UI: return GL_RGBA32UI; - case SG_PIXELFORMAT_RGBA32SI: return GL_RGBA32I; - case SG_PIXELFORMAT_RGBA32F: return GL_RGBA32F; - case SG_PIXELFORMAT_DEPTH: return GL_DEPTH_COMPONENT16; - case SG_PIXELFORMAT_DEPTH_STENCIL: return GL_DEPTH24_STENCIL8; - case SG_PIXELFORMAT_BC1_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; - case SG_PIXELFORMAT_BC2_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; - case SG_PIXELFORMAT_BC3_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; - case SG_PIXELFORMAT_BC4_R: return GL_COMPRESSED_RED_RGTC1; - case SG_PIXELFORMAT_BC4_RSN: return GL_COMPRESSED_SIGNED_RED_RGTC1; - case SG_PIXELFORMAT_BC5_RG: return GL_COMPRESSED_RED_GREEN_RGTC2; - case SG_PIXELFORMAT_BC5_RGSN: return GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2; - case SG_PIXELFORMAT_BC6H_RGBF: return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; - case SG_PIXELFORMAT_BC6H_RGBUF: return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; - case SG_PIXELFORMAT_BC7_RGBA: return GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; - case SG_PIXELFORMAT_PVRTC_RGB_2BPP: return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; - case SG_PIXELFORMAT_PVRTC_RGB_4BPP: return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; - case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; - case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; - case SG_PIXELFORMAT_ETC2_RGB8: return GL_COMPRESSED_RGB8_ETC2; - case SG_PIXELFORMAT_ETC2_RGB8A1: return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; - case SG_PIXELFORMAT_ETC2_RGBA8: return GL_COMPRESSED_RGBA8_ETC2_EAC; - case SG_PIXELFORMAT_ETC2_RG11: return GL_COMPRESSED_RG11_EAC; - case SG_PIXELFORMAT_ETC2_RG11SN: return GL_COMPRESSED_SIGNED_RG11_EAC; - default: SOKOL_UNREACHABLE; return 0; - } + switch (fmt) { + case SG_PIXELFORMAT_R8: return GL_R8; + case SG_PIXELFORMAT_R8SN: return GL_R8_SNORM; + case SG_PIXELFORMAT_R8UI: return GL_R8UI; + case SG_PIXELFORMAT_R8SI: return GL_R8I; + #if !defined(SOKOL_GLES3) + case SG_PIXELFORMAT_R16: return GL_R16; + case SG_PIXELFORMAT_R16SN: return GL_R16_SNORM; + #endif + case SG_PIXELFORMAT_R16UI: return GL_R16UI; + case SG_PIXELFORMAT_R16SI: return GL_R16I; + case SG_PIXELFORMAT_R16F: return GL_R16F; + case SG_PIXELFORMAT_RG8: return GL_RG8; + case SG_PIXELFORMAT_RG8SN: return GL_RG8_SNORM; + case SG_PIXELFORMAT_RG8UI: return GL_RG8UI; + case SG_PIXELFORMAT_RG8SI: return GL_RG8I; + case SG_PIXELFORMAT_R32UI: return GL_R32UI; + case SG_PIXELFORMAT_R32SI: return GL_R32I; + case SG_PIXELFORMAT_R32F: return GL_R32F; + #if !defined(SOKOL_GLES3) + case SG_PIXELFORMAT_RG16: return GL_RG16; + case SG_PIXELFORMAT_RG16SN: return GL_RG16_SNORM; + #endif + case SG_PIXELFORMAT_RG16UI: return GL_RG16UI; + 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; + case SG_PIXELFORMAT_RGB10A2: return GL_RGB10_A2; + case SG_PIXELFORMAT_RG11B10F: return GL_R11F_G11F_B10F; + case SG_PIXELFORMAT_RGB9E5: return GL_RGB9_E5; + case SG_PIXELFORMAT_RG32UI: return GL_RG32UI; + case SG_PIXELFORMAT_RG32SI: return GL_RG32I; + case SG_PIXELFORMAT_RG32F: return GL_RG32F; + #if !defined(SOKOL_GLES3) + case SG_PIXELFORMAT_RGBA16: return GL_RGBA16; + case SG_PIXELFORMAT_RGBA16SN: return GL_RGBA16_SNORM; + #endif + case SG_PIXELFORMAT_RGBA16UI: return GL_RGBA16UI; + case SG_PIXELFORMAT_RGBA16SI: return GL_RGBA16I; + case SG_PIXELFORMAT_RGBA16F: return GL_RGBA16F; + case SG_PIXELFORMAT_RGBA32UI: return GL_RGBA32UI; + case SG_PIXELFORMAT_RGBA32SI: return GL_RGBA32I; + case SG_PIXELFORMAT_RGBA32F: return GL_RGBA32F; + case SG_PIXELFORMAT_DEPTH: return GL_DEPTH_COMPONENT32F; + case SG_PIXELFORMAT_DEPTH_STENCIL: return GL_DEPTH24_STENCIL8; + case SG_PIXELFORMAT_BC1_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT1_EXT; + case SG_PIXELFORMAT_BC2_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT3_EXT; + case SG_PIXELFORMAT_BC3_RGBA: return GL_COMPRESSED_RGBA_S3TC_DXT5_EXT; + case SG_PIXELFORMAT_BC4_R: return GL_COMPRESSED_RED_RGTC1; + case SG_PIXELFORMAT_BC4_RSN: return GL_COMPRESSED_SIGNED_RED_RGTC1; + case SG_PIXELFORMAT_BC5_RG: return GL_COMPRESSED_RED_GREEN_RGTC2; + case SG_PIXELFORMAT_BC5_RGSN: return GL_COMPRESSED_SIGNED_RED_GREEN_RGTC2; + case SG_PIXELFORMAT_BC6H_RGBF: return GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT_ARB; + case SG_PIXELFORMAT_BC6H_RGBUF: return GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT_ARB; + case SG_PIXELFORMAT_BC7_RGBA: return GL_COMPRESSED_RGBA_BPTC_UNORM_ARB; + case SG_PIXELFORMAT_PVRTC_RGB_2BPP: return GL_COMPRESSED_RGB_PVRTC_2BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGB_4BPP: return GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGBA_2BPP: return GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG; + case SG_PIXELFORMAT_PVRTC_RGBA_4BPP: return GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG; + case SG_PIXELFORMAT_ETC2_RGB8: return GL_COMPRESSED_RGB8_ETC2; + case SG_PIXELFORMAT_ETC2_RGB8A1: return GL_COMPRESSED_RGB8_PUNCHTHROUGH_ALPHA1_ETC2; + case SG_PIXELFORMAT_ETC2_RGBA8: return GL_COMPRESSED_RGBA8_ETC2_EAC; + case SG_PIXELFORMAT_ETC2_RG11: return GL_COMPRESSED_RG11_EAC; + case SG_PIXELFORMAT_ETC2_RG11SN: return GL_COMPRESSED_SIGNED_RG11_EAC; + default: SOKOL_UNREACHABLE; return 0; } - #endif } _SOKOL_PRIVATE GLenum _sg_gl_cubeface_target(int face_index) { @@ -6129,204 +6024,96 @@ _SOKOL_PRIVATE GLenum _sg_gl_cubeface_target(int face_index) { } } -_SOKOL_PRIVATE GLenum _sg_gl_depth_attachment_format(sg_pixel_format fmt) { - switch (fmt) { - case SG_PIXELFORMAT_DEPTH: return GL_DEPTH_COMPONENT16; - case SG_PIXELFORMAT_DEPTH_STENCIL: return GL_DEPTH24_STENCIL8; - default: SOKOL_UNREACHABLE; return 0; - } -} - /* see: https://www.khronos.org/registry/OpenGL-Refpages/es3.0/html/glTexImage2D.xhtml */ _SOKOL_PRIVATE void _sg_gl_init_pixelformats(bool has_bgra) { - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R8]); - } - else { - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8]); - } - #else - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8SI]); + #if !defined(SOKOL_GLES3) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16SN]); #endif - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R8SN]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8UI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R8SI]); - #if !defined(SOKOL_GLES3) - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16SN]); - #endif - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16UI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16SI]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG8]); - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG8SN]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8UI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8SI]); - _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32UI]); - _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32SI]); - #if !defined(SOKOL_GLES3) - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16SN]); - #endif - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16UI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16SI]); - } + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_R16SI]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG8]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG8SN]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG8SI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32UI]); + _sg_pixelformat_sr(&_sg.formats[SG_PIXELFORMAT_R32SI]); + #if !defined(SOKOL_GLES3) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16SN]); #endif + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG16SI]); _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]); - } - #endif + _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]); if (has_bgra) { _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_BGRA8]); } - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGB10A2]); - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG11B10F]); - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGB9E5]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32UI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32SI]); - #if !defined(SOKOL_GLES3) - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16SN]); - #endif - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16UI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16SI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32UI]); - _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32SI]); - } + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGB10A2]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG11B10F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGB9E5]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RG32SI]); + #if !defined(SOKOL_GLES3) + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16SN]); #endif - // FIXME: WEBGL_depth_texture extension? + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA16SI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32UI]); + _sg_pixelformat_srm(&_sg.formats[SG_PIXELFORMAT_RGBA32SI]); _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH]); _sg_pixelformat_srmd(&_sg.formats[SG_PIXELFORMAT_DEPTH_STENCIL]); } /* FIXME: OES_half_float_blend */ -_SOKOL_PRIVATE void _sg_gl_init_pixelformats_half_float(bool has_colorbuffer_half_float, bool has_texture_half_float_linear) { - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - if (has_texture_half_float_linear) { - if (has_colorbuffer_half_float) { - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16F]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16F]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - else { - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R16F]); - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG16F]); - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - } - else { - if (has_colorbuffer_half_float) { - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_R16F]); - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RG16F]); - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - else { - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R16F]); - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RG16F]); - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - } +_SOKOL_PRIVATE void _sg_gl_init_pixelformats_half_float(bool has_colorbuffer_half_float) { + if (has_colorbuffer_half_float) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); + } else { + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R16F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG16F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); } - else { - #endif - /* GLES2 can only render to RGBA, and there's no RG format */ - if (has_texture_half_float_linear) { - if (has_colorbuffer_half_float) { - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - else { - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R16F]); - } - else { - if (has_colorbuffer_half_float) { - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - else { - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA16F]); - } - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R16F]); - } - #if !defined(SOKOL_GLES2) - } - #endif } _SOKOL_PRIVATE void _sg_gl_init_pixelformats_float(bool has_colorbuffer_float, bool has_texture_float_linear, bool has_float_blend) { - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - if (has_texture_float_linear) { - if (has_colorbuffer_float) { - if (has_float_blend) { - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R32F]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG32F]); - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - else { - _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_R32F]); - _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RG32F]); - _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - } - else { - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R32F]); - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG32F]); - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - } - else { - if (has_colorbuffer_float) { - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_R32F]); - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RG32F]); - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - else { - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R32F]); - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RG32F]); - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - } - } - else { - #endif - /* GLES2 can only render to RGBA, and there's no RG format */ - if (has_texture_float_linear) { - if (has_colorbuffer_float) { - if (has_float_blend) { - _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - else { - _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - } - else { - _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + if (has_texture_float_linear) { + if (has_colorbuffer_float) { + if (has_float_blend) { + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_all(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } else { + _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_sfrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); } + } else { _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_R32F]); - } - else { - if (has_colorbuffer_float) { - _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } - else { - _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); - } + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_sf(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } + } else { + if (has_colorbuffer_float) { + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_sbrm(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); + } else { _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_R32F]); + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RG32F]); + _sg_pixelformat_s(&_sg.formats[SG_PIXELFORMAT_RGBA32F]); } - #if !defined(SOKOL_GLES2) } - #endif } _SOKOL_PRIVATE void _sg_gl_init_pixelformats_s3tc(void) { @@ -6382,22 +6169,17 @@ _SOKOL_PRIVATE void _sg_gl_init_limits(void) { glGetIntegerv(GL_MAX_VERTEX_UNIFORM_VECTORS, &gl_int); _SG_GL_CHECK_ERROR(); _sg.limits.gl_max_vertex_uniform_vectors = gl_int; - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &gl_int); - _SG_GL_CHECK_ERROR(); - _sg.limits.max_image_size_3d = gl_int; - glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &gl_int); - _SG_GL_CHECK_ERROR(); - _sg.limits.max_image_array_layers = gl_int; - } - #endif + glGetIntegerv(GL_MAX_3D_TEXTURE_SIZE, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.limits.max_image_size_3d = gl_int; + glGetIntegerv(GL_MAX_ARRAY_TEXTURE_LAYERS, &gl_int); + _SG_GL_CHECK_ERROR(); + _sg.limits.max_image_array_layers = gl_int; if (_sg.gl.ext_anisotropic) { glGetIntegerv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gl_int); _SG_GL_CHECK_ERROR(); _sg.gl.max_anisotropy = gl_int; - } - else { + } else { _sg.gl.max_anisotropy = 1; } glGetIntegerv(GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS, &gl_int); @@ -6410,11 +6192,6 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_glcore33(void) { _sg.backend = SG_BACKEND_GLCORE33; _sg.features.origin_top_left = false; - _sg.features.instancing = true; - _sg.features.multiple_render_targets = true; - _sg.features.msaa_render_targets = true; - _sg.features.imagetype_3d = true; - _sg.features.imagetype_array = true; _sg.features.image_clamp_to_border = true; _sg.features.mrt_independent_blend_state = false; _sg.features.mrt_independent_write_mask = true; @@ -6432,20 +6209,15 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_glcore33(void) { if (ext) { if (strstr(ext, "_texture_compression_s3tc")) { has_s3tc = true; - } - else if (strstr(ext, "_texture_compression_rgtc")) { + } else if (strstr(ext, "_texture_compression_rgtc")) { has_rgtc = true; - } - else if (strstr(ext, "_texture_compression_bptc")) { + } else if (strstr(ext, "_texture_compression_bptc")) { has_bptc = true; - } - else if (strstr(ext, "_texture_compression_pvrtc")) { + } else if (strstr(ext, "_texture_compression_pvrtc")) { has_pvrtc = true; - } - else if (strstr(ext, "_ES3_compatibility")) { + } else if (strstr(ext, "_ES3_compatibility")) { has_etc2 = true; - } - else if (strstr(ext, "_texture_filter_anisotropic")) { + } else if (strstr(ext, "_texture_filter_anisotropic")) { _sg.gl.ext_anisotropic = true; } } @@ -6459,11 +6231,10 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_glcore33(void) { const bool has_colorbuffer_float = true; const bool has_colorbuffer_half_float = true; const bool has_texture_float_linear = true; /* FIXME??? */ - const bool has_texture_half_float_linear = true; const bool has_float_blend = true; _sg_gl_init_pixelformats(has_bgra); _sg_gl_init_pixelformats_float(has_colorbuffer_float, has_texture_float_linear, has_float_blend); - _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float, has_texture_half_float_linear); + _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float); if (has_s3tc) { _sg_gl_init_pixelformats_s3tc(); } @@ -6487,11 +6258,6 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_gles3(void) { _sg.backend = SG_BACKEND_GLES3; _sg.features.origin_top_left = false; - _sg.features.instancing = true; - _sg.features.multiple_render_targets = true; - _sg.features.msaa_render_targets = true; - _sg.features.imagetype_3d = true; - _sg.features.imagetype_array = true; _sg.features.image_clamp_to_border = false; _sg.features.mrt_independent_blend_state = false; _sg.features.mrt_independent_write_mask = false; @@ -6516,38 +6282,27 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_gles3(void) { if (ext) { if (strstr(ext, "_texture_compression_s3tc")) { has_s3tc = true; - } - else if (strstr(ext, "_compressed_texture_s3tc")) { + } else if (strstr(ext, "_compressed_texture_s3tc")) { has_s3tc = true; - } - else if (strstr(ext, "_texture_compression_rgtc")) { + } else if (strstr(ext, "_texture_compression_rgtc")) { has_rgtc = true; - } - else if (strstr(ext, "_texture_compression_bptc")) { + } else if (strstr(ext, "_texture_compression_bptc")) { has_bptc = true; - } - else if (strstr(ext, "_texture_compression_pvrtc")) { + } else if (strstr(ext, "_texture_compression_pvrtc")) { has_pvrtc = true; - } - else if (strstr(ext, "_compressed_texture_pvrtc")) { + } else if (strstr(ext, "_compressed_texture_pvrtc")) { has_pvrtc = true; - } - else if (strstr(ext, "_compressed_texture_etc")) { + } else if (strstr(ext, "_compressed_texture_etc")) { has_etc2 = true; - } - else if (strstr(ext, "_color_buffer_float")) { + } else if (strstr(ext, "_color_buffer_float")) { has_colorbuffer_float = true; - } - else if (strstr(ext, "_color_buffer_half_float")) { + } else if (strstr(ext, "_color_buffer_half_float")) { has_colorbuffer_half_float = true; - } - else if (strstr(ext, "_texture_float_linear")) { + } else if (strstr(ext, "_texture_float_linear")) { has_texture_float_linear = true; - } - else if (strstr(ext, "_float_blend")) { + } else if (strstr(ext, "_float_blend")) { has_float_blend = true; - } - else if (strstr(ext, "_texture_filter_anisotropic")) { + } else if (strstr(ext, "_texture_filter_anisotropic")) { _sg.gl.ext_anisotropic = true; } } @@ -6557,97 +6312,19 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_gles3(void) { see: https://developer.mozilla.org/en-US/docs/Web/API/EXT_color_buffer_float */ #if defined(__EMSCRIPTEN__) - has_colorbuffer_half_float = has_colorbuffer_float; - #endif - - /* limits */ - _sg_gl_init_limits(); - - /* pixel formats */ - const bool has_texture_half_float_linear = true; - const bool has_bgra = false; /* not a bug */ - _sg_gl_init_pixelformats(has_bgra); - _sg_gl_init_pixelformats_float(has_colorbuffer_float, has_texture_float_linear, has_float_blend); - _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float, has_texture_half_float_linear); - if (has_s3tc) { - _sg_gl_init_pixelformats_s3tc(); - } - if (has_rgtc) { - _sg_gl_init_pixelformats_rgtc(); - } - if (has_bptc) { - _sg_gl_init_pixelformats_bptc(); - } - if (has_pvrtc) { - _sg_gl_init_pixelformats_pvrtc(); - } - if (has_etc2) { - _sg_gl_init_pixelformats_etc2(); - } -} -#endif - -#if defined(SOKOL_GLES3) || defined(SOKOL_GLES2) -_SOKOL_PRIVATE void _sg_gl_init_caps_gles2(void) { - _sg.backend = SG_BACKEND_GLES2; - - bool has_s3tc = false; /* BC1..BC3 */ - bool has_rgtc = false; /* BC4 and BC5 */ - bool has_bptc = false; /* BC6H and BC7 */ - bool has_pvrtc = false; - bool has_etc2 = false; - bool has_texture_float = false; - bool has_texture_float_linear = false; - bool has_colorbuffer_float = false; - bool has_float_blend = false; - bool has_instancing = false; - const char* ext = (const char*) glGetString(GL_EXTENSIONS); - if (ext) { - has_s3tc = strstr(ext, "_texture_compression_s3tc") || strstr(ext, "_compressed_texture_s3tc"); - has_rgtc = strstr(ext, "_texture_compression_rgtc"); - has_bptc = strstr(ext, "_texture_compression_bptc"); - has_pvrtc = strstr(ext, "_texture_compression_pvrtc") || strstr(ext, "_compressed_texture_pvrtc"); - has_etc2 = strstr(ext, "_compressed_texture_etc"); - has_texture_float = strstr(ext, "_texture_float"); - has_texture_float_linear = strstr(ext, "_texture_float_linear"); - has_colorbuffer_float = strstr(ext, "_color_buffer_float"); - has_float_blend = strstr(ext, "_float_blend"); - /* don't bother with half_float support on WebGL1 - has_texture_half_float = strstr(ext, "_texture_half_float"); - has_texture_half_float_linear = strstr(ext, "_texture_half_float_linear"); - has_colorbuffer_half_float = strstr(ext, "_color_buffer_half_float"); - */ - has_instancing = strstr(ext, "_instanced_arrays"); - _sg.gl.ext_anisotropic = strstr(ext, "ext_anisotropic"); + if (!has_colorbuffer_half_float && has_colorbuffer_float) { + has_colorbuffer_half_float = has_colorbuffer_float; } - - _sg.features.origin_top_left = false; - #if defined(_SOKOL_GL_INSTANCING_ENABLED) - _sg.features.instancing = has_instancing; #endif - _sg.features.multiple_render_targets = false; - _sg.features.msaa_render_targets = false; - _sg.features.imagetype_3d = false; - _sg.features.imagetype_array = false; - _sg.features.image_clamp_to_border = false; - _sg.features.mrt_independent_blend_state = false; - _sg.features.mrt_independent_write_mask = false; /* limits */ _sg_gl_init_limits(); /* pixel formats */ const bool has_bgra = false; /* not a bug */ - const bool has_texture_half_float = false; - const bool has_texture_half_float_linear = false; - const bool has_colorbuffer_half_float = false; _sg_gl_init_pixelformats(has_bgra); - if (has_texture_float) { - _sg_gl_init_pixelformats_float(has_colorbuffer_float, has_texture_float_linear, has_float_blend); - } - if (has_texture_half_float) { - _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float, has_texture_half_float_linear); - } + _sg_gl_init_pixelformats_float(has_colorbuffer_float, has_texture_float_linear, has_float_blend); + _sg_gl_init_pixelformats_half_float(has_colorbuffer_half_float); if (has_s3tc) { _sg_gl_init_pixelformats_s3tc(); } @@ -6663,10 +6340,6 @@ _SOKOL_PRIVATE void _sg_gl_init_caps_gles2(void) { if (has_etc2) { _sg_gl_init_pixelformats_etc2(); } - /* GLES2 doesn't allow multi-sampled render targets at all */ - for (int i = 0; i < _SG_PIXELFORMAT_NUM; i++) { - _sg.formats[i].msaa = false; - } } #endif @@ -6689,8 +6362,7 @@ _SOKOL_PRIVATE void _sg_gl_cache_bind_buffer(GLenum target, GLuint buffer) { _sg.gl.cache.vertex_buffer = buffer; glBindBuffer(target, buffer); } - } - else { + } else { if (_sg.gl.cache.index_buffer != buffer) { _sg.gl.cache.index_buffer = buffer; glBindBuffer(target, buffer); @@ -6701,8 +6373,7 @@ _SOKOL_PRIVATE void _sg_gl_cache_bind_buffer(GLenum target, GLuint buffer) { _SOKOL_PRIVATE void _sg_gl_cache_store_buffer_binding(GLenum target) { if (target == GL_ARRAY_BUFFER) { _sg.gl.cache.stored_vertex_buffer = _sg.gl.cache.vertex_buffer; - } - else { + } else { _sg.gl.cache.stored_index_buffer = _sg.gl.cache.index_buffer; } } @@ -6714,8 +6385,7 @@ _SOKOL_PRIVATE void _sg_gl_cache_restore_buffer_binding(GLenum target) { _sg_gl_cache_bind_buffer(target, _sg.gl.cache.stored_vertex_buffer); _sg.gl.cache.stored_vertex_buffer = 0; } - } - else { + } else { if (_sg.gl.cache.stored_index_buffer != 0) { /* we only care restoring valid ids */ _sg_gl_cache_bind_buffer(target, _sg.gl.cache.stored_index_buffer); @@ -6761,12 +6431,8 @@ _SOKOL_PRIVATE void _sg_gl_cache_clear_texture_bindings(bool force) { glActiveTexture(gl_texture_slot); glBindTexture(GL_TEXTURE_2D, 0); glBindTexture(GL_TEXTURE_CUBE_MAP, 0); - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - glBindTexture(GL_TEXTURE_3D, 0); - glBindTexture(GL_TEXTURE_2D_ARRAY, 0); - } - #endif + glBindTexture(GL_TEXTURE_3D, 0); + glBindTexture(GL_TEXTURE_2D_ARRAY, 0); _sg.gl.cache.textures[i].target = 0; _sg.gl.cache.textures[i].texture = 0; _sg.gl.cache.cur_active_texture = gl_texture_slot; @@ -6852,12 +6518,8 @@ _SOKOL_PRIVATE void _sg_gl_cache_invalidate_pipeline(_sg_pipeline_t* pip) { _SOKOL_PRIVATE void _sg_gl_reset_state_cache(void) { if (_sg.gl.cur_context) { _SG_GL_CHECK_ERROR(); - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - glBindVertexArray(_sg.gl.cur_context->vao); - _SG_GL_CHECK_ERROR(); - } - #endif + glBindVertexArray(_sg.gl.cur_context->vao); + _SG_GL_CHECK_ERROR(); _sg_clear(&_sg.gl.cache, sizeof(_sg.gl.cache)); _sg_gl_cache_clear_buffer_bindings(true); _SG_GL_CHECK_ERROR(); @@ -6931,14 +6593,9 @@ _SOKOL_PRIVATE void _sg_gl_reset_state_cache(void) { } _SOKOL_PRIVATE void _sg_gl_setup_backend(const sg_desc* desc) { + _SOKOL_UNUSED(desc); /* assumes that _sg.gl is already zero-initialized */ _sg.gl.valid = true; - #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - _sg.gl.gles2 = desc->context.gl.force_gles2; - #else - _SOKOL_UNUSED(desc); - _sg.gl.gles2 = false; - #endif #if defined(_SOKOL_USE_WIN32_GL_LOADER) _sg_gl_load_opengl(); @@ -6951,14 +6608,7 @@ _SOKOL_PRIVATE void _sg_gl_setup_backend(const sg_desc* desc) { #if defined(SOKOL_GLCORE33) _sg_gl_init_caps_glcore33(); #elif defined(SOKOL_GLES3) - if (_sg.gl.gles2) { - _sg_gl_init_caps_gles2(); - } - else { - _sg_gl_init_caps_gles3(); - } - #else - _sg_gl_init_caps_gles2(); + _sg_gl_init_caps_gles3(); #endif } @@ -6984,14 +6634,10 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_context(_sg_context_t* ctx) { _SG_GL_CHECK_ERROR(); glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&ctx->default_framebuffer); _SG_GL_CHECK_ERROR(); - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - SOKOL_ASSERT(0 == ctx->vao); - glGenVertexArrays(1, &ctx->vao); - glBindVertexArray(ctx->vao); - _SG_GL_CHECK_ERROR(); - } - #endif + SOKOL_ASSERT(0 == ctx->vao); + glGenVertexArrays(1, &ctx->vao); + glBindVertexArray(ctx->vao); + _SG_GL_CHECK_ERROR(); // incoming texture data is generally expected to be packed tightly glPixelStorei(GL_UNPACK_ALIGNMENT, 1); return SG_RESOURCESTATE_VALID; @@ -6999,16 +6645,10 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_context(_sg_context_t* ctx) { _SOKOL_PRIVATE void _sg_gl_discard_context(_sg_context_t* ctx) { SOKOL_ASSERT(ctx); - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - if (ctx->vao) { - glDeleteVertexArrays(1, &ctx->vao); - } - _SG_GL_CHECK_ERROR(); + if (ctx->vao) { + glDeleteVertexArrays(1, &ctx->vao); } - #else - _SOKOL_UNUSED(ctx); - #endif + _SG_GL_CHECK_ERROR(); } _SOKOL_PRIVATE sg_resource_state _sg_gl_create_buffer(_sg_buffer_t* buf, const sg_buffer_desc* desc) { @@ -7016,15 +6656,14 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_buffer(_sg_buffer_t* buf, const s _SG_GL_CHECK_ERROR(); _sg_buffer_common_init(&buf->cmn, desc); buf->gl.ext_buffers = (0 != desc->gl_buffers[0]); - GLenum gl_target = _sg_gl_buffer_target(buf->cmn.type); - GLenum gl_usage = _sg_gl_usage(buf->cmn.usage); + const GLenum gl_target = _sg_gl_buffer_target(buf->cmn.type); + const GLenum gl_usage = _sg_gl_usage(buf->cmn.usage); for (int slot = 0; slot < buf->cmn.num_slots; slot++) { GLuint gl_buf = 0; if (buf->gl.ext_buffers) { SOKOL_ASSERT(desc->gl_buffers[slot]); gl_buf = desc->gl_buffers[slot]; - } - else { + } else { glGenBuffers(1, &gl_buf); SOKOL_ASSERT(gl_buf); _sg_gl_cache_store_buffer_binding(gl_target); @@ -7068,180 +6707,130 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_image(_sg_image_t* img, const sg_ _sg_image_common_init(&img->cmn, desc); img->gl.ext_textures = (0 != desc->gl_textures[0]); - /* check if texture format is support */ + // check if texture format is support if (!_sg_gl_supported_texture_format(img->cmn.pixel_format)) { _SG_ERROR(GL_TEXTURE_FORMAT_NOT_SUPPORTED); return SG_RESOURCESTATE_FAILED; } - /* check for optional texture types */ - if ((img->cmn.type == SG_IMAGETYPE_3D) && !_sg.features.imagetype_3d) { - _SG_ERROR(GL_3D_TEXTURES_NOT_SUPPORTED); - return SG_RESOURCESTATE_FAILED; - } - if ((img->cmn.type == SG_IMAGETYPE_ARRAY) && !_sg.features.imagetype_array) { - _SG_ERROR(GL_ARRAY_TEXTURES_NOT_SUPPORTED); - return SG_RESOURCESTATE_FAILED; - } - #if !defined(SOKOL_GLES2) - bool msaa = false; - if (!_sg.gl.gles2) { - msaa = (img->cmn.sample_count > 1) && (_sg.features.msaa_render_targets); - } - #endif + img->gl.target = _sg_gl_texture_target(img->cmn.type); + const GLenum gl_internal_format = _sg_gl_teximage_internal_format(img->cmn.pixel_format); - if (_sg_is_valid_rendertarget_depth_format(img->cmn.pixel_format)) { - /* special case depth-stencil-buffer? */ - SOKOL_ASSERT((img->cmn.usage == SG_USAGE_IMMUTABLE) && (img->cmn.num_slots == 1)); - SOKOL_ASSERT(!img->gl.ext_textures); /* cannot provide external texture for depth images */ - glGenRenderbuffers(1, &img->gl.depth_render_buffer); - glBindRenderbuffer(GL_RENDERBUFFER, img->gl.depth_render_buffer); - GLenum gl_depth_format = _sg_gl_depth_attachment_format(img->cmn.pixel_format); - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2 && msaa) { - glRenderbufferStorageMultisample(GL_RENDERBUFFER, img->cmn.sample_count, gl_depth_format, img->cmn.width, img->cmn.height); - } - else - #endif - { - glRenderbufferStorage(GL_RENDERBUFFER, gl_depth_format, img->cmn.width, img->cmn.height); - } + // if this is a MSAA render target, need to create a separate render buffer + const bool msaa = (img->cmn.sample_count > 1); + if (img->cmn.render_target && msaa) { + glGenRenderbuffers(1, &img->gl.msaa_render_buffer); + glBindRenderbuffer(GL_RENDERBUFFER, img->gl.msaa_render_buffer); + glRenderbufferStorageMultisample(GL_RENDERBUFFER, img->cmn.sample_count, gl_internal_format, img->cmn.width, img->cmn.height); } - else { - /* regular color texture */ - img->gl.target = _sg_gl_texture_target(img->cmn.type); - const GLenum gl_internal_format = _sg_gl_teximage_internal_format(img->cmn.pixel_format); - /* if this is a MSAA render target, need to create a separate render buffer */ - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2 && img->cmn.render_target && msaa) { - glGenRenderbuffers(1, &img->gl.msaa_render_buffer); - glBindRenderbuffer(GL_RENDERBUFFER, img->gl.msaa_render_buffer); - glRenderbufferStorageMultisample(GL_RENDERBUFFER, img->cmn.sample_count, gl_internal_format, img->cmn.width, img->cmn.height); + if (img->gl.ext_textures) { + // inject externally GL textures + for (int slot = 0; slot < img->cmn.num_slots; slot++) { + SOKOL_ASSERT(desc->gl_textures[slot]); + img->gl.tex[slot] = desc->gl_textures[slot]; } - #endif - - if (img->gl.ext_textures) { - /* inject externally GL textures */ - for (int slot = 0; slot < img->cmn.num_slots; slot++) { - SOKOL_ASSERT(desc->gl_textures[slot]); - img->gl.tex[slot] = desc->gl_textures[slot]; - } - if (desc->gl_texture_target) { - img->gl.target = (GLenum)desc->gl_texture_target; - } + if (desc->gl_texture_target) { + img->gl.target = (GLenum)desc->gl_texture_target; } - else { - /* create our own GL texture(s) */ - const GLenum gl_format = _sg_gl_teximage_format(img->cmn.pixel_format); - const bool is_compressed = _sg_is_compressed_pixel_format(img->cmn.pixel_format); - for (int slot = 0; slot < img->cmn.num_slots; slot++) { - glGenTextures(1, &img->gl.tex[slot]); - SOKOL_ASSERT(img->gl.tex[slot]); - _sg_gl_cache_store_texture_binding(0); - _sg_gl_cache_bind_texture(0, img->gl.target, img->gl.tex[slot]); - GLenum gl_min_filter = _sg_gl_filter(img->cmn.min_filter); - GLenum gl_mag_filter = _sg_gl_filter(img->cmn.mag_filter); - glTexParameteri(img->gl.target, GL_TEXTURE_MIN_FILTER, (GLint)gl_min_filter); - glTexParameteri(img->gl.target, GL_TEXTURE_MAG_FILTER, (GLint)gl_mag_filter); - if (_sg.gl.ext_anisotropic && (img->cmn.max_anisotropy > 1)) { - GLint max_aniso = (GLint) img->cmn.max_anisotropy; - if (max_aniso > _sg.gl.max_anisotropy) { - max_aniso = _sg.gl.max_anisotropy; - } - glTexParameteri(img->gl.target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_aniso); - } - if (img->cmn.type == SG_IMAGETYPE_CUBE) { - glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } else { + // create our own GL texture(s) + const GLenum gl_format = _sg_gl_teximage_format(img->cmn.pixel_format); + const bool is_compressed = _sg_is_compressed_pixel_format(img->cmn.pixel_format); + for (int slot = 0; slot < img->cmn.num_slots; slot++) { + glGenTextures(1, &img->gl.tex[slot]); + SOKOL_ASSERT(img->gl.tex[slot]); + _sg_gl_cache_store_texture_binding(0); + _sg_gl_cache_bind_texture(0, img->gl.target, img->gl.tex[slot]); + const GLenum gl_min_filter = _sg_gl_filter(img->cmn.min_filter); + const GLenum gl_mag_filter = _sg_gl_filter(img->cmn.mag_filter); + glTexParameteri(img->gl.target, GL_TEXTURE_MIN_FILTER, (GLint)gl_min_filter); + glTexParameteri(img->gl.target, GL_TEXTURE_MAG_FILTER, (GLint)gl_mag_filter); + if (_sg.gl.ext_anisotropic && (img->cmn.max_anisotropy > 1)) { + GLint max_aniso = (GLint) img->cmn.max_anisotropy; + if (max_aniso > _sg.gl.max_anisotropy) { + max_aniso = _sg.gl.max_anisotropy; } - else { - glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_S, (GLint)_sg_gl_wrap(img->cmn.wrap_u)); - glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_T, (GLint)_sg_gl_wrap(img->cmn.wrap_v)); - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2 && (img->cmn.type == SG_IMAGETYPE_3D)) { - glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_R, (GLint)_sg_gl_wrap(img->cmn.wrap_w)); - } - #endif - #if defined(SOKOL_GLCORE33) - float border[4]; - switch (img->cmn.border_color) { - case SG_BORDERCOLOR_TRANSPARENT_BLACK: - border[0] = 0.0f; border[1] = 0.0f; border[2] = 0.0f; border[3] = 0.0f; - break; - case SG_BORDERCOLOR_OPAQUE_WHITE: - border[0] = 1.0f; border[1] = 1.0f; border[2] = 1.0f; border[3] = 1.0f; - break; - default: - border[0] = 0.0f; border[1] = 0.0f; border[2] = 0.0f; border[3] = 1.0f; - break; - } - glTexParameterfv(img->gl.target, GL_TEXTURE_BORDER_COLOR, border); - #endif + glTexParameteri(img->gl.target, GL_TEXTURE_MAX_ANISOTROPY_EXT, max_aniso); + } + if (img->cmn.type == SG_IMAGETYPE_CUBE) { + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + } else { + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_S, (GLint)_sg_gl_wrap(img->cmn.wrap_u)); + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_T, (GLint)_sg_gl_wrap(img->cmn.wrap_v)); + if (img->cmn.type == SG_IMAGETYPE_3D) { + glTexParameteri(img->gl.target, GL_TEXTURE_WRAP_R, (GLint)_sg_gl_wrap(img->cmn.wrap_w)); } - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - /* GL spec has strange defaults for mipmap min/max lod: -1000 to +1000 */ - const float min_lod = _sg_clamp(desc->min_lod, 0.0f, 1000.0f); - const float max_lod = _sg_clamp(desc->max_lod, 0.0f, 1000.0f); - glTexParameterf(img->gl.target, GL_TEXTURE_MIN_LOD, min_lod); - glTexParameterf(img->gl.target, GL_TEXTURE_MAX_LOD, max_lod); + #if defined(SOKOL_GLCORE33) + float border[4]; + switch (img->cmn.border_color) { + case SG_BORDERCOLOR_TRANSPARENT_BLACK: + border[0] = 0.0f; border[1] = 0.0f; border[2] = 0.0f; border[3] = 0.0f; + break; + case SG_BORDERCOLOR_OPAQUE_WHITE: + border[0] = 1.0f; border[1] = 1.0f; border[2] = 1.0f; border[3] = 1.0f; + break; + default: + border[0] = 0.0f; border[1] = 0.0f; border[2] = 0.0f; border[3] = 1.0f; + break; } + glTexParameterfv(img->gl.target, GL_TEXTURE_BORDER_COLOR, border); #endif - const int num_faces = img->cmn.type == SG_IMAGETYPE_CUBE ? 6 : 1; - int data_index = 0; - for (int face_index = 0; face_index < num_faces; face_index++) { - for (int mip_index = 0; mip_index < img->cmn.num_mipmaps; mip_index++, data_index++) { - GLenum gl_img_target = img->gl.target; - if (SG_IMAGETYPE_CUBE == img->cmn.type) { - gl_img_target = _sg_gl_cubeface_target(face_index); - } - const GLvoid* data_ptr = desc->data.subimage[face_index][mip_index].ptr; - int mip_width = img->cmn.width >> mip_index; - if (mip_width == 0) { - mip_width = 1; + } + /* GL spec has strange defaults for mipmap min/max lod: -1000 to +1000 */ + const float min_lod = _sg_clamp(desc->min_lod, 0.0f, 1000.0f); + const float max_lod = _sg_clamp(desc->max_lod, 0.0f, 1000.0f); + glTexParameterf(img->gl.target, GL_TEXTURE_MIN_LOD, min_lod); + glTexParameterf(img->gl.target, GL_TEXTURE_MAX_LOD, max_lod); + const int num_faces = img->cmn.type == SG_IMAGETYPE_CUBE ? 6 : 1; + int data_index = 0; + for (int face_index = 0; face_index < num_faces; face_index++) { + for (int mip_index = 0; mip_index < img->cmn.num_mipmaps; mip_index++, data_index++) { + GLenum gl_img_target = img->gl.target; + if (SG_IMAGETYPE_CUBE == img->cmn.type) { + gl_img_target = _sg_gl_cubeface_target(face_index); + } + const GLvoid* data_ptr = desc->data.subimage[face_index][mip_index].ptr; + int mip_width = img->cmn.width >> mip_index; + if (mip_width == 0) { + mip_width = 1; + } + int mip_height = img->cmn.height >> mip_index; + if (mip_height == 0) { + mip_height = 1; + } + if ((SG_IMAGETYPE_2D == img->cmn.type) || (SG_IMAGETYPE_CUBE == img->cmn.type)) { + if (is_compressed) { + const GLsizei data_size = (GLsizei) desc->data.subimage[face_index][mip_index].size; + glCompressedTexImage2D(gl_img_target, mip_index, gl_internal_format, + mip_width, mip_height, 0, data_size, data_ptr); + } else { + const GLenum gl_type = _sg_gl_teximage_type(img->cmn.pixel_format); + glTexImage2D(gl_img_target, mip_index, (GLint)gl_internal_format, + mip_width, mip_height, 0, gl_format, gl_type, data_ptr); } - int mip_height = img->cmn.height >> mip_index; - if (mip_height == 0) { - mip_height = 1; + } else if ((SG_IMAGETYPE_3D == img->cmn.type) || (SG_IMAGETYPE_ARRAY == img->cmn.type)) { + int mip_depth = img->cmn.num_slices; + if (SG_IMAGETYPE_3D == img->cmn.type) { + mip_depth >>= mip_index; } - if ((SG_IMAGETYPE_2D == img->cmn.type) || (SG_IMAGETYPE_CUBE == img->cmn.type)) { - if (is_compressed) { - const GLsizei data_size = (GLsizei) desc->data.subimage[face_index][mip_index].size; - glCompressedTexImage2D(gl_img_target, mip_index, gl_internal_format, - mip_width, mip_height, 0, data_size, data_ptr); - } - else { - const GLenum gl_type = _sg_gl_teximage_type(img->cmn.pixel_format); - glTexImage2D(gl_img_target, mip_index, (GLint)gl_internal_format, - mip_width, mip_height, 0, gl_format, gl_type, data_ptr); - } + if (mip_depth == 0) { + mip_depth = 1; } - #if !defined(SOKOL_GLES2) - else if (!_sg.gl.gles2 && ((SG_IMAGETYPE_3D == img->cmn.type) || (SG_IMAGETYPE_ARRAY == img->cmn.type))) { - int mip_depth = img->cmn.num_slices; - if (SG_IMAGETYPE_3D == img->cmn.type) { - mip_depth >>= mip_index; - } - if (mip_depth == 0) { - mip_depth = 1; - } - if (is_compressed) { - const GLsizei data_size = (GLsizei) desc->data.subimage[face_index][mip_index].size; - glCompressedTexImage3D(gl_img_target, mip_index, gl_internal_format, - mip_width, mip_height, mip_depth, 0, data_size, data_ptr); - } - else { - const GLenum gl_type = _sg_gl_teximage_type(img->cmn.pixel_format); - glTexImage3D(gl_img_target, mip_index, (GLint)gl_internal_format, - mip_width, mip_height, mip_depth, 0, gl_format, gl_type, data_ptr); - } + if (is_compressed) { + const GLsizei data_size = (GLsizei) desc->data.subimage[face_index][mip_index].size; + glCompressedTexImage3D(gl_img_target, mip_index, gl_internal_format, + mip_width, mip_height, mip_depth, 0, data_size, data_ptr); + } else { + const GLenum gl_type = _sg_gl_teximage_type(img->cmn.pixel_format); + glTexImage3D(gl_img_target, mip_index, (GLint)gl_internal_format, + mip_width, mip_height, mip_depth, 0, gl_format, gl_type, data_ptr); } - #endif } } - _sg_gl_cache_restore_texture_binding(0); } + _sg_gl_cache_restore_texture_binding(0); } } _SG_GL_CHECK_ERROR(); @@ -7259,9 +6848,6 @@ _SOKOL_PRIVATE void _sg_gl_discard_image(_sg_image_t* img) { } } } - if (img->gl.depth_render_buffer) { - glDeleteRenderbuffers(1, &img->gl.depth_render_buffer); - } if (img->gl.msaa_render_buffer) { glDeleteRenderbuffers(1, &img->gl.msaa_render_buffer); } @@ -7301,7 +6887,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_shader(_sg_shader_t* shd, const s _sg_shader_common_init(&shd->cmn, desc); - /* copy vertex attribute names over, these are required for GLES2, and optional for GLES3 and GL3.x */ + /* copy vertex attribute names over, these are used by, but optional on GLES3 and GL3.x */ for (int i = 0; i < SG_MAX_VERTEX_ATTRIBUTES; i++) { _sg_strcpy(&shd->gl.attrs[i].name, desc->attrs[i].name); } @@ -7396,8 +6982,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_shader(_sg_shader_t* shd, const s if (gl_loc != -1) { gl_img->gl_tex_slot = gl_tex_slot++; glUniform1i(gl_loc, gl_img->gl_tex_slot); - } - else { + } else { gl_img->gl_tex_slot = -1; } } @@ -7462,8 +7047,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_pipeline(_sg_pipeline_t* pip, _sg gl_attr->vb_index = (int8_t) a_desc->buffer_index; if (step_func == SG_VERTEXSTEP_PER_VERTEX) { gl_attr->divisor = 0; - } - else { + } else { gl_attr->divisor = (int8_t) step_rate; pip->cmn.use_instanced_draw = true; } @@ -7488,8 +7072,38 @@ _SOKOL_PRIVATE void _sg_gl_discard_pipeline(_sg_pipeline_t* pip) { _sg_gl_cache_invalidate_pipeline(pip); } +_SOKOL_PRIVATE void _sg_gl_fb_attach_texture(const _sg_gl_attachment_t* gl_att, const _sg_pass_attachment_common_t* cmn_att, GLenum gl_att_type) { + const _sg_image_t* img = gl_att->image; + SOKOL_ASSERT(img); + const GLuint gl_tex = img->gl.tex[0]; + SOKOL_ASSERT(gl_tex); + const int mip_level = cmn_att->mip_level; + const int slice = cmn_att->slice; + switch (img->cmn.type) { + case SG_IMAGETYPE_2D: + glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att_type, GL_TEXTURE_2D, gl_tex, mip_level); + break; + case SG_IMAGETYPE_CUBE: + glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att_type, _sg_gl_cubeface_target(slice), gl_tex, mip_level); + break; + default: + glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_att_type, gl_tex, mip_level, slice); + break; + } +} + +_SOKOL_PRIVATE GLenum _sg_gl_depth_stencil_attachment_type(const _sg_gl_attachment_t* ds_att) { + const _sg_image_t* img = ds_att->image; + SOKOL_ASSERT(img); + if (_sg_is_depth_stencil_format(img->cmn.pixel_format)) { + return GL_DEPTH_STENCIL_ATTACHMENT; + } else { + return GL_DEPTH_ATTACHMENT; + } +} + /* - _sg_create_pass + _sg_gl_create_pass att_imgs must point to a _sg_image* att_imgs[SG_MAX_COLOR_ATTACHMENTS+1] array, first entries are the color attachment images (or nullptr), last entry @@ -7502,7 +7116,7 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_pass(_sg_pass_t* pass, _sg_image_ _sg_pass_common_init(&pass->cmn, desc); - /* copy image pointers */ + // copy image pointers const sg_pass_attachment_desc* att_desc; for (int i = 0; i < pass->cmn.num_color_atts; i++) { att_desc = &desc->color_attachments[i]; @@ -7521,129 +7135,79 @@ _SOKOL_PRIVATE sg_resource_state _sg_gl_create_pass(_sg_pass_t* pass, _sg_image_ pass->gl.ds_att.image = att_images[ds_img_index]; } - /* store current framebuffer binding (restored at end of function) */ + // store current framebuffer binding (restored at end of function) GLuint gl_orig_fb; glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint*)&gl_orig_fb); - /* create a framebuffer object */ + // create a framebuffer object glGenFramebuffers(1, &pass->gl.fb); glBindFramebuffer(GL_FRAMEBUFFER, pass->gl.fb); - /* attach msaa render buffer or textures */ + // attach msaa render buffer or textures const bool is_msaa = (0 != att_images[0]->gl.msaa_render_buffer); if (is_msaa) { - for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + for (int i = 0; i < pass->cmn.num_color_atts; i++) { const _sg_image_t* att_img = pass->gl.color_atts[i].image; - if (att_img) { - const GLuint gl_render_buffer = att_img->gl.msaa_render_buffer; - SOKOL_ASSERT(gl_render_buffer); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, (GLenum)(GL_COLOR_ATTACHMENT0+i), GL_RENDERBUFFER, gl_render_buffer); - } + SOKOL_ASSERT(att_img); + const GLuint gl_render_buffer = att_img->gl.msaa_render_buffer; + SOKOL_ASSERT(gl_render_buffer); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, (GLenum)(GL_COLOR_ATTACHMENT0+i), GL_RENDERBUFFER, gl_render_buffer); } - } - else { - for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { - const _sg_image_t* att_img = pass->gl.color_atts[i].image; - const int mip_level = pass->cmn.color_atts[i].mip_level; - const int slice = pass->cmn.color_atts[i].slice; - if (att_img) { - const GLuint gl_tex = att_img->gl.tex[0]; - SOKOL_ASSERT(gl_tex); - const GLenum gl_att = (GLenum)(GL_COLOR_ATTACHMENT0 + i); - switch (att_img->cmn.type) { - case SG_IMAGETYPE_2D: - glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att, GL_TEXTURE_2D, gl_tex, mip_level); - break; - case SG_IMAGETYPE_CUBE: - glFramebufferTexture2D(GL_FRAMEBUFFER, gl_att, _sg_gl_cubeface_target(slice), gl_tex, mip_level); - break; - default: - /* 3D- or array-texture */ - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - glFramebufferTextureLayer(GL_FRAMEBUFFER, gl_att, gl_tex, mip_level, slice); - } - #endif - break; - } - } + if (pass->gl.ds_att.image) { + const GLenum gl_att = _sg_gl_depth_stencil_attachment_type(&pass->gl.ds_att); + const _sg_image_t* att_img = pass->gl.ds_att.image; + const GLuint gl_render_buffer = att_img->gl.msaa_render_buffer; + SOKOL_ASSERT(gl_render_buffer); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, gl_att, GL_RENDERBUFFER, gl_render_buffer); } - } - - /* attach depth-stencil buffer to framebuffer */ - if (pass->gl.ds_att.image) { - const GLuint gl_render_buffer = pass->gl.ds_att.image->gl.depth_render_buffer; - SOKOL_ASSERT(gl_render_buffer); - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, gl_render_buffer); - if (_sg_is_depth_stencil_format(pass->gl.ds_att.image->cmn.pixel_format)) { - glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, gl_render_buffer); + } else { + for (int i = 0; i < pass->cmn.num_color_atts; i++) { + const GLenum gl_att_type = (GLenum)(GL_COLOR_ATTACHMENT0 + i); + _sg_gl_fb_attach_texture(&pass->gl.color_atts[i], &pass->cmn.color_atts[i], gl_att_type); + } + if (pass->gl.ds_att.image) { + const GLenum gl_att_type = _sg_gl_depth_stencil_attachment_type(&pass->gl.ds_att); + _sg_gl_fb_attach_texture(&pass->gl.ds_att, &pass->cmn.ds_att, gl_att_type); } } - /* check if framebuffer is complete */ + // check if framebuffer is complete if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { _SG_ERROR(GL_FRAMEBUFFER_INCOMPLETE); return SG_RESOURCESTATE_FAILED; } - /* setup color attachments for the framebuffer */ - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - GLenum att[SG_MAX_COLOR_ATTACHMENTS] = { - GL_COLOR_ATTACHMENT0, - GL_COLOR_ATTACHMENT1, - GL_COLOR_ATTACHMENT2, - GL_COLOR_ATTACHMENT3 - }; - glDrawBuffers(pass->cmn.num_color_atts, att); - } - #endif + // setup color attachments for the framebuffer + const GLenum att[SG_MAX_COLOR_ATTACHMENTS] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3 + }; + glDrawBuffers(pass->cmn.num_color_atts, att); - /* create MSAA resolve framebuffers if necessary */ + // create MSAA resolve framebuffers if necessary if (is_msaa) { - for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { + for (int i = 0; i < pass->cmn.num_color_atts; i++) { _sg_gl_attachment_t* gl_att = &pass->gl.color_atts[i]; + SOKOL_ASSERT(gl_att->image); _sg_pass_attachment_t* cmn_att = &pass->cmn.color_atts[i]; - if (gl_att->image) { - SOKOL_ASSERT(0 == gl_att->gl_msaa_resolve_buffer); - glGenFramebuffers(1, &gl_att->gl_msaa_resolve_buffer); - glBindFramebuffer(GL_FRAMEBUFFER, gl_att->gl_msaa_resolve_buffer); - const GLuint gl_tex = gl_att->image->gl.tex[0]; - SOKOL_ASSERT(gl_tex); - switch (gl_att->image->cmn.type) { - case SG_IMAGETYPE_2D: - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - GL_TEXTURE_2D, gl_tex, cmn_att->mip_level); - break; - case SG_IMAGETYPE_CUBE: - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, - _sg_gl_cubeface_target(cmn_att->slice), gl_tex, cmn_att->mip_level); - break; - default: - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, gl_tex, cmn_att->mip_level, cmn_att->slice); - } - #endif - break; - } - /* check if framebuffer is complete */ - if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { - _SG_ERROR(GL_MSAA_FRAMEBUFFER_INCOMPLETE); - return SG_RESOURCESTATE_FAILED; - } - /* setup color attachments for the framebuffer */ - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2) { - const GLenum gl_draw_bufs = GL_COLOR_ATTACHMENT0; - glDrawBuffers(1, &gl_draw_bufs); - } - #endif + SOKOL_ASSERT(0 == gl_att->gl_msaa_resolve_buffer); + glGenFramebuffers(1, &gl_att->gl_msaa_resolve_buffer); + glBindFramebuffer(GL_FRAMEBUFFER, gl_att->gl_msaa_resolve_buffer); + _sg_gl_fb_attach_texture(gl_att, cmn_att, GL_COLOR_ATTACHMENT0); + // check if framebuffer is complete + if (glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) { + _SG_ERROR(GL_MSAA_FRAMEBUFFER_INCOMPLETE); + return SG_RESOURCESTATE_FAILED; } + // setup color attachments for the framebuffer + const GLenum gl_draw_bufs = GL_COLOR_ATTACHMENT0; + glDrawBuffers(1, &gl_draw_bufs); } } - /* restore original framebuffer binding */ + // restore original framebuffer binding glBindFramebuffer(GL_FRAMEBUFFER, gl_orig_fb); _SG_GL_CHECK_ERROR(); return SG_RESOURCESTATE_VALID; @@ -7680,25 +7244,21 @@ _SOKOL_PRIVATE _sg_image_t* _sg_gl_pass_ds_image(const _sg_pass_t* pass) { } _SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* action, int w, int h) { - /* FIXME: what if a texture used as render target is still bound, should we - unbind all currently bound textures in begin pass? */ + // FIXME: what if a texture used as render target is still bound, should we + // unbind all currently bound textures in begin pass? SOKOL_ASSERT(action); SOKOL_ASSERT(!_sg.gl.in_pass); _SG_GL_CHECK_ERROR(); _sg.gl.in_pass = true; - _sg.gl.cur_pass = pass; /* can be 0 */ + _sg.gl.cur_pass = pass; // can be 0 if (pass) { _sg.gl.cur_pass_id.id = pass->slot.id; - } - else { + } else { _sg.gl.cur_pass_id.id = SG_INVALID_ID; } _sg.gl.cur_pass_width = w; _sg.gl.cur_pass_height = h; - /* number of color attachments */ - const int num_color_atts = pass ? pass->cmn.num_color_atts : 1; - // bind the render pass framebuffer // // FIXME: Disabling SRGB conversion for the default framebuffer is @@ -7715,8 +7275,7 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* ac #endif glBindFramebuffer(GL_FRAMEBUFFER, pass->gl.fb); - } - else { + } else { // default pass SOKOL_ASSERT(_sg.gl.cur_context); #if defined(SOKOL_GLCORE33) @@ -7727,11 +7286,14 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* ac glViewport(0, 0, w, h); glScissor(0, 0, w, h); - /* clear color and depth-stencil attachments if needed */ - bool clear_color = false; + // number of color attachments + const int num_color_atts = pass ? pass->cmn.num_color_atts : 1; + + // clear color and depth-stencil attachments if needed + bool clear_any_color = false; for (int i = 0; i < num_color_atts; i++) { if (SG_ACTION_CLEAR == action->colors[i].action) { - clear_color = true; + clear_any_color = true; break; } } @@ -7739,7 +7301,7 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* ac const bool clear_stencil = (action->stencil.action == SG_ACTION_CLEAR); bool need_pip_cache_flush = false; - if (clear_color) { + if (clear_any_color) { bool need_color_mask_flush = false; // NOTE: not a bug to iterate over all possible color attachments for (int i = 0; i < SG_MAX_COLOR_ATTACHMENTS; i++) { @@ -7773,64 +7335,26 @@ _SOKOL_PRIVATE void _sg_gl_begin_pass(_sg_pass_t* pass, const sg_pass_action* ac } } if (need_pip_cache_flush) { - /* we messed with the state cache directly, need to clear cached - pipeline to force re-evaluation in next sg_apply_pipeline() */ + // we messed with the state cache directly, need to clear cached + // pipeline to force re-evaluation in next sg_apply_pipeline() _sg.gl.cache.cur_pipeline = 0; _sg.gl.cache.cur_pipeline_id.id = SG_INVALID_ID; } - bool use_mrt_clear = (0 != pass); - #if defined(SOKOL_GLES2) - use_mrt_clear = false; - #else - if (_sg.gl.gles2) { - use_mrt_clear = false; - } - #endif - if (!use_mrt_clear) { - GLbitfield clear_mask = 0; - if (clear_color) { - clear_mask |= GL_COLOR_BUFFER_BIT; - const sg_color c = action->colors[0].value; - glClearColor(c.r, c.g, c.b, c.a); - } - if (clear_depth) { - clear_mask |= GL_DEPTH_BUFFER_BIT; - #ifdef SOKOL_GLCORE33 - glClearDepth(action->depth.value); - #else - glClearDepthf(action->depth.value); - #endif - } - if (clear_stencil) { - clear_mask |= GL_STENCIL_BUFFER_BIT; - glClearStencil(action->stencil.value); - } - if (0 != clear_mask) { - glClear(clear_mask); + for (int i = 0; i < num_color_atts; i++) { + if (action->colors[i].action == SG_ACTION_CLEAR) { + glClearBufferfv(GL_COLOR, i, &action->colors[i].value.r); } } - #if !defined SOKOL_GLES2 - else { - SOKOL_ASSERT(pass); - for (int i = 0; i < num_color_atts; i++) { - if (action->colors[i].action == SG_ACTION_CLEAR) { - glClearBufferfv(GL_COLOR, i, &action->colors[i].value.r); - } - } - if (pass->gl.ds_att.image) { - if (clear_depth && clear_stencil) { - glClearBufferfi(GL_DEPTH_STENCIL, 0, action->depth.value, action->stencil.value); - } - else if (clear_depth) { - glClearBufferfv(GL_DEPTH, 0, &action->depth.value); - } - else if (clear_stencil) { - GLint val = (GLint) action->stencil.value; - glClearBufferiv(GL_STENCIL, 0, &val); - } + if ((pass == 0) || (pass->gl.ds_att.image)) { + if (clear_depth && clear_stencil) { + glClearBufferfi(GL_DEPTH_STENCIL, 0, action->depth.value, action->stencil.value); + } else if (clear_depth) { + glClearBufferfv(GL_DEPTH, 0, &action->depth.value); + } else if (clear_stencil) { + GLint val = (GLint) action->stencil.value; + glClearBufferiv(GL_STENCIL, 0, &val); } } - #endif _SG_GL_CHECK_ERROR(); } @@ -7840,8 +7364,7 @@ _SOKOL_PRIVATE void _sg_gl_end_pass(void) { /* if this was an offscreen pass, and MSAA rendering was used, need to resolve into the pass images */ - #if !defined(SOKOL_GLES2) - if (!_sg.gl.gles2 && _sg.gl.cur_pass) { + if (_sg.gl.cur_pass) { /* check if the pass object is still valid */ const _sg_pass_t* pass = _sg.gl.cur_pass; SOKOL_ASSERT(pass->slot.id == _sg.gl.cur_pass_id.id); @@ -7852,21 +7375,25 @@ _SOKOL_PRIVATE void _sg_gl_end_pass(void) { SOKOL_ASSERT(pass->gl.color_atts[0].image); const int w = pass->gl.color_atts[0].image->cmn.width; const int h = pass->gl.color_atts[0].image->cmn.height; - for (int att_index = 0; att_index < SG_MAX_COLOR_ATTACHMENTS; att_index++) { + const int num_atts = pass->cmn.num_color_atts; + for (int att_index = 0; att_index < num_atts; att_index++) { const _sg_gl_attachment_t* gl_att = &pass->gl.color_atts[att_index]; - if (gl_att->image) { - SOKOL_ASSERT(gl_att->gl_msaa_resolve_buffer); - glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gl_att->gl_msaa_resolve_buffer); - glReadBuffer((GLenum)(GL_COLOR_ATTACHMENT0 + att_index)); - glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_NEAREST); - } - else { - break; - } + SOKOL_ASSERT(gl_att->gl_msaa_resolve_buffer); + glBindFramebuffer(GL_DRAW_FRAMEBUFFER, gl_att->gl_msaa_resolve_buffer); + glReadBuffer((GLenum)(GL_COLOR_ATTACHMENT0 + att_index)); + glBlitFramebuffer(0, 0, w, h, 0, 0, w, h, GL_COLOR_BUFFER_BIT, GL_NEAREST); } + #if defined(SOKOL_GLES3) + const GLenum color_att[SG_MAX_COLOR_ATTACHMENTS] = { + GL_COLOR_ATTACHMENT0, + GL_COLOR_ATTACHMENT1, + GL_COLOR_ATTACHMENT2, + GL_COLOR_ATTACHMENT3 + }; + glInvalidateFramebuffer(GL_READ_FRAMEBUFFER, num_atts, color_att); + #endif } } - #endif _sg.gl.cur_pass = 0; _sg.gl.cur_pass_id.id = SG_INVALID_ID; _sg.gl.cur_pass_width = 0; @@ -7933,8 +7460,7 @@ _SOKOL_PRIVATE void _sg_gl_apply_pipeline(_sg_pipeline_t* pip) { _sg.gl.cache.polygon_offset_enabled = po_enabled; if (po_enabled) { glEnable(GL_POLYGON_OFFSET_FILL); - } - else { + } else { glDisable(GL_POLYGON_OFFSET_FILL); } } @@ -7949,8 +7475,7 @@ _SOKOL_PRIVATE void _sg_gl_apply_pipeline(_sg_pipeline_t* pip) { cache_ss->enabled = state_ss->enabled; if (state_ss->enabled) { glEnable(GL_STENCIL_TEST); - } - else { + } else { glDisable(GL_STENCIL_TEST); } } @@ -7999,8 +7524,7 @@ _SOKOL_PRIVATE void _sg_gl_apply_pipeline(_sg_pipeline_t* pip) { cache_bs->enabled = state_bs->enabled; if (state_bs->enabled) { glEnable(GL_BLEND); - } - else { + } else { glDisable(GL_BLEND); } } @@ -8060,8 +7584,7 @@ _SOKOL_PRIVATE void _sg_gl_apply_pipeline(_sg_pipeline_t* pip) { _sg.gl.cache.cull_mode = pip->gl.cull_mode; if (SG_CULLMODE_NONE == pip->gl.cull_mode) { glDisable(GL_CULL_FACE); - } - else { + } else { glEnable(GL_CULL_FACE); GLenum gl_mode = (SG_CULLMODE_FRONT == pip->gl.cull_mode) ? GL_FRONT : GL_BACK; glCullFace(gl_mode); @@ -8076,8 +7599,7 @@ _SOKOL_PRIVATE void _sg_gl_apply_pipeline(_sg_pipeline_t* pip) { _sg.gl.cache.alpha_to_coverage_enabled = pip->gl.alpha_to_coverage_enabled; if (pip->gl.alpha_to_coverage_enabled) { glEnable(GL_SAMPLE_ALPHA_TO_COVERAGE); - } - else { + } else { glDisable(GL_SAMPLE_ALPHA_TO_COVERAGE); } } @@ -8086,8 +7608,7 @@ _SOKOL_PRIVATE void _sg_gl_apply_pipeline(_sg_pipeline_t* pip) { _sg.gl.cache.sample_count = pip->gl.sample_count; if (pip->gl.sample_count > 1) { glEnable(GL_MULTISAMPLE); - } - else { + } else { glDisable(GL_MULTISAMPLE); } } @@ -8166,19 +7687,14 @@ _SOKOL_PRIVATE void _sg_gl_apply_bindings( glVertexAttribPointer(attr_index, attr->size, attr->type, attr->normalized, attr->stride, (const GLvoid*)(GLintptr)vb_offset); - #if defined(_SOKOL_GL_INSTANCING_ENABLED) - if (_sg.features.instancing) { - glVertexAttribDivisor(attr_index, (GLuint)attr->divisor); - } - #endif + glVertexAttribDivisor(attr_index, (GLuint)attr->divisor); cache_attr_dirty = true; } if (cache_attr->gl_attr.vb_index == -1) { glEnableVertexAttribArray(attr_index); cache_attr_dirty = true; } - } - else { + } else { /* attribute is disabled */ if (cache_attr->gl_attr.vb_index != -1) { glDisableVertexAttribArray(attr_index); @@ -8257,22 +7773,15 @@ _SOKOL_PRIVATE void _sg_gl_draw(int base_element, int num_elements, int num_inst const int ib_offset = _sg.gl.cache.cur_ib_offset; const GLvoid* indices = (const GLvoid*)(GLintptr)(base_element*i_size+ib_offset); if (_sg.gl.cache.cur_pipeline->cmn.use_instanced_draw) { - if (_sg.features.instancing) { - glDrawElementsInstanced(p_type, num_elements, i_type, indices, num_instances); - } - } - else { + glDrawElementsInstanced(p_type, num_elements, i_type, indices, num_instances); + } else { glDrawElements(p_type, num_elements, i_type, indices); } - } - else { + } else { /* non-indexed rendering */ if (_sg.gl.cache.cur_pipeline->cmn.use_instanced_draw) { - if (_sg.features.instancing) { - glDrawArraysInstanced(p_type, base_element, num_elements, num_instances); - } - } - else { + glDrawArraysInstanced(p_type, base_element, num_elements, num_instances); + } else { glDrawArrays(p_type, base_element, num_elements); } } @@ -8359,9 +7868,7 @@ _SOKOL_PRIVATE void _sg_gl_update_image(_sg_image_t* img, const sg_image_data* d mip_width, mip_height, gl_img_format, gl_img_type, data_ptr); - } - #if !defined(SOKOL_GLES2) - else if (!_sg.gl.gles2 && ((SG_IMAGETYPE_3D == img->cmn.type) || (SG_IMAGETYPE_ARRAY == img->cmn.type))) { + } else if ((SG_IMAGETYPE_3D == img->cmn.type) || (SG_IMAGETYPE_ARRAY == img->cmn.type)) { int mip_depth = img->cmn.num_slices >> mip_index; if (mip_depth == 0) { mip_depth = 1; @@ -8373,7 +7880,6 @@ _SOKOL_PRIVATE void _sg_gl_update_image(_sg_image_t* img, const sg_image_data* d data_ptr); } - #endif } } _sg_gl_cache_restore_texture_binding(0); @@ -9045,12 +8551,7 @@ _SOKOL_PRIVATE UINT8 _sg_d3d11_color_write_mask(sg_color_mask m) { _SOKOL_PRIVATE void _sg_d3d11_init_caps(void) { _sg.backend = SG_BACKEND_D3D11; - _sg.features.instancing = true; _sg.features.origin_top_left = true; - _sg.features.multiple_render_targets = true; - _sg.features.msaa_render_targets = true; - _sg.features.imagetype_3d = true; - _sg.features.imagetype_array = true; _sg.features.image_clamp_to_border = true; _sg.features.mrt_independent_blend_state = true; _sg.features.mrt_independent_write_mask = true; @@ -10822,12 +10323,7 @@ _SOKOL_PRIVATE void _sg_mtl_init_caps(void) { _sg.backend = SG_BACKEND_METAL_IOS; #endif #endif - _sg.features.instancing = true; _sg.features.origin_top_left = true; - _sg.features.multiple_render_targets = true; - _sg.features.msaa_render_targets = true; - _sg.features.imagetype_3d = true; - _sg.features.imagetype_array = true; #if defined(_SG_TARGET_MACOS) _sg.features.image_clamp_to_border = true; #else @@ -12233,7 +11729,7 @@ _SOKOL_PRIVATE WGPUTextureFormat _sg_wgpu_textureformat(sg_pixel_format p) { case SG_PIXELFORMAT_RGBA32UI: return WGPUTextureFormat_RGBA32Uint; case SG_PIXELFORMAT_RGBA32SI: return WGPUTextureFormat_RGBA32Sint; case SG_PIXELFORMAT_RGBA32F: return WGPUTextureFormat_RGBA32Float; - case SG_PIXELFORMAT_DEPTH: return WGPUTextureFormat_Depth24Plus; + case SG_PIXELFORMAT_DEPTH: return WGPUTextureFormat_Depth32Float; case SG_PIXELFORMAT_DEPTH_STENCIL: return WGPUTextureFormat_Depth24PlusStencil8; case SG_PIXELFORMAT_BC1_RGBA: return WGPUTextureFormat_BC1RGBAUnorm; case SG_PIXELFORMAT_BC2_RGBA: return WGPUTextureFormat_BC2RGBAUnorm; @@ -12361,12 +11857,7 @@ _SOKOL_PRIVATE WGPUColorWriteMaskFlags _sg_wgpu_colorwritemask(uint8_t m) { _SOKOL_PRIVATE void _sg_wgpu_init_caps(void) { _sg.backend = SG_BACKEND_WGPU; - _sg.features.instancing = true; _sg.features.origin_top_left = true; - _sg.features.multiple_render_targets = true; - _sg.features.msaa_render_targets = true; - _sg.features.imagetype_3d = true; - _sg.features.imagetype_array = true; _sg.features.image_clamp_to_border = false; _sg.features.mrt_independent_blend_state = true; _sg.features.mrt_independent_write_mask = true; @@ -14711,16 +14202,9 @@ _SOKOL_PRIVATE bool _sg_validate_image_desc(const sg_image_desc* desc) { if (desc->render_target) { SOKOL_ASSERT(((int)fmt >= 0) && ((int)fmt < _SG_PIXELFORMAT_NUM)); _SG_VALIDATE(_sg.formats[fmt].render, VALIDATE_IMAGEDESC_RT_PIXELFORMAT); - /* on GLES2, sample count for render targets is completely ignored */ - #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - if (!_sg.gl.gles2) { - #endif - if (desc->sample_count > 1) { - _SG_VALIDATE(_sg.features.msaa_render_targets && _sg.formats[fmt].msaa, VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT); - } - #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + if (desc->sample_count > 1) { + _SG_VALIDATE(_sg.formats[fmt].msaa, VALIDATE_IMAGEDESC_NO_MSAA_RT_SUPPORT); } - #endif _SG_VALIDATE(usage == SG_USAGE_IMMUTABLE, VALIDATE_IMAGEDESC_RT_IMMUTABLE); _SG_VALIDATE(desc->data.subimage[0][0].ptr==0, VALIDATE_IMAGEDESC_RT_NO_DATA); } @@ -14775,12 +14259,10 @@ _SOKOL_PRIVATE bool _sg_validate_shader_desc(const sg_shader_desc* desc) { _sg_validate_begin(); _SG_VALIDATE(desc->_start_canary == 0, VALIDATE_SHADERDESC_CANARY); _SG_VALIDATE(desc->_end_canary == 0, VALIDATE_SHADERDESC_CANARY); - #if defined(SOKOL_GLES2) - _SG_VALIDATE(0 != desc->attrs[0].name, VALIDATE_SHADERDESC_ATTR_NAMES); - #elif defined(SOKOL_D3D11) + #if defined(SOKOL_D3D11) _SG_VALIDATE(0 != desc->attrs[0].sem_name, VALIDATE_SHADERDESC_ATTR_SEMANTICS); #endif - #if defined(SOKOL_GLCORE33) || defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + #if defined(SOKOL_GLCORE33) || defined(SOKOL_GLES3) /* on GL, must provide shader source code */ _SG_VALIDATE(0 != desc->vs.source, VALIDATE_SHADERDESC_SOURCE); _SG_VALIDATE(0 != desc->fs.source, VALIDATE_SHADERDESC_SOURCE); @@ -14825,7 +14307,7 @@ _SOKOL_PRIVATE bool _sg_validate_shader_desc(const sg_shader_desc* desc) { const sg_shader_uniform_desc* u_desc = &ub_desc->uniforms[u_index]; if (u_desc->type != SG_UNIFORMTYPE_INVALID) { _SG_VALIDATE(uniforms_continuous, VALIDATE_SHADERDESC_NO_CONT_UB_MEMBERS); - #if defined(SOKOL_GLES2) || defined(SOKOL_GLES3) + #if defined(SOKOL_GLES3) _SG_VALIDATE(0 != u_desc->name, VALIDATE_SHADERDESC_UB_MEMBER_NAME); #endif const int array_count = u_desc->array_count; @@ -14862,9 +14344,6 @@ _SOKOL_PRIVATE bool _sg_validate_shader_desc(const sg_shader_desc* desc) { const sg_shader_image_desc* img_desc = &stage_desc->images[img_index]; if (img_desc->image_type != _SG_IMAGETYPE_DEFAULT) { _SG_VALIDATE(images_continuous, VALIDATE_SHADERDESC_NO_CONT_IMGS); - #if defined(SOKOL_GLES2) - _SG_VALIDATE(0 != img_desc->name, VALIDATE_SHADERDESC_IMG_NAME); - #endif } else { images_continuous = false; @@ -14909,10 +14388,7 @@ _SOKOL_PRIVATE bool _sg_validate_pipeline_desc(const sg_pipeline_desc* desc) { } _SG_VALIDATE(attrs_cont, VALIDATE_PIPELINEDESC_NO_ATTRS); SOKOL_ASSERT(a_desc->buffer_index < SG_MAX_SHADERSTAGE_BUFFERS); - #if defined(SOKOL_GLES2) - /* on GLES2, vertex attribute names must be provided */ - _SG_VALIDATE(!_sg_strempty(&shd->gl.attrs[attr_index].name), VALIDATE_PIPELINEDESC_ATTR_NAME); - #elif defined(SOKOL_D3D11) + #if defined(SOKOL_D3D11) /* on D3D11, semantic names (and semantic indices) must be provided */ _SG_VALIDATE(!_sg_strempty(&shd->d3d11.attrs[attr_index].sem_name), VALIDATE_PIPELINEDESC_ATTR_SEMANTICS); #endif diff --git a/sokol_glue.h b/sokol_glue.h index 74ecb7c3..7216f6a1 100644 --- a/sokol_glue.h +++ b/sokol_glue.h @@ -118,7 +118,6 @@ SOKOL_API_IMPL sg_context_desc sapp_sgcontext(void) { desc.color_format = (sg_pixel_format) sapp_color_format(); desc.depth_format = (sg_pixel_format) sapp_depth_format(); desc.sample_count = sapp_sample_count(); - desc.gl.force_gles2 = sapp_gles2(); desc.metal.device = sapp_metal_get_device(); desc.metal.renderpass_descriptor_cb = sapp_metal_get_renderpass_descriptor; desc.metal.drawable_cb = sapp_metal_get_drawable; diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index ba2891b9..3545b758 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,7 +4,7 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}) set(CMAKE_C_STANDARD 11) set(CMAKE_CXX_STANDARD 11) -# SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU, SOKOL_DUMMY +# SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU, SOKOL_DUMMY set(SOKOL_BACKEND "SOKOL_DUMMY_BACKEND" CACHE STRING "Select 3D backend API") set_property(CACHE SOKOL_BACKEND PROPERTY STRINGS SOKOL_GLCORE33 SOKOL_METAL SOKOL_D3D11 SOKOL_DUMMY_BACKEND) option(SOKOL_FORCE_EGL "Force EGL with GLCORE33 backend" OFF) diff --git a/tests/CMakePresets.json b/tests/CMakePresets.json index dca08c53..df7a5659 100644 --- a/tests/CMakePresets.json +++ b/tests/CMakePresets.json @@ -391,26 +391,6 @@ } }, { - "name": "emsc_webgl1_debug", - "generator": "Ninja", - "binaryDir": "build/emsc_webgl1_debug", - "toolchainFile": "build/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake", - "cacheVariables": { - "SOKOL_BACKEND": "SOKOL_GLES2", - "CMAKE_BUILD_TYPE": "Debug" - } - }, - { - "name": "emsc_webgl1_release", - "generator": "Ninja", - "binaryDir": "build/emsc_webgl1_release", - "toolchainFile": "build/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake", - "cacheVariables": { - "SOKOL_BACKEND": "SOKOL_GLES2", - "CMAKE_BUILD_TYPE": "Release" - } - }, - { "name": "android_debug", "generator": "Ninja", "binaryDir": "build/android_debug", @@ -665,14 +645,6 @@ "configurePreset": "emsc_webgl2_release" }, { - "name": "emsc_webgl1_debug", - "configurePreset": "emsc_webgl1_debug" - }, - { - "name": "emsc_webgl1_release", - "configurePreset": "emsc_webgl1_release" - }, - { "name": "android_debug", "configurePreset": "android_debug" }, diff --git a/tests/functional/force_dummy_backend.h b/tests/functional/force_dummy_backend.h index 21fd0995..22390e7d 100644 --- a/tests/functional/force_dummy_backend.h +++ b/tests/functional/force_dummy_backend.h @@ -1,6 +1,3 @@ -#if defined(SOKOL_GLES2) -#undef SOKOL_GLES2 -#endif #if defined(SOKOL_GLES3) #undef SOKOL_GLES3 #endif @@ -19,4 +16,3 @@ #ifndef SOKOL_DUMMY_BACKEND #define SOKOL_DUMMY_BACKEND #endif - diff --git a/tests/test_emscripten.sh b/tests/test_emscripten.sh index b00e853e..74f0ad1b 100755 --- a/tests/test_emscripten.sh +++ b/tests/test_emscripten.sh @@ -4,5 +4,3 @@ source test_common.sh setup_emsdk build emsc_webgl2_debug emsc_webgl2_debug build emsc_webgl2_release emsc_webgl2_release -build emsc_webgl1_debug emsc_webgl1_debug -build emsc_webgl1_release emsc_webgl1_release diff --git a/util/sokol_debugtext.h b/util/sokol_debugtext.h index 78ae60de..eed04361 100644 --- a/util/sokol_debugtext.h +++ b/util/sokol_debugtext.h @@ -18,7 +18,6 @@ used by sokol_gfx.h and sokol_app.h): SOKOL_GLCORE33 - SOKOL_GLES2 SOKOL_GLES3 SOKOL_D3D11 SOKOL_METAL @@ -2375,7 +2374,7 @@ static const uint8_t _sdtx_font_oric[2048] = { /* Embedded source code compiled with: - sokol-shdc -i debugtext.glsl -o debugtext.h -l glsl330:glsl100:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + sokol-shdc -i debugtext.glsl -o debugtext.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b (not that for Metal and D3D11 byte code, sokol-shdc must be run on macOS and Windows) @@ -2406,7 +2405,7 @@ static const uint8_t _sdtx_font_oric[2048] = { @program debugtext vs fs */ #if defined(SOKOL_GLCORE33) -static const char _sdtx_vs_src_glcore33[300] = { +static const char _sdtx_vs_src_glsl330[300] = { 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x6c,0x61, 0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, 0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74, @@ -2428,7 +2427,7 @@ static const char _sdtx_vs_src_glcore33[300] = { 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -static const char _sdtx_fs_src_glcore33[174] = { +static const char _sdtx_fs_src_glsl330[174] = { 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x33,0x30,0x0a,0x0a,0x75,0x6e, 0x69,0x66,0x6f,0x72,0x6d,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20, 0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63, @@ -2441,41 +2440,45 @@ static const char _sdtx_fs_src_glcore33[174] = { 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x2e,0x78,0x78,0x78,0x78, 0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -#elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) -static const char _sdtx_vs_src_gles2[266] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x0a,0x61,0x74, - 0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73, - 0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x76, - 0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74, - 0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30, - 0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x34,0x20,0x63, - 0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20, - 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f, - 0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, - 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65, - 0x63,0x34,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2a,0x20,0x76, - 0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x29,0x20, - 0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x2d,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30, - 0x29,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20, - 0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30, - 0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f, - 0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +#elif defined(SOKOL_GLES3) +static const char _sdtx_vs_src_glsl300es[303] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x30,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f, + 0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32, + 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74, + 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30, + 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32, + 0x2e,0x30,0x29,0x29,0x20,0x2b,0x20,0x76,0x65,0x63,0x32,0x28,0x2d,0x31,0x2e,0x30, + 0x2c,0x20,0x31,0x2e,0x30,0x29,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30, + 0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63, + 0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72, + 0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -static const char _sdtx_fs_src_gles2[212] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x70,0x72,0x65, - 0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,0x70,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20, - 0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66, - 0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65, - 0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e, - 0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b, - 0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, - 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, - 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c, - 0x5f,0x46,0x72,0x61,0x67,0x44,0x61,0x74,0x61,0x5b,0x30,0x5d,0x20,0x3d,0x20,0x74, - 0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76, - 0x29,0x2e,0x78,0x78,0x78,0x78,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a, - 0x7d,0x0a,0x0a,0x00, +static const char _sdtx_fs_src_glsl300es[247] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x29,0x2e,0x78,0x78,0x78,0x78,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; #elif defined(SOKOL_METAL) static const uint8_t _sdtx_vs_bytecode_metal_macos[2896] = { @@ -3545,7 +3548,7 @@ static const uint8_t _sdtx_fs_bytecode_wgpu[940] = { static const char* _sdtx_vs_src_dummy = ""; static const char* _sdtx_fs_src_dummy = ""; #else -#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" #endif // ███████ ████████ ██████ ██ ██ ██████ ████████ ███████ @@ -4035,11 +4038,11 @@ static void _sdtx_setup_common(void) { shd_desc.fs.images[0].image_type = SG_IMAGETYPE_2D; shd_desc.fs.images[0].sampler_type = SG_SAMPLERTYPE_FLOAT; #if defined(SOKOL_GLCORE33) - shd_desc.vs.source = _sdtx_vs_src_glcore33; - shd_desc.fs.source = _sdtx_fs_src_glcore33; - #elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - shd_desc.vs.source = _sdtx_vs_src_gles2; - shd_desc.fs.source = _sdtx_fs_src_gles2; + shd_desc.vs.source = _sdtx_vs_src_glsl330; + shd_desc.fs.source = _sdtx_fs_src_glsl330; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sdtx_vs_src_glsl300es; + shd_desc.fs.source = _sdtx_fs_src_glsl300es; #elif defined(SOKOL_METAL) shd_desc.vs.entry = "main0"; shd_desc.fs.entry = "main0"; diff --git a/util/sokol_fontstash.h b/util/sokol_fontstash.h index 049d5e11..9bf406fc 100644 --- a/util/sokol_fontstash.h +++ b/util/sokol_fontstash.h @@ -20,7 +20,6 @@ used by sokol_gfx.h and sokol_app.h): SOKOL_GLCORE33 - SOKOL_GLES2 SOKOL_GLES3 SOKOL_D3D11 SOKOL_METAL @@ -283,7 +282,7 @@ SOKOL_FONTSTASH_API_DECL uint32_t sfons_rgba(uint8_t r, uint8_t g, uint8_t b, ui /* Embedded source code compiled with: - sokol-shdc -i sfons.glsl -o sfons.h -l glsl330:glsl100:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + sokol-shdc -i sfons.glsl -o sfons.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b (not that for Metal and D3D11 byte code, sokol-shdc must be run on macOS and Windows) @@ -366,52 +365,58 @@ static const char _sfons_fs_source_glsl330[195] = { 0x79,0x29,0x2e,0x78,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d, 0x0a,0x0a,0x00, }; -#elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) -static const char _sfons_vs_source_glsl100[430] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x0a,0x75,0x6e, - 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75, - 0x74,0x65,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x66,0x6c,0x6f,0x61, - 0x74,0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67, - 0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62, - 0x75,0x74,0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72, - 0x64,0x30,0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x34, - 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74, - 0x65,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a, - 0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20, - 0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, - 0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30, - 0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c, - 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76, - 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x70, - 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, - 0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70,0x73,0x69,0x7a, - 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34, - 0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x76, - 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x76,0x73,0x5f, - 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28, - 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20, - 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20, - 0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +#elif defined(SOKOL_GLES3) +static const char _sfons_vs_source_glsl300es[481] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74, + 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30, + 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20, + 0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70, + 0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d, + 0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65, + 0x63,0x34,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a, + 0x00, }; -static const char _sfons_fs_source_glsl100[233] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x70,0x72,0x65, - 0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,0x70,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20, - 0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66, - 0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65, - 0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e, - 0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b, - 0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, - 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, - 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c, - 0x5f,0x46,0x72,0x61,0x67,0x44,0x61,0x74,0x61,0x5b,0x30,0x5d,0x20,0x3d,0x20,0x76, - 0x65,0x63,0x34,0x28,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e, - 0x30,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x28,0x74,0x65,0x78, - 0x2c,0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x2e,0x78,0x29,0x20,0x2a,0x20,0x63,0x6f, - 0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +static const char _sfons_fs_source_glsl300es[268] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x31,0x2e,0x30,0x2c,0x20,0x31,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,0x2c,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28, + 0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x2e,0x78,0x29,0x20,0x2a, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; #elif defined(SOKOL_METAL) static const uint8_t _sfons_vs_bytecode_metal_macos[3417] = { @@ -1651,7 +1656,7 @@ static const uint8_t fs_bytecode_wgpu[1000] = { static const char* _sfons_vs_source_dummy = ""; static const char* _sfons_fs_source_dummy = ""; #else -#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" #endif typedef struct _sfons_t { @@ -1729,9 +1734,9 @@ static int _sfons_render_create(void* user_ptr, int width, int height) { #if defined(SOKOL_GLCORE33) shd_desc.vs.source = _sfons_vs_source_glsl330; shd_desc.fs.source = _sfons_fs_source_glsl330; - #elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - shd_desc.vs.source = _sfons_vs_source_glsl100; - shd_desc.fs.source = _sfons_fs_source_glsl100; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sfons_vs_source_glsl300es; + shd_desc.fs.source = _sfons_fs_source_glsl300es; #elif defined(SOKOL_METAL) shd_desc.vs.entry = "main0"; shd_desc.fs.entry = "main0"; diff --git a/util/sokol_gfx_imgui.h b/util/sokol_gfx_imgui.h index 9b9b8d7e..4e7cbe13 100644 --- a/util/sokol_gfx_imgui.h +++ b/util/sokol_gfx_imgui.h @@ -1043,7 +1043,6 @@ _SOKOL_PRIVATE void _sg_imgui_draw_resource_slot(const sg_slot_info* slot) { _SOKOL_PRIVATE const char* _sg_imgui_backend_string(sg_backend b) { switch (b) { case SG_BACKEND_GLCORE33: return "SG_BACKEND_GLCORE33"; - case SG_BACKEND_GLES2: return "SG_BACKEND_GLES2"; case SG_BACKEND_GLES3: return "SG_BACKEND_GLES3"; case SG_BACKEND_D3D11: return "SG_BACKEND_D3D11"; case SG_BACKEND_METAL_IOS: return "SG_BACKEND_METAL_IOS"; @@ -3890,12 +3889,7 @@ _SOKOL_PRIVATE void _sg_imgui_draw_caps_panel(void) { igText("Backend: %s\n\n", _sg_imgui_backend_string(sg_query_backend())); sg_features f = sg_query_features(); igText("Features:"); - igText(" instancing: %s", _sg_imgui_bool_string(f.instancing)); igText(" origin_top_left: %s", _sg_imgui_bool_string(f.origin_top_left)); - igText(" multiple_render_targets: %s", _sg_imgui_bool_string(f.multiple_render_targets)); - igText(" msaa_render_targets: %s", _sg_imgui_bool_string(f.msaa_render_targets)); - igText(" imagetype_3d: %s", _sg_imgui_bool_string(f.imagetype_3d)); - igText(" imagetype_array: %s", _sg_imgui_bool_string(f.imagetype_array)); igText(" image_clamp_to_border: %s", _sg_imgui_bool_string(f.image_clamp_to_border)); igText(" mrt_independent_blend_state: %s", _sg_imgui_bool_string(f.mrt_independent_blend_state)); igText(" mrt_independent_write_mask: %s", _sg_imgui_bool_string(f.mrt_independent_write_mask)); diff --git a/util/sokol_gl.h b/util/sokol_gl.h index 2360a4cd..090df218 100644 --- a/util/sokol_gl.h +++ b/util/sokol_gl.h @@ -18,7 +18,6 @@ used by sokol_gfx.h and sokol_app.h): SOKOL_GLCORE33 - SOKOL_GLES2 SOKOL_GLES3 SOKOL_D3D11 SOKOL_METAL @@ -970,7 +969,7 @@ inline sgl_pipeline sgl_context_make_pipeline(sgl_context ctx, const sg_pipeline /* Embedded source code compiled with: - sokol-shdc -i sgl.glsl -o sgl.h -l glsl330:glsl100:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + sokol-shdc -i sgl.glsl -o sgl.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b (not that for Metal and D3D11 byte code, sokol-shdc must be run on macOS and Windows) @@ -1053,51 +1052,57 @@ static const char _sgl_fs_source_glsl330[172] = { 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x20,0x2a, 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -#elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) -static const char _sgl_vs_source_glsl100[430] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x0a,0x75,0x6e, - 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75, - 0x74,0x65,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x66,0x6c,0x6f,0x61, - 0x74,0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67, - 0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62, - 0x75,0x74,0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72, - 0x64,0x30,0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x34, - 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74, - 0x65,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a, - 0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20, - 0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20, - 0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30, - 0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c, - 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76, - 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x70, - 0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, - 0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70,0x73,0x69,0x7a, - 0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34, - 0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x2c,0x20,0x76, - 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20,0x76,0x73,0x5f, - 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28, - 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20, - 0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20, - 0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +#elif defined(SOKOL_GLES3) +static const char _sgl_vs_source_glsl300es[481] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x38,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69, + 0x6f,0x6e,0x20,0x3d,0x20,0x33,0x29,0x20,0x69,0x6e,0x20,0x66,0x6c,0x6f,0x61,0x74, + 0x20,0x70,0x73,0x69,0x7a,0x65,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x75,0x76,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63, + 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74, + 0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32, + 0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30, + 0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b, + 0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, + 0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, + 0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, + 0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20, + 0x2a,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x69,0x6e,0x74,0x53,0x69,0x7a,0x65,0x20,0x3d,0x20,0x70, + 0x73,0x69,0x7a,0x65,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x6d, + 0x61,0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d, + 0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x35,0x5d,0x2c,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x36,0x5d,0x2c,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x37,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65, + 0x63,0x34,0x28,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x2c,0x20,0x30,0x2e, + 0x30,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a, + 0x00, }; -static const char _sgl_fs_source_glsl100[210] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x70,0x72,0x65, - 0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,0x70,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20, - 0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66, - 0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65, - 0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e, - 0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b, - 0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, - 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, - 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c, - 0x5f,0x46,0x72,0x61,0x67,0x44,0x61,0x74,0x61,0x5b,0x30,0x5d,0x20,0x3d,0x20,0x74, - 0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76, - 0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a, - 0x0a,0x00, +static const char _sgl_fs_source_glsl300es[245] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x2e,0x78,0x79,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b, + 0x0a,0x7d,0x0a,0x0a,0x00, }; #elif defined(SOKOL_METAL) static const uint8_t _sgl_vs_bytecode_metal_macos[3321] = { @@ -2265,7 +2270,7 @@ static const uint8_t _sgl_fs_bytecode_wgpu[936] = { static const char* _sgl_vs_source_dummy = ""; static const char* _sgl_fs_source_dummy = ""; #else -#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" #endif // ████████ ██ ██ ██████ ███████ ███████ @@ -3349,9 +3354,9 @@ static void _sgl_setup_common(void) { #if defined(SOKOL_GLCORE33) shd_desc.vs.source = _sgl_vs_source_glsl330; shd_desc.fs.source = _sgl_fs_source_glsl330; - #elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - shd_desc.vs.source = _sgl_vs_source_glsl100; - shd_desc.fs.source = _sgl_fs_source_glsl100; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sgl_vs_source_glsl300es; + shd_desc.fs.source = _sgl_fs_source_glsl300es; #elif defined(SOKOL_METAL) shd_desc.vs.entry = "main0"; shd_desc.fs.entry = "main0"; diff --git a/util/sokol_imgui.h b/util/sokol_imgui.h index 9a54f40a..48e36f59 100644 --- a/util/sokol_imgui.h +++ b/util/sokol_imgui.h @@ -27,7 +27,6 @@ used by sokol_gfx.h and sokol_app.h): SOKOL_GLCORE33 - SOKOL_GLES2 SOKOL_GLES3 SOKOL_D3D11 SOKOL_METAL @@ -419,7 +418,7 @@ static _simgui_state_t _simgui; /* Embedded source code compiled with: - sokol-shdc -i simgui.glsl -o simgui.h -l glsl330:glsl100:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + sokol-shdc -i simgui.glsl -o simgui.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b (not that for Metal and D3D11 byte code, sokol-shdc must be run on macOS and Windows) @@ -490,43 +489,48 @@ static const char _simgui_fs_source_glsl330[169] = { 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f, 0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -#elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) -static const char _simgui_vs_source_glsl100[307] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x0a,0x75,0x6e, - 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75, - 0x74,0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x32,0x20,0x75, - 0x76,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63, - 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x76,0x61,0x72, - 0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b, - 0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63,0x34,0x20, - 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61, - 0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f, - 0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x28, - 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2d,0x20,0x76,0x65, - 0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28, - 0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c,0x20,0x30,0x2e,0x35,0x2c, - 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20, - 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63, - 0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d, - 0x0a,0x0a,0x00, +#elif defined(SOKOL_GLES3) +static const char _simgui_vs_source_glsl300es[344] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c, + 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f, + 0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65, + 0x63,0x34,0x28,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29, + 0x20,0x2d,0x20,0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20, + 0x76,0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c, + 0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -static const char _simgui_fs_source_glsl100[207] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x70,0x72,0x65, - 0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,0x70,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20, - 0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66, - 0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65, - 0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e, - 0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b, - 0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, - 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, - 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c, - 0x5f,0x46,0x72,0x61,0x67,0x44,0x61,0x74,0x61,0x5b,0x30,0x5d,0x20,0x3d,0x20,0x74, - 0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76, - 0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +static const char _simgui_fs_source_glsl300es[242] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a, + 0x0a,0x00, }; #elif defined(SOKOL_METAL) static const uint8_t _simgui_vs_bytecode_metal_macos[3216] = { @@ -1663,7 +1667,7 @@ static const uint8_t _simgui_fs_bytecode_wgpu[904] = { static const char* _simgui_vs_source_dummy = ""; static const char* _simgui_fs_source_dummy = ""; #else -#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" #endif #if !defined(SOKOL_IMGUI_NO_SOKOL_APP) @@ -1851,9 +1855,9 @@ SOKOL_API_IMPL void simgui_setup(const simgui_desc_t* desc) { #if defined(SOKOL_GLCORE33) shd_desc.vs.source = _simgui_vs_source_glsl330; shd_desc.fs.source = _simgui_fs_source_glsl330; - #elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - shd_desc.vs.source = _simgui_vs_source_glsl100; - shd_desc.fs.source = _simgui_fs_source_glsl100; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _simgui_vs_source_glsl300es; + shd_desc.fs.source = _simgui_fs_source_glsl300es; #elif defined(SOKOL_METAL) shd_desc.vs.entry = "main0"; shd_desc.fs.entry = "main0"; diff --git a/util/sokol_nuklear.h b/util/sokol_nuklear.h index 3d996061..a52f43e0 100644 --- a/util/sokol_nuklear.h +++ b/util/sokol_nuklear.h @@ -19,7 +19,6 @@ used by sokol_gfx.h and sokol_app.h): SOKOL_GLCORE33 - SOKOL_GLES2 SOKOL_GLES3 SOKOL_D3D11 SOKOL_METAL @@ -326,7 +325,7 @@ static _snk_state_t _snuklear; /* Embedded source code compiled with: - sokol-shdc -i snuk.glsl -o snuk.h -l glsl330:glsl100:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + sokol-shdc -i snuk.glsl -o snuk.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b (not that for Metal and D3D11 byte code, sokol-shdc must be run on macOS and Windows) @@ -397,43 +396,48 @@ static const char _snk_fs_source_glsl330[169] = { 0x72,0x65,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f, 0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -#elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) -static const char _snk_vs_source_glsl100[307] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x0a,0x75,0x6e, - 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75, - 0x74,0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x32,0x20,0x75, - 0x76,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63, - 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x76,0x61,0x72, - 0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b, - 0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63,0x34,0x20, - 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61, - 0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f, - 0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65,0x63,0x34,0x28,0x28,0x28, - 0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29,0x20,0x2d,0x20,0x76,0x65, - 0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x32,0x28, - 0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c,0x20,0x30,0x2e,0x35,0x2c, - 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20, - 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63, - 0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d, - 0x0a,0x0a,0x00, +#elif defined(SOKOL_GLES3) +static const char _snk_vs_source_glsl300es[344] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c, + 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f, + 0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x76,0x65, + 0x63,0x34,0x28,0x28,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x2f,0x20, + 0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x79,0x29, + 0x20,0x2d,0x20,0x76,0x65,0x63,0x32,0x28,0x30,0x2e,0x35,0x29,0x29,0x20,0x2a,0x20, + 0x76,0x65,0x63,0x32,0x28,0x32,0x2e,0x30,0x2c,0x20,0x2d,0x32,0x2e,0x30,0x29,0x2c, + 0x20,0x30,0x2e,0x35,0x2c,0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20, + 0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -static const char _snk_fs_source_glsl100[207] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x70,0x72,0x65, - 0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,0x70,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20, - 0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66, - 0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c,0x65, - 0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e, - 0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b, - 0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76, - 0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64, - 0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c, - 0x5f,0x46,0x72,0x61,0x67,0x44,0x61,0x74,0x61,0x5b,0x30,0x5d,0x20,0x3d,0x20,0x74, - 0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76, - 0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +static const char _snk_fs_source_glsl300es[242] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d, + 0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x6c,0x61,0x79, + 0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30, + 0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34, + 0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x69,0x6e,0x20, + 0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a,0x69, + 0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c, + 0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29, + 0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f, + 0x72,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x28,0x74,0x65,0x78,0x2c, + 0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x7d,0x0a, + 0x0a,0x00, }; #elif defined(SOKOL_METAL) static const uint8_t _snk_vs_bytecode_metal_macos[3216] = { @@ -1613,7 +1617,7 @@ static const uint8_t _snk_fs_bytecode_wgpu[904] = { static const char* _snk_vs_source_dummy = ""; static const char* _snk_fs_source_dummy = ""; #else -#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" #endif #if !defined(SOKOL_NUKLEAR_NO_SOKOL_APP) @@ -1741,9 +1745,9 @@ SOKOL_API_IMPL void snk_setup(const snk_desc_t* desc) { #if defined(SOKOL_GLCORE33) vs_source = _snk_vs_source_glsl330; fs_source = _snk_fs_source_glsl330; - #elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - vs_source = _snk_vs_source_glsl100; - fs_source = _snk_fs_source_glsl100; + #elif defined(SOKOL_GLES3) + vs_source = _snk_vs_source_glsl300es; + fs_source = _snk_fs_source_glsl300es; #elif defined(SOKOL_METAL) switch (sg_query_backend()) { case SG_BACKEND_METAL_MACOS: diff --git a/util/sokol_spine.h b/util/sokol_spine.h index ae1f6f1c..2fd62c8d 100644 --- a/util/sokol_spine.h +++ b/util/sokol_spine.h @@ -20,7 +20,6 @@ used by sokol_gfx.h and sokol_app.h): SOKOL_GLCORE33 - SOKOL_GLES2 SOKOL_GLES3 SOKOL_D3D11 SOKOL_METAL @@ -1427,7 +1426,7 @@ SOKOL_SPINE_API_DECL void sspine_set_skin(sspine_instance instance, sspine_skin /* Embedded source compiled with: - sokol-shdc -i sspine.glsl -o sspine.h -l glsl330:glsl100:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b + sokol-shdc -i sspine.glsl -o sspine.h -l glsl330:glsl300es:hlsl4:metal_macos:metal_ios:metal_sim:wgpu -b @vs vs uniform vs_params { @@ -1508,53 +1507,58 @@ static const char _sspine_fs_source_glsl330[300] = { 0x20,0x76,0x65,0x63,0x34,0x28,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b, 0x30,0x5d,0x2e,0x78,0x29,0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; -#elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) -static const char _sspine_vs_source_glsl100[318] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x0a,0x75,0x6e, - 0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73,0x5f,0x70,0x61, - 0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75, - 0x74,0x65,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e, - 0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x32,0x20,0x75, - 0x76,0x3b,0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63, - 0x32,0x20,0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x76,0x61,0x72, - 0x79,0x69,0x6e,0x67,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b, - 0x0a,0x61,0x74,0x74,0x72,0x69,0x62,0x75,0x74,0x65,0x20,0x76,0x65,0x63,0x34,0x20, - 0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61, - 0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f,0x50,0x6f, - 0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61,0x74,0x34,0x28,0x76,0x73, - 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70, - 0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72, - 0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d, - 0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63,0x34,0x28,0x70,0x6f,0x73, - 0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c,0x20,0x31,0x2e,0x30,0x29, - 0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20,0x74,0x65,0x78,0x63,0x6f, - 0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x20, - 0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, +#elif defined(SOKOL_GLES3) +static const char _sspine_vs_source_glsl300es[355] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x0a,0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x76,0x65,0x63,0x34,0x20,0x76,0x73, + 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x34,0x5d,0x3b,0x0a,0x6c,0x61,0x79,0x6f, + 0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29, + 0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f, + 0x6e,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20, + 0x3d,0x20,0x31,0x29,0x20,0x69,0x6e,0x20,0x76,0x65,0x63,0x32,0x20,0x74,0x65,0x78, + 0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x6f,0x75,0x74,0x20,0x76,0x65,0x63,0x34, + 0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c, + 0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x32,0x29,0x20,0x69,0x6e,0x20, + 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x0a,0x76,0x6f, + 0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20, + 0x67,0x6c,0x5f,0x50,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x6d,0x61, + 0x74,0x34,0x28,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2c, + 0x20,0x76,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x2c,0x20,0x76, + 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x32,0x5d,0x2c,0x20,0x76,0x73,0x5f, + 0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x33,0x5d,0x29,0x20,0x2a,0x20,0x76,0x65,0x63, + 0x34,0x28,0x70,0x6f,0x73,0x69,0x74,0x69,0x6f,0x6e,0x2c,0x20,0x30,0x2e,0x30,0x2c, + 0x20,0x31,0x2e,0x30,0x29,0x3b,0x0a,0x20,0x20,0x20,0x20,0x75,0x76,0x20,0x3d,0x20, + 0x74,0x65,0x78,0x63,0x6f,0x6f,0x72,0x64,0x30,0x3b,0x0a,0x20,0x20,0x20,0x20,0x63, + 0x6f,0x6c,0x6f,0x72,0x20,0x3d,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x30,0x3b,0x0a,0x7d, + 0x0a,0x0a,0x00, }; -static const char _sspine_fs_source_glsl100[356] = { - 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x31,0x30,0x30,0x0a,0x70,0x72,0x65, - 0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d,0x70,0x20,0x66, - 0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20, - 0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75,0x6e,0x69,0x66, - 0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66, - 0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a,0x75,0x6e,0x69, - 0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61,0x6d,0x70,0x6c, - 0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x76,0x61,0x72,0x79,0x69, - 0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76, - 0x3b,0x0a,0x76,0x61,0x72,0x79,0x69,0x6e,0x67,0x20,0x68,0x69,0x67,0x68,0x70,0x20, - 0x76,0x65,0x63,0x34,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69, - 0x64,0x20,0x6d,0x61,0x69,0x6e,0x28,0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68, - 0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x5f,0x32,0x35,0x20,0x3d,0x20, - 0x74,0x65,0x78,0x74,0x75,0x72,0x65,0x32,0x44,0x28,0x74,0x65,0x78,0x2c,0x20,0x75, - 0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x3b,0x0a,0x20,0x20,0x20,0x20, - 0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x20,0x5f,0x33,0x34,0x20, - 0x3d,0x20,0x5f,0x32,0x35,0x2e,0x77,0x3b,0x0a,0x20,0x20,0x20,0x20,0x67,0x6c,0x5f, - 0x46,0x72,0x61,0x67,0x44,0x61,0x74,0x61,0x5b,0x30,0x5d,0x20,0x3d,0x20,0x6d,0x69, - 0x78,0x28,0x5f,0x32,0x35,0x2c,0x20,0x76,0x65,0x63,0x34,0x28,0x5f,0x32,0x35,0x2e, - 0x78,0x79,0x7a,0x20,0x2a,0x20,0x5f,0x33,0x34,0x2c,0x20,0x5f,0x33,0x34,0x29,0x20, - 0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x76,0x65,0x63,0x34,0x28,0x66,0x73, - 0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x29,0x29,0x3b,0x0a, - 0x7d,0x0a,0x0a,0x00, +static const char _sspine_fs_source_glsl300es[391] = { + 0x23,0x76,0x65,0x72,0x73,0x69,0x6f,0x6e,0x20,0x33,0x30,0x30,0x20,0x65,0x73,0x0a, + 0x70,0x72,0x65,0x63,0x69,0x73,0x69,0x6f,0x6e,0x20,0x6d,0x65,0x64,0x69,0x75,0x6d, + 0x70,0x20,0x66,0x6c,0x6f,0x61,0x74,0x3b,0x0a,0x70,0x72,0x65,0x63,0x69,0x73,0x69, + 0x6f,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x69,0x6e,0x74,0x3b,0x0a,0x0a,0x75, + 0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63, + 0x34,0x20,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x31,0x5d,0x3b,0x0a, + 0x75,0x6e,0x69,0x66,0x6f,0x72,0x6d,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x73,0x61, + 0x6d,0x70,0x6c,0x65,0x72,0x32,0x44,0x20,0x74,0x65,0x78,0x3b,0x0a,0x0a,0x69,0x6e, + 0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x32,0x20,0x75,0x76,0x3b,0x0a, + 0x69,0x6e,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x6c,0x61,0x79,0x6f,0x75,0x74,0x28,0x6c,0x6f,0x63,0x61, + 0x74,0x69,0x6f,0x6e,0x20,0x3d,0x20,0x30,0x29,0x20,0x6f,0x75,0x74,0x20,0x68,0x69, + 0x67,0x68,0x70,0x20,0x76,0x65,0x63,0x34,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f, + 0x6c,0x6f,0x72,0x3b,0x0a,0x0a,0x76,0x6f,0x69,0x64,0x20,0x6d,0x61,0x69,0x6e,0x28, + 0x29,0x0a,0x7b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x76,0x65, + 0x63,0x34,0x20,0x5f,0x32,0x35,0x20,0x3d,0x20,0x74,0x65,0x78,0x74,0x75,0x72,0x65, + 0x28,0x74,0x65,0x78,0x2c,0x20,0x75,0x76,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f, + 0x72,0x3b,0x0a,0x20,0x20,0x20,0x20,0x68,0x69,0x67,0x68,0x70,0x20,0x66,0x6c,0x6f, + 0x61,0x74,0x20,0x5f,0x33,0x34,0x20,0x3d,0x20,0x5f,0x32,0x35,0x2e,0x77,0x3b,0x0a, + 0x20,0x20,0x20,0x20,0x66,0x72,0x61,0x67,0x5f,0x63,0x6f,0x6c,0x6f,0x72,0x20,0x3d, + 0x20,0x6d,0x69,0x78,0x28,0x5f,0x32,0x35,0x2c,0x20,0x76,0x65,0x63,0x34,0x28,0x5f, + 0x32,0x35,0x2e,0x78,0x79,0x7a,0x20,0x2a,0x20,0x5f,0x33,0x34,0x2c,0x20,0x5f,0x33, + 0x34,0x29,0x20,0x2a,0x20,0x63,0x6f,0x6c,0x6f,0x72,0x2c,0x20,0x76,0x65,0x63,0x34, + 0x28,0x66,0x73,0x5f,0x70,0x61,0x72,0x61,0x6d,0x73,0x5b,0x30,0x5d,0x2e,0x78,0x29, + 0x29,0x3b,0x0a,0x7d,0x0a,0x0a,0x00, }; #elif defined(SOKOL_D3D11) static const uint8_t _sspine_vs_bytecode_hlsl4[844] = { @@ -2571,7 +2575,7 @@ static const char _sspine_fs_source_metal_sim[721] = { static const char* _sspine_vs_source_dummy = ""; static const char* _sspine_fs_source_dummy = ""; #else -#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES2, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" +#error "Please define one of SOKOL_GLCORE33, SOKOL_GLES3, SOKOL_D3D11, SOKOL_METAL, SOKOL_WGPU or SOKOL_DUMMY_BACKEND!" #endif // ███████ ████████ ██████ ██ ██ ██████ ████████ ███████ @@ -4468,9 +4472,9 @@ static void _sspine_init_shared(void) { #if defined(SOKOL_GLCORE33) shd_desc.vs.source = _sspine_vs_source_glsl330; shd_desc.fs.source = _sspine_fs_source_glsl330; - #elif defined(SOKOL_GLES2) || defined(SOKOL_GLES3) - shd_desc.vs.source = _sspine_vs_source_glsl100; - shd_desc.fs.source = _sspine_fs_source_glsl100; + #elif defined(SOKOL_GLES3) + shd_desc.vs.source = _sspine_vs_source_glsl300es; + shd_desc.fs.source = _sspine_fs_source_glsl300es; #elif defined(SOKOL_METAL) shd_desc.vs.entry = "main0"; shd_desc.fs.entry = "main0"; |