Skip to content

Commit

Permalink
Merge pull request #11481 from hrydgard/adreno-int-workarounds
Browse files Browse the repository at this point in the history
Workaround for bad int behaviour on Adreno / GLES. (no problems in Vulkan).
  • Loading branch information
unknownbrackets authored Oct 20, 2018
2 parents aea5f38 + ca58bb7 commit fd20d7b
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 4 deletions.
4 changes: 4 additions & 0 deletions GPU/GLES/DepalettizeShaderGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ DepalShaderCacheGLES::DepalShaderCacheGLES(Draw::DrawContext *draw) {
render_ = (GLRenderManager *)draw->GetNativeObject(Draw::NativeObject::RENDER_MANAGER);
// Pre-build the vertex program
useGL3_ = gl_extensions.GLES3 || gl_extensions.VersionGEThan(3, 3);
if (!gstate_c.Supports(GPU_SUPPORTS_32BIT_INT_FSHADER)) {
// Use the floating point path, it just can't handle the math.
useGL3_ = false;
}

vertexShaderFailed_ = false;
vertexShader_ = 0;
Expand Down
11 changes: 9 additions & 2 deletions GPU/GLES/GPU_GLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,11 +190,18 @@ void GPU_GLES::CheckGPUFeatures() {
}

if (gl_extensions.IsGLES) {
if (gl_extensions.GLES3)
if (gl_extensions.GLES3) {
features |= GPU_SUPPORTS_GLSL_ES_300;
// Mali reports 30 but works fine...
if (gl_extensions.range[1][5][1] >= 30) {
features |= GPU_SUPPORTS_32BIT_INT_FSHADER;
}
}
} else {
if (gl_extensions.VersionGEThan(3, 3, 0))
if (gl_extensions.VersionGEThan(3, 3, 0)) {
features |= GPU_SUPPORTS_GLSL_330;
features |= GPU_SUPPORTS_32BIT_INT_FSHADER;
}
}

if (gl_extensions.EXT_shader_framebuffer_fetch || gl_extensions.NV_shader_framebuffer_fetch || gl_extensions.ARM_shader_framebuffer_fetch) {
Expand Down
4 changes: 3 additions & 1 deletion GPU/GLES/TextureCacheGLES.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,9 @@ void TextureCacheGLES::ApplyTextureFramebuffer(TexCacheEntry *entry, VirtualFram
uint32_t clutMode = gstate.clutformat & 0xFFFFFF;

bool useShaderDepal = framebufferManager_->GetCurrentRenderVFB() != framebuffer && gstate_c.Supports(GPU_SUPPORTS_GLSL_ES_300);

if (!gstate_c.Supports(GPU_SUPPORTS_32BIT_INT_FSHADER)) {
useShaderDepal = false;
}
if ((entry->status & TexCacheEntry::STATUS_DEPALETTIZE) && !g_Config.bDisableSlowFramebufEffects) {
if (useShaderDepal) {
const GEPaletteFormat clutFormat = gstate.getClutPaletteFormat();
Expand Down
2 changes: 1 addition & 1 deletion GPU/GPUState.h
Original file line number Diff line number Diff line change
Expand Up @@ -466,7 +466,6 @@ enum {
GPU_SUPPORTS_DUALSOURCE_BLEND = FLAG_BIT(0),
GPU_SUPPORTS_GLSL_ES_300 = FLAG_BIT(1),
GPU_SUPPORTS_GLSL_330 = FLAG_BIT(2),
GPU_SUPPORTS_UNPACK_SUBIMAGE = FLAG_BIT(3),
GPU_SUPPORTS_BLEND_MINMAX = FLAG_BIT(4),
GPU_SUPPORTS_LOGIC_OP = FLAG_BIT(5),
GPU_USE_DEPTH_RANGE_HACK = FLAG_BIT(6),
Expand All @@ -478,6 +477,7 @@ enum {
GPU_SUPPORTS_TEXTURE_FLOAT = FLAG_BIT(12),
GPU_SUPPORTS_16BIT_FORMATS = FLAG_BIT(13),
GPU_SUPPORTS_DEPTH_CLAMP = FLAG_BIT(14),
GPU_SUPPORTS_32BIT_INT_FSHADER = FLAG_BIT(15),
GPU_SUPPORTS_LARGE_VIEWPORTS = FLAG_BIT(16),
GPU_SUPPORTS_ACCURATE_DEPTH = FLAG_BIT(17),
GPU_SUPPORTS_VAO = FLAG_BIT(18),
Expand Down
7 changes: 7 additions & 0 deletions UI/DevScreens.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,13 @@ void SystemInfoScreen::CreateViews() {
#endif
if (GetGPUBackend() == GPUBackend::OPENGL) {
deviceSpecs->Add(new InfoItem(si->T("Core Context"), gl_extensions.IsCoreContext ? di->T("Active") : di->T("Inactive")));
int highp_int_min = gl_extensions.range[1][5][0];
int highp_int_max = gl_extensions.range[1][5][1];
if (highp_int_max != 0) {
char highp_int_range[512];
snprintf(highp_int_range, sizeof(highp_int_range), "Highp int range: %d-%d", highp_int_min, highp_int_max);
deviceSpecs->Add(new InfoItem(si->T("High precision int range"), highp_int_range));
}
}
deviceSpecs->Add(new ItemHeader(si->T("OS Information")));
deviceSpecs->Add(new InfoItem(si->T("Memory Page Size"), StringFromFormat(si->T("%d bytes"), GetMemoryProtectPageSize())));
Expand Down
7 changes: 7 additions & 0 deletions ext/native/gfx_es2/gpu_features.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,13 @@ void CheckGLExtensions() {
glGetShaderPrecisionFormat(shaderTypes[st], precisions[p], gl_extensions.range[st][p], &gl_extensions.precision[st][p]);
}
}

// Now, Adreno lies. So let's override it.
if (gl_extensions.gpuVendor == GPU_VENDOR_QUALCOMM) {
WLOG("Detected Adreno - lowering int precision");
gl_extensions.range[1][5][0] = 15;
gl_extensions.range[1][5][1] = 15;
}
}
#endif

Expand Down

0 comments on commit fd20d7b

Please sign in to comment.