Updated VertexFormat enums

Shifts the older enum values up by 30, but if anyone was using values
rather than the enums themselves they'd land on the right formats
anyway.

Bug: dawn:695
Change-Id: I92a177b427fb1bb14b60d9280f89d030c5941a38
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/42561
Commit-Queue: Brandon Jones <bajones@chromium.org>
Commit-Queue: Kai Ninomiya <kainino@chromium.org>
Auto-Submit: Brandon Jones <bajones@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Brandon Jones 2021-02-26 02:20:25 +00:00 committed by Commit Bot service account
parent 87649ff09d
commit e3f10e3d8e
34 changed files with 980 additions and 526 deletions

View File

@ -1914,36 +1914,68 @@
"vertex format": { "vertex format": {
"category": "enum", "category": "enum",
"values": [ "values": [
{"value": 0, "name": "uChar2"}, {"value": 0, "name": "undefined", "valid": false, "jsrepr": "undefined"},
{"value": 1, "name": "uChar4"}, {"value": 1, "name": "uint8x2"},
{"value": 2, "name": "char2"}, {"value": 2, "name": "uint8x4"},
{"value": 3, "name": "char4"}, {"value": 3, "name": "sint8x2"},
{"value": 4, "name": "uChar2 norm"}, {"value": 4, "name": "sint8x4"},
{"value": 5, "name": "uChar4 norm"}, {"value": 5, "name": "unorm8x2"},
{"value": 6, "name": "char2 norm"}, {"value": 6, "name": "unorm8x4"},
{"value": 7, "name": "char4 norm"}, {"value": 7, "name": "snorm8x2"},
{"value": 8, "name": "uShort2"}, {"value": 8, "name": "snorm8x4"},
{"value": 9, "name": "uShort4"}, {"value": 9, "name": "uint16x2"},
{"value": 10, "name": "short2"}, {"value": 10, "name": "uint16x4"},
{"value": 11, "name": "short4"}, {"value": 11, "name": "sint16x2"},
{"value": 12, "name": "uShort2 norm"}, {"value": 12, "name": "sint16x4"},
{"value": 13, "name": "uShort4 norm"}, {"value": 13, "name": "unorm16x2"},
{"value": 14, "name": "short2 norm"}, {"value": 14, "name": "unorm16x4"},
{"value": 15, "name": "short4 norm"}, {"value": 15, "name": "snorm16x2"},
{"value": 16, "name": "half2"}, {"value": 16, "name": "snorm16x4"},
{"value": 17, "name": "half4"}, {"value": 17, "name": "float16x2"},
{"value": 18, "name": "float"}, {"value": 18, "name": "float16x4"},
{"value": 19, "name": "float2"}, {"value": 19, "name": "float32"},
{"value": 20, "name": "float3"}, {"value": 20, "name": "float32x2"},
{"value": 21, "name": "float4"}, {"value": 21, "name": "float32x3"},
{"value": 22, "name": "uInt"}, {"value": 22, "name": "float32x4"},
{"value": 23, "name": "uInt2"}, {"value": 23, "name": "uint32"},
{"value": 24, "name": "uInt3"}, {"value": 24, "name": "uint32x2"},
{"value": 25, "name": "uInt4"}, {"value": 25, "name": "uint32x3"},
{"value": 26, "name": "int"}, {"value": 26, "name": "uint32x4"},
{"value": 27, "name": "int2"}, {"value": 27, "name": "sint32"},
{"value": 28, "name": "int3"}, {"value": 28, "name": "sint32x2"},
{"value": 29, "name": "int4"} {"value": 29, "name": "sint32x3"},
{"value": 30, "name": "sint32x4"},
{"value": 101, "name": "uChar2"},
{"value": 102, "name": "uChar4"},
{"value": 103, "name": "char2"},
{"value": 104, "name": "char4"},
{"value": 105, "name": "uChar2 norm"},
{"value": 106, "name": "uChar4 norm"},
{"value": 107, "name": "char2 norm"},
{"value": 108, "name": "char4 norm"},
{"value": 109, "name": "uShort2"},
{"value": 110, "name": "uShort4"},
{"value": 111, "name": "short2"},
{"value": 112, "name": "short4"},
{"value": 113, "name": "uShort2 norm"},
{"value": 114, "name": "uShort4 norm"},
{"value": 115, "name": "short2 norm"},
{"value": 116, "name": "short4 norm"},
{"value": 117, "name": "half2"},
{"value": 118, "name": "half4"},
{"value": 119, "name": "float"},
{"value": 120, "name": "float2"},
{"value": 121, "name": "float3"},
{"value": 122, "name": "float4"},
{"value": 123, "name": "uInt"},
{"value": 124, "name": "uInt2"},
{"value": 125, "name": "uInt3"},
{"value": 126, "name": "uInt4"},
{"value": 127, "name": "int"},
{"value": 128, "name": "int2"},
{"value": 129, "name": "int3"},
{"value": 130, "name": "int4"}
] ]
}, },
"ObjectType": { "ObjectType": {

View File

@ -190,6 +190,8 @@ if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android) {
"TypeTraits.h", "TypeTraits.h",
"TypedInteger.h", "TypedInteger.h",
"UnderlyingType.h", "UnderlyingType.h",
"VertexFormatUtils.cpp",
"VertexFormatUtils.h",
"ityp_array.h", "ityp_array.h",
"ityp_bitset.h", "ityp_bitset.h",
"ityp_span.h", "ityp_span.h",
@ -201,7 +203,10 @@ if (is_win || is_linux || is_chromeos || is_mac || is_fuchsia || is_android) {
] ]
public_configs = [ ":dawn_internal" ] public_configs = [ ":dawn_internal" ]
deps = [ "${dawn_root}/src/dawn:dawn_headers" ] deps = [
"${dawn_root}/src/dawn:dawn_headers",
"${dawn_root}/src/dawn:dawncpp_headers",
]
if (dawn_enable_vulkan) { if (dawn_enable_vulkan) {
public_deps = [ "${dawn_root}/third_party/khronos:vulkan_headers" ] public_deps = [ "${dawn_root}/third_party/khronos:vulkan_headers" ]
} }

View File

@ -0,0 +1,289 @@
// Copyright 2021 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "VertexFormatUtils.h"
#include "Assert.h"
namespace dawn {
namespace {
static constexpr wgpu::VertexFormat kFirstDeprecatedVertexFormat =
wgpu::VertexFormat::UChar2;
static constexpr uint32_t kFirstDeprecatedVertexFormatValue =
static_cast<uint32_t>(kFirstDeprecatedVertexFormat);
} // namespace
bool IsDeprecatedVertexFormat(wgpu::VertexFormat format) {
return format >= kFirstDeprecatedVertexFormat;
}
wgpu::VertexFormat NormalizeVertexFormat(wgpu::VertexFormat format) {
// If the specified format is from the deprecated range return the corresponding
// non-deprecated format.
if (format >= kFirstDeprecatedVertexFormat) {
uint32_t formatValue = static_cast<uint32_t>(format);
// Need to add one to account for the "undefined" enum with value 0
return static_cast<wgpu::VertexFormat>(
(formatValue - kFirstDeprecatedVertexFormatValue) + 1);
}
return format;
}
uint32_t VertexFormatNumComponents(wgpu::VertexFormat format) {
format = NormalizeVertexFormat(format);
switch (format) {
case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::Sint8x4:
case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::Snorm8x4:
case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::Sint16x4:
case wgpu::VertexFormat::Unorm16x4:
case wgpu::VertexFormat::Snorm16x4:
case wgpu::VertexFormat::Float16x4:
case wgpu::VertexFormat::Float32x4:
case wgpu::VertexFormat::Uint32x4:
case wgpu::VertexFormat::Sint32x4:
return 4;
case wgpu::VertexFormat::Float32x3:
case wgpu::VertexFormat::Uint32x3:
case wgpu::VertexFormat::Sint32x3:
return 3;
case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::Sint8x2:
case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::Sint16x2:
case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Float32x2:
case wgpu::VertexFormat::Uint32x2:
case wgpu::VertexFormat::Sint32x2:
return 2;
case wgpu::VertexFormat::Float32:
case wgpu::VertexFormat::Uint32:
case wgpu::VertexFormat::Sint32:
return 1;
case wgpu::VertexFormat::Undefined:
break;
// Deprecated formats (should be unreachable after NormalizeVertexFormat call)
case wgpu::VertexFormat::UChar2:
case wgpu::VertexFormat::UChar4:
case wgpu::VertexFormat::Char2:
case wgpu::VertexFormat::Char4:
case wgpu::VertexFormat::UChar2Norm:
case wgpu::VertexFormat::UChar4Norm:
case wgpu::VertexFormat::Char2Norm:
case wgpu::VertexFormat::Char4Norm:
case wgpu::VertexFormat::UShort2:
case wgpu::VertexFormat::UShort4:
case wgpu::VertexFormat::UShort2Norm:
case wgpu::VertexFormat::UShort4Norm:
case wgpu::VertexFormat::Short2:
case wgpu::VertexFormat::Short4:
case wgpu::VertexFormat::Short2Norm:
case wgpu::VertexFormat::Short4Norm:
case wgpu::VertexFormat::Half2:
case wgpu::VertexFormat::Half4:
case wgpu::VertexFormat::Float:
case wgpu::VertexFormat::Float2:
case wgpu::VertexFormat::Float3:
case wgpu::VertexFormat::Float4:
case wgpu::VertexFormat::UInt:
case wgpu::VertexFormat::UInt2:
case wgpu::VertexFormat::UInt3:
case wgpu::VertexFormat::UInt4:
case wgpu::VertexFormat::Int:
case wgpu::VertexFormat::Int2:
case wgpu::VertexFormat::Int3:
case wgpu::VertexFormat::Int4:
break;
}
UNREACHABLE();
}
size_t VertexFormatComponentSize(wgpu::VertexFormat format) {
format = NormalizeVertexFormat(format);
switch (format) {
case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::Sint8x2:
case wgpu::VertexFormat::Sint8x4:
case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Snorm8x4:
return sizeof(char);
case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::Unorm16x4:
case wgpu::VertexFormat::Sint16x2:
case wgpu::VertexFormat::Sint16x4:
case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::Snorm16x4:
case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Float16x4:
return sizeof(uint16_t);
case wgpu::VertexFormat::Float32:
case wgpu::VertexFormat::Float32x2:
case wgpu::VertexFormat::Float32x3:
case wgpu::VertexFormat::Float32x4:
return sizeof(float);
case wgpu::VertexFormat::Uint32:
case wgpu::VertexFormat::Uint32x2:
case wgpu::VertexFormat::Uint32x3:
case wgpu::VertexFormat::Uint32x4:
case wgpu::VertexFormat::Sint32:
case wgpu::VertexFormat::Sint32x2:
case wgpu::VertexFormat::Sint32x3:
case wgpu::VertexFormat::Sint32x4:
return sizeof(int32_t);
case wgpu::VertexFormat::Undefined:
break;
// Deprecated formats (should be unreachable after NormalizeVertexFormat call)
case wgpu::VertexFormat::UChar2:
case wgpu::VertexFormat::UChar4:
case wgpu::VertexFormat::Char2:
case wgpu::VertexFormat::Char4:
case wgpu::VertexFormat::UChar2Norm:
case wgpu::VertexFormat::UChar4Norm:
case wgpu::VertexFormat::Char2Norm:
case wgpu::VertexFormat::Char4Norm:
case wgpu::VertexFormat::UShort2:
case wgpu::VertexFormat::UShort4:
case wgpu::VertexFormat::UShort2Norm:
case wgpu::VertexFormat::UShort4Norm:
case wgpu::VertexFormat::Short2:
case wgpu::VertexFormat::Short4:
case wgpu::VertexFormat::Short2Norm:
case wgpu::VertexFormat::Short4Norm:
case wgpu::VertexFormat::Half2:
case wgpu::VertexFormat::Half4:
case wgpu::VertexFormat::Float:
case wgpu::VertexFormat::Float2:
case wgpu::VertexFormat::Float3:
case wgpu::VertexFormat::Float4:
case wgpu::VertexFormat::UInt:
case wgpu::VertexFormat::UInt2:
case wgpu::VertexFormat::UInt3:
case wgpu::VertexFormat::UInt4:
case wgpu::VertexFormat::Int:
case wgpu::VertexFormat::Int2:
case wgpu::VertexFormat::Int3:
case wgpu::VertexFormat::Int4:
break;
}
UNREACHABLE();
}
size_t VertexFormatSize(wgpu::VertexFormat format) {
return VertexFormatNumComponents(format) * VertexFormatComponentSize(format);
}
const char* GetWGSLVertexFormatType(wgpu::VertexFormat format) {
format = NormalizeVertexFormat(format);
switch (format) {
case wgpu::VertexFormat::Float32:
return "f32";
case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Float32x2:
return "vec2<f32>";
case wgpu::VertexFormat::Float32x3:
return "vec3<f32>";
case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::Snorm8x4:
case wgpu::VertexFormat::Unorm16x4:
case wgpu::VertexFormat::Snorm16x4:
case wgpu::VertexFormat::Float16x4:
case wgpu::VertexFormat::Float32x4:
return "vec4<f32>";
case wgpu::VertexFormat::Uint32:
return "u32";
case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::Uint32x2:
return "vec2<u32>";
case wgpu::VertexFormat::Uint32x3:
return "vec3<u32>";
case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::Uint32x4:
return "vec4<u32>";
case wgpu::VertexFormat::Sint32:
return "i32";
case wgpu::VertexFormat::Sint8x2:
case wgpu::VertexFormat::Sint16x2:
case wgpu::VertexFormat::Sint32x2:
return "vec2<i32>";
case wgpu::VertexFormat::Sint32x3:
return "vec3<i32>";
case wgpu::VertexFormat::Sint8x4:
case wgpu::VertexFormat::Sint16x4:
case wgpu::VertexFormat::Sint32x4:
return "vec4<i32>";
case wgpu::VertexFormat::Undefined:
break;
// Deprecated formats (should be unreachable after NormalizeVertexFormat call)
case wgpu::VertexFormat::UChar2:
case wgpu::VertexFormat::UChar4:
case wgpu::VertexFormat::Char2:
case wgpu::VertexFormat::Char4:
case wgpu::VertexFormat::UChar2Norm:
case wgpu::VertexFormat::UChar4Norm:
case wgpu::VertexFormat::Char2Norm:
case wgpu::VertexFormat::Char4Norm:
case wgpu::VertexFormat::UShort2:
case wgpu::VertexFormat::UShort4:
case wgpu::VertexFormat::UShort2Norm:
case wgpu::VertexFormat::UShort4Norm:
case wgpu::VertexFormat::Short2:
case wgpu::VertexFormat::Short4:
case wgpu::VertexFormat::Short2Norm:
case wgpu::VertexFormat::Short4Norm:
case wgpu::VertexFormat::Half2:
case wgpu::VertexFormat::Half4:
case wgpu::VertexFormat::Float:
case wgpu::VertexFormat::Float2:
case wgpu::VertexFormat::Float3:
case wgpu::VertexFormat::Float4:
case wgpu::VertexFormat::UInt:
case wgpu::VertexFormat::UInt2:
case wgpu::VertexFormat::UInt3:
case wgpu::VertexFormat::UInt4:
case wgpu::VertexFormat::Int:
case wgpu::VertexFormat::Int2:
case wgpu::VertexFormat::Int3:
case wgpu::VertexFormat::Int4:
break;
}
UNREACHABLE();
}
} // namespace dawn

View File

@ -0,0 +1,65 @@
// Copyright 2021 The Dawn Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#ifndef DAWNNATIVE_VERTEX_FORMAT_UTILS_H_
#define DAWNNATIVE_VERTEX_FORMAT_UTILS_H_
#include <array>
#include <dawn/webgpu_cpp.h>
namespace dawn {
static constexpr std::array<wgpu::VertexFormat, 30> kAllVertexFormats = {
wgpu::VertexFormat::Uint8x2, wgpu::VertexFormat::Uint8x4, wgpu::VertexFormat::Sint8x2,
wgpu::VertexFormat::Sint8x4, wgpu::VertexFormat::Unorm8x2, wgpu::VertexFormat::Unorm8x4,
wgpu::VertexFormat::Snorm8x2, wgpu::VertexFormat::Snorm8x4, wgpu::VertexFormat::Uint16x2,
wgpu::VertexFormat::Uint16x4, wgpu::VertexFormat::Unorm16x2, wgpu::VertexFormat::Unorm16x4,
wgpu::VertexFormat::Sint16x2, wgpu::VertexFormat::Sint16x4, wgpu::VertexFormat::Snorm16x2,
wgpu::VertexFormat::Snorm16x4, wgpu::VertexFormat::Float16x2, wgpu::VertexFormat::Float16x4,
wgpu::VertexFormat::Float32, wgpu::VertexFormat::Float32x2, wgpu::VertexFormat::Float32x3,
wgpu::VertexFormat::Float32x4, wgpu::VertexFormat::Uint32, wgpu::VertexFormat::Uint32x2,
wgpu::VertexFormat::Uint32x3, wgpu::VertexFormat::Uint32x4, wgpu::VertexFormat::Sint32,
wgpu::VertexFormat::Sint32x2, wgpu::VertexFormat::Sint32x3, wgpu::VertexFormat::Sint32x4,
};
static constexpr std::array<wgpu::VertexFormat, 30> kAllDeprecatedVertexFormats = {
wgpu::VertexFormat::UChar2, wgpu::VertexFormat::UChar4,
wgpu::VertexFormat::Char2, wgpu::VertexFormat::Char4,
wgpu::VertexFormat::UChar2Norm, wgpu::VertexFormat::UChar4Norm,
wgpu::VertexFormat::Char2Norm, wgpu::VertexFormat::Char4Norm,
wgpu::VertexFormat::UShort2, wgpu::VertexFormat::UShort4,
wgpu::VertexFormat::UShort2Norm, wgpu::VertexFormat::UShort4Norm,
wgpu::VertexFormat::Short2, wgpu::VertexFormat::Short4,
wgpu::VertexFormat::Short2Norm, wgpu::VertexFormat::Short4Norm,
wgpu::VertexFormat::Half2, wgpu::VertexFormat::Half4,
wgpu::VertexFormat::Float, wgpu::VertexFormat::Float2,
wgpu::VertexFormat::Float3, wgpu::VertexFormat::Float4,
wgpu::VertexFormat::UInt, wgpu::VertexFormat::UInt2,
wgpu::VertexFormat::UInt3, wgpu::VertexFormat::UInt4,
wgpu::VertexFormat::Int, wgpu::VertexFormat::Int2,
wgpu::VertexFormat::Int3, wgpu::VertexFormat::Int4,
};
bool IsDeprecatedVertexFormat(wgpu::VertexFormat format);
wgpu::VertexFormat NormalizeVertexFormat(wgpu::VertexFormat format);
uint32_t VertexFormatNumComponents(wgpu::VertexFormat format);
size_t VertexFormatComponentSize(wgpu::VertexFormat format);
size_t VertexFormatSize(wgpu::VertexFormat format);
const char* GetWGSLVertexFormatType(wgpu::VertexFormat textureFormat);
} // namespace dawn
#endif

View File

@ -15,6 +15,7 @@
#include "dawn_native/RenderPipeline.h" #include "dawn_native/RenderPipeline.h"
#include "common/BitSetIterator.h" #include "common/BitSetIterator.h"
#include "common/VertexFormatUtils.h"
#include "dawn_native/Commands.h" #include "dawn_native/Commands.h"
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
#include "dawn_native/ObjectContentHasher.h" #include "dawn_native/ObjectContentHasher.h"
@ -27,19 +28,26 @@ namespace dawn_native {
namespace { namespace {
MaybeError ValidateVertexAttributeDescriptor( MaybeError ValidateVertexAttributeDescriptor(
DeviceBase* device,
const VertexAttributeDescriptor* attribute, const VertexAttributeDescriptor* attribute,
uint64_t vertexBufferStride, uint64_t vertexBufferStride,
std::bitset<kMaxVertexAttributes>* attributesSetMask) { std::bitset<kMaxVertexAttributes>* attributesSetMask) {
DAWN_TRY(ValidateVertexFormat(attribute->format)); DAWN_TRY(ValidateVertexFormat(attribute->format));
if (dawn::IsDeprecatedVertexFormat(attribute->format)) {
device->EmitDeprecationWarning(
"Vertex formats have changed and the old types will be removed soon.");
}
if (attribute->shaderLocation >= kMaxVertexAttributes) { if (attribute->shaderLocation >= kMaxVertexAttributes) {
return DAWN_VALIDATION_ERROR("Setting attribute out of bounds"); return DAWN_VALIDATION_ERROR("Setting attribute out of bounds");
} }
// No underflow is possible because the max vertex format size is smaller than // No underflow is possible because the max vertex format size is smaller than
// kMaxVertexBufferStride. // kMaxVertexBufferStride.
ASSERT(kMaxVertexBufferStride >= VertexFormatSize(attribute->format)); ASSERT(kMaxVertexBufferStride >= dawn::VertexFormatSize(attribute->format));
if (attribute->offset > kMaxVertexBufferStride - VertexFormatSize(attribute->format)) { if (attribute->offset >
kMaxVertexBufferStride - dawn::VertexFormatSize(attribute->format)) {
return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds"); return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds");
} }
@ -47,7 +55,8 @@ namespace dawn_native {
// than kMaxVertexBufferStride. // than kMaxVertexBufferStride.
ASSERT(attribute->offset < kMaxVertexBufferStride); ASSERT(attribute->offset < kMaxVertexBufferStride);
if (vertexBufferStride > 0 && if (vertexBufferStride > 0 &&
attribute->offset + VertexFormatSize(attribute->format) > vertexBufferStride) { attribute->offset + dawn::VertexFormatSize(attribute->format) >
vertexBufferStride) {
return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds"); return DAWN_VALIDATION_ERROR("Setting attribute offset out of bounds");
} }
@ -64,6 +73,7 @@ namespace dawn_native {
} }
MaybeError ValidateVertexBufferLayoutDescriptor( MaybeError ValidateVertexBufferLayoutDescriptor(
DeviceBase* device,
const VertexBufferLayoutDescriptor* buffer, const VertexBufferLayoutDescriptor* buffer,
std::bitset<kMaxVertexAttributes>* attributesSetMask) { std::bitset<kMaxVertexAttributes>* attributesSetMask) {
DAWN_TRY(ValidateInputStepMode(buffer->stepMode)); DAWN_TRY(ValidateInputStepMode(buffer->stepMode));
@ -77,7 +87,7 @@ namespace dawn_native {
} }
for (uint32_t i = 0; i < buffer->attributeCount; ++i) { for (uint32_t i = 0; i < buffer->attributeCount; ++i) {
DAWN_TRY(ValidateVertexAttributeDescriptor(&buffer->attributes[i], DAWN_TRY(ValidateVertexAttributeDescriptor(device, &buffer->attributes[i],
buffer->arrayStride, attributesSetMask)); buffer->arrayStride, attributesSetMask));
} }
@ -112,7 +122,7 @@ namespace dawn_native {
uint32_t totalAttributesNum = 0; uint32_t totalAttributesNum = 0;
for (uint32_t i = 0; i < descriptor->vertexBufferCount; ++i) { for (uint32_t i = 0; i < descriptor->vertexBufferCount; ++i) {
DAWN_TRY(ValidateVertexBufferLayoutDescriptor(&descriptor->vertexBuffers[i], DAWN_TRY(ValidateVertexBufferLayoutDescriptor(device, &descriptor->vertexBuffers[i],
attributesSetMask)); attributesSetMask));
totalAttributesNum += descriptor->vertexBuffers[i].attributeCount; totalAttributesNum += descriptor->vertexBuffers[i].attributeCount;
} }
@ -212,88 +222,6 @@ namespace dawn_native {
} }
} }
uint32_t VertexFormatNumComponents(wgpu::VertexFormat format) {
switch (format) {
case wgpu::VertexFormat::UChar4:
case wgpu::VertexFormat::Char4:
case wgpu::VertexFormat::UChar4Norm:
case wgpu::VertexFormat::Char4Norm:
case wgpu::VertexFormat::UShort4:
case wgpu::VertexFormat::Short4:
case wgpu::VertexFormat::UShort4Norm:
case wgpu::VertexFormat::Short4Norm:
case wgpu::VertexFormat::Half4:
case wgpu::VertexFormat::Float4:
case wgpu::VertexFormat::UInt4:
case wgpu::VertexFormat::Int4:
return 4;
case wgpu::VertexFormat::Float3:
case wgpu::VertexFormat::UInt3:
case wgpu::VertexFormat::Int3:
return 3;
case wgpu::VertexFormat::UChar2:
case wgpu::VertexFormat::Char2:
case wgpu::VertexFormat::UChar2Norm:
case wgpu::VertexFormat::Char2Norm:
case wgpu::VertexFormat::UShort2:
case wgpu::VertexFormat::Short2:
case wgpu::VertexFormat::UShort2Norm:
case wgpu::VertexFormat::Short2Norm:
case wgpu::VertexFormat::Half2:
case wgpu::VertexFormat::Float2:
case wgpu::VertexFormat::UInt2:
case wgpu::VertexFormat::Int2:
return 2;
case wgpu::VertexFormat::Float:
case wgpu::VertexFormat::UInt:
case wgpu::VertexFormat::Int:
return 1;
}
}
size_t VertexFormatComponentSize(wgpu::VertexFormat format) {
switch (format) {
case wgpu::VertexFormat::UChar2:
case wgpu::VertexFormat::UChar4:
case wgpu::VertexFormat::Char2:
case wgpu::VertexFormat::Char4:
case wgpu::VertexFormat::UChar2Norm:
case wgpu::VertexFormat::UChar4Norm:
case wgpu::VertexFormat::Char2Norm:
case wgpu::VertexFormat::Char4Norm:
return sizeof(char);
case wgpu::VertexFormat::UShort2:
case wgpu::VertexFormat::UShort4:
case wgpu::VertexFormat::UShort2Norm:
case wgpu::VertexFormat::UShort4Norm:
case wgpu::VertexFormat::Short2:
case wgpu::VertexFormat::Short4:
case wgpu::VertexFormat::Short2Norm:
case wgpu::VertexFormat::Short4Norm:
case wgpu::VertexFormat::Half2:
case wgpu::VertexFormat::Half4:
return sizeof(uint16_t);
case wgpu::VertexFormat::Float:
case wgpu::VertexFormat::Float2:
case wgpu::VertexFormat::Float3:
case wgpu::VertexFormat::Float4:
return sizeof(float);
case wgpu::VertexFormat::UInt:
case wgpu::VertexFormat::UInt2:
case wgpu::VertexFormat::UInt3:
case wgpu::VertexFormat::UInt4:
case wgpu::VertexFormat::Int:
case wgpu::VertexFormat::Int2:
case wgpu::VertexFormat::Int3:
case wgpu::VertexFormat::Int4:
return sizeof(int32_t);
}
}
size_t VertexFormatSize(wgpu::VertexFormat format) {
return VertexFormatNumComponents(format) * VertexFormatComponentSize(format);
}
bool IsStripPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) { bool IsStripPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) {
return primitiveTopology == wgpu::PrimitiveTopology::LineStrip || return primitiveTopology == wgpu::PrimitiveTopology::LineStrip ||
primitiveTopology == wgpu::PrimitiveTopology::TriangleStrip; primitiveTopology == wgpu::PrimitiveTopology::TriangleStrip;
@ -431,8 +359,9 @@ namespace dawn_native {
mAttributeInfos[location].vertexBufferSlot = typedSlot; mAttributeInfos[location].vertexBufferSlot = typedSlot;
mAttributeInfos[location].offset = mAttributeInfos[location].offset =
mVertexState.vertexBuffers[slot].attributes[i].offset; mVertexState.vertexBuffers[slot].attributes[i].offset;
mAttributeInfos[location].format =
mVertexState.vertexBuffers[slot].attributes[i].format; mAttributeInfos[location].format = dawn::NormalizeVertexFormat(
mVertexState.vertexBuffers[slot].attributes[i].format);
} }
} }

View File

@ -32,9 +32,7 @@ namespace dawn_native {
MaybeError ValidateRenderPipelineDescriptor(DeviceBase* device, MaybeError ValidateRenderPipelineDescriptor(DeviceBase* device,
const RenderPipelineDescriptor* descriptor); const RenderPipelineDescriptor* descriptor);
size_t IndexFormatSize(wgpu::IndexFormat format); size_t IndexFormatSize(wgpu::IndexFormat format);
uint32_t VertexFormatNumComponents(wgpu::VertexFormat format);
size_t VertexFormatComponentSize(wgpu::VertexFormat format);
size_t VertexFormatSize(wgpu::VertexFormat format);
bool IsStripPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology); bool IsStripPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology);
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState); bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState);

View File

@ -14,11 +14,13 @@
#include "dawn_native/ShaderModule.h" #include "dawn_native/ShaderModule.h"
#include "common/VertexFormatUtils.h"
#include "dawn_native/BindGroupLayout.h" #include "dawn_native/BindGroupLayout.h"
#include "dawn_native/Device.h" #include "dawn_native/Device.h"
#include "dawn_native/ObjectContentHasher.h" #include "dawn_native/ObjectContentHasher.h"
#include "dawn_native/Pipeline.h" #include "dawn_native/Pipeline.h"
#include "dawn_native/PipelineLayout.h" #include "dawn_native/PipelineLayout.h"
#include "dawn_native/RenderPipeline.h"
#include "dawn_native/SpirvUtils.h" #include "dawn_native/SpirvUtils.h"
#include <spirv-tools/libspirv.hpp> #include <spirv-tools/libspirv.hpp>
@ -48,68 +50,106 @@ namespace dawn_native {
#ifdef DAWN_ENABLE_WGSL #ifdef DAWN_ENABLE_WGSL
tint::transform::VertexFormat ToTintVertexFormat(wgpu::VertexFormat format) { tint::transform::VertexFormat ToTintVertexFormat(wgpu::VertexFormat format) {
format = dawn::NormalizeVertexFormat(format);
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
return tint::transform::VertexFormat::kVec2U8; return tint::transform::VertexFormat::kVec2U8;
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
return tint::transform::VertexFormat::kVec4U8; return tint::transform::VertexFormat::kVec4U8;
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Sint8x2:
return tint::transform::VertexFormat::kVec2I8; return tint::transform::VertexFormat::kVec2I8;
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Sint8x4:
return tint::transform::VertexFormat::kVec4I8; return tint::transform::VertexFormat::kVec4I8;
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
return tint::transform::VertexFormat::kVec2U8Norm; return tint::transform::VertexFormat::kVec2U8Norm;
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
return tint::transform::VertexFormat::kVec4U8Norm; return tint::transform::VertexFormat::kVec4U8Norm;
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
return tint::transform::VertexFormat::kVec2I8Norm; return tint::transform::VertexFormat::kVec2I8Norm;
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
return tint::transform::VertexFormat::kVec4I8Norm; return tint::transform::VertexFormat::kVec4I8Norm;
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
return tint::transform::VertexFormat::kVec2U16; return tint::transform::VertexFormat::kVec2U16;
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
return tint::transform::VertexFormat::kVec4U16; return tint::transform::VertexFormat::kVec4U16;
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Sint16x2:
return tint::transform::VertexFormat::kVec2I16; return tint::transform::VertexFormat::kVec2I16;
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Sint16x4:
return tint::transform::VertexFormat::kVec4I16; return tint::transform::VertexFormat::kVec4I16;
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
return tint::transform::VertexFormat::kVec2U16Norm; return tint::transform::VertexFormat::kVec2U16Norm;
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
return tint::transform::VertexFormat::kVec4U16Norm; return tint::transform::VertexFormat::kVec4U16Norm;
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
return tint::transform::VertexFormat::kVec2I16Norm; return tint::transform::VertexFormat::kVec2I16Norm;
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
return tint::transform::VertexFormat::kVec4I16Norm; return tint::transform::VertexFormat::kVec4I16Norm;
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
return tint::transform::VertexFormat::kVec2F16; return tint::transform::VertexFormat::kVec2F16;
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
return tint::transform::VertexFormat::kVec4F16; return tint::transform::VertexFormat::kVec4F16;
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Float32:
return tint::transform::VertexFormat::kF32; return tint::transform::VertexFormat::kF32;
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Float32x2:
return tint::transform::VertexFormat::kVec2F32; return tint::transform::VertexFormat::kVec2F32;
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Float32x3:
return tint::transform::VertexFormat::kVec3F32; return tint::transform::VertexFormat::kVec3F32;
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Float32x4:
return tint::transform::VertexFormat::kVec4F32; return tint::transform::VertexFormat::kVec4F32;
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Uint32:
return tint::transform::VertexFormat::kU32; return tint::transform::VertexFormat::kU32;
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Uint32x2:
return tint::transform::VertexFormat::kVec2U32; return tint::transform::VertexFormat::kVec2U32;
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
return tint::transform::VertexFormat::kVec3U32; return tint::transform::VertexFormat::kVec3U32;
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x4:
return tint::transform::VertexFormat::kVec4U32; return tint::transform::VertexFormat::kVec4U32;
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Sint32:
return tint::transform::VertexFormat::kI32; return tint::transform::VertexFormat::kI32;
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Sint32x2:
return tint::transform::VertexFormat::kVec2I32; return tint::transform::VertexFormat::kVec2I32;
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Sint32x3:
return tint::transform::VertexFormat::kVec3I32; return tint::transform::VertexFormat::kVec3I32;
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint32x4:
return tint::transform::VertexFormat::kVec4I32; return tint::transform::VertexFormat::kVec4I32;
case wgpu::VertexFormat::Undefined:
break;
// Deprecated formats (should be unreachable after NormalizeVertexFormat call)
case wgpu::VertexFormat::UChar2:
case wgpu::VertexFormat::UChar4:
case wgpu::VertexFormat::Char2:
case wgpu::VertexFormat::Char4:
case wgpu::VertexFormat::UChar2Norm:
case wgpu::VertexFormat::UChar4Norm:
case wgpu::VertexFormat::Char2Norm:
case wgpu::VertexFormat::Char4Norm:
case wgpu::VertexFormat::UShort2:
case wgpu::VertexFormat::UShort4:
case wgpu::VertexFormat::UShort2Norm:
case wgpu::VertexFormat::UShort4Norm:
case wgpu::VertexFormat::Short2:
case wgpu::VertexFormat::Short4:
case wgpu::VertexFormat::Short2Norm:
case wgpu::VertexFormat::Short4Norm:
case wgpu::VertexFormat::Half2:
case wgpu::VertexFormat::Half4:
case wgpu::VertexFormat::Float:
case wgpu::VertexFormat::Float2:
case wgpu::VertexFormat::Float3:
case wgpu::VertexFormat::Float4:
case wgpu::VertexFormat::UInt:
case wgpu::VertexFormat::UInt2:
case wgpu::VertexFormat::UInt3:
case wgpu::VertexFormat::UInt4:
case wgpu::VertexFormat::Int:
case wgpu::VertexFormat::Int2:
case wgpu::VertexFormat::Int3:
case wgpu::VertexFormat::Int4:
break;
} }
UNREACHABLE();
} }
tint::transform::InputStepMode ToTintInputStepMode(wgpu::InputStepMode mode) { tint::transform::InputStepMode ToTintInputStepMode(wgpu::InputStepMode mode) {

View File

@ -31,66 +31,68 @@ namespace dawn_native { namespace d3d12 {
namespace { namespace {
DXGI_FORMAT VertexFormatType(wgpu::VertexFormat format) { DXGI_FORMAT VertexFormatType(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
return DXGI_FORMAT_R8G8_UINT; return DXGI_FORMAT_R8G8_UINT;
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
return DXGI_FORMAT_R8G8B8A8_UINT; return DXGI_FORMAT_R8G8B8A8_UINT;
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Sint8x2:
return DXGI_FORMAT_R8G8_SINT; return DXGI_FORMAT_R8G8_SINT;
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Sint8x4:
return DXGI_FORMAT_R8G8B8A8_SINT; return DXGI_FORMAT_R8G8B8A8_SINT;
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
return DXGI_FORMAT_R8G8_UNORM; return DXGI_FORMAT_R8G8_UNORM;
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
return DXGI_FORMAT_R8G8B8A8_UNORM; return DXGI_FORMAT_R8G8B8A8_UNORM;
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
return DXGI_FORMAT_R8G8_SNORM; return DXGI_FORMAT_R8G8_SNORM;
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
return DXGI_FORMAT_R8G8B8A8_SNORM; return DXGI_FORMAT_R8G8B8A8_SNORM;
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
return DXGI_FORMAT_R16G16_UINT; return DXGI_FORMAT_R16G16_UINT;
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
return DXGI_FORMAT_R16G16B16A16_UINT; return DXGI_FORMAT_R16G16B16A16_UINT;
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Sint16x2:
return DXGI_FORMAT_R16G16_SINT; return DXGI_FORMAT_R16G16_SINT;
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Sint16x4:
return DXGI_FORMAT_R16G16B16A16_SINT; return DXGI_FORMAT_R16G16B16A16_SINT;
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
return DXGI_FORMAT_R16G16_UNORM; return DXGI_FORMAT_R16G16_UNORM;
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
return DXGI_FORMAT_R16G16B16A16_UNORM; return DXGI_FORMAT_R16G16B16A16_UNORM;
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
return DXGI_FORMAT_R16G16_SNORM; return DXGI_FORMAT_R16G16_SNORM;
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
return DXGI_FORMAT_R16G16B16A16_SNORM; return DXGI_FORMAT_R16G16B16A16_SNORM;
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
return DXGI_FORMAT_R16G16_FLOAT; return DXGI_FORMAT_R16G16_FLOAT;
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
return DXGI_FORMAT_R16G16B16A16_FLOAT; return DXGI_FORMAT_R16G16B16A16_FLOAT;
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Float32:
return DXGI_FORMAT_R32_FLOAT; return DXGI_FORMAT_R32_FLOAT;
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Float32x2:
return DXGI_FORMAT_R32G32_FLOAT; return DXGI_FORMAT_R32G32_FLOAT;
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Float32x3:
return DXGI_FORMAT_R32G32B32_FLOAT; return DXGI_FORMAT_R32G32B32_FLOAT;
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Float32x4:
return DXGI_FORMAT_R32G32B32A32_FLOAT; return DXGI_FORMAT_R32G32B32A32_FLOAT;
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Uint32:
return DXGI_FORMAT_R32_UINT; return DXGI_FORMAT_R32_UINT;
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Uint32x2:
return DXGI_FORMAT_R32G32_UINT; return DXGI_FORMAT_R32G32_UINT;
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
return DXGI_FORMAT_R32G32B32_UINT; return DXGI_FORMAT_R32G32B32_UINT;
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x4:
return DXGI_FORMAT_R32G32B32A32_UINT; return DXGI_FORMAT_R32G32B32A32_UINT;
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Sint32:
return DXGI_FORMAT_R32_SINT; return DXGI_FORMAT_R32_SINT;
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Sint32x2:
return DXGI_FORMAT_R32G32_SINT; return DXGI_FORMAT_R32G32_SINT;
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Sint32x3:
return DXGI_FORMAT_R32G32B32_SINT; return DXGI_FORMAT_R32G32B32_SINT;
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint32x4:
return DXGI_FORMAT_R32G32B32A32_SINT; return DXGI_FORMAT_R32G32B32A32_SINT;
default:
UNREACHABLE();
} }
} }

View File

@ -14,6 +14,7 @@
#include "dawn_native/metal/RenderPipelineMTL.h" #include "dawn_native/metal/RenderPipelineMTL.h"
#include "common/VertexFormatUtils.h"
#include "dawn_native/metal/DeviceMTL.h" #include "dawn_native/metal/DeviceMTL.h"
#include "dawn_native/metal/PipelineLayoutMTL.h" #include "dawn_native/metal/PipelineLayoutMTL.h"
#include "dawn_native/metal/ShaderModuleMTL.h" #include "dawn_native/metal/ShaderModuleMTL.h"
@ -25,66 +26,68 @@ namespace dawn_native { namespace metal {
namespace { namespace {
MTLVertexFormat VertexFormatType(wgpu::VertexFormat format) { MTLVertexFormat VertexFormatType(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
return MTLVertexFormatUChar2; return MTLVertexFormatUChar2;
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
return MTLVertexFormatUChar4; return MTLVertexFormatUChar4;
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Sint8x2:
return MTLVertexFormatChar2; return MTLVertexFormatChar2;
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Sint8x4:
return MTLVertexFormatChar4; return MTLVertexFormatChar4;
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
return MTLVertexFormatUChar2Normalized; return MTLVertexFormatUChar2Normalized;
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
return MTLVertexFormatUChar4Normalized; return MTLVertexFormatUChar4Normalized;
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
return MTLVertexFormatChar2Normalized; return MTLVertexFormatChar2Normalized;
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
return MTLVertexFormatChar4Normalized; return MTLVertexFormatChar4Normalized;
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
return MTLVertexFormatUShort2; return MTLVertexFormatUShort2;
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
return MTLVertexFormatUShort4; return MTLVertexFormatUShort4;
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Sint16x2:
return MTLVertexFormatShort2; return MTLVertexFormatShort2;
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Sint16x4:
return MTLVertexFormatShort4; return MTLVertexFormatShort4;
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
return MTLVertexFormatUShort2Normalized; return MTLVertexFormatUShort2Normalized;
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
return MTLVertexFormatUShort4Normalized; return MTLVertexFormatUShort4Normalized;
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
return MTLVertexFormatShort2Normalized; return MTLVertexFormatShort2Normalized;
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
return MTLVertexFormatShort4Normalized; return MTLVertexFormatShort4Normalized;
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
return MTLVertexFormatHalf2; return MTLVertexFormatHalf2;
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
return MTLVertexFormatHalf4; return MTLVertexFormatHalf4;
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Float32:
return MTLVertexFormatFloat; return MTLVertexFormatFloat;
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Float32x2:
return MTLVertexFormatFloat2; return MTLVertexFormatFloat2;
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Float32x3:
return MTLVertexFormatFloat3; return MTLVertexFormatFloat3;
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Float32x4:
return MTLVertexFormatFloat4; return MTLVertexFormatFloat4;
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Uint32:
return MTLVertexFormatUInt; return MTLVertexFormatUInt;
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Uint32x2:
return MTLVertexFormatUInt2; return MTLVertexFormatUInt2;
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
return MTLVertexFormatUInt3; return MTLVertexFormatUInt3;
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x4:
return MTLVertexFormatUInt4; return MTLVertexFormatUInt4;
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Sint32:
return MTLVertexFormatInt; return MTLVertexFormatInt;
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Sint32x2:
return MTLVertexFormatInt2; return MTLVertexFormatInt2;
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Sint32x3:
return MTLVertexFormatInt3; return MTLVertexFormatInt3;
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint32x4:
return MTLVertexFormatInt4; return MTLVertexFormatInt4;
default:
UNREACHABLE();
} }
} }
@ -458,8 +461,9 @@ namespace dawn_native { namespace metal {
if (attrib.vertexBufferSlot != slot) { if (attrib.vertexBufferSlot != slot) {
continue; continue;
} }
maxArrayStride = std::max( maxArrayStride =
maxArrayStride, VertexFormatSize(attrib.format) + size_t(attrib.offset)); std::max(maxArrayStride,
dawn::VertexFormatSize(attrib.format) + size_t(attrib.offset));
} }
layoutDesc.stepFunction = MTLVertexStepFunctionConstant; layoutDesc.stepFunction = MTLVertexStepFunctionConstant;
layoutDesc.stepRate = 0; layoutDesc.stepRate = 0;

View File

@ -14,6 +14,7 @@
#include "dawn_native/opengl/CommandBufferGL.h" #include "dawn_native/opengl/CommandBufferGL.h"
#include "common/VertexFormatUtils.h"
#include "dawn_native/BindGroup.h" #include "dawn_native/BindGroup.h"
#include "dawn_native/BindGroupTracker.h" #include "dawn_native/BindGroupTracker.h"
#include "dawn_native/CommandEncoder.h" #include "dawn_native/CommandEncoder.h"
@ -49,57 +50,59 @@ namespace dawn_native { namespace opengl {
GLenum VertexFormatType(wgpu::VertexFormat format) { GLenum VertexFormatType(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Sint8x2:
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Sint8x4:
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
return GL_BYTE; return GL_BYTE;
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
return GL_UNSIGNED_SHORT; return GL_UNSIGNED_SHORT;
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Sint16x2:
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Sint16x4:
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
return GL_SHORT; return GL_SHORT;
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
return GL_HALF_FLOAT; return GL_HALF_FLOAT;
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Float32:
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Float32x2:
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Float32x3:
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Float32x4:
return GL_FLOAT; return GL_FLOAT;
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Uint32:
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Uint32x2:
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x4:
return GL_UNSIGNED_INT; return GL_UNSIGNED_INT;
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Sint32:
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Sint32x2:
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Sint32x3:
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint32x4:
return GL_INT; return GL_INT;
default:
UNREACHABLE();
} }
} }
GLboolean VertexFormatIsNormalized(wgpu::VertexFormat format) { GLboolean VertexFormatIsNormalized(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
return GL_TRUE; return GL_TRUE;
default: default:
return GL_FALSE; return GL_FALSE;
@ -108,22 +111,22 @@ namespace dawn_native { namespace opengl {
bool VertexFormatIsInt(wgpu::VertexFormat format) { bool VertexFormatIsInt(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Sint8x2:
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Sint8x4:
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Sint16x2:
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Sint16x4:
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Uint32:
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Uint32x2:
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x4:
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Sint32:
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Sint32x2:
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Sint32x3:
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint32x4:
return true; return true;
default: default:
return false; return false;
@ -175,7 +178,7 @@ namespace dawn_native { namespace opengl {
uint64_t offset = mVertexBufferOffsets[slot]; uint64_t offset = mVertexBufferOffsets[slot];
const VertexBufferInfo& vertexBuffer = mLastPipeline->GetVertexBuffer(slot); const VertexBufferInfo& vertexBuffer = mLastPipeline->GetVertexBuffer(slot);
uint32_t components = VertexFormatNumComponents(attribute.format); uint32_t components = dawn::VertexFormatNumComponents(attribute.format);
GLenum formatType = VertexFormatType(attribute.format); GLenum formatType = VertexFormatType(attribute.format);
GLboolean normalized = VertexFormatIsNormalized(attribute.format); GLboolean normalized = VertexFormatIsNormalized(attribute.format);

View File

@ -38,66 +38,68 @@ namespace dawn_native { namespace vulkan {
VkFormat VulkanVertexFormat(wgpu::VertexFormat format) { VkFormat VulkanVertexFormat(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
return VK_FORMAT_R8G8_UINT; return VK_FORMAT_R8G8_UINT;
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
return VK_FORMAT_R8G8B8A8_UINT; return VK_FORMAT_R8G8B8A8_UINT;
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Sint8x2:
return VK_FORMAT_R8G8_SINT; return VK_FORMAT_R8G8_SINT;
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Sint8x4:
return VK_FORMAT_R8G8B8A8_SINT; return VK_FORMAT_R8G8B8A8_SINT;
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
return VK_FORMAT_R8G8_UNORM; return VK_FORMAT_R8G8_UNORM;
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
return VK_FORMAT_R8G8B8A8_UNORM; return VK_FORMAT_R8G8B8A8_UNORM;
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
return VK_FORMAT_R8G8_SNORM; return VK_FORMAT_R8G8_SNORM;
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
return VK_FORMAT_R8G8B8A8_SNORM; return VK_FORMAT_R8G8B8A8_SNORM;
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
return VK_FORMAT_R16G16_UINT; return VK_FORMAT_R16G16_UINT;
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
return VK_FORMAT_R16G16B16A16_UINT; return VK_FORMAT_R16G16B16A16_UINT;
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Sint16x2:
return VK_FORMAT_R16G16_SINT; return VK_FORMAT_R16G16_SINT;
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Sint16x4:
return VK_FORMAT_R16G16B16A16_SINT; return VK_FORMAT_R16G16B16A16_SINT;
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
return VK_FORMAT_R16G16_UNORM; return VK_FORMAT_R16G16_UNORM;
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
return VK_FORMAT_R16G16B16A16_UNORM; return VK_FORMAT_R16G16B16A16_UNORM;
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
return VK_FORMAT_R16G16_SNORM; return VK_FORMAT_R16G16_SNORM;
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
return VK_FORMAT_R16G16B16A16_SNORM; return VK_FORMAT_R16G16B16A16_SNORM;
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
return VK_FORMAT_R16G16_SFLOAT; return VK_FORMAT_R16G16_SFLOAT;
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
return VK_FORMAT_R16G16B16A16_SFLOAT; return VK_FORMAT_R16G16B16A16_SFLOAT;
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Float32:
return VK_FORMAT_R32_SFLOAT; return VK_FORMAT_R32_SFLOAT;
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Float32x2:
return VK_FORMAT_R32G32_SFLOAT; return VK_FORMAT_R32G32_SFLOAT;
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Float32x3:
return VK_FORMAT_R32G32B32_SFLOAT; return VK_FORMAT_R32G32B32_SFLOAT;
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Float32x4:
return VK_FORMAT_R32G32B32A32_SFLOAT; return VK_FORMAT_R32G32B32A32_SFLOAT;
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Uint32:
return VK_FORMAT_R32_UINT; return VK_FORMAT_R32_UINT;
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Uint32x2:
return VK_FORMAT_R32G32_UINT; return VK_FORMAT_R32G32_UINT;
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
return VK_FORMAT_R32G32B32_UINT; return VK_FORMAT_R32G32B32_UINT;
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x4:
return VK_FORMAT_R32G32B32A32_UINT; return VK_FORMAT_R32G32B32A32_UINT;
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Sint32:
return VK_FORMAT_R32_SINT; return VK_FORMAT_R32_SINT;
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Sint32x2:
return VK_FORMAT_R32G32_SINT; return VK_FORMAT_R32G32_SINT;
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Sint32x3:
return VK_FORMAT_R32G32B32_SINT; return VK_FORMAT_R32G32B32_SINT;
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint32x4:
return VK_FORMAT_R32G32B32A32_SINT; return VK_FORMAT_R32G32B32A32_SINT;
default:
UNREACHABLE();
} }
} }

View File

@ -231,7 +231,7 @@ class BufferZeroInitTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = vertexBufferCount; descriptor.cVertexState.vertexBufferCount = vertexBufferCount;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = kColorAttachmentFormat; descriptor.cColorStates[0].format = kColorAttachmentFormat;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline(&descriptor);
} }

View File

@ -20,9 +20,12 @@
#include "tests/DawnTest.h" #include "tests/DawnTest.h"
#include "common/Constants.h" #include "common/Constants.h"
#include "common/VertexFormatUtils.h"
#include "utils/ComboRenderPipelineDescriptor.h" #include "utils/ComboRenderPipelineDescriptor.h"
#include "utils/WGPUHelpers.h" #include "utils/WGPUHelpers.h"
#include <cmath>
class DeprecationTests : public DawnTest { class DeprecationTests : public DawnTest {
protected: protected:
void SetUp() override { void SetUp() override {
@ -194,3 +197,79 @@ class BufferCopyViewDeprecationTests : public DeprecationTests {
wgpu::Extent3D copySize = {1, 1, 1}; wgpu::Extent3D copySize = {1, 1, 1};
}; };
// Tests that deprecated vertex formats properly raise a deprecation warning when used
class VertexFormatDeprecationTests : public DeprecationTests {
protected:
// Runs the test
void DoTest(const wgpu::VertexFormat vertexFormat, bool deprecated) {
std::string attribute = "[[location(0)]] var<in> a : ";
attribute += dawn::GetWGSLVertexFormatType(vertexFormat);
attribute += ";";
std::string attribAccess = dawn::VertexFormatNumComponents(vertexFormat) > 1
? "vec4<f32>(a.x, 0.0, 0.0, 1.0)"
: "vec4<f32>(a, 0.0, 0.0, 1.0)";
wgpu::ShaderModule vsModule = utils::CreateShaderModuleFromWGSL(device, (attribute + R"(
[[builtin(position)]] var<out> Position : vec4<f32>;
[[stage(vertex)]] fn main() -> void {
Position = )" + attribAccess + R"(;
return;
}
)")
.c_str());
wgpu::ShaderModule fsModule = utils::CreateShaderModuleFromWGSL(device, R"(
[[location(0)]] var<out> outColor : vec4<f32>;
[[stage(fragment)]] fn main() -> void {
outColor = vec4<f32>(1.0, 1.0, 1.0, 1.0);
return;
}
)");
utils::ComboVertexStateDescriptor vertexState;
vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = 32;
vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = vertexFormat;
vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0;
utils::ComboRenderPipelineDescriptor descriptor(device);
descriptor.vertexStage.module = vsModule;
descriptor.cFragmentStage.module = fsModule;
descriptor.primitiveTopology = wgpu::PrimitiveTopology::PointList;
descriptor.vertexState = &vertexState;
descriptor.cColorStates[0].format = utils::BasicRenderPass::kDefaultColorFormat;
if (deprecated) {
EXPECT_DEPRECATION_WARNING(device.CreateRenderPipeline(&descriptor));
} else {
device.CreateRenderPipeline(&descriptor);
}
}
};
TEST_P(VertexFormatDeprecationTests, NewVertexFormats) {
// Using the new vertex formats does not emit a warning.
for (auto& format : dawn::kAllVertexFormats) {
DoTest(format, false);
}
}
TEST_P(VertexFormatDeprecationTests, DeprecatedVertexFormats) {
// Using deprecated vertex formats does emit a warning.
for (auto& format : dawn::kAllDeprecatedVertexFormats) {
DoTest(format, true);
}
}
DAWN_INSTANTIATE_TEST(VertexFormatDeprecationTests,
D3D12Backend(),
MetalBackend(),
NullBackend(),
OpenGLBackend(),
OpenGLESBackend(),
VulkanBackend());

View File

@ -47,7 +47,7 @@ class DestroyTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);

View File

@ -47,7 +47,7 @@ class DrawIndexedIndirectTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);

View File

@ -47,7 +47,7 @@ class DrawIndexedTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);

View File

@ -47,7 +47,7 @@ class DrawIndirectTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);

View File

@ -46,7 +46,7 @@ class DrawTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);

View File

@ -163,7 +163,7 @@ void FirstIndexOffsetTests::TestImpl(DrawMode mode,
pipelineDesc.cVertexState.vertexBufferCount = 1; pipelineDesc.cVertexState.vertexBufferCount = 1;
pipelineDesc.cVertexState.cVertexBuffers[0].arrayStride = kComponentsPerVertex * sizeof(float); pipelineDesc.cVertexState.cVertexBuffers[0].arrayStride = kComponentsPerVertex * sizeof(float);
pipelineDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; pipelineDesc.cVertexState.cVertexBuffers[0].attributeCount = 1;
pipelineDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; pipelineDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
pipelineDesc.cColorStates[0].format = renderPass.colorFormat; pipelineDesc.cColorStates[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&pipelineDesc);

View File

@ -602,7 +602,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, SeparateBuffers) {
rpDesc.cVertexState.vertexBufferCount = 1; rpDesc.cVertexState.vertexBufferCount = 1;
rpDesc.cVertexState.cVertexBuffers[0].arrayStride = kVertexBufferStride; rpDesc.cVertexState.cVertexBuffers[0].arrayStride = kVertexBufferStride;
rpDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; rpDesc.cVertexState.cVertexBuffers[0].attributeCount = 1;
rpDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; rpDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
rpDesc.cColorStates[0].format = renderPass.colorFormat; rpDesc.cColorStates[0].format = renderPass.colorFormat;
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&rpDesc); wgpu::RenderPipeline rp = device.CreateRenderPipeline(&rpDesc);
@ -719,7 +719,7 @@ TEST_P(MultipleWriteThenMultipleReadTests, OneBuffer) {
rpDesc.cVertexState.vertexBufferCount = 1; rpDesc.cVertexState.vertexBufferCount = 1;
rpDesc.cVertexState.cVertexBuffers[0].arrayStride = kVertexBufferStride; rpDesc.cVertexState.cVertexBuffers[0].arrayStride = kVertexBufferStride;
rpDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; rpDesc.cVertexState.cVertexBuffers[0].attributeCount = 1;
rpDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; rpDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
rpDesc.cColorStates[0].format = renderPass.colorFormat; rpDesc.cColorStates[0].format = renderPass.colorFormat;
wgpu::RenderPipeline rp = device.CreateRenderPipeline(&rpDesc); wgpu::RenderPipeline rp = device.CreateRenderPipeline(&rpDesc);

View File

@ -59,7 +59,7 @@ class IndexFormatTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
return device.CreateRenderPipeline(&descriptor); return device.CreateRenderPipeline(&descriptor);

View File

@ -72,7 +72,7 @@ class MultisampledSamplingTest : public DawnTest {
desc.cVertexState.vertexBufferCount = 1; desc.cVertexState.vertexBufferCount = 1;
desc.cVertexState.cVertexBuffers[0].attributeCount = 1; desc.cVertexState.cVertexBuffers[0].attributeCount = 1;
desc.cVertexState.cVertexBuffers[0].arrayStride = 2 * sizeof(float); desc.cVertexState.cVertexBuffers[0].arrayStride = 2 * sizeof(float);
desc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float2; desc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
desc.cDepthStencilState.format = kDepthFormat; desc.cDepthStencilState.format = kDepthFormat;
desc.cDepthStencilState.depthWriteEnabled = true; desc.cDepthStencilState.depthWriteEnabled = true;

View File

@ -198,7 +198,7 @@ class PrimitiveTopologyTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor); wgpu::RenderPipeline pipeline = device.CreateRenderPipeline(&descriptor);

View File

@ -56,7 +56,7 @@ class RenderBundleTest : public DawnTest {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); descriptor.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cColorStates[0].format = renderPass.colorFormat; descriptor.cColorStates[0].format = renderPass.colorFormat;
pipeline = device.CreateRenderPipeline(&descriptor); pipeline = device.CreateRenderPipeline(&descriptor);

View File

@ -71,10 +71,10 @@ class SamplerFilterAnisotropicTest : public DawnTest {
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
vertexState.cVertexBuffers[0].attributeCount = 2; vertexState.cVertexBuffers[0].attributeCount = 2;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; vertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
vertexState.cAttributes[1].shaderLocation = 1; vertexState.cAttributes[1].shaderLocation = 1;
vertexState.cAttributes[1].offset = 4 * sizeof(float); vertexState.cAttributes[1].offset = 4 * sizeof(float);
vertexState.cAttributes[1].format = wgpu::VertexFormat::Float2; vertexState.cAttributes[1].format = wgpu::VertexFormat::Float32x2;
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = 6 * sizeof(float); vertexState.cVertexBuffers[0].arrayStride = 6 * sizeof(float);

View File

@ -99,7 +99,7 @@ TEST_P(VertexBufferRobustnessTest, DetectInvalidValues) {
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = sizeof(float); vertexState.cVertexBuffers[0].arrayStride = sizeof(float);
vertexState.cVertexBuffers[0].attributeCount = 1; vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float; vertexState.cAttributes[0].format = wgpu::VertexFormat::Float32;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;
@ -116,7 +116,7 @@ TEST_P(VertexBufferRobustnessTest, FloatClamp) {
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = sizeof(float); vertexState.cVertexBuffers[0].arrayStride = sizeof(float);
vertexState.cVertexBuffers[0].attributeCount = 1; vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float; vertexState.cAttributes[0].format = wgpu::VertexFormat::Float32;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;
@ -133,7 +133,7 @@ TEST_P(VertexBufferRobustnessTest, IntClamp) {
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = sizeof(int32_t); vertexState.cVertexBuffers[0].arrayStride = sizeof(int32_t);
vertexState.cVertexBuffers[0].attributeCount = 1; vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Int; vertexState.cAttributes[0].format = wgpu::VertexFormat::Sint32;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;
@ -150,7 +150,7 @@ TEST_P(VertexBufferRobustnessTest, UIntClamp) {
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = sizeof(uint32_t); vertexState.cVertexBuffers[0].arrayStride = sizeof(uint32_t);
vertexState.cVertexBuffers[0].attributeCount = 1; vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = wgpu::VertexFormat::UInt; vertexState.cAttributes[0].format = wgpu::VertexFormat::Uint32;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;
@ -167,7 +167,7 @@ TEST_P(VertexBufferRobustnessTest, Float2Clamp) {
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = sizeof(float) * 2; vertexState.cVertexBuffers[0].arrayStride = sizeof(float) * 2;
vertexState.cVertexBuffers[0].attributeCount = 1; vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float2; vertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;
@ -185,7 +185,7 @@ TEST_P(VertexBufferRobustnessTest, Float3Clamp) {
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = sizeof(float) * 3; vertexState.cVertexBuffers[0].arrayStride = sizeof(float) * 3;
vertexState.cVertexBuffers[0].attributeCount = 1; vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float3; vertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x3;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;
@ -203,7 +203,7 @@ TEST_P(VertexBufferRobustnessTest, Float4Clamp) {
vertexState.vertexBufferCount = 1; vertexState.vertexBufferCount = 1;
vertexState.cVertexBuffers[0].arrayStride = sizeof(float) * 4; vertexState.cVertexBuffers[0].arrayStride = sizeof(float) * 4;
vertexState.cVertexBuffers[0].attributeCount = 1; vertexState.cVertexBuffers[0].attributeCount = 1;
vertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; vertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;

View File

@ -56,14 +56,14 @@ class VertexFormatTest : public DawnTest {
bool IsNormalizedFormat(wgpu::VertexFormat format) { bool IsNormalizedFormat(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
return true; return true;
default: default:
return false; return false;
@ -72,18 +72,18 @@ class VertexFormatTest : public DawnTest {
bool IsUnsignedFormat(wgpu::VertexFormat format) { bool IsUnsignedFormat(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Uint32:
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Uint32x2:
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x4:
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Unorm16x4:
return true; return true;
default: default:
return false; return false;
@ -92,12 +92,12 @@ class VertexFormatTest : public DawnTest {
bool IsFloatFormat(wgpu::VertexFormat format) { bool IsFloatFormat(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Float32:
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Float32x2:
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Float32x3:
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Float32x4:
return true; return true;
default: default:
return false; return false;
@ -106,8 +106,8 @@ class VertexFormatTest : public DawnTest {
bool IsHalfFormat(wgpu::VertexFormat format) { bool IsHalfFormat(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
return true; return true;
default: default:
return false; return false;
@ -116,38 +116,38 @@ class VertexFormatTest : public DawnTest {
uint32_t BytesPerComponents(wgpu::VertexFormat format) { uint32_t BytesPerComponents(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Sint8x2:
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Sint8x4:
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm8x4:
return 1; return 1;
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Unorm16x4:
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Sint16x2:
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Sint16x4:
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Snorm16x4:
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Float16x4:
return 2; return 2;
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Float32:
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Float32x2:
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Float32x3:
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Float32x4:
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32:
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Uint32x2:
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Uint32x3:
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Uint32x4:
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint32:
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Sint32x2:
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Sint32x3:
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Sint32x4:
return 4; return 4;
default: default:
DAWN_UNREACHABLE(); DAWN_UNREACHABLE();
@ -156,39 +156,39 @@ class VertexFormatTest : public DawnTest {
uint32_t ComponentCount(wgpu::VertexFormat format) { uint32_t ComponentCount(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case wgpu::VertexFormat::UInt: case wgpu::VertexFormat::Float32:
case wgpu::VertexFormat::Int: case wgpu::VertexFormat::Uint32:
case wgpu::VertexFormat::Float: case wgpu::VertexFormat::Sint32:
return 1; return 1;
case wgpu::VertexFormat::UChar2: case wgpu::VertexFormat::Uint8x2:
case wgpu::VertexFormat::UShort2: case wgpu::VertexFormat::Sint8x2:
case wgpu::VertexFormat::UInt2: case wgpu::VertexFormat::Unorm8x2:
case wgpu::VertexFormat::Char2: case wgpu::VertexFormat::Snorm8x2:
case wgpu::VertexFormat::Short2: case wgpu::VertexFormat::Uint16x2:
case wgpu::VertexFormat::Int2: case wgpu::VertexFormat::Sint16x2:
case wgpu::VertexFormat::UChar2Norm: case wgpu::VertexFormat::Unorm16x2:
case wgpu::VertexFormat::Char2Norm: case wgpu::VertexFormat::Snorm16x2:
case wgpu::VertexFormat::UShort2Norm: case wgpu::VertexFormat::Float16x2:
case wgpu::VertexFormat::Short2Norm: case wgpu::VertexFormat::Float32x2:
case wgpu::VertexFormat::Half2: case wgpu::VertexFormat::Uint32x2:
case wgpu::VertexFormat::Float2: case wgpu::VertexFormat::Sint32x2:
return 2; return 2;
case wgpu::VertexFormat::Int3: case wgpu::VertexFormat::Float32x3:
case wgpu::VertexFormat::UInt3: case wgpu::VertexFormat::Uint32x3:
case wgpu::VertexFormat::Float3: case wgpu::VertexFormat::Sint32x3:
return 3; return 3;
case wgpu::VertexFormat::UChar4: case wgpu::VertexFormat::Uint8x4:
case wgpu::VertexFormat::UShort4: case wgpu::VertexFormat::Sint8x4:
case wgpu::VertexFormat::UInt4: case wgpu::VertexFormat::Unorm8x4:
case wgpu::VertexFormat::Char4: case wgpu::VertexFormat::Snorm8x4:
case wgpu::VertexFormat::Short4: case wgpu::VertexFormat::Uint16x4:
case wgpu::VertexFormat::Int4: case wgpu::VertexFormat::Sint16x4:
case wgpu::VertexFormat::UChar4Norm: case wgpu::VertexFormat::Unorm16x4:
case wgpu::VertexFormat::Char4Norm: case wgpu::VertexFormat::Snorm16x4:
case wgpu::VertexFormat::UShort4Norm: case wgpu::VertexFormat::Float16x4:
case wgpu::VertexFormat::Short4Norm: case wgpu::VertexFormat::Float32x4:
case wgpu::VertexFormat::Half4: case wgpu::VertexFormat::Uint32x4:
case wgpu::VertexFormat::Float4: case wgpu::VertexFormat::Sint32x4:
return 4; return 4;
default: default:
DAWN_UNREACHABLE(); DAWN_UNREACHABLE();
@ -399,7 +399,7 @@ class VertexFormatTest : public DawnTest {
} }
}; };
TEST_P(VertexFormatTest, UChar2) { TEST_P(VertexFormatTest, Uint8x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -423,10 +423,10 @@ TEST_P(VertexFormatTest, UChar2) {
std::numeric_limits<uint8_t>::max(), 0, std::numeric_limits<uint8_t>::min(), 2, 200, 201, std::numeric_limits<uint8_t>::max(), 0, std::numeric_limits<uint8_t>::min(), 2, 200, 201,
}; };
DoVertexFormatTest(wgpu::VertexFormat::UChar2, vertexData, expectedData); DoVertexFormatTest(wgpu::VertexFormat::Uint8x2, vertexData, expectedData);
} }
TEST_P(VertexFormatTest, UChar4) { TEST_P(VertexFormatTest, Uint8x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -446,10 +446,10 @@ TEST_P(VertexFormatTest, UChar4) {
203, 203,
}; };
DoVertexFormatTest(wgpu::VertexFormat::UChar4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Uint8x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Char2) { TEST_P(VertexFormatTest, Sint8x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -473,10 +473,10 @@ TEST_P(VertexFormatTest, Char2) {
std::numeric_limits<int8_t>::max(), 0, std::numeric_limits<int8_t>::min(), -2, 120, -121, std::numeric_limits<int8_t>::max(), 0, std::numeric_limits<int8_t>::min(), -2, 120, -121,
}; };
DoVertexFormatTest(wgpu::VertexFormat::Char2, vertexData, expectedData); DoVertexFormatTest(wgpu::VertexFormat::Sint8x2, vertexData, expectedData);
} }
TEST_P(VertexFormatTest, Char4) { TEST_P(VertexFormatTest, Sint8x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -496,10 +496,10 @@ TEST_P(VertexFormatTest, Char4) {
-123, -123,
}; };
DoVertexFormatTest(wgpu::VertexFormat::Char4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Sint8x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UChar2Norm) { TEST_P(VertexFormatTest, Unorm8x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -526,10 +526,10 @@ TEST_P(VertexFormatTest, UChar2Norm) {
200, 200,
201}; 201};
DoVertexFormatTest(wgpu::VertexFormat::UChar2Norm, vertexData, expectedData); DoVertexFormatTest(wgpu::VertexFormat::Unorm8x2, vertexData, expectedData);
} }
TEST_P(VertexFormatTest, UChar4Norm) { TEST_P(VertexFormatTest, Unorm8x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -547,10 +547,10 @@ TEST_P(VertexFormatTest, UChar4Norm) {
202, 202,
203}; 203};
DoVertexFormatTest(wgpu::VertexFormat::UChar4Norm, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Unorm8x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Char2Norm) { TEST_P(VertexFormatTest, Snorm8x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -579,10 +579,10 @@ TEST_P(VertexFormatTest, Char2Norm) {
-121, -121,
}; };
DoVertexFormatTest(wgpu::VertexFormat::Char2Norm, vertexData, expectedData); DoVertexFormatTest(wgpu::VertexFormat::Snorm8x2, vertexData, expectedData);
} }
TEST_P(VertexFormatTest, Char4Norm) { TEST_P(VertexFormatTest, Snorm8x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -600,10 +600,10 @@ TEST_P(VertexFormatTest, Char4Norm) {
102, 102,
-123}; -123};
DoVertexFormatTest(wgpu::VertexFormat::Char4Norm, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Snorm8x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UShort2) { TEST_P(VertexFormatTest, Uint16x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -615,10 +615,10 @@ TEST_P(VertexFormatTest, UShort2) {
65432, 65432,
4890}; 4890};
DoVertexFormatTest(wgpu::VertexFormat::UShort2, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Uint16x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UShort4) { TEST_P(VertexFormatTest, Uint16x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -638,10 +638,10 @@ TEST_P(VertexFormatTest, UShort4) {
3467, 3467,
}; };
DoVertexFormatTest(wgpu::VertexFormat::UShort4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Uint16x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Short2) { TEST_P(VertexFormatTest, Sint16x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -653,10 +653,10 @@ TEST_P(VertexFormatTest, Short2) {
3876, 3876,
-3948}; -3948};
DoVertexFormatTest(wgpu::VertexFormat::Short2, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Sint16x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Short4) { TEST_P(VertexFormatTest, Sint16x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -676,10 +676,10 @@ TEST_P(VertexFormatTest, Short4) {
-2987, -2987,
}; };
DoVertexFormatTest(wgpu::VertexFormat::Short4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Sint16x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UShort2Norm) { TEST_P(VertexFormatTest, Unorm16x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -691,10 +691,10 @@ TEST_P(VertexFormatTest, UShort2Norm) {
3456, 3456,
6543}; 6543};
DoVertexFormatTest(wgpu::VertexFormat::UShort2Norm, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Unorm16x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UShort4Norm) { TEST_P(VertexFormatTest, Unorm16x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -712,10 +712,10 @@ TEST_P(VertexFormatTest, UShort4Norm) {
2987, 2987,
2987}; 2987};
DoVertexFormatTest(wgpu::VertexFormat::UShort4Norm, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Unorm16x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Short2Norm) { TEST_P(VertexFormatTest, Snorm16x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -727,10 +727,10 @@ TEST_P(VertexFormatTest, Short2Norm) {
4987, 4987,
-6789}; -6789};
DoVertexFormatTest(wgpu::VertexFormat::Short2Norm, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Snorm16x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Short4Norm) { TEST_P(VertexFormatTest, Snorm16x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -748,10 +748,10 @@ TEST_P(VertexFormatTest, Short4Norm) {
20432, 20432,
-2083}; -2083};
DoVertexFormatTest(wgpu::VertexFormat::Short4Norm, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Snorm16x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Half2) { TEST_P(VertexFormatTest, Float16x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -759,10 +759,10 @@ TEST_P(VertexFormatTest, Half2) {
std::vector<uint16_t> vertexData = std::vector<uint16_t> vertexData =
Float32ToFloat16(std::vector<float>({14.8f, -0.0f, 22.5f, 1.3f, +0.0f, -24.8f})); Float32ToFloat16(std::vector<float>({14.8f, -0.0f, 22.5f, 1.3f, +0.0f, -24.8f}));
DoVertexFormatTest(wgpu::VertexFormat::Half2, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Float16x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Half4) { TEST_P(VertexFormatTest, Float16x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -770,34 +770,34 @@ TEST_P(VertexFormatTest, Half4) {
std::vector<uint16_t> vertexData = Float32ToFloat16(std::vector<float>( std::vector<uint16_t> vertexData = Float32ToFloat16(std::vector<float>(
{+0.0f, -16.8f, 18.2f, -0.0f, 12.5f, 1.3f, 14.8f, -12.4f, 22.5f, -48.8f, 47.4f, -24.8f})); {+0.0f, -16.8f, 18.2f, -0.0f, 12.5f, 1.3f, 14.8f, -12.4f, 22.5f, -48.8f, 47.4f, -24.8f}));
DoVertexFormatTest(wgpu::VertexFormat::Half4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Float16x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Float) { TEST_P(VertexFormatTest, Float32) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
std::vector<float> vertexData = {1.3f, +0.0f, -0.0f}; std::vector<float> vertexData = {1.3f, +0.0f, -0.0f};
DoVertexFormatTest(wgpu::VertexFormat::Float, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Float32, vertexData, vertexData);
vertexData = std::vector<float>{+1.0f, -1.0f, 18.23f}; vertexData = std::vector<float>{+1.0f, -1.0f, 18.23f};
DoVertexFormatTest(wgpu::VertexFormat::Float, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Float32, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Float2) { TEST_P(VertexFormatTest, Float32x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
std::vector<float> vertexData = {18.23f, -0.0f, +0.0f, +1.0f, 1.3f, -1.0f}; std::vector<float> vertexData = {18.23f, -0.0f, +0.0f, +1.0f, 1.3f, -1.0f};
DoVertexFormatTest(wgpu::VertexFormat::Float2, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Float32x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Float3) { TEST_P(VertexFormatTest, Float32x3) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -806,10 +806,10 @@ TEST_P(VertexFormatTest, Float3) {
+0.0f, -1.0f, -0.0f, 1.0f, 1.3f, 99.45f, 23.6f, -81.2f, 55.0f, +0.0f, -1.0f, -0.0f, 1.0f, 1.3f, 99.45f, 23.6f, -81.2f, 55.0f,
}; };
DoVertexFormatTest(wgpu::VertexFormat::Float3, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Float32x3, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Float4) { TEST_P(VertexFormatTest, Float32x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -818,10 +818,10 @@ TEST_P(VertexFormatTest, Float4) {
19.2f, -19.3f, +0.0f, 1.0f, -0.0f, 1.0f, 1.3f, -1.0f, 13.078f, 21.1965f, -1.1f, -1.2f, 19.2f, -19.3f, +0.0f, 1.0f, -0.0f, 1.0f, 1.3f, -1.0f, 13.078f, 21.1965f, -1.1f, -1.2f,
}; };
DoVertexFormatTest(wgpu::VertexFormat::Float4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Float32x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UInt) { TEST_P(VertexFormatTest, Uint32) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -830,10 +830,10 @@ TEST_P(VertexFormatTest, UInt) {
std::numeric_limits<uint16_t>::max(), std::numeric_limits<uint16_t>::max(),
std::numeric_limits<uint8_t>::max()}; std::numeric_limits<uint8_t>::max()};
DoVertexFormatTest(wgpu::VertexFormat::UInt, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Uint32, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UInt2) { TEST_P(VertexFormatTest, Uint32x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -842,10 +842,10 @@ TEST_P(VertexFormatTest, UInt2) {
std::numeric_limits<uint16_t>::max(), 64, std::numeric_limits<uint16_t>::max(), 64,
std::numeric_limits<uint8_t>::max(), 128}; std::numeric_limits<uint8_t>::max(), 128};
DoVertexFormatTest(wgpu::VertexFormat::UInt2, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Uint32x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UInt3) { TEST_P(VertexFormatTest, Uint32x3) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -854,10 +854,10 @@ TEST_P(VertexFormatTest, UInt3) {
std::numeric_limits<uint16_t>::max(), 164, 128, std::numeric_limits<uint16_t>::max(), 164, 128,
std::numeric_limits<uint8_t>::max(), 1283, 256}; std::numeric_limits<uint8_t>::max(), 1283, 256};
DoVertexFormatTest(wgpu::VertexFormat::UInt3, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Uint32x3, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, UInt4) { TEST_P(VertexFormatTest, Uint32x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -866,10 +866,10 @@ TEST_P(VertexFormatTest, UInt4) {
std::numeric_limits<uint16_t>::max(), 164, 128, 0, std::numeric_limits<uint16_t>::max(), 164, 128, 0,
std::numeric_limits<uint8_t>::max(), 1283, 256, 4567}; std::numeric_limits<uint8_t>::max(), 1283, 256, 4567};
DoVertexFormatTest(wgpu::VertexFormat::UInt4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Uint32x4, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Int) { TEST_P(VertexFormatTest, Sint32) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -878,10 +878,10 @@ TEST_P(VertexFormatTest, Int) {
std::numeric_limits<int32_t>::min(), std::numeric_limits<int32_t>::min(),
std::numeric_limits<int8_t>::max()}; std::numeric_limits<int8_t>::max()};
DoVertexFormatTest(wgpu::VertexFormat::Int, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Sint32, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Int2) { TEST_P(VertexFormatTest, Sint32x2) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -891,10 +891,10 @@ TEST_P(VertexFormatTest, Int2) {
std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min(), std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min(),
std::numeric_limits<int8_t>::max(), std::numeric_limits<int8_t>::min()}; std::numeric_limits<int8_t>::max(), std::numeric_limits<int8_t>::min()};
DoVertexFormatTest(wgpu::VertexFormat::Int2, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Sint32x2, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Int3) { TEST_P(VertexFormatTest, Sint32x3) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -904,10 +904,10 @@ TEST_P(VertexFormatTest, Int3) {
std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min(), 128, std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min(), 128,
std::numeric_limits<int8_t>::max(), std::numeric_limits<int8_t>::min(), 256}; std::numeric_limits<int8_t>::max(), std::numeric_limits<int8_t>::min(), 256};
DoVertexFormatTest(wgpu::VertexFormat::Int3, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Sint32x3, vertexData, vertexData);
} }
TEST_P(VertexFormatTest, Int4) { TEST_P(VertexFormatTest, Sint32x4) {
// TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue. // TODO(cwallez@chromium.org): Failing because of a SPIRV-Cross issue.
// See http://crbug.com/dawn/259 // See http://crbug.com/dawn/259
DAWN_SKIP_TEST_IF(IsMetal() && IsIntel()); DAWN_SKIP_TEST_IF(IsMetal() && IsIntel());
@ -917,7 +917,7 @@ TEST_P(VertexFormatTest, Int4) {
std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min(), -128, 0, std::numeric_limits<int16_t>::max(), std::numeric_limits<int16_t>::min(), -128, 0,
std::numeric_limits<int8_t>::max(), std::numeric_limits<int8_t>::min(), 256, -4567}; std::numeric_limits<int8_t>::max(), std::numeric_limits<int8_t>::min(), 256, -4567};
DoVertexFormatTest(wgpu::VertexFormat::Int4, vertexData, vertexData); DoVertexFormatTest(wgpu::VertexFormat::Sint32x4, vertexData, vertexData);
} }
DAWN_INSTANTIATE_TEST(VertexFormatTest, DAWN_INSTANTIATE_TEST(VertexFormatTest,

View File

@ -46,15 +46,15 @@ class VertexStateTest : public DawnTest {
bool ShouldComponentBeDefault(VertexFormat format, int component) { bool ShouldComponentBeDefault(VertexFormat format, int component) {
EXPECT_TRUE(component >= 0 && component < 4); EXPECT_TRUE(component >= 0 && component < 4);
switch (format) { switch (format) {
case VertexFormat::Float4: case VertexFormat::Float32x4:
case VertexFormat::UChar4Norm: case VertexFormat::Unorm8x4:
return component >= 4; return component >= 4;
case VertexFormat::Float3: case VertexFormat::Float32x3:
return component >= 3; return component >= 3;
case VertexFormat::Float2: case VertexFormat::Float32x2:
case VertexFormat::UChar2Norm: case VertexFormat::Unorm8x2:
return component >= 2; return component >= 2;
case VertexFormat::Float: case VertexFormat::Float32:
return component >= 1; return component >= 1;
default: default:
DAWN_UNREACHABLE(); DAWN_UNREACHABLE();
@ -236,10 +236,10 @@ class VertexStateTest : public DawnTest {
// Test compilation and usage of the fixture :) // Test compilation and usage of the fixture :)
TEST_P(VertexStateTest, Basic) { TEST_P(VertexStateTest, Basic) {
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
MakeVertexState({{4 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}}, MakeVertexState({{4 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}},
&vertexState); &vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
// clang-format off // clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({ wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@ -257,9 +257,9 @@ TEST_P(VertexStateTest, ZeroStride) {
DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL()); DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL());
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}}, &vertexState); MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}}, &vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float4, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({ wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
0, 0,
@ -278,9 +278,10 @@ TEST_P(VertexStateTest, AttributeExpanding) {
// R32F case // R32F case
{ {
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float}}}}, &vertexState); MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32}}}},
&vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3}); wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
@ -288,9 +289,10 @@ TEST_P(VertexStateTest, AttributeExpanding) {
// RG32F case // RG32F case
{ {
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float2}}}}, &vertexState); MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x2}}}},
&vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float2, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32x2, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3}); wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
@ -298,9 +300,10 @@ TEST_P(VertexStateTest, AttributeExpanding) {
// RGB32F case // RGB32F case
{ {
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float3}}}}, &vertexState); MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x3}}}},
&vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float3, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32x3, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3}); wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{0, &buffer0}});
@ -313,10 +316,10 @@ TEST_P(VertexStateTest, StrideLargerThanAttributes) {
DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL()); DAWN_SKIP_TEST_IF(IsLinux() && IsOpenGL());
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
MakeVertexState({{8 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}}, MakeVertexState({{8 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}},
&vertexState); &vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
// clang-format off // clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({ wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@ -334,10 +337,10 @@ TEST_P(VertexStateTest, TwoAttributesAtAnOffsetVertex) {
MakeVertexState( MakeVertexState(
{{8 * sizeof(float), {{8 * sizeof(float),
InputStepMode::Vertex, InputStepMode::Vertex,
{{0, 0, VertexFormat::Float4}, {1, 4 * sizeof(float), VertexFormat::Float4}}}}, {{0, 0, VertexFormat::Float32x4}, {1, 4 * sizeof(float), VertexFormat::Float32x4}}}},
&vertexState); &vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
// clang-format off // clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({ wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@ -355,10 +358,10 @@ TEST_P(VertexStateTest, TwoAttributesAtAnOffsetInstance) {
MakeVertexState( MakeVertexState(
{{8 * sizeof(float), {{8 * sizeof(float),
InputStepMode::Instance, InputStepMode::Instance,
{{0, 0, VertexFormat::Float4}, {1, 4 * sizeof(float), VertexFormat::Float4}}}}, {{0, 0, VertexFormat::Float32x4}, {1, 4 * sizeof(float), VertexFormat::Float32x4}}}},
&vertexState); &vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}}); MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
// clang-format off // clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({ wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@ -373,10 +376,11 @@ TEST_P(VertexStateTest, TwoAttributesAtAnOffsetInstance) {
// Test a pure-instance input state // Test a pure-instance input state
TEST_P(VertexStateTest, PureInstance) { TEST_P(VertexStateTest, PureInstance) {
utils::ComboVertexStateDescriptor vertexState; utils::ComboVertexStateDescriptor vertexState;
MakeVertexState({{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float4}}}}, MakeVertexState(
{{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
&vertexState); &vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}}); MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
// clang-format off // clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({ wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@ -396,17 +400,17 @@ TEST_P(VertexStateTest, MixedEverything) {
MakeVertexState( MakeVertexState(
{{12 * sizeof(float), {{12 * sizeof(float),
InputStepMode::Vertex, InputStepMode::Vertex,
{{0, 0, VertexFormat::Float}, {1, 6 * sizeof(float), VertexFormat::Float2}}}, {{0, 0, VertexFormat::Float32}, {1, 6 * sizeof(float), VertexFormat::Float32x2}}},
{10 * sizeof(float), {10 * sizeof(float),
InputStepMode::Instance, InputStepMode::Instance,
{{2, 0, VertexFormat::Float3}, {3, 5 * sizeof(float), VertexFormat::Float4}}}}, {{2, 0, VertexFormat::Float32x3}, {3, 5 * sizeof(float), VertexFormat::Float32x4}}}},
&vertexState); &vertexState);
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 1, MakeTestPipeline(vertexState, 1,
{{0, VertexFormat::Float, InputStepMode::Vertex}, {{0, VertexFormat::Float32, InputStepMode::Vertex},
{1, VertexFormat::Float2, InputStepMode::Vertex}, {1, VertexFormat::Float32x2, InputStepMode::Vertex},
{2, VertexFormat::Float3, InputStepMode::Instance}, {2, VertexFormat::Float32x3, InputStepMode::Instance},
{3, VertexFormat::Float4, InputStepMode::Instance}}); {3, VertexFormat::Float32x4, InputStepMode::Instance}});
// clang-format off // clang-format off
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({ wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
@ -429,11 +433,12 @@ TEST_P(VertexStateTest, MixedEverything) {
TEST_P(VertexStateTest, UnusedVertexSlot) { TEST_P(VertexStateTest, UnusedVertexSlot) {
// Instance input state, using slot 1 // Instance input state, using slot 1
utils::ComboVertexStateDescriptor instanceVertexState; utils::ComboVertexStateDescriptor instanceVertexState;
MakeVertexState({{0, InputStepMode::Vertex, {}}, MakeVertexState(
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float4}}}}, {{0, InputStepMode::Vertex, {}},
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
&instanceVertexState); &instanceVertexState);
wgpu::RenderPipeline instancePipeline = MakeTestPipeline( wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
instanceVertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}}); instanceVertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
// clang-format off // clang-format off
wgpu::Buffer buffer = MakeVertexBuffer<float>({ wgpu::Buffer buffer = MakeVertexBuffer<float>({
@ -469,18 +474,19 @@ TEST_P(VertexStateTest, UnusedVertexSlot) {
TEST_P(VertexStateTest, MultiplePipelinesMixedVertexState) { TEST_P(VertexStateTest, MultiplePipelinesMixedVertexState) {
// Basic input state, using slot 0 // Basic input state, using slot 0
utils::ComboVertexStateDescriptor vertexVertexState; utils::ComboVertexStateDescriptor vertexVertexState;
MakeVertexState({{4 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float4}}}}, MakeVertexState({{4 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}},
&vertexVertexState); &vertexVertexState);
wgpu::RenderPipeline vertexPipeline = wgpu::RenderPipeline vertexPipeline = MakeTestPipeline(
MakeTestPipeline(vertexVertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}}); vertexVertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
// Instance input state, using slot 1 // Instance input state, using slot 1
utils::ComboVertexStateDescriptor instanceVertexState; utils::ComboVertexStateDescriptor instanceVertexState;
MakeVertexState({{0, InputStepMode::Instance, {}}, MakeVertexState(
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float4}}}}, {{0, InputStepMode::Instance, {}},
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
&instanceVertexState); &instanceVertexState);
wgpu::RenderPipeline instancePipeline = MakeTestPipeline( wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
instanceVertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Instance}}); instanceVertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
// clang-format off // clang-format off
wgpu::Buffer buffer = MakeVertexBuffer<float>({ wgpu::Buffer buffer = MakeVertexBuffer<float>({
@ -525,10 +531,10 @@ TEST_P(VertexStateTest, LastAllowedVertexBuffer) {
vertexState.cVertexBuffers[kBufferIndex].attributes = &vertexState.cAttributes[0]; vertexState.cVertexBuffers[kBufferIndex].attributes = &vertexState.cAttributes[0];
vertexState.cAttributes[0].shaderLocation = 0; vertexState.cAttributes[0].shaderLocation = 0;
vertexState.cAttributes[0].offset = 0; vertexState.cAttributes[0].offset = 0;
vertexState.cAttributes[0].format = VertexFormat::Float4; vertexState.cAttributes[0].format = VertexFormat::Float32x4;
wgpu::RenderPipeline pipeline = wgpu::RenderPipeline pipeline =
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}}); MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5}); wgpu::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5});
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{kMaxVertexBuffers - 1, &buffer0}}); DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{kMaxVertexBuffers - 1, &buffer0}});
@ -543,10 +549,10 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
InputStepMode::Vertex, InputStepMode::Vertex,
{ {
// "****" represents the bytes we'll actually read in the shader. // "****" represents the bytes we'll actually read in the shader.
{0, 0 /* offset */, VertexFormat::Float4}, // |****|----|----|----| {0, 0 /* offset */, VertexFormat::Float32x4}, // |****|----|----|----|
{1, 4 /* offset */, VertexFormat::UInt2}, // |****|****| {1, 4 /* offset */, VertexFormat::Uint32x2}, // |****|****|
{2, 8 /* offset */, VertexFormat::Half4}, // |-----****| {2, 8 /* offset */, VertexFormat::Float16x4}, // |-----****|
{3, 0 /* offset */, VertexFormat::Float}, // |****| {3, 0 /* offset */, VertexFormat::Float32}, // |****|
}}}, }}},
&vertexState); &vertexState);

View File

@ -355,7 +355,7 @@ void DrawCallPerf::SetUp() {
renderPipelineDesc.cVertexState.vertexBufferCount = 1; renderPipelineDesc.cVertexState.vertexBufferCount = 1;
renderPipelineDesc.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float); renderPipelineDesc.cVertexState.cVertexBuffers[0].arrayStride = 4 * sizeof(float);
renderPipelineDesc.cVertexState.cVertexBuffers[0].attributeCount = 1; renderPipelineDesc.cVertexState.cVertexBuffers[0].attributeCount = 1;
renderPipelineDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; renderPipelineDesc.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
renderPipelineDesc.depthStencilState = &renderPipelineDesc.cDepthStencilState; renderPipelineDesc.depthStencilState = &renderPipelineDesc.cDepthStencilState;
renderPipelineDesc.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8; renderPipelineDesc.cDepthStencilState.format = wgpu::TextureFormat::Depth24PlusStencil8;
renderPipelineDesc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm; renderPipelineDesc.cColorStates[0].format = wgpu::TextureFormat::RGBA8Unorm;

View File

@ -106,7 +106,7 @@ namespace {
descriptor->cVertexState.vertexBufferCount = 1; descriptor->cVertexState.vertexBufferCount = 1;
descriptor->cVertexState.cVertexBuffers[0].arrayStride = 2 * sizeof(float); descriptor->cVertexState.cVertexBuffers[0].arrayStride = 2 * sizeof(float);
descriptor->cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor->cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor->cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float2; descriptor->cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
descriptor->cVertexState.cAttributes[0].shaderLocation = 0; descriptor->cVertexState.cAttributes[0].shaderLocation = 0;
} }

View File

@ -646,7 +646,7 @@ TEST_F(RenderPipelineValidationTest, VertexAttribCorrectEntryPoint) {
descriptor.cVertexState.vertexBufferCount = 1; descriptor.cVertexState.vertexBufferCount = 1;
descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1; descriptor.cVertexState.cVertexBuffers[0].attributeCount = 1;
descriptor.cVertexState.cVertexBuffers[0].arrayStride = 16; descriptor.cVertexState.cVertexBuffers[0].arrayStride = 16;
descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float4; descriptor.cVertexState.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
descriptor.cVertexState.cAttributes[0].offset = 0; descriptor.cVertexState.cAttributes[0].offset = 0;
// Success cases, the attribute used by the entryPoint is declared in the pipeline. // Success cases, the attribute used by the entryPoint is declared in the pipeline.

View File

@ -73,7 +73,7 @@ class VertexBufferValidationTest : public ValidationTest {
descriptor.cVertexState.cVertexBuffers[i].attributes = descriptor.cVertexState.cVertexBuffers[i].attributes =
&descriptor.cVertexState.cAttributes[i]; &descriptor.cVertexState.cAttributes[i];
descriptor.cVertexState.cAttributes[i].shaderLocation = i; descriptor.cVertexState.cAttributes[i].shaderLocation = i;
descriptor.cVertexState.cAttributes[i].format = wgpu::VertexFormat::Float3; descriptor.cVertexState.cAttributes[i].format = wgpu::VertexFormat::Float32x3;
} }
descriptor.cVertexState.vertexBufferCount = bufferCount; descriptor.cVertexState.vertexBufferCount = bufferCount;

View File

@ -284,7 +284,7 @@ TEST_F(VertexStateTest, SetAttributeOffsetOutOfBounds) {
utils::ComboVertexStateDescriptor state; utils::ComboVertexStateDescriptor state;
state.vertexBufferCount = 1; state.vertexBufferCount = 1;
state.cVertexBuffers[0].attributeCount = 1; state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].offset = kMaxVertexBufferStride - sizeof(wgpu::VertexFormat::Float); state.cAttributes[0].offset = kMaxVertexBufferStride - sizeof(wgpu::VertexFormat::Float32);
CreatePipeline(true, state, kDummyVertexShader); CreatePipeline(true, state, kDummyVertexShader);
// Test attribute offset out of bounds // Test attribute offset out of bounds
@ -321,6 +321,6 @@ TEST_F(VertexStateTest, VertexFormatLargerThanNonZeroStride) {
state.vertexBufferCount = 1; state.vertexBufferCount = 1;
state.cVertexBuffers[0].arrayStride = 4; state.cVertexBuffers[0].arrayStride = 4;
state.cVertexBuffers[0].attributeCount = 1; state.cVertexBuffers[0].attributeCount = 1;
state.cAttributes[0].format = wgpu::VertexFormat::Float4; state.cAttributes[0].format = wgpu::VertexFormat::Float32x4;
CreatePipeline(false, state, kDummyVertexShader); CreatePipeline(false, state, kDummyVertexShader);
} }

View File

@ -28,7 +28,7 @@ namespace utils {
wgpu::VertexAttributeDescriptor vertexAttribute; wgpu::VertexAttributeDescriptor vertexAttribute;
vertexAttribute.shaderLocation = 0; vertexAttribute.shaderLocation = 0;
vertexAttribute.offset = 0; vertexAttribute.offset = 0;
vertexAttribute.format = wgpu::VertexFormat::Float; vertexAttribute.format = wgpu::VertexFormat::Float32;
for (uint32_t i = 0; i < kMaxVertexAttributes; ++i) { for (uint32_t i = 0; i < kMaxVertexAttributes; ++i) {
cAttributes[i] = vertexAttribute; cAttributes[i] = vertexAttribute;
} }