mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-12-17 17:05:31 +00:00
Metal: Pack vertex buffers just after the pipeline layout
WebGPU have a 2D pipeline layout plus a vertex buffer table while Metal has a single vertex buffer table that contains everything (including uniform and storage buffers). Previously the space for vertex buffers was statically allocated in that table which made the last vertex buffer go out of bound of the Metal vertex buffer table. This fixes the issue by packing all the vertex buffers that are used right after the vertex buffers used by the bind groups. This is a drive-by fix found while looking at reserving Metal vertex buffer 30 to contain the shader storage buffer lengths. BUG=dawn:195 Change-Id: If5c67bbc0d15c976793ef43889e50e4a360217d7 Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/9387 Commit-Queue: Corentin Wallez <cwallez@chromium.org> Reviewed-by: Austin Eng <enga@chromium.org>
This commit is contained in:
committed by
Commit Bot service account
parent
b98f0faa4d
commit
10fe83305a
@@ -487,6 +487,28 @@ TEST_P(VertexInputTest, MultiplePipelinesMixedVertexInput) {
|
||||
CheckResult(1, 4);
|
||||
}
|
||||
|
||||
// Checks that using the last vertex buffer doesn't overflow the vertex buffer table in Metal.
|
||||
TEST_P(VertexInputTest, LastAllowedVertexBuffer) {
|
||||
constexpr uint32_t kBufferIndex = kMaxVertexBuffers - 1;
|
||||
|
||||
utils::ComboVertexInputDescriptor vertexInput;
|
||||
// All the other vertex buffers default to no attributes
|
||||
vertexInput.bufferCount = kMaxVertexBuffers;
|
||||
vertexInput.cBuffers[kBufferIndex].stride = 4 * sizeof(float);
|
||||
vertexInput.cBuffers[kBufferIndex].stepMode = InputStepMode::Vertex;
|
||||
vertexInput.cBuffers[kBufferIndex].attributeCount = 1;
|
||||
vertexInput.cBuffers[kBufferIndex].attributes = &vertexInput.cAttributes[0];
|
||||
vertexInput.cAttributes[0].shaderLocation = 0;
|
||||
vertexInput.cAttributes[0].offset = 0;
|
||||
vertexInput.cAttributes[0].format = VertexFormat::Float4;
|
||||
|
||||
dawn::RenderPipeline pipeline =
|
||||
MakeTestPipeline(vertexInput, 1, {{0, VertexFormat::Float4, InputStepMode::Vertex}});
|
||||
|
||||
dawn::Buffer buffer0 = MakeVertexBuffer<float>({0, 1, 2, 3, 1, 2, 3, 4, 2, 3, 4, 5});
|
||||
DoTestDraw(pipeline, 1, 1, {DrawVertexBuffer{kMaxVertexBuffers - 1, &buffer0}});
|
||||
}
|
||||
|
||||
DAWN_INSTANTIATE_TEST(VertexInputTest, D3D12Backend, MetalBackend, OpenGLBackend, VulkanBackend);
|
||||
|
||||
// TODO for the input state:
|
||||
|
||||
Reference in New Issue
Block a user