Skip to content

Fix cookie srgb #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions com.unity.render-pipelines.high-definition/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- DXR: Fixed shader compilation error with shader graph and pathtracer
- Fixed issue with screen-space shadows not enabled properly when RT is disabled (case 1235821)
- Fixed a performance issue with stochastic ray traced area shadows.
- Fixed cookie texture not updated when changing an import settings (srgb for example).

### Changed
- Improve MIP selection for decals on Transparents
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class Texture2DAtlas
private AtlasAllocator m_AtlasAllocator = null;
private Dictionary<int, Vector4> m_AllocationCache = new Dictionary<int, Vector4>();
private Dictionary<int, uint> m_IsGPUTextureUpToDate = new Dictionary<int, uint>();
private Dictionary<int, int> m_TextureHashes = new Dictionary<int, int>();

static readonly Vector4 fullScaleOffset = new Vector4(1, 1, 0, 0);

Expand Down Expand Up @@ -280,6 +281,7 @@ public virtual bool AllocateTextureWithoutBlit(int instanceId, int width, int he
scaleOffset.Scale(new Vector4(1.0f / m_Width, 1.0f / m_Height, 1.0f / m_Width, 1.0f / m_Height));
m_AllocationCache.Add(instanceId, scaleOffset);
MarkGPUTextureInvalid(instanceId); // the texture data haven't been uploaded
m_TextureHashes[instanceId] = -1;
return true;
}
else
Expand All @@ -291,10 +293,29 @@ public virtual bool AllocateTextureWithoutBlit(int instanceId, int width, int he
public bool IsCached(out Vector4 scaleOffset, Texture texture)
=> m_AllocationCache.TryGetValue(texture.GetInstanceID(), out scaleOffset);

protected int GetTextureHash(Texture texture)
{
int hash = texture.GetHashCode();

unchecked
{
hash = hash * 23 + texture.graphicsFormat.GetHashCode();
hash = hash * 23 + texture.wrapMode.GetHashCode();
hash = hash * 23 + texture.width.GetHashCode();
hash = hash * 23 + texture.height.GetHashCode();
hash = hash * 23 + texture.filterMode.GetHashCode();
hash = hash * 23 + texture.anisoLevel.GetHashCode();
hash = hash * 23 + texture.mipmapCount.GetHashCode();
}

return hash;
}

public virtual bool NeedsUpdate(Texture texture, bool needMips = false)
{
RenderTexture rt = texture as RenderTexture;
int key = texture.GetInstanceID();
int textureHash = GetTextureHash(texture);

// Update the render texture if needed
if (rt != null)
Expand All @@ -311,6 +332,12 @@ public virtual bool NeedsUpdate(Texture texture, bool needMips = false)
m_IsGPUTextureUpToDate[key] = rt.updateCount;
}
}
// In case the texture settings/import settings have changed, we need to update it
else if (m_TextureHashes.TryGetValue(key, out int hash) && hash != textureHash)
{
m_TextureHashes[key] = textureHash;
return true;
}
// For regular textures, values == 0 means that their GPU data needs to be updated (either because
// the atlas have been re-layouted or the texture have never been uploaded. We also check if the mips
// are valid for the texture if we need them
Expand Down