dawn_native: deduplicate shader modules

BUG=dawn:143

Change-Id: I2c0fa63e3a6d77c137418f12b9807d16a0636d57
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/6862
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez
2019-05-01 13:27:07 +00:00
committed by Commit Bot service account
parent 0ee9859c91
commit c535198d96
5 changed files with 101 additions and 4 deletions

View File

@@ -48,4 +48,31 @@ TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
}
// Test that ShaderModules are correctly deduplicated.
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
dawn::ShaderModule module = utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
dawn::ShaderModule sameModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
})");
dawn::ShaderModule otherModule =
utils::CreateShaderModule(device, dawn::ShaderStage::Fragment, R"(
#version 450
layout(location = 0) out vec4 fragColor;
void main() {
fragColor = vec4(0.0);
})");
EXPECT_NE(module.Get(), otherModule.Get());
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
}
DAWN_INSTANTIATE_TEST(ObjectCachingTest, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);