Update ObjectCachingTests to use WGSL
Bug: dawn:572 Change-Id: I64ebc3f0aabf806dd10b6b90cd7352707643ee58 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/33880 Commit-Queue: Austin Eng <enga@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
5fc12c314a
commit
054d85366a
|
@ -108,27 +108,21 @@ TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
|
||||||
|
|
||||||
// Test that ShaderModules are correctly deduplicated.
|
// Test that ShaderModules are correctly deduplicated.
|
||||||
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
|
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
|
||||||
wgpu::ShaderModule module =
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[location(0)]] var<out> fragColor : vec4<f32>;
|
||||||
#version 450
|
[[stage(fragment)]] fn main() -> void {
|
||||||
layout(location = 0) out vec4 fragColor;
|
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||||
void main() {
|
})");
|
||||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
})");
|
[[location(0)]] var<out> fragColor : vec4<f32>;
|
||||||
wgpu::ShaderModule sameModule =
|
[[stage(fragment)]] fn main() -> void {
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||||
#version 450
|
})");
|
||||||
layout(location = 0) out vec4 fragColor;
|
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
void main() {
|
[[location(0)]] var<out> fragColor : vec4<f32>;
|
||||||
fragColor = vec4(0.0, 1.0, 0.0, 1.0);
|
[[stage(fragment)]] fn main() -> void {
|
||||||
})");
|
fragColor = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||||
wgpu::ShaderModule otherModule =
|
})");
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
|
||||||
#version 450
|
|
||||||
layout(location = 0) out vec4 fragColor;
|
|
||||||
void main() {
|
|
||||||
fragColor = vec4(0.0);
|
|
||||||
})");
|
|
||||||
|
|
||||||
EXPECT_NE(module.Get(), otherModule.Get());
|
EXPECT_NE(module.Get(), otherModule.Get());
|
||||||
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
||||||
|
@ -136,25 +130,19 @@ TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
|
||||||
|
|
||||||
// Test that ComputePipeline are correctly deduplicated wrt. their ShaderModule
|
// Test that ComputePipeline are correctly deduplicated wrt. their ShaderModule
|
||||||
TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
|
TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
|
||||||
wgpu::ShaderModule module =
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
var<workgroup> i : u32;
|
||||||
#version 450
|
[[stage(compute)]] fn main() -> void {
|
||||||
shared uint i;
|
i = 0u;
|
||||||
void main() {
|
})");
|
||||||
i = 0;
|
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
})");
|
var<workgroup> i : u32;
|
||||||
wgpu::ShaderModule sameModule =
|
[[stage(compute)]] fn main() -> void {
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
i = 0u;
|
||||||
#version 450
|
})");
|
||||||
shared uint i;
|
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
void main() {
|
[[stage(compute)]] fn main() -> void {
|
||||||
i = 0;
|
})");
|
||||||
})");
|
|
||||||
wgpu::ShaderModule otherModule =
|
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
|
||||||
#version 450
|
|
||||||
void main() {
|
|
||||||
})");
|
|
||||||
|
|
||||||
EXPECT_NE(module.Get(), otherModule.Get());
|
EXPECT_NE(module.Get(), otherModule.Get());
|
||||||
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
||||||
|
@ -194,12 +182,10 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
|
||||||
|
|
||||||
wgpu::ComputePipelineDescriptor desc;
|
wgpu::ComputePipelineDescriptor desc;
|
||||||
desc.computeStage.entryPoint = "main";
|
desc.computeStage.entryPoint = "main";
|
||||||
desc.computeStage.module =
|
desc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Compute, R"(
|
var<workgroup> i : u32;
|
||||||
#version 450
|
[[stage(compute)]] fn main() -> void {
|
||||||
shared uint i;
|
i = 0u;
|
||||||
void main() {
|
|
||||||
i = 0;
|
|
||||||
})");
|
})");
|
||||||
|
|
||||||
desc.layout = pl;
|
desc.layout = pl;
|
||||||
|
@ -230,17 +216,14 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
|
||||||
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
|
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor desc(device);
|
utils::ComboRenderPipelineDescriptor desc(device);
|
||||||
desc.vertexStage.module =
|
desc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
#version 450
|
[[stage(vertex)]] fn main() -> void {
|
||||||
void main() {
|
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||||
gl_Position = vec4(0.0);
|
})");
|
||||||
})");
|
desc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
desc.cFragmentStage.module =
|
[[stage(fragment)]] fn main() -> void {
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
})");
|
||||||
#version 450
|
|
||||||
void main() {
|
|
||||||
})");
|
|
||||||
|
|
||||||
desc.layout = pl;
|
desc.layout = pl;
|
||||||
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
|
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
|
||||||
|
@ -257,33 +240,28 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
|
||||||
|
|
||||||
// Test that RenderPipelines are correctly deduplicated wrt. their vertex module
|
// Test that RenderPipelines are correctly deduplicated wrt. their vertex module
|
||||||
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
|
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
|
||||||
wgpu::ShaderModule module =
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
#version 450
|
[[stage(vertex)]] fn main() -> void {
|
||||||
void main() {
|
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||||
gl_Position = vec4(0.0);
|
})");
|
||||||
})");
|
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
wgpu::ShaderModule sameModule =
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[stage(vertex)]] fn main() -> void {
|
||||||
#version 450
|
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||||
void main() {
|
})");
|
||||||
gl_Position = vec4(0.0);
|
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
})");
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
wgpu::ShaderModule otherModule =
|
[[stage(vertex)]] fn main() -> void {
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
Position = vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||||
#version 450
|
})");
|
||||||
void main() {
|
|
||||||
gl_Position = vec4(1.0);
|
|
||||||
})");
|
|
||||||
|
|
||||||
EXPECT_NE(module.Get(), otherModule.Get());
|
EXPECT_NE(module.Get(), otherModule.Get());
|
||||||
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor desc(device);
|
utils::ComboRenderPipelineDescriptor desc(device);
|
||||||
desc.cFragmentStage.module =
|
desc.cFragmentStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[stage(fragment)]] fn main() -> void {
|
||||||
#version 450
|
|
||||||
void main() {
|
|
||||||
})");
|
})");
|
||||||
|
|
||||||
desc.vertexStage.module = module;
|
desc.vertexStage.module = module;
|
||||||
|
@ -301,34 +279,27 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
|
||||||
|
|
||||||
// Test that RenderPipelines are correctly deduplicated wrt. their fragment module
|
// Test that RenderPipelines are correctly deduplicated wrt. their fragment module
|
||||||
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
|
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
|
||||||
wgpu::ShaderModule module =
|
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
[[stage(fragment)]] fn main() -> void {
|
||||||
#version 450
|
})");
|
||||||
void main() {
|
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
})");
|
[[stage(fragment)]] fn main() -> void {
|
||||||
wgpu::ShaderModule sameModule =
|
})");
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
#version 450
|
[[location(0)]] var<out> fragColor : vec4<f32>;
|
||||||
void main() {
|
[[stage(fragment)]] fn main() -> void {
|
||||||
})");
|
fragColor = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||||
wgpu::ShaderModule otherModule =
|
})");
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Fragment, R"(
|
|
||||||
#version 450
|
|
||||||
layout (location = 0) out vec4 color;
|
|
||||||
void main() {
|
|
||||||
color = vec4(0.0);
|
|
||||||
})");
|
|
||||||
|
|
||||||
EXPECT_NE(module.Get(), otherModule.Get());
|
EXPECT_NE(module.Get(), otherModule.Get());
|
||||||
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
|
||||||
|
|
||||||
utils::ComboRenderPipelineDescriptor desc(device);
|
utils::ComboRenderPipelineDescriptor desc(device);
|
||||||
desc.vertexStage.module =
|
desc.vertexStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
|
||||||
utils::CreateShaderModule(device, utils::SingleShaderStage::Vertex, R"(
|
[[builtin(position)]] var<out> Position : vec4<f32>;
|
||||||
#version 450
|
[[stage(vertex)]] fn main() -> void {
|
||||||
void main() {
|
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||||
gl_Position = vec4(0.0);
|
})");
|
||||||
})");
|
|
||||||
|
|
||||||
desc.cFragmentStage.module = module;
|
desc.cFragmentStage.module = module;
|
||||||
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
|
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&desc);
|
||||||
|
|
Loading…
Reference in New Issue