From 53fe5a04ec978bec1536140a974f709e716135b2 Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Feb 2016 23:26:24 -0500 Subject: [PATCH 1/2] ShaderCache: Remove unnecessary null checks We already bail out if the shader compilation fails. Also, there would have already been a nullptr dereference in InsertByteCode prior to reaching this point. --- Source/Core/VideoBackends/D3D12/ShaderCache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoBackends/D3D12/ShaderCache.cpp b/Source/Core/VideoBackends/D3D12/ShaderCache.cpp index 299834434b..272a6a436b 100644 --- a/Source/Core/VideoBackends/D3D12/ShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D12/ShaderCache.cpp @@ -244,7 +244,7 @@ void ShaderCache::HandleGSUIDChange(GeometryShaderUid gs_uid, u32 gs_primitive_t s_last_geometry_shader_bytecode = InsertByteCode(gs_uid, &s_gs_bytecode_cache, gs_bytecode); s_gs_disk_cache.Append(gs_uid, reinterpret_cast(gs_bytecode->GetBufferPointer()), static_cast(gs_bytecode->GetBufferSize())); - if (g_ActiveConfig.bEnableShaderDebugging && gs_bytecode) + if (g_ActiveConfig.bEnableShaderDebugging) { s_gs_hlsl_cache[gs_uid] = gs_code.GetBuffer(); } @@ -284,7 +284,7 @@ void ShaderCache::HandlePSUIDChange(PixelShaderUid ps_uid, DSTALPHA_MODE ps_dst_ SETSTAT(stats.numPixelShadersAlive, static_cast(s_ps_bytecode_cache.size())); INCSTAT(stats.numPixelShadersCreated); - if (g_ActiveConfig.bEnableShaderDebugging && ps_bytecode) + if (g_ActiveConfig.bEnableShaderDebugging) { s_ps_hlsl_cache[ps_uid] = ps_code.GetBuffer(); } @@ -324,7 +324,7 @@ void ShaderCache::HandleVSUIDChange(VertexShaderUid vs_uid) SETSTAT(stats.numVertexShadersAlive, static_cast(s_vs_bytecode_cache.size())); INCSTAT(stats.numVertexShadersCreated); - if (g_ActiveConfig.bEnableShaderDebugging && vs_bytecode) + if (g_ActiveConfig.bEnableShaderDebugging) { s_vs_hlsl_cache[vs_uid] = vs_code.GetBuffer(); } From 6c0db9fe3c2160b0d1231716aea1a2663b0ae35d Mon Sep 17 00:00:00 2001 From: Lioncash Date: Mon, 15 Feb 2016 23:31:25 -0500 Subject: [PATCH 2/2] ShaderCache: Remove unnecessary template type specifications These are already inferred through the passed in arguments. --- Source/Core/VideoBackends/D3D12/ShaderCache.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Core/VideoBackends/D3D12/ShaderCache.cpp b/Source/Core/VideoBackends/D3D12/ShaderCache.cpp index 272a6a436b..1152ea19b6 100644 --- a/Source/Core/VideoBackends/D3D12/ShaderCache.cpp +++ b/Source/Core/VideoBackends/D3D12/ShaderCache.cpp @@ -241,7 +241,7 @@ void ShaderCache::HandleGSUIDChange(GeometryShaderUid gs_uid, u32 gs_primitive_t return; } - s_last_geometry_shader_bytecode = InsertByteCode(gs_uid, &s_gs_bytecode_cache, gs_bytecode); + s_last_geometry_shader_bytecode = InsertByteCode(gs_uid, &s_gs_bytecode_cache, gs_bytecode); s_gs_disk_cache.Append(gs_uid, reinterpret_cast(gs_bytecode->GetBufferPointer()), static_cast(gs_bytecode->GetBufferSize())); if (g_ActiveConfig.bEnableShaderDebugging) @@ -278,7 +278,7 @@ void ShaderCache::HandlePSUIDChange(PixelShaderUid ps_uid, DSTALPHA_MODE ps_dst_ return; } - s_last_pixel_shader_bytecode = InsertByteCode(ps_uid, &s_ps_bytecode_cache, ps_bytecode); + s_last_pixel_shader_bytecode = InsertByteCode(ps_uid, &s_ps_bytecode_cache, ps_bytecode); s_ps_disk_cache.Append(ps_uid, reinterpret_cast(ps_bytecode->GetBufferPointer()), static_cast(ps_bytecode->GetBufferSize())); SETSTAT(stats.numPixelShadersAlive, static_cast(s_ps_bytecode_cache.size())); @@ -318,7 +318,7 @@ void ShaderCache::HandleVSUIDChange(VertexShaderUid vs_uid) return; } - s_last_vertex_shader_bytecode = InsertByteCode(vs_uid, &s_vs_bytecode_cache, vs_bytecode); + s_last_vertex_shader_bytecode = InsertByteCode(vs_uid, &s_vs_bytecode_cache, vs_bytecode); s_vs_disk_cache.Append(vs_uid, reinterpret_cast(vs_bytecode->GetBufferPointer()), static_cast(vs_bytecode->GetBufferSize())); SETSTAT(stats.numVertexShadersAlive, static_cast(s_vs_bytecode_cache.size()));