Remove TINT_EXPECTS_UBOS_TO_BE_MULTIPLE_OF_16 macro usage
This was a temporary measure to be able to roll Tint into Dawn with this change. The macro will be removed in Tint once this lands. Bug: tint:984 Change-Id: If599e92b16b5edd96b357ce5ee57143a2c00e22d Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/58365 Reviewed-by: Austin Eng <enga@chromium.org> Reviewed-by: Ben Clayton <bclayton@google.com> Reviewed-by: Corentin Wallez <cwallez@chromium.org> Commit-Queue: Antonio Maiorano <amaiorano@google.com>
This commit is contained in:
parent
ffc0a1f6fc
commit
70324d89e0
src/dawn_native/metal
|
@ -274,7 +274,9 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
// The lengths of buffers are stored as 32bit integers because that is the width the
|
// The lengths of buffers are stored as 32bit integers because that is the width the
|
||||||
// MSL code generated by SPIRV-Cross expects.
|
// MSL code generated by SPIRV-Cross expects.
|
||||||
PerStage<std::array<uint32_t, ((kGenericMetalBufferSlots / 4) + 1) * 4>> data;
|
// UBOs require we align the max buffer count to 4 elements (16 bytes).
|
||||||
|
static constexpr size_t MaxBufferCount = ((kGenericMetalBufferSlots + 3) / 4) * 4;
|
||||||
|
PerStage<std::array<uint32_t, MaxBufferCount>> data;
|
||||||
|
|
||||||
void Apply(id<MTLRenderCommandEncoder> render,
|
void Apply(id<MTLRenderCommandEncoder> render,
|
||||||
RenderPipeline* pipeline,
|
RenderPipeline* pipeline,
|
||||||
|
@ -294,10 +296,9 @@ namespace dawn_native { namespace metal {
|
||||||
bufferCount += pipeline->GetVertexBufferCount();
|
bufferCount += pipeline->GetVertexBufferCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TINT_EXPECTS_UBOS_TO_BE_MULTIPLE_OF_16
|
|
||||||
bufferCount = Align(bufferCount, 4);
|
bufferCount = Align(bufferCount, 4);
|
||||||
ASSERT(bufferCount <= data[SingleShaderStage::Vertex].size());
|
ASSERT(bufferCount <= data[SingleShaderStage::Vertex].size());
|
||||||
#endif
|
|
||||||
[render setVertexBytes:data[SingleShaderStage::Vertex].data()
|
[render setVertexBytes:data[SingleShaderStage::Vertex].data()
|
||||||
length:sizeof(uint32_t) * bufferCount
|
length:sizeof(uint32_t) * bufferCount
|
||||||
atIndex:kBufferLengthBufferSlot];
|
atIndex:kBufferLengthBufferSlot];
|
||||||
|
@ -306,10 +307,9 @@ namespace dawn_native { namespace metal {
|
||||||
if (stagesToApply & wgpu::ShaderStage::Fragment) {
|
if (stagesToApply & wgpu::ShaderStage::Fragment) {
|
||||||
uint32_t bufferCount = ToBackend(pipeline->GetLayout())
|
uint32_t bufferCount = ToBackend(pipeline->GetLayout())
|
||||||
->GetBufferBindingCount(SingleShaderStage::Fragment);
|
->GetBufferBindingCount(SingleShaderStage::Fragment);
|
||||||
#ifdef TINT_EXPECTS_UBOS_TO_BE_MULTIPLE_OF_16
|
|
||||||
bufferCount = Align(bufferCount, 4);
|
bufferCount = Align(bufferCount, 4);
|
||||||
ASSERT(bufferCount <= data[SingleShaderStage::Fragment].size());
|
ASSERT(bufferCount <= data[SingleShaderStage::Fragment].size());
|
||||||
#endif
|
|
||||||
[render setFragmentBytes:data[SingleShaderStage::Fragment].data()
|
[render setFragmentBytes:data[SingleShaderStage::Fragment].data()
|
||||||
length:sizeof(uint32_t) * bufferCount
|
length:sizeof(uint32_t) * bufferCount
|
||||||
atIndex:kBufferLengthBufferSlot];
|
atIndex:kBufferLengthBufferSlot];
|
||||||
|
@ -330,10 +330,9 @@ namespace dawn_native { namespace metal {
|
||||||
|
|
||||||
uint32_t bufferCount = ToBackend(pipeline->GetLayout())
|
uint32_t bufferCount = ToBackend(pipeline->GetLayout())
|
||||||
->GetBufferBindingCount(SingleShaderStage::Compute);
|
->GetBufferBindingCount(SingleShaderStage::Compute);
|
||||||
#ifdef TINT_EXPECTS_UBOS_TO_BE_MULTIPLE_OF_16
|
|
||||||
bufferCount = Align(bufferCount, 4);
|
bufferCount = Align(bufferCount, 4);
|
||||||
ASSERT(bufferCount <= data[SingleShaderStage::Compute].size());
|
ASSERT(bufferCount <= data[SingleShaderStage::Compute].size());
|
||||||
#endif
|
|
||||||
[compute setBytes:data[SingleShaderStage::Compute].data()
|
[compute setBytes:data[SingleShaderStage::Compute].data()
|
||||||
length:sizeof(uint32_t) * bufferCount
|
length:sizeof(uint32_t) * bufferCount
|
||||||
atIndex:kBufferLengthBufferSlot];
|
atIndex:kBufferLengthBufferSlot];
|
||||||
|
|
Loading…
Reference in New Issue