diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-10-25 22:57:40 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-10-26 11:54:21 +0300 |
commit | d5fe6e47850311e10a1ae1663693018634c83e84 (patch) | |
tree | ec68cbd7d95e476b6c8ee50a76ef14a4e2bc129d /source | |
parent | 48b56481ea4c93c9fe538ddf3fce0b9af0446f7b (diff) |
GPU: Add workarounds for buggy glBlitFramebuffer function on macOS + Radeon
When calling glBlitFramebuffer on most (if not all) mac that have a GPU
from the Radeon Pro series, the data is not properly copied and only a
subset of the pixels are correctly copied.
This only happens when blitting the depth buffer if the depth buffer is
GL_DEPTH24_STENCIL8.
Changing the depth buffer format to GPU_DEPTH32F_STENCIL8 fixes the issue
but only works if blitting the depth componnent. The stencil componnent
still provoke issues when being copied.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/gpu/GPU_extensions.h | 1 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_extensions.c | 16 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_texture.c | 6 |
3 files changed, 23 insertions, 0 deletions
diff --git a/source/blender/gpu/GPU_extensions.h b/source/blender/gpu/GPU_extensions.h index 994f545eb38..805023e31df 100644 --- a/source/blender/gpu/GPU_extensions.h +++ b/source/blender/gpu/GPU_extensions.h @@ -52,6 +52,7 @@ int GPU_max_ubo_size(void); int GPU_color_depth(void); void GPU_get_dfdy_factors(float fac[2]); bool GPU_mip_render_workaround(void); +bool GPU_depth_blitting_workaround(void); bool GPU_mem_stats_supported(void); void GPU_mem_stats_get(int *totalmem, int *freemem); diff --git a/source/blender/gpu/intern/gpu_extensions.c b/source/blender/gpu/intern/gpu_extensions.c index c95f5e5e252..b5ca8e9a30c 100644 --- a/source/blender/gpu/intern/gpu_extensions.c +++ b/source/blender/gpu/intern/gpu_extensions.c @@ -89,6 +89,11 @@ static struct GPUGlobal { * GL_TEXTURE_MAX_LEVEL is higher than the target mip. * We need a workaround in this cases. */ bool mip_render_workaround; + /* There is an issue with the glBlitFramebuffer on MacOS with radeon pro graphics. + * Blitting depth with GL_DEPTH24_STENCIL8 is buggy so the workaround is to use + * GPU_DEPTH32F_STENCIL8. Then Blitting depth will work but blitting stencil will + * still be broken. */ + bool depth_blitting_workaround; } GG = {1, 0}; @@ -195,6 +200,11 @@ bool GPU_mip_render_workaround(void) return GG.mip_render_workaround; } +bool GPU_depth_blitting_workaround(void) +{ + return GG.depth_blitting_workaround; +} + void gpu_extensions_init(void) { /* during 2.8 development each platform has its own OpenGL minimum requirements @@ -243,6 +253,12 @@ void gpu_extensions_init(void) if (strstr(vendor, "ATI") || strstr(vendor, "AMD")) { GG.device = GPU_DEVICE_ATI; GG.driver = GPU_DRIVER_OFFICIAL; + +#if defined(__APPLE__) + if (strstr(vendor, "AMD Radeon Pro")) { + GG.depth_blitting_workaround = true; + } +#endif } else if (strstr(vendor, "NVIDIA")) { GG.device = GPU_DEVICE_NVIDIA; diff --git a/source/blender/gpu/intern/gpu_texture.c b/source/blender/gpu/intern/gpu_texture.c index 444424af55c..7119fdb423b 100644 --- a/source/blender/gpu/intern/gpu_texture.c +++ b/source/blender/gpu/intern/gpu_texture.c @@ -512,6 +512,12 @@ GPUTexture *GPU_texture_create_nD( CLAMP_MAX(samples, GPU_max_color_texture_samples()); } + if ((tex_format == GPU_DEPTH24_STENCIL8) && GPU_depth_blitting_workaround()) { + /* MacOS + Radeon Pro fails to blit depth on GPU_DEPTH24_STENCIL8 + * but works on GPU_DEPTH32F_STENCIL8. */ + tex_format = GPU_DEPTH32F_STENCIL8; + } + GPUTexture *tex = MEM_callocN(sizeof(GPUTexture), "GPUTexture"); tex->w = w; tex->h = h; |