Skip to content

Commit

Permalink
Merge pull request #8012 from stenzek/bounding-box-shaders
Browse files Browse the repository at this point in the history
PixelShaderGen: Don't emit bounding box shader code for old UIDs when disabled
  • Loading branch information
stenzek committed Apr 21, 2019
2 parents 18589e5 + c6b45c5 commit 5b4ebcc
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 16 deletions.
4 changes: 4 additions & 0 deletions Source/Core/VideoCommon/PixelShaderGen.cpp
Expand Up @@ -347,6 +347,10 @@ void ClearUnusedPixelShaderUidBits(APIType ApiType, const ShaderHostConfig& host
// uint output when logic op is not supported (i.e. driver/device does not support D3D11.1).
if (ApiType != APIType::D3D || !host_config.backend_logic_op)
uid_data->uint_output = 0;

// If bounding box is enabled when a UID cache is created, then later disabled, we shouldn't
// emit the bounding box portion of the shader.
uid_data->bounding_box &= host_config.bounding_box;
}

void WritePixelShaderCommonHeader(ShaderCode& out, APIType ApiType, u32 num_texgens,
Expand Down
36 changes: 20 additions & 16 deletions Source/Core/VideoCommon/ShaderCache.cpp
Expand Up @@ -641,17 +641,19 @@ const AbstractPipeline* ShaderCache::InsertGXPipeline(const GXPipelineUid& confi
auto& entry = m_gx_pipeline_cache[config];
entry.second = false;
if (!entry.first && pipeline)
{
entry.first = std::move(pipeline);

if (g_ActiveConfig.bShaderCache)
{
auto cache_data = entry.first->GetCacheData();
if (!cache_data.empty())
if (g_ActiveConfig.bShaderCache)
{
SerializedGXPipelineUid disk_uid;
SerializePipelineUid(config, disk_uid);
m_gx_pipeline_disk_cache.Append(disk_uid, cache_data.data(),
static_cast<u32>(cache_data.size()));
auto cache_data = entry.first->GetCacheData();
if (!cache_data.empty())
{
SerializedGXPipelineUid disk_uid;
SerializePipelineUid(config, disk_uid);
m_gx_pipeline_disk_cache.Append(disk_uid, cache_data.data(),
static_cast<u32>(cache_data.size()));
}
}
}

Expand All @@ -665,17 +667,19 @@ ShaderCache::InsertGXUberPipeline(const GXUberPipelineUid& config,
auto& entry = m_gx_uber_pipeline_cache[config];
entry.second = false;
if (!entry.first && pipeline)
{
entry.first = std::move(pipeline);

if (g_ActiveConfig.bShaderCache)
{
auto cache_data = entry.first->GetCacheData();
if (!cache_data.empty())
if (g_ActiveConfig.bShaderCache)
{
SerializedGXUberPipelineUid disk_uid;
SerializePipelineUid(config, disk_uid);
m_gx_uber_pipeline_disk_cache.Append(disk_uid, cache_data.data(),
static_cast<u32>(cache_data.size()));
auto cache_data = entry.first->GetCacheData();
if (!cache_data.empty())
{
SerializedGXUberPipelineUid disk_uid;
SerializePipelineUid(config, disk_uid);
m_gx_uber_pipeline_disk_cache.Append(disk_uid, cache_data.data(),
static_cast<u32>(cache_data.size()));
}
}
}

Expand Down

0 comments on commit 5b4ebcc

Please sign in to comment.