Rename nxt:: to dawn:: in the backends

This commit is contained in:
Corentin Wallez 2018-07-18 11:38:11 +02:00 committed by Corentin Wallez
parent 141c0be317
commit 226110f958
120 changed files with 1056 additions and 1056 deletions

View File

@ -35,29 +35,29 @@ namespace backend {
return mLayout.Get();
}
nxt::BindGroupUsage BindGroupBase::GetUsage() const {
dawn::BindGroupUsage BindGroupBase::GetUsage() const {
return mUsage;
}
BufferViewBase* BindGroupBase::GetBindingAsBufferView(size_t binding) {
ASSERT(binding < kMaxBindingsPerGroup);
ASSERT(mLayout->GetBindingInfo().mask[binding]);
ASSERT(mLayout->GetBindingInfo().types[binding] == nxt::BindingType::UniformBuffer ||
mLayout->GetBindingInfo().types[binding] == nxt::BindingType::StorageBuffer);
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer ||
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer);
return reinterpret_cast<BufferViewBase*>(mBindings[binding].Get());
}
SamplerBase* BindGroupBase::GetBindingAsSampler(size_t binding) {
ASSERT(binding < kMaxBindingsPerGroup);
ASSERT(mLayout->GetBindingInfo().mask[binding]);
ASSERT(mLayout->GetBindingInfo().types[binding] == nxt::BindingType::Sampler);
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::Sampler);
return reinterpret_cast<SamplerBase*>(mBindings[binding].Get());
}
TextureViewBase* BindGroupBase::GetBindingAsTextureView(size_t binding) {
ASSERT(binding < kMaxBindingsPerGroup);
ASSERT(mLayout->GetBindingInfo().mask[binding]);
ASSERT(mLayout->GetBindingInfo().types[binding] == nxt::BindingType::SampledTexture);
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::SampledTexture);
return reinterpret_cast<TextureViewBase*>(mBindings[binding].Get());
}
@ -100,7 +100,7 @@ namespace backend {
mPropertiesSet |= BINDGROUP_PROPERTY_LAYOUT;
}
void BindGroupBuilder::SetUsage(nxt::BindGroupUsage usage) {
void BindGroupBuilder::SetUsage(dawn::BindGroupUsage usage) {
if ((mPropertiesSet & BINDGROUP_PROPERTY_USAGE) != 0) {
HandleError("Bindgroup usage property set multiple times");
return;
@ -119,18 +119,18 @@ namespace backend {
const auto& layoutInfo = mLayout->GetBindingInfo();
for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
nxt::BufferUsageBit requiredBit = nxt::BufferUsageBit::None;
dawn::BufferUsageBit requiredBit = dawn::BufferUsageBit::None;
switch (layoutInfo.types[i]) {
case nxt::BindingType::UniformBuffer:
requiredBit = nxt::BufferUsageBit::Uniform;
case dawn::BindingType::UniformBuffer:
requiredBit = dawn::BufferUsageBit::Uniform;
break;
case nxt::BindingType::StorageBuffer:
requiredBit = nxt::BufferUsageBit::Storage;
case dawn::BindingType::StorageBuffer:
requiredBit = dawn::BufferUsageBit::Storage;
break;
case nxt::BindingType::Sampler:
case nxt::BindingType::SampledTexture:
case dawn::BindingType::Sampler:
case dawn::BindingType::SampledTexture:
HandleError("Setting buffer for a wrong binding type");
return;
}
@ -158,7 +158,7 @@ namespace backend {
const auto& layoutInfo = mLayout->GetBindingInfo();
for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
if (layoutInfo.types[i] != nxt::BindingType::Sampler) {
if (layoutInfo.types[i] != dawn::BindingType::Sampler) {
HandleError("Setting binding for a wrong layout binding type");
return;
}
@ -176,13 +176,13 @@ namespace backend {
const auto& layoutInfo = mLayout->GetBindingInfo();
for (size_t i = start, j = 0; i < start + count; ++i, ++j) {
if (layoutInfo.types[i] != nxt::BindingType::SampledTexture) {
if (layoutInfo.types[i] != dawn::BindingType::SampledTexture) {
HandleError("Setting binding for a wrong layout binding type");
return;
}
if (!(textureViews[j]->GetTexture()->GetAllowedUsage() &
nxt::TextureUsageBit::Sampled)) {
dawn::TextureUsageBit::Sampled)) {
HandleError("Texture needs to allow the sampled usage bit");
return;
}

View File

@ -34,7 +34,7 @@ namespace backend {
BindGroupBase(BindGroupBuilder* builder);
const BindGroupLayoutBase* GetLayout() const;
nxt::BindGroupUsage GetUsage() const;
dawn::BindGroupUsage GetUsage() const;
BufferViewBase* GetBindingAsBufferView(size_t binding);
SamplerBase* GetBindingAsSampler(size_t binding);
TextureViewBase* GetBindingAsTextureView(size_t binding);
@ -43,7 +43,7 @@ namespace backend {
private:
Ref<BindGroupLayoutBase> mLayout;
nxt::BindGroupUsage mUsage;
dawn::BindGroupUsage mUsage;
std::array<Ref<RefCounted>, kMaxBindingsPerGroup> mBindings;
};
@ -53,7 +53,7 @@ namespace backend {
// NXT API
void SetLayout(BindGroupLayoutBase* layout);
void SetUsage(nxt::BindGroupUsage usage);
void SetUsage(dawn::BindGroupUsage usage);
template <typename T>
void SetBufferViews(uint32_t start, uint32_t count, T* const* bufferViews) {
@ -87,7 +87,7 @@ namespace backend {
int mPropertiesSet = 0;
Ref<BindGroupLayoutBase> mLayout;
nxt::BindGroupUsage mUsage;
dawn::BindGroupUsage mUsage;
std::array<Ref<RefCounted>, kMaxBindingsPerGroup> mBindings;
};

View File

@ -23,8 +23,9 @@
namespace backend {
MaybeError ValidateBindGroupLayoutDescriptor(DeviceBase*,
const nxt::BindGroupLayoutDescriptor* descriptor) {
MaybeError ValidateBindGroupLayoutDescriptor(
DeviceBase*,
const dawn::BindGroupLayoutDescriptor* descriptor) {
NXT_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
std::bitset<kMaxBindingsPerGroup> bindingsSet;
@ -72,7 +73,7 @@ namespace backend {
// BindGroupLayoutBase
BindGroupLayoutBase::BindGroupLayoutBase(DeviceBase* device,
const nxt::BindGroupLayoutDescriptor* descriptor,
const dawn::BindGroupLayoutDescriptor* descriptor,
bool blueprint)
: mDevice(device), mIsBlueprint(blueprint) {
for (uint32_t i = 0; i < descriptor->numBindings; ++i) {

View File

@ -28,18 +28,18 @@
namespace backend {
MaybeError ValidateBindGroupLayoutDescriptor(DeviceBase*,
const nxt::BindGroupLayoutDescriptor* descriptor);
const dawn::BindGroupLayoutDescriptor* descriptor);
class BindGroupLayoutBase : public RefCounted {
public:
BindGroupLayoutBase(DeviceBase* device,
const nxt::BindGroupLayoutDescriptor* descriptor,
const dawn::BindGroupLayoutDescriptor* descriptor,
bool blueprint = false);
~BindGroupLayoutBase() override;
struct LayoutBindingInfo {
std::array<nxt::ShaderStageBit, kMaxBindingsPerGroup> visibilities;
std::array<nxt::BindingType, kMaxBindingsPerGroup> types;
std::array<dawn::ShaderStageBit, kMaxBindingsPerGroup> visibilities;
std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
std::bitset<kMaxBindingsPerGroup> mask;
};
const LayoutBindingInfo& GetBindingInfo() const;

View File

@ -54,9 +54,9 @@ namespace backend {
mBlendInfo.blendEnabled = blendEnabled;
}
void BlendStateBuilder::SetAlphaBlend(nxt::BlendOperation blendOperation,
nxt::BlendFactor srcFactor,
nxt::BlendFactor dstFactor) {
void BlendStateBuilder::SetAlphaBlend(dawn::BlendOperation blendOperation,
dawn::BlendFactor srcFactor,
dawn::BlendFactor dstFactor) {
if ((mPropertiesSet & BLEND_STATE_PROPERTY_ALPHA_BLEND) != 0) {
HandleError("Alpha blend property set multiple times");
return;
@ -67,9 +67,9 @@ namespace backend {
mBlendInfo.alphaBlend = {blendOperation, srcFactor, dstFactor};
}
void BlendStateBuilder::SetColorBlend(nxt::BlendOperation blendOperation,
nxt::BlendFactor srcFactor,
nxt::BlendFactor dstFactor) {
void BlendStateBuilder::SetColorBlend(dawn::BlendOperation blendOperation,
dawn::BlendFactor srcFactor,
dawn::BlendFactor dstFactor) {
if ((mPropertiesSet & BLEND_STATE_PROPERTY_COLOR_BLEND) != 0) {
HandleError("Color blend property set multiple times");
return;
@ -80,7 +80,7 @@ namespace backend {
mBlendInfo.colorBlend = {blendOperation, srcFactor, dstFactor};
}
void BlendStateBuilder::SetColorWriteMask(nxt::ColorWriteMask colorWriteMask) {
void BlendStateBuilder::SetColorWriteMask(dawn::ColorWriteMask colorWriteMask) {
if ((mPropertiesSet & BLEND_STATE_PROPERTY_COLOR_WRITE_MASK) != 0) {
HandleError("Color write mask property set multiple times");
return;

View File

@ -29,15 +29,15 @@ namespace backend {
struct BlendInfo {
struct BlendOpFactor {
nxt::BlendOperation operation = nxt::BlendOperation::Add;
nxt::BlendFactor srcFactor = nxt::BlendFactor::One;
nxt::BlendFactor dstFactor = nxt::BlendFactor::Zero;
dawn::BlendOperation operation = dawn::BlendOperation::Add;
dawn::BlendFactor srcFactor = dawn::BlendFactor::One;
dawn::BlendFactor dstFactor = dawn::BlendFactor::Zero;
};
bool blendEnabled = false;
BlendOpFactor alphaBlend;
BlendOpFactor colorBlend;
nxt::ColorWriteMask colorWriteMask = nxt::ColorWriteMask::All;
dawn::ColorWriteMask colorWriteMask = dawn::ColorWriteMask::All;
};
const BlendInfo& GetBlendInfo() const;
@ -52,13 +52,13 @@ namespace backend {
// NXT API
void SetBlendEnabled(bool blendEnabled);
void SetAlphaBlend(nxt::BlendOperation blendOperation,
nxt::BlendFactor srcFactor,
nxt::BlendFactor dstFactor);
void SetColorBlend(nxt::BlendOperation blendOperation,
nxt::BlendFactor srcFactor,
nxt::BlendFactor dstFactor);
void SetColorWriteMask(nxt::ColorWriteMask colorWriteMask);
void SetAlphaBlend(dawn::BlendOperation blendOperation,
dawn::BlendFactor srcFactor,
dawn::BlendFactor dstFactor);
void SetColorBlend(dawn::BlendOperation blendOperation,
dawn::BlendFactor srcFactor,
dawn::BlendFactor dstFactor);
void SetColorWriteMask(dawn::ColorWriteMask colorWriteMask);
private:
friend class BlendStateBase;

View File

@ -47,7 +47,7 @@ namespace backend {
return mSize;
}
nxt::BufferUsageBit BufferBase::GetAllowedUsage() const {
dawn::BufferUsageBit BufferBase::GetAllowedUsage() const {
return mAllowedUsage;
}
@ -83,7 +83,7 @@ namespace backend {
return;
}
if (!(mAllowedUsage & nxt::BufferUsageBit::TransferDst)) {
if (!(mAllowedUsage & dawn::BufferUsageBit::TransferDst)) {
mDevice->HandleError("Buffer needs the transfer dst usage bit");
return;
}
@ -95,7 +95,7 @@ namespace backend {
uint32_t size,
nxtBufferMapReadCallback callback,
nxtCallbackUserdata userdata) {
if (!ValidateMapBase(start, size, nxt::BufferUsageBit::MapRead)) {
if (!ValidateMapBase(start, size, dawn::BufferUsageBit::MapRead)) {
callback(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
return;
}
@ -115,7 +115,7 @@ namespace backend {
uint32_t size,
nxtBufferMapWriteCallback callback,
nxtCallbackUserdata userdata) {
if (!ValidateMapBase(start, size, nxt::BufferUsageBit::MapWrite)) {
if (!ValidateMapBase(start, size, dawn::BufferUsageBit::MapWrite)) {
callback(NXT_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, userdata);
return;
}
@ -150,7 +150,7 @@ namespace backend {
bool BufferBase::ValidateMapBase(uint32_t start,
uint32_t size,
nxt::BufferUsageBit requiredUsage) {
dawn::BufferUsageBit requiredUsage) {
// TODO(cwallez@chromium.org): check for overflows.
if (start + size > GetSize()) {
mDevice->HandleError("Buffer map read out of range");
@ -187,17 +187,17 @@ namespace backend {
return nullptr;
}
const nxt::BufferUsageBit kMapWriteAllowedUsages =
nxt::BufferUsageBit::MapWrite | nxt::BufferUsageBit::TransferSrc;
if (mAllowedUsage & nxt::BufferUsageBit::MapWrite &&
const dawn::BufferUsageBit kMapWriteAllowedUsages =
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferSrc;
if (mAllowedUsage & dawn::BufferUsageBit::MapWrite &&
(mAllowedUsage & kMapWriteAllowedUsages) != mAllowedUsage) {
HandleError("Only TransferSrc is allowed with MapWrite");
return nullptr;
}
const nxt::BufferUsageBit kMapReadAllowedUsages =
nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferDst;
if (mAllowedUsage & nxt::BufferUsageBit::MapRead &&
const dawn::BufferUsageBit kMapReadAllowedUsages =
dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferDst;
if (mAllowedUsage & dawn::BufferUsageBit::MapRead &&
(mAllowedUsage & kMapReadAllowedUsages) != mAllowedUsage) {
HandleError("Only TransferDst is allowed with MapRead");
return nullptr;
@ -206,7 +206,7 @@ namespace backend {
return mDevice->CreateBuffer(this);
}
void BufferBuilder::SetAllowedUsage(nxt::BufferUsageBit usage) {
void BufferBuilder::SetAllowedUsage(dawn::BufferUsageBit usage) {
if ((mPropertiesSet & BUFFER_PROPERTY_ALLOWED_USAGE) != 0) {
HandleError("Buffer allowedUsage property set multiple times");
return;

View File

@ -23,13 +23,13 @@
namespace backend {
static constexpr nxt::BufferUsageBit kReadOnlyBufferUsages =
nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::TransferSrc |
nxt::BufferUsageBit::Index | nxt::BufferUsageBit::Vertex | nxt::BufferUsageBit::Uniform;
static constexpr dawn::BufferUsageBit kReadOnlyBufferUsages =
dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::TransferSrc |
dawn::BufferUsageBit::Index | dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Uniform;
static constexpr nxt::BufferUsageBit kWritableBufferUsages = nxt::BufferUsageBit::MapWrite |
nxt::BufferUsageBit::TransferDst |
nxt::BufferUsageBit::Storage;
static constexpr dawn::BufferUsageBit kWritableBufferUsages =
dawn::BufferUsageBit::MapWrite | dawn::BufferUsageBit::TransferDst |
dawn::BufferUsageBit::Storage;
class BufferBase : public RefCounted {
public:
@ -37,7 +37,7 @@ namespace backend {
~BufferBase();
uint32_t GetSize() const;
nxt::BufferUsageBit GetAllowedUsage() const;
dawn::BufferUsageBit GetAllowedUsage() const;
DeviceBase* GetDevice() const;
@ -66,11 +66,11 @@ namespace backend {
virtual void MapWriteAsyncImpl(uint32_t serial, uint32_t start, uint32_t size) = 0;
virtual void UnmapImpl() = 0;
bool ValidateMapBase(uint32_t start, uint32_t size, nxt::BufferUsageBit requiredUsage);
bool ValidateMapBase(uint32_t start, uint32_t size, dawn::BufferUsageBit requiredUsage);
DeviceBase* mDevice;
uint32_t mSize;
nxt::BufferUsageBit mAllowedUsage = nxt::BufferUsageBit::None;
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
nxtBufferMapReadCallback mMapReadCallback = nullptr;
nxtBufferMapWriteCallback mMapWriteCallback = nullptr;
@ -85,8 +85,8 @@ namespace backend {
BufferBuilder(DeviceBase* device);
// NXT API
void SetAllowedUsage(nxt::BufferUsageBit usage);
void SetInitialUsage(nxt::BufferUsageBit usage);
void SetAllowedUsage(dawn::BufferUsageBit usage);
void SetInitialUsage(dawn::BufferUsageBit usage);
void SetSize(uint32_t size);
private:
@ -95,8 +95,8 @@ namespace backend {
BufferBase* GetResultImpl() override;
uint32_t mSize;
nxt::BufferUsageBit mAllowedUsage = nxt::BufferUsageBit::None;
nxt::BufferUsageBit mCurrentUsage = nxt::BufferUsageBit::None;
dawn::BufferUsageBit mAllowedUsage = dawn::BufferUsageBit::None;
dawn::BufferUsageBit mCurrentUsage = dawn::BufferUsageBit::None;
int mPropertiesSet = 0;
};

View File

@ -28,12 +28,12 @@ namespace backend {
}
void BuilderBase::HandleError(const char* message) {
SetStatus(nxt::BuilderErrorStatus::Error, message);
SetStatus(dawn::BuilderErrorStatus::Error, message);
}
void BuilderBase::SetErrorCallback(nxt::BuilderErrorCallback callback,
nxt::CallbackUserdata userdata1,
nxt::CallbackUserdata userdata2) {
void BuilderBase::SetErrorCallback(dawn::BuilderErrorCallback callback,
dawn::CallbackUserdata userdata1,
dawn::CallbackUserdata userdata2) {
mCallback = callback;
mUserdata1 = userdata1;
mUserdata2 = userdata2;
@ -49,9 +49,9 @@ namespace backend {
}
}
void BuilderBase::SetStatus(nxt::BuilderErrorStatus status, const char* message) {
ASSERT(status != nxt::BuilderErrorStatus::Success);
ASSERT(status != nxt::BuilderErrorStatus::Unknown);
void BuilderBase::SetStatus(dawn::BuilderErrorStatus status, const char* message) {
ASSERT(status != dawn::BuilderErrorStatus::Success);
ASSERT(status != dawn::BuilderErrorStatus::Unknown);
ASSERT(!mGotStatus); // This is not strictly necessary but something to strive for.
mGotStatus = true;
@ -69,7 +69,7 @@ namespace backend {
// If we have any error, then we have to return nullptr
if (mGotStatus) {
ASSERT(mStoredStatus != nxt::BuilderErrorStatus::Success);
ASSERT(mStoredStatus != dawn::BuilderErrorStatus::Success);
// The application will never see "result" so we need to remove the
// external ref here.
@ -82,7 +82,7 @@ namespace backend {
if (!mCallback)
mDevice->HandleError(("Unhandled builder error: " + mStoredMessage).c_str());
} else {
ASSERT(mStoredStatus == nxt::BuilderErrorStatus::Success);
ASSERT(mStoredStatus == dawn::BuilderErrorStatus::Success);
ASSERT(mStoredMessage.empty());
}

View File

@ -50,9 +50,9 @@ namespace backend {
bool HandleResult(RefCounted* result);
// NXT API
void SetErrorCallback(nxt::BuilderErrorCallback callback,
nxt::CallbackUserdata userdata1,
nxt::CallbackUserdata userdata2);
void SetErrorCallback(dawn::BuilderErrorCallback callback,
dawn::CallbackUserdata userdata1,
dawn::CallbackUserdata userdata2);
protected:
BuilderBase(DeviceBase* device);
@ -62,13 +62,13 @@ namespace backend {
bool mGotStatus = false;
private:
void SetStatus(nxt::BuilderErrorStatus status, const char* message);
void SetStatus(dawn::BuilderErrorStatus status, const char* message);
nxt::BuilderErrorCallback mCallback = nullptr;
nxt::CallbackUserdata mUserdata1 = 0;
nxt::CallbackUserdata mUserdata2 = 0;
dawn::BuilderErrorCallback mCallback = nullptr;
dawn::CallbackUserdata mUserdata1 = 0;
dawn::CallbackUserdata mUserdata2 = 0;
nxt::BuilderErrorStatus mStoredStatus = nxt::BuilderErrorStatus::Success;
dawn::BuilderErrorStatus mStoredStatus = dawn::BuilderErrorStatus::Success;
std::string mStoredMessage;
bool mIsConsumed = false;

View File

@ -109,7 +109,7 @@ namespace backend {
return {};
}
MaybeError ValidateCanUseAs(BufferBase* buffer, nxt::BufferUsageBit usage) {
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
ASSERT(HasZeroOrOneBits(usage));
if (!(buffer->GetAllowedUsage() & usage)) {
NXT_RETURN_ERROR("buffer doesn't have the required usage.");
@ -118,7 +118,7 @@ namespace backend {
return {};
}
MaybeError ValidateCanUseAs(TextureBase* texture, nxt::TextureUsageBit usage) {
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsageBit usage) {
ASSERT(HasZeroOrOneBits(usage));
if (!(texture->GetAllowedUsage() & usage)) {
NXT_RETURN_ERROR("texture doesn't have the required usage.");
@ -138,26 +138,26 @@ namespace backend {
// information.
class PassResourceUsageTracker {
public:
void BufferUsedAs(BufferBase* buffer, nxt::BufferUsageBit usage) {
void BufferUsedAs(BufferBase* buffer, dawn::BufferUsageBit usage) {
// std::map's operator[] will create the key and return 0 if the key didn't exist
// before.
nxt::BufferUsageBit& storedUsage = mBufferUsages[buffer];
dawn::BufferUsageBit& storedUsage = mBufferUsages[buffer];
if (usage == nxt::BufferUsageBit::Storage &&
storedUsage & nxt::BufferUsageBit::Storage) {
if (usage == dawn::BufferUsageBit::Storage &&
storedUsage & dawn::BufferUsageBit::Storage) {
mStorageUsedMultipleTimes = true;
}
storedUsage |= usage;
}
void TextureUsedAs(TextureBase* texture, nxt::TextureUsageBit usage) {
void TextureUsedAs(TextureBase* texture, dawn::TextureUsageBit usage) {
// std::map's operator[] will create the key and return 0 if the key didn't exist
// before.
nxt::TextureUsageBit& storedUsage = mTextureUsages[texture];
dawn::TextureUsageBit& storedUsage = mTextureUsages[texture];
if (usage == nxt::TextureUsageBit::Storage &&
storedUsage & nxt::TextureUsageBit::Storage) {
if (usage == dawn::TextureUsageBit::Storage &&
storedUsage & dawn::TextureUsageBit::Storage) {
mStorageUsedMultipleTimes = true;
}
@ -174,14 +174,14 @@ namespace backend {
// Buffers can only be used as single-write or multiple read.
for (auto& it : mBufferUsages) {
BufferBase* buffer = it.first;
nxt::BufferUsageBit usage = it.second;
dawn::BufferUsageBit usage = it.second;
if (usage & ~buffer->GetAllowedUsage()) {
NXT_RETURN_ERROR("Buffer missing usage for the pass");
}
bool readOnly = (usage & kReadOnlyBufferUsages) == usage;
bool singleUse = nxt::HasZeroOrOneBits(usage);
bool singleUse = dawn::HasZeroOrOneBits(usage);
if (!readOnly && !singleUse) {
NXT_RETURN_ERROR(
@ -193,7 +193,7 @@ namespace backend {
// TODO(cwallez@chromium.org): implement per-subresource tracking
for (auto& it : mTextureUsages) {
TextureBase* texture = it.first;
nxt::TextureUsageBit usage = it.second;
dawn::TextureUsageBit usage = it.second;
if (usage & ~texture->GetAllowedUsage()) {
NXT_RETURN_ERROR("Texture missing usage for the pass");
@ -201,7 +201,7 @@ namespace backend {
// 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.
if (!nxt::HasZeroOrOneBits(it.second)) {
if (!dawn::HasZeroOrOneBits(it.second)) {
NXT_RETURN_ERROR("Texture used with more than one usage in pass");
}
}
@ -231,8 +231,8 @@ namespace backend {
}
private:
std::map<BufferBase*, nxt::BufferUsageBit> mBufferUsages;
std::map<TextureBase*, nxt::TextureUsageBit> mTextureUsages;
std::map<BufferBase*, dawn::BufferUsageBit> mBufferUsages;
std::map<TextureBase*, dawn::TextureUsageBit> mTextureUsages;
bool mStorageUsedMultipleTimes = false;
};
@ -240,25 +240,25 @@ namespace backend {
const auto& layoutInfo = group->GetLayout()->GetBindingInfo();
for (uint32_t i : IterateBitSet(layoutInfo.mask)) {
nxt::BindingType type = layoutInfo.types[i];
dawn::BindingType type = layoutInfo.types[i];
switch (type) {
case nxt::BindingType::UniformBuffer: {
case dawn::BindingType::UniformBuffer: {
BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
tracker->BufferUsedAs(buffer, nxt::BufferUsageBit::Uniform);
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Uniform);
} break;
case nxt::BindingType::StorageBuffer: {
case dawn::BindingType::StorageBuffer: {
BufferBase* buffer = group->GetBindingAsBufferView(i)->GetBuffer();
tracker->BufferUsedAs(buffer, nxt::BufferUsageBit::Storage);
tracker->BufferUsedAs(buffer, dawn::BufferUsageBit::Storage);
} break;
case nxt::BindingType::SampledTexture: {
case dawn::BindingType::SampledTexture: {
TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture();
tracker->TextureUsedAs(texture, nxt::TextureUsageBit::Sampled);
tracker->TextureUsedAs(texture, dawn::TextureUsageBit::Sampled);
} break;
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
break;
}
}
@ -339,9 +339,9 @@ namespace backend {
NXT_TRY(ValidateCopySizeFitsInBuffer(copy->destination, copy->size));
NXT_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
nxt::BufferUsageBit::TransferSrc));
dawn::BufferUsageBit::TransferSrc));
NXT_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
nxt::BufferUsageBit::TransferDst));
dawn::BufferUsageBit::TransferDst));
} break;
case Command::CopyBufferToTexture: {
@ -358,9 +358,9 @@ namespace backend {
ValidateTexelBufferOffset(copy->destination.texture.Get(), copy->source));
NXT_TRY(ValidateCanUseAs(copy->source.buffer.Get(),
nxt::BufferUsageBit::TransferSrc));
dawn::BufferUsageBit::TransferSrc));
NXT_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
nxt::TextureUsageBit::TransferDst));
dawn::TextureUsageBit::TransferDst));
} break;
case Command::CopyTextureToBuffer: {
@ -377,9 +377,9 @@ namespace backend {
ValidateTexelBufferOffset(copy->source.texture.Get(), copy->destination));
NXT_TRY(ValidateCanUseAs(copy->source.texture.Get(),
nxt::TextureUsageBit::TransferSrc));
dawn::TextureUsageBit::TransferSrc));
NXT_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
nxt::BufferUsageBit::TransferDst));
dawn::BufferUsageBit::TransferDst));
} break;
default:
@ -423,7 +423,7 @@ namespace backend {
// 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.
if (cmd->stages & ~nxt::ShaderStageBit::Compute) {
if (cmd->stages & ~dawn::ShaderStageBit::Compute) {
NXT_RETURN_ERROR(
"SetPushConstants stage must be compute or 0 in compute passes");
}
@ -450,12 +450,12 @@ namespace backend {
// Track usage of the render pass attachments
for (uint32_t i : IterateBitSet(renderPass->GetColorAttachmentMask())) {
TextureBase* texture = renderPass->GetColorAttachment(i).view->GetTexture();
usageTracker.TextureUsedAs(texture, nxt::TextureUsageBit::OutputAttachment);
usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
}
if (renderPass->HasDepthStencilAttachment()) {
TextureBase* texture = renderPass->GetDepthStencilAttachment().view->GetTexture();
usageTracker.TextureUsedAs(texture, nxt::TextureUsageBit::OutputAttachment);
usageTracker.TextureUsedAs(texture, dawn::TextureUsageBit::OutputAttachment);
}
Command type;
@ -499,7 +499,7 @@ namespace backend {
// recorded because it impacts the size of an allocation in the
// CommandAllocator.
if (cmd->stages &
~(nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment)) {
~(dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment)) {
NXT_RETURN_ERROR(
"SetPushConstants stage must be a subset of (vertex|fragment) in "
"render passes");
@ -528,7 +528,7 @@ namespace backend {
case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = mIterator.NextCommand<SetIndexBufferCmd>();
usageTracker.BufferUsedAs(cmd->buffer.Get(), nxt::BufferUsageBit::Index);
usageTracker.BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsageBit::Index);
NXT_TRY(mState->SetIndexBuffer());
} break;
@ -538,7 +538,7 @@ namespace backend {
mIterator.NextData<uint32_t>(cmd->count);
for (uint32_t i = 0; i < cmd->count; ++i) {
usageTracker.BufferUsedAs(buffers[i].Get(), nxt::BufferUsageBit::Vertex);
usageTracker.BufferUsedAs(buffers[i].Get(), dawn::BufferUsageBit::Vertex);
NXT_TRY(mState->SetVertexBuffer(cmd->startSlot + i));
}
} break;
@ -692,7 +692,7 @@ namespace backend {
cmd->pipeline = pipeline;
}
void CommandBufferBuilder::SetPushConstants(nxt::ShaderStageBit stages,
void CommandBufferBuilder::SetPushConstants(dawn::ShaderStageBit stages,
uint32_t offset,
uint32_t count,
const void* data) {

View File

@ -101,7 +101,7 @@ namespace backend {
uint32_t firstInstance);
void EndComputePass();
void EndRenderPass();
void SetPushConstants(nxt::ShaderStageBit stages,
void SetPushConstants(dawn::ShaderStageBit stages,
uint32_t offset,
uint32_t count,
const void* data);
@ -127,7 +127,7 @@ namespace backend {
BufferBase* const* buffers,
uint32_t const* offsets);
void TransitionBufferUsage(BufferBase* buffer, nxt::BufferUsageBit usage);
void TransitionBufferUsage(BufferBase* buffer, dawn::BufferUsageBit usage);
private:
friend class CommandBufferBase;

View File

@ -117,7 +117,7 @@ namespace backend {
};
struct SetPushConstantsCmd {
nxt::ShaderStageBit stages;
dawn::ShaderStageBit stages;
uint32_t offset;
uint32_t count;
};

View File

@ -22,7 +22,7 @@ namespace backend {
ComputePipelineBase::ComputePipelineBase(ComputePipelineBuilder* builder)
: PipelineBase(builder) {
if (GetStageMask() != nxt::ShaderStageBit::Compute) {
if (GetStageMask() != dawn::ShaderStageBit::Compute) {
builder->HandleError("Compute pipeline should have exactly a compute stage");
return;
}

View File

@ -25,14 +25,14 @@ namespace backend {
}
bool DepthStencilStateBase::StencilTestEnabled() const {
return mStencilInfo.back.compareFunction != nxt::CompareFunction::Always ||
mStencilInfo.back.stencilFail != nxt::StencilOperation::Keep ||
mStencilInfo.back.depthFail != nxt::StencilOperation::Keep ||
mStencilInfo.back.depthStencilPass != nxt::StencilOperation::Keep ||
mStencilInfo.front.compareFunction != nxt::CompareFunction::Always ||
mStencilInfo.front.stencilFail != nxt::StencilOperation::Keep ||
mStencilInfo.front.depthFail != nxt::StencilOperation::Keep ||
mStencilInfo.front.depthStencilPass != nxt::StencilOperation::Keep;
return mStencilInfo.back.compareFunction != dawn::CompareFunction::Always ||
mStencilInfo.back.stencilFail != dawn::StencilOperation::Keep ||
mStencilInfo.back.depthFail != dawn::StencilOperation::Keep ||
mStencilInfo.back.depthStencilPass != dawn::StencilOperation::Keep ||
mStencilInfo.front.compareFunction != dawn::CompareFunction::Always ||
mStencilInfo.front.stencilFail != dawn::StencilOperation::Keep ||
mStencilInfo.front.depthFail != dawn::StencilOperation::Keep ||
mStencilInfo.front.depthStencilPass != dawn::StencilOperation::Keep;
}
const DepthStencilStateBase::DepthInfo& DepthStencilStateBase::GetDepth() const {
@ -61,7 +61,7 @@ namespace backend {
}
void DepthStencilStateBuilder::SetDepthCompareFunction(
nxt::CompareFunction depthCompareFunction) {
dawn::CompareFunction depthCompareFunction) {
if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_DEPTH_COMPARE_FUNCTION) != 0) {
HandleError("Depth compare property set multiple times");
return;
@ -83,17 +83,17 @@ namespace backend {
mDepthInfo.depthWriteEnabled = enabled;
}
void DepthStencilStateBuilder::SetStencilFunction(nxt::Face face,
nxt::CompareFunction stencilCompareFunction,
nxt::StencilOperation stencilFail,
nxt::StencilOperation depthFail,
nxt::StencilOperation depthStencilPass) {
if (face == nxt::Face::None) {
void DepthStencilStateBuilder::SetStencilFunction(dawn::Face face,
dawn::CompareFunction stencilCompareFunction,
dawn::StencilOperation stencilFail,
dawn::StencilOperation depthFail,
dawn::StencilOperation depthStencilPass) {
if (face == dawn::Face::None) {
HandleError("Can't set stencil function of None face");
return;
}
if (face & nxt::Face::Back) {
if (face & dawn::Face::Back) {
if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_STENCIL_BACK_FUNCTION) != 0) {
HandleError("Stencil back function property set multiple times");
return;
@ -106,7 +106,7 @@ namespace backend {
mStencilInfo.back.depthFail = depthFail;
mStencilInfo.back.depthStencilPass = depthStencilPass;
}
if (face & nxt::Face::Front) {
if (face & dawn::Face::Front) {
if ((mPropertiesSet & DEPTH_STENCIL_STATE_PROPERTY_STENCIL_FRONT_FUNCTION) != 0) {
HandleError("Stencil front function property set multiple times");
return;

View File

@ -28,15 +28,15 @@ namespace backend {
DepthStencilStateBase(DepthStencilStateBuilder* builder);
struct DepthInfo {
nxt::CompareFunction compareFunction = nxt::CompareFunction::Always;
dawn::CompareFunction compareFunction = dawn::CompareFunction::Always;
bool depthWriteEnabled = false;
};
struct StencilFaceInfo {
nxt::CompareFunction compareFunction = nxt::CompareFunction::Always;
nxt::StencilOperation stencilFail = nxt::StencilOperation::Keep;
nxt::StencilOperation depthFail = nxt::StencilOperation::Keep;
nxt::StencilOperation depthStencilPass = nxt::StencilOperation::Keep;
dawn::CompareFunction compareFunction = dawn::CompareFunction::Always;
dawn::StencilOperation stencilFail = dawn::StencilOperation::Keep;
dawn::StencilOperation depthFail = dawn::StencilOperation::Keep;
dawn::StencilOperation depthStencilPass = dawn::StencilOperation::Keep;
};
struct StencilInfo {
@ -60,13 +60,13 @@ namespace backend {
DepthStencilStateBuilder(DeviceBase* device);
// NXT API
void SetDepthCompareFunction(nxt::CompareFunction depthCompareFunction);
void SetDepthCompareFunction(dawn::CompareFunction depthCompareFunction);
void SetDepthWriteEnabled(bool enabled);
void SetStencilFunction(nxt::Face face,
nxt::CompareFunction stencilCompareFunction,
nxt::StencilOperation stencilFail,
nxt::StencilOperation depthFail,
nxt::StencilOperation depthStencilPass);
void SetStencilFunction(dawn::Face face,
dawn::CompareFunction stencilCompareFunction,
dawn::StencilOperation stencilFail,
dawn::StencilOperation depthFail,
dawn::StencilOperation depthStencilPass);
void SetStencilMask(uint32_t readMask, uint32_t writeMask);
private:

View File

@ -63,8 +63,8 @@ namespace backend {
}
}
void DeviceBase::SetErrorCallback(nxt::DeviceErrorCallback callback,
nxt::CallbackUserdata userdata) {
void DeviceBase::SetErrorCallback(dawn::DeviceErrorCallback callback,
dawn::CallbackUserdata userdata) {
mErrorCallback = callback;
mErrorUserdata = userdata;
}
@ -74,7 +74,7 @@ namespace backend {
}
ResultOrError<BindGroupLayoutBase*> DeviceBase::GetOrCreateBindGroupLayout(
const nxt::BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
BindGroupLayoutBase blueprint(this, descriptor, true);
auto iter = mCaches->bindGroupLayouts.find(&blueprint);
@ -99,7 +99,7 @@ namespace backend {
return new BindGroupBuilder(this);
}
BindGroupLayoutBase* DeviceBase::CreateBindGroupLayout(
const nxt::BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
BindGroupLayoutBase* result = nullptr;
if (ConsumedError(CreateBindGroupLayoutInternal(&result, descriptor))) {
@ -127,7 +127,7 @@ namespace backend {
return new InputStateBuilder(this);
}
PipelineLayoutBase* DeviceBase::CreatePipelineLayout(
const nxt::PipelineLayoutDescriptor* descriptor) {
const dawn::PipelineLayoutDescriptor* descriptor) {
PipelineLayoutBase* result = nullptr;
if (ConsumedError(CreatePipelineLayoutInternal(&result, descriptor))) {
@ -151,7 +151,7 @@ namespace backend {
RenderPipelineBuilder* DeviceBase::CreateRenderPipelineBuilder() {
return new RenderPipelineBuilder(this);
}
SamplerBase* DeviceBase::CreateSampler(const nxt::SamplerDescriptor* descriptor) {
SamplerBase* DeviceBase::CreateSampler(const dawn::SamplerDescriptor* descriptor) {
SamplerBase* result = nullptr;
if (ConsumedError(CreateSamplerInternal(&result, descriptor))) {
@ -193,7 +193,7 @@ namespace backend {
MaybeError DeviceBase::CreateBindGroupLayoutInternal(
BindGroupLayoutBase** result,
const nxt::BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
NXT_TRY(ValidateBindGroupLayoutDescriptor(this, descriptor));
NXT_TRY_ASSIGN(*result, GetOrCreateBindGroupLayout(descriptor));
return {};
@ -201,7 +201,7 @@ namespace backend {
MaybeError DeviceBase::CreatePipelineLayoutInternal(
PipelineLayoutBase** result,
const nxt::PipelineLayoutDescriptor* descriptor) {
const dawn::PipelineLayoutDescriptor* descriptor) {
NXT_TRY(ValidatePipelineLayoutDescriptor(this, descriptor));
NXT_TRY_ASSIGN(*result, CreatePipelineLayoutImpl(descriptor));
return {};
@ -213,7 +213,7 @@ namespace backend {
}
MaybeError DeviceBase::CreateSamplerInternal(SamplerBase** result,
const nxt::SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
NXT_TRY(ValidateSamplerDescriptor(this, descriptor));
NXT_TRY_ASSIGN(*result, CreateSamplerImpl(descriptor));
return {};

View File

@ -77,49 +77,49 @@ namespace backend {
// instead of a backend Foo object. If the blueprint doesn't match an object in the
// cache, then the builder is used to make a new object.
ResultOrError<BindGroupLayoutBase*> GetOrCreateBindGroupLayout(
const nxt::BindGroupLayoutDescriptor* descriptor);
const dawn::BindGroupLayoutDescriptor* descriptor);
void UncacheBindGroupLayout(BindGroupLayoutBase* obj);
// NXT API
BindGroupBuilder* CreateBindGroupBuilder();
BindGroupLayoutBase* CreateBindGroupLayout(
const nxt::BindGroupLayoutDescriptor* descriptor);
const dawn::BindGroupLayoutDescriptor* descriptor);
BlendStateBuilder* CreateBlendStateBuilder();
BufferBuilder* CreateBufferBuilder();
CommandBufferBuilder* CreateCommandBufferBuilder();
ComputePipelineBuilder* CreateComputePipelineBuilder();
DepthStencilStateBuilder* CreateDepthStencilStateBuilder();
InputStateBuilder* CreateInputStateBuilder();
PipelineLayoutBase* CreatePipelineLayout(const nxt::PipelineLayoutDescriptor* descriptor);
PipelineLayoutBase* CreatePipelineLayout(const dawn::PipelineLayoutDescriptor* descriptor);
QueueBase* CreateQueue();
RenderPassDescriptorBuilder* CreateRenderPassDescriptorBuilder();
RenderPipelineBuilder* CreateRenderPipelineBuilder();
SamplerBase* CreateSampler(const nxt::SamplerDescriptor* descriptor);
SamplerBase* CreateSampler(const dawn::SamplerDescriptor* descriptor);
ShaderModuleBuilder* CreateShaderModuleBuilder();
SwapChainBuilder* CreateSwapChainBuilder();
TextureBuilder* CreateTextureBuilder();
void Tick();
void SetErrorCallback(nxt::DeviceErrorCallback callback, nxt::CallbackUserdata userdata);
void SetErrorCallback(dawn::DeviceErrorCallback callback, dawn::CallbackUserdata userdata);
void Reference();
void Release();
private:
virtual ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) = 0;
const dawn::BindGroupLayoutDescriptor* descriptor) = 0;
virtual ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) = 0;
const dawn::PipelineLayoutDescriptor* descriptor) = 0;
virtual ResultOrError<QueueBase*> CreateQueueImpl() = 0;
virtual ResultOrError<SamplerBase*> CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) = 0;
const dawn::SamplerDescriptor* descriptor) = 0;
MaybeError CreateBindGroupLayoutInternal(BindGroupLayoutBase** result,
const nxt::BindGroupLayoutDescriptor* descriptor);
const dawn::BindGroupLayoutDescriptor* descriptor);
MaybeError CreatePipelineLayoutInternal(PipelineLayoutBase** result,
const nxt::PipelineLayoutDescriptor* descriptor);
const dawn::PipelineLayoutDescriptor* descriptor);
MaybeError CreateQueueInternal(QueueBase** result);
MaybeError CreateSamplerInternal(SamplerBase** result,
const nxt::SamplerDescriptor* descriptor);
const dawn::SamplerDescriptor* descriptor);
void ConsumeError(ErrorData* error);
@ -128,8 +128,8 @@ namespace backend {
struct Caches;
Caches* mCaches = nullptr;
nxt::DeviceErrorCallback mErrorCallback = nullptr;
nxt::CallbackUserdata mErrorUserdata = 0;
dawn::DeviceErrorCallback mErrorCallback = nullptr;
dawn::CallbackUserdata mErrorUserdata = 0;
uint32_t mRefCount = 1;
};

View File

@ -21,64 +21,64 @@ namespace backend {
// InputState helpers
size_t IndexFormatSize(nxt::IndexFormat format) {
size_t IndexFormatSize(dawn::IndexFormat format) {
switch (format) {
case nxt::IndexFormat::Uint16:
case dawn::IndexFormat::Uint16:
return sizeof(uint16_t);
case nxt::IndexFormat::Uint32:
case dawn::IndexFormat::Uint32:
return sizeof(uint32_t);
default:
UNREACHABLE();
}
}
uint32_t VertexFormatNumComponents(nxt::VertexFormat format) {
uint32_t VertexFormatNumComponents(dawn::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::IntR32G32B32A32:
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UnormR8G8B8A8:
case dawn::VertexFormat::FloatR32G32B32A32:
case dawn::VertexFormat::IntR32G32B32A32:
case dawn::VertexFormat::UshortR16G16B16A16:
case dawn::VertexFormat::UnormR8G8B8A8:
return 4;
case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::IntR32G32B32:
case dawn::VertexFormat::FloatR32G32B32:
case dawn::VertexFormat::IntR32G32B32:
return 3;
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::IntR32G32:
case nxt::VertexFormat::UshortR16G16:
case nxt::VertexFormat::UnormR8G8:
case dawn::VertexFormat::FloatR32G32:
case dawn::VertexFormat::IntR32G32:
case dawn::VertexFormat::UshortR16G16:
case dawn::VertexFormat::UnormR8G8:
return 2;
case nxt::VertexFormat::FloatR32:
case nxt::VertexFormat::IntR32:
case dawn::VertexFormat::FloatR32:
case dawn::VertexFormat::IntR32:
return 1;
default:
UNREACHABLE();
}
}
size_t VertexFormatComponentSize(nxt::VertexFormat format) {
size_t VertexFormatComponentSize(dawn::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
case dawn::VertexFormat::FloatR32G32B32A32:
case dawn::VertexFormat::FloatR32G32B32:
case dawn::VertexFormat::FloatR32G32:
case dawn::VertexFormat::FloatR32:
return sizeof(float);
case nxt::VertexFormat::IntR32G32B32A32:
case nxt::VertexFormat::IntR32G32B32:
case nxt::VertexFormat::IntR32G32:
case nxt::VertexFormat::IntR32:
case dawn::VertexFormat::IntR32G32B32A32:
case dawn::VertexFormat::IntR32G32B32:
case dawn::VertexFormat::IntR32G32:
case dawn::VertexFormat::IntR32:
return sizeof(int32_t);
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UshortR16G16:
case dawn::VertexFormat::UshortR16G16B16A16:
case dawn::VertexFormat::UshortR16G16:
return sizeof(uint16_t);
case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8:
case dawn::VertexFormat::UnormR8G8B8A8:
case dawn::VertexFormat::UnormR8G8:
return sizeof(uint8_t);
default:
UNREACHABLE();
}
}
size_t VertexFormatSize(nxt::VertexFormat format) {
size_t VertexFormatSize(dawn::VertexFormat format) {
return VertexFormatNumComponents(format) * VertexFormatComponentSize(format);
}
@ -128,7 +128,7 @@ namespace backend {
void InputStateBuilder::SetAttribute(uint32_t shaderLocation,
uint32_t bindingSlot,
nxt::VertexFormat format,
dawn::VertexFormat format,
uint32_t offset) {
if (shaderLocation >= kMaxVertexAttributes) {
HandleError("Setting attribute out of bounds");
@ -152,7 +152,7 @@ namespace backend {
void InputStateBuilder::SetInput(uint32_t bindingSlot,
uint32_t stride,
nxt::InputStepMode stepMode) {
dawn::InputStepMode stepMode) {
if (bindingSlot >= kMaxVertexInputs) {
HandleError("Setting input out of bounds");
return;

View File

@ -27,10 +27,10 @@
namespace backend {
size_t IndexFormatSize(nxt::IndexFormat format);
uint32_t VertexFormatNumComponents(nxt::VertexFormat format);
size_t VertexFormatComponentSize(nxt::VertexFormat format);
size_t VertexFormatSize(nxt::VertexFormat format);
size_t IndexFormatSize(dawn::IndexFormat format);
uint32_t VertexFormatNumComponents(dawn::VertexFormat format);
size_t VertexFormatComponentSize(dawn::VertexFormat format);
size_t VertexFormatSize(dawn::VertexFormat format);
class InputStateBase : public RefCounted {
public:
@ -38,13 +38,13 @@ namespace backend {
struct AttributeInfo {
uint32_t bindingSlot;
nxt::VertexFormat format;
dawn::VertexFormat format;
uint32_t offset;
};
struct InputInfo {
uint32_t stride;
nxt::InputStepMode stepMode;
dawn::InputStepMode stepMode;
};
const std::bitset<kMaxVertexAttributes>& GetAttributesSetMask() const;
@ -66,9 +66,9 @@ namespace backend {
// NXT API
void SetAttribute(uint32_t shaderLocation,
uint32_t bindingSlot,
nxt::VertexFormat format,
dawn::VertexFormat format,
uint32_t offset);
void SetInput(uint32_t bindingSlot, uint32_t stride, nxt::InputStepMode stepMode);
void SetInput(uint32_t bindingSlot, uint32_t stride, dawn::InputStepMode stepMode);
private:
friend class InputStateBase;

View File

@ -29,10 +29,10 @@ namespace backend {
// re-compute it.
struct PassResourceUsage {
std::vector<BufferBase*> buffers;
std::vector<nxt::BufferUsageBit> bufferUsages;
std::vector<dawn::BufferUsageBit> bufferUsages;
std::vector<TextureBase*> textures;
std::vector<nxt::TextureUsageBit> textureUsages;
std::vector<dawn::TextureUsageBit> textureUsages;
};
} // namespace backend

View File

@ -16,14 +16,14 @@
namespace backend {
BitSetIterator<kNumStages, nxt::ShaderStage> IterateStages(nxt::ShaderStageBit stages) {
BitSetIterator<kNumStages, dawn::ShaderStage> IterateStages(dawn::ShaderStageBit stages) {
std::bitset<kNumStages> bits(static_cast<uint32_t>(stages));
return BitSetIterator<kNumStages, nxt::ShaderStage>(bits);
return BitSetIterator<kNumStages, dawn::ShaderStage>(bits);
}
nxt::ShaderStageBit StageBit(nxt::ShaderStage stage) {
dawn::ShaderStageBit StageBit(dawn::ShaderStage stage) {
ASSERT(static_cast<uint32_t>(stage) < kNumStages);
return static_cast<nxt::ShaderStageBit>(1 << static_cast<uint32_t>(stage));
return static_cast<dawn::ShaderStageBit>(1 << static_cast<uint32_t>(stage));
}
} // namespace backend

View File

@ -25,44 +25,44 @@
namespace backend {
static_assert(static_cast<uint32_t>(nxt::ShaderStage::Vertex) < kNumStages, "");
static_assert(static_cast<uint32_t>(nxt::ShaderStage::Fragment) < kNumStages, "");
static_assert(static_cast<uint32_t>(nxt::ShaderStage::Compute) < kNumStages, "");
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Vertex) < kNumStages, "");
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Fragment) < kNumStages, "");
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Compute) < kNumStages, "");
static_assert(static_cast<uint32_t>(nxt::ShaderStageBit::Vertex) ==
(1 << static_cast<uint32_t>(nxt::ShaderStage::Vertex)),
static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Vertex) ==
(1 << static_cast<uint32_t>(dawn::ShaderStage::Vertex)),
"");
static_assert(static_cast<uint32_t>(nxt::ShaderStageBit::Fragment) ==
(1 << static_cast<uint32_t>(nxt::ShaderStage::Fragment)),
static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Fragment) ==
(1 << static_cast<uint32_t>(dawn::ShaderStage::Fragment)),
"");
static_assert(static_cast<uint32_t>(nxt::ShaderStageBit::Compute) ==
(1 << static_cast<uint32_t>(nxt::ShaderStage::Compute)),
static_assert(static_cast<uint32_t>(dawn::ShaderStageBit::Compute) ==
(1 << static_cast<uint32_t>(dawn::ShaderStage::Compute)),
"");
BitSetIterator<kNumStages, nxt::ShaderStage> IterateStages(nxt::ShaderStageBit stages);
nxt::ShaderStageBit StageBit(nxt::ShaderStage stage);
BitSetIterator<kNumStages, dawn::ShaderStage> IterateStages(dawn::ShaderStageBit stages);
dawn::ShaderStageBit StageBit(dawn::ShaderStage stage);
static constexpr nxt::ShaderStageBit kAllStages =
static_cast<nxt::ShaderStageBit>((1 << kNumStages) - 1);
static constexpr dawn::ShaderStageBit kAllStages =
static_cast<dawn::ShaderStageBit>((1 << kNumStages) - 1);
template <typename T>
class PerStage {
public:
T& operator[](nxt::ShaderStage stage) {
T& operator[](dawn::ShaderStage stage) {
NXT_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
return mData[static_cast<uint32_t>(stage)];
}
const T& operator[](nxt::ShaderStage stage) const {
const T& operator[](dawn::ShaderStage stage) const {
NXT_ASSERT(static_cast<uint32_t>(stage) < kNumStages);
return mData[static_cast<uint32_t>(stage)];
}
T& operator[](nxt::ShaderStageBit stageBit) {
T& operator[](dawn::ShaderStageBit stageBit) {
uint32_t bit = static_cast<uint32_t>(stageBit);
NXT_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
return mData[Log2(bit)];
}
const T& operator[](nxt::ShaderStageBit stageBit) const {
const T& operator[](dawn::ShaderStageBit stageBit) const {
uint32_t bit = static_cast<uint32_t>(stageBit);
NXT_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
return mData[Log2(bit)];

View File

@ -27,7 +27,7 @@ namespace backend {
PipelineBase::PipelineBase(PipelineBuilder* builder)
: mStageMask(builder->mStageMask), mLayout(std::move(builder->mLayout)) {
if (!mLayout) {
nxt::PipelineLayoutDescriptor descriptor;
dawn::PipelineLayoutDescriptor descriptor;
descriptor.numBindGroupLayouts = 0;
descriptor.bindGroupLayouts = nullptr;
mLayout = builder->GetParentBuilder()->GetDevice()->CreatePipelineLayout(&descriptor);
@ -63,11 +63,11 @@ namespace backend {
}
const PipelineBase::PushConstantInfo& PipelineBase::GetPushConstants(
nxt::ShaderStage stage) const {
dawn::ShaderStage stage) const {
return mPushConstants[stage];
}
nxt::ShaderStageBit PipelineBase::GetStageMask() const {
dawn::ShaderStageBit PipelineBase::GetStageMask() const {
return mStageMask;
}
@ -78,10 +78,10 @@ namespace backend {
// PipelineBuilder
PipelineBuilder::PipelineBuilder(BuilderBase* parentBuilder)
: mParentBuilder(parentBuilder), mStageMask(static_cast<nxt::ShaderStageBit>(0)) {
: mParentBuilder(parentBuilder), mStageMask(static_cast<dawn::ShaderStageBit>(0)) {
}
const PipelineBuilder::StageInfo& PipelineBuilder::GetStageInfo(nxt::ShaderStage stage) const {
const PipelineBuilder::StageInfo& PipelineBuilder::GetStageInfo(dawn::ShaderStage stage) const {
ASSERT(mStageMask & StageBit(stage));
return mStages[stage];
}
@ -94,7 +94,7 @@ namespace backend {
mLayout = layout;
}
void PipelineBuilder::SetStage(nxt::ShaderStage stage,
void PipelineBuilder::SetStage(dawn::ShaderStage stage,
ShaderModuleBase* module,
const char* entryPoint) {
if (entryPoint != std::string("main")) {
@ -107,7 +107,7 @@ namespace backend {
return;
}
nxt::ShaderStageBit bit = StageBit(stage);
dawn::ShaderStageBit bit = StageBit(stage);
if (mStageMask & bit) {
mParentBuilder->HandleError("Setting already set stage");
return;

View File

@ -45,13 +45,13 @@ namespace backend {
std::bitset<kMaxPushConstants> mask;
std::array<PushConstantType, kMaxPushConstants> types;
};
const PushConstantInfo& GetPushConstants(nxt::ShaderStage stage) const;
nxt::ShaderStageBit GetStageMask() const;
const PushConstantInfo& GetPushConstants(dawn::ShaderStage stage) const;
dawn::ShaderStageBit GetStageMask() const;
PipelineLayoutBase* GetLayout();
private:
nxt::ShaderStageBit mStageMask;
dawn::ShaderStageBit mStageMask;
Ref<PipelineLayoutBase> mLayout;
PerStage<PushConstantInfo> mPushConstants;
};
@ -64,19 +64,19 @@ namespace backend {
std::string entryPoint;
Ref<ShaderModuleBase> module;
};
const StageInfo& GetStageInfo(nxt::ShaderStage stage) const;
const StageInfo& GetStageInfo(dawn::ShaderStage stage) const;
BuilderBase* GetParentBuilder() const;
// NXT API
void SetLayout(PipelineLayoutBase* layout);
void SetStage(nxt::ShaderStage stage, ShaderModuleBase* module, const char* entryPoint);
void SetStage(dawn::ShaderStage stage, ShaderModuleBase* module, const char* entryPoint);
private:
friend class PipelineBase;
BuilderBase* mParentBuilder;
Ref<PipelineLayoutBase> mLayout;
nxt::ShaderStageBit mStageMask;
dawn::ShaderStageBit mStageMask;
PerStage<StageInfo> mStages;
};

View File

@ -21,7 +21,7 @@
namespace backend {
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*,
const nxt::PipelineLayoutDescriptor* descriptor) {
const dawn::PipelineLayoutDescriptor* descriptor) {
NXT_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
NXT_TRY_ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups,
"too many bind group layouts");
@ -35,7 +35,7 @@ namespace backend {
// PipelineLayoutBase
PipelineLayoutBase::PipelineLayoutBase(DeviceBase* device,
const nxt::PipelineLayoutDescriptor* descriptor)
const dawn::PipelineLayoutDescriptor* descriptor)
: mDevice(device) {
ASSERT(descriptor->numBindGroupLayouts <= kMaxBindGroups);
for (uint32_t group = 0; group < descriptor->numBindGroupLayouts; ++group) {

View File

@ -28,13 +28,13 @@
namespace backend {
MaybeError ValidatePipelineLayoutDescriptor(DeviceBase*,
const nxt::PipelineLayoutDescriptor* descriptor);
const dawn::PipelineLayoutDescriptor* descriptor);
using BindGroupLayoutArray = std::array<Ref<BindGroupLayoutBase>, kMaxBindGroups>;
class PipelineLayoutBase : public RefCounted {
public:
PipelineLayoutBase(DeviceBase* device, const nxt::PipelineLayoutDescriptor* descriptor);
PipelineLayoutBase(DeviceBase* device, const dawn::PipelineLayoutDescriptor* descriptor);
const BindGroupLayoutBase* GetBindGroupLayout(size_t group) const;
const std::bitset<kMaxBindGroups> GetBindGroupLayoutsMask() const;

View File

@ -126,7 +126,7 @@ namespace backend {
void RenderPassDescriptorBuilder::SetColorAttachment(uint32_t attachment,
TextureViewBase* textureView,
nxt::LoadOp loadOp) {
dawn::LoadOp loadOp) {
if (attachment >= kMaxColorAttachments) {
HandleError("Setting color attachment out of bounds");
return;
@ -159,8 +159,8 @@ namespace backend {
}
void RenderPassDescriptorBuilder::SetDepthStencilAttachment(TextureViewBase* textureView,
nxt::LoadOp depthLoadOp,
nxt::LoadOp stencilLoadOp) {
dawn::LoadOp depthLoadOp,
dawn::LoadOp stencilLoadOp) {
if (!TextureFormatHasDepthOrStencil(textureView->GetTexture()->GetFormat())) {
HandleError("Using color texture as depth stencil attachment");
return;

View File

@ -29,14 +29,14 @@
namespace backend {
struct RenderPassColorAttachmentInfo {
nxt::LoadOp loadOp;
dawn::LoadOp loadOp;
std::array<float, 4> clearColor = {{0.0f, 0.0f, 0.0f, 0.0f}};
Ref<TextureViewBase> view;
};
struct RenderPassDepthStencilAttachmentInfo {
nxt::LoadOp depthLoadOp;
nxt::LoadOp stencilLoadOp;
dawn::LoadOp depthLoadOp;
dawn::LoadOp stencilLoadOp;
float clearDepth = 1.0f;
uint32_t clearStencil = 0;
Ref<TextureViewBase> view;
@ -80,15 +80,15 @@ namespace backend {
RenderPassDescriptorBase* GetResultImpl() override;
void SetColorAttachment(uint32_t attachment,
TextureViewBase* textureView,
nxt::LoadOp loadOp);
dawn::LoadOp loadOp);
void SetColorAttachmentClearColor(uint32_t attachment,
float clearR,
float clearG,
float clearB,
float clearA);
void SetDepthStencilAttachment(TextureViewBase* textureView,
nxt::LoadOp depthLoadOp,
nxt::LoadOp stencilLoadOp);
dawn::LoadOp depthLoadOp,
dawn::LoadOp stencilLoadOp);
void SetDepthStencilAttachmentClearValue(float clearDepth, uint32_t clearStencil);
private:

View File

@ -37,14 +37,14 @@ namespace backend {
mColorAttachmentFormats(builder->mColorAttachmentFormats),
mDepthStencilFormatSet(builder->mDepthStencilFormatSet),
mDepthStencilFormat(builder->mDepthStencilFormat) {
if (GetStageMask() != (nxt::ShaderStageBit::Vertex | nxt::ShaderStageBit::Fragment)) {
if (GetStageMask() != (dawn::ShaderStageBit::Vertex | dawn::ShaderStageBit::Fragment)) {
builder->HandleError("Render pipeline should have exactly a vertex and fragment stage");
return;
}
// TODO(kainino@chromium.org): Need to verify the pipeline against its render subpass.
if ((builder->GetStageInfo(nxt::ShaderStage::Vertex).module->GetUsedVertexAttributes() &
if ((builder->GetStageInfo(dawn::ShaderStage::Vertex).module->GetUsedVertexAttributes() &
~mInputState->GetAttributesSetMask())
.any()) {
builder->HandleError("Pipeline vertex stage uses inputs not in the input state");
@ -74,7 +74,7 @@ namespace backend {
return mDepthStencilState.Get();
}
nxt::IndexFormat RenderPipelineBase::GetIndexFormat() const {
dawn::IndexFormat RenderPipelineBase::GetIndexFormat() const {
return mIndexFormat;
}
@ -82,7 +82,7 @@ namespace backend {
return mInputState.Get();
}
nxt::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const {
dawn::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const {
return mPrimitiveTopology;
}
@ -94,11 +94,11 @@ namespace backend {
return mDepthStencilFormatSet;
}
nxt::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(uint32_t attachment) const {
dawn::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(uint32_t attachment) const {
return mColorAttachmentFormats[attachment];
}
nxt::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const {
dawn::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const {
return mDepthStencilFormat;
}
@ -172,7 +172,7 @@ namespace backend {
}
void RenderPipelineBuilder::SetColorAttachmentFormat(uint32_t attachmentSlot,
nxt::TextureFormat format) {
dawn::TextureFormat format) {
if (attachmentSlot >= kMaxColorAttachments) {
HandleError("Attachment index out of bounds");
return;
@ -201,12 +201,12 @@ namespace backend {
mDepthStencilState = depthStencilState;
}
void RenderPipelineBuilder::SetDepthStencilAttachmentFormat(nxt::TextureFormat format) {
void RenderPipelineBuilder::SetDepthStencilAttachmentFormat(dawn::TextureFormat format) {
mDepthStencilFormatSet = true;
mDepthStencilFormat = format;
}
void RenderPipelineBuilder::SetIndexFormat(nxt::IndexFormat format) {
void RenderPipelineBuilder::SetIndexFormat(dawn::IndexFormat format) {
mIndexFormat = format;
}
@ -214,7 +214,7 @@ namespace backend {
mInputState = inputState;
}
void RenderPipelineBuilder::SetPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology) {
void RenderPipelineBuilder::SetPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
mPrimitiveTopology = primitiveTopology;
}

View File

@ -33,14 +33,14 @@ namespace backend {
BlendStateBase* GetBlendState(uint32_t attachmentSlot);
DepthStencilStateBase* GetDepthStencilState();
nxt::IndexFormat GetIndexFormat() const;
dawn::IndexFormat GetIndexFormat() const;
InputStateBase* GetInputState();
nxt::PrimitiveTopology GetPrimitiveTopology() const;
dawn::PrimitiveTopology GetPrimitiveTopology() const;
std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const;
bool HasDepthStencilAttachment() const;
nxt::TextureFormat GetColorAttachmentFormat(uint32_t attachment) const;
nxt::TextureFormat GetDepthStencilFormat() const;
dawn::TextureFormat GetColorAttachmentFormat(uint32_t attachment) const;
dawn::TextureFormat GetDepthStencilFormat() const;
// A pipeline can be used in a render pass if its attachment info matches the actual
// attachments in the render pass. This returns whether it is the case.
@ -48,15 +48,15 @@ namespace backend {
private:
Ref<DepthStencilStateBase> mDepthStencilState;
nxt::IndexFormat mIndexFormat;
dawn::IndexFormat mIndexFormat;
Ref<InputStateBase> mInputState;
nxt::PrimitiveTopology mPrimitiveTopology;
dawn::PrimitiveTopology mPrimitiveTopology;
std::array<Ref<BlendStateBase>, kMaxColorAttachments> mBlendStates;
std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
std::array<nxt::TextureFormat, kMaxColorAttachments> mColorAttachmentFormats;
std::array<dawn::TextureFormat, kMaxColorAttachments> mColorAttachmentFormats;
bool mDepthStencilFormatSet = false;
nxt::TextureFormat mDepthStencilFormat;
dawn::TextureFormat mDepthStencilFormat;
};
class RenderPipelineBuilder : public Builder<RenderPipelineBase>, public PipelineBuilder {
@ -64,12 +64,12 @@ namespace backend {
RenderPipelineBuilder(DeviceBase* device);
// NXT API
void SetColorAttachmentFormat(uint32_t attachmentSlot, nxt::TextureFormat format);
void SetColorAttachmentFormat(uint32_t attachmentSlot, dawn::TextureFormat format);
void SetColorAttachmentBlendState(uint32_t attachmentSlot, BlendStateBase* blendState);
void SetDepthStencilAttachmentFormat(nxt::TextureFormat format);
void SetDepthStencilAttachmentFormat(dawn::TextureFormat format);
void SetDepthStencilState(DepthStencilStateBase* depthStencilState);
void SetPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology);
void SetIndexFormat(nxt::IndexFormat format);
void SetPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology);
void SetIndexFormat(dawn::IndexFormat format);
void SetInputState(InputStateBase* inputState);
private:
@ -81,14 +81,14 @@ namespace backend {
Ref<InputStateBase> mInputState;
// TODO(enga@google.com): Remove default when we validate that all required properties are
// set
nxt::PrimitiveTopology mPrimitiveTopology = nxt::PrimitiveTopology::TriangleList;
nxt::IndexFormat mIndexFormat = nxt::IndexFormat::Uint32;
dawn::PrimitiveTopology mPrimitiveTopology = dawn::PrimitiveTopology::TriangleList;
dawn::IndexFormat mIndexFormat = dawn::IndexFormat::Uint32;
std::bitset<kMaxColorAttachments> mBlendStatesSet;
std::array<Ref<BlendStateBase>, kMaxColorAttachments> mBlendStates;
std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
std::array<nxt::TextureFormat, kMaxColorAttachments> mColorAttachmentFormats;
std::array<dawn::TextureFormat, kMaxColorAttachments> mColorAttachmentFormats;
bool mDepthStencilFormatSet = false;
nxt::TextureFormat mDepthStencilFormat;
dawn::TextureFormat mDepthStencilFormat;
};
} // namespace backend

View File

@ -19,7 +19,7 @@
namespace backend {
MaybeError ValidateSamplerDescriptor(DeviceBase*, const nxt::SamplerDescriptor* descriptor) {
MaybeError ValidateSamplerDescriptor(DeviceBase*, const dawn::SamplerDescriptor* descriptor) {
NXT_TRY_ASSERT(descriptor->nextInChain == nullptr, "nextInChain must be nullptr");
NXT_TRY(ValidateFilterMode(descriptor->minFilter));
NXT_TRY(ValidateFilterMode(descriptor->magFilter));
@ -32,7 +32,7 @@ namespace backend {
// SamplerBase
SamplerBase::SamplerBase(DeviceBase*, const nxt::SamplerDescriptor*) {
SamplerBase::SamplerBase(DeviceBase*, const dawn::SamplerDescriptor*) {
}
} // namespace backend

View File

@ -25,11 +25,11 @@ namespace backend {
class DeviceBase;
MaybeError ValidateSamplerDescriptor(DeviceBase* device,
const nxt::SamplerDescriptor* descriptor);
const dawn::SamplerDescriptor* descriptor);
class SamplerBase : public RefCounted {
public:
SamplerBase(DeviceBase* device, const nxt::SamplerDescriptor* descriptor);
SamplerBase(DeviceBase* device, const dawn::SamplerDescriptor* descriptor);
};
} // namespace backend

View File

@ -37,13 +37,13 @@ namespace backend {
switch (compiler.get_execution_model()) {
case spv::ExecutionModelVertex:
mExecutionModel = nxt::ShaderStage::Vertex;
mExecutionModel = dawn::ShaderStage::Vertex;
break;
case spv::ExecutionModelFragment:
mExecutionModel = nxt::ShaderStage::Fragment;
mExecutionModel = dawn::ShaderStage::Fragment;
break;
case spv::ExecutionModelGLCompute:
mExecutionModel = nxt::ShaderStage::Compute;
mExecutionModel = dawn::ShaderStage::Compute;
break;
default:
UNREACHABLE();
@ -103,7 +103,7 @@ namespace backend {
// Fill in bindingInfo with the SPIRV bindings
auto ExtractResourcesBinding = [this](const std::vector<spirv_cross::Resource>& resources,
const spirv_cross::Compiler& compiler,
nxt::BindingType bindingType) {
dawn::BindingType bindingType) {
constexpr uint64_t requiredBindingDecorationMask =
(1ull << spv::DecorationBinding) | (1ull << spv::DecorationDescriptorSet);
@ -127,15 +127,15 @@ namespace backend {
};
ExtractResourcesBinding(resources.uniform_buffers, compiler,
nxt::BindingType::UniformBuffer);
dawn::BindingType::UniformBuffer);
ExtractResourcesBinding(resources.separate_images, compiler,
nxt::BindingType::SampledTexture);
ExtractResourcesBinding(resources.separate_samplers, compiler, nxt::BindingType::Sampler);
dawn::BindingType::SampledTexture);
ExtractResourcesBinding(resources.separate_samplers, compiler, dawn::BindingType::Sampler);
ExtractResourcesBinding(resources.storage_buffers, compiler,
nxt::BindingType::StorageBuffer);
dawn::BindingType::StorageBuffer);
// Extract the vertex attributes
if (mExecutionModel == nxt::ShaderStage::Vertex) {
if (mExecutionModel == dawn::ShaderStage::Vertex) {
for (const auto& attrib : resources.stage_inputs) {
ASSERT(compiler.get_decoration_mask(attrib.id) & (1ull << spv::DecorationLocation));
uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation);
@ -159,7 +159,7 @@ namespace backend {
}
}
if (mExecutionModel == nxt::ShaderStage::Fragment) {
if (mExecutionModel == dawn::ShaderStage::Fragment) {
// Without a location qualifier on vertex inputs, spirv_cross::CompilerMSL gives them
// all the location 0, causing a compile error.
for (const auto& attrib : resources.stage_inputs) {
@ -184,7 +184,7 @@ namespace backend {
return mUsedVertexAttributes;
}
nxt::ShaderStage ShaderModuleBase::GetExecutionModel() const {
dawn::ShaderStage ShaderModuleBase::GetExecutionModel() const {
return mExecutionModel;
}

View File

@ -52,7 +52,7 @@ namespace backend {
// The SPIRV ID of the resource.
uint32_t id;
uint32_t base_type_id;
nxt::BindingType type;
dawn::BindingType type;
bool used = false;
};
using ModuleBindingInfo =
@ -61,7 +61,7 @@ namespace backend {
const PushConstantInfo& GetPushConstants() const;
const ModuleBindingInfo& GetBindingInfo() const;
const std::bitset<kMaxVertexAttributes>& GetUsedVertexAttributes() const;
nxt::ShaderStage GetExecutionModel() const;
dawn::ShaderStage GetExecutionModel() const;
bool IsCompatibleWithPipelineLayout(const PipelineLayoutBase* layout);
@ -72,7 +72,7 @@ namespace backend {
PushConstantInfo mPushConstants = {};
ModuleBindingInfo mBindingInfo;
std::bitset<kMaxVertexAttributes> mUsedVertexAttributes;
nxt::ShaderStage mExecutionModel;
dawn::ShaderStage mExecutionModel;
};
class ShaderModuleBuilder : public Builder<ShaderModuleBase> {

View File

@ -34,15 +34,15 @@ namespace backend {
return mDevice;
}
void SwapChainBase::Configure(nxt::TextureFormat format,
nxt::TextureUsageBit allowedUsage,
void SwapChainBase::Configure(dawn::TextureFormat format,
dawn::TextureUsageBit allowedUsage,
uint32_t width,
uint32_t height) {
if (width == 0 || height == 0) {
mDevice->HandleError("Swap chain cannot be configured to zero size");
return;
}
allowedUsage |= nxt::TextureUsageBit::Present;
allowedUsage |= dawn::TextureUsageBit::Present;
mFormat = format;
mAllowedUsage = allowedUsage;
@ -60,7 +60,7 @@ namespace backend {
}
auto* builder = mDevice->CreateTextureBuilder();
builder->SetDimension(nxt::TextureDimension::e2D);
builder->SetDimension(dawn::TextureDimension::e2D);
builder->SetExtent(mWidth, mHeight, 1);
builder->SetFormat(mFormat);
builder->SetMipLevels(1);

View File

@ -32,8 +32,8 @@ namespace backend {
DeviceBase* GetDevice();
// NXT API
void Configure(nxt::TextureFormat format,
nxt::TextureUsageBit allowedUsage,
void Configure(dawn::TextureFormat format,
dawn::TextureUsageBit allowedUsage,
uint32_t width,
uint32_t height);
TextureBase* GetNextTexture();
@ -47,8 +47,8 @@ namespace backend {
private:
DeviceBase* mDevice = nullptr;
nxtSwapChainImplementation mImplementation = {};
nxt::TextureFormat mFormat = {};
nxt::TextureUsageBit mAllowedUsage;
dawn::TextureFormat mFormat = {};
dawn::TextureUsageBit mAllowedUsage;
uint32_t mWidth = 0;
uint32_t mHeight = 0;
TextureBase* mLastNextTexture = nullptr;

View File

@ -19,46 +19,46 @@
namespace backend {
uint32_t TextureFormatPixelSize(nxt::TextureFormat format) {
uint32_t TextureFormatPixelSize(dawn::TextureFormat format) {
switch (format) {
case nxt::TextureFormat::R8Unorm:
case nxt::TextureFormat::R8Uint:
case dawn::TextureFormat::R8Unorm:
case dawn::TextureFormat::R8Uint:
return 1;
case nxt::TextureFormat::R8G8Unorm:
case nxt::TextureFormat::R8G8Uint:
case dawn::TextureFormat::R8G8Unorm:
case dawn::TextureFormat::R8G8Uint:
return 2;
case nxt::TextureFormat::R8G8B8A8Unorm:
case nxt::TextureFormat::R8G8B8A8Uint:
case nxt::TextureFormat::B8G8R8A8Unorm:
case dawn::TextureFormat::R8G8B8A8Unorm:
case dawn::TextureFormat::R8G8B8A8Uint:
case dawn::TextureFormat::B8G8R8A8Unorm:
return 4;
case nxt::TextureFormat::D32FloatS8Uint:
case dawn::TextureFormat::D32FloatS8Uint:
return 8;
default:
UNREACHABLE();
}
}
bool TextureFormatHasDepth(nxt::TextureFormat format) {
bool TextureFormatHasDepth(dawn::TextureFormat format) {
switch (format) {
case nxt::TextureFormat::D32FloatS8Uint:
case dawn::TextureFormat::D32FloatS8Uint:
return true;
default:
return false;
}
}
bool TextureFormatHasStencil(nxt::TextureFormat format) {
bool TextureFormatHasStencil(dawn::TextureFormat format) {
switch (format) {
case nxt::TextureFormat::D32FloatS8Uint:
case dawn::TextureFormat::D32FloatS8Uint:
return true;
default:
return false;
}
}
bool TextureFormatHasDepthOrStencil(nxt::TextureFormat format) {
bool TextureFormatHasDepthOrStencil(dawn::TextureFormat format) {
switch (format) {
case nxt::TextureFormat::D32FloatS8Uint:
case dawn::TextureFormat::D32FloatS8Uint:
return true;
default:
return false;
@ -82,10 +82,10 @@ namespace backend {
return mDevice;
}
nxt::TextureDimension TextureBase::GetDimension() const {
dawn::TextureDimension TextureBase::GetDimension() const {
return mDimension;
}
nxt::TextureFormat TextureBase::GetFormat() const {
dawn::TextureFormat TextureBase::GetFormat() const {
return mFormat;
}
uint32_t TextureBase::GetWidth() const {
@ -100,7 +100,7 @@ namespace backend {
uint32_t TextureBase::GetNumMipLevels() const {
return mNumMipLevels;
}
nxt::TextureUsageBit TextureBase::GetAllowedUsage() const {
dawn::TextureUsageBit TextureBase::GetAllowedUsage() const {
return mAllowedUsage;
}
@ -135,7 +135,7 @@ namespace backend {
return mDevice->CreateTexture(this);
}
void TextureBuilder::SetDimension(nxt::TextureDimension dimension) {
void TextureBuilder::SetDimension(dawn::TextureDimension dimension) {
if ((mPropertiesSet & TEXTURE_PROPERTY_DIMENSION) != 0) {
HandleError("Texture dimension property set multiple times");
return;
@ -162,7 +162,7 @@ namespace backend {
mDepth = depth;
}
void TextureBuilder::SetFormat(nxt::TextureFormat format) {
void TextureBuilder::SetFormat(dawn::TextureFormat format) {
if ((mPropertiesSet & TEXTURE_PROPERTY_FORMAT) != 0) {
HandleError("Texture format property set multiple times");
return;
@ -182,7 +182,7 @@ namespace backend {
mNumMipLevels = numMipLevels;
}
void TextureBuilder::SetAllowedUsage(nxt::TextureUsageBit usage) {
void TextureBuilder::SetAllowedUsage(dawn::TextureUsageBit usage) {
if ((mPropertiesSet & TEXTURE_PROPERTY_ALLOWED_USAGE) != 0) {
HandleError("Texture allowed usage property set multiple times");
return;

View File

@ -23,30 +23,30 @@
namespace backend {
uint32_t TextureFormatPixelSize(nxt::TextureFormat format);
bool TextureFormatHasDepth(nxt::TextureFormat format);
bool TextureFormatHasStencil(nxt::TextureFormat format);
bool TextureFormatHasDepthOrStencil(nxt::TextureFormat format);
uint32_t TextureFormatPixelSize(dawn::TextureFormat format);
bool TextureFormatHasDepth(dawn::TextureFormat format);
bool TextureFormatHasStencil(dawn::TextureFormat format);
bool TextureFormatHasDepthOrStencil(dawn::TextureFormat format);
static constexpr nxt::TextureUsageBit kReadOnlyTextureUsages =
nxt::TextureUsageBit::TransferSrc | nxt::TextureUsageBit::Sampled |
nxt::TextureUsageBit::Present;
static constexpr dawn::TextureUsageBit kReadOnlyTextureUsages =
dawn::TextureUsageBit::TransferSrc | dawn::TextureUsageBit::Sampled |
dawn::TextureUsageBit::Present;
static constexpr nxt::TextureUsageBit kWritableTextureUsages =
nxt::TextureUsageBit::TransferDst | nxt::TextureUsageBit::Storage |
nxt::TextureUsageBit::OutputAttachment;
static constexpr dawn::TextureUsageBit kWritableTextureUsages =
dawn::TextureUsageBit::TransferDst | dawn::TextureUsageBit::Storage |
dawn::TextureUsageBit::OutputAttachment;
class TextureBase : public RefCounted {
public:
TextureBase(TextureBuilder* builder);
nxt::TextureDimension GetDimension() const;
nxt::TextureFormat GetFormat() const;
dawn::TextureDimension GetDimension() const;
dawn::TextureFormat GetFormat() const;
uint32_t GetWidth() const;
uint32_t GetHeight() const;
uint32_t GetDepth() const;
uint32_t GetNumMipLevels() const;
nxt::TextureUsageBit GetAllowedUsage() const;
dawn::TextureUsageBit GetAllowedUsage() const;
DeviceBase* GetDevice() const;
// NXT API
@ -55,11 +55,11 @@ namespace backend {
private:
DeviceBase* mDevice;
nxt::TextureDimension mDimension;
nxt::TextureFormat mFormat;
dawn::TextureDimension mDimension;
dawn::TextureFormat mFormat;
uint32_t mWidth, mHeight, mDepth;
uint32_t mNumMipLevels;
nxt::TextureUsageBit mAllowedUsage = nxt::TextureUsageBit::None;
dawn::TextureUsageBit mAllowedUsage = dawn::TextureUsageBit::None;
};
class TextureBuilder : public Builder<TextureBase> {
@ -67,12 +67,12 @@ namespace backend {
TextureBuilder(DeviceBase* device);
// NXT API
void SetDimension(nxt::TextureDimension dimension);
void SetDimension(dawn::TextureDimension dimension);
void SetExtent(uint32_t width, uint32_t height, uint32_t depth);
void SetFormat(nxt::TextureFormat format);
void SetFormat(dawn::TextureFormat format);
void SetMipLevels(uint32_t numMipLevels);
void SetAllowedUsage(nxt::TextureUsageBit usage);
void SetInitialUsage(nxt::TextureUsageBit usage);
void SetAllowedUsage(dawn::TextureUsageBit usage);
void SetInitialUsage(dawn::TextureUsageBit usage);
private:
friend class TextureBase;
@ -81,11 +81,11 @@ namespace backend {
int mPropertiesSet = 0;
nxt::TextureDimension mDimension;
dawn::TextureDimension mDimension;
uint32_t mWidth, mHeight, mDepth;
nxt::TextureFormat mFormat;
dawn::TextureFormat mFormat;
uint32_t mNumMipLevels;
nxt::TextureUsageBit mAllowedUsage = nxt::TextureUsageBit::None;
dawn::TextureUsageBit mAllowedUsage = dawn::TextureUsageBit::None;
};
class TextureViewBase : public RefCounted {

View File

@ -46,14 +46,14 @@ namespace backend { namespace d3d12 {
auto d3d12Device = mDevice->GetD3D12Device();
for (uint32_t binding : IterateBitSet(layout.mask)) {
switch (layout.types[binding]) {
case nxt::BindingType::UniformBuffer: {
case dawn::BindingType::UniformBuffer: {
auto* view = ToBackend(GetBindingAsBufferView(binding));
auto& cbv = view->GetCBVDescriptor();
d3d12Device->CreateConstantBufferView(
&cbv, cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
bindingOffsets[binding]));
} break;
case nxt::BindingType::StorageBuffer: {
case dawn::BindingType::StorageBuffer: {
auto* view = ToBackend(GetBindingAsBufferView(binding));
auto& uav = view->GetUAVDescriptor();
d3d12Device->CreateUnorderedAccessView(
@ -61,7 +61,7 @@ namespace backend { namespace d3d12 {
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
bindingOffsets[binding]));
} break;
case nxt::BindingType::SampledTexture: {
case dawn::BindingType::SampledTexture: {
auto* view = ToBackend(GetBindingAsTextureView(binding));
auto& srv = view->GetSRVDescriptor();
d3d12Device->CreateShaderResourceView(
@ -69,7 +69,7 @@ namespace backend { namespace d3d12 {
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
bindingOffsets[binding]));
} break;
case nxt::BindingType::Sampler: {
case dawn::BindingType::Sampler: {
auto* sampler = ToBackend(GetBindingAsSampler(binding));
auto& samplerDesc = sampler->GetSamplerDescriptor();
d3d12Device->CreateSampler(

View File

@ -20,22 +20,22 @@
namespace backend { namespace d3d12 {
BindGroupLayout::BindGroupLayout(Device* device,
const nxt::BindGroupLayoutDescriptor* descriptor)
const dawn::BindGroupLayoutDescriptor* descriptor)
: BindGroupLayoutBase(device, descriptor), mDescriptorCounts{} {
const auto& groupInfo = GetBindingInfo();
for (uint32_t binding : IterateBitSet(groupInfo.mask)) {
switch (groupInfo.types[binding]) {
case nxt::BindingType::UniformBuffer:
case dawn::BindingType::UniformBuffer:
mBindingOffsets[binding] = mDescriptorCounts[CBV]++;
break;
case nxt::BindingType::StorageBuffer:
case dawn::BindingType::StorageBuffer:
mBindingOffsets[binding] = mDescriptorCounts[UAV]++;
break;
case nxt::BindingType::SampledTexture:
case dawn::BindingType::SampledTexture:
mBindingOffsets[binding] = mDescriptorCounts[SRV]++;
break;
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
break;
}
@ -85,16 +85,16 @@ namespace backend { namespace d3d12 {
for (uint32_t binding : IterateBitSet(groupInfo.mask)) {
switch (groupInfo.types[binding]) {
case nxt::BindingType::UniformBuffer:
case dawn::BindingType::UniformBuffer:
mBindingOffsets[binding] += descriptorOffsets[CBV];
break;
case nxt::BindingType::StorageBuffer:
case dawn::BindingType::StorageBuffer:
mBindingOffsets[binding] += descriptorOffsets[UAV];
break;
case nxt::BindingType::SampledTexture:
case dawn::BindingType::SampledTexture:
mBindingOffsets[binding] += descriptorOffsets[SRV];
break;
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
mBindingOffsets[binding] += descriptorOffsets[Sampler];
break;
}

View File

@ -25,7 +25,7 @@ namespace backend { namespace d3d12 {
class BindGroupLayout : public BindGroupLayoutBase {
public:
BindGroupLayout(Device* device, const nxt::BindGroupLayoutDescriptor* descriptor);
BindGroupLayout(Device* device, const dawn::BindGroupLayoutDescriptor* descriptor);
enum DescriptorType {
CBV,

View File

@ -20,67 +20,67 @@
namespace backend { namespace d3d12 {
namespace {
D3D12_BLEND D3D12Blend(nxt::BlendFactor factor) {
D3D12_BLEND D3D12Blend(dawn::BlendFactor factor) {
switch (factor) {
case nxt::BlendFactor::Zero:
case dawn::BlendFactor::Zero:
return D3D12_BLEND_ZERO;
case nxt::BlendFactor::One:
case dawn::BlendFactor::One:
return D3D12_BLEND_ONE;
case nxt::BlendFactor::SrcColor:
case dawn::BlendFactor::SrcColor:
return D3D12_BLEND_SRC_COLOR;
case nxt::BlendFactor::OneMinusSrcColor:
case dawn::BlendFactor::OneMinusSrcColor:
return D3D12_BLEND_INV_SRC_COLOR;
case nxt::BlendFactor::SrcAlpha:
case dawn::BlendFactor::SrcAlpha:
return D3D12_BLEND_SRC_ALPHA;
case nxt::BlendFactor::OneMinusSrcAlpha:
case dawn::BlendFactor::OneMinusSrcAlpha:
return D3D12_BLEND_INV_SRC_ALPHA;
case nxt::BlendFactor::DstColor:
case dawn::BlendFactor::DstColor:
return D3D12_BLEND_DEST_COLOR;
case nxt::BlendFactor::OneMinusDstColor:
case dawn::BlendFactor::OneMinusDstColor:
return D3D12_BLEND_INV_DEST_COLOR;
case nxt::BlendFactor::DstAlpha:
case dawn::BlendFactor::DstAlpha:
return D3D12_BLEND_DEST_ALPHA;
case nxt::BlendFactor::OneMinusDstAlpha:
case dawn::BlendFactor::OneMinusDstAlpha:
return D3D12_BLEND_INV_DEST_ALPHA;
case nxt::BlendFactor::SrcAlphaSaturated:
case dawn::BlendFactor::SrcAlphaSaturated:
return D3D12_BLEND_SRC_ALPHA_SAT;
case nxt::BlendFactor::BlendColor:
case dawn::BlendFactor::BlendColor:
return D3D12_BLEND_BLEND_FACTOR;
case nxt::BlendFactor::OneMinusBlendColor:
case dawn::BlendFactor::OneMinusBlendColor:
return D3D12_BLEND_INV_BLEND_FACTOR;
default:
UNREACHABLE();
}
}
D3D12_BLEND_OP D3D12BlendOperation(nxt::BlendOperation operation) {
D3D12_BLEND_OP D3D12BlendOperation(dawn::BlendOperation operation) {
switch (operation) {
case nxt::BlendOperation::Add:
case dawn::BlendOperation::Add:
return D3D12_BLEND_OP_ADD;
case nxt::BlendOperation::Subtract:
case dawn::BlendOperation::Subtract:
return D3D12_BLEND_OP_SUBTRACT;
case nxt::BlendOperation::ReverseSubtract:
case dawn::BlendOperation::ReverseSubtract:
return D3D12_BLEND_OP_REV_SUBTRACT;
case nxt::BlendOperation::Min:
case dawn::BlendOperation::Min:
return D3D12_BLEND_OP_MIN;
case nxt::BlendOperation::Max:
case dawn::BlendOperation::Max:
return D3D12_BLEND_OP_MAX;
default:
UNREACHABLE();
}
}
uint8_t D3D12RenderTargetWriteMask(nxt::ColorWriteMask colorWriteMask) {
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(nxt::ColorWriteMask::Red) ==
uint8_t D3D12RenderTargetWriteMask(dawn::ColorWriteMask colorWriteMask) {
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Red) ==
D3D12_COLOR_WRITE_ENABLE_RED,
"ColorWriteMask values must match");
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(nxt::ColorWriteMask::Green) ==
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Green) ==
D3D12_COLOR_WRITE_ENABLE_GREEN,
"ColorWriteMask values must match");
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(nxt::ColorWriteMask::Blue) ==
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Blue) ==
D3D12_COLOR_WRITE_ENABLE_BLUE,
"ColorWriteMask values must match");
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(nxt::ColorWriteMask::Alpha) ==
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Alpha) ==
D3D12_COLOR_WRITE_ENABLE_ALPHA,
"ColorWriteMask values must match");
return static_cast<uint8_t>(colorWriteMask);

View File

@ -24,42 +24,42 @@
namespace backend { namespace d3d12 {
namespace {
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(nxt::BufferUsageBit usage) {
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::BufferUsageBit usage) {
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
if (usage & nxt::BufferUsageBit::Storage) {
if (usage & dawn::BufferUsageBit::Storage) {
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
}
return flags;
}
D3D12_RESOURCE_STATES D3D12BufferUsage(nxt::BufferUsageBit usage) {
D3D12_RESOURCE_STATES D3D12BufferUsage(dawn::BufferUsageBit usage) {
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
if (usage & nxt::BufferUsageBit::TransferSrc) {
if (usage & dawn::BufferUsageBit::TransferSrc) {
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
}
if (usage & nxt::BufferUsageBit::TransferDst) {
if (usage & dawn::BufferUsageBit::TransferDst) {
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
}
if (usage & (nxt::BufferUsageBit::Vertex | nxt::BufferUsageBit::Uniform)) {
if (usage & (dawn::BufferUsageBit::Vertex | dawn::BufferUsageBit::Uniform)) {
resourceState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
}
if (usage & nxt::BufferUsageBit::Index) {
if (usage & dawn::BufferUsageBit::Index) {
resourceState |= D3D12_RESOURCE_STATE_INDEX_BUFFER;
}
if (usage & nxt::BufferUsageBit::Storage) {
if (usage & dawn::BufferUsageBit::Storage) {
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
}
return resourceState;
}
D3D12_HEAP_TYPE D3D12HeapType(nxt::BufferUsageBit allowedUsage) {
if (allowedUsage & nxt::BufferUsageBit::MapRead) {
D3D12_HEAP_TYPE D3D12HeapType(dawn::BufferUsageBit allowedUsage) {
if (allowedUsage & dawn::BufferUsageBit::MapRead) {
return D3D12_HEAP_TYPE_READBACK;
} else if (allowedUsage & nxt::BufferUsageBit::MapWrite) {
} else if (allowedUsage & dawn::BufferUsageBit::MapWrite) {
return D3D12_HEAP_TYPE_UPLOAD;
} else {
return D3D12_HEAP_TYPE_DEFAULT;
@ -89,7 +89,7 @@ namespace backend { namespace d3d12 {
if (heapType == D3D12_HEAP_TYPE_READBACK) {
bufferUsage |= D3D12_RESOURCE_STATE_COPY_DEST;
mFixedResourceState = true;
mLastUsage = nxt::BufferUsageBit::TransferDst;
mLastUsage = dawn::BufferUsageBit::TransferDst;
}
// D3D12 requires buffers on the UPLOAD heap to have the D3D12_RESOURCE_STATE_GENERIC_READ
@ -97,7 +97,7 @@ namespace backend { namespace d3d12 {
if (heapType == D3D12_HEAP_TYPE_UPLOAD) {
bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ;
mFixedResourceState = true;
mLastUsage = nxt::BufferUsageBit::TransferSrc;
mLastUsage = dawn::BufferUsageBit::TransferSrc;
}
mResource = ToBackend(GetDevice())
@ -119,7 +119,7 @@ namespace backend { namespace d3d12 {
}
void Buffer::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
nxt::BufferUsageBit usage) {
dawn::BufferUsageBit usage) {
// Resources in upload and readback heaps must be kept in the COPY_SOURCE/DEST state
if (mFixedResourceState) {
ASSERT(usage == mLastUsage);
@ -164,7 +164,7 @@ namespace backend { namespace d3d12 {
void Buffer::SetSubDataImpl(uint32_t start, uint32_t count, const uint8_t* data) {
Device* device = ToBackend(GetDevice());
TransitionUsageNow(device->GetPendingCommandList(), nxt::BufferUsageBit::TransferDst);
TransitionUsageNow(device->GetPendingCommandList(), dawn::BufferUsageBit::TransferDst);
device->GetResourceUploader()->BufferSubData(mResource, start, count, data);
}

View File

@ -35,7 +35,7 @@ namespace backend { namespace d3d12 {
void OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite);
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
nxt::BufferUsageBit usage);
dawn::BufferUsageBit usage);
private:
// NXT API
@ -46,7 +46,7 @@ namespace backend { namespace d3d12 {
ComPtr<ID3D12Resource> mResource;
bool mFixedResourceState = false;
nxt::BufferUsageBit mLastUsage = nxt::BufferUsageBit::None;
dawn::BufferUsageBit mLastUsage = dawn::BufferUsageBit::None;
};
class BufferView : public BufferViewBase {

View File

@ -34,11 +34,11 @@
namespace backend { namespace d3d12 {
namespace {
DXGI_FORMAT DXGIIndexFormat(nxt::IndexFormat format) {
DXGI_FORMAT DXGIIndexFormat(dawn::IndexFormat format) {
switch (format) {
case nxt::IndexFormat::Uint16:
case dawn::IndexFormat::Uint16:
return DXGI_FORMAT_R16_UINT;
case nxt::IndexFormat::Uint32:
case dawn::IndexFormat::Uint32:
return DXGI_FORMAT_R32_UINT;
default:
UNREACHABLE();
@ -308,8 +308,8 @@ namespace backend { namespace d3d12 {
Buffer* srcBuffer = ToBackend(copy->source.buffer.Get());
Buffer* dstBuffer = ToBackend(copy->destination.buffer.Get());
srcBuffer->TransitionUsageNow(commandList, nxt::BufferUsageBit::TransferSrc);
dstBuffer->TransitionUsageNow(commandList, nxt::BufferUsageBit::TransferDst);
srcBuffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferSrc);
dstBuffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferDst);
commandList->CopyBufferRegion(
dstBuffer->GetD3D12Resource().Get(), copy->destination.offset,
@ -321,8 +321,8 @@ namespace backend { namespace d3d12 {
Buffer* buffer = ToBackend(copy->source.buffer.Get());
Texture* texture = ToBackend(copy->destination.texture.Get());
buffer->TransitionUsageNow(commandList, nxt::BufferUsageBit::TransferSrc);
texture->TransitionUsageNow(commandList, nxt::TextureUsageBit::TransferDst);
buffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferSrc);
texture->TransitionUsageNow(commandList, dawn::TextureUsageBit::TransferDst);
auto copySplit = ComputeTextureCopySplit(
copy->destination.x, copy->destination.y, copy->destination.z,
@ -367,8 +367,8 @@ namespace backend { namespace d3d12 {
Texture* texture = ToBackend(copy->source.texture.Get());
Buffer* buffer = ToBackend(copy->destination.buffer.Get());
texture->TransitionUsageNow(commandList, nxt::TextureUsageBit::TransferSrc);
buffer->TransitionUsageNow(commandList, nxt::BufferUsageBit::TransferDst);
texture->TransitionUsageNow(commandList, dawn::TextureUsageBit::TransferSrc);
buffer->TransitionUsageNow(commandList, dawn::BufferUsageBit::TransferDst);
auto copySplit = ComputeTextureCopySplit(
copy->source.x, copy->source.y, copy->source.z, copy->source.width,
@ -462,7 +462,7 @@ namespace backend { namespace d3d12 {
auto& attachmentInfo = renderPass->GetColorAttachment(i);
// Load op - color
if (attachmentInfo.loadOp == nxt::LoadOp::Clear) {
if (attachmentInfo.loadOp == dawn::LoadOp::Clear) {
D3D12_CPU_DESCRIPTOR_HANDLE handle = renderPass->GetRTVDescriptor(i);
commandList->ClearRenderTargetView(handle, attachmentInfo.clearColor.data(), 0,
nullptr);
@ -475,9 +475,9 @@ namespace backend { namespace d3d12 {
// Load op - depth/stencil
bool doDepthClear = TextureFormatHasDepth(texture->GetFormat()) &&
(attachmentInfo.depthLoadOp == nxt::LoadOp::Clear);
(attachmentInfo.depthLoadOp == dawn::LoadOp::Clear);
bool doStencilClear = TextureFormatHasStencil(texture->GetFormat()) &&
(attachmentInfo.stencilLoadOp == nxt::LoadOp::Clear);
(attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear);
D3D12_CLEAR_FLAGS clearFlags = {};
if (doDepthClear) {

View File

@ -33,8 +33,8 @@ namespace backend { namespace d3d12 {
// SPRIV-cross does matrix multiplication expecting row major matrices
compileFlags |= D3DCOMPILE_PACK_MATRIX_ROW_MAJOR;
const auto& module = ToBackend(builder->GetStageInfo(nxt::ShaderStage::Compute).module);
const auto& entryPoint = builder->GetStageInfo(nxt::ShaderStage::Compute).entryPoint;
const auto& module = ToBackend(builder->GetStageInfo(dawn::ShaderStage::Compute).module);
const auto& entryPoint = builder->GetStageInfo(dawn::ShaderStage::Compute).entryPoint;
const auto& hlslSource = module->GetHLSLSource();
ComPtr<ID3DBlob> compiledShader;

View File

@ -18,46 +18,46 @@
namespace backend { namespace d3d12 {
static D3D12_STENCIL_OP StencilOp(nxt::StencilOperation op) {
static D3D12_STENCIL_OP StencilOp(dawn::StencilOperation op) {
switch (op) {
case nxt::StencilOperation::Keep:
case dawn::StencilOperation::Keep:
return D3D12_STENCIL_OP_KEEP;
case nxt::StencilOperation::Zero:
case dawn::StencilOperation::Zero:
return D3D12_STENCIL_OP_ZERO;
case nxt::StencilOperation::Replace:
case dawn::StencilOperation::Replace:
return D3D12_STENCIL_OP_REPLACE;
case nxt::StencilOperation::IncrementClamp:
case dawn::StencilOperation::IncrementClamp:
return D3D12_STENCIL_OP_INCR_SAT;
case nxt::StencilOperation::DecrementClamp:
case dawn::StencilOperation::DecrementClamp:
return D3D12_STENCIL_OP_DECR_SAT;
case nxt::StencilOperation::Invert:
case dawn::StencilOperation::Invert:
return D3D12_STENCIL_OP_INVERT;
case nxt::StencilOperation::IncrementWrap:
case dawn::StencilOperation::IncrementWrap:
return D3D12_STENCIL_OP_INCR;
case nxt::StencilOperation::DecrementWrap:
case dawn::StencilOperation::DecrementWrap:
return D3D12_STENCIL_OP_DECR;
default:
UNREACHABLE();
}
}
static D3D12_COMPARISON_FUNC ComparisonFunc(nxt::CompareFunction func) {
static D3D12_COMPARISON_FUNC ComparisonFunc(dawn::CompareFunction func) {
switch (func) {
case nxt::CompareFunction::Always:
case dawn::CompareFunction::Always:
return D3D12_COMPARISON_FUNC_ALWAYS;
case nxt::CompareFunction::Equal:
case dawn::CompareFunction::Equal:
return D3D12_COMPARISON_FUNC_EQUAL;
case nxt::CompareFunction::Greater:
case dawn::CompareFunction::Greater:
return D3D12_COMPARISON_FUNC_GREATER;
case nxt::CompareFunction::GreaterEqual:
case dawn::CompareFunction::GreaterEqual:
return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
case nxt::CompareFunction::Less:
case dawn::CompareFunction::Less:
return D3D12_COMPARISON_FUNC_LESS;
case nxt::CompareFunction::LessEqual:
case dawn::CompareFunction::LessEqual:
return D3D12_COMPARISON_FUNC_LESS_EQUAL;
case nxt::CompareFunction::Never:
case dawn::CompareFunction::Never:
return D3D12_COMPARISON_FUNC_NEVER;
case nxt::CompareFunction::NotEqual:
case dawn::CompareFunction::NotEqual:
return D3D12_COMPARISON_FUNC_NOT_EQUAL;
default:
UNREACHABLE();

View File

@ -267,7 +267,7 @@ namespace backend { namespace d3d12 {
return new BindGroup(this, builder);
}
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor);
}
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -292,7 +292,7 @@ namespace backend { namespace d3d12 {
return new InputState(this, builder);
}
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) {
const dawn::PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor);
}
ResultOrError<QueueBase*> Device::CreateQueueImpl() {
@ -306,7 +306,7 @@ namespace backend { namespace d3d12 {
return new RenderPipeline(builder);
}
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor);
}
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -78,12 +78,12 @@ namespace backend { namespace d3d12 {
private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) override;
const dawn::BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) override;
const dawn::PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
uint64_t mSerial = 0;
ComPtr<ID3D12Fence> mFence;

View File

@ -18,42 +18,42 @@
namespace backend { namespace d3d12 {
static DXGI_FORMAT VertexFormatType(nxt::VertexFormat format) {
static DXGI_FORMAT VertexFormatType(dawn::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case dawn::VertexFormat::FloatR32G32B32A32:
return DXGI_FORMAT_R32G32B32A32_FLOAT;
case nxt::VertexFormat::FloatR32G32B32:
case dawn::VertexFormat::FloatR32G32B32:
return DXGI_FORMAT_R32G32B32_FLOAT;
case nxt::VertexFormat::FloatR32G32:
case dawn::VertexFormat::FloatR32G32:
return DXGI_FORMAT_R32G32_FLOAT;
case nxt::VertexFormat::FloatR32:
case dawn::VertexFormat::FloatR32:
return DXGI_FORMAT_R32_FLOAT;
case nxt::VertexFormat::IntR32G32B32A32:
case dawn::VertexFormat::IntR32G32B32A32:
return DXGI_FORMAT_R32G32B32A32_SINT;
case nxt::VertexFormat::IntR32G32B32:
case dawn::VertexFormat::IntR32G32B32:
return DXGI_FORMAT_R32G32B32_SINT;
case nxt::VertexFormat::IntR32G32:
case dawn::VertexFormat::IntR32G32:
return DXGI_FORMAT_R32G32_SINT;
case nxt::VertexFormat::IntR32:
case dawn::VertexFormat::IntR32:
return DXGI_FORMAT_R32_SINT;
case nxt::VertexFormat::UshortR16G16B16A16:
case dawn::VertexFormat::UshortR16G16B16A16:
return DXGI_FORMAT_R16G16B16A16_UINT;
case nxt::VertexFormat::UshortR16G16:
case dawn::VertexFormat::UshortR16G16:
return DXGI_FORMAT_R16G16_UINT;
case nxt::VertexFormat::UnormR8G8B8A8:
case dawn::VertexFormat::UnormR8G8B8A8:
return DXGI_FORMAT_R8G8B8A8_UNORM;
case nxt::VertexFormat::UnormR8G8:
case dawn::VertexFormat::UnormR8G8:
return DXGI_FORMAT_R8G8_UNORM;
default:
UNREACHABLE();
}
}
static D3D12_INPUT_CLASSIFICATION InputStepModeFunction(nxt::InputStepMode mode) {
static D3D12_INPUT_CLASSIFICATION InputStepModeFunction(dawn::InputStepMode mode) {
switch (mode) {
case nxt::InputStepMode::Vertex:
case dawn::InputStepMode::Vertex:
return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
case nxt::InputStepMode::Instance:
case dawn::InputStepMode::Instance:
return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA;
default:
UNREACHABLE();

View File

@ -111,8 +111,8 @@ namespace backend { namespace d3d12 {
return NXT_SWAP_CHAIN_NO_ERROR;
}
nxt::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
return nxt::TextureFormat::R8G8B8A8Unorm;
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
return dawn::TextureFormat::R8G8B8A8Unorm;
}
}} // namespace backend::d3d12

View File

@ -41,7 +41,7 @@ namespace backend { namespace d3d12 {
nxtSwapChainError GetNextTexture(nxtSwapChainNextTexture* nextTexture);
nxtSwapChainError Present();
nxt::TextureFormat GetPreferredFormat() const;
dawn::TextureFormat GetPreferredFormat() const;
private:
HWND mWindow = nullptr;

View File

@ -23,7 +23,7 @@ using Microsoft::WRL::ComPtr;
namespace backend { namespace d3d12 {
PipelineLayout::PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor)
PipelineLayout::PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor) {
D3D12_ROOT_PARAMETER rootParameters[kMaxBindGroups * 2];

View File

@ -25,7 +25,7 @@ namespace backend { namespace d3d12 {
class PipelineLayout : public PipelineLayoutBase {
public:
PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor);
PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor);
uint32_t GetCbvUavSrvRootParameterIndex(uint32_t group) const;
uint32_t GetSamplerRootParameterIndex(uint32_t group) const;

View File

@ -28,17 +28,17 @@
namespace backend { namespace d3d12 {
namespace {
D3D12_PRIMITIVE_TOPOLOGY D3D12PrimitiveTopology(nxt::PrimitiveTopology primitiveTopology) {
D3D12_PRIMITIVE_TOPOLOGY D3D12PrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) {
case nxt::PrimitiveTopology::PointList:
case dawn::PrimitiveTopology::PointList:
return D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
case nxt::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::LineList:
return D3D_PRIMITIVE_TOPOLOGY_LINELIST;
case nxt::PrimitiveTopology::LineStrip:
case dawn::PrimitiveTopology::LineStrip:
return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP;
case nxt::PrimitiveTopology::TriangleList:
case dawn::PrimitiveTopology::TriangleList:
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case nxt::PrimitiveTopology::TriangleStrip:
case dawn::PrimitiveTopology::TriangleStrip:
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
default:
UNREACHABLE();
@ -46,15 +46,15 @@ namespace backend { namespace d3d12 {
}
D3D12_PRIMITIVE_TOPOLOGY_TYPE D3D12PrimitiveTopologyType(
nxt::PrimitiveTopology primitiveTopology) {
dawn::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) {
case nxt::PrimitiveTopology::PointList:
case dawn::PrimitiveTopology::PointList:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
case nxt::PrimitiveTopology::LineList:
case nxt::PrimitiveTopology::LineStrip:
case dawn::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::LineStrip:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
case nxt::PrimitiveTopology::TriangleList:
case nxt::PrimitiveTopology::TriangleStrip:
case dawn::PrimitiveTopology::TriangleList:
case dawn::PrimitiveTopology::TriangleStrip:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
default:
UNREACHABLE();
@ -88,15 +88,15 @@ namespace backend { namespace d3d12 {
D3D12_SHADER_BYTECODE* shader = nullptr;
switch (stage) {
case nxt::ShaderStage::Vertex:
case dawn::ShaderStage::Vertex:
shader = &descriptor.VS;
compileTarget = "vs_5_1";
break;
case nxt::ShaderStage::Fragment:
case dawn::ShaderStage::Fragment:
shader = &descriptor.PS;
compileTarget = "ps_5_1";
break;
case nxt::ShaderStage::Compute:
case dawn::ShaderStage::Compute:
UNREACHABLE();
break;
}

View File

@ -19,13 +19,13 @@
namespace backend { namespace d3d12 {
namespace {
D3D12_TEXTURE_ADDRESS_MODE AddressMode(nxt::AddressMode mode) {
D3D12_TEXTURE_ADDRESS_MODE AddressMode(dawn::AddressMode mode) {
switch (mode) {
case nxt::AddressMode::Repeat:
case dawn::AddressMode::Repeat:
return D3D12_TEXTURE_ADDRESS_MODE_WRAP;
case nxt::AddressMode::MirroredRepeat:
case dawn::AddressMode::MirroredRepeat:
return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
case nxt::AddressMode::ClampToEdge:
case dawn::AddressMode::ClampToEdge:
return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
default:
UNREACHABLE();
@ -33,7 +33,7 @@ namespace backend { namespace d3d12 {
}
} // namespace
Sampler::Sampler(Device* device, const nxt::SamplerDescriptor* descriptor)
Sampler::Sampler(Device* device, const dawn::SamplerDescriptor* descriptor)
: SamplerBase(device, descriptor) {
// https://msdn.microsoft.com/en-us/library/windows/desktop/dn770367(v=vs.85).aspx
// hex value, decimal value, min linear, mag linear, mip linear
@ -53,25 +53,25 @@ namespace backend { namespace d3d12 {
uint8_t mode = 0;
switch (descriptor->minFilter) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
break;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
mode += 16;
break;
}
switch (descriptor->magFilter) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
break;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
mode += 4;
break;
}
switch (descriptor->mipmapFilter) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
break;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
mode += 1;
break;
}

View File

@ -25,7 +25,7 @@ namespace backend { namespace d3d12 {
class Sampler : public SamplerBase {
public:
Sampler(Device* device, const nxt::SamplerDescriptor* descriptor);
Sampler(Device* device, const dawn::SamplerDescriptor* descriptor);
const D3D12_SAMPLER_DESC& GetSamplerDescriptor() const;

View File

@ -24,15 +24,15 @@ namespace backend { namespace d3d12 {
template <typename T>
class BindingTypeMap {
public:
T& operator[](nxt::BindingType type) {
T& operator[](dawn::BindingType type) {
switch (type) {
case nxt::BindingType::UniformBuffer:
case dawn::BindingType::UniformBuffer:
return mMap[0];
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
return mMap[1];
case nxt::BindingType::SampledTexture:
case dawn::BindingType::SampledTexture:
return mMap[2];
case nxt::BindingType::StorageBuffer:
case dawn::BindingType::StorageBuffer:
return mMap[3];
default:
NXT_UNREACHABLE();

View File

@ -28,7 +28,7 @@ namespace backend { namespace d3d12 {
im.Init(im.userData, &wsiContext);
ASSERT(im.textureUsage != NXT_TEXTURE_USAGE_BIT_NONE);
mTextureUsage = static_cast<nxt::TextureUsageBit>(im.textureUsage);
mTextureUsage = static_cast<dawn::TextureUsageBit>(im.textureUsage);
}
SwapChain::~SwapChain() {

View File

@ -28,7 +28,7 @@ namespace backend { namespace d3d12 {
TextureBase* GetNextTextureImpl(TextureBuilder* builder) override;
void OnBeforePresent(TextureBase* texture) override;
nxt::TextureUsageBit mTextureUsage;
dawn::TextureUsageBit mTextureUsage;
};
}} // namespace backend::d3d12

View File

@ -20,29 +20,29 @@
namespace backend { namespace d3d12 {
namespace {
D3D12_RESOURCE_STATES D3D12TextureUsage(nxt::TextureUsageBit usage,
nxt::TextureFormat format) {
D3D12_RESOURCE_STATES D3D12TextureUsage(dawn::TextureUsageBit usage,
dawn::TextureFormat format) {
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
// Present is an exclusive flag.
if (usage & nxt::TextureUsageBit::Present) {
if (usage & dawn::TextureUsageBit::Present) {
return D3D12_RESOURCE_STATE_PRESENT;
}
if (usage & nxt::TextureUsageBit::TransferSrc) {
if (usage & dawn::TextureUsageBit::TransferSrc) {
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
}
if (usage & nxt::TextureUsageBit::TransferDst) {
if (usage & dawn::TextureUsageBit::TransferDst) {
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
}
if (usage & nxt::TextureUsageBit::Sampled) {
if (usage & dawn::TextureUsageBit::Sampled) {
resourceState |= (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE |
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
}
if (usage & nxt::TextureUsageBit::Storage) {
if (usage & dawn::TextureUsageBit::Storage) {
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
}
if (usage & nxt::TextureUsageBit::OutputAttachment) {
if (usage & dawn::TextureUsageBit::OutputAttachment) {
if (TextureFormatHasDepth(format) || TextureFormatHasStencil(format)) {
resourceState |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
} else {
@ -53,14 +53,14 @@ namespace backend { namespace d3d12 {
return resourceState;
}
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(nxt::TextureUsageBit usage,
nxt::TextureFormat format) {
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::TextureUsageBit usage,
dawn::TextureFormat format) {
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
if (usage & nxt::TextureUsageBit::Storage) {
if (usage & dawn::TextureUsageBit::Storage) {
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
}
if (usage & nxt::TextureUsageBit::OutputAttachment) {
if (usage & dawn::TextureUsageBit::OutputAttachment) {
if (TextureFormatHasDepth(format) || TextureFormatHasStencil(format)) {
flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
} else {
@ -73,9 +73,9 @@ namespace backend { namespace d3d12 {
return flags;
}
D3D12_RESOURCE_DIMENSION D3D12TextureDimension(nxt::TextureDimension dimension) {
D3D12_RESOURCE_DIMENSION D3D12TextureDimension(dawn::TextureDimension dimension) {
switch (dimension) {
case nxt::TextureDimension::e2D:
case dawn::TextureDimension::e2D:
return D3D12_RESOURCE_DIMENSION_TEXTURE2D;
default:
UNREACHABLE();
@ -84,23 +84,23 @@ namespace backend { namespace d3d12 {
} // namespace
DXGI_FORMAT D3D12TextureFormat(nxt::TextureFormat format) {
DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format) {
switch (format) {
case nxt::TextureFormat::R8G8B8A8Unorm:
case dawn::TextureFormat::R8G8B8A8Unorm:
return DXGI_FORMAT_R8G8B8A8_UNORM;
case nxt::TextureFormat::R8G8Unorm:
case dawn::TextureFormat::R8G8Unorm:
return DXGI_FORMAT_R8G8_UNORM;
case nxt::TextureFormat::R8Unorm:
case dawn::TextureFormat::R8Unorm:
return DXGI_FORMAT_R8_UNORM;
case nxt::TextureFormat::R8G8B8A8Uint:
case dawn::TextureFormat::R8G8B8A8Uint:
return DXGI_FORMAT_R8G8B8A8_UINT;
case nxt::TextureFormat::R8G8Uint:
case dawn::TextureFormat::R8G8Uint:
return DXGI_FORMAT_R8G8_UINT;
case nxt::TextureFormat::R8Uint:
case dawn::TextureFormat::R8Uint:
return DXGI_FORMAT_R8_UINT;
case nxt::TextureFormat::B8G8R8A8Unorm:
case dawn::TextureFormat::B8G8R8A8Unorm:
return DXGI_FORMAT_B8G8R8A8_UNORM;
case nxt::TextureFormat::D32FloatS8Uint:
case dawn::TextureFormat::D32FloatS8Uint:
return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
default:
UNREACHABLE();
@ -150,7 +150,7 @@ namespace backend { namespace d3d12 {
}
void Texture::TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
nxt::TextureUsageBit usage) {
dawn::TextureUsageBit usage) {
// Avoid transitioning the texture when it isn't needed.
// TODO(cwallez@chromium.org): Need some form of UAV barriers at some point.
if (usage == mLastUsage) {
@ -177,7 +177,7 @@ namespace backend { namespace d3d12 {
mSrvDesc.Format = D3D12TextureFormat(GetTexture()->GetFormat());
mSrvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
switch (GetTexture()->GetDimension()) {
case nxt::TextureDimension::e2D:
case dawn::TextureDimension::e2D:
mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2D;
mSrvDesc.Texture2D.MostDetailedMip = 0;
mSrvDesc.Texture2D.MipLevels = GetTexture()->GetNumMipLevels();

View File

@ -23,7 +23,7 @@ namespace backend { namespace d3d12 {
class Device;
DXGI_FORMAT D3D12TextureFormat(nxt::TextureFormat format);
DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format);
class Texture : public TextureBase {
public:
@ -35,13 +35,13 @@ namespace backend { namespace d3d12 {
ID3D12Resource* GetD3D12Resource();
void TransitionUsageNow(ComPtr<ID3D12GraphicsCommandList> commandList,
nxt::TextureUsageBit usage);
dawn::TextureUsageBit usage);
private:
Device* mDevice;
ComPtr<ID3D12Resource> mResource = {};
ID3D12Resource* mResourcePtr = nullptr;
nxt::TextureUsageBit mLastUsage = nxt::TextureUsageBit::None;
dawn::TextureUsageBit mLastUsage = dawn::TextureUsageBit::None;
};
class TextureView : public TextureViewBase {

View File

@ -18,64 +18,64 @@ namespace backend { namespace metal {
namespace {
MTLBlendFactor MetalBlendFactor(nxt::BlendFactor factor, bool alpha) {
MTLBlendFactor MetalBlendFactor(dawn::BlendFactor factor, bool alpha) {
switch (factor) {
case nxt::BlendFactor::Zero:
case dawn::BlendFactor::Zero:
return MTLBlendFactorZero;
case nxt::BlendFactor::One:
case dawn::BlendFactor::One:
return MTLBlendFactorOne;
case nxt::BlendFactor::SrcColor:
case dawn::BlendFactor::SrcColor:
return MTLBlendFactorSourceColor;
case nxt::BlendFactor::OneMinusSrcColor:
case dawn::BlendFactor::OneMinusSrcColor:
return MTLBlendFactorOneMinusSourceColor;
case nxt::BlendFactor::SrcAlpha:
case dawn::BlendFactor::SrcAlpha:
return MTLBlendFactorSourceAlpha;
case nxt::BlendFactor::OneMinusSrcAlpha:
case dawn::BlendFactor::OneMinusSrcAlpha:
return MTLBlendFactorOneMinusSourceAlpha;
case nxt::BlendFactor::DstColor:
case dawn::BlendFactor::DstColor:
return MTLBlendFactorDestinationColor;
case nxt::BlendFactor::OneMinusDstColor:
case dawn::BlendFactor::OneMinusDstColor:
return MTLBlendFactorOneMinusDestinationColor;
case nxt::BlendFactor::DstAlpha:
case dawn::BlendFactor::DstAlpha:
return MTLBlendFactorDestinationAlpha;
case nxt::BlendFactor::OneMinusDstAlpha:
case dawn::BlendFactor::OneMinusDstAlpha:
return MTLBlendFactorOneMinusDestinationAlpha;
case nxt::BlendFactor::SrcAlphaSaturated:
case dawn::BlendFactor::SrcAlphaSaturated:
return MTLBlendFactorSourceAlphaSaturated;
case nxt::BlendFactor::BlendColor:
case dawn::BlendFactor::BlendColor:
return alpha ? MTLBlendFactorBlendAlpha : MTLBlendFactorBlendColor;
case nxt::BlendFactor::OneMinusBlendColor:
case dawn::BlendFactor::OneMinusBlendColor:
return alpha ? MTLBlendFactorOneMinusBlendAlpha
: MTLBlendFactorOneMinusBlendColor;
}
}
MTLBlendOperation MetalBlendOperation(nxt::BlendOperation operation) {
MTLBlendOperation MetalBlendOperation(dawn::BlendOperation operation) {
switch (operation) {
case nxt::BlendOperation::Add:
case dawn::BlendOperation::Add:
return MTLBlendOperationAdd;
case nxt::BlendOperation::Subtract:
case dawn::BlendOperation::Subtract:
return MTLBlendOperationSubtract;
case nxt::BlendOperation::ReverseSubtract:
case dawn::BlendOperation::ReverseSubtract:
return MTLBlendOperationReverseSubtract;
case nxt::BlendOperation::Min:
case dawn::BlendOperation::Min:
return MTLBlendOperationMin;
case nxt::BlendOperation::Max:
case dawn::BlendOperation::Max:
return MTLBlendOperationMax;
}
}
MTLColorWriteMask MetalColorWriteMask(nxt::ColorWriteMask colorWriteMask) {
return (((colorWriteMask & nxt::ColorWriteMask::Red) != nxt::ColorWriteMask::None
MTLColorWriteMask MetalColorWriteMask(dawn::ColorWriteMask colorWriteMask) {
return (((colorWriteMask & dawn::ColorWriteMask::Red) != dawn::ColorWriteMask::None
? MTLColorWriteMaskRed
: MTLColorWriteMaskNone) |
((colorWriteMask & nxt::ColorWriteMask::Green) != nxt::ColorWriteMask::None
((colorWriteMask & dawn::ColorWriteMask::Green) != dawn::ColorWriteMask::None
? MTLColorWriteMaskGreen
: MTLColorWriteMaskNone) |
((colorWriteMask & nxt::ColorWriteMask::Blue) != nxt::ColorWriteMask::None
((colorWriteMask & dawn::ColorWriteMask::Blue) != dawn::ColorWriteMask::None
? MTLColorWriteMaskBlue
: MTLColorWriteMaskNone) |
((colorWriteMask & nxt::ColorWriteMask::Alpha) != nxt::ColorWriteMask::None
((colorWriteMask & dawn::ColorWriteMask::Alpha) != dawn::ColorWriteMask::None
? MTLColorWriteMaskAlpha
: MTLColorWriteMaskNone));
}

View File

@ -21,7 +21,7 @@ namespace backend { namespace metal {
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
MTLResourceOptions storageMode;
if (GetAllowedUsage() & (nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) {
if (GetAllowedUsage() & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
storageMode = MTLResourceStorageModeShared;
} else {
storageMode = MTLResourceStorageModePrivate;

View File

@ -54,7 +54,7 @@ namespace backend { namespace metal {
for (uint32_t i : IterateBitSet(desc->GetColorAttachmentMask())) {
auto& attachmentInfo = desc->GetColorAttachment(i);
if (attachmentInfo.loadOp == nxt::LoadOp::Clear) {
if (attachmentInfo.loadOp == dawn::LoadOp::Clear) {
descriptor.colorAttachments[i].loadAction = MTLLoadActionClear;
descriptor.colorAttachments[i].clearColor = MTLClearColorMake(
attachmentInfo.clearColor[0], attachmentInfo.clearColor[1],
@ -73,13 +73,13 @@ namespace backend { namespace metal {
id<MTLTexture> texture =
ToBackend(attachmentInfo.view->GetTexture())->GetMTLTexture();
nxt::TextureFormat format = attachmentInfo.view->GetTexture()->GetFormat();
dawn::TextureFormat format = attachmentInfo.view->GetTexture()->GetFormat();
if (TextureFormatHasDepth(format)) {
descriptor.depthAttachment.texture = texture;
descriptor.depthAttachment.storeAction = MTLStoreActionStore;
if (attachmentInfo.depthLoadOp == nxt::LoadOp::Clear) {
if (attachmentInfo.depthLoadOp == dawn::LoadOp::Clear) {
descriptor.depthAttachment.loadAction = MTLLoadActionClear;
descriptor.depthAttachment.clearDepth = attachmentInfo.clearDepth;
} else {
@ -91,7 +91,7 @@ namespace backend { namespace metal {
descriptor.stencilAttachment.texture = texture;
descriptor.stencilAttachment.storeAction = MTLStoreActionStore;
if (attachmentInfo.stencilLoadOp == nxt::LoadOp::Clear) {
if (attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear) {
descriptor.stencilAttachment.loadAction = MTLLoadActionClear;
descriptor.stencilAttachment.clearStencil = attachmentInfo.clearStencil;
} else {
@ -123,9 +123,9 @@ namespace backend { namespace metal {
}
auto stage = layout.visibilities[binding];
bool hasVertStage = stage & nxt::ShaderStageBit::Vertex && render != nil;
bool hasFragStage = stage & nxt::ShaderStageBit::Fragment && render != nil;
bool hasComputeStage = stage & nxt::ShaderStageBit::Compute && compute != nil;
bool hasVertStage = stage & dawn::ShaderStageBit::Vertex && render != nil;
bool hasFragStage = stage & dawn::ShaderStageBit::Fragment && render != nil;
bool hasComputeStage = stage & dawn::ShaderStageBit::Compute && compute != nil;
uint32_t vertIndex = 0;
uint32_t fragIndex = 0;
@ -133,20 +133,20 @@ namespace backend { namespace metal {
if (hasVertStage) {
vertIndex = pipelineLayout->GetBindingIndexInfo(
nxt::ShaderStage::Vertex)[index][binding];
dawn::ShaderStage::Vertex)[index][binding];
}
if (hasFragStage) {
fragIndex = pipelineLayout->GetBindingIndexInfo(
nxt::ShaderStage::Fragment)[index][binding];
dawn::ShaderStage::Fragment)[index][binding];
}
if (hasComputeStage) {
computeIndex = pipelineLayout->GetBindingIndexInfo(
nxt::ShaderStage::Compute)[index][binding];
dawn::ShaderStage::Compute)[index][binding];
}
switch (layout.types[binding]) {
case nxt::BindingType::UniformBuffer:
case nxt::BindingType::StorageBuffer: {
case dawn::BindingType::UniformBuffer:
case dawn::BindingType::StorageBuffer: {
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
auto b = ToBackend(view->GetBuffer());
const id<MTLBuffer> buffer = b->GetMTLBuffer();
@ -170,7 +170,7 @@ namespace backend { namespace metal {
} break;
case nxt::BindingType::Sampler: {
case dawn::BindingType::Sampler: {
auto sampler = ToBackend(group->GetBindingAsSampler(binding));
if (hasVertStage) {
[render setVertexSamplerState:sampler->GetMTLSamplerState()
@ -186,7 +186,7 @@ namespace backend { namespace metal {
}
} break;
case nxt::BindingType::SampledTexture: {
case dawn::BindingType::SampledTexture: {
auto texture =
ToBackend(group->GetBindingAsTextureView(binding)->GetTexture());
if (hasVertStage) {
@ -348,7 +348,7 @@ namespace backend { namespace metal {
SetPushConstantsCmd* cmd = mCommands.NextCommand<SetPushConstantsCmd>();
uint32_t* values = mCommands.NextData<uint32_t>(cmd->count);
if (cmd->stages & nxt::ShaderStageBit::Compute) {
if (cmd->stages & dawn::ShaderStageBit::Compute) {
memcpy(&pushConstants[cmd->offset], values, cmd->count * sizeof(uint32_t));
[encoder setBytes:&pushConstants
@ -443,7 +443,7 @@ namespace backend { namespace metal {
SetPushConstantsCmd* cmd = mCommands.NextCommand<SetPushConstantsCmd>();
uint32_t* values = mCommands.NextData<uint32_t>(cmd->count);
if (cmd->stages & nxt::ShaderStageBit::Vertex) {
if (cmd->stages & dawn::ShaderStageBit::Vertex) {
memcpy(&vertexPushConstants[cmd->offset], values,
cmd->count * sizeof(uint32_t));
[encoder setVertexBytes:&vertexPushConstants
@ -451,7 +451,7 @@ namespace backend { namespace metal {
atIndex:0];
}
if (cmd->stages & nxt::ShaderStageBit::Fragment) {
if (cmd->stages & dawn::ShaderStageBit::Fragment) {
memcpy(&fragmentPushConstants[cmd->offset], values,
cmd->count * sizeof(uint32_t));
[encoder setFragmentBytes:&fragmentPushConstants

View File

@ -23,8 +23,8 @@ namespace backend { namespace metal {
: ComputePipelineBase(builder) {
auto mtlDevice = ToBackend(builder->GetDevice())->GetMTLDevice();
const auto& module = ToBackend(builder->GetStageInfo(nxt::ShaderStage::Compute).module);
const auto& entryPoint = builder->GetStageInfo(nxt::ShaderStage::Compute).entryPoint;
const auto& module = ToBackend(builder->GetStageInfo(dawn::ShaderStage::Compute).module);
const auto& entryPoint = builder->GetStageInfo(dawn::ShaderStage::Compute).entryPoint;
auto compilationData = module->GetFunction(entryPoint.c_str(), ToBackend(GetLayout()));

View File

@ -19,44 +19,44 @@
namespace backend { namespace metal {
namespace {
MTLCompareFunction MetalDepthStencilCompareFunction(nxt::CompareFunction compareFunction) {
MTLCompareFunction MetalDepthStencilCompareFunction(dawn::CompareFunction compareFunction) {
switch (compareFunction) {
case nxt::CompareFunction::Never:
case dawn::CompareFunction::Never:
return MTLCompareFunctionNever;
case nxt::CompareFunction::Less:
case dawn::CompareFunction::Less:
return MTLCompareFunctionLess;
case nxt::CompareFunction::LessEqual:
case dawn::CompareFunction::LessEqual:
return MTLCompareFunctionLessEqual;
case nxt::CompareFunction::Greater:
case dawn::CompareFunction::Greater:
return MTLCompareFunctionGreater;
case nxt::CompareFunction::GreaterEqual:
case dawn::CompareFunction::GreaterEqual:
return MTLCompareFunctionGreaterEqual;
case nxt::CompareFunction::NotEqual:
case dawn::CompareFunction::NotEqual:
return MTLCompareFunctionNotEqual;
case nxt::CompareFunction::Equal:
case dawn::CompareFunction::Equal:
return MTLCompareFunctionEqual;
case nxt::CompareFunction::Always:
case dawn::CompareFunction::Always:
return MTLCompareFunctionAlways;
}
}
MTLStencilOperation MetalStencilOperation(nxt::StencilOperation stencilOperation) {
MTLStencilOperation MetalStencilOperation(dawn::StencilOperation stencilOperation) {
switch (stencilOperation) {
case nxt::StencilOperation::Keep:
case dawn::StencilOperation::Keep:
return MTLStencilOperationKeep;
case nxt::StencilOperation::Zero:
case dawn::StencilOperation::Zero:
return MTLStencilOperationZero;
case nxt::StencilOperation::Replace:
case dawn::StencilOperation::Replace:
return MTLStencilOperationReplace;
case nxt::StencilOperation::Invert:
case dawn::StencilOperation::Invert:
return MTLStencilOperationInvert;
case nxt::StencilOperation::IncrementClamp:
case dawn::StencilOperation::IncrementClamp:
return MTLStencilOperationIncrementClamp;
case nxt::StencilOperation::DecrementClamp:
case dawn::StencilOperation::DecrementClamp:
return MTLStencilOperationDecrementClamp;
case nxt::StencilOperation::IncrementWrap:
case dawn::StencilOperation::IncrementWrap:
return MTLStencilOperationIncrementWrap;
case nxt::StencilOperation::DecrementWrap:
case dawn::StencilOperation::DecrementWrap:
return MTLStencilOperationDecrementWrap;
}
}

View File

@ -64,12 +64,12 @@ namespace backend { namespace metal {
private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) override;
const dawn::BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) override;
const dawn::PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
void OnCompletedHandler();

View File

@ -86,7 +86,7 @@ namespace backend { namespace metal {
return new BindGroup(builder);
}
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor);
}
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -111,7 +111,7 @@ namespace backend { namespace metal {
return new InputState(builder);
}
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) {
const dawn::PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor);
}
RenderPassDescriptorBase* Device::CreateRenderPassDescriptor(
@ -125,7 +125,7 @@ namespace backend { namespace metal {
return new Queue(this);
}
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor);
}
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -19,40 +19,40 @@
namespace backend { namespace metal {
namespace {
MTLVertexFormat VertexFormatType(nxt::VertexFormat format) {
MTLVertexFormat VertexFormatType(dawn::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case dawn::VertexFormat::FloatR32G32B32A32:
return MTLVertexFormatFloat4;
case nxt::VertexFormat::FloatR32G32B32:
case dawn::VertexFormat::FloatR32G32B32:
return MTLVertexFormatFloat3;
case nxt::VertexFormat::FloatR32G32:
case dawn::VertexFormat::FloatR32G32:
return MTLVertexFormatFloat2;
case nxt::VertexFormat::FloatR32:
case dawn::VertexFormat::FloatR32:
return MTLVertexFormatFloat;
case nxt::VertexFormat::IntR32G32B32A32:
case dawn::VertexFormat::IntR32G32B32A32:
return MTLVertexFormatInt4;
case nxt::VertexFormat::IntR32G32B32:
case dawn::VertexFormat::IntR32G32B32:
return MTLVertexFormatInt3;
case nxt::VertexFormat::IntR32G32:
case dawn::VertexFormat::IntR32G32:
return MTLVertexFormatInt2;
case nxt::VertexFormat::IntR32:
case dawn::VertexFormat::IntR32:
return MTLVertexFormatInt;
case nxt::VertexFormat::UshortR16G16B16A16:
case dawn::VertexFormat::UshortR16G16B16A16:
return MTLVertexFormatUShort4;
case nxt::VertexFormat::UshortR16G16:
case dawn::VertexFormat::UshortR16G16:
return MTLVertexFormatUShort2;
case nxt::VertexFormat::UnormR8G8B8A8:
case dawn::VertexFormat::UnormR8G8B8A8:
return MTLVertexFormatUChar4Normalized;
case nxt::VertexFormat::UnormR8G8:
case dawn::VertexFormat::UnormR8G8:
return MTLVertexFormatUChar2Normalized;
}
}
MTLVertexStepFunction InputStepModeFunction(nxt::InputStepMode mode) {
MTLVertexStepFunction InputStepModeFunction(dawn::InputStepMode mode) {
switch (mode) {
case nxt::InputStepMode::Vertex:
case dawn::InputStepMode::Vertex:
return MTLVertexStepFunctionPerVertex;
case nxt::InputStepMode::Instance:
case dawn::InputStepMode::Instance:
return MTLVertexStepFunctionPerInstance;
}
}

View File

@ -31,11 +31,11 @@ namespace backend { namespace metal {
class PipelineLayout : public PipelineLayoutBase {
public:
PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor);
PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor);
using BindingIndexInfo =
std::array<std::array<uint32_t, kMaxBindingsPerGroup>, kMaxBindGroups>;
const BindingIndexInfo& GetBindingIndexInfo(nxt::ShaderStage stage) const;
const BindingIndexInfo& GetBindingIndexInfo(dawn::ShaderStage stage) const;
private:
PerStage<BindingIndexInfo> mIndexInfo;

View File

@ -20,7 +20,7 @@
namespace backend { namespace metal {
PipelineLayout::PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor)
PipelineLayout::PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor) {
// Each stage has its own numbering namespace in CompilerMSL.
for (auto stage : IterateStages(kAllStages)) {
@ -40,16 +40,16 @@ namespace backend { namespace metal {
}
switch (groupInfo.types[binding]) {
case nxt::BindingType::UniformBuffer:
case nxt::BindingType::StorageBuffer:
case dawn::BindingType::UniformBuffer:
case dawn::BindingType::StorageBuffer:
mIndexInfo[stage][group][binding] = bufferIndex;
bufferIndex++;
break;
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
mIndexInfo[stage][group][binding] = samplerIndex;
samplerIndex++;
break;
case nxt::BindingType::SampledTexture:
case dawn::BindingType::SampledTexture:
mIndexInfo[stage][group][binding] = textureIndex;
textureIndex++;
break;
@ -60,7 +60,7 @@ namespace backend { namespace metal {
}
const PipelineLayout::BindingIndexInfo& PipelineLayout::GetBindingIndexInfo(
nxt::ShaderStage stage) const {
dawn::ShaderStage stage) const {
return mIndexInfo[stage];
}

View File

@ -25,40 +25,40 @@
namespace backend { namespace metal {
namespace {
MTLPrimitiveType MTLPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology) {
MTLPrimitiveType MTLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) {
case nxt::PrimitiveTopology::PointList:
case dawn::PrimitiveTopology::PointList:
return MTLPrimitiveTypePoint;
case nxt::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::LineList:
return MTLPrimitiveTypeLine;
case nxt::PrimitiveTopology::LineStrip:
case dawn::PrimitiveTopology::LineStrip:
return MTLPrimitiveTypeLineStrip;
case nxt::PrimitiveTopology::TriangleList:
case dawn::PrimitiveTopology::TriangleList:
return MTLPrimitiveTypeTriangle;
case nxt::PrimitiveTopology::TriangleStrip:
case dawn::PrimitiveTopology::TriangleStrip:
return MTLPrimitiveTypeTriangleStrip;
}
}
MTLPrimitiveTopologyClass MTLInputPrimitiveTopology(
nxt::PrimitiveTopology primitiveTopology) {
dawn::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) {
case nxt::PrimitiveTopology::PointList:
case dawn::PrimitiveTopology::PointList:
return MTLPrimitiveTopologyClassPoint;
case nxt::PrimitiveTopology::LineList:
case nxt::PrimitiveTopology::LineStrip:
case dawn::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::LineStrip:
return MTLPrimitiveTopologyClassLine;
case nxt::PrimitiveTopology::TriangleList:
case nxt::PrimitiveTopology::TriangleStrip:
case dawn::PrimitiveTopology::TriangleList:
case dawn::PrimitiveTopology::TriangleStrip:
return MTLPrimitiveTopologyClassTriangle;
}
}
MTLIndexType MTLIndexFormat(nxt::IndexFormat format) {
MTLIndexType MTLIndexFormat(dawn::IndexFormat format) {
switch (format) {
case nxt::IndexFormat::Uint16:
case dawn::IndexFormat::Uint16:
return MTLIndexTypeUInt16;
case nxt::IndexFormat::Uint32:
case dawn::IndexFormat::Uint32:
return MTLIndexTypeUInt32;
}
}
@ -81,20 +81,20 @@ namespace backend { namespace metal {
id<MTLFunction> function = data.function;
switch (stage) {
case nxt::ShaderStage::Vertex:
case dawn::ShaderStage::Vertex:
descriptor.vertexFunction = function;
break;
case nxt::ShaderStage::Fragment:
case dawn::ShaderStage::Fragment:
descriptor.fragmentFunction = function;
break;
case nxt::ShaderStage::Compute:
case dawn::ShaderStage::Compute:
UNREACHABLE();
}
}
if (HasDepthStencilAttachment()) {
// TODO(kainino@chromium.org): Handle depth-only and stencil-only formats.
nxt::TextureFormat depthStencilFormat = GetDepthStencilFormat();
dawn::TextureFormat depthStencilFormat = GetDepthStencilFormat();
descriptor.depthAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
descriptor.stencilAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
}

View File

@ -25,7 +25,7 @@ namespace backend { namespace metal {
class Sampler : public SamplerBase {
public:
Sampler(Device* device, const nxt::SamplerDescriptor* descriptor);
Sampler(Device* device, const dawn::SamplerDescriptor* descriptor);
~Sampler();
id<MTLSamplerState> GetMTLSamplerState();

View File

@ -19,37 +19,37 @@
namespace backend { namespace metal {
namespace {
MTLSamplerMinMagFilter FilterModeToMinMagFilter(nxt::FilterMode mode) {
MTLSamplerMinMagFilter FilterModeToMinMagFilter(dawn::FilterMode mode) {
switch (mode) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
return MTLSamplerMinMagFilterNearest;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
return MTLSamplerMinMagFilterLinear;
}
}
MTLSamplerMipFilter FilterModeToMipFilter(nxt::FilterMode mode) {
MTLSamplerMipFilter FilterModeToMipFilter(dawn::FilterMode mode) {
switch (mode) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
return MTLSamplerMipFilterNearest;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
return MTLSamplerMipFilterLinear;
}
}
MTLSamplerAddressMode AddressMode(nxt::AddressMode mode) {
MTLSamplerAddressMode AddressMode(dawn::AddressMode mode) {
switch (mode) {
case nxt::AddressMode::Repeat:
case dawn::AddressMode::Repeat:
return MTLSamplerAddressModeRepeat;
case nxt::AddressMode::MirroredRepeat:
case dawn::AddressMode::MirroredRepeat:
return MTLSamplerAddressModeMirrorRepeat;
case nxt::AddressMode::ClampToEdge:
case dawn::AddressMode::ClampToEdge:
return MTLSamplerAddressModeClampToEdge;
}
}
}
Sampler::Sampler(Device* device, const nxt::SamplerDescriptor* descriptor)
Sampler::Sampler(Device* device, const dawn::SamplerDescriptor* descriptor)
: SamplerBase(device, descriptor) {
MTLSamplerDescriptor* mtlDesc = [MTLSamplerDescriptor new];
[mtlDesc autorelease];

View File

@ -26,13 +26,13 @@ namespace backend { namespace metal {
namespace {
spv::ExecutionModel SpirvExecutionModelForStage(nxt::ShaderStage stage) {
spv::ExecutionModel SpirvExecutionModelForStage(dawn::ShaderStage stage) {
switch (stage) {
case nxt::ShaderStage::Vertex:
case dawn::ShaderStage::Vertex:
return spv::ExecutionModelVertex;
case nxt::ShaderStage::Fragment:
case dawn::ShaderStage::Fragment:
return spv::ExecutionModelFragment;
case nxt::ShaderStage::Compute:
case dawn::ShaderStage::Compute:
return spv::ExecutionModelGLCompute;
default:
UNREACHABLE();

View File

@ -21,7 +21,7 @@
namespace backend { namespace metal {
MTLPixelFormat MetalPixelFormat(nxt::TextureFormat format);
MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format);
class Texture : public TextureBase {
public:

View File

@ -18,49 +18,49 @@
namespace backend { namespace metal {
MTLPixelFormat MetalPixelFormat(nxt::TextureFormat format) {
MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format) {
switch (format) {
case nxt::TextureFormat::R8G8B8A8Unorm:
case dawn::TextureFormat::R8G8B8A8Unorm:
return MTLPixelFormatRGBA8Unorm;
case nxt::TextureFormat::R8G8Unorm:
case dawn::TextureFormat::R8G8Unorm:
return MTLPixelFormatRG8Unorm;
case nxt::TextureFormat::R8Unorm:
case dawn::TextureFormat::R8Unorm:
return MTLPixelFormatR8Unorm;
case nxt::TextureFormat::R8G8B8A8Uint:
case dawn::TextureFormat::R8G8B8A8Uint:
return MTLPixelFormatRGBA8Uint;
case nxt::TextureFormat::R8G8Uint:
case dawn::TextureFormat::R8G8Uint:
return MTLPixelFormatRG8Uint;
case nxt::TextureFormat::R8Uint:
case dawn::TextureFormat::R8Uint:
return MTLPixelFormatR8Uint;
case nxt::TextureFormat::B8G8R8A8Unorm:
case dawn::TextureFormat::B8G8R8A8Unorm:
return MTLPixelFormatBGRA8Unorm;
case nxt::TextureFormat::D32FloatS8Uint:
case dawn::TextureFormat::D32FloatS8Uint:
return MTLPixelFormatDepth32Float_Stencil8;
}
}
namespace {
MTLTextureUsage MetalTextureUsage(nxt::TextureUsageBit usage) {
MTLTextureUsage MetalTextureUsage(dawn::TextureUsageBit usage) {
MTLTextureUsage result = MTLTextureUsageUnknown; // This is 0
if (usage & (nxt::TextureUsageBit::Storage)) {
if (usage & (dawn::TextureUsageBit::Storage)) {
result |= MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
}
if (usage & (nxt::TextureUsageBit::Sampled)) {
if (usage & (dawn::TextureUsageBit::Sampled)) {
result |= MTLTextureUsageShaderRead;
}
if (usage & (nxt::TextureUsageBit::OutputAttachment)) {
if (usage & (dawn::TextureUsageBit::OutputAttachment)) {
result |= MTLTextureUsageRenderTarget;
}
return result;
}
MTLTextureType MetalTextureType(nxt::TextureDimension dimension) {
MTLTextureType MetalTextureType(dawn::TextureDimension dimension) {
switch (dimension) {
case nxt::TextureDimension::e2D:
case dawn::TextureDimension::e2D:
return MTLTextureType2D;
}
}

View File

@ -40,7 +40,7 @@ namespace backend { namespace null {
return new BindGroup(builder);
}
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor);
}
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -65,7 +65,7 @@ namespace backend { namespace null {
return new InputState(builder);
}
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) {
const dawn::PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor);
}
ResultOrError<QueueBase*> Device::CreateQueueImpl() {
@ -79,7 +79,7 @@ namespace backend { namespace null {
return new RenderPipeline(builder);
}
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor);
}
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {
@ -124,8 +124,8 @@ namespace backend { namespace null {
};
Buffer::Buffer(BufferBuilder* builder) : BufferBase(builder) {
if (GetAllowedUsage() & (nxt::BufferUsageBit::TransferDst | nxt::BufferUsageBit::MapRead |
nxt::BufferUsageBit::MapWrite)) {
if (GetAllowedUsage() & (dawn::BufferUsageBit::TransferDst | dawn::BufferUsageBit::MapRead |
dawn::BufferUsageBit::MapWrite)) {
mBackingData = std::unique_ptr<char[]>(new char[GetSize()]);
}
}

View File

@ -118,12 +118,12 @@ namespace backend { namespace null {
private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) override;
const dawn::BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) override;
const dawn::PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
std::vector<std::unique_ptr<PendingOperation>> mPendingOperations;
};

View File

@ -19,50 +19,50 @@
namespace backend { namespace opengl {
namespace {
GLenum GLBlendFactor(nxt::BlendFactor factor, bool alpha) {
GLenum GLBlendFactor(dawn::BlendFactor factor, bool alpha) {
switch (factor) {
case nxt::BlendFactor::Zero:
case dawn::BlendFactor::Zero:
return GL_ZERO;
case nxt::BlendFactor::One:
case dawn::BlendFactor::One:
return GL_ONE;
case nxt::BlendFactor::SrcColor:
case dawn::BlendFactor::SrcColor:
return GL_SRC_COLOR;
case nxt::BlendFactor::OneMinusSrcColor:
case dawn::BlendFactor::OneMinusSrcColor:
return GL_ONE_MINUS_SRC_COLOR;
case nxt::BlendFactor::SrcAlpha:
case dawn::BlendFactor::SrcAlpha:
return GL_SRC_ALPHA;
case nxt::BlendFactor::OneMinusSrcAlpha:
case dawn::BlendFactor::OneMinusSrcAlpha:
return GL_ONE_MINUS_SRC_ALPHA;
case nxt::BlendFactor::DstColor:
case dawn::BlendFactor::DstColor:
return GL_DST_COLOR;
case nxt::BlendFactor::OneMinusDstColor:
case dawn::BlendFactor::OneMinusDstColor:
return GL_ONE_MINUS_DST_COLOR;
case nxt::BlendFactor::DstAlpha:
case dawn::BlendFactor::DstAlpha:
return GL_DST_ALPHA;
case nxt::BlendFactor::OneMinusDstAlpha:
case dawn::BlendFactor::OneMinusDstAlpha:
return GL_ONE_MINUS_DST_ALPHA;
case nxt::BlendFactor::SrcAlphaSaturated:
case dawn::BlendFactor::SrcAlphaSaturated:
return GL_SRC_ALPHA_SATURATE;
case nxt::BlendFactor::BlendColor:
case dawn::BlendFactor::BlendColor:
return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR;
case nxt::BlendFactor::OneMinusBlendColor:
case dawn::BlendFactor::OneMinusBlendColor:
return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR;
default:
UNREACHABLE();
}
}
GLenum GLBlendMode(nxt::BlendOperation operation) {
GLenum GLBlendMode(dawn::BlendOperation operation) {
switch (operation) {
case nxt::BlendOperation::Add:
case dawn::BlendOperation::Add:
return GL_FUNC_ADD;
case nxt::BlendOperation::Subtract:
case dawn::BlendOperation::Subtract:
return GL_FUNC_SUBTRACT;
case nxt::BlendOperation::ReverseSubtract:
case dawn::BlendOperation::ReverseSubtract:
return GL_FUNC_REVERSE_SUBTRACT;
case nxt::BlendOperation::Min:
case dawn::BlendOperation::Min:
return GL_MIN;
case nxt::BlendOperation::Max:
case dawn::BlendOperation::Max:
return GL_MAX;
default:
UNREACHABLE();
@ -87,10 +87,10 @@ namespace backend { namespace opengl {
} else {
glDisablei(GL_BLEND, attachment);
}
glColorMaski(attachment, info.colorWriteMask & nxt::ColorWriteMask::Red,
info.colorWriteMask & nxt::ColorWriteMask::Green,
info.colorWriteMask & nxt::ColorWriteMask::Blue,
info.colorWriteMask & nxt::ColorWriteMask::Alpha);
glColorMaski(attachment, info.colorWriteMask & dawn::ColorWriteMask::Red,
info.colorWriteMask & dawn::ColorWriteMask::Green,
info.colorWriteMask & dawn::ColorWriteMask::Blue,
info.colorWriteMask & dawn::ColorWriteMask::Alpha);
}
}} // namespace backend::opengl

View File

@ -32,44 +32,44 @@ namespace backend { namespace opengl {
namespace {
GLenum IndexFormatType(nxt::IndexFormat format) {
GLenum IndexFormatType(dawn::IndexFormat format) {
switch (format) {
case nxt::IndexFormat::Uint16:
case dawn::IndexFormat::Uint16:
return GL_UNSIGNED_SHORT;
case nxt::IndexFormat::Uint32:
case dawn::IndexFormat::Uint32:
return GL_UNSIGNED_INT;
default:
UNREACHABLE();
}
}
GLenum VertexFormatType(nxt::VertexFormat format) {
GLenum VertexFormatType(dawn::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::FloatR32G32B32A32:
case nxt::VertexFormat::FloatR32G32B32:
case nxt::VertexFormat::FloatR32G32:
case nxt::VertexFormat::FloatR32:
case dawn::VertexFormat::FloatR32G32B32A32:
case dawn::VertexFormat::FloatR32G32B32:
case dawn::VertexFormat::FloatR32G32:
case dawn::VertexFormat::FloatR32:
return GL_FLOAT;
case nxt::VertexFormat::IntR32G32B32A32:
case nxt::VertexFormat::IntR32G32B32:
case nxt::VertexFormat::IntR32G32:
case nxt::VertexFormat::IntR32:
case dawn::VertexFormat::IntR32G32B32A32:
case dawn::VertexFormat::IntR32G32B32:
case dawn::VertexFormat::IntR32G32:
case dawn::VertexFormat::IntR32:
return GL_INT;
case nxt::VertexFormat::UshortR16G16B16A16:
case nxt::VertexFormat::UshortR16G16:
case dawn::VertexFormat::UshortR16G16B16A16:
case dawn::VertexFormat::UshortR16G16:
return GL_UNSIGNED_SHORT;
case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8:
case dawn::VertexFormat::UnormR8G8B8A8:
case dawn::VertexFormat::UnormR8G8:
return GL_UNSIGNED_BYTE;
default:
UNREACHABLE();
}
}
GLboolean VertexFormatIsNormalized(nxt::VertexFormat format) {
GLboolean VertexFormatIsNormalized(dawn::VertexFormat format) {
switch (format) {
case nxt::VertexFormat::UnormR8G8B8A8:
case nxt::VertexFormat::UnormR8G8:
case dawn::VertexFormat::UnormR8G8B8A8:
case dawn::VertexFormat::UnormR8G8:
return GL_TRUE;
default:
return GL_FALSE;
@ -92,7 +92,7 @@ namespace backend { namespace opengl {
}
}
void OnSetPushConstants(nxt::ShaderStageBit stages,
void OnSetPushConstants(dawn::ShaderStageBit stages,
uint32_t count,
uint32_t offset,
const uint32_t* data) {
@ -237,7 +237,7 @@ namespace backend { namespace opengl {
for (uint32_t binding : IterateBitSet(layout.mask)) {
switch (layout.types[binding]) {
case nxt::BindingType::UniformBuffer: {
case dawn::BindingType::UniformBuffer: {
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
GLuint uboIndex = indices[binding];
@ -246,7 +246,7 @@ namespace backend { namespace opengl {
view->GetSize());
} break;
case nxt::BindingType::Sampler: {
case dawn::BindingType::Sampler: {
GLuint sampler =
ToBackend(group->GetBindingAsSampler(binding))->GetHandle();
GLuint samplerIndex = indices[binding];
@ -256,7 +256,7 @@ namespace backend { namespace opengl {
}
} break;
case nxt::BindingType::SampledTexture: {
case dawn::BindingType::SampledTexture: {
TextureView* view = ToBackend(group->GetBindingAsTextureView(binding));
Texture* texture = ToBackend(view->GetTexture());
GLuint handle = texture->GetHandle();
@ -269,7 +269,7 @@ namespace backend { namespace opengl {
}
} break;
case nxt::BindingType::StorageBuffer: {
case dawn::BindingType::StorageBuffer: {
BufferView* view = ToBackend(group->GetBindingAsBufferView(binding));
GLuint buffer = ToBackend(view->GetBuffer())->GetHandle();
GLuint ssboIndex = indices[binding];
@ -331,7 +331,7 @@ namespace backend { namespace opengl {
glActiveTexture(GL_TEXTURE0);
glBindTexture(target, texture->GetHandle());
ASSERT(texture->GetDimension() == nxt::TextureDimension::e2D);
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D);
glPixelStorei(GL_UNPACK_ROW_LENGTH,
copy->rowPitch / TextureFormatPixelSize(texture->GetFormat()));
glTexSubImage2D(target, dst.level, dst.x, dst.y, dst.width, dst.height,
@ -351,7 +351,7 @@ namespace backend { namespace opengl {
// The only way to move data from a texture to a buffer in GL is via
// glReadPixels with a pack buffer. Create a temporary FBO for the copy.
ASSERT(texture->GetDimension() == nxt::TextureDimension::e2D);
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D);
glBindTexture(GL_TEXTURE_2D, texture->GetHandle());
GLuint readFBO = 0;
@ -462,18 +462,18 @@ namespace backend { namespace opengl {
// TODO(kainino@chromium.org): the color clears (later in
// this function) may be undefined for non-normalized integer formats.
nxt::TextureFormat format = textureView->GetTexture()->GetFormat();
ASSERT(format == nxt::TextureFormat::R8G8B8A8Unorm ||
format == nxt::TextureFormat::R8G8Unorm ||
format == nxt::TextureFormat::R8Unorm ||
format == nxt::TextureFormat::B8G8R8A8Unorm);
dawn::TextureFormat format = textureView->GetTexture()->GetFormat();
ASSERT(format == dawn::TextureFormat::R8G8B8A8Unorm ||
format == dawn::TextureFormat::R8G8Unorm ||
format == dawn::TextureFormat::R8Unorm ||
format == dawn::TextureFormat::B8G8R8A8Unorm);
}
glDrawBuffers(attachmentCount, drawBuffers.data());
if (renderPass->HasDepthStencilAttachment()) {
TextureViewBase* textureView = renderPass->GetDepthStencilAttachment().view.Get();
GLuint texture = ToBackend(textureView->GetTexture())->GetHandle();
nxt::TextureFormat format = textureView->GetTexture()->GetFormat();
dawn::TextureFormat format = textureView->GetTexture()->GetFormat();
// Attach depth/stencil buffer.
GLenum glAttachment = 0;
@ -494,7 +494,7 @@ namespace backend { namespace opengl {
// TODO(kainino@chromium.org): the depth/stencil clears (later in
// this function) may be undefined for other texture formats.
ASSERT(format == nxt::TextureFormat::D32FloatS8Uint);
ASSERT(format == dawn::TextureFormat::D32FloatS8Uint);
}
}
@ -504,21 +504,21 @@ namespace backend { namespace opengl {
const auto& attachmentInfo = renderPass->GetColorAttachment(i);
// Load op - color
if (attachmentInfo.loadOp == nxt::LoadOp::Clear) {
if (attachmentInfo.loadOp == dawn::LoadOp::Clear) {
glClearBufferfv(GL_COLOR, i, attachmentInfo.clearColor.data());
}
}
if (renderPass->HasDepthStencilAttachment()) {
const auto& attachmentInfo = renderPass->GetDepthStencilAttachment();
nxt::TextureFormat attachmentFormat =
dawn::TextureFormat attachmentFormat =
attachmentInfo.view->GetTexture()->GetFormat();
// Load op - depth/stencil
bool doDepthClear = TextureFormatHasDepth(attachmentFormat) &&
(attachmentInfo.depthLoadOp == nxt::LoadOp::Clear);
(attachmentInfo.depthLoadOp == dawn::LoadOp::Clear);
bool doStencilClear = TextureFormatHasStencil(attachmentFormat) &&
(attachmentInfo.stencilLoadOp == nxt::LoadOp::Clear);
(attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear);
if (doDepthClear && doStencilClear) {
glClearBufferfi(GL_DEPTH_STENCIL, 0, attachmentInfo.clearDepth,
attachmentInfo.clearStencil);
@ -576,7 +576,7 @@ namespace backend { namespace opengl {
pushConstants.Apply(lastPipeline, lastPipeline);
inputBuffers.Apply();
nxt::IndexFormat indexFormat = lastPipeline->GetIndexFormat();
dawn::IndexFormat indexFormat = lastPipeline->GetIndexFormat();
size_t formatSize = IndexFormatSize(indexFormat);
GLenum formatType = IndexFormatType(indexFormat);

View File

@ -20,46 +20,46 @@
namespace backend { namespace opengl {
namespace {
GLuint OpenGLCompareFunction(nxt::CompareFunction compareFunction) {
GLuint OpenGLCompareFunction(dawn::CompareFunction compareFunction) {
switch (compareFunction) {
case nxt::CompareFunction::Never:
case dawn::CompareFunction::Never:
return GL_NEVER;
case nxt::CompareFunction::Less:
case dawn::CompareFunction::Less:
return GL_LESS;
case nxt::CompareFunction::LessEqual:
case dawn::CompareFunction::LessEqual:
return GL_LEQUAL;
case nxt::CompareFunction::Greater:
case dawn::CompareFunction::Greater:
return GL_GREATER;
case nxt::CompareFunction::GreaterEqual:
case dawn::CompareFunction::GreaterEqual:
return GL_GEQUAL;
case nxt::CompareFunction::NotEqual:
case dawn::CompareFunction::NotEqual:
return GL_NOTEQUAL;
case nxt::CompareFunction::Equal:
case dawn::CompareFunction::Equal:
return GL_EQUAL;
case nxt::CompareFunction::Always:
case dawn::CompareFunction::Always:
return GL_ALWAYS;
default:
UNREACHABLE();
}
}
GLuint OpenGLStencilOperation(nxt::StencilOperation stencilOperation) {
GLuint OpenGLStencilOperation(dawn::StencilOperation stencilOperation) {
switch (stencilOperation) {
case nxt::StencilOperation::Keep:
case dawn::StencilOperation::Keep:
return GL_KEEP;
case nxt::StencilOperation::Zero:
case dawn::StencilOperation::Zero:
return GL_ZERO;
case nxt::StencilOperation::Replace:
case dawn::StencilOperation::Replace:
return GL_REPLACE;
case nxt::StencilOperation::Invert:
case dawn::StencilOperation::Invert:
return GL_INVERT;
case nxt::StencilOperation::IncrementClamp:
case dawn::StencilOperation::IncrementClamp:
return GL_INCR;
case nxt::StencilOperation::DecrementClamp:
case dawn::StencilOperation::DecrementClamp:
return GL_DECR;
case nxt::StencilOperation::IncrementWrap:
case dawn::StencilOperation::IncrementWrap:
return GL_INCR_WRAP;
case nxt::StencilOperation::DecrementWrap:
case dawn::StencilOperation::DecrementWrap:
return GL_DECR_WRAP;
default:
UNREACHABLE();
@ -75,7 +75,7 @@ namespace backend { namespace opengl {
auto& depthInfo = GetDepth();
// Depth writes only occur if depth is enabled
if (depthInfo.compareFunction == nxt::CompareFunction::Always &&
if (depthInfo.compareFunction == dawn::CompareFunction::Always &&
!depthInfo.depthWriteEnabled) {
glDisable(GL_DEPTH_TEST);
} else {

View File

@ -54,7 +54,7 @@ namespace backend { namespace opengl {
return new BindGroup(builder);
}
ResultOrError<BindGroupLayoutBase*> Device::CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) {
const dawn::BindGroupLayoutDescriptor* descriptor) {
return new BindGroupLayout(this, descriptor);
}
BlendStateBase* Device::CreateBlendState(BlendStateBuilder* builder) {
@ -79,7 +79,7 @@ namespace backend { namespace opengl {
return new InputState(builder);
}
ResultOrError<PipelineLayoutBase*> Device::CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) {
const dawn::PipelineLayoutDescriptor* descriptor) {
return new PipelineLayout(this, descriptor);
}
ResultOrError<QueueBase*> Device::CreateQueueImpl() {
@ -93,7 +93,7 @@ namespace backend { namespace opengl {
return new RenderPipeline(builder);
}
ResultOrError<SamplerBase*> Device::CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) {
const dawn::SamplerDescriptor* descriptor) {
return new Sampler(this, descriptor);
}
ShaderModuleBase* Device::CreateShaderModule(ShaderModuleBuilder* builder) {

View File

@ -52,12 +52,12 @@ namespace backend { namespace opengl {
private:
ResultOrError<BindGroupLayoutBase*> CreateBindGroupLayoutImpl(
const nxt::BindGroupLayoutDescriptor* descriptor) override;
const dawn::BindGroupLayoutDescriptor* descriptor) override;
ResultOrError<PipelineLayoutBase*> CreatePipelineLayoutImpl(
const nxt::PipelineLayoutDescriptor* descriptor) override;
const dawn::PipelineLayoutDescriptor* descriptor) override;
ResultOrError<QueueBase*> CreateQueueImpl() override;
ResultOrError<SamplerBase*> CreateSamplerImpl(
const nxt::SamplerDescriptor* descriptor) override;
const dawn::SamplerDescriptor* descriptor) override;
};
}} // namespace backend::opengl

View File

@ -38,9 +38,9 @@ namespace backend { namespace opengl {
glVertexAttribDivisor(location, 0xffffffff);
} else {
switch (input.stepMode) {
case nxt::InputStepMode::Vertex:
case dawn::InputStepMode::Vertex:
break;
case nxt::InputStepMode::Instance:
case dawn::InputStepMode::Instance:
glVertexAttribDivisor(location, 1);
break;
default:

View File

@ -28,13 +28,13 @@ namespace backend { namespace opengl {
namespace {
GLenum GLShaderType(nxt::ShaderStage stage) {
GLenum GLShaderType(dawn::ShaderStage stage) {
switch (stage) {
case nxt::ShaderStage::Vertex:
case dawn::ShaderStage::Vertex:
return GL_VERTEX_SHADER;
case nxt::ShaderStage::Fragment:
case dawn::ShaderStage::Fragment:
return GL_FRAGMENT_SHADER;
case nxt::ShaderStage::Compute:
case dawn::ShaderStage::Compute:
return GL_COMPUTE_SHADER;
default:
UNREACHABLE();
@ -136,19 +136,19 @@ namespace backend { namespace opengl {
std::string name = GetBindingName(group, binding);
switch (groupInfo.types[binding]) {
case nxt::BindingType::UniformBuffer: {
case dawn::BindingType::UniformBuffer: {
GLint location = glGetUniformBlockIndex(mProgram, name.c_str());
glUniformBlockBinding(mProgram, location, indices[group][binding]);
} break;
case nxt::BindingType::StorageBuffer: {
case dawn::BindingType::StorageBuffer: {
GLuint location = glGetProgramResourceIndex(
mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str());
glShaderStorageBlockBinding(mProgram, location, indices[group][binding]);
} break;
case nxt::BindingType::Sampler:
case nxt::BindingType::SampledTexture:
case dawn::BindingType::Sampler:
case dawn::BindingType::SampledTexture:
// These binding types are handled in the separate sampler and texture
// emulation
break;
@ -190,7 +190,7 @@ namespace backend { namespace opengl {
}
const PipelineGL::GLPushConstantInfo& PipelineGL::GetGLPushConstants(
nxt::ShaderStage stage) const {
dawn::ShaderStage stage) const {
return mGlPushConstants[stage];
}

View File

@ -35,7 +35,7 @@ namespace backend { namespace opengl {
using BindingLocations =
std::array<std::array<GLint, kMaxBindingsPerGroup>, kMaxBindGroups>;
const GLPushConstantInfo& GetGLPushConstants(nxt::ShaderStage stage) const;
const GLPushConstantInfo& GetGLPushConstants(dawn::ShaderStage stage) const;
const std::vector<GLuint>& GetTextureUnitsForSampler(GLuint index) const;
const std::vector<GLuint>& GetTextureUnitsForTexture(GLuint index) const;
GLuint GetProgramHandle() const;

View File

@ -20,7 +20,7 @@
namespace backend { namespace opengl {
PipelineLayout::PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor)
PipelineLayout::PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor)
: PipelineLayoutBase(device, descriptor) {
GLuint uboIndex = 0;
GLuint samplerIndex = 0;
@ -36,20 +36,20 @@ namespace backend { namespace opengl {
}
switch (groupInfo.types[binding]) {
case nxt::BindingType::UniformBuffer:
case dawn::BindingType::UniformBuffer:
mIndexInfo[group][binding] = uboIndex;
uboIndex++;
break;
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
mIndexInfo[group][binding] = samplerIndex;
samplerIndex++;
break;
case nxt::BindingType::SampledTexture:
case dawn::BindingType::SampledTexture:
mIndexInfo[group][binding] = sampledTextureIndex;
sampledTextureIndex++;
break;
case nxt::BindingType::StorageBuffer:
case dawn::BindingType::StorageBuffer:
mIndexInfo[group][binding] = ssboIndex;
ssboIndex++;
break;

View File

@ -25,7 +25,7 @@ namespace backend { namespace opengl {
class PipelineLayout : public PipelineLayoutBase {
public:
PipelineLayout(Device* device, const nxt::PipelineLayoutDescriptor* descriptor);
PipelineLayout(Device* device, const dawn::PipelineLayoutDescriptor* descriptor);
using BindingIndexInfo =
std::array<std::array<GLuint, kMaxBindingsPerGroup>, kMaxBindGroups>;

View File

@ -23,17 +23,17 @@
namespace backend { namespace opengl {
namespace {
GLenum GLPrimitiveTopology(nxt::PrimitiveTopology primitiveTopology) {
GLenum GLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) {
case nxt::PrimitiveTopology::PointList:
case dawn::PrimitiveTopology::PointList:
return GL_POINTS;
case nxt::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::LineList:
return GL_LINES;
case nxt::PrimitiveTopology::LineStrip:
case dawn::PrimitiveTopology::LineStrip:
return GL_LINE_STRIP;
case nxt::PrimitiveTopology::TriangleList:
case dawn::PrimitiveTopology::TriangleList:
return GL_TRIANGLES;
case nxt::PrimitiveTopology::TriangleStrip:
case dawn::PrimitiveTopology::TriangleStrip:
return GL_TRIANGLE_STRIP;
default:
UNREACHABLE();

View File

@ -20,33 +20,33 @@
namespace backend { namespace opengl {
namespace {
GLenum MagFilterMode(nxt::FilterMode filter) {
GLenum MagFilterMode(dawn::FilterMode filter) {
switch (filter) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
return GL_NEAREST;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
return GL_LINEAR;
default:
UNREACHABLE();
}
}
GLenum MinFilterMode(nxt::FilterMode minFilter, nxt::FilterMode mipMapFilter) {
GLenum MinFilterMode(dawn::FilterMode minFilter, dawn::FilterMode mipMapFilter) {
switch (minFilter) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
switch (mipMapFilter) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
return GL_NEAREST_MIPMAP_NEAREST;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
return GL_NEAREST_MIPMAP_LINEAR;
default:
UNREACHABLE();
}
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
switch (mipMapFilter) {
case nxt::FilterMode::Nearest:
case dawn::FilterMode::Nearest:
return GL_LINEAR_MIPMAP_NEAREST;
case nxt::FilterMode::Linear:
case dawn::FilterMode::Linear:
return GL_LINEAR_MIPMAP_LINEAR;
default:
UNREACHABLE();
@ -56,13 +56,13 @@ namespace backend { namespace opengl {
}
}
GLenum WrapMode(nxt::AddressMode mode) {
GLenum WrapMode(dawn::AddressMode mode) {
switch (mode) {
case nxt::AddressMode::Repeat:
case dawn::AddressMode::Repeat:
return GL_REPEAT;
case nxt::AddressMode::MirroredRepeat:
case dawn::AddressMode::MirroredRepeat:
return GL_MIRRORED_REPEAT;
case nxt::AddressMode::ClampToEdge:
case dawn::AddressMode::ClampToEdge:
return GL_CLAMP_TO_EDGE;
default:
UNREACHABLE();
@ -71,7 +71,7 @@ namespace backend { namespace opengl {
} // namespace
Sampler::Sampler(Device* device, const nxt::SamplerDescriptor* descriptor)
Sampler::Sampler(Device* device, const dawn::SamplerDescriptor* descriptor)
: SamplerBase(device, descriptor) {
glGenSamplers(1, &mHandle);
glSamplerParameteri(mHandle, GL_TEXTURE_MAG_FILTER, MagFilterMode(descriptor->magFilter));

View File

@ -25,7 +25,7 @@ namespace backend { namespace opengl {
class Sampler : public SamplerBase {
public:
Sampler(Device* device, const nxt::SamplerDescriptor* descriptor);
Sampler(Device* device, const dawn::SamplerDescriptor* descriptor);
GLuint GetHandle() const;

View File

@ -23,33 +23,33 @@ namespace backend { namespace opengl {
namespace {
GLenum TargetForDimension(nxt::TextureDimension dimension) {
GLenum TargetForDimension(dawn::TextureDimension dimension) {
switch (dimension) {
case nxt::TextureDimension::e2D:
case dawn::TextureDimension::e2D:
return GL_TEXTURE_2D;
default:
UNREACHABLE();
}
}
TextureFormatInfo GetGLFormatInfo(nxt::TextureFormat format) {
TextureFormatInfo GetGLFormatInfo(dawn::TextureFormat format) {
switch (format) {
case nxt::TextureFormat::R8G8B8A8Unorm:
case dawn::TextureFormat::R8G8B8A8Unorm:
return {GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE};
case nxt::TextureFormat::R8G8Unorm:
case dawn::TextureFormat::R8G8Unorm:
return {GL_RG8, GL_RG, GL_UNSIGNED_BYTE};
case nxt::TextureFormat::R8Unorm:
case dawn::TextureFormat::R8Unorm:
return {GL_R8, GL_RED, GL_UNSIGNED_BYTE};
case nxt::TextureFormat::R8G8B8A8Uint:
case dawn::TextureFormat::R8G8B8A8Uint:
return {GL_RGBA8UI, GL_RGBA, GL_UNSIGNED_INT};
case nxt::TextureFormat::R8G8Uint:
case dawn::TextureFormat::R8G8Uint:
return {GL_RG8UI, GL_RG, GL_UNSIGNED_INT};
case nxt::TextureFormat::R8Uint:
case dawn::TextureFormat::R8Uint:
return {GL_R8UI, GL_RED, GL_UNSIGNED_INT};
case nxt::TextureFormat::B8G8R8A8Unorm:
case dawn::TextureFormat::B8G8R8A8Unorm:
// This doesn't have an enum for the internal format in OpenGL, so use RGBA8.
return {GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE};
case nxt::TextureFormat::D32FloatS8Uint:
case dawn::TextureFormat::D32FloatS8Uint:
return {GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL,
GL_FLOAT_32_UNSIGNED_INT_24_8_REV};
default:

View File

@ -21,16 +21,16 @@ namespace backend { namespace vulkan {
namespace {
VkShaderStageFlags VulkanShaderStageFlags(nxt::ShaderStageBit stages) {
VkShaderStageFlags VulkanShaderStageFlags(dawn::ShaderStageBit stages) {
VkShaderStageFlags flags = 0;
if (stages & nxt::ShaderStageBit::Vertex) {
if (stages & dawn::ShaderStageBit::Vertex) {
flags |= VK_SHADER_STAGE_VERTEX_BIT;
}
if (stages & nxt::ShaderStageBit::Fragment) {
if (stages & dawn::ShaderStageBit::Fragment) {
flags |= VK_SHADER_STAGE_FRAGMENT_BIT;
}
if (stages & nxt::ShaderStageBit::Compute) {
if (stages & dawn::ShaderStageBit::Compute) {
flags |= VK_SHADER_STAGE_COMPUTE_BIT;
}
@ -39,15 +39,15 @@ namespace backend { namespace vulkan {
} // anonymous namespace
VkDescriptorType VulkanDescriptorType(nxt::BindingType type) {
VkDescriptorType VulkanDescriptorType(dawn::BindingType type) {
switch (type) {
case nxt::BindingType::UniformBuffer:
case dawn::BindingType::UniformBuffer:
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
return VK_DESCRIPTOR_TYPE_SAMPLER;
case nxt::BindingType::SampledTexture:
case dawn::BindingType::SampledTexture:
return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
case nxt::BindingType::StorageBuffer:
case dawn::BindingType::StorageBuffer:
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER;
default:
UNREACHABLE();
@ -55,7 +55,7 @@ namespace backend { namespace vulkan {
}
BindGroupLayout::BindGroupLayout(Device* device,
const nxt::BindGroupLayoutDescriptor* descriptor)
const dawn::BindGroupLayoutDescriptor* descriptor)
: BindGroupLayoutBase(device, descriptor) {
const auto& info = GetBindingInfo();
@ -116,15 +116,15 @@ namespace backend { namespace vulkan {
MAX_TYPE,
};
static_assert(MAX_TYPE == kMaxPoolSizesNeeded, "");
auto ToDescriptorType = [](nxt::BindingType type) -> DescriptorType {
auto ToDescriptorType = [](dawn::BindingType type) -> DescriptorType {
switch (type) {
case nxt::BindingType::UniformBuffer:
case dawn::BindingType::UniformBuffer:
return UNIFORM_BUFFER;
case nxt::BindingType::Sampler:
case dawn::BindingType::Sampler:
return SAMPLER;
case nxt::BindingType::SampledTexture:
case dawn::BindingType::SampledTexture:
return SAMPLED_IMAGE;
case nxt::BindingType::StorageBuffer:
case dawn::BindingType::StorageBuffer:
return STORAGE_BUFFER;
default:
UNREACHABLE();

View File

@ -23,11 +23,11 @@ namespace backend { namespace vulkan {
class Device;
VkDescriptorType VulkanDescriptorType(nxt::BindingType type);
VkDescriptorType VulkanDescriptorType(dawn::BindingType type);
class BindGroupLayout : public BindGroupLayoutBase {
public:
BindGroupLayout(Device* device, const nxt::BindGroupLayoutDescriptor* descriptor);
BindGroupLayout(Device* device, const dawn::BindGroupLayoutDescriptor* descriptor);
~BindGroupLayout();
VkDescriptorSetLayout GetHandle() const;

View File

@ -80,8 +80,8 @@ namespace backend { namespace vulkan {
write.descriptorType = VulkanDescriptorType(layoutInfo.types[bindingIndex]);
switch (layoutInfo.types[bindingIndex]) {
case nxt::BindingType::UniformBuffer:
case nxt::BindingType::StorageBuffer: {
case dawn::BindingType::UniformBuffer:
case dawn::BindingType::StorageBuffer: {
BufferViewBase* view = GetBindingAsBufferView(bindingIndex);
Buffer* buffer = ToBackend(view->GetBuffer());
@ -92,13 +92,13 @@ namespace backend { namespace vulkan {
write.pBufferInfo = &writeBufferInfo[numWrites];
} break;
case nxt::BindingType::Sampler: {
case dawn::BindingType::Sampler: {
Sampler* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
writeImageInfo[numWrites].sampler = sampler->GetHandle();
write.pImageInfo = &writeImageInfo[numWrites];
} break;
case nxt::BindingType::SampledTexture: {
case dawn::BindingType::SampledTexture: {
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
writeImageInfo[numWrites].imageView = view->GetHandle();

View File

@ -19,68 +19,68 @@
namespace backend { namespace vulkan {
namespace {
VkBlendFactor VulkanBlendFactor(nxt::BlendFactor factor) {
VkBlendFactor VulkanBlendFactor(dawn::BlendFactor factor) {
switch (factor) {
case nxt::BlendFactor::Zero:
case dawn::BlendFactor::Zero:
return VK_BLEND_FACTOR_ZERO;
case nxt::BlendFactor::One:
case dawn::BlendFactor::One:
return VK_BLEND_FACTOR_ONE;
case nxt::BlendFactor::SrcColor:
case dawn::BlendFactor::SrcColor:
return VK_BLEND_FACTOR_SRC_COLOR;
case nxt::BlendFactor::OneMinusSrcColor:
case dawn::BlendFactor::OneMinusSrcColor:
return VK_BLEND_FACTOR_ONE_MINUS_SRC_COLOR;
case nxt::BlendFactor::SrcAlpha:
case dawn::BlendFactor::SrcAlpha:
return VK_BLEND_FACTOR_SRC_ALPHA;
case nxt::BlendFactor::OneMinusSrcAlpha:
case dawn::BlendFactor::OneMinusSrcAlpha:
return VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
case nxt::BlendFactor::DstColor:
case dawn::BlendFactor::DstColor:
return VK_BLEND_FACTOR_DST_COLOR;
case nxt::BlendFactor::OneMinusDstColor:
case dawn::BlendFactor::OneMinusDstColor:
return VK_BLEND_FACTOR_ONE_MINUS_DST_COLOR;
case nxt::BlendFactor::DstAlpha:
case dawn::BlendFactor::DstAlpha:
return VK_BLEND_FACTOR_DST_ALPHA;
case nxt::BlendFactor::OneMinusDstAlpha:
case dawn::BlendFactor::OneMinusDstAlpha:
return VK_BLEND_FACTOR_ONE_MINUS_DST_ALPHA;
case nxt::BlendFactor::SrcAlphaSaturated:
case dawn::BlendFactor::SrcAlphaSaturated:
return VK_BLEND_FACTOR_SRC_ALPHA_SATURATE;
case nxt::BlendFactor::BlendColor:
case dawn::BlendFactor::BlendColor:
return VK_BLEND_FACTOR_CONSTANT_COLOR;
case nxt::BlendFactor::OneMinusBlendColor:
case dawn::BlendFactor::OneMinusBlendColor:
return VK_BLEND_FACTOR_ONE_MINUS_CONSTANT_COLOR;
default:
UNREACHABLE();
}
}
VkBlendOp VulkanBlendOperation(nxt::BlendOperation operation) {
VkBlendOp VulkanBlendOperation(dawn::BlendOperation operation) {
switch (operation) {
case nxt::BlendOperation::Add:
case dawn::BlendOperation::Add:
return VK_BLEND_OP_ADD;
case nxt::BlendOperation::Subtract:
case dawn::BlendOperation::Subtract:
return VK_BLEND_OP_SUBTRACT;
case nxt::BlendOperation::ReverseSubtract:
case dawn::BlendOperation::ReverseSubtract:
return VK_BLEND_OP_REVERSE_SUBTRACT;
case nxt::BlendOperation::Min:
case dawn::BlendOperation::Min:
return VK_BLEND_OP_MIN;
case nxt::BlendOperation::Max:
case dawn::BlendOperation::Max:
return VK_BLEND_OP_MAX;
default:
UNREACHABLE();
}
}
VkColorComponentFlagBits VulkanColorWriteMask(nxt::ColorWriteMask mask) {
VkColorComponentFlagBits VulkanColorWriteMask(dawn::ColorWriteMask mask) {
// Vulkan and NXT color write masks match, static assert it and return the mask
static_assert(static_cast<VkColorComponentFlagBits>(nxt::ColorWriteMask::Red) ==
static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Red) ==
VK_COLOR_COMPONENT_R_BIT,
"");
static_assert(static_cast<VkColorComponentFlagBits>(nxt::ColorWriteMask::Green) ==
static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Green) ==
VK_COLOR_COMPONENT_G_BIT,
"");
static_assert(static_cast<VkColorComponentFlagBits>(nxt::ColorWriteMask::Blue) ==
static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Blue) ==
VK_COLOR_COMPONENT_B_BIT,
"");
static_assert(static_cast<VkColorComponentFlagBits>(nxt::ColorWriteMask::Alpha) ==
static_assert(static_cast<VkColorComponentFlagBits>(dawn::ColorWriteMask::Alpha) ==
VK_COLOR_COMPONENT_A_BIT,
"");

View File

@ -24,44 +24,44 @@ namespace backend { namespace vulkan {
namespace {
VkBufferUsageFlags VulkanBufferUsage(nxt::BufferUsageBit usage) {
VkBufferUsageFlags VulkanBufferUsage(dawn::BufferUsageBit usage) {
VkBufferUsageFlags flags = 0;
if (usage & nxt::BufferUsageBit::TransferSrc) {
if (usage & dawn::BufferUsageBit::TransferSrc) {
flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
}
if (usage & nxt::BufferUsageBit::TransferDst) {
if (usage & dawn::BufferUsageBit::TransferDst) {
flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
}
if (usage & nxt::BufferUsageBit::Index) {
if (usage & dawn::BufferUsageBit::Index) {
flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
}
if (usage & nxt::BufferUsageBit::Vertex) {
if (usage & dawn::BufferUsageBit::Vertex) {
flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
}
if (usage & nxt::BufferUsageBit::Uniform) {
if (usage & dawn::BufferUsageBit::Uniform) {
flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
}
if (usage & nxt::BufferUsageBit::Storage) {
if (usage & dawn::BufferUsageBit::Storage) {
flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
}
return flags;
}
VkPipelineStageFlags VulkanPipelineStage(nxt::BufferUsageBit usage) {
VkPipelineStageFlags VulkanPipelineStage(dawn::BufferUsageBit usage) {
VkPipelineStageFlags flags = 0;
if (usage & (nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) {
if (usage & (dawn::BufferUsageBit::MapRead | dawn::BufferUsageBit::MapWrite)) {
flags |= VK_PIPELINE_STAGE_HOST_BIT;
}
if (usage & (nxt::BufferUsageBit::TransferSrc | nxt::BufferUsageBit::TransferDst)) {
if (usage & (dawn::BufferUsageBit::TransferSrc | dawn::BufferUsageBit::TransferDst)) {
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
}
if (usage & (nxt::BufferUsageBit::Index | nxt::BufferUsageBit::Vertex)) {
if (usage & (dawn::BufferUsageBit::Index | dawn::BufferUsageBit::Vertex)) {
flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
}
if (usage & (nxt::BufferUsageBit::Uniform | nxt::BufferUsageBit::Storage)) {
if (usage & (dawn::BufferUsageBit::Uniform | dawn::BufferUsageBit::Storage)) {
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
@ -70,31 +70,31 @@ namespace backend { namespace vulkan {
return flags;
}
VkAccessFlags VulkanAccessFlags(nxt::BufferUsageBit usage) {
VkAccessFlags VulkanAccessFlags(dawn::BufferUsageBit usage) {
VkAccessFlags flags = 0;
if (usage & nxt::BufferUsageBit::MapRead) {
if (usage & dawn::BufferUsageBit::MapRead) {
flags |= VK_ACCESS_HOST_READ_BIT;
}
if (usage & nxt::BufferUsageBit::MapWrite) {
if (usage & dawn::BufferUsageBit::MapWrite) {
flags |= VK_ACCESS_HOST_WRITE_BIT;
}
if (usage & nxt::BufferUsageBit::TransferSrc) {
if (usage & dawn::BufferUsageBit::TransferSrc) {
flags |= VK_ACCESS_TRANSFER_READ_BIT;
}
if (usage & nxt::BufferUsageBit::TransferDst) {
if (usage & dawn::BufferUsageBit::TransferDst) {
flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
}
if (usage & nxt::BufferUsageBit::Index) {
if (usage & dawn::BufferUsageBit::Index) {
flags |= VK_ACCESS_INDEX_READ_BIT;
}
if (usage & nxt::BufferUsageBit::Vertex) {
if (usage & dawn::BufferUsageBit::Vertex) {
flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
}
if (usage & nxt::BufferUsageBit::Uniform) {
if (usage & dawn::BufferUsageBit::Uniform) {
flags |= VK_ACCESS_UNIFORM_READ_BIT;
}
if (usage & nxt::BufferUsageBit::Storage) {
if (usage & dawn::BufferUsageBit::Storage) {
flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
}
@ -124,9 +124,8 @@ namespace backend { namespace vulkan {
VkMemoryRequirements requirements;
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
bool requestMappable =
(GetAllowedUsage() & (nxt::BufferUsageBit::MapRead | nxt::BufferUsageBit::MapWrite)) !=
0;
bool requestMappable = (GetAllowedUsage() & (dawn::BufferUsageBit::MapRead |
dawn::BufferUsageBit::MapWrite)) != 0;
if (!device->GetMemoryAllocator()->Allocate(requirements, requestMappable,
&mMemoryAllocation)) {
ASSERT(false);
@ -162,7 +161,7 @@ namespace backend { namespace vulkan {
return mHandle;
}
void Buffer::TransitionUsageNow(VkCommandBuffer commands, nxt::BufferUsageBit usage) {
void Buffer::TransitionUsageNow(VkCommandBuffer commands, dawn::BufferUsageBit usage) {
bool lastIncludesTarget = (mLastUsage & usage) == usage;
bool lastReadOnly = (mLastUsage & kReadOnlyBufferUsages) == mLastUsage;
@ -172,7 +171,7 @@ namespace backend { namespace vulkan {
}
// Special-case for the initial transition: Vulkan doesn't allow access flags to be 0.
if (mLastUsage == nxt::BufferUsageBit::None) {
if (mLastUsage == dawn::BufferUsageBit::None) {
mLastUsage = usage;
return;
}
@ -202,7 +201,7 @@ namespace backend { namespace vulkan {
Device* device = ToBackend(GetDevice());
VkCommandBuffer commands = device->GetPendingCommandBuffer();
TransitionUsageNow(commands, nxt::BufferUsageBit::TransferDst);
TransitionUsageNow(commands, dawn::BufferUsageBit::TransferDst);
BufferUploader* uploader = device->GetBufferUploader();
uploader->BufferSubData(mHandle, start, count, data);
@ -212,7 +211,7 @@ namespace backend { namespace vulkan {
Device* device = ToBackend(GetDevice());
VkCommandBuffer commands = device->GetPendingCommandBuffer();
TransitionUsageNow(commands, nxt::BufferUsageBit::MapRead);
TransitionUsageNow(commands, dawn::BufferUsageBit::MapRead);
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
ASSERT(memory != nullptr);
@ -225,7 +224,7 @@ namespace backend { namespace vulkan {
Device* device = ToBackend(GetDevice());
VkCommandBuffer commands = device->GetPendingCommandBuffer();
TransitionUsageNow(commands, nxt::BufferUsageBit::MapWrite);
TransitionUsageNow(commands, dawn::BufferUsageBit::MapWrite);
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
ASSERT(memory != nullptr);

Some files were not shown because too many files have changed in this diff Show More