Modernize some internal WGSL syntax

Change-Id: I4706e517608d436fa646537fec9e930ae47d1c40
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/118029
Commit-Queue: Austin Eng <enga@chromium.org>
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Loko Kung <lokokung@google.com>
This commit is contained in:
Austin Eng 2023-02-02 20:17:46 +00:00 committed by Dawn LUCI CQ
parent 78b14285bc
commit 08027c662e
103 changed files with 1545 additions and 1550 deletions

View File

@ -35,15 +35,15 @@ namespace {
// General helper functions and data structures for applying clear values with draw
static const char kVSSource[] = R"(
@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),
vec2<f32>( 0.0, 1.0),
vec2<f32>( 0.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f( 0.0, -1.0),
vec2f( 1.0, -1.0),
vec2f( 0.0, 1.0),
vec2f( 0.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})";
const char* GetTextureComponentTypeString(DeviceBase* device, wgpu::TextureFormat format) {

View File

@ -34,27 +34,27 @@ constexpr char kBlitRG8ToDepthShaders[] = R"(
@vertex fn vert_fullscreen_quad(
@builtin(vertex_index) vertex_index : u32
) -> @builtin(position) vec4<f32> {
const pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 3.0, -1.0),
vec2<f32>(-1.0, 3.0));
return vec4<f32>(pos[vertex_index], 0.0, 1.0);
) -> @builtin(position) vec4f {
const pos = array(
vec2f(-1.0, -1.0),
vec2f( 3.0, -1.0),
vec2f(-1.0, 3.0));
return vec4f(pos[vertex_index], 0.0, 1.0);
}
struct Params {
origin : vec2<u32>
origin : vec2u
};
@group(0) @binding(0) var src_tex : texture_2d<u32>;
@group(0) @binding(1) var<uniform> params : Params;
@fragment fn blit_to_depth(
@builtin(position) position : vec4<f32>
@builtin(position) position : vec4f
) -> @builtin(frag_depth) f32 {
// Load the source texel.
let src_texel = textureLoad(
src_tex, vec2<u32>(position.xy) - params.origin, 0u);
src_tex, vec2u(position.xy) - params.origin, 0u);
let depth_u16_val = (src_texel.y << 8u) + src_texel.x;
@ -68,7 +68,7 @@ constexpr char kBlitStencilShaders[] = R"(
struct VertexOutputs {
@location(0) @interpolate(flat) stencil_val : u32,
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
};
// The instance_index here is not used for instancing.
@ -80,18 +80,18 @@ struct VertexOutputs {
@builtin(vertex_index) vertex_index : u32,
@builtin(instance_index) instance_index: u32,
) -> VertexOutputs {
const pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 3.0, -1.0),
vec2<f32>(-1.0, 3.0));
const pos = array(
vec2f(-1.0, -1.0),
vec2f( 3.0, -1.0),
vec2f(-1.0, 3.0));
return VertexOutputs(
instance_index,
vec4<f32>(pos[vertex_index], 0.0, 1.0),
vec4f(pos[vertex_index], 0.0, 1.0),
);
}
struct Params {
origin : vec2<u32>
origin : vec2u
};
@group(0) @binding(0) var src_tex : texture_2d<u32>;
@ -106,7 +106,7 @@ struct Params {
@fragment fn frag_check_src_stencil(input : VertexOutputs) {
// Load the source stencil value.
let src_val : u32 = textureLoad(
src_tex, vec2<u32>(input.position.xy) - params.origin, 0u)[0];
src_tex, vec2u(input.position.xy) - params.origin, 0u)[0];
// Discard it if it doesn't contain the stencil reference.
if ((src_val & input.stencil_val) == 0u) {

View File

@ -33,19 +33,19 @@ constexpr char kBlitToDepthShaders[] = R"(
@vertex fn vert_fullscreen_quad(
@builtin(vertex_index) vertex_index : u32,
) -> @builtin(position) vec4<f32> {
const pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 3.0, -1.0),
vec2<f32>(-1.0, 3.0));
return vec4<f32>(pos[vertex_index], 0.0, 1.0);
) -> @builtin(position) vec4f {
const pos = array(
vec2f(-1.0, -1.0),
vec2f( 3.0, -1.0),
vec2f(-1.0, 3.0));
return vec4f(pos[vertex_index], 0.0, 1.0);
}
@group(0) @binding(0) var src_tex : texture_depth_2d;
// Load the depth value and return it as the frag_depth.
@fragment fn blit_to_depth(@builtin(position) position : vec4<f32>) -> @builtin(frag_depth) f32 {
return textureLoad(src_tex, vec2<u32>(position.xy), 0);
@fragment fn blit_to_depth(@builtin(position) position : vec4f) -> @builtin(frag_depth) f32 {
return textureLoad(src_tex, vec2u(position.xy), 0);
}
)";

View File

@ -50,8 +50,8 @@ static const char sCopyForBrowserShader[] = R"(
};
struct Uniforms { // offset align size
scale: vec2<f32>, // 0 8 8
offset: vec2<f32>, // 8 8 8
scale: vec2f, // 0 8 8
offset: vec2f, // 8 8 8
steps_mask: u32, // 16 4 4
// implicit padding; // 20 12
conversion_matrix: mat3x3<f32>, // 32 16 48
@ -63,8 +63,8 @@ static const char sCopyForBrowserShader[] = R"(
@binding(0) @group(0) var<uniform> uniforms : Uniforms;
struct VertexOutputs {
@location(0) texcoords : vec2<f32>,
@builtin(position) position : vec4<f32>,
@location(0) texcoords : vec2f,
@builtin(position) position : vec4f,
};
// Chromium uses unified equation to construct gamma decoding function
@ -89,13 +89,13 @@ static const char sCopyForBrowserShader[] = R"(
fn vs_main(
@builtin(vertex_index) VertexIndex : u32
) -> VertexOutputs {
var texcoord = array<vec2<f32>, 3>(
vec2<f32>(-0.5, 0.0),
vec2<f32>( 1.5, 0.0),
vec2<f32>( 0.5, 2.0));
var texcoord = array(
vec2f(-0.5, 0.0),
vec2f( 1.5, 0.0),
vec2f( 0.5, 2.0));
var output : VertexOutputs;
output.position = vec4<f32>((texcoord[VertexIndex] * 2.0 - vec2<f32>(1.0, 1.0)), 0.0, 1.0);
output.position = vec4f((texcoord[VertexIndex] * 2.0 - vec2f(1.0, 1.0)), 0.0, 1.0);
output.texcoords = texcoord[VertexIndex] * uniforms.scale + uniforms.offset;
return output;
@ -109,15 +109,15 @@ static const char sCopyForBrowserShader[] = R"(
// Resource used in copyExternalTexture entry point only.
@binding(2) @group(0) var mySourceExternalTexture: texture_external;
fn discardIfOutsideOfCopy(texcoord : vec2<f32>) {
fn discardIfOutsideOfCopy(texcoord : vec2f) {
var clampedTexcoord =
clamp(texcoord, vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 1.0));
clamp(texcoord, vec2f(0.0, 0.0), vec2f(1.0, 1.0));
if (!all(clampedTexcoord == texcoord)) {
discard;
}
}
fn transform(srcColor : vec4<f32>) -> vec4<f32> {
fn transform(srcColor : vec4f) -> vec4f {
var color = srcColor;
let kUnpremultiplyStep = 0x01u;
let kDecodeToLinearStep = 0x02u;
@ -132,14 +132,14 @@ static const char sCopyForBrowserShader[] = R"(
// This step is exclusive with clear src alpha to one step.
if (bool(uniforms.steps_mask & kUnpremultiplyStep)) {
if (color.a != 0.0) {
color = vec4<f32>(color.rgb / color.a, color.a);
color = vec4f(color.rgb / color.a, color.a);
}
}
// Linearize the source color using the source color spaces
// transfer function if it is non-linear.
if (bool(uniforms.steps_mask & kDecodeToLinearStep)) {
color = vec4<f32>(gamma_conversion(color.r, uniforms.gamma_decoding_params),
color = vec4f(gamma_conversion(color.r, uniforms.gamma_decoding_params),
gamma_conversion(color.g, uniforms.gamma_decoding_params),
gamma_conversion(color.b, uniforms.gamma_decoding_params),
color.a);
@ -149,13 +149,13 @@ static const char sCopyForBrowserShader[] = R"(
// multiplying by a 3x3 matrix. Calculate transformFromXYZD50 * transformToXYZD50
// in CPU side and upload the final result in uniforms.
if (bool(uniforms.steps_mask & kConvertToDstGamutStep)) {
color = vec4<f32>(uniforms.conversion_matrix * color.rgb, color.a);
color = vec4f(uniforms.conversion_matrix * color.rgb, color.a);
}
// Encode that color using the inverse of the destination color
// spaces transfer function if it is non-linear.
if (bool(uniforms.steps_mask & kEncodeToGammaStep)) {
color = vec4<f32>(gamma_conversion(color.r, uniforms.gamma_encoding_params),
color = vec4f(gamma_conversion(color.r, uniforms.gamma_encoding_params),
gamma_conversion(color.g, uniforms.gamma_encoding_params),
gamma_conversion(color.b, uniforms.gamma_encoding_params),
color.a);
@ -164,12 +164,12 @@ static const char sCopyForBrowserShader[] = R"(
// Premultiply step.
// This step is exclusive with clear src alpha to one step.
if (bool(uniforms.steps_mask & kPremultiplyStep)) {
color = vec4<f32>(color.rgb * color.a, color.a);
color = vec4f(color.rgb * color.a, color.a);
}
// Decode for copying from non-srgb formats to srgb formats
if (bool(uniforms.steps_mask & kDecodeForSrgbDstFormat)) {
color = vec4<f32>(gamma_conversion(color.r, uniforms.gamma_decoding_for_dst_srgb_params),
color = vec4f(gamma_conversion(color.r, uniforms.gamma_decoding_for_dst_srgb_params),
gamma_conversion(color.g, uniforms.gamma_decoding_for_dst_srgb_params),
gamma_conversion(color.b, uniforms.gamma_decoding_for_dst_srgb_params),
color.a);
@ -185,8 +185,8 @@ static const char sCopyForBrowserShader[] = R"(
}
@fragment
fn copyTexture(@location(0) texcoord : vec2<f32>
) -> @location(0) vec4<f32> {
fn copyTexture(@location(0) texcoord : vec2f
) -> @location(0) vec4f {
var color = textureSample(mySourceTexture, mySampler, texcoord);
// TODO(crbug.com/tint/1723): Discard before sampling should be valid.
@ -196,8 +196,8 @@ static const char sCopyForBrowserShader[] = R"(
}
@fragment
fn copyExternalTexture(@location(0) texcoord : vec2<f32>
) -> @location(0) vec4<f32> {
fn copyExternalTexture(@location(0) texcoord : vec2f
) -> @location(0) vec4f {
var color = textureSampleBaseClampToEdge(mySourceExternalTexture, mySampler, texcoord);
// TODO(crbug.com/tint/1723): Discard before sampling should be valid.

View File

@ -131,7 +131,7 @@ static const char sRenderValidationShaderSource[] = R"(
}
@compute @workgroup_size(64, 1, 1)
fn main(@builtin(global_invocation_id) id : vec3<u32>) {
fn main(@builtin(global_invocation_id) id : vec3u) {
if (id.x >= batch.numDraws) {
return;
}

View File

@ -67,7 +67,7 @@ static const char sConvertTimestampsToNanoseconds[] = R"(
const sizeofTimestamp : u32 = 8u;
@compute @workgroup_size(8, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
if (GlobalInvocationID.x >= params.count) { return; }
var index = GlobalInvocationID.x + params.offset / sizeofTimestamp;

View File

@ -68,25 +68,25 @@ void init() {
@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 : vec4f,
@builtin(position) Position : vec4f,
};
@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),
vec4<f32>( 0.1, -0.1, 0.0, 1.0)
var positions : array<vec4f, 3> = array(
vec4f( 0.0, 0.1, 0.0, 1.0),
vec4f(-0.1, -0.1, 0.0, 1.0),
vec4f( 0.1, -0.1, 0.0, 1.0)
);
var colors : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
vec4<f32>(1.0, 0.0, 0.0, 1.0),
vec4<f32>(0.0, 1.0, 0.0, 1.0),
vec4<f32>(0.0, 0.0, 1.0, 1.0)
var colors : array<vec4f, 3> = array(
vec4f(1.0, 0.0, 0.0, 1.0),
vec4f(0.0, 1.0, 0.0, 1.0),
vec4f(0.0, 0.0, 1.0, 1.0)
);
var position : vec4<f32> = positions[VertexIndex];
var color : vec4<f32> = colors[VertexIndex];
var position : vec4f = positions[VertexIndex];
var color : vec4f = colors[VertexIndex];
// TODO(dawn:572): Revisit once modf has been reworked in WGSL.
var fade : f32 = c.scalarOffset + c.time * c.scalar / 10.0;
@ -106,13 +106,13 @@ void init() {
ypos = yrot + c.offsetY;
var output : VertexOut;
output.v_color = vec4<f32>(fade, 1.0 - fade, 0.0, 1.0) + color;
output.Position = vec4<f32>(xpos, ypos, 0.0, 1.0);
output.v_color = vec4f(fade, 1.0 - fade, 0.0, 1.0) + color;
output.Position = vec4f(xpos, ypos, 0.0, 1.0);
return output;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@location(0) v_color : vec4<f32>) -> @location(0) vec4<f32> {
@fragment fn main(@location(0) v_color : vec4f) -> @location(0) vec4f {
return v_color;
})");

View File

@ -34,19 +34,19 @@ void init() {
const char* vs = R"(
@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),
vec2<f32>( 0.5, -0.5)
) -> @builtin(position) vec4f {
var pos = array(
vec2f( 0.0, 0.5),
vec2f(-0.5, -0.5),
vec2f( 0.5, -0.5)
);
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})";
WGPUShaderModule vsModule = utils::CreateShaderModule(device, vs).Release();
const char* fs = R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
})";
WGPUShaderModule fsModule = utils::CreateShaderModule(device, fs).Release();

View File

@ -97,25 +97,25 @@ 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 : vec2f,
@location(1) a_particleVel : vec2f,
@location(2) a_pos : vec2f,
};
@vertex
fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
fn main(input : VertexIn) -> @builtin(position) vec4f {
var angle : f32 = -atan2(input.a_particleVel.x, input.a_particleVel.y);
var pos : vec2<f32> = vec2<f32>(
var pos : vec2f = vec2f(
(input.a_pos.x * cos(angle)) - (input.a_pos.y * sin(angle)),
(input.a_pos.x * sin(angle)) + (input.a_pos.y * cos(angle)));
return vec4<f32>(pos + input.a_particlePos, 0.0, 1.0);
return vec4f(pos + input.a_particlePos, 0.0, 1.0);
}
)");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
fn main() -> @location(0) vec4f {
return vec4f(1.0, 1.0, 1.0, 1.0);
}
)");
@ -149,8 +149,8 @@ void initRender() {
void initSim() {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Particle {
pos : vec2<f32>,
vel : vec2<f32>,
pos : vec2f,
vel : vec2f,
};
struct SimParams {
deltaT : f32,
@ -171,20 +171,20 @@ void initSim() {
// https://github.com/austinEng/Project6-Vulkan-Flocking/blob/master/data/shaders/computeparticles/particle.comp
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
var index : u32 = GlobalInvocationID.x;
if (index >= params.particleCount) {
return;
}
var vPos : vec2<f32> = particlesA.particles[index].pos;
var vVel : vec2<f32> = particlesA.particles[index].vel;
var cMass : vec2<f32> = vec2<f32>(0.0, 0.0);
var cVel : vec2<f32> = vec2<f32>(0.0, 0.0);
var colVel : vec2<f32> = vec2<f32>(0.0, 0.0);
var vPos : vec2f = particlesA.particles[index].pos;
var vVel : vec2f = particlesA.particles[index].vel;
var cMass : vec2f = vec2f(0.0, 0.0);
var cVel : vec2f = vec2f(0.0, 0.0);
var colVel : vec2f = vec2f(0.0, 0.0);
var cMassCount : u32 = 0u;
var cVelCount : u32 = 0u;
var pos : vec2<f32>;
var vel : vec2<f32>;
var pos : vec2f;
var vel : vec2f;
for (var i : u32 = 0u; i < params.particleCount; i = i + 1u) {
if (i == index) {
@ -207,11 +207,11 @@ void initSim() {
}
if (cMassCount > 0u) {
cMass = (cMass / vec2<f32>(f32(cMassCount), f32(cMassCount))) - vPos;
cMass = (cMass / vec2f(f32(cMassCount), f32(cMassCount))) - vPos;
}
if (cVelCount > 0u) {
cVel = cVel / vec2<f32>(f32(cVelCount), f32(cVelCount));
cVel = cVel / vec2f(f32(cVelCount), f32(cVelCount));
}
vVel = vVel + (cMass * params.rule1Scale) + (colVel * params.rule2Scale) +
(cVel * params.rule3Scale);

View File

@ -95,8 +95,8 @@ void init() {
initTextures();
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main(@location(0) pos : vec4<f32>)
-> @builtin(position) vec4<f32> {
@vertex fn main(@location(0) pos : vec4f)
-> @builtin(position) vec4f {
return pos;
})");
@ -104,9 +104,9 @@ void init() {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture : texture_2d<f32>;
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
return textureSample(myTexture, mySampler, FragCoord.xy / vec2<f32>(640.0, 480.0));
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
return textureSample(myTexture, mySampler, FragCoord.xy / vec2f(640.0, 480.0));
})");
auto bgl = utils::MakeBindGroupLayout(

View File

@ -317,17 +317,17 @@ int main(int argc, const char* argv[]) {
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 0.5, -0.5)
-> @builtin(position) vec4f {
var pos = array(
vec2f( 0.0, 0.5),
vec2f(-0.5, -0.5),
vec2f( 0.5, -0.5)
);
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
})");
// BGRA shouldn't be hardcoded. Consider having a map[format -> pipeline].
pipelineDesc.cTargets[0].format = wgpu::TextureFormat::BGRA8Unorm;

View File

@ -1115,7 +1115,7 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t
shaderSource << "const sampleCount : u32 = " << sampleCount << "u;\n";
shaderSource << "fn doTextureLoad(t: " << wgslTextureType
<< ", coord: vec2<i32>, sample: u32, component: u32) -> f32";
<< ", coord: vec2i, sample: u32, component: u32) -> f32";
if (sampleCount > 1) {
shaderSource << R"({
return textureLoad(tex, coord, i32(sample))[component];
@ -1134,7 +1134,7 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t
}
shaderSource << R"(
@compute @workgroup_size(1) fn main(
@builtin(global_invocation_id) GlobalInvocationId : vec3<u32>
@builtin(global_invocation_id) GlobalInvocationId : vec3u
) {
let baseOutIndex = GlobalInvocationId.y * width + GlobalInvocationId.x;
for (var s = 0u; s < sampleCount; s = s + 1u) {
@ -1143,7 +1143,7 @@ std::ostringstream& DawnTestBase::ExpectSampledFloatDataImpl(wgpu::TextureView t
baseOutIndex * sampleCount * componentCount +
s * componentCount +
c
] = doTextureLoad(tex, vec2<i32>(GlobalInvocationId.xy), s, c);
] = doTextureLoad(tex, vec2i(GlobalInvocationId.xy), s, c);
}
}
}
@ -1278,12 +1278,12 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, 3.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f( 3.0, -1.0),
vec2f(-1.0, 3.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
if (depthDataTexture) {
@ -1298,10 +1298,10 @@ std::ostringstream& DawnTestBase::ExpectAttachmentDepthStencilTestData(
}
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
fn main(@builtin(position) FragCoord : vec4f) -> FragmentOut {
var output : FragmentOut;
output.result = 1u;
output.fragDepth = textureLoad(texture0, vec2<i32>(FragCoord.xy), 0)[0];
output.fragDepth = textureLoad(texture0, vec2i(FragCoord.xy), 0)[0];
return output;
})");
} else {

View File

@ -55,13 +55,13 @@ class BindGroupTests : public DawnTest {
wgpu::ShaderModule MakeSimpleVSModule() const {
return utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
}
@ -71,7 +71,7 @@ class BindGroupTests : public DawnTest {
std::ostringstream fs;
for (size_t i = 0; i < bindingTypes.size(); ++i) {
fs << "struct Buffer" << i << R"( {
color : vec4<f32>
color : vec4f
})";
switch (bindingTypes[i]) {
@ -88,8 +88,8 @@ class BindGroupTests : public DawnTest {
}
}
fs << "\n@fragment fn main() -> @location(0) vec4<f32>{\n";
fs << "var fragColor : vec4<f32> = vec4<f32>();\n";
fs << "\n@fragment fn main() -> @location(0) vec4f{\n";
fs << "var fragColor : vec4f = vec4f();\n";
for (size_t i = 0; i < bindingTypes.size(); ++i) {
fs << "fragColor = fragColor + buffer" << i << ".color;\n";
}
@ -168,29 +168,29 @@ TEST_P(BindGroupTests, ReusedUBO) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
struct VertexUniformBuffer {
transform : vec4<f32>
transform : vec4f
}
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
@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),
vec2<f32>(-1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0));
var transform = mat2x2<f32>(vertexUbo.transform.xy, vertexUbo.transform.zw);
return vec4<f32>(transform * pos[VertexIndex], 0.0, 1.0);
return vec4f(transform * pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct FragmentUniformBuffer {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(1) var <uniform> fragmentUbo : FragmentUniformBuffer;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return fragmentUbo.color;
})");
@ -246,19 +246,19 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
struct VertexUniformBuffer {
transform : vec4<f32>
transform : vec4f
}
@group(0) @binding(0) var <uniform> vertexUbo : VertexUniformBuffer;
@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),
vec2<f32>(-1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0));
var transform = mat2x2<f32>(vertexUbo.transform.xy, vertexUbo.transform.zw);
return vec4<f32>(transform * pos[VertexIndex], 0.0, 1.0);
return vec4f(transform * pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -266,7 +266,7 @@ TEST_P(BindGroupTests, UBOSamplerAndTexture) {
@group(0) @binding(2) var tex : texture_2d<f32>;
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return textureSample(tex, samp, FragCoord.xy);
})");
@ -349,20 +349,20 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
// TODO(crbug.com/tint/369): Use a mat2x2 when Tint translates it correctly.
struct VertexUniformBuffer {
transform : vec4<f32>
transform : vec4f
}
@group(0) @binding(0) var <uniform> vertexUbo1 : VertexUniformBuffer;
@group(1) @binding(0) var <uniform> vertexUbo2 : VertexUniformBuffer;
@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),
vec2<f32>(-1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0));
return vec4<f32>(mat2x2<f32>(
return vec4f(mat2x2<f32>(
vertexUbo1.transform.xy + vertexUbo2.transform.xy,
vertexUbo1.transform.zw + vertexUbo2.transform.zw
) * pos[VertexIndex], 0.0, 1.0);
@ -370,13 +370,13 @@ TEST_P(BindGroupTests, MultipleBindLayouts) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct FragmentUniformBuffer {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(1) var <uniform> fragmentUbo1 : FragmentUniformBuffer;
@group(1) @binding(1) var <uniform> fragmentUbo2 : FragmentUniformBuffer;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return fragmentUbo1.color + fragmentUbo2.color;
})");
@ -1048,10 +1048,10 @@ TEST_P(BindGroupTests, DynamicOffsetOrder) {
@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 : vec3<u32>;
@group(0) @binding(4) var<storage, read_write> outputBuffer : vec3u;
@compute @workgroup_size(1) fn main() {
outputBuffer = vec3<u32>(buffer0.value, buffer2.value, buffer3.value);
outputBuffer = vec3u(buffer0.value, buffer2.value, buffer3.value);
})");
pipelineDescriptor.compute.entryPoint = "main";
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
@ -1125,7 +1125,7 @@ TEST_P(BindGroupTests, DynamicAndNonDynamicBindingsDoNotConflictAfterRemapping)
}
struct OutputBuffer {
value : vec2<u32>
value : vec2u
}
@group(0) @binding(0) var<uniform> buffer0 : Buffer;
@ -1133,7 +1133,7 @@ TEST_P(BindGroupTests, DynamicAndNonDynamicBindingsDoNotConflictAfterRemapping)
@group(0) @binding(2) var<storage, read_write> outputBuffer : OutputBuffer;
@compute @workgroup_size(1) fn main() {
outputBuffer.value = vec2<u32>(buffer0.value, buffer1.value);
outputBuffer.value = vec2u(buffer0.value, buffer1.value);
})");
pipelineDescriptor.compute.entryPoint = "main";
pipelineDescriptor.layout = utils::MakeBasicPipelineLayout(device, &bgl);
@ -1236,25 +1236,25 @@ TEST_P(BindGroupTests, ArbitraryBindingNumbers) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Ubo {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(553) var <uniform> ubo1 : Ubo;
@group(0) @binding(47) var <uniform> ubo2 : Ubo;
@group(0) @binding(111) var <uniform> ubo3 : Ubo;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return ubo1.color + 2.0 * ubo2.color + 4.0 * ubo3.color;
})");
@ -1379,22 +1379,22 @@ TEST_P(BindGroupTests, ReadonlyStorage) {
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
struct Buffer0 {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<storage, read> buffer0 : Buffer0;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return buffer0.color;
})");
@ -1483,8 +1483,7 @@ TEST_P(BindGroupTests, ReallyLargeBindGroup) {
<< "var samp" << i << " : sampler;\n";
body << "if (abs(textureSampleLevel(tex" << i << ", samp" << i
<< ", vec2<f32>(0.5, 0.5), 0.0).r - " << expectedValue++
<< ".0 / 255.0) > 0.0001) {\n";
<< ", vec2f(0.5, 0.5), 0.0).r - " << expectedValue++ << ".0 / 255.0) > 0.0001) {\n";
body << " return;\n";
body << "}\n";
}

View File

@ -213,7 +213,7 @@ class BufferZeroInitTest : public DawnTest {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment
fn main(@location(0) i_color : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) i_color : vec4f) -> @location(0) vec4f {
return i_color;
})");
@ -252,18 +252,18 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline = CreateRenderPipelineForTest(R"(
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex fn main(@location(0) pos : vec4<f32>) -> VertexOut {
@vertex fn main(@location(0) pos : vec4f) -> 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);
if (all(pos == vec4f(0.0, 0.0, 0.0, 0.0))) {
output.color = vec4f(0.0, 1.0, 0.0, 1.0);
} else {
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
}
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
})");
@ -296,19 +296,19 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"(
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@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);
output.color = vec4f(0.0, 1.0, 0.0, 1.0);
} else {
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
}
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
})",
0 /* vertexBufferCount */);
@ -346,14 +346,14 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"(
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@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);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
})",
0 /* vertexBufferCount */);
@ -387,14 +387,14 @@ class BufferZeroInitTest : public DawnTest {
wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"(
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@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);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
})",
0 /* vertexBufferCount */);
@ -433,7 +433,7 @@ class BufferZeroInitTest : public DawnTest {
@group(0) @binding(0) var outImage : texture_storage_2d<rgba8unorm, write>;
@compute @workgroup_size(1) fn main() {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
textureStore(outImage, vec2i(0, 0), vec4f(1.0, 0.0, 0.0, 1.0));
})";
wgpu::ComputePipelineDescriptor pipelineDescriptor;
@ -996,16 +996,16 @@ TEST_P(BufferZeroInitTest, BoundAsUniformBuffer) {
constexpr uint32_t kBoundBufferSize = 16u;
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct UBO {
value : vec4<u32>
value : vec4u
}
@group(0) @binding(0) var<uniform> ubo : UBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@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));
if (all(ubo.value == vec4u(0u, 0u, 0u, 0u))) {
textureStore(outImage, vec2i(0, 0), vec4f(0.0, 1.0, 0.0, 1.0));
} else {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
textureStore(outImage, vec2i(0, 0), vec4f(1.0, 0.0, 0.0, 1.0));
}
}
)");
@ -1035,16 +1035,16 @@ TEST_P(BufferZeroInitTest, BoundAsReadonlyStorageBuffer) {
constexpr uint32_t kBoundBufferSize = 16u;
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct SSBO {
value : vec4<u32>
value : vec4u
}
@group(0) @binding(0) var<storage, read> ssbo : SSBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@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));
if (all(ssbo.value == vec4u(0u, 0u, 0u, 0u))) {
textureStore(outImage, vec2i(0, 0), vec4f(0.0, 1.0, 0.0, 1.0));
} else {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
textureStore(outImage, vec2i(0, 0), vec4f(1.0, 0.0, 0.0, 1.0));
}
}
)");
@ -1074,17 +1074,17 @@ TEST_P(BufferZeroInitTest, BoundAsStorageBuffer) {
constexpr uint32_t kBoundBufferSize = 32u;
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct SSBO {
value : array<vec4<u32>, 2>
value : array<vec4u, 2>
}
@group(0) @binding(0) var<storage, read_write> ssbo : SSBO;
@group(0) @binding(1) var outImage : texture_storage_2d<rgba8unorm, write>;
@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));
if (all(ssbo.value[0] == vec4u(0u, 0u, 0u, 0u)) &&
all(ssbo.value[1] == vec4u(0u, 0u, 0u, 0u))) {
textureStore(outImage, vec2i(0, 0), vec4f(0.0, 1.0, 0.0, 1.0));
} else {
textureStore(outImage, vec2<i32>(0, 0), vec4<f32>(1.0, 0.0, 0.0, 1.0));
textureStore(outImage, vec2i(0, 0), vec4f(1.0, 0.0, 0.0, 1.0));
}
storageBarrier();
@ -1148,18 +1148,18 @@ TEST_P(BufferZeroInitTest, PaddingInitialized) {
wgpu::RenderPipeline renderPipeline =
CreateRenderPipelineForTest(R"(
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex fn main(@location(0) pos : vec2<f32>) -> VertexOut {
@vertex fn main(@location(0) pos : vec2f) -> 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);
if (all(pos == vec2f(0.0, 0.0))) {
output.color = vec4f(0.0, 1.0, 0.0, 1.0);
} else {
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
}
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
})",
/* vertexBufferCount */ 1u, vertexFormat);

View File

@ -27,20 +27,20 @@ class ClipSpaceTest : public DawnTest {
// 2. The depth value of the bottom-right one is <= 0.5
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec3<f32>( 1.0, 1.0, 0.5),
vec3<f32>( 1.0, 1.0, 0.5),
vec3<f32>(-1.0, -1.0, 0.5),
vec3<f32>( 1.0, -1.0, 0.0));
return vec4<f32>(pos[VertexIndex], 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec3f(-1.0, 1.0, 1.0),
vec3f(-1.0, -1.0, 0.5),
vec3f( 1.0, 1.0, 0.5),
vec3f( 1.0, 1.0, 0.5),
vec3f(-1.0, -1.0, 0.5),
vec3f( 1.0, -1.0, 0.0));
return vec4f(pos[VertexIndex], 1.0);
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
})");
wgpu::DepthStencilState* depthStencil = pipelineDescriptor.EnableDepthStencil();

View File

@ -41,12 +41,12 @@ class ColorStateTest : public DawnTest {
vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, 3.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f(3.0, -1.0),
vec2f(-1.0, 3.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
}
)");
@ -63,12 +63,12 @@ class ColorStateTest : public DawnTest {
void SetupSingleSourcePipelines(wgpu::ColorTargetState colorTargetState) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<uniform> myUbo : MyBlock;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return myUbo.color;
}
)");
@ -807,19 +807,19 @@ TEST_P(ColorStateTest, IndependentColorState) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock {
color0 : vec4<f32>,
color1 : vec4<f32>,
color2 : vec4<f32>,
color3 : vec4<f32>,
color0 : vec4f,
color1 : vec4f,
color2 : vec4f,
color3 : vec4f,
}
@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 : vec4f,
@location(1) fragColor1 : vec4f,
@location(2) fragColor2 : vec4f,
@location(3) fragColor3 : vec4f,
}
@fragment fn main() -> FragmentOut {
@ -931,12 +931,12 @@ TEST_P(ColorStateTest, IndependentColorState) {
TEST_P(ColorStateTest, DefaultBlendColor) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<uniform> myUbo : MyBlock;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return myUbo.color;
}
)");
@ -1057,12 +1057,12 @@ TEST_P(ColorStateTest, DefaultBlendColor) {
TEST_P(ColorStateTest, ColorWriteMaskDoesNotAffectRenderPassLoadOpClear) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct MyBlock {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<uniform> myUbo : MyBlock;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return myUbo.color;
}
)");
@ -1117,12 +1117,12 @@ TEST_P(ColorStateTest, SparseAttachmentsDifferentColorMask) {
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Outputs {
@location(1) o1 : vec4<f32>,
@location(3) o3 : vec4<f32>,
@location(1) o1 : vec4f,
@location(3) o3 : vec4f,
}
@fragment fn main() -> Outputs {
return Outputs(vec4<f32>(1.0), vec4<f32>(0.0, 1.0, 1.0, 1.0));
return Outputs(vec4f(1.0), vec4f(0.0, 1.0, 1.0, 1.0));
}
)");

View File

@ -165,19 +165,19 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct VertexOut {
@location(0) texCoord : vec2 <f32>,
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
}
@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),
vec2<f32>( 0.0, -2.0)
var pos = array(
vec2f(-3.0, 1.0),
vec2f( 3.0, 1.0),
vec2f( 0.0, -2.0)
);
var output : VertexOut;
output.position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
output.texCoord = vec2<f32>(output.position.x / 2.0, -output.position.y / 2.0) + vec2<f32>(0.5, 0.5);
output.position = vec4f(pos[VertexIndex], 0.0, 1.0);
output.texCoord = vec2f(output.position.x / 2.0, -output.position.y / 2.0) + vec2f(0.5, 0.5);
return output;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -185,7 +185,7 @@ class CompressedTextureFormatTest : public DawnTestWithParams<CompressedTextureF
@group(0) @binding(1) var texture0 : texture_2d<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
return textureSample(texture0, sampler0, texCoord);
})");
renderPipelineDescriptor.vertex.module = vsModule;

View File

@ -89,14 +89,14 @@ void ComputeCopyStorageBufferTests::BasicTest(const char* shader) {
TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) {
BasicTest(R"(
struct Buf {
s : array<vec4<u32>, 4>
s : array<vec4u, 4>
}
@group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
let index : u32 = GlobalInvocationID.x;
if (index >= 4u) { return; }
dst.s[index] = src.s[index];
@ -107,8 +107,8 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) {
TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
BasicTest(R"(
struct S {
a : vec2<u32>,
b : vec2<u32>,
a : vec2u,
b : vec2u,
}
struct Buf {
@ -119,7 +119,7 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
@group(0) @binding(1) var<storage, read_write> dst : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
let index : u32 = GlobalInvocationID.x;
if (index >= 4u) { return; }
dst.s[index] = src.s[index];
@ -130,14 +130,14 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
TEST_P(ComputeCopyStorageBufferTests, UnsizedArrayOfBasic) {
BasicTest(R"(
struct Buf {
s : array<vec4<u32>>
s : array<vec4u>
}
@group(0) @binding(0) var<storage, read_write> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
let index : u32 = GlobalInvocationID.x;
if (index >= 4u) { return; }
dst.s[index] = src.s[index];

View File

@ -28,17 +28,17 @@ class ComputeDispatchTests : public DawnTest {
// Write workgroup number into the output buffer if we saw the biggest dispatch
// To make sure the dispatch was not called, write maximum u32 value for 0 dispatches
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var<storage, read_write> output : vec3<u32>;
@group(0) @binding(0) var<storage, read_write> output : vec3u;
@compute @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>,
@builtin(num_workgroups) dispatch : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u,
@builtin(num_workgroups) dispatch : vec3u) {
if (dispatch.x == 0u || dispatch.y == 0u || dispatch.z == 0u) {
output = vec3<u32>(0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu);
output = vec3u(0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu);
return;
}
if (all(GlobalInvocationID == dispatch - vec3<u32>(1u, 1u, 1u))) {
if (all(GlobalInvocationID == dispatch - vec3u(1u, 1u, 1u))) {
output = dispatch;
}
})");
@ -50,19 +50,19 @@ class ComputeDispatchTests : public DawnTest {
// Test the use of the compute pipelines without using @num_workgroups
wgpu::ShaderModule moduleWithoutNumWorkgroups = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var<uniform> input : vec3<u32>;
@group(0) @binding(1) var<storage, read_write> output : vec3<u32>;
@group(0) @binding(0) var<uniform> input : vec3u;
@group(0) @binding(1) var<storage, read_write> output : vec3u;
@compute @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
let dispatch : vec3<u32> = input;
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
let dispatch : vec3u = input;
if (dispatch.x == 0u || dispatch.y == 0u || dispatch.z == 0u) {
output = vec3<u32>(0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu);
output = vec3u(0xFFFFFFFFu, 0xFFFFFFFFu, 0xFFFFFFFFu);
return;
}
if (all(GlobalInvocationID == dispatch - vec3<u32>(1u, 1u, 1u))) {
if (all(GlobalInvocationID == dispatch - vec3u(1u, 1u, 1u))) {
output = dispatch;
}
})");

View File

@ -242,8 +242,8 @@ class MemoryDataBuilder {
// offset and size are in units of bytes.
using DataMatcherCallback = std::function<void(uint32_t offset, uint32_t size)>;
// Field describe a type that has contiguous data bytes, e.g. `i32`, `vec2<f32>`, `mat4x4<f32>` or
// `array<f32, 5>`, or have a fixed data stride, e.g. `mat3x3<f32>` or `array<vec3<f32>, 4>`.
// Field describe a type that has contiguous data bytes, e.g. `i32`, `vec2f`, `mat4x4<f32>` or
// `array<f32, 5>`, or have a fixed data stride, e.g. `mat3x3<f32>` or `array<vec3f, 4>`.
// `@size` and `@align` attributes, when used as a struct member, can also described by this struct.
class Field {
public:
@ -921,36 +921,36 @@ auto GenerateParams() {
.StorageBufferOnly(),
Field("array<u32, 4>", /* align */ 4, /* size */ 16, /* requireF16Feature */ false)
.StorageBufferOnly(),
Field("array<vec2<u32>, 1>", /* align */ 8, /* size */ 8, /* requireF16Feature */ false)
Field("array<vec2u, 1>", /* align */ 8, /* size */ 8, /* requireF16Feature */ false)
.StorageBufferOnly(),
Field("array<vec2<u32>, 2>", /* align */ 8, /* size */ 16,
Field("array<vec2u, 2>", /* align */ 8, /* size */ 16,
/* requireF16Feature */ false)
.StorageBufferOnly(),
Field("array<vec2<u32>, 3>", /* align */ 8, /* size */ 24,
Field("array<vec2u, 3>", /* align */ 8, /* size */ 24,
/* requireF16Feature */ false)
.StorageBufferOnly(),
Field("array<vec2<u32>, 4>", /* align */ 8, /* size */ 32,
Field("array<vec2u, 4>", /* align */ 8, /* size */ 32,
/* requireF16Feature */ false)
.StorageBufferOnly(),
Field("array<vec3<u32>, 1>", /* align */ 16, /* size */ 16,
Field("array<vec3u, 1>", /* align */ 16, /* size */ 16,
/* requireF16Feature */ false)
.Strided(12, 4),
Field("array<vec3<u32>, 2>", /* align */ 16, /* size */ 32,
Field("array<vec3u, 2>", /* align */ 16, /* size */ 32,
/* requireF16Feature */ false)
.Strided(12, 4),
Field("array<vec3<u32>, 3>", /* align */ 16, /* size */ 48,
Field("array<vec3u, 3>", /* align */ 16, /* size */ 48,
/* requireF16Feature */ false)
.Strided(12, 4),
Field("array<vec3<u32>, 4>", /* align */ 16, /* size */ 64,
Field("array<vec3u, 4>", /* align */ 16, /* size */ 64,
/* requireF16Feature */ false)
.Strided(12, 4),
Field("array<vec4<u32>, 1>", /* align */ 16, /* size */ 16,
Field("array<vec4u, 1>", /* align */ 16, /* size */ 16,
/* requireF16Feature */ false),
Field("array<vec4<u32>, 2>", /* align */ 16, /* size */ 32,
Field("array<vec4u, 2>", /* align */ 16, /* size */ 32,
/* requireF16Feature */ false),
Field("array<vec4<u32>, 3>", /* align */ 16, /* size */ 48,
Field("array<vec4u, 3>", /* align */ 16, /* size */ 48,
/* requireF16Feature */ false),
Field("array<vec4<u32>, 4>", /* align */ 16, /* size */ 64,
Field("array<vec4u, 4>", /* align */ 16, /* size */ 64,
/* requireF16Feature */ false),
// Array types with custom alignment
@ -966,47 +966,47 @@ auto GenerateParams() {
Field("array<u32, 4>", /* align */ 4, /* size */ 16, /* requireF16Feature */ false)
.AlignAttribute(32)
.StorageBufferOnly(),
Field("array<vec2<u32>, 1>", /* align */ 8, /* size */ 8, /* requireF16Feature */ false)
Field("array<vec2u, 1>", /* align */ 8, /* size */ 8, /* requireF16Feature */ false)
.AlignAttribute(32)
.StorageBufferOnly(),
Field("array<vec2<u32>, 2>", /* align */ 8, /* size */ 16,
Field("array<vec2u, 2>", /* align */ 8, /* size */ 16,
/* requireF16Feature */ false)
.AlignAttribute(32)
.StorageBufferOnly(),
Field("array<vec2<u32>, 3>", /* align */ 8, /* size */ 24,
Field("array<vec2u, 3>", /* align */ 8, /* size */ 24,
/* requireF16Feature */ false)
.AlignAttribute(32)
.StorageBufferOnly(),
Field("array<vec2<u32>, 4>", /* align */ 8, /* size */ 32,
Field("array<vec2u, 4>", /* align */ 8, /* size */ 32,
/* requireF16Feature */ false)
.AlignAttribute(32)
.StorageBufferOnly(),
Field("array<vec3<u32>, 1>", /* align */ 16, /* size */ 16,
Field("array<vec3u, 1>", /* align */ 16, /* size */ 16,
/* requireF16Feature */ false)
.AlignAttribute(32)
.Strided(12, 4),
Field("array<vec3<u32>, 2>", /* align */ 16, /* size */ 32,
Field("array<vec3u, 2>", /* align */ 16, /* size */ 32,
/* requireF16Feature */ false)
.AlignAttribute(32)
.Strided(12, 4),
Field("array<vec3<u32>, 3>", /* align */ 16, /* size */ 48,
Field("array<vec3u, 3>", /* align */ 16, /* size */ 48,
/* requireF16Feature */ false)
.AlignAttribute(32)
.Strided(12, 4),
Field("array<vec3<u32>, 4>", /* align */ 16, /* size */ 64,
Field("array<vec3u, 4>", /* align */ 16, /* size */ 64,
/* requireF16Feature */ false)
.AlignAttribute(32)
.Strided(12, 4),
Field("array<vec4<u32>, 1>", /* align */ 16, /* size */ 16,
Field("array<vec4u, 1>", /* align */ 16, /* size */ 16,
/* requireF16Feature */ false)
.AlignAttribute(32),
Field("array<vec4<u32>, 2>", /* align */ 16, /* size */ 32,
Field("array<vec4u, 2>", /* align */ 16, /* size */ 32,
/* requireF16Feature */ false)
.AlignAttribute(32),
Field("array<vec4<u32>, 3>", /* align */ 16, /* size */ 48,
Field("array<vec4u, 3>", /* align */ 16, /* size */ 48,
/* requireF16Feature */ false)
.AlignAttribute(32),
Field("array<vec4<u32>, 4>", /* align */ 16, /* size */ 64,
Field("array<vec4u, 4>", /* align */ 16, /* size */ 64,
/* requireF16Feature */ false)
.AlignAttribute(32),
@ -1023,7 +1023,7 @@ auto GenerateParams() {
Field("array<u32, 4>", /* align */ 4, /* size */ 16, /* requireF16Feature */ false)
.SizeAttribute(128)
.StorageBufferOnly(),
Field("array<vec3<u32>, 4>", /* align */ 16, /* size */ 64,
Field("array<vec3u, 4>", /* align */ 16, /* size */ 64,
/* requireF16Feature */ false)
.SizeAttribute(128)
.Strided(12, 4),

View File

@ -82,7 +82,7 @@ TEST_P(ComputeSharedMemoryTests, Basic) {
var<workgroup> tmp : u32;
@compute @workgroup_size(4,4,1)
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3u) {
let index : u32 = LocalInvocationID.y * kTileSize + LocalInvocationID.x;
if (index == 0u) {
tmp = 0u;
@ -114,7 +114,7 @@ TEST_P(ComputeSharedMemoryTests, AssortedTypes) {
d_struct : StructValues,
d_matrix : mat2x2<f32>,
d_array : array<u32, 4>,
d_vector : vec4<f32>,
d_vector : vec4f,
}
@group(0) @binding(0) var<storage, read_write> dst : Dst;
@ -122,27 +122,27 @@ TEST_P(ComputeSharedMemoryTests, AssortedTypes) {
var<workgroup> wg_struct : StructValues;
var<workgroup> wg_matrix : mat2x2<f32>;
var<workgroup> wg_array : array<u32, 4>;
var<workgroup> wg_vector : vec4<f32>;
var<workgroup> wg_vector : vec4f;
@compute @workgroup_size(4,1,1)
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3<u32>) {
fn main(@builtin(local_invocation_id) LocalInvocationID : vec3u) {
let i = 4u * LocalInvocationID.x;
if (LocalInvocationID.x == 0u) {
wg_struct.m = mat2x2<f32>(
vec2<f32>(f32(i), f32(i + 1u)),
vec2<f32>(f32(i + 2u), f32(i + 3u)));
vec2f(f32(i), f32(i + 1u)),
vec2f(f32(i + 2u), f32(i + 3u)));
} else if (LocalInvocationID.x == 1u) {
wg_matrix = mat2x2<f32>(
vec2<f32>(f32(i), f32(i + 1u)),
vec2<f32>(f32(i + 2u), f32(i + 3u)));
vec2f(f32(i), f32(i + 1u)),
vec2f(f32(i + 2u), f32(i + 3u)));
} else if (LocalInvocationID.x == 2u) {
wg_array[0u] = i;
wg_array[1u] = i + 1u;
wg_array[2u] = i + 2u;
wg_array[3u] = i + 3u;
} else if (LocalInvocationID.x == 3u) {
wg_vector = vec4<f32>(
wg_vector = vec4f(
f32(i), f32(i + 1u), f32(i + 2u), f32(i + 3u));
}

View File

@ -40,7 +40,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddIncrement) {
@group(0) @binding(0) var<storage, read_write> buf : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
buf.data[GlobalInvocationID.x] = buf.data[GlobalInvocationID.x] + 0x1234u;
}
)");
@ -91,7 +91,7 @@ TEST_P(ComputeStorageBufferBarrierTests, AddPingPong) {
@group(0) @binding(1) var<storage, read_write> dst : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u;
}
)");
@ -157,7 +157,7 @@ TEST_P(ComputeStorageBufferBarrierTests, StorageAndReadonlyStoragePingPongInOneP
@group(0) @binding(1) var<storage, read_write> dst : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] + 0x1234u;
}
)");
@ -218,16 +218,16 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPong) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf {
data : array<vec4<u32>, 25>
data : array<vec4u, 25>
}
@group(0) @binding(0) var<uniform> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u);
vec4u(0x1234u, 0x1234u, 0x1234u, 0x1234u);
}
)");
@ -286,16 +286,16 @@ TEST_P(ComputeStorageBufferBarrierTests, UniformToStorageAddPingPongInOnePass) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Buf {
data : array<vec4<u32>, 25>
data : array<vec4u, 25>
}
@group(0) @binding(0) var<uniform> src : Buf;
@group(0) @binding(1) var<storage, read_write> dst : Buf;
@compute @workgroup_size(1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
dst.data[GlobalInvocationID.x] = src.data[GlobalInvocationID.x] +
vec4<u32>(0x1234u, 0x1234u, 0x1234u, 0x1234u);
vec4u(0x1234u, 0x1234u, 0x1234u, 0x1234u);
}
)");
@ -349,7 +349,7 @@ TEST_P(ComputeStorageBufferBarrierTests, IndirectBufferCorrectBarrier) {
@group(0) @binding(0) var<storage, read_write> buf : Buf;
@compute @workgroup_size(1) fn main() {
buf.data = array<u32, 3>(1u, 1u, 1u);
buf.data = array(1u, 1u, 1u);
}
)");
wgpu::ComputePipeline step2Pipeline = device.CreateComputePipeline(&step2PipelineDesc);

View File

@ -247,9 +247,9 @@ class CopyTextureForBrowserTests : public Parent {
struct Uniforms {
dstTextureFlipY : u32,
channelCount : u32,
srcCopyOrigin : vec2<u32>,
dstCopyOrigin : vec2<u32>,
copySize : vec2<u32>,
srcCopyOrigin : vec2u,
dstCopyOrigin : vec2u,
copySize : vec2u,
srcAlphaMode : u32,
dstAlphaMode : u32,
}
@ -265,11 +265,11 @@ class CopyTextureForBrowserTests : public Parent {
return abs(value - expect) < 0.01;
}
@compute @workgroup_size(1, 1, 1)
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3<u32>) {
fn main(@builtin(global_invocation_id) GlobalInvocationID : vec3u) {
let srcSize = textureDimensions(src);
let dstSize = textureDimensions(dst);
let dstTexCoord = vec2<u32>(GlobalInvocationID.xy);
let nonCoveredColor = vec4<f32>(0.0, 1.0, 0.0, 1.0); // should be green
let dstTexCoord = vec2u(GlobalInvocationID.xy);
let nonCoveredColor = vec4f(0.0, 1.0, 0.0, 1.0); // should be green
var success : bool = true;
if (dstTexCoord.x < uniforms.dstCopyOrigin.x ||
@ -277,7 +277,7 @@ class CopyTextureForBrowserTests : public Parent {
dstTexCoord.x >= uniforms.dstCopyOrigin.x + uniforms.copySize.x ||
dstTexCoord.y >= uniforms.dstCopyOrigin.y + uniforms.copySize.y) {
success = success &&
all(textureLoad(dst, vec2<i32>(dstTexCoord), 0) == nonCoveredColor);
all(textureLoad(dst, vec2i(dstTexCoord), 0) == nonCoveredColor);
} else {
// Calculate source texture coord.
var srcTexCoordInRect = dstTexCoord - uniforms.dstCopyOrigin;
@ -289,8 +289,8 @@ class CopyTextureForBrowserTests : public Parent {
var srcTexCoord = srcTexCoordInRect + uniforms.srcCopyOrigin;
var srcColor = textureLoad(src, vec2<i32>(srcTexCoord), 0);
var dstColor = textureLoad(dst, vec2<i32>(dstTexCoord), 0);
var srcColor = textureLoad(src, vec2i(srcTexCoord), 0);
var dstColor = textureLoad(dst, vec2i(dstTexCoord), 0);
// Expect the dst texture channels should be all equal to alpha value
// after premultiply.
@ -302,12 +302,12 @@ class CopyTextureForBrowserTests : public Parent {
}
if (uniforms.srcAlphaMode == unpremultiplied && uniforms.dstAlphaMode == premultiplied) {
srcColor = vec4<f32>(srcColor.rgb * srcColor.a, srcColor.a);
srcColor = vec4f(srcColor.rgb * srcColor.a, srcColor.a);
}
if (uniforms.srcAlphaMode == premultiplied && uniforms.dstAlphaMode == unpremultiplied) {
if (srcColor.a != 0.0) {
srcColor = vec4<f32>(srcColor.rgb / srcColor.a, srcColor.a);
srcColor = vec4f(srcColor.rgb / srcColor.a, srcColor.a);
}
}

View File

@ -236,12 +236,12 @@ TEST_P(CreatePipelineAsyncTest, BasicUseOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragment.module = fsModule;
@ -260,12 +260,12 @@ TEST_P(CreatePipelineAsyncTest, ReleaseEntryPointsAfterCreateRenderPipelineAsync
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragment.module = fsModule;
@ -325,12 +325,12 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineFailed) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragment.module = fsModule;
@ -387,12 +387,12 @@ TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateComputePipeli
TEST_P(CreatePipelineAsyncTest, ReleaseDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragment.module = fsModule;
@ -444,12 +444,12 @@ TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateComputePipeli
TEST_P(CreatePipelineAsyncTest, DestroyDeviceBeforeCallbackOfCreateRenderPipelineAsync) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragment.module = fsModule;
@ -578,12 +578,12 @@ TEST_P(CreatePipelineAsyncTest, CreateSameRenderPipelineTwiceAtSameTime) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
renderPipelineDescriptor.vertex.module = vsModule;
renderPipelineDescriptor.cFragment.module = fsModule;
@ -635,24 +635,24 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithVertexBufferLayouts
}
struct VertexOutput {
@location(0) vertexColorOut: vec4<f32>,
@builtin(position) position: vec4<f32>,
@location(0) vertexColorOut: vec4f,
@builtin(position) position: vec4f,
}
@vertex
fn main(vertexInput : VertexInput) -> VertexOutput {
var vertexOutput : VertexOutput;
vertexOutput.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
vertexOutput.position = vec4f(0.0, 0.0, 0.0, 1.0);
if (vertexInput.input0 == 1u && vertexInput.input1 == 2u) {
vertexOutput.vertexColorOut = vec4<f32>(0.0, 1.0, 0.0, 1.0);
vertexOutput.vertexColorOut = vec4f(0.0, 1.0, 0.0, 1.0);
} else {
vertexOutput.vertexColorOut = vec4<f32>(1.0, 0.0, 0.0, 1.0);
vertexOutput.vertexColorOut = vec4f(1.0, 0.0, 0.0, 1.0);
}
return vertexOutput;
})");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment
fn main(@location(0) fragColorIn : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) fragColorIn : vec4f) -> @location(0) vec4f {
return fragColorIn;
})");
@ -732,13 +732,13 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithDepthStencilState)
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@vertex
fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
})");
renderPipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
@ -804,13 +804,13 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineWithMultisampleState) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@vertex
fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment
fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
renderPipelineDescriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
@ -876,19 +876,19 @@ TEST_P(CreatePipelineAsyncTest, CreateRenderPipelineAsyncWithBlendState) {
utils::ComboRenderPipelineDescriptor renderPipelineDescriptor;
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@vertex
fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
fn main() -> @builtin(position) vec4f {
return vec4f(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 : vec4f,
@location(1) fragColor1 : vec4f,
}
@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);
output.fragColor0 = vec4f(0.4, 0.0, 0.0, 0.4);
output.fragColor1 = vec4f(0.0, 1.0, 0.0, 1.0);
return output;
})");

View File

@ -27,15 +27,15 @@ class CullingTest : public DawnTest {
// 2. The bottom-right one is clockwise (CW)
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 0.0, 1.0),
vec2<f32>( 0.0, -1.0),
vec2<f32>( 1.0, 0.0),
vec2<f32>( 1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f(-1.0, 0.0),
vec2f( 0.0, 1.0),
vec2f( 0.0, -1.0),
vec2f( 1.0, 0.0),
vec2f( 1.0, -1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
// FragCoord of pixel(x, y) in framebuffer coordinate is (x + 0.5, y + 0.5). And we use
@ -43,9 +43,9 @@ class CullingTest : public DawnTest {
// 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"(
@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),
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return vec4f(
(FragCoord.xy - vec2f(0.5, 0.5)) / vec2f(255.0, 255.0),
0.0, 1.0);
})");

View File

@ -45,12 +45,12 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
mMockCache.Disable();
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn vertex_main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
}
@fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn fragment_main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)");
@ -82,12 +82,12 @@ TEST_P(D3D12CachingTests, SameShaderNoCache) {
// entrypoints)
TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn vertex_main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
}
@fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn fragment_main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)");
@ -115,12 +115,12 @@ TEST_P(D3D12CachingTests, ReuseShaderWithMultipleEntryPointsPerStage) {
// Modify the WGSL shader functions and make sure it doesn't hit.
wgpu::ShaderModule newModule = utils::CreateShaderModule(device, R"(
@vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
@vertex fn vertex_main() -> @builtin(position) vec4f {
return vec4f(1.0, 1.0, 1.0, 1.0);
}
@fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
@fragment fn fragment_main() -> @location(0) vec4f {
return vec4f(1.0, 1.0, 1.0, 1.0);
}
)");

View File

@ -40,15 +40,15 @@ class DepthBiasTests : public DawnTest {
// Draw a square at z = 0.25
vertexSource = R"(
@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),
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.25, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0));
return vec4f(pos[VertexIndex], 0.25, 1.0);
})";
break;
@ -56,15 +56,15 @@ class DepthBiasTests : public DawnTest {
// Draw a square ranging from 0 to 0.5, bottom to top
vertexSource = R"(
@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),
vec3<f32>(-1.0, 1.0, 0.5),
vec3<f32>(-1.0, 1.0, 0.5),
vec3<f32>( 1.0, -1.0, 0.0),
vec3<f32>( 1.0, 1.0, 0.5));
return vec4<f32>(pos[VertexIndex], 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec3f(-1.0, -1.0, 0.0),
vec3f( 1.0, -1.0, 0.0),
vec3f(-1.0, 1.0, 0.5),
vec3f(-1.0, 1.0, 0.5),
vec3f( 1.0, -1.0, 0.0),
vec3f( 1.0, 1.0, 0.5));
return vec4f(pos[VertexIndex], 1.0);
})";
break;
}
@ -72,8 +72,8 @@ class DepthBiasTests : public DawnTest {
wgpu::ShaderModule vertexModule = utils::CreateShaderModule(device, vertexSource);
wgpu::ShaderModule fragmentModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
})");
{

View File

@ -50,15 +50,15 @@ class DepthStencilCopyTests : public DawnTestWithParams<DepthStencilCopyTestPara
// Draw a square in the bottom left quarter of the screen.
mVertexModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, 0.0),
vec2<f32>(-1.0, 0.0),
vec2<f32>( 0.0, -1.0),
vec2<f32>( 0.0, 0.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f( 0.0, -1.0),
vec2f(-1.0, 0.0),
vec2f(-1.0, 0.0),
vec2f( 0.0, -1.0),
vec2f( 0.0, 0.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
}

View File

@ -102,7 +102,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
ASSERT(components.size() == 1 && components[0] == 0);
shaderBody << "\nresult" << index << ".value = textureLoad(tex" << index
<< ", vec2<i32>(0, 0), 0);";
<< ", vec2i(0, 0), 0);";
break;
case TestAspectAndSamplerType::DepthAsFloat:
shaderSource << "@group(0) @binding(" << 2 * index << ") var tex" << index
@ -114,7 +114,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
ASSERT(components.size() == 1 && components[0] == 0);
shaderBody << "\nresult" << index << ".value = textureLoad(tex" << index
<< ", vec2<i32>(0, 0), 0)[0];";
<< ", vec2i(0, 0), 0)[0];";
break;
case TestAspectAndSamplerType::StencilAsUint:
shaderSource << "@group(0) @binding(" << 2 * index << ") var tex" << index
@ -124,8 +124,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
<< ") var<storage, read_write> result" << index
<< " : StencilResult;\n";
shaderBody << "var texel = textureLoad(tex" << index
<< ", vec2<i32>(0, 0), 0);";
shaderBody << "var texel = textureLoad(tex" << index << ", vec2i(0, 0), 0);";
for (uint32_t i = 0; i < components.size(); ++i) {
shaderBody << "\nresult" << index << ".values[" << i << "] = texel["
@ -142,8 +141,8 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
std::vector<TestAspectAndSamplerType> aspectAndSamplerTypes,
std::vector<uint32_t> components) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
@ -154,8 +153,8 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
GenerateSamplingShader(aspectAndSamplerTypes, components, shaderSource, shaderBody);
shaderSource << "@fragment fn main() -> @location(0) vec4<f32> {\n";
shaderSource << shaderBody.str() << "return vec4<f32>();\n }";
shaderSource << "@fragment fn main() -> @location(0) vec4f {\n";
shaderSource << shaderBody.str() << "return vec4f();\n }";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, shaderSource.str().c_str());
pipelineDescriptor.vertex.module = vsModule;
@ -200,8 +199,8 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
wgpu::RenderPipeline CreateComparisonRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -213,7 +212,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
@group(0) @binding(2) var<uniform> uniforms : Uniforms;
@fragment fn main() -> @location(0) f32 {
return textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef);
return textureSampleCompare(tex, samp, vec2f(0.5, 0.5), uniforms.compareRef);
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
@ -240,7 +239,7 @@ class DepthStencilSamplingTest : public DawnTestWithParams<DepthStencilSamplingT
@group(0) @binding(3) var<storage, read_write> samplerResult : SamplerResult;
@compute @workgroup_size(1) fn main() {
samplerResult.value = textureSampleCompare(tex, samp, vec2<f32>(0.5, 0.5), uniforms.compareRef);
samplerResult.value = textureSampleCompare(tex, samp, vec2f(0.5, 0.5), uniforms.compareRef);
})");
wgpu::ComputePipelineDescriptor pipelineDescriptor;
@ -629,7 +628,7 @@ TEST_P(DepthStencilSamplingTest, CheckDepthTextureRange) {
const kWidth = 16.0;
// Write a point per texel of a height = 0 texture with depths varying between 0 and 1.
@vertex fn vs(@builtin(vertex_index) index : u32) -> @builtin(position) vec4<f32> {
@vertex fn vs(@builtin(vertex_index) index : u32) -> @builtin(position) vec4f {
let x = (f32(index) + 0.5) / kWidth * 2.0 - 1.0;
let z = f32(index) / (kWidth - 1.0);
return vec4(x, 0.0, z, 1.0);
@ -644,7 +643,7 @@ TEST_P(DepthStencilSamplingTest, CheckDepthTextureRange) {
@group(0) @binding(1) var s : sampler;
// Check each depth texture texel has the expected value and outputs a "bool".
@fragment fn fs2(@builtin(position) pos : vec4<f32>) -> @location(0) f32 {
@fragment fn fs2(@builtin(position) pos : vec4f) -> @location(0) f32 {
let x = pos.x / kWidth;
let depth = textureSample(t, s, vec2(x, 0.5));

View File

@ -58,32 +58,32 @@ class DepthStencilStateTest : public DawnTest {
vsModule = utils::CreateShaderModule(device, R"(
struct UBO {
color : vec3<f32>,
color : vec3f,
depth : f32,
}
@group(0) @binding(0) var<uniform> ubo : UBO;
@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),
vec2<f32>( 1.0, -1.0), // front-facing
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>( 1.0, -1.0)); // back-facing
return vec4<f32>(pos[VertexIndex], ubo.depth, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0), // front-facing
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f( 1.0, -1.0)); // back-facing
return vec4f(pos[VertexIndex], ubo.depth, 1.0);
})");
fsModule = utils::CreateShaderModule(device, R"(
struct UBO {
color : vec3<f32>,
color : vec3f,
depth : f32,
}
@group(0) @binding(0) var<uniform> ubo : UBO;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(ubo.color, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(ubo.color, 1.0);
})");
}

View File

@ -32,13 +32,13 @@ class DestroyTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -108,7 +108,7 @@ TEST_P(DeviceLostTest, CreateBindGroupLayoutFails) {
TEST_P(DeviceLostTest, GetBindGroupLayoutFails) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct UniformBuffer {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> ubo : UniformBuffer;
@compute @workgroup_size(1) fn main() {
@ -195,7 +195,7 @@ TEST_P(DeviceLostTest, CreateShaderModuleFails) {
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) color : vec4f) -> @location(0) vec4f {
return color;
})"));
}
@ -499,17 +499,17 @@ TEST_P(DeviceLostTest, DeviceLostInRenderPassWithDrawIndirect) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 4u, 4u);
utils::ComboRenderPipelineDescriptor desc;
desc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main(@builtin(vertex_index) i : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>(3.0, -1.0),
vec2<f32>(-1.0, 3.0));
return vec4<f32>(pos[i], 0.0, 1.0);
@vertex fn main(@builtin(vertex_index) i : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f(3.0, -1.0),
vec2f(-1.0, 3.0));
return vec4f(pos[i], 0.0, 1.0);
}
)");
desc.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
}
)");
desc.cTargets[0].format = renderPass.colorFormat;

View File

@ -38,13 +38,13 @@ class DrawIndexedIndirectTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -28,13 +28,13 @@ class DrawIndexedTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -28,13 +28,13 @@ class DrawIndirectTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -28,13 +28,13 @@ class DrawTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -105,12 +105,12 @@ class DynamicBufferOffsetTests : public DawnTest {
wgpu::RenderPipeline CreateRenderPipeline(bool isInheritedPipeline = false) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 0.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 0.0),
vec2f(-1.0, 1.0),
vec2f( 0.0, 1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
// Construct fragment shader source
@ -118,7 +118,7 @@ class DynamicBufferOffsetTests : public DawnTest {
std::string multipleNumber = isInheritedPipeline ? "2" : "1";
fs << R"(
struct Buf {
value : vec2<u32>
value : vec2u
}
@group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf;
@ -135,10 +135,10 @@ class DynamicBufferOffsetTests : public DawnTest {
fs << "const multipleNumber : u32 = " << multipleNumber << "u;\n";
fs << R"(
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
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,
sBuffer.value = vec2u(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy);
return vec4f(f32(uBuffer.value.x) / 255.0, f32(uBuffer.value.y) / 255.0,
1.0, 1.0);
}
)";
@ -168,7 +168,7 @@ class DynamicBufferOffsetTests : public DawnTest {
std::string multipleNumber = isInheritedPipeline ? "2" : "1";
cs << R"(
struct Buf {
value : vec2<u32>
value : vec2u
}
@group(0) @binding(0) var<uniform> uBufferNotDynamic : Buf;
@ -187,7 +187,7 @@ class DynamicBufferOffsetTests : public DawnTest {
cs << R"(
@compute @workgroup_size(1) fn main() {
sBufferNotDynamic.value = uBufferNotDynamic.value.xy;
sBuffer.value = vec2<u32>(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy);
sBuffer.value = vec2u(multipleNumber, multipleNumber) * (uBuffer.value.xy + uBufferNotDynamic.value.xy);
}
)";
@ -456,7 +456,7 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
case wgpu::BufferUsage::Uniform:
shader << R"(
struct Src {
values : array<vec4<u32>, kArrayLength>
values : array<vec4u, kArrayLength>
}
@group(0) @binding(0) var<uniform> src : Src;
)";
@ -464,7 +464,7 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
case wgpu::BufferUsage::Storage:
shader << R"(
struct Src {
values : array<vec4<u32>>
values : array<vec4u>
}
@group(0) @binding(0) var<storage, read> src : Src;
)";
@ -475,7 +475,7 @@ TEST_P(ClampedOOBDynamicBufferOffsetTests, CheckOOBAccess) {
shader << R"(
struct Dst {
values : array<vec4<u32>>
values : array<vec4u>
}
@group(0) @binding(1) var<storage, read_write> dst : Dst;
)";

View File

@ -24,12 +24,12 @@ 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"(
@vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn vertex_main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
}
@fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn fragment_main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)");

View File

@ -41,14 +41,14 @@ class ExternalTextureTests : public DawnTest {
DawnTest::SetUp();
vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var positions = array<vec4<f32>, 6>(
vec4<f32>(-1.0, 1.0, 0.0, 1.0),
vec4<f32>(-1.0, -1.0, 0.0, 1.0),
vec4<f32>(1.0, 1.0, 0.0, 1.0),
vec4<f32>(1.0, -1.0, 0.0, 1.0),
vec4<f32>(-1.0, -1.0, 0.0, 1.0),
vec4<f32>(1.0, 1.0, 0.0, 1.0)
@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var positions = array(
vec4f(-1.0, 1.0, 0.0, 1.0),
vec4f(-1.0, -1.0, 0.0, 1.0),
vec4f(1.0, 1.0, 0.0, 1.0),
vec4f(1.0, -1.0, 0.0, 1.0),
vec4f(-1.0, -1.0, 0.0, 1.0),
vec4f(1.0, 1.0, 0.0, 1.0)
);
return positions[VertexIndex];
})");
@ -57,9 +57,9 @@ class ExternalTextureTests : public DawnTest {
@group(0) @binding(0) var s : sampler;
@group(0) @binding(1) var t : texture_external;
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
return textureSampleBaseClampToEdge(t, s, FragCoord.xy / vec2<f32>(4.0, 4.0));
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
return textureSampleBaseClampToEdge(t, s, FragCoord.xy / vec2f(4.0, 4.0));
})");
}
@ -300,21 +300,21 @@ TEST_P(ExternalTextureTests, RotateAndOrFlipSinglePlane) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
const wgpu::ShaderModule sourceTextureFsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
if(FragCoord.y < 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
return vec4f(0.0, 1.0, 0.0, 1.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.0, 0.0, 1.0, 1.0);
return vec4f(0.0, 0.0, 1.0, 1.0);
}
if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vec4f(0.0, 0.0, 0.0, 1.0);
}
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
return vec4f(1.0, 0.0, 0.0, 1.0);
})");
wgpu::Texture sourceTexture =
@ -461,41 +461,41 @@ TEST_P(ExternalTextureTests, RotateAndOrFlipMultiplanar) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
const wgpu::ShaderModule sourceTexturePlane0FsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
if(FragCoord.y < 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(0.7152, 0.0, 0.0, 0.0);
return vec4f(0.7152, 0.0, 0.0, 0.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.0722, 0.0, 1.0, 1.0);
return vec4f(0.0722, 0.0, 1.0, 1.0);
}
if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
return vec4f(0.0, 0.0, 0.0, 0.0);
}
return vec4<f32>(0.2126, 0.0, 0.0, 0.0);
return vec4f(0.2126, 0.0, 0.0, 0.0);
})");
const wgpu::ShaderModule sourceTexturePlane1FsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
if(FragCoord.x < 2.0 && FragCoord.y < 2.0) {
return vec4<f32>(0.1402, 0.0175, 0.0, 0.0);
return vec4f(0.1402, 0.0175, 0.0, 0.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(1.0, 0.4937, 0.0, 0.0);
return vec4f(1.0, 0.4937, 0.0, 0.0);
}
if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.5, 0.5, 0.0, 0.0);
return vec4f(0.5, 0.5, 0.0, 0.0);
}
return vec4<f32>(0.4172, 1.0, 0.0, 0.0);
return vec4f(0.4172, 1.0, 0.0, 0.0);
})");
wgpu::Texture sourceTexturePlane0 =
@ -647,27 +647,27 @@ TEST_P(ExternalTextureTests, CropSinglePlane) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
const wgpu::ShaderModule sourceTextureFsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
if(FragCoord.x >= 1.0 && FragCoord.x < 3.0 && FragCoord.y >= 1.0 && FragCoord.y < 3.0) {
if(FragCoord.y < 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
return vec4f(0.0, 1.0, 0.0, 1.0);
}
if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
return vec4f(1.0, 1.0, 1.0, 1.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
return vec4f(1.0, 0.0, 0.0, 1.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.0, 0.0, 1.0, 1.0);
return vec4f(0.0, 0.0, 1.0, 1.0);
}
}
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::Texture sourceTexture =
@ -811,51 +811,51 @@ TEST_P(ExternalTextureTests, CropMultiplanar) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
const wgpu::ShaderModule sourceTexturePlane0FsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
if(FragCoord.x >= 1.0 && FragCoord.x < 3.0 && FragCoord.y >= 1.0 && FragCoord.y < 3.0) {
if(FragCoord.y < 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(0.7152, 0.0, 0.0, 0.0);
return vec4f(0.7152, 0.0, 0.0, 0.0);
}
if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(1.0, 0.0, 0.0, 0.0);
return vec4f(1.0, 0.0, 0.0, 0.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(0.2126, 0.0, 0.0, 0.0);
return vec4f(0.2126, 0.0, 0.0, 0.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.0722, 0.0, 1.0, 1.0);
return vec4f(0.0722, 0.0, 1.0, 1.0);
}
}
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
const wgpu::ShaderModule sourceTexturePlane1FsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(position) FragCoord : vec4<f32>)
-> @location(0) vec4<f32> {
@fragment fn main(@builtin(position) FragCoord : vec4f)
-> @location(0) vec4f {
if(FragCoord.x >= 1.0 && FragCoord.x < 3.0 && FragCoord.y >= 1.0 && FragCoord.y < 3.0) {
if(FragCoord.y < 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(0.1402, 0.0175, 0.0, 0.0);
return vec4f(0.1402, 0.0175, 0.0, 0.0);
}
if(FragCoord.y < 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(0.5, 0.5, 0.0, 0.0);
return vec4f(0.5, 0.5, 0.0, 0.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x < 2.0) {
return vec4<f32>(0.4172, 1.0, 0.0, 0.0);
return vec4f(0.4172, 1.0, 0.0, 0.0);
}
if(FragCoord.y >= 2.0 && FragCoord.x >= 2.0) {
return vec4<f32>(1.0, 0.4937, 0.0, 0.0);
return vec4f(1.0, 0.4937, 0.0, 0.0);
}
}
return vec4<f32>(0.5, 0.5, 0.0, 0.0);
return vec4f(0.5, 0.5, 0.0, 0.0);
})");
wgpu::Texture sourceTexturePlane0 =

View File

@ -108,8 +108,8 @@ 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 : vec4f,\n";
vertexOutputs << " @builtin(position) position : vec4f,\n";
if ((checkIndex & CheckIndex::Vertex) != 0) {
vertexInputs << " @builtin(vertex_index) vertex_index : u32,\n";

View File

@ -26,8 +26,8 @@ TEST_P(FragDepthTests, FragDepthIsClampedToViewport) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@vertex fn vs() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.5, 1.0);
@vertex fn vs() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.5, 1.0);
}
@fragment fn fs() -> @builtin(frag_depth) f32 {
@ -81,8 +81,8 @@ TEST_P(FragDepthTests, ChangingPipelineLayoutDoesntInvalidateViewport) {
DAWN_SUPPRESS_TEST_IF(IsOpenGL() || IsOpenGLES());
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@vertex fn vs() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.5, 1.0);
@vertex fn vs() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.5, 1.0);
}
@group(0) @binding(0) var<uniform> uniformDepth : f32;
@ -174,8 +174,8 @@ TEST_P(FragDepthTests, RasterizationClipBeforeFS) {
DAWN_SUPPRESS_TEST_IF(IsMetal());
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@vertex fn vs() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 5.0, 1.0);
@vertex fn vs() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 5.0, 1.0);
}
@fragment fn fs() -> @builtin(frag_depth) f32 {

View File

@ -61,8 +61,8 @@ class GpuMemorySyncTests : public DawnTest {
const wgpu::Buffer& buffer,
wgpu::TextureFormat colorFormat) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -70,9 +70,9 @@ class GpuMemorySyncTests : public DawnTest {
i : i32
}
@group(0) @binding(0) var<storage, read_write> data : Data;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
data.i = data.i + 1;
return vec4<f32>(f32(data.i) / 255.0, 0.0, 0.0, 1.0);
return vec4f(f32(data.i) / 255.0, 0.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor rpDesc;
@ -252,8 +252,8 @@ class StorageToUniformSyncTests : public DawnTest {
std::tuple<wgpu::RenderPipeline, wgpu::BindGroup> CreatePipelineAndBindGroupForRender(
wgpu::TextureFormat colorFormat) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -262,8 +262,8 @@ class StorageToUniformSyncTests : public DawnTest {
}
@group(0) @binding(0) var<uniform> contents : Contents;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(contents.color, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(contents.color, 0.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor rpDesc;
@ -417,12 +417,12 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
// Create pipeline, bind group, and different buffers for compute pass.
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct VBContents {
pos : array<vec4<f32>, 4>
pos : array<vec4f, 4>
}
@group(0) @binding(0) var<storage, read_write> vbContents : VBContents;
struct IBContents {
indices : array<vec4<i32>, 2>
indices : array<vec4i, 2>
}
@group(0) @binding(1) var<storage, read_write> ibContents : IBContents;
@ -433,13 +433,13 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
@group(0) @binding(3) var<storage, read_write> storageContents : ColorContents;
@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);
vbContents.pos[3] = vec4<f32>(-1.0, -1.0, 0.0, 1.0);
vbContents.pos[0] = vec4f(-1.0, 1.0, 0.0, 1.0);
vbContents.pos[1] = vec4f(1.0, 1.0, 0.0, 1.0);
vbContents.pos[2] = vec4f(1.0, -1.0, 0.0, 1.0);
vbContents.pos[3] = vec4f(-1.0, -1.0, 0.0, 1.0);
let placeholder : i32 = 0;
ibContents.indices[0] = vec4<i32>(0, 1, 2, 0);
ibContents.indices[1] = vec4<i32>(2, 3, placeholder, placeholder);
ibContents.indices[0] = vec4i(0, 1, 2, 0);
ibContents.indices[1] = vec4i(2, 3, placeholder, placeholder);
uniformContents.color = 1.0;
storageContents.color = 1.0;
})");
@ -474,7 +474,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
// Create pipeline, bind group, and reuse buffers in render pass.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
@ -486,8 +486,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
@group(0) @binding(0) var<uniform> uniformBuffer : Buf;
@group(0) @binding(1) var<storage, read> storageBuffer : Buf;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
@ -539,8 +539,8 @@ 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) pos : array<vec4f, 4>,
@align(256) indices : array<vec4i, 2>,
@align(256) color0 : f32,
@align(256) color1 : f32,
}
@ -548,13 +548,13 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
@group(0) @binding(0) var<storage, read_write> contents : Contents;
@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);
contents.pos[3] = vec4<f32>(-1.0, -1.0, 0.0, 1.0);
contents.pos[0] = vec4f(-1.0, 1.0, 0.0, 1.0);
contents.pos[1] = vec4f(1.0, 1.0, 0.0, 1.0);
contents.pos[2] = vec4f(1.0, -1.0, 0.0, 1.0);
contents.pos[3] = vec4f(-1.0, -1.0, 0.0, 1.0);
let placeholder : i32 = 0;
contents.indices[0] = vec4<i32>(0, 1, 2, 0);
contents.indices[1] = vec4<i32>(2, 3, placeholder, placeholder);
contents.indices[0] = vec4i(0, 1, 2, 0);
contents.indices[1] = vec4i(2, 3, placeholder, placeholder);
contents.color0 = 1.0;
contents.color1 = 1.0;
})");
@ -591,7 +591,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
// Create pipeline, bind group, and reuse the buffer in render pass.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
@ -602,8 +602,8 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
@group(0) @binding(0) var<uniform> uniformBuffer : Buf;
@group(0) @binding(1) var<storage, read> storageBuffer : Buf;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(uniformBuffer.color, storageBuffer.color, 0.0, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);

View File

@ -225,30 +225,30 @@ 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 : vec2f,
@builtin(position) position : vec4f,
}
@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),
vec2<f32>( 2.0, -2.0),
vec2<f32>(-2.0, 2.0),
vec2<f32>( 2.0, -2.0),
vec2<f32>( 2.0, 2.0));
var pos = array(
vec2f(-2.0, -2.0),
vec2f(-2.0, 2.0),
vec2f( 2.0, -2.0),
vec2f(-2.0, 2.0),
vec2f( 2.0, -2.0),
vec2f( 2.0, 2.0));
var texCoord = array<vec2<f32>, 6>(
vec2<f32>(0.0, 0.0),
vec2<f32>(0.0, 1.0),
vec2<f32>(1.0, 0.0),
vec2<f32>(0.0, 1.0),
vec2<f32>(1.0, 0.0),
vec2<f32>(1.0, 1.0));
var texCoord = array(
vec2f(0.0, 0.0),
vec2f(0.0, 1.0),
vec2f(1.0, 0.0),
vec2f(0.0, 1.0),
vec2f(1.0, 0.0),
vec2f(1.0, 1.0));
var output : VertexOut;
output.position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
output.position = vec4f(pos[VertexIndex], 0.0, 1.0);
output.texCoord = texCoord[VertexIndex];
return output;
}
@ -258,7 +258,7 @@ class IOSurfaceUsageTests : public IOSurfaceTestBase {
@group(0) @binding(1) var texture0 : texture_2d<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
return textureSample(texture0, sampler0, texCoord);
}
)");

View File

@ -35,21 +35,21 @@ class IndexFormatTest : public DawnTest {
wgpu::PrimitiveTopology primitiveTopology = wgpu::PrimitiveTopology::TriangleStrip) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct VertexIn {
@location(0) pos : vec4<f32>,
@location(0) pos : vec4f,
@builtin(vertex_index) idx : u32,
}
@vertex fn main(input : VertexIn) -> @builtin(position) vec4<f32> {
@vertex fn main(input : VertexIn) -> @builtin(position) vec4f {
// 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);
return vec4f(0.0, 0.0, 0.0, 1.0);
}
return input.pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -47,13 +47,13 @@ class MultisampledRenderingTest : public DawnTest {
bool flipTriangle = false) {
const char* kFsOneOutputWithDepth = R"(
struct U {
color : vec4<f32>,
color : vec4f,
depth : f32,
}
@group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut {
@location(0) color : vec4<f32>,
@location(0) color : vec4f,
@builtin(frag_depth) depth : f32,
}
@ -66,11 +66,11 @@ class MultisampledRenderingTest : public DawnTest {
const char* kFsOneOutputWithoutDepth = R"(
struct U {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<uniform> uBuffer : U;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return uBuffer.color;
})";
@ -85,14 +85,14 @@ class MultisampledRenderingTest : public DawnTest {
bool alphaToCoverageEnabled = false) {
const char* kFsTwoOutputs = R"(
struct U {
color0 : vec4<f32>,
color1 : vec4<f32>,
color0 : vec4f,
color1 : vec4f,
}
@group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut {
@location(0) color0 : vec4<f32>,
@location(1) color1 : vec4<f32>,
@location(0) color0 : vec4f,
@location(1) color1 : vec4f,
}
@fragment fn main() -> FragmentOut {
@ -226,25 +226,25 @@ class MultisampledRenderingTest : public DawnTest {
// only two of the samples will be touched.
const char* vs = R"(
@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),
vec2<f32>( 1.0, -1.0)
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f( 1.0, -1.0)
);
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})";
// Draw a bottom-left triangle.
const char* vsFlipped = R"(
@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),
vec2<f32>(-1.0, -1.0)
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0)
);
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})";
if (flipTriangle) {
@ -769,12 +769,12 @@ TEST_P(MultisampledRenderingTest, ResolveInto2DTextureWithSampleMaskAndShaderOut
constexpr uint32_t kSampleMask = kFirstSampleMaskBit | kThirdSampleMaskBit;
const char* fs = R"(
struct U {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut {
@location(0) color : vec4<f32>,
@location(0) color : vec4f,
@builtin(sample_mask) sampleMask : u32,
}
@ -825,14 +825,14 @@ TEST_P(MultisampledRenderingTest, ResolveIntoMultipleResolveTargetsWithShaderOut
constexpr float kMSAACoverage = 0.25f;
const char* fs = R"(
struct U {
color0 : vec4<f32>,
color1 : vec4<f32>,
color0 : vec4f,
color1 : vec4f,
}
@group(0) @binding(0) var<uniform> uBuffer : U;
struct FragmentOut {
@location(0) color0 : vec4<f32>,
@location(1) color1 : vec4<f32>,
@location(0) color0 : vec4f,
@location(1) color1 : vec4f,
@builtin(sample_mask) sampleMask : u32,
}

View File

@ -56,8 +56,8 @@ class MultisampledSamplingTest : public DawnTest {
desc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> {
return vec4<f32>(pos, 0.0, 1.0);
fn main(@location(0) pos : vec2f) -> @builtin(position) vec4f {
return vec4f(pos, 0.0, 1.0);
})");
desc.cFragment.module = utils::CreateShaderModule(device, R"(
@ -105,8 +105,8 @@ class MultisampledSamplingTest : public DawnTest {
@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);
results.colorSamples[i] = textureLoad(texture0, vec2i(0, 0), i).x;
results.depthSamples[i] = textureLoad(texture1, vec2i(0, 0), i);
}
})");

View File

@ -106,16 +106,16 @@ TEST_P(ObjectCachingTest, PipelineLayoutDeduplication) {
// Test that ShaderModules are correctly deduplicated.
TEST_P(ObjectCachingTest, ShaderModuleDeduplication) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
EXPECT_NE(module.Get(), otherModule.Get());
@ -252,8 +252,8 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnLayout) {
utils::ComboRenderPipelineDescriptor desc;
desc.cTargets[0].writeMask = wgpu::ColorWriteMask::None;
desc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
desc.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() {
@ -275,16 +275,16 @@ 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"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
wgpu::ShaderModule sameModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(1.0, 1.0, 1.0, 1.0);
})");
EXPECT_NE(module.Get(), otherModule.Get());
@ -318,8 +318,8 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
@fragment fn main() {
})");
wgpu::ShaderModule otherModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
EXPECT_NE(module.Get(), otherModule.Get());
@ -327,8 +327,8 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
utils::ComboRenderPipelineDescriptor desc;
desc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
desc.cFragment.module = module;
@ -349,11 +349,11 @@ TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnFragmentModule) {
TEST_P(ObjectCachingTest, RenderPipelineDeduplicationOnOverrides) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
override a: f32 = 1.0;
@vertex fn vertexMain() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn vertexMain() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
}
@fragment fn fragmentMain() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, a);
@fragment fn fragmentMain() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 0.0, a);
})");
utils::ComboRenderPipelineDescriptor desc;

View File

@ -168,13 +168,13 @@ TEST_P(OpArrayLengthTest, Fragment) {
// Create the pipeline that computes the length of the buffers and writes it to the only render
// pass pixel.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, (mShaderInterface + R"(
@fragment fn main() -> @location(0) vec4<f32> {
var fragColor : vec4<f32>;
@fragment fn main() -> @location(0) vec4f {
var fragColor : vec4f;
fragColor.r = f32(arrayLength(&buffer1.data)) / 255.0;
fragColor.g = f32(arrayLength(&buffer2.data)) / 255.0;
fragColor.b = f32(arrayLength(&buffer3.data)) / 255.0;
@ -226,8 +226,8 @@ 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 : vec4f,
@builtin(position) position : vec4f,
}
@vertex fn main() -> VertexOut {
@ -237,14 +237,14 @@ TEST_P(OpArrayLengthTest, Vertex) {
output.color.b = f32(arrayLength(&buffer3.data)) / 255.0;
output.color.a = 0.0;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
})")
.c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) color : vec4f) -> @location(0) vec4f {
return color;
})");

View File

@ -36,37 +36,37 @@ static constexpr std::string_view kComputeShaderMultipleEntryPoints = R"(
)";
static constexpr std::string_view kVertexShaderDefault = R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
}
)";
static constexpr std::string_view kVertexShaderMultipleEntryPoints = R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
@vertex fn main2() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.5, 0.5, 0.5, 1.0);
@vertex fn main2() -> @builtin(position) vec4f {
return vec4f(0.5, 0.5, 0.5, 1.0);
}
)";
static constexpr std::string_view kFragmentShaderDefault = R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.1, 0.2, 0.3, 0.4);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.1, 0.2, 0.3, 0.4);
}
)";
static constexpr std::string_view kFragmentShaderMultipleOutput = R"(
struct FragmentOut {
@location(0) fragColor0 : vec4<f32>,
@location(1) fragColor1 : vec4<f32>,
@location(0) fragColor0 : vec4f,
@location(1) fragColor1 : vec4f,
}
@fragment fn main() -> FragmentOut {
var output : FragmentOut;
output.fragColor0 = vec4<f32>(0.1, 0.2, 0.3, 0.4);
output.fragColor1 = vec4<f32>(0.5, 0.6, 0.7, 0.8);
output.fragColor0 = vec4f(0.1, 0.2, 0.3, 0.4);
output.fragColor1 = vec4f(0.5, 0.6, 0.7, 0.8);
return output;
}
)";
@ -78,8 +78,8 @@ static constexpr std::string_view kFragmentShaderBindGroup00Uniform = R"(
@group(0) @binding(0) var<uniform> uBuffer : S;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uBuffer.value, 0.2, 0.3, 0.4);
@fragment fn main() -> @location(0) vec4f {
return vec4f(uBuffer.value, 0.2, 0.3, 0.4);
}
)";
@ -90,8 +90,8 @@ static constexpr std::string_view kFragmentShaderBindGroup01Uniform = R"(
@group(0) @binding(1) var<uniform> uBuffer : S;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(uBuffer.value, 0.2, 0.3, 0.4);
@fragment fn main() -> @location(0) vec4f {
return vec4f(uBuffer.value, 0.2, 0.3, 0.4);
}
)";

View File

@ -47,24 +47,24 @@ class DepthClippingTest : public DawnTest {
vsModule = utils::CreateShaderModule(device, R"(
struct UBO {
color : vec3<f32>,
color : vec3f,
depth : f32,
}
@group(0) @binding(0) var<uniform> ubo : UBO;
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, ubo.depth, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, ubo.depth, 1.0);
})");
fsModule = utils::CreateShaderModule(device, R"(
struct UBO {
color : vec3<f32>,
color : vec3f,
depth : f32,
}
@group(0) @binding(0) var<uniform> ubo : UBO;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(ubo.color, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(ubo.color, 1.0);
})");
}
@ -326,14 +326,14 @@ TEST_P(DepthClippingTest, UnclippedNotClamped) {
descriptor.primitive.topology = wgpu::PrimitiveTopology::PointList;
// Draw the point at (0, 0) with depth 2.0.
descriptor.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 2.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 2.0, 1.0);
})");
// Write frag_pos.z / 4.0 which should be about 0.5 to the red channel.
// This is the depth output from the vertex shader which is not clamped to the viewport.
descriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(position) frag_pos: vec4<f32>) -> @location(0) vec4<f32> {
return vec4<f32>(frag_pos.z / 4.0, 0.0, 0.0, 1.0);
@fragment fn main(@builtin(position) frag_pos: vec4f) -> @location(0) vec4f {
return vec4f(frag_pos.z / 4.0, 0.0, 0.0, 1.0);
})");
wgpu::DepthStencilState* depthStencil = descriptor.EnableDepthStencil();
depthStencil->depthWriteEnabled = true;

View File

@ -156,13 +156,13 @@ class PrimitiveTopologyTest : public DawnTest {
vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
vertexBuffer = utils::CreateBufferFromData(device, kVertices, sizeof(kVertices),

View File

@ -89,17 +89,17 @@ class OcclusionQueryTests : public QueryTests {
// Create basic render pipeline
vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -534,18 +534,18 @@ class TimestampQueryTests : public QueryTests {
descriptor.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
if (hasFragmentStage) {
descriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
} else {
descriptor.fragment = nullptr;

View File

@ -65,22 +65,22 @@ class ReadOnlyDepthStencilAttachmentTests
// pipeline.
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec3<f32>( 1.0, 1.0, 0.4),
vec3<f32>( 1.0, 1.0, 0.4),
vec3<f32>(-1.0, -1.0, 0.0),
vec3<f32>( 1.0, -1.0, 0.0));
return vec4<f32>(pos[VertexIndex], 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec3f(-1.0, 1.0, 0.4),
vec3f(-1.0, -1.0, 0.0),
vec3f( 1.0, 1.0, 0.4),
vec3f( 1.0, 1.0, 0.4),
vec3f(-1.0, -1.0, 0.0),
vec3f( 1.0, -1.0, 0.0));
return vec4f(pos[VertexIndex], 1.0);
})");
if (!sampleFromAttachment) {
// Draw a solid blue into color buffer if not sample from depth/stencil attachment.
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 1.0, 0.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 1.0, 0.0);
})");
} else {
// Sample from depth/stencil attachment and draw that sampled texel into color buffer.
@ -90,8 +90,8 @@ class ReadOnlyDepthStencilAttachmentTests
@group(0) @binding(1) var tex : texture_depth_2d;
@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);
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return vec4f(textureSample(tex, samp, FragCoord.xy), 0.0, 0.0, 0.0);
})");
} else {
ASSERT(aspect == wgpu::TextureAspect::StencilOnly);
@ -99,9 +99,9 @@ class ReadOnlyDepthStencilAttachmentTests
@group(0) @binding(0) var tex : texture_2d<u32>;
@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);
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
var texel = textureLoad(tex, vec2i(FragCoord.xy), 0);
return vec4f(f32(texel[0]) / 255.0, 0.0, 0.0, 0.0);
})");
}
}

View File

@ -24,25 +24,25 @@ class RenderAttachmentTest : public DawnTest {};
TEST_P(RenderAttachmentTest, MoreFragmentOutputsThanAttachments) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
fn main() -> @builtin(position) vec4f {
return vec4f(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 : vec4f,
@location(1) color1 : vec4f,
@location(2) color2 : vec4f,
@location(3) color3 : vec4f,
}
@fragment
fn main() -> Output {
var output : Output;
output.color0 = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.color1 = vec4<f32>(0.0, 1.0, 0.0, 1.0);
output.color2 = vec4<f32>(0.0, 0.0, 1.0, 1.0);
output.color3 = vec4<f32>(1.0, 1.0, 0.0, 1.0);
output.color0 = vec4f(1.0, 0.0, 0.0, 1.0);
output.color1 = vec4f(0.0, 1.0, 0.0, 1.0);
output.color2 = vec4f(0.0, 0.0, 1.0, 1.0);
output.color3 = vec4f(1.0, 1.0, 0.0, 1.0);
return output;
})");

View File

@ -33,17 +33,17 @@ class RenderBundleTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct Ubo {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<uniform> fragmentUniformBuffer : Ubo;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return fragmentUniformBuffer.color;
})");

View File

@ -82,21 +82,21 @@ class RenderPassLoadOpTests : public DawnTest {
// draws a blue quad on the right half of the screen
const char* vsSource = R"(
@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),
vec2<f32>( 0.0, 1.0),
vec2<f32>( 0.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f( 0.0, -1.0),
vec2f( 1.0, -1.0),
vec2f( 0.0, 1.0),
vec2f( 0.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})";
const char* fsSource = R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 1.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 1.0, 1.0);
})";
blueQuad = DrawQuad(device, vsSource, fsSource);
}

View File

@ -30,18 +30,18 @@ class RenderPassTest : public DawnTest {
// Shaders to draw a bottom-left triangle in blue.
mVSModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f(-1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 1.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 1.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -44,15 +44,15 @@ class SamplerFilterAnisotropicTest : public DawnTest {
}
struct VertexIn {
@location(0) position : vec4<f32>,
@location(1) uv : vec2<f32>,
@location(0) position : vec4f,
@location(1) uv : vec2f,
}
@group(0) @binding(2) var<uniform> uniforms : Uniforms;
struct VertexOut {
@location(0) uv : vec2<f32>,
@builtin(position) position : vec4<f32>,
@location(0) uv : vec2f,
@builtin(position) position : vec4f,
}
@vertex
@ -68,12 +68,12 @@ class SamplerFilterAnisotropicTest : public DawnTest {
@group(0) @binding(1) var texture0 : texture_2d<f32>;
struct FragmentIn {
@location(0) uv: vec2<f32>,
@builtin(position) fragCoord : vec4<f32>,
@location(0) uv: vec2f,
@builtin(position) fragCoord : vec4f,
}
@fragment
fn main(input : FragmentIn) -> @location(0) vec4<f32> {
fn main(input : FragmentIn) -> @location(0) vec4f {
return textureSample(texture0, sampler0, input.uv);
})");

View File

@ -92,15 +92,15 @@ class SamplerTest : public DawnTest {
void InitShaders(const char* frag_shader) {
auto vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 2.0, -2.0),
vec2<f32>(-2.0, 2.0),
vec2<f32>( 2.0, -2.0),
vec2<f32>( 2.0, 2.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-2.0, -2.0),
vec2f(-2.0, 2.0),
vec2f( 2.0, -2.0),
vec2f(-2.0, 2.0),
vec2f( 2.0, -2.0),
vec2f( 2.0, 2.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
}
)");
auto fsModule = utils::CreateShaderModule(device, frag_shader);
@ -169,7 +169,7 @@ TEST_P(SamplerTest, AddressMode) {
@group(0) @binding(1) var texture0 : texture_2d<f32>;
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return textureSample(texture0, sampler0, FragCoord.xy / vec2(2.0, 2.0));
})");
for (auto u : addressModes) {
@ -187,12 +187,12 @@ TEST_P(SamplerTest, PassThroughUserFunctionParameters) {
@group(0) @binding(0) var sampler0 : sampler;
@group(0) @binding(1) var texture0 : texture_2d<f32>;
fn foo(t : texture_2d<f32>, s : sampler, FragCoord : vec4<f32>) -> vec4<f32> {
fn foo(t : texture_2d<f32>, s : sampler, FragCoord : vec4f) -> vec4f {
return textureSample(t, s, FragCoord.xy / vec2(2.0, 2.0));
}
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return foo(texture0, sampler0, FragCoord);
})");
for (auto u : addressModes) {

View File

@ -22,20 +22,20 @@ class ScissorTest : public DawnTest {
wgpu::RenderPipeline CreateQuadPipeline(wgpu::TextureFormat format) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.5, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0));
return vec4f(pos[VertexIndex], 0.5, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -147,13 +147,13 @@ TEST_P(ShaderF16Tests, RenderPipelineIOF16_RenderTarget) {
enable f16;
@vertex
fn VSMain(@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),
vec2<f32>(-1.0, -1.0));
fn VSMain(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f(-1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
}
@fragment
@ -215,23 +215,23 @@ enable f16;
struct VSOutput{
@builtin(position)
pos: vec4<f32>,
pos: vec4f,
@location(3)
color_vsout: vec4<f16>,
}
@vertex
fn VSMain(@builtin(vertex_index) VertexIndex : u32) -> VSOutput {
var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>(-1.0, -1.0));
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f(-1.0, -1.0));
// Blue
var color = vec4<f16>(0.0h, 0.0h, 1.0h, 1.0h);
var result: VSOutput;
result.pos = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
result.pos = vec4f(pos[VertexIndex], 0.0, 1.0);
result.color_vsout = color;
return result;
@ -243,9 +243,9 @@ struct FSInput{
}
@fragment
fn FSMain(fsInput: FSInput) -> @location(0) vec4<f32> {
fn FSMain(fsInput: FSInput) -> @location(0) vec4f {
// Paint it with given color
return vec4<f32>(fsInput.color_fsin);
return vec4f(fsInput.color_fsin);
})";
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, shader);
@ -307,17 +307,17 @@ struct VSInput {
}
struct VSOutput {
@builtin(position) pos : vec4<f32>,
@location(0) color : vec4<f32>,
@builtin(position) pos : vec4f,
@location(0) color : vec4f,
}
@vertex
fn VSMain(in: VSInput) -> VSOutput {
return VSOutput(vec4<f32>(vec2<f32>(in.pos_half * 2.0h), 0.0, 1.0), vec4<f32>(in.color_quarter * 4.0h));
return VSOutput(vec4f(vec2f(in.pos_half * 2.0h), 0.0, 1.0), vec4f(in.color_quarter * 4.0h));
}
@fragment
fn FSMain(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
fn FSMain(@location(0) color : vec4f) -> @location(0) vec4f {
return color;
})";

View File

@ -116,19 +116,19 @@ I am an invalid shader and should never pass validation!
TEST_P(ShaderTests, WGSLParamIO) {
std::string vertexShader = R"(
@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),
vec2<f32>( 0.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f( 0.0, -1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})";
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexShader.c_str());
std::string fragmentShader = R"(
@fragment
fn main(@builtin(position) fragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return vec4<f32>(fragCoord.xy, 0.0, 1.0);
fn main(@builtin(position) fragCoord : vec4f) -> @location(0) vec4f {
return vec4f(fragCoord.xy, 0.0, 1.0);
})";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
@ -143,19 +143,19 @@ 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 : vec3f,
@location(1) color : vec4f,
}
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex
fn main(input : VertexIn) -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0);
output.position = vec4f(input.position, 1.0);
output.color = input.color;
return output;
})";
@ -163,7 +163,7 @@ fn main(input : VertexIn) -> VertexOut {
std::string fragmentShader = R"(
@fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) color : vec4f) -> @location(0) vec4f {
return color;
})";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
@ -186,19 +186,19 @@ 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 : vec3f,
@location(1) color : vec4f,
}
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex
fn main(input : VertexIn) -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0);
output.position = vec4f(input.position, 1.0);
output.color = input.color;
return output;
})";
@ -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 : vec4f,
@builtin(position) fragCoord : vec4f,
}
@fragment
fn main(input : FragmentIn) -> @location(0) vec4<f32> {
fn main(input : FragmentIn) -> @location(0) vec4f {
return input.color * input.fragCoord;
})";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
@ -233,19 +233,19 @@ 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 : vec3f,
@location(1) color : vec4f,
}
struct VertexOut {
@builtin(position) position : vec4<f32>,
@location(0) color : vec4<f32>,
@builtin(position) position : vec4f,
@location(0) color : vec4f,
}
@vertex
fn main(input : VertexIn) -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0);
output.position = vec4f(input.position, 1.0);
output.color = input.color;
return output;
})";
@ -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 : vec4f,
@builtin(position) fragCoord : vec4f,
}
@fragment
fn main(input : FragmentIn) -> @location(0) vec4<f32> {
fn main(input : FragmentIn) -> @location(0) vec4f {
return input.color * input.fragCoord;
})";
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentShader.c_str());
@ -280,25 +280,25 @@ 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 : vec3f,
@location(1) color : vec4f,
}
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex
fn vertexMain(input : VertexIn) -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(input.position, 1.0);
output.position = vec4f(input.position, 1.0);
output.color = input.color;
return output;
}
@fragment
fn fragmentMain(input : VertexOut) -> @location(0) vec4<f32> {
fn fragmentMain(input : VertexOut) -> @location(0) vec4f {
return input.color;
})";
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, shader.c_str());
@ -324,22 +324,22 @@ fn fragmentMain(input : VertexOut) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLInterstageVariablesSparse) {
std::string shader = R"(
struct ShaderIO {
@builtin(position) position : vec4<f32>,
@location(1) attribute1 : vec4<f32>,
@location(3) attribute3 : vec4<f32>,
@builtin(position) position : vec4f,
@location(1) attribute1 : vec4f,
@location(3) attribute3 : vec4f,
}
@vertex
fn vertexMain() -> ShaderIO {
var output : ShaderIO;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.attribute1 = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.attribute3 = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
output.attribute1 = vec4f(0.0, 0.0, 0.0, 1.0);
output.attribute3 = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
}
@fragment
fn fragmentMain(input : ShaderIO) -> @location(0) vec4<f32> {
fn fragmentMain(input : ShaderIO) -> @location(0) vec4f {
return input.attribute1;
})";
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, shader.c_str());
@ -359,29 +359,29 @@ fn fragmentMain(input : ShaderIO) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLInterstageVariablesBuiltinsMismatched) {
std::string shader = R"(
struct VertexOut {
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
@location(1) attribute1 : f32,
@location(3) attribute3 : vec4<f32>,
@location(3) attribute3 : vec4f,
}
struct FragmentIn {
@location(3) attribute3 : vec4<f32>,
@location(3) attribute3 : vec4f,
@builtin(front_facing) front_facing : bool,
@location(1) attribute1 : f32,
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
}
@vertex
fn vertexMain() -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
output.attribute1 = 1.0;
output.attribute3 = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.attribute3 = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
}
@fragment
fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
fn fragmentMain(input : FragmentIn) -> @location(0) vec4f {
_ = input.front_facing;
_ = input.position.x;
return input.attribute3;
@ -402,29 +402,29 @@ fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLInterstageVariablesPrefixSubset) {
std::string shader = R"(
struct VertexOut {
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
@location(1) attribute1 : f32,
@location(3) attribute3 : vec4<f32>,
@location(3) attribute3 : vec4f,
}
struct FragmentIn {
@location(1) attribute1 : f32,
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
}
@vertex
fn vertexMain() -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
output.attribute1 = 1.0;
output.attribute3 = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.attribute3 = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
}
@fragment
fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
fn fragmentMain(input : FragmentIn) -> @location(0) vec4f {
_ = input.position.x;
return vec4<f32>(input.attribute1, 0.0, 0.0, 1.0);
return vec4f(input.attribute1, 0.0, 0.0, 1.0);
})";
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, shader.c_str());
@ -442,27 +442,27 @@ fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLInterstageVariablesSparseSubset) {
std::string shader = R"(
struct VertexOut {
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
@location(1) attribute1 : f32,
@location(3) attribute3 : vec4<f32>,
@location(3) attribute3 : vec4f,
}
struct FragmentIn {
@location(3) attribute3 : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(3) attribute3 : vec4f,
@builtin(position) position : vec4f,
}
@vertex
fn vertexMain() -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
output.attribute1 = 1.0;
output.attribute3 = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.attribute3 = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
}
@fragment
fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
fn fragmentMain(input : FragmentIn) -> @location(0) vec4f {
_ = input.position.x;
return input.attribute3;
})";
@ -482,28 +482,28 @@ fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLInterstageVariablesSparseSubsetUnused) {
std::string shader = R"(
struct VertexOut {
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
@location(1) attribute1 : f32,
@location(3) attribute3 : vec4<f32>,
@location(3) attribute3 : vec4f,
}
struct FragmentIn {
@location(3) attribute3 : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(3) attribute3 : vec4f,
@builtin(position) position : vec4f,
}
@vertex
fn vertexMain() -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
output.attribute1 = 1.0;
output.attribute3 = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.attribute3 = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
}
@fragment
fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
fn fragmentMain(input : FragmentIn) -> @location(0) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})";
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, shader.c_str());
@ -521,23 +521,23 @@ fn fragmentMain(input : FragmentIn) -> @location(0) vec4<f32> {
TEST_P(ShaderTests, WGSLInterstageVariablesEmptySubset) {
std::string shader = R"(
struct VertexOut {
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
@location(1) attribute1 : f32,
@location(3) attribute3 : vec4<f32>,
@location(3) attribute3 : vec4f,
}
@vertex
fn vertexMain() -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
output.attribute1 = 1.0;
output.attribute3 = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.attribute3 = vec4f(0.0, 0.0, 0.0, 1.0);
return output;
}
@fragment
fn fragmentMain() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
fn fragmentMain() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})";
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, shader.c_str());
@ -566,16 +566,16 @@ struct Inputs {
}
// [1] a binding point that conflicts with the regitster
struct S1 { data : array<vec4<u32>, 20> }
struct S1 { data : array<vec4u, 20> }
@group(0) @binding(1) var<uniform> providedData1 : S1;
@vertex fn vsMain(input : Inputs) -> @builtin(position) vec4<f32> {
@vertex fn vsMain(input : Inputs) -> @builtin(position) vec4f {
_ = providedData1.data[input.vertexIndex][0];
return vec4<f32>();
return vec4f();
}
@fragment fn fsMain() -> @location(0) vec4<f32> {
return vec4<f32>();
@fragment fn fsMain() -> @location(0) vec4f {
return vec4f();
}
)";
auto module = utils::CreateShaderModule(device, shader);
@ -601,14 +601,14 @@ TEST_P(ShaderTests, SampleIndex) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main(@builtin(sample_index) sampleIndex : u32)
-> @location(0) vec4<f32> {
return vec4<f32>(f32(sampleIndex), 1.0, 0.0, 1.0);
-> @location(0) vec4f {
return vec4f(f32(sampleIndex), 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -765,7 +765,7 @@ struct Buf {
@group(0) @binding(0) var<storage, read_write> buf : Buf;
@compute @workgroup_size(x) fn main(
@builtin(local_invocation_id) local_invocation_id : vec3<u32>
@builtin(local_invocation_id) local_invocation_id : vec3u
) {
if (local_invocation_id.x >= x - 1) {
buf.data[0] = local_invocation_id.x + 1;
@ -1025,20 +1025,20 @@ TEST_P(ShaderTests, OverridableConstantsRenderPipeline) {
@id(2222) override ytop: f32;
@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),
vec2<f32>(xright, 0.0));
-> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, ytop),
vec2f(-1.0, -ytop),
vec2f(xright, 0.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@id(1000) override intensity: f32 = 0.0;
@fragment fn main()
-> @location(0) vec4<f32> {
return vec4<f32>(intensity, intensity, intensity, 1.0);
-> @location(0) vec4f {
return vec4f(intensity, intensity, intensity, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
@ -1080,15 +1080,15 @@ TEST_P(ShaderTests, ConflictingBindingsDueToTransformOrder) {
@group(0) @binding(0) var<uniform> b0 : u32;
@group(0) @binding(1) var<uniform> b1 : u32;
@vertex fn vertex() -> @builtin(position) vec4<f32> {
@vertex fn vertex() -> @builtin(position) vec4f {
_ = b0;
return vec4<f32>(0.0);
return vec4f(0.0);
}
@fragment fn fragment() -> @location(0) vec4<f32> {
@fragment fn fragment() -> @location(0) vec4f {
_ = b0;
_ = b1;
return vec4<f32>(0.0);
return vec4f(0.0);
}
)");
@ -1109,7 +1109,7 @@ TEST_P(ShaderTests, DISABLED_CheckUsageOf_chromium_disable_uniformity_analysis)
enable chromium_disable_uniformity_analysis;
@compute @workgroup_size(8) fn uniformity_error(
@builtin(local_invocation_id) local_invocation_id : vec3<u32>
@builtin(local_invocation_id) local_invocation_id : vec3u
) {
if (local_invocation_id.x == 0u) {
workgroupBarrier();
@ -1118,7 +1118,7 @@ TEST_P(ShaderTests, DISABLED_CheckUsageOf_chromium_disable_uniformity_analysis)
)");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@compute @workgroup_size(8) fn uniformity_error(
@builtin(local_invocation_id) local_invocation_id : vec3<u32>
@builtin(local_invocation_id) local_invocation_id : vec3u
) {
if (local_invocation_id.x == 0u) {
workgroupBarrier();
@ -1146,7 +1146,7 @@ TEST_P(ShaderTests, ShaderOverridingRobustnessBuiltins) {
// Prevent the SingleEntryPoint transform from removing our min().
let forceUseOfMin = min(0, 1);
let values = array<u32, 2>(1, 2);
let values = array(1u, 2u);
let index = 1u;
// Robustness adds transforms values[index] into values[min(index, 1u)].
// - If our min() is called, the this will be values[0] which is 1.
@ -1193,15 +1193,15 @@ struct ShaderIO {
@location(5) @interpolate(flat) var5: i32,
@location(7) var7: f32,
@location(9) @interpolate(flat) var9: u32,
@builtin(position) pos: vec4<f32>,
@builtin(position) pos: vec4f,
}
@vertex fn main(@builtin(vertex_index) VertexIndex : u32)
-> ShaderIO {
var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 3.0),
vec2<f32>(-1.0, -3.0),
vec2<f32>(3.0, 0.0));
var pos = array(
vec2f(-1.0, 3.0),
vec2f(-1.0, -3.0),
vec2f(3.0, 0.0));
var shaderIO: ShaderIO;
shaderIO.var1 = 0.0;
@ -1209,7 +1209,7 @@ struct ShaderIO {
shaderIO.var5 = -9;
shaderIO.var7 = 1.0;
shaderIO.var9 = 0u;
shaderIO.pos = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
shaderIO.pos = vec4f(pos[VertexIndex], 0.0, 1.0);
return shaderIO;
})");
@ -1221,8 +1221,8 @@ struct ShaderIO {
}
@fragment fn main(io: ShaderIO)
-> @location(0) vec4<f32> {
return vec4<f32>(f32(io.var3), io.var7, 1.0, 1.0);
-> @location(0) vec4f {
return vec4f(f32(io.var3), io.var7, 1.0, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
@ -1258,38 +1258,38 @@ struct ShaderIO {
@location(1) var1: f32,
@location(2) var2: f32,
@location(3) @align(8) var3: f32,
@location(4) var4: vec4<f32>,
@builtin(position) pos: vec4<f32>,
@location(4) var4: vec4f,
@builtin(position) pos: vec4f,
}
@vertex fn main(@builtin(vertex_index) VertexIndex : u32)
-> ShaderIO {
var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 3.0),
vec2<f32>(-1.0, -3.0),
vec2<f32>(3.0, 0.0));
var pos = array(
vec2f(-1.0, 3.0),
vec2f(-1.0, -3.0),
vec2f(3.0, 0.0));
var shaderIO: ShaderIO;
shaderIO.var1 = 0.0;
shaderIO.var2 = 0.0;
shaderIO.var3 = 1.0;
shaderIO.var4 = vec4<f32>(0.4, 0.4, 0.4, 0.4);
shaderIO.var4 = vec4f(0.4, 0.4, 0.4, 0.4);
shaderIO.var5 = 1.0;
shaderIO.pos = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
shaderIO.pos = vec4f(pos[VertexIndex], 0.0, 1.0);
return shaderIO;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct ShaderIO {
@location(4) var4: vec4<f32>,
@location(4) var4: vec4f,
@location(1) var1: f32,
@location(5) @align(16) var5: f32,
}
@fragment fn main(io: ShaderIO)
-> @location(0) vec4<f32> {
return vec4<f32>(io.var1, io.var5, io.var4.x, 1.0);
-> @location(0) vec4f {
return vec4f(io.var1, io.var5, io.var4.x, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
@ -1319,36 +1319,36 @@ TEST_P(ShaderTests, FragmentInputIsSubsetOfVertexOutputBuiltinOrder) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct ShaderIO {
@location(1) var1: f32,
@builtin(position) pos: vec4<f32>,
@location(8) var8: vec3<f32>,
@builtin(position) pos: vec4f,
@location(8) var8: vec3f,
@location(7) var7: f32,
}
@vertex fn main(@builtin(vertex_index) VertexIndex : u32)
-> ShaderIO {
var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, 3.0),
vec2<f32>(-1.0, -3.0),
vec2<f32>(3.0, 0.0));
var pos = array(
vec2f(-1.0, 3.0),
vec2f(-1.0, -3.0),
vec2f(3.0, 0.0));
var shaderIO: ShaderIO;
shaderIO.var1 = 0.0;
shaderIO.var7 = 1.0;
shaderIO.var8 = vec3<f32>(1.0, 0.4, 0.0);
shaderIO.pos = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
shaderIO.var8 = vec3f(1.0, 0.4, 0.0);
shaderIO.pos = vec4f(pos[VertexIndex], 0.0, 1.0);
return shaderIO;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct ShaderIO {
@builtin(position) pos: vec4<f32>,
@builtin(position) pos: vec4f,
@location(7) var7: f32,
}
@fragment fn main(io: ShaderIO)
-> @location(0) vec4<f32> {
return vec4<f32>(0.0, io.var7, 0.4, 1.0);
-> @location(0) vec4f {
return vec4f(0.0, io.var7, 0.4, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 1, 1);
@ -1377,7 +1377,7 @@ struct ShaderIO {
TEST_P(ShaderTests, DerivativeUniformityDiagnosticFilter) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct VertexOut {
@builtin(position) pos : vec4<f32>,
@builtin(position) pos : vec4f,
@location(0) value : f32,
}
@ -1395,7 +1395,7 @@ fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
diagnostic(off, derivative_uniformity);
@fragment
fn main(@location(0) value : f32) -> @location(0) vec4<f32> {
fn main(@location(0) value : f32) -> @location(0) vec4f {
if (value > 0) {
let intensity = 1.0 - dpdx(1.0);
return vec4(intensity, intensity, intensity, 1.0);

View File

@ -169,7 +169,7 @@ TEST_P(WorkgroupSizeValidationTest, WithFixedValuesStorageSizeLimits) {
std::ostringstream ss;
std::ostringstream body;
if (vec4_count > 0) {
ss << "var<workgroup> vec4_data: array<vec4<f32>, " << vec4_count << ">;";
ss << "var<workgroup> vec4_data: array<vec4f, " << vec4_count << ">;";
body << "_ = vec4_data;";
}
if (mat4_count > 0) {
@ -346,7 +346,7 @@ TEST_P(WorkgroupSizeValidationTest, ValidationAfterOverrideStorageSize) {
ss << "override a: u32;";
ss << "override b: u32;";
if (vec4_count > 0) {
ss << "var<workgroup> vec4_data: array<vec4<f32>, a>;";
ss << "var<workgroup> vec4_data: array<vec4f, a>;";
body << "_ = vec4_data[0];";
constants.push_back({nullptr, "a", static_cast<double>(vec4_count)});
}

View File

@ -197,51 +197,51 @@ class StorageTextureTests : public DawnTest {
switch (format) {
// non-normalized unsigned integer formats
case wgpu::TextureFormat::R32Uint:
return "vec4<u32>(u32(value), 0u, 0u, 1u)";
return "vec4u(u32(value), 0u, 0u, 1u)";
case wgpu::TextureFormat::RG32Uint:
return "vec4<u32>(u32(value), u32(value) * 2u, 0u, 1u)";
return "vec4u(u32(value), u32(value) * 2u, 0u, 1u)";
case wgpu::TextureFormat::RGBA8Uint:
case wgpu::TextureFormat::RGBA16Uint:
case wgpu::TextureFormat::RGBA32Uint:
return "vec4<u32>(u32(value), u32(value) * 2u, "
return "vec4u(u32(value), u32(value) * 2u, "
"u32(value) * 3u, u32(value) * 4u)";
// non-normalized signed integer formats
case wgpu::TextureFormat::R32Sint:
return "vec4<i32>(i32(value), 0, 0, 1)";
return "vec4i(i32(value), 0, 0, 1)";
case wgpu::TextureFormat::RG32Sint:
return "vec4<i32>(i32(value), -i32(value), 0, 1)";
return "vec4i(i32(value), -i32(value), 0, 1)";
case wgpu::TextureFormat::RGBA8Sint:
case wgpu::TextureFormat::RGBA16Sint:
case wgpu::TextureFormat::RGBA32Sint:
return "vec4<i32>(i32(value), -i32(value), i32(value) * 2, -i32(value) * 2)";
return "vec4i(i32(value), -i32(value), i32(value) * 2, -i32(value) * 2)";
// float formats
case wgpu::TextureFormat::R32Float:
return "vec4<f32>(f32(value) * 1.1, 0.0, 0.0, 1.0)";
return "vec4f(f32(value) * 1.1, 0.0, 0.0, 1.0)";
case wgpu::TextureFormat::RG32Float:
return "vec4<f32>(f32(value) * 1.1, -f32(value) * 2.2, 0.0, 1.0)";
return "vec4f(f32(value) * 1.1, -f32(value) * 2.2, 0.0, 1.0)";
case wgpu::TextureFormat::RGBA16Float:
return "vec4<f32>(f32(value), -f32(value), "
return "vec4f(f32(value), -f32(value), "
"f32(value) * 2.0, -f32(value) * 2.0)";
case wgpu::TextureFormat::RGBA32Float:
return "vec4<f32>(f32(value) * 1.1, -f32(value) * 1.1, "
return "vec4f(f32(value) * 1.1, -f32(value) * 1.1, "
"f32(value) * 2.2, -f32(value) * 2.2)";
// normalized signed/unsigned integer formats
case wgpu::TextureFormat::RGBA8Unorm:
return "vec4<f32>(f32(value) / 255.0, f32(value) / 255.0 * 2.0, "
return "vec4f(f32(value) / 255.0, f32(value) / 255.0 * 2.0, "
"f32(value) / 255.0 * 3.0, f32(value) / 255.0 * 4.0)";
case wgpu::TextureFormat::RGBA8Snorm:
return "vec4<f32>(f32(value) / 127.0, -f32(value) / 127.0, "
return "vec4f(f32(value) / 127.0, -f32(value) / 127.0, "
"f32(value) * 2.0 / 127.0, -f32(value) * 2.0 / 127.0)";
default:
@ -259,7 +259,7 @@ class StorageTextureTests : public DawnTest {
case wgpu::TextureFormat::RGBA16Uint:
case wgpu::TextureFormat::RGBA32Uint:
return R"(
fn IsEqualTo(pixel : vec4<u32>, expected : vec4<u32>) -> bool {
fn IsEqualTo(pixel : vec4u, expected : vec4u) -> bool {
return all(pixel == expected);
})";
@ -270,7 +270,7 @@ fn IsEqualTo(pixel : vec4<u32>, expected : vec4<u32>) -> bool {
case wgpu::TextureFormat::RGBA16Sint:
case wgpu::TextureFormat::RGBA32Sint:
return R"(
fn IsEqualTo(pixel : vec4<i32>, expected : vec4<i32>) -> bool {
fn IsEqualTo(pixel : vec4i, expected : vec4i) -> bool {
return all(pixel == expected);
})";
@ -280,7 +280,7 @@ fn IsEqualTo(pixel : vec4<i32>, expected : vec4<i32>) -> bool {
case wgpu::TextureFormat::RGBA16Float:
case wgpu::TextureFormat::RGBA32Float:
return R"(
fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
fn IsEqualTo(pixel : vec4f, expected : vec4f) -> bool {
return all(pixel == expected);
})";
@ -289,9 +289,9 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
case wgpu::TextureFormat::RGBA8Snorm:
// On Windows Intel drivers the tests will fail if tolerance <= 0.00000001f.
return R"(
fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
fn IsEqualTo(pixel : vec4f, expected : vec4f) -> bool {
let tolerance : f32 = 0.0000001;
return all(abs(pixel - expected) < vec4<f32>(tolerance, tolerance, tolerance, tolerance));
return all(abs(pixel - expected) < vec4f(tolerance, tolerance, tolerance, tolerance));
})";
default:
@ -310,24 +310,24 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
auto texelType = "vec4<" + componentFmt + ">";
std::string sliceCount;
std::string textureStore;
std::string textureSize = "vec2<i32>(textureDimensions(storageImage0).xy)";
std::string textureSize = "vec2i(textureDimensions(storageImage0).xy)";
switch (dimension) {
case wgpu::TextureViewDimension::e1D:
sliceCount = "1";
textureStore = "textureStore(storageImage0, x, expected)";
textureSize = "vec2<i32>(i32(textureDimensions(storageImage0)), 1)";
textureSize = "vec2i(i32(textureDimensions(storageImage0)), 1)";
break;
case wgpu::TextureViewDimension::e2D:
sliceCount = "1";
textureStore = "textureStore(storageImage0, vec2<i32>(x, y), expected)";
textureStore = "textureStore(storageImage0, vec2i(x, y), expected)";
break;
case wgpu::TextureViewDimension::e2DArray:
sliceCount = "i32(textureNumLayers(storageImage0))";
textureStore = "textureStore(storageImage0, vec2<i32>(x, y), slice, expected)";
textureStore = "textureStore(storageImage0, vec2i(x, y), slice, expected)";
break;
case wgpu::TextureViewDimension::e3D:
sliceCount = "i32(textureDimensions(storageImage0).z)";
textureStore = "textureStore(storageImage0, vec3<i32>(x, y, slice), expected)";
textureStore = "textureStore(storageImage0, vec3i(x, y, slice), expected)";
break;
default:
UNREACHABLE();
@ -341,10 +341,10 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
ostream << "@" << stage << workgroupSize << "\n";
ostream << "fn main() ";
if (isFragment) {
ostream << "-> @location(0) vec4<f32> ";
ostream << "-> @location(0) vec4f ";
}
ostream << "{\n";
ostream << " let size : vec2<i32> = " << textureSize << ";\n";
ostream << " let size : vec2i = " << textureSize << ";\n";
ostream << " let sliceCount : i32 = " << sliceCount << ";\n";
ostream << " for (var slice : i32 = 0; slice < sliceCount; slice = slice + 1) {\n";
ostream << " for (var y : i32 = 0; y < size.y; y = y + 1) {\n";
@ -357,7 +357,7 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
ostream << " }\n";
ostream << " }\n";
if (isFragment) {
ostream << "return vec4<f32>();\n";
ostream << "return vec4f();\n";
}
ostream << "}\n";
@ -649,8 +649,8 @@ fn IsEqualTo(pixel : vec4<f32>, expected : vec4<f32>) -> bool {
const char* kSimpleVertexShader = R"(
;
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})";
const char* kComputeExpectedValue = "1 + x + size.x * (y + size.y * slice)";
@ -798,9 +798,9 @@ TEST_P(StorageTextureTests, SampledAndWriteonlyStorageTexturePingPong) {
@group(0) @binding(0) var Src : texture_2d<u32>;
@group(0) @binding(1) var Dst : texture_storage_2d<r32uint, write>;
@compute @workgroup_size(1) fn main() {
var srcValue : vec4<u32> = textureLoad(Src, vec2<i32>(0, 0), 0);
var srcValue : vec4u = textureLoad(Src, vec2i(0, 0), 0);
srcValue.x = srcValue.x + 1u;
textureStore(Dst, vec2<i32>(0, 0), srcValue);
textureStore(Dst, vec2i(0, 0), srcValue);
}
)");
@ -884,8 +884,8 @@ class StorageTextureZeroInitTests : public StorageTextureTests {
fn doTest() -> bool {
for (var y : i32 = 0; y < 4; y = y + 1) {
for (var x : i32 = 0; x < 4; x = x + 1) {
var pixel : vec4<u32> = textureLoad(srcImage, vec2<i32>(x, y));
if (any(pixel != vec4<u32>(0u, 0u, 0u, 1u))) {
var pixel : vec4u = textureLoad(srcImage, vec2i(x, y));
if (any(pixel != vec4u(0u, 0u, 0u, 1u))) {
return false;
}
}
@ -896,15 +896,15 @@ fn doTest() -> bool {
const char* kCommonWriteOnlyZeroInitTestCodeFragment = R"(
@group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>;
@fragment fn main() -> @location(0) vec4<f32> {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
return vec4<f32>();
@fragment fn main() -> @location(0) vec4f {
textureStore(dstImage, vec2i(0, 0), vec4u(1u, 0u, 0u, 1u));
return vec4f();
})";
const char* kCommonWriteOnlyZeroInitTestCodeCompute = R"(
@group(0) @binding(0) var dstImage : texture_storage_2d<r32uint, write>;
@compute @workgroup_size(1) fn main() {
textureStore(dstImage, vec2<i32>(0, 0), vec4<u32>(1u, 0u, 0u, 1u));
textureStore(dstImage, vec2i(0, 0), vec4u(1u, 0u, 0u, 1u));
})";
};

View File

@ -225,17 +225,17 @@ TEST_P(SwapChainValidationTests, ViewDestroyedAfterPresent) {
TEST_P(SwapChainValidationTests, ReturnedViewCharacteristics) {
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
struct FragmentOut {
@location(0) target0 : vec4<f32>,
@location(0) target0 : vec4f,
@location(1) target1 : f32,
}
@fragment fn main() -> FragmentOut {
var out : FragmentOut;
out.target0 = vec4<f32>(0.0, 1.0, 0.0, 1.0);
out.target0 = vec4f(0.0, 1.0, 0.0, 1.0);
out.target1 = 0.5;
return out;
})");

View File

@ -31,16 +31,16 @@ TEST_P(Texture3DTests, Sampling) {
// color attachment with data sampled from 3D texture.
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(1.0, 1.0),
vec2<f32>(1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>(1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( -1.0, -1.0),
vec2f(1.0, 1.0),
vec2f(1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f(1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -48,8 +48,8 @@ TEST_P(Texture3DTests, Sampling) {
@group(0) @binding(1) var tex : texture_3d<f32>;
@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));
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return textureSample(tex, samp, vec3f(FragCoord.xy / 4.0, 1.5 / 4.0));
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;

View File

@ -220,22 +220,22 @@ class TextureCorruptionTests : public DawnTestWithParams<TextureCorruptionTestsP
// Draw the whole texture (a rectangle) via two triangles
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
if (type == WriteType::RenderConstant) {
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return vec4f(1.0, 1.0, 1.0, 1.0);
})");
} else if (type == WriteType::RenderFromTextureSample) {
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@ -243,7 +243,7 @@ class TextureCorruptionTests : public DawnTestWithParams<TextureCorruptionTestsP
@group(0) @binding(1) var tex : texture_2d<f32>;
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return textureSample(tex, samp, FragCoord.xy);
})");
} else {
@ -251,8 +251,8 @@ class TextureCorruptionTests : public DawnTestWithParams<TextureCorruptionTestsP
@group(0) @binding(0) var tex : texture_2d<f32>;
@fragment
fn main(@builtin(position) Fragcoord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(tex, vec2<i32>(Fragcoord.xy), 0);
fn main(@builtin(position) Fragcoord: vec4f) -> @location(0) vec4f {
return textureLoad(tex, vec2i(Fragcoord.xy), 0);
})");
}

View File

@ -221,13 +221,13 @@ class TextureFormatTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 0.0, 2.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-3.0, -1.0),
vec2f( 3.0, -1.0),
vec2f( 0.0, 2.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
// Compute the WGSL type of the texture's data.
@ -239,9 +239,9 @@ class TextureFormatTest : public DawnTest {
fsSource << " @location(0) color : vec4<" << type << ">\n";
fsSource << R"(}
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
fn main(@builtin(position) FragCoord : vec4f) -> FragmentOut {
var output : FragmentOut;
output.color = textureLoad(myTexture, vec2<i32>(FragCoord.xy), 0);
output.color = textureLoad(myTexture, vec2i(FragCoord.xy), 0);
return output;
})";

View File

@ -51,18 +51,18 @@ class TextureSubresourceTest : public DawnTest {
void DrawTriangle(const wgpu::TextureView& view) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, -1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -88,16 +88,16 @@ class TextureSubresourceTest : public DawnTest {
void SampleAndDraw(const wgpu::TextureView& samplerView, const wgpu::TextureView& renderView) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>(-1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -105,8 +105,8 @@ class TextureSubresourceTest : public DawnTest {
@group(0) @binding(1) var tex : texture_2d<f32>;
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> @location(0) vec4<f32> {
return textureSample(tex, samp, FragCoord.xy / vec2<f32>(4.0, 4.0));
fn main(@builtin(position) FragCoord : vec4f) -> @location(0) vec4f {
return textureSample(tex, samp, FragCoord.xy / vec2f(4.0, 4.0));
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -64,28 +64,28 @@ wgpu::Texture Create3DTexture(wgpu::Device device,
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 : vec2f,
@builtin(position) position : vec4f,
}
@vertex
fn main(@builtin(vertex_index) VertexIndex : u32) -> VertexOut {
var output : VertexOut;
var pos = array<vec2<f32>, 6>(
vec2<f32>(-2., -2.),
vec2<f32>(-2., 2.),
vec2<f32>( 2., -2.),
vec2<f32>(-2., 2.),
vec2<f32>( 2., -2.),
vec2<f32>( 2., 2.));
var texCoord = array<vec2<f32>, 6>(
vec2<f32>(0., 0.),
vec2<f32>(0., 1.),
vec2<f32>(1., 0.),
vec2<f32>(0., 1.),
vec2<f32>(1., 0.),
vec2<f32>(1., 1.));
output.position = vec4<f32>(pos[VertexIndex], 0., 1.);
var pos = array(
vec2f(-2., -2.),
vec2f(-2., 2.),
vec2f( 2., -2.),
vec2f(-2., 2.),
vec2f( 2., -2.),
vec2f( 2., 2.));
var texCoord = array(
vec2f(0., 0.),
vec2f(0., 1.),
vec2f(1., 0.),
vec2f(0., 1.),
vec2f(1., 0.),
vec2f(1., 1.));
output.position = vec4f(pos[VertexIndex], 0., 1.);
output.texCoord = texCoord[VertexIndex];
return output;
}
@ -225,7 +225,7 @@ class TextureViewSamplingTest : public DawnTest {
@group(0) @binding(1) var texture0 : texture_2d<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
return textureSample(texture0, sampler0, texCoord);
}
)";
@ -261,7 +261,7 @@ class TextureViewSamplingTest : public DawnTest {
@group(0) @binding(1) var texture0 : texture_2d_array<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
return textureSample(texture0, sampler0, texCoord, 0) +
textureSample(texture0, sampler0, texCoord, 1) +
textureSample(texture0, sampler0, texCoord, 2);
@ -296,10 +296,10 @@ class TextureViewSamplingTest : public DawnTest {
@group(0) @binding(1) var texture0 : )"
<< textureType << R"(<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
var sc : f32 = 2.0 * texCoord.x - 1.0;
var tc : f32 = 2.0 * texCoord.y - 1.0;
return textureSample(texture0, sampler0, vec3<f32>()"
return textureSample(texture0, sampler0, vec3f()"
<< coordToCubeMapFace << ")";
if (isCubeMapArray) {
@ -370,7 +370,7 @@ TEST_P(TextureViewSamplingTest, Default2DArrayTexture) {
@group(0) @binding(1) var texture0 : texture_2d_array<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
return textureSample(texture0, sampler0, texCoord, 0) +
textureSample(texture0, sampler0, texCoord, 1) +
textureSample(texture0, sampler0, texCoord, 2);
@ -410,7 +410,7 @@ TEST_P(TextureViewSamplingTest, Texture2DArrayViewOnSingleLayer2DTexture) {
@group(0) @binding(1) var texture0 : texture_2d_array<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
return textureSample(texture0, sampler0, texCoord, 0);
}
)";
@ -471,23 +471,23 @@ TEST_P(TextureViewSamplingTest, SRGBReinterpretation) {
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, -1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
}
)");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture : texture_2d<f32>;
@fragment
fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(texture, vec2<i32>(coord.xy), 0);
fn main(@builtin(position) coord: vec4f) -> @location(0) vec4f {
return textureLoad(texture, vec2i(coord.xy), 0);
}
)");
@ -603,9 +603,9 @@ class TextureViewRenderingTest : public DawnTest {
renderPassInfo.cColorAttachments[0].clearValue = {1.0f, 0.0f, 0.0f, 1.0f};
const char* oneColorFragmentShader = R"(
@fragment fn main(@location(0) texCoord : vec2<f32>) ->
@location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main(@location(0) texCoord : vec2f) ->
@location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
}
)";
wgpu::ShaderModule oneColorFsModule =
@ -803,23 +803,23 @@ TEST_P(TextureViewRenderingTest, SRGBReinterpretationRenderAttachment) {
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, -1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
}
)");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture : texture_2d<f32>;
@fragment
fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(texture, vec2<i32>(coord.xy), 0);
fn main(@builtin(position) coord: vec4f) -> @location(0) vec4f {
return textureLoad(texture, vec2i(coord.xy), 0);
}
)");
pipelineDesc.cTargets[0].format = viewDesc.format;
@ -917,23 +917,23 @@ TEST_P(TextureViewRenderingTest, SRGBReinterpretionResolveAttachment) {
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, -1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
}
)");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture : texture_2d<f32>;
@fragment
fn main(@builtin(position) coord: vec4<f32>) -> @location(0) vec4<f32> {
return textureLoad(texture, vec2<i32>(coord.xy), 0);
fn main(@builtin(position) coord: vec4f) -> @location(0) vec4f {
return textureLoad(texture, vec2i(coord.xy), 0);
}
)");
pipelineDesc.cTargets[0].format = viewDesc.format;
@ -1067,18 +1067,18 @@ TEST_P(TextureView1DTest, Sampling) {
// Create a pipeline that will sample from the 1D texture and output to an attachment.
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
@vertex
fn vs(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
var pos = array<vec4<f32>, 3>(
vec4<f32>( 0., 2., 0., 1.),
vec4<f32>(-3., -1., 0., 1.),
vec4<f32>( 3., -1., 0., 1.));
fn vs(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec4f( 0., 2., 0., 1.),
vec4f(-3., -1., 0., 1.),
vec4f( 3., -1., 0., 1.));
return pos[VertexIndex];
}
@group(0) @binding(0) var tex : texture_1d<f32>;
@group(0) @binding(1) var samp : sampler;
@fragment
fn fs(@builtin(position) pos: vec4<f32>) -> @location(0) vec4<f32> {
fn fs(@builtin(position) pos: vec4f) -> @location(0) vec4f {
return textureSample(tex, samp, pos.x / 4.0);
}
)");

View File

@ -72,8 +72,8 @@ class TextureZeroInitTest : public DawnTest {
pipelineDescriptor.vertex.module = CreateBasicVertexShaderForTest(depth);
const char* fs = R"(
;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)";
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, fs);
@ -86,16 +86,16 @@ class TextureZeroInitTest : public DawnTest {
wgpu::ShaderModule CreateBasicVertexShaderForTest(float depth = 0.f) {
std::string source = R"(
@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),
vec2<f32>( 1.0, -1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>( 1.0, -1.0)
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, 1.0),
vec2f( 1.0, -1.0)
);
return vec4<f32>(pos[VertexIndex], )" +
return vec4f(pos[VertexIndex], )" +
std::to_string(depth) + R"(, 1.0);
})";
return utils::CreateShaderModule(device, source.c_str());
@ -104,12 +104,12 @@ class TextureZeroInitTest : public DawnTest {
return utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var texture0 : texture_2d<f32>;
struct FragmentOut {
@location(0) color : vec4<f32>
@location(0) color : vec4f
}
@fragment
fn main(@builtin(position) FragCoord : vec4<f32>) -> FragmentOut {
fn main(@builtin(position) FragCoord : vec4f) -> FragmentOut {
var output : FragmentOut;
output.color = textureLoad(texture0, vec2<i32>(FragCoord.xy), 0);
output.color = textureLoad(texture0, vec2i(FragCoord.xy), 0);
return output;
}
)");
@ -1144,11 +1144,11 @@ TEST_P(TextureZeroInitTest, ComputePassSampledTextureClear) {
const char* cs = R"(
@group(0) @binding(0) var tex : texture_2d<f32>;
struct Result {
value : vec4<f32>
value : vec4f
}
@group(0) @binding(1) var<storage, read_write> result : Result;
@compute @workgroup_size(1) fn main() {
result.value = textureLoad(tex, vec2<i32>(0,0), 0);
result.value = textureLoad(tex, vec2i(0,0), 0);
}
)";
computePipelineDescriptor.compute.module = utils::CreateShaderModule(device, cs);

View File

@ -269,18 +269,18 @@ class VertexFormatTest : public DawnTest {
}
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex
fn main(input : VertexIn) -> VertexOut {
var pos = array<vec2<f32>, 3>(
vec2<f32>(-1.0, -1.0),
vec2<f32>( 2.0, 0.0),
vec2<f32>( 0.0, 2.0));
var pos = array(
vec2f(-1.0, -1.0),
vec2f( 2.0, 0.0),
vec2f( 0.0, 2.0));
var output : VertexOut;
output.position = vec4<f32>(pos[input.VertexIndex], 0.0, 1.0);
output.position = vec4f(pos[input.VertexIndex], 0.0, 1.0);
)";
// Declare expected values.
@ -353,9 +353,9 @@ class VertexFormatTest : public DawnTest {
}
vs << R"(
if (success) {
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
output.color = vec4f(0.0, 1.0, 0.0, 1.0);
} else {
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
}
return output;
})";
@ -363,7 +363,7 @@ class VertexFormatTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) color : vec4f) -> @location(0) vec4f {
return color;
})");

View File

@ -103,13 +103,13 @@ class VertexOnlyRenderPipelineTest : public DawnTest {
bool useFragment = true) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex
fn main(@location(0) pos : vec4<f32>) -> @builtin(position) vec4<f32> {
fn main(@location(0) pos : vec4f) -> @builtin(position) vec4f {
return pos;
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -75,10 +75,9 @@ 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 : vec4f;
for (const auto& input : testSpec) {
vs << "@location(" << input.location << ") input" << input.location
<< " : vec4<f32>,\n";
vs << "@location(" << input.location << ") input" << input.location << " : vec4f,\n";
}
vs << R"(
@ -87,8 +86,8 @@ class VertexStateTest : public DawnTest {
}
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex fn main(input : VertexIn) -> VertexOut {
@ -97,14 +96,14 @@ class VertexStateTest : public DawnTest {
// Hard code the triangle in the shader so that we don't have to add a vertex input for it.
// Also this places the triangle in the grid based on its VertexID and InstanceID
vs << " var pos = array<vec2<f32>, 3>(\n"
" vec2<f32>(0.5, 1.0), vec2<f32>(0.0, 0.0), vec2<f32>(1.0, 0.0));\n";
vs << " var offset : vec2<f32> = vec2<f32>(f32(input.VertexIndex / 3u), "
vs << " var pos = array(\n"
" vec2f(0.5, 1.0), vec2f(0.0, 0.0), vec2f(1.0, 0.0));\n";
vs << " var offset : vec2f = vec2f(f32(input.VertexIndex / 3u), "
"f32(input.InstanceIndex));\n";
vs << " var worldPos = pos[input.VertexIndex % 3u] + offset;\n";
vs << " var position = vec4<f32>(0.5 * worldPos - vec2<f32>(1.0, 1.0), 0.0, "
vs << " var position = vec4f(0.5 * worldPos - vec2f(1.0, 1.0), 0.0, "
"1.0);\n";
vs << " output.position = vec4<f32>(position.x, -position.y, position.z, position.w);\n";
vs << " output.position = vec4f(position.x, -position.y, position.z, position.w);\n";
// Perform the checks by successively ANDing a boolean
vs << " var success = true;\n";
@ -130,9 +129,9 @@ class VertexStateTest : public DawnTest {
// Choose the color
vs << R"(
if (success) {
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
output.color = vec4f(0.0, 1.0, 0.0, 1.0);
} else {
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
}
return output;
})";
@ -140,7 +139,7 @@ class VertexStateTest : public DawnTest {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vs.str().c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) color : vec4f) -> @location(0) vec4f {
return color;
}
)");
@ -591,20 +590,20 @@ 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(0) attr0 : vec4f,
@location(1) attr1 : vec2u,
@location(2) attr2 : vec4f,
@location(3) attr3 : f32,
}
struct VertexOut {
@location(0) color : vec4<f32>,
@builtin(position) position : vec4<f32>,
@location(0) color : vec4f,
@builtin(position) position : vec4f,
}
@vertex fn main(input : VertexIn) -> VertexOut {
var output : VertexOut;
output.position = vec4<f32>(0.0, 0.0, 0.0, 1.0);
output.position = vec4f(0.0, 0.0, 0.0, 1.0);
var success : bool = (
input.attr0.x == 1.0 &&
@ -615,15 +614,15 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
input.attr3 == 1.0
);
if (success) {
output.color = vec4<f32>(0.0, 1.0, 0.0, 1.0);
output.color = vec4f(0.0, 1.0, 0.0, 1.0);
} else {
output.color = vec4<f32>(1.0, 0.0, 0.0, 1.0);
output.color = vec4f(1.0, 0.0, 0.0, 1.0);
}
return output;
})");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment
fn main(@location(0) color : vec4<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) color : vec4f) -> @location(0) vec4f {
return color;
})");
pipelineDesc.vertex.bufferCount = vertexState.vertexBufferCount;
@ -659,13 +658,13 @@ TEST_P(OptionalVertexStateTest, Basic) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 3, 3);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -174,22 +174,22 @@ wgpu::ShaderModule VideoViewsTests::GetTestVertexShaderModule() const {
return utils::CreateShaderModule(device, R"(
struct VertexOut {
@location(0) texCoord : vec2 <f32>,
@builtin(position) position : vec4<f32>,
@builtin(position) position : vec4f,
}
@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),
vec2<f32>(1.0, -1.0),
vec2<f32>(-1.0, 1.0),
vec2<f32>(1.0, -1.0),
vec2<f32>(1.0, 1.0)
var pos = array(
vec2f(-1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f(1.0, -1.0),
vec2f(-1.0, 1.0),
vec2f(1.0, -1.0),
vec2f(1.0, 1.0)
);
var output : VertexOut;
output.position = vec4<f32>(pos[VertexIndex], 0.0, 1.0);
output.texCoord = vec2<f32>(output.position.xy * 0.5) + vec2<f32>(0.5, 0.5);
output.position = vec4f(pos[VertexIndex], 0.0, 1.0);
output.texCoord = vec2f(output.position.xy * 0.5) + vec2f(0.5, 0.5);
return output;
})");
}
@ -231,9 +231,9 @@ TEST_P(VideoViewsTests, NV12SampleYtoR) {
@group(0) @binding(1) var texture : texture_2d<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
let y : f32 = textureSample(texture, sampler0, texCoord).r;
return vec4<f32>(y, 0.0, 0.0, 1.0);
return vec4f(y, 0.0, 0.0, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(
@ -290,10 +290,10 @@ TEST_P(VideoViewsTests, NV12SampleUVtoRG) {
@group(0) @binding(1) var texture : texture_2d<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
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);
return vec4f(u, v, 0.0, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(
@ -356,11 +356,11 @@ TEST_P(VideoViewsTests, NV12SampleYUVtoRGB) {
@group(0) @binding(2) var chromaTexture : texture_2d<f32>;
@fragment
fn main(@location(0) texCoord : vec2<f32>) -> @location(0) vec4<f32> {
fn main(@location(0) texCoord : vec2f) -> @location(0) vec4f {
let y : f32 = textureSample(lumaTexture, sampler0, texCoord).r;
let u : f32 = textureSample(chromaTexture, sampler0, texCoord).r;
let v : f32 = textureSample(chromaTexture, sampler0, texCoord).g;
return vec4<f32>(y, u, v, 1.0);
return vec4f(y, u, v, 1.0);
})");
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(

View File

@ -24,13 +24,13 @@ TEST_P(ViewportOrientationTests, OriginAt0x0) {
utils::BasicRenderPass renderPass = utils::CreateBasicRenderPass(device, 2, 2);
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(-0.5, 0.5, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(-0.5, 0.5, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -25,20 +25,20 @@ class ViewportTest : public DawnTest {
mQuadVS = utils::CreateShaderModule(device, R"(
@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),
vec2<f32>( 1.0, 1.0),
vec2<f32>( 1.0, 1.0),
vec2<f32>(-1.0, -1.0),
vec2<f32>( 1.0, -1.0));
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0),
vec2f( 1.0, -1.0));
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
mQuadFS = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 1.0, 1.0, 1.0);
})");
}
@ -94,12 +94,12 @@ class ViewportTest : public DawnTest {
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@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),
vec3<f32>( 0.9, 0.0, 0.0));
return vec4<f32>(points[VertexIndex], 1.0);
fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
var points : array<vec3f, 3> = array(
vec3f(-0.9, 0.0, 1.0),
vec3f( 0.0, 0.0, 0.5),
vec3f( 0.9, 0.0, 0.0));
return vec4f(points[VertexIndex], 1.0);
})");
pipelineDesc.cFragment.module = mQuadFS;
pipelineDesc.cFragment.targetCount = 0;

View File

@ -35,23 +35,23 @@ constexpr float kVertexData[12] = {
constexpr char kVertexShader[] = R"(
@vertex fn main(
@location(0) pos : vec4<f32>
) -> @builtin(position) vec4<f32> {
@location(0) pos : vec4f
) -> @builtin(position) vec4f {
return pos;
})";
constexpr char kFragmentShaderA[] = R"(
@group(0) @binding(0) var<uniform> color : vec3<f32>;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(color * (1.0 / 5000.0), 1.0);
@group(0) @binding(0) var<uniform> color : vec3f;
@fragment fn main() -> @location(0) vec4f {
return vec4f(color * (1.0 / 5000.0), 1.0);
})";
constexpr char kFragmentShaderB[] = R"(
@group(0) @binding(0) var<uniform> constant_color : vec3<f32>;
@group(1) @binding(0) var<uniform> uniform_color : vec3<f32>;
@group(0) @binding(0) var<uniform> constant_color : vec3f;
@group(1) @binding(0) var<uniform> uniform_color : vec3f;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>((constant_color + uniform_color) * (1.0 / 5000.0), 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f((constant_color + uniform_color) * (1.0 / 5000.0), 1.0);
})";
enum class Pipeline {

View File

@ -76,8 +76,8 @@ const std::string& kMatMulFloatSharedArray2D = R"(
var<workgroup> mm_Bsub : array<array<f32, 32>, 32>;)";
const std::string& kMatMulFloatBodyPart1 = R"(
@compute @workgroup_size(8, 8, 1)
fn main(@builtin(local_invocation_id) local_id : vec3<u32>,
@builtin(global_invocation_id) global_id : vec3<u32>) {
fn main(@builtin(local_invocation_id) local_id : vec3u,
@builtin(global_invocation_id) global_id : vec3u) {
let tileRow : u32 = local_id.y * RowPerThread;
let tileCol : u32 = local_id.x * ColPerThread;
@ -195,7 +195,7 @@ const std::string& kMatMulVec4Header = R"(
dimBOuter : u32,
}
struct Matrix {
numbers: array<vec4<f32>>
numbers: array<vec4f>
}
@group(0) @binding(0) var<storage, read> firstMatrix : Matrix;
@ -203,25 +203,25 @@ const std::string& kMatMulVec4Header = R"(
@group(0) @binding(2) var<storage, read_write> resultMatrix : Matrix;
@group(0) @binding(3) var<uniform> uniforms : Uniforms;
fn mm_readA(row : u32, col : u32) -> vec4<f32> {
fn mm_readA(row : u32, col : u32) -> vec4f {
if (row < uniforms.dimAOuter && col < uniforms.dimInner)
{
let result : vec4<f32> = firstMatrix.numbers[row * uniforms.dimInner / 4u + col];
let result : vec4f = firstMatrix.numbers[row * uniforms.dimInner / 4u + col];
return result;
}
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
return vec4f(0.0, 0.0, 0.0, 0.0);
}
fn mm_readB(row : u32, col : u32) -> vec4<f32> {
fn mm_readB(row : u32, col : u32) -> vec4f {
if (row < uniforms.dimInner && col < uniforms.dimBOuter)
{
let result : vec4<f32> = secondMatrix.numbers[row * uniforms.dimBOuter / 4u + col];
let result : vec4f = secondMatrix.numbers[row * uniforms.dimBOuter / 4u + col];
return result;
}
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
return vec4f(0.0, 0.0, 0.0, 0.0);
}
fn mm_write(row : u32, col : u32, value : vec4<f32>) {
fn mm_write(row : u32, col : u32, value : vec4f) {
if (row < uniforms.dimAOuter && col < uniforms.dimBOuter)
{
let index : u32 = col + row * uniforms.dimBOuter / 4u;
@ -234,15 +234,15 @@ const std::string& kMatMulVec4Header = R"(
const TileOuter : u32 = 32u;
const TileInner : u32 = 32u;)";
const std::string& kMatMulVec4SharedArray1D = R"(
var<workgroup> mm_Asub : array<vec4<f32>, 256>;
var<workgroup> mm_Bsub : array<vec4<f32>, 256>;)";
var<workgroup> mm_Asub : array<vec4f, 256>;
var<workgroup> mm_Bsub : array<vec4f, 256>;)";
const std::string& kMatMulVec4SharedArray2D = R"(
var<workgroup> mm_Asub : array<array<vec4<f32>, 8>, 32>;
var<workgroup> mm_Bsub : array<array<vec4<f32>, 8>, 32>;)";
var<workgroup> mm_Asub : array<array<vec4f, 8>, 32>;
var<workgroup> mm_Bsub : array<array<vec4f, 8>, 32>;)";
const std::string& kMatMulVec4BodyPart1 = R"(
@compute @workgroup_size(8, 8, 1)
fn main(@builtin(local_invocation_id) local_id : vec3<u32>,
@builtin(global_invocation_id) global_id : vec3<u32>) {
fn main(@builtin(local_invocation_id) local_id : vec3u,
@builtin(global_invocation_id) global_id : vec3u) {
let tileRow : u32 = local_id.y * RowPerThread;
let tileCol : u32 = local_id.x;
@ -251,15 +251,15 @@ const std::string& kMatMulVec4BodyPart1 = R"(
let numTiles : u32 = (uniforms.dimInner - 1u) / TileInner + 1u;
var acc: array<vec4<f32>, 4>;
var ACached : vec4<f32>;
var BCached : array<vec4<f32>, 4>;
var acc: array<vec4f, 4>;
var ACached : vec4f;
var BCached : array<vec4f, 4>;
// Without this initialization strange values show up in acc.
// TODO: Remove it once the following bug is fixed.
// https://bugs.chromium.org/p/tint/issues/detail?id=759
for (var index : u32 = 0u; index < RowPerThread; index = index + 1u) {
acc[index] = vec4<f32>(0.0, 0.0, 0.0, 0.0);
acc[index] = vec4f(0.0, 0.0, 0.0, 0.0);
}
var globalColA : u32 = tileCol;

View File

@ -68,15 +68,15 @@ class SubresourceTrackingPerf : public DawnPerfTestWithParams<SubresourceTrackin
utils::ComboRenderPipelineDescriptor pipelineDesc;
pipelineDesc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)");
pipelineDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var materials : texture_2d<f32>;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
_ = materials;
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)");
mPipeline = device.CreateRenderPipeline(&pipelineDesc);

View File

@ -73,8 +73,8 @@ class DestroyObjectTests : public Test {
}
DAWN_TRY_ASSIGN_WITH_CLEANUP(
mVsModule, ShaderModuleMock::Create(&mDevice, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})"),
{ ASSERT(false); }, mVsModule);
EXPECT_CALL(*mVsModule.Get(), DestroyImpl).Times(1);
@ -759,8 +759,8 @@ static constexpr std::string_view kComputeShader = R"(
)";
static constexpr std::string_view kVertexShader = R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
}
)";

View File

@ -1706,13 +1706,13 @@ class SetBindGroupValidationTest : public ValidationTest {
wgpu::RenderPipeline CreateRenderPipeline() {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S {
value : vec2<f32>
value : vec2f
}
@group(0) @binding(0) var<uniform> uBufferDynamic : S;
@ -1736,7 +1736,7 @@ class SetBindGroupValidationTest : public ValidationTest {
wgpu::ComputePipeline CreateComputePipeline() {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct S {
value : vec2<f32>
value : vec2f
}
@group(0) @binding(0) var<uniform> uBufferDynamic : S;
@ -2164,8 +2164,8 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
ValidationTest::SetUp();
mVsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
mBufferSize = 3 * GetSupportedLimits().limits.minUniformBufferOffsetAlignment + 8;
@ -2212,7 +2212,7 @@ class SetBindGroupPersistenceValidationTest : public ValidationTest {
device.CreatePipelineLayout(&pipelineLayoutDescriptor);
std::stringstream ss;
ss << "struct S { value : vec2<f32> }";
ss << "struct S { value : vec2f }";
// Build a shader which has bindings that match the pipeline layout.
for (uint32_t l = 0; l < layouts.size(); ++l) {
@ -2366,8 +2366,8 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
const char* fsShader,
std::vector<wgpu::BindGroupLayout> bindGroupLayout) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fsShader);
@ -2387,14 +2387,14 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
wgpu::RenderPipeline CreateRenderPipeline(std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
return CreateFSRenderPipeline(R"(
struct S {
value : vec2<f32>
value : vec2f
}
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
@fragment fn main() {
var val : vec2<f32> = sBufferDynamic.value;
var val : vec2f = sBufferDynamic.value;
val = sReadonlyBufferDynamic.value;
})",
std::move(bindGroupLayouts));
@ -2422,14 +2422,14 @@ class BindGroupLayoutCompatibilityTest : public ValidationTest {
std::vector<wgpu::BindGroupLayout> bindGroupLayouts) {
return CreateComputePipeline(R"(
struct S {
value : vec2<f32>
value : vec2f
}
@group(0) @binding(0) var<storage, read_write> sBufferDynamic : S;
@group(1) @binding(0) var<storage, read> sReadonlyBufferDynamic : S;
@compute @workgroup_size(4, 4, 1) fn main() {
var val : vec2<f32> = sBufferDynamic.value;
var val : vec2f = sBufferDynamic.value;
val = sReadonlyBufferDynamic.value;
})",
std::move(bindGroupLayouts));
@ -2771,8 +2771,8 @@ class SamplerTypeBindingTest : public ValidationTest {
wgpu::RenderPipeline CreateFragmentPipeline(wgpu::BindGroupLayout* bindGroupLayout,
const char* fragmentSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, fragmentSource);
@ -2873,7 +2873,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
textureSample(myTexture, mySampler, vec2f(0.0, 0.0));
})");
}
@ -2887,7 +2887,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
textureSample(myTexture, mySampler, vec2f(0.0, 0.0));
})");
}
@ -2901,7 +2901,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_depth_2d;
@fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
textureSample(myTexture, mySampler, vec2f(0.0, 0.0));
})");
}
@ -2915,7 +2915,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_depth_2d;
@fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
textureSample(myTexture, mySampler, vec2f(0.0, 0.0));
})");
}
@ -2929,7 +2929,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
@group(0) @binding(0) var mySampler: sampler_comparison;
@group(0) @binding(1) var myTexture: texture_depth_2d;
@fragment fn main() {
textureSampleCompare(myTexture, mySampler, vec2<f32>(0.0, 0.0), 0.0);
textureSampleCompare(myTexture, mySampler, vec2f(0.0, 0.0), 0.0);
})");
}
@ -2943,7 +2943,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
textureSample(myTexture, mySampler, vec2f(0.0, 0.0));
})"));
}
@ -2957,7 +2957,7 @@ TEST_F(SamplerTypeBindingTest, ShaderAndBGLMatches) {
@group(0) @binding(0) var mySampler: sampler;
@group(0) @binding(1) var myTexture: texture_2d<f32>;
@fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>(0.0, 0.0));
textureSample(myTexture, mySampler, vec2f(0.0, 0.0));
})");
}
}

View File

@ -24,13 +24,13 @@ class DrawIndirectValidationTest : public ValidationTest {
ValidationTest::SetUp();
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32>{
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@fragment fn main() -> @location(0) vec4f{
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
// Set up render pipeline

View File

@ -83,8 +83,8 @@ class DrawVertexAndIndexBufferOOBValidationTests : public ValidationTest {
renderPass = utils::CreateBasicRenderPass(device, kRTSize, kRTSize);
fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
}
@ -109,7 +109,7 @@ class DrawVertexAndIndexBufferOOBValidationTests : public ValidationTest {
for (auto attr : buffer.attributes) {
// @location({shaderLocation}) var_{id} : {typeString},
inputStringStream << "@location(" << attr.shaderLocation << ") var_"
<< attributeCount << " : vec4<f32>,";
<< attributeCount << " : vec4f,";
attributeCount++;
}
}
@ -119,8 +119,8 @@ class DrawVertexAndIndexBufferOOBValidationTests : public ValidationTest {
shaderStringStream << R"(
@vertex
fn main()" << inputStringStream.str()
<< R"() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
<< R"() -> @builtin(position) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})";
return utils::CreateShaderModule(device, shaderStringStream.str().c_str());

View File

@ -21,8 +21,8 @@ class GetBindGroupLayoutTests : public ValidationTest {
protected:
wgpu::RenderPipeline RenderPipelineFromFragmentShader(const char* shader) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, shader);
@ -47,20 +47,20 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S;
@vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniform0.pos;
@vertex fn main() -> @builtin(position) vec4f {
var pos : vec4f = uniform0.pos;
pos = uniform1.pos;
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S2 {
pos : vec4<f32>
pos : vec4f
}
@group(2) @binding(0) var<uniform> uniform2 : S2;
@ -70,7 +70,7 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
@group(3) @binding(0) var<storage, read_write> storage3 : S3;
@fragment fn main() {
var pos_u : vec4<f32> = uniform2.pos;
var pos_u : vec4f = uniform2.pos;
var pos_s : mat4x4<f32> = storage3.pos;
})");
@ -99,12 +99,12 @@ TEST_F(GetBindGroupLayoutTests, SameObject) {
TEST_F(GetBindGroupLayoutTests, DefaultBindGroupLayoutPipelineCompatibility) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniforms : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
ASSERT_DEVICE_ERROR(utils::MakePipelineLayout(device, {pipeline.GetBindGroupLayout(0)}));
@ -121,12 +121,12 @@ TEST_F(GetBindGroupLayoutTests, DefaultShaderStageAndDynamicOffsets) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniforms : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
wgpu::BindGroupLayoutEntry binding = {};
@ -178,27 +178,27 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
wgpu::ShaderModule emptyVertexModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@vertex fn main() -> @builtin(position) vec4<f32> {
@vertex fn main() -> @builtin(position) vec4f {
_ = myTexture;
_ = mySampler;
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule textureLoadVertexModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@vertex fn main() -> @builtin(position) vec4<f32> {
textureLoad(myTexture, vec2<i32>(), 0);
@vertex fn main() -> @builtin(position) vec4f {
textureLoad(myTexture, vec2i(), 0);
_ = mySampler;
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule textureSampleVertexModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@vertex fn main() -> @builtin(position) vec4<f32> {
textureSampleLevel(myTexture, mySampler, vec2<f32>(), 0.0);
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
textureSampleLevel(myTexture, mySampler, vec2f(), 0.0);
return vec4f();
})");
wgpu::ShaderModule unusedTextureFragmentModule = utils::CreateShaderModule(device, R"(
@ -213,7 +213,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@fragment fn main() {
textureLoad(myTexture, vec2<i32>(), 0);
textureLoad(myTexture, vec2i(), 0);
_ = mySampler;
})");
@ -221,7 +221,7 @@ TEST_F(GetBindGroupLayoutTests, DefaultTextureSampleType) {
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@group(0) @binding(1) var mySampler : sampler;
@fragment fn main() {
textureSample(myTexture, mySampler, vec2<f32>());
textureSample(myTexture, mySampler, vec2f());
})");
auto BGLFromModules = [this](wgpu::ShaderModule vertexModule,
@ -291,12 +291,12 @@ TEST_F(GetBindGroupLayoutTests, ComputePipeline) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniforms : S;
@compute @workgroup_size(1) fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
wgpu::ComputePipelineDescriptor descriptor;
@ -344,12 +344,12 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
binding.buffer.type = wgpu::BufferBindingType::Storage;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<storage, read_write> ssbo : S;
@fragment fn main() {
var pos : vec4<f32> = ssbo.pos;
var pos : vec4f = ssbo.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get()));
@ -358,12 +358,12 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
binding.buffer.type = wgpu::BufferBindingType::Uniform;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniforms : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get()));
@ -373,12 +373,12 @@ TEST_F(GetBindGroupLayoutTests, BindingType) {
binding.buffer.type = wgpu::BufferBindingType::ReadOnlyStorage;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<storage, read> ssbo : S;
@fragment fn main() {
var pos : vec4<f32> = ssbo.pos;
var pos : vec4f = ssbo.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get()));
@ -613,12 +613,12 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
binding.binding = 0;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniforms : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get()));
@ -628,12 +628,12 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
binding.binding = 1;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(1) var<uniform> uniforms : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
EXPECT_TRUE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get()));
@ -643,12 +643,12 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
binding.binding = 2;
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(1) var<uniform> uniforms : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
EXPECT_FALSE(dawn::native::BindGroupLayoutBindingsEqualForTesting(
device.CreateBindGroupLayout(&desc).Get(), pipeline.GetBindGroupLayout(0).Get()));
@ -659,25 +659,25 @@ TEST_F(GetBindGroupLayoutTests, BindingIndices) {
TEST_F(GetBindGroupLayoutTests, DuplicateBinding) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniform0 : S;
@group(1) @binding(0) var<uniform> uniform1 : S;
@vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniform0.pos;
@vertex fn main() -> @builtin(position) vec4f {
var pos : vec4f = uniform0.pos;
pos = uniform1.pos;
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(1) @binding(0) var<uniform> uniforms : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms.pos;
var pos : vec4f = uniforms.pos;
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -702,9 +702,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
}
@group(0) @binding(0) var<uniform> uniforms : S;
@vertex fn main() -> @builtin(position) vec4<f32> {
@vertex fn main() -> @builtin(position) vec4f {
var pos : f32 = uniforms.pos;
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule vsModule64 = utils::CreateShaderModule(device, R"(
@ -713,9 +713,9 @@ TEST_F(GetBindGroupLayoutTests, MinBufferSize) {
}
@group(0) @binding(0) var<uniform> uniforms : S;
@vertex fn main() -> @builtin(position) vec4<f32> {
@vertex fn main() -> @builtin(position) vec4f {
var pos : mat4x4<f32> = uniforms.pos;
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule fsModule4 = utils::CreateShaderModule(device, R"(
@ -793,15 +793,15 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule vsModuleNoSampler = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule vsModuleSampler = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var mySampler: sampler;
@vertex fn main() -> @builtin(position) vec4<f32> {
@vertex fn main() -> @builtin(position) vec4f {
_ = mySampler;
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule fsModuleNoSampler = utils::CreateShaderModule(device, R"(
@ -865,23 +865,23 @@ TEST_F(GetBindGroupLayoutTests, StageAggregation) {
TEST_F(GetBindGroupLayoutTests, ConflictingBindingType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> ubo : S;
@vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = ubo.pos;
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
var pos : vec4f = ubo.pos;
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<storage, read_write> ssbo : S;
@fragment fn main() {
var pos : vec4<f32> = ssbo.pos;
var pos : vec4f = ssbo.pos;
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -897,9 +897,9 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureMultisampling) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@vertex fn main() -> @builtin(position) vec4<f32> {
@vertex fn main() -> @builtin(position) vec4f {
textureDimensions(myTexture);
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -922,9 +922,9 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingViewDimension) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@vertex fn main() -> @builtin(position) vec4<f32> {
@vertex fn main() -> @builtin(position) vec4f {
textureDimensions(myTexture);
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -947,9 +947,9 @@ TEST_F(GetBindGroupLayoutTests, ConflictingBindingTextureComponentType) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var myTexture : texture_2d<f32>;
@vertex fn main() -> @builtin(position) vec4<f32> {
@vertex fn main() -> @builtin(position) vec4f {
textureDimensions(myTexture);
return vec4<f32>();
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -990,13 +990,13 @@ TEST_F(GetBindGroupLayoutTests, UnusedIndex) {
wgpu::RenderPipeline pipeline = RenderPipelineFromFragmentShader(R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniforms0 : S;
@group(2) @binding(0) var<uniform> uniforms2 : S;
@fragment fn main() {
var pos : vec4<f32> = uniforms0.pos;
var pos : vec4f = uniforms0.pos;
pos = uniforms2.pos;
})");
@ -1042,13 +1042,13 @@ TEST_F(GetBindGroupLayoutTests, Reflection) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
struct S {
pos : vec4<f32>
pos : vec4f
}
@group(0) @binding(0) var<uniform> uniforms : S;
@vertex fn main() -> @builtin(position) vec4<f32> {
var pos : vec4<f32> = uniforms.pos;
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
var pos : vec4f = uniforms.pos;
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(

View File

@ -23,13 +23,13 @@ class IndexBufferValidationTest : public ValidationTest {
wgpu::RenderPipeline MakeTestPipeline(wgpu::IndexFormat format,
wgpu::PrimitiveTopology primitiveTopology) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -534,13 +534,13 @@ TEST_F(LabelTest, RenderPipeline) {
std::string label = "test";
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -126,9 +126,9 @@ std::string CreateComputeShaderWithBindings(const std::vector<BindingDescriptor>
// Creates a vertex shader with given bindings
std::string CreateVertexShaderWithBindings(const std::vector<BindingDescriptor>& bindings) {
return kStructs + GenerateBindingString(bindings) +
"@vertex fn main() -> @builtin(position) vec4<f32> {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Vertex) +
"\n return vec4<f32>(); " + "}";
"@vertex fn main() -> @builtin(position) vec4f {\n" +
GenerateReferenceString(bindings, wgpu::ShaderStage::Vertex) + "\n return vec4f(); " +
"}";
}
// Creates a fragment shader with given bindings
@ -581,7 +581,7 @@ TEST_F(MinBufferSizeDefaultLayoutTests, RenderPassConsidersBothStages) {
std::string vertexShader = CreateVertexShaderWithBindings(
{{0, 0, "a : f32, b : f32,", "f32", "a", 8, wgpu::BufferBindingType::Uniform,
wgpu::ShaderStage::Vertex},
{0, 1, "c : vec4<f32>,", "vec4<f32>", "c", 16, wgpu::BufferBindingType::Uniform,
{0, 1, "c : vec4f,", "vec4f", "c", 16, wgpu::BufferBindingType::Uniform,
wgpu::ShaderStage::Vertex}});
std::string fragShader = CreateFragmentShaderWithBindings(
{{0, 0, "a : f32,", "f32", "a", 4, wgpu::BufferBindingType::Uniform,
@ -600,7 +600,7 @@ TEST_F(MinBufferSizePipelineCreationTests, NonStructVec3) {
auto MakeShader = [](const char* stageAttributes) {
std::ostringstream ostream;
ostream << "@group(0) @binding(0) var<storage, read_write> buffer : vec3<u32>;\n";
ostream << "@group(0) @binding(0) var<storage, read_write> buffer : vec3u;\n";
ostream << stageAttributes << " fn main() { buffer = vec3(42, 0, 7); }\n";
return ostream.str();
};

View File

@ -33,8 +33,8 @@ class RenderPipelineAndPassCompatibilityTests : public ValidationTest {
// Create a NoOp pipeline
utils::ComboRenderPipelineDescriptor pipelineDescriptor;
pipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() {

View File

@ -175,13 +175,13 @@ TEST_F(QueueSubmitValidationTest, SubmitInCreateRenderPipelineAsyncCallback) {
};
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;

View File

@ -36,13 +36,13 @@ class RenderBundleValidationTest : public ValidationTest {
}
@group(0) @binding(0) var<uniform> uniforms : S;
@vertex fn main(@location(0) pos : vec2<f32>) -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main(@location(0) pos : vec2f) -> @builtin(position) vec4f {
return vec4f();
})");
fsModule = utils::CreateShaderModule(device, R"(
struct Uniforms {
color : vec4<f32>
color : vec4f
}
@group(1) @binding(0) var<uniform> uniforms : Uniforms;

View File

@ -553,13 +553,13 @@ TEST_F(RenderPassDescriptorValidationTest, MaxDrawCount) {
constexpr uint64_t kMaxDrawCount = 16;
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
utils::ComboRenderPipelineDescriptor pipelineDescriptor;

View File

@ -49,18 +49,18 @@ class RenderPipelineValidationTest : public ValidationTest {
ValidationTest::SetUp();
vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
fsModuleUint = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<u32> {
return vec4<u32>(0u, 255u, 0u, 255u);
@fragment fn main() -> @location(0) vec4u {
return vec4u(0u, 255u, 0u, 255u);
})");
}
@ -198,13 +198,13 @@ TEST_F(RenderPipelineValidationTest, DepthAttachmentRequiredWhenFragDepthIsWritt
wgpu::ShaderModule fsModuleFragDepthOutput = utils::CreateShaderModule(device, R"(
struct Output {
@builtin(frag_depth) depth_out: f32,
@location(0) color : vec4<f32>,
@location(0) color : vec4f,
}
@fragment fn main() -> Output {
var o: Output;
// We need to make sure this frag_depth isn't optimized out even its value equals "no op".
o.depth_out = 0.5;
o.color = vec4<f32>(1.0, 1.0, 1.0, 1.0);
o.color = vec4f(1.0, 1.0, 1.0, 1.0);
return o;
}
)");
@ -475,18 +475,18 @@ TEST_F(RenderPipelineValidationTest, FragmentOutputComponentCountCompatibility)
})";
break;
case 2:
stream << R"(vec2<f32> {
return vec2<f32>(1.0, 1.0);
stream << R"(vec2f {
return vec2f(1.0, 1.0);
})";
break;
case 3:
stream << R"(vec3<f32> {
return vec3<f32>(1.0, 1.0, 1.0);
stream << R"(vec3f {
return vec3f(1.0, 1.0, 1.0);
})";
break;
case 4:
stream << R"(vec4<f32> {
return vec4<f32>(1.0, 1.0, 1.0, 1.0);
stream << R"(vec4f {
return vec4f(1.0, 1.0, 1.0, 1.0);
})";
break;
default:
@ -864,13 +864,13 @@ TEST_F(RenderPipelineValidationTest, AlphaToCoverageAndSampleMaskOutput) {
wgpu::ShaderModule fsModuleSampleMaskOutput = utils::CreateShaderModule(device, R"(
struct Output {
@builtin(sample_mask) mask_out: u32,
@location(0) color : vec4<f32>,
@location(0) color : vec4f,
}
@fragment fn main() -> Output {
var o: Output;
// We need to make sure this sample_mask isn't optimized out even its value equals "no op".
o.mask_out = 0xFFFFFFFFu;
o.color = vec4<f32>(1.0, 1.0, 1.0, 1.0);
o.color = vec4f(1.0, 1.0, 1.0, 1.0);
return o;
}
)");
@ -1005,9 +1005,9 @@ TEST_F(RenderPipelineValidationTest, StorageBufferInVertexShaderNoLayout) {
data : array<u32, 100>
}
@group(0) @binding(0) var<storage, read_write> dst : Dst;
@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4<f32> {
@vertex fn main(@builtin(vertex_index) VertexIndex : u32) -> @builtin(position) vec4f {
dst.data[VertexIndex] = 0x1234u;
return vec4<f32>();
return vec4f();
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -1132,12 +1132,12 @@ 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"(
@vertex fn vertex_main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn vertex_main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
}
@fragment fn fragment_main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn fragment_main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)");
@ -1178,12 +1178,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"(
@vertex fn vertex0(@location(0) attrib0 : vec4<f32>)
-> @builtin(position) vec4<f32> {
@vertex fn vertex0(@location(0) attrib0 : vec4f)
-> @builtin(position) vec4f {
return attrib0;
}
@vertex fn vertex1(@location(1) attrib1 : vec4<f32>)
-> @builtin(position) vec4<f32> {
@vertex fn vertex1(@location(1) attrib1 : vec4f)
-> @builtin(position) vec4f {
return attrib1;
}
)");
@ -1220,11 +1220,11 @@ 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"(
@fragment fn fragmentFloat() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@fragment fn fragmentFloat() -> @location(0) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
}
@fragment fn fragmentUint() -> @location(0) vec4<u32> {
return vec4<u32>(0u, 0u, 0u, 0u);
@fragment fn fragmentUint() -> @location(0) vec4u {
return vec4u(0u, 0u, 0u, 0u);
}
)");
@ -1254,8 +1254,8 @@ 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"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
}
)");
@ -1264,21 +1264,21 @@ TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
)");
wgpu::ShaderModule fsModuleWrite0 = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>();
@fragment fn main() -> @location(0) vec4f {
return vec4f();
}
)");
wgpu::ShaderModule fsModuleWrite1 = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(1) vec4<f32> {
return vec4<f32>();
@fragment fn main() -> @location(1) vec4f {
return vec4f();
}
)");
wgpu::ShaderModule fsModuleWriteBoth = utils::CreateShaderModule(device, R"(
struct FragmentOut {
@location(0) target0 : vec4<f32>,
@location(1) target1 : vec4<f32>,
@location(0) target0 : vec4f,
@location(1) target1 : vec4f,
}
@fragment fn main() -> FragmentOut {
var out : FragmentOut;
@ -1387,15 +1387,15 @@ TEST_F(RenderPipelineValidationTest, UnwrittenFragmentOutputsMask0) {
TEST_F(RenderPipelineValidationTest, BindingsFromCorrectEntryPoint) {
wgpu::ShaderModule module = utils::CreateShaderModule(device, R"(
struct Uniforms {
data : vec4<f32>
data : vec4f
}
@group(0) @binding(0) var<uniform> var0 : Uniforms;
@group(0) @binding(1) var<uniform> var1 : Uniforms;
@vertex fn vertex0() -> @builtin(position) vec4<f32> {
@vertex fn vertex0() -> @builtin(position) vec4f {
return var0.data;
}
@vertex fn vertex1() -> @builtin(position) vec4<f32> {
@vertex fn vertex1() -> @builtin(position) vec4f {
return var1.data;
}
)");
@ -1437,7 +1437,7 @@ TEST_P(DeprecationTests, RenderPipelineColorAttachmentBytesPerSample) {
// Creates a fragment shader with maximum number of color attachments to enable testing.
auto CreateShader = [&](const std::vector<wgpu::TextureFormat>& formats) -> wgpu::ShaderModule {
// Default type to use when formats.size() < kMaxColorAttachments.
static constexpr std::string_view kDefaultWgslType = "vec4<f32>";
static constexpr std::string_view kDefaultWgslType = "vec4f";
std::ostringstream bindings;
std::ostringstream outputs;
@ -1512,8 +1512,8 @@ TEST_P(DeprecationTests, RenderPipelineColorAttachmentBytesPerSample) {
for (const TestCase& testCase : kTestCases) {
utils::ComboRenderPipelineDescriptor descriptor;
descriptor.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
descriptor.cFragment.module = CreateShader(testCase.formats);
descriptor.cFragment.targetCount = testCase.formats.size();
@ -1583,35 +1583,35 @@ TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocatio
wgpu::ShaderModule vertexModuleOutputAtLocation0 = utils::CreateShaderModule(device, R"(
struct A {
@location(0) vout: f32,
@builtin(position) pos: vec4<f32>,
@builtin(position) pos: vec4f,
}
@vertex fn main() -> A {
var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
vertexOut.pos = vec4f(0.0, 0.0, 0.0, 1.0);
return vertexOut;
})");
wgpu::ShaderModule fragmentModuleAtLocation0 = utils::CreateShaderModule(device, R"(
struct B {
@location(0) fin: f32
}
@fragment fn main(fragmentIn: B) -> @location(0) vec4<f32> {
return vec4<f32>(fragmentIn.fin, 0.0, 0.0, 1.0);
@fragment fn main(fragmentIn: B) -> @location(0) vec4f {
return vec4f(fragmentIn.fin, 0.0, 0.0, 1.0);
})");
wgpu::ShaderModule fragmentModuleInputAtLocation1 = utils::CreateShaderModule(device, R"(
struct A {
@location(1) vout: f32
}
@fragment fn main(vertexOut: A) -> @location(0) vec4<f32> {
return vec4<f32>(vertexOut.vout, 0.0, 0.0, 1.0);
@fragment fn main(vertexOut: A) -> @location(0) vec4f {
return vec4f(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>,
@builtin(position) pos: vec4f,
}
@vertex fn main() -> B {
var fragmentIn: B;
fragmentIn.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
fragmentIn.pos = vec4f(0.0, 0.0, 0.0, 1.0);
return fragmentIn;
})");
@ -1637,10 +1637,9 @@ TEST_F(InterStageVariableMatchingValidationTest, MissingDeclarationAtSameLocatio
// Tests that creating render pipeline should fail when the type of a vertex stage output variable
// doesn't match the type of the fragment stage input variable at the same location.
TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
constexpr std::array<const char*, 16> kTypes = {{"f32", "vec2<f32>", "vec3<f32>", "vec4<f32>",
"f16", "vec2<f16>", "vec3<f16>", "vec4<f16>",
"i32", "vec2<i32>", "vec3<i32>", "vec4<i32>",
"u32", "vec2<u32>", "vec3<u32>", "vec4<u32>"}};
constexpr std::array<const char*, 16> kTypes = {
{"f32", "vec2f", "vec3f", "vec4f", "f16", "vec2<f16>", "vec3<f16>", "vec4<f16>", "i32",
"vec2i", "vec3i", "vec4i", "u32", "vec2u", "vec3u", "vec4u"}};
std::array<wgpu::ShaderModule, 16> vertexModules;
std::array<wgpu::ShaderModule, 16> fragmentModules;
@ -1658,11 +1657,11 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
{
std::ostringstream vertexStream;
vertexStream << extensionDeclaration << interfaceDeclaration << R"(
@builtin(position) pos: vec4<f32>,
@builtin(position) pos: vec4f,
}
@vertex fn main() -> A {
var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
vertexOut.pos = vec4f(0.0, 0.0, 0.0, 1.0);
return vertexOut;
})";
vertexModules[i] = utils::CreateShaderModule(device, vertexStream.str().c_str());
@ -1671,8 +1670,8 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentTypeAtSameLocation) {
std::ostringstream fragmentStream;
fragmentStream << extensionDeclaration << interfaceDeclaration << R"(
}
@fragment fn main(fragmentIn: A) -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@fragment fn main(fragmentIn: A) -> @location(0) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})";
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());
}
@ -1750,17 +1749,17 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
}
sstream << ")";
}
sstream << " a : vec4<f32>," << std::endl;
sstream << " a : vec4f," << std::endl;
interfaceDeclaration = sstream.str();
}
{
std::ostringstream vertexStream;
vertexStream << interfaceDeclaration << R"(
@builtin(position) pos: vec4<f32>,
@builtin(position) pos: vec4f,
}
@vertex fn main() -> A {
var vertexOut: A;
vertexOut.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
vertexOut.pos = vec4f(0.0, 0.0, 0.0, 1.0);
return vertexOut;
})";
vertexModules[i] = utils::CreateShaderModule(device, vertexStream.str().c_str());
@ -1769,7 +1768,7 @@ TEST_F(InterStageVariableMatchingValidationTest, DifferentInterpolationAttribute
std::ostringstream fragmentStream;
fragmentStream << interfaceDeclaration << R"(
}
@fragment fn main(fragmentIn: A) -> @location(0) vec4<f32> {
@fragment fn main(fragmentIn: A) -> @location(0) vec4f {
return fragmentIn.a;
})";
fragmentModules[i] = utils::CreateShaderModule(device, fragmentStream.str().c_str());

View File

@ -50,8 +50,8 @@ class ResourceUsageTrackingTest : public ValidationTest {
// 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"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -749,8 +749,8 @@ TEST_F(ResourceUsageTrackingTest, BufferUsageConflictWithUnusedPipelineBindings)
// Create a passthrough render pipeline with a readonly buffer
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@ -1567,8 +1567,8 @@ TEST_F(ResourceUsageTrackingTest, TextureUsageConflictWithUnusedPipelineBindings
{
// Create a passthrough render pipeline with a sampled storage texture
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>();
@vertex fn main() -> @builtin(position) vec4f {
return vec4f();
})");
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(

View File

@ -153,8 +153,8 @@ TEST_F(ShaderModuleValidationTest, GetCompilationMessages) {
DAWN_SKIP_TEST_IF(UsesWire());
wgpu::ShaderModule shaderModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
dawn::native::ShaderModuleBase* shaderModuleBase = dawn::native::FromAPI(shaderModule.Get());
@ -215,7 +215,7 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
}
if (failingShaderStage == wgpu::ShaderStage::Vertex) {
stream << " @builtin(position) pos: vec4<f32>,";
stream << " @builtin(position) pos: vec4f,";
}
stream << "}\n";
@ -235,14 +235,14 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
pDesc.vertex.module = utils::CreateShaderModule(device, (ioStruct + R"(
@vertex fn failingVertex() -> ShaderIO {
var shaderIO : ShaderIO;
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
shaderIO.pos = vec4f(0.0, 0.0, 0.0, 1.0);
return shaderIO;
}
)")
.c_str());
pDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0);
}
)");
break;
@ -252,14 +252,14 @@ TEST_F(ShaderModuleValidationTest, MaximumShaderIOLocations) {
errorMatcher = "failingFragment";
pDesc.cFragment.entryPoint = "failingFragment";
pDesc.cFragment.module = utils::CreateShaderModule(device, (ioStruct + R"(
@fragment fn failingFragment(io : ShaderIO) -> @location(0) vec4<f32> {
return vec4<f32>(0.0);
@fragment fn failingFragment(io : ShaderIO) -> @location(0) vec4f {
return vec4f(0.0);
}
)")
.c_str());
pDesc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0);
}
)");
break;
@ -316,8 +316,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
uint32_t vec4InputLocations = totalUserDefinedInterStageShaderComponentCount / 4;
for (uint32_t location = 0; location < vec4InputLocations; ++location) {
stream << "@location(" << location << ") var" << location << ": vec4<f32>,"
<< std::endl;
stream << "@location(" << location << ") var" << location << ": vec4f," << std::endl;
}
uint32_t lastComponentCount = totalUserDefinedInterStageShaderComponentCount % 4;
@ -332,7 +331,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
}
if (failingShaderStage == wgpu::ShaderStage::Vertex) {
stream << " @builtin(position) pos: vec4<f32>,";
stream << " @builtin(position) pos: vec4f,";
}
stream << "}\n";
@ -361,14 +360,14 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
pDesc.vertex.module = utils::CreateShaderModule(device, (ioStruct + R"(
@vertex fn failingVertex() -> ShaderIO {
var shaderIO : ShaderIO;
shaderIO.pos = vec4<f32>(0.0, 0.0, 0.0, 1.0);
shaderIO.pos = vec4f(0.0, 0.0, 0.0, 1.0);
return shaderIO;
}
)")
.c_str());
pDesc.cFragment.module = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0);
}
)");
break;
@ -378,14 +377,14 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
errorMatcher = "failingFragment";
pDesc.cFragment.entryPoint = "failingFragment";
pDesc.cFragment.module = utils::CreateShaderModule(device, (ioStruct + R"(
@fragment fn failingFragment(io : ShaderIO) -> @location(0) vec4<f32> {
return vec4<f32>(0.0);
@fragment fn failingFragment(io : ShaderIO) -> @location(0) vec4f {
return vec4f(0.0);
}
)")
.c_str());
pDesc.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0);
}
)");
break;
@ -438,7 +437,7 @@ TEST_F(ShaderModuleValidationTest, MaximumInterStageShaderComponents) {
// component count.
{
CheckTestPipeline(true, kMaxInterStageShaderComponents, wgpu::ShaderStage::Fragment,
"@builtin(position) fragCoord : vec4<f32>,");
"@builtin(position) fragCoord : vec4f,");
}
// @builtin(front_facing) should be counted into the maximum inter-stage component count.
@ -515,12 +514,12 @@ TEST_F(ShaderModuleValidationTest, MaxBindingNumber) {
TEST_F(ShaderModuleValidationTest, MissingDecorations) {
// Vertex input.
utils::CreateShaderModule(device, R"(
@vertex fn main(@location(0) a : vec4<f32>) -> @builtin(position) vec4<f32> {
@vertex fn main(@location(0) a : vec4f) -> @builtin(position) vec4f {
return vec4(1.0);
}
)");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@vertex fn main(a : vec4<f32>) -> @builtin(position) vec4<f32> {
@vertex fn main(a : vec4f) -> @builtin(position) vec4f {
return vec4(1.0);
}
)"));
@ -528,7 +527,7 @@ TEST_F(ShaderModuleValidationTest, MissingDecorations) {
// Vertex output
utils::CreateShaderModule(device, R"(
struct Output {
@builtin(position) pos : vec4<f32>,
@builtin(position) pos : vec4f,
@location(0) a : f32,
}
@vertex fn main() -> Output {
@ -538,7 +537,7 @@ TEST_F(ShaderModuleValidationTest, MissingDecorations) {
)");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
struct Output {
@builtin(position) pos : vec4<f32>,
@builtin(position) pos : vec4f,
a : f32,
}
@vertex fn main() -> Output {
@ -549,12 +548,12 @@ TEST_F(ShaderModuleValidationTest, MissingDecorations) {
// Fragment input
utils::CreateShaderModule(device, R"(
@fragment fn main(@location(0) a : vec4<f32>) -> @location(0) f32 {
@fragment fn main(@location(0) a : vec4f) -> @location(0) f32 {
return 1.0;
}
)");
ASSERT_DEVICE_ERROR(utils::CreateShaderModule(device, R"(
@fragment fn main(a : vec4<f32>) -> @location(0) f32 {
@fragment fn main(a : vec4f) -> @location(0) f32 {
return 1.0;
}
)"));

View File

@ -26,12 +26,12 @@ class StorageTextureValidationTests : public ValidationTest {
ValidationTest::SetUp();
mDefaultVSModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
mDefaultFSModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
})");
}
@ -121,9 +121,9 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
@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);
fn main(@builtin(vertex_index) vertex_index : u32) -> @builtin(position) vec4f {
textureStore(image0, vec2i(i32(vertex_index), 0), vec4f(1.0, 0.0, 0.0, 1.0));
return vec4f(0.0);
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -137,8 +137,8 @@ TEST_F(StorageTextureValidationTests, RenderPipeline) {
{
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
@fragment fn main(@builtin(position) position : vec4<f32>) {
textureStore(image0, vec2<i32>(position.xy), vec4<f32>(1.0, 0.0, 0.0, 1.0));
@fragment fn main(@builtin(position) position : vec4f) {
textureStore(image0, vec2i(position.xy), vec4f(1.0, 0.0, 0.0, 1.0));
})");
utils::ComboRenderPipelineDescriptor descriptor;
@ -158,8 +158,8 @@ TEST_F(StorageTextureValidationTests, ComputePipeline) {
wgpu::ShaderModule csModule = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var image0 : texture_storage_2d<rgba8unorm, write>;
@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));
@compute @workgroup_size(1) fn main(@builtin(local_invocation_id) LocalInvocationID : vec3u) {
textureStore(image0, vec2i(LocalInvocationID.xy), vec4f(0.0, 0.0, 0.0, 0.0));
})");
wgpu::ComputePipelineDescriptor descriptor;

View File

@ -43,7 +43,7 @@ TEST_F(UnsafeAPIValidationTest, chromium_disable_uniformity_analysis) {
enable chromium_disable_uniformity_analysis;
@compute @workgroup_size(8) fn uniformity_error(
@builtin(local_invocation_id) local_invocation_id : vec3<u32>
@builtin(local_invocation_id) local_invocation_id : vec3u
) {
if (local_invocation_id.x == 0u) {
workgroupBarrier();

View File

@ -27,12 +27,12 @@ class VertexBufferValidationTest : public ValidationTest {
// Placeholder vertex shader module
vsModule = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(0.0, 1.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(0.0, 1.0, 0.0, 1.0);
})");
}
@ -53,11 +53,11 @@ class VertexBufferValidationTest : public ValidationTest {
if (i != 0) {
vs << ", ";
}
vs << "@location(" << i << ") a_position" << i << " : vec3<f32>\n";
vs << "@location(" << i << ") a_position" << i << " : vec3f\n";
}
vs << ") -> @builtin(position) vec4<f32> {";
vs << ") -> @builtin(position) vec4f {";
vs << "return vec4<f32>(";
vs << "return vec4f(";
for (unsigned int i = 0; i < bufferCount; ++i) {
vs << "a_position" << i;
if (i != bufferCount - 1) {

View File

@ -26,8 +26,8 @@ class VertexStateTest : public ValidationTest {
const char* vertexSource) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, vertexSource);
wgpu::ShaderModule fsModule = utils::CreateShaderModule(device, R"(
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(1.0, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(1.0, 0.0, 0.0, 1.0);
}
)");
@ -46,8 +46,8 @@ class VertexStateTest : public ValidationTest {
}
const char* kPlaceholderVertexShader = R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
}
)";
};
@ -99,28 +99,28 @@ TEST_F(VertexStateTest, PipelineCompatibility) {
// Control case: pipeline with one input per attribute
CreatePipeline(true, state, R"(
@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);
@location(0) a : vec4f,
@location(1) b : vec4f
) -> @builtin(position) vec4f {
return vec4f(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"(
@vertex fn main(
@location(0) a : vec4<f32>
) -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@location(0) a : vec4f
) -> @builtin(position) vec4f {
return vec4f(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"(
@vertex fn main(
@location(2) a : vec4<f32>
) -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
@location(2) a : vec4f
) -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
}
)");
}
@ -361,8 +361,8 @@ TEST_F(VertexStateTest, BaseTypeMatching) {
state.cAttributes[0].format = format;
std::string shader = "@vertex fn main(@location(0) attrib : " + shaderType +
R"() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
R"() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})";
CreatePipeline(success, state, shader.c_str());
@ -395,14 +395,14 @@ TEST_F(VertexStateTest, BaseTypeMatching) {
// Test that formats are compatible with any width of vectors.
DoTest(wgpu::VertexFormat::Float32, "f32", true);
DoTest(wgpu::VertexFormat::Float32, "vec2<f32>", true);
DoTest(wgpu::VertexFormat::Float32, "vec3<f32>", true);
DoTest(wgpu::VertexFormat::Float32, "vec4<f32>", true);
DoTest(wgpu::VertexFormat::Float32, "vec2f", true);
DoTest(wgpu::VertexFormat::Float32, "vec3f", true);
DoTest(wgpu::VertexFormat::Float32, "vec4f", true);
DoTest(wgpu::VertexFormat::Float32x4, "f32", true);
DoTest(wgpu::VertexFormat::Float32x4, "vec2<f32>", true);
DoTest(wgpu::VertexFormat::Float32x4, "vec3<f32>", true);
DoTest(wgpu::VertexFormat::Float32x4, "vec4<f32>", true);
DoTest(wgpu::VertexFormat::Float32x4, "vec2f", true);
DoTest(wgpu::VertexFormat::Float32x4, "vec3f", true);
DoTest(wgpu::VertexFormat::Float32x4, "vec4f", true);
}
// Check that we only check base type compatibility for vertex inputs the shader uses.
@ -414,8 +414,8 @@ TEST_F(VertexStateTest, BaseTypeMatchingForInexistentInput) {
state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].format = format;
std::string shader = R"(@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
std::string shader = R"(@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 0.0);
})";
CreatePipeline(true, state, shader.c_str());

View File

@ -46,22 +46,22 @@ class D3D12DescriptorHeapTests : public DawnTest {
@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),
vec2<f32>(-1.0, -1.0)
) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0)
);
return vec4<f32>(pos[VertexIndex], 0.0, 1.0);
return vec4f(pos[VertexIndex], 0.0, 1.0);
})");
mSimpleFSModule = utils::CreateShaderModule(device, R"(
struct U {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(0) var<uniform> colorBuffer : U;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
return colorBuffer.color;
})");
}
@ -176,15 +176,15 @@ TEST_P(D3D12DescriptorHeapTests, NoSwitchOverSamplerHeap) {
// a sampler bindgroup each draw. After HEAP_SIZE + 1 draws, the heaps WILL NOT switch over
// because the sampler heap allocations are de-duplicated.
renderPipelineDescriptor.vertex.module = utils::CreateShaderModule(device, R"(
@vertex fn main() -> @builtin(position) vec4<f32> {
return vec4<f32>(0.0, 0.0, 0.0, 1.0);
@vertex fn main() -> @builtin(position) vec4f {
return vec4f(0.0, 0.0, 0.0, 1.0);
})");
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
@group(0) @binding(0) var sampler0 : sampler;
@fragment fn main() -> @location(0) vec4<f32> {
@fragment fn main() -> @location(0) vec4f {
_ = sampler0;
return vec4<f32>(0.0, 0.0, 0.0, 0.0);
return vec4f(0.0, 0.0, 0.0, 0.0);
})");
wgpu::RenderPipeline renderPipeline = device.CreateRenderPipeline(&renderPipelineDescriptor);
@ -447,8 +447,8 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBO) {
}
@group(0) @binding(0) var<uniform> buffer0 : U;
@fragment fn main() -> @location(0) vec4<f32> {
return vec4<f32>(buffer0.heapSize, 0.0, 0.0, 1.0);
@fragment fn main() -> @location(0) vec4f {
return vec4f(buffer0.heapSize, 0.0, 0.0, 1.0);
})");
wgpu::BlendState blend;
@ -782,25 +782,25 @@ TEST_P(D3D12DescriptorHeapTests, EncodeManyUBOAndSamplers) {
@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),
vec2<f32>(-1.0, -1.0)
) -> @builtin(position) vec4f {
var pos = array(
vec2f(-1.0, 1.0),
vec2f( 1.0, 1.0),
vec2f(-1.0, -1.0)
);
return vec4<f32>(buffer0.transform * (pos[VertexIndex]), 0.0, 1.0);
return vec4f(buffer0.transform * (pos[VertexIndex]), 0.0, 1.0);
})");
pipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
struct U {
color : vec4<f32>
color : vec4f
}
@group(0) @binding(1) var sampler0 : sampler;
@group(0) @binding(2) var texture0 : texture_2d<f32>;
@group(0) @binding(3) var<uniform> buffer0 : U;
@fragment fn main(
@builtin(position) FragCoord : vec4<f32>
) -> @location(0) vec4<f32> {
@builtin(position) FragCoord : vec4f
) -> @location(0) vec4f {
return textureSample(texture0, sampler0, FragCoord.xy) + buffer0.color;
})");

Some files were not shown because too many files have changed in this diff Show More