2018-07-18 09:40:26 +00:00
|
|
|
// Copyright 2017 The Dawn Authors
|
2017-04-20 18:38:20 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/CommandBuffer.h"
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/BindGroup.h"
|
|
|
|
#include "dawn_native/Buffer.h"
|
|
|
|
#include "dawn_native/CommandBufferStateTracker.h"
|
|
|
|
#include "dawn_native/Commands.h"
|
2018-09-21 00:24:37 +00:00
|
|
|
#include "dawn_native/ComputePassEncoder.h"
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/ComputePipeline.h"
|
|
|
|
#include "dawn_native/Device.h"
|
2018-09-21 00:24:37 +00:00
|
|
|
#include "dawn_native/ErrorData.h"
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/InputState.h"
|
|
|
|
#include "dawn_native/PipelineLayout.h"
|
2018-09-21 00:24:37 +00:00
|
|
|
#include "dawn_native/RenderPassEncoder.h"
|
2018-07-24 11:53:51 +00:00
|
|
|
#include "dawn_native/RenderPipeline.h"
|
|
|
|
#include "dawn_native/Texture.h"
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
#include <cstring>
|
|
|
|
#include <map>
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
namespace dawn_native {
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2017-06-26 15:43:51 +00:00
|
|
|
namespace {
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError ValidateCopyLocationFitsInTexture(const TextureCopyLocation& location) {
|
2017-06-26 15:43:51 +00:00
|
|
|
const TextureBase* texture = location.texture.Get();
|
|
|
|
if (location.level >= texture->GetNumMipLevels()) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Copy mip-level out of range");
|
2017-06-26 15:43:51 +00:00
|
|
|
}
|
|
|
|
|
2018-08-30 08:27:38 +00:00
|
|
|
if (location.slice >= texture->GetArrayLayers()) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Copy array-layer out of range");
|
2018-08-30 08:27:38 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
// All texture dimensions are in uint32_t so by doing checks in uint64_t we avoid
|
|
|
|
// overflows.
|
2017-06-26 15:43:51 +00:00
|
|
|
uint64_t level = location.level;
|
2017-11-24 18:59:42 +00:00
|
|
|
if (uint64_t(location.x) + uint64_t(location.width) >
|
2018-09-18 12:51:42 +00:00
|
|
|
(static_cast<uint64_t>(texture->GetSize().width) >> level) ||
|
2017-11-24 18:59:42 +00:00
|
|
|
uint64_t(location.y) + uint64_t(location.height) >
|
2018-09-18 12:51:42 +00:00
|
|
|
(static_cast<uint64_t>(texture->GetSize().height) >> level)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Copy would touch outside of the texture");
|
2017-06-26 15:43:51 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
// TODO(cwallez@chromium.org): Check the depth bound differently for 2D arrays and 3D
|
|
|
|
// textures
|
2017-06-26 15:43:51 +00:00
|
|
|
if (location.z != 0 || location.depth != 1) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("No support for z != 0 and depth != 1 for now");
|
2017-06-26 15:43:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2017-06-26 15:43:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool FitsInBuffer(const BufferBase* buffer, uint32_t offset, uint32_t size) {
|
|
|
|
uint32_t bufferSize = buffer->GetSize();
|
|
|
|
return offset <= bufferSize && (size <= (bufferSize - offset));
|
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError ValidateCopySizeFitsInBuffer(const BufferCopyLocation& location,
|
|
|
|
uint32_t dataSize) {
|
2017-06-26 15:43:51 +00:00
|
|
|
if (!FitsInBuffer(location.buffer.Get(), location.offset, dataSize)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Copy would overflow the buffer");
|
2017-06-26 15:43:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2017-06-26 15:43:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError ValidateTexelBufferOffset(TextureBase* texture,
|
|
|
|
const BufferCopyLocation& location) {
|
2017-11-24 18:59:42 +00:00
|
|
|
uint32_t texelSize =
|
|
|
|
static_cast<uint32_t>(TextureFormatPixelSize(texture->GetFormat()));
|
2017-07-18 17:18:58 +00:00
|
|
|
if (location.offset % texelSize != 0) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Buffer offset must be a multiple of the texel size");
|
2017-07-18 17:18:58 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2017-07-18 17:18:58 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError ComputeTextureCopyBufferSize(const TextureCopyLocation& location,
|
|
|
|
uint32_t rowPitch,
|
|
|
|
uint32_t* bufferSize) {
|
2017-06-26 15:43:51 +00:00
|
|
|
// TODO(cwallez@chromium.org): check for overflows
|
2017-07-13 14:23:26 +00:00
|
|
|
*bufferSize = (rowPitch * (location.height - 1) + location.width) * location.depth;
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2017-07-13 14:23:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
uint32_t ComputeDefaultRowPitch(TextureBase* texture, uint32_t width) {
|
2017-07-22 00:00:22 +00:00
|
|
|
uint32_t texelSize = TextureFormatPixelSize(texture->GetFormat());
|
2017-07-13 14:23:26 +00:00
|
|
|
return texelSize * width;
|
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError ValidateRowPitch(const TextureCopyLocation& location, uint32_t rowPitch) {
|
2017-07-13 14:23:26 +00:00
|
|
|
if (rowPitch % kTextureRowPitchAlignment != 0) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Row pitch must be a multiple of 256");
|
2017-07-13 14:23:26 +00:00
|
|
|
}
|
|
|
|
|
2017-07-22 00:00:22 +00:00
|
|
|
uint32_t texelSize = TextureFormatPixelSize(location.texture.Get()->GetFormat());
|
2017-07-13 14:23:26 +00:00
|
|
|
if (rowPitch < location.width * texelSize) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR(
|
|
|
|
"Row pitch must not be less than the number of bytes per row");
|
2017-07-13 14:23:26 +00:00
|
|
|
}
|
2017-06-26 15:43:51 +00:00
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2017-06-26 15:43:51 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
|
2018-07-09 13:15:07 +00:00
|
|
|
ASSERT(HasZeroOrOneBits(usage));
|
2018-08-22 13:08:02 +00:00
|
|
|
if (!(buffer->GetUsage() & usage)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("buffer doesn't have the required usage.");
|
2018-07-09 13:15:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2018-07-09 13:15:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsageBit usage) {
|
2018-07-09 13:15:07 +00:00
|
|
|
ASSERT(HasZeroOrOneBits(usage));
|
2018-08-22 13:08:02 +00:00
|
|
|
if (!(texture->GetUsage() & usage)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("texture doesn't have the required usage.");
|
2018-07-09 13:15:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2018-07-09 13:15:07 +00:00
|
|
|
}
|
|
|
|
|
2018-07-10 16:03:22 +00:00
|
|
|
enum class PassType {
|
|
|
|
Render,
|
|
|
|
Compute,
|
|
|
|
};
|
|
|
|
|
|
|
|
// Helper class to encapsulate the logic of tracking per-resource usage during the
|
|
|
|
// validation of command buffer passes. It is used both to know if there are validation
|
|
|
|
// errors, and to get a list of resources used per pass for backends that need the
|
|
|
|
// information.
|
|
|
|
class PassResourceUsageTracker {
|
|
|
|
public:
|
2018-07-18 09:38:11 +00:00
|
|
|
void BufferUsedAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
|
2018-07-10 16:03:22 +00:00
|
|
|
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
|
|
|
// before.
|
2018-07-18 09:38:11 +00:00
|
|
|
dawn::BufferUsageBit& storedUsage = mBufferUsages[buffer];
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
if (usage == dawn::BufferUsageBit::Storage &&
|
|
|
|
storedUsage & dawn::BufferUsageBit::Storage) {
|
2018-07-10 16:03:22 +00:00
|
|
|
mStorageUsedMultipleTimes = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
storedUsage |= usage;
|
|
|
|
}
|
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
void TextureUsedAs(TextureBase* texture, dawn::TextureUsageBit usage) {
|
2018-07-10 16:03:22 +00:00
|
|
|
// std::map's operator[] will create the key and return 0 if the key didn't exist
|
|
|
|
// before.
|
2018-07-18 09:38:11 +00:00
|
|
|
dawn::TextureUsageBit& storedUsage = mTextureUsages[texture];
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
if (usage == dawn::TextureUsageBit::Storage &&
|
|
|
|
storedUsage & dawn::TextureUsageBit::Storage) {
|
2018-07-10 16:03:22 +00:00
|
|
|
mStorageUsedMultipleTimes = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
storedUsage |= usage;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Performs the per-pass usage validation checks
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError ValidateUsages(PassType pass) const {
|
2018-07-10 16:03:22 +00:00
|
|
|
// Storage resources cannot be used twice in the same compute pass
|
|
|
|
if (pass == PassType::Compute && mStorageUsedMultipleTimes) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR(
|
|
|
|
"Storage resource used multiple times in compute pass");
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Buffers can only be used as single-write or multiple read.
|
|
|
|
for (auto& it : mBufferUsages) {
|
|
|
|
BufferBase* buffer = it.first;
|
2018-07-18 09:38:11 +00:00
|
|
|
dawn::BufferUsageBit usage = it.second;
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-08-22 13:08:02 +00:00
|
|
|
if (usage & ~buffer->GetUsage()) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass");
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool readOnly = (usage & kReadOnlyBufferUsages) == usage;
|
2018-07-18 09:38:11 +00:00
|
|
|
bool singleUse = dawn::HasZeroOrOneBits(usage);
|
2018-07-10 16:03:22 +00:00
|
|
|
|
|
|
|
if (!readOnly && !singleUse) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR(
|
2018-07-16 16:20:09 +00:00
|
|
|
"Buffer used as writeable usage and another usage in pass");
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Textures can only be used as single-write or multiple read.
|
|
|
|
// TODO(cwallez@chromium.org): implement per-subresource tracking
|
|
|
|
for (auto& it : mTextureUsages) {
|
|
|
|
TextureBase* texture = it.first;
|
2018-07-18 09:38:11 +00:00
|
|
|
dawn::TextureUsageBit usage = it.second;
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-08-22 13:08:02 +00:00
|
|
|
if (usage & ~texture->GetUsage()) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Texture missing usage for the pass");
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// For textures the only read-only usage in a pass is Sampled, so checking the
|
|
|
|
// usage constraint simplifies to checking a single usage bit is set.
|
2018-07-18 09:38:11 +00:00
|
|
|
if (!dawn::HasZeroOrOneBits(it.second)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR(
|
|
|
|
"Texture used with more than one usage in pass");
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Returns the per-pass usage for use by backends for APIs with explicit barriers.
|
|
|
|
PassResourceUsage AcquireResourceUsage() {
|
|
|
|
PassResourceUsage result;
|
|
|
|
result.buffers.reserve(mBufferUsages.size());
|
|
|
|
result.bufferUsages.reserve(mBufferUsages.size());
|
|
|
|
result.textures.reserve(mTextureUsages.size());
|
|
|
|
result.textureUsages.reserve(mTextureUsages.size());
|
|
|
|
|
|
|
|
for (auto& it : mBufferUsages) {
|
|
|
|
result.buffers.push_back(it.first);
|
|
|
|
result.bufferUsages.push_back(it.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (auto& it : mTextureUsages) {
|
|
|
|
result.textures.push_back(it.first);
|
|
|
|
result.textureUsages.push_back(it.second);
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-07-18 09:38:11 +00:00
|
|
|
std::map<BufferBase*, dawn::BufferUsageBit> mBufferUsages;
|
|
|
|
std::map<TextureBase*, dawn::TextureUsageBit> mTextureUsages;
|
2018-07-10 16:03:22 +00:00
|
|
|
bool mStorageUsedMultipleTimes = false;
|
|
|
|
};
|
|
|
|
|
|
|
|
void TrackBindGroupResourceUsage(BindGroupBase* group, PassResourceUsageTracker* tracker) {
|
|
|
|
const auto& layoutInfo = group->GetLayout()->GetBindingInfo();
|
|
|
|
|
|
|
|
for (uint32_t i : IterateBitSet(layoutInfo.mask)) {
|
2018-07-18 09:38:11 +00:00
|
|
|
dawn::BindingType type = layoutInfo.types[i];
|
2018-07-10 16:03:22 +00:00
|
|
|
|
|
|
|
switch (type) {
|
2018-07-18 09:38:11 +00:00
|
|
|
case dawn::BindingType::UniformBuffer: {
|
2018-07-10 16:03:22 +00:00
|
|
|
BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
|
2018-07-18 09:38:11 +00:00
|
|
|
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
|
2018-07-10 16:03:22 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
case dawn::BindingType::StorageBuffer: {
|
2018-07-10 16:03:22 +00:00
|
|
|
BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
|
2018-07-18 09:38:11 +00:00
|
|
|
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
|
2018-07-10 16:03:22 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
case dawn::BindingType::SampledTexture: {
|
2018-07-10 16:03:22 +00:00
|
|
|
TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture();
|
2018-07-18 09:38:11 +00:00
|
|
|
tracker->TextureUsedAs(texture, dawn::TextureUsageBit::Sampled);
|
2018-07-10 16:03:22 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
case dawn::BindingType::Sampler:
|
2018-07-10 16:03:22 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
} // namespace
|
2017-06-26 15:43:51 +00:00
|
|
|
|
2018-09-21 00:24:37 +00:00
|
|
|
enum class CommandBufferBuilder::EncodingState : uint8_t {
|
|
|
|
TopLevel,
|
|
|
|
ComputePass,
|
|
|
|
RenderPass,
|
|
|
|
Finished
|
|
|
|
};
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
// CommandBuffer
|
|
|
|
|
2017-04-20 18:38:20 +00:00
|
|
|
CommandBufferBase::CommandBufferBase(CommandBufferBuilder* builder)
|
2018-10-15 12:54:30 +00:00
|
|
|
: ObjectBase(builder->GetDevice()) {
|
2017-07-12 00:49:20 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
// CommandBufferBuilder
|
|
|
|
|
2018-09-21 00:24:37 +00:00
|
|
|
CommandBufferBuilder::CommandBufferBuilder(DeviceBase* device)
|
|
|
|
: Builder(device), mEncodingState(EncodingState::TopLevel) {
|
2017-04-20 18:38:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
CommandBufferBuilder::~CommandBufferBuilder() {
|
2017-11-23 18:32:51 +00:00
|
|
|
if (!mWereCommandsAcquired) {
|
2017-04-20 18:38:20 +00:00
|
|
|
MoveToIterator();
|
2017-11-23 18:32:51 +00:00
|
|
|
FreeCommands(&mIterator);
|
2017-04-20 18:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
CommandIterator CommandBufferBuilder::AcquireCommands() {
|
|
|
|
ASSERT(!mWereCommandsAcquired);
|
|
|
|
mWereCommandsAcquired = true;
|
|
|
|
return std::move(mIterator);
|
|
|
|
}
|
|
|
|
|
2018-07-10 16:03:22 +00:00
|
|
|
std::vector<PassResourceUsage> CommandBufferBuilder::AcquirePassResourceUsage() {
|
|
|
|
ASSERT(!mWerePassUsagesAcquired);
|
|
|
|
mWerePassUsagesAcquired = true;
|
|
|
|
return std::move(mPassResourceUsages);
|
|
|
|
}
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
CommandBufferBase* CommandBufferBuilder::GetResultImpl() {
|
2018-09-21 00:24:37 +00:00
|
|
|
mEncodingState = EncodingState::Finished;
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
MoveToIterator();
|
2018-10-15 12:54:30 +00:00
|
|
|
return GetDevice()->CreateCommandBuffer(this);
|
2018-07-04 13:20:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CommandBufferBuilder::MoveToIterator() {
|
|
|
|
if (!mWasMovedToIterator) {
|
|
|
|
mIterator = std::move(mAllocator);
|
|
|
|
mWasMovedToIterator = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-21 00:24:37 +00:00
|
|
|
void CommandBufferBuilder::PassEnded() {
|
|
|
|
if (mEncodingState == EncodingState::ComputePass) {
|
|
|
|
mAllocator.Allocate<EndComputePassCmd>(Command::EndComputePass);
|
|
|
|
} else {
|
|
|
|
ASSERT(mEncodingState == EncodingState::RenderPass);
|
|
|
|
mAllocator.Allocate<EndRenderPassCmd>(Command::EndRenderPass);
|
|
|
|
}
|
|
|
|
mEncodingState = EncodingState::TopLevel;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CommandBufferBuilder::ConsumeError(ErrorData* error) {
|
|
|
|
HandleError(error->GetMessage().c_str());
|
|
|
|
delete error;
|
|
|
|
}
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
// Implementation of the command buffer validation that can be precomputed before submit
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError CommandBufferBuilder::ValidateGetResult() {
|
2017-04-20 18:38:20 +00:00
|
|
|
MoveToIterator();
|
2018-07-04 13:20:19 +00:00
|
|
|
mIterator.Reset();
|
2017-04-20 18:38:20 +00:00
|
|
|
|
|
|
|
Command type;
|
2017-11-23 18:32:51 +00:00
|
|
|
while (mIterator.NextCommandId(&type)) {
|
2017-04-20 18:38:20 +00:00
|
|
|
switch (type) {
|
2017-11-24 18:59:42 +00:00
|
|
|
case Command::BeginComputePass: {
|
|
|
|
mIterator.NextCommand<BeginComputePassCmd>();
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateComputePass());
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::BeginRenderPass: {
|
|
|
|
BeginRenderPassCmd* cmd = mIterator.NextCommand<BeginRenderPassCmd>();
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateRenderPass(cmd->info.Get()));
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::CopyBufferToBuffer: {
|
|
|
|
CopyBufferToBufferCmd* copy = mIterator.NextCommand<CopyBufferToBufferCmd>();
|
2018-07-16 16:20:09 +00:00
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->source, copy->size));
|
|
|
|
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->destination, copy->size));
|
2018-07-16 16:20:09 +00:00
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
|
|
|
|
dawn::BufferUsageBit::TransferSrc));
|
|
|
|
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
|
|
|
|
dawn::BufferUsageBit::TransferDst));
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::CopyBufferToTexture: {
|
|
|
|
CopyBufferToTextureCmd* copy = mIterator.NextCommand<CopyBufferToTextureCmd>();
|
|
|
|
|
|
|
|
uint32_t bufferCopySize = 0;
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateRowPitch(copy->destination, copy->rowPitch));
|
|
|
|
DAWN_TRY(ComputeTextureCopyBufferSize(copy->destination, copy->rowPitch,
|
|
|
|
&bufferCopySize));
|
2018-07-16 16:20:09 +00:00
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateCopyLocationFitsInTexture(copy->destination));
|
|
|
|
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->source, bufferCopySize));
|
|
|
|
DAWN_TRY(
|
2018-07-16 16:20:09 +00:00
|
|
|
ValidateTexelBufferOffset(copy->destination.texture.Get(), copy->source));
|
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
|
|
|
|
dawn::BufferUsageBit::TransferSrc));
|
|
|
|
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
|
|
|
|
dawn::TextureUsageBit::TransferDst));
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::CopyTextureToBuffer: {
|
|
|
|
CopyTextureToBufferCmd* copy = mIterator.NextCommand<CopyTextureToBufferCmd>();
|
|
|
|
|
|
|
|
uint32_t bufferCopySize = 0;
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateRowPitch(copy->source, copy->rowPitch));
|
|
|
|
DAWN_TRY(ComputeTextureCopyBufferSize(copy->source, copy->rowPitch,
|
|
|
|
&bufferCopySize));
|
2018-07-16 16:20:09 +00:00
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateCopyLocationFitsInTexture(copy->source));
|
|
|
|
DAWN_TRY(ValidateCopySizeFitsInBuffer(copy->destination, bufferCopySize));
|
|
|
|
DAWN_TRY(
|
2018-07-16 16:20:09 +00:00
|
|
|
ValidateTexelBufferOffset(copy->source.texture.Get(), copy->destination));
|
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(ValidateCanUseAs(copy->source.texture.Get(),
|
|
|
|
dawn::TextureUsageBit::TransferSrc));
|
|
|
|
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
|
|
|
|
dawn::BufferUsageBit::TransferDst));
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
default:
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Command disallowed outside of a pass");
|
2018-07-04 13:20:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2018-07-04 13:20:19 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError CommandBufferBuilder::ValidateComputePass() {
|
2018-07-10 16:03:22 +00:00
|
|
|
PassResourceUsageTracker usageTracker;
|
2018-07-18 16:23:08 +00:00
|
|
|
CommandBufferStateTracker persistentState;
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
Command type;
|
|
|
|
while (mIterator.NextCommandId(&type)) {
|
|
|
|
switch (type) {
|
|
|
|
case Command::EndComputePass: {
|
|
|
|
mIterator.NextCommand<EndComputePassCmd>();
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(usageTracker.ValidateUsages(PassType::Compute));
|
2018-07-10 16:03:22 +00:00
|
|
|
mPassResourceUsages.push_back(usageTracker.AcquireResourceUsage());
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2018-07-04 13:20:19 +00:00
|
|
|
} break;
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
case Command::Dispatch: {
|
|
|
|
mIterator.NextCommand<DispatchCmd>();
|
2018-07-18 16:23:08 +00:00
|
|
|
DAWN_TRY(persistentState.ValidateCanDispatch());
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
case Command::SetComputePipeline: {
|
|
|
|
SetComputePipelineCmd* cmd = mIterator.NextCommand<SetComputePipelineCmd>();
|
|
|
|
ComputePipelineBase* pipeline = cmd->pipeline.Get();
|
2018-07-18 16:23:08 +00:00
|
|
|
persistentState.SetComputePipeline(pipeline);
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
case Command::SetPushConstants: {
|
|
|
|
SetPushConstantsCmd* cmd = mIterator.NextCommand<SetPushConstantsCmd>();
|
|
|
|
mIterator.NextData<uint32_t>(cmd->count);
|
|
|
|
// Validation of count and offset has already been done when the command was
|
|
|
|
// recorded because it impacts the size of an allocation in the
|
|
|
|
// CommandAllocator.
|
2018-07-18 09:38:11 +00:00
|
|
|
if (cmd->stages & ~dawn::ShaderStageBit::Compute) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR(
|
2018-07-04 13:20:19 +00:00
|
|
|
"SetPushConstants stage must be compute or 0 in compute passes");
|
2017-11-24 18:59:42 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
case Command::SetBindGroup: {
|
|
|
|
SetBindGroupCmd* cmd = mIterator.NextCommand<SetBindGroupCmd>();
|
2018-07-10 16:03:22 +00:00
|
|
|
|
|
|
|
TrackBindGroupResourceUsage(cmd->group.Get(), &usageTracker);
|
2018-07-18 16:23:08 +00:00
|
|
|
persistentState.SetBindGroup(cmd->index, cmd->group.Get());
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
default:
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Command disallowed inside a compute pass");
|
2018-07-04 13:20:19 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Unfinished compute pass");
|
2018-07-04 13:20:19 +00:00
|
|
|
}
|
|
|
|
|
2018-07-16 16:20:09 +00:00
|
|
|
MaybeError CommandBufferBuilder::ValidateRenderPass(RenderPassDescriptorBase* renderPass) {
|
2018-07-10 16:03:22 +00:00
|
|
|
PassResourceUsageTracker usageTracker;
|
2018-07-18 16:23:08 +00:00
|
|
|
CommandBufferStateTracker persistentState;
|
2018-07-10 16:03:22 +00:00
|
|
|
|
|
|
|
// Track usage of the render pass attachments
|
|
|
|
for (uint32_t i : IterateBitSet(renderPass->GetColorAttachmentMask())) {
|
|
|
|
TextureBase* texture = renderPass->GetColorAttachment(i).view->GetTexture();
|
2018-07-18 09:38:11 +00:00
|
|
|
usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (renderPass->HasDepthStencilAttachment()) {
|
|
|
|
TextureBase* texture = renderPass->GetDepthStencilAttachment().view->GetTexture();
|
2018-07-18 09:38:11 +00:00
|
|
|
usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
|
2018-07-10 16:03:22 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
Command type;
|
|
|
|
while (mIterator.NextCommandId(&type)) {
|
|
|
|
switch (type) {
|
2017-11-24 18:59:42 +00:00
|
|
|
case Command::EndRenderPass: {
|
|
|
|
mIterator.NextCommand<EndRenderPassCmd>();
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-07-18 09:45:17 +00:00
|
|
|
DAWN_TRY(usageTracker.ValidateUsages(PassType::Render));
|
2018-07-10 16:03:22 +00:00
|
|
|
mPassResourceUsages.push_back(usageTracker.AcquireResourceUsage());
|
2018-07-16 16:20:09 +00:00
|
|
|
return {};
|
2018-07-04 13:20:19 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::DrawArrays: {
|
|
|
|
mIterator.NextCommand<DrawArraysCmd>();
|
2018-07-18 16:23:08 +00:00
|
|
|
DAWN_TRY(persistentState.ValidateCanDrawArrays());
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
case Command::DrawElements: {
|
|
|
|
mIterator.NextCommand<DrawElementsCmd>();
|
2018-07-18 16:23:08 +00:00
|
|
|
DAWN_TRY(persistentState.ValidateCanDrawElements());
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::SetRenderPipeline: {
|
|
|
|
SetRenderPipelineCmd* cmd = mIterator.NextCommand<SetRenderPipelineCmd>();
|
|
|
|
RenderPipelineBase* pipeline = cmd->pipeline.Get();
|
2018-07-04 13:20:19 +00:00
|
|
|
|
|
|
|
if (!pipeline->IsCompatibleWith(renderPass)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR(
|
|
|
|
"Pipeline is incompatible with this render pass");
|
2018-07-04 13:20:19 +00:00
|
|
|
}
|
|
|
|
|
2018-07-18 16:23:08 +00:00
|
|
|
persistentState.SetRenderPipeline(pipeline);
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::SetPushConstants: {
|
|
|
|
SetPushConstantsCmd* cmd = mIterator.NextCommand<SetPushConstantsCmd>();
|
|
|
|
mIterator.NextData<uint32_t>(cmd->count);
|
|
|
|
// Validation of count and offset has already been done when the command was
|
|
|
|
// recorded because it impacts the size of an allocation in the
|
|
|
|
// CommandAllocator.
|
2018-07-04 13:20:19 +00:00
|
|
|
if (cmd->stages &
|
2018-07-18 09:38:11 +00:00
|
|
|
~(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment)) {
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR(
|
2018-07-04 13:20:19 +00:00
|
|
|
"SetPushConstants stage must be a subset of (vertex|fragment) in "
|
|
|
|
"render passes");
|
2017-11-24 18:59:42 +00:00
|
|
|
}
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::SetStencilReference: {
|
|
|
|
mIterator.NextCommand<SetStencilReferenceCmd>();
|
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::SetBlendColor: {
|
|
|
|
mIterator.NextCommand<SetBlendColorCmd>();
|
|
|
|
} break;
|
|
|
|
|
2018-02-13 19:57:13 +00:00
|
|
|
case Command::SetScissorRect: {
|
|
|
|
mIterator.NextCommand<SetScissorRectCmd>();
|
|
|
|
} break;
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
case Command::SetBindGroup: {
|
|
|
|
SetBindGroupCmd* cmd = mIterator.NextCommand<SetBindGroupCmd>();
|
2018-07-10 16:03:22 +00:00
|
|
|
|
|
|
|
TrackBindGroupResourceUsage(cmd->group.Get(), &usageTracker);
|
2018-07-18 16:23:08 +00:00
|
|
|
persistentState.SetBindGroup(cmd->index, cmd->group.Get());
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case Command::SetIndexBuffer: {
|
|
|
|
SetIndexBufferCmd* cmd = mIterator.NextCommand<SetIndexBufferCmd>();
|
2018-07-10 16:03:22 +00:00
|
|
|
|
2018-07-18 09:38:11 +00:00
|
|
|
usageTracker.BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsageBit::Index);
|
2018-07-18 16:23:08 +00:00
|
|
|
persistentState.SetIndexBuffer();
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
case Command::SetVertexBuffers: {
|
|
|
|
SetVertexBuffersCmd* cmd = mIterator.NextCommand<SetVertexBuffersCmd>();
|
|
|
|
auto buffers = mIterator.NextData<Ref<BufferBase>>(cmd->count);
|
|
|
|
mIterator.NextData<uint32_t>(cmd->count);
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
for (uint32_t i = 0; i < cmd->count; ++i) {
|
2018-07-18 09:38:11 +00:00
|
|
|
usageTracker.BufferUsedAs(buffers[i].Get(), dawn::BufferUsageBit::Vertex);
|
2017-04-20 18:38:20 +00:00
|
|
|
}
|
2018-07-18 16:23:08 +00:00
|
|
|
persistentState.SetVertexBuffer(cmd->startSlot, cmd->count);
|
2017-11-24 18:59:42 +00:00
|
|
|
} break;
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
default:
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Command disallowed inside a render pass");
|
2017-04-20 18:38:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-09-10 14:17:24 +00:00
|
|
|
return DAWN_VALIDATION_ERROR("Unfinished render pass");
|
2017-04-20 18:38:20 +00:00
|
|
|
}
|
|
|
|
|
2018-07-04 13:20:19 +00:00
|
|
|
// Implementation of the API's command recording methods
|
2017-04-20 18:38:20 +00:00
|
|
|
|
2018-09-21 00:24:37 +00:00
|
|
|
ComputePassEncoderBase* CommandBufferBuilder::BeginComputePass() {
|
2017-11-23 18:32:51 +00:00
|
|
|
mAllocator.Allocate<BeginComputePassCmd>(Command::BeginComputePass);
|
2018-09-21 00:24:37 +00:00
|
|
|
|
|
|
|
mEncodingState = EncodingState::ComputePass;
|
2018-10-15 12:54:30 +00:00
|
|
|
return new ComputePassEncoderBase(GetDevice(), this, &mAllocator);
|
2017-05-16 21:04:22 +00:00
|
|
|
}
|
|
|
|
|
2018-09-21 00:24:37 +00:00
|
|
|
RenderPassEncoderBase* CommandBufferBuilder::BeginRenderPass(RenderPassDescriptorBase* info) {
|
2017-11-23 18:32:51 +00:00
|
|
|
BeginRenderPassCmd* cmd = mAllocator.Allocate<BeginRenderPassCmd>(Command::BeginRenderPass);
|
2017-11-24 18:59:42 +00:00
|
|
|
new (cmd) BeginRenderPassCmd;
|
2018-05-02 22:10:13 +00:00
|
|
|
cmd->info = info;
|
2018-09-21 00:24:37 +00:00
|
|
|
|
|
|
|
mEncodingState = EncodingState::RenderPass;
|
2018-10-15 12:54:30 +00:00
|
|
|
return new RenderPassEncoderBase(GetDevice(), this, &mAllocator);
|
2017-07-10 21:07:24 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
void CommandBufferBuilder::CopyBufferToBuffer(BufferBase* source,
|
|
|
|
uint32_t sourceOffset,
|
|
|
|
BufferBase* destination,
|
|
|
|
uint32_t destinationOffset,
|
|
|
|
uint32_t size) {
|
|
|
|
CopyBufferToBufferCmd* copy =
|
|
|
|
mAllocator.Allocate<CopyBufferToBufferCmd>(Command::CopyBufferToBuffer);
|
|
|
|
new (copy) CopyBufferToBufferCmd;
|
2017-06-26 15:43:51 +00:00
|
|
|
copy->source.buffer = source;
|
|
|
|
copy->source.offset = sourceOffset;
|
|
|
|
copy->destination.buffer = destination;
|
|
|
|
copy->destination.offset = destinationOffset;
|
2017-06-12 22:12:29 +00:00
|
|
|
copy->size = size;
|
|
|
|
}
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
void CommandBufferBuilder::CopyBufferToTexture(BufferBase* buffer,
|
|
|
|
uint32_t bufferOffset,
|
|
|
|
uint32_t rowPitch,
|
|
|
|
TextureBase* texture,
|
|
|
|
uint32_t x,
|
|
|
|
uint32_t y,
|
|
|
|
uint32_t z,
|
|
|
|
uint32_t width,
|
|
|
|
uint32_t height,
|
|
|
|
uint32_t depth,
|
2018-08-30 08:27:38 +00:00
|
|
|
uint32_t level,
|
|
|
|
uint32_t slice) {
|
2017-07-13 14:23:26 +00:00
|
|
|
if (rowPitch == 0) {
|
|
|
|
rowPitch = ComputeDefaultRowPitch(texture, width);
|
|
|
|
}
|
2017-11-24 18:59:42 +00:00
|
|
|
CopyBufferToTextureCmd* copy =
|
|
|
|
mAllocator.Allocate<CopyBufferToTextureCmd>(Command::CopyBufferToTexture);
|
|
|
|
new (copy) CopyBufferToTextureCmd;
|
2017-06-26 15:43:51 +00:00
|
|
|
copy->source.buffer = buffer;
|
|
|
|
copy->source.offset = bufferOffset;
|
|
|
|
copy->destination.texture = texture;
|
|
|
|
copy->destination.x = x;
|
|
|
|
copy->destination.y = y;
|
|
|
|
copy->destination.z = z;
|
|
|
|
copy->destination.width = width;
|
|
|
|
copy->destination.height = height;
|
|
|
|
copy->destination.depth = depth;
|
|
|
|
copy->destination.level = level;
|
2018-08-30 08:27:38 +00:00
|
|
|
copy->destination.slice = slice;
|
2017-07-13 14:04:23 +00:00
|
|
|
copy->rowPitch = rowPitch;
|
2017-04-20 18:38:20 +00:00
|
|
|
}
|
|
|
|
|
2017-11-24 18:59:42 +00:00
|
|
|
void CommandBufferBuilder::CopyTextureToBuffer(TextureBase* texture,
|
|
|
|
uint32_t x,
|
|
|
|
uint32_t y,
|
|
|
|
uint32_t z,
|
|
|
|
uint32_t width,
|
|
|
|
uint32_t height,
|
|
|
|
uint32_t depth,
|
|
|
|
uint32_t level,
|
2018-08-30 08:27:38 +00:00
|
|
|
uint32_t slice,
|
2017-11-24 18:59:42 +00:00
|
|
|
BufferBase* buffer,
|
|
|
|
uint32_t bufferOffset,
|
|
|
|
uint32_t rowPitch) {
|
2017-07-13 14:23:26 +00:00
|
|
|
if (rowPitch == 0) {
|
|
|
|
rowPitch = ComputeDefaultRowPitch(texture, width);
|
|
|
|
}
|
2017-11-24 18:59:42 +00:00
|
|
|
CopyTextureToBufferCmd* copy =
|
|
|
|
mAllocator.Allocate<CopyTextureToBufferCmd>(Command::CopyTextureToBuffer);
|
|
|
|
new (copy) CopyTextureToBufferCmd;
|
2017-06-26 20:23:03 +00:00
|
|
|
copy->source.texture = texture;
|
|
|
|
copy->source.x = x;
|
|
|
|
copy->source.y = y;
|
|
|
|
copy->source.z = z;
|
|
|
|
copy->source.width = width;
|
|
|
|
copy->source.height = height;
|
|
|
|
copy->source.depth = depth;
|
|
|
|
copy->source.level = level;
|
2018-08-30 08:27:38 +00:00
|
|
|
copy->source.slice = slice;
|
2017-06-26 20:23:03 +00:00
|
|
|
copy->destination.buffer = buffer;
|
|
|
|
copy->destination.offset = bufferOffset;
|
2017-07-13 14:04:23 +00:00
|
|
|
copy->rowPitch = rowPitch;
|
2017-06-26 20:23:03 +00:00
|
|
|
}
|
|
|
|
|
2018-07-24 14:45:45 +00:00
|
|
|
} // namespace dawn_native
|