Frédéric Vauchelles
7 年前
当前提交
eb462aff
共有 7 个文件被更改,包括 98 次插入 和 34 次删除
-
44ScriptableRenderPipeline/Core/TextureCache.cs
-
8Tests/CoreTests.meta
-
8Tests/CoreTests/Editor.meta
-
61Tests/CoreTests/Editor/TextureCacheTests.cs
-
11Tests/CoreTests/Editor/TextureCacheTests.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: f7dbbd5a5c998eb45af5af9e5702fc0c |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: aedf4443dd1f470469570e170988015e |
|||
folderAsset: yes |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using NUnit.Framework; |
|||
using UnityEngine; |
|||
using UnityEngine.Experimental.Rendering; |
|||
namespace UnityEditor.Experimental.Rendering |
|||
{ |
|||
public class TextureCacheCounter : TextureCache |
|||
{ |
|||
public int transferToSliceCallCount { get; private set; } |
|||
public TextureCacheCounter() |
|||
{ |
|||
AllocTextureArray(8); |
|||
} |
|||
public override void TransferToSlice(int sliceIndex, Texture texture) |
|||
{ |
|||
++transferToSliceCallCount; |
|||
} |
|||
} |
|||
|
|||
[TestFixture] |
|||
public class TextureCacheTests |
|||
{ |
|||
Texture2D m_Tex; |
|||
const int k_TextureSize = 8; |
|||
static readonly Color[] s_Pixels = new Color[k_TextureSize * k_TextureSize]; |
|||
[OneTimeSetUp] |
|||
public void Setup() |
|||
{ |
|||
m_Tex = new Texture2D(k_TextureSize, k_TextureSize, TextureFormat.ARGB32, false, true); |
|||
|
|||
SetTextureColor(Color.blue);
} |
|||
|
|||
[Test] |
|||
public void TextureCacheAddSlice() |
|||
{ |
|||
var cache = new TextureCacheCounter(); |
|||
var slice = cache.FetchSlice(m_Tex); |
|||
|
|||
Assert.True(slice >= 0); |
|||
Assert.AreEqual(1, cache.transferToSliceCallCount); |
|||
|
|||
var slice2 = cache.FetchSlice(m_Tex); |
|||
|
|||
Assert.AreEqual(slice, slice2); |
|||
Assert.AreEqual(1, cache.transferToSliceCallCount); |
|||
|
|||
SetTextureColor(Color.red); |
|||
|
|||
var slice3 = cache.FetchSlice(m_Tex); |
|||
|
|||
Assert.AreEqual(slice, slice3); |
|||
Assert.AreEqual(2, cache.transferToSliceCallCount);
} |
|||
void SetTextureColor(Color col) |
|||
{ |
|||
for (var i = 0; i < s_Pixels.Length; ++i) |
|||
s_Pixels[i] = Color.blue; |
|||
m_Tex.SetPixels(s_Pixels); |
|||
m_Tex.Apply(); |
|||
} |
|||
} |
|||
} |
|||
|
|
|||
fileFormatVersion: 2 |
|||
guid: ac8bd2a0373f2d24782ffb8d77e7512d |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue