diff --git a/drivers/glrend/devpixmp.h b/drivers/glrend/devpixmp.h index 523e04e4..af58e57c 100644 --- a/drivers/glrend/devpixmp.h +++ b/drivers/glrend/devpixmp.h @@ -8,6 +8,14 @@ extern "C" { #endif +typedef union br_quirks_gl { + struct { + br_uint_32 disable_anisotropic_filtering : 1; + br_uint_32 reserved : 31; + }; + br_uint_32 value; +} br_quirks_gl; + #ifdef BR_DEVICE_PIXELMAP_PRIVATE /* @@ -81,6 +89,8 @@ typedef struct br_device_pixelmap { GLint gl_num_extensions; char **gl_extensions; + br_quirks_gl quirks; + GLuint tex_white; GLuint tex_checkerboard; diff --git a/drivers/glrend/devpmglf.c b/drivers/glrend/devpmglf.c index 7e377b78..d904e5ac 100644 --- a/drivers/glrend/devpmglf.c +++ b/drivers/glrend/devpmglf.c @@ -4,6 +4,7 @@ #include "drv.h" #include +#include /* * Default dispatch table for device (defined at end of file) @@ -80,6 +81,22 @@ static struct br_tv_template_entry pixelmapNewTemplateEntries[] = { }; #undef F +static void setup_qiurks(br_device_pixelmap *self) +{ + const char *gl_renderer = self->asFront.gl_renderer; + const char *gl_vendor = self->asFront.gl_vendor; + + self->asFront.quirks.value = 0; + + /* + * Disable anisotropic filtering on llvmpipe. It is _slow_. + */ + if(BrStrCmp(gl_vendor, "Mesa") == 0 && strstr(gl_renderer, "llvmpipe (") == gl_renderer) { + BrLogInfo("GLREND", "Quirk - using llvmpipe, disabling anisotropic filtering."); + self->asFront.quirks.disable_anisotropic_filtering = 1; + } +} + br_device_pixelmap *DevicePixelmapGLAllocateFront(br_device *dev, br_output_facility *outfcty, br_token_value *tv) { br_device_pixelmap *self; @@ -212,6 +229,11 @@ br_device_pixelmap *DevicePixelmapGLAllocateFront(br_device *dev, br_output_faci return NULL; } + /* + * Everything's init'd, quirkify. + */ + setup_qiurks(self); + self->asFront.tex_white = DeviceGLBuildWhiteTexture(); self->asFront.tex_checkerboard = DeviceGLBuildCheckerboardTexture(); diff --git a/drivers/glrend/renderer.c b/drivers/glrend/renderer.c index c4e31e41..2cb7c6dc 100644 --- a/drivers/glrend/renderer.c +++ b/drivers/glrend/renderer.c @@ -793,6 +793,7 @@ static int sampler_comp(const void *a, const void *b) GLuint RendererGLGetSampler(br_renderer *self, const br_sampler_info_gl *info) { br_sampler_gl *smp; + const br_quirks_gl *quirks = &self->pixelmap->screen->asFront.quirks; smp = BrBSearch(info, self->sampler_pool, self->sampler_count, sizeof(br_sampler_gl), sampler_comp); if(smp != NULL) @@ -811,8 +812,10 @@ GLuint RendererGLGetSampler(br_renderer *self, const br_sampler_info_gl *info) glSamplerParameteri(smp->sampler, GL_TEXTURE_MIN_FILTER, info->filter_min); glSamplerParameteri(smp->sampler, GL_TEXTURE_MAG_FILTER, info->filter_mag); - if(GLAD_GL_ARB_texture_filter_anisotropic && info->filter_min != GL_NEAREST && info->filter_mag != GL_NEAREST) { - glSamplerParameterf(smp->sampler, GL_TEXTURE_MAX_ANISOTROPY, self->pixelmap->screen->asFront.video.maxAnisotropy); + if(!quirks->disable_anisotropic_filtering) { + if(GLAD_GL_ARB_texture_filter_anisotropic && info->filter_min != GL_NEAREST && info->filter_mag != GL_NEAREST) { + glSamplerParameterf(smp->sampler, GL_TEXTURE_MAX_ANISOTROPY, self->pixelmap->screen->asFront.video.maxAnisotropy); + } } BrQsort(self->sampler_pool, self->sampler_count, sizeof(br_sampler_gl), sampler_comp);