wgpu::InputStepMode -> VertexStepMode
See https://github.com/gpuweb/gpuweb/pull/1927 Adds a typedef to make a gradual deprecation. Bug: dawn:1023 Change-Id: Ic81a933a95556fbf5726056530788dde017a1449 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/59442 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Stephen White <senorblanco@chromium.org> Commit-Queue: Corentin Wallez <cwallez@chromium.org>
This commit is contained in:
parent
f004b6ec2a
commit
ff6c9ca6f0
|
@ -1032,7 +1032,7 @@
|
||||||
"extensible": false,
|
"extensible": false,
|
||||||
"members": [
|
"members": [
|
||||||
{"name": "array stride", "type": "uint64_t"},
|
{"name": "array stride", "type": "uint64_t"},
|
||||||
{"name": "step mode", "type": "input step mode", "default": "vertex"},
|
{"name": "step mode", "type": "vertex step mode", "default": "vertex"},
|
||||||
{"name": "attribute count", "type": "uint32_t"},
|
{"name": "attribute count", "type": "uint32_t"},
|
||||||
{"name": "attributes", "type": "vertex attribute", "annotation": "const*", "length": "attribute count"}
|
{"name": "attributes", "type": "vertex attribute", "annotation": "const*", "length": "attribute count"}
|
||||||
]
|
]
|
||||||
|
@ -1042,6 +1042,10 @@
|
||||||
"type": "vertex buffer layout"
|
"type": "vertex buffer layout"
|
||||||
},
|
},
|
||||||
"input step mode": {
|
"input step mode": {
|
||||||
|
"category": "typedef",
|
||||||
|
"type": "vertex step mode"
|
||||||
|
},
|
||||||
|
"vertex step mode": {
|
||||||
"category": "enum",
|
"category": "enum",
|
||||||
"values": [
|
"values": [
|
||||||
{"value": 0, "name": "vertex"},
|
{"value": 0, "name": "vertex"},
|
||||||
|
|
|
@ -127,7 +127,7 @@ void initRender() {
|
||||||
descriptor.vertex.module = vsModule;
|
descriptor.vertex.module = vsModule;
|
||||||
descriptor.vertex.bufferCount = 2;
|
descriptor.vertex.bufferCount = 2;
|
||||||
descriptor.cBuffers[0].arrayStride = sizeof(Particle);
|
descriptor.cBuffers[0].arrayStride = sizeof(Particle);
|
||||||
descriptor.cBuffers[0].stepMode = wgpu::InputStepMode::Instance;
|
descriptor.cBuffers[0].stepMode = wgpu::VertexStepMode::Instance;
|
||||||
descriptor.cBuffers[0].attributeCount = 2;
|
descriptor.cBuffers[0].attributeCount = 2;
|
||||||
descriptor.cAttributes[0].offset = offsetof(Particle, pos);
|
descriptor.cAttributes[0].offset = offsetof(Particle, pos);
|
||||||
descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
|
descriptor.cAttributes[0].format = wgpu::VertexFormat::Float32x2;
|
||||||
|
|
|
@ -64,7 +64,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
{% for typeDef in by_category["typedef"] %}
|
{% for typeDef in by_category["typedef"] if typeDef.type.category == "structure" %}
|
||||||
using {{as_cppType(typeDef.name)}} = {{as_cppType(typeDef.type.name)}};
|
using {{as_cppType(typeDef.name)}} = {{as_cppType(typeDef.type.name)}};
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
|
|
@ -74,7 +74,7 @@
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL)
|
#define WGPU_WHOLE_SIZE (0xffffffffffffffffULL)
|
||||||
// TODO(crbug.com/520): Remove WGPU_STRIDE_UNDEFINED in favor of WGPU_COPY_STRIDE_UNDEFINED.
|
// TODO(crbug.com/dawn/520): Remove WGPU_STRIDE_UNDEFINED in favor of WGPU_COPY_STRIDE_UNDEFINED.
|
||||||
#define WGPU_STRIDE_UNDEFINED (0xffffffffUL)
|
#define WGPU_STRIDE_UNDEFINED (0xffffffffUL)
|
||||||
#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL)
|
#define WGPU_COPY_STRIDE_UNDEFINED (0xffffffffUL)
|
||||||
|
|
||||||
|
@ -124,6 +124,11 @@ typedef struct WGPUChainedStruct {
|
||||||
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
// TODO(crbug.com/dawn/1023): Remove after the deprecation period.
|
||||||
|
#define WGPUInputStepMode_Vertex WGPUVertexStepMode_Vertex
|
||||||
|
#define WGPUInputStepMode_Instance WGPUVertexStepMode_Instance
|
||||||
|
#define WGPUInputStepMode_Force32 WGPUVertexStepMode_Force32
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -81,7 +81,7 @@ namespace dawn_native {
|
||||||
const VertexBufferLayout* buffer,
|
const VertexBufferLayout* buffer,
|
||||||
const EntryPointMetadata& metadata,
|
const EntryPointMetadata& metadata,
|
||||||
ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes>* attributesSetMask) {
|
ityp::bitset<VertexAttributeLocation, kMaxVertexAttributes>* attributesSetMask) {
|
||||||
DAWN_TRY(ValidateInputStepMode(buffer->stepMode));
|
DAWN_TRY(ValidateVertexStepMode(buffer->stepMode));
|
||||||
if (buffer->arrayStride > kMaxVertexBufferArrayStride) {
|
if (buffer->arrayStride > kMaxVertexBufferArrayStride) {
|
||||||
return DAWN_VALIDATION_ERROR("Setting arrayStride out of bounds");
|
return DAWN_VALIDATION_ERROR("Setting arrayStride out of bounds");
|
||||||
}
|
}
|
||||||
|
@ -411,10 +411,10 @@ namespace dawn_native {
|
||||||
mVertexBufferInfos[typedSlot].arrayStride = buffers[slot].arrayStride;
|
mVertexBufferInfos[typedSlot].arrayStride = buffers[slot].arrayStride;
|
||||||
mVertexBufferInfos[typedSlot].stepMode = buffers[slot].stepMode;
|
mVertexBufferInfos[typedSlot].stepMode = buffers[slot].stepMode;
|
||||||
switch (buffers[slot].stepMode) {
|
switch (buffers[slot].stepMode) {
|
||||||
case wgpu::InputStepMode::Vertex:
|
case wgpu::VertexStepMode::Vertex:
|
||||||
mVertexBufferSlotsUsedAsVertexBuffer.set(typedSlot);
|
mVertexBufferSlotsUsedAsVertexBuffer.set(typedSlot);
|
||||||
break;
|
break;
|
||||||
case wgpu::InputStepMode::Instance:
|
case wgpu::VertexStepMode::Instance:
|
||||||
mVertexBufferSlotsUsedAsInstanceBuffer.set(typedSlot);
|
mVertexBufferSlotsUsedAsInstanceBuffer.set(typedSlot);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -49,7 +49,7 @@ namespace dawn_native {
|
||||||
|
|
||||||
struct VertexBufferInfo {
|
struct VertexBufferInfo {
|
||||||
uint64_t arrayStride;
|
uint64_t arrayStride;
|
||||||
wgpu::InputStepMode stepMode;
|
wgpu::VertexStepMode stepMode;
|
||||||
};
|
};
|
||||||
|
|
||||||
class RenderPipelineBase : public PipelineBase {
|
class RenderPipelineBase : public PipelineBase {
|
||||||
|
|
|
@ -119,11 +119,11 @@ namespace dawn_native {
|
||||||
UNREACHABLE();
|
UNREACHABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
tint::transform::InputStepMode ToTintInputStepMode(wgpu::InputStepMode mode) {
|
tint::transform::InputStepMode ToTintVertexStepMode(wgpu::VertexStepMode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case wgpu::InputStepMode::Vertex:
|
case wgpu::VertexStepMode::Vertex:
|
||||||
return tint::transform::InputStepMode::kVertex;
|
return tint::transform::InputStepMode::kVertex;
|
||||||
case wgpu::InputStepMode::Instance:
|
case wgpu::VertexStepMode::Instance:
|
||||||
return tint::transform::InputStepMode::kInstance;
|
return tint::transform::InputStepMode::kInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1286,7 +1286,7 @@ namespace dawn_native {
|
||||||
const auto& vertexBuffer = vertexState.buffers[i];
|
const auto& vertexBuffer = vertexState.buffers[i];
|
||||||
tint::transform::VertexBufferLayoutDescriptor layout;
|
tint::transform::VertexBufferLayoutDescriptor layout;
|
||||||
layout.array_stride = vertexBuffer.arrayStride;
|
layout.array_stride = vertexBuffer.arrayStride;
|
||||||
layout.step_mode = ToTintInputStepMode(vertexBuffer.stepMode);
|
layout.step_mode = ToTintVertexStepMode(vertexBuffer.stepMode);
|
||||||
|
|
||||||
for (uint32_t j = 0; j < vertexBuffer.attributeCount; ++j) {
|
for (uint32_t j = 0; j < vertexBuffer.attributeCount; ++j) {
|
||||||
const auto& attribute = vertexBuffer.attributes[j];
|
const auto& attribute = vertexBuffer.attributes[j];
|
||||||
|
|
|
@ -96,11 +96,11 @@ namespace dawn_native { namespace d3d12 {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
D3D12_INPUT_CLASSIFICATION InputStepModeFunction(wgpu::InputStepMode mode) {
|
D3D12_INPUT_CLASSIFICATION VertexStepModeFunction(wgpu::VertexStepMode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case wgpu::InputStepMode::Vertex:
|
case wgpu::VertexStepMode::Vertex:
|
||||||
return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
|
return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
|
||||||
case wgpu::InputStepMode::Instance:
|
case wgpu::VertexStepMode::Instance:
|
||||||
return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA;
|
return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -463,7 +463,7 @@ namespace dawn_native { namespace d3d12 {
|
||||||
const VertexBufferInfo& input = GetVertexBuffer(attribute.vertexBufferSlot);
|
const VertexBufferInfo& input = GetVertexBuffer(attribute.vertexBufferSlot);
|
||||||
|
|
||||||
inputElementDescriptor.AlignedByteOffset = attribute.offset;
|
inputElementDescriptor.AlignedByteOffset = attribute.offset;
|
||||||
inputElementDescriptor.InputSlotClass = InputStepModeFunction(input.stepMode);
|
inputElementDescriptor.InputSlotClass = VertexStepModeFunction(input.stepMode);
|
||||||
if (inputElementDescriptor.InputSlotClass ==
|
if (inputElementDescriptor.InputSlotClass ==
|
||||||
D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA) {
|
D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA) {
|
||||||
inputElementDescriptor.InstanceDataStepRate = 0;
|
inputElementDescriptor.InstanceDataStepRate = 0;
|
||||||
|
|
|
@ -91,11 +91,11 @@ namespace dawn_native { namespace metal {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
MTLVertexStepFunction InputStepModeFunction(wgpu::InputStepMode mode) {
|
MTLVertexStepFunction VertexStepModeFunction(wgpu::VertexStepMode mode) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case wgpu::InputStepMode::Vertex:
|
case wgpu::VertexStepMode::Vertex:
|
||||||
return MTLVertexStepFunctionPerVertex;
|
return MTLVertexStepFunctionPerVertex;
|
||||||
case wgpu::InputStepMode::Instance:
|
case wgpu::VertexStepMode::Instance:
|
||||||
return MTLVertexStepFunctionPerInstance;
|
return MTLVertexStepFunctionPerInstance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -488,7 +488,7 @@ namespace dawn_native { namespace metal {
|
||||||
// multiple of 4 if it's not.
|
// multiple of 4 if it's not.
|
||||||
layoutDesc.stride = Align(maxArrayStride, 4);
|
layoutDesc.stride = Align(maxArrayStride, 4);
|
||||||
} else {
|
} else {
|
||||||
layoutDesc.stepFunction = InputStepModeFunction(info.stepMode);
|
layoutDesc.stepFunction = VertexStepModeFunction(info.stepMode);
|
||||||
layoutDesc.stepRate = 1;
|
layoutDesc.stepRate = 1;
|
||||||
layoutDesc.stride = info.arrayStride;
|
layoutDesc.stride = info.arrayStride;
|
||||||
}
|
}
|
||||||
|
|
|
@ -267,9 +267,9 @@ namespace dawn_native { namespace opengl {
|
||||||
gl.VertexAttribDivisor(glAttrib, 0xffffffff);
|
gl.VertexAttribDivisor(glAttrib, 0xffffffff);
|
||||||
} else {
|
} else {
|
||||||
switch (vertexBuffer.stepMode) {
|
switch (vertexBuffer.stepMode) {
|
||||||
case wgpu::InputStepMode::Vertex:
|
case wgpu::VertexStepMode::Vertex:
|
||||||
break;
|
break;
|
||||||
case wgpu::InputStepMode::Instance:
|
case wgpu::VertexStepMode::Instance:
|
||||||
gl.VertexAttribDivisor(glAttrib, 1);
|
gl.VertexAttribDivisor(glAttrib, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,11 +27,11 @@ namespace dawn_native { namespace vulkan {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
VkVertexInputRate VulkanInputRate(wgpu::InputStepMode stepMode) {
|
VkVertexInputRate VulkanInputRate(wgpu::VertexStepMode stepMode) {
|
||||||
switch (stepMode) {
|
switch (stepMode) {
|
||||||
case wgpu::InputStepMode::Vertex:
|
case wgpu::VertexStepMode::Vertex:
|
||||||
return VK_VERTEX_INPUT_RATE_VERTEX;
|
return VK_VERTEX_INPUT_RATE_VERTEX;
|
||||||
case wgpu::InputStepMode::Instance:
|
case wgpu::VertexStepMode::Instance:
|
||||||
return VK_VERTEX_INPUT_RATE_INSTANCE;
|
return VK_VERTEX_INPUT_RATE_INSTANCE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,8 +19,8 @@
|
||||||
#include "utils/ComboRenderPipelineDescriptor.h"
|
#include "utils/ComboRenderPipelineDescriptor.h"
|
||||||
#include "utils/WGPUHelpers.h"
|
#include "utils/WGPUHelpers.h"
|
||||||
|
|
||||||
using wgpu::InputStepMode;
|
|
||||||
using wgpu::VertexFormat;
|
using wgpu::VertexFormat;
|
||||||
|
using wgpu::VertexStepMode;
|
||||||
|
|
||||||
// Input state tests all work the same way: the test will render triangles in a grid up to 4x4. Each
|
// Input state tests all work the same way: the test will render triangles in a grid up to 4x4. Each
|
||||||
// triangle is position in the grid such that X will correspond to the "triangle number" and the Y
|
// triangle is position in the grid such that X will correspond to the "triangle number" and the Y
|
||||||
|
@ -64,7 +64,7 @@ class VertexStateTest : public DawnTest {
|
||||||
struct ShaderTestSpec {
|
struct ShaderTestSpec {
|
||||||
uint32_t location;
|
uint32_t location;
|
||||||
VertexFormat format;
|
VertexFormat format;
|
||||||
InputStepMode step;
|
VertexStepMode step;
|
||||||
};
|
};
|
||||||
wgpu::RenderPipeline MakeTestPipeline(const utils::ComboVertexStateDescriptor& vertexState,
|
wgpu::RenderPipeline MakeTestPipeline(const utils::ComboVertexStateDescriptor& vertexState,
|
||||||
int multiplier,
|
int multiplier,
|
||||||
|
@ -114,7 +114,7 @@ class VertexStateTest : public DawnTest {
|
||||||
if (ShouldComponentBeDefault(input.format, component)) {
|
if (ShouldComponentBeDefault(input.format, component)) {
|
||||||
vs << (component == 3 ? "1.0" : "0.0");
|
vs << (component == 3 ? "1.0" : "0.0");
|
||||||
} else {
|
} else {
|
||||||
if (input.step == InputStepMode::Vertex) {
|
if (input.step == VertexStepMode::Vertex) {
|
||||||
vs << "f32(" << multiplier << "u * input.VertexIndex) + " << component
|
vs << "f32(" << multiplier << "u * input.VertexIndex) + " << component
|
||||||
<< ".0";
|
<< ".0";
|
||||||
} else {
|
} else {
|
||||||
|
@ -161,7 +161,7 @@ class VertexStateTest : public DawnTest {
|
||||||
};
|
};
|
||||||
struct VertexBufferSpec {
|
struct VertexBufferSpec {
|
||||||
uint64_t arrayStride;
|
uint64_t arrayStride;
|
||||||
InputStepMode step;
|
VertexStepMode step;
|
||||||
std::vector<VertexAttributeSpec> attributes;
|
std::vector<VertexAttributeSpec> attributes;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -249,10 +249,11 @@ 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::Float32x4}}}},
|
MakeVertexState(
|
||||||
&vertexState);
|
{{4 * sizeof(float), VertexStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}},
|
||||||
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
|
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Vertex}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
||||||
|
@ -270,9 +271,9 @@ TEST_P(VertexStateTest, ZeroStride) {
|
||||||
DAWN_SUPPRESS_TEST_IF(IsLinux() && IsOpenGL());
|
DAWN_SUPPRESS_TEST_IF(IsLinux() && IsOpenGL());
|
||||||
|
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}}, &vertexState);
|
MakeVertexState({{0, VertexStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}}, &vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
|
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32x4, VertexStepMode::Vertex}});
|
||||||
|
|
||||||
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
||||||
0,
|
0,
|
||||||
|
@ -291,10 +292,10 @@ TEST_P(VertexStateTest, AttributeExpanding) {
|
||||||
// R32F case
|
// R32F case
|
||||||
{
|
{
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32}}}},
|
MakeVertexState({{0, VertexStepMode::Vertex, {{0, 0, VertexFormat::Float32}}}},
|
||||||
&vertexState);
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32, InputStepMode::Vertex}});
|
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32, VertexStepMode::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}});
|
||||||
|
@ -302,10 +303,10 @@ TEST_P(VertexStateTest, AttributeExpanding) {
|
||||||
// RG32F case
|
// RG32F case
|
||||||
{
|
{
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x2}}}},
|
MakeVertexState({{0, VertexStepMode::Vertex, {{0, 0, VertexFormat::Float32x2}}}},
|
||||||
&vertexState);
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline = MakeTestPipeline(
|
||||||
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32x2, InputStepMode::Vertex}});
|
vertexState, 0, {{0, VertexFormat::Float32x2, VertexStepMode::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 +314,10 @@ TEST_P(VertexStateTest, AttributeExpanding) {
|
||||||
// RGB32F case
|
// RGB32F case
|
||||||
{
|
{
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState({{0, InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x3}}}},
|
MakeVertexState({{0, VertexStepMode::Vertex, {{0, 0, VertexFormat::Float32x3}}}},
|
||||||
&vertexState);
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline = MakeTestPipeline(
|
||||||
MakeTestPipeline(vertexState, 0, {{0, VertexFormat::Float32x3, InputStepMode::Vertex}});
|
vertexState, 0, {{0, VertexFormat::Float32x3, VertexStepMode::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}});
|
||||||
|
@ -329,10 +330,11 @@ TEST_P(VertexStateTest, StrideLargerThanAttributes) {
|
||||||
DAWN_SUPPRESS_TEST_IF(IsLinux() && IsOpenGL());
|
DAWN_SUPPRESS_TEST_IF(IsLinux() && IsOpenGL());
|
||||||
|
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState({{8 * sizeof(float), InputStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}},
|
MakeVertexState(
|
||||||
&vertexState);
|
{{8 * sizeof(float), VertexStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}},
|
||||||
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
|
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Vertex}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
||||||
|
@ -349,11 +351,11 @@ TEST_P(VertexStateTest, TwoAttributesAtAnOffsetVertex) {
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState(
|
MakeVertexState(
|
||||||
{{8 * sizeof(float),
|
{{8 * sizeof(float),
|
||||||
InputStepMode::Vertex,
|
VertexStepMode::Vertex,
|
||||||
{{0, 0, VertexFormat::Float32x4}, {1, 4 * sizeof(float), VertexFormat::Float32x4}}}},
|
{{0, 0, VertexFormat::Float32x4}, {1, 4 * sizeof(float), VertexFormat::Float32x4}}}},
|
||||||
&vertexState);
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
|
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Vertex}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
||||||
|
@ -370,11 +372,11 @@ TEST_P(VertexStateTest, TwoAttributesAtAnOffsetInstance) {
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState(
|
MakeVertexState(
|
||||||
{{8 * sizeof(float),
|
{{8 * sizeof(float),
|
||||||
InputStepMode::Instance,
|
VertexStepMode::Instance,
|
||||||
{{0, 0, VertexFormat::Float32x4}, {1, 4 * sizeof(float), VertexFormat::Float32x4}}}},
|
{{0, 0, VertexFormat::Float32x4}, {1, 4 * sizeof(float), VertexFormat::Float32x4}}}},
|
||||||
&vertexState);
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
|
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Instance}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
||||||
|
@ -390,10 +392,10 @@ TEST_P(VertexStateTest, TwoAttributesAtAnOffsetInstance) {
|
||||||
TEST_P(VertexStateTest, PureInstance) {
|
TEST_P(VertexStateTest, PureInstance) {
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState(
|
MakeVertexState(
|
||||||
{{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
|
{{4 * sizeof(float), VertexStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
|
||||||
&vertexState);
|
&vertexState);
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
|
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Instance}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
||||||
|
@ -412,18 +414,18 @@ TEST_P(VertexStateTest, MixedEverything) {
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState(
|
MakeVertexState(
|
||||||
{{12 * sizeof(float),
|
{{12 * sizeof(float),
|
||||||
InputStepMode::Vertex,
|
VertexStepMode::Vertex,
|
||||||
{{0, 0, VertexFormat::Float32}, {1, 6 * sizeof(float), VertexFormat::Float32x2}}},
|
{{0, 0, VertexFormat::Float32}, {1, 6 * sizeof(float), VertexFormat::Float32x2}}},
|
||||||
{10 * sizeof(float),
|
{10 * sizeof(float),
|
||||||
InputStepMode::Instance,
|
VertexStepMode::Instance,
|
||||||
{{2, 0, VertexFormat::Float32x3}, {3, 5 * sizeof(float), VertexFormat::Float32x4}}}},
|
{{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::Float32, InputStepMode::Vertex},
|
{{0, VertexFormat::Float32, VertexStepMode::Vertex},
|
||||||
{1, VertexFormat::Float32x2, InputStepMode::Vertex},
|
{1, VertexFormat::Float32x2, VertexStepMode::Vertex},
|
||||||
{2, VertexFormat::Float32x3, InputStepMode::Instance},
|
{2, VertexFormat::Float32x3, VertexStepMode::Instance},
|
||||||
{3, VertexFormat::Float32x4, InputStepMode::Instance}});
|
{3, VertexFormat::Float32x4, VertexStepMode::Instance}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer0 = MakeVertexBuffer<float>({
|
||||||
|
@ -447,11 +449,11 @@ TEST_P(VertexStateTest, UnusedVertexSlot) {
|
||||||
// Instance input state, using slot 1
|
// Instance input state, using slot 1
|
||||||
utils::ComboVertexStateDescriptor instanceVertexState;
|
utils::ComboVertexStateDescriptor instanceVertexState;
|
||||||
MakeVertexState(
|
MakeVertexState(
|
||||||
{{0, InputStepMode::Vertex, {}},
|
{{0, VertexStepMode::Vertex, {}},
|
||||||
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
|
{4 * sizeof(float), VertexStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
|
||||||
&instanceVertexState);
|
&instanceVertexState);
|
||||||
wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
|
wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
|
||||||
instanceVertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
|
instanceVertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Instance}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer = MakeVertexBuffer<float>({
|
||||||
|
@ -487,19 +489,20 @@ 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::Float32x4}}}},
|
MakeVertexState(
|
||||||
&vertexVertexState);
|
{{4 * sizeof(float), VertexStepMode::Vertex, {{0, 0, VertexFormat::Float32x4}}}},
|
||||||
|
&vertexVertexState);
|
||||||
wgpu::RenderPipeline vertexPipeline = MakeTestPipeline(
|
wgpu::RenderPipeline vertexPipeline = MakeTestPipeline(
|
||||||
vertexVertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
|
vertexVertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Vertex}});
|
||||||
|
|
||||||
// Instance input state, using slot 1
|
// Instance input state, using slot 1
|
||||||
utils::ComboVertexStateDescriptor instanceVertexState;
|
utils::ComboVertexStateDescriptor instanceVertexState;
|
||||||
MakeVertexState(
|
MakeVertexState(
|
||||||
{{0, InputStepMode::Instance, {}},
|
{{0, VertexStepMode::Instance, {}},
|
||||||
{4 * sizeof(float), InputStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
|
{4 * sizeof(float), VertexStepMode::Instance, {{0, 0, VertexFormat::Float32x4}}}},
|
||||||
&instanceVertexState);
|
&instanceVertexState);
|
||||||
wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
|
wgpu::RenderPipeline instancePipeline = MakeTestPipeline(
|
||||||
instanceVertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Instance}});
|
instanceVertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::Instance}});
|
||||||
|
|
||||||
// clang-format off
|
// clang-format off
|
||||||
wgpu::Buffer buffer = MakeVertexBuffer<float>({
|
wgpu::Buffer buffer = MakeVertexBuffer<float>({
|
||||||
|
@ -539,7 +542,7 @@ TEST_P(VertexStateTest, LastAllowedVertexBuffer) {
|
||||||
// All the other vertex buffers default to no attributes
|
// All the other vertex buffers default to no attributes
|
||||||
vertexState.vertexBufferCount = kMaxVertexBuffers;
|
vertexState.vertexBufferCount = kMaxVertexBuffers;
|
||||||
vertexState.cVertexBuffers[kBufferIndex].arrayStride = 4 * sizeof(float);
|
vertexState.cVertexBuffers[kBufferIndex].arrayStride = 4 * sizeof(float);
|
||||||
vertexState.cVertexBuffers[kBufferIndex].stepMode = InputStepMode::Vertex;
|
vertexState.cVertexBuffers[kBufferIndex].stepMode = VertexStepMode::Vertex;
|
||||||
vertexState.cVertexBuffers[kBufferIndex].attributeCount = 1;
|
vertexState.cVertexBuffers[kBufferIndex].attributeCount = 1;
|
||||||
vertexState.cVertexBuffers[kBufferIndex].attributes = &vertexState.cAttributes[0];
|
vertexState.cVertexBuffers[kBufferIndex].attributes = &vertexState.cAttributes[0];
|
||||||
vertexState.cAttributes[0].shaderLocation = 0;
|
vertexState.cAttributes[0].shaderLocation = 0;
|
||||||
|
@ -547,7 +550,7 @@ TEST_P(VertexStateTest, LastAllowedVertexBuffer) {
|
||||||
vertexState.cAttributes[0].format = VertexFormat::Float32x4;
|
vertexState.cAttributes[0].format = VertexFormat::Float32x4;
|
||||||
|
|
||||||
wgpu::RenderPipeline pipeline =
|
wgpu::RenderPipeline pipeline =
|
||||||
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, InputStepMode::Vertex}});
|
MakeTestPipeline(vertexState, 1, {{0, VertexFormat::Float32x4, VertexStepMode::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}});
|
||||||
|
@ -559,7 +562,7 @@ TEST_P(VertexStateTest, OverlappingVertexAttributes) {
|
||||||
|
|
||||||
utils::ComboVertexStateDescriptor vertexState;
|
utils::ComboVertexStateDescriptor vertexState;
|
||||||
MakeVertexState({{16,
|
MakeVertexState({{16,
|
||||||
InputStepMode::Vertex,
|
VertexStepMode::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::Float32x4}, // |****|----|----|----|
|
{0, 0 /* offset */, VertexFormat::Float32x4}, // |****|----|----|----|
|
||||||
|
|
|
@ -72,7 +72,7 @@ namespace {
|
||||||
};
|
};
|
||||||
struct PipelineVertexBufferDesc {
|
struct PipelineVertexBufferDesc {
|
||||||
uint64_t arrayStride;
|
uint64_t arrayStride;
|
||||||
wgpu::InputStepMode stepMode;
|
wgpu::VertexStepMode stepMode;
|
||||||
std::vector<PipelineVertexBufferAttributeDesc> attributes = {};
|
std::vector<PipelineVertexBufferAttributeDesc> attributes = {};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -171,7 +171,7 @@ namespace {
|
||||||
DAWN_ASSERT(bufferStride >= kFloat32x4Stride);
|
DAWN_ASSERT(bufferStride >= kFloat32x4Stride);
|
||||||
|
|
||||||
std::vector<PipelineVertexBufferDesc> bufferDescList = {
|
std::vector<PipelineVertexBufferDesc> bufferDescList = {
|
||||||
{bufferStride, wgpu::InputStepMode::Vertex, {{0, wgpu::VertexFormat::Float32x4}}},
|
{bufferStride, wgpu::VertexStepMode::Vertex, {{0, wgpu::VertexFormat::Float32x4}}},
|
||||||
};
|
};
|
||||||
|
|
||||||
return CreateRenderPipelineWithBufferDesc(bufferDescList);
|
return CreateRenderPipelineWithBufferDesc(bufferDescList);
|
||||||
|
@ -186,9 +186,9 @@ namespace {
|
||||||
DAWN_ASSERT(bufferStride2 >= kFloat32x2Stride);
|
DAWN_ASSERT(bufferStride2 >= kFloat32x2Stride);
|
||||||
|
|
||||||
std::vector<PipelineVertexBufferDesc> bufferDescList = {
|
std::vector<PipelineVertexBufferDesc> bufferDescList = {
|
||||||
{bufferStride1, wgpu::InputStepMode::Vertex, {{0, wgpu::VertexFormat::Float32x4}}},
|
{bufferStride1, wgpu::VertexStepMode::Vertex, {{0, wgpu::VertexFormat::Float32x4}}},
|
||||||
{bufferStride2,
|
{bufferStride2,
|
||||||
wgpu::InputStepMode::Instance,
|
wgpu::VertexStepMode::Instance,
|
||||||
{{3, wgpu::VertexFormat::Float32x2}}},
|
{{3, wgpu::VertexFormat::Float32x2}}},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ namespace utils {
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
|
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
|
||||||
cVertexBuffers[i].arrayStride = 0;
|
cVertexBuffers[i].arrayStride = 0;
|
||||||
cVertexBuffers[i].stepMode = wgpu::InputStepMode::Vertex;
|
cVertexBuffers[i].stepMode = wgpu::VertexStepMode::Vertex;
|
||||||
cVertexBuffers[i].attributeCount = 0;
|
cVertexBuffers[i].attributeCount = 0;
|
||||||
cVertexBuffers[i].attributes = nullptr;
|
cVertexBuffers[i].attributes = nullptr;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ namespace utils {
|
||||||
}
|
}
|
||||||
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
|
for (uint32_t i = 0; i < kMaxVertexBuffers; ++i) {
|
||||||
cBuffers[i].arrayStride = 0;
|
cBuffers[i].arrayStride = 0;
|
||||||
cBuffers[i].stepMode = wgpu::InputStepMode::Vertex;
|
cBuffers[i].stepMode = wgpu::VertexStepMode::Vertex;
|
||||||
cBuffers[i].attributeCount = 0;
|
cBuffers[i].attributeCount = 0;
|
||||||
cBuffers[i].attributes = nullptr;
|
cBuffers[i].attributes = nullptr;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue