Skip to content

Commit

Permalink
drivers/glrend: disable anisotropic filtering on llvmpipe
Browse files Browse the repository at this point in the history
  • Loading branch information
vs49688 committed Oct 13, 2024
1 parent 7273809 commit 0541073
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 2 deletions.
10 changes: 10 additions & 0 deletions drivers/glrend/devpixmp.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

/*
Expand Down Expand Up @@ -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;

Expand Down
22 changes: 22 additions & 0 deletions drivers/glrend/devpmglf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "drv.h"
#include <brassert.h>
#include <string.h>

/*
* Default dispatch table for device (defined at end of file)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();

Expand Down
7 changes: 5 additions & 2 deletions drivers/glrend/renderer.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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);
Expand Down

0 comments on commit 0541073

Please sign in to comment.