sokol
sokol copied to clipboard
sg_create_image with OpenGL + SG_FILTER_*_MIPMAP* produces GL_INVALID_ENUM (1280)
tiny bug: in _sg_gl_create_image
uses _sg_gl_filter
to convert sokol filter enums -> GL enums, but glTexParameteri(GL_TEXTURE_MAG_FILTER, ...)
only accepts GL_NEAREST
and GL_LINEAR
as parameters, so _sg_gl_filter
returns invalid enums for mipmap-ing filters (see https://registry.khronos.org/OpenGL-Refpages/gl4/html/glTexParameter.xhtml)
sg_make_image(
&(sg_image_desc) {
.type = SG_IMAGETYPE_ARRAY,
.width = 1024,
.height = 1024,
.num_slices = 4,
.pixel_format = SG_PIXELFORMAT_RGBA8,
.min_filter = SG_FILTER_NEAREST_MIPMAP_NEAREST,
.mag_filter = SG_FILTER_NEAREST_MIPMAP_NEAREST,
.usage = SG_USAGE_DYNAMIC,
.num_mipmaps = 4
});
produces GL_INVALID_ENUM
for me.
I'll get a PR up when I verify a fix, should I just split _sg_gl_filter
into _sg_gl_min_filter
and _sg_gl_mag_filter
?
Yep, good catch, there's basically a validation layer check missing.
But please don't bother with a PR because there's a better solution on the way with the next "big" update which I'm currently working on, this will split off samplers as their own objects, and while at it, I'll do some more 'harmonization' with WebGPU (basically, the sg_filter
enum will only have two options 'nearest' and 'linear', and there will be a separate .mipmap_filter
in the new sg_sampler_desc
struct.
(PS: I'll keep this ticket open until the 'separate sampler objects' update goes live. It will be a little while though, because I'm currently not sure if this will be a separate update before WebGPU support, or if WebGPU support will be part of the update.
Linking the associated PR: https://github.com/floooh/sokol/pull/842
(not ready yet though)
Ok, closing this ticket because that PR is now merged.