VideoBackends: Clear uid bits that are unused for the current backend
Currently, this is only the logic op bit, but this will be extended to the framebuffer fetch/blend modes. In the future, when/if we move to VideoCommon pipelines, this state will be part of the pipeline UID anyway, and we can mask it out in the backend by using a two-level map, so the shaders/programs are shared.
This commit is contained in:
parent
6d32cce2f5
commit
84f8ebd95f
|
@ -593,6 +593,7 @@ bool PixelShaderCache::SetShader()
|
||||||
return SetUberShader();
|
return SetUberShader();
|
||||||
|
|
||||||
PixelShaderUid uid = GetPixelShaderUid();
|
PixelShaderUid uid = GetPixelShaderUid();
|
||||||
|
ClearUnusedPixelShaderUidBits(APIType::D3D, &uid);
|
||||||
if (last_entry && uid == last_uid)
|
if (last_entry && uid == last_uid)
|
||||||
{
|
{
|
||||||
if (last_entry->pending)
|
if (last_entry->pending)
|
||||||
|
@ -656,6 +657,7 @@ bool PixelShaderCache::SetShader()
|
||||||
bool PixelShaderCache::SetUberShader()
|
bool PixelShaderCache::SetUberShader()
|
||||||
{
|
{
|
||||||
UberShader::PixelShaderUid uid = UberShader::GetPixelShaderUid();
|
UberShader::PixelShaderUid uid = UberShader::GetPixelShaderUid();
|
||||||
|
UberShader::ClearUnusedPixelShaderUidBits(APIType::D3D, &uid);
|
||||||
|
|
||||||
if (last_uber_entry && last_uber_uid == uid)
|
if (last_uber_entry && last_uber_uid == uid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -231,6 +231,7 @@ SHADER* ProgramShaderCache::SetShader(u32 primitive_type, const GLVertexFormat*
|
||||||
uid.puid = GetPixelShaderUid();
|
uid.puid = GetPixelShaderUid();
|
||||||
uid.vuid = GetVertexShaderUid();
|
uid.vuid = GetVertexShaderUid();
|
||||||
uid.guid = GetGeometryShaderUid(primitive_type);
|
uid.guid = GetGeometryShaderUid(primitive_type);
|
||||||
|
ClearUnusedPixelShaderUidBits(APIType::OpenGL, &uid.puid);
|
||||||
|
|
||||||
// Check if the shader is already set
|
// Check if the shader is already set
|
||||||
if (last_entry && uid == last_uid)
|
if (last_entry && uid == last_uid)
|
||||||
|
@ -298,6 +299,7 @@ SHADER* ProgramShaderCache::SetUberShader(u32 primitive_type, const GLVertexForm
|
||||||
uid.puid = UberShader::GetPixelShaderUid();
|
uid.puid = UberShader::GetPixelShaderUid();
|
||||||
uid.vuid = UberShader::GetVertexShaderUid();
|
uid.vuid = UberShader::GetVertexShaderUid();
|
||||||
uid.guid = GetGeometryShaderUid(primitive_type);
|
uid.guid = GetGeometryShaderUid(primitive_type);
|
||||||
|
UberShader::ClearUnusedPixelShaderUidBits(APIType::OpenGL, &uid.puid);
|
||||||
|
|
||||||
// We need to use the ubershader vertex format with all attributes enabled.
|
// We need to use the ubershader vertex format with all attributes enabled.
|
||||||
// Otherwise, the NV driver can generate variants for the vertex shaders.
|
// Otherwise, the NV driver can generate variants for the vertex shaders.
|
||||||
|
|
|
@ -338,8 +338,9 @@ bool StateTracker::CheckForShaderChanges(u32 gx_primitive_type)
|
||||||
{
|
{
|
||||||
VertexShaderUid vs_uid = GetVertexShaderUid();
|
VertexShaderUid vs_uid = GetVertexShaderUid();
|
||||||
PixelShaderUid ps_uid = GetPixelShaderUid();
|
PixelShaderUid ps_uid = GetPixelShaderUid();
|
||||||
bool changed = false;
|
ClearUnusedPixelShaderUidBits(APIType::Vulkan, &ps_uid);
|
||||||
|
|
||||||
|
bool changed = false;
|
||||||
bool use_ubershaders = g_ActiveConfig.bDisableSpecializedShaders;
|
bool use_ubershaders = g_ActiveConfig.bDisableSpecializedShaders;
|
||||||
if (g_ActiveConfig.CanBackgroundCompileShaders() && !g_ActiveConfig.bDisableSpecializedShaders)
|
if (g_ActiveConfig.CanBackgroundCompileShaders() && !g_ActiveConfig.bDisableSpecializedShaders)
|
||||||
{
|
{
|
||||||
|
@ -405,6 +406,7 @@ bool StateTracker::CheckForShaderChanges(u32 gx_primitive_type)
|
||||||
}
|
}
|
||||||
|
|
||||||
UberShader::PixelShaderUid uber_ps_uid = UberShader::GetPixelShaderUid();
|
UberShader::PixelShaderUid uber_ps_uid = UberShader::GetPixelShaderUid();
|
||||||
|
UberShader::ClearUnusedPixelShaderUidBits(APIType::Vulkan, &uber_ps_uid);
|
||||||
VkShaderModule ps = g_shader_cache->GetPixelUberShaderForUid(uber_ps_uid);
|
VkShaderModule ps = g_shader_cache->GetPixelUberShaderForUid(uber_ps_uid);
|
||||||
if (ps != m_pipeline_state.ps)
|
if (ps != m_pipeline_state.ps)
|
||||||
{
|
{
|
||||||
|
@ -983,6 +985,7 @@ VkPipeline StateTracker::GetPipelineAndCacheUID()
|
||||||
PipelineInfo uber_info = m_pipeline_state;
|
PipelineInfo uber_info = m_pipeline_state;
|
||||||
UberShader::VertexShaderUid uber_vuid = UberShader::GetVertexShaderUid();
|
UberShader::VertexShaderUid uber_vuid = UberShader::GetVertexShaderUid();
|
||||||
UberShader::PixelShaderUid uber_puid = UberShader::GetPixelShaderUid();
|
UberShader::PixelShaderUid uber_puid = UberShader::GetPixelShaderUid();
|
||||||
|
UberShader::ClearUnusedPixelShaderUidBits(APIType::Vulkan, &uber_puid);
|
||||||
uber_info.vs = g_shader_cache->GetVertexUberShaderForUid(uber_vuid);
|
uber_info.vs = g_shader_cache->GetVertexUberShaderForUid(uber_vuid);
|
||||||
uber_info.ps = g_shader_cache->GetPixelUberShaderForUid(uber_puid);
|
uber_info.ps = g_shader_cache->GetPixelUberShaderForUid(uber_puid);
|
||||||
|
|
||||||
|
|
|
@ -322,6 +322,16 @@ PixelShaderUid GetPixelShaderUid()
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid)
|
||||||
|
{
|
||||||
|
pixel_shader_uid_data* uid_data = uid->GetUidData<pixel_shader_uid_data>();
|
||||||
|
|
||||||
|
// OpenGL and Vulkan convert implicitly normalized color outputs to their uint representation.
|
||||||
|
// Therefore, it is not necessary to use a uint output on these backends.
|
||||||
|
if (ApiType != APIType::D3D)
|
||||||
|
uid_data->uint_output = 0;
|
||||||
|
}
|
||||||
|
|
||||||
void WritePixelShaderCommonHeader(ShaderCode& out, APIType ApiType, u32 num_texgens,
|
void WritePixelShaderCommonHeader(ShaderCode& out, APIType ApiType, u32 num_texgens,
|
||||||
bool per_pixel_lighting, bool bounding_box)
|
bool per_pixel_lighting, bool bounding_box)
|
||||||
{
|
{
|
||||||
|
|
|
@ -162,5 +162,5 @@ ShaderCode GeneratePixelShaderCode(APIType ApiType, const ShaderHostConfig& host
|
||||||
const pixel_shader_uid_data* uid_data);
|
const pixel_shader_uid_data* uid_data);
|
||||||
void WritePixelShaderCommonHeader(ShaderCode& out, APIType ApiType, u32 num_texgens,
|
void WritePixelShaderCommonHeader(ShaderCode& out, APIType ApiType, u32 num_texgens,
|
||||||
bool per_pixel_lighting, bool bounding_box);
|
bool per_pixel_lighting, bool bounding_box);
|
||||||
ShaderCode GeneratePixelShaderCode(APIType ApiType, const pixel_shader_uid_data* uid_data);
|
void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid);
|
||||||
PixelShaderUid GetPixelShaderUid();
|
PixelShaderUid GetPixelShaderUid();
|
||||||
|
|
|
@ -29,6 +29,16 @@ PixelShaderUid GetPixelShaderUid()
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid)
|
||||||
|
{
|
||||||
|
pixel_ubershader_uid_data* uid_data = uid->GetUidData<pixel_ubershader_uid_data>();
|
||||||
|
|
||||||
|
// OpenGL and Vulkan convert implicitly normalized color outputs to their uint representation.
|
||||||
|
// Therefore, it is not necessary to use a uint output on these backends.
|
||||||
|
if (ApiType != APIType::D3D)
|
||||||
|
uid_data->uint_output = 0;
|
||||||
|
}
|
||||||
|
|
||||||
ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
|
ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
|
||||||
const pixel_ubershader_uid_data* uid_data)
|
const pixel_ubershader_uid_data* uid_data)
|
||||||
{
|
{
|
||||||
|
|
|
@ -29,4 +29,5 @@ ShaderCode GenPixelShader(APIType ApiType, const ShaderHostConfig& host_config,
|
||||||
const pixel_ubershader_uid_data* uid_data);
|
const pixel_ubershader_uid_data* uid_data);
|
||||||
|
|
||||||
void EnumeratePixelShaderUids(const std::function<void(const PixelShaderUid&)>& callback);
|
void EnumeratePixelShaderUids(const std::function<void(const PixelShaderUid&)>& callback);
|
||||||
|
void ClearUnusedPixelShaderUidBits(APIType ApiType, PixelShaderUid* uid);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue