GeometryShader: Disable the geometry shader stage if it is a pass-through shader.

This commit is contained in:
Jules Blok 2014-12-16 17:28:35 +01:00
parent f2e52b46c3
commit bd6d229733
5 changed files with 20 additions and 2 deletions

View File

@ -28,6 +28,7 @@ GeometryShaderCache::GSCache GeometryShaderCache::GeometryShaders;
const GeometryShaderCache::GSCacheEntry* GeometryShaderCache::last_entry;
GeometryShaderUid GeometryShaderCache::last_uid;
UidChecker<GeometryShaderUid,ShaderCode> GeometryShaderCache::geometry_uid_checker;
const GeometryShaderCache::GSCacheEntry GeometryShaderCache::pass_entry;
ID3D11GeometryShader* ClearGeometryShader = nullptr;
ID3D11GeometryShader* CopyGeometryShader = nullptr;
@ -203,12 +204,20 @@ bool GeometryShaderCache::SetShader(u32 primitive_type)
if (uid == last_uid)
{
GFX_DEBUGGER_PAUSE_AT(NEXT_PIXEL_SHADER_CHANGE,true);
return (last_entry->shader != nullptr);
return true;
}
}
last_uid = uid;
// Check if the shader is a pass-through shader
if (IsPassthroughGeometryShader(uid))
{
// Return the default pass-through shader
last_entry = &pass_entry;
return true;
}
// Check if the shader is already in the cache
GSCache::iterator iter;
iter = GeometryShaders.find(uid);

View File

@ -43,6 +43,7 @@ private:
static GSCache GeometryShaders;
static const GSCacheEntry* last_entry;
static GeometryShaderUid last_uid;
static const GSCacheEntry pass_entry;
static UidChecker<GeometryShaderUid, ShaderCode> geometry_uid_checker;
};

View File

@ -211,7 +211,8 @@ SHADER* ProgramShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode, u32 components
ShaderCode gcode;
GenerateVertexShaderCode(vcode, components, API_OPENGL);
GeneratePixelShaderCode(pcode, dstAlphaMode, API_OPENGL, components);
GenerateGeometryShaderCode(gcode, primitive_type, API_OPENGL);
if (!IsPassthroughGeometryShader(uid.guid))
GenerateGeometryShaderCode(gcode, primitive_type, API_OPENGL);
if (g_ActiveConfig.bEnableShaderDebugging)
{

View File

@ -281,3 +281,9 @@ void GenerateGeometryShaderCode(ShaderCode& object, u32 primitive_type, API_TYPE
{
GenerateGeometryShader<ShaderCode>(object, primitive_type, ApiType);
}
bool IsPassthroughGeometryShader(GeometryShaderUid& object)
{
geometry_shader_uid_data* uid_data = object.GetUidData<geometry_shader_uid_data>();
return uid_data->primitive_type == PRIMITIVE_TRIANGLES && !uid_data->stereo;
}

View File

@ -25,3 +25,4 @@ typedef ShaderUid<geometry_shader_uid_data> GeometryShaderUid;
void GenerateGeometryShaderCode(ShaderCode& object, u32 primitive_type, API_TYPE ApiType);
void GetGeometryShaderUid(GeometryShaderUid& object, u32 primitive_type, API_TYPE ApiType);
bool IsPassthroughGeometryShader(GeometryShaderUid& object);