From 310f13a2f768a823136fd38d092391693d037a30 Mon Sep 17 00:00:00 2001 From: Gregory Hainaut Date: Sun, 18 Sep 2016 16:58:02 +0200 Subject: [PATCH] gsdx ogl: only use geometry shader to convert big enough draw call (#1554) gsdx ogl: only use geometry shader to convert big enough draw call The purpose of geometry shader is to reduce bandwidth (72 bytes by sprite) and CPU load. Unfortunately it increases CPU load due to extra shader validations. So geometry shader will only be enabled for draw call with more than 16 sprites (arbitrarily, smallest number before shadow hearts plummet) v2: don't disable geometry shader in replayer. It is easier to spot sprite rendering and to manually read vertex info. --- plugins/GSdx/GSRendererOGL.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/plugins/GSdx/GSRendererOGL.cpp b/plugins/GSdx/GSRendererOGL.cpp index eac537958a..c8188fe930 100644 --- a/plugins/GSdx/GSRendererOGL.cpp +++ b/plugins/GSdx/GSRendererOGL.cpp @@ -159,7 +159,22 @@ void GSRendererOGL::SetupIA(const float& sx, const float& sy) break; case GS_SPRITE_CLASS: - if (GLLoader::found_geometry_shader) { + // Heuristics: trade-off + // CPU conversion => ofc, more CPU ;) more bandwidth (72 bytes / sprite) + // GPU conversion => ofc, more GPU. And also more CPU due to extra shader validation stage. + // + // Note: severals openGL operation does draw call under the wood like texture upload. So even if + // you do 10 consecutive draw with the geometry shader, you will still pay extra validation if new + // texture are uploaded. (game Shadow Hearts) + // + // Note2: Due to MultiThreaded driver, Nvidia suffers less of the previous issue. Still it isn't free + // Shadow Heart is 90 fps (gs) vs 113 fps (no gs) + + // If the draw calls contains few primitives. Geometry Shader gain with be rather small versus + // the extra validation cost of the extra stage. + // + // Note: keep Geometry Shader in the replayer to ease debug. + if (GLLoader::found_geometry_shader && (m_vertex.next > 32 || GLLoader::in_replayer)) { // <=> 16 sprites (based on Shadow Hearts) m_gs_sel.sprite = 1; t = GL_LINES;