Remove all use of deprecated tint APIs and WGSL syntax

Tint:
* Use the new transform::VertexFormat enum names

WGSL:
* The [[set(n)]] decoration is now [[group(n)]]
* [[builtin(vertex_idx)]] is now [[builtin(vertex_index)]]

Change-Id: I9cbf1368074488c4bb7fa81430bb12ec7581c1fb
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/56540
Reviewed-by: Corentin Wallez <cwallez@chromium.org>
Commit-Queue: Ben Clayton <bclayton@google.com>
This commit is contained in:
Ben Clayton 2021-06-30 11:33:04 +00:00 committed by Dawn LUCI CQ
parent 1ce20bf5cf
commit bf832f07d6
6 changed files with 49 additions and 49 deletions

View File

@ -65,14 +65,14 @@ void init() {
scalar : f32; scalar : f32;
scalarOffset : f32; scalarOffset : f32;
}; };
[[set(0), binding(0)]] var<uniform> c : Constants; [[group(0), binding(0)]] var<uniform> c : Constants;
struct VertexOut { struct VertexOut {
[[location(0)]] v_color : vec4<f32>; [[location(0)]] v_color : vec4<f32>;
[[builtin(position)]] Position : vec4<f32>; [[builtin(position)]] Position : vec4<f32>;
}; };
[[stage(vertex)]] fn main([[builtin(vertex_idx)]] VertexIndex : u32) -> VertexOut { [[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) -> VertexOut {
var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>( var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
vec4<f32>( 0.0, 0.1, 0.0, 1.0), 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),

View File

@ -53,65 +53,65 @@ namespace dawn_native {
tint::transform::VertexFormat ToTintVertexFormat(wgpu::VertexFormat format) { tint::transform::VertexFormat ToTintVertexFormat(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::Uint8x2: case wgpu::VertexFormat::Uint8x2:
return tint::transform::VertexFormat::kVec2U8; return tint::transform::VertexFormat::kUint8x2;
case wgpu::VertexFormat::Uint8x4: case wgpu::VertexFormat::Uint8x4:
return tint::transform::VertexFormat::kVec4U8; return tint::transform::VertexFormat::kUint8x4;
case wgpu::VertexFormat::Sint8x2: case wgpu::VertexFormat::Sint8x2:
return tint::transform::VertexFormat::kVec2I8; return tint::transform::VertexFormat::kSint8x2;
case wgpu::VertexFormat::Sint8x4: case wgpu::VertexFormat::Sint8x4:
return tint::transform::VertexFormat::kVec4I8; return tint::transform::VertexFormat::kSint8x4;
case wgpu::VertexFormat::Unorm8x2: case wgpu::VertexFormat::Unorm8x2:
return tint::transform::VertexFormat::kVec2U8Norm; return tint::transform::VertexFormat::kUnorm8x2;
case wgpu::VertexFormat::Unorm8x4: case wgpu::VertexFormat::Unorm8x4:
return tint::transform::VertexFormat::kVec4U8Norm; return tint::transform::VertexFormat::kUnorm8x4;
case wgpu::VertexFormat::Snorm8x2: case wgpu::VertexFormat::Snorm8x2:
return tint::transform::VertexFormat::kVec2I8Norm; return tint::transform::VertexFormat::kSnorm8x2;
case wgpu::VertexFormat::Snorm8x4: case wgpu::VertexFormat::Snorm8x4:
return tint::transform::VertexFormat::kVec4I8Norm; return tint::transform::VertexFormat::kSnorm8x4;
case wgpu::VertexFormat::Uint16x2: case wgpu::VertexFormat::Uint16x2:
return tint::transform::VertexFormat::kVec2U16; return tint::transform::VertexFormat::kUint16x2;
case wgpu::VertexFormat::Uint16x4: case wgpu::VertexFormat::Uint16x4:
return tint::transform::VertexFormat::kVec4U16; return tint::transform::VertexFormat::kUint16x4;
case wgpu::VertexFormat::Sint16x2: case wgpu::VertexFormat::Sint16x2:
return tint::transform::VertexFormat::kVec2I16; return tint::transform::VertexFormat::kSint16x2;
case wgpu::VertexFormat::Sint16x4: case wgpu::VertexFormat::Sint16x4:
return tint::transform::VertexFormat::kVec4I16; return tint::transform::VertexFormat::kSint16x4;
case wgpu::VertexFormat::Unorm16x2: case wgpu::VertexFormat::Unorm16x2:
return tint::transform::VertexFormat::kVec2U16Norm; return tint::transform::VertexFormat::kUnorm16x2;
case wgpu::VertexFormat::Unorm16x4: case wgpu::VertexFormat::Unorm16x4:
return tint::transform::VertexFormat::kVec4U16Norm; return tint::transform::VertexFormat::kUnorm16x4;
case wgpu::VertexFormat::Snorm16x2: case wgpu::VertexFormat::Snorm16x2:
return tint::transform::VertexFormat::kVec2I16Norm; return tint::transform::VertexFormat::kSnorm16x2;
case wgpu::VertexFormat::Snorm16x4: case wgpu::VertexFormat::Snorm16x4:
return tint::transform::VertexFormat::kVec4I16Norm; return tint::transform::VertexFormat::kSnorm16x4;
case wgpu::VertexFormat::Float16x2: case wgpu::VertexFormat::Float16x2:
return tint::transform::VertexFormat::kVec2F16; return tint::transform::VertexFormat::kFloat16x2;
case wgpu::VertexFormat::Float16x4: case wgpu::VertexFormat::Float16x4:
return tint::transform::VertexFormat::kVec4F16; return tint::transform::VertexFormat::kFloat16x4;
case wgpu::VertexFormat::Float32: case wgpu::VertexFormat::Float32:
return tint::transform::VertexFormat::kF32; return tint::transform::VertexFormat::kFloat32;
case wgpu::VertexFormat::Float32x2: case wgpu::VertexFormat::Float32x2:
return tint::transform::VertexFormat::kVec2F32; return tint::transform::VertexFormat::kFloat32x2;
case wgpu::VertexFormat::Float32x3: case wgpu::VertexFormat::Float32x3:
return tint::transform::VertexFormat::kVec3F32; return tint::transform::VertexFormat::kFloat32x3;
case wgpu::VertexFormat::Float32x4: case wgpu::VertexFormat::Float32x4:
return tint::transform::VertexFormat::kVec4F32; return tint::transform::VertexFormat::kFloat32x4;
case wgpu::VertexFormat::Uint32: case wgpu::VertexFormat::Uint32:
return tint::transform::VertexFormat::kU32; return tint::transform::VertexFormat::kUint32;
case wgpu::VertexFormat::Uint32x2: case wgpu::VertexFormat::Uint32x2:
return tint::transform::VertexFormat::kVec2U32; return tint::transform::VertexFormat::kUint32x2;
case wgpu::VertexFormat::Uint32x3: case wgpu::VertexFormat::Uint32x3:
return tint::transform::VertexFormat::kVec3U32; return tint::transform::VertexFormat::kUint32x3;
case wgpu::VertexFormat::Uint32x4: case wgpu::VertexFormat::Uint32x4:
return tint::transform::VertexFormat::kVec4U32; return tint::transform::VertexFormat::kUint32x4;
case wgpu::VertexFormat::Sint32: case wgpu::VertexFormat::Sint32:
return tint::transform::VertexFormat::kI32; return tint::transform::VertexFormat::kSint32;
case wgpu::VertexFormat::Sint32x2: case wgpu::VertexFormat::Sint32x2:
return tint::transform::VertexFormat::kVec2I32; return tint::transform::VertexFormat::kSint32x2;
case wgpu::VertexFormat::Sint32x3: case wgpu::VertexFormat::Sint32x3:
return tint::transform::VertexFormat::kVec3I32; return tint::transform::VertexFormat::kSint32x3;
case wgpu::VertexFormat::Sint32x4: case wgpu::VertexFormat::Sint32x4:
return tint::transform::VertexFormat::kVec4I32; return tint::transform::VertexFormat::kSint32x4;
case wgpu::VertexFormat::Undefined: case wgpu::VertexFormat::Undefined:
break; break;

View File

@ -96,8 +96,8 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfBasic) {
}; };
// TODO(crbug.com/tint/386): Use the same struct type // TODO(crbug.com/tint/386): Use the same struct type
[[set(0), binding(0)]] var<storage, read_write> src : Buf1; [[group(0), binding(0)]] var<storage, read_write> src : Buf1;
[[set(0), binding(1)]] var<storage, read_write> dst : Buf2; [[group(0), binding(1)]] var<storage, read_write> dst : Buf2;
[[stage(compute), workgroup_size(1)]] [[stage(compute), workgroup_size(1)]]
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) { fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
@ -123,8 +123,8 @@ TEST_P(ComputeCopyStorageBufferTests, SizedArrayOfStruct) {
}; };
// TODO(crbug.com/tint/386): Use the same struct type // TODO(crbug.com/tint/386): Use the same struct type
[[set(0), binding(0)]] var<storage, read_write> src : Buf1; [[group(0), binding(0)]] var<storage, read_write> src : Buf1;
[[set(0), binding(1)]] var<storage, read_write> dst : Buf2; [[group(0), binding(1)]] var<storage, read_write> dst : Buf2;
[[stage(compute), workgroup_size(1)]] [[stage(compute), workgroup_size(1)]]
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) { fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {
@ -145,8 +145,8 @@ TEST_P(ComputeCopyStorageBufferTests, UnsizedArrayOfBasic) {
}; };
// TODO(crbug.com/tint/386): Use the same struct type // TODO(crbug.com/tint/386): Use the same struct type
[[set(0), binding(0)]] var<storage, read_write> src : Buf1; [[group(0), binding(0)]] var<storage, read_write> src : Buf1;
[[set(0), binding(1)]] var<storage, read_write> dst : Buf2; [[group(0), binding(1)]] var<storage, read_write> dst : Buf2;
[[stage(compute), workgroup_size(1)]] [[stage(compute), workgroup_size(1)]]
fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) { fn main([[builtin(global_invocation_id)]] GlobalInvocationID : vec3<u32>) {

View File

@ -190,9 +190,9 @@ struct Data {
code : u32; code : u32;
}; };
[[set(0), binding(0)]] var<{input_qualifiers}> input : Input; [[group(0), binding(0)]] var<{input_qualifiers}> input : Input;
[[set(0), binding(1)]] var<storage, read_write> output : Output; [[group(0), binding(1)]] var<storage, read_write> output : Output;
[[set(0), binding(2)]] var<storage, read_write> status : Status; [[group(0), binding(2)]] var<storage, read_write> status : Status;
[[stage(compute), workgroup_size(1,1,1)]] [[stage(compute), workgroup_size(1,1,1)]]
fn main() { fn main() {

View File

@ -297,8 +297,8 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYtoR) {
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule(); renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler; [[group(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var texture : texture_2d<f32>; [[group(0), binding(1)]] var texture : texture_2d<f32>;
[[stage(fragment)]] [[stage(fragment)]]
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> { fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
@ -348,8 +348,8 @@ TEST_P(D3D12VideoViewsTests, NV12SampleUVtoRG) {
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule(); renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler; [[group(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var texture : texture_2d<f32>; [[group(0), binding(1)]] var texture : texture_2d<f32>;
[[stage(fragment)]] [[stage(fragment)]]
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> { fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {
@ -408,9 +408,9 @@ TEST_P(D3D12VideoViewsTests, NV12SampleYUVtoRGB) {
renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule(); renderPipelineDescriptor.vertex.module = GetTestVertexShaderModule();
renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"( renderPipelineDescriptor.cFragment.module = utils::CreateShaderModule(device, R"(
[[set(0), binding(0)]] var sampler0 : sampler; [[group(0), binding(0)]] var sampler0 : sampler;
[[set(0), binding(1)]] var lumaTexture : texture_2d<f32>; [[group(0), binding(1)]] var lumaTexture : texture_2d<f32>;
[[set(0), binding(2)]] var chromaTexture : texture_2d<f32>; [[group(0), binding(2)]] var chromaTexture : texture_2d<f32>;
[[stage(fragment)]] [[stage(fragment)]]
fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> { fn main([[location(0)]] texCoord : vec2<f32>) -> [[location(0)]] vec4<f32> {

View File

@ -63,7 +63,7 @@ TEST_P(ExternalTextureTests, CreateExternalTextureSuccess) {
TEST_P(ExternalTextureTests, SampleExternalTexture) { TEST_P(ExternalTextureTests, SampleExternalTexture) {
wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"( wgpu::ShaderModule vsModule = utils::CreateShaderModule(device, R"(
[[stage(vertex)]] fn main([[builtin(vertex_idx)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> { [[stage(vertex)]] fn main([[builtin(vertex_index)]] VertexIndex : u32) -> [[builtin(position)]] vec4<f32> {
var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>( var positions : array<vec4<f32>, 3> = array<vec4<f32>, 3>(
vec4<f32>(-1.0, 1.0, 0.0, 1.0), vec4<f32>(-1.0, 1.0, 0.0, 1.0),
vec4<f32>(-1.0, -1.0, 0.0, 1.0), vec4<f32>(-1.0, -1.0, 0.0, 1.0),