wgsl: Replace use of [[attribute]] with @attribute
Bug: tint:1382 Change-Id: I58ad2c88fde1e7c96f2ae8257e6df924b94b61db Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/77660 Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
parent
facbc82d6c
commit
a9ca8cb4ab
|
@ -66,14 +66,14 @@ void init() {
|
|||
scalar : f32;
|
||||
scalarOffset : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> c : Constants;
|
||||
@group(0) @binding(0) var<uniform> c : Constants;
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] v_color : vec4<f32>;
|
||||
[[builtin(position)]] Position : vec4<f32>;
|
||||
@location(0) v_color : vec4<f32>;
|
||||
@builtin(position) Position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
|
||||
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
|
||||
var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
|
||||
vec4<f32>( 0.0, 0.1, 0.0, 1.0),
|
||||
vec4<f32>(-0.1, -0.1, 0.0, 1.0),
|
||||
|
@ -113,8 +113,7 @@ void init() {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main([[location(0)]] v_color : vec4<f32>)
|
||||
-> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(@location(0) v_color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return v_color;
|
||||
})");
|
||||
|
||||
|
|
|
@ -38,9 +38,9 @@ void init() {
|
|||
wgpuSwapChainConfigure(swapchain, swapChainFormat, WGPUTextureUsage_RenderAttachment, 640, 480);
|
||||
|
||||
const char* vs = R"(
|
||||
[[stage(vertex)]] fn main(
|
||||
[[builtin(vertex_index)]] VertexIndex : u32
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@builtin(vertex_index) VertexIndex : u32
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>( 0.0, 0.5),
|
||||
vec2<f32>(-0.5, -0.5),
|
||||
|
@ -51,7 +51,7 @@ void init() {
|
|||
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
|
||||
|
||||
const char* fs = R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();
|
||||
|
|
|
@ -96,13 +96,13 @@ void initBuffers() {
|
|||
void initRender() {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
struct VertexIn {
|
||||
[[location(0)]] a_particlePos : vec2<f32>;
|
||||
[[location(1)]] a_particleVel : vec2<f32>;
|
||||
[[location(2)]] a_pos : vec2<f32>;
|
||||
@location(0) a_particlePos : vec2<f32>;
|
||||
@location(1) a_particleVel : vec2<f32>;
|
||||
@location(2) a_pos : vec2<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main(input : VertexIn) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
|
||||
var angle : f32 = -atan2(input.a_particleVel.x, input.a_particleVel.y);
|
||||
var pos : vec2<f32> = vec2<f32>(
|
||||
(input.a_pos.x * cos(angle)) - (input.a_pos.y * sin(angle)),
|
||||
|
@ -112,8 +112,8 @@ void initRender() {
|
|||
)");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
@ -164,13 +164,13 @@ void initSim() {
|
|||
struct Particles {
|
||||
particles : array<Particle>;
|
||||
};
|
||||
[[binding(0), group(0)]] var<uniform> params : SimParams;
|
||||
[[binding(1), group(0)]] var<storage, read> particlesA : Particles;
|
||||
[[binding(2), group(0)]] var<storage, read_write> particlesB : Particles;
|
||||
@binding(0), group(0) var<uniform> params : SimParams;
|
||||
@binding(1), group(0) var<storage, read> particlesA : Particles;
|
||||
@binding(2), group(0) var<storage, read_write> particlesB : Particles;
|
||||
|
||||
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
var index : u32 = GlobalInvocationID.x;
|
||||
if (index >= params.particleCount) {
|
||||
return;
|
||||
|
|
|
@ -97,17 +97,17 @@ void init() {
|
|||
initTextures();
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main([[location(0)]] pos : vec4<f32>)
|
||||
-> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(@location(0) pos : vec4<f32>)
|
||||
-> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[group(0), binding(1)]] var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@group(0) @binding(1) var myTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main([[builtin(position)]] FragCoord : vec4<f32>)
|
||||
-> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(@builtin(position) FragCoord : vec4<f32>)
|
||||
-> @location(0) vec4<f32> {
|
||||
return textureSample(myTexture, mySampler, FragCoord.xy / vec2<f32>(640.0, 480.0));
|
||||
})");
|
||||
|
||||
|
|
|
@ -314,8 +314,8 @@ int main(int argc, const char* argv[]) {
|
|||
// The hacky pipeline to render a triangle.
|
||||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32)
|
||||
-> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32)
|
||||
-> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>( 0.0, 0.5),
|
||||
vec2<f32>(-0.5, -0.5),
|
||||
|
@ -324,7 +324,7 @@ int main(int argc, const char* argv[]) {
|
|||
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
|
||||
})");
|
||||
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
// BGRA shouldn't be hardcoded. Consider having a map[format -> pipeline].
|
||||
|
|
|
@ -60,11 +60,11 @@ namespace dawn::native {
|
|||
data: array<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> uniformParams: UniformParams;
|
||||
[[group(0), binding(1)]] var<storage, read_write> clientParams: IndirectParams;
|
||||
[[group(0), binding(2)]] var<storage, write> validatedParams: ValidatedParams;
|
||||
@group(0) @binding(0) var<uniform> uniformParams: UniformParams;
|
||||
@group(0) @binding(1) var<storage, read_write> clientParams: IndirectParams;
|
||||
@group(0) @binding(2) var<storage, write> validatedParams: ValidatedParams;
|
||||
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
fn main() {
|
||||
for (var i = 0u; i < 3u; i = i + 1u) {
|
||||
var numWorkgroups = clientParams.data[uniformParams.clientOffsetInU32 + i];
|
||||
|
@ -326,7 +326,7 @@ namespace dawn::native {
|
|||
// - Validate each indirect dispatch with a single dispatch to copy the indirect
|
||||
// buffer params into a scratch buffer if they're valid, and otherwise zero them
|
||||
// out.
|
||||
// - Duplicate all the indirect dispatch parameters to support [[num_workgroups]] on
|
||||
// - Duplicate all the indirect dispatch parameters to support @num_workgroups on
|
||||
// D3D12.
|
||||
// - Directly return the original indirect dispatch buffer if we don't need any
|
||||
// transformations on it.
|
||||
|
|
|
@ -59,11 +59,11 @@ namespace dawn::native {
|
|||
gamma_decoding_for_dst_srgb_params: GammaTransferParams; // 144 4 32
|
||||
};
|
||||
|
||||
[[binding(0), group(0)]] var<uniform> uniforms : Uniforms;
|
||||
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
|
||||
|
||||
struct VertexOutputs {
|
||||
[[location(0)]] texcoords : vec2<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) texcoords : vec2<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
// Chromium uses unified equation to construct gamma decoding function
|
||||
|
@ -84,9 +84,9 @@ namespace dawn::native {
|
|||
return sign(v) * (pow(params.A * abs(v) + params.B, params.G) + params.E);
|
||||
}
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn vs_main(
|
||||
[[builtin(vertex_index)]] VertexIndex : u32
|
||||
@builtin(vertex_index) VertexIndex : u32
|
||||
) -> VertexOutputs {
|
||||
var texcoord = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-0.5, 0.0),
|
||||
|
@ -119,13 +119,13 @@ namespace dawn::native {
|
|||
return output;
|
||||
}
|
||||
|
||||
[[binding(1), group(0)]] var mySampler: sampler;
|
||||
[[binding(2), group(0)]] var myTexture: texture_2d<f32>;
|
||||
@binding(1) @group(0) var mySampler: sampler;
|
||||
@binding(2) @group(0) var myTexture: texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn fs_main(
|
||||
[[location(0)]] texcoord : vec2<f32>
|
||||
) -> [[location(0)]] vec4<f32> {
|
||||
@location(0) texcoord : vec2<f32>
|
||||
) -> @location(0) vec4<f32> {
|
||||
// Clamp the texcoord and discard the out-of-bound pixels.
|
||||
var clampedTexcoord =
|
||||
clamp(texcoord, vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 1.0));
|
||||
|
|
|
@ -251,7 +251,7 @@ namespace dawn::native {
|
|||
if (IsToggleEnabled(Toggle::UseDummyFragmentInVertexOnlyPipeline)) {
|
||||
// The empty fragment shader, used as a work around for vertex-only render pipeline
|
||||
constexpr char kEmptyFragmentShader[] = R"(
|
||||
[[stage(fragment)]] fn fs_empty_main() {}
|
||||
@stage(fragment) fn fs_empty_main() {}
|
||||
)";
|
||||
ShaderModuleDescriptor descriptor;
|
||||
ShaderModuleWGSLDescriptor wgslDesc;
|
||||
|
|
|
@ -65,9 +65,9 @@ namespace dawn::native {
|
|||
data: array<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> batch: BatchInfo;
|
||||
[[group(0), binding(1)]] var<storage, read_write> clientParams: IndirectParams;
|
||||
[[group(0), binding(2)]] var<storage, write> validatedParams: IndirectParams;
|
||||
@group(0) @binding(0) var<storage, read> batch: BatchInfo;
|
||||
@group(0) @binding(1) var<storage, read_write> clientParams: IndirectParams;
|
||||
@group(0) @binding(2) var<storage, write> validatedParams: IndirectParams;
|
||||
|
||||
fn fail(drawIndex: u32) {
|
||||
let index = drawIndex * kNumIndirectParamsPerDrawCall;
|
||||
|
@ -93,8 +93,8 @@ namespace dawn::native {
|
|||
clientParams.data[cIndex + kFirstInstanceEntry];
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(64, 1, 1)]]
|
||||
fn main([[builtin(global_invocation_id)]] id : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(64, 1, 1)
|
||||
fn main(@builtin(global_invocation_id) id : vec3<u32>) {
|
||||
if (id.x >= batch.numDraws) {
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -55,17 +55,15 @@ namespace dawn::native {
|
|||
period : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]]
|
||||
var<storage, read_write> timestamps : TimestampArr;
|
||||
[[group(0), binding(1)]]
|
||||
var<storage, read> availability : AvailabilityArr;
|
||||
[[group(0), binding(2)]] var<uniform> params : TimestampParams;
|
||||
@group(0) @binding(0) var<storage, read_write> timestamps : TimestampArr;
|
||||
@group(0) @binding(1) var<storage, read> availability : AvailabilityArr;
|
||||
@group(0) @binding(2) var<uniform> params : TimestampParams;
|
||||
|
||||
|
||||
let sizeofTimestamp : u32 = 8u;
|
||||
|
||||
[[stage(compute), workgroup_size(8, 1, 1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(8, 1, 1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
if (GlobalInvocationID.x >= params.count) { return; }
|
||||
|
||||
var index = GlobalInvocationID.x + params.offset / sizeofTimestamp;
|
||||
|
|
|
@ -1163,12 +1163,12 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t
|
|||
detail::Expectation* expectation) {
|
||||
std::ostringstream shaderSource;
|
||||
shaderSource << "let width : u32 = " << width << "u;\n";
|
||||
shaderSource << "[[group(0), binding(0)]] var tex : " << wgslTextureType << ";\n";
|
||||
shaderSource << "@group(0) @binding(0) var tex : " << wgslTextureType << ";\n";
|
||||
shaderSource << R"(
|
||||
struct Result {
|
||||
values : array<f32>;
|
||||
};
|
||||
[[group(0), binding(1)]] var<storage, read_write> result : Result;
|
||||
@group(0) @binding(1) var<storage, read_write> result : Result;
|
||||
)";
|
||||
shaderSource << "let componentCount : u32 = " << componentCount << "u;\n";
|
||||
shaderSource << "let sampleCount : u32 = " << sampleCount << "u;\n";
|
||||
|
@ -1192,8 +1192,8 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t
|
|||
}
|
||||
}
|
||||
shaderSource << R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main(
|
||||
[[builtin(global_invocation_id)]] GlobalInvocationId : vec3<u32>
|
||||
@stage(compute) @workgroup_size(1) fn main(
|
||||
@builtin(global_invocation_id) GlobalInvocationId : vec3<u32>
|
||||
) {
|
||||
let baseOutIndex = GlobalInvocationId.y * width + GlobalInvocationId.x;
|
||||
for (var s = 0u; s < sampleCount; s = s + 1u) {
|
||||
|
@ -1336,8 +1336,8 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
|
|||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
|
||||
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>( 3.0, -1.0),
|
||||
|
@ -1349,15 +1349,15 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
|
|||
// 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::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(0) var texture0 : texture_2d<f32>;
|
||||
|
||||
struct FragmentOut {
|
||||
[[location(0)]] result : u32;
|
||||
[[builtin(frag_depth)]] fragDepth : f32;
|
||||
@location(0) result : u32;
|
||||
@builtin(frag_depth) fragDepth : f32;
|
||||
};
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> FragmentOut {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.result = 1u;
|
||||
output.fragDepth = textureLoad(texture0, vec2<i32>(FragCoord.xy), 0)[0];
|
||||
|
@ -1365,8 +1365,8 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
|
|||
})");
|
||||
} else {
|
||||
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] u32 {
|
||||
@stage(fragment)
|
||||
fn main() -> @location(0) u32 {
|
||||
return 1u;
|
||||
})");
|
||||
}
|
||||
|
|
|
@ -51,8 +51,8 @@ class BindGroupTests : public DawnTest {
|
|||
|
||||
wgpu::ShaderModule MakeSimpleVSModule() const {
|
||||
return utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -73,11 +73,11 @@ class BindGroupTests : public DawnTest {
|
|||
|
||||
switch (bindingTypes[i]) {
|
||||
case wgpu::BufferBindingType::Uniform:
|
||||
fs << "\n[[group(" << i << "), binding(0)]] var<uniform> buffer" << i
|
||||
fs << "\n@group(" << i << ") @binding(0) var<uniform> buffer" << i
|
||||
<< " : Buffer" << i << ";";
|
||||
break;
|
||||
case wgpu::BufferBindingType::Storage:
|
||||
fs << "\n[[group(" << i << "), binding(0)]] var<storage, read> buffer" << i
|
||||
fs << "\n@group(" << i << ") @binding(0) var<storage, read> buffer" << i
|
||||
<< " : Buffer" << i << ";";
|
||||
break;
|
||||
default:
|
||||
|
@ -85,7 +85,7 @@ class BindGroupTests : public DawnTest {
|
|||
}
|
||||
}
|
||||
|
||||
fs << "\n[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32>{\n";
|
||||
fs << "\n@stage(fragment) fn main() -> @location(0) vec4<f32>{\n";
|
||||
fs << "var fragColor : vec4<f32> = vec4<f32>();\n";
|
||||
for (size_t i = 0; i < bindingTypes.size(); ++i) {
|
||||
fs << "fragColor = fragColor + buffer" << i << ".color;\n";
|
||||
|
@ -132,9 +132,9 @@ TEST_P(BindGroupTests, ReusedBindGroupSingleSubmit) {
|
|||
struct Contents {
|
||||
f : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var <uniform> contents: Contents;
|
||||
@group(0) @binding(0) var <uniform> contents: Contents;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
var f : f32 = contents.f;
|
||||
})");
|
||||
|
||||
|
@ -168,10 +168,10 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
|||
transform : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var <uniform> vertexUbo : VertexUniformBuffer;
|
||||
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -185,9 +185,9 @@ TEST_P(BindGroupTests, ReusedUBO) {
|
|||
struct FragmentUniformBuffer {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(1)]] var <uniform> fragmentUbo : FragmentUniformBuffer;
|
||||
@group(0) @binding(1) var <uniform> fragmentUbo : FragmentUniformBuffer;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return fragmentUbo.color;
|
||||
})");
|
||||
|
||||
|
@ -245,10 +245,10 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||
struct VertexUniformBuffer {
|
||||
transform : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var <uniform> vertexUbo : VertexUniformBuffer;
|
||||
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -259,11 +259,11 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(1)]] var samp : sampler;
|
||||
[[group(0), binding(2)]] var tex : texture_2d<f32>;
|
||||
@group(0) @binding(1) var samp : sampler;
|
||||
@group(0) @binding(2) var tex : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(tex, samp, FragCoord.xy);
|
||||
})");
|
||||
|
||||
|
@ -349,11 +349,11 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
|
|||
transform : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var <uniform> vertexUbo1 : VertexUniformBuffer;
|
||||
[[group(1), binding(0)]] var <uniform> vertexUbo2 : VertexUniformBuffer;
|
||||
@group(0) @binding(0) var <uniform> vertexUbo1 : VertexUniformBuffer;
|
||||
@group(1) @binding(0) var <uniform> vertexUbo2 : VertexUniformBuffer;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -370,10 +370,10 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
|
|||
color : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(1)]] var <uniform> fragmentUbo1 : FragmentUniformBuffer;
|
||||
[[group(1), binding(1)]] var <uniform> fragmentUbo2 : FragmentUniformBuffer;
|
||||
@group(0) @binding(1) var <uniform> fragmentUbo1 : FragmentUniformBuffer;
|
||||
@group(1) @binding(1) var <uniform> fragmentUbo2 : FragmentUniformBuffer;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return fragmentUbo1.color + fragmentUbo2.color;
|
||||
})");
|
||||
|
||||
|
@ -438,20 +438,20 @@ TEST_P(BindGroupTests, MultipleEntryPointsWithMultipleNonZeroGroups) {
|
|||
struct Contents {
|
||||
f : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var <uniform> contents0: Contents;
|
||||
[[group(1), binding(0)]] var <uniform> contents1: Contents;
|
||||
[[group(2), binding(0)]] var <uniform> contents2: Contents;
|
||||
@group(0) @binding(0) var <uniform> contents0: Contents;
|
||||
@group(1) @binding(0) var <uniform> contents1: Contents;
|
||||
@group(2) @binding(0) var <uniform> contents2: Contents;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main0() {
|
||||
@stage(compute) @workgroup_size(1) fn main0() {
|
||||
var a : f32 = contents0.f;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main1() {
|
||||
@stage(compute) @workgroup_size(1) fn main1() {
|
||||
var a : f32 = contents1.f;
|
||||
var b : f32 = contents2.f;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main2() {
|
||||
@stage(compute) @workgroup_size(1) fn main2() {
|
||||
var a : f32 = contents0.f;
|
||||
var b : f32 = contents1.f;
|
||||
var c : f32 = contents2.f;
|
||||
|
@ -1043,12 +1043,12 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
|
|||
value : vec3<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(2)]] var<uniform> buffer2 : Buffer;
|
||||
[[group(0), binding(3)]] var<storage, read> buffer3 : Buffer;
|
||||
[[group(0), binding(0)]] var<storage, read> buffer0 : Buffer;
|
||||
[[group(0), binding(4)]] var<storage, read_write> outputBuffer : OutputBuffer;
|
||||
@group(0) @binding(2) var<uniform> buffer2 : Buffer;
|
||||
@group(0) @binding(3) var<storage, read> buffer3 : Buffer;
|
||||
@group(0) @binding(0) var<storage, read> buffer0 : Buffer;
|
||||
@group(0) @binding(4) var<storage, read_write> outputBuffer : OutputBuffer;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
outputBuffer.value = vec3<u32>(buffer0.value, buffer2.value, buffer3.value);
|
||||
})");
|
||||
pipelineDescriptor.compute.entryPoint = "main";
|
||||
|
@ -1126,11 +1126,11 @@ TEST_P(BindGroupTests, DynamicAndNonDynamicBindingsDoNotConflictAfterRemapping)
|
|||
value : vec2<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> buffer0 : Buffer;
|
||||
[[group(0), binding(1)]] var<uniform> buffer1 : Buffer;
|
||||
[[group(0), binding(2)]] var<storage, read_write> outputBuffer : OutputBuffer;
|
||||
@group(0) @binding(0) var<uniform> buffer0 : Buffer;
|
||||
@group(0) @binding(1) var<uniform> buffer1 : Buffer;
|
||||
@group(0) @binding(2) var<storage, read_write> outputBuffer : OutputBuffer;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
outputBuffer.value = vec2<u32>(buffer0.value, buffer1.value);
|
||||
})");
|
||||
pipelineDescriptor.compute.entryPoint = "main";
|
||||
|
@ -1233,8 +1233,8 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
|
|||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -1248,11 +1248,11 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
|
|||
color : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(953)]] var <uniform> ubo1 : Ubo;
|
||||
[[group(0), binding(47)]] var <uniform> ubo2 : Ubo;
|
||||
[[group(0), binding(111)]] var <uniform> ubo3 : Ubo;
|
||||
@group(0) @binding(953) var <uniform> ubo1 : Ubo;
|
||||
@group(0) @binding(47) var <uniform> ubo2 : Ubo;
|
||||
@group(0) @binding(111) var <uniform> ubo3 : Ubo;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return ubo1.color + 2.0 * ubo2.color + 4.0 * ubo3.color;
|
||||
})");
|
||||
|
||||
|
@ -1352,7 +1352,7 @@ TEST_P(BindGroupTests, EmptyLayout) {
|
|||
pipelineDesc.layout = utils::MakeBasicPipelineLayout(device, &bgl);
|
||||
pipelineDesc.compute.entryPoint = "main";
|
||||
pipelineDesc.compute.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
|
||||
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&pipelineDesc);
|
||||
|
@ -1375,8 +1375,8 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
|
|||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
|
||||
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -1389,9 +1389,9 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
|
|||
struct Buffer0 {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> buffer0 : Buffer0;
|
||||
@group(0) @binding(0) var<storage, read> buffer0 : Buffer0;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return buffer0.color;
|
||||
})");
|
||||
|
||||
|
@ -1471,12 +1471,12 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
|
|||
wgpu::TextureFormat::R8Unorm, expectedValue, wgpu::TextureUsage::TextureBinding);
|
||||
bgEntries.push_back({nullptr, binding, nullptr, 0, 0, nullptr, texture.CreateView()});
|
||||
|
||||
interface << "[[group(0), binding(" << binding++ << ")]] "
|
||||
interface << "@group(0) @binding(" << binding++ << ") "
|
||||
<< "var tex" << i << " : texture_2d<f32>;\n";
|
||||
|
||||
bgEntries.push_back({nullptr, binding, nullptr, 0, 0, device.CreateSampler(), nullptr});
|
||||
|
||||
interface << "[[group(0), binding(" << binding++ << ")]]"
|
||||
interface << "@group(0) @binding(" << binding++ << ")"
|
||||
<< "var samp" << i << " : sampler;\n";
|
||||
|
||||
body << "if (abs(textureSampleLevel(tex" << i << ", samp" << i
|
||||
|
@ -1490,7 +1490,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
|
|||
wgpu::TextureFormat::R32Uint, expectedValue, wgpu::TextureUsage::StorageBinding);
|
||||
bgEntries.push_back({nullptr, binding, nullptr, 0, 0, nullptr, texture.CreateView()});
|
||||
|
||||
interface << "[[group(0), binding(" << binding++ << ")]] "
|
||||
interface << "@group(0) @binding(" << binding++ << ") "
|
||||
<< "var image" << i << " : texture_storage_2d<r32uint, write>;\n";
|
||||
|
||||
body << "_ = image" << i << ";";
|
||||
|
@ -1505,7 +1505,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
|
|||
value : u32;
|
||||
};
|
||||
)";
|
||||
interface << "[[group(0), binding(" << binding++ << ")]] "
|
||||
interface << "@group(0) @binding(" << binding++ << ") "
|
||||
<< "var<uniform> ubuf" << i << " : UniformBuffer" << i << ";\n";
|
||||
|
||||
body << "if (ubuf" << i << ".value != " << expectedValue++ << "u) {\n";
|
||||
|
@ -1522,7 +1522,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
|
|||
value : u32;
|
||||
};
|
||||
)";
|
||||
interface << "[[group(0), binding(" << binding++ << ")]] "
|
||||
interface << "@group(0) @binding(" << binding++ << ") "
|
||||
<< "var<storage, read> sbuf" << i << " : ReadOnlyStorageBuffer" << i << ";\n";
|
||||
|
||||
body << "if (sbuf" << i << ".value != " << expectedValue++ << "u) {\n";
|
||||
|
@ -1538,13 +1538,13 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
|
|||
value : u32;
|
||||
};
|
||||
)";
|
||||
interface << "[[group(0), binding(" << binding++ << ")]] "
|
||||
interface << "@group(0) @binding(" << binding++ << ") "
|
||||
<< "var<storage, read_write> result : ReadWriteStorageBuffer;\n";
|
||||
|
||||
body << "result.value = 1u;\n";
|
||||
|
||||
std::string shader = interface.str() + "[[stage(compute), workgroup_size(1)]] fn main() {\n" +
|
||||
body.str() + "}\n";
|
||||
std::string shader =
|
||||
interface.str() + "@stage(compute) @workgroup_size(1) fn main() {\n" + body.str() + "}\n";
|
||||
wgpu::ComputePipelineDescriptor cpDesc;
|
||||
cpDesc.compute.module = utils::CreateShaderModule(device, shader.c_str());
|
||||
cpDesc.compute.entryPoint = "main";
|
||||
|
|
|
@ -211,8 +211,8 @@ class BufferZeroInitTest : public DawnTest {
|
|||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader);
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] i_color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) i_color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return i_color;
|
||||
})");
|
||||
|
||||
|
@ -251,11 +251,11 @@ class BufferZeroInitTest : public DawnTest {
|
|||
|
||||
wgpu::RenderPipeline renderPipeline = CreateRenderPipelineForTest(R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main([[location(0)]] pos : vec4<f32>) -> VertexOut {
|
||||
@stage(vertex) fn main(@location(0) pos : vec4<f32>) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
if (all(pos == vec4<f32>(0.0, 0.0, 0.0, 0.0))) {
|
||||
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
|
@ -295,12 +295,12 @@ class BufferZeroInitTest : public DawnTest {
|
|||
wgpu::RenderPipeline renderPipeline =
|
||||
CreateRenderPipelineForTest(R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
if (VertexIndex == 0u) {
|
||||
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
|
@ -345,11 +345,11 @@ class BufferZeroInitTest : public DawnTest {
|
|||
wgpu::RenderPipeline renderPipeline =
|
||||
CreateRenderPipelineForTest(R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main() -> VertexOut {
|
||||
@stage(vertex) fn main() -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
|
@ -386,11 +386,11 @@ class BufferZeroInitTest : public DawnTest {
|
|||
wgpu::RenderPipeline renderPipeline =
|
||||
CreateRenderPipelineForTest(R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main() -> VertexOut {
|
||||
@stage(vertex) fn main() -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
|
@ -429,9 +429,9 @@ class BufferZeroInitTest : public DawnTest {
|
|||
// As long as the comptue shader is executed once, the pixel color of outImage will be set
|
||||
// to red.
|
||||
const char* computeShader = R"(
|
||||
[[group(0), binding(0)]] var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
@group(0) @binding(0) var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
|
||||
})";
|
||||
|
||||
|
@ -1000,10 +1000,10 @@ TEST_P(BufferZeroInitTest, BoundAsUniformBuffer) {
|
|||
struct UBO {
|
||||
value : vec4<u32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> ubo : UBO;
|
||||
[[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
@group(0) @binding(0) var<uniform> ubo : UBO;
|
||||
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
if (all(ubo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
|
||||
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0));
|
||||
} else {
|
||||
|
@ -1039,10 +1039,10 @@ TEST_P(BufferZeroInitTest, BoundAsReadonlyStorageBuffer) {
|
|||
struct SSBO {
|
||||
value : vec4<u32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> ssbo : SSBO;
|
||||
[[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
@group(0) @binding(0) var<storage, read> ssbo : SSBO;
|
||||
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
if (all(ssbo.value == vec4<u32>(0u, 0u, 0u, 0u))) {
|
||||
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0));
|
||||
} else {
|
||||
|
@ -1078,10 +1078,10 @@ TEST_P(BufferZeroInitTest, BoundAsStorageBuffer) {
|
|||
struct SSBO {
|
||||
value : array<vec4<u32>, 2>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : SSBO;
|
||||
[[group(0), binding(1)]] var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
|
||||
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
if (all(ssbo.value[0] == vec4<u32>(0u, 0u, 0u, 0u)) &&
|
||||
all(ssbo.value[1] == vec4<u32>(0u, 0u, 0u, 0u))) {
|
||||
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(0.0, 1.0, 0.0, 1.0));
|
||||
|
@ -1138,7 +1138,7 @@ TEST_P(BufferZeroInitTest, SetVertexBuffer) {
|
|||
// draw call. A backend which implements robust buffer access via clamping should
|
||||
// still see zeros at the end of the buffer.
|
||||
TEST_P(BufferZeroInitTest, PaddingInitialized) {
|
||||
DAWN_SUPPRESS_TEST_IF(IsANGLE()); // TODO(crbug.com/dawn/1084).
|
||||
DAWN_SUPPRESS_TEST_IF(IsANGLE()); // TODO(crbug.com/dawn/1084).
|
||||
DAWN_SUPPRESS_TEST_IF(IsLinux() && IsVulkan() && IsNvidia()); // TODO(crbug.com/dawn/1214).
|
||||
|
||||
constexpr wgpu::TextureFormat kColorAttachmentFormat = wgpu::TextureFormat::RGBA8Unorm;
|
||||
|
@ -1150,11 +1150,11 @@ TEST_P(BufferZeroInitTest, PaddingInitialized) {
|
|||
wgpu::RenderPipeline renderPipeline =
|
||||
CreateRenderPipelineForTest(R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main([[location(0)]] pos : vec2<f32>) -> VertexOut {
|
||||
@stage(vertex) fn main(@location(0) pos : vec2<f32>) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
if (all(pos == vec2<f32>(0.0, 0.0))) {
|
||||
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
|
|
|
@ -26,8 +26,8 @@ class ClipSpaceTest : public DawnTest {
|
|||
// 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::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec3<f32>, 6>(
|
||||
vec3<f32>(-1.0, 1.0, 1.0),
|
||||
vec3<f32>(-1.0, -1.0, 0.5),
|
||||
|
@ -39,7 +39,7 @@ class ClipSpaceTest : public DawnTest {
|
|||
})");
|
||||
|
||||
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -39,8 +39,8 @@ class ColorStateTest : public DawnTest {
|
|||
DAWN_SUPPRESS_TEST_IF(IsD3D12() && IsWARP());
|
||||
|
||||
vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>(3.0, -1.0),
|
||||
|
@ -65,9 +65,9 @@ class ColorStateTest : public DawnTest {
|
|||
color : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
|
||||
@group(0) @binding(0) var<uniform> myUbo : MyBlock;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return myUbo.color;
|
||||
}
|
||||
)");
|
||||
|
@ -798,16 +798,16 @@ TEST_P(ColorStateTest, IndependentColorState) {
|
|||
color3 : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
|
||||
@group(0) @binding(0) var<uniform> myUbo : MyBlock;
|
||||
|
||||
struct FragmentOut {
|
||||
[[location(0)]] fragColor0 : vec4<f32>;
|
||||
[[location(1)]] fragColor1 : vec4<f32>;
|
||||
[[location(2)]] fragColor2 : vec4<f32>;
|
||||
[[location(3)]] fragColor3 : vec4<f32>;
|
||||
@location(0) fragColor0 : vec4<f32>;
|
||||
@location(1) fragColor1 : vec4<f32>;
|
||||
@location(2) fragColor2 : vec4<f32>;
|
||||
@location(3) fragColor3 : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.fragColor0 = myUbo.color0;
|
||||
output.fragColor1 = myUbo.color1;
|
||||
|
@ -919,9 +919,9 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
|
|||
color : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
|
||||
@group(0) @binding(0) var<uniform> myUbo : MyBlock;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return myUbo.color;
|
||||
}
|
||||
)");
|
||||
|
@ -1045,9 +1045,9 @@ TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
|
|||
color : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> myUbo : MyBlock;
|
||||
@group(0) @binding(0) var<uniform> myUbo : MyBlock;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return myUbo.color;
|
||||
}
|
||||
)");
|
||||
|
|
|
@ -165,12 +165,12 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
|
|||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] texCoord : vec2 <f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) texCoord : vec2 <f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-3.0, 1.0),
|
||||
vec2<f32>( 3.0, 1.0),
|
||||
|
@ -182,11 +182,11 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
|
|||
return output;
|
||||
})");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, texCoord);
|
||||
})");
|
||||
renderPipelineDescriptor.vertex.module = vsModule;
|
||||
|
|
|
@ -92,11 +92,11 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) {
|
|||
s : array<vec4<u32>, 4>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> src : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> src : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
let index : u32 = GlobalInvocationID.x;
|
||||
if (index >= 4u) { return; }
|
||||
dst.s[index] = src.s[index];
|
||||
|
@ -115,11 +115,11 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
|
|||
s : array<S, 4>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> src : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> src : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
let index : u32 = GlobalInvocationID.x;
|
||||
if (index >= 4u) { return; }
|
||||
dst.s[index] = src.s[index];
|
||||
|
@ -133,11 +133,11 @@ TEST_P(ComputeCopyStorageBufferTests, UnsizedArrayOfBasic) {
|
|||
s : array<vec4<u32>>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> src : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> src : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
let index : u32 = GlobalInvocationID.x;
|
||||
if (index >= 4u) { return; }
|
||||
dst.s[index] = src.s[index];
|
||||
|
|
|
@ -32,11 +32,11 @@ class ComputeDispatchTests : public DawnTest {
|
|||
workGroups : vec3<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> output : OutputBuf;
|
||||
@group(0) @binding(0) var<storage, read_write> output : OutputBuf;
|
||||
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>,
|
||||
[[builtin(num_workgroups)]] dispatch : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>,
|
||||
@builtin(num_workgroups) dispatch : vec3<u32>) {
|
||||
if (dispatch.x == 0u || dispatch.y == 0u || dispatch.z == 0u) {
|
||||
output.workGroups = vec3<u32>(0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu);
|
||||
return;
|
||||
|
@ -52,7 +52,7 @@ class ComputeDispatchTests : public DawnTest {
|
|||
csDesc.compute.entryPoint = "main";
|
||||
pipeline = device.CreateComputePipeline(&csDesc);
|
||||
|
||||
// Test the use of the compute pipelines without using [[num_workgroups]]
|
||||
// Test the use of the compute pipelines without using @num_workgroups
|
||||
wgpu::ShaderModule moduleWithoutNumWorkgroups = utils::CreateShaderModule(device, R"(
|
||||
struct InputBuf {
|
||||
expectedDispatch : vec3<u32>;
|
||||
|
@ -61,11 +61,11 @@ class ComputeDispatchTests : public DawnTest {
|
|||
workGroups : vec3<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> input : InputBuf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> output : OutputBuf;
|
||||
@group(0) @binding(0) var<uniform> input : InputBuf;
|
||||
@group(0) @binding(1) var<storage, read_write> output : OutputBuf;
|
||||
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
let dispatch : vec3<u32> = input.expectedDispatch;
|
||||
|
||||
if (dispatch.x == 0u || dispatch.y == 0u || dispatch.z == 0u) {
|
||||
|
@ -224,7 +224,7 @@ TEST_P(ComputeDispatchTests, IndirectBasic) {
|
|||
IndirectTest({2, 3, 4}, 0);
|
||||
}
|
||||
|
||||
// Test basic indirect without using [[num_workgroups]]
|
||||
// Test basic indirect without using @num_workgroups
|
||||
TEST_P(ComputeDispatchTests, IndirectBasicWithoutNumWorkgroups) {
|
||||
IndirectTest({2, 3, 4}, 0, false);
|
||||
}
|
||||
|
@ -256,7 +256,7 @@ TEST_P(ComputeDispatchTests, IndirectOffset) {
|
|||
IndirectTest({0, 0, 0, 2, 3, 4}, 3 * sizeof(uint32_t));
|
||||
}
|
||||
|
||||
// Test indirect with buffer offset without using [[num_workgroups]]
|
||||
// Test indirect with buffer offset without using @num_workgroups
|
||||
TEST_P(ComputeDispatchTests, IndirectOffsetWithoutNumWorkgroups) {
|
||||
IndirectTest({0, 0, 0, 2, 3, 4}, 3 * sizeof(uint32_t), false);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ namespace {
|
|||
|
||||
// Align returns the WGSL decoration for an explicit structure field alignment
|
||||
std::string AlignDeco(uint32_t value) {
|
||||
return "[[align(" + std::to_string(value) + ")]] ";
|
||||
return "@align(" + std::to_string(value) + ") ";
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
@ -124,8 +124,8 @@ std::ostream& operator<<(std::ostream& o, StorageClass storageClass) {
|
|||
}
|
||||
|
||||
std::ostream& operator<<(std::ostream& o, Field field) {
|
||||
o << "[[align(" << field.align << "), size("
|
||||
<< (field.padded_size > 0 ? field.padded_size : field.size) << ")]] " << field.type;
|
||||
o << "@align(" << field.align << ") @size("
|
||||
<< (field.padded_size > 0 ? field.padded_size : field.size) << ") " << field.type;
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -170,7 +170,7 @@ TEST_P(ComputeLayoutMemoryBufferTests, Fields) {
|
|||
std::string shader = R"(
|
||||
struct Data {
|
||||
header : u32;
|
||||
[[align({field_align}), size({field_size})]] field : {field_type};
|
||||
@align({field_align}) @size({field_size}) field : {field_type};
|
||||
footer : u32;
|
||||
};
|
||||
|
||||
|
@ -188,11 +188,11 @@ struct Status {
|
|||
code : u32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<{input_qualifiers}> input : Input;
|
||||
[[group(0), binding(1)]] var<storage, read_write> output : Output;
|
||||
[[group(0), binding(2)]] var<storage, read_write> status : Status;
|
||||
@group(0) @binding(0) var<{input_qualifiers}> input : Input;
|
||||
@group(0) @binding(1) var<storage, read_write> output : Output;
|
||||
@group(0) @binding(2) var<storage, read_write> status : Status;
|
||||
|
||||
[[stage(compute), workgroup_size(1,1,1)]]
|
||||
@stage(compute) @workgroup_size(1,1,1)
|
||||
fn main() {
|
||||
if (input.header != {input_header_code}u) {
|
||||
status.code = {status_bad_input_header}u;
|
||||
|
@ -283,7 +283,7 @@ fn main() {
|
|||
PushU32(kDataFooterCode); // Input.data.footer
|
||||
AlignTo(field.align, kDataSizePaddingCode); // Input.data padding
|
||||
}
|
||||
AlignTo(footerAlign, kInputFooterAlignPaddingCode); // Input.footer [[align]]
|
||||
AlignTo(footerAlign, kInputFooterAlignPaddingCode); // Input.footer @align
|
||||
PushU32(kInputFooterCode); // Input.footer
|
||||
AlignTo(256, kInputTailPaddingCode); // Input padding
|
||||
}
|
||||
|
@ -451,20 +451,20 @@ namespace {
|
|||
Field{"array<u32, 2>", /* align */ 4, /* size */ 8}.StorageBufferOnly(),
|
||||
Field{"array<u32, 3>", /* align */ 4, /* size */ 12}.StorageBufferOnly(),
|
||||
Field{"array<u32, 4>", /* align */ 4, /* size */ 16}.StorageBufferOnly(),
|
||||
Field{"[[stride(16)]] array<u32, 1>", /* align */ 4, /* size */ 16}
|
||||
Field{"@stride(16) array<u32, 1>", /* align */ 4, /* size */ 16}
|
||||
.StorageBufferOnly()
|
||||
.Strided<4, 12>(),
|
||||
Field{"[[stride(16)]] array<u32, 2>", /* align */ 4, /* size */ 32}
|
||||
Field{"@stride(16) array<u32, 2>", /* align */ 4, /* size */ 32}
|
||||
.StorageBufferOnly()
|
||||
.Strided<4, 12>(),
|
||||
Field{"[[stride(16)]] array<u32, 3>", /* align */ 4, /* size */ 48}
|
||||
Field{"@stride(16) array<u32, 3>", /* align */ 4, /* size */ 48}
|
||||
.StorageBufferOnly()
|
||||
.Strided<4, 12>(),
|
||||
Field{"[[stride(16)]] array<u32, 4>", /* align */ 4, /* size */ 64}
|
||||
Field{"@stride(16) array<u32, 4>", /* align */ 4, /* size */ 64}
|
||||
.StorageBufferOnly()
|
||||
.Strided<4, 12>(),
|
||||
Field{"array<vec3<u32>, 4>", /* align */ 16, /* size */ 64}.Strided<12, 4>(),
|
||||
Field{"[[stride(32)]] array<vec3<u32>, 4>", /* align */ 16, /* size */ 128}
|
||||
Field{"@stride(32) array<vec3<u32>, 4>", /* align */ 16, /* size */ 128}
|
||||
.Strided<12, 20>(),
|
||||
|
||||
// Array types with custom alignment
|
||||
|
@ -472,14 +472,10 @@ namespace {
|
|||
Field{"array<u32, 2>", /* align */ 32, /* size */ 8}.StorageBufferOnly(),
|
||||
Field{"array<u32, 3>", /* align */ 32, /* size */ 12}.StorageBufferOnly(),
|
||||
Field{"array<u32, 4>", /* align */ 32, /* size */ 16}.StorageBufferOnly(),
|
||||
Field{"[[stride(16)]] array<u32, 1>", /* align */ 32, /* size */ 16}
|
||||
.Strided<4, 12>(),
|
||||
Field{"[[stride(16)]] array<u32, 2>", /* align */ 32, /* size */ 32}
|
||||
.Strided<4, 12>(),
|
||||
Field{"[[stride(16)]] array<u32, 3>", /* align */ 32, /* size */ 48}
|
||||
.Strided<4, 12>(),
|
||||
Field{"[[stride(16)]] array<u32, 4>", /* align */ 32, /* size */ 64}
|
||||
.Strided<4, 12>(),
|
||||
Field{"@stride(16) array<u32, 1>", /* align */ 32, /* size */ 16}.Strided<4, 12>(),
|
||||
Field{"@stride(16) array<u32, 2>", /* align */ 32, /* size */ 32}.Strided<4, 12>(),
|
||||
Field{"@stride(16) array<u32, 3>", /* align */ 32, /* size */ 48}.Strided<4, 12>(),
|
||||
Field{"@stride(16) array<u32, 4>", /* align */ 32, /* size */ 64}.Strided<4, 12>(),
|
||||
Field{"array<vec3<u32>, 4>", /* align */ 32, /* size */ 64}.Strided<12, 4>(),
|
||||
|
||||
// Array types with custom size
|
||||
|
|
|
@ -78,11 +78,11 @@ TEST_P(ComputeSharedMemoryTests, Basic) {
|
|||
x : u32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, write> dst : Dst;
|
||||
@group(0) @binding(0) var<storage, write> dst : Dst;
|
||||
var<workgroup> tmp : u32;
|
||||
|
||||
[[stage(compute), workgroup_size(4,4,1)]]
|
||||
fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(4,4,1)
|
||||
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
|
||||
let index : u32 = LocalInvocationID.y * kTileSize + LocalInvocationID.x;
|
||||
if (index == 0u) {
|
||||
tmp = 0u;
|
||||
|
@ -117,15 +117,15 @@ TEST_P(ComputeSharedMemoryTests, AssortedTypes) {
|
|||
d_vector : vec4<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, write> dst : Dst;
|
||||
@group(0) @binding(0) var<storage, write> dst : Dst;
|
||||
|
||||
var<workgroup> wg_struct : StructValues;
|
||||
var<workgroup> wg_matrix : mat2x2<f32>;
|
||||
var<workgroup> wg_array : array<u32, 4>;
|
||||
var<workgroup> wg_vector : vec4<f32>;
|
||||
|
||||
[[stage(compute), workgroup_size(4,1,1)]]
|
||||
fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(4,1,1)
|
||||
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
|
||||
|
||||
let i = 4u * LocalInvocationID.x;
|
||||
if (LocalInvocationID.x == 0u) {
|
||||
|
|
|
@ -36,10 +36,10 @@ TEST_P(ComputeStorageBufferBarrierTests, AddIncrement) {
|
|||
data : array<u32, 100>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234u;
|
||||
}
|
||||
)");
|
||||
|
@ -86,11 +86,11 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
|
|||
data : array<u32, 100>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> src : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> src : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u;
|
||||
}
|
||||
)");
|
||||
|
@ -152,11 +152,11 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
|
|||
data : array<u32, 100>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> src : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Buf;
|
||||
@group(0) @binding(0) var<storage, read> src : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u;
|
||||
}
|
||||
)");
|
||||
|
@ -220,11 +220,11 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPong) {
|
|||
data : array<vec4<u32>, 25>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> src : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Buf;
|
||||
@group(0) @binding(0) var<uniform> src : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
|
||||
vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u);
|
||||
}
|
||||
|
@ -288,11 +288,11 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPongInOnePass) {
|
|||
data : array<vec4<u32>, 25>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> src : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Buf;
|
||||
@group(0) @binding(0) var<uniform> src : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
|
||||
vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u);
|
||||
}
|
||||
|
@ -345,9 +345,9 @@ TEST_P(ComputeStorageBufferBarrierTests, IndirectBufferCorrectBarrier) {
|
|||
struct Buf {
|
||||
data : array<u32, 3>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
buf.data = array<u32, 3>(1u, 1u, 1u);
|
||||
}
|
||||
)");
|
||||
|
@ -359,14 +359,14 @@ TEST_P(ComputeStorageBufferBarrierTests, IndirectBufferCorrectBarrier) {
|
|||
struct Buf {
|
||||
data : array<u32, 3>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read> buf : Buf;
|
||||
|
||||
struct Result {
|
||||
data : u32;
|
||||
};
|
||||
[[group(0), binding(1)]] var<storage, read_write> result : Result;
|
||||
@group(0) @binding(1) var<storage, read_write> result : Result;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
result.data = 2u;
|
||||
if (buf.data[0] == 1u && buf.data[1] == 1u && buf.data[2] == 1u) {
|
||||
result.data = 1u;
|
||||
|
|
|
@ -258,16 +258,16 @@ class CopyTextureForBrowserTests : public Parent {
|
|||
struct OutputBuf {
|
||||
result : array<u32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var src : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var dst : texture_2d<f32>;
|
||||
[[group(0), binding(2)]] var<storage, read_write> output : OutputBuf;
|
||||
[[group(0), binding(3)]] var<uniform> uniforms : Uniforms;
|
||||
@group(0) @binding(0) var src : texture_2d<f32>;
|
||||
@group(0) @binding(1) var dst : texture_2d<f32>;
|
||||
@group(0) @binding(2) var<storage, read_write> output : OutputBuf;
|
||||
@group(0) @binding(3) var<uniform> uniforms : Uniforms;
|
||||
fn aboutEqual(value : f32, expect : f32) -> bool {
|
||||
// The value diff should be smaller than the hard coded tolerance.
|
||||
return abs(value - expect) < 0.01;
|
||||
}
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
|
||||
let srcSize = textureDimensions(src);
|
||||
let dstSize = textureDimensions(dst);
|
||||
let dstTexCoord = vec2<u32>(GlobalInvocationID.xy);
|
||||
|
|
|
@ -136,9 +136,9 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateComputePipelineAsync) {
|
|||
struct SSBO {
|
||||
value : u32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : SSBO;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
ssbo.value = 1u;
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main";
|
||||
|
@ -166,9 +166,9 @@ TEST_P(CreatePipelineAsyncTest, ReleaseEntryPointAfterCreatComputePipelineAsync)
|
|||
struct SSBO {
|
||||
value : u32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : SSBO;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
ssbo.value = 1u;
|
||||
})");
|
||||
|
||||
|
@ -205,9 +205,9 @@ TEST_P(CreatePipelineAsyncTest, CreateComputePipelineFailed) {
|
|||
struct SSBO {
|
||||
value : u32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : SSBO;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
ssbo.value = 1u;
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main0";
|
||||
|
@ -239,11 +239,11 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) {
|
|||
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -263,11 +263,11 @@ TEST_P(CreatePipelineAsyncTest, ReleaseEntryPointsAfterCreateRenderPipelineAsync
|
|||
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -328,11 +328,11 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
|
|||
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -366,7 +366,7 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
|
|||
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipelineAsync) {
|
||||
wgpu::ComputePipelineDescriptor csDesc;
|
||||
csDesc.compute.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main";
|
||||
|
||||
|
@ -390,11 +390,11 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipeli
|
|||
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -422,7 +422,7 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelin
|
|||
TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateComputePipelineAsync) {
|
||||
wgpu::ComputePipelineDescriptor csDesc;
|
||||
csDesc.compute.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main";
|
||||
|
||||
|
@ -448,11 +448,11 @@ TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateComputePipeli
|
|||
TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -485,9 +485,9 @@ TEST_P(CreatePipelineAsyncTest, CreateSameComputePipelineTwice) {
|
|||
struct SSBO {
|
||||
value : u32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : SSBO;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
ssbo.value = 1u;
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main";
|
||||
|
@ -544,9 +544,9 @@ TEST_P(CreatePipelineAsyncTest, CreateSameComputePipelineTwiceAtSameTime) {
|
|||
struct SSBO {
|
||||
value : u32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : SSBO;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
ssbo.value = 1u;
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main";
|
||||
|
@ -583,11 +583,11 @@ TEST_P(CreatePipelineAsyncTest, CreateSameRenderPipelineTwiceAtSameTime) {
|
|||
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -635,16 +635,16 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithVertexBufferLayouts
|
|||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
struct VertexInput {
|
||||
[[location(0)]] input0: u32;
|
||||
[[location(1)]] input1: u32;
|
||||
@location(0) input0: u32;
|
||||
@location(1) input1: u32;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
[[location(0)]] vertexColorOut: vec4<f32>;
|
||||
[[builtin(position)]] position: vec4<f32>;
|
||||
@location(0) vertexColorOut: vec4<f32>;
|
||||
@builtin(position) position: vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(vertexInput : VertexInput) -> VertexOutput {
|
||||
var vertexOutput : VertexOutput;
|
||||
vertexOutput.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
|
@ -656,8 +656,8 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithVertexBufferLayouts
|
|||
return vertexOutput;
|
||||
})");
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] fragColorIn : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) fragColorIn : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return fragColorIn;
|
||||
})");
|
||||
|
||||
|
@ -736,13 +736,13 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithDepthStencilState)
|
|||
{
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -808,13 +808,13 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineWithMultisampleState) {
|
|||
{
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -880,17 +880,17 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithBlendState) {
|
|||
{
|
||||
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
|
||||
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
struct FragmentOut {
|
||||
[[location(0)]] fragColor0 : vec4<f32>;
|
||||
[[location(1)]] fragColor1 : vec4<f32>;
|
||||
@location(0) fragColor0 : vec4<f32>;
|
||||
@location(1) fragColor1 : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.fragColor0 = vec4<f32>(0.4, 0.0, 0.0, 0.4);
|
||||
output.fragColor1 = vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
|
|
|
@ -26,8 +26,8 @@ class CullingTest : public DawnTest {
|
|||
// 1. The top-left one is counterclockwise (CCW)
|
||||
// 2. The bottom-right one is clockwise (CW)
|
||||
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>(-1.0, 0.0),
|
||||
|
@ -42,8 +42,8 @@ class CullingTest : public DawnTest {
|
|||
// 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::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(
|
||||
(FragCoord.xy - vec2<f32>(0.5, 0.5)) / vec2<f32>(255.0, 255.0),
|
||||
0.0, 1.0);
|
||||
|
|
|
@ -101,11 +101,11 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
|
|||
mPersistentCache.mIsDisabled = true;
|
||||
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]] fn fragment_main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
@ -142,11 +142,11 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
|
|||
// entrypoints)
|
||||
TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]] fn fragment_main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
@ -181,11 +181,11 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
|
|||
|
||||
// Modify the WGSL shader functions and make sure it doesn't hit.
|
||||
wgpu::ShaderModule newModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]] fn fragment_main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
@ -211,13 +211,13 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPoints) {
|
|||
struct Data {
|
||||
data : u32;
|
||||
};
|
||||
[[binding(0), group(0)]] var<storage, read_write> data : Data;
|
||||
@binding(0) @group(0) var<storage, read_write> data : Data;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn write1() {
|
||||
@stage(compute) @workgroup_size(1) fn write1() {
|
||||
data.data = 1u;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn write42() {
|
||||
@stage(compute) @workgroup_size(1) fn write42() {
|
||||
data.data = 42u;
|
||||
}
|
||||
)");
|
||||
|
|
|
@ -36,8 +36,8 @@ class DepthBiasTests : public DawnTest {
|
|||
case QuadAngle::Flat:
|
||||
// Draw a square at z = 0.25
|
||||
vertexSource = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>( 1.0, -1.0),
|
||||
|
@ -52,8 +52,8 @@ class DepthBiasTests : public DawnTest {
|
|||
case QuadAngle::TiltedX:
|
||||
// Draw a square ranging from 0 to 0.5, bottom to top
|
||||
vertexSource = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec3<f32>, 6>(
|
||||
vec3<f32>(-1.0, -1.0, 0.0),
|
||||
vec3<f32>( 1.0, -1.0, 0.0),
|
||||
|
@ -69,7 +69,7 @@ class DepthBiasTests : public DawnTest {
|
|||
wgpu::ShaderModule vertexModule = utils::CreateShaderModule(device, vertexSource);
|
||||
|
||||
wgpu::ShaderModule fragmentModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -42,8 +42,8 @@ class DepthStencilCopyTests : public DawnTestWithParams<DepthStencilCopyTestPara
|
|||
|
||||
// Draw a square in the bottom left quarter of the screen.
|
||||
mVertexModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>( 0.0, -1.0),
|
||||
|
@ -128,7 +128,7 @@ class DepthStencilCopyTests : public DawnTestWithParams<DepthStencilCopyTestPara
|
|||
desc->vertex.module = mVertexModule;
|
||||
|
||||
std::string fsSource = R"(
|
||||
[[stage(fragment)]] fn main() -> [[builtin(frag_depth)]] f32 {
|
||||
@stage(fragment) fn main() -> @builtin(frag_depth) f32 {
|
||||
return )" + std::to_string(regionDepth) +
|
||||
";\n}";
|
||||
|
||||
|
@ -632,7 +632,7 @@ TEST_P(StencilCopyTests, ToStencilAspect) {
|
|||
utils::ComboRenderPipelineDescriptor renderPipelineDesc;
|
||||
renderPipelineDesc.vertex.module = mVertexModule;
|
||||
renderPipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
wgpu::DepthStencilState* depthStencil =
|
||||
renderPipelineDesc.EnableDepthStencil(GetParam().mTextureFormat);
|
||||
|
|
|
@ -95,11 +95,11 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
|
|||
for (TestAspect aspect : aspects) {
|
||||
switch (aspect) {
|
||||
case TestAspect::Depth:
|
||||
shaderSource << "[[group(0), binding(" << 2 * index << ")]] var tex" << index
|
||||
shaderSource << "@group(0) @binding(" << 2 * index << ") var tex" << index
|
||||
<< " : texture_depth_2d;\n";
|
||||
|
||||
shaderSource << "[[group(0), binding(" << 2 * index + 1
|
||||
<< ")]] var<storage, read_write> result" << index
|
||||
shaderSource << "@group(0) @binding(" << 2 * index + 1
|
||||
<< ") var<storage, read_write> result" << index
|
||||
<< " : DepthResult;\n";
|
||||
|
||||
ASSERT(components.size() == 1 && components[0] == 0);
|
||||
|
@ -107,11 +107,11 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
|
|||
<< ", vec2<i32>(0, 0), 0);";
|
||||
break;
|
||||
case TestAspect::Stencil:
|
||||
shaderSource << "[[group(0), binding(" << 2 * index << ")]] var tex" << index
|
||||
shaderSource << "@group(0) @binding(" << 2 * index << ") var tex" << index
|
||||
<< " : texture_2d<u32>;\n";
|
||||
|
||||
shaderSource << "[[group(0), binding(" << 2 * index + 1
|
||||
<< ")]] var<storage, read_write> result" << index
|
||||
shaderSource << "@group(0) @binding(" << 2 * index + 1
|
||||
<< ") var<storage, read_write> result" << index
|
||||
<< " : StencilResult;\n";
|
||||
|
||||
shaderBody << "var texel = textureLoad(tex" << index
|
||||
|
@ -131,7 +131,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
|
|||
wgpu::RenderPipeline CreateSamplingRenderPipeline(std::vector<TestAspect> aspects,
|
||||
std::vector<uint32_t> components) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -143,7 +143,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
|
|||
|
||||
GenerateSamplingShader(aspects, components, shaderSource, shaderBody);
|
||||
|
||||
shaderSource << "[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {\n";
|
||||
shaderSource << "@stage(fragment) fn main() -> @location(0) vec4<f32> {\n";
|
||||
shaderSource << shaderBody.str() << "return vec4<f32>();\n }";
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, shaderSource.str().c_str());
|
||||
|
@ -161,7 +161,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
|
|||
std::ostringstream shaderBody;
|
||||
GenerateSamplingShader(aspects, components, shaderSource, shaderBody);
|
||||
|
||||
shaderSource << "[[stage(compute), workgroup_size(1)]] fn main() { " << shaderBody.str()
|
||||
shaderSource << "@stage(compute) @workgroup_size(1) fn main() { " << shaderBody.str()
|
||||
<< "\n}";
|
||||
|
||||
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, shaderSource.str().c_str());
|
||||
|
@ -187,19 +187,19 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
|
|||
|
||||
wgpu::RenderPipeline CreateComparisonRenderPipeline() {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var samp : sampler_comparison;
|
||||
[[group(0), binding(1)]] var tex : texture_depth_2d;
|
||||
@group(0) @binding(0) var samp : sampler_comparison;
|
||||
@group(0) @binding(1) var tex : texture_depth_2d;
|
||||
struct Uniforms {
|
||||
compareRef : f32;
|
||||
};
|
||||
[[group(0), binding(2)]] var<uniform> uniforms : Uniforms;
|
||||
@group(0) @binding(2) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] f32 {
|
||||
@stage(fragment) fn main() -> @location(0) f32 {
|
||||
return textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef);
|
||||
})");
|
||||
|
||||
|
@ -214,19 +214,19 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
|
|||
|
||||
wgpu::ComputePipeline CreateComparisonComputePipeline() {
|
||||
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var samp : sampler_comparison;
|
||||
[[group(0), binding(1)]] var tex : texture_depth_2d;
|
||||
@group(0) @binding(0) var samp : sampler_comparison;
|
||||
@group(0) @binding(1) var tex : texture_depth_2d;
|
||||
struct Uniforms {
|
||||
compareRef : f32;
|
||||
};
|
||||
[[group(0), binding(2)]] var<uniform> uniforms : Uniforms;
|
||||
@group(0) @binding(2) var<uniform> uniforms : Uniforms;
|
||||
|
||||
struct SamplerResult {
|
||||
value : f32;
|
||||
};
|
||||
[[group(0), binding(3)]] var<storage, read_write> samplerResult : SamplerResult;
|
||||
@group(0) @binding(3) var<storage, read_write> samplerResult : SamplerResult;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
samplerResult.value = textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef);
|
||||
})");
|
||||
|
||||
|
|
|
@ -60,10 +60,10 @@ class DepthStencilStateTest : public DawnTest {
|
|||
color : vec3<f32>;
|
||||
depth : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> ubo : UBO;
|
||||
@group(0) @binding(0) var<uniform> ubo : UBO;
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
|
@ -79,9 +79,9 @@ class DepthStencilStateTest : public DawnTest {
|
|||
color : vec3<f32>;
|
||||
depth : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> ubo : UBO;
|
||||
@group(0) @binding(0) var<uniform> ubo : UBO;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(ubo.color, 1.0);
|
||||
})");
|
||||
}
|
||||
|
|
|
@ -30,13 +30,13 @@ class DestroyTest : public DawnTest {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -115,8 +115,8 @@ TEST_P(DeviceLostTest, GetBindGroupLayoutFails) {
|
|||
struct UniformBuffer {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> ubo : UniformBuffer;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var<uniform> ubo : UniformBuffer;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
|
||||
wgpu::ComputePipelineDescriptor descriptor;
|
||||
|
@ -199,8 +199,8 @@ TEST_P(DeviceLostTest, CreateShaderModuleFails) {
|
|||
LoseForTesting();
|
||||
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return color;
|
||||
})"));
|
||||
}
|
||||
|
@ -450,7 +450,7 @@ TEST_P(DeviceLostTest, DeviceLostDoesntCallUncapturedError) {
|
|||
// before the callback of Create*PipelineAsync() is called.
|
||||
TEST_P(DeviceLostTest, DeviceLostBeforeCreatePipelineAsyncCallback) {
|
||||
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
|
||||
wgpu::ComputePipelineDescriptor descriptor;
|
||||
|
|
|
@ -28,13 +28,13 @@ class DrawIndexedIndirectTest : public DawnTest {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -143,7 +143,7 @@ TEST_P(DrawIndexedIndirectTest, BaseVertex) {
|
|||
DAWN_TEST_UNSUPPORTED_IF(IsOpenGL());
|
||||
DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
|
||||
|
||||
// TODO(crbug.com/dawn/966): Fails on Metal Intel, likely because [[builtin(vertex_index)]]
|
||||
// TODO(crbug.com/dawn/966): Fails on Metal Intel, likely because @builtin(vertex_index)
|
||||
// doesn't take into account BaseVertex, which breaks programmable vertex pulling.
|
||||
DAWN_SUPPRESS_TEST_IF(IsMetal() && IsIntel());
|
||||
|
||||
|
@ -172,7 +172,7 @@ TEST_P(DrawIndexedIndirectTest, IndirectOffset) {
|
|||
// TODO(crbug.com/dawn/789): Test is failing after a roll on SwANGLE on Windows only.
|
||||
DAWN_SUPPRESS_TEST_IF(IsANGLE() && IsWindows());
|
||||
|
||||
// TODO(crbug.com/dawn/966): Fails on Metal Intel, likely because [[builtin(vertex_index)]]
|
||||
// TODO(crbug.com/dawn/966): Fails on Metal Intel, likely because @builtin(vertex_index)
|
||||
// doesn't take into account BaseVertex, which breaks programmable vertex pulling.
|
||||
DAWN_SUPPRESS_TEST_IF(IsMetal() && IsIntel());
|
||||
|
||||
|
@ -601,9 +601,9 @@ TEST_P(DrawIndexedIndirectTest, ValidateReusedBundleWithChangingParams) {
|
|||
instanceCount: u32;
|
||||
firstIndex: u32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> input: Input;
|
||||
[[group(0), binding(1)]] var<storage, write> params: Params;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var<uniform> input: Input;
|
||||
@group(0) @binding(1) var<storage, write> params: Params;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
params.indexCount = 3u;
|
||||
params.instanceCount = 1u;
|
||||
params.firstIndex = input.firstIndex;
|
||||
|
|
|
@ -27,13 +27,13 @@ class DrawIndexedTest : public DawnTest {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -27,13 +27,13 @@ class DrawIndirectTest : public DawnTest {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -27,13 +27,13 @@ class DrawTest : public DawnTest {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -102,8 +102,8 @@ class DynamicBufferOffsetTests : public DawnTest {
|
|||
|
||||
wgpu::RenderPipeline CreateRenderPipeline(bool isInheritedPipeline = false) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 0.0),
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
|
@ -119,21 +119,21 @@ class DynamicBufferOffsetTests : public DawnTest {
|
|||
value : vec2<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> uBufferNotDynamic : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> sBufferNotDynamic : Buf;
|
||||
[[group(0), binding(3)]] var<uniform> uBuffer : Buf;
|
||||
[[group(0), binding(4)]] var<storage, read_write> sBuffer : Buf;
|
||||
@group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> sBufferNotDynamic : Buf;
|
||||
@group(0) @binding(3) var<uniform> uBuffer : Buf;
|
||||
@group(0) @binding(4) var<storage, read_write> sBuffer : Buf;
|
||||
)";
|
||||
|
||||
if (isInheritedPipeline) {
|
||||
fs << R"(
|
||||
[[group(1), binding(0)]] var<uniform> paddingBlock : Buf;
|
||||
@group(1) @binding(0) var<uniform> paddingBlock : Buf;
|
||||
)";
|
||||
}
|
||||
|
||||
fs << "let multipleNumber : u32 = " << multipleNumber << "u;\n";
|
||||
fs << R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
sBufferNotDynamic.value = uBufferNotDynamic.value.xy;
|
||||
sBuffer.value = vec2<u32>(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy);
|
||||
return vec4<f32>(f32(uBuffer.value.x) / 255.0, f32(uBuffer.value.y) / 255.0,
|
||||
|
@ -169,21 +169,21 @@ class DynamicBufferOffsetTests : public DawnTest {
|
|||
value : vec2<u32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> uBufferNotDynamic : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read_write> sBufferNotDynamic : Buf;
|
||||
[[group(0), binding(3)]] var<uniform> uBuffer : Buf;
|
||||
[[group(0), binding(4)]] var<storage, read_write> sBuffer : Buf;
|
||||
@group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf;
|
||||
@group(0) @binding(1) var<storage, read_write> sBufferNotDynamic : Buf;
|
||||
@group(0) @binding(3) var<uniform> uBuffer : Buf;
|
||||
@group(0) @binding(4) var<storage, read_write> sBuffer : Buf;
|
||||
)";
|
||||
|
||||
if (isInheritedPipeline) {
|
||||
cs << R"(
|
||||
[[group(1), binding(0)]] var<uniform> paddingBlock : Buf;
|
||||
@group(1) @binding(0) var<uniform> paddingBlock : Buf;
|
||||
)";
|
||||
}
|
||||
|
||||
cs << "let multipleNumber : u32 = " << multipleNumber << "u;\n";
|
||||
cs << R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
sBufferNotDynamic.value = uBufferNotDynamic.value.xy;
|
||||
sBuffer.value = vec2<u32>(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy);
|
||||
}
|
||||
|
@ -456,7 +456,7 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
|
|||
struct Src {
|
||||
values : array<vec4<u32>, kArrayLength>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> src : Src;
|
||||
@group(0) @binding(0) var<uniform> src : Src;
|
||||
)";
|
||||
break;
|
||||
case wgpu::BufferUsage::Storage:
|
||||
|
@ -464,7 +464,7 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
|
|||
struct Src {
|
||||
values : array<vec4<u32>>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> src : Src;
|
||||
@group(0) @binding(0) var<storage, read> src : Src;
|
||||
)";
|
||||
break;
|
||||
default:
|
||||
|
@ -475,10 +475,10 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
|
|||
struct Dst {
|
||||
values : array<vec4<u32>>;
|
||||
};
|
||||
[[group(0), binding(1)]] var<storage, read_write> dst : Dst;
|
||||
@group(0) @binding(1) var<storage, read_write> dst : Dst;
|
||||
)";
|
||||
shader << R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
for (var i: u32 = 0u; i < kArrayLength; i = i + 1u) {
|
||||
dst.values[i + kWriteOffset] = src.values[i + kReadOffset];
|
||||
}
|
||||
|
|
|
@ -24,11 +24,11 @@ TEST_P(EntryPointTests, FragAndVertexSameModule) {
|
|||
// TODO(crbug.com/dawn/658): Crashes on bots
|
||||
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]] fn fragment_main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
@ -81,14 +81,14 @@ TEST_P(EntryPointTests, TwoComputeInModule) {
|
|||
struct Data {
|
||||
data : u32;
|
||||
};
|
||||
[[binding(0), group(0)]] var<storage, read_write> data : Data;
|
||||
@binding(0) @group(0) var<storage, read_write> data : Data;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn write1() {
|
||||
@stage(compute) @workgroup_size(1) fn write1() {
|
||||
data.data = 1u;
|
||||
return;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn write42() {
|
||||
@stage(compute) @workgroup_size(1) fn write42() {
|
||||
data.data = 42u;
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ TEST_P(ExternalTextureTests, CreateExternalTextureSuccess) {
|
|||
|
||||
TEST_P(ExternalTextureTests, SampleExternalTexture) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
|
||||
vec4<f32>(-1.0, 1.0, 0.0, 1.0),
|
||||
vec4<f32>(-1.0, -1.0, 0.0, 1.0),
|
||||
|
@ -73,11 +73,11 @@ TEST_P(ExternalTextureTests, SampleExternalTexture) {
|
|||
})");
|
||||
|
||||
const wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var s : sampler;
|
||||
[[group(0), binding(1)]] var t : texture_external;
|
||||
@group(0) @binding(0) var s : sampler;
|
||||
@group(0) @binding(1) var t : texture_external;
|
||||
|
||||
[[stage(fragment)]] fn main([[builtin(position)]] FragCoord : vec4<f32>)
|
||||
-> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(@builtin(position) FragCoord : vec4<f32>)
|
||||
-> @location(0) vec4<f32> {
|
||||
return textureSampleLevel(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0));
|
||||
})");
|
||||
|
||||
|
|
|
@ -92,23 +92,23 @@ void FirstIndexOffsetTests::TestImpl(DrawMode mode,
|
|||
std::stringstream fragmentInputs;
|
||||
std::stringstream fragmentBody;
|
||||
|
||||
vertexInputs << " [[location(0)]] position : vec4<f32>;\n";
|
||||
vertexOutputs << " [[builtin(position)]] position : vec4<f32>;\n";
|
||||
vertexInputs << " @location(0) position : vec4<f32>;\n";
|
||||
vertexOutputs << " @builtin(position) position : vec4<f32>;\n";
|
||||
|
||||
if ((checkIndex & CheckIndex::Vertex) != 0) {
|
||||
vertexInputs << " [[builtin(vertex_index)]] vertex_index : u32;\n";
|
||||
vertexOutputs << " [[location(1), interpolate(flat)]] vertex_index : u32;\n";
|
||||
vertexInputs << " @builtin(vertex_index) vertex_index : u32;\n";
|
||||
vertexOutputs << " @location(1) @interpolate(flat) vertex_index : u32;\n";
|
||||
vertexBody << " output.vertex_index = input.vertex_index;\n";
|
||||
|
||||
fragmentInputs << " [[location(1), interpolate(flat)]] vertex_index : u32;\n";
|
||||
fragmentInputs << " @location(1) @interpolate(flat) vertex_index : u32;\n";
|
||||
fragmentBody << " _ = atomicMin(&idx_vals.vertex_index, input.vertex_index);\n";
|
||||
}
|
||||
if ((checkIndex & CheckIndex::Instance) != 0) {
|
||||
vertexInputs << " [[builtin(instance_index)]] instance_index : u32;\n";
|
||||
vertexOutputs << " [[location(2), interpolate(flat)]] instance_index : u32;\n";
|
||||
vertexInputs << " @builtin(instance_index) instance_index : u32;\n";
|
||||
vertexOutputs << " @location(2) @interpolate(flat) instance_index : u32;\n";
|
||||
vertexBody << " output.instance_index = input.instance_index;\n";
|
||||
|
||||
fragmentInputs << " [[location(2), interpolate(flat)]] instance_index : u32;\n";
|
||||
fragmentInputs << " @location(2) @interpolate(flat) instance_index : u32;\n";
|
||||
fragmentBody << " _ = atomicMin(&idx_vals.instance_index, input.instance_index);\n";
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ struct VertexInputs {
|
|||
struct VertexOutputs {
|
||||
)" + vertexOutputs.str() + R"(
|
||||
};
|
||||
[[stage(vertex)]] fn main(input : VertexInputs) -> VertexOutputs {
|
||||
@stage(vertex) fn main(input : VertexInputs) -> VertexOutputs {
|
||||
var output : VertexOutputs;
|
||||
)" + vertexBody.str() + R"(
|
||||
output.position = input.position;
|
||||
|
@ -131,12 +131,12 @@ struct IndexVals {
|
|||
vertex_index : atomic<u32>;
|
||||
instance_index : atomic<u32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> idx_vals : IndexVals;
|
||||
@group(0) @binding(0) var<storage, read_write> idx_vals : IndexVals;
|
||||
|
||||
struct FragInputs {
|
||||
)" + fragmentInputs.str() + R"(
|
||||
};
|
||||
[[stage(fragment)]] fn main(input : FragInputs) {
|
||||
@stage(fragment) fn main(input : FragInputs) {
|
||||
)" + fragmentBody.str() + R"(
|
||||
})";
|
||||
|
||||
|
@ -165,31 +165,37 @@ struct FragInputs {
|
|||
wgpu::Buffer indices =
|
||||
utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Index, {0});
|
||||
|
||||
const uint32_t bufferInitialVertex = checkIndex & CheckIndex::Vertex ? std::numeric_limits<uint32_t>::max() : 0;
|
||||
const uint32_t bufferInitialInstance = checkIndex & CheckIndex::Instance ? std::numeric_limits<uint32_t>::max() : 0;
|
||||
wgpu::Buffer buffer = utils::CreateBufferFromData(
|
||||
device, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Storage, {bufferInitialVertex, bufferInitialInstance});
|
||||
const uint32_t bufferInitialVertex =
|
||||
checkIndex & CheckIndex::Vertex ? std::numeric_limits<uint32_t>::max() : 0;
|
||||
const uint32_t bufferInitialInstance =
|
||||
checkIndex & CheckIndex::Instance ? std::numeric_limits<uint32_t>::max() : 0;
|
||||
wgpu::Buffer buffer =
|
||||
utils::CreateBufferFromData(device, wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Storage,
|
||||
{bufferInitialVertex, bufferInitialInstance});
|
||||
|
||||
wgpu::Buffer indirectBuffer;
|
||||
switch (mode) {
|
||||
case DrawMode::NonIndexed:
|
||||
case DrawMode::Indexed:
|
||||
break;
|
||||
case DrawMode::NonIndexedIndirect:
|
||||
// With DrawIndirect firstInstance is reserved and must be 0 according to spec.
|
||||
ASSERT_EQ(firstInstance, 0u);
|
||||
indirectBuffer = utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Indirect, {1, 1, firstVertex, firstInstance});
|
||||
break;
|
||||
case DrawMode::IndexedIndirect:
|
||||
// With DrawIndexedIndirect firstInstance is reserved and must be 0 according to spec.
|
||||
ASSERT_EQ(firstInstance, 0u);
|
||||
indirectBuffer = utils::CreateBufferFromData<uint32_t>(device, wgpu::BufferUsage::Indirect, {1, 1, 0, firstVertex, firstInstance});
|
||||
break;
|
||||
default:
|
||||
FAIL();
|
||||
case DrawMode::NonIndexed:
|
||||
case DrawMode::Indexed:
|
||||
break;
|
||||
case DrawMode::NonIndexedIndirect:
|
||||
// With DrawIndirect firstInstance is reserved and must be 0 according to spec.
|
||||
ASSERT_EQ(firstInstance, 0u);
|
||||
indirectBuffer = utils::CreateBufferFromData<uint32_t>(
|
||||
device, wgpu::BufferUsage::Indirect, {1, 1, firstVertex, firstInstance});
|
||||
break;
|
||||
case DrawMode::IndexedIndirect:
|
||||
// With DrawIndexedIndirect firstInstance is reserved and must be 0 according to spec.
|
||||
ASSERT_EQ(firstInstance, 0u);
|
||||
indirectBuffer = utils::CreateBufferFromData<uint32_t>(
|
||||
device, wgpu::BufferUsage::Indirect, {1, 1, 0, firstVertex, firstInstance});
|
||||
break;
|
||||
default:
|
||||
FAIL();
|
||||
}
|
||||
|
||||
wgpu::BindGroup bindGroup = utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, buffer}});
|
||||
wgpu::BindGroup bindGroup =
|
||||
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, buffer}});
|
||||
|
||||
wgpu::CommandEncoder encoder = device.CreateCommandEncoder();
|
||||
wgpu::RenderPassEncoder pass = encoder.BeginRenderPass(&renderPass.renderPassInfo);
|
||||
|
@ -200,22 +206,22 @@ struct FragInputs {
|
|||
// We should only see the values from the second draw.
|
||||
pass.Draw(1, 1, firstVertex + 1, firstInstance + 1);
|
||||
switch (mode) {
|
||||
case DrawMode::NonIndexed:
|
||||
pass.Draw(1, 1, firstVertex, firstInstance);
|
||||
break;
|
||||
case DrawMode::Indexed:
|
||||
pass.SetIndexBuffer(indices, wgpu::IndexFormat::Uint32);
|
||||
pass.DrawIndexed(1, 1, 0, firstVertex, firstInstance);
|
||||
break;
|
||||
case DrawMode::NonIndexedIndirect:
|
||||
pass.DrawIndirect(indirectBuffer, 0);
|
||||
break;
|
||||
case DrawMode::IndexedIndirect:
|
||||
pass.SetIndexBuffer(indices, wgpu::IndexFormat::Uint32);
|
||||
pass.DrawIndexedIndirect(indirectBuffer, 0);
|
||||
break;
|
||||
default:
|
||||
FAIL();
|
||||
case DrawMode::NonIndexed:
|
||||
pass.Draw(1, 1, firstVertex, firstInstance);
|
||||
break;
|
||||
case DrawMode::Indexed:
|
||||
pass.SetIndexBuffer(indices, wgpu::IndexFormat::Uint32);
|
||||
pass.DrawIndexed(1, 1, 0, firstVertex, firstInstance);
|
||||
break;
|
||||
case DrawMode::NonIndexedIndirect:
|
||||
pass.DrawIndirect(indirectBuffer, 0);
|
||||
break;
|
||||
case DrawMode::IndexedIndirect:
|
||||
pass.SetIndexBuffer(indices, wgpu::IndexFormat::Uint32);
|
||||
pass.DrawIndexedIndirect(indirectBuffer, 0);
|
||||
break;
|
||||
default:
|
||||
FAIL();
|
||||
}
|
||||
pass.EndPass();
|
||||
wgpu::CommandBuffer commands = encoder.Finish();
|
||||
|
|
|
@ -39,8 +39,8 @@ class GpuMemorySyncTests : public DawnTest {
|
|||
struct Data {
|
||||
a : i32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> data : Data;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var<storage, read_write> data : Data;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
data.a = data.a + 1;
|
||||
})");
|
||||
|
||||
|
@ -58,7 +58,7 @@ class GpuMemorySyncTests : public DawnTest {
|
|||
const wgpu::Buffer& buffer,
|
||||
wgpu::TextureFormat colorFormat) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -66,8 +66,8 @@ class GpuMemorySyncTests : public DawnTest {
|
|||
struct Data {
|
||||
i : i32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> data : Data;
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@group(0) @binding(0) var<storage, read_write> data : Data;
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
data.i = data.i + 1;
|
||||
return vec4<f32>(f32(data.i) / 255.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
@ -231,8 +231,8 @@ class StorageToUniformSyncTests : public DawnTest {
|
|||
struct Data {
|
||||
a : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> data : Data;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var<storage, read_write> data : Data;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
data.a = 1.0;
|
||||
})");
|
||||
|
||||
|
@ -249,7 +249,7 @@ class StorageToUniformSyncTests : public DawnTest {
|
|||
std::tuple<wgpu::RenderPipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForRender(
|
||||
wgpu::TextureFormat colorFormat) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -257,9 +257,9 @@ class StorageToUniformSyncTests : public DawnTest {
|
|||
struct Contents {
|
||||
color : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> contents : Contents;
|
||||
@group(0) @binding(0) var<uniform> contents : Contents;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(contents.color, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -416,20 +416,20 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
|
|||
struct VBContents {
|
||||
pos : array<vec4<f32>, 4>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> vbContents : VBContents;
|
||||
@group(0) @binding(0) var<storage, read_write> vbContents : VBContents;
|
||||
|
||||
struct IBContents {
|
||||
indices : array<vec4<i32>, 2>;
|
||||
};
|
||||
[[group(0), binding(1)]] var<storage, read_write> ibContents : IBContents;
|
||||
@group(0) @binding(1) var<storage, read_write> ibContents : IBContents;
|
||||
|
||||
struct ColorContents {
|
||||
color : f32;
|
||||
};
|
||||
[[group(0), binding(2)]] var<storage, read_write> uniformContents : ColorContents;
|
||||
[[group(0), binding(3)]] var<storage, read_write> storageContents : ColorContents;
|
||||
@group(0) @binding(2) var<storage, read_write> uniformContents : ColorContents;
|
||||
@group(0) @binding(3) var<storage, read_write> storageContents : ColorContents;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
vbContents.pos[0] = vec4<f32>(-1.0, 1.0, 0.0, 1.0);
|
||||
vbContents.pos[1] = vec4<f32>(1.0, 1.0, 0.0, 1.0);
|
||||
vbContents.pos[2] = vec4<f32>(1.0, -1.0, 0.0, 1.0);
|
||||
|
@ -470,8 +470,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
|
|||
|
||||
// Create pipeline, bind group, and reuse buffers in render pass.
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
|
@ -480,10 +480,10 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
|
|||
color : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> uniformBuffer : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read> storageBuffer : Buf;
|
||||
@group(0) @binding(0) var<uniform> uniformBuffer : Buf;
|
||||
@group(0) @binding(1) var<storage, read> storageBuffer : Buf;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -536,15 +536,15 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
|
|||
// Create pipeline, bind group, and a complex buffer for compute pass.
|
||||
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
|
||||
struct Contents {
|
||||
[[align(256)]] pos : array<vec4<f32>, 4>;
|
||||
[[align(256)]] indices : array<vec4<i32>, 2>;
|
||||
[[align(256)]] color0 : f32;
|
||||
[[align(256)]] color1 : f32;
|
||||
@align(256) pos : array<vec4<f32>, 4>;
|
||||
@align(256) indices : array<vec4<i32>, 2>;
|
||||
@align(256) color0 : f32;
|
||||
@align(256) color1 : f32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> contents : Contents;
|
||||
@group(0) @binding(0) var<storage, read_write> contents : Contents;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
contents.pos[0] = vec4<f32>(-1.0, 1.0, 0.0, 1.0);
|
||||
contents.pos[1] = vec4<f32>(1.0, 1.0, 0.0, 1.0);
|
||||
contents.pos[2] = vec4<f32>(1.0, -1.0, 0.0, 1.0);
|
||||
|
@ -587,8 +587,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
|
|||
|
||||
// Create pipeline, bind group, and reuse the buffer in render pass.
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
|
@ -596,10 +596,10 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
|
|||
struct Buf {
|
||||
color : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniformBuffer : Buf;
|
||||
[[group(0), binding(1)]] var<storage, read> storageBuffer : Buf;
|
||||
@group(0) @binding(0) var<uniform> uniformBuffer : Buf;
|
||||
@group(0) @binding(1) var<storage, read> storageBuffer : Buf;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -249,12 +249,12 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
|
|||
{
|
||||
wgpu::ShaderModule vs = utils::CreateShaderModule(device, R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] texCoord : vec2<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) texCoord : vec2<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-2.0, -2.0),
|
||||
vec2<f32>(-2.0, 2.0),
|
||||
|
@ -278,11 +278,11 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
|
|||
}
|
||||
)");
|
||||
wgpu::ShaderModule fs = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, texCoord);
|
||||
}
|
||||
)");
|
||||
|
|
|
@ -30,15 +30,16 @@ class IndexFormatTest : public DawnTest {
|
|||
|
||||
utils::BasicRenderPass renderPass;
|
||||
|
||||
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format,
|
||||
wgpu::RenderPipeline MakeTestPipeline(
|
||||
wgpu::IndexFormat format,
|
||||
wgpu::PrimitiveTopology primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
struct VertexIn {
|
||||
[[location(0)]] pos : vec4<f32>;
|
||||
[[builtin(vertex_index)]] idx : u32;
|
||||
@location(0) pos : vec4<f32>;
|
||||
@builtin(vertex_index) idx : u32;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main(input : VertexIn) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
|
||||
// 0xFFFFFFFE is a designated invalid index used by some tests.
|
||||
if (input.idx == 0xFFFFFFFEu) {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
|
@ -47,7 +48,7 @@ class IndexFormatTest : public DawnTest {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -38,19 +38,19 @@ TEST_P(MaxLimitTests, MaxComputeWorkgroupStorageSize) {
|
|||
value1 : u32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, write> dst : Dst;
|
||||
@group(0) @binding(0) var<storage, write> dst : Dst;
|
||||
|
||||
struct WGData {
|
||||
value0 : u32;
|
||||
// padding such that value0 and value1 are the first and last bytes of the memory.
|
||||
[[size()" + std::to_string(maxComputeWorkgroupStorageSize / 4 - 2) +
|
||||
R"()]] padding : u32;
|
||||
@size()" + std::to_string(maxComputeWorkgroupStorageSize / 4 - 2) +
|
||||
R"() padding : u32;
|
||||
value1 : u32;
|
||||
};
|
||||
var<workgroup> wg_data : WGData;
|
||||
|
||||
[[stage(compute), workgroup_size(2,1,1)]]
|
||||
fn main([[builtin(local_invocation_index)]] LocalInvocationIndex : u32) {
|
||||
@stage(compute) @workgroup_size(2,1,1)
|
||||
fn main(@builtin(local_invocation_index) LocalInvocationIndex : u32) {
|
||||
if (LocalInvocationIndex == 0u) {
|
||||
// Put data into the first and last byte of workgroup memory.
|
||||
wg_data.value0 = 79u;
|
||||
|
@ -138,10 +138,10 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
|
|||
value1 : u32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> buf : Buf;
|
||||
[[group(0), binding(1)]] var<storage, write> result : Result;
|
||||
@group(0) @binding(0) var<storage, read> buf : Buf;
|
||||
@group(0) @binding(1) var<storage, write> result : Result;
|
||||
|
||||
[[stage(compute), workgroup_size(1,1,1)]]
|
||||
@stage(compute) @workgroup_size(1,1,1)
|
||||
fn main() {
|
||||
result.value0 = buf.values[0];
|
||||
result.value1 = buf.values[arrayLength(&buf.values) - 1u];
|
||||
|
@ -151,7 +151,7 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
|
|||
case wgpu::BufferUsage::Uniform:
|
||||
maxBufferBindingSize = GetSupportedLimits().limits.maxUniformBufferBindingSize;
|
||||
|
||||
// Clamp to not exceed the maximum i32 value for the WGSL [[size(x)]] annotation.
|
||||
// Clamp to not exceed the maximum i32 value for the WGSL @size(x) annotation.
|
||||
maxBufferBindingSize = std::min(maxBufferBindingSize,
|
||||
uint64_t(std::numeric_limits<int32_t>::max()) + 8);
|
||||
|
||||
|
@ -159,8 +159,8 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
|
|||
struct Buf {
|
||||
value0 : u32;
|
||||
// padding such that value0 and value1 are the first and last bytes of the memory.
|
||||
[[size()" +
|
||||
std::to_string(maxBufferBindingSize - 8) + R"()]] padding : u32;
|
||||
@size()" +
|
||||
std::to_string(maxBufferBindingSize - 8) + R"() padding : u32;
|
||||
value1 : u32;
|
||||
};
|
||||
|
||||
|
@ -169,10 +169,10 @@ TEST_P(MaxLimitTests, MaxBufferBindingSize) {
|
|||
value1 : u32;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> buf : Buf;
|
||||
[[group(0), binding(1)]] var<storage, write> result : Result;
|
||||
@group(0) @binding(0) var<uniform> buf : Buf;
|
||||
@group(0) @binding(1) var<storage, write> result : Result;
|
||||
|
||||
[[stage(compute), workgroup_size(1,1,1)]]
|
||||
@stage(compute) @workgroup_size(1,1,1)
|
||||
fn main() {
|
||||
result.value0 = buf.value0;
|
||||
result.value1 = buf.value1;
|
||||
|
|
|
@ -49,14 +49,14 @@ class MultisampledRenderingTest : public DawnTest {
|
|||
color : vec4<f32>;
|
||||
depth : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uBuffer : U;
|
||||
@group(0) @binding(0) var<uniform> uBuffer : U;
|
||||
|
||||
struct FragmentOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(frag_depth)]] depth : f32;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(frag_depth) depth : f32;
|
||||
};
|
||||
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.color = uBuffer.color;
|
||||
output.depth = uBuffer.depth;
|
||||
|
@ -67,9 +67,9 @@ class MultisampledRenderingTest : public DawnTest {
|
|||
struct U {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uBuffer : U;
|
||||
@group(0) @binding(0) var<uniform> uBuffer : U;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return uBuffer.color;
|
||||
})";
|
||||
|
||||
|
@ -87,14 +87,14 @@ class MultisampledRenderingTest : public DawnTest {
|
|||
color0 : vec4<f32>;
|
||||
color1 : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uBuffer : U;
|
||||
@group(0) @binding(0) var<uniform> uBuffer : U;
|
||||
|
||||
struct FragmentOut {
|
||||
[[location(0)]] color0 : vec4<f32>;
|
||||
[[location(1)]] color1 : vec4<f32>;
|
||||
@location(0) color0 : vec4<f32>;
|
||||
@location(1) color1 : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.color0 = uBuffer.color0;
|
||||
output.color1 = uBuffer.color1;
|
||||
|
@ -223,8 +223,8 @@ class MultisampledRenderingTest : public DawnTest {
|
|||
// Draw a bottom-right triangle. In standard 4xMSAA pattern, for the pixels on diagonal,
|
||||
// only two of the samples will be touched.
|
||||
const char* vs = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -235,8 +235,8 @@ class MultisampledRenderingTest : public DawnTest {
|
|||
|
||||
// Draw a bottom-left triangle.
|
||||
const char* vsFlipped = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -780,14 +780,14 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOut
|
|||
struct U {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uBuffer : U;
|
||||
@group(0) @binding(0) var<uniform> uBuffer : U;
|
||||
|
||||
struct FragmentOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(sample_mask)]] sampleMask : u32;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(sample_mask) sampleMask : u32;
|
||||
};
|
||||
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.color = uBuffer.color;
|
||||
output.sampleMask = 6u;
|
||||
|
@ -842,15 +842,15 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOut
|
|||
color0 : vec4<f32>;
|
||||
color1 : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uBuffer : U;
|
||||
@group(0) @binding(0) var<uniform> uBuffer : U;
|
||||
|
||||
struct FragmentOut {
|
||||
[[location(0)]] color0 : vec4<f32>;
|
||||
[[location(1)]] color1 : vec4<f32>;
|
||||
[[builtin(sample_mask)]] sampleMask : u32;
|
||||
@location(0) color0 : vec4<f32>;
|
||||
@location(1) color1 : vec4<f32>;
|
||||
@builtin(sample_mask) sampleMask : u32;
|
||||
};
|
||||
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.color0 = uBuffer.color0;
|
||||
output.color1 = uBuffer.color1;
|
||||
|
|
|
@ -57,18 +57,18 @@ class MultisampledSamplingTest : public DawnTest {
|
|||
utils::ComboRenderPipelineDescriptor desc;
|
||||
|
||||
desc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec2<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(pos, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
desc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
struct FragmentOut {
|
||||
[[location(0)]] color : f32;
|
||||
[[builtin(frag_depth)]] depth : f32;
|
||||
@location(0) color : f32;
|
||||
@builtin(frag_depth) depth : f32;
|
||||
};
|
||||
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.color = 1.0;
|
||||
output.depth = 0.7;
|
||||
|
@ -96,16 +96,16 @@ class MultisampledSamplingTest : public DawnTest {
|
|||
wgpu::ComputePipelineDescriptor desc = {};
|
||||
desc.compute.entryPoint = "main";
|
||||
desc.compute.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var texture0 : texture_multisampled_2d<f32>;
|
||||
[[group(0), binding(1)]] var texture1 : texture_depth_multisampled_2d;
|
||||
@group(0) @binding(0) var texture0 : texture_multisampled_2d<f32>;
|
||||
@group(0) @binding(1) var texture1 : texture_depth_multisampled_2d;
|
||||
|
||||
struct Results {
|
||||
colorSamples : array<f32, 4>;
|
||||
depthSamples : array<f32, 4>;
|
||||
};
|
||||
[[group(0), binding(2)]] var<storage, read_write> results : Results;
|
||||
@group(0) @binding(2) var<storage, read_write> results : Results;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
for (var i : i32 = 0; i < 4; i = i + 1) {
|
||||
results.colorSamples[i] = textureLoad(texture0, vec2<i32>(0, 0), i).x;
|
||||
results.depthSamples[i] = textureLoad(texture1, vec2<i32>(0, 0), i);
|
||||
|
|
|
@ -104,15 +104,15 @@ TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
|
|||
// Test that ShaderModules are correctly deduplicated.
|
||||
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
|
||||
|
@ -124,16 +124,16 @@ TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
|
|||
TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnShaderModule) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
var<workgroup> i : u32;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
i = 0u;
|
||||
})");
|
||||
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
|
||||
var<workgroup> i : u32;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
i = 0u;
|
||||
})");
|
||||
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
|
||||
EXPECT_NE(module.Get(), otherModule.Get());
|
||||
|
@ -176,7 +176,7 @@ TEST_P(ObjectCachingTest, ComputePipelineDeduplicationOnLayout) {
|
|||
desc.compute.entryPoint = "main";
|
||||
desc.compute.module = utils::CreateShaderModule(device, R"(
|
||||
var<workgroup> i : u32;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
i = 0u;
|
||||
})");
|
||||
|
||||
|
@ -210,11 +210,11 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
|
|||
utils::ComboRenderPipelineDescriptor desc;
|
||||
desc.cTargets[0].writeMask = wgpu::ColorWriteMask::None;
|
||||
desc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
desc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
|
||||
desc.layout = pl;
|
||||
|
@ -233,15 +233,15 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
|
|||
// Test that RenderPipelines are correctly deduplicated wrt. their vertex module
|
||||
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -251,7 +251,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
|
|||
utils::ComboRenderPipelineDescriptor desc;
|
||||
desc.cTargets[0].writeMask = wgpu::ColorWriteMask::None;
|
||||
desc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
|
||||
desc.vertex.module = module;
|
||||
|
@ -270,13 +270,13 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnVertexModule) {
|
|||
// Test that RenderPipelines are correctly deduplicated wrt. their fragment module
|
||||
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
|
||||
|
@ -285,7 +285,7 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
|
|||
|
||||
utils::ComboRenderPipelineDescriptor desc;
|
||||
desc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -54,14 +54,14 @@ class OpArrayLengthTest : public DawnTest {
|
|||
// 0.
|
||||
mShaderInterface = R"(
|
||||
struct DataBuffer {
|
||||
data : [[stride(4)]] array<f32>;
|
||||
data : @stride(4) array<f32>;
|
||||
};
|
||||
|
||||
// The length should be 1 because the buffer is 4-byte long.
|
||||
[[group(0), binding(0)]] var<storage, read> buffer1 : DataBuffer;
|
||||
@group(0) @binding(0) var<storage, read> buffer1 : DataBuffer;
|
||||
|
||||
// The length should be 64 because the buffer is 256 bytes long.
|
||||
[[group(0), binding(1)]] var<storage, read> buffer2 : DataBuffer;
|
||||
@group(0) @binding(1) var<storage, read> buffer2 : DataBuffer;
|
||||
|
||||
// The length should be (512 - 16*4) / 8 = 56 because the buffer is 512 bytes long
|
||||
// and the structure is 8 bytes big.
|
||||
|
@ -71,10 +71,10 @@ class OpArrayLengthTest : public DawnTest {
|
|||
};
|
||||
|
||||
struct Buffer3 {
|
||||
[[size(64)]] garbage : mat4x4<f32>;
|
||||
data : [[stride(8)]] array<Buffer3Data>;
|
||||
@size(64) garbage : mat4x4<f32>;
|
||||
data : @stride(8) array<Buffer3Data>;
|
||||
};
|
||||
[[group(0), binding(2)]] var<storage, read> buffer3 : Buffer3;
|
||||
@group(0) @binding(2) var<storage, read> buffer3 : Buffer3;
|
||||
)";
|
||||
|
||||
// See comments in the shader for an explanation of these values
|
||||
|
@ -121,11 +121,11 @@ TEST_P(OpArrayLengthTest, Compute) {
|
|||
pipelineDesc.compute.entryPoint = "main";
|
||||
pipelineDesc.compute.module = utils::CreateShaderModule(device, (R"(
|
||||
struct ResultBuffer {
|
||||
data : [[stride(4)]] array<u32, 3>;
|
||||
data : @stride(4) array<u32, 3>;
|
||||
};
|
||||
[[group(1), binding(0)]] var<storage, read_write> result : ResultBuffer;
|
||||
@group(1) @binding(0) var<storage, read_write> result : ResultBuffer;
|
||||
)" + mShaderInterface + R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
result.data[0] = arrayLength(&buffer1.data);
|
||||
result.data[1] = arrayLength(&buffer2.data);
|
||||
result.data[2] = arrayLength(&buffer3.data);
|
||||
|
@ -159,12 +159,12 @@ 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::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, (mShaderInterface + R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
var fragColor : vec4<f32>;
|
||||
fragColor.r = f32(arrayLength(&buffer1.data)) / 255.0;
|
||||
fragColor.g = f32(arrayLength(&buffer2.data)) / 255.0;
|
||||
|
@ -212,11 +212,11 @@ TEST_P(OpArrayLengthTest, Vertex) {
|
|||
// pass pixel.
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, (mShaderInterface + R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main() -> VertexOut {
|
||||
@stage(vertex) fn main() -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.color.r = f32(arrayLength(&buffer1.data)) / 255.0;
|
||||
output.color.g = f32(arrayLength(&buffer2.data)) / 255.0;
|
||||
|
@ -229,8 +229,8 @@ TEST_P(OpArrayLengthTest, Vertex) {
|
|||
.c_str());
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return color;
|
||||
})");
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ class DepthClampingTest : public DawnTest {
|
|||
color : vec3<f32>;
|
||||
depth : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> ubo : UBO;
|
||||
@group(0) @binding(0) var<uniform> ubo : UBO;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, ubo.depth, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -60,9 +60,9 @@ class DepthClampingTest : public DawnTest {
|
|||
color : vec3<f32>;
|
||||
depth : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> ubo : UBO;
|
||||
@group(0) @binding(0) var<uniform> ubo : UBO;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(ubo.color, 1.0);
|
||||
})");
|
||||
}
|
||||
|
@ -122,8 +122,8 @@ class DepthClampingTest : public DawnTest {
|
|||
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);
|
||||
|
||||
// Create a bind group for the data
|
||||
wgpu::BindGroup bindGroup = utils::MakeBindGroup(
|
||||
device, pipeline.GetBindGroupLayout(0), {{0, buffer}});
|
||||
wgpu::BindGroup bindGroup =
|
||||
utils::MakeBindGroup(device, pipeline.GetBindGroupLayout(0), {{0, buffer}});
|
||||
|
||||
pass.SetPipeline(pipeline);
|
||||
pass.SetBindGroup(0, bindGroup);
|
||||
|
@ -134,7 +134,7 @@ class DepthClampingTest : public DawnTest {
|
|||
wgpu::CommandBuffer commands = encoder.Finish();
|
||||
queue.Submit(1, &commands);
|
||||
|
||||
EXPECT_PIXEL_RGBA8_EQ(expected, renderTarget, 0, 0) << "Pixel check failed";
|
||||
EXPECT_PIXEL_RGBA8_EQ(expected, renderTarget, 0, 0) << "Pixel check failed";
|
||||
}
|
||||
|
||||
wgpu::Texture renderTarget;
|
||||
|
@ -154,16 +154,16 @@ TEST_P(DepthClampingTest, ClampOnBeyondFarPlane) {
|
|||
{
|
||||
// Draw a red triangle at depth 1.
|
||||
{
|
||||
nullptr, /* depthClampingState */
|
||||
nullptr, /* depthClampingState */
|
||||
RGBA8(255, 0, 0, 255), /* color */
|
||||
1.f, /* depth */
|
||||
1.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
// Draw a green triangle at depth 2 which should get clamped to 1.
|
||||
{
|
||||
&clampingState,
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
2.f, /* depth */
|
||||
2.f, /* depth */
|
||||
wgpu::CompareFunction::Equal,
|
||||
},
|
||||
},
|
||||
|
@ -181,16 +181,16 @@ TEST_P(DepthClampingTest, ClampOnBeyondNearPlane) {
|
|||
{
|
||||
// Draw a red triangle at depth 0.
|
||||
{
|
||||
nullptr, /* depthClampingState */
|
||||
nullptr, /* depthClampingState */
|
||||
RGBA8(255, 0, 0, 255), /* color */
|
||||
0.f, /* depth */
|
||||
0.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
// Draw a green triangle at depth -1 which should get clamped to 0.
|
||||
{
|
||||
&clampingState,
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
-1.f, /* depth */
|
||||
-1.f, /* depth */
|
||||
wgpu::CompareFunction::Equal,
|
||||
},
|
||||
},
|
||||
|
@ -209,14 +209,13 @@ TEST_P(DepthClampingTest, ClampOnInsideViewFrustum) {
|
|||
{
|
||||
&clampingState,
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
0.5f, /* depth */
|
||||
0.5f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
},
|
||||
RGBA8(0, 255, 0, 255));
|
||||
}
|
||||
|
||||
|
||||
// Test that fragments outside the view frustum are clipped if depth clamping is disabled.
|
||||
TEST_P(DepthClampingTest, ClampOffOutsideViewFrustum) {
|
||||
wgpu::PrimitiveDepthClampingState clampingState;
|
||||
|
@ -227,13 +226,13 @@ TEST_P(DepthClampingTest, ClampOffOutsideViewFrustum) {
|
|||
{
|
||||
&clampingState,
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
2.f, /* depth */
|
||||
2.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
{
|
||||
&clampingState,
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
-1.f, /* depth */
|
||||
-1.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
},
|
||||
|
@ -245,15 +244,15 @@ TEST_P(DepthClampingTest, ClampUnspecifiedOutsideViewFrustum) {
|
|||
DoTest(
|
||||
{
|
||||
{
|
||||
nullptr, /* depthClampingState */
|
||||
nullptr, /* depthClampingState */
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
-1.f, /* depth */
|
||||
-1.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
{
|
||||
nullptr, /* depthClampingState */
|
||||
nullptr, /* depthClampingState */
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
2.f, /* depth */
|
||||
2.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
},
|
||||
|
@ -275,18 +274,18 @@ TEST_P(DepthClampingTest, MultipleRenderPipelines) {
|
|||
{
|
||||
&clampingState,
|
||||
RGBA8(0, 255, 0, 255), /* color */
|
||||
2.f, /* depth */
|
||||
2.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
// Draw red with clipping
|
||||
{
|
||||
&clippingState,
|
||||
RGBA8(255, 0, 0, 255), /* color */
|
||||
2.f, /* depth */
|
||||
2.f, /* depth */
|
||||
wgpu::CompareFunction::Always,
|
||||
},
|
||||
},
|
||||
RGBA8(0, 255, 0, 255)); // Result should be green
|
||||
RGBA8(0, 255, 0, 255)); // Result should be green
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(DepthClampingTest,
|
||||
|
|
|
@ -154,13 +154,13 @@ class PrimitiveTopologyTest : public DawnTest {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -78,8 +78,8 @@ class OcclusionQueryTests : public QueryTests {
|
|||
|
||||
// Create basic render pipeline
|
||||
vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
|
@ -88,7 +88,7 @@ class OcclusionQueryTests : public QueryTests {
|
|||
})");
|
||||
|
||||
fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -72,8 +72,8 @@ class ReadOnlyDepthStencilAttachmentTests
|
|||
// and pass the depth test, and sample from the depth buffer in fragment shader in the same
|
||||
// pipeline.
|
||||
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec3<f32>, 6>(
|
||||
vec3<f32>(-1.0, 1.0, 0.4),
|
||||
vec3<f32>(-1.0, -1.0, 0.0),
|
||||
|
@ -87,27 +87,27 @@ class ReadOnlyDepthStencilAttachmentTests
|
|||
if (!sampleFromAttachment) {
|
||||
// Draw a solid blue into color buffer if not sample from depth/stencil attachment.
|
||||
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 1.0, 0.0);
|
||||
})");
|
||||
} else {
|
||||
// Sample from depth/stencil attachment and draw that sampled texel into color buffer.
|
||||
if (aspect == wgpu::TextureAspect::DepthOnly) {
|
||||
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var samp : sampler;
|
||||
[[group(0), binding(1)]] var tex : texture_depth_2d;
|
||||
@group(0) @binding(0) var samp : sampler;
|
||||
@group(0) @binding(1) var tex : texture_depth_2d;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(textureSample(tex, samp, FragCoord.xy), 0.0, 0.0, 0.0);
|
||||
})");
|
||||
} else {
|
||||
ASSERT(aspect == wgpu::TextureAspect::StencilOnly);
|
||||
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var tex : texture_2d<u32>;
|
||||
@group(0) @binding(0) var tex : texture_2d<u32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
var texel = textureLoad(tex, vec2<i32>(FragCoord.xy), 0);
|
||||
return vec4<f32>(f32(texel[0]) / 255.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
|
|
|
@ -23,20 +23,20 @@ class RenderAttachmentTest : public DawnTest {};
|
|||
// There should be no backend validation errors or indexing out-of-bounds.
|
||||
TEST_P(RenderAttachmentTest, MoreFragmentOutputsThanAttachments) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
struct Output {
|
||||
[[location(0)]] color0 : vec4<f32>;
|
||||
[[location(1)]] color1 : vec4<f32>;
|
||||
[[location(2)]] color2 : vec4<f32>;
|
||||
[[location(3)]] color3 : vec4<f32>;
|
||||
@location(0) color0 : vec4<f32>;
|
||||
@location(1) color1 : vec4<f32>;
|
||||
@location(2) color2 : vec4<f32>;
|
||||
@location(3) color3 : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]]
|
||||
@stage(fragment)
|
||||
fn main() -> Output {
|
||||
var output : Output;
|
||||
output.color0 = vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
|
|
|
@ -32,8 +32,8 @@ class RenderBundleTest : public DawnTest {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
|
@ -41,9 +41,9 @@ class RenderBundleTest : public DawnTest {
|
|||
struct Ubo {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> fragmentUniformBuffer : Ubo;
|
||||
@group(0) @binding(0) var<uniform> fragmentUniformBuffer : Ubo;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return fragmentUniformBuffer.color;
|
||||
})");
|
||||
|
||||
|
|
|
@ -77,8 +77,8 @@ class RenderPassLoadOpTests : public DawnTest {
|
|||
|
||||
// draws a blue quad on the right half of the screen
|
||||
const char* vsSource = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>( 0.0, -1.0),
|
||||
vec2<f32>( 1.0, -1.0),
|
||||
|
@ -91,7 +91,7 @@ class RenderPassLoadOpTests : public DawnTest {
|
|||
})";
|
||||
|
||||
const char* fsSource = R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 1.0, 1.0);
|
||||
})";
|
||||
blueQuad = DrawQuad(device, vsSource, fsSource);
|
||||
|
|
|
@ -27,8 +27,8 @@ class RenderPassTest : public DawnTest {
|
|||
|
||||
// Shaders to draw a bottom-left triangle in blue.
|
||||
mVSModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, -1.0),
|
||||
|
@ -38,7 +38,7 @@ class RenderPassTest : public DawnTest {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 1.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -138,7 +138,7 @@ TEST_P(RenderPassTest, NoCorrespondingFragmentShaderOutputs) {
|
|||
{
|
||||
// Next we use a pipeline whose fragment shader has no outputs.
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
utils::ComboRenderPipelineDescriptor descriptor;
|
||||
descriptor.vertex.module = mVSModule;
|
||||
|
|
|
@ -43,18 +43,18 @@ class SamplerFilterAnisotropicTest : public DawnTest {
|
|||
};
|
||||
|
||||
struct VertexIn {
|
||||
[[location(0)]] position : vec4<f32>;
|
||||
[[location(1)]] uv : vec2<f32>;
|
||||
@location(0) position : vec4<f32>;
|
||||
@location(1) uv : vec2<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(2)]] var<uniform> uniforms : Uniforms;
|
||||
@group(0) @binding(2) var<uniform> uniforms : Uniforms;
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] uv : vec2<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) uv : vec2<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(input : VertexIn) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.uv = input.uv;
|
||||
|
@ -63,16 +63,16 @@ class SamplerFilterAnisotropicTest : public DawnTest {
|
|||
}
|
||||
)");
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : texture_2d<f32>;
|
||||
|
||||
struct FragmentIn {
|
||||
[[location(0)]] uv: vec2<f32>;
|
||||
[[builtin(position)]] fragCoord : vec4<f32>;
|
||||
@location(0) uv: vec2<f32>;
|
||||
@builtin(position) fragCoord : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main(input : FragmentIn) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(input : FragmentIn) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, input.uv);
|
||||
})");
|
||||
|
||||
|
|
|
@ -55,8 +55,8 @@ class SamplerTest : public DawnTest {
|
|||
mRenderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
auto vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-2.0, -2.0),
|
||||
vec2<f32>(-2.0, 2.0),
|
||||
|
@ -68,11 +68,11 @@ class SamplerTest : public DawnTest {
|
|||
}
|
||||
)");
|
||||
auto fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, FragCoord.xy / vec2<f32>(2.0, 2.0));
|
||||
})");
|
||||
|
||||
|
|
|
@ -21,8 +21,8 @@ class ScissorTest : public DawnTest {
|
|||
protected:
|
||||
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
|
@ -34,7 +34,7 @@ class ScissorTest : public DawnTest {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -54,9 +54,9 @@ struct Buf {
|
|||
data : array<u32, 19>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
let factor : f32 = 1.0001;
|
||||
|
||||
buf.data[0] = u32(log2(1.0 * factor));
|
||||
|
@ -115,8 +115,8 @@ I am an invalid shader and should never pass validation!
|
|||
// can compile and link successfully.
|
||||
TEST_P(ShaderTests, WGSLParamIO) {
|
||||
std::string vertexShader = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -126,8 +126,8 @@ fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] ve
|
|||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str());
|
||||
|
||||
std::string fragmentShader = R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] fragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) fragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(fragCoord.xy, 0.0, 1.0);
|
||||
})";
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
|
||||
|
@ -143,16 +143,16 @@ fn main([[builtin(position)]] fragCoord : vec4<f32>) -> [[location(0)]] vec4<f32
|
|||
TEST_P(ShaderTests, WGSLMixedStructParamIO) {
|
||||
std::string vertexShader = R"(
|
||||
struct VertexIn {
|
||||
[[location(0)]] position : vec3<f32>;
|
||||
[[location(1)]] color : vec4<f32>;
|
||||
@location(0) position : vec3<f32>;
|
||||
@location(1) color : vec4<f32>;
|
||||
};
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(input : VertexIn) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.position = vec4<f32>(input.position, 1.0);
|
||||
|
@ -162,8 +162,8 @@ fn main(input : VertexIn) -> VertexOut {
|
|||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str());
|
||||
|
||||
std::string fragmentShader = R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return color;
|
||||
})";
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
|
||||
|
@ -186,16 +186,16 @@ fn main([[location(0)]] color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
|||
TEST_P(ShaderTests, WGSLStructIO) {
|
||||
std::string vertexShader = R"(
|
||||
struct VertexIn {
|
||||
[[location(0)]] position : vec3<f32>;
|
||||
[[location(1)]] color : vec4<f32>;
|
||||
@location(0) position : vec3<f32>;
|
||||
@location(1) color : vec4<f32>;
|
||||
};
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(input : VertexIn) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.position = vec4<f32>(input.position, 1.0);
|
||||
|
@ -206,12 +206,12 @@ fn main(input : VertexIn) -> VertexOut {
|
|||
|
||||
std::string fragmentShader = R"(
|
||||
struct FragmentIn {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] fragCoord : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) fragCoord : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main(input : FragmentIn) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(input : FragmentIn) -> @location(0) vec4<f32> {
|
||||
return input.color * input.fragCoord;
|
||||
})";
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
|
||||
|
@ -233,16 +233,16 @@ fn main(input : FragmentIn) -> [[location(0)]] vec4<f32> {
|
|||
TEST_P(ShaderTests, WGSLUnsortedStructIO) {
|
||||
std::string vertexShader = R"(
|
||||
struct VertexIn {
|
||||
[[location(0)]] position : vec3<f32>;
|
||||
[[location(1)]] color : vec4<f32>;
|
||||
@location(0) position : vec3<f32>;
|
||||
@location(1) color : vec4<f32>;
|
||||
};
|
||||
|
||||
struct VertexOut {
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(input : VertexIn) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.position = vec4<f32>(input.position, 1.0);
|
||||
|
@ -253,12 +253,12 @@ fn main(input : VertexIn) -> VertexOut {
|
|||
|
||||
std::string fragmentShader = R"(
|
||||
struct FragmentIn {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] fragCoord : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) fragCoord : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main(input : FragmentIn) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(input : FragmentIn) -> @location(0) vec4<f32> {
|
||||
return input.color * input.fragCoord;
|
||||
})";
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
|
||||
|
@ -280,16 +280,16 @@ fn main(input : FragmentIn) -> [[location(0)]] vec4<f32> {
|
|||
TEST_P(ShaderTests, WGSLSharedStructIO) {
|
||||
std::string shader = R"(
|
||||
struct VertexIn {
|
||||
[[location(0)]] position : vec3<f32>;
|
||||
[[location(1)]] color : vec4<f32>;
|
||||
@location(0) position : vec3<f32>;
|
||||
@location(1) color : vec4<f32>;
|
||||
};
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn vertexMain(input : VertexIn) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.position = vec4<f32>(input.position, 1.0);
|
||||
|
@ -297,8 +297,8 @@ fn vertexMain(input : VertexIn) -> VertexOut {
|
|||
return output;
|
||||
}
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn fragmentMain(input : VertexOut) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn fragmentMain(input : VertexOut) -> @location(0) vec4<f32> {
|
||||
return input.color;
|
||||
})";
|
||||
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, shader.c_str());
|
||||
|
@ -329,21 +329,21 @@ TEST_P(ShaderTests, FirstIndexOffsetRegisterConflictInHLSLTransforms) {
|
|||
// Dumped WGSL:
|
||||
|
||||
struct Inputs {
|
||||
[[location(1)]] attrib1 : u32;
|
||||
@location(1) attrib1 : u32;
|
||||
// The extra register added to handle base_vertex for vertex_index conflicts with [1]
|
||||
[[builtin(vertex_index)]] vertexIndex: u32;
|
||||
@builtin(vertex_index) vertexIndex: u32;
|
||||
};
|
||||
|
||||
// [1] a binding point that conflicts with the regitster
|
||||
struct S1 { data : array<vec4<u32>, 20>; };
|
||||
[[group(0), binding(1)]] var<uniform> providedData1 : S1;
|
||||
@group(0) @binding(1) var<uniform> providedData1 : S1;
|
||||
|
||||
[[stage(vertex)]] fn vsMain(input : Inputs) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vsMain(input : Inputs) -> @builtin(position) vec4<f32> {
|
||||
_ = providedData1.data[input.vertexIndex][0];
|
||||
return vec4<f32>();
|
||||
}
|
||||
|
||||
[[stage(fragment)]] fn fsMain() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn fsMain() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)";
|
||||
|
@ -362,17 +362,17 @@ struct S1 { data : array<vec4<u32>, 20>; };
|
|||
device.CreateRenderPipeline(&rpDesc);
|
||||
}
|
||||
|
||||
// Test that WGSL built-in variable [[sample_index]] can be used in fragment shaders.
|
||||
// Test that WGSL built-in variable @sample_index can be used in fragment shaders.
|
||||
TEST_P(ShaderTests, SampleIndex) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main([[builtin(sample_index)]] sampleIndex : u32)
|
||||
-> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(@builtin(sample_index) sampleIndex : u32)
|
||||
-> @location(0) vec4<f32> {
|
||||
return vec4<f32>(f32(sampleIndex), 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -400,25 +400,25 @@ TEST_P(ShaderTests, OverridableConstants) {
|
|||
wgpu::Buffer buffer = CreateBuffer(kCount);
|
||||
|
||||
std::string shader = R"(
|
||||
[[override]] let c0: bool; // type: bool
|
||||
[[override]] let c1: bool = false; // default override
|
||||
[[override]] let c2: f32; // type: float32
|
||||
[[override]] let c3: f32 = 0.0; // default override
|
||||
[[override]] let c4: f32 = 4.0; // default
|
||||
[[override]] let c5: i32; // type: int32
|
||||
[[override]] let c6: i32 = 0; // default override
|
||||
[[override]] let c7: i32 = 7; // default
|
||||
[[override]] let c8: u32; // type: uint32
|
||||
[[override]] let c9: u32 = 0u; // default override
|
||||
[[override]] let c10: u32 = 10u; // default
|
||||
@override let c0: bool; // type: bool
|
||||
@override let c1: bool = false; // default override
|
||||
@override let c2: f32; // type: float32
|
||||
@override let c3: f32 = 0.0; // default override
|
||||
@override let c4: f32 = 4.0; // default
|
||||
@override let c5: i32; // type: int32
|
||||
@override let c6: i32 = 0; // default override
|
||||
@override let c7: i32 = 7; // default
|
||||
@override let c8: u32; // type: uint32
|
||||
@override let c9: u32 = 0u; // default override
|
||||
@override let c10: u32 = 10u; // default
|
||||
|
||||
struct Buf {
|
||||
data : array<u32, 11>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
buf.data[0] = u32(c0);
|
||||
buf.data[1] = u32(c1);
|
||||
buf.data[2] = u32(c2);
|
||||
|
@ -477,18 +477,18 @@ TEST_P(ShaderTests, OverridableConstantsNumericIdentifiers) {
|
|||
wgpu::Buffer buffer = CreateBuffer(kCount);
|
||||
|
||||
std::string shader = R"(
|
||||
[[override(1001)]] let c1: u32; // some big numeric id
|
||||
[[override(1)]] let c2: u32 = 0u; // id == 1 might collide with some generated constant id
|
||||
[[override(1003)]] let c3: u32 = 3u; // default
|
||||
[[override(1004)]] let c4: u32; // default unspecified
|
||||
@override(1001) let c1: u32; // some big numeric id
|
||||
@override(1) let c2: u32 = 0u; // id == 1 might collide with some generated constant id
|
||||
@override(1003) let c3: u32 = 3u; // default
|
||||
@override(1004) let c4: u32; // default unspecified
|
||||
|
||||
struct Buf {
|
||||
data : array<u32, 4>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
buf.data[0] = c1;
|
||||
buf.data[1] = c2;
|
||||
buf.data[2] = c3;
|
||||
|
@ -536,16 +536,16 @@ TEST_P(ShaderTests, OverridableConstantsPrecision) {
|
|||
wgpu::Buffer buffer = CreateBuffer(kCount);
|
||||
|
||||
std::string shader = R"(
|
||||
[[override(1001)]] let c1: f32;
|
||||
[[override(1002)]] let c2: f32;
|
||||
@override(1001) let c1: f32;
|
||||
@override(1002) let c2: f32;
|
||||
|
||||
struct Buf {
|
||||
data : array<f32, 2>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
buf.data[0] = c1;
|
||||
buf.data[1] = c2;
|
||||
})";
|
||||
|
@ -590,24 +590,24 @@ TEST_P(ShaderTests, OverridableConstantsMultipleEntryPoints) {
|
|||
wgpu::Buffer buffer3 = CreateBuffer(kCount);
|
||||
|
||||
std::string shader = R"(
|
||||
[[override(1001)]] let c1: u32;
|
||||
[[override(1002)]] let c2: u32;
|
||||
@override(1001) let c1: u32;
|
||||
@override(1002) let c2: u32;
|
||||
|
||||
struct Buf {
|
||||
data : array<u32, 1>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main1() {
|
||||
@stage(compute) @workgroup_size(1) fn main1() {
|
||||
buf.data[0] = c1;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main2() {
|
||||
@stage(compute) @workgroup_size(1) fn main2() {
|
||||
buf.data[0] = c2;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main3() {
|
||||
@stage(compute) @workgroup_size(1) fn main3() {
|
||||
buf.data[0] = 3u;
|
||||
}
|
||||
)";
|
||||
|
@ -681,11 +681,11 @@ TEST_P(ShaderTests, OverridableConstantsRenderPipeline) {
|
|||
DAWN_TEST_UNSUPPORTED_IF(IsOpenGLES());
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[override(1111)]] let xright: f32;
|
||||
[[override(2222)]] let ytop: f32;
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32)
|
||||
-> [[builtin(position)]] vec4<f32> {
|
||||
@override(1111) let xright: f32;
|
||||
@override(2222) let ytop: f32;
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32)
|
||||
-> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, ytop),
|
||||
vec2<f32>(-1.0, -ytop),
|
||||
|
@ -695,9 +695,9 @@ fn main([[builtin(vertex_index)]] VertexIndex : u32)
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[override(1000)]] let intensity: f32 = 0.0;
|
||||
[[stage(fragment)]] fn main()
|
||||
-> [[location(0)]] vec4<f32> {
|
||||
@override(1000) let intensity: f32 = 0.0;
|
||||
@stage(fragment) fn main()
|
||||
-> @location(0) vec4<f32> {
|
||||
return vec4<f32>(intensity, intensity, intensity, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ class StorageTextureTests : public DawnTest {
|
|||
wgpu::TextureViewDimension dimension,
|
||||
uint32_t binding) {
|
||||
std::ostringstream ostream;
|
||||
ostream << "[[group(0), binding(" << binding << ")]] "
|
||||
ostream << "@group(0) @binding(" << binding << ") "
|
||||
<< "var storageImage" << binding << " : ";
|
||||
switch (dimension) {
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
|
@ -370,15 +370,15 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
|||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
const char* workgroupSize = !strcmp(stage, "compute") ? ", workgroup_size(1)" : "";
|
||||
const char* workgroupSize = !strcmp(stage, "compute") ? " @workgroup_size(1)" : "";
|
||||
const bool isFragment = strcmp(stage, "fragment") == 0;
|
||||
|
||||
std::ostringstream ostream;
|
||||
ostream << GetImageDeclaration(format, "write", dimension, 0) << "\n";
|
||||
ostream << "[[stage(" << stage << ")" << workgroupSize << "]]\n";
|
||||
ostream << "@stage(" << stage << ")" << workgroupSize << "\n";
|
||||
ostream << "fn main() ";
|
||||
if (isFragment) {
|
||||
ostream << "-> [[location(0)]] vec4<f32> ";
|
||||
ostream << "-> @location(0) vec4<f32> ";
|
||||
}
|
||||
ostream << "{\n";
|
||||
ostream << " let size : vec2<i32> = textureDimensions(storageImage0).xy;\n";
|
||||
|
@ -433,7 +433,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
|||
std::ostringstream ostream;
|
||||
ostream << GetImageDeclaration(format, "write", dimension, 0) << "\n";
|
||||
ostream << GetImageDeclaration(format, "read", dimension, 1) << "\n";
|
||||
ostream << "[[stage(compute), workgroup_size(1)]] fn main() {\n";
|
||||
ostream << "@stage(compute) @workgroup_size(1) fn main() {\n";
|
||||
ostream << " let size : vec2<i32> = textureDimensions(storageImage0).xy;\n";
|
||||
ostream << " let sliceCount : i32 = " << sliceCount << ";\n";
|
||||
ostream << " for (var slice : i32 = 0; slice < sliceCount; slice = slice + 1) {\n";
|
||||
|
@ -739,7 +739,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
|
|||
|
||||
const char* kSimpleVertexShader = R"(
|
||||
;
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
|
||||
|
@ -863,9 +863,9 @@ TEST_P(StorageTextureTests, SampledAndWriteonlyStorageTexturePingPong) {
|
|||
kTextureFormat, wgpu::TextureUsage::TextureBinding | wgpu::TextureUsage::StorageBinding, 1u,
|
||||
1u);
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var Src : texture_2d<u32>;
|
||||
[[group(0), binding(1)]] var Dst : texture_storage_2d<r32uint, write>;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var Src : texture_2d<u32>;
|
||||
@group(0) @binding(1) var Dst : texture_storage_2d<r32uint, write>;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0), 0);
|
||||
srcValue.x = srcValue.x + 1u;
|
||||
textureStore(Dst, vec2<i32>(0, 0), srcValue);
|
||||
|
@ -962,16 +962,16 @@ fn doTest() -> bool {
|
|||
})";
|
||||
|
||||
const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"(
|
||||
[[group(0), binding(0)]] var dstImage : texture_storage_2d<r32uint, write>;
|
||||
@group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
|
||||
return vec4<f32>();
|
||||
})";
|
||||
const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"(
|
||||
[[group(0), binding(0)]] var dstImage : texture_storage_2d<r32uint, write>;
|
||||
@group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
|
||||
})";
|
||||
};
|
||||
|
|
|
@ -223,15 +223,15 @@ TEST_P(SwapChainValidationTests, ViewDestroyedAfterPresent) {
|
|||
TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
|
||||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
struct FragmentOut {
|
||||
[[location(0)]] target0 : vec4<f32>;
|
||||
[[location(1)]] target1 : f32;
|
||||
@location(0) target0 : vec4<f32>;
|
||||
@location(1) target1 : f32;
|
||||
};
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var out : FragmentOut;
|
||||
out.target0 = vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
out.target1 = 0.5;
|
||||
|
|
|
@ -29,8 +29,8 @@ TEST_P(Texture3DTests, Sampling) {
|
|||
// Set up pipeline. Two triangles will be drawn via the pipeline. They will fill the entire
|
||||
// color attachment with data sampled from 3D texture.
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( -1.0, -1.0),
|
||||
|
@ -43,11 +43,11 @@ TEST_P(Texture3DTests, Sampling) {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var samp : sampler;
|
||||
[[group(0), binding(1)]] var tex : texture_3d<f32>;
|
||||
@group(0) @binding(0) var samp : sampler;
|
||||
@group(0) @binding(1) var tex : texture_3d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(tex, samp, vec3<f32>(FragCoord.xy / 4.0, 1.5 / 4.0));
|
||||
})");
|
||||
|
||||
|
|
|
@ -143,8 +143,8 @@ class TextureFormatTest : public DawnTest {
|
|||
utils::ComboRenderPipelineDescriptor desc;
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-3.0, -1.0),
|
||||
vec2<f32>( 3.0, -1.0),
|
||||
|
@ -157,12 +157,12 @@ class TextureFormatTest : public DawnTest {
|
|||
const char* type = utils::GetWGSLColorTextureComponentType(sampleFormatInfo.format);
|
||||
|
||||
std::ostringstream fsSource;
|
||||
fsSource << "[[group(0), binding(0)]] var myTexture : texture_2d<" << type << ">;\n";
|
||||
fsSource << "@group(0) @binding(0) var myTexture : texture_2d<" << type << ">;\n";
|
||||
fsSource << "struct FragmentOut {\n";
|
||||
fsSource << " [[location(0)]] color : vec4<" << type << ">;\n";
|
||||
fsSource << " @location(0) color : vec4<" << type << ">;\n";
|
||||
fsSource << R"(};
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> FragmentOut {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.color = textureLoad(myTexture, vec2<i32>(FragCoord.xy), 0);
|
||||
return output;
|
||||
|
|
|
@ -50,8 +50,8 @@ class TextureSubresourceTest : public DawnTest {
|
|||
|
||||
void DrawTriangle(const wgpu::TextureView& view) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
|
@ -61,7 +61,7 @@ class TextureSubresourceTest : public DawnTest {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -87,8 +87,8 @@ class TextureSubresourceTest : public DawnTest {
|
|||
|
||||
void SampleAndDraw(const wgpu::TextureView& samplerView, const wgpu::TextureView& renderView) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -101,11 +101,11 @@ class TextureSubresourceTest : public DawnTest {
|
|||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var samp : sampler;
|
||||
[[group(0), binding(1)]] var tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var samp : sampler;
|
||||
@group(0) @binding(1) var tex : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(tex, samp, FragCoord.xy / vec2<f32>(4.0, 4.0));
|
||||
})");
|
||||
|
||||
|
|
|
@ -62,12 +62,12 @@ namespace {
|
|||
wgpu::ShaderModule CreateDefaultVertexShaderModule(wgpu::Device device) {
|
||||
return utils::CreateShaderModule(device, R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] texCoord : vec2<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) texCoord : vec2<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-2., -2.),
|
||||
|
@ -219,11 +219,11 @@ class TextureViewSamplingTest : public DawnTest {
|
|||
wgpu::TextureView textureView = mTexture.CreateView(&descriptor);
|
||||
|
||||
const char* fragmentShader = R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, texCoord);
|
||||
}
|
||||
)";
|
||||
|
@ -257,11 +257,11 @@ class TextureViewSamplingTest : public DawnTest {
|
|||
wgpu::TextureView textureView = mTexture.CreateView(&descriptor);
|
||||
|
||||
const char* fragmentShader = R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : texture_2d_array<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : texture_2d_array<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, texCoord, 0) +
|
||||
textureSample(texture0, sampler0, texCoord, 1) +
|
||||
textureSample(texture0, sampler0, texCoord, 2);
|
||||
|
@ -292,11 +292,11 @@ class TextureViewSamplingTest : public DawnTest {
|
|||
|
||||
std::ostringstream stream;
|
||||
stream << R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : )"
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : )"
|
||||
<< textureType << R"(<f32>;
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
var sc : f32 = 2.0 * texCoord.x - 1.0;
|
||||
var tc : f32 = 2.0 * texCoord.y - 1.0;
|
||||
return textureSample(texture0, sampler0, vec3<f32>()"
|
||||
|
@ -366,11 +366,11 @@ TEST_P(TextureViewSamplingTest, Default2DArrayTexture) {
|
|||
wgpu::TextureView textureView = mTexture.CreateView(&descriptor);
|
||||
|
||||
const char* fragmentShader = R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture0 : texture_2d_array<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture0 : texture_2d_array<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, texCoord, 0) +
|
||||
textureSample(texture0, sampler0, texCoord, 1) +
|
||||
textureSample(texture0, sampler0, texCoord, 2);
|
||||
|
@ -498,8 +498,8 @@ class TextureViewRenderingTest : public DawnTest {
|
|||
renderPassInfo.cColorAttachments[0].clearColor = {1.0f, 0.0f, 0.0f, 1.0f};
|
||||
|
||||
const char* oneColorFragmentShader = R"(
|
||||
[[stage(fragment)]] fn main([[location(0)]] texCoord : vec2<f32>) ->
|
||||
[[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(@location(0) texCoord : vec2<f32>) ->
|
||||
@location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
|
|
@ -70,7 +70,7 @@ class TextureZeroInitTest : public DawnTest {
|
|||
pipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest(depth);
|
||||
const char* fs = R"(
|
||||
;
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)";
|
||||
|
@ -83,8 +83,8 @@ class TextureZeroInitTest : public DawnTest {
|
|||
}
|
||||
wgpu::ShaderModule CreateBasicVertexShaderForTest(float depth = 0.f) {
|
||||
std::string source = R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
|
@ -100,12 +100,12 @@ class TextureZeroInitTest : public DawnTest {
|
|||
}
|
||||
wgpu::ShaderModule CreateSampledTextureFragmentShaderForTest() {
|
||||
return utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(0) var texture0 : texture_2d<f32>;
|
||||
struct FragmentOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
};
|
||||
[[stage(fragment)]]
|
||||
fn main([[builtin(position)]] FragCoord : vec4<f32>) -> FragmentOut {
|
||||
@stage(fragment)
|
||||
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
|
||||
var output : FragmentOut;
|
||||
output.color = textureLoad(texture0, vec2<i32>(FragCoord.xy), 0);
|
||||
return output;
|
||||
|
@ -979,12 +979,12 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
|
|||
wgpu::ComputePipelineDescriptor computePipelineDescriptor;
|
||||
wgpu::ProgrammableStageDescriptor compute;
|
||||
const char* cs = R"(
|
||||
[[group(0), binding(0)]] var tex : texture_2d<f32>;
|
||||
@group(0) @binding(0) var tex : texture_2d<f32>;
|
||||
struct Result {
|
||||
value : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(1)]] var<storage, read_write> result : Result;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(1) var<storage, read_write> result : Result;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
result.value = textureLoad(tex, vec2<i32>(0,0), 0);
|
||||
}
|
||||
)";
|
||||
|
|
|
@ -236,8 +236,8 @@ class VertexFormatTest : public DawnTest {
|
|||
|
||||
std::ostringstream vs;
|
||||
vs << "struct VertexIn {\n";
|
||||
vs << " [[location(0)]] test : " << variableType << ";\n";
|
||||
vs << " [[builtin(vertex_index)]] VertexIndex : u32;\n";
|
||||
vs << " @location(0) test : " << variableType << ";\n";
|
||||
vs << " @builtin(vertex_index) VertexIndex : u32;\n";
|
||||
vs << "};\n";
|
||||
|
||||
// Because x86 CPU using "extended
|
||||
|
@ -260,11 +260,11 @@ class VertexFormatTest : public DawnTest {
|
|||
}
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main(input : VertexIn) -> VertexOut {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
|
@ -353,8 +353,8 @@ class VertexFormatTest : public DawnTest {
|
|||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return color;
|
||||
})");
|
||||
|
||||
|
|
|
@ -102,13 +102,13 @@ class VertexOnlyRenderPipelineTest : public DawnTest {
|
|||
bool writeDepth = false,
|
||||
bool useFragment = true) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[location(0)]] pos : vec4<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -74,23 +74,23 @@ class VertexStateTest : public DawnTest {
|
|||
|
||||
// TODO(cwallez@chromium.org): this only handles float attributes, we should extend it to
|
||||
// other types Adds line of the form
|
||||
// [[location(1) input1 : vec4<f32>;
|
||||
// @location(1) input1 : vec4<f32>;
|
||||
for (const auto& input : testSpec) {
|
||||
vs << "[[location(" << input.location << ")]] input" << input.location
|
||||
vs << "@location(" << input.location << ") input" << input.location
|
||||
<< " : vec4<f32>;\n";
|
||||
}
|
||||
|
||||
vs << R"(
|
||||
[[builtin(vertex_index)]] VertexIndex : u32;
|
||||
[[builtin(instance_index)]] InstanceIndex : u32;
|
||||
@builtin(vertex_index) VertexIndex : u32;
|
||||
@builtin(instance_index) InstanceIndex : u32;
|
||||
};
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main(input : VertexIn) -> VertexOut {
|
||||
@stage(vertex) fn main(input : VertexIn) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
)";
|
||||
|
||||
|
@ -138,8 +138,8 @@ class VertexStateTest : public DawnTest {
|
|||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return color;
|
||||
}
|
||||
)");
|
||||
|
@ -586,18 +586,18 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
|
|||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
struct VertexIn {
|
||||
[[location(0)]] attr0 : vec4<f32>;
|
||||
[[location(1)]] attr1 : vec2<u32>;
|
||||
[[location(2)]] attr2 : vec4<f32>;
|
||||
[[location(3)]] attr3 : f32;
|
||||
@location(0) attr0 : vec4<f32>;
|
||||
@location(1) attr1 : vec2<u32>;
|
||||
@location(2) attr2 : vec4<f32>;
|
||||
@location(3) attr3 : f32;
|
||||
};
|
||||
|
||||
struct VertexOut {
|
||||
[[location(0)]] color : vec4<f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) color : vec4<f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]] fn main(input : VertexIn) -> VertexOut {
|
||||
@stage(vertex) fn main(input : VertexIn) -> VertexOut {
|
||||
var output : VertexOut;
|
||||
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
|
||||
|
@ -617,8 +617,8 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
|
|||
return output;
|
||||
})");
|
||||
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] color : vec4<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
|
||||
return color;
|
||||
})");
|
||||
pipelineDesc.vertex.bufferCount = vertexState.vertexBufferCount;
|
||||
|
@ -662,12 +662,12 @@ TEST_P(OptionalVertexStateTest, Basic) {
|
|||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 3, 3);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -121,12 +121,12 @@ std::vector<uint8_t> VideoViewsTests::GetTestTextureData(wgpu::TextureFormat for
|
|||
wgpu::ShaderModule VideoViewsTests::GetTestVertexShaderModule() const {
|
||||
return utils::CreateShaderModule(device, R"(
|
||||
struct VertexOut {
|
||||
[[location(0)]] texCoord : vec2 <f32>;
|
||||
[[builtin(position)]] position : vec4<f32>;
|
||||
@location(0) texCoord : vec2 <f32>;
|
||||
@builtin(position) position : vec4<f32>;
|
||||
};
|
||||
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
|
@ -163,11 +163,11 @@ TEST_P(VideoViewsTests, NV12SampleYtoR) {
|
|||
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
|
||||
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
let y : f32 = textureSample(texture, sampler0, texCoord).r;
|
||||
return vec4<f32>(y, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
@ -221,11 +221,11 @@ TEST_P(VideoViewsTests, NV12SampleUVtoRG) {
|
|||
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
|
||||
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var texture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var texture : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
let u : f32 = textureSample(texture, sampler0, texCoord).r;
|
||||
let v : f32 = textureSample(texture, sampler0, texCoord).g;
|
||||
return vec4<f32>(u, v, 0.0, 1.0);
|
||||
|
@ -289,12 +289,12 @@ TEST_P(VideoViewsTests, NV12SampleYUVtoRGB) {
|
|||
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
|
||||
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[group(0), binding(1)]] var lumaTexture : texture_2d<f32>;
|
||||
[[group(0), binding(2)]] var chromaTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@group(0) @binding(1) var lumaTexture : texture_2d<f32>;
|
||||
@group(0) @binding(2) var chromaTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]]
|
||||
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment)
|
||||
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
|
||||
let y : f32 = textureSample(lumaTexture, sampler0, texCoord).r;
|
||||
let u : f32 = textureSample(chromaTexture, sampler0, texCoord).r;
|
||||
let v : f32 = textureSample(chromaTexture, sampler0, texCoord).g;
|
||||
|
|
|
@ -24,12 +24,12 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
|
|||
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(-0.5, 0.5, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -23,8 +23,8 @@ class ViewportTest : public DawnTest {
|
|||
DawnTest::SetUp();
|
||||
|
||||
mQuadVS = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 6>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>(-1.0, -1.0),
|
||||
|
@ -36,7 +36,7 @@ class ViewportTest : public DawnTest {
|
|||
})");
|
||||
|
||||
mQuadFS = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
|
||||
})");
|
||||
}
|
||||
|
@ -92,8 +92,8 @@ class ViewportTest : public DawnTest {
|
|||
// Create a pipeline drawing 3 points at depth 1.0, 0.5 and 0.0.
|
||||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
var points : array<vec3<f32>, 3> = array<vec3<f32>, 3>(
|
||||
vec3<f32>(-0.9, 0.0, 1.0),
|
||||
vec3<f32>( 0.0, 0.0, 0.5),
|
||||
|
|
|
@ -32,9 +32,9 @@ namespace {
|
|||
};
|
||||
|
||||
constexpr char kVertexShader[] = R"(
|
||||
[[stage(vertex)]] fn main(
|
||||
[[location(0)]] pos : vec4<f32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@location(0) pos : vec4<f32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return pos;
|
||||
})";
|
||||
|
||||
|
@ -42,8 +42,8 @@ namespace {
|
|||
struct Uniforms {
|
||||
color : vec3<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : Uniforms;
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@group(0) @binding(0) var<uniform> uniforms : Uniforms;
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(uniforms.color * (1.0 / 5000.0), 1.0);
|
||||
})";
|
||||
|
||||
|
@ -54,10 +54,10 @@ namespace {
|
|||
struct Uniforms {
|
||||
color : vec3<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> constants : Constants;
|
||||
[[group(1), binding(0)]] var<uniform> uniforms : Uniforms;
|
||||
@group(0) @binding(0) var<uniform> constants : Constants;
|
||||
@group(1) @binding(0) var<uniform> uniforms : Uniforms;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>((constants.color + uniforms.color) * (1.0 / 5000.0), 1.0);
|
||||
})";
|
||||
|
||||
|
|
|
@ -29,10 +29,10 @@ namespace {
|
|||
numbers: array<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> firstMatrix : Matrix;
|
||||
[[group(0), binding(1)]] var<storage, read> secondMatrix : Matrix;
|
||||
[[group(0), binding(2)]] var<storage, write> resultMatrix : Matrix;
|
||||
[[group(0), binding(3)]] var<uniform> uniforms : Uniforms;
|
||||
@group(0) @binding(0) var<storage, read> firstMatrix : Matrix;
|
||||
@group(0) @binding(1) var<storage, read> secondMatrix : Matrix;
|
||||
@group(0) @binding(2) var<storage, write> resultMatrix : Matrix;
|
||||
@group(0) @binding(3) var<uniform> uniforms : Uniforms;
|
||||
|
||||
fn mm_readA(row : u32, col : u32) -> f32 {
|
||||
if (row < uniforms.dimAOuter && col < uniforms.dimInner)
|
||||
|
@ -73,9 +73,9 @@ namespace {
|
|||
var<workgroup> mm_Asub : array<array<f32, 32>, 32>;
|
||||
var<workgroup> mm_Bsub : array<array<f32, 32>, 32>;)";
|
||||
const std::string& kMatMulFloatBodyPart1 = R"(
|
||||
[[stage(compute), workgroup_size(8, 8, 1)]]
|
||||
fn main([[builtin(local_invocation_id)]] local_id : vec3<u32>,
|
||||
[[builtin(global_invocation_id)]] global_id : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(8, 8, 1)
|
||||
fn main(@builtin(local_invocation_id) local_id : vec3<u32>,
|
||||
@builtin(global_invocation_id) global_id : vec3<u32>) {
|
||||
let tileRow : u32 = local_id.y * RowPerThread;
|
||||
let tileCol : u32 = local_id.x * ColPerThread;
|
||||
|
||||
|
@ -196,10 +196,10 @@ namespace {
|
|||
numbers: array<vec4<f32>>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read> firstMatrix : Matrix;
|
||||
[[group(0), binding(1)]] var<storage, read> secondMatrix : Matrix;
|
||||
[[group(0), binding(2)]] var<storage, write> resultMatrix : Matrix;
|
||||
[[group(0), binding(3)]] var<uniform> uniforms : Uniforms;
|
||||
@group(0) @binding(0) var<storage, read> firstMatrix : Matrix;
|
||||
@group(0) @binding(1) var<storage, read> secondMatrix : Matrix;
|
||||
@group(0) @binding(2) var<storage, write> resultMatrix : Matrix;
|
||||
@group(0) @binding(3) var<uniform> uniforms : Uniforms;
|
||||
|
||||
fn mm_readA(row : u32, col : u32) -> vec4<f32> {
|
||||
if (row < uniforms.dimAOuter && col < uniforms.dimInner)
|
||||
|
@ -238,9 +238,9 @@ namespace {
|
|||
var<workgroup> mm_Asub : array<array<vec4<f32>, 8>, 32>;
|
||||
var<workgroup> mm_Bsub : array<array<vec4<f32>, 8>, 32>;)";
|
||||
const std::string& kMatMulVec4BodyPart1 = R"(
|
||||
[[stage(compute), workgroup_size(8, 8, 1)]]
|
||||
fn main([[builtin(local_invocation_id)]] local_id : vec3<u32>,
|
||||
[[builtin(global_invocation_id)]] global_id : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(8, 8, 1)
|
||||
fn main(@builtin(local_invocation_id) local_id : vec3<u32>,
|
||||
@builtin(global_invocation_id) global_id : vec3<u32>) {
|
||||
let tileRow : u32 = local_id.y * RowPerThread;
|
||||
let tileCol : u32 = local_id.x;
|
||||
|
||||
|
|
|
@ -70,13 +70,13 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams<SubresourceTrackin
|
|||
|
||||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var materials : texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@group(0) @binding(0) var materials : texture_2d<f32>;
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
let foo : vec2<i32> = textureDimensions(materials);
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
|
|
@ -58,7 +58,7 @@ TEST_F(CommandBufferEncodingTests, ComputePassEncoderIndirectDispatchStateRestor
|
|||
// Create a simple pipeline
|
||||
wgpu::ComputePipelineDescriptor csDesc;
|
||||
csDesc.compute.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
fn main() {
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main";
|
||||
|
@ -290,7 +290,7 @@ TEST_F(CommandBufferEncodingTests, StateNotLeakedAfterRestore) {
|
|||
// Create a simple pipeline
|
||||
wgpu::ComputePipelineDescriptor csDesc;
|
||||
csDesc.compute.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]]
|
||||
@stage(compute) @workgroup_size(1, 1, 1)
|
||||
fn main() {
|
||||
})");
|
||||
csDesc.compute.entryPoint = "main";
|
||||
|
|
|
@ -72,7 +72,7 @@ namespace dawn::native { namespace {
|
|||
}
|
||||
DAWN_TRY_ASSIGN_WITH_CLEANUP(
|
||||
mVsModule, ShaderModuleMock::Create(&mDevice, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})"),
|
||||
{ ASSERT(false); }, mVsModule);
|
||||
|
@ -86,7 +86,7 @@ namespace dawn::native { namespace {
|
|||
}
|
||||
DAWN_TRY_ASSIGN_WITH_CLEANUP(
|
||||
mCsModule, ShaderModuleMock::Create(&mDevice, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})"),
|
||||
{ ASSERT(false); }, mCsModule);
|
||||
EXPECT_CALL(*mCsModule.Get(), DestroyImpl).Times(1);
|
||||
|
@ -426,7 +426,7 @@ namespace dawn::native { namespace {
|
|||
{
|
||||
ShaderModuleWGSLDescriptor wgslDesc;
|
||||
wgslDesc.source = R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
}
|
||||
)";
|
||||
ShaderModuleDescriptor desc = {};
|
||||
|
@ -696,7 +696,7 @@ namespace dawn::native { namespace {
|
|||
{
|
||||
ShaderModuleWGSLDescriptor wgslDesc;
|
||||
wgslDesc.source = R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
}
|
||||
)";
|
||||
ShaderModuleDescriptor desc = {};
|
||||
|
|
|
@ -1415,7 +1415,7 @@ class SetBindGroupValidationTest : public ValidationTest {
|
|||
|
||||
wgpu::RenderPipeline CreateRenderPipeline() {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
|
@ -1424,12 +1424,12 @@ class SetBindGroupValidationTest : public ValidationTest {
|
|||
value : vec2<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> uBufferDynamic : S;
|
||||
[[group(0), binding(1)]] var<uniform> uBuffer : S;
|
||||
[[group(0), binding(2)]] var<storage, read_write> sBufferDynamic : S;
|
||||
[[group(0), binding(3)]] var<storage, read> sReadonlyBufferDynamic : S;
|
||||
@group(0) @binding(0) var<uniform> uBufferDynamic : S;
|
||||
@group(0) @binding(1) var<uniform> uBuffer : S;
|
||||
@group(0) @binding(2) var<storage, read_write> sBufferDynamic : S;
|
||||
@group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
|
||||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
|
@ -1448,12 +1448,12 @@ class SetBindGroupValidationTest : public ValidationTest {
|
|||
value : vec2<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<uniform> uBufferDynamic : S;
|
||||
[[group(0), binding(1)]] var<uniform> uBuffer : S;
|
||||
[[group(0), binding(2)]] var<storage, read_write> sBufferDynamic : S;
|
||||
[[group(0), binding(3)]] var<storage, read> sReadonlyBufferDynamic : S;
|
||||
@group(0) @binding(0) var<uniform> uBufferDynamic : S;
|
||||
@group(0) @binding(1) var<uniform> uBuffer : S;
|
||||
@group(0) @binding(2) var<storage, read_write> sBufferDynamic : S;
|
||||
@group(0) @binding(3) var<storage, read> sReadonlyBufferDynamic : S;
|
||||
|
||||
[[stage(compute), workgroup_size(4, 4, 1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(4, 4, 1) fn main() {
|
||||
})");
|
||||
|
||||
wgpu::PipelineLayout pipelineLayout =
|
||||
|
@ -1824,7 +1824,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
|
|||
ValidationTest::SetUp();
|
||||
|
||||
mVsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
|
@ -1880,7 +1880,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
|
|||
|
||||
for (uint32_t b = 0; b < layout.size(); ++b) {
|
||||
wgpu::BufferBindingType binding = layout[b];
|
||||
ss << "[[group(" << l << "), binding(" << b << ")]] ";
|
||||
ss << "@group(" << l << ") @binding(" << b << ") ";
|
||||
switch (binding) {
|
||||
case wgpu::BufferBindingType::Storage:
|
||||
ss << "var<storage, read_write> set" << l << "_binding" << b << " : S;";
|
||||
|
@ -1894,7 +1894,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
|
|||
}
|
||||
}
|
||||
|
||||
ss << "[[stage(fragment)]] fn main() {}";
|
||||
ss << "@stage(fragment) fn main() {}";
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, ss.str().c_str());
|
||||
|
||||
|
@ -2026,7 +2026,7 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
|
|||
const char* fsShader,
|
||||
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
|
@ -2050,10 +2050,10 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
|
|||
value : vec2<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> sBufferDynamic : S;
|
||||
[[group(1), binding(0)]] var<storage, read> sReadonlyBufferDynamic : S;
|
||||
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
|
||||
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var val : vec2<f32> = sBufferDynamic.value;
|
||||
val = sReadonlyBufferDynamic.value;
|
||||
})",
|
||||
|
@ -2085,10 +2085,10 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
|
|||
value : vec2<f32>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> sBufferDynamic : S;
|
||||
[[group(1), binding(0)]] var<storage, read> sReadonlyBufferDynamic : S;
|
||||
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
|
||||
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
|
||||
|
||||
[[stage(compute), workgroup_size(4, 4, 1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(4, 4, 1) fn main() {
|
||||
var val : vec2<f32> = sBufferDynamic.value;
|
||||
val = sReadonlyBufferDynamic.value;
|
||||
})",
|
||||
|
@ -2130,13 +2130,13 @@ TEST_F(BindGroupLayoutCompatibilityTest, ROStorageInBGLWithRWStorageInShader) {
|
|||
|
||||
TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
|
||||
constexpr char kTexture2DShaderFS[] = R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})";
|
||||
constexpr char kTexture2DShaderCS[] = R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})";
|
||||
|
||||
|
@ -2169,13 +2169,13 @@ TEST_F(BindGroupLayoutCompatibilityTest, TextureViewDimension) {
|
|||
wgpu::TextureViewDimension::e2DArray}})}));
|
||||
|
||||
constexpr char kTexture2DArrayShaderFS[] = R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture : texture_2d_array<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})";
|
||||
constexpr char kTexture2DArrayShaderCS[] = R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture : texture_2d_array<f32>;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})";
|
||||
|
||||
|
@ -2216,16 +2216,16 @@ TEST_F(BindGroupLayoutCompatibilityTest, ExternalTextureBindGroupLayoutCompatibi
|
|||
|
||||
// Test that an external texture binding works with a texture_external in the shader.
|
||||
CreateFSRenderPipeline(R"(
|
||||
[[group(0), binding(0)]] var myExternalTexture: texture_external;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var myExternalTexture: texture_external;
|
||||
@stage(fragment) fn main() {
|
||||
_ = myExternalTexture;
|
||||
})",
|
||||
{bgl});
|
||||
|
||||
// Test that an external texture binding doesn't work with a texture_2d<f32> in the shader.
|
||||
ASSERT_DEVICE_ERROR(CreateFSRenderPipeline(R"(
|
||||
[[group(0), binding(0)]] var myTexture: texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture: texture_2d<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
_ = myTexture;
|
||||
})",
|
||||
{bgl}));
|
||||
|
@ -2429,7 +2429,7 @@ class SamplerTypeBindingTest : public ValidationTest {
|
|||
wgpu::RenderPipeline CreateFragmentPipeline(wgpu::BindGroupLayout* bindGroupLayout,
|
||||
const char* fragmentSource) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
|
@ -2455,8 +2455,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})");
|
||||
}
|
||||
|
@ -2467,8 +2467,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::NonFiltering}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})");
|
||||
}
|
||||
|
@ -2479,8 +2479,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler_comparison;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler_comparison;
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})");
|
||||
}
|
||||
|
@ -2491,8 +2491,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Filtering}});
|
||||
|
||||
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler_comparison;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler_comparison;
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})"));
|
||||
}
|
||||
|
@ -2503,8 +2503,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::NonFiltering}});
|
||||
|
||||
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler_comparison;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler_comparison;
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})"));
|
||||
}
|
||||
|
@ -2515,8 +2515,8 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
device, {{0, wgpu::ShaderStage::Fragment, wgpu::SamplerBindingType::Comparison}});
|
||||
|
||||
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})"));
|
||||
}
|
||||
|
@ -2528,9 +2528,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@group(0) @binding(1) var myTexture: texture_2d<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
|
||||
})");
|
||||
}
|
||||
|
@ -2542,9 +2542,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Float}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@group(0) @binding(1) var myTexture: texture_2d<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
|
||||
})");
|
||||
}
|
||||
|
@ -2556,9 +2556,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[group(0), binding(1)]] var myTexture: texture_depth_2d;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@group(0) @binding(1) var myTexture: texture_depth_2d;
|
||||
@stage(fragment) fn main() {
|
||||
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
|
||||
})");
|
||||
}
|
||||
|
@ -2570,9 +2570,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[group(0), binding(1)]] var myTexture: texture_depth_2d;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@group(0) @binding(1) var myTexture: texture_depth_2d;
|
||||
@stage(fragment) fn main() {
|
||||
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
|
||||
})");
|
||||
}
|
||||
|
@ -2584,9 +2584,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::Depth}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler_comparison;
|
||||
[[group(0), binding(1)]] var myTexture: texture_depth_2d;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler_comparison;
|
||||
@group(0) @binding(1) var myTexture: texture_depth_2d;
|
||||
@stage(fragment) fn main() {
|
||||
textureSampleCompare(myTexture, mySampler, vec2<f32>(0.0, 0.0), 0.0);
|
||||
})");
|
||||
}
|
||||
|
@ -2598,9 +2598,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::UnfilterableFloat}});
|
||||
|
||||
ASSERT_DEVICE_ERROR(CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@group(0) @binding(1) var myTexture: texture_2d<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
|
||||
})"));
|
||||
}
|
||||
|
@ -2612,9 +2612,9 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
|
|||
{1, wgpu::ShaderStage::Fragment, wgpu::TextureSampleType::UnfilterableFloat}});
|
||||
|
||||
CreateFragmentPipeline(&bindGroupLayout, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[group(0), binding(1)]] var myTexture: texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@group(0) @binding(1) var myTexture: texture_2d<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
|
||||
})");
|
||||
}
|
||||
|
|
|
@ -23,7 +23,7 @@ class ComputeIndirectValidationTest : public ValidationTest {
|
|||
ValidationTest::SetUp();
|
||||
|
||||
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
|
||||
// Set up compute pipeline
|
||||
|
|
|
@ -25,7 +25,7 @@ class ComputeValidationTest : public ValidationTest {
|
|||
ValidationTest::SetUp();
|
||||
|
||||
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
|
||||
// Set up compute pipeline
|
||||
|
|
|
@ -24,12 +24,12 @@ class DrawIndirectValidationTest : public ValidationTest {
|
|||
ValidationTest::SetUp();
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32>{
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32>{
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
|
||||
|
|
|
@ -82,7 +82,7 @@ namespace {
|
|||
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
|
||||
|
||||
fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
}
|
||||
|
@ -107,8 +107,8 @@ namespace {
|
|||
|
||||
for (auto buffer : bufferDescList) {
|
||||
for (auto attr : buffer.attributes) {
|
||||
// [[location({shaderLocation})]] var_{id} : {typeString},
|
||||
inputStringStream << "[[location(" << attr.shaderLocation << ")]] var_"
|
||||
// @location({shaderLocation}) var_{id} : {typeString},
|
||||
inputStringStream << "@location(" << attr.shaderLocation << ") var_"
|
||||
<< attributeCount << " : vec4<f32>,";
|
||||
attributeCount++;
|
||||
}
|
||||
|
@ -117,9 +117,9 @@ namespace {
|
|||
std::stringstream shaderStringStream;
|
||||
|
||||
shaderStringStream << R"(
|
||||
[[stage(vertex)]]
|
||||
@stage(vertex)
|
||||
fn main()" << inputStringStream.str()
|
||||
<< R"() -> [[builtin(position)]] vec4<f32> {
|
||||
<< R"() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})";
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ class GetBindGroupLayoutTests : public ValidationTest {
|
|||
protected:
|
||||
wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
|
@ -49,10 +49,10 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniform0 : S;
|
||||
[[group(1), binding(0)]] var<uniform> uniform1 : S;
|
||||
@group(0) @binding(0) var<uniform> uniform0 : S;
|
||||
@group(1) @binding(0) var<uniform> uniform1 : S;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
var pos : vec4<f32> = uniform0.pos;
|
||||
pos = uniform1.pos;
|
||||
return vec4<f32>();
|
||||
|
@ -62,14 +62,14 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
|
|||
struct S2 {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(2), binding(0)]] var<uniform> uniform2 : S2;
|
||||
@group(2) @binding(0) var<uniform> uniform2 : S2;
|
||||
|
||||
struct S3 {
|
||||
pos : mat4x4<f32>;
|
||||
};
|
||||
[[group(3), binding(0)]] var<storage, read_write> storage3 : S3;
|
||||
@group(3) @binding(0) var<storage, read_write> storage3 : S3;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos_u : vec4<f32> = uniform2.pos;
|
||||
var pos_s : mat4x4<f32> = storage3.pos;
|
||||
})");
|
||||
|
@ -101,9 +101,9 @@ TEST_F(GetBindGroupLayoutTests, DefaultBindGroupLayoutPipelineCompatibility) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
|
||||
|
@ -123,9 +123,9 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
|
||||
|
@ -176,51 +176,51 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
|
|||
wgpu::SamplerBindingType::Filtering}});
|
||||
|
||||
wgpu::ShaderModule emptyVertexModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var mySampler : sampler;
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler : sampler;
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
_ = myTexture;
|
||||
_ = mySampler;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule textureLoadVertexModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var mySampler : sampler;
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler : sampler;
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
textureLoad(myTexture, vec2<i32>(), 0);
|
||||
_ = mySampler;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule textureSampleVertexModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var mySampler : sampler;
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler : sampler;
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
textureSampleLevel(myTexture, mySampler, vec2<f32>(), 0.0);
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule unusedTextureFragmentModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var mySampler : sampler;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler : sampler;
|
||||
@stage(fragment) fn main() {
|
||||
_ = myTexture;
|
||||
_ = mySampler;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule textureLoadFragmentModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var mySampler : sampler;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler : sampler;
|
||||
@stage(fragment) fn main() {
|
||||
textureLoad(myTexture, vec2<i32>(), 0);
|
||||
_ = mySampler;
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule textureSampleFragmentModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
[[group(0), binding(1)]] var mySampler : sampler;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(1) var mySampler : sampler;
|
||||
@stage(fragment) fn main() {
|
||||
textureSample(myTexture, mySampler, vec2<f32>());
|
||||
})");
|
||||
|
||||
|
@ -293,9 +293,9 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
|
||||
|
@ -346,9 +346,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : S;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = ssbo.pos;
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -360,9 +360,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -375,9 +375,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> ssbo : S;
|
||||
@group(0) @binding(0) var<storage, read> ssbo : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = ssbo.pos;
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -389,9 +389,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
|||
{
|
||||
binding.texture.sampleType = wgpu::TextureSampleType::UnfilterableFloat;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -401,9 +401,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
|||
{
|
||||
binding.texture.multisampled = true;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_multisampled_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_multisampled_2d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -414,9 +414,9 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
|
|||
{
|
||||
binding.sampler.type = wgpu::SamplerBindingType::Filtering;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -442,9 +442,9 @@ TEST_F(GetBindGroupLayoutTests, ExternalTextureBindingType) {
|
|||
|
||||
binding.nextInChain = &utils::kExternalTextureBindingLayout;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myExternalTexture: texture_external;
|
||||
@group(0) @binding(0) var myExternalTexture: texture_external;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
_ = myExternalTexture;
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -470,9 +470,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
|||
{
|
||||
binding.texture.viewDimension = wgpu::TextureViewDimension::e1D;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_1d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_1d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -482,9 +482,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
|||
{
|
||||
binding.texture.viewDimension = wgpu::TextureViewDimension::e2D;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -494,9 +494,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
|||
{
|
||||
binding.texture.viewDimension = wgpu::TextureViewDimension::e2DArray;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d_array<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d_array<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -506,9 +506,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
|||
{
|
||||
binding.texture.viewDimension = wgpu::TextureViewDimension::e3D;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_3d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_3d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -518,9 +518,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
|||
{
|
||||
binding.texture.viewDimension = wgpu::TextureViewDimension::Cube;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_cube<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_cube<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -530,9 +530,9 @@ TEST_F(GetBindGroupLayoutTests, ViewDimension) {
|
|||
{
|
||||
binding.texture.viewDimension = wgpu::TextureViewDimension::CubeArray;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_cube_array<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_cube_array<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -558,9 +558,9 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
|
|||
{
|
||||
binding.texture.sampleType = wgpu::TextureSampleType::UnfilterableFloat;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -570,9 +570,9 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
|
|||
{
|
||||
binding.texture.sampleType = wgpu::TextureSampleType::Sint;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<i32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<i32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -582,9 +582,9 @@ TEST_F(GetBindGroupLayoutTests, TextureComponentType) {
|
|||
{
|
||||
binding.texture.sampleType = wgpu::TextureSampleType::Uint;
|
||||
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<u32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<u32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -615,9 +615,9 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -630,9 +630,9 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(1)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(1) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -645,9 +645,9 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(1)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(1) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
|
||||
|
@ -661,10 +661,10 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniform0 : S;
|
||||
[[group(1), binding(0)]] var<uniform> uniform1 : S;
|
||||
@group(0) @binding(0) var<uniform> uniform0 : S;
|
||||
@group(1) @binding(0) var<uniform> uniform1 : S;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
var pos : vec4<f32> = uniform0.pos;
|
||||
pos = uniform1.pos;
|
||||
return vec4<f32>();
|
||||
|
@ -674,9 +674,9 @@ TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(1), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(1) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
})");
|
||||
|
||||
|
@ -700,9 +700,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
|
|||
struct S {
|
||||
pos : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
var pos : f32 = uniforms.pos;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
@ -711,9 +711,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
|
|||
struct S {
|
||||
pos : mat4x4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
var pos : mat4x4<f32> = uniforms.pos;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
@ -722,9 +722,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
|
|||
struct S {
|
||||
pos : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : f32 = uniforms.pos;
|
||||
})");
|
||||
|
||||
|
@ -732,9 +732,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
|
|||
struct S {
|
||||
pos : mat4x4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : mat4x4<f32> = uniforms.pos;
|
||||
})");
|
||||
|
||||
|
@ -793,24 +793,24 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
|
|||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
|
||||
wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
_ = mySampler;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModuleSampler = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var mySampler: sampler;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var mySampler: sampler;
|
||||
@stage(fragment) fn main() {
|
||||
_ = mySampler;
|
||||
})");
|
||||
|
||||
|
@ -867,9 +867,9 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> ubo : S;
|
||||
@group(0) @binding(0) var<uniform> ubo : S;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
var pos : vec4<f32> = ubo.pos;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
@ -878,9 +878,9 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> ssbo : S;
|
||||
@group(0) @binding(0) var<storage, read_write> ssbo : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = ssbo.pos;
|
||||
})");
|
||||
|
||||
|
@ -895,17 +895,17 @@ 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::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
textureDimensions(myTexture);
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_multisampled_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_multisampled_2d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
|
||||
|
@ -920,17 +920,17 @@ 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::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
textureDimensions(myTexture);
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_3d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_3d<f32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
|
||||
|
@ -945,17 +945,17 @@ 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::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<f32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<f32>;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
textureDimensions(myTexture);
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<i32>;
|
||||
@group(0) @binding(0) var myTexture : texture_2d<i32>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})");
|
||||
|
||||
|
@ -970,12 +970,12 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
|
|||
// Test it is an error to query an out of range bind group layout.
|
||||
TEST_F(GetBindGroupLayoutTests, OutOfRangeIndex) {
|
||||
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})")
|
||||
.GetBindGroupLayout(kMaxBindGroups));
|
||||
|
||||
ASSERT_DEVICE_ERROR(RenderPipelineFromFragmentShader(R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})")
|
||||
.GetBindGroupLayout(kMaxBindGroups + 1));
|
||||
}
|
||||
|
@ -991,10 +991,10 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms0 : S;
|
||||
[[group(2), binding(0)]] var<uniform> uniforms2 : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms0 : S;
|
||||
@group(2) @binding(0) var<uniform> uniforms2 : S;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
var pos : vec4<f32> = uniforms0.pos;
|
||||
pos = uniforms2.pos;
|
||||
})");
|
||||
|
@ -1044,15 +1044,15 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
|
|||
struct S {
|
||||
pos : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
var pos : vec4<f32> = uniforms.pos;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
|
||||
utils::ComboRenderPipelineDescriptor pipelineDesc;
|
||||
|
@ -1085,14 +1085,14 @@ TEST_F(GetBindGroupLayoutTests, FromCorrectEntryPoint) {
|
|||
struct Data {
|
||||
data : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> data0 : Data;
|
||||
[[group(0), binding(1)]] var<storage, read_write> data1 : Data;
|
||||
@group(0) @binding(0) var<storage, read_write> data0 : Data;
|
||||
@group(0) @binding(1) var<storage, read_write> data1 : Data;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn compute0() {
|
||||
@stage(compute) @workgroup_size(1) fn compute0() {
|
||||
data0.data = 0.0;
|
||||
}
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn compute1() {
|
||||
@stage(compute) @workgroup_size(1) fn compute1() {
|
||||
data1.data = 0.0;
|
||||
}
|
||||
)");
|
||||
|
|
|
@ -19,16 +19,16 @@
|
|||
#include "utils/WGPUHelpers.h"
|
||||
|
||||
class IndexBufferValidationTest : public ValidationTest {
|
||||
protected:
|
||||
protected:
|
||||
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format,
|
||||
wgpu::PrimitiveTopology primitiveTopology) {
|
||||
wgpu::PrimitiveTopology primitiveTopology) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -151,10 +151,10 @@ TEST_F(IndexBufferValidationTest, IndexBufferOffsetOOBValidation) {
|
|||
// Test that formats given when setting an index buffers must match the format specified on the
|
||||
// pipeline for strip primitive topologies.
|
||||
TEST_F(IndexBufferValidationTest, IndexBufferFormatMatchesPipelineStripFormat) {
|
||||
wgpu::RenderPipeline pipeline32 = MakeTestPipeline(wgpu::IndexFormat::Uint32,
|
||||
wgpu::PrimitiveTopology::TriangleStrip);
|
||||
wgpu::RenderPipeline pipeline16 = MakeTestPipeline(wgpu::IndexFormat::Uint16,
|
||||
wgpu::PrimitiveTopology::LineStrip);
|
||||
wgpu::RenderPipeline pipeline32 =
|
||||
MakeTestPipeline(wgpu::IndexFormat::Uint32, wgpu::PrimitiveTopology::TriangleStrip);
|
||||
wgpu::RenderPipeline pipeline16 =
|
||||
MakeTestPipeline(wgpu::IndexFormat::Uint16, wgpu::PrimitiveTopology::LineStrip);
|
||||
wgpu::RenderPipeline pipelineUndef =
|
||||
MakeTestPipeline(wgpu::IndexFormat::Undefined, wgpu::PrimitiveTopology::LineStrip);
|
||||
|
||||
|
|
|
@ -502,12 +502,12 @@ TEST_F(LabelTest, RenderPipeline) {
|
|||
std::string label = "test";
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -544,7 +544,7 @@ TEST_F(LabelTest, ComputePipeline) {
|
|||
std::string label = "test";
|
||||
|
||||
wgpu::ShaderModule computeModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
wgpu::PipelineLayout pl = utils::MakeBasicPipelineLayout(device, nullptr);
|
||||
wgpu::ComputePipelineDescriptor descriptor;
|
||||
|
@ -581,7 +581,7 @@ TEST_F(LabelTest, ShaderModule) {
|
|||
std::string label = "test";
|
||||
|
||||
const char* source = R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})";
|
||||
|
||||
wgpu::ShaderModuleWGSLDescriptor wgslDesc;
|
||||
|
|
|
@ -74,7 +74,7 @@ namespace {
|
|||
size_t index = 0;
|
||||
for (const BindingDescriptor& b : bindings) {
|
||||
ostream << "struct S" << index << " { " << b.decl << "};\n";
|
||||
ostream << "[[group(" << b.group << "), binding(" << b.binding << ")]] ";
|
||||
ostream << "@group(" << b.group << ") @binding(" << b.binding << ") ";
|
||||
switch (b.type) {
|
||||
case wgpu::BufferBindingType::Uniform:
|
||||
ostream << "var<uniform> b" << index << " : S" << index << ";\n";
|
||||
|
@ -115,21 +115,21 @@ namespace {
|
|||
// Creates a compute shader with given bindings
|
||||
std::string CreateComputeShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
|
||||
return kStructs + GenerateBindingString(bindings) +
|
||||
"[[stage(compute), workgroup_size(1,1,1)]] fn main() {\n" +
|
||||
"@stage(compute) @workgroup_size(1,1,1) fn main() {\n" +
|
||||
GenerateReferenceString(bindings, wgpu::ShaderStage::Compute) + "}";
|
||||
}
|
||||
|
||||
// Creates a vertex shader with given bindings
|
||||
std::string CreateVertexShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
|
||||
return kStructs + GenerateBindingString(bindings) +
|
||||
"[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {\n" +
|
||||
"@stage(vertex) fn main() -> @builtin(position) vec4<f32> {\n" +
|
||||
GenerateReferenceString(bindings, wgpu::ShaderStage::Vertex) +
|
||||
"\n return vec4<f32>(); " + "}";
|
||||
}
|
||||
|
||||
// Creates a fragment shader with given bindings
|
||||
std::string CreateFragmentShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
|
||||
return kStructs + GenerateBindingString(bindings) + "[[stage(fragment)]] fn main() {\n" +
|
||||
return kStructs + GenerateBindingString(bindings) + "@stage(fragment) fn main() {\n" +
|
||||
GenerateReferenceString(bindings, wgpu::ShaderStage::Fragment) + "}";
|
||||
}
|
||||
|
||||
|
@ -565,11 +565,10 @@ TEST_F(MinBufferSizeDefaultLayoutTests, MultipleBindGroups) {
|
|||
|
||||
// Test the minimum size computations with manual size/align/stride decorations.
|
||||
TEST_F(MinBufferSizeDefaultLayoutTests, NonDefaultLayout) {
|
||||
CheckShaderBindingSizeReflection(
|
||||
{{{0, 0, "[[size(256)]] a : u32; b : u32;", "u32", "a", 260},
|
||||
{0, 1, "c : u32; [[align(16)]] d : u32;", "u32", "c", 20},
|
||||
{0, 2, "d : [[stride(40)]] array<u32, 3>;", "u32", "d[0]", 120},
|
||||
{0, 3, "e : [[stride(40)]] array<u32>;", "u32", "e[0]", 40}}});
|
||||
CheckShaderBindingSizeReflection({{{0, 0, "@size(256) a : u32; b : u32;", "u32", "a", 260},
|
||||
{0, 1, "c : u32; @align(16) d : u32;", "u32", "c", 20},
|
||||
{0, 2, "d : @stride(40) array<u32, 3>;", "u32", "d[0]", 120},
|
||||
{0, 3, "e : @stride(40) array<u32>;", "u32", "e[0]", 40}}});
|
||||
}
|
||||
|
||||
// Minimum size should be the max requirement of both vertex and fragment stages.
|
||||
|
|
|
@ -33,7 +33,7 @@ TEST_F(MultipleDeviceTest, ValidatesSameDevice) {
|
|||
TEST_F(MultipleDeviceTest, ValidatesSameDeviceCreatePipelineAsync) {
|
||||
wgpu::ShaderModuleWGSLDescriptor wgslDesc = {};
|
||||
wgslDesc.source = R"(
|
||||
[[stage(compute), workgroup_size(1, 1, 1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1, 1, 1) fn main() {
|
||||
}
|
||||
)";
|
||||
|
||||
|
|
|
@ -20,19 +20,19 @@ class ComputePipelineOverridableConstantsValidationTest : public ValidationTest
|
|||
protected:
|
||||
void SetUpShadersWithDefaultValueConstants() {
|
||||
computeModule = utils::CreateShaderModule(device, R"(
|
||||
[[override]] let c0: bool = true; // type: bool
|
||||
[[override]] let c1: bool = false; // default override
|
||||
[[override]] let c2: f32 = 0.0; // type: float32
|
||||
[[override]] let c3: f32 = 0.0; // default override
|
||||
[[override]] let c4: f32 = 4.0; // default
|
||||
[[override]] let c5: i32 = 0; // type: int32
|
||||
[[override]] let c6: i32 = 0; // default override
|
||||
[[override]] let c7: i32 = 7; // default
|
||||
[[override]] let c8: u32 = 0u; // type: uint32
|
||||
[[override]] let c9: u32 = 0u; // default override
|
||||
[[override(1000)]] let c10: u32 = 10u; // default
|
||||
@override let c0: bool = true; // type: bool
|
||||
@override let c1: bool = false; // default override
|
||||
@override let c2: f32 = 0.0; // type: float32
|
||||
@override let c3: f32 = 0.0; // default override
|
||||
@override let c4: f32 = 4.0; // default
|
||||
@override let c5: i32 = 0; // type: int32
|
||||
@override let c6: i32 = 0; // default override
|
||||
@override let c7: i32 = 7; // default
|
||||
@override let c8: u32 = 0u; // type: uint32
|
||||
@override let c9: u32 = 0u; // default override
|
||||
@override(1000) let c10: u32 = 10u; // default
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
// make sure the overridable constants are not optimized out
|
||||
_ = u32(c0);
|
||||
_ = u32(c1);
|
||||
|
@ -50,19 +50,19 @@ class ComputePipelineOverridableConstantsValidationTest : public ValidationTest
|
|||
|
||||
void SetUpShadersWithUninitializedConstants() {
|
||||
computeModule = utils::CreateShaderModule(device, R"(
|
||||
[[override]] let c0: bool; // type: bool
|
||||
[[override]] let c1: bool = false; // default override
|
||||
[[override]] let c2: f32; // type: float32
|
||||
[[override]] let c3: f32 = 0.0; // default override
|
||||
[[override]] let c4: f32 = 4.0; // default
|
||||
[[override]] let c5: i32; // type: int32
|
||||
[[override]] let c6: i32 = 0; // default override
|
||||
[[override]] let c7: i32 = 7; // default
|
||||
[[override]] let c8: u32; // type: uint32
|
||||
[[override]] let c9: u32 = 0u; // default override
|
||||
[[override(1000)]] let c10: u32 = 10u; // default
|
||||
@override let c0: bool; // type: bool
|
||||
@override let c1: bool = false; // default override
|
||||
@override let c2: f32; // type: float32
|
||||
@override let c3: f32 = 0.0; // default override
|
||||
@override let c4: f32 = 4.0; // default
|
||||
@override let c5: i32; // type: int32
|
||||
@override let c6: i32 = 0; // default override
|
||||
@override let c7: i32 = 7; // default
|
||||
@override let c8: u32; // type: uint32
|
||||
@override let c9: u32 = 0u; // default override
|
||||
@override(1000) let c10: u32 = 10u; // default
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
// make sure the overridable constants are not optimized out
|
||||
_ = u32(c0);
|
||||
_ = u32(c1);
|
||||
|
|
|
@ -33,11 +33,11 @@ namespace {
|
|||
// Create a NoOp pipeline
|
||||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
pipelineDescriptor.cFragment.targets = nullptr;
|
||||
pipelineDescriptor.cFragment.targetCount = 0;
|
||||
|
|
|
@ -175,12 +175,12 @@ namespace {
|
|||
};
|
||||
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -211,7 +211,7 @@ namespace {
|
|||
|
||||
wgpu::ComputePipelineDescriptor descriptor;
|
||||
descriptor.compute.module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
descriptor.compute.entryPoint = "main";
|
||||
device.CreateComputePipelineAsync(&descriptor, callback, &callbackData);
|
||||
|
@ -236,7 +236,7 @@ namespace {
|
|||
cpDesc.layout = utils::MakePipelineLayout(device, {emptyBGL, testBGL});
|
||||
cpDesc.compute.entryPoint = "main";
|
||||
cpDesc.compute.module =
|
||||
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
|
||||
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
|
||||
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&cpDesc);
|
||||
|
||||
wgpu::BufferDescriptor bufDesc;
|
||||
|
@ -304,7 +304,7 @@ namespace {
|
|||
cpDesc.layout = utils::MakePipelineLayout(device, {emptyBGL, emptyBGL, testBGL});
|
||||
cpDesc.compute.entryPoint = "main";
|
||||
cpDesc.compute.module =
|
||||
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
|
||||
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
|
||||
wgpu::ComputePipeline pipeline = device.CreateComputePipeline(&cpDesc);
|
||||
|
||||
wgpu::TextureDescriptor texDesc;
|
||||
|
|
|
@ -31,9 +31,9 @@ namespace {
|
|||
struct S {
|
||||
transform : mat2x2<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> uniforms : S;
|
||||
@group(0) @binding(0) var<uniform> uniforms : S;
|
||||
|
||||
[[stage(vertex)]] fn main([[location(0)]] pos : vec2<f32>) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
|
@ -41,14 +41,14 @@ namespace {
|
|||
struct Uniforms {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(1), binding(0)]] var<uniform> uniforms : Uniforms;
|
||||
@group(1) @binding(0) var<uniform> uniforms : Uniforms;
|
||||
|
||||
struct Storage {
|
||||
dummy : array<f32>;
|
||||
};
|
||||
[[group(1), binding(1)]] var<storage, read_write> ssbo : Storage;
|
||||
@group(1) @binding(1) var<storage, read_write> ssbo : Storage;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
|
||||
wgpu::BindGroupLayout bgls[] = {
|
||||
|
|
|
@ -27,17 +27,17 @@ class RenderPipelineValidationTest : public ValidationTest {
|
|||
ValidationTest::SetUp();
|
||||
|
||||
vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
fsModuleUint = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<u32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<u32> {
|
||||
return vec4<u32>(0u, 255u, 0u, 255u);
|
||||
})");
|
||||
}
|
||||
|
@ -288,7 +288,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputFormatCompatibility) {
|
|||
descriptor.vertex.module = vsModule;
|
||||
std::ostringstream stream;
|
||||
stream << R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<)"
|
||||
@stage(fragment) fn main() -> @location(0) vec4<)"
|
||||
<< kScalarTypes[i] << R"(> {
|
||||
var result : vec4<)"
|
||||
<< kScalarTypes[i] << R"(>;
|
||||
|
@ -329,7 +329,7 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputComponentCountCompatibility)
|
|||
|
||||
std::ostringstream stream;
|
||||
stream << R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] )";
|
||||
@stage(fragment) fn main() -> @location(0) )";
|
||||
switch (componentCount) {
|
||||
case 1:
|
||||
stream << R"(f32 {
|
||||
|
@ -737,10 +737,10 @@ TEST_F(RenderPipelineValidationTest, TextureComponentTypeCompatibility) {
|
|||
|
||||
std::ostringstream stream;
|
||||
stream << R"(
|
||||
[[group(0), binding(0)]] var myTexture : texture_2d<)"
|
||||
@group(0) @binding(0) var myTexture : texture_2d<)"
|
||||
<< kScalarTypes[i] << R"(>;
|
||||
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})";
|
||||
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
|
||||
|
@ -787,9 +787,9 @@ TEST_F(RenderPipelineValidationTest, TextureViewDimensionCompatibility) {
|
|||
|
||||
std::ostringstream stream;
|
||||
stream << R"(
|
||||
[[group(0), binding(0)]] var myTexture : )"
|
||||
@group(0) @binding(0) var myTexture : )"
|
||||
<< kTextureKeywords[i] << R"(<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(myTexture);
|
||||
})";
|
||||
descriptor.cFragment.module = utils::CreateShaderModule(device, stream.str().c_str());
|
||||
|
@ -816,8 +816,8 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
|
|||
struct Dst {
|
||||
data : array<u32, 100>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read_write> dst : Dst;
|
||||
[[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@group(0) @binding(0) var<storage, read_write> dst : Dst;
|
||||
@stage(vertex) fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
|
||||
dst.data[VertexIndex] = 0x1234u;
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
@ -918,11 +918,11 @@ TEST_F(RenderPipelineValidationTest, DepthCompareUndefinedIsError) {
|
|||
// Test that the entryPoint names must be present for the correct stage in the shader module.
|
||||
TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn vertex_main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex_main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
|
||||
[[stage(fragment)]] fn fragment_main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn fragment_main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
@ -964,12 +964,12 @@ TEST_F(RenderPipelineValidationTest, EntryPointNameValidation) {
|
|||
// Test that vertex attrib validation is for the correct entryPoint
|
||||
TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn vertex0([[location(0)]] attrib0 : vec4<f32>)
|
||||
-> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex0(@location(0) attrib0 : vec4<f32>)
|
||||
-> @builtin(position) vec4<f32> {
|
||||
return attrib0;
|
||||
}
|
||||
[[stage(vertex)]] fn vertex1([[location(1)]] attrib1 : vec4<f32>)
|
||||
-> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex1(@location(1) attrib1 : vec4<f32>)
|
||||
-> @builtin(position) vec4<f32> {
|
||||
return attrib1;
|
||||
}
|
||||
)");
|
||||
|
@ -1006,10 +1006,10 @@ TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
|
|||
// Test that fragment output validation is for the correct entryPoint
|
||||
TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
|
||||
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn fragmentFloat() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn fragmentFloat() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
[[stage(fragment)]] fn fragmentUint() -> [[location(0)]] vec4<u32> {
|
||||
@stage(fragment) fn fragmentUint() -> @location(0) vec4<u32> {
|
||||
return vec4<u32>(0u, 0u, 0u, 0u);
|
||||
}
|
||||
)");
|
||||
|
@ -1040,33 +1040,33 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputCorrectEntryPoint) {
|
|||
// Test that unwritten fragment outputs must have a write mask of 0.
|
||||
TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)");
|
||||
|
||||
wgpu::ShaderModule fsModuleWriteNone = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {}
|
||||
@stage(fragment) fn main() {}
|
||||
)");
|
||||
|
||||
wgpu::ShaderModule fsModuleWrite0 = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)");
|
||||
|
||||
wgpu::ShaderModule fsModuleWrite1 = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(1)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(1) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
}
|
||||
)");
|
||||
|
||||
wgpu::ShaderModule fsModuleWriteBoth = utils::CreateShaderModule(device, R"(
|
||||
struct FragmentOut {
|
||||
[[location(0)]] target0 : vec4<f32>;
|
||||
[[location(1)]] target1 : vec4<f32>;
|
||||
@location(0) target0 : vec4<f32>;
|
||||
@location(1) target1 : vec4<f32>;
|
||||
};
|
||||
[[stage(fragment)]] fn main() -> FragmentOut {
|
||||
@stage(fragment) fn main() -> FragmentOut {
|
||||
var out : FragmentOut;
|
||||
return out;
|
||||
}
|
||||
|
@ -1175,13 +1175,13 @@ TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
|
|||
struct Uniforms {
|
||||
data : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> var0 : Uniforms;
|
||||
[[group(0), binding(1)]] var<uniform> var1 : Uniforms;
|
||||
@group(0) @binding(0) var<uniform> var0 : Uniforms;
|
||||
@group(0) @binding(1) var<uniform> var1 : Uniforms;
|
||||
|
||||
[[stage(vertex)]] fn vertex0() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex0() -> @builtin(position) vec4<f32> {
|
||||
return var0.data;
|
||||
}
|
||||
[[stage(vertex)]] fn vertex1() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn vertex1() -> @builtin(position) vec4<f32> {
|
||||
return var1.data;
|
||||
}
|
||||
)");
|
||||
|
@ -1272,34 +1272,34 @@ class InterStageVariableMatchingValidationTest : public RenderPipelineValidation
|
|||
TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocation) {
|
||||
wgpu::ShaderModule vertexModuleOutputAtLocation0 = utils::CreateShaderModule(device, R"(
|
||||
struct A {
|
||||
[[location(0)]] vout: f32;
|
||||
[[builtin(position)]] pos: vec4<f32>;
|
||||
@location(0) vout: f32;
|
||||
@builtin(position) pos: vec4<f32>;
|
||||
};
|
||||
[[stage(vertex)]] fn main() -> A {
|
||||
@stage(vertex) fn main() -> A {
|
||||
var vertexOut: A;
|
||||
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
return vertexOut;
|
||||
})");
|
||||
wgpu::ShaderModule fragmentModuleAtLocation0 = utils::CreateShaderModule(device, R"(
|
||||
struct B {
|
||||
[[location(0)]] fin: f32;
|
||||
@location(0) fin: f32;
|
||||
};
|
||||
[[stage(fragment)]] fn main(fragmentIn: B) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(fragmentIn: B) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(fragmentIn.fin, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule fragmentModuleInputAtLocation1 = utils::CreateShaderModule(device, R"(
|
||||
struct A {
|
||||
[[location(1)]] vout: f32;
|
||||
@location(1) vout: f32;
|
||||
};
|
||||
[[stage(fragment)]] fn main(vertexOut: A) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(vertexOut: A) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(vertexOut.vout, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
wgpu::ShaderModule vertexModuleOutputAtLocation1 = utils::CreateShaderModule(device, R"(
|
||||
struct B {
|
||||
[[location(1)]] fin: f32;
|
||||
[[builtin(position)]] pos: vec4<f32>;
|
||||
@location(1) fin: f32;
|
||||
@builtin(position) pos: vec4<f32>;
|
||||
};
|
||||
[[stage(vertex)]] fn main() -> B {
|
||||
@stage(vertex) fn main() -> B {
|
||||
var fragmentIn: B;
|
||||
fragmentIn.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
return fragmentIn;
|
||||
|
@ -1334,15 +1334,15 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
|
|||
std::string interfaceDeclaration;
|
||||
{
|
||||
std::ostringstream sstream;
|
||||
sstream << "struct A { [[location(0)]] a: " << kTypes[i] << ";" << std::endl;
|
||||
sstream << "struct A { @location(0) a: " << kTypes[i] << ";" << std::endl;
|
||||
interfaceDeclaration = sstream.str();
|
||||
}
|
||||
{
|
||||
std::ostringstream vertexStream;
|
||||
vertexStream << interfaceDeclaration << R"(
|
||||
[[builtin(position)]] pos: vec4<f32>;
|
||||
@builtin(position) pos: vec4<f32>;
|
||||
};
|
||||
[[stage(vertex)]] fn main() -> A {
|
||||
@stage(vertex) fn main() -> A {
|
||||
var vertexOut: A;
|
||||
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
return vertexOut;
|
||||
|
@ -1353,7 +1353,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
|
|||
std::ostringstream fragmentStream;
|
||||
fragmentStream << interfaceDeclaration << R"(
|
||||
};
|
||||
[[stage(fragment)]] fn main(fragmentIn: A) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());
|
||||
|
@ -1420,9 +1420,9 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
|
|||
{
|
||||
const auto& interpolationAttribute = validInterpolationAttributes[i];
|
||||
std::ostringstream sstream;
|
||||
sstream << "struct A { [[location(0)";
|
||||
sstream << "struct A { @location(0)";
|
||||
if (interpolationAttribute.interpolationType != InterpolationType::None) {
|
||||
sstream << ", interpolate("
|
||||
sstream << " @interpolate("
|
||||
<< kInterpolationTypeString[static_cast<uint8_t>(
|
||||
interpolationAttribute.interpolationType)];
|
||||
if (interpolationAttribute.interpolationSampling != InterpolationSampling::None) {
|
||||
|
@ -1432,15 +1432,15 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
|
|||
}
|
||||
sstream << ")";
|
||||
}
|
||||
sstream << " ]] a : vec4<f32>;" << std::endl;
|
||||
sstream << " a : vec4<f32>;" << std::endl;
|
||||
interfaceDeclaration = sstream.str();
|
||||
}
|
||||
{
|
||||
std::ostringstream vertexStream;
|
||||
vertexStream << interfaceDeclaration << R"(
|
||||
[[builtin(position)]] pos: vec4<f32>;
|
||||
@builtin(position) pos: vec4<f32>;
|
||||
};
|
||||
[[stage(vertex)]] fn main() -> A {
|
||||
@stage(vertex) fn main() -> A {
|
||||
var vertexOut: A;
|
||||
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
return vertexOut;
|
||||
|
@ -1451,7 +1451,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
|
|||
std::ostringstream fragmentStream;
|
||||
fragmentStream << interfaceDeclaration << R"(
|
||||
};
|
||||
[[stage(fragment)]] fn main(fragmentIn: A) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(fragmentIn: A) -> @location(0) vec4<f32> {
|
||||
return fragmentIn.a;
|
||||
})";
|
||||
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());
|
||||
|
@ -1463,7 +1463,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
|
|||
attribute.interpolationSampling};
|
||||
switch (attribute.interpolationType) {
|
||||
// If the interpolation attribute is not specified, then
|
||||
// [[interpolate(perspective, center)]] or [[interpolate(perspective)]] is assumed.
|
||||
// @interpolate(perspective, center) or @interpolate(perspective) is assumed.
|
||||
case InterpolationType::None:
|
||||
appliedAttribute.interpolationType = InterpolationType::Perspective;
|
||||
appliedAttribute.interpolationSampling = InterpolationSampling::Center;
|
||||
|
|
|
@ -48,12 +48,12 @@ namespace {
|
|||
// pipeline. But those bind groups in caller can be used for validation for other purposes.
|
||||
wgpu::RenderPipeline CreateNoOpRenderPipeline() {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() {
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -65,7 +65,7 @@ namespace {
|
|||
|
||||
wgpu::ComputePipeline CreateNoOpComputePipeline(std::vector<wgpu::BindGroupLayout> bgls) {
|
||||
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
})");
|
||||
wgpu::ComputePipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.layout = utils::MakePipelineLayout(device, std::move(bgls));
|
||||
|
@ -756,7 +756,7 @@ namespace {
|
|||
|
||||
// Create a passthrough render pipeline with a readonly buffer
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
|
@ -764,8 +764,8 @@ namespace {
|
|||
struct RBuffer {
|
||||
value : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<storage, read> rBuffer : RBuffer;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var<storage, read> rBuffer : RBuffer;
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.vertex.module = vsModule;
|
||||
|
@ -1573,13 +1573,13 @@ namespace {
|
|||
{
|
||||
// Create a passthrough render pipeline with a sampled storage texture
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>();
|
||||
})");
|
||||
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var tex : texture_2d<f32>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var tex : texture_2d<f32>;
|
||||
@stage(fragment) fn main() {
|
||||
})");
|
||||
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
|
||||
pipelineDescriptor.vertex.module = vsModule;
|
||||
|
|
|
@ -60,8 +60,7 @@ TEST_F(ShaderModuleValidationTest, CreationSuccess) {
|
|||
// be compiled.
|
||||
TEST_F(ShaderModuleValidationTest, FragmentOutputLocationExceedsMaxColorAttachments) {
|
||||
std::ostringstream stream;
|
||||
stream << "[[stage(fragment)]] fn main() -> [[location(" << kMaxColorAttachments
|
||||
<< R"()]] vec4<f32> {
|
||||
stream << "@stage(fragment) fn main() -> @location(" << kMaxColorAttachments << R"() vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})";
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, stream.str().c_str()));
|
||||
|
@ -163,7 +162,7 @@ TEST_F(ShaderModuleValidationTest, GetCompilationMessages) {
|
|||
DAWN_SKIP_TEST_IF(UsesWire());
|
||||
|
||||
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -219,14 +218,14 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
|
|||
std::ostringstream stream;
|
||||
stream << "struct ShaderIO {" << std::endl;
|
||||
for (uint32_t location = 1; location <= maximumOutputLocation; ++location) {
|
||||
stream << "[[location(" << location << ")]] var" << location << ": f32;" << std::endl;
|
||||
stream << "@location(" << location << ") var" << location << ": f32;" << std::endl;
|
||||
}
|
||||
switch (shaderStage) {
|
||||
case wgpu::ShaderStage::Vertex: {
|
||||
stream << R"(
|
||||
[[builtin(position)]] pos: vec4<f32>;
|
||||
@builtin(position) pos: vec4<f32>;
|
||||
};
|
||||
[[stage(vertex)]] fn main() -> ShaderIO {
|
||||
@stage(vertex) fn main() -> ShaderIO {
|
||||
var shaderIO : ShaderIO;
|
||||
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
return shaderIO;
|
||||
|
@ -236,7 +235,7 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
|
|||
case wgpu::ShaderStage::Fragment: {
|
||||
stream << R"(
|
||||
};
|
||||
[[stage(fragment)]] fn main(shaderIO: ShaderIO) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(shaderIO: ShaderIO) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
} break;
|
||||
|
@ -293,14 +292,13 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
uint32_t vec4InputLocations = totalUserDefinedInterStageShaderComponentCount / 4;
|
||||
|
||||
for (uint32_t location = 0; location < vec4InputLocations; ++location) {
|
||||
stream << "[[location(" << location << ")]] var" << location << ": vec4<f32>;"
|
||||
stream << "@location(" << location << ") var" << location << ": vec4<f32>;"
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
uint32_t lastComponentCount = totalUserDefinedInterStageShaderComponentCount % 4;
|
||||
if (lastComponentCount > 0) {
|
||||
stream << "[[location(" << vec4InputLocations << ")]] var" << vec4InputLocations
|
||||
<< ": ";
|
||||
stream << "@location(" << vec4InputLocations << ") var" << vec4InputLocations << ": ";
|
||||
if (lastComponentCount == 1) {
|
||||
stream << "f32;";
|
||||
} else {
|
||||
|
@ -312,9 +310,9 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
switch (shaderStage) {
|
||||
case wgpu::ShaderStage::Vertex: {
|
||||
stream << R"(
|
||||
[[builtin(position)]] pos: vec4<f32>;
|
||||
@builtin(position) pos: vec4<f32>;
|
||||
};
|
||||
[[stage(vertex)]] fn main() -> ShaderIO {
|
||||
@stage(vertex) fn main() -> ShaderIO {
|
||||
var shaderIO : ShaderIO;
|
||||
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
return shaderIO;
|
||||
|
@ -324,7 +322,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
case wgpu::ShaderStage::Fragment: {
|
||||
stream << R"(
|
||||
};
|
||||
[[stage(fragment)]] fn main(shaderIO: ShaderIO) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(shaderIO: ShaderIO) -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})";
|
||||
} break;
|
||||
|
@ -350,8 +348,8 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, errorFragmentShader.c_str()));
|
||||
}
|
||||
|
||||
// [[position]] should be counted into the maximum inter-stage component count.
|
||||
// Note that in vertex shader we always have [[position]] so we don't need to specify it
|
||||
// @position should be counted into the maximum inter-stage component count.
|
||||
// Note that in vertex shader we always have @position so we don't need to specify it
|
||||
// again in the parameter "builtInDeclarations" of generateShaderForTest().
|
||||
{
|
||||
constexpr uint32_t kInterStageShaderComponentCount = kMaxInterStageShaderComponents - 4;
|
||||
|
@ -361,7 +359,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
|
||||
std::string fragmentShader =
|
||||
generateShaderForTest(kInterStageShaderComponentCount, wgpu::ShaderStage::Fragment,
|
||||
"[[builtin(position)]] fragCoord: vec4<f32>;");
|
||||
"@builtin(position) fragCoord: vec4<f32>;");
|
||||
utils::CreateShaderModule(device, fragmentShader.c_str());
|
||||
}
|
||||
|
||||
|
@ -373,13 +371,13 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
|
||||
std::string fragmentShader =
|
||||
generateShaderForTest(kInterStageShaderComponentCount, wgpu::ShaderStage::Fragment,
|
||||
"[[builtin(position)]] fragCoord: vec4<f32>;");
|
||||
"@builtin(position) fragCoord: vec4<f32>;");
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, fragmentShader.c_str()));
|
||||
}
|
||||
|
||||
// [[front_facing]] should be counted into the maximum inter-stage component count.
|
||||
// front_facing should be counted into the maximum inter-stage component count.
|
||||
{
|
||||
const char* builtinDeclaration = "[[builtin(front_facing)]] frontFacing : bool;";
|
||||
const char* builtinDeclaration = "@builtin(front_facing) frontFacing : bool;";
|
||||
|
||||
{
|
||||
std::string fragmentShader =
|
||||
|
@ -395,9 +393,9 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
}
|
||||
}
|
||||
|
||||
// [[sample_index]] should be counted into the maximum inter-stage component count.
|
||||
// @sample_index should be counted into the maximum inter-stage component count.
|
||||
{
|
||||
const char* builtinDeclaration = "[[builtin(sample_index)]] sampleIndex: u32;";
|
||||
const char* builtinDeclaration = "@builtin(sample_index) sampleIndex: u32;";
|
||||
|
||||
{
|
||||
std::string fragmentShader =
|
||||
|
@ -413,9 +411,9 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
}
|
||||
}
|
||||
|
||||
// [[sample_mask]] should be counted into the maximum inter-stage component count.
|
||||
// @sample_mask should be counted into the maximum inter-stage component count.
|
||||
{
|
||||
const char* builtinDeclaration = "[[builtin(front_facing)]] frontFacing : bool;";
|
||||
const char* builtinDeclaration = "@builtin(front_facing) frontFacing : bool;";
|
||||
|
||||
{
|
||||
std::string fragmentShader =
|
||||
|
@ -436,8 +434,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
|
|||
TEST_F(ShaderModuleValidationTest, ComputeWorkgroupSizeLimits) {
|
||||
auto MakeShaderWithWorkgroupSize = [this](uint32_t x, uint32_t y, uint32_t z) {
|
||||
std::ostringstream ss;
|
||||
ss << "[[stage(compute), workgroup_size(" << x << "," << y << "," << z
|
||||
<< ")]] fn main() {}";
|
||||
ss << "@stage(compute) @workgroup_size(" << x << "," << y << "," << z << ") fn main() {}";
|
||||
utils::CreateShaderModule(device, ss.str().c_str());
|
||||
};
|
||||
|
||||
|
@ -482,7 +479,7 @@ TEST_F(ShaderModuleValidationTest, ComputeWorkgroupStorageSizeLimits) {
|
|||
ss << "var<workgroup> mat4_data: array<mat4x4<f32>, " << mat4_count << ">;";
|
||||
body << "_ = mat4_data;";
|
||||
}
|
||||
ss << "[[stage(compute), workgroup_size(1)]] fn main() { " << body.str() << " }";
|
||||
ss << "@stage(compute) @workgroup_size(1) fn main() { " << body.str() << " }";
|
||||
utils::CreateShaderModule(device, ss.str().c_str());
|
||||
};
|
||||
|
||||
|
@ -500,16 +497,16 @@ TEST_F(ShaderModuleValidationTest, ComputeWorkgroupStorageSizeLimits) {
|
|||
// Test that numeric ID must be unique
|
||||
TEST_F(ShaderModuleValidationTest, OverridableConstantsNumericIDConflicts) {
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
|
||||
[[override(1234)]] let c0: u32;
|
||||
[[override(1234)]] let c1: u32;
|
||||
@override(1234) let c0: u32;
|
||||
@override(1234) let c1: u32;
|
||||
|
||||
struct Buf {
|
||||
data : array<u32, 2>;
|
||||
};
|
||||
|
||||
[[group(0), binding(0)]] var<storage, read_write> buf : Buf;
|
||||
@group(0) @binding(0) var<storage, read_write> buf : Buf;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
// make sure the overridable constants are not optimized out
|
||||
buf.data[0] = c0;
|
||||
buf.data[1] = c1;
|
||||
|
|
|
@ -24,11 +24,11 @@ class StorageTextureValidationTests : public ValidationTest {
|
|||
ValidationTest::SetUp();
|
||||
|
||||
mDefaultVSModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
mDefaultFSModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
}
|
||||
|
@ -79,10 +79,10 @@ class StorageTextureValidationTests : public ValidationTest {
|
|||
}
|
||||
|
||||
std::ostringstream ostream;
|
||||
ostream << "[[group(0), binding(0)]] var image0 : " << imageTypeDeclaration << "<"
|
||||
ostream << "@group(0) @binding(0) var image0 : " << imageTypeDeclaration << "<"
|
||||
<< imageFormatQualifier << ", " << access
|
||||
<< ">;\n"
|
||||
"[[stage(compute), workgroup_size(1)]] fn main() {\n"
|
||||
"@stage(compute) @workgroup_size(1) fn main() {\n"
|
||||
" textureDimensions(image0);\n"
|
||||
"}\n";
|
||||
|
||||
|
@ -117,9 +117,9 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
|
|||
// Write-only storage textures cannot be declared in a vertex shader.
|
||||
{
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
|
||||
[[stage(vertex)]]
|
||||
fn main([[builtin(vertex_index)]] vertex_index : u32) -> [[builtin(position)]] vec4<f32> {
|
||||
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
|
||||
@stage(vertex)
|
||||
fn main(@builtin(vertex_index) vertex_index : u32) -> @builtin(position) vec4<f32> {
|
||||
textureStore(image0, vec2<i32>(i32(vertex_index), 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
|
||||
return vec4<f32>(0.0);
|
||||
})");
|
||||
|
@ -134,8 +134,8 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
|
|||
// Write-only storage textures can be declared in a fragment shader.
|
||||
{
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
|
||||
[[stage(fragment)]] fn main([[builtin(position)]] position : vec4<f32>) {
|
||||
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
|
||||
@stage(fragment) fn main(@builtin(position) position : vec4<f32>) {
|
||||
textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
|
||||
})");
|
||||
|
||||
|
@ -154,9 +154,9 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
|
|||
// Write-only storage textures can be declared in a compute shader.
|
||||
{
|
||||
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, write>;
|
||||
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main([[builtin(local_invocation_id)]] LocalInvocationID : vec3<u32>) {
|
||||
@stage(compute) @workgroup_size(1) fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
|
||||
textureStore(image0, vec2<i32>(LocalInvocationID.xy), vec4<f32>(0.0, 0.0, 0.0, 0.0));
|
||||
})");
|
||||
|
||||
|
@ -174,8 +174,8 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
|
|||
// Read-write storage textures cannot be declared in a vertex shader by default.
|
||||
{
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
|
||||
[[stage(vertex)]] fn main() {
|
||||
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
|
||||
@stage(vertex) fn main() {
|
||||
textureDimensions(image0);
|
||||
})"));
|
||||
}
|
||||
|
@ -183,8 +183,8 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
|
|||
// Read-write storage textures cannot be declared in a fragment shader by default.
|
||||
{
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
|
||||
[[stage(fragment)]] fn main() {
|
||||
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
|
||||
@stage(fragment) fn main() {
|
||||
textureDimensions(image0);
|
||||
})"));
|
||||
}
|
||||
|
@ -192,8 +192,8 @@ TEST_F(StorageTextureValidationTests, ReadWriteStorageTexture) {
|
|||
// Read-write storage textures cannot be declared in a compute shader by default.
|
||||
{
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var image0 : texture_storage_2d<rgba8unorm, read_write>;
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, read_write>;
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
textureDimensions(image0);
|
||||
})"));
|
||||
}
|
||||
|
|
|
@ -70,7 +70,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
|
|||
{
|
||||
wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase;
|
||||
pipelineDesc.compute.module =
|
||||
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
|
||||
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
|
||||
|
||||
device.CreateComputePipeline(&pipelineDesc);
|
||||
}
|
||||
|
@ -78,10 +78,10 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
|
|||
// Error case: shader with overridable constant with default value
|
||||
{
|
||||
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
|
||||
[[override(1000)]] let c0: u32 = 1u;
|
||||
[[override(1000)]] let c1: u32;
|
||||
@override(1000) let c0: u32 = 1u;
|
||||
@override(1000) let c1: u32;
|
||||
|
||||
[[stage(compute), workgroup_size(1)]] fn main() {
|
||||
@stage(compute) @workgroup_size(1) fn main() {
|
||||
_ = c0;
|
||||
_ = c1;
|
||||
})"));
|
||||
|
@ -91,7 +91,7 @@ TEST_F(UnsafeAPIValidationTest, PipelineOverridableConstants) {
|
|||
{
|
||||
wgpu::ComputePipelineDescriptor pipelineDesc = pipelineDescBase;
|
||||
pipelineDesc.compute.module =
|
||||
utils::CreateShaderModule(device, "[[stage(compute), workgroup_size(1)]] fn main() {}");
|
||||
utils::CreateShaderModule(device, "@stage(compute) @workgroup_size(1) fn main() {}");
|
||||
std::vector<wgpu::ConstantEntry> constants{{nullptr, "c", 1u}};
|
||||
pipelineDesc.compute.constants = constants.data();
|
||||
pipelineDesc.compute.constantCount = constants.size();
|
||||
|
|
|
@ -26,7 +26,7 @@ class VertexBufferValidationTest : public ValidationTest {
|
|||
ValidationTest::SetUp();
|
||||
|
||||
fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
|
||||
})");
|
||||
}
|
||||
|
@ -41,16 +41,16 @@ class VertexBufferValidationTest : public ValidationTest {
|
|||
|
||||
wgpu::ShaderModule MakeVertexShader(unsigned int bufferCount) {
|
||||
std::ostringstream vs;
|
||||
vs << "[[stage(vertex)]] fn main(\n";
|
||||
vs << "@stage(vertex) fn main(\n";
|
||||
for (unsigned int i = 0; i < bufferCount; ++i) {
|
||||
// TODO(cwallez@chromium.org): remove this special handling of 0 once Tint supports
|
||||
// trailing commas in argument lists.
|
||||
if (i != 0) {
|
||||
vs << ", ";
|
||||
}
|
||||
vs << "[[location(" << i << ")]] a_position" << i << " : vec3<f32>\n";
|
||||
vs << "@location(" << i << ") a_position" << i << " : vec3<f32>\n";
|
||||
}
|
||||
vs << ") -> [[builtin(position)]] vec4<f32> {";
|
||||
vs << ") -> @builtin(position) vec4<f32> {";
|
||||
|
||||
vs << "return vec4<f32>(";
|
||||
for (unsigned int i = 0; i < bufferCount; ++i) {
|
||||
|
|
|
@ -24,7 +24,7 @@ class VertexStateTest : public ValidationTest {
|
|||
const char* vertexSource) {
|
||||
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexSource);
|
||||
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
|
||||
}
|
||||
)");
|
||||
|
@ -44,7 +44,7 @@ class VertexStateTest : public ValidationTest {
|
|||
}
|
||||
|
||||
const char* kDummyVertexShader = R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
)";
|
||||
|
@ -97,28 +97,28 @@ TEST_F(VertexStateTest, PipelineCompatibility) {
|
|||
|
||||
// Control case: pipeline with one input per attribute
|
||||
CreatePipeline(true, state, R"(
|
||||
[[stage(vertex)]] fn main(
|
||||
[[location(0)]] a : vec4<f32>,
|
||||
[[location(1)]] b : vec4<f32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@location(0) a : vec4<f32>,
|
||||
@location(1) b : vec4<f32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Check it is valid for the pipeline to use a subset of the VertexState
|
||||
CreatePipeline(true, state, R"(
|
||||
[[stage(vertex)]] fn main(
|
||||
[[location(0)]] a : vec4<f32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@location(0) a : vec4<f32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
)");
|
||||
|
||||
// Check for an error when the pipeline uses an attribute not in the vertex input
|
||||
CreatePipeline(false, state, R"(
|
||||
[[stage(vertex)]] fn main(
|
||||
[[location(2)]] a : vec4<f32>
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@location(2) a : vec4<f32>
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
}
|
||||
)");
|
||||
|
@ -359,8 +359,8 @@ TEST_F(VertexStateTest, BaseTypeMatching) {
|
|||
state.cVertexBuffers[0].attributeCount = 1;
|
||||
state.cAttributes[0].format = format;
|
||||
|
||||
std::string shader = "[[stage(vertex)]] fn main([[location(0)]] attrib : " + shaderType +
|
||||
R"() -> [[builtin(position)]] vec4<f32> {
|
||||
std::string shader = "@stage(vertex) fn main(@location(0) attrib : " + shaderType +
|
||||
R"() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})";
|
||||
|
||||
|
@ -413,7 +413,7 @@ TEST_F(VertexStateTest, BaseTypeMatchingForInexistentInput) {
|
|||
state.cVertexBuffers[0].attributeCount = 1;
|
||||
state.cAttributes[0].format = format;
|
||||
|
||||
std::string shader = R"([[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
std::string shader = R"(@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})";
|
||||
|
||||
|
|
|
@ -41,9 +41,9 @@ class D3D12DescriptorHeapTests : public DawnTest {
|
|||
|
||||
mSimpleVSModule = utils::CreateShaderModule(device, R"(
|
||||
|
||||
[[stage(vertex)]] fn main(
|
||||
[[builtin(vertex_index)]] VertexIndex : u32
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@builtin(vertex_index) VertexIndex : u32
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -56,9 +56,9 @@ class D3D12DescriptorHeapTests : public DawnTest {
|
|||
struct U {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> colorBuffer : U;
|
||||
@group(0) @binding(0) var<uniform> colorBuffer : U;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return colorBuffer.color;
|
||||
})");
|
||||
}
|
||||
|
@ -176,13 +176,13 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) {
|
|||
// 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::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main() -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main() -> @builtin(position) vec4<f32> {
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
|
||||
[[group(0), binding(0)]] var sampler0 : sampler;
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@group(0) @binding(0) var sampler0 : sampler;
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
_ = sampler0;
|
||||
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
|
||||
})");
|
||||
|
@ -447,9 +447,9 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
|
|||
struct U {
|
||||
heapSize : f32;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> buffer0 : U;
|
||||
@group(0) @binding(0) var<uniform> buffer0 : U;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return vec4<f32>(buffer0.heapSize, 0.0, 0.0, 1.0);
|
||||
})");
|
||||
|
||||
|
@ -780,11 +780,11 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
|
|||
struct U {
|
||||
transform : mat2x2<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> buffer0 : U;
|
||||
@group(0) @binding(0) var<uniform> buffer0 : U;
|
||||
|
||||
[[stage(vertex)]] fn main(
|
||||
[[builtin(vertex_index)]] VertexIndex : u32
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@builtin(vertex_index) VertexIndex : u32
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -796,13 +796,13 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
|
|||
struct U {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(1)]] var sampler0 : sampler;
|
||||
[[group(0), binding(2)]] var texture0 : texture_2d<f32>;
|
||||
[[group(0), binding(3)]] var<uniform> buffer0 : U;
|
||||
@group(0) @binding(1) var sampler0 : sampler;
|
||||
@group(0) @binding(2) var texture0 : texture_2d<f32>;
|
||||
@group(0) @binding(3) var<uniform> buffer0 : U;
|
||||
|
||||
[[stage(fragment)]] fn main(
|
||||
[[builtin(position)]] FragCoord : vec4<f32>
|
||||
) -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main(
|
||||
@builtin(position) FragCoord : vec4<f32>
|
||||
) -> @location(0) vec4<f32> {
|
||||
return textureSample(texture0, sampler0, FragCoord.xy) + buffer0.color;
|
||||
})");
|
||||
|
||||
|
|
|
@ -341,9 +341,9 @@ 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::CreateShaderModule(device, R"(
|
||||
[[stage(vertex)]] fn main(
|
||||
[[builtin(vertex_index)]] VertexIndex : u32
|
||||
) -> [[builtin(position)]] vec4<f32> {
|
||||
@stage(vertex) fn main(
|
||||
@builtin(vertex_index) VertexIndex : u32
|
||||
) -> @builtin(position) vec4<f32> {
|
||||
var pos = array<vec2<f32>, 3>(
|
||||
vec2<f32>(-1.0, 1.0),
|
||||
vec2<f32>( 1.0, 1.0),
|
||||
|
@ -356,9 +356,9 @@ TEST_P(D3D12DescriptorResidencyTests, SwitchedViewHeapResidency) {
|
|||
struct U {
|
||||
color : vec4<f32>;
|
||||
};
|
||||
[[group(0), binding(0)]] var<uniform> colorBuffer : U;
|
||||
@group(0) @binding(0) var<uniform> colorBuffer : U;
|
||||
|
||||
[[stage(fragment)]] fn main() -> [[location(0)]] vec4<f32> {
|
||||
@stage(fragment) fn main() -> @location(0) vec4<f32> {
|
||||
return colorBuffer.color;
|
||||
})");
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue