Remove UID Checker.
Kind of pointless now that multiple shaders with the same UID are now fundementally impossible.
This commit is contained in:
parent
24e5d21780
commit
95469ec225
|
@ -26,7 +26,6 @@ namespace DX11
|
|||
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;
|
||||
|
@ -177,7 +176,6 @@ void GeometryShaderCache::Clear()
|
|||
for (auto& iter : GeometryShaders)
|
||||
iter.second.Destroy();
|
||||
GeometryShaders.clear();
|
||||
geometry_uid_checker.Invalidate();
|
||||
|
||||
last_entry = nullptr;
|
||||
}
|
||||
|
@ -197,11 +195,6 @@ void GeometryShaderCache::Shutdown()
|
|||
bool GeometryShaderCache::SetShader(u32 primitive_type)
|
||||
{
|
||||
GeometryShaderUid uid = GetGeometryShaderUid(primitive_type);
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code = GenerateGeometryShaderCode(primitive_type, API_D3D, uid.GetUidData());
|
||||
geometry_uid_checker.AddToIndexAndCheck(code, uid, "Geometry", "g");
|
||||
}
|
||||
|
||||
// Check if the shader is already set
|
||||
if (last_entry)
|
||||
|
|
|
@ -44,8 +44,6 @@ private:
|
|||
static const GSCacheEntry* last_entry;
|
||||
static GeometryShaderUid last_uid;
|
||||
static const GSCacheEntry pass_entry;
|
||||
|
||||
static UidChecker<GeometryShaderUid, ShaderCode> geometry_uid_checker;
|
||||
};
|
||||
|
||||
} // namespace DX11
|
||||
|
|
|
@ -26,7 +26,6 @@ namespace DX11
|
|||
PixelShaderCache::PSCache PixelShaderCache::PixelShaders;
|
||||
const PixelShaderCache::PSCacheEntry* PixelShaderCache::last_entry;
|
||||
PixelShaderUid PixelShaderCache::last_uid;
|
||||
UidChecker<PixelShaderUid, ShaderCode> PixelShaderCache::pixel_uid_checker;
|
||||
|
||||
LinearDiskCache<PixelShaderUid, u8> g_ps_disk_cache;
|
||||
|
||||
|
@ -517,7 +516,6 @@ void PixelShaderCache::Clear()
|
|||
for (auto& iter : PixelShaders)
|
||||
iter.second.Destroy();
|
||||
PixelShaders.clear();
|
||||
pixel_uid_checker.Invalidate();
|
||||
|
||||
last_entry = nullptr;
|
||||
}
|
||||
|
@ -557,11 +555,6 @@ void PixelShaderCache::Shutdown()
|
|||
bool PixelShaderCache::SetShader(DSTALPHA_MODE dstAlphaMode)
|
||||
{
|
||||
PixelShaderUid uid = GetPixelShaderUid(dstAlphaMode);
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code = GeneratePixelShaderCode(dstAlphaMode, API_D3D, uid.GetUidData());
|
||||
pixel_uid_checker.AddToIndexAndCheck(code, uid, "Pixel", "p");
|
||||
}
|
||||
|
||||
// Check if the shader is already set
|
||||
if (last_entry)
|
||||
|
|
|
@ -53,8 +53,6 @@ private:
|
|||
static PSCache PixelShaders;
|
||||
static const PSCacheEntry* last_entry;
|
||||
static PixelShaderUid last_uid;
|
||||
|
||||
static UidChecker<PixelShaderUid, ShaderCode> pixel_uid_checker;
|
||||
};
|
||||
|
||||
} // namespace DX11
|
||||
|
|
|
@ -24,7 +24,6 @@ namespace DX11
|
|||
VertexShaderCache::VSCache VertexShaderCache::vshaders;
|
||||
const VertexShaderCache::VSCacheEntry* VertexShaderCache::last_entry;
|
||||
VertexShaderUid VertexShaderCache::last_uid;
|
||||
UidChecker<VertexShaderUid, ShaderCode> VertexShaderCache::vertex_uid_checker;
|
||||
|
||||
static ID3D11VertexShader* SimpleVertexShader = nullptr;
|
||||
static ID3D11VertexShader* ClearVertexShader = nullptr;
|
||||
|
@ -177,7 +176,6 @@ void VertexShaderCache::Clear()
|
|||
for (auto& iter : vshaders)
|
||||
iter.second.Destroy();
|
||||
vshaders.clear();
|
||||
vertex_uid_checker.Invalidate();
|
||||
|
||||
last_entry = nullptr;
|
||||
}
|
||||
|
@ -200,11 +198,6 @@ void VertexShaderCache::Shutdown()
|
|||
bool VertexShaderCache::SetShader()
|
||||
{
|
||||
VertexShaderUid uid = GetVertexShaderUid();
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code = GenerateVertexShaderCode(API_D3D, uid.GetUidData());
|
||||
vertex_uid_checker.AddToIndexAndCheck(code, uid, "Vertex", "v");
|
||||
}
|
||||
|
||||
if (last_entry)
|
||||
{
|
||||
|
|
|
@ -58,8 +58,6 @@ private:
|
|||
static VSCache vshaders;
|
||||
static const VSCacheEntry* last_entry;
|
||||
static VertexShaderUid last_uid;
|
||||
|
||||
static UidChecker<VertexShaderUid, ShaderCode> vertex_uid_checker;
|
||||
};
|
||||
|
||||
} // namespace DX11
|
||||
|
|
|
@ -42,10 +42,6 @@ static LinearDiskCache<GeometryShaderUid, u8> s_gs_disk_cache;
|
|||
static LinearDiskCache<PixelShaderUid, u8> s_ps_disk_cache;
|
||||
static LinearDiskCache<VertexShaderUid, u8> s_vs_disk_cache;
|
||||
|
||||
static UidChecker<GeometryShaderUid, ShaderCode> s_geometry_uid_checker;
|
||||
static UidChecker<PixelShaderUid, ShaderCode> s_pixel_uid_checker;
|
||||
static UidChecker<VertexShaderUid, ShaderCode> s_vertex_uid_checker;
|
||||
|
||||
static D3D12_SHADER_BYTECODE s_last_geometry_shader_bytecode;
|
||||
static D3D12_SHADER_BYTECODE s_last_pixel_shader_bytecode;
|
||||
static D3D12_SHADER_BYTECODE s_last_vertex_shader_bytecode;
|
||||
|
@ -152,10 +148,6 @@ void ShaderCache::Shutdown()
|
|||
s_ps_hlsl_cache.clear();
|
||||
s_vs_hlsl_cache.clear();
|
||||
}
|
||||
|
||||
s_geometry_uid_checker.Invalidate();
|
||||
s_pixel_uid_checker.Invalidate();
|
||||
s_vertex_uid_checker.Invalidate();
|
||||
}
|
||||
|
||||
void ShaderCache::LoadAndSetActiveShaders(DSTALPHA_MODE ps_dst_alpha_mode, u32 gs_primitive_type)
|
||||
|
@ -217,12 +209,6 @@ void ShaderCache::HandleGSUIDChange(GeometryShaderUid gs_uid, u32 gs_primitive_t
|
|||
{
|
||||
s_last_geometry_shader_uid = gs_uid;
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code = GenerateGeometryShaderCode(gs_primitive_type, API_D3D, gs_uid.GetUidData());
|
||||
s_geometry_uid_checker.AddToIndexAndCheck(code, gs_uid, "Geometry", "g");
|
||||
}
|
||||
|
||||
if (gs_uid.GetUidData()->IsPassthrough())
|
||||
{
|
||||
s_last_geometry_shader_bytecode = {};
|
||||
|
@ -261,12 +247,6 @@ void ShaderCache::HandlePSUIDChange(PixelShaderUid ps_uid, DSTALPHA_MODE ps_dst_
|
|||
{
|
||||
s_last_pixel_shader_uid = ps_uid;
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code = GeneratePixelShaderCode(ps_dst_alpha_mode, API_D3D, ps_uid.GetUidData());
|
||||
s_pixel_uid_checker.AddToIndexAndCheck(code, ps_uid, "Pixel", "p");
|
||||
}
|
||||
|
||||
auto ps_iterator = s_ps_bytecode_cache.find(ps_uid);
|
||||
if (ps_iterator != s_ps_bytecode_cache.end())
|
||||
{
|
||||
|
@ -302,12 +282,6 @@ void ShaderCache::HandleVSUIDChange(VertexShaderUid vs_uid)
|
|||
{
|
||||
s_last_vertex_shader_uid = vs_uid;
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode code = GenerateVertexShaderCode(API_D3D, vs_uid.GetUidData());
|
||||
s_vertex_uid_checker.AddToIndexAndCheck(code, vs_uid, "Vertex", "v");
|
||||
}
|
||||
|
||||
auto vs_iterator = s_vs_bytecode_cache.find(vs_uid);
|
||||
if (vs_iterator != s_vs_bytecode_cache.end())
|
||||
{
|
||||
|
|
|
@ -33,7 +33,6 @@ private:
|
|||
std::map<Uid, std::string> m_shaders;
|
||||
const std::string* m_last_entry = nullptr;
|
||||
Uid m_last_uid;
|
||||
UidChecker<Uid, ShaderCode> m_uid_checker;
|
||||
};
|
||||
|
||||
class VertexShaderCache : public ShaderCache<VertexShaderUid>
|
||||
|
|
|
@ -36,9 +36,6 @@ static GLuint CurrentProgram = 0;
|
|||
ProgramShaderCache::PCache ProgramShaderCache::pshaders;
|
||||
ProgramShaderCache::PCacheEntry* ProgramShaderCache::last_entry;
|
||||
SHADERUID ProgramShaderCache::last_uid;
|
||||
UidChecker<PixelShaderUid, ShaderCode> ProgramShaderCache::pixel_uid_checker;
|
||||
UidChecker<VertexShaderUid, ShaderCode> ProgramShaderCache::vertex_uid_checker;
|
||||
UidChecker<GeometryShaderUid, ShaderCode> ProgramShaderCache::geometry_uid_checker;
|
||||
|
||||
static std::string s_glsl_header = "";
|
||||
|
||||
|
@ -400,19 +397,6 @@ void ProgramShaderCache::GetShaderId(SHADERUID* uid, DSTALPHA_MODE dstAlphaMode,
|
|||
uid->puid = GetPixelShaderUid(dstAlphaMode);
|
||||
uid->vuid = GetVertexShaderUid();
|
||||
uid->guid = GetGeometryShaderUid(primitive_type);
|
||||
|
||||
if (g_ActiveConfig.bEnableShaderDebugging)
|
||||
{
|
||||
ShaderCode pcode = GeneratePixelShaderCode(dstAlphaMode, API_OPENGL, uid->puid.GetUidData());
|
||||
pixel_uid_checker.AddToIndexAndCheck(pcode, uid->puid, "Pixel", "p");
|
||||
|
||||
ShaderCode vcode = GenerateVertexShaderCode(API_OPENGL, uid->vuid.GetUidData());
|
||||
vertex_uid_checker.AddToIndexAndCheck(vcode, uid->vuid, "Vertex", "v");
|
||||
|
||||
ShaderCode gcode =
|
||||
GenerateGeometryShaderCode(primitive_type, API_OPENGL, uid->guid.GetUidData());
|
||||
geometry_uid_checker.AddToIndexAndCheck(gcode, uid->guid, "Geometry", "g");
|
||||
}
|
||||
}
|
||||
|
||||
ProgramShaderCache::PCacheEntry ProgramShaderCache::GetShaderProgram()
|
||||
|
@ -517,9 +501,6 @@ void ProgramShaderCache::Shutdown()
|
|||
}
|
||||
pshaders.clear();
|
||||
|
||||
pixel_uid_checker.Invalidate();
|
||||
vertex_uid_checker.Invalidate();
|
||||
|
||||
s_buffer.reset();
|
||||
}
|
||||
|
||||
|
|
|
@ -88,10 +88,6 @@ private:
|
|||
static PCacheEntry* last_entry;
|
||||
static SHADERUID last_uid;
|
||||
|
||||
static UidChecker<PixelShaderUid, ShaderCode> pixel_uid_checker;
|
||||
static UidChecker<VertexShaderUid, ShaderCode> vertex_uid_checker;
|
||||
static UidChecker<GeometryShaderUid, ShaderCode> geometry_uid_checker;
|
||||
|
||||
static u32 s_ubo_buffer_size;
|
||||
static s32 s_ubo_align;
|
||||
};
|
||||
|
|
|
@ -154,74 +154,6 @@ public:
|
|||
private:
|
||||
std::vector<bool> constant_usage; // TODO: Is vector<bool> appropriate here?
|
||||
};
|
||||
/**
|
||||
* Checks if there has been
|
||||
*/
|
||||
template <class UidT, class CodeT>
|
||||
class UidChecker
|
||||
{
|
||||
public:
|
||||
void Invalidate()
|
||||
{
|
||||
m_shaders.clear();
|
||||
m_uids.clear();
|
||||
}
|
||||
|
||||
void AddToIndexAndCheck(CodeT& new_code, const UidT& new_uid, const char* shader_type,
|
||||
const char* dump_prefix)
|
||||
{
|
||||
bool uid_is_indexed = std::find(m_uids.begin(), m_uids.end(), new_uid) != m_uids.end();
|
||||
if (!uid_is_indexed)
|
||||
{
|
||||
m_uids.push_back(new_uid);
|
||||
m_shaders[new_uid] = new_code.GetBuffer();
|
||||
}
|
||||
else
|
||||
{
|
||||
// uid is already in the index => check if there's a shader with the same uid but different
|
||||
// code
|
||||
auto& old_code = m_shaders[new_uid];
|
||||
if (old_code != new_code.GetBuffer())
|
||||
{
|
||||
static int num_failures = 0;
|
||||
|
||||
std::string temp =
|
||||
StringFromFormat("%s%ssuid_mismatch_%04i.txt", File::GetUserPath(D_DUMP_IDX).c_str(),
|
||||
dump_prefix, ++num_failures);
|
||||
|
||||
// TODO: Should also dump uids
|
||||
std::ofstream file;
|
||||
OpenFStream(file, temp, std::ios_base::out);
|
||||
file << "Old shader code:\n" << old_code;
|
||||
file << "\n\nNew shader code:\n" << new_code.GetBuffer();
|
||||
file << "\n\nShader uid:\n";
|
||||
for (unsigned int i = 0; i < new_uid.GetUidDataSize(); ++i)
|
||||
{
|
||||
u8 value = new_uid.GetUidDataRaw()[i];
|
||||
if ((i % 4) == 0)
|
||||
{
|
||||
auto last_value =
|
||||
(i + 3 < new_uid.GetUidDataSize() - 1) ? i + 3 : new_uid.GetUidDataSize();
|
||||
file << std::setfill(' ') << std::dec;
|
||||
file << "Values " << std::setw(2) << i << " - " << last_value << ": ";
|
||||
}
|
||||
|
||||
file << std::setw(2) << std::setfill('0') << std::hex << value << std::setw(1);
|
||||
if ((i % 4) < 3)
|
||||
file << ' ';
|
||||
else
|
||||
file << std::endl;
|
||||
}
|
||||
|
||||
ERROR_LOG(VIDEO, "%s shader uid mismatch! See %s for details", shader_type, temp.c_str());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
std::map<UidT, std::string> m_shaders;
|
||||
std::vector<UidT> m_uids;
|
||||
};
|
||||
|
||||
template <class T>
|
||||
inline void DefineOutputMember(T& object, API_TYPE api_type, const char* qualifier,
|
||||
|
|
Loading…
Reference in New Issue