Eevee : Add a workaround for bug with AMD RX VEGA Linux + Mesa Driver

This bug (explained here https://github.com/dfelinto/opengl-sandbox/blob/downsample/README.md) is breaking eevee beyond the point it's workable.

This patch workaround the issue by making sure every fbo have mipmaps that are strictly greater than 16px. This break the bloom visuals a bit but only for this setup.
This commit is contained in:
Clément Foucault 2017-10-10 17:18:29 +02:00
parent eb734746a8
commit 12fa6750f5
4 changed files with 43 additions and 6 deletions

View File

@ -46,8 +46,9 @@
#include "BLI_rand.h"
#include "eevee_private.h"
#include "GPU_texture.h"
#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
#include "GPU_texture.h"
#define SHADER_DEFINES \
"#define EEVEE_ENGINE\n" \
@ -403,8 +404,15 @@ void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
copy_v2_v2_int(texsize, blitsize);
for (int i = 0; i < effects->bloom_iteration_ct; ++i) {
texsize[0] /= 2; texsize[1] /= 2;
texsize[0] = MAX2(texsize[0], 2);
texsize[1] = MAX2(texsize[1], 2);
if (GPU_type_matches(GPU_DEVICE_AMD_VEGA, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
texsize[0] = MAX2(texsize[0], 17);
texsize[1] = MAX2(texsize[1], 17);
}
else {
texsize[0] = MAX2(texsize[0], 2);
texsize[1] = MAX2(texsize[1], 2);
}
effects->downsamp_texel_size[i][0] = 1.0f / (float)texsize[0];
effects->downsamp_texel_size[i][1] = 1.0f / (float)texsize[1];
@ -419,8 +427,15 @@ void EEVEE_effects_init(EEVEE_SceneLayerData *sldata, EEVEE_Data *vedata)
copy_v2_v2_int(texsize, blitsize);
for (int i = 0; i < effects->bloom_iteration_ct - 1; ++i) {
texsize[0] /= 2; texsize[1] /= 2;
texsize[0] = MAX2(texsize[0], 2);
texsize[1] = MAX2(texsize[1], 2);
if (GPU_type_matches(GPU_DEVICE_AMD_VEGA, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
texsize[0] = MAX2(texsize[0], 17);
texsize[1] = MAX2(texsize[1], 17);
}
else {
texsize[0] = MAX2(texsize[0], 2);
texsize[1] = MAX2(texsize[1], 2);
}
DRWFboTexture tex_bloom = {&txl->bloom_upsample[i], DRW_TEX_RGB_11_11_10, DRW_TEX_FILTER};
DRW_framebuffer_init(&fbl->bloom_accum_fb[i], &draw_engine_eevee_type,

View File

@ -64,6 +64,7 @@ typedef enum GPUDeviceType {
GPU_DEVICE_INTEL = (1 << 2),
GPU_DEVICE_SOFTWARE = (1 << 3),
GPU_DEVICE_UNKNOWN = (1 << 4),
GPU_DEVICE_AMD_VEGA = (1 << 5),
GPU_DEVICE_ANY = (0xff)
} GPUDeviceType;

View File

@ -178,6 +178,13 @@ void gpu_extensions_init(void)
GG.device = GPU_DEVICE_ATI;
GG.driver = GPU_DRIVER_OFFICIAL;
}
/* XXX : TODO : Remove this once this sampling mipmap problem is gone.
* https://github.com/dfelinto/opengl-sandbox/blob/downsample/README.md */
else if (strstr(renderer, "AMD VEGA") ||
strstr(vendor, "X.Org")) {
GG.device = GPU_DEVICE_AMD_VEGA;
GG.driver = GPU_DRIVER_OPENSOURCE;
}
else if (strstr(vendor, "NVIDIA")) {
GG.device = GPU_DEVICE_NVIDIA;
GG.driver = GPU_DRIVER_OFFICIAL;

View File

@ -34,6 +34,7 @@
#include "GPU_batch.h"
#include "GPU_draw.h"
#include "GPU_extensions.h"
#include "GPU_framebuffer.h"
#include "GPU_matrix.h"
#include "GPU_shader.h"
@ -573,7 +574,20 @@ void GPU_framebuffer_recursive_downsample(
glReadBuffer(GL_COLOR_ATTACHMENT0);
}
for (i = 1; i < num_iter + 1 && (current_dim[0] > 4 && current_dim[1] > 4); i++) {
for (i = 1; i < num_iter + 1; i++) {
if (GPU_type_matches(GPU_DEVICE_AMD_VEGA, GPU_OS_UNIX, GPU_DRIVER_OPENSOURCE)) {
/* NOTE : here 16 is because of a bug on AMD Vega GPU + non-pro drivers, that prevents us
* from sampling mipmaps that are smaller or equal to 16px. (9) */
if (current_dim[0] / 2 > 16 && current_dim[1] / 2 > 16) {
break;
}
}
else {
if (current_dim[0] / 2 > 1 && current_dim[1] / 2 > 1) {
break;
}
}
/* calculate next viewport size */
current_dim[0] /= 2;