Remove utility to create shader modules from GLSL

And rename CreateShaderModuleFromWGSL to CreateShaderModule.

Bug: dawn:572
Change-Id: I80dab401078b2001d738b87d6e24437f93b690d1
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/45764
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Reviewed-by: Austin Eng <enga@chromium.org>
Commit-Queue: Austin Eng <enga@chromium.org>
Auto-Submit: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
Corentin Wallez 2021-03-24 15:55:32 +00:00 committed by Commit Bot service account
parent 1452cf60e5
commit 7aec4ae7c5
81 changed files with 338 additions and 432 deletions

View File

@ -55,8 +55,7 @@ void init() {
swapchain.Configure(GetPreferredSwapChainTextureFormat(), wgpu::TextureUsage::RenderAttachment,
640, 480);
wgpu::ShaderModule vsModule =
utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Constants {
scale : f32;
time : f32;
@ -108,7 +107,7 @@ void init() {
Position = vec4<f32>(xpos, ypos, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>;
[[location(0)]] var<in> v_color : vec4<f32>;

View File

@ -48,7 +48,7 @@ void init() {
" Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);\n"
" return;\n"
"}\n";
WGPUShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vs).Release();
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
const char* fs =
"[[location(0)]] var<out> fragColor : vec4<f32>;\n"
@ -56,7 +56,7 @@ void init() {
" fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);\n"
" return;\n"
"}\n";
WGPUShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fs).Release();
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();
{
WGPURenderPipelineDescriptor2 descriptor = {};

View File

@ -95,7 +95,7 @@ void initBuffers() {
}
void initRender() {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> a_particlePos : vec2<f32>;
[[location(1)]] var<in> a_particleVel : vec2<f32>;
[[location(2)]] var<in> a_pos : vec2<f32>;
@ -112,7 +112,7 @@ void initRender() {
}
)");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>;
[[stage(fragment)]]
fn main() -> void {
@ -149,7 +149,7 @@ void initRender() {
}
void initSim() {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Particle {
pos : vec2<f32>;
vel : vec2<f32>;

View File

@ -95,7 +95,7 @@ void init() {
initBuffers();
initTextures();
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[location(0)]] var<in> pos : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
@ -103,7 +103,7 @@ void init() {
return;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[group(0), binding(0)]] var mySampler: sampler;
[[group(0), binding(1)]] var myTexture : texture_2d<f32>;

View File

@ -101,7 +101,7 @@ void init() {
initBuffers();
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Camera {
view : mat4x4<f32>;
proj : mat4x4<f32>;
@ -125,7 +125,7 @@ void init() {
return;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>;
[[location(2)]] var<in> f_col : vec3<f32>;
@ -134,7 +134,7 @@ void init() {
return;
})");
wgpu::ShaderModule fsReflectionModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsReflectionModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>;
[[location(2)]] var<in> f_col : vec3<f32>;

View File

@ -312,7 +312,7 @@ int main(int argc, const char* argv[]) {
// The hacky pipeline to render a triangle.
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
const pos : array<vec2<f32>, 3> = array<vec2<f32>, 3>(
@ -324,7 +324,7 @@ int main(int argc, const char* argv[]) {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return;
})");
pipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);

View File

@ -45,7 +45,7 @@ class BindGroupTests : public DawnTest {
}
wgpu::ShaderModule MakeSimpleVSModule() const {
return utils::CreateShaderModuleFromWGSL(device, R"(
return utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -89,7 +89,7 @@ class BindGroupTests : public DawnTest {
fs << "fragColor = fragColor + buffer" << i << ".color;\n";
}
fs << "}\n";
return utils::CreateShaderModuleFromWGSL(device, fs.str().c_str());
return utils::CreateShaderModule(device, fs.str().c_str());
}
wgpu::RenderPipeline MakeTestPipeline(const utils::BasicRenderPass& renderPass,
@ -123,7 +123,7 @@ class BindGroupTests : public DawnTest {
// Test a bindgroup reused in two command buffers in the same call to queue.Submit().
// This test passes by not asserting or crashing.
TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Contents {
f : f32;
};
@ -156,7 +156,7 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
TEST_P(BindGroupTests, ReusedUBO) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
[[block]] struct VertexUniformBuffer {
transform : vec4<f32>;
@ -179,7 +179,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
Position = vec4<f32>(transform * pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct FragmentUniformBuffer {
color : vec4<f32>;
};
@ -240,7 +240,7 @@ TEST_P(BindGroupTests, ReusedUBO) {
TEST_P(BindGroupTests, UBOSamplerAndTexture) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
[[block]] struct VertexUniformBuffer {
transform : vec4<f32>;
@ -262,7 +262,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
Position = vec4<f32>(transform * pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(1)]] var samp : sampler;
[[group(0), binding(2)]] var tex : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
@ -349,7 +349,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
TEST_P(BindGroupTests, MultipleBindLayouts) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
// TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct VertexUniformBuffer1 {
@ -379,7 +379,7 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
) * pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/386): Use the same struct
[[block]] struct FragmentUniformBuffer1 {
color : vec4<f32>;
@ -835,7 +835,7 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
});
wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.computeStage.module = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/386): Use the same struct
[[block]] struct Buffer0 {
value : u32;
@ -950,7 +950,7 @@ TEST_P(BindGroupTests, DynamicBindingNoneVisibility) {
TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -963,7 +963,7 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/386): Use the same struct
[[block]] struct Ubo1 {
color : vec4<f32>;
@ -1083,7 +1083,7 @@ TEST_P(BindGroupTests, EmptyLayout) {
wgpu::ComputePipelineDescriptor pipelineDesc;
pipelineDesc.layout = utils::MakeBasicPipelineLayout(device, &bgl);
pipelineDesc.computeStage.entryPoint = "main";
pipelineDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.computeStage.module = utils::CreateShaderModule(device, R"(
[[stage(compute)]] fn main() -> void {
})");
@ -1106,7 +1106,7 @@ TEST_P(BindGroupTests, EmptyLayout) {
TEST_P(BindGroupTests, ReadonlyStorage) {
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -1119,7 +1119,7 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[block]] struct Buffer0 {
color : vec4<f32>;
};
@ -1285,7 +1285,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
std::string shader =
interface.str() + "[[stage(compute)]] fn main() -> void {\n" + body.str() + "}\n";
wgpu::ComputePipelineDescriptor cpDesc;
cpDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, shader.c_str());
cpDesc.computeStage.module = utils::CreateShaderModule(device, shader.c_str());
cpDesc.computeStage.entryPoint = "main";
wgpu::ComputePipeline cp = device.CreateComputePipeline(&cpDesc);

View File

@ -204,9 +204,9 @@ class BufferZeroInitTest : public DawnTest {
uint32_t vertexBufferCount = 1u) {
constexpr wgpu::TextureFormat kColorAttachmentFormat = wgpu::TextureFormat::RGBA8Unorm;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vertexShader);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> i_color : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>;
@ -424,8 +424,7 @@ class BufferZeroInitTest : public DawnTest {
wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.layout = nullptr;
pipelineDescriptor.computeStage.module =
utils::CreateShaderModuleFromWGSL(device, computeShader);
pipelineDescriptor.computeStage.module = utils::CreateShaderModule(device, computeShader);
pipelineDescriptor.computeStage.entryPoint = "main";
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDescriptor);
@ -984,7 +983,7 @@ TEST_P(BufferZeroInitTest, BoundAsUniformBuffer) {
DAWN_SKIP_TEST_IF(IsOpenGLES() && IsBackendValidationEnabled());
constexpr uint32_t kBoundBufferSize = 16u;
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct UBO {
value : vec4<u32>;
};
@ -1023,7 +1022,7 @@ TEST_P(BufferZeroInitTest, BoundAsReadonlyStorageBuffer) {
DAWN_SKIP_TEST_IF(IsOpenGLES() && IsBackendValidationEnabled());
constexpr uint32_t kBoundBufferSize = 16u;
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct SSBO {
value : vec4<u32>;
};
@ -1062,7 +1061,7 @@ TEST_P(BufferZeroInitTest, BoundAsStorageBuffer) {
DAWN_SKIP_TEST_IF(IsOpenGLES() && IsBackendValidationEnabled());
constexpr uint32_t kBoundBufferSize = 32u;
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct SSBO {
value : array<vec4<u32>, 2>;
};

View File

@ -25,7 +25,7 @@ class ClipSpaceTest : public DawnTest {
// Draw two triangles:
// 1. The depth value of the top-left one is >= 0.5
// 2. The depth value of the bottom-right one is <= 0.5
pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
const pos : array<vec3<f32>, 6> = array<vec3<f32>, 6>(
vec3<f32>(-1.0, 1.0, 1.0),
vec3<f32>(-1.0, -1.0, 0.5),
@ -42,7 +42,7 @@ class ClipSpaceTest : public DawnTest {
return;
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);

View File

@ -30,7 +30,7 @@ class ColorStateTest : public DawnTest {
void SetUp() override {
DawnTest::SetUp();
vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -55,7 +55,7 @@ class ColorStateTest : public DawnTest {
// Set up basePipeline and testPipeline. testPipeline has the given blend state on the first
// attachment. basePipeline has no blending
void SetupSingleSourcePipelines(wgpu::ColorTargetState colorTargetState) {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct MyBlock {
color : vec4<f32>;
};
@ -785,7 +785,7 @@ TEST_P(ColorStateTest, IndependentColorState) {
utils::ComboRenderPassDescriptor renderPass(
{renderTargetViews[0], renderTargetViews[1], renderTargetViews[2], renderTargetViews[3]});
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct MyBlock {
color0 : vec4<f32>;
color1 : vec4<f32>;
@ -904,7 +904,7 @@ TEST_P(ColorStateTest, IndependentColorState) {
// Test that the default blend color is correctly set at the beginning of every subpass
TEST_P(ColorStateTest, DefaultBlendColor) {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct MyBlock {
color : vec4<f32>;
};
@ -1031,7 +1031,7 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
// persisted and prevented a render pass loadOp from fully clearing the output
// attachment.
TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct MyBlock {
color : vec4<f32>;
};

View File

@ -139,7 +139,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
ASSERT(IsBCFormatSupported());
utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[location(0)]] var<out> texCoord : vec2 <f32>;
@ -155,7 +155,7 @@ class CompressedTextureBCFormatTest : public DawnTest {
texCoord = vec2<f32>(Position.x / 2.0, -Position.y / 2.0) + vec2<f32>(0.5, 0.5);
return;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var sampler0 : sampler;
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;

View File

@ -29,7 +29,7 @@ class ComputeCopyStorageBufferTests : public DawnTest {
void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
// Set up shader and pipeline
auto module = utils::CreateShaderModuleFromWGSL(device, shader);
auto module = utils::CreateShaderModule(device, shader);
wgpu::ComputePipelineDescriptor csDesc;
csDesc.computeStage.module = module;

View File

@ -28,7 +28,7 @@ class ComputeDispatchTests : public DawnTest {
// Write workgroup number into the output buffer if we saw the biggest dispatch
// This is a workaround since D3D12 doesn't have gl_NumWorkGroups
// To make sure the dispatch was not called, write maximum u32 value for 0 dispatches
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct InputBuf {
expectedDispatch : vec3<u32>;
};

View File

@ -27,7 +27,7 @@ class ComputeSharedMemoryTests : public DawnTest {
void ComputeSharedMemoryTests::BasicTest(const char* shader) {
// Set up shader and pipeline
auto module = utils::CreateShaderModuleFromWGSL(device, shader);
auto module = utils::CreateShaderModule(device, shader);
wgpu::ComputePipelineDescriptor csDesc;
csDesc.computeStage.module = module;

View File

@ -31,7 +31,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddIncrement) {
wgpu::Buffer buffer = utils::CreateBufferFromData(
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Buf {
data : array<u32, 100>;
};
@ -82,7 +82,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
wgpu::Buffer bufferB = utils::CreateBufferFromData(
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct Src {
data : array<u32, 100>;
@ -153,7 +153,7 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
wgpu::Buffer bufferB = utils::CreateBufferFromData(
device, data.data(), bufferSize, wgpu::BufferUsage::Storage | wgpu::BufferUsage::CopySrc);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/386): Use the same struct.
[[block]] struct Src {
data : array<u32, 100>;
@ -227,7 +227,7 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPong) {
device, data.data(), bufferSize,
wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopySrc);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Buf {
data : array<vec4<u32>, 25>;
};
@ -295,7 +295,7 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPongInOnePass) {
device, data.data(), bufferSize,
wgpu::BufferUsage::Storage | wgpu::BufferUsage::Uniform | wgpu::BufferUsage::CopySrc);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Buf {
data : array<vec4<u32>, 25>;
};

View File

@ -110,7 +110,7 @@ class CopyTextureForBrowserTests : public DawnTest {
// shader) instead of CPU after executing CopyTextureForBrowser() to avoid the errors caused by
// comparing a value generated on CPU to the one generated on GPU.
wgpu::ComputePipeline MakeTestPipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct Uniforms {
dstTextureFlipY : u32;
channelCount : u32;

View File

@ -34,7 +34,7 @@ class CreatePipelineAsyncTest : public DawnTest {
// Verify the basic use of CreateComputePipelineAsync works on all backends.
TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateComputePipelineAsync) {
wgpu::ComputePipelineDescriptor csDesc;
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
csDesc.computeStage.module = utils::CreateShaderModule(device, R"(
[[block]] struct SSBO {
value : u32;
};
@ -101,7 +101,7 @@ TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
DAWN_SKIP_TEST_IF(HasToggleEnabled("skip_validation"));
wgpu::ComputePipelineDescriptor csDesc;
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
csDesc.computeStage.module = utils::CreateShaderModule(device, R"(
[[block]] struct SSBO {
value : u32;
};
@ -138,12 +138,12 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) {
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::RGBA8Unorm;
utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> o_color : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
@ -208,12 +208,12 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
constexpr wgpu::TextureFormat kRenderAttachmentFormat = wgpu::TextureFormat::Depth32Float;
utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> o_color : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
@ -248,7 +248,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
// CreateComputePipelineAsync() is called.
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipelineAsync) {
wgpu::ComputePipelineDescriptor csDesc;
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
csDesc.computeStage.module = utils::CreateShaderModule(device, R"(
[[stage(compute)]] fn main() -> void {
})");
csDesc.computeStage.entryPoint = "main";
@ -272,12 +272,12 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipeli
// CreateRenderPipelineAsync() is called.
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> o_color : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -25,7 +25,7 @@ class CullingTest : public DawnTest {
// Draw two triangles with different winding orders:
// 1. The top-left one is counterclockwise (CCW)
// 2. The bottom-right one is clockwise (CW)
pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
const pos : array<vec2<f32>, 6> = array<vec2<f32>, 6>(
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, 0.0),
@ -45,7 +45,7 @@ class CullingTest : public DawnTest {
// FragCoord of pixel(x, y) in framebuffer coordinate is (x + 0.5, y + 0.5). And we use
// RGBA8 format for the back buffer. So (FragCoord.xy - vec2(0.5)) / 255 in shader code
// will make the pixel's R and G channels exactly equal to the pixel's x and y coordinates.
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;

View File

@ -100,7 +100,7 @@ class D3D12CachingTests : public DawnTest {
TEST_P(D3D12CachingTests, SameShaderNoCache) {
mPersistentCache.mIsDisabled = true;
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn vertex_main() -> void {
@ -147,7 +147,7 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
// of HLSL shaders. WGSL shader should result into caching 2 HLSL shaders (stage x
// entrypoints)
TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn vertex_main() -> void {
@ -192,7 +192,7 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
EXPECT_EQ(mPersistentCache.mCache.size(), 2u);
// Modify the WGSL shader functions and make sure it doesn't hit.
wgpu::ShaderModule newModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule newModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn vertex_main() -> void {
@ -225,7 +225,7 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
// Test creating a WGSL shader with two entrypoints in the same stage will cache the correct number
// of HLSL shaders. WGSL shader should result into caching 1 HLSL shader (stage x entrypoints)
TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPoints) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Data {
data : u32;
};

View File

@ -221,7 +221,7 @@ namespace {
// Vertex shader used to render a sampled texture into a quad.
wgpu::ShaderModule GetTestVertexShaderModule() const {
return utils::CreateShaderModuleFromWGSL(device, R"(
return utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[location(0)]] var<out> texCoord : vec2 <f32>;
@ -276,7 +276,7 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYtoR) {
utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var texture : texture_2d<f32>;
@ -329,7 +329,7 @@ TEST_P(D3D12VideoViewsTests, NV12SampleUVtoRG) {
utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var texture : texture_2d<f32>;
@ -387,7 +387,7 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYUVtoRGB) {
utils::ComboRenderPipelineDescriptor2 renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var lumaTexture : texture_2d<f32>;
[[set(0), binding(2)]] var chromaTexture : texture_2d<f32>;

View File

@ -496,7 +496,7 @@ class VertexFormatDeprecationTests : public DeprecationTests {
? "vec4<f32>(f32(a.x), 0.0, 0.0, 1.0)"
: "vec4<f32>(f32(a), 0.0, 0.0, 1.0)";
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, (attribute + R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, (attribute + R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
@ -504,8 +504,8 @@ class VertexFormatDeprecationTests : public DeprecationTests {
return;
}
)")
.c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
.c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> outColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {

View File

@ -70,9 +70,9 @@ class DepthBiasTests : public DawnTest {
break;
}
wgpu::ShaderModule vertexModule = utils::CreateShaderModuleFromWGSL(device, vertexSource);
wgpu::ShaderModule vertexModule = utils::CreateShaderModule(device, vertexSource);
wgpu::ShaderModule fragmentModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fragmentModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);

View File

@ -28,7 +28,7 @@ class DepthStencilCopyTests : public DawnTest {
DawnTest::SetUp();
// Draw a square in the bottom left quarter of the screen.
mVertexModule = utils::CreateShaderModuleFromWGSL(device, R"(
mVertexModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -79,7 +79,7 @@ class DepthStencilCopyTests : public DawnTest {
FragDepth = )" + std::to_string(regionDepth) +
";\n}";
desc->cFragment.module = utils::CreateShaderModuleFromWGSL(device, fsSource.c_str());
desc->cFragment.module = utils::CreateShaderModule(device, fsSource.c_str());
wgpu::DepthStencilState* depthStencil = desc->EnableDepthStencil(format);
depthStencil->depthWriteEnabled = true;
desc->cFragment.targetCount = 0;
@ -238,7 +238,7 @@ class DepthStencilCopyTests : public DawnTest {
// Pipeline for a full screen quad.
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -252,7 +252,7 @@ class DepthStencilCopyTests : public DawnTest {
// Sample the input texture and write out depth. |result| will only be set to 1 if we
// pass the depth test.
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var texture0 : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
@ -645,7 +645,7 @@ TEST_P(DepthStencilCopyTests, ToStencilAspect) {
// A quad is drawn in the bottom left.
utils::ComboRenderPipelineDescriptor2 renderPipelineDesc;
renderPipelineDesc.vertex.module = mVertexModule;
renderPipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
wgpu::DepthStencilState* depthStencil =

View File

@ -65,7 +65,7 @@ class DepthStencilSamplingTest : public DawnTest {
wgpu::RenderPipeline CreateSamplingRenderPipeline(std::vector<TestAspect> aspects,
uint32_t componentIndex) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -108,8 +108,7 @@ class DepthStencilSamplingTest : public DawnTest {
shaderSource << "[[stage(fragment)]] fn main() -> void { " << shaderBody.str() << "\n}";
wgpu::ShaderModule fsModule =
utils::CreateShaderModuleFromWGSL(device, shaderSource.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, shaderSource.str().c_str());
pipelineDescriptor.vertex.module = vsModule;
pipelineDescriptor.cFragment.module = fsModule;
pipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
@ -163,8 +162,7 @@ class DepthStencilSamplingTest : public DawnTest {
shaderSource << "[[stage(compute)]] fn main() -> void { " << shaderBody.str() << "\n}";
wgpu::ShaderModule csModule =
utils::CreateShaderModuleFromWGSL(device, shaderSource.str().c_str());
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, shaderSource.str().c_str());
wgpu::ComputePipelineDescriptor pipelineDescriptor;
pipelineDescriptor.computeStage.module = csModule;
@ -174,13 +172,13 @@ class DepthStencilSamplingTest : public DawnTest {
}
wgpu::RenderPipeline CreateComparisonRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var samp : sampler_comparison;
[[group(0), binding(1)]] var tex : texture_depth_2d;
[[block]] struct Uniforms {
@ -212,7 +210,7 @@ class DepthStencilSamplingTest : public DawnTest {
}
wgpu::ComputePipeline CreateComparisonComputePipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var samp : sampler_comparison;
[[group(0), binding(1)]] var tex : texture_depth_2d;
[[block]] struct Uniforms {

View File

@ -52,7 +52,7 @@ class DepthStencilStateTest : public DawnTest {
depthTextureView = depthTexture.CreateView();
vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct UBO {
color : vec3<f32>;
depth : f32;
@ -72,7 +72,7 @@ class DepthStencilStateTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], ubo.depth, 1.0);
})");
fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct UBO {
color : vec3<f32>;
depth : f32;

View File

@ -27,14 +27,14 @@ class DestroyTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -124,7 +124,7 @@ TEST_P(DeviceLostTest, CreateBindGroupLayoutFails) {
// Test that GetBindGroupLayout fails when device is lost
TEST_P(DeviceLostTest, GetBindGroupLayoutFails) {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct UniformBuffer {
pos : vec4<f32>;
};
@ -211,7 +211,7 @@ TEST_P(DeviceLostTest, CreateSamplerFails) {
TEST_P(DeviceLostTest, CreateShaderModuleFails) {
SetCallbackAndLoseForTesting();
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, R"(
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> color : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {

View File

@ -26,14 +26,14 @@ class DrawIndexedIndirectTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -26,14 +26,14 @@ class DrawIndexedTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -26,14 +26,14 @@ class DrawIndirectTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -26,14 +26,14 @@ class DrawTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -93,7 +93,7 @@ class DynamicBufferOffsetTests : public DawnTest {
wgpu::Texture mColorAttachment;
wgpu::RenderPipeline CreateRenderPipeline(bool isInheritedPipeline = false) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
@ -153,7 +153,7 @@ class DynamicBufferOffsetTests : public DawnTest {
}
)";
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fs.str().c_str());
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;
@ -218,7 +218,7 @@ class DynamicBufferOffsetTests : public DawnTest {
}
)";
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, cs.str().c_str());
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, cs.str().c_str());
wgpu::ComputePipelineDescriptor csDesc;
csDesc.computeStage.module = csModule;

View File

@ -23,7 +23,7 @@ class EntryPointTests : public DawnTest {};
TEST_P(EntryPointTests, FragAndVertexSameModule) {
// TODO(crbug.com/dawn/658): Crashes on bots
DAWN_SKIP_TEST_IF(IsOpenGL() || IsOpenGLES());
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn vertex_main() -> void {
@ -70,7 +70,7 @@ TEST_P(EntryPointTests, TwoComputeInModule) {
// https://crbug.com/tint/297
DAWN_SKIP_TEST_IF(IsD3D12() && HasToggleEnabled("use_tint_generator"));
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Data {
data : u32;
};

View File

@ -155,10 +155,8 @@ void FirstIndexOffsetTests::TestImpl(DrawMode mode,
constexpr uint32_t kComponentsPerVertex = 4;
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertex.module =
utils::CreateShaderModuleFromWGSL(device, vertexShader.str().c_str());
pipelineDesc.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, fragmentShader.str().c_str());
pipelineDesc.vertex.module = utils::CreateShaderModule(device, vertexShader.str().c_str());
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, fragmentShader.str().c_str());
pipelineDesc.primitive.topology = wgpu::PrimitiveTopology::PointList;
pipelineDesc.vertex.bufferCount = 1;
pipelineDesc.cBuffers[0].arrayStride = kComponentsPerVertex * sizeof(float);

View File

@ -35,7 +35,7 @@ class GpuMemorySyncTests : public DawnTest {
std::tuple<wgpu::ComputePipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForCompute(
const wgpu::Buffer& buffer) {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct Data {
a : i32;
};
@ -57,13 +57,13 @@ class GpuMemorySyncTests : public DawnTest {
std::tuple<wgpu::RenderPipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForRender(
const wgpu::Buffer& buffer,
wgpu::TextureFormat colorFormat) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Data {
i : i32;
};
@ -252,7 +252,7 @@ TEST_P(GpuMemorySyncTests, SampledAndROStorageTextureInComputePass) {
// Create a pipeline that loads the texture from both the sampled and storage paths.
wgpu::ComputePipelineDescriptor pipelineDesc;
pipelineDesc.computeStage.entryPoint = "main";
pipelineDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.computeStage.module = utils::CreateShaderModule(device, R"(
[[block]] struct Output {
sampledOut: u32;
storageOut: u32;
@ -313,7 +313,7 @@ class StorageToUniformSyncTests : public DawnTest {
}
std::tuple<wgpu::ComputePipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForCompute() {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct Data {
a : f32;
};
@ -334,13 +334,13 @@ class StorageToUniformSyncTests : public DawnTest {
std::tuple<wgpu::RenderPipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForRender(
wgpu::TextureFormat colorFormat) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Contents {
color : f32;
};
@ -512,7 +512,7 @@ class MultipleWriteThenMultipleReadTests : public DawnTest {
// operation in compute pass.
TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
// Create pipeline, bind group, and different buffers for compute pass.
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct VBContents {
pos : array<vec4<f32>, 4>;
};
@ -573,14 +573,14 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
pass0.EndPass();
// Create pipeline, bind group, and reuse buffers in render pass.
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position: vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Buf {
color : f32;
};
@ -640,7 +640,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
DAWN_SKIP_TEST_IF(IsOpenGLES());
// Create pipeline, bind group, and a complex buffer for compute pass.
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct Contents {
[[align(256)]] pos : array<vec4<f32>, 4>;
[[align(256)]] indices : array<vec4<i32>, 2>;
@ -691,14 +691,14 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
pass0.EndPass();
// Create pipeline, bind group, and reuse the buffer in render pass.
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Buf {
color : f32;
};

View File

@ -247,7 +247,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
// The simplest texture sampling pipeline.
wgpu::RenderPipeline pipeline;
{
wgpu::ShaderModule vs = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vs = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[location(0)]] var<out> o_texCoord : vec2<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -273,7 +273,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
o_texCoord = texCoord[VertexIndex];
}
)");
wgpu::ShaderModule fs = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fs = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var sampler0 : sampler;
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;

View File

@ -32,7 +32,7 @@ class IndexFormatTest : public DawnTest {
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format,
wgpu::PrimitiveTopology primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(vertex_index)]] var<in> idx : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -45,7 +45,7 @@ class IndexFormatTest : public DawnTest {
}
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -238,12 +238,12 @@ class MultisampledRenderingTest : public DawnTest {
})";
if (flipTriangle) {
pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, vsFlipped);
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, vsFlipped);
} else {
pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, vs);
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, vs);
}
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, fs);
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, fs);
if (hasDepthStencilAttachment) {
wgpu::DepthStencilState* depthStencil =

View File

@ -53,14 +53,14 @@ class MultisampledSamplingTest : public DawnTest {
{
utils::ComboRenderPipelineDescriptor2 desc;
desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.vertex.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec2<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(pos, 0.0, 1.0);
})");
desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : f32;
[[builtin(frag_depth)]] var<out> FragDepth : f32;
[[stage(fragment)]] fn main() -> void {
@ -88,7 +88,7 @@ class MultisampledSamplingTest : public DawnTest {
{
wgpu::ComputePipelineDescriptor desc = {};
desc.computeStage.entryPoint = "main";
desc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.computeStage.module = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var texture0 : texture_multisampled_2d<f32>;
[[group(0), binding(1)]] var texture1 : texture_multisampled_2d<f32>;

View File

@ -103,17 +103,17 @@ TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
// Test that ShaderModules are correctly deduplicated.
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})");
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 0.0, 0.0, 0.0);
@ -125,17 +125,17 @@ TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
// Test that ComputePipeline are correctly deduplicated wrt. their ShaderModule
TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
var<workgroup> i : u32;
[[stage(compute)]] fn main() -> void {
i = 0u;
})");
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
var<workgroup> i : u32;
[[stage(compute)]] fn main() -> void {
i = 0u;
})");
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
[[stage(compute)]] fn main() -> void {
})");
@ -177,7 +177,7 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
wgpu::ComputePipelineDescriptor desc;
desc.computeStage.entryPoint = "main";
desc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.computeStage.module = utils::CreateShaderModule(device, R"(
var<workgroup> i : u32;
[[stage(compute)]] fn main() -> void {
i = 0u;
@ -211,12 +211,12 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
EXPECT_EQ(pl.Get() == samePl.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor2 desc;
desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
})");
desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.cFragment.module = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
@ -235,17 +235,17 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
// Test that RenderPipelines are correctly deduplicated wrt. their vertex module
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
})");
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
})");
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(1.0, 1.0, 1.0, 1.0);
@ -255,7 +255,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor2 desc;
desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.cFragment.module = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
@ -274,13 +274,13 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
// Test that RenderPipelines are correctly deduplicated wrt. their fragment module
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
wgpu::ShaderModule sameModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
wgpu::ShaderModule otherModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 0.0, 0.0, 0.0);
@ -290,7 +290,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
EXPECT_EQ(module.Get() == sameModule.Get(), !UsesWire());
utils::ComboRenderPipelineDescriptor2 desc;
desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);

View File

@ -124,7 +124,7 @@ TEST_P(OpArrayLengthTest, Compute) {
wgpu::ComputePipelineDescriptor pipelineDesc;
pipelineDesc.layout = pl;
pipelineDesc.computeStage.entryPoint = "main";
pipelineDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, (R"(
pipelineDesc.computeStage.module = utils::CreateShaderModule(device, (R"(
[[block]] struct ResultBuffer {
data : [[stride(4)]] array<u32, 3>;
};
@ -135,7 +135,7 @@ TEST_P(OpArrayLengthTest, Compute) {
result.data[1] = arrayLength(buffer2.data);
result.data[2] = arrayLength(buffer3.data);
})")
.c_str());
.c_str());
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
// Run a single instance of the compute shader
@ -164,13 +164,13 @@ TEST_P(OpArrayLengthTest, Fragment) {
// Create the pipeline that computes the length of the buffers and writes it to the only render
// pass pixel.
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, (mShaderInterface + R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, (mShaderInterface + R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor.r = f32(arrayLength(buffer1.data)) / 255.0;
@ -178,7 +178,7 @@ TEST_P(OpArrayLengthTest, Fragment) {
fragColor.b = f32(arrayLength(buffer3.data)) / 255.0;
fragColor.a = 0.0;
})")
.c_str());
.c_str());
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.vertex.module = vsModule;
@ -220,7 +220,7 @@ TEST_P(OpArrayLengthTest, Vertex) {
// Create the pipeline that computes the length of the buffers and writes it to the only render
// pass pixel.
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, (mShaderInterface + R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, (mShaderInterface + R"(
[[location(0)]] var<out> pointColor : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
@ -231,9 +231,9 @@ TEST_P(OpArrayLengthTest, Vertex) {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})")
.c_str());
.c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[location(0)]] var<in> pointColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {

View File

@ -153,14 +153,14 @@ class PrimitiveTopologyTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -78,7 +78,7 @@ class OcclusionQueryTests : public QueryTests {
void SetUp() override {
DawnTest::SetUp();
vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
@ -89,7 +89,7 @@ class OcclusionQueryTests : public QueryTests {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -31,14 +31,14 @@ class RenderBundleTest : public DawnTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec4<f32>;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[block]] struct Ubo {
color : vec4<f32>;

View File

@ -26,8 +26,8 @@ class DrawQuad {
DrawQuad() {
}
DrawQuad(wgpu::Device device, const char* vsSource, const char* fsSource) : device(device) {
vsModule = utils::CreateShaderModuleFromWGSL(device, vsSource);
fsModule = utils::CreateShaderModuleFromWGSL(device, fsSource);
vsModule = utils::CreateShaderModule(device, vsSource);
fsModule = utils::CreateShaderModule(device, fsSource);
pipelineLayout = utils::MakeBasicPipelineLayout(device, nullptr);
}

View File

@ -26,7 +26,7 @@ class RenderPassTest : public DawnTest {
DawnTest::SetUp();
// Shaders to draw a bottom-left triangle in blue.
mVSModule = utils::CreateShaderModuleFromWGSL(device, R"(
mVSModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -39,7 +39,7 @@ class RenderPassTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 0.0, 1.0, 1.0);
@ -140,7 +140,7 @@ TEST_P(RenderPassTest, NoCorrespondingFragmentShaderOutputs) {
{
// Next we use a pipeline whose fragment shader has no outputs.
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor2 descriptor;

View File

@ -37,7 +37,7 @@ class SamplerFilterAnisotropicTest : public DawnTest {
DawnTest::SetUp();
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Uniforms {
matrix : mat4x4<f32>;
};
@ -55,7 +55,7 @@ class SamplerFilterAnisotropicTest : public DawnTest {
Position = uniforms.matrix * position;
}
)");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var sampler0 : sampler;
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;

View File

@ -54,7 +54,7 @@ class SamplerTest : public DawnTest {
DawnTest::SetUp();
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
auto vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
auto vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -69,7 +69,7 @@ class SamplerTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
}
)");
auto fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
auto fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var sampler0 : sampler;
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;

View File

@ -20,7 +20,7 @@
class ScissorTest : public DawnTest {
protected:
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -36,7 +36,7 @@ class ScissorTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], 0.5, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -62,7 +62,7 @@ TEST_P(ShaderTests, ComputeLog2) {
})";
wgpu::ComputePipelineDescriptor csDesc;
csDesc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, shader.c_str());
csDesc.computeStage.module = utils::CreateShaderModule(device, shader.c_str());
csDesc.computeStage.entryPoint = "main";
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&csDesc);

View File

@ -461,7 +461,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
}
wgpu::ComputePipeline CreateComputePipeline(const char* computeShader) {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, computeShader);
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, computeShader);
wgpu::ComputePipelineDescriptor computeDescriptor;
computeDescriptor.layout = nullptr;
computeDescriptor.computeStage.module = csModule;
@ -471,8 +471,8 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
wgpu::RenderPipeline CreateRenderPipeline(const char* vertexShader,
const char* fragmentShader) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vertexShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragmentShader);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader);
utils::ComboRenderPipelineDescriptor2 desc;
desc.vertex.module = vsModule;
@ -982,7 +982,7 @@ TEST_P(StorageTextureTests, ReadonlyAndWriteonlyStorageTexturePingPong) {
wgpu::Texture storageTexture2 = CreateTexture(
kTextureFormat, wgpu::TextureUsage::Storage | wgpu::TextureUsage::CopySrc, 1u, 1u);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var Src : [[access(read)]] texture_storage_2d<r32uint>;
[[group(0), binding(1)]] var Dst : [[access(write)]] texture_storage_2d<r32uint>;
[[stage(compute)]] fn main() -> void {
@ -1056,7 +1056,7 @@ TEST_P(StorageTextureTests, SampledAndWriteonlyStorageTexturePingPong) {
1u);
wgpu::Texture storageTexture2 = CreateTexture(
kTextureFormat, wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Storage, 1u, 1u);
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var Src : texture_2d<u32>;
[[group(0), binding(1)]] var Dst : [[access(write)]] texture_storage_2d<r32uint>;
[[stage(compute)]] fn main() -> void {

View File

@ -221,12 +221,12 @@ TEST_P(SwapChainValidationTests, ViewDestroyedAfterPresent) {
// Check that returned view is of the current format / usage / dimension / size / sample count
TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
pipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -146,7 +146,7 @@ class TextureFormatTest : public DawnTest {
FormatTestInfo renderFormatInfo) {
utils::ComboRenderPipelineDescriptor2 desc;
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -170,8 +170,7 @@ class TextureFormatTest : public DawnTest {
fsSource << " fragColor = textureLoad(myTexture, vec2<i32>(FragCoord.xy), 0);\n";
fsSource << "}";
wgpu::ShaderModule fsModule =
utils::CreateShaderModuleFromWGSL(device, fsSource.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fsSource.str().c_str());
desc.vertex.module = vsModule;
desc.cFragment.module = fsModule;

View File

@ -49,7 +49,7 @@ class TextureSubresourceTest : public DawnTest {
}
void DrawTriangle(const wgpu::TextureView& view) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -62,7 +62,7 @@ class TextureSubresourceTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
@ -89,7 +89,7 @@ class TextureSubresourceTest : public DawnTest {
}
void SampleAndDraw(const wgpu::TextureView& samplerView, const wgpu::TextureView& renderView) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -105,7 +105,7 @@ class TextureSubresourceTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var samp : sampler;
[[group(0), binding(1)]] var tex : texture_2d<f32>;

View File

@ -60,7 +60,7 @@ namespace {
}
wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) {
return utils::CreateShaderModuleFromWGSL(device, R"(
return utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
[[location(0)]] var<out> TexCoord : vec2<f32>;
@ -163,7 +163,7 @@ class TextureViewSamplingTest : public DawnTest {
}
void Verify(const wgpu::TextureView& textureView, const char* fragmentShader, int expected) {
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragmentShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader);
utils::ComboRenderPipelineDescriptor2 textureDescriptor;
textureDescriptor.vertex.module = mVSModule;
@ -503,7 +503,7 @@ class TextureViewRenderingTest : public DawnTest {
}
)";
wgpu::ShaderModule oneColorFsModule =
utils::CreateShaderModuleFromWGSL(device, oneColorFragmentShader);
utils::CreateShaderModule(device, oneColorFragmentShader);
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;

View File

@ -74,7 +74,7 @@ class TextureZeroInitTest : public DawnTest {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
}
)";
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, fs);
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, fs);
wgpu::DepthStencilState* depthStencil = pipelineDescriptor.EnableDepthStencil();
depthStencil->depthCompare = wgpu::CompareFunction::Equal;
depthStencil->stencilFront.compare = wgpu::CompareFunction::Equal;
@ -99,10 +99,10 @@ class TextureZeroInitTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], )" +
std::to_string(depth) + R"(, 1.0);
})";
return utils::CreateShaderModuleFromWGSL(device, source.c_str());
return utils::CreateShaderModule(device, source.c_str());
}
wgpu::ShaderModule CreateSampledTextureFragmentShaderForTest() {
return utils::CreateShaderModuleFromWGSL(device, R"(
return utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var texture0 : texture_2d<f32>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>;
@ -982,7 +982,7 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
result.value = textureLoad(tex, vec2<i32>(0,0), 0);
}
)";
computePipelineDescriptor.computeStage.module = utils::CreateShaderModuleFromWGSL(device, cs);
computePipelineDescriptor.computeStage.module = utils::CreateShaderModule(device, cs);
computePipelineDescriptor.computeStage.entryPoint = "main";
wgpu::ComputePipeline computePipeline =
device.CreateComputePipeline(&computePipelineDescriptor);

View File

@ -32,7 +32,7 @@ class VertexBufferRobustnessTest : public DawnTest {
// viewport.
wgpu::ShaderModule CreateVertexModule(const std::string& attributes,
const std::string& successExpression) {
return utils::CreateShaderModuleFromWGSL(device, (attributes + R"(
return utils::CreateShaderModule(device, (attributes + R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
@ -46,7 +46,7 @@ class VertexBufferRobustnessTest : public DawnTest {
return;
}
)")
.c_str());
.c_str());
}
// Runs the test, a true |expectation| meaning success
@ -57,7 +57,7 @@ class VertexBufferRobustnessTest : public DawnTest {
uint64_t bufferOffset,
bool expectation) {
wgpu::ShaderModule vsModule = CreateVertexModule(attributes, successExpression);
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> outColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {

View File

@ -339,8 +339,8 @@ class VertexFormatTest : public DawnTest {
}
})";
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> color : vec4<f32>;
[[location(0)]] var<out> FragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {

View File

@ -123,8 +123,8 @@ class VertexStateTest : public DawnTest {
vs << " }\n";
vs << "}\n";
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> color : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
@ -569,7 +569,7 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
utils::CreateBufferFromData(device, &data, sizeof(data), wgpu::BufferUsage::Vertex);
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> attr0 : vec4<f32>;
[[location(1)]] var<in> attr1 : vec2<u32>;
[[location(2)]] var<in> attr2 : vec4<f32>;
@ -595,7 +595,7 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
}
})");
pipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> color : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
@ -641,13 +641,13 @@ class OptionalVertexStateTest : public DawnTest {};
TEST_P(OptionalVertexStateTest, Basic) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 3, 3);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -23,14 +23,14 @@ class ViewportOrientationTests : public DawnTest {};
TEST_P(ViewportOrientationTests, OriginAt0x0) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(-0.5, 0.5, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -22,7 +22,7 @@ class ViewportTest : public DawnTest {
void SetUp() override {
DawnTest::SetUp();
mQuadVS = utils::CreateShaderModuleFromWGSL(device, R"(
mQuadVS = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -38,7 +38,7 @@ class ViewportTest : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
mQuadFS = utils::CreateShaderModuleFromWGSL(device, R"(
mQuadFS = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 1.0, 1.0, 1.0);
@ -95,7 +95,7 @@ class ViewportTest : public DawnTest {
void TestViewportDepth(float minDepth, float maxDepth, bool doViewportCall = true) {
// Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0.
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;

View File

@ -366,8 +366,8 @@ void DrawCallPerf::SetUp() {
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&pipelineLayoutDesc);
// Create the shaders for the first pipeline.
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, kVertexShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, kFragmentShaderA);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, kVertexShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, kFragmentShaderA);
// Create the first pipeline.
renderPipelineDesc.layout = pipelineLayout;
@ -395,7 +395,7 @@ void DrawCallPerf::SetUp() {
// Create the fragment shader module. This shader matches the pipeline layout described
// above.
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, kFragmentShaderB);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, kFragmentShaderB);
// Create the pipeline.
renderPipelineDesc.layout = pipelineLayout;

View File

@ -70,13 +70,13 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams<SubresourceTrackin
mUploadTexture = device.CreateTexture(&uploadTexDesc);
utils::ComboRenderPipelineDescriptor2 pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(1.0, 0.0, 0.0, 1.0);
}
)");
pipelineDesc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>;
[[group(0), binding(0)]] var materials : texture_2d<f32>;
[[stage(fragment)]] fn main() -> void {

View File

@ -1083,11 +1083,11 @@ class SetBindGroupValidationTest : public ValidationTest {
wgpu::BindGroupLayout mBindGroupLayout;
wgpu::RenderPipeline CreateRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
value : vec2<f32>;
};
@ -1110,7 +1110,7 @@ class SetBindGroupValidationTest : public ValidationTest {
}
wgpu::ComputePipeline CreateComputePipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
value : vec2<f32>;
};
@ -1486,7 +1486,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
mVsModule = utils::CreateShaderModuleFromWGSL(device, R"(
mVsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
}
@ -1557,7 +1557,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
ss << "[[stage(fragment)]] fn main() -> void {}";
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, ss.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, ss.str().c_str());
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = mVsModule;
@ -1688,11 +1688,11 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
wgpu::RenderPipeline CreateFSRenderPipeline(
const char* fsShader,
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fsShader);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fsShader);
wgpu::PipelineLayoutDescriptor descriptor;
descriptor.bindGroupLayoutCount = bindGroupLayout.size();
@ -1722,7 +1722,7 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
wgpu::ComputePipeline CreateComputePipeline(
const char* shader,
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, shader);
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, shader);
wgpu::PipelineLayoutDescriptor descriptor;
descriptor.bindGroupLayoutCount = bindGroupLayout.size();
@ -2052,11 +2052,11 @@ class ComparisonSamplerBindingTest : public ValidationTest {
protected:
wgpu::RenderPipeline CreateFragmentPipeline(wgpu::BindGroupLayout* bindGroupLayout,
const char* fragmentSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragmentSource);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentSource);
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;

View File

@ -22,7 +22,7 @@ class ComputeIndirectValidationTest : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
wgpu::ShaderModule computeModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
[[stage(compute), workgroup_size(1)]] fn main() -> void {
})");

View File

@ -23,13 +23,13 @@ class DrawIndirectValidationTest : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 0.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 0.0, 0.0, 0.0);

View File

@ -20,11 +20,11 @@
class GetBindGroupLayoutTests : public ValidationTest {
protected:
wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, shader);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, shader);
utils::ComboRenderPipelineDescriptor2 descriptor;
descriptor.layout = nullptr;
@ -43,7 +43,7 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
// Native.
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : vec4<f32>;
};
@ -53,7 +53,7 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S2 {
pos : vec4<f32>;
};
@ -139,7 +139,7 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
// Native.
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : vec4<f32>;
};
@ -442,7 +442,7 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
// Test it is valid to have duplicate bindings in the shaders.
TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : vec4<f32>;
};
@ -452,7 +452,7 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : vec4<f32>;
};
@ -476,7 +476,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
// Native.
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule vsModule4 = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule4 = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : f32;
};
@ -485,7 +485,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule vsModule64 = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule64 = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : mat4x4<f32>;
};
@ -494,7 +494,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule4 = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule4 = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : f32;
};
@ -503,7 +503,7 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
[[stage(fragment)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule64 = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule64 = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : mat4x4<f32>;
};
@ -562,20 +562,20 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
// Native.
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var mySampler: sampler;
[[stage(fragment)]] fn main() -> void {
})");
@ -625,7 +625,7 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
// Test it is invalid to have conflicting binding types in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : vec4<f32>;
};
@ -634,7 +634,7 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : vec4<f32>;
};
@ -653,13 +653,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
// Test it is invalid to have conflicting binding texture multisampling in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_multisampled_2d<f32>;
[[stage(fragment)]] fn main() -> void {
@ -675,13 +675,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
// Test it is invalid to have conflicting binding texture dimension in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_3d<f32>;
[[stage(fragment)]] fn main() -> void {
@ -697,13 +697,13 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
// Test it is invalid to have conflicting binding texture component type in the shaders.
TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var myTexture : texture_2d<i32>;
[[stage(fragment)]] fn main() -> void {
@ -784,7 +784,7 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
wgpu::PipelineLayout pipelineLayout = device.CreatePipelineLayout(&pipelineLayoutDesc);
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[block]] struct S {
pos : vec4<f32>;
};
@ -793,7 +793,7 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
@ -823,7 +823,7 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
// Test that fragment output validation is for the correct entryPoint
// TODO(dawn:216): Re-enable when we correctly reflect which bindings are used for an entryPoint.
TEST_F(GetBindGroupLayoutTests, DISABLED_FromCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Data {
data : f32;
};

View File

@ -22,13 +22,13 @@ class IndexBufferValidationTest : public ValidationTest {
protected:
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format,
wgpu::PrimitiveTopology primitiveTopology) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -142,7 +142,7 @@ class MinBufferSizeTestsBase : public ValidationTest {
// Creates compute pipeline given a layout and shader
wgpu::ComputePipeline CreateComputePipeline(const std::vector<wgpu::BindGroupLayout>& layouts,
const std::string& shader) {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, shader.c_str());
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, shader.c_str());
wgpu::ComputePipelineDescriptor csDesc;
csDesc.layout = nullptr;
@ -167,10 +167,9 @@ class MinBufferSizeTestsBase : public ValidationTest {
wgpu::RenderPipeline CreateRenderPipeline(const std::vector<wgpu::BindGroupLayout>& layouts,
const std::string& vertexShader,
const std::string& fragShader) {
wgpu::ShaderModule vsModule =
utils::CreateShaderModuleFromWGSL(device, vertexShader.c_str());
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, fragShader.c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragShader.c_str());
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = vsModule;

View File

@ -27,7 +27,7 @@ namespace {
void SetUp() override {
ValidationTest::SetUp();
vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
vsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<in> pos : vec2<f32>;
[[block]] struct S {
@ -38,7 +38,7 @@ namespace {
[[stage(vertex)]] fn main() -> void {
})");
fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct Uniforms {
color : vec4<f32>;
};

View File

@ -26,13 +26,13 @@ class RenderPipelineValidationTest : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
vsModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
@ -195,8 +195,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
<< kScalarTypes[i] << R"(>;
[[stage(fragment)]] fn main() -> void {
})";
descriptor.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
if (i == j) {
device.CreateRenderPipeline2(&descriptor);
@ -414,8 +413,7 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
[[stage(fragment)]] fn main() -> void {
})";
descriptor.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, kTextureComponentTypes[j]}});
@ -462,8 +460,7 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
<< kTextureKeywords[i] << R"(<f32>;
[[stage(fragment)]] fn main() -> void {
})";
descriptor.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, stream.str().c_str());
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
wgpu::BindGroupLayout bgl = utils::MakeBindGroupLayout(
device, {{0, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float,
@ -482,7 +479,7 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
// Test that declaring a storage buffer in the vertex shader without setting pipeline layout won't
// cause crash.
TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
wgpu::ShaderModule vsModuleWithStorageBuffer = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModuleWithStorageBuffer = utils::CreateShaderModule(device, R"(
[[block]] struct Dst {
data : array<u32, 100>;
};
@ -555,7 +552,7 @@ TEST_F(RenderPipelineValidationTest, StripIndexFormatRequired) {
// Test that the entryPoint names must be present for the correct stage in the shader module.
TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> position : vec4<f32>;
[[stage(vertex)]] fn vertex_main() -> void {
position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
@ -605,7 +602,7 @@ TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
// Test that vertex attrib validation is for the correct entryPoint
TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> position : vec4<f32>;
[[location(0)]] var<in> attrib0 : vec4<f32>;
[[location(1)]] var<in> attrib1 : vec4<f32>;
@ -651,7 +648,7 @@ TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
// Test that fragment output validation is for the correct entryPoint
TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> colorFloat : vec4<f32>;
[[location(0)]] var<out> colorUint : vec4<u32>;
@ -691,7 +688,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
// Test that fragment output validation is for the correct entryPoint
// TODO(dawn:216): Re-enable when we correctly reflect which bindings are used for an entryPoint.
TEST_F(RenderPipelineValidationTest, DISABLED_BindingsFromCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
[[block]] struct Uniforms {
data : vec4<f32>;
};

View File

@ -46,11 +46,11 @@ namespace {
// in the caller, so it is always correct for binding validation between bind groups and
// pipeline. But those bind groups in caller can be used for validation for other purposes.
wgpu::RenderPipeline CreateNoOpRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[stage(fragment)]] fn main() -> void {
})");
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
@ -61,7 +61,7 @@ namespace {
}
wgpu::ComputePipeline CreateNoOpComputePipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[stage(compute)]] fn main() -> void {
})");
wgpu::ComputePipelineDescriptor pipelineDescriptor;
@ -771,11 +771,11 @@ namespace {
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
// Create a passthrough render pipeline with a readonly buffer
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[block]] struct RBuffer {
value : f32;
};
@ -815,7 +815,7 @@ namespace {
wgpu::BindGroup bg1 = utils::MakeBindGroup(device, bgl1, {{0, buffer}});
// Create a passthrough compute pipeline with a readonly buffer
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[block]] struct RBuffer {
value : f32;
};
@ -1549,11 +1549,11 @@ namespace {
// Test render pass
{
// Create a passthrough render pipeline with a readonly storage texture
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main() -> void {
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void {
})");
@ -1579,7 +1579,7 @@ namespace {
// Test compute pass
{
// Create a passthrough compute pipeline with a readonly storage texture
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var tex : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[stage(compute)]] fn main() -> void {
})");

View File

@ -62,7 +62,7 @@ TEST_F(ShaderModuleValidationTest, FragmentOutputLocationExceedsMaxColorAttachme
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
})";
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, stream.str().c_str()));
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, stream.str().c_str()));
}
// Test that it is invalid to create a shader module with no chained descriptor. (It must be

View File

@ -23,12 +23,12 @@ class StorageTextureValidationTests : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
mDefaultVSModule = utils::CreateShaderModuleFromWGSL(device, R"(
mDefaultVSModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
mDefaultFSModule = utils::CreateShaderModuleFromWGSL(device, R"(
mDefaultFSModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);
@ -120,7 +120,7 @@ class StorageTextureValidationTests : public ValidationTest {
TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Readonly storage texture can be declared in a vertex shader.
{
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
[[builtin(position)]] var<out> Position : vec4<f32>;
@ -137,7 +137,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Read-only storage textures can be declared in a fragment shader.
{
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(frag_coord)]] var<in> FragCoord : vec4<f32>;
[[location(0)]] var<out> fragColor : vec4<f32>;
@ -154,7 +154,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Write-only storage textures cannot be declared in a vertex shader.
if ((false) /* TODO(https://crbug.com/tint/449) */) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[builtin(vertex_index)]] var<in> vertex_index : u32;
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[stage(vertex)]] fn main() -> void {
@ -170,7 +170,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
// Write-only storage textures can be declared in a fragment shader.
{
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[builtin(frag_coord)]] var<in> frag_coord : vec4<f32>;
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void {
@ -190,7 +190,7 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Read-only storage textures can be declared in a compute shader.
{
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read)]] texture_storage_2d<rgba8unorm>;
[[builtin(local_invocation_id)]] var<in> LocalInvocationID : vec3<u32>;
@ -213,7 +213,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
// Write-only storage textures can be declared in a compute shader.
{
wgpu::ShaderModule csModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(write)]] texture_storage_2d<rgba8unorm>;
[[builtin(local_invocation_id)]] var<in> LocalInvocationID : vec3<u32>;
@ -234,7 +234,7 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a vertex shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, R"(
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[stage(vertex)]] fn main() -> void {
})"));
@ -242,7 +242,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a fragment shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, R"(
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[stage(fragment)]] fn main() -> void {
})"));
@ -250,7 +250,7 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
// Read-write storage textures cannot be declared in a compute shader by default.
{
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, R"(
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
[[group(0), binding(0)]] var image0 : [[access(read_write)]] texture_storage_2d<rgba8unorm>;
[[stage(compute)]] fn main() -> void {
})"));
@ -317,10 +317,9 @@ TEST_F(StorageTextureValidationTests, StorageTextureFormatInShaders) {
std::string computeShader =
CreateComputeShaderWithStorageTexture(storageTextureBindingType, format);
if (utils::TextureFormatSupportsStorageTexture(format)) {
utils::CreateShaderModuleFromWGSL(device, computeShader.c_str());
utils::CreateShaderModule(device, computeShader.c_str());
} else {
ASSERT_DEVICE_ERROR(
utils::CreateShaderModuleFromWGSL(device, computeShader.c_str()));
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, computeShader.c_str()));
}
}
}
@ -343,7 +342,7 @@ TEST_F(StorageTextureValidationTests, UnsupportedWGSLStorageTextureFormat) {
for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
for (wgpu::TextureFormat format : kUnsupportedTextureFormats) {
std::string computeShader = CreateComputeShaderWithStorageTexture(bindingType, format);
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, computeShader.c_str()));
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, computeShader.c_str()));
}
}
}
@ -360,7 +359,7 @@ TEST_F(StorageTextureValidationTests, UnsupportedTextureViewDimensionInShader) {
for (wgpu::TextureViewDimension dimension : kUnsupportedTextureViewDimensions) {
std::string computeShader =
CreateComputeShaderWithStorageTexture(bindingType, kFormat, dimension);
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, computeShader.c_str()));
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, computeShader.c_str()));
}
}
}
@ -402,8 +401,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutEntryTypeMatchesShaderDecla
// Create the compute shader with the given binding type.
std::string computeShader =
CreateComputeShaderWithStorageTexture(bindingTypeInShader, kStorageTextureFormat);
wgpu::ShaderModule csModule =
utils::CreateShaderModuleFromWGSL(device, computeShader.c_str());
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, computeShader.c_str());
// Set common fields of compute pipeline descriptor.
wgpu::ComputePipelineDescriptor defaultComputePipelineDescriptor;
@ -479,8 +477,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutStorageTextureFormatMatches
// format.
std::string computeShader =
CreateComputeShaderWithStorageTexture(bindingType, storageTextureFormatInShader);
wgpu::ShaderModule csModule =
utils::CreateShaderModuleFromWGSL(device, computeShader.c_str());
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, computeShader.c_str());
// Set common fields of compute pipeline descriptor.
wgpu::ComputePipelineDescriptor defaultComputePipelineDescriptor;
@ -536,8 +533,7 @@ TEST_F(StorageTextureValidationTests, BindGroupLayoutViewDimensionMatchesShaderD
// Create the compute shader with the given texture view dimension.
std::string computeShader = CreateComputeShaderWithStorageTexture(
bindingType, kStorageTextureFormat, dimensionInShader);
wgpu::ShaderModule csModule =
utils::CreateShaderModuleFromWGSL(device, computeShader.c_str());
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, computeShader.c_str());
// Set common fields of compute pipeline descriptor.
wgpu::ComputePipelineDescriptor defaultComputePipelineDescriptor;
@ -768,7 +764,7 @@ TEST_F(StorageTextureValidationTests, MultisampledStorageTexture) {
for (wgpu::StorageTextureAccess bindingType : kSupportedStorageTextureAccess) {
std::string computeShader =
CreateComputeShaderWithStorageTexture(bindingType, "", "image2DMS");
ASSERT_DEVICE_ERROR(utils::CreateShaderModuleFromWGSL(device, computeShader.c_str()));
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, computeShader.c_str()));
}
}

View File

@ -50,9 +50,9 @@ TEST_F(UnsafeAPIValidationTest, DrawIndexedIndirectDisallowed) {
utils::ComboRenderPipelineDescriptor2 desc;
desc.vertex.module =
utils::CreateShaderModuleFromWGSL(device, "[[stage(vertex)]] fn main() -> void {}");
utils::CreateShaderModule(device, "[[stage(vertex)]] fn main() -> void {}");
desc.cFragment.module =
utils::CreateShaderModuleFromWGSL(device, "[[stage(fragment)]] fn main() -> void {}");
utils::CreateShaderModule(device, "[[stage(fragment)]] fn main() -> void {}");
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline2(&desc);
// Control cases: DrawIndirect and DrawIndexed are allowed inside a render pass.
@ -118,7 +118,7 @@ TEST_F(UnsafeAPIValidationTest, DispatchIndirectDisallowed) {
wgpu::ComputePipelineDescriptor pipelineDesc;
pipelineDesc.computeStage.entryPoint = "main";
pipelineDesc.computeStage.module =
utils::CreateShaderModuleFromWGSL(device, "[[stage(compute)]] fn main() -> void {}");
utils::CreateShaderModule(device, "[[stage(compute)]] fn main() -> void {}");
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
// Control case: dispatch is allowed.
@ -216,7 +216,7 @@ TEST_F(UnsafeAPIValidationTest, OcclusionQueryDisallowed) {
// Check that CreateComputePipelineAsync is disallowed as part of unsafe APIs
TEST_F(UnsafeAPIValidationTest, CreateComputePipelineAsyncDisallowed) {
wgpu::ComputePipelineDescriptor desc;
desc.computeStage.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.computeStage.module = utils::CreateShaderModule(device, R"(
[[stage(compute)]] fn main() -> void {
})");
desc.computeStage.entryPoint = "main";
@ -236,12 +236,12 @@ TEST_F(UnsafeAPIValidationTest, CreateComputePipelineAsyncDisallowed) {
// Check that CreateRenderPipelineAsync is disallowed as part of unsafe APIs
TEST_F(UnsafeAPIValidationTest, CreateRenderPipelineAsyncDisallowed) {
utils::ComboRenderPipelineDescriptor2 desc;
desc.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
desc.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
desc.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> o_color : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
o_color = vec4<f32>(0.0, 1.0, 0.0, 1.0);

View File

@ -25,7 +25,7 @@ class VertexBufferValidationTest : public ValidationTest {
void SetUp() override {
ValidationTest::SetUp();
fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(0.0, 1.0, 0.0, 1.0);
@ -59,7 +59,7 @@ class VertexBufferValidationTest : public ValidationTest {
vs << "}\n";
return utils::CreateShaderModuleFromWGSL(device, vs.str().c_str());
return utils::CreateShaderModule(device, vs.str().c_str());
}
wgpu::RenderPipeline MakeRenderPipeline(const wgpu::ShaderModule& vsModule,

View File

@ -22,8 +22,8 @@ class VertexStateTest : public ValidationTest {
void CreatePipeline(bool success,
const utils::ComboVertexStateDescriptor& state,
const char* vertexSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, vertexSource);
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexSource);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> fragColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
fragColor = vec4<f32>(1.0, 0.0, 0.0, 1.0);

View File

@ -39,7 +39,7 @@ class D3D12DescriptorHeapTests : public DawnTest {
DAWN_SKIP_TEST_IF(UsesWire());
mD3DDevice = reinterpret_cast<Device*>(device.Get());
mSimpleVSModule = utils::CreateShaderModuleFromWGSL(device, R"(
mSimpleVSModule = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
@ -52,7 +52,7 @@ class D3D12DescriptorHeapTests : public DawnTest {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
mSimpleFSModule = utils::CreateShaderModuleFromWGSL(device, R"(
mSimpleFSModule = utils::CreateShaderModule(device, R"(
[[block]] struct U {
color : vec4<f32>;
};
@ -176,13 +176,13 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) {
// Fill in a sampler heap with "sampler only" bindgroups (1x sampler per group) by creating a
// sampler bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps WILL NOT switch over
// because the sampler heap allocations are de-duplicated.
renderPipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
})");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[location(0)]] var<out> FragColor : vec4<f32>;
[[group(0), binding(0)]] var sampler0 : sampler;
[[stage(fragment)]] fn main() -> void {
@ -445,7 +445,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = mSimpleVSModule;
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[block]] struct U {
heapSize : f32;
};
@ -778,7 +778,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
{
utils::ComboRenderPipelineDescriptor2 pipelineDescriptor;
pipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[block]] struct U {
transform : mat2x2<f32>;
};
@ -794,7 +794,7 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
);
Position = vec4<f32>(buffer0.transform * (pos[VertexIndex]), 0.0, 1.0);
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[block]] struct U {
color : vec4<f32>;
};

View File

@ -334,7 +334,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
// Fill in a view heap with "view only" bindgroups (1x view per group) by creating a
// view bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps must switch over.
renderPipelineDescriptor.vertex.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[builtin(vertex_index)]] var<in> VertexIndex : u32;
@ -347,7 +347,7 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
Position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
})");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModuleFromWGSL(device, R"(
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[block]] struct U {
color : vec4<f32>;
};

View File

@ -28,39 +28,6 @@ namespace utils {
namespace {
shaderc_shader_kind ShadercShaderKind(SingleShaderStage stage) {
switch (stage) {
case SingleShaderStage::Vertex:
return shaderc_glsl_vertex_shader;
case SingleShaderStage::Fragment:
return shaderc_glsl_fragment_shader;
case SingleShaderStage::Compute:
return shaderc_glsl_compute_shader;
default:
UNREACHABLE();
}
}
wgpu::ShaderModule CreateShaderModuleFromResult(
const wgpu::Device& device,
const shaderc::SpvCompilationResult& result) {
// result.cend and result.cbegin return pointers to uint32_t.
const uint32_t* resultBegin = result.cbegin();
const uint32_t* resultEnd = result.cend();
// So this size is in units of sizeof(uint32_t).
ptrdiff_t resultSize = resultEnd - resultBegin;
// SetSource takes data as uint32_t*.
wgpu::ShaderModuleSPIRVDescriptor spirvDesc;
spirvDesc.codeSize = static_cast<uint32_t>(resultSize);
spirvDesc.code = result.cbegin();
wgpu::ShaderModuleDescriptor descriptor;
descriptor.nextInChain = &spirvDesc;
return device.CreateShaderModule(&descriptor);
}
class CompilerSingleton {
public:
static shaderc::Compiler* Get() {
@ -87,49 +54,6 @@ namespace utils {
} // anonymous namespace
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device,
SingleShaderStage stage,
const char* source) {
shaderc_shader_kind kind = ShadercShaderKind(stage);
shaderc::Compiler* compiler = CompilerSingleton::Get();
auto result = compiler->CompileGlslToSpv(source, strlen(source), kind, "myshader?");
if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
dawn::ErrorLog() << result.GetErrorMessage();
return {};
}
#ifdef DUMP_SPIRV_ASSEMBLY
{
shaderc::CompileOptions options;
auto resultAsm = compiler->CompileGlslToSpvAssembly(source, strlen(source), kind,
"myshader?", options);
size_t sizeAsm = (resultAsm.cend() - resultAsm.cbegin());
char* buffer = reinterpret_cast<char*>(malloc(sizeAsm + 1));
memcpy(buffer, resultAsm.cbegin(), sizeAsm);
buffer[sizeAsm] = '\0';
printf("SPIRV ASSEMBLY DUMP START\n%s\nSPIRV ASSEMBLY DUMP END\n", buffer);
free(buffer);
}
#endif
#ifdef DUMP_SPIRV_JS_ARRAY
printf("SPIRV JS ARRAY DUMP START\n");
for (size_t i = 0; i < size; i++) {
printf("%#010x", result.cbegin()[i]);
if ((i + 1) % 4 == 0) {
printf(",\n");
} else {
printf(", ");
}
}
printf("\n");
printf("SPIRV JS ARRAY DUMP END\n");
#endif
return CreateShaderModuleFromResult(device, result);
}
wgpu::ShaderModule CreateShaderModuleFromASM(const wgpu::Device& device, const char* source) {
shaderc::Compiler* compiler = CompilerSingleton::Get();
shaderc::SpvCompilationResult result = compiler->AssembleToSpv(source, strlen(source));
@ -138,10 +62,24 @@ namespace utils {
return {};
}
return CreateShaderModuleFromResult(device, result);
// result.cend and result.cbegin return pointers to uint32_t.
const uint32_t* resultBegin = result.cbegin();
const uint32_t* resultEnd = result.cend();
// So this size is in units of sizeof(uint32_t).
ptrdiff_t resultSize = resultEnd - resultBegin;
// SetSource takes data as uint32_t*.
wgpu::ShaderModuleSPIRVDescriptor spirvDesc;
spirvDesc.codeSize = static_cast<uint32_t>(resultSize);
spirvDesc.code = result.cbegin();
wgpu::ShaderModuleDescriptor descriptor;
descriptor.nextInChain = &spirvDesc;
return device.CreateShaderModule(&descriptor);
}
wgpu::ShaderModule CreateShaderModuleFromWGSL(const wgpu::Device& device, const char* source) {
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device, const char* source) {
wgpu::ShaderModuleWGSLDescriptor wgslDesc;
wgslDesc.source = source;
wgpu::ShaderModuleDescriptor descriptor;
@ -149,18 +87,6 @@ namespace utils {
return device.CreateShaderModule(&descriptor);
}
std::vector<uint32_t> CompileGLSLToSpirv(SingleShaderStage stage, const char* source) {
shaderc_shader_kind kind = ShadercShaderKind(stage);
shaderc::Compiler* compiler = CompilerSingleton::Get();
auto result = compiler->CompileGlslToSpv(source, strlen(source), kind, "myshader?");
if (result.GetCompilationStatus() != shaderc_compilation_status_success) {
dawn::ErrorLog() << result.GetErrorMessage();
return {};
}
return {result.cbegin(), result.cend()};
}
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
const void* data,
uint64_t size,

View File

@ -30,13 +30,8 @@ namespace utils {
enum class SingleShaderStage { Vertex, Fragment, Compute };
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device,
SingleShaderStage stage,
const char* source);
wgpu::ShaderModule CreateShaderModuleFromASM(const wgpu::Device& device, const char* source);
wgpu::ShaderModule CreateShaderModuleFromWGSL(const wgpu::Device& device, const char* source);
std::vector<uint32_t> CompileGLSLToSpirv(SingleShaderStage stage, const char* source);
wgpu::ShaderModule CreateShaderModule(const wgpu::Device& device, const char* source);
wgpu::Buffer CreateBufferFromData(const wgpu::Device& device,
const void* data,