GLES3: Don't call glTexParameter* for invalid filter and repeat modes

This commit is contained in:
LRFLEW 2023-07-20 00:40:17 -05:00
parent 6588a4a29a
commit 3e9173f11a
1 changed files with 16 additions and 7 deletions

View File

@ -252,10 +252,10 @@ struct Texture {
} }
Config *config = Config::get_singleton(); Config *config = Config::get_singleton();
state_filter = p_filter; state_filter = p_filter;
GLenum pmin = GL_NEAREST; // param min GLenum pmin = GL_NEAREST;
GLenum pmag = GL_NEAREST; // param mag GLenum pmag = GL_NEAREST;
GLint max_lod = 1000; GLint max_lod = 0;
float anisotropy = 1.0f; GLfloat anisotropy = 1.0f;
switch (state_filter) { switch (state_filter) {
case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: { case RS::CANVAS_ITEM_TEXTURE_FILTER_NEAREST: {
pmin = GL_NEAREST; pmin = GL_NEAREST;
@ -278,8 +278,10 @@ struct Texture {
max_lod = 0; max_lod = 0;
} else if (config->use_nearest_mip_filter) { } else if (config->use_nearest_mip_filter) {
pmin = GL_NEAREST_MIPMAP_NEAREST; pmin = GL_NEAREST_MIPMAP_NEAREST;
max_lod = 1000;
} else { } else {
pmin = GL_NEAREST_MIPMAP_LINEAR; pmin = GL_NEAREST_MIPMAP_LINEAR;
max_lod = 1000;
} }
} break; } break;
case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: { case RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR_WITH_MIPMAPS_ANISOTROPIC: {
@ -293,11 +295,14 @@ struct Texture {
max_lod = 0; max_lod = 0;
} else if (config->use_nearest_mip_filter) { } else if (config->use_nearest_mip_filter) {
pmin = GL_LINEAR_MIPMAP_NEAREST; pmin = GL_LINEAR_MIPMAP_NEAREST;
max_lod = 1000;
} else { } else {
pmin = GL_LINEAR_MIPMAP_LINEAR; pmin = GL_LINEAR_MIPMAP_LINEAR;
max_lod = 1000;
} }
} break; } break;
default: { default: {
return;
} break; } break;
} }
glTexParameteri(target, GL_TEXTURE_MIN_FILTER, pmin); glTexParameteri(target, GL_TEXTURE_MIN_FILTER, pmin);
@ -313,8 +318,11 @@ struct Texture {
return; return;
} }
state_repeat = p_repeat; state_repeat = p_repeat;
GLenum prep = GL_CLAMP_TO_EDGE; // parameter repeat GLenum prep = GL_CLAMP_TO_EDGE;
switch (state_repeat) { switch (state_repeat) {
case RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED: {
prep = GL_CLAMP_TO_EDGE;
} break;
case RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: { case RS::CANVAS_ITEM_TEXTURE_REPEAT_ENABLED: {
prep = GL_REPEAT; prep = GL_REPEAT;
} break; } break;
@ -322,6 +330,7 @@ struct Texture {
prep = GL_MIRRORED_REPEAT; prep = GL_MIRRORED_REPEAT;
} break; } break;
default: { default: {
return;
} break; } break;
} }
glTexParameteri(target, GL_TEXTURE_WRAP_T, prep); glTexParameteri(target, GL_TEXTURE_WRAP_T, prep);
@ -330,8 +339,8 @@ struct Texture {
} }
private: private:
RS::CanvasItemTextureFilter state_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_LINEAR; RS::CanvasItemTextureFilter state_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_MAX;
RS::CanvasItemTextureRepeat state_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DISABLED; RS::CanvasItemTextureRepeat state_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_MAX;
}; };
struct RenderTarget { struct RenderTarget {