Make dawn_native use the webgpu.h header

BUG=dawn:22

Change-Id: I66e2d998f5e09030e40ec88813cd65c492018fd0
Reviewed-on: https://dawn-review.googlesource.com/c/dawn/+/12541
Commit-Queue: Corentin Wallez <cwallez@chromium.org>
Reviewed-by: Kai Ninomiya <kainino@chromium.org>
This commit is contained in:
Corentin Wallez 2019-10-23 11:57:41 +00:00 committed by Commit Bot service account
parent c833c0c592
commit 1f6c8c4d54
114 changed files with 1614 additions and 1617 deletions

View File

@ -69,8 +69,8 @@ dawn_json_generator("libdawn_native_utils_gen") {
target = "dawn_native_utils" target = "dawn_native_utils"
outputs = [ outputs = [
"src/dawn_native/ProcTable.cpp", "src/dawn_native/ProcTable.cpp",
"src/dawn_native/dawn_structs_autogen.h", "src/dawn_native/wgpu_structs_autogen.h",
"src/dawn_native/dawn_structs_autogen.cpp", "src/dawn_native/wgpu_structs_autogen.cpp",
"src/dawn_native/ValidationUtils_autogen.h", "src/dawn_native/ValidationUtils_autogen.h",
"src/dawn_native/ValidationUtils_autogen.cpp", "src/dawn_native/ValidationUtils_autogen.cpp",
] ]

View File

@ -448,7 +448,7 @@ def as_frontendType(typ):
if typ.category == 'object': if typ.category == 'object':
return typ.name.CamelCase() + 'Base*' return typ.name.CamelCase() + 'Base*'
elif typ.category in ['bitmask', 'enum']: elif typ.category in ['bitmask', 'enum']:
return 'dawn::' + typ.name.CamelCase() return 'wgpu::' + typ.name.CamelCase()
elif typ.category == 'structure': elif typ.category == 'structure':
return as_cppType(typ.name) return as_cppType(typ.name)
else: else:
@ -559,8 +559,8 @@ class MultiGeneratorFromDawnJSON(Generator):
renders.append(FileRender('dawn_native/ValidationUtils.h', 'src/dawn_native/ValidationUtils_autogen.h', frontend_params)) renders.append(FileRender('dawn_native/ValidationUtils.h', 'src/dawn_native/ValidationUtils_autogen.h', frontend_params))
renders.append(FileRender('dawn_native/ValidationUtils.cpp', 'src/dawn_native/ValidationUtils_autogen.cpp', frontend_params)) renders.append(FileRender('dawn_native/ValidationUtils.cpp', 'src/dawn_native/ValidationUtils_autogen.cpp', frontend_params))
renders.append(FileRender('dawn_native/api_structs.h', 'src/dawn_native/dawn_structs_autogen.h', frontend_params)) renders.append(FileRender('dawn_native/wgpu_structs.h', 'src/dawn_native/wgpu_structs_autogen.h', frontend_params))
renders.append(FileRender('dawn_native/api_structs.cpp', 'src/dawn_native/dawn_structs_autogen.cpp', frontend_params)) renders.append(FileRender('dawn_native/wgpu_structs.cpp', 'src/dawn_native/wgpu_structs_autogen.cpp', frontend_params))
renders.append(FileRender('dawn_native/ProcTable.cpp', 'src/dawn_native/ProcTable.cpp', frontend_params)) renders.append(FileRender('dawn_native/ProcTable.cpp', 'src/dawn_native/ProcTable.cpp', frontend_params))
if 'dawn_wire' in targets: if 'dawn_wire' in targets:

View File

@ -17,10 +17,10 @@
namespace dawn_native { namespace dawn_native {
{% for type in by_category["enum"] %} {% for type in by_category["enum"] %}
MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) { MaybeError Validate{{type.name.CamelCase()}}(wgpu::{{as_cppType(type.name)}} value) {
switch (value) { switch (value) {
{% for value in type.values if value.valid %} {% for value in type.values if value.valid %}
case dawn::{{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}: case wgpu::{{as_cppType(type.name)}}::{{as_cppEnum(value.name)}}:
return {}; return {};
{% endfor %} {% endfor %}
default: default:
@ -31,8 +31,8 @@ namespace dawn_native {
{% endfor %} {% endfor %}
{% for type in by_category["bitmask"] %} {% for type in by_category["bitmask"] %}
MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) { MaybeError Validate{{type.name.CamelCase()}}(wgpu::{{as_cppType(type.name)}} value) {
if ((value & static_cast<dawn::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) { if ((value & static_cast<wgpu::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
return {}; return {};
} }
return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}"); return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");

View File

@ -15,7 +15,7 @@
#ifndef BACKEND_VALIDATIONUTILS_H_ #ifndef BACKEND_VALIDATIONUTILS_H_
#define BACKEND_VALIDATIONUTILS_H_ #define BACKEND_VALIDATIONUTILS_H_
#include "dawn/dawncpp.h" #include "dawn/webgpu_cpp.h"
#include "dawn_native/Error.h" #include "dawn_native/Error.h"
@ -23,7 +23,7 @@ namespace dawn_native {
// Helper functions to check the value of enums and bitmasks // Helper functions to check the value of enums and bitmasks
{% for type in by_category["enum"] + by_category["bitmask"] %} {% for type in by_category["enum"] + by_category["bitmask"] %}
MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value); MaybeError Validate{{type.name.CamelCase()}}(wgpu::{{as_cppType(type.name)}} value);
{% endfor %} {% endfor %}
} // namespace dawn_native } // namespace dawn_native

View File

@ -12,7 +12,7 @@
//* See the License for the specific language governing permissions and //* See the License for the specific language governing permissions and
//* limitations under the License. //* limitations under the License.
#include "dawn_native/dawn_structs_autogen.h" #include "dawn_native/wgpu_structs_autogen.h"
namespace dawn_native { namespace dawn_native {

View File

@ -12,10 +12,10 @@
//* See the License for the specific language governing permissions and //* See the License for the specific language governing permissions and
//* limitations under the License. //* limitations under the License.
#ifndef DAWNNATIVE_DAWN_STRUCTS_H_ #ifndef DAWNNATIVE_WGPU_STRUCTS_H_
#define DAWNNATIVE_DAWN_STRUCTS_H_ #define DAWNNATIVE_WGPU_STRUCTS_H_
#include "dawn/dawncpp.h" #include "dawn/webgpu_cpp.h"
#include "dawn_native/Forward.h" #include "dawn_native/Forward.h"
namespace dawn_native { namespace dawn_native {
@ -24,7 +24,7 @@ namespace dawn_native {
{%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%} {%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%}
{{" "}}= nullptr {{" "}}= nullptr
{%- elif member.type.category in ["enum", "bitmask"] and member.default_value != None -%} {%- elif member.type.category in ["enum", "bitmask"] and member.default_value != None -%}
{{" "}}= dawn::{{as_cppType(member.type.name)}}::{{as_cppEnum(Name(member.default_value))}} {{" "}}= wgpu::{{as_cppType(member.type.name)}}::{{as_cppEnum(Name(member.default_value))}}
{%- elif member.type.category == "native" and member.default_value != None -%} {%- elif member.type.category == "native" and member.default_value != None -%}
{{" "}}= {{member.default_value}} {{" "}}= {{member.default_value}}
{%- else -%} {%- else -%}
@ -46,4 +46,4 @@ namespace dawn_native {
} // namespace dawn_native } // namespace dawn_native
#endif // DAWNNATIVE_DAWN_STRUCTS_H_ #endif // DAWNNATIVE_WGPU_STRUCTS_H_

View File

@ -127,16 +127,16 @@ namespace dawn_native {
return mColorAttachmentsSet; return mColorAttachmentsSet;
} }
dawn::TextureFormat AttachmentState::GetColorAttachmentFormat(uint32_t index) const { wgpu::TextureFormat AttachmentState::GetColorAttachmentFormat(uint32_t index) const {
ASSERT(mColorAttachmentsSet[index]); ASSERT(mColorAttachmentsSet[index]);
return mColorFormats[index]; return mColorFormats[index];
} }
bool AttachmentState::HasDepthStencilAttachment() const { bool AttachmentState::HasDepthStencilAttachment() const {
return mDepthStencilFormat != dawn::TextureFormat::Undefined; return mDepthStencilFormat != wgpu::TextureFormat::Undefined;
} }
dawn::TextureFormat AttachmentState::GetDepthStencilFormat() const { wgpu::TextureFormat AttachmentState::GetDepthStencilFormat() const {
ASSERT(HasDepthStencilAttachment()); ASSERT(HasDepthStencilAttachment());
return mDepthStencilFormat; return mDepthStencilFormat;
} }

View File

@ -50,9 +50,9 @@ namespace dawn_native {
protected: protected:
std::bitset<kMaxColorAttachments> mColorAttachmentsSet; std::bitset<kMaxColorAttachments> mColorAttachmentsSet;
std::array<dawn::TextureFormat, kMaxColorAttachments> mColorFormats; std::array<wgpu::TextureFormat, kMaxColorAttachments> mColorFormats;
// Default (texture format Undefined) indicates there is no depth stencil attachment. // Default (texture format Undefined) indicates there is no depth stencil attachment.
dawn::TextureFormat mDepthStencilFormat = dawn::TextureFormat::Undefined; wgpu::TextureFormat mDepthStencilFormat = wgpu::TextureFormat::Undefined;
uint32_t mSampleCount = 0; uint32_t mSampleCount = 0;
}; };
@ -62,9 +62,9 @@ namespace dawn_native {
~AttachmentState() override; ~AttachmentState() override;
std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const; std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const;
dawn::TextureFormat GetColorAttachmentFormat(uint32_t index) const; wgpu::TextureFormat GetColorAttachmentFormat(uint32_t index) const;
bool HasDepthStencilAttachment() const; bool HasDepthStencilAttachment() const;
dawn::TextureFormat GetDepthStencilFormat() const; wgpu::TextureFormat GetDepthStencilFormat() const;
uint32_t GetSampleCount() const; uint32_t GetSampleCount() const;
private: private:

View File

@ -30,7 +30,7 @@ namespace dawn_native {
MaybeError ValidateBufferBinding(const DeviceBase* device, MaybeError ValidateBufferBinding(const DeviceBase* device,
const BindGroupBinding& binding, const BindGroupBinding& binding,
dawn::BufferUsage requiredUsage) { wgpu::BufferUsage requiredUsage) {
if (binding.buffer == nullptr || binding.sampler != nullptr || if (binding.buffer == nullptr || binding.sampler != nullptr ||
binding.textureView != nullptr) { binding.textureView != nullptr) {
return DAWN_VALIDATION_ERROR("expected buffer binding"); return DAWN_VALIDATION_ERROR("expected buffer binding");
@ -38,7 +38,7 @@ namespace dawn_native {
DAWN_TRY(device->ValidateObject(binding.buffer)); DAWN_TRY(device->ValidateObject(binding.buffer));
uint64_t bufferSize = binding.buffer->GetSize(); uint64_t bufferSize = binding.buffer->GetSize();
uint64_t bindingSize = (binding.size == dawn::kWholeSize) ? bufferSize : binding.size; uint64_t bindingSize = (binding.size == wgpu::kWholeSize) ? bufferSize : binding.size;
if (bindingSize > bufferSize) { if (bindingSize > bufferSize) {
return DAWN_VALIDATION_ERROR("Buffer binding size larger than the buffer"); return DAWN_VALIDATION_ERROR("Buffer binding size larger than the buffer");
} }
@ -63,10 +63,10 @@ namespace dawn_native {
MaybeError ValidateTextureBinding(const DeviceBase* device, MaybeError ValidateTextureBinding(const DeviceBase* device,
const BindGroupBinding& binding, const BindGroupBinding& binding,
dawn::TextureUsage requiredUsage, wgpu::TextureUsage requiredUsage,
bool multisampledBinding, bool multisampledBinding,
dawn::TextureComponentType requiredComponentType, wgpu::TextureComponentType requiredComponentType,
dawn::TextureViewDimension requiredDimension) { wgpu::TextureViewDimension requiredDimension) {
if (binding.textureView == nullptr || binding.sampler != nullptr || if (binding.textureView == nullptr || binding.sampler != nullptr ||
binding.buffer != nullptr) { binding.buffer != nullptr) {
return DAWN_VALIDATION_ERROR("expected texture binding"); return DAWN_VALIDATION_ERROR("expected texture binding");
@ -143,23 +143,23 @@ namespace dawn_native {
// Perform binding-type specific validation. // Perform binding-type specific validation.
switch (layoutInfo.types[bindingIndex]) { switch (layoutInfo.types[bindingIndex]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsage::Uniform)); DAWN_TRY(ValidateBufferBinding(device, binding, wgpu::BufferUsage::Uniform));
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsage::Storage)); DAWN_TRY(ValidateBufferBinding(device, binding, wgpu::BufferUsage::Storage));
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
DAWN_TRY(ValidateTextureBinding(device, binding, dawn::TextureUsage::Sampled, DAWN_TRY(ValidateTextureBinding(device, binding, wgpu::TextureUsage::Sampled,
layoutInfo.multisampled[bindingIndex], layoutInfo.multisampled[bindingIndex],
layoutInfo.textureComponentTypes[bindingIndex], layoutInfo.textureComponentTypes[bindingIndex],
layoutInfo.textureDimensions[bindingIndex])); layoutInfo.textureDimensions[bindingIndex]));
break; break;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
DAWN_TRY(ValidateSamplerBinding(device, binding)); DAWN_TRY(ValidateSamplerBinding(device, binding));
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
} }
@ -193,7 +193,7 @@ namespace dawn_native {
mBindings[bindingIndex] = binding.buffer; mBindings[bindingIndex] = binding.buffer;
mOffsets[bindingIndex] = binding.offset; mOffsets[bindingIndex] = binding.offset;
uint64_t bufferSize = uint64_t bufferSize =
(binding.size == dawn::kWholeSize) ? binding.buffer->GetSize() : binding.size; (binding.size == wgpu::kWholeSize) ? binding.buffer->GetSize() : binding.size;
mSizes[bindingIndex] = bufferSize; mSizes[bindingIndex] = bufferSize;
continue; continue;
} }
@ -230,8 +230,8 @@ namespace dawn_native {
ASSERT(!IsError()); ASSERT(!IsError());
ASSERT(binding < kMaxBindingsPerGroup); ASSERT(binding < kMaxBindingsPerGroup);
ASSERT(mLayout->GetBindingInfo().mask[binding]); ASSERT(mLayout->GetBindingInfo().mask[binding]);
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer || ASSERT(mLayout->GetBindingInfo().types[binding] == wgpu::BindingType::UniformBuffer ||
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer); mLayout->GetBindingInfo().types[binding] == wgpu::BindingType::StorageBuffer);
BufferBase* buffer = static_cast<BufferBase*>(mBindings[binding].Get()); BufferBase* buffer = static_cast<BufferBase*>(mBindings[binding].Get());
return {buffer, mOffsets[binding], mSizes[binding]}; return {buffer, mOffsets[binding], mSizes[binding]};
} }
@ -240,7 +240,7 @@ namespace dawn_native {
ASSERT(!IsError()); ASSERT(!IsError());
ASSERT(binding < kMaxBindingsPerGroup); ASSERT(binding < kMaxBindingsPerGroup);
ASSERT(mLayout->GetBindingInfo().mask[binding]); ASSERT(mLayout->GetBindingInfo().mask[binding]);
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::Sampler); ASSERT(mLayout->GetBindingInfo().types[binding] == wgpu::BindingType::Sampler);
return static_cast<SamplerBase*>(mBindings[binding].Get()); return static_cast<SamplerBase*>(mBindings[binding].Get());
} }
@ -248,7 +248,7 @@ namespace dawn_native {
ASSERT(!IsError()); ASSERT(!IsError());
ASSERT(binding < kMaxBindingsPerGroup); ASSERT(binding < kMaxBindingsPerGroup);
ASSERT(mLayout->GetBindingInfo().mask[binding]); ASSERT(mLayout->GetBindingInfo().mask[binding]);
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::SampledTexture); ASSERT(mLayout->GetBindingInfo().types[binding] == wgpu::BindingType::SampledTexture);
return static_cast<TextureViewBase*>(mBindings[binding].Get()); return static_cast<TextureViewBase*>(mBindings[binding].Get());
} }

View File

@ -42,26 +42,26 @@ namespace dawn_native {
const auto& info = layout->GetBindingInfo(); const auto& info = layout->GetBindingInfo();
for (uint32_t binding : IterateBitSet(info.mask)) { for (uint32_t binding : IterateBitSet(info.mask)) {
if ((info.visibilities[binding] & dawn::ShaderStage::Compute) == 0) { if ((info.visibilities[binding] & wgpu::ShaderStage::Compute) == 0) {
continue; continue;
} }
mBindingTypes[index][binding] = info.types[binding]; mBindingTypes[index][binding] = info.types[binding];
switch (info.types[binding]) { switch (info.types[binding]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
// Don't require barriers. // Don't require barriers.
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
mBuffersNeedingBarrier[index].set(binding); mBuffersNeedingBarrier[index].set(binding);
mBuffers[index][binding] = mBuffers[index][binding] =
bindGroup->GetBindingAsBufferBinding(binding).buffer; bindGroup->GetBindingAsBufferBinding(binding).buffer;
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
// Not implemented. // Not implemented.
default: default:
@ -76,7 +76,7 @@ namespace dawn_native {
protected: protected:
std::array<std::bitset<kMaxBindingsPerGroup>, kMaxBindGroups> mBuffersNeedingBarrier = {}; std::array<std::bitset<kMaxBindingsPerGroup>, kMaxBindGroups> mBuffersNeedingBarrier = {};
std::array<std::array<dawn::BindingType, kMaxBindingsPerGroup>, kMaxBindGroups> std::array<std::array<wgpu::BindingType, kMaxBindingsPerGroup>, kMaxBindGroups>
mBindingTypes = {}; mBindingTypes = {};
std::array<std::array<BufferBase*, kMaxBindingsPerGroup>, kMaxBindGroups> mBuffers = {}; std::array<std::array<BufferBase*, kMaxBindingsPerGroup>, kMaxBindGroups> mBuffers = {};
}; };

View File

@ -38,7 +38,7 @@ namespace dawn_native {
DAWN_TRY(ValidateBindingType(binding.type)); DAWN_TRY(ValidateBindingType(binding.type));
DAWN_TRY(ValidateTextureComponentType(binding.textureComponentType)); DAWN_TRY(ValidateTextureComponentType(binding.textureComponentType));
if (binding.textureDimension != dawn::TextureViewDimension::Undefined) { if (binding.textureDimension != wgpu::TextureViewDimension::Undefined) {
DAWN_TRY(ValidateTextureViewDimension(binding.textureDimension)); DAWN_TRY(ValidateTextureViewDimension(binding.textureDimension));
} }
@ -50,25 +50,25 @@ namespace dawn_native {
} }
switch (binding.type) { switch (binding.type) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
if (binding.hasDynamicOffset) { if (binding.hasDynamicOffset) {
++dynamicUniformBufferCount; ++dynamicUniformBufferCount;
} }
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
if (binding.hasDynamicOffset) { if (binding.hasDynamicOffset) {
++dynamicStorageBufferCount; ++dynamicStorageBufferCount;
} }
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
if (binding.hasDynamicOffset) { if (binding.hasDynamicOffset) {
return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic"); return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic");
} }
break; break;
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
return DAWN_VALIDATION_ERROR("readonly storage buffers aren't supported (yet)"); return DAWN_VALIDATION_ERROR("readonly storage buffers aren't supported (yet)");
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)"); return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)");
} }
@ -140,24 +140,24 @@ namespace dawn_native {
mBindingInfo.types[index] = binding.type; mBindingInfo.types[index] = binding.type;
mBindingInfo.textureComponentTypes[index] = binding.textureComponentType; mBindingInfo.textureComponentTypes[index] = binding.textureComponentType;
if (binding.textureDimension == dawn::TextureViewDimension::Undefined) { if (binding.textureDimension == wgpu::TextureViewDimension::Undefined) {
mBindingInfo.textureDimensions[index] = dawn::TextureViewDimension::e2D; mBindingInfo.textureDimensions[index] = wgpu::TextureViewDimension::e2D;
} else { } else {
mBindingInfo.textureDimensions[index] = binding.textureDimension; mBindingInfo.textureDimensions[index] = binding.textureDimension;
} }
if (binding.hasDynamicOffset) { if (binding.hasDynamicOffset) {
mBindingInfo.hasDynamicOffset.set(index); mBindingInfo.hasDynamicOffset.set(index);
switch (binding.type) { switch (binding.type) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
++mDynamicUniformBufferCount; ++mDynamicUniformBufferCount;
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
++mDynamicStorageBufferCount; ++mDynamicStorageBufferCount;
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
UNREACHABLE(); UNREACHABLE();
break; break;
} }

View File

@ -40,10 +40,10 @@ namespace dawn_native {
static BindGroupLayoutBase* MakeError(DeviceBase* device); static BindGroupLayoutBase* MakeError(DeviceBase* device);
struct LayoutBindingInfo { struct LayoutBindingInfo {
std::array<dawn::ShaderStage, kMaxBindingsPerGroup> visibilities; std::array<wgpu::ShaderStage, kMaxBindingsPerGroup> visibilities;
std::array<dawn::BindingType, kMaxBindingsPerGroup> types; std::array<wgpu::BindingType, kMaxBindingsPerGroup> types;
std::array<dawn::TextureComponentType, kMaxBindingsPerGroup> textureComponentTypes; std::array<wgpu::TextureComponentType, kMaxBindingsPerGroup> textureComponentTypes;
std::array<dawn::TextureViewDimension, kMaxBindingsPerGroup> textureDimensions; std::array<wgpu::TextureViewDimension, kMaxBindingsPerGroup> textureDimensions;
std::bitset<kMaxBindingsPerGroup> hasDynamicOffset; std::bitset<kMaxBindingsPerGroup> hasDynamicOffset;
std::bitset<kMaxBindingsPerGroup> multisampled; std::bitset<kMaxBindingsPerGroup> multisampled;
std::bitset<kMaxBindingsPerGroup> mask; std::bitset<kMaxBindingsPerGroup> mask;

View File

@ -91,17 +91,17 @@ namespace dawn_native {
DAWN_TRY(ValidateBufferUsage(descriptor->usage)); DAWN_TRY(ValidateBufferUsage(descriptor->usage));
dawn::BufferUsage usage = descriptor->usage; wgpu::BufferUsage usage = descriptor->usage;
const dawn::BufferUsage kMapWriteAllowedUsages = const wgpu::BufferUsage kMapWriteAllowedUsages =
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc; wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
if (usage & dawn::BufferUsage::MapWrite && (usage & kMapWriteAllowedUsages) != usage) { if (usage & wgpu::BufferUsage::MapWrite && (usage & kMapWriteAllowedUsages) != usage) {
return DAWN_VALIDATION_ERROR("Only CopySrc is allowed with MapWrite"); return DAWN_VALIDATION_ERROR("Only CopySrc is allowed with MapWrite");
} }
const dawn::BufferUsage kMapReadAllowedUsages = const wgpu::BufferUsage kMapReadAllowedUsages =
dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst; wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst;
if (usage & dawn::BufferUsage::MapRead && (usage & kMapReadAllowedUsages) != usage) { if (usage & wgpu::BufferUsage::MapRead && (usage & kMapReadAllowedUsages) != usage) {
return DAWN_VALIDATION_ERROR("Only CopyDst is allowed with MapRead"); return DAWN_VALIDATION_ERROR("Only CopyDst is allowed with MapRead");
} }
@ -146,7 +146,7 @@ namespace dawn_native {
return mSize; return mSize;
} }
dawn::BufferUsage BufferBase::GetUsage() const { wgpu::BufferUsage BufferBase::GetUsage() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mUsage; return mUsage;
} }
@ -189,7 +189,7 @@ namespace dawn_native {
} }
void BufferBase::CallMapReadCallback(uint32_t serial, void BufferBase::CallMapReadCallback(uint32_t serial,
DawnBufferMapAsyncStatus status, WGPUBufferMapAsyncStatus status,
const void* pointer, const void* pointer,
uint32_t dataLength) { uint32_t dataLength) {
ASSERT(!IsError()); ASSERT(!IsError());
@ -197,14 +197,14 @@ namespace dawn_native {
ASSERT(mMapWriteCallback == nullptr); ASSERT(mMapWriteCallback == nullptr);
// Tag the callback as fired before firing it, otherwise it could fire a second time if // Tag the callback as fired before firing it, otherwise it could fire a second time if
// for example buffer.Unmap() is called inside the application-provided callback. // for example buffer.Unmap() is called inside the application-provided callback.
DawnBufferMapReadCallback callback = mMapReadCallback; WGPUBufferMapReadCallback callback = mMapReadCallback;
mMapReadCallback = nullptr; mMapReadCallback = nullptr;
callback(status, pointer, dataLength, mMapUserdata); callback(status, pointer, dataLength, mMapUserdata);
} }
} }
void BufferBase::CallMapWriteCallback(uint32_t serial, void BufferBase::CallMapWriteCallback(uint32_t serial,
DawnBufferMapAsyncStatus status, WGPUBufferMapAsyncStatus status,
void* pointer, void* pointer,
uint32_t dataLength) { uint32_t dataLength) {
ASSERT(!IsError()); ASSERT(!IsError());
@ -212,7 +212,7 @@ namespace dawn_native {
ASSERT(mMapReadCallback == nullptr); ASSERT(mMapReadCallback == nullptr);
// Tag the callback as fired before firing it, otherwise it could fire a second time if // Tag the callback as fired before firing it, otherwise it could fire a second time if
// for example buffer.Unmap() is called inside the application-provided callback. // for example buffer.Unmap() is called inside the application-provided callback.
DawnBufferMapWriteCallback callback = mMapWriteCallback; WGPUBufferMapWriteCallback callback = mMapWriteCallback;
mMapWriteCallback = nullptr; mMapWriteCallback = nullptr;
callback(status, pointer, dataLength, mMapUserdata); callback(status, pointer, dataLength, mMapUserdata);
} }
@ -229,8 +229,8 @@ namespace dawn_native {
} }
} }
void BufferBase::MapReadAsync(DawnBufferMapReadCallback callback, void* userdata) { void BufferBase::MapReadAsync(WGPUBufferMapReadCallback callback, void* userdata) {
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsage::MapRead))) { if (GetDevice()->ConsumedError(ValidateMap(wgpu::BufferUsage::MapRead))) {
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata); callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
return; return;
} }
@ -265,8 +265,8 @@ namespace dawn_native {
return {}; return {};
} }
void BufferBase::MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata) { void BufferBase::MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata) {
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsage::MapWrite))) { if (GetDevice()->ConsumedError(ValidateMap(wgpu::BufferUsage::MapWrite))) {
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata); callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
return; return;
} }
@ -374,14 +374,14 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Buffer subdata out of range"); return DAWN_VALIDATION_ERROR("Buffer subdata out of range");
} }
if (!(mUsage & dawn::BufferUsage::CopyDst)) { if (!(mUsage & wgpu::BufferUsage::CopyDst)) {
return DAWN_VALIDATION_ERROR("Buffer needs the CopyDst usage bit"); return DAWN_VALIDATION_ERROR("Buffer needs the CopyDst usage bit");
} }
return {}; return {};
} }
MaybeError BufferBase::ValidateMap(dawn::BufferUsage requiredUsage) const { MaybeError BufferBase::ValidateMap(wgpu::BufferUsage requiredUsage) const {
DAWN_TRY(GetDevice()->ValidateObject(this)); DAWN_TRY(GetDevice()->ValidateObject(this));
switch (mState) { switch (mState) {
@ -409,7 +409,7 @@ namespace dawn_native {
// even if it did not have a mappable usage. // even if it did not have a mappable usage.
return {}; return {};
case BufferState::Unmapped: case BufferState::Unmapped:
if ((mUsage & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) == 0) { if ((mUsage & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) == 0) {
return DAWN_VALIDATION_ERROR("Buffer does not have map usage"); return DAWN_VALIDATION_ERROR("Buffer does not have map usage");
} }
return {}; return {};

View File

@ -27,12 +27,12 @@ namespace dawn_native {
MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor); MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor);
static constexpr dawn::BufferUsage kReadOnlyBufferUsages = static constexpr wgpu::BufferUsage kReadOnlyBufferUsages =
dawn::BufferUsage::MapRead | dawn::BufferUsage::CopySrc | dawn::BufferUsage::Index | wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Index |
dawn::BufferUsage::Vertex | dawn::BufferUsage::Uniform; wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Uniform;
static constexpr dawn::BufferUsage kWritableBufferUsages = static constexpr wgpu::BufferUsage kWritableBufferUsages =
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopyDst | dawn::BufferUsage::Storage; wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Storage;
class BufferBase : public ObjectBase { class BufferBase : public ObjectBase {
enum class BufferState { enum class BufferState {
@ -51,7 +51,7 @@ namespace dawn_native {
uint8_t** mappedPointer); uint8_t** mappedPointer);
uint64_t GetSize() const; uint64_t GetSize() const;
dawn::BufferUsage GetUsage() const; wgpu::BufferUsage GetUsage() const;
MaybeError MapAtCreation(uint8_t** mappedPointer); MaybeError MapAtCreation(uint8_t** mappedPointer);
@ -59,8 +59,8 @@ namespace dawn_native {
// Dawn API // Dawn API
void SetSubData(uint32_t start, uint32_t count, const void* data); void SetSubData(uint32_t start, uint32_t count, const void* data);
void MapReadAsync(DawnBufferMapReadCallback callback, void* userdata); void MapReadAsync(WGPUBufferMapReadCallback callback, void* userdata);
void MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata); void MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata);
void Unmap(); void Unmap();
void Destroy(); void Destroy();
@ -68,11 +68,11 @@ namespace dawn_native {
BufferBase(DeviceBase* device, ObjectBase::ErrorTag tag); BufferBase(DeviceBase* device, ObjectBase::ErrorTag tag);
void CallMapReadCallback(uint32_t serial, void CallMapReadCallback(uint32_t serial,
DawnBufferMapAsyncStatus status, WGPUBufferMapAsyncStatus status,
const void* pointer, const void* pointer,
uint32_t dataLength); uint32_t dataLength);
void CallMapWriteCallback(uint32_t serial, void CallMapWriteCallback(uint32_t serial,
DawnBufferMapAsyncStatus status, WGPUBufferMapAsyncStatus status,
void* pointer, void* pointer,
uint32_t dataLength); uint32_t dataLength);
@ -90,15 +90,15 @@ namespace dawn_native {
MaybeError CopyFromStagingBuffer(); MaybeError CopyFromStagingBuffer();
MaybeError ValidateSetSubData(uint32_t start, uint32_t count) const; MaybeError ValidateSetSubData(uint32_t start, uint32_t count) const;
MaybeError ValidateMap(dawn::BufferUsage requiredUsage) const; MaybeError ValidateMap(wgpu::BufferUsage requiredUsage) const;
MaybeError ValidateUnmap() const; MaybeError ValidateUnmap() const;
MaybeError ValidateDestroy() const; MaybeError ValidateDestroy() const;
uint64_t mSize = 0; uint64_t mSize = 0;
dawn::BufferUsage mUsage = dawn::BufferUsage::None; wgpu::BufferUsage mUsage = wgpu::BufferUsage::None;
DawnBufferMapReadCallback mMapReadCallback = nullptr; WGPUBufferMapReadCallback mMapReadCallback = nullptr;
DawnBufferMapWriteCallback mMapWriteCallback = nullptr; WGPUBufferMapWriteCallback mMapWriteCallback = nullptr;
void* mMapUserdata = 0; void* mMapUserdata = 0;
uint32_t mMapSerial = 0; uint32_t mMapSerial = 0;

View File

@ -242,8 +242,8 @@ namespace dawn_native {
return {}; return {};
} }
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsage usage) { MaybeError ValidateCanUseAs(BufferBase* buffer, wgpu::BufferUsage usage) {
ASSERT(dawn::HasZeroOrOneBits(usage)); ASSERT(wgpu::HasZeroOrOneBits(usage));
if (!(buffer->GetUsage() & usage)) { if (!(buffer->GetUsage() & usage)) {
return DAWN_VALIDATION_ERROR("buffer doesn't have the required usage."); return DAWN_VALIDATION_ERROR("buffer doesn't have the required usage.");
} }
@ -251,8 +251,8 @@ namespace dawn_native {
return {}; return {};
} }
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsage usage) { MaybeError ValidateCanUseAs(TextureBase* texture, wgpu::TextureUsage usage) {
ASSERT(dawn::HasZeroOrOneBits(usage)); ASSERT(wgpu::HasZeroOrOneBits(usage));
if (!(texture->GetUsage() & usage)) { if (!(texture->GetUsage() & usage)) {
return DAWN_VALIDATION_ERROR("texture doesn't have the required usage."); return DAWN_VALIDATION_ERROR("texture doesn't have the required usage.");
} }
@ -352,7 +352,7 @@ namespace dawn_native {
"The size of the resolve target must be the same as the color attachment"); "The size of the resolve target must be the same as the color attachment");
} }
dawn::TextureFormat resolveTargetFormat = resolveTarget->GetFormat().format; wgpu::TextureFormat resolveTargetFormat = resolveTarget->GetFormat().format;
if (resolveTargetFormat != attachment->GetFormat().format) { if (resolveTargetFormat != attachment->GetFormat().format) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"The format of the resolve target must be the same as the color attachment"); "The format of the resolve target must be the same as the color attachment");
@ -755,8 +755,8 @@ namespace dawn_native {
DAWN_TRY(ValidateB2BCopySizeAlignment(copy->size, copy->sourceOffset, DAWN_TRY(ValidateB2BCopySizeAlignment(copy->size, copy->sourceOffset,
copy->destinationOffset)); copy->destinationOffset));
DAWN_TRY(ValidateCanUseAs(copy->source.Get(), dawn::BufferUsage::CopySrc)); DAWN_TRY(ValidateCanUseAs(copy->source.Get(), wgpu::BufferUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.Get(), dawn::BufferUsage::CopyDst)); DAWN_TRY(ValidateCanUseAs(copy->destination.Get(), wgpu::BufferUsage::CopyDst));
mResourceUsages.topLevelBuffers.insert(copy->source.Get()); mResourceUsages.topLevelBuffers.insert(copy->source.Get());
mResourceUsages.topLevelBuffers.insert(copy->destination.Get()); mResourceUsages.topLevelBuffers.insert(copy->destination.Get());
@ -789,9 +789,9 @@ namespace dawn_native {
copy->destination.texture->GetFormat())); copy->destination.texture->GetFormat()));
DAWN_TRY( DAWN_TRY(
ValidateCanUseAs(copy->source.buffer.Get(), dawn::BufferUsage::CopySrc)); ValidateCanUseAs(copy->source.buffer.Get(), wgpu::BufferUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(), DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
dawn::TextureUsage::CopyDst)); wgpu::TextureUsage::CopyDst));
mResourceUsages.topLevelBuffers.insert(copy->source.buffer.Get()); mResourceUsages.topLevelBuffers.insert(copy->source.buffer.Get());
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get()); mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
@ -824,9 +824,9 @@ namespace dawn_native {
copy->source.texture->GetFormat())); copy->source.texture->GetFormat()));
DAWN_TRY( DAWN_TRY(
ValidateCanUseAs(copy->source.texture.Get(), dawn::TextureUsage::CopySrc)); ValidateCanUseAs(copy->source.texture.Get(), wgpu::TextureUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(), DAWN_TRY(ValidateCanUseAs(copy->destination.buffer.Get(),
dawn::BufferUsage::CopyDst)); wgpu::BufferUsage::CopyDst));
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get()); mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
mResourceUsages.topLevelBuffers.insert(copy->destination.buffer.Get()); mResourceUsages.topLevelBuffers.insert(copy->destination.buffer.Get());
@ -852,9 +852,9 @@ namespace dawn_native {
DAWN_TRY(ValidateCopySizeFitsInTexture(copy->destination, copy->copySize)); DAWN_TRY(ValidateCopySizeFitsInTexture(copy->destination, copy->copySize));
DAWN_TRY( DAWN_TRY(
ValidateCanUseAs(copy->source.texture.Get(), dawn::TextureUsage::CopySrc)); ValidateCanUseAs(copy->source.texture.Get(), wgpu::TextureUsage::CopySrc));
DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(), DAWN_TRY(ValidateCanUseAs(copy->destination.texture.Get(),
dawn::TextureUsage::CopyDst)); wgpu::TextureUsage::CopyDst));
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get()); mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get()); mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());

View File

@ -31,29 +31,29 @@ namespace dawn_native {
const auto& layoutInfo = group->GetLayout()->GetBindingInfo(); const auto& layoutInfo = group->GetLayout()->GetBindingInfo();
for (uint32_t i : IterateBitSet(layoutInfo.mask)) { for (uint32_t i : IterateBitSet(layoutInfo.mask)) {
dawn::BindingType type = layoutInfo.types[i]; wgpu::BindingType type = layoutInfo.types[i];
switch (type) { switch (type) {
case dawn::BindingType::UniformBuffer: { case wgpu::BindingType::UniformBuffer: {
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer; BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
usageTracker->BufferUsedAs(buffer, dawn::BufferUsage::Uniform); usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Uniform);
} break; } break;
case dawn::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer; BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
usageTracker->BufferUsedAs(buffer, dawn::BufferUsage::Storage); usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Storage);
} break; } break;
case dawn::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture(); TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture();
usageTracker->TextureUsedAs(texture, dawn::TextureUsage::Sampled); usageTracker->TextureUsedAs(texture, wgpu::TextureUsage::Sampled);
} break; } break;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
} }
@ -82,14 +82,14 @@ namespace dawn_native {
DrawIndirectCmd* cmd = commands->NextCommand<DrawIndirectCmd>(); DrawIndirectCmd* cmd = commands->NextCommand<DrawIndirectCmd>();
DAWN_TRY(commandBufferState->ValidateCanDraw()); DAWN_TRY(commandBufferState->ValidateCanDraw());
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(), usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
dawn::BufferUsage::Indirect); wgpu::BufferUsage::Indirect);
} break; } break;
case Command::DrawIndexedIndirect: { case Command::DrawIndexedIndirect: {
DrawIndexedIndirectCmd* cmd = commands->NextCommand<DrawIndexedIndirectCmd>(); DrawIndexedIndirectCmd* cmd = commands->NextCommand<DrawIndexedIndirectCmd>();
DAWN_TRY(commandBufferState->ValidateCanDrawIndexed()); DAWN_TRY(commandBufferState->ValidateCanDrawIndexed());
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(), usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
dawn::BufferUsage::Indirect); wgpu::BufferUsage::Indirect);
} break; } break;
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {
@ -132,14 +132,14 @@ namespace dawn_native {
case Command::SetIndexBuffer: { case Command::SetIndexBuffer: {
SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>(); SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>();
usageTracker->BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsage::Index); usageTracker->BufferUsedAs(cmd->buffer.Get(), wgpu::BufferUsage::Index);
commandBufferState->SetIndexBuffer(); commandBufferState->SetIndexBuffer();
} break; } break;
case Command::SetVertexBuffer: { case Command::SetVertexBuffer: {
SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>(); SetVertexBufferCmd* cmd = commands->NextCommand<SetVertexBufferCmd>();
usageTracker->BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsage::Vertex); usageTracker->BufferUsedAs(cmd->buffer.Get(), wgpu::BufferUsage::Vertex);
commandBufferState->SetVertexBuffer(cmd->slot); commandBufferState->SetVertexBuffer(cmd->slot);
} break; } break;
@ -199,18 +199,18 @@ namespace dawn_native {
for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) { for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
RenderPassColorAttachmentInfo* colorAttachment = &renderPass->colorAttachments[i]; RenderPassColorAttachmentInfo* colorAttachment = &renderPass->colorAttachments[i];
TextureBase* texture = colorAttachment->view->GetTexture(); TextureBase* texture = colorAttachment->view->GetTexture();
usageTracker.TextureUsedAs(texture, dawn::TextureUsage::OutputAttachment); usageTracker.TextureUsedAs(texture, wgpu::TextureUsage::OutputAttachment);
TextureViewBase* resolveTarget = colorAttachment->resolveTarget.Get(); TextureViewBase* resolveTarget = colorAttachment->resolveTarget.Get();
if (resolveTarget != nullptr) { if (resolveTarget != nullptr) {
usageTracker.TextureUsedAs(resolveTarget->GetTexture(), usageTracker.TextureUsedAs(resolveTarget->GetTexture(),
dawn::TextureUsage::OutputAttachment); wgpu::TextureUsage::OutputAttachment);
} }
} }
if (renderPass->attachmentState->HasDepthStencilAttachment()) { if (renderPass->attachmentState->HasDepthStencilAttachment()) {
TextureBase* texture = renderPass->depthStencilAttachment.view->GetTexture(); TextureBase* texture = renderPass->depthStencilAttachment.view->GetTexture();
usageTracker.TextureUsedAs(texture, dawn::TextureUsage::OutputAttachment); usageTracker.TextureUsedAs(texture, wgpu::TextureUsage::OutputAttachment);
} }
Command type; Command type;
@ -310,7 +310,7 @@ namespace dawn_native {
DispatchIndirectCmd* cmd = commands->NextCommand<DispatchIndirectCmd>(); DispatchIndirectCmd* cmd = commands->NextCommand<DispatchIndirectCmd>();
DAWN_TRY(commandBufferState.ValidateCanDispatch()); DAWN_TRY(commandBufferState.ValidateCanDispatch());
usageTracker.BufferUsedAs(cmd->indirectBuffer.Get(), usageTracker.BufferUsedAs(cmd->indirectBuffer.Get(),
dawn::BufferUsage::Indirect); wgpu::BufferUsage::Indirect);
} break; } break;
case Command::InsertDebugMarker: { case Command::InsertDebugMarker: {

View File

@ -66,17 +66,17 @@ namespace dawn_native {
struct RenderPassColorAttachmentInfo { struct RenderPassColorAttachmentInfo {
Ref<TextureViewBase> view; Ref<TextureViewBase> view;
Ref<TextureViewBase> resolveTarget; Ref<TextureViewBase> resolveTarget;
dawn::LoadOp loadOp; wgpu::LoadOp loadOp;
dawn::StoreOp storeOp; wgpu::StoreOp storeOp;
dawn_native::Color clearColor; dawn_native::Color clearColor;
}; };
struct RenderPassDepthStencilAttachmentInfo { struct RenderPassDepthStencilAttachmentInfo {
Ref<TextureViewBase> view; Ref<TextureViewBase> view;
dawn::LoadOp depthLoadOp; wgpu::LoadOp depthLoadOp;
dawn::StoreOp depthStoreOp; wgpu::StoreOp depthStoreOp;
dawn::LoadOp stencilLoadOp; wgpu::LoadOp stencilLoadOp;
dawn::StoreOp stencilStoreOp; wgpu::StoreOp stencilStoreOp;
float clearDepth; float clearDepth;
uint32_t clearStencil; uint32_t clearStencil;
}; };

View File

@ -36,7 +36,7 @@ namespace dawn_native {
ComputePipelineBase::ComputePipelineBase(DeviceBase* device, ComputePipelineBase::ComputePipelineBase(DeviceBase* device,
const ComputePipelineDescriptor* descriptor, const ComputePipelineDescriptor* descriptor,
bool blueprint) bool blueprint)
: PipelineBase(device, descriptor->layout, dawn::ShaderStage::Compute), : PipelineBase(device, descriptor->layout, wgpu::ShaderStage::Compute),
mModule(descriptor->computeStage.module), mModule(descriptor->computeStage.module),
mEntryPoint(descriptor->computeStage.entryPoint), mEntryPoint(descriptor->computeStage.entryPoint),
mIsBlueprint(blueprint) { mIsBlueprint(blueprint) {

View File

@ -94,16 +94,16 @@ namespace dawn_native {
ASSERT(mCaches->shaderModules.empty()); ASSERT(mCaches->shaderModules.empty());
} }
void DeviceBase::HandleError(dawn::ErrorType type, const char* message) { void DeviceBase::HandleError(wgpu::ErrorType type, const char* message) {
mCurrentErrorScope->HandleError(type, message); mCurrentErrorScope->HandleError(type, message);
} }
void DeviceBase::InjectError(dawn::ErrorType type, const char* message) { void DeviceBase::InjectError(wgpu::ErrorType type, const char* message) {
if (ConsumedError(ValidateErrorType(type))) { if (ConsumedError(ValidateErrorType(type))) {
return; return;
} }
if (DAWN_UNLIKELY(type == dawn::ErrorType::NoError)) { if (DAWN_UNLIKELY(type == wgpu::ErrorType::NoError)) {
HandleError(dawn::ErrorType::Validation, "Invalid injected error NoError"); HandleError(wgpu::ErrorType::Validation, "Invalid injected error NoError");
return; return;
} }
HandleError(type, message); HandleError(type, message);
@ -115,18 +115,18 @@ namespace dawn_native {
delete error; delete error;
} }
void DeviceBase::SetUncapturedErrorCallback(dawn::ErrorCallback callback, void* userdata) { void DeviceBase::SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata) {
mRootErrorScope->SetCallback(callback, userdata); mRootErrorScope->SetCallback(callback, userdata);
} }
void DeviceBase::PushErrorScope(dawn::ErrorFilter filter) { void DeviceBase::PushErrorScope(wgpu::ErrorFilter filter) {
if (ConsumedError(ValidateErrorFilter(filter))) { if (ConsumedError(ValidateErrorFilter(filter))) {
return; return;
} }
mCurrentErrorScope = AcquireRef(new ErrorScope(filter, mCurrentErrorScope.Get())); mCurrentErrorScope = AcquireRef(new ErrorScope(filter, mCurrentErrorScope.Get()));
} }
bool DeviceBase::PopErrorScope(dawn::ErrorCallback callback, void* userdata) { bool DeviceBase::PopErrorScope(wgpu::ErrorCallback callback, void* userdata) {
if (DAWN_UNLIKELY(mCurrentErrorScope.Get() == mRootErrorScope.Get())) { if (DAWN_UNLIKELY(mCurrentErrorScope.Get() == mRootErrorScope.Get())) {
return false; return false;
} }
@ -168,7 +168,7 @@ namespace dawn_native {
return mFenceSignalTracker.get(); return mFenceSignalTracker.get();
} }
ResultOrError<const Format*> DeviceBase::GetInternalFormat(dawn::TextureFormat format) const { ResultOrError<const Format*> DeviceBase::GetInternalFormat(wgpu::TextureFormat format) const {
size_t index = ComputeFormatIndex(format); size_t index = ComputeFormatIndex(format);
if (index >= mFormatTable.size()) { if (index >= mFormatTable.size()) {
return DAWN_VALIDATION_ERROR("Unknown texture format"); return DAWN_VALIDATION_ERROR("Unknown texture format");
@ -182,7 +182,7 @@ namespace dawn_native {
return internalFormat; return internalFormat;
} }
const Format& DeviceBase::GetValidInternalFormat(dawn::TextureFormat format) const { const Format& DeviceBase::GetValidInternalFormat(wgpu::TextureFormat format) const {
size_t index = ComputeFormatIndex(format); size_t index = ComputeFormatIndex(format);
ASSERT(index < mFormatTable.size()); ASSERT(index < mFormatTable.size());
ASSERT(mFormatTable[index].isSupported); ASSERT(mFormatTable[index].isSupported);
@ -413,7 +413,7 @@ namespace dawn_native {
return result; return result;
} }
void DeviceBase::CreateBufferMappedAsync(const BufferDescriptor* descriptor, void DeviceBase::CreateBufferMappedAsync(const BufferDescriptor* descriptor,
dawn::BufferCreateMappedCallback callback, wgpu::BufferCreateMappedCallback callback,
void* userdata) { void* userdata) {
DawnCreateBufferMappedResult result = CreateBufferMapped(descriptor); DawnCreateBufferMappedResult result = CreateBufferMapped(descriptor);

View File

@ -46,7 +46,7 @@ namespace dawn_native {
DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor); DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor);
virtual ~DeviceBase(); virtual ~DeviceBase();
void HandleError(dawn::ErrorType type, const char* message); void HandleError(wgpu::ErrorType type, const char* message);
bool ConsumedError(MaybeError maybeError) { bool ConsumedError(MaybeError maybeError) {
if (DAWN_UNLIKELY(maybeError.IsError())) { if (DAWN_UNLIKELY(maybeError.IsError())) {
@ -74,15 +74,15 @@ namespace dawn_native {
ErrorScopeTracker* GetErrorScopeTracker() const; ErrorScopeTracker* GetErrorScopeTracker() const;
FenceSignalTracker* GetFenceSignalTracker() const; FenceSignalTracker* GetFenceSignalTracker() const;
// Returns the Format corresponding to the dawn::TextureFormat or an error if the format // Returns the Format corresponding to the wgpu::TextureFormat or an error if the format
// isn't a valid dawn::TextureFormat or isn't supported by this device. // isn't a valid wgpu::TextureFormat or isn't supported by this device.
// The pointer returned has the same lifetime as the device. // The pointer returned has the same lifetime as the device.
ResultOrError<const Format*> GetInternalFormat(dawn::TextureFormat format) const; ResultOrError<const Format*> GetInternalFormat(wgpu::TextureFormat format) const;
// Returns the Format corresponding to the dawn::TextureFormat and assumes the format is // Returns the Format corresponding to the wgpu::TextureFormat and assumes the format is
// valid and supported. // valid and supported.
// The reference returned has the same lifetime as the device. // The reference returned has the same lifetime as the device.
const Format& GetValidInternalFormat(dawn::TextureFormat format) const; const Format& GetValidInternalFormat(wgpu::TextureFormat format) const;
virtual CommandBufferBase* CreateCommandBuffer( virtual CommandBufferBase* CreateCommandBuffer(
CommandEncoderBase* encoder, CommandEncoderBase* encoder,
@ -143,7 +143,7 @@ namespace dawn_native {
BufferBase* CreateBuffer(const BufferDescriptor* descriptor); BufferBase* CreateBuffer(const BufferDescriptor* descriptor);
DawnCreateBufferMappedResult CreateBufferMapped(const BufferDescriptor* descriptor); DawnCreateBufferMappedResult CreateBufferMapped(const BufferDescriptor* descriptor);
void CreateBufferMappedAsync(const BufferDescriptor* descriptor, void CreateBufferMappedAsync(const BufferDescriptor* descriptor,
dawn::BufferCreateMappedCallback callback, wgpu::BufferCreateMappedCallback callback,
void* userdata); void* userdata);
CommandEncoderBase* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor); CommandEncoderBase* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor);
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor); ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
@ -159,13 +159,13 @@ namespace dawn_native {
TextureViewBase* CreateTextureView(TextureBase* texture, TextureViewBase* CreateTextureView(TextureBase* texture,
const TextureViewDescriptor* descriptor); const TextureViewDescriptor* descriptor);
void InjectError(dawn::ErrorType type, const char* message); void InjectError(wgpu::ErrorType type, const char* message);
void Tick(); void Tick();
void SetUncapturedErrorCallback(dawn::ErrorCallback callback, void* userdata); void SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);
void PushErrorScope(dawn::ErrorFilter filter); void PushErrorScope(wgpu::ErrorFilter filter);
bool PopErrorScope(dawn::ErrorCallback callback, void* userdata); bool PopErrorScope(wgpu::ErrorCallback callback, void* userdata);
ErrorScope* GetCurrentErrorScope(); ErrorScope* GetCurrentErrorScope();
void Reference(); void Reference();
@ -261,7 +261,7 @@ namespace dawn_native {
std::unique_ptr<Caches> mCaches; std::unique_ptr<Caches> mCaches;
struct DeferredCreateBufferMappedAsync { struct DeferredCreateBufferMappedAsync {
dawn::BufferCreateMappedCallback callback; wgpu::BufferCreateMappedCallback callback;
DawnBufferMapAsyncStatus status; DawnBufferMapAsyncStatus status;
DawnCreateBufferMappedResult result; DawnCreateBufferMappedResult result;
void* userdata; void* userdata;

View File

@ -45,7 +45,7 @@ namespace dawn_native {
return &mIterator; return &mIterator;
} }
void EncodingContext::HandleError(dawn::ErrorType type, const char* message) { void EncodingContext::HandleError(wgpu::ErrorType type, const char* message) {
if (!IsFinished()) { if (!IsFinished()) {
// If the encoding context is not finished, errors are deferred until // If the encoding context is not finished, errors are deferred until
// Finish() is called. // Finish() is called.

View File

@ -38,7 +38,7 @@ namespace dawn_native {
CommandIterator* GetIterator(); CommandIterator* GetIterator();
// Functions to handle encoder errors // Functions to handle encoder errors
void HandleError(dawn::ErrorType type, const char* message); void HandleError(wgpu::ErrorType type, const char* message);
inline void ConsumeError(ErrorData* error) { inline void ConsumeError(ErrorData* error) {
HandleError(error->GetType(), error->GetMessage().c_str()); HandleError(error->GetType(), error->GetMessage().c_str());
@ -58,10 +58,10 @@ namespace dawn_native {
if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) { if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) {
if (mCurrentEncoder != mTopLevelEncoder) { if (mCurrentEncoder != mTopLevelEncoder) {
// The top level encoder was used when a pass encoder was current. // The top level encoder was used when a pass encoder was current.
HandleError(dawn::ErrorType::Validation, HandleError(wgpu::ErrorType::Validation,
"Command cannot be recorded inside a pass"); "Command cannot be recorded inside a pass");
} else { } else {
HandleError(dawn::ErrorType::Validation, HandleError(wgpu::ErrorType::Validation,
"Recording in an error or already ended pass encoder"); "Recording in an error or already ended pass encoder");
} }
return false; return false;

View File

@ -38,16 +38,16 @@ namespace dawn_native {
return mType; return mType;
} }
dawn::ErrorType ErrorData::GetType() const { wgpu::ErrorType ErrorData::GetType() const {
switch (mType) { switch (mType) {
case InternalErrorType::Validation: case InternalErrorType::Validation:
return dawn::ErrorType::Validation; return wgpu::ErrorType::Validation;
case InternalErrorType::OutOfMemory: case InternalErrorType::OutOfMemory:
return dawn::ErrorType::OutOfMemory; return wgpu::ErrorType::OutOfMemory;
case InternalErrorType::DeviceLost: case InternalErrorType::DeviceLost:
return dawn::ErrorType::DeviceLost; return wgpu::ErrorType::DeviceLost;
default: default:
return dawn::ErrorType::Unknown; return wgpu::ErrorType::Unknown;
} }
} }

View File

@ -44,7 +44,7 @@ namespace dawn_native {
void AppendBacktrace(const char* file, const char* function, int line); void AppendBacktrace(const char* file, const char* function, int line);
InternalErrorType GetInternalType() const; InternalErrorType GetInternalType() const;
dawn::ErrorType GetType() const; wgpu::ErrorType GetType() const;
const std::string& GetMessage() const; const std::string& GetMessage() const;
const std::vector<BacktraceRecord>& GetBacktrace() const; const std::vector<BacktraceRecord>& GetBacktrace() const;

View File

@ -20,7 +20,7 @@ namespace dawn_native {
ErrorScope::ErrorScope() = default; ErrorScope::ErrorScope() = default;
ErrorScope::ErrorScope(dawn::ErrorFilter errorFilter, ErrorScope* parent) ErrorScope::ErrorScope(wgpu::ErrorFilter errorFilter, ErrorScope* parent)
: RefCounted(), mErrorFilter(errorFilter), mParent(parent) { : RefCounted(), mErrorFilter(errorFilter), mParent(parent) {
ASSERT(mParent.Get() != nullptr); ASSERT(mParent.Get() != nullptr);
} }
@ -29,10 +29,10 @@ namespace dawn_native {
if (mCallback == nullptr || IsRoot()) { if (mCallback == nullptr || IsRoot()) {
return; return;
} }
mCallback(static_cast<DawnErrorType>(mErrorType), mErrorMessage.c_str(), mUserdata); mCallback(static_cast<WGPUErrorType>(mErrorType), mErrorMessage.c_str(), mUserdata);
} }
void ErrorScope::SetCallback(dawn::ErrorCallback callback, void* userdata) { void ErrorScope::SetCallback(wgpu::ErrorCallback callback, void* userdata) {
mCallback = callback; mCallback = callback;
mUserdata = userdata; mUserdata = userdata;
} }
@ -45,28 +45,28 @@ namespace dawn_native {
return mParent.Get() == nullptr; return mParent.Get() == nullptr;
} }
void ErrorScope::HandleError(dawn::ErrorType type, const char* message) { void ErrorScope::HandleError(wgpu::ErrorType type, const char* message) {
HandleErrorImpl(this, type, message); HandleErrorImpl(this, type, message);
} }
// static // static
void ErrorScope::HandleErrorImpl(ErrorScope* scope, dawn::ErrorType type, const char* message) { void ErrorScope::HandleErrorImpl(ErrorScope* scope, wgpu::ErrorType type, const char* message) {
ErrorScope* currentScope = scope; ErrorScope* currentScope = scope;
for (; !currentScope->IsRoot(); currentScope = currentScope->GetParent()) { for (; !currentScope->IsRoot(); currentScope = currentScope->GetParent()) {
ASSERT(currentScope != nullptr); ASSERT(currentScope != nullptr);
bool consumed = false; bool consumed = false;
switch (type) { switch (type) {
case dawn::ErrorType::Validation: case wgpu::ErrorType::Validation:
if (currentScope->mErrorFilter != dawn::ErrorFilter::Validation) { if (currentScope->mErrorFilter != wgpu::ErrorFilter::Validation) {
// Error filter does not match. Move on to the next scope. // Error filter does not match. Move on to the next scope.
continue; continue;
} }
consumed = true; consumed = true;
break; break;
case dawn::ErrorType::OutOfMemory: case wgpu::ErrorType::OutOfMemory:
if (currentScope->mErrorFilter != dawn::ErrorFilter::OutOfMemory) { if (currentScope->mErrorFilter != wgpu::ErrorFilter::OutOfMemory) {
// Error filter does not match. Move on to the next scope. // Error filter does not match. Move on to the next scope.
continue; continue;
} }
@ -75,19 +75,19 @@ namespace dawn_native {
// Unknown and DeviceLost are fatal. All error scopes capture them. // Unknown and DeviceLost are fatal. All error scopes capture them.
// |consumed| is false because these should bubble to all scopes. // |consumed| is false because these should bubble to all scopes.
case dawn::ErrorType::Unknown: case wgpu::ErrorType::Unknown:
case dawn::ErrorType::DeviceLost: case wgpu::ErrorType::DeviceLost:
consumed = false; consumed = false;
break; break;
case dawn::ErrorType::NoError: case wgpu::ErrorType::NoError:
default: default:
UNREACHABLE(); UNREACHABLE();
return; return;
} }
// Record the error if the scope doesn't have one yet. // Record the error if the scope doesn't have one yet.
if (currentScope->mErrorType == dawn::ErrorType::NoError) { if (currentScope->mErrorType == wgpu::ErrorType::NoError) {
currentScope->mErrorType = type; currentScope->mErrorType = type;
currentScope->mErrorMessage = message; currentScope->mErrorMessage = message;
} }
@ -100,14 +100,14 @@ namespace dawn_native {
// The root error scope captures all uncaptured errors. // The root error scope captures all uncaptured errors.
ASSERT(currentScope->IsRoot()); ASSERT(currentScope->IsRoot());
if (currentScope->mCallback) { if (currentScope->mCallback) {
currentScope->mCallback(static_cast<DawnErrorType>(type), message, currentScope->mCallback(static_cast<WGPUErrorType>(type), message,
currentScope->mUserdata); currentScope->mUserdata);
} }
} }
void ErrorScope::Destroy() { void ErrorScope::Destroy() {
if (!IsRoot()) { if (!IsRoot()) {
mErrorType = dawn::ErrorType::Unknown; mErrorType = wgpu::ErrorType::Unknown;
mErrorMessage = "Error scope destroyed"; mErrorMessage = "Error scope destroyed";
} }
} }

View File

@ -38,27 +38,27 @@ namespace dawn_native {
class ErrorScope : public RefCounted { class ErrorScope : public RefCounted {
public: public:
ErrorScope(); // Constructor for the root error scope. ErrorScope(); // Constructor for the root error scope.
ErrorScope(dawn::ErrorFilter errorFilter, ErrorScope* parent); ErrorScope(wgpu::ErrorFilter errorFilter, ErrorScope* parent);
~ErrorScope(); ~ErrorScope();
void SetCallback(dawn::ErrorCallback callback, void* userdata); void SetCallback(wgpu::ErrorCallback callback, void* userdata);
ErrorScope* GetParent(); ErrorScope* GetParent();
void HandleError(dawn::ErrorType type, const char* message); void HandleError(wgpu::ErrorType type, const char* message);
void Destroy(); void Destroy();
private: private:
bool IsRoot() const; bool IsRoot() const;
static void HandleErrorImpl(ErrorScope* scope, dawn::ErrorType type, const char* message); static void HandleErrorImpl(ErrorScope* scope, wgpu::ErrorType type, const char* message);
dawn::ErrorFilter mErrorFilter = dawn::ErrorFilter::None; wgpu::ErrorFilter mErrorFilter = wgpu::ErrorFilter::None;
Ref<ErrorScope> mParent = nullptr; Ref<ErrorScope> mParent = nullptr;
dawn::ErrorCallback mCallback = nullptr; wgpu::ErrorCallback mCallback = nullptr;
void* mUserdata = nullptr; void* mUserdata = nullptr;
dawn::ErrorType mErrorType = dawn::ErrorType::NoError; wgpu::ErrorType mErrorType = wgpu::ErrorType::NoError;
std::string mErrorMessage = ""; std::string mErrorMessage = "";
}; };

View File

@ -64,7 +64,7 @@ namespace dawn_native {
} }
void FenceBase::OnCompletion(uint64_t value, void FenceBase::OnCompletion(uint64_t value,
dawn::FenceOnCompletionCallback callback, wgpu::FenceOnCompletionCallback callback,
void* userdata) { void* userdata) {
if (GetDevice()->ConsumedError(ValidateOnCompletion(value))) { if (GetDevice()->ConsumedError(ValidateOnCompletion(value))) {
callback(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata); callback(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata);

View File

@ -40,7 +40,7 @@ namespace dawn_native {
// Dawn API // Dawn API
uint64_t GetCompletedValue() const; uint64_t GetCompletedValue() const;
void OnCompletion(uint64_t value, dawn::FenceOnCompletionCallback callback, void* userdata); void OnCompletion(uint64_t value, wgpu::FenceOnCompletionCallback callback, void* userdata);
protected: protected:
friend class QueueBase; friend class QueueBase;
@ -54,7 +54,7 @@ namespace dawn_native {
MaybeError ValidateOnCompletion(uint64_t value) const; MaybeError ValidateOnCompletion(uint64_t value) const;
struct OnCompletionData { struct OnCompletionData {
dawn::FenceOnCompletionCallback completionCallback = nullptr; wgpu::FenceOnCompletionCallback completionCallback = nullptr;
void* userdata = nullptr; void* userdata = nullptr;
}; };

View File

@ -38,23 +38,23 @@ namespace dawn_native {
return aspect != Color; return aspect != Color;
} }
bool Format::HasComponentType(dawn::TextureComponentType componentType) const { bool Format::HasComponentType(wgpu::TextureComponentType componentType) const {
// Depth stencil textures need to be special cased but we don't support sampling them yet. // Depth stencil textures need to be special cased but we don't support sampling them yet.
if (aspect != Color) { if (aspect != Color) {
return false; return false;
} }
// Check that Type is correctly mirrors TextureComponentType except for "Other". // Check that Type is correctly mirrors TextureComponentType except for "Other".
static_assert(static_cast<dawn::TextureComponentType>(Type::Float) == static_assert(static_cast<wgpu::TextureComponentType>(Type::Float) ==
dawn::TextureComponentType::Float, wgpu::TextureComponentType::Float,
""); "");
static_assert( static_assert(
static_cast<dawn::TextureComponentType>(Type::Sint) == dawn::TextureComponentType::Sint, static_cast<wgpu::TextureComponentType>(Type::Sint) == wgpu::TextureComponentType::Sint,
""); "");
static_assert( static_assert(
static_cast<dawn::TextureComponentType>(Type::Uint) == dawn::TextureComponentType::Uint, static_cast<wgpu::TextureComponentType>(Type::Uint) == wgpu::TextureComponentType::Uint,
""); "");
return static_cast<dawn::TextureComponentType>(type) == componentType; return static_cast<wgpu::TextureComponentType>(type) == componentType;
} }
size_t Format::GetIndex() const { size_t Format::GetIndex() const {
@ -65,10 +65,10 @@ namespace dawn_native {
// For the enum for formats are packed but this might change when we have a broader extension // For the enum for formats are packed but this might change when we have a broader extension
// mechanism for webgpu.h. Formats start at 1 because 0 is the undefined format. // mechanism for webgpu.h. Formats start at 1 because 0 is the undefined format.
size_t ComputeFormatIndex(dawn::TextureFormat format) { size_t ComputeFormatIndex(wgpu::TextureFormat format) {
// This takes advantage of overflows to make the index of TextureFormat::Undefined outside // This takes advantage of overflows to make the index of TextureFormat::Undefined outside
// of the range of the FormatTable. // of the range of the FormatTable.
static_assert(static_cast<uint32_t>(dawn::TextureFormat::Undefined) - 1 > kKnownFormatCount, static_assert(static_cast<uint32_t>(wgpu::TextureFormat::Undefined) - 1 > kKnownFormatCount,
""); "");
return static_cast<size_t>(static_cast<uint32_t>(format) - 1); return static_cast<size_t>(static_cast<uint32_t>(format) - 1);
} }
@ -92,7 +92,7 @@ namespace dawn_native {
formatsSet.set(index); formatsSet.set(index);
}; };
auto AddColorFormat = [&AddFormat](dawn::TextureFormat format, bool renderable, auto AddColorFormat = [&AddFormat](wgpu::TextureFormat format, bool renderable,
uint32_t byteSize, Type type) { uint32_t byteSize, Type type) {
Format internalFormat; Format internalFormat;
internalFormat.format = format; internalFormat.format = format;
@ -107,7 +107,7 @@ namespace dawn_native {
AddFormat(internalFormat); AddFormat(internalFormat);
}; };
auto AddDepthStencilFormat = [&AddFormat](dawn::TextureFormat format, Format::Aspect aspect, auto AddDepthStencilFormat = [&AddFormat](wgpu::TextureFormat format, Format::Aspect aspect,
uint32_t byteSize) { uint32_t byteSize) {
Format internalFormat; Format internalFormat;
internalFormat.format = format; internalFormat.format = format;
@ -122,7 +122,7 @@ namespace dawn_native {
AddFormat(internalFormat); AddFormat(internalFormat);
}; };
auto AddCompressedFormat = [&AddFormat](dawn::TextureFormat format, uint32_t byteSize, auto AddCompressedFormat = [&AddFormat](wgpu::TextureFormat format, uint32_t byteSize,
uint32_t width, uint32_t height, bool isSupported) { uint32_t width, uint32_t height, bool isSupported) {
Format internalFormat; Format internalFormat;
internalFormat.format = format; internalFormat.format = format;
@ -140,74 +140,74 @@ namespace dawn_native {
// clang-format off // clang-format off
// 1 byte color formats // 1 byte color formats
AddColorFormat(dawn::TextureFormat::R8Unorm, true, 1, Type::Float); AddColorFormat(wgpu::TextureFormat::R8Unorm, true, 1, Type::Float);
AddColorFormat(dawn::TextureFormat::R8Snorm, false, 1, Type::Float); AddColorFormat(wgpu::TextureFormat::R8Snorm, false, 1, Type::Float);
AddColorFormat(dawn::TextureFormat::R8Uint, true, 1, Type::Uint); AddColorFormat(wgpu::TextureFormat::R8Uint, true, 1, Type::Uint);
AddColorFormat(dawn::TextureFormat::R8Sint, true, 1, Type::Sint); AddColorFormat(wgpu::TextureFormat::R8Sint, true, 1, Type::Sint);
// 2 bytes color formats // 2 bytes color formats
AddColorFormat(dawn::TextureFormat::R16Uint, true, 2, Type::Uint); AddColorFormat(wgpu::TextureFormat::R16Uint, true, 2, Type::Uint);
AddColorFormat(dawn::TextureFormat::R16Sint, true, 2, Type::Sint); AddColorFormat(wgpu::TextureFormat::R16Sint, true, 2, Type::Sint);
AddColorFormat(dawn::TextureFormat::R16Float, true, 2, Type::Float); AddColorFormat(wgpu::TextureFormat::R16Float, true, 2, Type::Float);
AddColorFormat(dawn::TextureFormat::RG8Unorm, true, 2, Type::Float); AddColorFormat(wgpu::TextureFormat::RG8Unorm, true, 2, Type::Float);
AddColorFormat(dawn::TextureFormat::RG8Snorm, false, 2, Type::Float); AddColorFormat(wgpu::TextureFormat::RG8Snorm, false, 2, Type::Float);
AddColorFormat(dawn::TextureFormat::RG8Uint, true, 2, Type::Uint); AddColorFormat(wgpu::TextureFormat::RG8Uint, true, 2, Type::Uint);
AddColorFormat(dawn::TextureFormat::RG8Sint, true, 2, Type::Sint); AddColorFormat(wgpu::TextureFormat::RG8Sint, true, 2, Type::Sint);
// 4 bytes color formats // 4 bytes color formats
AddColorFormat(dawn::TextureFormat::R32Uint, true, 4, Type::Uint); AddColorFormat(wgpu::TextureFormat::R32Uint, true, 4, Type::Uint);
AddColorFormat(dawn::TextureFormat::R32Sint, true, 4, Type::Sint); AddColorFormat(wgpu::TextureFormat::R32Sint, true, 4, Type::Sint);
AddColorFormat(dawn::TextureFormat::R32Float, true, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::R32Float, true, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::RG16Uint, true, 4, Type::Uint); AddColorFormat(wgpu::TextureFormat::RG16Uint, true, 4, Type::Uint);
AddColorFormat(dawn::TextureFormat::RG16Sint, true, 4, Type::Sint); AddColorFormat(wgpu::TextureFormat::RG16Sint, true, 4, Type::Sint);
AddColorFormat(dawn::TextureFormat::RG16Float, true, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::RG16Float, true, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::RGBA8Unorm, true, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::RGBA8Unorm, true, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::RGBA8UnormSrgb, true, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::RGBA8UnormSrgb, true, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::RGBA8Snorm, false, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::RGBA8Snorm, false, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::RGBA8Uint, true, 4, Type::Uint); AddColorFormat(wgpu::TextureFormat::RGBA8Uint, true, 4, Type::Uint);
AddColorFormat(dawn::TextureFormat::RGBA8Sint, true, 4, Type::Sint); AddColorFormat(wgpu::TextureFormat::RGBA8Sint, true, 4, Type::Sint);
AddColorFormat(dawn::TextureFormat::BGRA8Unorm, true, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::BGRA8Unorm, true, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::BGRA8UnormSrgb, true, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::BGRA8UnormSrgb, true, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::RGB10A2Unorm, true, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::RGB10A2Unorm, true, 4, Type::Float);
AddColorFormat(dawn::TextureFormat::RG11B10Float, false, 4, Type::Float); AddColorFormat(wgpu::TextureFormat::RG11B10Float, false, 4, Type::Float);
// 8 bytes color formats // 8 bytes color formats
AddColorFormat(dawn::TextureFormat::RG32Uint, true, 8, Type::Uint); AddColorFormat(wgpu::TextureFormat::RG32Uint, true, 8, Type::Uint);
AddColorFormat(dawn::TextureFormat::RG32Sint, true, 8, Type::Sint); AddColorFormat(wgpu::TextureFormat::RG32Sint, true, 8, Type::Sint);
AddColorFormat(dawn::TextureFormat::RG32Float, true, 8, Type::Float); AddColorFormat(wgpu::TextureFormat::RG32Float, true, 8, Type::Float);
AddColorFormat(dawn::TextureFormat::RGBA16Uint, true, 8, Type::Uint); AddColorFormat(wgpu::TextureFormat::RGBA16Uint, true, 8, Type::Uint);
AddColorFormat(dawn::TextureFormat::RGBA16Sint, true, 8, Type::Sint); AddColorFormat(wgpu::TextureFormat::RGBA16Sint, true, 8, Type::Sint);
AddColorFormat(dawn::TextureFormat::RGBA16Float, true, 8, Type::Float); AddColorFormat(wgpu::TextureFormat::RGBA16Float, true, 8, Type::Float);
// 16 bytes color formats // 16 bytes color formats
AddColorFormat(dawn::TextureFormat::RGBA32Uint, true, 16, Type::Uint); AddColorFormat(wgpu::TextureFormat::RGBA32Uint, true, 16, Type::Uint);
AddColorFormat(dawn::TextureFormat::RGBA32Sint, true, 16, Type::Sint); AddColorFormat(wgpu::TextureFormat::RGBA32Sint, true, 16, Type::Sint);
AddColorFormat(dawn::TextureFormat::RGBA32Float, true, 16, Type::Float); AddColorFormat(wgpu::TextureFormat::RGBA32Float, true, 16, Type::Float);
// Depth stencil formats // Depth stencil formats
AddDepthStencilFormat(dawn::TextureFormat::Depth32Float, Aspect::Depth, 4); AddDepthStencilFormat(wgpu::TextureFormat::Depth32Float, Aspect::Depth, 4);
AddDepthStencilFormat(dawn::TextureFormat::Depth24Plus, Aspect::Depth, 4); AddDepthStencilFormat(wgpu::TextureFormat::Depth24Plus, Aspect::Depth, 4);
// TODO(cwallez@chromium.org): It isn't clear if this format should be copyable // TODO(cwallez@chromium.org): It isn't clear if this format should be copyable
// because its size isn't well defined, is it 4, 5 or 8? // because its size isn't well defined, is it 4, 5 or 8?
AddDepthStencilFormat(dawn::TextureFormat::Depth24PlusStencil8, Aspect::DepthStencil, 4); AddDepthStencilFormat(wgpu::TextureFormat::Depth24PlusStencil8, Aspect::DepthStencil, 4);
// BC compressed formats // BC compressed formats
bool isBCFormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionBC); bool isBCFormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionBC);
AddCompressedFormat(dawn::TextureFormat::BC1RGBAUnorm, 8, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnorm, 8, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC1RGBAUnormSrgb, 8, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnormSrgb, 8, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC4RSnorm, 8, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC4RSnorm, 8, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC4RUnorm, 8, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC4RUnorm, 8, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC2RGBAUnorm, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC2RGBAUnorm, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC2RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC2RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC3RGBAUnorm, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC3RGBAUnorm, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC3RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC3RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC5RGSnorm, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC5RGSnorm, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC5RGUnorm, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC5RGUnorm, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC6HRGBSfloat, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC6HRGBSfloat, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC6HRGBUfloat, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC6HRGBUfloat, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC7RGBAUnorm, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC7RGBAUnorm, 16, 4, 4, isBCFormatSupported);
AddCompressedFormat(dawn::TextureFormat::BC7RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported); AddCompressedFormat(wgpu::TextureFormat::BC7RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
// clang-format on // clang-format on

View File

@ -29,7 +29,7 @@ namespace dawn_native {
// exact number of known format. // exact number of known format.
static constexpr size_t kKnownFormatCount = 52; static constexpr size_t kKnownFormatCount = 52;
// A dawn::TextureFormat along with all the information about it necessary for validation. // A wgpu::TextureFormat along with all the information about it necessary for validation.
struct Format { struct Format {
enum Aspect { enum Aspect {
Color, Color,
@ -45,7 +45,7 @@ namespace dawn_native {
Other, Other,
}; };
dawn::TextureFormat format; wgpu::TextureFormat format;
bool isRenderable; bool isRenderable;
bool isCompressed; bool isCompressed;
// A format can be known but not supported because it is part of a disabled extension. // A format can be known but not supported because it is part of a disabled extension.
@ -61,7 +61,7 @@ namespace dawn_native {
bool HasDepth() const; bool HasDepth() const;
bool HasStencil() const; bool HasStencil() const;
bool HasDepthOrStencil() const; bool HasDepthOrStencil() const;
bool HasComponentType(dawn::TextureComponentType componentType) const; bool HasComponentType(wgpu::TextureComponentType componentType) const;
// The index of the format in the list of all known formats: a unique number for each format // The index of the format in the list of all known formats: a unique number for each format
// in [0, kKnownFormatCount) // in [0, kKnownFormatCount)
@ -73,7 +73,7 @@ namespace dawn_native {
using FormatTable = std::array<Format, kKnownFormatCount>; using FormatTable = std::array<Format, kKnownFormatCount>;
// Returns the index of a format in the FormatTable. // Returns the index of a format in the FormatTable.
size_t ComputeFormatIndex(dawn::TextureFormat format); size_t ComputeFormatIndex(wgpu::TextureFormat format);
// Builds the format table with the extensions enabled on the device. // Builds the format table with the extensions enabled on the device.
FormatTable BuildFormatTable(const DeviceBase* device); FormatTable BuildFormatTable(const DeviceBase* device);

View File

@ -30,10 +30,10 @@ namespace dawn_native {
// re-compute it. // re-compute it.
struct PassResourceUsage { struct PassResourceUsage {
std::vector<BufferBase*> buffers; std::vector<BufferBase*> buffers;
std::vector<dawn::BufferUsage> bufferUsages; std::vector<wgpu::BufferUsage> bufferUsages;
std::vector<TextureBase*> textures; std::vector<TextureBase*> textures;
std::vector<dawn::TextureUsage> textureUsages; std::vector<wgpu::TextureUsage> textureUsages;
}; };
struct CommandBufferResourceUsage { struct CommandBufferResourceUsage {

View File

@ -19,13 +19,13 @@
namespace dawn_native { namespace dawn_native {
void PassResourceUsageTracker::BufferUsedAs(BufferBase* buffer, dawn::BufferUsage usage) { void PassResourceUsageTracker::BufferUsedAs(BufferBase* buffer, wgpu::BufferUsage usage) {
// std::map's operator[] will create the key and return 0 if the key didn't exist // std::map's operator[] will create the key and return 0 if the key didn't exist
// before. // before.
mBufferUsages[buffer] |= usage; mBufferUsages[buffer] |= usage;
} }
void PassResourceUsageTracker::TextureUsedAs(TextureBase* texture, dawn::TextureUsage usage) { void PassResourceUsageTracker::TextureUsedAs(TextureBase* texture, wgpu::TextureUsage usage) {
// std::map's operator[] will create the key and return 0 if the key didn't exist // std::map's operator[] will create the key and return 0 if the key didn't exist
// before. // before.
mTextureUsages[texture] |= usage; mTextureUsages[texture] |= usage;
@ -44,14 +44,14 @@ namespace dawn_native {
// Buffers can only be used as single-write or multiple read. // Buffers can only be used as single-write or multiple read.
for (auto& it : mBufferUsages) { for (auto& it : mBufferUsages) {
BufferBase* buffer = it.first; BufferBase* buffer = it.first;
dawn::BufferUsage usage = it.second; wgpu::BufferUsage usage = it.second;
if (usage & ~buffer->GetUsage()) { if (usage & ~buffer->GetUsage()) {
return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass"); return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass");
} }
bool readOnly = (usage & kReadOnlyBufferUsages) == usage; bool readOnly = (usage & kReadOnlyBufferUsages) == usage;
bool singleUse = dawn::HasZeroOrOneBits(usage); bool singleUse = wgpu::HasZeroOrOneBits(usage);
if (!readOnly && !singleUse) { if (!readOnly && !singleUse) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
@ -63,7 +63,7 @@ namespace dawn_native {
// TODO(cwallez@chromium.org): implement per-subresource tracking // TODO(cwallez@chromium.org): implement per-subresource tracking
for (auto& it : mTextureUsages) { for (auto& it : mTextureUsages) {
TextureBase* texture = it.first; TextureBase* texture = it.first;
dawn::TextureUsage usage = it.second; wgpu::TextureUsage usage = it.second;
if (usage & ~texture->GetUsage()) { if (usage & ~texture->GetUsage()) {
return DAWN_VALIDATION_ERROR("Texture missing usage for the pass"); return DAWN_VALIDATION_ERROR("Texture missing usage for the pass");
@ -71,7 +71,7 @@ namespace dawn_native {
// For textures the only read-only usage in a pass is Sampled, so checking the // 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. // usage constraint simplifies to checking a single usage bit is set.
if (!dawn::HasZeroOrOneBits(it.second)) { if (!wgpu::HasZeroOrOneBits(it.second)) {
return DAWN_VALIDATION_ERROR("Texture used with more than one usage in pass"); return DAWN_VALIDATION_ERROR("Texture used with more than one usage in pass");
} }
} }

View File

@ -33,8 +33,8 @@ namespace dawn_native {
// information. // information.
class PassResourceUsageTracker { class PassResourceUsageTracker {
public: public:
void BufferUsedAs(BufferBase* buffer, dawn::BufferUsage usage); void BufferUsedAs(BufferBase* buffer, wgpu::BufferUsage usage);
void TextureUsedAs(TextureBase* texture, dawn::TextureUsage usage); void TextureUsedAs(TextureBase* texture, wgpu::TextureUsage usage);
MaybeError ValidateComputePassUsages() const; MaybeError ValidateComputePassUsages() const;
MaybeError ValidateRenderPassUsages() const; MaybeError ValidateRenderPassUsages() const;
@ -46,8 +46,8 @@ namespace dawn_native {
// Performs the per-pass usage validation checks // Performs the per-pass usage validation checks
MaybeError ValidateUsages() const; MaybeError ValidateUsages() const;
std::map<BufferBase*, dawn::BufferUsage> mBufferUsages; std::map<BufferBase*, wgpu::BufferUsage> mBufferUsages;
std::map<TextureBase*, dawn::TextureUsage> mTextureUsages; std::map<TextureBase*, wgpu::TextureUsage> mTextureUsages;
}; };
} // namespace dawn_native } // namespace dawn_native

View File

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

View File

@ -31,21 +31,21 @@ namespace dawn_native {
static_assert(static_cast<uint32_t>(SingleShaderStage::Fragment) < kNumStages, ""); static_assert(static_cast<uint32_t>(SingleShaderStage::Fragment) < kNumStages, "");
static_assert(static_cast<uint32_t>(SingleShaderStage::Compute) < kNumStages, ""); static_assert(static_cast<uint32_t>(SingleShaderStage::Compute) < kNumStages, "");
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Vertex) == static_assert(static_cast<uint32_t>(wgpu::ShaderStage::Vertex) ==
(1 << static_cast<uint32_t>(SingleShaderStage::Vertex)), (1 << static_cast<uint32_t>(SingleShaderStage::Vertex)),
""); "");
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Fragment) == static_assert(static_cast<uint32_t>(wgpu::ShaderStage::Fragment) ==
(1 << static_cast<uint32_t>(SingleShaderStage::Fragment)), (1 << static_cast<uint32_t>(SingleShaderStage::Fragment)),
""); "");
static_assert(static_cast<uint32_t>(dawn::ShaderStage::Compute) == static_assert(static_cast<uint32_t>(wgpu::ShaderStage::Compute) ==
(1 << static_cast<uint32_t>(SingleShaderStage::Compute)), (1 << static_cast<uint32_t>(SingleShaderStage::Compute)),
""); "");
BitSetIterator<kNumStages, SingleShaderStage> IterateStages(dawn::ShaderStage stages); BitSetIterator<kNumStages, SingleShaderStage> IterateStages(wgpu::ShaderStage stages);
dawn::ShaderStage StageBit(SingleShaderStage stage); wgpu::ShaderStage StageBit(SingleShaderStage stage);
static constexpr dawn::ShaderStage kAllStages = static constexpr wgpu::ShaderStage kAllStages =
static_cast<dawn::ShaderStage>((1 << kNumStages) - 1); static_cast<wgpu::ShaderStage>((1 << kNumStages) - 1);
template <typename T> template <typename T>
class PerStage { class PerStage {
@ -64,12 +64,12 @@ namespace dawn_native {
return mData[static_cast<uint32_t>(stage)]; return mData[static_cast<uint32_t>(stage)];
} }
T& operator[](dawn::ShaderStage stageBit) { T& operator[](wgpu::ShaderStage stageBit) {
uint32_t bit = static_cast<uint32_t>(stageBit); uint32_t bit = static_cast<uint32_t>(stageBit);
DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages)); DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
return mData[Log2(bit)]; return mData[Log2(bit)];
} }
const T& operator[](dawn::ShaderStage stageBit) const { const T& operator[](wgpu::ShaderStage stageBit) const {
uint32_t bit = static_cast<uint32_t>(stageBit); uint32_t bit = static_cast<uint32_t>(stageBit);
DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages)); DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
return mData[Log2(bit)]; return mData[Log2(bit)];

View File

@ -42,7 +42,7 @@ namespace dawn_native {
PipelineBase::PipelineBase(DeviceBase* device, PipelineBase::PipelineBase(DeviceBase* device,
PipelineLayoutBase* layout, PipelineLayoutBase* layout,
dawn::ShaderStage stages) wgpu::ShaderStage stages)
: ObjectBase(device), mStageMask(stages), mLayout(layout) { : ObjectBase(device), mStageMask(stages), mLayout(layout) {
} }
@ -50,7 +50,7 @@ namespace dawn_native {
: ObjectBase(device, tag) { : ObjectBase(device, tag) {
} }
dawn::ShaderStage PipelineBase::GetStageMask() const { wgpu::ShaderStage PipelineBase::GetStageMask() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mStageMask; return mStageMask;
} }

View File

@ -35,16 +35,16 @@ namespace dawn_native {
class PipelineBase : public ObjectBase { class PipelineBase : public ObjectBase {
public: public:
dawn::ShaderStage GetStageMask() const; wgpu::ShaderStage GetStageMask() const;
PipelineLayoutBase* GetLayout(); PipelineLayoutBase* GetLayout();
const PipelineLayoutBase* GetLayout() const; const PipelineLayoutBase* GetLayout() const;
protected: protected:
PipelineBase(DeviceBase* device, PipelineLayoutBase* layout, dawn::ShaderStage stages); PipelineBase(DeviceBase* device, PipelineLayoutBase* layout, wgpu::ShaderStage stages);
PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag); PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
private: private:
dawn::ShaderStage mStageMask; wgpu::ShaderStage mStageMask;
Ref<PipelineLayoutBase> mLayout; Ref<PipelineLayoutBase> mLayout;
}; };

View File

@ -24,7 +24,7 @@
namespace dawn_native { namespace dawn_native {
MaybeError ValidateColorAttachmentFormat(const DeviceBase* device, MaybeError ValidateColorAttachmentFormat(const DeviceBase* device,
dawn::TextureFormat textureFormat) { wgpu::TextureFormat textureFormat) {
DAWN_TRY(ValidateTextureFormat(textureFormat)); DAWN_TRY(ValidateTextureFormat(textureFormat));
const Format* format = nullptr; const Format* format = nullptr;
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(textureFormat)); DAWN_TRY_ASSIGN(format, device->GetInternalFormat(textureFormat));
@ -36,7 +36,7 @@ namespace dawn_native {
} }
MaybeError ValidateDepthStencilAttachmentFormat(const DeviceBase* device, MaybeError ValidateDepthStencilAttachmentFormat(const DeviceBase* device,
dawn::TextureFormat textureFormat) { wgpu::TextureFormat textureFormat) {
DAWN_TRY(ValidateTextureFormat(textureFormat)); DAWN_TRY(ValidateTextureFormat(textureFormat));
const Format* format = nullptr; const Format* format = nullptr;
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(textureFormat)); DAWN_TRY_ASSIGN(format, device->GetInternalFormat(textureFormat));
@ -60,7 +60,7 @@ namespace dawn_native {
} }
if (descriptor->colorFormatsCount == 0 && if (descriptor->colorFormatsCount == 0 &&
descriptor->depthStencilFormat == dawn::TextureFormat::Undefined) { descriptor->depthStencilFormat == wgpu::TextureFormat::Undefined) {
return DAWN_VALIDATION_ERROR("Should have at least one attachment format"); return DAWN_VALIDATION_ERROR("Should have at least one attachment format");
} }
@ -68,7 +68,7 @@ namespace dawn_native {
DAWN_TRY(ValidateColorAttachmentFormat(device, descriptor->colorFormats[i])); DAWN_TRY(ValidateColorAttachmentFormat(device, descriptor->colorFormats[i]));
} }
if (descriptor->depthStencilFormat != dawn::TextureFormat::Undefined) { if (descriptor->depthStencilFormat != wgpu::TextureFormat::Undefined) {
DAWN_TRY(ValidateDepthStencilAttachmentFormat(device, descriptor->depthStencilFormat)); DAWN_TRY(ValidateDepthStencilAttachmentFormat(device, descriptor->depthStencilFormat));
} }

View File

@ -177,100 +177,100 @@ namespace dawn_native {
} // anonymous namespace } // anonymous namespace
// Helper functions // Helper functions
size_t IndexFormatSize(dawn::IndexFormat format) { size_t IndexFormatSize(wgpu::IndexFormat format) {
switch (format) { switch (format) {
case dawn::IndexFormat::Uint16: case wgpu::IndexFormat::Uint16:
return sizeof(uint16_t); return sizeof(uint16_t);
case dawn::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return sizeof(uint32_t); return sizeof(uint32_t);
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
uint32_t VertexFormatNumComponents(dawn::VertexFormat format) { uint32_t VertexFormatNumComponents(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case dawn::VertexFormat::UChar4: case wgpu::VertexFormat::UChar4:
case dawn::VertexFormat::Char4: case wgpu::VertexFormat::Char4:
case dawn::VertexFormat::UChar4Norm: case wgpu::VertexFormat::UChar4Norm:
case dawn::VertexFormat::Char4Norm: case wgpu::VertexFormat::Char4Norm:
case dawn::VertexFormat::UShort4: case wgpu::VertexFormat::UShort4:
case dawn::VertexFormat::Short4: case wgpu::VertexFormat::Short4:
case dawn::VertexFormat::UShort4Norm: case wgpu::VertexFormat::UShort4Norm:
case dawn::VertexFormat::Short4Norm: case wgpu::VertexFormat::Short4Norm:
case dawn::VertexFormat::Half4: case wgpu::VertexFormat::Half4:
case dawn::VertexFormat::Float4: case wgpu::VertexFormat::Float4:
case dawn::VertexFormat::UInt4: case wgpu::VertexFormat::UInt4:
case dawn::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return 4; return 4;
case dawn::VertexFormat::Float3: case wgpu::VertexFormat::Float3:
case dawn::VertexFormat::UInt3: case wgpu::VertexFormat::UInt3:
case dawn::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
return 3; return 3;
case dawn::VertexFormat::UChar2: case wgpu::VertexFormat::UChar2:
case dawn::VertexFormat::Char2: case wgpu::VertexFormat::Char2:
case dawn::VertexFormat::UChar2Norm: case wgpu::VertexFormat::UChar2Norm:
case dawn::VertexFormat::Char2Norm: case wgpu::VertexFormat::Char2Norm:
case dawn::VertexFormat::UShort2: case wgpu::VertexFormat::UShort2:
case dawn::VertexFormat::Short2: case wgpu::VertexFormat::Short2:
case dawn::VertexFormat::UShort2Norm: case wgpu::VertexFormat::UShort2Norm:
case dawn::VertexFormat::Short2Norm: case wgpu::VertexFormat::Short2Norm:
case dawn::VertexFormat::Half2: case wgpu::VertexFormat::Half2:
case dawn::VertexFormat::Float2: case wgpu::VertexFormat::Float2:
case dawn::VertexFormat::UInt2: case wgpu::VertexFormat::UInt2:
case dawn::VertexFormat::Int2: case wgpu::VertexFormat::Int2:
return 2; return 2;
case dawn::VertexFormat::Float: case wgpu::VertexFormat::Float:
case dawn::VertexFormat::UInt: case wgpu::VertexFormat::UInt:
case dawn::VertexFormat::Int: case wgpu::VertexFormat::Int:
return 1; return 1;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
size_t VertexFormatComponentSize(dawn::VertexFormat format) { size_t VertexFormatComponentSize(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case dawn::VertexFormat::UChar2: case wgpu::VertexFormat::UChar2:
case dawn::VertexFormat::UChar4: case wgpu::VertexFormat::UChar4:
case dawn::VertexFormat::Char2: case wgpu::VertexFormat::Char2:
case dawn::VertexFormat::Char4: case wgpu::VertexFormat::Char4:
case dawn::VertexFormat::UChar2Norm: case wgpu::VertexFormat::UChar2Norm:
case dawn::VertexFormat::UChar4Norm: case wgpu::VertexFormat::UChar4Norm:
case dawn::VertexFormat::Char2Norm: case wgpu::VertexFormat::Char2Norm:
case dawn::VertexFormat::Char4Norm: case wgpu::VertexFormat::Char4Norm:
return sizeof(char); return sizeof(char);
case dawn::VertexFormat::UShort2: case wgpu::VertexFormat::UShort2:
case dawn::VertexFormat::UShort4: case wgpu::VertexFormat::UShort4:
case dawn::VertexFormat::UShort2Norm: case wgpu::VertexFormat::UShort2Norm:
case dawn::VertexFormat::UShort4Norm: case wgpu::VertexFormat::UShort4Norm:
case dawn::VertexFormat::Short2: case wgpu::VertexFormat::Short2:
case dawn::VertexFormat::Short4: case wgpu::VertexFormat::Short4:
case dawn::VertexFormat::Short2Norm: case wgpu::VertexFormat::Short2Norm:
case dawn::VertexFormat::Short4Norm: case wgpu::VertexFormat::Short4Norm:
case dawn::VertexFormat::Half2: case wgpu::VertexFormat::Half2:
case dawn::VertexFormat::Half4: case wgpu::VertexFormat::Half4:
return sizeof(uint16_t); return sizeof(uint16_t);
case dawn::VertexFormat::Float: case wgpu::VertexFormat::Float:
case dawn::VertexFormat::Float2: case wgpu::VertexFormat::Float2:
case dawn::VertexFormat::Float3: case wgpu::VertexFormat::Float3:
case dawn::VertexFormat::Float4: case wgpu::VertexFormat::Float4:
return sizeof(float); return sizeof(float);
case dawn::VertexFormat::UInt: case wgpu::VertexFormat::UInt:
case dawn::VertexFormat::UInt2: case wgpu::VertexFormat::UInt2:
case dawn::VertexFormat::UInt3: case wgpu::VertexFormat::UInt3:
case dawn::VertexFormat::UInt4: case wgpu::VertexFormat::UInt4:
case dawn::VertexFormat::Int: case wgpu::VertexFormat::Int:
case dawn::VertexFormat::Int2: case wgpu::VertexFormat::Int2:
case dawn::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
case dawn::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return sizeof(int32_t); return sizeof(int32_t);
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
size_t VertexFormatSize(dawn::VertexFormat format) { size_t VertexFormatSize(wgpu::VertexFormat format) {
return VertexFormatNumComponents(format) * VertexFormatComponentSize(format); return VertexFormatNumComponents(format) * VertexFormatComponentSize(format);
} }
@ -344,23 +344,23 @@ namespace dawn_native {
} }
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState) { bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState) {
return mDepthStencilState->stencilBack.compare != dawn::CompareFunction::Always || return mDepthStencilState->stencilBack.compare != wgpu::CompareFunction::Always ||
mDepthStencilState->stencilBack.failOp != dawn::StencilOperation::Keep || mDepthStencilState->stencilBack.failOp != wgpu::StencilOperation::Keep ||
mDepthStencilState->stencilBack.depthFailOp != dawn::StencilOperation::Keep || mDepthStencilState->stencilBack.depthFailOp != wgpu::StencilOperation::Keep ||
mDepthStencilState->stencilBack.passOp != dawn::StencilOperation::Keep || mDepthStencilState->stencilBack.passOp != wgpu::StencilOperation::Keep ||
mDepthStencilState->stencilFront.compare != dawn::CompareFunction::Always || mDepthStencilState->stencilFront.compare != wgpu::CompareFunction::Always ||
mDepthStencilState->stencilFront.failOp != dawn::StencilOperation::Keep || mDepthStencilState->stencilFront.failOp != wgpu::StencilOperation::Keep ||
mDepthStencilState->stencilFront.depthFailOp != dawn::StencilOperation::Keep || mDepthStencilState->stencilFront.depthFailOp != wgpu::StencilOperation::Keep ||
mDepthStencilState->stencilFront.passOp != dawn::StencilOperation::Keep; mDepthStencilState->stencilFront.passOp != wgpu::StencilOperation::Keep;
} }
bool BlendEnabled(const ColorStateDescriptor* mColorState) { bool BlendEnabled(const ColorStateDescriptor* mColorState) {
return mColorState->alphaBlend.operation != dawn::BlendOperation::Add || return mColorState->alphaBlend.operation != wgpu::BlendOperation::Add ||
mColorState->alphaBlend.srcFactor != dawn::BlendFactor::One || mColorState->alphaBlend.srcFactor != wgpu::BlendFactor::One ||
mColorState->alphaBlend.dstFactor != dawn::BlendFactor::Zero || mColorState->alphaBlend.dstFactor != wgpu::BlendFactor::Zero ||
mColorState->colorBlend.operation != dawn::BlendOperation::Add || mColorState->colorBlend.operation != wgpu::BlendOperation::Add ||
mColorState->colorBlend.srcFactor != dawn::BlendFactor::One || mColorState->colorBlend.srcFactor != wgpu::BlendFactor::One ||
mColorState->colorBlend.dstFactor != dawn::BlendFactor::Zero; mColorState->colorBlend.dstFactor != wgpu::BlendFactor::Zero;
} }
// RenderPipelineBase // RenderPipelineBase
@ -370,7 +370,7 @@ namespace dawn_native {
bool blueprint) bool blueprint)
: PipelineBase(device, : PipelineBase(device,
descriptor->layout, descriptor->layout,
dawn::ShaderStage::Vertex | dawn::ShaderStage::Fragment), wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Fragment),
mAttachmentState(device->GetOrCreateAttachmentState(descriptor)), mAttachmentState(device->GetOrCreateAttachmentState(descriptor)),
mPrimitiveTopology(descriptor->primitiveTopology), mPrimitiveTopology(descriptor->primitiveTopology),
mSampleMask(descriptor->sampleMask), mSampleMask(descriptor->sampleMask),
@ -419,16 +419,16 @@ namespace dawn_native {
// The values indicate that depth and stencil test are disabled when backends // The values indicate that depth and stencil test are disabled when backends
// set their own depth stencil states/descriptors according to the values in // set their own depth stencil states/descriptors according to the values in
// mDepthStencilState. // mDepthStencilState.
mDepthStencilState.depthCompare = dawn::CompareFunction::Always; mDepthStencilState.depthCompare = wgpu::CompareFunction::Always;
mDepthStencilState.depthWriteEnabled = false; mDepthStencilState.depthWriteEnabled = false;
mDepthStencilState.stencilBack.compare = dawn::CompareFunction::Always; mDepthStencilState.stencilBack.compare = wgpu::CompareFunction::Always;
mDepthStencilState.stencilBack.failOp = dawn::StencilOperation::Keep; mDepthStencilState.stencilBack.failOp = wgpu::StencilOperation::Keep;
mDepthStencilState.stencilBack.depthFailOp = dawn::StencilOperation::Keep; mDepthStencilState.stencilBack.depthFailOp = wgpu::StencilOperation::Keep;
mDepthStencilState.stencilBack.passOp = dawn::StencilOperation::Keep; mDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Keep;
mDepthStencilState.stencilFront.compare = dawn::CompareFunction::Always; mDepthStencilState.stencilFront.compare = wgpu::CompareFunction::Always;
mDepthStencilState.stencilFront.failOp = dawn::StencilOperation::Keep; mDepthStencilState.stencilFront.failOp = wgpu::StencilOperation::Keep;
mDepthStencilState.stencilFront.depthFailOp = dawn::StencilOperation::Keep; mDepthStencilState.stencilFront.depthFailOp = wgpu::StencilOperation::Keep;
mDepthStencilState.stencilFront.passOp = dawn::StencilOperation::Keep; mDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Keep;
mDepthStencilState.stencilReadMask = 0xff; mDepthStencilState.stencilReadMask = 0xff;
mDepthStencilState.stencilWriteMask = 0xff; mDepthStencilState.stencilWriteMask = 0xff;
} }
@ -496,17 +496,17 @@ namespace dawn_native {
return &mDepthStencilState; return &mDepthStencilState;
} }
dawn::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const { wgpu::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mPrimitiveTopology; return mPrimitiveTopology;
} }
dawn::CullMode RenderPipelineBase::GetCullMode() const { wgpu::CullMode RenderPipelineBase::GetCullMode() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mRasterizationState.cullMode; return mRasterizationState.cullMode;
} }
dawn::FrontFace RenderPipelineBase::GetFrontFace() const { wgpu::FrontFace RenderPipelineBase::GetFrontFace() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mRasterizationState.frontFace; return mRasterizationState.frontFace;
} }
@ -521,12 +521,12 @@ namespace dawn_native {
return mAttachmentState->HasDepthStencilAttachment(); return mAttachmentState->HasDepthStencilAttachment();
} }
dawn::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(uint32_t attachment) const { wgpu::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(uint32_t attachment) const {
ASSERT(!IsError()); ASSERT(!IsError());
return mColorStates[attachment].format; return mColorStates[attachment].format;
} }
dawn::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const { wgpu::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const {
ASSERT(!IsError()); ASSERT(!IsError());
ASSERT(mAttachmentState->HasDepthStencilAttachment()); ASSERT(mAttachmentState->HasDepthStencilAttachment());
return mDepthStencilState.format; return mDepthStencilState.format;

View File

@ -32,10 +32,10 @@ namespace dawn_native {
MaybeError ValidateRenderPipelineDescriptor(const DeviceBase* device, MaybeError ValidateRenderPipelineDescriptor(const DeviceBase* device,
const RenderPipelineDescriptor* descriptor); const RenderPipelineDescriptor* descriptor);
size_t IndexFormatSize(dawn::IndexFormat format); size_t IndexFormatSize(wgpu::IndexFormat format);
uint32_t VertexFormatNumComponents(dawn::VertexFormat format); uint32_t VertexFormatNumComponents(wgpu::VertexFormat format);
size_t VertexFormatComponentSize(dawn::VertexFormat format); size_t VertexFormatComponentSize(wgpu::VertexFormat format);
size_t VertexFormatSize(dawn::VertexFormat format); size_t VertexFormatSize(wgpu::VertexFormat format);
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState); bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState);
bool BlendEnabled(const ColorStateDescriptor* mColorState); bool BlendEnabled(const ColorStateDescriptor* mColorState);
@ -44,12 +44,12 @@ namespace dawn_native {
uint32_t shaderLocation; uint32_t shaderLocation;
uint32_t inputSlot; uint32_t inputSlot;
uint64_t offset; uint64_t offset;
dawn::VertexFormat format; wgpu::VertexFormat format;
}; };
struct VertexBufferInfo { struct VertexBufferInfo {
uint64_t stride; uint64_t stride;
dawn::InputStepMode stepMode; wgpu::InputStepMode stepMode;
}; };
class RenderPipelineBase : public PipelineBase { class RenderPipelineBase : public PipelineBase {
@ -69,14 +69,14 @@ namespace dawn_native {
const ColorStateDescriptor* GetColorStateDescriptor(uint32_t attachmentSlot) const; const ColorStateDescriptor* GetColorStateDescriptor(uint32_t attachmentSlot) const;
const DepthStencilStateDescriptor* GetDepthStencilStateDescriptor() const; const DepthStencilStateDescriptor* GetDepthStencilStateDescriptor() const;
dawn::PrimitiveTopology GetPrimitiveTopology() const; wgpu::PrimitiveTopology GetPrimitiveTopology() const;
dawn::CullMode GetCullMode() const; wgpu::CullMode GetCullMode() const;
dawn::FrontFace GetFrontFace() const; wgpu::FrontFace GetFrontFace() const;
std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const; std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const;
bool HasDepthStencilAttachment() const; bool HasDepthStencilAttachment() const;
dawn::TextureFormat GetColorAttachmentFormat(uint32_t attachment) const; wgpu::TextureFormat GetColorAttachmentFormat(uint32_t attachment) const;
dawn::TextureFormat GetDepthStencilFormat() const; wgpu::TextureFormat GetDepthStencilFormat() const;
uint32_t GetSampleCount() const; uint32_t GetSampleCount() const;
const AttachmentState* GetAttachmentState() const; const AttachmentState* GetAttachmentState() const;
@ -108,7 +108,7 @@ namespace dawn_native {
std::array<ColorStateDescriptor, kMaxColorAttachments> mColorStates; std::array<ColorStateDescriptor, kMaxColorAttachments> mColorStates;
// Other state // Other state
dawn::PrimitiveTopology mPrimitiveTopology; wgpu::PrimitiveTopology mPrimitiveTopology;
RasterizationStateDescriptor mRasterizationState; RasterizationStateDescriptor mRasterizationState;
uint32_t mSampleMask; uint32_t mSampleMask;
bool mAlphaToCoverageEnabled; bool mAlphaToCoverageEnabled;

View File

@ -47,15 +47,15 @@ namespace dawn_native {
SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag); SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag);
// TODO(cwallez@chromium.org): Store a crypto hash of the items instead? // TODO(cwallez@chromium.org): Store a crypto hash of the items instead?
dawn::AddressMode mAddressModeU; wgpu::AddressMode mAddressModeU;
dawn::AddressMode mAddressModeV; wgpu::AddressMode mAddressModeV;
dawn::AddressMode mAddressModeW; wgpu::AddressMode mAddressModeW;
dawn::FilterMode mMagFilter; wgpu::FilterMode mMagFilter;
dawn::FilterMode mMinFilter; wgpu::FilterMode mMinFilter;
dawn::FilterMode mMipmapFilter; wgpu::FilterMode mMipmapFilter;
float mLodMinClamp; float mLodMinClamp;
float mLodMaxClamp; float mLodMaxClamp;
dawn::CompareFunction mCompareFunction; wgpu::CompareFunction mCompareFunction;
bool mIsBlueprint = false; bool mIsBlueprint = false;
}; };

View File

@ -132,7 +132,7 @@ namespace dawn_native {
} }
if (resources.push_constant_buffers.size() > 0) { if (resources.push_constant_buffers.size() > 0) {
GetDevice()->HandleError(dawn::ErrorType::Validation, GetDevice()->HandleError(wgpu::ErrorType::Validation,
"Push constants aren't supported."); "Push constants aren't supported.");
} }
@ -140,7 +140,7 @@ namespace dawn_native {
auto ExtractResourcesBinding = [this](const spirv_cross::SmallVector<spirv_cross::Resource>& auto ExtractResourcesBinding = [this](const spirv_cross::SmallVector<spirv_cross::Resource>&
resources, resources,
const spirv_cross::Compiler& compiler, const spirv_cross::Compiler& compiler,
dawn::BindingType bindingType) { wgpu::BindingType bindingType) {
for (const auto& resource : resources) { for (const auto& resource : resources) {
ASSERT(compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding)); ASSERT(compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding));
ASSERT( ASSERT(
@ -150,7 +150,7 @@ namespace dawn_native {
uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet); uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
if (binding >= kMaxBindingsPerGroup || set >= kMaxBindGroups) { if (binding >= kMaxBindingsPerGroup || set >= kMaxBindGroups) {
GetDevice()->HandleError(dawn::ErrorType::Validation, GetDevice()->HandleError(wgpu::ErrorType::Validation,
"Binding over limits in the SPIRV"); "Binding over limits in the SPIRV");
continue; continue;
} }
@ -164,12 +164,12 @@ namespace dawn_native {
}; };
ExtractResourcesBinding(resources.uniform_buffers, compiler, ExtractResourcesBinding(resources.uniform_buffers, compiler,
dawn::BindingType::UniformBuffer); wgpu::BindingType::UniformBuffer);
ExtractResourcesBinding(resources.separate_images, compiler, ExtractResourcesBinding(resources.separate_images, compiler,
dawn::BindingType::SampledTexture); wgpu::BindingType::SampledTexture);
ExtractResourcesBinding(resources.separate_samplers, compiler, dawn::BindingType::Sampler); ExtractResourcesBinding(resources.separate_samplers, compiler, wgpu::BindingType::Sampler);
ExtractResourcesBinding(resources.storage_buffers, compiler, ExtractResourcesBinding(resources.storage_buffers, compiler,
dawn::BindingType::StorageBuffer); wgpu::BindingType::StorageBuffer);
// Extract the vertex attributes // Extract the vertex attributes
if (mExecutionModel == SingleShaderStage::Vertex) { if (mExecutionModel == SingleShaderStage::Vertex) {
@ -178,7 +178,7 @@ namespace dawn_native {
uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation); uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation);
if (location >= kMaxVertexAttributes) { if (location >= kMaxVertexAttributes) {
device->HandleError(dawn::ErrorType::Validation, device->HandleError(wgpu::ErrorType::Validation,
"Attribute location over limits in the SPIRV"); "Attribute location over limits in the SPIRV");
return; return;
} }
@ -190,7 +190,7 @@ namespace dawn_native {
// all the location 0, causing a compile error. // all the location 0, causing a compile error.
for (const auto& attrib : resources.stage_outputs) { for (const auto& attrib : resources.stage_outputs) {
if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) { if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
device->HandleError(dawn::ErrorType::Validation, device->HandleError(wgpu::ErrorType::Validation,
"Need location qualifier on vertex output"); "Need location qualifier on vertex output");
return; return;
} }
@ -202,7 +202,7 @@ namespace dawn_native {
// all the location 0, causing a compile error. // all the location 0, causing a compile error.
for (const auto& attrib : resources.stage_inputs) { for (const auto& attrib : resources.stage_inputs) {
if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) { if (!compiler.get_decoration_bitset(attrib.id).get(spv::DecorationLocation)) {
device->HandleError(dawn::ErrorType::Validation, device->HandleError(wgpu::ErrorType::Validation,
"Need location qualifier on fragment input"); "Need location qualifier on fragment input");
return; return;
} }
@ -214,7 +214,7 @@ namespace dawn_native {
uint32_t location = uint32_t location =
compiler.get_decoration(fragmentOutput.id, spv::DecorationLocation); compiler.get_decoration(fragmentOutput.id, spv::DecorationLocation);
if (location >= kMaxColorAttachments) { if (location >= kMaxColorAttachments) {
device->HandleError(dawn::ErrorType::Validation, device->HandleError(wgpu::ErrorType::Validation,
"Fragment output location over limits in the SPIRV"); "Fragment output location over limits in the SPIRV");
return; return;
} }

View File

@ -52,7 +52,7 @@ namespace dawn_native {
// The SPIRV ID of the resource. // The SPIRV ID of the resource.
uint32_t id; uint32_t id;
uint32_t base_type_id; uint32_t base_type_id;
dawn::BindingType type; wgpu::BindingType type;
bool used = false; bool used = false;
}; };
using ModuleBindingInfo = using ModuleBindingInfo =

View File

@ -80,8 +80,8 @@ namespace dawn_native {
return new ErrorSwapChain(device); return new ErrorSwapChain(device);
} }
void SwapChainBase::Configure(dawn::TextureFormat format, void SwapChainBase::Configure(wgpu::TextureFormat format,
dawn::TextureUsage allowedUsage, wgpu::TextureUsage allowedUsage,
uint32_t width, uint32_t width,
uint32_t height) { uint32_t height) {
if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) { if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) {
@ -89,7 +89,7 @@ namespace dawn_native {
} }
ASSERT(!IsError()); ASSERT(!IsError());
allowedUsage |= dawn::TextureUsage::Present; allowedUsage |= wgpu::TextureUsage::Present;
mFormat = format; mFormat = format;
mAllowedUsage = allowedUsage; mAllowedUsage = allowedUsage;
@ -106,7 +106,7 @@ namespace dawn_native {
ASSERT(!IsError()); ASSERT(!IsError());
TextureDescriptor descriptor; TextureDescriptor descriptor;
descriptor.dimension = dawn::TextureDimension::e2D; descriptor.dimension = wgpu::TextureDimension::e2D;
descriptor.size.width = mWidth; descriptor.size.width = mWidth;
descriptor.size.height = mHeight; descriptor.size.height = mHeight;
descriptor.size.depth = 1; descriptor.size.depth = 1;
@ -138,8 +138,8 @@ namespace dawn_native {
return mImplementation; return mImplementation;
} }
MaybeError SwapChainBase::ValidateConfigure(dawn::TextureFormat format, MaybeError SwapChainBase::ValidateConfigure(wgpu::TextureFormat format,
dawn::TextureUsage allowedUsage, wgpu::TextureUsage allowedUsage,
uint32_t width, uint32_t width,
uint32_t height) const { uint32_t height) const {
DAWN_TRY(GetDevice()->ValidateObject(this)); DAWN_TRY(GetDevice()->ValidateObject(this));

View File

@ -35,8 +35,8 @@ namespace dawn_native {
static SwapChainBase* MakeError(DeviceBase* device); static SwapChainBase* MakeError(DeviceBase* device);
// Dawn API // Dawn API
void Configure(dawn::TextureFormat format, void Configure(wgpu::TextureFormat format,
dawn::TextureUsage allowedUsage, wgpu::TextureUsage allowedUsage,
uint32_t width, uint32_t width,
uint32_t height); uint32_t height);
TextureBase* GetNextTexture(); TextureBase* GetNextTexture();
@ -50,16 +50,16 @@ namespace dawn_native {
virtual MaybeError OnBeforePresent(TextureBase* texture) = 0; virtual MaybeError OnBeforePresent(TextureBase* texture) = 0;
private: private:
MaybeError ValidateConfigure(dawn::TextureFormat format, MaybeError ValidateConfigure(wgpu::TextureFormat format,
dawn::TextureUsage allowedUsage, wgpu::TextureUsage allowedUsage,
uint32_t width, uint32_t width,
uint32_t height) const; uint32_t height) const;
MaybeError ValidateGetNextTexture() const; MaybeError ValidateGetNextTexture() const;
MaybeError ValidatePresent(TextureBase* texture) const; MaybeError ValidatePresent(TextureBase* texture) const;
DawnSwapChainImplementation mImplementation = {}; DawnSwapChainImplementation mImplementation = {};
dawn::TextureFormat mFormat = {}; wgpu::TextureFormat mFormat = {};
dawn::TextureUsage mAllowedUsage; wgpu::TextureUsage mAllowedUsage;
uint32_t mWidth = 0; uint32_t mWidth = 0;
uint32_t mHeight = 0; uint32_t mHeight = 0;
TextureBase* mLastNextTexture = nullptr; TextureBase* mLastNextTexture = nullptr;

View File

@ -37,14 +37,14 @@ namespace dawn_native {
// TODO(jiawei.shao@intel.com): support validation on all texture view dimensions // TODO(jiawei.shao@intel.com): support validation on all texture view dimensions
bool IsTextureViewDimensionCompatibleWithTextureDimension( bool IsTextureViewDimensionCompatibleWithTextureDimension(
dawn::TextureViewDimension textureViewDimension, wgpu::TextureViewDimension textureViewDimension,
dawn::TextureDimension textureDimension) { wgpu::TextureDimension textureDimension) {
switch (textureViewDimension) { switch (textureViewDimension) {
case dawn::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:
case dawn::TextureViewDimension::e2DArray: case wgpu::TextureViewDimension::e2DArray:
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return textureDimension == dawn::TextureDimension::e2D; return textureDimension == wgpu::TextureDimension::e2D;
default: default:
UNREACHABLE(); UNREACHABLE();
return false; return false;
@ -53,16 +53,16 @@ namespace dawn_native {
// TODO(jiawei.shao@intel.com): support validation on all texture view dimensions // TODO(jiawei.shao@intel.com): support validation on all texture view dimensions
bool IsArrayLayerValidForTextureViewDimension( bool IsArrayLayerValidForTextureViewDimension(
dawn::TextureViewDimension textureViewDimension, wgpu::TextureViewDimension textureViewDimension,
uint32_t textureViewArrayLayer) { uint32_t textureViewArrayLayer) {
switch (textureViewDimension) { switch (textureViewDimension) {
case dawn::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:
return textureViewArrayLayer == 1u; return textureViewArrayLayer == 1u;
case dawn::TextureViewDimension::e2DArray: case wgpu::TextureViewDimension::e2DArray:
return true; return true;
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
return textureViewArrayLayer == 6u; return textureViewArrayLayer == 6u;
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return textureViewArrayLayer % 6 == 0; return textureViewArrayLayer % 6 == 0;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -71,14 +71,14 @@ namespace dawn_native {
} }
bool IsTextureSizeValidForTextureViewDimension( bool IsTextureSizeValidForTextureViewDimension(
dawn::TextureViewDimension textureViewDimension, wgpu::TextureViewDimension textureViewDimension,
const Extent3D& textureSize) { const Extent3D& textureSize) {
switch (textureViewDimension) { switch (textureViewDimension) {
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return textureSize.width == textureSize.height; return textureSize.width == textureSize.height;
case dawn::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:
case dawn::TextureViewDimension::e2DArray: case wgpu::TextureViewDimension::e2DArray:
return true; return true;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -159,21 +159,21 @@ namespace dawn_native {
MaybeError ValidateTextureUsage(const TextureDescriptor* descriptor, const Format* format) { MaybeError ValidateTextureUsage(const TextureDescriptor* descriptor, const Format* format) {
DAWN_TRY(dawn_native::ValidateTextureUsage(descriptor->usage)); DAWN_TRY(dawn_native::ValidateTextureUsage(descriptor->usage));
constexpr dawn::TextureUsage kValidCompressedUsages = dawn::TextureUsage::Sampled | constexpr wgpu::TextureUsage kValidCompressedUsages = wgpu::TextureUsage::Sampled |
dawn::TextureUsage::CopySrc | wgpu::TextureUsage::CopySrc |
dawn::TextureUsage::CopyDst; wgpu::TextureUsage::CopyDst;
if (format->isCompressed && (descriptor->usage & (~kValidCompressedUsages))) { if (format->isCompressed && (descriptor->usage & (~kValidCompressedUsages))) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"Compressed texture format is incompatible with the texture usage"); "Compressed texture format is incompatible with the texture usage");
} }
if (!format->isRenderable && if (!format->isRenderable &&
(descriptor->usage & dawn::TextureUsage::OutputAttachment)) { (descriptor->usage & wgpu::TextureUsage::OutputAttachment)) {
return DAWN_VALIDATION_ERROR( return DAWN_VALIDATION_ERROR(
"Non-renderable format used with OutputAttachment usage"); "Non-renderable format used with OutputAttachment usage");
} }
if (descriptor->usage & dawn::TextureUsage::Storage) { if (descriptor->usage & wgpu::TextureUsage::Storage) {
return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)"); return DAWN_VALIDATION_ERROR("storage textures aren't supported (yet)");
} }
@ -205,7 +205,7 @@ namespace dawn_native {
return DAWN_VALIDATION_ERROR("Cannot create an empty texture"); return DAWN_VALIDATION_ERROR("Cannot create an empty texture");
} }
if (descriptor->dimension != dawn::TextureDimension::e2D) { if (descriptor->dimension != wgpu::TextureDimension::e2D) {
return DAWN_VALIDATION_ERROR("Texture dimension must be 2D (for now)"); return DAWN_VALIDATION_ERROR("Texture dimension must be 2D (for now)");
} }
@ -228,15 +228,15 @@ namespace dawn_native {
} }
DAWN_TRY(ValidateTextureViewDimension(descriptor->dimension)); DAWN_TRY(ValidateTextureViewDimension(descriptor->dimension));
if (descriptor->dimension == dawn::TextureViewDimension::e1D || if (descriptor->dimension == wgpu::TextureViewDimension::e1D ||
descriptor->dimension == dawn::TextureViewDimension::e3D) { descriptor->dimension == wgpu::TextureViewDimension::e3D) {
return DAWN_VALIDATION_ERROR("Texture view dimension must be 2D compatible."); return DAWN_VALIDATION_ERROR("Texture view dimension must be 2D compatible.");
} }
DAWN_TRY(ValidateTextureFormat(descriptor->format)); DAWN_TRY(ValidateTextureFormat(descriptor->format));
DAWN_TRY(ValidateTextureAspect(descriptor->aspect)); DAWN_TRY(ValidateTextureAspect(descriptor->aspect));
if (descriptor->aspect != dawn::TextureAspect::All) { if (descriptor->aspect != wgpu::TextureAspect::All) {
return DAWN_VALIDATION_ERROR("Texture aspect must be 'all'"); return DAWN_VALIDATION_ERROR("Texture aspect must be 'all'");
} }
@ -273,22 +273,22 @@ namespace dawn_native {
// The default value for the view dimension depends on the texture's dimension with a // The default value for the view dimension depends on the texture's dimension with a
// special case for 2DArray being chosen automatically if arrayLayerCount is unspecified. // special case for 2DArray being chosen automatically if arrayLayerCount is unspecified.
if (desc.dimension == dawn::TextureViewDimension::Undefined) { if (desc.dimension == wgpu::TextureViewDimension::Undefined) {
switch (texture->GetDimension()) { switch (texture->GetDimension()) {
case dawn::TextureDimension::e1D: case wgpu::TextureDimension::e1D:
desc.dimension = dawn::TextureViewDimension::e1D; desc.dimension = wgpu::TextureViewDimension::e1D;
break; break;
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
if (texture->GetArrayLayers() > 1u && desc.arrayLayerCount == 0) { if (texture->GetArrayLayers() > 1u && desc.arrayLayerCount == 0) {
desc.dimension = dawn::TextureViewDimension::e2DArray; desc.dimension = wgpu::TextureViewDimension::e2DArray;
} else { } else {
desc.dimension = dawn::TextureViewDimension::e2D; desc.dimension = wgpu::TextureViewDimension::e2D;
} }
break; break;
case dawn::TextureDimension::e3D: case wgpu::TextureDimension::e3D:
desc.dimension = dawn::TextureViewDimension::e3D; desc.dimension = wgpu::TextureViewDimension::e3D;
break; break;
default: default:
@ -296,7 +296,7 @@ namespace dawn_native {
} }
} }
if (desc.format == dawn::TextureFormat::Undefined) { if (desc.format == wgpu::TextureFormat::Undefined) {
desc.format = texture->GetFormat().format; desc.format = texture->GetFormat().format;
} }
if (desc.arrayLayerCount == 0) { if (desc.arrayLayerCount == 0) {
@ -349,7 +349,7 @@ namespace dawn_native {
return new TextureBase(device, ObjectBase::kError); return new TextureBase(device, ObjectBase::kError);
} }
dawn::TextureDimension TextureBase::GetDimension() const { wgpu::TextureDimension TextureBase::GetDimension() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mDimension; return mDimension;
} }
@ -375,7 +375,7 @@ namespace dawn_native {
ASSERT(!IsError()); ASSERT(!IsError());
return mSampleCount; return mSampleCount;
} }
dawn::TextureUsage TextureBase::GetUsage() const { wgpu::TextureUsage TextureBase::GetUsage() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mUsage; return mUsage;
} }
@ -527,7 +527,7 @@ namespace dawn_native {
return mFormat; return mFormat;
} }
dawn::TextureViewDimension TextureViewBase::GetDimension() const { wgpu::TextureViewDimension TextureViewBase::GetDimension() const {
ASSERT(!IsError()); ASSERT(!IsError());
return mDimension; return mDimension;
} }

View File

@ -34,12 +34,12 @@ namespace dawn_native {
bool IsValidSampleCount(uint32_t sampleCount); bool IsValidSampleCount(uint32_t sampleCount);
static constexpr dawn::TextureUsage kReadOnlyTextureUsages = static constexpr wgpu::TextureUsage kReadOnlyTextureUsages =
dawn::TextureUsage::CopySrc | dawn::TextureUsage::Sampled | dawn::TextureUsage::Present; wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Present;
static constexpr dawn::TextureUsage kWritableTextureUsages = static constexpr wgpu::TextureUsage kWritableTextureUsages =
dawn::TextureUsage::CopyDst | dawn::TextureUsage::Storage | wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Storage |
dawn::TextureUsage::OutputAttachment; wgpu::TextureUsage::OutputAttachment;
class TextureBase : public ObjectBase { class TextureBase : public ObjectBase {
public: public:
@ -49,13 +49,13 @@ namespace dawn_native {
static TextureBase* MakeError(DeviceBase* device); static TextureBase* MakeError(DeviceBase* device);
dawn::TextureDimension GetDimension() const; wgpu::TextureDimension GetDimension() const;
const Format& GetFormat() const; const Format& GetFormat() const;
const Extent3D& GetSize() const; const Extent3D& GetSize() const;
uint32_t GetArrayLayers() const; uint32_t GetArrayLayers() const;
uint32_t GetNumMipLevels() const; uint32_t GetNumMipLevels() const;
uint32_t GetSampleCount() const; uint32_t GetSampleCount() const;
dawn::TextureUsage GetUsage() const; wgpu::TextureUsage GetUsage() const;
TextureState GetTextureState() const; TextureState GetTextureState() const;
uint32_t GetSubresourceIndex(uint32_t mipLevel, uint32_t arraySlice) const; uint32_t GetSubresourceIndex(uint32_t mipLevel, uint32_t arraySlice) const;
bool IsSubresourceContentInitialized(uint32_t baseMipLevel, bool IsSubresourceContentInitialized(uint32_t baseMipLevel,
@ -92,14 +92,14 @@ namespace dawn_native {
virtual void DestroyImpl(); virtual void DestroyImpl();
MaybeError ValidateDestroy() const; MaybeError ValidateDestroy() const;
dawn::TextureDimension mDimension; wgpu::TextureDimension mDimension;
// TODO(cwallez@chromium.org): This should be deduplicated in the Device // TODO(cwallez@chromium.org): This should be deduplicated in the Device
const Format& mFormat; const Format& mFormat;
Extent3D mSize; Extent3D mSize;
uint32_t mArrayLayerCount; uint32_t mArrayLayerCount;
uint32_t mMipLevelCount; uint32_t mMipLevelCount;
uint32_t mSampleCount; uint32_t mSampleCount;
dawn::TextureUsage mUsage = dawn::TextureUsage::None; wgpu::TextureUsage mUsage = wgpu::TextureUsage::None;
TextureState mState; TextureState mState;
// TODO(natlee@microsoft.com): Use a more optimized data structure to save space // TODO(natlee@microsoft.com): Use a more optimized data structure to save space
@ -116,7 +116,7 @@ namespace dawn_native {
TextureBase* GetTexture(); TextureBase* GetTexture();
const Format& GetFormat() const; const Format& GetFormat() const;
dawn::TextureViewDimension GetDimension() const; wgpu::TextureViewDimension GetDimension() const;
uint32_t GetBaseMipLevel() const; uint32_t GetBaseMipLevel() const;
uint32_t GetLevelCount() const; uint32_t GetLevelCount() const;
uint32_t GetBaseArrayLayer() const; uint32_t GetBaseArrayLayer() const;
@ -129,7 +129,7 @@ namespace dawn_native {
// TODO(cwallez@chromium.org): This should be deduplicated in the Device // TODO(cwallez@chromium.org): This should be deduplicated in the Device
const Format& mFormat; const Format& mFormat;
dawn::TextureViewDimension mDimension; wgpu::TextureViewDimension mDimension;
uint32_t mBaseMipLevel; uint32_t mBaseMipLevel;
uint32_t mMipLevelCount; uint32_t mMipLevelCount;
uint32_t mBaseArrayLayer; uint32_t mBaseArrayLayer;

View File

@ -49,7 +49,7 @@ namespace dawn_native { namespace d3d12 {
} }
switch (layout.types[bindingIndex]) { switch (layout.types[bindingIndex]) {
case dawn::BindingType::UniformBuffer: { case wgpu::BindingType::UniformBuffer: {
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex); BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
D3D12_CONSTANT_BUFFER_VIEW_DESC desc; D3D12_CONSTANT_BUFFER_VIEW_DESC desc;
@ -62,7 +62,7 @@ namespace dawn_native { namespace d3d12 {
&desc, cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset + &desc, cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; } break;
case dawn::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex); BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
// Since SPIRV-Cross outputs HLSL shaders with RWByteAddressBuffer, // Since SPIRV-Cross outputs HLSL shaders with RWByteAddressBuffer,
@ -86,7 +86,7 @@ namespace dawn_native { namespace d3d12 {
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset + cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; } break;
case dawn::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
auto* view = ToBackend(GetBindingAsTextureView(bindingIndex)); auto* view = ToBackend(GetBindingAsTextureView(bindingIndex));
auto& srv = view->GetSRVDescriptor(); auto& srv = view->GetSRVDescriptor();
d3d12Device->CreateShaderResourceView( d3d12Device->CreateShaderResourceView(
@ -94,7 +94,7 @@ namespace dawn_native { namespace d3d12 {
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset + cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; } break;
case dawn::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
auto* sampler = ToBackend(GetBindingAsSampler(bindingIndex)); auto* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
auto& samplerDesc = sampler->GetSamplerDescriptor(); auto& samplerDesc = sampler->GetSamplerDescriptor();
d3d12Device->CreateSampler( d3d12Device->CreateSampler(
@ -102,8 +102,8 @@ namespace dawn_native { namespace d3d12 {
bindingOffsets[bindingIndex])); bindingOffsets[bindingIndex]));
} break; } break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;

View File

@ -32,21 +32,21 @@ namespace dawn_native { namespace d3d12 {
} }
switch (groupInfo.types[binding]) { switch (groupInfo.types[binding]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
mBindingOffsets[binding] = mDescriptorCounts[CBV]++; mBindingOffsets[binding] = mDescriptorCounts[CBV]++;
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
mBindingOffsets[binding] = mDescriptorCounts[UAV]++; mBindingOffsets[binding] = mDescriptorCounts[UAV]++;
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
mBindingOffsets[binding] = mDescriptorCounts[SRV]++; mBindingOffsets[binding] = mDescriptorCounts[SRV]++;
break; break;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
mBindingOffsets[binding] = mDescriptorCounts[Sampler]++; mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
} }
@ -99,14 +99,14 @@ namespace dawn_native { namespace d3d12 {
// Root descriptor needs to set this value to set correct register number in // Root descriptor needs to set this value to set correct register number in
// generated HLSL shader. // generated HLSL shader.
switch (groupInfo.types[binding]) { switch (groupInfo.types[binding]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
mBindingOffsets[binding] = baseRegister++; mBindingOffsets[binding] = baseRegister++;
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
} }
@ -114,21 +114,21 @@ namespace dawn_native { namespace d3d12 {
} }
switch (groupInfo.types[binding]) { switch (groupInfo.types[binding]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
mBindingOffsets[binding] += descriptorOffsets[CBV]; mBindingOffsets[binding] += descriptorOffsets[CBV];
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
mBindingOffsets[binding] += descriptorOffsets[UAV]; mBindingOffsets[binding] += descriptorOffsets[UAV];
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
mBindingOffsets[binding] += descriptorOffsets[SRV]; mBindingOffsets[binding] += descriptorOffsets[SRV];
break; break;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
mBindingOffsets[binding] += descriptorOffsets[Sampler]; mBindingOffsets[binding] += descriptorOffsets[Sampler];
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;

View File

@ -24,45 +24,45 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
namespace { namespace {
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::BufferUsage usage) { D3D12_RESOURCE_FLAGS D3D12ResourceFlags(wgpu::BufferUsage usage) {
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE; D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
if (usage & dawn::BufferUsage::Storage) { if (usage & wgpu::BufferUsage::Storage) {
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
} }
return flags; return flags;
} }
D3D12_RESOURCE_STATES D3D12BufferUsage(dawn::BufferUsage usage) { D3D12_RESOURCE_STATES D3D12BufferUsage(wgpu::BufferUsage usage) {
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON; D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
if (usage & dawn::BufferUsage::CopySrc) { if (usage & wgpu::BufferUsage::CopySrc) {
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE; resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
} }
if (usage & dawn::BufferUsage::CopyDst) { if (usage & wgpu::BufferUsage::CopyDst) {
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST; resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
} }
if (usage & (dawn::BufferUsage::Vertex | dawn::BufferUsage::Uniform)) { if (usage & (wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Uniform)) {
resourceState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER; resourceState |= D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER;
} }
if (usage & dawn::BufferUsage::Index) { if (usage & wgpu::BufferUsage::Index) {
resourceState |= D3D12_RESOURCE_STATE_INDEX_BUFFER; resourceState |= D3D12_RESOURCE_STATE_INDEX_BUFFER;
} }
if (usage & dawn::BufferUsage::Storage) { if (usage & wgpu::BufferUsage::Storage) {
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS; resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
} }
if (usage & dawn::BufferUsage::Indirect) { if (usage & wgpu::BufferUsage::Indirect) {
resourceState |= D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT; resourceState |= D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT;
} }
return resourceState; return resourceState;
} }
D3D12_HEAP_TYPE D3D12HeapType(dawn::BufferUsage allowedUsage) { D3D12_HEAP_TYPE D3D12HeapType(wgpu::BufferUsage allowedUsage) {
if (allowedUsage & dawn::BufferUsage::MapRead) { if (allowedUsage & wgpu::BufferUsage::MapRead) {
return D3D12_HEAP_TYPE_READBACK; return D3D12_HEAP_TYPE_READBACK;
} else if (allowedUsage & dawn::BufferUsage::MapWrite) { } else if (allowedUsage & wgpu::BufferUsage::MapWrite) {
return D3D12_HEAP_TYPE_UPLOAD; return D3D12_HEAP_TYPE_UPLOAD;
} else { } else {
return D3D12_HEAP_TYPE_DEFAULT; return D3D12_HEAP_TYPE_DEFAULT;
@ -88,7 +88,7 @@ namespace dawn_native { namespace d3d12 {
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR; resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped // Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
// and robust resource initialization. // and robust resource initialization.
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage() | dawn::BufferUsage::CopyDst); resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage() | wgpu::BufferUsage::CopyDst);
auto heapType = D3D12HeapType(GetUsage()); auto heapType = D3D12HeapType(GetUsage());
auto bufferUsage = D3D12_RESOURCE_STATE_COMMON; auto bufferUsage = D3D12_RESOURCE_STATE_COMMON;
@ -98,7 +98,7 @@ namespace dawn_native { namespace d3d12 {
if (heapType == D3D12_HEAP_TYPE_READBACK) { if (heapType == D3D12_HEAP_TYPE_READBACK) {
bufferUsage |= D3D12_RESOURCE_STATE_COPY_DEST; bufferUsage |= D3D12_RESOURCE_STATE_COPY_DEST;
mFixedResourceState = true; mFixedResourceState = true;
mLastUsage = dawn::BufferUsage::CopyDst; mLastUsage = wgpu::BufferUsage::CopyDst;
} }
// D3D12 requires buffers on the UPLOAD heap to have the D3D12_RESOURCE_STATE_GENERIC_READ // D3D12 requires buffers on the UPLOAD heap to have the D3D12_RESOURCE_STATE_GENERIC_READ
@ -106,7 +106,7 @@ namespace dawn_native { namespace d3d12 {
if (heapType == D3D12_HEAP_TYPE_UPLOAD) { if (heapType == D3D12_HEAP_TYPE_UPLOAD) {
bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ; bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ;
mFixedResourceState = true; mFixedResourceState = true;
mLastUsage = dawn::BufferUsage::CopySrc; mLastUsage = wgpu::BufferUsage::CopySrc;
} }
DAWN_TRY_ASSIGN( DAWN_TRY_ASSIGN(
@ -133,7 +133,7 @@ namespace dawn_native { namespace d3d12 {
// cause subsequent errors. // cause subsequent errors.
bool Buffer::TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext, bool Buffer::TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
D3D12_RESOURCE_BARRIER* barrier, D3D12_RESOURCE_BARRIER* barrier,
dawn::BufferUsage newUsage) { wgpu::BufferUsage newUsage) {
// Resources in upload and readback heaps must be kept in the COPY_SOURCE/DEST state // Resources in upload and readback heaps must be kept in the COPY_SOURCE/DEST state
if (mFixedResourceState) { if (mFixedResourceState) {
ASSERT(mLastUsage == newUsage); ASSERT(mLastUsage == newUsage);
@ -204,7 +204,7 @@ namespace dawn_native { namespace d3d12 {
} }
void Buffer::TransitionUsageNow(CommandRecordingContext* commandContext, void Buffer::TransitionUsageNow(CommandRecordingContext* commandContext,
dawn::BufferUsage usage) { wgpu::BufferUsage usage) {
D3D12_RESOURCE_BARRIER barrier; D3D12_RESOURCE_BARRIER barrier;
if (TransitionUsageAndGetResourceBarrier(commandContext, &barrier, usage)) { if (TransitionUsageAndGetResourceBarrier(commandContext, &barrier, usage)) {
@ -226,7 +226,7 @@ namespace dawn_native { namespace d3d12 {
bool Buffer::IsMapWritable() const { bool Buffer::IsMapWritable() const {
// TODO(enga): Handle CPU-visible memory on UMA // TODO(enga): Handle CPU-visible memory on UMA
return (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0; return (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0;
} }
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) { MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {

View File

@ -39,8 +39,8 @@ namespace dawn_native { namespace d3d12 {
void OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite); void OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite);
bool TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext, bool TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
D3D12_RESOURCE_BARRIER* barrier, D3D12_RESOURCE_BARRIER* barrier,
dawn::BufferUsage newUsage); wgpu::BufferUsage newUsage);
void TransitionUsageNow(CommandRecordingContext* commandContext, dawn::BufferUsage usage); void TransitionUsageNow(CommandRecordingContext* commandContext, wgpu::BufferUsage usage);
private: private:
// Dawn API // Dawn API
@ -54,7 +54,7 @@ namespace dawn_native { namespace d3d12 {
ResourceHeapAllocation mResourceAllocation; ResourceHeapAllocation mResourceAllocation;
bool mFixedResourceState = false; bool mFixedResourceState = false;
dawn::BufferUsage mLastUsage = dawn::BufferUsage::None; wgpu::BufferUsage mLastUsage = wgpu::BufferUsage::None;
Serial mLastUsedSerial = UINT64_MAX; Serial mLastUsedSerial = UINT64_MAX;
D3D12_RANGE mWrittenMappedRange; D3D12_RANGE mWrittenMappedRange;
}; };

View File

@ -40,11 +40,11 @@ namespace dawn_native { namespace d3d12 {
namespace { namespace {
DXGI_FORMAT DXGIIndexFormat(dawn::IndexFormat format) { DXGI_FORMAT DXGIIndexFormat(wgpu::IndexFormat format) {
switch (format) { switch (format) {
case dawn::IndexFormat::Uint16: case wgpu::IndexFormat::Uint16:
return DXGI_FORMAT_R16_UINT; return DXGI_FORMAT_R16_UINT;
case dawn::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return DXGI_FORMAT_R32_UINT; return DXGI_FORMAT_R32_UINT;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -149,21 +149,21 @@ namespace dawn_native { namespace d3d12 {
if (mInCompute) { if (mInCompute) {
for (uint32_t index : IterateBitSet(mBindGroupLayoutsMask)) { for (uint32_t index : IterateBitSet(mBindGroupLayoutsMask)) {
for (uint32_t binding : IterateBitSet(mBuffersNeedingBarrier[index])) { for (uint32_t binding : IterateBitSet(mBuffersNeedingBarrier[index])) {
dawn::BindingType bindingType = mBindingTypes[index][binding]; wgpu::BindingType bindingType = mBindingTypes[index][binding];
switch (bindingType) { switch (bindingType) {
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
ToBackend(mBuffers[index][binding]) ToBackend(mBuffers[index][binding])
->TransitionUsageNow(commandContext, ->TransitionUsageNow(commandContext,
dawn::BufferUsage::Storage); wgpu::BufferUsage::Storage);
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
// Not implemented. // Not implemented.
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
// Don't require barriers. // Don't require barriers.
default: default:
@ -224,7 +224,7 @@ namespace dawn_native { namespace d3d12 {
ToBackend(binding.buffer)->GetVA() + offset; ToBackend(binding.buffer)->GetVA() + offset;
switch (layout.types[bindingIndex]) { switch (layout.types[bindingIndex]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
if (mInCompute) { if (mInCompute) {
commandList->SetComputeRootConstantBufferView(parameterIndex, commandList->SetComputeRootConstantBufferView(parameterIndex,
bufferLocation); bufferLocation);
@ -233,7 +233,7 @@ namespace dawn_native { namespace d3d12 {
bufferLocation); bufferLocation);
} }
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
if (mInCompute) { if (mInCompute) {
commandList->SetComputeRootUnorderedAccessView(parameterIndex, commandList->SetComputeRootUnorderedAccessView(parameterIndex,
bufferLocation); bufferLocation);
@ -242,10 +242,10 @@ namespace dawn_native { namespace d3d12 {
bufferLocation); bufferLocation);
} }
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
} }
@ -619,7 +619,7 @@ namespace dawn_native { namespace d3d12 {
// Clear textures that are not output attachments. Output attachments will be // Clear textures that are not output attachments. Output attachments will be
// cleared during record render pass if the texture subresource has not been // cleared during record render pass if the texture subresource has not been
// initialized before the render pass. // initialized before the render pass.
if (!(usages.textureUsages[i] & dawn::TextureUsage::OutputAttachment)) { if (!(usages.textureUsages[i] & wgpu::TextureUsage::OutputAttachment)) {
texture->EnsureSubresourceContentInitialized(commandContext, 0, texture->EnsureSubresourceContentInitialized(commandContext, 0,
texture->GetNumMipLevels(), 0, texture->GetNumMipLevels(), 0,
texture->GetArrayLayers()); texture->GetArrayLayers());
@ -673,8 +673,8 @@ namespace dawn_native { namespace d3d12 {
Buffer* srcBuffer = ToBackend(copy->source.Get()); Buffer* srcBuffer = ToBackend(copy->source.Get());
Buffer* dstBuffer = ToBackend(copy->destination.Get()); Buffer* dstBuffer = ToBackend(copy->destination.Get());
srcBuffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopySrc); srcBuffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopySrc);
dstBuffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopyDst); dstBuffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopyDst);
commandList->CopyBufferRegion( commandList->CopyBufferRegion(
dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset, dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset,
@ -696,8 +696,8 @@ namespace dawn_native { namespace d3d12 {
copy->destination.arrayLayer, 1); copy->destination.arrayLayer, 1);
} }
buffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopySrc); buffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopySrc);
texture->TransitionUsageNow(commandContext, dawn::TextureUsage::CopyDst); texture->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopyDst);
auto copySplit = ComputeTextureCopySplit( auto copySplit = ComputeTextureCopySplit(
copy->destination.origin, copy->copySize, texture->GetFormat(), copy->destination.origin, copy->copySize, texture->GetFormat(),
@ -731,8 +731,8 @@ namespace dawn_native { namespace d3d12 {
texture->EnsureSubresourceContentInitialized( texture->EnsureSubresourceContentInitialized(
commandContext, copy->source.mipLevel, 1, copy->source.arrayLayer, 1); commandContext, copy->source.mipLevel, 1, copy->source.arrayLayer, 1);
texture->TransitionUsageNow(commandContext, dawn::TextureUsage::CopySrc); texture->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopySrc);
buffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopyDst); buffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopyDst);
TextureCopySplit copySplit = ComputeTextureCopySplit( TextureCopySplit copySplit = ComputeTextureCopySplit(
copy->source.origin, copy->copySize, texture->GetFormat(), copy->source.origin, copy->copySize, texture->GetFormat(),
@ -778,8 +778,8 @@ namespace dawn_native { namespace d3d12 {
commandContext, copy->destination.mipLevel, 1, commandContext, copy->destination.mipLevel, 1,
copy->destination.arrayLayer, 1); copy->destination.arrayLayer, 1);
} }
source->TransitionUsageNow(commandContext, dawn::TextureUsage::CopySrc); source->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopySrc);
destination->TransitionUsageNow(commandContext, dawn::TextureUsage::CopyDst); destination->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopyDst);
if (CanUseCopyResource(source->GetNumMipLevels(), source->GetSize(), if (CanUseCopyResource(source->GetNumMipLevels(), source->GetSize(),
destination->GetSize(), copy->copySize)) { destination->GetSize(), copy->copySize)) {
@ -928,8 +928,8 @@ namespace dawn_native { namespace d3d12 {
// Load op - color // Load op - color
ASSERT(view->GetLevelCount() == 1); ASSERT(view->GetLevelCount() == 1);
ASSERT(view->GetLayerCount() == 1); ASSERT(view->GetLayerCount() == 1);
if (attachmentInfo.loadOp == dawn::LoadOp::Clear || if (attachmentInfo.loadOp == wgpu::LoadOp::Clear ||
(attachmentInfo.loadOp == dawn::LoadOp::Load && (attachmentInfo.loadOp == wgpu::LoadOp::Load &&
!view->GetTexture()->IsSubresourceContentInitialized( !view->GetTexture()->IsSubresourceContentInitialized(
view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1))) { view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1))) {
D3D12_CPU_DESCRIPTOR_HANDLE handle = args.RTVs[i]; D3D12_CPU_DESCRIPTOR_HANDLE handle = args.RTVs[i];
@ -949,12 +949,12 @@ namespace dawn_native { namespace d3d12 {
} }
switch (attachmentInfo.storeOp) { switch (attachmentInfo.storeOp) {
case dawn::StoreOp::Store: { case wgpu::StoreOp::Store: {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
true, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1); true, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
} break; } break;
case dawn::StoreOp::Clear: { case wgpu::StoreOp::Clear: {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
false, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1); false, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
} break; } break;
@ -974,9 +974,9 @@ namespace dawn_native { namespace d3d12 {
// Load op - depth/stencil // Load op - depth/stencil
bool doDepthClear = texture->GetFormat().HasDepth() && bool doDepthClear = texture->GetFormat().HasDepth() &&
(attachmentInfo.depthLoadOp == dawn::LoadOp::Clear); (attachmentInfo.depthLoadOp == wgpu::LoadOp::Clear);
bool doStencilClear = texture->GetFormat().HasStencil() && bool doStencilClear = texture->GetFormat().HasStencil() &&
(attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear); (attachmentInfo.stencilLoadOp == wgpu::LoadOp::Clear);
D3D12_CLEAR_FLAGS clearFlags = {}; D3D12_CLEAR_FLAGS clearFlags = {};
if (doDepthClear) { if (doDepthClear) {
@ -991,12 +991,12 @@ namespace dawn_native { namespace d3d12 {
view->GetBaseMipLevel(), view->GetLevelCount(), view->GetBaseArrayLayer(), view->GetBaseMipLevel(), view->GetLevelCount(), view->GetBaseArrayLayer(),
view->GetLayerCount())) { view->GetLayerCount())) {
if (texture->GetFormat().HasDepth() && if (texture->GetFormat().HasDepth() &&
attachmentInfo.depthLoadOp == dawn::LoadOp::Load) { attachmentInfo.depthLoadOp == wgpu::LoadOp::Load) {
clearDepth = 0.0f; clearDepth = 0.0f;
clearFlags |= D3D12_CLEAR_FLAG_DEPTH; clearFlags |= D3D12_CLEAR_FLAG_DEPTH;
} }
if (texture->GetFormat().HasStencil() && if (texture->GetFormat().HasStencil() &&
attachmentInfo.stencilLoadOp == dawn::LoadOp::Load) { attachmentInfo.stencilLoadOp == wgpu::LoadOp::Load) {
clearStencil = 0u; clearStencil = 0u;
clearFlags |= D3D12_CLEAR_FLAG_STENCIL; clearFlags |= D3D12_CLEAR_FLAG_STENCIL;
} }
@ -1008,13 +1008,13 @@ namespace dawn_native { namespace d3d12 {
0, nullptr); 0, nullptr);
} }
if (attachmentInfo.depthStoreOp == dawn::StoreOp::Store && if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Store &&
attachmentInfo.stencilStoreOp == dawn::StoreOp::Store) { attachmentInfo.stencilStoreOp == wgpu::StoreOp::Store) {
texture->SetIsSubresourceContentInitialized( texture->SetIsSubresourceContentInitialized(
true, view->GetBaseMipLevel(), view->GetLevelCount(), true, view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount()); view->GetBaseArrayLayer(), view->GetLayerCount());
} else if (attachmentInfo.depthStoreOp == dawn::StoreOp::Clear && } else if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Clear &&
attachmentInfo.stencilStoreOp == dawn::StoreOp::Clear) { attachmentInfo.stencilStoreOp == wgpu::StoreOp::Clear) {
texture->SetIsSubresourceContentInitialized( texture->SetIsSubresourceContentInitialized(
false, view->GetBaseMipLevel(), view->GetLevelCount(), false, view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount()); view->GetBaseArrayLayer(), view->GetLayerCount());

View File

@ -304,7 +304,7 @@ namespace dawn_native { namespace d3d12 {
DAWN_TRY_ASSIGN(commandRecordingContext, GetPendingCommandContext()); DAWN_TRY_ASSIGN(commandRecordingContext, GetPendingCommandContext());
ToBackend(destination) ToBackend(destination)
->TransitionUsageNow(commandRecordingContext, dawn::BufferUsage::CopyDst); ->TransitionUsageNow(commandRecordingContext, wgpu::BufferUsage::CopyDst);
commandRecordingContext->GetCommandList()->CopyBufferRegion( commandRecordingContext->GetCommandList()->CopyBufferRegion(
ToBackend(destination)->GetD3D12Resource().Get(), destinationOffset, ToBackend(destination)->GetD3D12Resource().Get(), destinationOffset,

View File

@ -113,8 +113,8 @@ namespace dawn_native { namespace d3d12 {
return DAWN_SWAP_CHAIN_NO_ERROR; return DAWN_SWAP_CHAIN_NO_ERROR;
} }
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const { wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
return dawn::TextureFormat::RGBA8Unorm; return wgpu::TextureFormat::RGBA8Unorm;
} }
}} // namespace dawn_native::d3d12 }} // namespace dawn_native::d3d12

View File

@ -41,7 +41,7 @@ namespace dawn_native { namespace d3d12 {
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture); DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
DawnSwapChainError Present(); DawnSwapChainError Present();
dawn::TextureFormat GetPreferredFormat() const; wgpu::TextureFormat GetPreferredFormat() const;
private: private:
HWND mWindow = nullptr; HWND mWindow = nullptr;

View File

@ -25,14 +25,14 @@ using Microsoft::WRL::ComPtr;
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
namespace { namespace {
D3D12_SHADER_VISIBILITY ShaderVisibilityType(dawn::ShaderStage visibility) { D3D12_SHADER_VISIBILITY ShaderVisibilityType(wgpu::ShaderStage visibility) {
ASSERT(visibility != dawn::ShaderStage::None); ASSERT(visibility != wgpu::ShaderStage::None);
if (visibility == dawn::ShaderStage::Vertex) { if (visibility == wgpu::ShaderStage::Vertex) {
return D3D12_SHADER_VISIBILITY_VERTEX; return D3D12_SHADER_VISIBILITY_VERTEX;
} }
if (visibility == dawn::ShaderStage::Fragment) { if (visibility == wgpu::ShaderStage::Fragment) {
return D3D12_SHADER_VISIBILITY_PIXEL; return D3D12_SHADER_VISIBILITY_PIXEL;
} }
@ -40,16 +40,16 @@ namespace dawn_native { namespace d3d12 {
return D3D12_SHADER_VISIBILITY_ALL; return D3D12_SHADER_VISIBILITY_ALL;
} }
D3D12_ROOT_PARAMETER_TYPE RootParameterType(dawn::BindingType type) { D3D12_ROOT_PARAMETER_TYPE RootParameterType(wgpu::BindingType type) {
switch (type) { switch (type) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
return D3D12_ROOT_PARAMETER_TYPE_CBV; return D3D12_ROOT_PARAMETER_TYPE_CBV;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
return D3D12_ROOT_PARAMETER_TYPE_UAV; return D3D12_ROOT_PARAMETER_TYPE_UAV;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
} }
} }

View File

@ -28,95 +28,95 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
namespace { namespace {
DXGI_FORMAT VertexFormatType(dawn::VertexFormat format) { DXGI_FORMAT VertexFormatType(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case dawn::VertexFormat::UChar2: case wgpu::VertexFormat::UChar2:
return DXGI_FORMAT_R8G8_UINT; return DXGI_FORMAT_R8G8_UINT;
case dawn::VertexFormat::UChar4: case wgpu::VertexFormat::UChar4:
return DXGI_FORMAT_R8G8B8A8_UINT; return DXGI_FORMAT_R8G8B8A8_UINT;
case dawn::VertexFormat::Char2: case wgpu::VertexFormat::Char2:
return DXGI_FORMAT_R8G8_SINT; return DXGI_FORMAT_R8G8_SINT;
case dawn::VertexFormat::Char4: case wgpu::VertexFormat::Char4:
return DXGI_FORMAT_R8G8B8A8_SINT; return DXGI_FORMAT_R8G8B8A8_SINT;
case dawn::VertexFormat::UChar2Norm: case wgpu::VertexFormat::UChar2Norm:
return DXGI_FORMAT_R8G8_UNORM; return DXGI_FORMAT_R8G8_UNORM;
case dawn::VertexFormat::UChar4Norm: case wgpu::VertexFormat::UChar4Norm:
return DXGI_FORMAT_R8G8B8A8_UNORM; return DXGI_FORMAT_R8G8B8A8_UNORM;
case dawn::VertexFormat::Char2Norm: case wgpu::VertexFormat::Char2Norm:
return DXGI_FORMAT_R8G8_SNORM; return DXGI_FORMAT_R8G8_SNORM;
case dawn::VertexFormat::Char4Norm: case wgpu::VertexFormat::Char4Norm:
return DXGI_FORMAT_R8G8B8A8_SNORM; return DXGI_FORMAT_R8G8B8A8_SNORM;
case dawn::VertexFormat::UShort2: case wgpu::VertexFormat::UShort2:
return DXGI_FORMAT_R16G16_UINT; return DXGI_FORMAT_R16G16_UINT;
case dawn::VertexFormat::UShort4: case wgpu::VertexFormat::UShort4:
return DXGI_FORMAT_R16G16B16A16_UINT; return DXGI_FORMAT_R16G16B16A16_UINT;
case dawn::VertexFormat::Short2: case wgpu::VertexFormat::Short2:
return DXGI_FORMAT_R16G16_SINT; return DXGI_FORMAT_R16G16_SINT;
case dawn::VertexFormat::Short4: case wgpu::VertexFormat::Short4:
return DXGI_FORMAT_R16G16B16A16_SINT; return DXGI_FORMAT_R16G16B16A16_SINT;
case dawn::VertexFormat::UShort2Norm: case wgpu::VertexFormat::UShort2Norm:
return DXGI_FORMAT_R16G16_UNORM; return DXGI_FORMAT_R16G16_UNORM;
case dawn::VertexFormat::UShort4Norm: case wgpu::VertexFormat::UShort4Norm:
return DXGI_FORMAT_R16G16B16A16_UNORM; return DXGI_FORMAT_R16G16B16A16_UNORM;
case dawn::VertexFormat::Short2Norm: case wgpu::VertexFormat::Short2Norm:
return DXGI_FORMAT_R16G16_SNORM; return DXGI_FORMAT_R16G16_SNORM;
case dawn::VertexFormat::Short4Norm: case wgpu::VertexFormat::Short4Norm:
return DXGI_FORMAT_R16G16B16A16_SNORM; return DXGI_FORMAT_R16G16B16A16_SNORM;
case dawn::VertexFormat::Half2: case wgpu::VertexFormat::Half2:
return DXGI_FORMAT_R16G16_FLOAT; return DXGI_FORMAT_R16G16_FLOAT;
case dawn::VertexFormat::Half4: case wgpu::VertexFormat::Half4:
return DXGI_FORMAT_R16G16B16A16_FLOAT; return DXGI_FORMAT_R16G16B16A16_FLOAT;
case dawn::VertexFormat::Float: case wgpu::VertexFormat::Float:
return DXGI_FORMAT_R32_FLOAT; return DXGI_FORMAT_R32_FLOAT;
case dawn::VertexFormat::Float2: case wgpu::VertexFormat::Float2:
return DXGI_FORMAT_R32G32_FLOAT; return DXGI_FORMAT_R32G32_FLOAT;
case dawn::VertexFormat::Float3: case wgpu::VertexFormat::Float3:
return DXGI_FORMAT_R32G32B32_FLOAT; return DXGI_FORMAT_R32G32B32_FLOAT;
case dawn::VertexFormat::Float4: case wgpu::VertexFormat::Float4:
return DXGI_FORMAT_R32G32B32A32_FLOAT; return DXGI_FORMAT_R32G32B32A32_FLOAT;
case dawn::VertexFormat::UInt: case wgpu::VertexFormat::UInt:
return DXGI_FORMAT_R32_UINT; return DXGI_FORMAT_R32_UINT;
case dawn::VertexFormat::UInt2: case wgpu::VertexFormat::UInt2:
return DXGI_FORMAT_R32G32_UINT; return DXGI_FORMAT_R32G32_UINT;
case dawn::VertexFormat::UInt3: case wgpu::VertexFormat::UInt3:
return DXGI_FORMAT_R32G32B32_UINT; return DXGI_FORMAT_R32G32B32_UINT;
case dawn::VertexFormat::UInt4: case wgpu::VertexFormat::UInt4:
return DXGI_FORMAT_R32G32B32A32_UINT; return DXGI_FORMAT_R32G32B32A32_UINT;
case dawn::VertexFormat::Int: case wgpu::VertexFormat::Int:
return DXGI_FORMAT_R32_SINT; return DXGI_FORMAT_R32_SINT;
case dawn::VertexFormat::Int2: case wgpu::VertexFormat::Int2:
return DXGI_FORMAT_R32G32_SINT; return DXGI_FORMAT_R32G32_SINT;
case dawn::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
return DXGI_FORMAT_R32G32B32_SINT; return DXGI_FORMAT_R32G32B32_SINT;
case dawn::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return DXGI_FORMAT_R32G32B32A32_SINT; return DXGI_FORMAT_R32G32B32A32_SINT;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
D3D12_INPUT_CLASSIFICATION InputStepModeFunction(dawn::InputStepMode mode) { D3D12_INPUT_CLASSIFICATION InputStepModeFunction(wgpu::InputStepMode mode) {
switch (mode) { switch (mode) {
case dawn::InputStepMode::Vertex: case wgpu::InputStepMode::Vertex:
return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA; return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
case dawn::InputStepMode::Instance: case wgpu::InputStepMode::Instance:
return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA; return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
D3D12_PRIMITIVE_TOPOLOGY D3D12PrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) { D3D12_PRIMITIVE_TOPOLOGY D3D12PrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) { switch (primitiveTopology) {
case dawn::PrimitiveTopology::PointList: case wgpu::PrimitiveTopology::PointList:
return D3D_PRIMITIVE_TOPOLOGY_POINTLIST; return D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
case dawn::PrimitiveTopology::LineList: case wgpu::PrimitiveTopology::LineList:
return D3D_PRIMITIVE_TOPOLOGY_LINELIST; return D3D_PRIMITIVE_TOPOLOGY_LINELIST;
case dawn::PrimitiveTopology::LineStrip: case wgpu::PrimitiveTopology::LineStrip:
return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP; return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP;
case dawn::PrimitiveTopology::TriangleList: case wgpu::PrimitiveTopology::TriangleList:
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST; return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
case dawn::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP; return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -124,95 +124,95 @@ namespace dawn_native { namespace d3d12 {
} }
D3D12_PRIMITIVE_TOPOLOGY_TYPE D3D12PrimitiveTopologyType( D3D12_PRIMITIVE_TOPOLOGY_TYPE D3D12PrimitiveTopologyType(
dawn::PrimitiveTopology primitiveTopology) { wgpu::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) { switch (primitiveTopology) {
case dawn::PrimitiveTopology::PointList: case wgpu::PrimitiveTopology::PointList:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT; return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
case dawn::PrimitiveTopology::LineList: case wgpu::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::LineStrip: case wgpu::PrimitiveTopology::LineStrip:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE; return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
case dawn::PrimitiveTopology::TriangleList: case wgpu::PrimitiveTopology::TriangleList:
case dawn::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE; return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
D3D12_CULL_MODE D3D12CullMode(dawn::CullMode mode) { D3D12_CULL_MODE D3D12CullMode(wgpu::CullMode mode) {
switch (mode) { switch (mode) {
case dawn::CullMode::None: case wgpu::CullMode::None:
return D3D12_CULL_MODE_NONE; return D3D12_CULL_MODE_NONE;
case dawn::CullMode::Front: case wgpu::CullMode::Front:
return D3D12_CULL_MODE_FRONT; return D3D12_CULL_MODE_FRONT;
case dawn::CullMode::Back: case wgpu::CullMode::Back:
return D3D12_CULL_MODE_BACK; return D3D12_CULL_MODE_BACK;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
D3D12_BLEND D3D12Blend(dawn::BlendFactor factor) { D3D12_BLEND D3D12Blend(wgpu::BlendFactor factor) {
switch (factor) { switch (factor) {
case dawn::BlendFactor::Zero: case wgpu::BlendFactor::Zero:
return D3D12_BLEND_ZERO; return D3D12_BLEND_ZERO;
case dawn::BlendFactor::One: case wgpu::BlendFactor::One:
return D3D12_BLEND_ONE; return D3D12_BLEND_ONE;
case dawn::BlendFactor::SrcColor: case wgpu::BlendFactor::SrcColor:
return D3D12_BLEND_SRC_COLOR; return D3D12_BLEND_SRC_COLOR;
case dawn::BlendFactor::OneMinusSrcColor: case wgpu::BlendFactor::OneMinusSrcColor:
return D3D12_BLEND_INV_SRC_COLOR; return D3D12_BLEND_INV_SRC_COLOR;
case dawn::BlendFactor::SrcAlpha: case wgpu::BlendFactor::SrcAlpha:
return D3D12_BLEND_SRC_ALPHA; return D3D12_BLEND_SRC_ALPHA;
case dawn::BlendFactor::OneMinusSrcAlpha: case wgpu::BlendFactor::OneMinusSrcAlpha:
return D3D12_BLEND_INV_SRC_ALPHA; return D3D12_BLEND_INV_SRC_ALPHA;
case dawn::BlendFactor::DstColor: case wgpu::BlendFactor::DstColor:
return D3D12_BLEND_DEST_COLOR; return D3D12_BLEND_DEST_COLOR;
case dawn::BlendFactor::OneMinusDstColor: case wgpu::BlendFactor::OneMinusDstColor:
return D3D12_BLEND_INV_DEST_COLOR; return D3D12_BLEND_INV_DEST_COLOR;
case dawn::BlendFactor::DstAlpha: case wgpu::BlendFactor::DstAlpha:
return D3D12_BLEND_DEST_ALPHA; return D3D12_BLEND_DEST_ALPHA;
case dawn::BlendFactor::OneMinusDstAlpha: case wgpu::BlendFactor::OneMinusDstAlpha:
return D3D12_BLEND_INV_DEST_ALPHA; return D3D12_BLEND_INV_DEST_ALPHA;
case dawn::BlendFactor::SrcAlphaSaturated: case wgpu::BlendFactor::SrcAlphaSaturated:
return D3D12_BLEND_SRC_ALPHA_SAT; return D3D12_BLEND_SRC_ALPHA_SAT;
case dawn::BlendFactor::BlendColor: case wgpu::BlendFactor::BlendColor:
return D3D12_BLEND_BLEND_FACTOR; return D3D12_BLEND_BLEND_FACTOR;
case dawn::BlendFactor::OneMinusBlendColor: case wgpu::BlendFactor::OneMinusBlendColor:
return D3D12_BLEND_INV_BLEND_FACTOR; return D3D12_BLEND_INV_BLEND_FACTOR;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
D3D12_BLEND_OP D3D12BlendOperation(dawn::BlendOperation operation) { D3D12_BLEND_OP D3D12BlendOperation(wgpu::BlendOperation operation) {
switch (operation) { switch (operation) {
case dawn::BlendOperation::Add: case wgpu::BlendOperation::Add:
return D3D12_BLEND_OP_ADD; return D3D12_BLEND_OP_ADD;
case dawn::BlendOperation::Subtract: case wgpu::BlendOperation::Subtract:
return D3D12_BLEND_OP_SUBTRACT; return D3D12_BLEND_OP_SUBTRACT;
case dawn::BlendOperation::ReverseSubtract: case wgpu::BlendOperation::ReverseSubtract:
return D3D12_BLEND_OP_REV_SUBTRACT; return D3D12_BLEND_OP_REV_SUBTRACT;
case dawn::BlendOperation::Min: case wgpu::BlendOperation::Min:
return D3D12_BLEND_OP_MIN; return D3D12_BLEND_OP_MIN;
case dawn::BlendOperation::Max: case wgpu::BlendOperation::Max:
return D3D12_BLEND_OP_MAX; return D3D12_BLEND_OP_MAX;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
uint8_t D3D12RenderTargetWriteMask(dawn::ColorWriteMask writeMask) { uint8_t D3D12RenderTargetWriteMask(wgpu::ColorWriteMask writeMask) {
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Red) == static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(wgpu::ColorWriteMask::Red) ==
D3D12_COLOR_WRITE_ENABLE_RED, D3D12_COLOR_WRITE_ENABLE_RED,
"ColorWriteMask values must match"); "ColorWriteMask values must match");
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Green) == static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(wgpu::ColorWriteMask::Green) ==
D3D12_COLOR_WRITE_ENABLE_GREEN, D3D12_COLOR_WRITE_ENABLE_GREEN,
"ColorWriteMask values must match"); "ColorWriteMask values must match");
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Blue) == static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(wgpu::ColorWriteMask::Blue) ==
D3D12_COLOR_WRITE_ENABLE_BLUE, D3D12_COLOR_WRITE_ENABLE_BLUE,
"ColorWriteMask values must match"); "ColorWriteMask values must match");
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Alpha) == static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(wgpu::ColorWriteMask::Alpha) ==
D3D12_COLOR_WRITE_ENABLE_ALPHA, D3D12_COLOR_WRITE_ENABLE_ALPHA,
"ColorWriteMask values must match"); "ColorWriteMask values must match");
return static_cast<uint8_t>(writeMask); return static_cast<uint8_t>(writeMask);
@ -233,23 +233,23 @@ namespace dawn_native { namespace d3d12 {
return blendDesc; return blendDesc;
} }
D3D12_STENCIL_OP StencilOp(dawn::StencilOperation op) { D3D12_STENCIL_OP StencilOp(wgpu::StencilOperation op) {
switch (op) { switch (op) {
case dawn::StencilOperation::Keep: case wgpu::StencilOperation::Keep:
return D3D12_STENCIL_OP_KEEP; return D3D12_STENCIL_OP_KEEP;
case dawn::StencilOperation::Zero: case wgpu::StencilOperation::Zero:
return D3D12_STENCIL_OP_ZERO; return D3D12_STENCIL_OP_ZERO;
case dawn::StencilOperation::Replace: case wgpu::StencilOperation::Replace:
return D3D12_STENCIL_OP_REPLACE; return D3D12_STENCIL_OP_REPLACE;
case dawn::StencilOperation::IncrementClamp: case wgpu::StencilOperation::IncrementClamp:
return D3D12_STENCIL_OP_INCR_SAT; return D3D12_STENCIL_OP_INCR_SAT;
case dawn::StencilOperation::DecrementClamp: case wgpu::StencilOperation::DecrementClamp:
return D3D12_STENCIL_OP_DECR_SAT; return D3D12_STENCIL_OP_DECR_SAT;
case dawn::StencilOperation::Invert: case wgpu::StencilOperation::Invert:
return D3D12_STENCIL_OP_INVERT; return D3D12_STENCIL_OP_INVERT;
case dawn::StencilOperation::IncrementWrap: case wgpu::StencilOperation::IncrementWrap:
return D3D12_STENCIL_OP_INCR; return D3D12_STENCIL_OP_INCR;
case dawn::StencilOperation::DecrementWrap: case wgpu::StencilOperation::DecrementWrap:
return D3D12_STENCIL_OP_DECR; return D3D12_STENCIL_OP_DECR;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -313,7 +313,7 @@ namespace dawn_native { namespace d3d12 {
PerStage<ComPtr<ID3DBlob>> compiledShader; PerStage<ComPtr<ID3DBlob>> compiledShader;
ComPtr<ID3DBlob> errors; ComPtr<ID3DBlob> errors;
dawn::ShaderStage renderStages = dawn::ShaderStage::Vertex | dawn::ShaderStage::Fragment; wgpu::ShaderStage renderStages = wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Fragment;
for (auto stage : IterateStages(renderStages)) { for (auto stage : IterateStages(renderStages)) {
const ShaderModule* module = nullptr; const ShaderModule* module = nullptr;
const char* entryPoint = nullptr; const char* entryPoint = nullptr;
@ -366,7 +366,7 @@ namespace dawn_native { namespace d3d12 {
descriptorD3D12.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID; descriptorD3D12.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
descriptorD3D12.RasterizerState.CullMode = D3D12CullMode(GetCullMode()); descriptorD3D12.RasterizerState.CullMode = D3D12CullMode(GetCullMode());
descriptorD3D12.RasterizerState.FrontCounterClockwise = descriptorD3D12.RasterizerState.FrontCounterClockwise =
(GetFrontFace() == dawn::FrontFace::CCW) ? TRUE : FALSE; (GetFrontFace() == wgpu::FrontFace::CCW) ? TRUE : FALSE;
descriptorD3D12.RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS; descriptorD3D12.RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS;
descriptorD3D12.RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP; descriptorD3D12.RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP;
descriptorD3D12.RasterizerState.SlopeScaledDepthBias = descriptorD3D12.RasterizerState.SlopeScaledDepthBias =

View File

@ -20,13 +20,13 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
namespace { namespace {
D3D12_TEXTURE_ADDRESS_MODE AddressMode(dawn::AddressMode mode) { D3D12_TEXTURE_ADDRESS_MODE AddressMode(wgpu::AddressMode mode) {
switch (mode) { switch (mode) {
case dawn::AddressMode::Repeat: case wgpu::AddressMode::Repeat:
return D3D12_TEXTURE_ADDRESS_MODE_WRAP; return D3D12_TEXTURE_ADDRESS_MODE_WRAP;
case dawn::AddressMode::MirrorRepeat: case wgpu::AddressMode::MirrorRepeat:
return D3D12_TEXTURE_ADDRESS_MODE_MIRROR; return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
case dawn::AddressMode::ClampToEdge: case wgpu::AddressMode::ClampToEdge:
return D3D12_TEXTURE_ADDRESS_MODE_CLAMP; return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -54,25 +54,25 @@ namespace dawn_native { namespace d3d12 {
uint8_t mode = 0; uint8_t mode = 0;
switch (descriptor->minFilter) { switch (descriptor->minFilter) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
break; break;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
mode += 16; mode += 16;
break; break;
} }
switch (descriptor->magFilter) { switch (descriptor->magFilter) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
break; break;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
mode += 4; mode += 4;
break; break;
} }
switch (descriptor->mipmapFilter) { switch (descriptor->mipmapFilter) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
break; break;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
mode += 1; mode += 1;
break; break;
} }

View File

@ -29,7 +29,7 @@ namespace dawn_native { namespace d3d12 {
im.Init(im.userData, &wsiContext); im.Init(im.userData, &wsiContext);
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_NONE); ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_NONE);
mTextureUsage = static_cast<dawn::TextureUsage>(im.textureUsage); mTextureUsage = static_cast<wgpu::TextureUsage>(im.textureUsage);
} }
SwapChain::~SwapChain() { SwapChain::~SwapChain() {
@ -40,7 +40,7 @@ namespace dawn_native { namespace d3d12 {
DawnSwapChainNextTexture next = {}; DawnSwapChainNextTexture next = {};
DawnSwapChainError error = im.GetNextTexture(im.userData, &next); DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
if (error) { if (error) {
GetDevice()->HandleError(dawn::ErrorType::Unknown, error); GetDevice()->HandleError(wgpu::ErrorType::Unknown, error);
return nullptr; return nullptr;
} }

View File

@ -30,7 +30,7 @@ namespace dawn_native { namespace d3d12 {
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override; TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
MaybeError OnBeforePresent(TextureBase* texture) override; MaybeError OnBeforePresent(TextureBase* texture) override;
dawn::TextureUsage mTextureUsage; wgpu::TextureUsage mTextureUsage;
}; };
}} // namespace dawn_native::d3d12 }} // namespace dawn_native::d3d12

View File

@ -30,28 +30,28 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
namespace { namespace {
D3D12_RESOURCE_STATES D3D12TextureUsage(dawn::TextureUsage usage, const Format& format) { D3D12_RESOURCE_STATES D3D12TextureUsage(wgpu::TextureUsage usage, const Format& format) {
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON; D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
// Present is an exclusive flag. // Present is an exclusive flag.
if (usage & dawn::TextureUsage::Present) { if (usage & wgpu::TextureUsage::Present) {
return D3D12_RESOURCE_STATE_PRESENT; return D3D12_RESOURCE_STATE_PRESENT;
} }
if (usage & dawn::TextureUsage::CopySrc) { if (usage & wgpu::TextureUsage::CopySrc) {
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE; resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
} }
if (usage & dawn::TextureUsage::CopyDst) { if (usage & wgpu::TextureUsage::CopyDst) {
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST; resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
} }
if (usage & dawn::TextureUsage::Sampled) { if (usage & wgpu::TextureUsage::Sampled) {
resourceState |= (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE | resourceState |= (D3D12_RESOURCE_STATE_PIXEL_SHADER_RESOURCE |
D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE); D3D12_RESOURCE_STATE_NON_PIXEL_SHADER_RESOURCE);
} }
if (usage & dawn::TextureUsage::Storage) { if (usage & wgpu::TextureUsage::Storage) {
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS; resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
} }
if (usage & dawn::TextureUsage::OutputAttachment) { if (usage & wgpu::TextureUsage::OutputAttachment) {
if (format.HasDepthOrStencil()) { if (format.HasDepthOrStencil()) {
resourceState |= D3D12_RESOURCE_STATE_DEPTH_WRITE; resourceState |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
} else { } else {
@ -62,12 +62,12 @@ namespace dawn_native { namespace d3d12 {
return resourceState; return resourceState;
} }
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::TextureUsage usage, D3D12_RESOURCE_FLAGS D3D12ResourceFlags(wgpu::TextureUsage usage,
const Format& format, const Format& format,
bool isMultisampledTexture) { bool isMultisampledTexture) {
D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE; D3D12_RESOURCE_FLAGS flags = D3D12_RESOURCE_FLAG_NONE;
if (usage & dawn::TextureUsage::Storage) { if (usage & wgpu::TextureUsage::Storage) {
flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS; flags |= D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS;
} }
@ -79,7 +79,7 @@ namespace dawn_native { namespace d3d12 {
// flag is invalid. // flag is invalid.
// TODO(natlee@microsoft.com, jiawei.shao@intel.com): do not require render target for // TODO(natlee@microsoft.com, jiawei.shao@intel.com): do not require render target for
// lazy clearing. // lazy clearing.
if ((usage & dawn::TextureUsage::OutputAttachment) || isMultisampledTexture || if ((usage & wgpu::TextureUsage::OutputAttachment) || isMultisampledTexture ||
!format.isCompressed) { !format.isCompressed) {
if (format.HasDepthOrStencil()) { if (format.HasDepthOrStencil()) {
flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL; flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
@ -93,9 +93,9 @@ namespace dawn_native { namespace d3d12 {
return flags; return flags;
} }
D3D12_RESOURCE_DIMENSION D3D12TextureDimension(dawn::TextureDimension dimension) { D3D12_RESOURCE_DIMENSION D3D12TextureDimension(wgpu::TextureDimension dimension) {
switch (dimension) { switch (dimension) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
return D3D12_RESOURCE_DIMENSION_TEXTURE2D; return D3D12_RESOURCE_DIMENSION_TEXTURE2D;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -103,117 +103,117 @@ namespace dawn_native { namespace d3d12 {
} }
} // namespace } // namespace
DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format) { DXGI_FORMAT D3D12TextureFormat(wgpu::TextureFormat format) {
switch (format) { switch (format) {
case dawn::TextureFormat::R8Unorm: case wgpu::TextureFormat::R8Unorm:
return DXGI_FORMAT_R8_UNORM; return DXGI_FORMAT_R8_UNORM;
case dawn::TextureFormat::R8Snorm: case wgpu::TextureFormat::R8Snorm:
return DXGI_FORMAT_R8_SNORM; return DXGI_FORMAT_R8_SNORM;
case dawn::TextureFormat::R8Uint: case wgpu::TextureFormat::R8Uint:
return DXGI_FORMAT_R8_UINT; return DXGI_FORMAT_R8_UINT;
case dawn::TextureFormat::R8Sint: case wgpu::TextureFormat::R8Sint:
return DXGI_FORMAT_R8_SINT; return DXGI_FORMAT_R8_SINT;
case dawn::TextureFormat::R16Uint: case wgpu::TextureFormat::R16Uint:
return DXGI_FORMAT_R16_UINT; return DXGI_FORMAT_R16_UINT;
case dawn::TextureFormat::R16Sint: case wgpu::TextureFormat::R16Sint:
return DXGI_FORMAT_R16_SINT; return DXGI_FORMAT_R16_SINT;
case dawn::TextureFormat::R16Float: case wgpu::TextureFormat::R16Float:
return DXGI_FORMAT_R16_FLOAT; return DXGI_FORMAT_R16_FLOAT;
case dawn::TextureFormat::RG8Unorm: case wgpu::TextureFormat::RG8Unorm:
return DXGI_FORMAT_R8G8_UNORM; return DXGI_FORMAT_R8G8_UNORM;
case dawn::TextureFormat::RG8Snorm: case wgpu::TextureFormat::RG8Snorm:
return DXGI_FORMAT_R8G8_SNORM; return DXGI_FORMAT_R8G8_SNORM;
case dawn::TextureFormat::RG8Uint: case wgpu::TextureFormat::RG8Uint:
return DXGI_FORMAT_R8G8_UINT; return DXGI_FORMAT_R8G8_UINT;
case dawn::TextureFormat::RG8Sint: case wgpu::TextureFormat::RG8Sint:
return DXGI_FORMAT_R8G8_SINT; return DXGI_FORMAT_R8G8_SINT;
case dawn::TextureFormat::R32Uint: case wgpu::TextureFormat::R32Uint:
return DXGI_FORMAT_R32_UINT; return DXGI_FORMAT_R32_UINT;
case dawn::TextureFormat::R32Sint: case wgpu::TextureFormat::R32Sint:
return DXGI_FORMAT_R32_SINT; return DXGI_FORMAT_R32_SINT;
case dawn::TextureFormat::R32Float: case wgpu::TextureFormat::R32Float:
return DXGI_FORMAT_R32_FLOAT; return DXGI_FORMAT_R32_FLOAT;
case dawn::TextureFormat::RG16Uint: case wgpu::TextureFormat::RG16Uint:
return DXGI_FORMAT_R16G16_UINT; return DXGI_FORMAT_R16G16_UINT;
case dawn::TextureFormat::RG16Sint: case wgpu::TextureFormat::RG16Sint:
return DXGI_FORMAT_R16G16_SINT; return DXGI_FORMAT_R16G16_SINT;
case dawn::TextureFormat::RG16Float: case wgpu::TextureFormat::RG16Float:
return DXGI_FORMAT_R16G16_FLOAT; return DXGI_FORMAT_R16G16_FLOAT;
case dawn::TextureFormat::RGBA8Unorm: case wgpu::TextureFormat::RGBA8Unorm:
return DXGI_FORMAT_R8G8B8A8_UNORM; return DXGI_FORMAT_R8G8B8A8_UNORM;
case dawn::TextureFormat::RGBA8UnormSrgb: case wgpu::TextureFormat::RGBA8UnormSrgb:
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB; return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
case dawn::TextureFormat::RGBA8Snorm: case wgpu::TextureFormat::RGBA8Snorm:
return DXGI_FORMAT_R8G8B8A8_SNORM; return DXGI_FORMAT_R8G8B8A8_SNORM;
case dawn::TextureFormat::RGBA8Uint: case wgpu::TextureFormat::RGBA8Uint:
return DXGI_FORMAT_R8G8B8A8_UINT; return DXGI_FORMAT_R8G8B8A8_UINT;
case dawn::TextureFormat::RGBA8Sint: case wgpu::TextureFormat::RGBA8Sint:
return DXGI_FORMAT_R8G8B8A8_SINT; return DXGI_FORMAT_R8G8B8A8_SINT;
case dawn::TextureFormat::BGRA8Unorm: case wgpu::TextureFormat::BGRA8Unorm:
return DXGI_FORMAT_B8G8R8A8_UNORM; return DXGI_FORMAT_B8G8R8A8_UNORM;
case dawn::TextureFormat::BGRA8UnormSrgb: case wgpu::TextureFormat::BGRA8UnormSrgb:
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB; return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
case dawn::TextureFormat::RGB10A2Unorm: case wgpu::TextureFormat::RGB10A2Unorm:
return DXGI_FORMAT_R10G10B10A2_UNORM; return DXGI_FORMAT_R10G10B10A2_UNORM;
case dawn::TextureFormat::RG11B10Float: case wgpu::TextureFormat::RG11B10Float:
return DXGI_FORMAT_R11G11B10_FLOAT; return DXGI_FORMAT_R11G11B10_FLOAT;
case dawn::TextureFormat::RG32Uint: case wgpu::TextureFormat::RG32Uint:
return DXGI_FORMAT_R32G32_UINT; return DXGI_FORMAT_R32G32_UINT;
case dawn::TextureFormat::RG32Sint: case wgpu::TextureFormat::RG32Sint:
return DXGI_FORMAT_R32G32_SINT; return DXGI_FORMAT_R32G32_SINT;
case dawn::TextureFormat::RG32Float: case wgpu::TextureFormat::RG32Float:
return DXGI_FORMAT_R32G32_FLOAT; return DXGI_FORMAT_R32G32_FLOAT;
case dawn::TextureFormat::RGBA16Uint: case wgpu::TextureFormat::RGBA16Uint:
return DXGI_FORMAT_R16G16B16A16_UINT; return DXGI_FORMAT_R16G16B16A16_UINT;
case dawn::TextureFormat::RGBA16Sint: case wgpu::TextureFormat::RGBA16Sint:
return DXGI_FORMAT_R16G16B16A16_SINT; return DXGI_FORMAT_R16G16B16A16_SINT;
case dawn::TextureFormat::RGBA16Float: case wgpu::TextureFormat::RGBA16Float:
return DXGI_FORMAT_R16G16B16A16_FLOAT; return DXGI_FORMAT_R16G16B16A16_FLOAT;
case dawn::TextureFormat::RGBA32Uint: case wgpu::TextureFormat::RGBA32Uint:
return DXGI_FORMAT_R32G32B32A32_UINT; return DXGI_FORMAT_R32G32B32A32_UINT;
case dawn::TextureFormat::RGBA32Sint: case wgpu::TextureFormat::RGBA32Sint:
return DXGI_FORMAT_R32G32B32A32_SINT; return DXGI_FORMAT_R32G32B32A32_SINT;
case dawn::TextureFormat::RGBA32Float: case wgpu::TextureFormat::RGBA32Float:
return DXGI_FORMAT_R32G32B32A32_FLOAT; return DXGI_FORMAT_R32G32B32A32_FLOAT;
case dawn::TextureFormat::Depth32Float: case wgpu::TextureFormat::Depth32Float:
return DXGI_FORMAT_D32_FLOAT; return DXGI_FORMAT_D32_FLOAT;
case dawn::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24Plus:
return DXGI_FORMAT_D32_FLOAT; return DXGI_FORMAT_D32_FLOAT;
case dawn::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
return DXGI_FORMAT_D32_FLOAT_S8X24_UINT; return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
case dawn::TextureFormat::BC1RGBAUnorm: case wgpu::TextureFormat::BC1RGBAUnorm:
return DXGI_FORMAT_BC1_UNORM; return DXGI_FORMAT_BC1_UNORM;
case dawn::TextureFormat::BC1RGBAUnormSrgb: case wgpu::TextureFormat::BC1RGBAUnormSrgb:
return DXGI_FORMAT_BC1_UNORM_SRGB; return DXGI_FORMAT_BC1_UNORM_SRGB;
case dawn::TextureFormat::BC2RGBAUnorm: case wgpu::TextureFormat::BC2RGBAUnorm:
return DXGI_FORMAT_BC2_UNORM; return DXGI_FORMAT_BC2_UNORM;
case dawn::TextureFormat::BC2RGBAUnormSrgb: case wgpu::TextureFormat::BC2RGBAUnormSrgb:
return DXGI_FORMAT_BC2_UNORM_SRGB; return DXGI_FORMAT_BC2_UNORM_SRGB;
case dawn::TextureFormat::BC3RGBAUnorm: case wgpu::TextureFormat::BC3RGBAUnorm:
return DXGI_FORMAT_BC3_UNORM; return DXGI_FORMAT_BC3_UNORM;
case dawn::TextureFormat::BC3RGBAUnormSrgb: case wgpu::TextureFormat::BC3RGBAUnormSrgb:
return DXGI_FORMAT_BC3_UNORM_SRGB; return DXGI_FORMAT_BC3_UNORM_SRGB;
case dawn::TextureFormat::BC4RSnorm: case wgpu::TextureFormat::BC4RSnorm:
return DXGI_FORMAT_BC4_SNORM; return DXGI_FORMAT_BC4_SNORM;
case dawn::TextureFormat::BC4RUnorm: case wgpu::TextureFormat::BC4RUnorm:
return DXGI_FORMAT_BC4_UNORM; return DXGI_FORMAT_BC4_UNORM;
case dawn::TextureFormat::BC5RGSnorm: case wgpu::TextureFormat::BC5RGSnorm:
return DXGI_FORMAT_BC5_SNORM; return DXGI_FORMAT_BC5_SNORM;
case dawn::TextureFormat::BC5RGUnorm: case wgpu::TextureFormat::BC5RGUnorm:
return DXGI_FORMAT_BC5_UNORM; return DXGI_FORMAT_BC5_UNORM;
case dawn::TextureFormat::BC6HRGBSfloat: case wgpu::TextureFormat::BC6HRGBSfloat:
return DXGI_FORMAT_BC6H_SF16; return DXGI_FORMAT_BC6H_SF16;
case dawn::TextureFormat::BC6HRGBUfloat: case wgpu::TextureFormat::BC6HRGBUfloat:
return DXGI_FORMAT_BC6H_UF16; return DXGI_FORMAT_BC6H_UF16;
case dawn::TextureFormat::BC7RGBAUnorm: case wgpu::TextureFormat::BC7RGBAUnorm:
return DXGI_FORMAT_BC7_UNORM; return DXGI_FORMAT_BC7_UNORM;
case dawn::TextureFormat::BC7RGBAUnormSrgb: case wgpu::TextureFormat::BC7RGBAUnormSrgb:
return DXGI_FORMAT_BC7_UNORM_SRGB; return DXGI_FORMAT_BC7_UNORM_SRGB;
default: default:
@ -222,7 +222,7 @@ namespace dawn_native { namespace d3d12 {
} }
MaybeError ValidateTextureDescriptorCanBeWrapped(const TextureDescriptor* descriptor) { MaybeError ValidateTextureDescriptorCanBeWrapped(const TextureDescriptor* descriptor) {
if (descriptor->dimension != dawn::TextureDimension::e2D) { if (descriptor->dimension != wgpu::TextureDimension::e2D) {
return DAWN_VALIDATION_ERROR("Texture must be 2D"); return DAWN_VALIDATION_ERROR("Texture must be 2D");
} }
@ -397,7 +397,7 @@ namespace dawn_native { namespace d3d12 {
UINT16 Texture::GetDepthOrArraySize() { UINT16 Texture::GetDepthOrArraySize() {
switch (GetDimension()) { switch (GetDimension()) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
return static_cast<UINT16>(GetArrayLayers()); return static_cast<UINT16>(GetArrayLayers());
default: default:
UNREACHABLE(); UNREACHABLE();
@ -409,7 +409,7 @@ namespace dawn_native { namespace d3d12 {
// cause subsequent errors. // cause subsequent errors.
bool Texture::TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext, bool Texture::TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
D3D12_RESOURCE_BARRIER* barrier, D3D12_RESOURCE_BARRIER* barrier,
dawn::TextureUsage newUsage) { wgpu::TextureUsage newUsage) {
return TransitionUsageAndGetResourceBarrier(commandContext, barrier, return TransitionUsageAndGetResourceBarrier(commandContext, barrier,
D3D12TextureUsage(newUsage, GetFormat())); D3D12TextureUsage(newUsage, GetFormat()));
} }
@ -493,7 +493,7 @@ namespace dawn_native { namespace d3d12 {
} }
void Texture::TransitionUsageNow(CommandRecordingContext* commandContext, void Texture::TransitionUsageNow(CommandRecordingContext* commandContext,
dawn::TextureUsage usage) { wgpu::TextureUsage usage) {
TransitionUsageNow(commandContext, D3D12TextureUsage(usage, GetFormat())); TransitionUsageNow(commandContext, D3D12TextureUsage(usage, GetFormat()));
} }
@ -509,7 +509,7 @@ namespace dawn_native { namespace d3d12 {
D3D12_RENDER_TARGET_VIEW_DESC Texture::GetRTVDescriptor(uint32_t baseMipLevel, D3D12_RENDER_TARGET_VIEW_DESC Texture::GetRTVDescriptor(uint32_t baseMipLevel,
uint32_t baseArrayLayer, uint32_t baseArrayLayer,
uint32_t layerCount) const { uint32_t layerCount) const {
ASSERT(GetDimension() == dawn::TextureDimension::e2D); ASSERT(GetDimension() == wgpu::TextureDimension::e2D);
D3D12_RENDER_TARGET_VIEW_DESC rtvDesc; D3D12_RENDER_TARGET_VIEW_DESC rtvDesc;
rtvDesc.Format = GetD3D12Format(); rtvDesc.Format = GetD3D12Format();
if (IsMultisampledTexture()) { if (IsMultisampledTexture()) {
@ -696,9 +696,9 @@ namespace dawn_native { namespace d3d12 {
// TODO(jiawei.shao@intel.com): support more texture view dimensions. // TODO(jiawei.shao@intel.com): support more texture view dimensions.
// TODO(jiawei.shao@intel.com): support creating SRV on multisampled textures. // TODO(jiawei.shao@intel.com): support creating SRV on multisampled textures.
switch (descriptor->dimension) { switch (descriptor->dimension) {
case dawn::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:
case dawn::TextureViewDimension::e2DArray: case wgpu::TextureViewDimension::e2DArray:
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D); ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY; mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
mSrvDesc.Texture2DArray.ArraySize = descriptor->arrayLayerCount; mSrvDesc.Texture2DArray.ArraySize = descriptor->arrayLayerCount;
mSrvDesc.Texture2DArray.FirstArraySlice = descriptor->baseArrayLayer; mSrvDesc.Texture2DArray.FirstArraySlice = descriptor->baseArrayLayer;
@ -707,9 +707,9 @@ namespace dawn_native { namespace d3d12 {
mSrvDesc.Texture2DArray.PlaneSlice = 0; mSrvDesc.Texture2DArray.PlaneSlice = 0;
mSrvDesc.Texture2DArray.ResourceMinLODClamp = 0; mSrvDesc.Texture2DArray.ResourceMinLODClamp = 0;
break; break;
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D); ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
ASSERT(descriptor->arrayLayerCount % 6 == 0); ASSERT(descriptor->arrayLayerCount % 6 == 0);
mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY; mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
mSrvDesc.TextureCubeArray.First2DArrayFace = descriptor->baseArrayLayer; mSrvDesc.TextureCubeArray.First2DArrayFace = descriptor->baseArrayLayer;

View File

@ -26,7 +26,7 @@ namespace dawn_native { namespace d3d12 {
class CommandRecordingContext; class CommandRecordingContext;
class Device; class Device;
DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format); DXGI_FORMAT D3D12TextureFormat(wgpu::TextureFormat format);
MaybeError ValidateD3D12TextureCanBeWrapped(ID3D12Resource* d3d12Resource, MaybeError ValidateD3D12TextureCanBeWrapped(ID3D12Resource* d3d12Resource,
const TextureDescriptor* descriptor); const TextureDescriptor* descriptor);
MaybeError ValidateTextureDescriptorCanBeWrapped(const TextureDescriptor* descriptor); MaybeError ValidateTextureDescriptorCanBeWrapped(const TextureDescriptor* descriptor);
@ -49,8 +49,8 @@ namespace dawn_native { namespace d3d12 {
ID3D12Resource* GetD3D12Resource() const; ID3D12Resource* GetD3D12Resource() const;
bool TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext, bool TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
D3D12_RESOURCE_BARRIER* barrier, D3D12_RESOURCE_BARRIER* barrier,
dawn::TextureUsage newUsage); wgpu::TextureUsage newUsage);
void TransitionUsageNow(CommandRecordingContext* commandContext, dawn::TextureUsage usage); void TransitionUsageNow(CommandRecordingContext* commandContext, wgpu::TextureUsage usage);
void TransitionUsageNow(CommandRecordingContext* commandContext, void TransitionUsageNow(CommandRecordingContext* commandContext,
D3D12_RESOURCE_STATES newState); D3D12_RESOURCE_STATES newState);

View File

@ -18,23 +18,23 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(dawn::CompareFunction func) { D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(wgpu::CompareFunction func) {
switch (func) { switch (func) {
case dawn::CompareFunction::Always: case wgpu::CompareFunction::Always:
return D3D12_COMPARISON_FUNC_ALWAYS; return D3D12_COMPARISON_FUNC_ALWAYS;
case dawn::CompareFunction::Equal: case wgpu::CompareFunction::Equal:
return D3D12_COMPARISON_FUNC_EQUAL; return D3D12_COMPARISON_FUNC_EQUAL;
case dawn::CompareFunction::Greater: case wgpu::CompareFunction::Greater:
return D3D12_COMPARISON_FUNC_GREATER; return D3D12_COMPARISON_FUNC_GREATER;
case dawn::CompareFunction::GreaterEqual: case wgpu::CompareFunction::GreaterEqual:
return D3D12_COMPARISON_FUNC_GREATER_EQUAL; return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
case dawn::CompareFunction::Less: case wgpu::CompareFunction::Less:
return D3D12_COMPARISON_FUNC_LESS; return D3D12_COMPARISON_FUNC_LESS;
case dawn::CompareFunction::LessEqual: case wgpu::CompareFunction::LessEqual:
return D3D12_COMPARISON_FUNC_LESS_EQUAL; return D3D12_COMPARISON_FUNC_LESS_EQUAL;
case dawn::CompareFunction::Never: case wgpu::CompareFunction::Never:
return D3D12_COMPARISON_FUNC_NEVER; return D3D12_COMPARISON_FUNC_NEVER;
case dawn::CompareFunction::NotEqual: case wgpu::CompareFunction::NotEqual:
return D3D12_COMPARISON_FUNC_NOT_EQUAL; return D3D12_COMPARISON_FUNC_NOT_EQUAL;
default: default:
UNREACHABLE(); UNREACHABLE();

View File

@ -23,7 +23,7 @@
namespace dawn_native { namespace d3d12 { namespace dawn_native { namespace d3d12 {
D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(dawn::CompareFunction func); D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(wgpu::CompareFunction func);
D3D12_TEXTURE_COPY_LOCATION ComputeTextureCopyLocationForTexture(const Texture* texture, D3D12_TEXTURE_COPY_LOCATION ComputeTextureCopyLocationForTexture(const Texture* texture,
uint32_t level, uint32_t level,

View File

@ -15,11 +15,11 @@
#ifndef DAWNNATIVE_DAWNPLATFORM_H_ #ifndef DAWNNATIVE_DAWNPLATFORM_H_
#define DAWNNATIVE_DAWNPLATFORM_H_ #define DAWNNATIVE_DAWNPLATFORM_H_
// Use dawncpp to have the enum and bitfield definitions // Use webgpu_cpp to have the enum and bitfield definitions
#include <dawn/dawncpp.h> #include <dawn/webgpu_cpp.h>
// Use our autogenerated version of the dawn structures that point to dawn_native object types // Use our autogenerated version of the wgpu structures that point to dawn_native object types
// (dawn::Buffer is dawn_native::BufferBase*) // (wgpu::Buffer is dawn_native::BufferBase*)
#include <dawn_native/dawn_structs_autogen.h> #include <dawn_native/wgpu_structs_autogen.h>
#endif // DAWNNATIVE_DAWNPLATFORM_H_ #endif // DAWNNATIVE_DAWNPLATFORM_H_

View File

@ -25,7 +25,7 @@ namespace dawn_native { namespace metal {
Buffer::Buffer(Device* device, const BufferDescriptor* descriptor) Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
: BufferBase(device, descriptor) { : BufferBase(device, descriptor) {
MTLResourceOptions storageMode; MTLResourceOptions storageMode;
if (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) { if (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) {
storageMode = MTLResourceStorageModeShared; storageMode = MTLResourceStorageModeShared;
} else { } else {
storageMode = MTLResourceStorageModePrivate; storageMode = MTLResourceStorageModePrivate;
@ -35,7 +35,7 @@ namespace dawn_native { namespace metal {
// Metal validation layer requires the size of uniform buffer and storage buffer to be no // Metal validation layer requires the size of uniform buffer and storage buffer to be no
// less than the size of the buffer block defined in shader, and the overall size of the // less than the size of the buffer block defined in shader, and the overall size of the
// buffer must be aligned to the largest alignment of its members. // buffer must be aligned to the largest alignment of its members.
if (GetUsage() & (dawn::BufferUsage::Uniform | dawn::BufferUsage::Storage)) { if (GetUsage() & (wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage)) {
currentSize = Align(currentSize, kMinUniformOrStorageBufferAlignment); currentSize = Align(currentSize, kMinUniformOrStorageBufferAlignment);
} }
@ -61,7 +61,7 @@ namespace dawn_native { namespace metal {
bool Buffer::IsMapWritable() const { bool Buffer::IsMapWritable() const {
// TODO(enga): Handle CPU-visible memory on UMA // TODO(enga): Handle CPU-visible memory on UMA
return (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0; return (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0;
} }
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) { MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {

View File

@ -56,7 +56,7 @@ namespace dawn_native { namespace metal {
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) { IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
auto& attachmentInfo = renderPass->colorAttachments[i]; auto& attachmentInfo = renderPass->colorAttachments[i];
if (attachmentInfo.loadOp == dawn::LoadOp::Clear) { if (attachmentInfo.loadOp == wgpu::LoadOp::Clear) {
descriptor.colorAttachments[i].loadAction = MTLLoadActionClear; descriptor.colorAttachments[i].loadAction = MTLLoadActionClear;
descriptor.colorAttachments[i].clearColor = descriptor.colorAttachments[i].clearColor =
MTLClearColorMake(attachmentInfo.clearColor.r, attachmentInfo.clearColor.g, MTLClearColorMake(attachmentInfo.clearColor.r, attachmentInfo.clearColor.g,
@ -70,7 +70,7 @@ namespace dawn_native { namespace metal {
descriptor.colorAttachments[i].level = attachmentInfo.view->GetBaseMipLevel(); descriptor.colorAttachments[i].level = attachmentInfo.view->GetBaseMipLevel();
descriptor.colorAttachments[i].slice = attachmentInfo.view->GetBaseArrayLayer(); descriptor.colorAttachments[i].slice = attachmentInfo.view->GetBaseArrayLayer();
if (attachmentInfo.storeOp == dawn::StoreOp::Store) { if (attachmentInfo.storeOp == wgpu::StoreOp::Store) {
if (attachmentInfo.resolveTarget.Get() != nullptr) { if (attachmentInfo.resolveTarget.Get() != nullptr) {
descriptor.colorAttachments[i].resolveTexture = descriptor.colorAttachments[i].resolveTexture =
ToBackend(attachmentInfo.resolveTarget->GetTexture())->GetMTLTexture(); ToBackend(attachmentInfo.resolveTarget->GetTexture())->GetMTLTexture();
@ -98,7 +98,7 @@ namespace dawn_native { namespace metal {
descriptor.depthAttachment.texture = texture; descriptor.depthAttachment.texture = texture;
descriptor.depthAttachment.storeAction = MTLStoreActionStore; descriptor.depthAttachment.storeAction = MTLStoreActionStore;
if (attachmentInfo.depthLoadOp == dawn::LoadOp::Clear) { if (attachmentInfo.depthLoadOp == wgpu::LoadOp::Clear) {
descriptor.depthAttachment.loadAction = MTLLoadActionClear; descriptor.depthAttachment.loadAction = MTLLoadActionClear;
descriptor.depthAttachment.clearDepth = attachmentInfo.clearDepth; descriptor.depthAttachment.clearDepth = attachmentInfo.clearDepth;
} else { } else {
@ -110,7 +110,7 @@ namespace dawn_native { namespace metal {
descriptor.stencilAttachment.texture = texture; descriptor.stencilAttachment.texture = texture;
descriptor.stencilAttachment.storeAction = MTLStoreActionStore; descriptor.stencilAttachment.storeAction = MTLStoreActionStore;
if (attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear) { if (attachmentInfo.stencilLoadOp == wgpu::LoadOp::Clear) {
descriptor.stencilAttachment.loadAction = MTLLoadActionClear; descriptor.stencilAttachment.loadAction = MTLLoadActionClear;
descriptor.stencilAttachment.clearStencil = attachmentInfo.clearStencil; descriptor.stencilAttachment.clearStencil = attachmentInfo.clearStencil;
} else { } else {
@ -201,21 +201,21 @@ namespace dawn_native { namespace metal {
// length of storage buffers and can apply them to the reserved "buffer length buffer" when // length of storage buffers and can apply them to the reserved "buffer length buffer" when
// needed for a draw or a dispatch. // needed for a draw or a dispatch.
struct StorageBufferLengthTracker { struct StorageBufferLengthTracker {
dawn::ShaderStage dirtyStages = dawn::ShaderStage::None; wgpu::ShaderStage dirtyStages = wgpu::ShaderStage::None;
// The lengths of buffers are stored as 32bit integers because that is the width the // The lengths of buffers are stored as 32bit integers because that is the width the
// MSL code generated by SPIRV-Cross expects. // MSL code generated by SPIRV-Cross expects.
PerStage<std::array<uint32_t, kGenericMetalBufferSlots>> data; PerStage<std::array<uint32_t, kGenericMetalBufferSlots>> data;
void Apply(id<MTLRenderCommandEncoder> render, RenderPipeline* pipeline) { void Apply(id<MTLRenderCommandEncoder> render, RenderPipeline* pipeline) {
dawn::ShaderStage stagesToApply = wgpu::ShaderStage stagesToApply =
dirtyStages & pipeline->GetStagesRequiringStorageBufferLength(); dirtyStages & pipeline->GetStagesRequiringStorageBufferLength();
if (stagesToApply == dawn::ShaderStage::None) { if (stagesToApply == wgpu::ShaderStage::None) {
return; return;
} }
if (stagesToApply & dawn::ShaderStage::Vertex) { if (stagesToApply & wgpu::ShaderStage::Vertex) {
uint32_t bufferCount = ToBackend(pipeline->GetLayout()) uint32_t bufferCount = ToBackend(pipeline->GetLayout())
->GetBufferBindingCount(SingleShaderStage::Vertex); ->GetBufferBindingCount(SingleShaderStage::Vertex);
[render setVertexBytes:data[SingleShaderStage::Vertex].data() [render setVertexBytes:data[SingleShaderStage::Vertex].data()
@ -223,7 +223,7 @@ namespace dawn_native { namespace metal {
atIndex:kBufferLengthBufferSlot]; atIndex:kBufferLengthBufferSlot];
} }
if (stagesToApply & dawn::ShaderStage::Fragment) { if (stagesToApply & wgpu::ShaderStage::Fragment) {
uint32_t bufferCount = ToBackend(pipeline->GetLayout()) uint32_t bufferCount = ToBackend(pipeline->GetLayout())
->GetBufferBindingCount(SingleShaderStage::Fragment); ->GetBufferBindingCount(SingleShaderStage::Fragment);
[render setFragmentBytes:data[SingleShaderStage::Fragment].data() [render setFragmentBytes:data[SingleShaderStage::Fragment].data()
@ -236,7 +236,7 @@ namespace dawn_native { namespace metal {
} }
void Apply(id<MTLComputeCommandEncoder> compute, ComputePipeline* pipeline) { void Apply(id<MTLComputeCommandEncoder> compute, ComputePipeline* pipeline) {
if (!(dirtyStages & dawn::ShaderStage::Compute)) { if (!(dirtyStages & wgpu::ShaderStage::Compute)) {
return; return;
} }
@ -250,7 +250,7 @@ namespace dawn_native { namespace metal {
length:sizeof(uint32_t) * bufferCount length:sizeof(uint32_t) * bufferCount
atIndex:kBufferLengthBufferSlot]; atIndex:kBufferLengthBufferSlot];
dirtyStages ^= dawn::ShaderStage::Compute; dirtyStages ^= wgpu::ShaderStage::Compute;
} }
}; };
@ -430,9 +430,9 @@ namespace dawn_native { namespace metal {
// call here. // call here.
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) { for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
auto stage = layout.visibilities[bindingIndex]; auto stage = layout.visibilities[bindingIndex];
bool hasVertStage = stage & dawn::ShaderStage::Vertex && render != nil; bool hasVertStage = stage & wgpu::ShaderStage::Vertex && render != nil;
bool hasFragStage = stage & dawn::ShaderStage::Fragment && render != nil; bool hasFragStage = stage & wgpu::ShaderStage::Fragment && render != nil;
bool hasComputeStage = stage & dawn::ShaderStage::Compute && compute != nil; bool hasComputeStage = stage & wgpu::ShaderStage::Compute && compute != nil;
uint32_t vertIndex = 0; uint32_t vertIndex = 0;
uint32_t fragIndex = 0; uint32_t fragIndex = 0;
@ -452,8 +452,8 @@ namespace dawn_native { namespace metal {
} }
switch (layout.types[bindingIndex]) { switch (layout.types[bindingIndex]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case dawn::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
const BufferBinding& binding = const BufferBinding& binding =
group->GetBindingAsBufferBinding(bindingIndex); group->GetBindingAsBufferBinding(bindingIndex);
const id<MTLBuffer> buffer = ToBackend(binding.buffer)->GetMTLBuffer(); const id<MTLBuffer> buffer = ToBackend(binding.buffer)->GetMTLBuffer();
@ -469,7 +469,7 @@ namespace dawn_native { namespace metal {
if (hasVertStage) { if (hasVertStage) {
mLengthTracker->data[SingleShaderStage::Vertex][vertIndex] = mLengthTracker->data[SingleShaderStage::Vertex][vertIndex] =
binding.size; binding.size;
mLengthTracker->dirtyStages |= dawn::ShaderStage::Vertex; mLengthTracker->dirtyStages |= wgpu::ShaderStage::Vertex;
[render setVertexBuffers:&buffer [render setVertexBuffers:&buffer
offsets:&offset offsets:&offset
withRange:NSMakeRange(vertIndex, 1)]; withRange:NSMakeRange(vertIndex, 1)];
@ -477,7 +477,7 @@ namespace dawn_native { namespace metal {
if (hasFragStage) { if (hasFragStage) {
mLengthTracker->data[SingleShaderStage::Fragment][fragIndex] = mLengthTracker->data[SingleShaderStage::Fragment][fragIndex] =
binding.size; binding.size;
mLengthTracker->dirtyStages |= dawn::ShaderStage::Fragment; mLengthTracker->dirtyStages |= wgpu::ShaderStage::Fragment;
[render setFragmentBuffers:&buffer [render setFragmentBuffers:&buffer
offsets:&offset offsets:&offset
withRange:NSMakeRange(fragIndex, 1)]; withRange:NSMakeRange(fragIndex, 1)];
@ -485,7 +485,7 @@ namespace dawn_native { namespace metal {
if (hasComputeStage) { if (hasComputeStage) {
mLengthTracker->data[SingleShaderStage::Compute][computeIndex] = mLengthTracker->data[SingleShaderStage::Compute][computeIndex] =
binding.size; binding.size;
mLengthTracker->dirtyStages |= dawn::ShaderStage::Compute; mLengthTracker->dirtyStages |= wgpu::ShaderStage::Compute;
[compute setBuffers:&buffer [compute setBuffers:&buffer
offsets:&offset offsets:&offset
withRange:NSMakeRange(computeIndex, 1)]; withRange:NSMakeRange(computeIndex, 1)];
@ -493,7 +493,7 @@ namespace dawn_native { namespace metal {
} break; } break;
case dawn::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
auto sampler = ToBackend(group->GetBindingAsSampler(bindingIndex)); auto sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
if (hasVertStage) { if (hasVertStage) {
[render setVertexSamplerState:sampler->GetMTLSamplerState() [render setVertexSamplerState:sampler->GetMTLSamplerState()
@ -509,7 +509,7 @@ namespace dawn_native { namespace metal {
} }
} break; } break;
case dawn::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
auto textureView = auto textureView =
ToBackend(group->GetBindingAsTextureView(bindingIndex)); ToBackend(group->GetBindingAsTextureView(bindingIndex));
if (hasVertStage) { if (hasVertStage) {
@ -526,8 +526,8 @@ namespace dawn_native { namespace metal {
} }
} break; } break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
} }

View File

@ -33,7 +33,7 @@ namespace dawn_native { namespace metal {
[mtlDevice newComputePipelineStateWithFunction:computeData.function error:&error]; [mtlDevice newComputePipelineStateWithFunction:computeData.function error:&error];
if (error != nil) { if (error != nil) {
NSLog(@" error => %@", error); NSLog(@" error => %@", error);
GetDevice()->HandleError(dawn::ErrorType::DeviceLost, "Error creating pipeline state"); GetDevice()->HandleError(wgpu::ErrorType::DeviceLost, "Error creating pipeline state");
return; return;
} }

View File

@ -39,21 +39,21 @@ namespace dawn_native { namespace metal {
} }
switch (groupInfo.types[binding]) { switch (groupInfo.types[binding]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
mIndexInfo[stage][group][binding] = bufferIndex; mIndexInfo[stage][group][binding] = bufferIndex;
bufferIndex++; bufferIndex++;
break; break;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
mIndexInfo[stage][group][binding] = samplerIndex; mIndexInfo[stage][group][binding] = samplerIndex;
samplerIndex++; samplerIndex++;
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
mIndexInfo[stage][group][binding] = textureIndex; mIndexInfo[stage][group][binding] = textureIndex;
textureIndex++; textureIndex++;
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
} }

View File

@ -41,7 +41,7 @@ namespace dawn_native { namespace metal {
// vertex buffer table. // vertex buffer table.
uint32_t GetMtlVertexBufferIndex(uint32_t dawnIndex) const; uint32_t GetMtlVertexBufferIndex(uint32_t dawnIndex) const;
dawn::ShaderStage GetStagesRequiringStorageBufferLength() const; wgpu::ShaderStage GetStagesRequiringStorageBufferLength() const;
private: private:
MTLVertexDescriptor* MakeVertexDesc(); MTLVertexDescriptor* MakeVertexDesc();
@ -54,7 +54,7 @@ namespace dawn_native { namespace metal {
id<MTLDepthStencilState> mMtlDepthStencilState = nil; id<MTLDepthStencilState> mMtlDepthStencilState = nil;
std::array<uint32_t, kMaxVertexBuffers> mMtlVertexBufferIndices; std::array<uint32_t, kMaxVertexBuffers> mMtlVertexBufferIndices;
dawn::ShaderStage mStagesRequiringStorageBufferLength = dawn::ShaderStage::None; wgpu::ShaderStage mStagesRequiringStorageBufferLength = wgpu::ShaderStage::None;
}; };
}} // namespace dawn_native::metal }} // namespace dawn_native::metal

View File

@ -23,166 +23,166 @@
namespace dawn_native { namespace metal { namespace dawn_native { namespace metal {
namespace { namespace {
MTLVertexFormat VertexFormatType(dawn::VertexFormat format) { MTLVertexFormat VertexFormatType(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case dawn::VertexFormat::UChar2: case wgpu::VertexFormat::UChar2:
return MTLVertexFormatUChar2; return MTLVertexFormatUChar2;
case dawn::VertexFormat::UChar4: case wgpu::VertexFormat::UChar4:
return MTLVertexFormatUChar4; return MTLVertexFormatUChar4;
case dawn::VertexFormat::Char2: case wgpu::VertexFormat::Char2:
return MTLVertexFormatChar2; return MTLVertexFormatChar2;
case dawn::VertexFormat::Char4: case wgpu::VertexFormat::Char4:
return MTLVertexFormatChar4; return MTLVertexFormatChar4;
case dawn::VertexFormat::UChar2Norm: case wgpu::VertexFormat::UChar2Norm:
return MTLVertexFormatUChar2Normalized; return MTLVertexFormatUChar2Normalized;
case dawn::VertexFormat::UChar4Norm: case wgpu::VertexFormat::UChar4Norm:
return MTLVertexFormatUChar4Normalized; return MTLVertexFormatUChar4Normalized;
case dawn::VertexFormat::Char2Norm: case wgpu::VertexFormat::Char2Norm:
return MTLVertexFormatChar2Normalized; return MTLVertexFormatChar2Normalized;
case dawn::VertexFormat::Char4Norm: case wgpu::VertexFormat::Char4Norm:
return MTLVertexFormatChar4Normalized; return MTLVertexFormatChar4Normalized;
case dawn::VertexFormat::UShort2: case wgpu::VertexFormat::UShort2:
return MTLVertexFormatUShort2; return MTLVertexFormatUShort2;
case dawn::VertexFormat::UShort4: case wgpu::VertexFormat::UShort4:
return MTLVertexFormatUShort4; return MTLVertexFormatUShort4;
case dawn::VertexFormat::Short2: case wgpu::VertexFormat::Short2:
return MTLVertexFormatShort2; return MTLVertexFormatShort2;
case dawn::VertexFormat::Short4: case wgpu::VertexFormat::Short4:
return MTLVertexFormatShort4; return MTLVertexFormatShort4;
case dawn::VertexFormat::UShort2Norm: case wgpu::VertexFormat::UShort2Norm:
return MTLVertexFormatUShort2Normalized; return MTLVertexFormatUShort2Normalized;
case dawn::VertexFormat::UShort4Norm: case wgpu::VertexFormat::UShort4Norm:
return MTLVertexFormatUShort4Normalized; return MTLVertexFormatUShort4Normalized;
case dawn::VertexFormat::Short2Norm: case wgpu::VertexFormat::Short2Norm:
return MTLVertexFormatShort2Normalized; return MTLVertexFormatShort2Normalized;
case dawn::VertexFormat::Short4Norm: case wgpu::VertexFormat::Short4Norm:
return MTLVertexFormatShort4Normalized; return MTLVertexFormatShort4Normalized;
case dawn::VertexFormat::Half2: case wgpu::VertexFormat::Half2:
return MTLVertexFormatHalf2; return MTLVertexFormatHalf2;
case dawn::VertexFormat::Half4: case wgpu::VertexFormat::Half4:
return MTLVertexFormatHalf4; return MTLVertexFormatHalf4;
case dawn::VertexFormat::Float: case wgpu::VertexFormat::Float:
return MTLVertexFormatFloat; return MTLVertexFormatFloat;
case dawn::VertexFormat::Float2: case wgpu::VertexFormat::Float2:
return MTLVertexFormatFloat2; return MTLVertexFormatFloat2;
case dawn::VertexFormat::Float3: case wgpu::VertexFormat::Float3:
return MTLVertexFormatFloat3; return MTLVertexFormatFloat3;
case dawn::VertexFormat::Float4: case wgpu::VertexFormat::Float4:
return MTLVertexFormatFloat4; return MTLVertexFormatFloat4;
case dawn::VertexFormat::UInt: case wgpu::VertexFormat::UInt:
return MTLVertexFormatUInt; return MTLVertexFormatUInt;
case dawn::VertexFormat::UInt2: case wgpu::VertexFormat::UInt2:
return MTLVertexFormatUInt2; return MTLVertexFormatUInt2;
case dawn::VertexFormat::UInt3: case wgpu::VertexFormat::UInt3:
return MTLVertexFormatUInt3; return MTLVertexFormatUInt3;
case dawn::VertexFormat::UInt4: case wgpu::VertexFormat::UInt4:
return MTLVertexFormatUInt4; return MTLVertexFormatUInt4;
case dawn::VertexFormat::Int: case wgpu::VertexFormat::Int:
return MTLVertexFormatInt; return MTLVertexFormatInt;
case dawn::VertexFormat::Int2: case wgpu::VertexFormat::Int2:
return MTLVertexFormatInt2; return MTLVertexFormatInt2;
case dawn::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
return MTLVertexFormatInt3; return MTLVertexFormatInt3;
case dawn::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return MTLVertexFormatInt4; return MTLVertexFormatInt4;
} }
} }
MTLVertexStepFunction InputStepModeFunction(dawn::InputStepMode mode) { MTLVertexStepFunction InputStepModeFunction(wgpu::InputStepMode mode) {
switch (mode) { switch (mode) {
case dawn::InputStepMode::Vertex: case wgpu::InputStepMode::Vertex:
return MTLVertexStepFunctionPerVertex; return MTLVertexStepFunctionPerVertex;
case dawn::InputStepMode::Instance: case wgpu::InputStepMode::Instance:
return MTLVertexStepFunctionPerInstance; return MTLVertexStepFunctionPerInstance;
} }
} }
MTLPrimitiveType MTLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) { MTLPrimitiveType MTLPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) { switch (primitiveTopology) {
case dawn::PrimitiveTopology::PointList: case wgpu::PrimitiveTopology::PointList:
return MTLPrimitiveTypePoint; return MTLPrimitiveTypePoint;
case dawn::PrimitiveTopology::LineList: case wgpu::PrimitiveTopology::LineList:
return MTLPrimitiveTypeLine; return MTLPrimitiveTypeLine;
case dawn::PrimitiveTopology::LineStrip: case wgpu::PrimitiveTopology::LineStrip:
return MTLPrimitiveTypeLineStrip; return MTLPrimitiveTypeLineStrip;
case dawn::PrimitiveTopology::TriangleList: case wgpu::PrimitiveTopology::TriangleList:
return MTLPrimitiveTypeTriangle; return MTLPrimitiveTypeTriangle;
case dawn::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return MTLPrimitiveTypeTriangleStrip; return MTLPrimitiveTypeTriangleStrip;
} }
} }
MTLPrimitiveTopologyClass MTLInputPrimitiveTopology( MTLPrimitiveTopologyClass MTLInputPrimitiveTopology(
dawn::PrimitiveTopology primitiveTopology) { wgpu::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) { switch (primitiveTopology) {
case dawn::PrimitiveTopology::PointList: case wgpu::PrimitiveTopology::PointList:
return MTLPrimitiveTopologyClassPoint; return MTLPrimitiveTopologyClassPoint;
case dawn::PrimitiveTopology::LineList: case wgpu::PrimitiveTopology::LineList:
case dawn::PrimitiveTopology::LineStrip: case wgpu::PrimitiveTopology::LineStrip:
return MTLPrimitiveTopologyClassLine; return MTLPrimitiveTopologyClassLine;
case dawn::PrimitiveTopology::TriangleList: case wgpu::PrimitiveTopology::TriangleList:
case dawn::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return MTLPrimitiveTopologyClassTriangle; return MTLPrimitiveTopologyClassTriangle;
} }
} }
MTLIndexType MTLIndexFormat(dawn::IndexFormat format) { MTLIndexType MTLIndexFormat(wgpu::IndexFormat format) {
switch (format) { switch (format) {
case dawn::IndexFormat::Uint16: case wgpu::IndexFormat::Uint16:
return MTLIndexTypeUInt16; return MTLIndexTypeUInt16;
case dawn::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return MTLIndexTypeUInt32; return MTLIndexTypeUInt32;
} }
} }
MTLBlendFactor MetalBlendFactor(dawn::BlendFactor factor, bool alpha) { MTLBlendFactor MetalBlendFactor(wgpu::BlendFactor factor, bool alpha) {
switch (factor) { switch (factor) {
case dawn::BlendFactor::Zero: case wgpu::BlendFactor::Zero:
return MTLBlendFactorZero; return MTLBlendFactorZero;
case dawn::BlendFactor::One: case wgpu::BlendFactor::One:
return MTLBlendFactorOne; return MTLBlendFactorOne;
case dawn::BlendFactor::SrcColor: case wgpu::BlendFactor::SrcColor:
return MTLBlendFactorSourceColor; return MTLBlendFactorSourceColor;
case dawn::BlendFactor::OneMinusSrcColor: case wgpu::BlendFactor::OneMinusSrcColor:
return MTLBlendFactorOneMinusSourceColor; return MTLBlendFactorOneMinusSourceColor;
case dawn::BlendFactor::SrcAlpha: case wgpu::BlendFactor::SrcAlpha:
return MTLBlendFactorSourceAlpha; return MTLBlendFactorSourceAlpha;
case dawn::BlendFactor::OneMinusSrcAlpha: case wgpu::BlendFactor::OneMinusSrcAlpha:
return MTLBlendFactorOneMinusSourceAlpha; return MTLBlendFactorOneMinusSourceAlpha;
case dawn::BlendFactor::DstColor: case wgpu::BlendFactor::DstColor:
return MTLBlendFactorDestinationColor; return MTLBlendFactorDestinationColor;
case dawn::BlendFactor::OneMinusDstColor: case wgpu::BlendFactor::OneMinusDstColor:
return MTLBlendFactorOneMinusDestinationColor; return MTLBlendFactorOneMinusDestinationColor;
case dawn::BlendFactor::DstAlpha: case wgpu::BlendFactor::DstAlpha:
return MTLBlendFactorDestinationAlpha; return MTLBlendFactorDestinationAlpha;
case dawn::BlendFactor::OneMinusDstAlpha: case wgpu::BlendFactor::OneMinusDstAlpha:
return MTLBlendFactorOneMinusDestinationAlpha; return MTLBlendFactorOneMinusDestinationAlpha;
case dawn::BlendFactor::SrcAlphaSaturated: case wgpu::BlendFactor::SrcAlphaSaturated:
return MTLBlendFactorSourceAlphaSaturated; return MTLBlendFactorSourceAlphaSaturated;
case dawn::BlendFactor::BlendColor: case wgpu::BlendFactor::BlendColor:
return alpha ? MTLBlendFactorBlendAlpha : MTLBlendFactorBlendColor; return alpha ? MTLBlendFactorBlendAlpha : MTLBlendFactorBlendColor;
case dawn::BlendFactor::OneMinusBlendColor: case wgpu::BlendFactor::OneMinusBlendColor:
return alpha ? MTLBlendFactorOneMinusBlendAlpha return alpha ? MTLBlendFactorOneMinusBlendAlpha
: MTLBlendFactorOneMinusBlendColor; : MTLBlendFactorOneMinusBlendColor;
} }
} }
MTLBlendOperation MetalBlendOperation(dawn::BlendOperation operation) { MTLBlendOperation MetalBlendOperation(wgpu::BlendOperation operation) {
switch (operation) { switch (operation) {
case dawn::BlendOperation::Add: case wgpu::BlendOperation::Add:
return MTLBlendOperationAdd; return MTLBlendOperationAdd;
case dawn::BlendOperation::Subtract: case wgpu::BlendOperation::Subtract:
return MTLBlendOperationSubtract; return MTLBlendOperationSubtract;
case dawn::BlendOperation::ReverseSubtract: case wgpu::BlendOperation::ReverseSubtract:
return MTLBlendOperationReverseSubtract; return MTLBlendOperationReverseSubtract;
case dawn::BlendOperation::Min: case wgpu::BlendOperation::Min:
return MTLBlendOperationMin; return MTLBlendOperationMin;
case dawn::BlendOperation::Max: case wgpu::BlendOperation::Max:
return MTLBlendOperationMax; return MTLBlendOperationMax;
} }
} }
MTLColorWriteMask MetalColorWriteMask(dawn::ColorWriteMask writeMask, MTLColorWriteMask MetalColorWriteMask(wgpu::ColorWriteMask writeMask,
bool isDeclaredInFragmentShader) { bool isDeclaredInFragmentShader) {
if (!isDeclaredInFragmentShader) { if (!isDeclaredInFragmentShader) {
return MTLColorWriteMaskNone; return MTLColorWriteMaskNone;
@ -190,16 +190,16 @@ namespace dawn_native { namespace metal {
MTLColorWriteMask mask = MTLColorWriteMaskNone; MTLColorWriteMask mask = MTLColorWriteMaskNone;
if (writeMask & dawn::ColorWriteMask::Red) { if (writeMask & wgpu::ColorWriteMask::Red) {
mask |= MTLColorWriteMaskRed; mask |= MTLColorWriteMaskRed;
} }
if (writeMask & dawn::ColorWriteMask::Green) { if (writeMask & wgpu::ColorWriteMask::Green) {
mask |= MTLColorWriteMaskGreen; mask |= MTLColorWriteMaskGreen;
} }
if (writeMask & dawn::ColorWriteMask::Blue) { if (writeMask & wgpu::ColorWriteMask::Blue) {
mask |= MTLColorWriteMaskBlue; mask |= MTLColorWriteMaskBlue;
} }
if (writeMask & dawn::ColorWriteMask::Alpha) { if (writeMask & wgpu::ColorWriteMask::Alpha) {
mask |= MTLColorWriteMaskAlpha; mask |= MTLColorWriteMaskAlpha;
} }
@ -224,23 +224,23 @@ namespace dawn_native { namespace metal {
MetalColorWriteMask(descriptor->writeMask, isDeclaredInFragmentShader); MetalColorWriteMask(descriptor->writeMask, isDeclaredInFragmentShader);
} }
MTLStencilOperation MetalStencilOperation(dawn::StencilOperation stencilOperation) { MTLStencilOperation MetalStencilOperation(wgpu::StencilOperation stencilOperation) {
switch (stencilOperation) { switch (stencilOperation) {
case dawn::StencilOperation::Keep: case wgpu::StencilOperation::Keep:
return MTLStencilOperationKeep; return MTLStencilOperationKeep;
case dawn::StencilOperation::Zero: case wgpu::StencilOperation::Zero:
return MTLStencilOperationZero; return MTLStencilOperationZero;
case dawn::StencilOperation::Replace: case wgpu::StencilOperation::Replace:
return MTLStencilOperationReplace; return MTLStencilOperationReplace;
case dawn::StencilOperation::Invert: case wgpu::StencilOperation::Invert:
return MTLStencilOperationInvert; return MTLStencilOperationInvert;
case dawn::StencilOperation::IncrementClamp: case wgpu::StencilOperation::IncrementClamp:
return MTLStencilOperationIncrementClamp; return MTLStencilOperationIncrementClamp;
case dawn::StencilOperation::DecrementClamp: case wgpu::StencilOperation::DecrementClamp:
return MTLStencilOperationDecrementClamp; return MTLStencilOperationDecrementClamp;
case dawn::StencilOperation::IncrementWrap: case wgpu::StencilOperation::IncrementWrap:
return MTLStencilOperationIncrementWrap; return MTLStencilOperationIncrementWrap;
case dawn::StencilOperation::DecrementWrap: case wgpu::StencilOperation::DecrementWrap:
return MTLStencilOperationDecrementWrap; return MTLStencilOperationDecrementWrap;
} }
} }
@ -289,22 +289,22 @@ namespace dawn_native { namespace metal {
return mtlDepthStencilDescriptor; return mtlDepthStencilDescriptor;
} }
MTLWinding MTLFrontFace(dawn::FrontFace face) { MTLWinding MTLFrontFace(wgpu::FrontFace face) {
switch (face) { switch (face) {
case dawn::FrontFace::CW: case wgpu::FrontFace::CW:
return MTLWindingClockwise; return MTLWindingClockwise;
case dawn::FrontFace::CCW: case wgpu::FrontFace::CCW:
return MTLWindingCounterClockwise; return MTLWindingCounterClockwise;
} }
} }
MTLCullMode ToMTLCullMode(dawn::CullMode mode) { MTLCullMode ToMTLCullMode(wgpu::CullMode mode) {
switch (mode) { switch (mode) {
case dawn::CullMode::None: case wgpu::CullMode::None:
return MTLCullModeNone; return MTLCullModeNone;
case dawn::CullMode::Front: case wgpu::CullMode::Front:
return MTLCullModeFront; return MTLCullModeFront;
case dawn::CullMode::Back: case wgpu::CullMode::Back:
return MTLCullModeBack; return MTLCullModeBack;
} }
} }
@ -327,7 +327,7 @@ namespace dawn_native { namespace metal {
vertexEntryPoint, SingleShaderStage::Vertex, ToBackend(GetLayout())); vertexEntryPoint, SingleShaderStage::Vertex, ToBackend(GetLayout()));
descriptorMTL.vertexFunction = vertexData.function; descriptorMTL.vertexFunction = vertexData.function;
if (vertexData.needsStorageBufferLength) { if (vertexData.needsStorageBufferLength) {
mStagesRequiringStorageBufferLength |= dawn::ShaderStage::Vertex; mStagesRequiringStorageBufferLength |= wgpu::ShaderStage::Vertex;
} }
const ShaderModule* fragmentModule = ToBackend(descriptor->fragmentStage->module); const ShaderModule* fragmentModule = ToBackend(descriptor->fragmentStage->module);
@ -336,12 +336,12 @@ namespace dawn_native { namespace metal {
fragmentEntryPoint, SingleShaderStage::Fragment, ToBackend(GetLayout())); fragmentEntryPoint, SingleShaderStage::Fragment, ToBackend(GetLayout()));
descriptorMTL.fragmentFunction = fragmentData.function; descriptorMTL.fragmentFunction = fragmentData.function;
if (fragmentData.needsStorageBufferLength) { if (fragmentData.needsStorageBufferLength) {
mStagesRequiringStorageBufferLength |= dawn::ShaderStage::Fragment; mStagesRequiringStorageBufferLength |= wgpu::ShaderStage::Fragment;
} }
if (HasDepthStencilAttachment()) { if (HasDepthStencilAttachment()) {
// TODO(kainino@chromium.org): Handle depth-only and stencil-only formats. // TODO(kainino@chromium.org): Handle depth-only and stencil-only formats.
dawn::TextureFormat depthStencilFormat = GetDepthStencilFormat(); wgpu::TextureFormat depthStencilFormat = GetDepthStencilFormat();
descriptorMTL.depthAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat); descriptorMTL.depthAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
descriptorMTL.stencilAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat); descriptorMTL.stencilAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
} }
@ -372,7 +372,7 @@ namespace dawn_native { namespace metal {
[descriptorMTL release]; [descriptorMTL release];
if (error != nil) { if (error != nil) {
NSLog(@" error => %@", error); NSLog(@" error => %@", error);
device->HandleError(dawn::ErrorType::DeviceLost, device->HandleError(wgpu::ErrorType::DeviceLost,
"Error creating rendering pipeline state"); "Error creating rendering pipeline state");
return; return;
} }
@ -421,7 +421,7 @@ namespace dawn_native { namespace metal {
return mMtlVertexBufferIndices[dawnIndex]; return mMtlVertexBufferIndices[dawnIndex];
} }
dawn::ShaderStage RenderPipeline::GetStagesRequiringStorageBufferLength() const { wgpu::ShaderStage RenderPipeline::GetStagesRequiringStorageBufferLength() const {
return mStagesRequiringStorageBufferLength; return mStagesRequiringStorageBufferLength;
} }

View File

@ -20,31 +20,31 @@
namespace dawn_native { namespace metal { namespace dawn_native { namespace metal {
namespace { namespace {
MTLSamplerMinMagFilter FilterModeToMinMagFilter(dawn::FilterMode mode) { MTLSamplerMinMagFilter FilterModeToMinMagFilter(wgpu::FilterMode mode) {
switch (mode) { switch (mode) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
return MTLSamplerMinMagFilterNearest; return MTLSamplerMinMagFilterNearest;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
return MTLSamplerMinMagFilterLinear; return MTLSamplerMinMagFilterLinear;
} }
} }
MTLSamplerMipFilter FilterModeToMipFilter(dawn::FilterMode mode) { MTLSamplerMipFilter FilterModeToMipFilter(wgpu::FilterMode mode) {
switch (mode) { switch (mode) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
return MTLSamplerMipFilterNearest; return MTLSamplerMipFilterNearest;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
return MTLSamplerMipFilterLinear; return MTLSamplerMipFilterLinear;
} }
} }
MTLSamplerAddressMode AddressMode(dawn::AddressMode mode) { MTLSamplerAddressMode AddressMode(wgpu::AddressMode mode) {
switch (mode) { switch (mode) {
case dawn::AddressMode::Repeat: case wgpu::AddressMode::Repeat:
return MTLSamplerAddressModeRepeat; return MTLSamplerAddressModeRepeat;
case dawn::AddressMode::MirrorRepeat: case wgpu::AddressMode::MirrorRepeat:
return MTLSamplerAddressModeMirrorRepeat; return MTLSamplerAddressModeMirrorRepeat;
case dawn::AddressMode::ClampToEdge: case wgpu::AddressMode::ClampToEdge:
return MTLSamplerAddressModeClampToEdge; return MTLSamplerAddressModeClampToEdge;
} }
} }

View File

@ -38,7 +38,7 @@ namespace dawn_native { namespace metal {
DawnSwapChainNextTexture next = {}; DawnSwapChainNextTexture next = {};
DawnSwapChainError error = im.GetNextTexture(im.userData, &next); DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
if (error) { if (error) {
GetDevice()->HandleError(dawn::ErrorType::Unknown, error); GetDevice()->HandleError(wgpu::ErrorType::Unknown, error);
return nullptr; return nullptr;
} }

View File

@ -24,7 +24,7 @@ namespace dawn_native { namespace metal {
class Device; class Device;
MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format); MTLPixelFormat MetalPixelFormat(wgpu::TextureFormat format);
MaybeError ValidateIOSurfaceCanBeWrapped(const DeviceBase* device, MaybeError ValidateIOSurfaceCanBeWrapped(const DeviceBase* device,
const TextureDescriptor* descriptor, const TextureDescriptor* descriptor,
IOSurfaceRef ioSurface, IOSurfaceRef ioSurface,

View File

@ -20,24 +20,24 @@
namespace dawn_native { namespace metal { namespace dawn_native { namespace metal {
namespace { namespace {
bool UsageNeedsTextureView(dawn::TextureUsage usage) { bool UsageNeedsTextureView(wgpu::TextureUsage usage) {
constexpr dawn::TextureUsage kUsageNeedsTextureView = constexpr wgpu::TextureUsage kUsageNeedsTextureView =
dawn::TextureUsage::Storage | dawn::TextureUsage::Sampled; wgpu::TextureUsage::Storage | wgpu::TextureUsage::Sampled;
return usage & kUsageNeedsTextureView; return usage & kUsageNeedsTextureView;
} }
MTLTextureUsage MetalTextureUsage(dawn::TextureUsage usage) { MTLTextureUsage MetalTextureUsage(wgpu::TextureUsage usage) {
MTLTextureUsage result = MTLTextureUsageUnknown; // This is 0 MTLTextureUsage result = MTLTextureUsageUnknown; // This is 0
if (usage & (dawn::TextureUsage::Storage)) { if (usage & (wgpu::TextureUsage::Storage)) {
result |= MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead; result |= MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
} }
if (usage & (dawn::TextureUsage::Sampled)) { if (usage & (wgpu::TextureUsage::Sampled)) {
result |= MTLTextureUsageShaderRead; result |= MTLTextureUsageShaderRead;
} }
if (usage & (dawn::TextureUsage::OutputAttachment)) { if (usage & (wgpu::TextureUsage::OutputAttachment)) {
result |= MTLTextureUsageRenderTarget; result |= MTLTextureUsageRenderTarget;
} }
@ -48,11 +48,11 @@ namespace dawn_native { namespace metal {
return result; return result;
} }
MTLTextureType MetalTextureType(dawn::TextureDimension dimension, MTLTextureType MetalTextureType(wgpu::TextureDimension dimension,
unsigned int arrayLayers, unsigned int arrayLayers,
unsigned int sampleCount) { unsigned int sampleCount) {
switch (dimension) { switch (dimension) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
if (sampleCount > 1) { if (sampleCount > 1) {
ASSERT(arrayLayers == 1); ASSERT(arrayLayers == 1);
return MTLTextureType2DMultisample; return MTLTextureType2DMultisample;
@ -64,16 +64,16 @@ namespace dawn_native { namespace metal {
} }
} }
MTLTextureType MetalTextureViewType(dawn::TextureViewDimension dimension, MTLTextureType MetalTextureViewType(wgpu::TextureViewDimension dimension,
unsigned int sampleCount) { unsigned int sampleCount) {
switch (dimension) { switch (dimension) {
case dawn::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:
return (sampleCount > 1) ? MTLTextureType2DMultisample : MTLTextureType2D; return (sampleCount > 1) ? MTLTextureType2DMultisample : MTLTextureType2D;
case dawn::TextureViewDimension::e2DArray: case wgpu::TextureViewDimension::e2DArray:
return MTLTextureType2DArray; return MTLTextureType2DArray;
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
return MTLTextureTypeCube; return MTLTextureTypeCube;
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return MTLTextureTypeCubeArray; return MTLTextureTypeCubeArray;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -96,8 +96,8 @@ namespace dawn_native { namespace metal {
} }
switch (textureViewDescriptor->dimension) { switch (textureViewDescriptor->dimension) {
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return true; return true;
default: default:
break; break;
@ -106,16 +106,16 @@ namespace dawn_native { namespace metal {
return false; return false;
} }
ResultOrError<dawn::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t format) { ResultOrError<wgpu::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t format) {
switch (format) { switch (format) {
case 'RGBA': case 'RGBA':
return dawn::TextureFormat::RGBA8Unorm; return wgpu::TextureFormat::RGBA8Unorm;
case 'BGRA': case 'BGRA':
return dawn::TextureFormat::BGRA8Unorm; return wgpu::TextureFormat::BGRA8Unorm;
case '2C08': case '2C08':
return dawn::TextureFormat::RG8Unorm; return wgpu::TextureFormat::RG8Unorm;
case 'L008': case 'L008':
return dawn::TextureFormat::R8Unorm; return wgpu::TextureFormat::R8Unorm;
default: default:
return DAWN_VALIDATION_ERROR("Unsupported IOSurface format"); return DAWN_VALIDATION_ERROR("Unsupported IOSurface format");
} }
@ -130,118 +130,118 @@ namespace dawn_native { namespace metal {
#endif #endif
} }
MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format) { MTLPixelFormat MetalPixelFormat(wgpu::TextureFormat format) {
switch (format) { switch (format) {
case dawn::TextureFormat::R8Unorm: case wgpu::TextureFormat::R8Unorm:
return MTLPixelFormatR8Unorm; return MTLPixelFormatR8Unorm;
case dawn::TextureFormat::R8Snorm: case wgpu::TextureFormat::R8Snorm:
return MTLPixelFormatR8Snorm; return MTLPixelFormatR8Snorm;
case dawn::TextureFormat::R8Uint: case wgpu::TextureFormat::R8Uint:
return MTLPixelFormatR8Uint; return MTLPixelFormatR8Uint;
case dawn::TextureFormat::R8Sint: case wgpu::TextureFormat::R8Sint:
return MTLPixelFormatR8Sint; return MTLPixelFormatR8Sint;
case dawn::TextureFormat::R16Uint: case wgpu::TextureFormat::R16Uint:
return MTLPixelFormatR16Uint; return MTLPixelFormatR16Uint;
case dawn::TextureFormat::R16Sint: case wgpu::TextureFormat::R16Sint:
return MTLPixelFormatR16Sint; return MTLPixelFormatR16Sint;
case dawn::TextureFormat::R16Float: case wgpu::TextureFormat::R16Float:
return MTLPixelFormatR16Float; return MTLPixelFormatR16Float;
case dawn::TextureFormat::RG8Unorm: case wgpu::TextureFormat::RG8Unorm:
return MTLPixelFormatRG8Unorm; return MTLPixelFormatRG8Unorm;
case dawn::TextureFormat::RG8Snorm: case wgpu::TextureFormat::RG8Snorm:
return MTLPixelFormatRG8Snorm; return MTLPixelFormatRG8Snorm;
case dawn::TextureFormat::RG8Uint: case wgpu::TextureFormat::RG8Uint:
return MTLPixelFormatRG8Uint; return MTLPixelFormatRG8Uint;
case dawn::TextureFormat::RG8Sint: case wgpu::TextureFormat::RG8Sint:
return MTLPixelFormatRG8Sint; return MTLPixelFormatRG8Sint;
case dawn::TextureFormat::R32Uint: case wgpu::TextureFormat::R32Uint:
return MTLPixelFormatR32Uint; return MTLPixelFormatR32Uint;
case dawn::TextureFormat::R32Sint: case wgpu::TextureFormat::R32Sint:
return MTLPixelFormatR32Sint; return MTLPixelFormatR32Sint;
case dawn::TextureFormat::R32Float: case wgpu::TextureFormat::R32Float:
return MTLPixelFormatR32Float; return MTLPixelFormatR32Float;
case dawn::TextureFormat::RG16Uint: case wgpu::TextureFormat::RG16Uint:
return MTLPixelFormatRG16Uint; return MTLPixelFormatRG16Uint;
case dawn::TextureFormat::RG16Sint: case wgpu::TextureFormat::RG16Sint:
return MTLPixelFormatRG16Sint; return MTLPixelFormatRG16Sint;
case dawn::TextureFormat::RG16Float: case wgpu::TextureFormat::RG16Float:
return MTLPixelFormatRG16Float; return MTLPixelFormatRG16Float;
case dawn::TextureFormat::RGBA8Unorm: case wgpu::TextureFormat::RGBA8Unorm:
return MTLPixelFormatRGBA8Unorm; return MTLPixelFormatRGBA8Unorm;
case dawn::TextureFormat::RGBA8UnormSrgb: case wgpu::TextureFormat::RGBA8UnormSrgb:
return MTLPixelFormatRGBA8Unorm_sRGB; return MTLPixelFormatRGBA8Unorm_sRGB;
case dawn::TextureFormat::RGBA8Snorm: case wgpu::TextureFormat::RGBA8Snorm:
return MTLPixelFormatRGBA8Snorm; return MTLPixelFormatRGBA8Snorm;
case dawn::TextureFormat::RGBA8Uint: case wgpu::TextureFormat::RGBA8Uint:
return MTLPixelFormatRGBA8Uint; return MTLPixelFormatRGBA8Uint;
case dawn::TextureFormat::RGBA8Sint: case wgpu::TextureFormat::RGBA8Sint:
return MTLPixelFormatRGBA8Sint; return MTLPixelFormatRGBA8Sint;
case dawn::TextureFormat::BGRA8Unorm: case wgpu::TextureFormat::BGRA8Unorm:
return MTLPixelFormatBGRA8Unorm; return MTLPixelFormatBGRA8Unorm;
case dawn::TextureFormat::BGRA8UnormSrgb: case wgpu::TextureFormat::BGRA8UnormSrgb:
return MTLPixelFormatBGRA8Unorm_sRGB; return MTLPixelFormatBGRA8Unorm_sRGB;
case dawn::TextureFormat::RGB10A2Unorm: case wgpu::TextureFormat::RGB10A2Unorm:
return MTLPixelFormatRGB10A2Unorm; return MTLPixelFormatRGB10A2Unorm;
case dawn::TextureFormat::RG11B10Float: case wgpu::TextureFormat::RG11B10Float:
return MTLPixelFormatRG11B10Float; return MTLPixelFormatRG11B10Float;
case dawn::TextureFormat::RG32Uint: case wgpu::TextureFormat::RG32Uint:
return MTLPixelFormatRG32Uint; return MTLPixelFormatRG32Uint;
case dawn::TextureFormat::RG32Sint: case wgpu::TextureFormat::RG32Sint:
return MTLPixelFormatRG32Sint; return MTLPixelFormatRG32Sint;
case dawn::TextureFormat::RG32Float: case wgpu::TextureFormat::RG32Float:
return MTLPixelFormatRG32Float; return MTLPixelFormatRG32Float;
case dawn::TextureFormat::RGBA16Uint: case wgpu::TextureFormat::RGBA16Uint:
return MTLPixelFormatRGBA16Uint; return MTLPixelFormatRGBA16Uint;
case dawn::TextureFormat::RGBA16Sint: case wgpu::TextureFormat::RGBA16Sint:
return MTLPixelFormatRGBA16Sint; return MTLPixelFormatRGBA16Sint;
case dawn::TextureFormat::RGBA16Float: case wgpu::TextureFormat::RGBA16Float:
return MTLPixelFormatRGBA16Float; return MTLPixelFormatRGBA16Float;
case dawn::TextureFormat::RGBA32Uint: case wgpu::TextureFormat::RGBA32Uint:
return MTLPixelFormatRGBA32Uint; return MTLPixelFormatRGBA32Uint;
case dawn::TextureFormat::RGBA32Sint: case wgpu::TextureFormat::RGBA32Sint:
return MTLPixelFormatRGBA32Sint; return MTLPixelFormatRGBA32Sint;
case dawn::TextureFormat::RGBA32Float: case wgpu::TextureFormat::RGBA32Float:
return MTLPixelFormatRGBA32Float; return MTLPixelFormatRGBA32Float;
case dawn::TextureFormat::Depth32Float: case wgpu::TextureFormat::Depth32Float:
return MTLPixelFormatDepth32Float; return MTLPixelFormatDepth32Float;
case dawn::TextureFormat::Depth24Plus: case wgpu::TextureFormat::Depth24Plus:
return MTLPixelFormatDepth32Float; return MTLPixelFormatDepth32Float;
case dawn::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
return MTLPixelFormatDepth32Float_Stencil8; return MTLPixelFormatDepth32Float_Stencil8;
#if defined(DAWN_PLATFORM_MACOS) #if defined(DAWN_PLATFORM_MACOS)
case dawn::TextureFormat::BC1RGBAUnorm: case wgpu::TextureFormat::BC1RGBAUnorm:
return MTLPixelFormatBC1_RGBA; return MTLPixelFormatBC1_RGBA;
case dawn::TextureFormat::BC1RGBAUnormSrgb: case wgpu::TextureFormat::BC1RGBAUnormSrgb:
return MTLPixelFormatBC1_RGBA_sRGB; return MTLPixelFormatBC1_RGBA_sRGB;
case dawn::TextureFormat::BC2RGBAUnorm: case wgpu::TextureFormat::BC2RGBAUnorm:
return MTLPixelFormatBC2_RGBA; return MTLPixelFormatBC2_RGBA;
case dawn::TextureFormat::BC2RGBAUnormSrgb: case wgpu::TextureFormat::BC2RGBAUnormSrgb:
return MTLPixelFormatBC2_RGBA_sRGB; return MTLPixelFormatBC2_RGBA_sRGB;
case dawn::TextureFormat::BC3RGBAUnorm: case wgpu::TextureFormat::BC3RGBAUnorm:
return MTLPixelFormatBC3_RGBA; return MTLPixelFormatBC3_RGBA;
case dawn::TextureFormat::BC3RGBAUnormSrgb: case wgpu::TextureFormat::BC3RGBAUnormSrgb:
return MTLPixelFormatBC3_RGBA_sRGB; return MTLPixelFormatBC3_RGBA_sRGB;
case dawn::TextureFormat::BC4RSnorm: case wgpu::TextureFormat::BC4RSnorm:
return MTLPixelFormatBC4_RSnorm; return MTLPixelFormatBC4_RSnorm;
case dawn::TextureFormat::BC4RUnorm: case wgpu::TextureFormat::BC4RUnorm:
return MTLPixelFormatBC4_RUnorm; return MTLPixelFormatBC4_RUnorm;
case dawn::TextureFormat::BC5RGSnorm: case wgpu::TextureFormat::BC5RGSnorm:
return MTLPixelFormatBC5_RGSnorm; return MTLPixelFormatBC5_RGSnorm;
case dawn::TextureFormat::BC5RGUnorm: case wgpu::TextureFormat::BC5RGUnorm:
return MTLPixelFormatBC5_RGUnorm; return MTLPixelFormatBC5_RGUnorm;
case dawn::TextureFormat::BC6HRGBSfloat: case wgpu::TextureFormat::BC6HRGBSfloat:
return MTLPixelFormatBC6H_RGBFloat; return MTLPixelFormatBC6H_RGBFloat;
case dawn::TextureFormat::BC6HRGBUfloat: case wgpu::TextureFormat::BC6HRGBUfloat:
return MTLPixelFormatBC6H_RGBUfloat; return MTLPixelFormatBC6H_RGBUfloat;
case dawn::TextureFormat::BC7RGBAUnorm: case wgpu::TextureFormat::BC7RGBAUnorm:
return MTLPixelFormatBC7_RGBAUnorm; return MTLPixelFormatBC7_RGBAUnorm;
case dawn::TextureFormat::BC7RGBAUnormSrgb: case wgpu::TextureFormat::BC7RGBAUnormSrgb:
return MTLPixelFormatBC7_RGBAUnorm_sRGB; return MTLPixelFormatBC7_RGBAUnorm_sRGB;
#endif #endif
@ -261,7 +261,7 @@ namespace dawn_native { namespace metal {
return DAWN_VALIDATION_ERROR("IOSurface plane doesn't exist"); return DAWN_VALIDATION_ERROR("IOSurface plane doesn't exist");
} }
if (descriptor->dimension != dawn::TextureDimension::e2D) { if (descriptor->dimension != wgpu::TextureDimension::e2D) {
return DAWN_VALIDATION_ERROR("IOSurface texture must be 2D"); return DAWN_VALIDATION_ERROR("IOSurface texture must be 2D");
} }
@ -283,7 +283,7 @@ namespace dawn_native { namespace metal {
return DAWN_VALIDATION_ERROR("IOSurface size doesn't match descriptor"); return DAWN_VALIDATION_ERROR("IOSurface size doesn't match descriptor");
} }
dawn::TextureFormat ioSurfaceFormat; wgpu::TextureFormat ioSurfaceFormat;
DAWN_TRY_ASSIGN(ioSurfaceFormat, DAWN_TRY_ASSIGN(ioSurfaceFormat,
GetFormatEquivalentToIOSurfaceFormat(IOSurfaceGetPixelFormat(ioSurface))); GetFormatEquivalentToIOSurfaceFormat(IOSurfaceGetPixelFormat(ioSurface)));
if (descriptor->format != ioSurfaceFormat) { if (descriptor->format != ioSurfaceFormat) {

View File

@ -21,7 +21,7 @@
namespace dawn_native { namespace metal { namespace dawn_native { namespace metal {
MTLCompareFunction ToMetalCompareFunction(dawn::CompareFunction compareFunction); MTLCompareFunction ToMetalCompareFunction(wgpu::CompareFunction compareFunction);
}} // namespace dawn_native::metal }} // namespace dawn_native::metal

View File

@ -16,23 +16,23 @@
namespace dawn_native { namespace metal { namespace dawn_native { namespace metal {
MTLCompareFunction ToMetalCompareFunction(dawn::CompareFunction compareFunction) { MTLCompareFunction ToMetalCompareFunction(wgpu::CompareFunction compareFunction) {
switch (compareFunction) { switch (compareFunction) {
case dawn::CompareFunction::Never: case wgpu::CompareFunction::Never:
return MTLCompareFunctionNever; return MTLCompareFunctionNever;
case dawn::CompareFunction::Less: case wgpu::CompareFunction::Less:
return MTLCompareFunctionLess; return MTLCompareFunctionLess;
case dawn::CompareFunction::LessEqual: case wgpu::CompareFunction::LessEqual:
return MTLCompareFunctionLessEqual; return MTLCompareFunctionLessEqual;
case dawn::CompareFunction::Greater: case wgpu::CompareFunction::Greater:
return MTLCompareFunctionGreater; return MTLCompareFunctionGreater;
case dawn::CompareFunction::GreaterEqual: case wgpu::CompareFunction::GreaterEqual:
return MTLCompareFunctionGreaterEqual; return MTLCompareFunctionGreaterEqual;
case dawn::CompareFunction::NotEqual: case wgpu::CompareFunction::NotEqual:
return MTLCompareFunctionNotEqual; return MTLCompareFunctionNotEqual;
case dawn::CompareFunction::Equal: case wgpu::CompareFunction::Equal:
return MTLCompareFunctionEqual; return MTLCompareFunctionEqual;
case dawn::CompareFunction::Always: case wgpu::CompareFunction::Always:
return MTLCompareFunctionAlways; return MTLCompareFunctionAlways;
} }
} }

View File

@ -241,7 +241,7 @@ namespace dawn_native { namespace null {
bool Buffer::IsMapWritable() const { bool Buffer::IsMapWritable() const {
// Only return true for mappable buffers so we can test cases that need / don't need a // Only return true for mappable buffers so we can test cases that need / don't need a
// staging buffer. // staging buffer.
return (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0; return (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0;
} }
MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) { MaybeError Buffer::MapAtCreationImpl(uint8_t** mappedPointer) {
@ -363,8 +363,8 @@ namespace dawn_native { namespace null {
return DAWN_SWAP_CHAIN_NO_ERROR; return DAWN_SWAP_CHAIN_NO_ERROR;
} }
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const { wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
return dawn::TextureFormat::RGBA8Unorm; return wgpu::TextureFormat::RGBA8Unorm;
} }
// StagingBuffer // StagingBuffer

View File

@ -214,7 +214,7 @@ namespace dawn_native { namespace null {
uint32_t height); uint32_t height);
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture); DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
DawnSwapChainError Present(); DawnSwapChainError Present();
dawn::TextureFormat GetPreferredFormat() const; wgpu::TextureFormat GetPreferredFormat() const;
}; };
class StagingBuffer : public StagingBufferBase { class StagingBuffer : public StagingBufferBase {

View File

@ -36,96 +36,96 @@ namespace dawn_native { namespace opengl {
namespace { namespace {
GLenum IndexFormatType(dawn::IndexFormat format) { GLenum IndexFormatType(wgpu::IndexFormat format) {
switch (format) { switch (format) {
case dawn::IndexFormat::Uint16: case wgpu::IndexFormat::Uint16:
return GL_UNSIGNED_SHORT; return GL_UNSIGNED_SHORT;
case dawn::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return GL_UNSIGNED_INT; return GL_UNSIGNED_INT;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
GLenum VertexFormatType(dawn::VertexFormat format) { GLenum VertexFormatType(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case dawn::VertexFormat::UChar2: case wgpu::VertexFormat::UChar2:
case dawn::VertexFormat::UChar4: case wgpu::VertexFormat::UChar4:
case dawn::VertexFormat::UChar2Norm: case wgpu::VertexFormat::UChar2Norm:
case dawn::VertexFormat::UChar4Norm: case wgpu::VertexFormat::UChar4Norm:
return GL_UNSIGNED_BYTE; return GL_UNSIGNED_BYTE;
case dawn::VertexFormat::Char2: case wgpu::VertexFormat::Char2:
case dawn::VertexFormat::Char4: case wgpu::VertexFormat::Char4:
case dawn::VertexFormat::Char2Norm: case wgpu::VertexFormat::Char2Norm:
case dawn::VertexFormat::Char4Norm: case wgpu::VertexFormat::Char4Norm:
return GL_BYTE; return GL_BYTE;
case dawn::VertexFormat::UShort2: case wgpu::VertexFormat::UShort2:
case dawn::VertexFormat::UShort4: case wgpu::VertexFormat::UShort4:
case dawn::VertexFormat::UShort2Norm: case wgpu::VertexFormat::UShort2Norm:
case dawn::VertexFormat::UShort4Norm: case wgpu::VertexFormat::UShort4Norm:
return GL_UNSIGNED_SHORT; return GL_UNSIGNED_SHORT;
case dawn::VertexFormat::Short2: case wgpu::VertexFormat::Short2:
case dawn::VertexFormat::Short4: case wgpu::VertexFormat::Short4:
case dawn::VertexFormat::Short2Norm: case wgpu::VertexFormat::Short2Norm:
case dawn::VertexFormat::Short4Norm: case wgpu::VertexFormat::Short4Norm:
return GL_SHORT; return GL_SHORT;
case dawn::VertexFormat::Half2: case wgpu::VertexFormat::Half2:
case dawn::VertexFormat::Half4: case wgpu::VertexFormat::Half4:
return GL_HALF_FLOAT; return GL_HALF_FLOAT;
case dawn::VertexFormat::Float: case wgpu::VertexFormat::Float:
case dawn::VertexFormat::Float2: case wgpu::VertexFormat::Float2:
case dawn::VertexFormat::Float3: case wgpu::VertexFormat::Float3:
case dawn::VertexFormat::Float4: case wgpu::VertexFormat::Float4:
return GL_FLOAT; return GL_FLOAT;
case dawn::VertexFormat::UInt: case wgpu::VertexFormat::UInt:
case dawn::VertexFormat::UInt2: case wgpu::VertexFormat::UInt2:
case dawn::VertexFormat::UInt3: case wgpu::VertexFormat::UInt3:
case dawn::VertexFormat::UInt4: case wgpu::VertexFormat::UInt4:
return GL_UNSIGNED_INT; return GL_UNSIGNED_INT;
case dawn::VertexFormat::Int: case wgpu::VertexFormat::Int:
case dawn::VertexFormat::Int2: case wgpu::VertexFormat::Int2:
case dawn::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
case dawn::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return GL_INT; return GL_INT;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
GLboolean VertexFormatIsNormalized(dawn::VertexFormat format) { GLboolean VertexFormatIsNormalized(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case dawn::VertexFormat::UChar2Norm: case wgpu::VertexFormat::UChar2Norm:
case dawn::VertexFormat::UChar4Norm: case wgpu::VertexFormat::UChar4Norm:
case dawn::VertexFormat::Char2Norm: case wgpu::VertexFormat::Char2Norm:
case dawn::VertexFormat::Char4Norm: case wgpu::VertexFormat::Char4Norm:
case dawn::VertexFormat::UShort2Norm: case wgpu::VertexFormat::UShort2Norm:
case dawn::VertexFormat::UShort4Norm: case wgpu::VertexFormat::UShort4Norm:
case dawn::VertexFormat::Short2Norm: case wgpu::VertexFormat::Short2Norm:
case dawn::VertexFormat::Short4Norm: case wgpu::VertexFormat::Short4Norm:
return GL_TRUE; return GL_TRUE;
default: default:
return GL_FALSE; return GL_FALSE;
} }
} }
bool VertexFormatIsInt(dawn::VertexFormat format) { bool VertexFormatIsInt(wgpu::VertexFormat format) {
switch (format) { switch (format) {
case dawn::VertexFormat::UChar2: case wgpu::VertexFormat::UChar2:
case dawn::VertexFormat::UChar4: case wgpu::VertexFormat::UChar4:
case dawn::VertexFormat::Char2: case wgpu::VertexFormat::Char2:
case dawn::VertexFormat::Char4: case wgpu::VertexFormat::Char4:
case dawn::VertexFormat::UShort2: case wgpu::VertexFormat::UShort2:
case dawn::VertexFormat::UShort4: case wgpu::VertexFormat::UShort4:
case dawn::VertexFormat::Short2: case wgpu::VertexFormat::Short2:
case dawn::VertexFormat::Short4: case wgpu::VertexFormat::Short4:
case dawn::VertexFormat::UInt: case wgpu::VertexFormat::UInt:
case dawn::VertexFormat::UInt2: case wgpu::VertexFormat::UInt2:
case dawn::VertexFormat::UInt3: case wgpu::VertexFormat::UInt3:
case dawn::VertexFormat::UInt4: case wgpu::VertexFormat::UInt4:
case dawn::VertexFormat::Int: case wgpu::VertexFormat::Int:
case dawn::VertexFormat::Int2: case wgpu::VertexFormat::Int2:
case dawn::VertexFormat::Int3: case wgpu::VertexFormat::Int3:
case dawn::VertexFormat::Int4: case wgpu::VertexFormat::Int4:
return true; return true;
default: default:
return false; return false;
@ -242,7 +242,7 @@ namespace dawn_native { namespace opengl {
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) { for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
switch (layout.types[bindingIndex]) { switch (layout.types[bindingIndex]) {
case dawn::BindingType::UniformBuffer: { case wgpu::BindingType::UniformBuffer: {
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex); BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
GLuint buffer = ToBackend(binding.buffer)->GetHandle(); GLuint buffer = ToBackend(binding.buffer)->GetHandle();
GLuint uboIndex = indices[bindingIndex]; GLuint uboIndex = indices[bindingIndex];
@ -257,7 +257,7 @@ namespace dawn_native { namespace opengl {
binding.size); binding.size);
} break; } break;
case dawn::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex)); Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
GLuint samplerIndex = indices[bindingIndex]; GLuint samplerIndex = indices[bindingIndex];
@ -273,7 +273,7 @@ namespace dawn_native { namespace opengl {
} }
} break; } break;
case dawn::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
TextureView* view = TextureView* view =
ToBackend(group->GetBindingAsTextureView(bindingIndex)); ToBackend(group->GetBindingAsTextureView(bindingIndex));
GLuint handle = view->GetHandle(); GLuint handle = view->GetHandle();
@ -286,7 +286,7 @@ namespace dawn_native { namespace opengl {
} }
} break; } break;
case dawn::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex); BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
GLuint buffer = ToBackend(binding.buffer)->GetHandle(); GLuint buffer = ToBackend(binding.buffer)->GetHandle();
GLuint ssboIndex = indices[bindingIndex]; GLuint ssboIndex = indices[bindingIndex];
@ -301,8 +301,8 @@ namespace dawn_native { namespace opengl {
binding.size); binding.size);
} break; } break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
@ -410,7 +410,7 @@ namespace dawn_native { namespace opengl {
// We count the lazy clears for non output attachment textures in order to match the // We count the lazy clears for non output attachment textures in order to match the
// backdoor lazy clear counts in Vulkan and D3D12. // backdoor lazy clear counts in Vulkan and D3D12.
bool isLazyClear = bool isLazyClear =
!(usages.textureUsages[i] & dawn::TextureUsage::OutputAttachment); !(usages.textureUsages[i] & wgpu::TextureUsage::OutputAttachment);
texture->EnsureSubresourceContentInitialized( texture->EnsureSubresourceContentInitialized(
0, texture->GetNumMipLevels(), 0, texture->GetArrayLayers(), isLazyClear); 0, texture->GetNumMipLevels(), 0, texture->GetArrayLayers(), isLazyClear);
} }
@ -483,7 +483,7 @@ namespace dawn_native { namespace opengl {
gl.PixelStorei(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT, formatInfo.blockHeight); gl.PixelStorei(GL_UNPACK_COMPRESSED_BLOCK_HEIGHT, formatInfo.blockHeight);
gl.PixelStorei(GL_UNPACK_COMPRESSED_BLOCK_DEPTH, 1); gl.PixelStorei(GL_UNPACK_COMPRESSED_BLOCK_DEPTH, 1);
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D); ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
uint64_t copyDataSize = (copySize.width / formatInfo.blockWidth) * uint64_t copyDataSize = (copySize.width / formatInfo.blockWidth) *
(copySize.height / formatInfo.blockHeight) * (copySize.height / formatInfo.blockHeight) *
formatInfo.blockByteSize; formatInfo.blockByteSize;
@ -503,7 +503,7 @@ namespace dawn_native { namespace opengl {
} }
} else { } else {
switch (texture->GetDimension()) { switch (texture->GetDimension()) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
if (texture->GetArrayLayers() > 1) { if (texture->GetArrayLayers() > 1) {
gl.TexSubImage3D(target, dst.mipLevel, dst.origin.x, gl.TexSubImage3D(target, dst.mipLevel, dst.origin.x,
dst.origin.y, dst.arrayLayer, copySize.width, dst.origin.y, dst.arrayLayer, copySize.width,
@ -556,7 +556,7 @@ namespace dawn_native { namespace opengl {
gl.GenFramebuffers(1, &readFBO); gl.GenFramebuffers(1, &readFBO);
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, readFBO); gl.BindFramebuffer(GL_READ_FRAMEBUFFER, readFBO);
switch (texture->GetDimension()) { switch (texture->GetDimension()) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
if (texture->GetArrayLayers() > 1) { if (texture->GetArrayLayers() > 1) {
gl.FramebufferTextureLayer( gl.FramebufferTextureLayer(
GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture->GetHandle(), GL_READ_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, texture->GetHandle(),
@ -785,19 +785,19 @@ namespace dawn_native { namespace opengl {
// componentType: things work for now because the clear color is always a float, but // componentType: things work for now because the clear color is always a float, but
// when that's fixed will lose precision on integer formats when converting to // when that's fixed will lose precision on integer formats when converting to
// float. // float.
if (attachmentInfo->loadOp == dawn::LoadOp::Clear) { if (attachmentInfo->loadOp == wgpu::LoadOp::Clear) {
gl.ColorMaski(i, true, true, true, true); gl.ColorMaski(i, true, true, true, true);
gl.ClearBufferfv(GL_COLOR, i, &attachmentInfo->clearColor.r); gl.ClearBufferfv(GL_COLOR, i, &attachmentInfo->clearColor.r);
} }
switch (attachmentInfo->storeOp) { switch (attachmentInfo->storeOp) {
case dawn::StoreOp::Store: { case wgpu::StoreOp::Store: {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
true, view->GetBaseMipLevel(), view->GetLevelCount(), true, view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount()); view->GetBaseArrayLayer(), view->GetLayerCount());
} break; } break;
case dawn::StoreOp::Clear: { case wgpu::StoreOp::Clear: {
// TODO(natlee@microsoft.com): call glDiscard to do optimization // TODO(natlee@microsoft.com): call glDiscard to do optimization
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
false, view->GetBaseMipLevel(), view->GetLevelCount(), false, view->GetBaseMipLevel(), view->GetLevelCount(),
@ -817,9 +817,9 @@ namespace dawn_native { namespace opengl {
// Load op - depth/stencil // Load op - depth/stencil
bool doDepthClear = attachmentFormat.HasDepth() && bool doDepthClear = attachmentFormat.HasDepth() &&
(attachmentInfo->depthLoadOp == dawn::LoadOp::Clear); (attachmentInfo->depthLoadOp == wgpu::LoadOp::Clear);
bool doStencilClear = attachmentFormat.HasStencil() && bool doStencilClear = attachmentFormat.HasStencil() &&
(attachmentInfo->stencilLoadOp == dawn::LoadOp::Clear); (attachmentInfo->stencilLoadOp == wgpu::LoadOp::Clear);
if (doDepthClear) { if (doDepthClear) {
gl.DepthMask(GL_TRUE); gl.DepthMask(GL_TRUE);
@ -838,13 +838,13 @@ namespace dawn_native { namespace opengl {
gl.ClearBufferiv(GL_STENCIL, 0, &clearStencil); gl.ClearBufferiv(GL_STENCIL, 0, &clearStencil);
} }
if (attachmentInfo->depthStoreOp == dawn::StoreOp::Store && if (attachmentInfo->depthStoreOp == wgpu::StoreOp::Store &&
attachmentInfo->stencilStoreOp == dawn::StoreOp::Store) { attachmentInfo->stencilStoreOp == wgpu::StoreOp::Store) {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
true, view->GetBaseMipLevel(), view->GetLevelCount(), true, view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount()); view->GetBaseArrayLayer(), view->GetLayerCount());
} else if (attachmentInfo->depthStoreOp == dawn::StoreOp::Clear && } else if (attachmentInfo->depthStoreOp == wgpu::StoreOp::Clear &&
attachmentInfo->stencilStoreOp == dawn::StoreOp::Clear) { attachmentInfo->stencilStoreOp == wgpu::StoreOp::Clear) {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
false, view->GetBaseMipLevel(), view->GetLevelCount(), false, view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount()); view->GetBaseArrayLayer(), view->GetLayerCount());
@ -882,7 +882,7 @@ namespace dawn_native { namespace opengl {
inputBuffers.Apply(gl); inputBuffers.Apply(gl);
bindGroupTracker.Apply(gl); bindGroupTracker.Apply(gl);
dawn::IndexFormat indexFormat = wgpu::IndexFormat indexFormat =
lastPipeline->GetVertexInputDescriptor()->indexFormat; lastPipeline->GetVertexInputDescriptor()->indexFormat;
size_t formatSize = IndexFormatSize(indexFormat); size_t formatSize = IndexFormatSize(indexFormat);
GLenum formatType = IndexFormatType(indexFormat); GLenum formatType = IndexFormatType(indexFormat);
@ -922,7 +922,7 @@ namespace dawn_native { namespace opengl {
inputBuffers.Apply(gl); inputBuffers.Apply(gl);
bindGroupTracker.Apply(gl); bindGroupTracker.Apply(gl);
dawn::IndexFormat indexFormat = wgpu::IndexFormat indexFormat =
lastPipeline->GetVertexInputDescriptor()->indexFormat; lastPipeline->GetVertexInputDescriptor()->indexFormat;
GLenum formatType = IndexFormatType(indexFormat); GLenum formatType = IndexFormatType(indexFormat);

View File

@ -21,7 +21,7 @@ namespace dawn_native { namespace opengl {
using Type = GLFormat::ComponentType; using Type = GLFormat::ComponentType;
auto AddFormat = [&table](dawn::TextureFormat dawnFormat, GLenum internalFormat, auto AddFormat = [&table](wgpu::TextureFormat dawnFormat, GLenum internalFormat,
GLenum format, GLenum type, Type componentType) { GLenum format, GLenum type, Type componentType) {
size_t index = ComputeFormatIndex(dawnFormat); size_t index = ComputeFormatIndex(dawnFormat);
ASSERT(index < table.size()); ASSERT(index < table.size());
@ -44,71 +44,71 @@ namespace dawn_native { namespace opengl {
// clang-format off // clang-format off
// 1 byte color formats // 1 byte color formats
AddFormat(dawn::TextureFormat::R8Unorm, GL_R8, GL_RED, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::R8Unorm, GL_R8, GL_RED, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::R8Snorm, GL_R8_SNORM, GL_RED, GL_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::R8Snorm, GL_R8_SNORM, GL_RED, GL_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::R8Uint, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, Type::Uint); AddFormat(wgpu::TextureFormat::R8Uint, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, Type::Uint);
AddFormat(dawn::TextureFormat::R8Sint, GL_R8I, GL_RED_INTEGER, GL_BYTE, Type::Int); AddFormat(wgpu::TextureFormat::R8Sint, GL_R8I, GL_RED_INTEGER, GL_BYTE, Type::Int);
// 2 bytes color formats // 2 bytes color formats
AddFormat(dawn::TextureFormat::R16Uint, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, Type::Uint); AddFormat(wgpu::TextureFormat::R16Uint, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, Type::Uint);
AddFormat(dawn::TextureFormat::R16Sint, GL_R16I, GL_RED_INTEGER, GL_SHORT, Type::Int); AddFormat(wgpu::TextureFormat::R16Sint, GL_R16I, GL_RED_INTEGER, GL_SHORT, Type::Int);
AddFormat(dawn::TextureFormat::R16Float, GL_R16F, GL_RED, GL_HALF_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::R16Float, GL_R16F, GL_RED, GL_HALF_FLOAT, Type::Float);
AddFormat(dawn::TextureFormat::RG8Unorm, GL_RG8, GL_RG, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::RG8Unorm, GL_RG8, GL_RG, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::RG8Snorm, GL_RG8_SNORM, GL_RG, GL_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::RG8Snorm, GL_RG8_SNORM, GL_RG, GL_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::RG8Uint, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, Type::Uint); AddFormat(wgpu::TextureFormat::RG8Uint, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, Type::Uint);
AddFormat(dawn::TextureFormat::RG8Sint, GL_RG8I, GL_RG_INTEGER, GL_BYTE, Type::Int); AddFormat(wgpu::TextureFormat::RG8Sint, GL_RG8I, GL_RG_INTEGER, GL_BYTE, Type::Int);
// 4 bytes color formats // 4 bytes color formats
AddFormat(dawn::TextureFormat::R32Uint, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, Type::Uint); AddFormat(wgpu::TextureFormat::R32Uint, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, Type::Uint);
AddFormat(dawn::TextureFormat::R32Sint, GL_R32I, GL_RED_INTEGER, GL_INT, Type::Int); AddFormat(wgpu::TextureFormat::R32Sint, GL_R32I, GL_RED_INTEGER, GL_INT, Type::Int);
AddFormat(dawn::TextureFormat::R32Float, GL_R32F, GL_RED, GL_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::R32Float, GL_R32F, GL_RED, GL_FLOAT, Type::Float);
AddFormat(dawn::TextureFormat::RG16Uint, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, Type::Uint); AddFormat(wgpu::TextureFormat::RG16Uint, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, Type::Uint);
AddFormat(dawn::TextureFormat::RG16Sint, GL_RG16I, GL_RG_INTEGER, GL_SHORT, Type::Int); AddFormat(wgpu::TextureFormat::RG16Sint, GL_RG16I, GL_RG_INTEGER, GL_SHORT, Type::Int);
AddFormat(dawn::TextureFormat::RG16Float, GL_RG16F, GL_RG, GL_HALF_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::RG16Float, GL_RG16F, GL_RG, GL_HALF_FLOAT, Type::Float);
AddFormat(dawn::TextureFormat::RGBA8Unorm, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::RGBA8Unorm, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::RGBA8UnormSrgb, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::RGBA8UnormSrgb, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::RGBA8Snorm, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::RGBA8Snorm, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::RGBA8Uint, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, Type::Uint); AddFormat(wgpu::TextureFormat::RGBA8Uint, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, Type::Uint);
AddFormat(dawn::TextureFormat::RGBA8Sint, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE, Type::Int); AddFormat(wgpu::TextureFormat::RGBA8Sint, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE, Type::Int);
// This doesn't have an enum for the internal format in OpenGL, so use RGBA8. // This doesn't have an enum for the internal format in OpenGL, so use RGBA8.
AddFormat(dawn::TextureFormat::BGRA8Unorm, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BGRA8Unorm, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::RGB10A2Unorm, GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, Type::Float); AddFormat(wgpu::TextureFormat::RGB10A2Unorm, GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_REV, Type::Float);
AddFormat(dawn::TextureFormat::RG11B10Float, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, Type::Float); AddFormat(wgpu::TextureFormat::RG11B10Float, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, Type::Float);
// 8 bytes color formats // 8 bytes color formats
AddFormat(dawn::TextureFormat::RG32Uint, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, Type::Uint); AddFormat(wgpu::TextureFormat::RG32Uint, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, Type::Uint);
AddFormat(dawn::TextureFormat::RG32Sint, GL_RG32I, GL_RG_INTEGER, GL_INT, Type::Int); AddFormat(wgpu::TextureFormat::RG32Sint, GL_RG32I, GL_RG_INTEGER, GL_INT, Type::Int);
AddFormat(dawn::TextureFormat::RG32Float, GL_RG32F, GL_RG, GL_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::RG32Float, GL_RG32F, GL_RG, GL_FLOAT, Type::Float);
AddFormat(dawn::TextureFormat::RGBA16Uint, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, Type::Uint); AddFormat(wgpu::TextureFormat::RGBA16Uint, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, Type::Uint);
AddFormat(dawn::TextureFormat::RGBA16Sint, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, Type::Int); AddFormat(wgpu::TextureFormat::RGBA16Sint, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, Type::Int);
AddFormat(dawn::TextureFormat::RGBA16Float, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::RGBA16Float, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, Type::Float);
// 16 bytes color formats // 16 bytes color formats
AddFormat(dawn::TextureFormat::RGBA32Uint, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, Type::Uint); AddFormat(wgpu::TextureFormat::RGBA32Uint, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, Type::Uint);
AddFormat(dawn::TextureFormat::RGBA32Sint, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, Type::Int); AddFormat(wgpu::TextureFormat::RGBA32Sint, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, Type::Int);
AddFormat(dawn::TextureFormat::RGBA32Float, GL_RGBA32F, GL_RGBA, GL_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::RGBA32Float, GL_RGBA32F, GL_RGBA, GL_FLOAT, Type::Float);
// Depth stencil formats // Depth stencil formats
AddFormat(dawn::TextureFormat::Depth32Float, GL_DEPTH_COMPONENT32F, GL_DEPTH, GL_FLOAT, Type::DepthStencil); AddFormat(wgpu::TextureFormat::Depth32Float, GL_DEPTH_COMPONENT32F, GL_DEPTH, GL_FLOAT, Type::DepthStencil);
AddFormat(dawn::TextureFormat::Depth24Plus, GL_DEPTH_COMPONENT32F, GL_DEPTH, GL_FLOAT, Type::DepthStencil); AddFormat(wgpu::TextureFormat::Depth24Plus, GL_DEPTH_COMPONENT32F, GL_DEPTH, GL_FLOAT, Type::DepthStencil);
AddFormat(dawn::TextureFormat::Depth24PlusStencil8, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, Type::DepthStencil); AddFormat(wgpu::TextureFormat::Depth24PlusStencil8, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, Type::DepthStencil);
// Block compressed formats // Block compressed formats
AddFormat(dawn::TextureFormat::BC1RGBAUnorm, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC1RGBAUnorm, GL_COMPRESSED_RGBA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC1RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC1RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT1_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC2RGBAUnorm, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC2RGBAUnorm, GL_COMPRESSED_RGBA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC2RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC2RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT3_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC3RGBAUnorm, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC3RGBAUnorm, GL_COMPRESSED_RGBA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC3RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC3RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_S3TC_DXT5_EXT, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC4RSnorm, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_RED, GL_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC4RSnorm, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_RED, GL_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC4RUnorm, GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC4RUnorm, GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC5RGSnorm, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC5RGSnorm, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC5RGUnorm, GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC5RGUnorm, GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC6HRGBSfloat, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_HALF_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::BC6HRGBSfloat, GL_COMPRESSED_RGB_BPTC_SIGNED_FLOAT, GL_RGB, GL_HALF_FLOAT, Type::Float);
AddFormat(dawn::TextureFormat::BC6HRGBUfloat, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_HALF_FLOAT, Type::Float); AddFormat(wgpu::TextureFormat::BC6HRGBUfloat, GL_COMPRESSED_RGB_BPTC_UNSIGNED_FLOAT, GL_RGB, GL_HALF_FLOAT, Type::Float);
AddFormat(dawn::TextureFormat::BC7RGBAUnorm, GL_COMPRESSED_RGBA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC7RGBAUnorm, GL_COMPRESSED_RGBA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
AddFormat(dawn::TextureFormat::BC7RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float); AddFormat(wgpu::TextureFormat::BC7RGBAUnormSrgb, GL_COMPRESSED_SRGB_ALPHA_BPTC_UNORM, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
// clang-format on // clang-format on

View File

@ -80,8 +80,8 @@ namespace dawn_native { namespace opengl {
return DAWN_SWAP_CHAIN_NO_ERROR; return DAWN_SWAP_CHAIN_NO_ERROR;
} }
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const { wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
return dawn::TextureFormat::RGBA8Unorm; return wgpu::TextureFormat::RGBA8Unorm;
} }
}} // namespace dawn_native::opengl }} // namespace dawn_native::opengl

View File

@ -39,7 +39,7 @@ namespace dawn_native { namespace opengl {
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture); DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
DawnSwapChainError Present(); DawnSwapChainError Present();
dawn::TextureFormat GetPreferredFormat() const; wgpu::TextureFormat GetPreferredFormat() const;
private: private:
PresentCallback mPresentCallback; PresentCallback mPresentCallback;

View File

@ -74,7 +74,7 @@ namespace dawn_native { namespace opengl {
mProgram = gl.CreateProgram(); mProgram = gl.CreateProgram();
dawn::ShaderStage activeStages = dawn::ShaderStage::None; wgpu::ShaderStage activeStages = wgpu::ShaderStage::None;
for (SingleShaderStage stage : IterateStages(kAllStages)) { for (SingleShaderStage stage : IterateStages(kAllStages)) {
if (modules[stage] != nullptr) { if (modules[stage] != nullptr) {
activeStages |= StageBit(stage); activeStages |= StageBit(stage);
@ -118,14 +118,14 @@ namespace dawn_native { namespace opengl {
std::string name = GetBindingName(group, binding); std::string name = GetBindingName(group, binding);
switch (groupInfo.types[binding]) { switch (groupInfo.types[binding]) {
case dawn::BindingType::UniformBuffer: { case wgpu::BindingType::UniformBuffer: {
GLint location = gl.GetUniformBlockIndex(mProgram, name.c_str()); GLint location = gl.GetUniformBlockIndex(mProgram, name.c_str());
if (location != -1) { if (location != -1) {
gl.UniformBlockBinding(mProgram, location, indices[group][binding]); gl.UniformBlockBinding(mProgram, location, indices[group][binding]);
} }
} break; } break;
case dawn::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
GLuint location = gl.GetProgramResourceIndex( GLuint location = gl.GetProgramResourceIndex(
mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str()); mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str());
if (location != GL_INVALID_INDEX) { if (location != GL_INVALID_INDEX) {
@ -134,14 +134,14 @@ namespace dawn_native { namespace opengl {
} }
} break; } break;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
// These binding types are handled in the separate sampler and texture // These binding types are handled in the separate sampler and texture
// emulation // emulation
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;
@ -177,11 +177,11 @@ namespace dawn_native { namespace opengl {
indices[combined.textureLocation.group][combined.textureLocation.binding]; indices[combined.textureLocation.group][combined.textureLocation.binding];
mUnitsForTextures[textureIndex].push_back(textureUnit); mUnitsForTextures[textureIndex].push_back(textureUnit);
dawn::TextureComponentType componentType = wgpu::TextureComponentType componentType =
layout->GetBindGroupLayout(combined.textureLocation.group) layout->GetBindGroupLayout(combined.textureLocation.group)
->GetBindingInfo() ->GetBindingInfo()
.textureComponentTypes[combined.textureLocation.binding]; .textureComponentTypes[combined.textureLocation.binding];
bool shouldUseFiltering = componentType == dawn::TextureComponentType::Float; bool shouldUseFiltering = componentType == wgpu::TextureComponentType::Float;
GLuint samplerIndex = GLuint samplerIndex =
indices[combined.samplerLocation.group][combined.samplerLocation.binding]; indices[combined.samplerLocation.group][combined.samplerLocation.binding];

View File

@ -36,26 +36,26 @@ namespace dawn_native { namespace opengl {
} }
switch (groupInfo.types[binding]) { switch (groupInfo.types[binding]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
mIndexInfo[group][binding] = uboIndex; mIndexInfo[group][binding] = uboIndex;
uboIndex++; uboIndex++;
break; break;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
mIndexInfo[group][binding] = samplerIndex; mIndexInfo[group][binding] = samplerIndex;
samplerIndex++; samplerIndex++;
break; break;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
mIndexInfo[group][binding] = sampledTextureIndex; mIndexInfo[group][binding] = sampledTextureIndex;
sampledTextureIndex++; sampledTextureIndex++;
break; break;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
mIndexInfo[group][binding] = ssboIndex; mIndexInfo[group][binding] = ssboIndex;
ssboIndex++; ssboIndex++;
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
UNREACHABLE(); UNREACHABLE();
break; break;

View File

@ -23,17 +23,17 @@ namespace dawn_native { namespace opengl {
namespace { namespace {
GLenum GLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) { GLenum GLPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) {
switch (primitiveTopology) { switch (primitiveTopology) {
case dawn::PrimitiveTopology::PointList: case wgpu::PrimitiveTopology::PointList:
return GL_POINTS; return GL_POINTS;
case dawn::PrimitiveTopology::LineList: case wgpu::PrimitiveTopology::LineList:
return GL_LINES; return GL_LINES;
case dawn::PrimitiveTopology::LineStrip: case wgpu::PrimitiveTopology::LineStrip:
return GL_LINE_STRIP; return GL_LINE_STRIP;
case dawn::PrimitiveTopology::TriangleList: case wgpu::PrimitiveTopology::TriangleList:
return GL_TRIANGLES; return GL_TRIANGLES;
case dawn::PrimitiveTopology::TriangleStrip: case wgpu::PrimitiveTopology::TriangleStrip:
return GL_TRIANGLE_STRIP; return GL_TRIANGLE_STRIP;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -41,66 +41,66 @@ namespace dawn_native { namespace opengl {
} }
void ApplyFrontFaceAndCulling(const OpenGLFunctions& gl, void ApplyFrontFaceAndCulling(const OpenGLFunctions& gl,
dawn::FrontFace face, wgpu::FrontFace face,
dawn::CullMode mode) { wgpu::CullMode mode) {
if (mode == dawn::CullMode::None) { if (mode == wgpu::CullMode::None) {
gl.Disable(GL_CULL_FACE); gl.Disable(GL_CULL_FACE);
} else { } else {
gl.Enable(GL_CULL_FACE); gl.Enable(GL_CULL_FACE);
// Note that we invert winding direction in OpenGL. Because Y axis is up in OpenGL, // Note that we invert winding direction in OpenGL. Because Y axis is up in OpenGL,
// which is different from WebGPU and other backends (Y axis is down). // which is different from WebGPU and other backends (Y axis is down).
GLenum direction = (face == dawn::FrontFace::CCW) ? GL_CW : GL_CCW; GLenum direction = (face == wgpu::FrontFace::CCW) ? GL_CW : GL_CCW;
gl.FrontFace(direction); gl.FrontFace(direction);
GLenum cullMode = (mode == dawn::CullMode::Front) ? GL_FRONT : GL_BACK; GLenum cullMode = (mode == wgpu::CullMode::Front) ? GL_FRONT : GL_BACK;
gl.CullFace(cullMode); gl.CullFace(cullMode);
} }
} }
GLenum GLBlendFactor(dawn::BlendFactor factor, bool alpha) { GLenum GLBlendFactor(wgpu::BlendFactor factor, bool alpha) {
switch (factor) { switch (factor) {
case dawn::BlendFactor::Zero: case wgpu::BlendFactor::Zero:
return GL_ZERO; return GL_ZERO;
case dawn::BlendFactor::One: case wgpu::BlendFactor::One:
return GL_ONE; return GL_ONE;
case dawn::BlendFactor::SrcColor: case wgpu::BlendFactor::SrcColor:
return GL_SRC_COLOR; return GL_SRC_COLOR;
case dawn::BlendFactor::OneMinusSrcColor: case wgpu::BlendFactor::OneMinusSrcColor:
return GL_ONE_MINUS_SRC_COLOR; return GL_ONE_MINUS_SRC_COLOR;
case dawn::BlendFactor::SrcAlpha: case wgpu::BlendFactor::SrcAlpha:
return GL_SRC_ALPHA; return GL_SRC_ALPHA;
case dawn::BlendFactor::OneMinusSrcAlpha: case wgpu::BlendFactor::OneMinusSrcAlpha:
return GL_ONE_MINUS_SRC_ALPHA; return GL_ONE_MINUS_SRC_ALPHA;
case dawn::BlendFactor::DstColor: case wgpu::BlendFactor::DstColor:
return GL_DST_COLOR; return GL_DST_COLOR;
case dawn::BlendFactor::OneMinusDstColor: case wgpu::BlendFactor::OneMinusDstColor:
return GL_ONE_MINUS_DST_COLOR; return GL_ONE_MINUS_DST_COLOR;
case dawn::BlendFactor::DstAlpha: case wgpu::BlendFactor::DstAlpha:
return GL_DST_ALPHA; return GL_DST_ALPHA;
case dawn::BlendFactor::OneMinusDstAlpha: case wgpu::BlendFactor::OneMinusDstAlpha:
return GL_ONE_MINUS_DST_ALPHA; return GL_ONE_MINUS_DST_ALPHA;
case dawn::BlendFactor::SrcAlphaSaturated: case wgpu::BlendFactor::SrcAlphaSaturated:
return GL_SRC_ALPHA_SATURATE; return GL_SRC_ALPHA_SATURATE;
case dawn::BlendFactor::BlendColor: case wgpu::BlendFactor::BlendColor:
return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR; return alpha ? GL_CONSTANT_ALPHA : GL_CONSTANT_COLOR;
case dawn::BlendFactor::OneMinusBlendColor: case wgpu::BlendFactor::OneMinusBlendColor:
return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR; return alpha ? GL_ONE_MINUS_CONSTANT_ALPHA : GL_ONE_MINUS_CONSTANT_COLOR;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
GLenum GLBlendMode(dawn::BlendOperation operation) { GLenum GLBlendMode(wgpu::BlendOperation operation) {
switch (operation) { switch (operation) {
case dawn::BlendOperation::Add: case wgpu::BlendOperation::Add:
return GL_FUNC_ADD; return GL_FUNC_ADD;
case dawn::BlendOperation::Subtract: case wgpu::BlendOperation::Subtract:
return GL_FUNC_SUBTRACT; return GL_FUNC_SUBTRACT;
case dawn::BlendOperation::ReverseSubtract: case wgpu::BlendOperation::ReverseSubtract:
return GL_FUNC_REVERSE_SUBTRACT; return GL_FUNC_REVERSE_SUBTRACT;
case dawn::BlendOperation::Min: case wgpu::BlendOperation::Min:
return GL_MIN; return GL_MIN;
case dawn::BlendOperation::Max: case wgpu::BlendOperation::Max:
return GL_MAX; return GL_MAX;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -122,29 +122,29 @@ namespace dawn_native { namespace opengl {
} else { } else {
gl.Disablei(GL_BLEND, attachment); gl.Disablei(GL_BLEND, attachment);
} }
gl.ColorMaski(attachment, descriptor->writeMask & dawn::ColorWriteMask::Red, gl.ColorMaski(attachment, descriptor->writeMask & wgpu::ColorWriteMask::Red,
descriptor->writeMask & dawn::ColorWriteMask::Green, descriptor->writeMask & wgpu::ColorWriteMask::Green,
descriptor->writeMask & dawn::ColorWriteMask::Blue, descriptor->writeMask & wgpu::ColorWriteMask::Blue,
descriptor->writeMask & dawn::ColorWriteMask::Alpha); descriptor->writeMask & wgpu::ColorWriteMask::Alpha);
} }
GLuint OpenGLStencilOperation(dawn::StencilOperation stencilOperation) { GLuint OpenGLStencilOperation(wgpu::StencilOperation stencilOperation) {
switch (stencilOperation) { switch (stencilOperation) {
case dawn::StencilOperation::Keep: case wgpu::StencilOperation::Keep:
return GL_KEEP; return GL_KEEP;
case dawn::StencilOperation::Zero: case wgpu::StencilOperation::Zero:
return GL_ZERO; return GL_ZERO;
case dawn::StencilOperation::Replace: case wgpu::StencilOperation::Replace:
return GL_REPLACE; return GL_REPLACE;
case dawn::StencilOperation::Invert: case wgpu::StencilOperation::Invert:
return GL_INVERT; return GL_INVERT;
case dawn::StencilOperation::IncrementClamp: case wgpu::StencilOperation::IncrementClamp:
return GL_INCR; return GL_INCR;
case dawn::StencilOperation::DecrementClamp: case wgpu::StencilOperation::DecrementClamp:
return GL_DECR; return GL_DECR;
case dawn::StencilOperation::IncrementWrap: case wgpu::StencilOperation::IncrementWrap:
return GL_INCR_WRAP; return GL_INCR_WRAP;
case dawn::StencilOperation::DecrementWrap: case wgpu::StencilOperation::DecrementWrap:
return GL_DECR_WRAP; return GL_DECR_WRAP;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -155,7 +155,7 @@ namespace dawn_native { namespace opengl {
const DepthStencilStateDescriptor* descriptor, const DepthStencilStateDescriptor* descriptor,
PersistentPipelineState* persistentPipelineState) { PersistentPipelineState* persistentPipelineState) {
// Depth writes only occur if depth is enabled // Depth writes only occur if depth is enabled
if (descriptor->depthCompare == dawn::CompareFunction::Always && if (descriptor->depthCompare == wgpu::CompareFunction::Always &&
!descriptor->depthWriteEnabled) { !descriptor->depthWriteEnabled) {
gl.Disable(GL_DEPTH_TEST); gl.Disable(GL_DEPTH_TEST);
} else { } else {
@ -234,9 +234,9 @@ namespace dawn_native { namespace opengl {
gl.VertexAttribDivisor(location, 0xffffffff); gl.VertexAttribDivisor(location, 0xffffffff);
} else { } else {
switch (input.stepMode) { switch (input.stepMode) {
case dawn::InputStepMode::Vertex: case wgpu::InputStepMode::Vertex:
break; break;
case dawn::InputStepMode::Instance: case wgpu::InputStepMode::Instance:
gl.VertexAttribDivisor(location, 1); gl.VertexAttribDivisor(location, 1);
break; break;
default: default:

View File

@ -21,33 +21,33 @@
namespace dawn_native { namespace opengl { namespace dawn_native { namespace opengl {
namespace { namespace {
GLenum MagFilterMode(dawn::FilterMode filter) { GLenum MagFilterMode(wgpu::FilterMode filter) {
switch (filter) { switch (filter) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
return GL_NEAREST; return GL_NEAREST;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
return GL_LINEAR; return GL_LINEAR;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
GLenum MinFilterMode(dawn::FilterMode minFilter, dawn::FilterMode mipMapFilter) { GLenum MinFilterMode(wgpu::FilterMode minFilter, wgpu::FilterMode mipMapFilter) {
switch (minFilter) { switch (minFilter) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
switch (mipMapFilter) { switch (mipMapFilter) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
return GL_NEAREST_MIPMAP_NEAREST; return GL_NEAREST_MIPMAP_NEAREST;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
return GL_NEAREST_MIPMAP_LINEAR; return GL_NEAREST_MIPMAP_LINEAR;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
switch (mipMapFilter) { switch (mipMapFilter) {
case dawn::FilterMode::Nearest: case wgpu::FilterMode::Nearest:
return GL_LINEAR_MIPMAP_NEAREST; return GL_LINEAR_MIPMAP_NEAREST;
case dawn::FilterMode::Linear: case wgpu::FilterMode::Linear:
return GL_LINEAR_MIPMAP_LINEAR; return GL_LINEAR_MIPMAP_LINEAR;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -57,13 +57,13 @@ namespace dawn_native { namespace opengl {
} }
} }
GLenum WrapMode(dawn::AddressMode mode) { GLenum WrapMode(wgpu::AddressMode mode) {
switch (mode) { switch (mode) {
case dawn::AddressMode::Repeat: case wgpu::AddressMode::Repeat:
return GL_REPEAT; return GL_REPEAT;
case dawn::AddressMode::MirrorRepeat: case wgpu::AddressMode::MirrorRepeat:
return GL_MIRRORED_REPEAT; return GL_MIRRORED_REPEAT;
case dawn::AddressMode::ClampToEdge: case wgpu::AddressMode::ClampToEdge:
return GL_CLAMP_TO_EDGE; return GL_CLAMP_TO_EDGE;
default: default:
UNREACHABLE(); UNREACHABLE();

View File

@ -36,7 +36,7 @@ namespace dawn_native { namespace opengl {
DawnSwapChainNextTexture next = {}; DawnSwapChainNextTexture next = {};
DawnSwapChainError error = im.GetNextTexture(im.userData, &next); DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
if (error) { if (error) {
GetDevice()->HandleError(dawn::ErrorType::Unknown, error); GetDevice()->HandleError(wgpu::ErrorType::Unknown, error);
return nullptr; return nullptr;
} }
GLuint nativeTexture = next.texture.u32; GLuint nativeTexture = next.texture.u32;

View File

@ -27,7 +27,7 @@ namespace dawn_native { namespace opengl {
GLenum TargetForTexture(const TextureDescriptor* descriptor) { GLenum TargetForTexture(const TextureDescriptor* descriptor) {
switch (descriptor->dimension) { switch (descriptor->dimension) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
if (descriptor->arrayLayerCount > 1) { if (descriptor->arrayLayerCount > 1) {
ASSERT(descriptor->sampleCount == 1); ASSERT(descriptor->sampleCount == 1);
return GL_TEXTURE_2D_ARRAY; return GL_TEXTURE_2D_ARRAY;
@ -45,17 +45,17 @@ namespace dawn_native { namespace opengl {
} }
} }
GLenum TargetForTextureViewDimension(dawn::TextureViewDimension dimension, GLenum TargetForTextureViewDimension(wgpu::TextureViewDimension dimension,
uint32_t sampleCount) { uint32_t sampleCount) {
switch (dimension) { switch (dimension) {
case dawn::TextureViewDimension::e2D: case wgpu::TextureViewDimension::e2D:
return (sampleCount > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D; return (sampleCount > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
case dawn::TextureViewDimension::e2DArray: case wgpu::TextureViewDimension::e2DArray:
ASSERT(sampleCount == 1); ASSERT(sampleCount == 1);
return GL_TEXTURE_2D_ARRAY; return GL_TEXTURE_2D_ARRAY;
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
return GL_TEXTURE_CUBE_MAP; return GL_TEXTURE_CUBE_MAP;
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return GL_TEXTURE_CUBE_MAP_ARRAY; return GL_TEXTURE_CUBE_MAP_ARRAY;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -69,9 +69,9 @@ namespace dawn_native { namespace opengl {
return handle; return handle;
} }
bool UsageNeedsTextureView(dawn::TextureUsage usage) { bool UsageNeedsTextureView(wgpu::TextureUsage usage) {
constexpr dawn::TextureUsage kUsageNeedingTextureView = constexpr wgpu::TextureUsage kUsageNeedingTextureView =
dawn::TextureUsage::Storage | dawn::TextureUsage::Sampled; wgpu::TextureUsage::Storage | wgpu::TextureUsage::Sampled;
return usage & kUsageNeedingTextureView; return usage & kUsageNeedingTextureView;
} }
@ -90,8 +90,8 @@ namespace dawn_native { namespace opengl {
} }
switch (textureViewDescriptor->dimension) { switch (textureViewDescriptor->dimension) {
case dawn::TextureViewDimension::Cube: case wgpu::TextureViewDimension::Cube:
case dawn::TextureViewDimension::CubeArray: case wgpu::TextureViewDimension::CubeArray:
return true; return true;
default: default:
break; break;
@ -122,7 +122,7 @@ namespace dawn_native { namespace opengl {
// GL_TRUE, so the storage of the texture must be allocated with glTexStorage*D. // GL_TRUE, so the storage of the texture must be allocated with glTexStorage*D.
// https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTextureView.xhtml // https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glTextureView.xhtml
switch (GetDimension()) { switch (GetDimension()) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
if (arrayLayers > 1) { if (arrayLayers > 1) {
ASSERT(!IsMultisampledTexture()); ASSERT(!IsMultisampledTexture());
gl.TexStorage3D(mTarget, levels, glFormat.internalFormat, width, height, gl.TexStorage3D(mTarget, levels, glFormat.internalFormat, width, height,
@ -254,7 +254,7 @@ namespace dawn_native { namespace opengl {
return DAWN_OUT_OF_MEMORY_ERROR("Unable to allocate buffer."); return DAWN_OUT_OF_MEMORY_ERROR("Unable to allocate buffer.");
} }
descriptor.nextInChain = nullptr; descriptor.nextInChain = nullptr;
descriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::MapWrite; descriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::MapWrite;
// TODO(natlee@microsoft.com): use Dynamic Uplaoder here for temp buffer // TODO(natlee@microsoft.com): use Dynamic Uplaoder here for temp buffer
Ref<Buffer> srcBuffer = ToBackend(device->CreateBuffer(&descriptor)); Ref<Buffer> srcBuffer = ToBackend(device->CreateBuffer(&descriptor));
// Call release here to prevent memory leak since CreateBuffer will up the ref count to // Call release here to prevent memory leak since CreateBuffer will up the ref count to
@ -280,7 +280,7 @@ namespace dawn_native { namespace opengl {
Extent3D size = GetMipLevelPhysicalSize(level); Extent3D size = GetMipLevelPhysicalSize(level);
switch (GetDimension()) { switch (GetDimension()) {
case dawn::TextureDimension::e2D: case wgpu::TextureDimension::e2D:
// TODO(natlee@microsoft.com): This will break when layerCount is greater // TODO(natlee@microsoft.com): This will break when layerCount is greater
// than 1, because the buffer is only sized for one layer. // than 1, because the buffer is only sized for one layer.
ASSERT(layerCount == 1); ASSERT(layerCount == 1);

View File

@ -18,32 +18,32 @@
namespace dawn_native { namespace opengl { namespace dawn_native { namespace opengl {
GLuint ToOpenGLCompareFunction(dawn::CompareFunction compareFunction) { GLuint ToOpenGLCompareFunction(wgpu::CompareFunction compareFunction) {
switch (compareFunction) { switch (compareFunction) {
case dawn::CompareFunction::Never: case wgpu::CompareFunction::Never:
return GL_NEVER; return GL_NEVER;
case dawn::CompareFunction::Less: case wgpu::CompareFunction::Less:
return GL_LESS; return GL_LESS;
case dawn::CompareFunction::LessEqual: case wgpu::CompareFunction::LessEqual:
return GL_LEQUAL; return GL_LEQUAL;
case dawn::CompareFunction::Greater: case wgpu::CompareFunction::Greater:
return GL_GREATER; return GL_GREATER;
case dawn::CompareFunction::GreaterEqual: case wgpu::CompareFunction::GreaterEqual:
return GL_GEQUAL; return GL_GEQUAL;
case dawn::CompareFunction::NotEqual: case wgpu::CompareFunction::NotEqual:
return GL_NOTEQUAL; return GL_NOTEQUAL;
case dawn::CompareFunction::Equal: case wgpu::CompareFunction::Equal:
return GL_EQUAL; return GL_EQUAL;
case dawn::CompareFunction::Always: case wgpu::CompareFunction::Always:
return GL_ALWAYS; return GL_ALWAYS;
default: default:
UNREACHABLE(); UNREACHABLE();
} }
} }
GLint GetStencilMaskFromStencilFormat(dawn::TextureFormat depthStencilFormat) { GLint GetStencilMaskFromStencilFormat(wgpu::TextureFormat depthStencilFormat) {
switch (depthStencilFormat) { switch (depthStencilFormat) {
case dawn::TextureFormat::Depth24PlusStencil8: case wgpu::TextureFormat::Depth24PlusStencil8:
return 0xFF; return 0xFF;
default: default:
UNREACHABLE(); UNREACHABLE();

View File

@ -20,8 +20,8 @@
namespace dawn_native { namespace opengl { namespace dawn_native { namespace opengl {
GLuint ToOpenGLCompareFunction(dawn::CompareFunction compareFunction); GLuint ToOpenGLCompareFunction(wgpu::CompareFunction compareFunction);
GLint GetStencilMaskFromStencilFormat(dawn::TextureFormat depthStencilFormat); GLint GetStencilMaskFromStencilFormat(wgpu::TextureFormat depthStencilFormat);
}} // namespace dawn_native::opengl }} // namespace dawn_native::opengl
#endif // DAWNNATIVE_OPENGL_UTILSGL_H_ #endif // DAWNNATIVE_OPENGL_UTILSGL_H_

View File

@ -22,16 +22,16 @@ namespace dawn_native { namespace vulkan {
namespace { namespace {
VkShaderStageFlags VulkanShaderStageFlags(dawn::ShaderStage stages) { VkShaderStageFlags VulkanShaderStageFlags(wgpu::ShaderStage stages) {
VkShaderStageFlags flags = 0; VkShaderStageFlags flags = 0;
if (stages & dawn::ShaderStage::Vertex) { if (stages & wgpu::ShaderStage::Vertex) {
flags |= VK_SHADER_STAGE_VERTEX_BIT; flags |= VK_SHADER_STAGE_VERTEX_BIT;
} }
if (stages & dawn::ShaderStage::Fragment) { if (stages & wgpu::ShaderStage::Fragment) {
flags |= VK_SHADER_STAGE_FRAGMENT_BIT; flags |= VK_SHADER_STAGE_FRAGMENT_BIT;
} }
if (stages & dawn::ShaderStage::Compute) { if (stages & wgpu::ShaderStage::Compute) {
flags |= VK_SHADER_STAGE_COMPUTE_BIT; flags |= VK_SHADER_STAGE_COMPUTE_BIT;
} }
@ -40,18 +40,18 @@ namespace dawn_native { namespace vulkan {
} // anonymous namespace } // anonymous namespace
VkDescriptorType VulkanDescriptorType(dawn::BindingType type, bool isDynamic) { VkDescriptorType VulkanDescriptorType(wgpu::BindingType type, bool isDynamic) {
switch (type) { switch (type) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
if (isDynamic) { if (isDynamic) {
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC; return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
} }
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
return VK_DESCRIPTOR_TYPE_SAMPLER; return VK_DESCRIPTOR_TYPE_SAMPLER;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE; return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
if (isDynamic) { if (isDynamic) {
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC; return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
} }
@ -132,15 +132,15 @@ namespace dawn_native { namespace vulkan {
MAX_TYPE, MAX_TYPE,
}; };
static_assert(MAX_TYPE == kMaxPoolSizesNeeded, ""); static_assert(MAX_TYPE == kMaxPoolSizesNeeded, "");
auto ToDescriptorType = [](dawn::BindingType type) -> DescriptorType { auto ToDescriptorType = [](wgpu::BindingType type) -> DescriptorType {
switch (type) { switch (type) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
return UNIFORM_BUFFER; return UNIFORM_BUFFER;
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
return SAMPLER; return SAMPLER;
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
return SAMPLED_IMAGE; return SAMPLED_IMAGE;
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
return STORAGE_BUFFER; return STORAGE_BUFFER;
default: default:
UNREACHABLE(); UNREACHABLE();

View File

@ -23,7 +23,7 @@ namespace dawn_native { namespace vulkan {
class Device; class Device;
VkDescriptorType VulkanDescriptorType(dawn::BindingType type, bool isDynamic); VkDescriptorType VulkanDescriptorType(wgpu::BindingType type, bool isDynamic);
class BindGroupLayout : public BindGroupLayoutBase { class BindGroupLayout : public BindGroupLayoutBase {
public: public:

View File

@ -88,8 +88,8 @@ namespace dawn_native { namespace vulkan {
layoutInfo.hasDynamicOffset[bindingIndex]); layoutInfo.hasDynamicOffset[bindingIndex]);
switch (layoutInfo.types[bindingIndex]) { switch (layoutInfo.types[bindingIndex]) {
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case dawn::BindingType::StorageBuffer: { case wgpu::BindingType::StorageBuffer: {
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex); BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
writeBufferInfo[numWrites].buffer = ToBackend(binding.buffer)->GetHandle(); writeBufferInfo[numWrites].buffer = ToBackend(binding.buffer)->GetHandle();
@ -98,13 +98,13 @@ namespace dawn_native { namespace vulkan {
write.pBufferInfo = &writeBufferInfo[numWrites]; write.pBufferInfo = &writeBufferInfo[numWrites];
} break; } break;
case dawn::BindingType::Sampler: { case wgpu::BindingType::Sampler: {
Sampler* sampler = ToBackend(GetBindingAsSampler(bindingIndex)); Sampler* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
writeImageInfo[numWrites].sampler = sampler->GetHandle(); writeImageInfo[numWrites].sampler = sampler->GetHandle();
write.pImageInfo = &writeImageInfo[numWrites]; write.pImageInfo = &writeImageInfo[numWrites];
} break; } break;
case dawn::BindingType::SampledTexture: { case wgpu::BindingType::SampledTexture: {
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex)); TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
writeImageInfo[numWrites].imageView = view->GetHandle(); writeImageInfo[numWrites].imageView = view->GetHandle();

View File

@ -26,86 +26,86 @@ namespace dawn_native { namespace vulkan {
namespace { namespace {
VkBufferUsageFlags VulkanBufferUsage(dawn::BufferUsage usage) { VkBufferUsageFlags VulkanBufferUsage(wgpu::BufferUsage usage) {
VkBufferUsageFlags flags = 0; VkBufferUsageFlags flags = 0;
if (usage & dawn::BufferUsage::CopySrc) { if (usage & wgpu::BufferUsage::CopySrc) {
flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT; flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
} }
if (usage & dawn::BufferUsage::CopyDst) { if (usage & wgpu::BufferUsage::CopyDst) {
flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT; flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
} }
if (usage & dawn::BufferUsage::Index) { if (usage & wgpu::BufferUsage::Index) {
flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT; flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
} }
if (usage & dawn::BufferUsage::Vertex) { if (usage & wgpu::BufferUsage::Vertex) {
flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT; flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
} }
if (usage & dawn::BufferUsage::Uniform) { if (usage & wgpu::BufferUsage::Uniform) {
flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT; flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
} }
if (usage & dawn::BufferUsage::Storage) { if (usage & wgpu::BufferUsage::Storage) {
flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT; flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
} }
if (usage & dawn::BufferUsage::Indirect) { if (usage & wgpu::BufferUsage::Indirect) {
flags |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT; flags |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
} }
return flags; return flags;
} }
VkPipelineStageFlags VulkanPipelineStage(dawn::BufferUsage usage) { VkPipelineStageFlags VulkanPipelineStage(wgpu::BufferUsage usage) {
VkPipelineStageFlags flags = 0; VkPipelineStageFlags flags = 0;
if (usage & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) { if (usage & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) {
flags |= VK_PIPELINE_STAGE_HOST_BIT; flags |= VK_PIPELINE_STAGE_HOST_BIT;
} }
if (usage & (dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst)) { if (usage & (wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst)) {
flags |= VK_PIPELINE_STAGE_TRANSFER_BIT; flags |= VK_PIPELINE_STAGE_TRANSFER_BIT;
} }
if (usage & (dawn::BufferUsage::Index | dawn::BufferUsage::Vertex)) { if (usage & (wgpu::BufferUsage::Index | wgpu::BufferUsage::Vertex)) {
flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT; flags |= VK_PIPELINE_STAGE_VERTEX_INPUT_BIT;
} }
if (usage & (dawn::BufferUsage::Uniform | dawn::BufferUsage::Storage)) { if (usage & (wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage)) {
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT | flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT | VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT |
VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT; VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT;
} }
if (usage & dawn::BufferUsage::Indirect) { if (usage & wgpu::BufferUsage::Indirect) {
flags |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT; flags |= VK_PIPELINE_STAGE_DRAW_INDIRECT_BIT;
} }
return flags; return flags;
} }
VkAccessFlags VulkanAccessFlags(dawn::BufferUsage usage) { VkAccessFlags VulkanAccessFlags(wgpu::BufferUsage usage) {
VkAccessFlags flags = 0; VkAccessFlags flags = 0;
if (usage & dawn::BufferUsage::MapRead) { if (usage & wgpu::BufferUsage::MapRead) {
flags |= VK_ACCESS_HOST_READ_BIT; flags |= VK_ACCESS_HOST_READ_BIT;
} }
if (usage & dawn::BufferUsage::MapWrite) { if (usage & wgpu::BufferUsage::MapWrite) {
flags |= VK_ACCESS_HOST_WRITE_BIT; flags |= VK_ACCESS_HOST_WRITE_BIT;
} }
if (usage & dawn::BufferUsage::CopySrc) { if (usage & wgpu::BufferUsage::CopySrc) {
flags |= VK_ACCESS_TRANSFER_READ_BIT; flags |= VK_ACCESS_TRANSFER_READ_BIT;
} }
if (usage & dawn::BufferUsage::CopyDst) { if (usage & wgpu::BufferUsage::CopyDst) {
flags |= VK_ACCESS_TRANSFER_WRITE_BIT; flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
} }
if (usage & dawn::BufferUsage::Index) { if (usage & wgpu::BufferUsage::Index) {
flags |= VK_ACCESS_INDEX_READ_BIT; flags |= VK_ACCESS_INDEX_READ_BIT;
} }
if (usage & dawn::BufferUsage::Vertex) { if (usage & wgpu::BufferUsage::Vertex) {
flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT; flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
} }
if (usage & dawn::BufferUsage::Uniform) { if (usage & wgpu::BufferUsage::Uniform) {
flags |= VK_ACCESS_UNIFORM_READ_BIT; flags |= VK_ACCESS_UNIFORM_READ_BIT;
} }
if (usage & dawn::BufferUsage::Storage) { if (usage & wgpu::BufferUsage::Storage) {
flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT; flags |= VK_ACCESS_SHADER_READ_BIT | VK_ACCESS_SHADER_WRITE_BIT;
} }
if (usage & dawn::BufferUsage::Indirect) { if (usage & wgpu::BufferUsage::Indirect) {
flags |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT; flags |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
} }
@ -129,7 +129,7 @@ namespace dawn_native { namespace vulkan {
createInfo.size = GetSize(); createInfo.size = GetSize();
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped // Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
// and robust resource initialization. // and robust resource initialization.
createInfo.usage = VulkanBufferUsage(GetUsage() | dawn::BufferUsage::CopyDst); createInfo.usage = VulkanBufferUsage(GetUsage() | wgpu::BufferUsage::CopyDst);
createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE; createInfo.sharingMode = VK_SHARING_MODE_EXCLUSIVE;
createInfo.queueFamilyIndexCount = 0; createInfo.queueFamilyIndexCount = 0;
createInfo.pQueueFamilyIndices = 0; createInfo.pQueueFamilyIndices = 0;
@ -143,7 +143,7 @@ namespace dawn_native { namespace vulkan {
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements); device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
bool requestMappable = bool requestMappable =
(GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) != 0; (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) != 0;
DAWN_TRY_ASSIGN(mMemoryAllocation, device->AllocateMemory(requirements, requestMappable)); DAWN_TRY_ASSIGN(mMemoryAllocation, device->AllocateMemory(requirements, requestMappable));
DAWN_TRY(CheckVkSuccess( DAWN_TRY(CheckVkSuccess(
@ -172,7 +172,7 @@ namespace dawn_native { namespace vulkan {
} }
void Buffer::TransitionUsageNow(CommandRecordingContext* recordingContext, void Buffer::TransitionUsageNow(CommandRecordingContext* recordingContext,
dawn::BufferUsage usage) { wgpu::BufferUsage usage) {
bool lastIncludesTarget = (mLastUsage & usage) == usage; bool lastIncludesTarget = (mLastUsage & usage) == usage;
bool lastReadOnly = (mLastUsage & kReadOnlyBufferUsages) == mLastUsage; bool lastReadOnly = (mLastUsage & kReadOnlyBufferUsages) == mLastUsage;
@ -182,7 +182,7 @@ namespace dawn_native { namespace vulkan {
} }
// Special-case for the initial transition: Vulkan doesn't allow access flags to be 0. // Special-case for the initial transition: Vulkan doesn't allow access flags to be 0.
if (mLastUsage == dawn::BufferUsage::None) { if (mLastUsage == wgpu::BufferUsage::None) {
mLastUsage = usage; mLastUsage = usage;
return; return;
} }
@ -222,7 +222,7 @@ namespace dawn_native { namespace vulkan {
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext(); CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
TransitionUsageNow(recordingContext, dawn::BufferUsage::MapRead); TransitionUsageNow(recordingContext, wgpu::BufferUsage::MapRead);
uint8_t* memory = mMemoryAllocation.GetMappedPointer(); uint8_t* memory = mMemoryAllocation.GetMappedPointer();
ASSERT(memory != nullptr); ASSERT(memory != nullptr);
@ -236,7 +236,7 @@ namespace dawn_native { namespace vulkan {
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext(); CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
TransitionUsageNow(recordingContext, dawn::BufferUsage::MapWrite); TransitionUsageNow(recordingContext, wgpu::BufferUsage::MapWrite);
uint8_t* memory = mMemoryAllocation.GetMappedPointer(); uint8_t* memory = mMemoryAllocation.GetMappedPointer();
ASSERT(memory != nullptr); ASSERT(memory != nullptr);

View File

@ -40,7 +40,7 @@ namespace dawn_native { namespace vulkan {
// Transitions the buffer to be used as `usage`, recording any necessary barrier in // Transitions the buffer to be used as `usage`, recording any necessary barrier in
// `commands`. // `commands`.
// TODO(cwallez@chromium.org): coalesce barriers and do them early when possible. // TODO(cwallez@chromium.org): coalesce barriers and do them early when possible.
void TransitionUsageNow(CommandRecordingContext* recordingContext, dawn::BufferUsage usage); void TransitionUsageNow(CommandRecordingContext* recordingContext, wgpu::BufferUsage usage);
private: private:
using BufferBase::BufferBase; using BufferBase::BufferBase;
@ -58,7 +58,7 @@ namespace dawn_native { namespace vulkan {
VkBuffer mHandle = VK_NULL_HANDLE; VkBuffer mHandle = VK_NULL_HANDLE;
ResourceMemoryAllocation mMemoryAllocation; ResourceMemoryAllocation mMemoryAllocation;
dawn::BufferUsage mLastUsage = dawn::BufferUsage::None; wgpu::BufferUsage mLastUsage = wgpu::BufferUsage::None;
}; };
class MapRequestTracker { class MapRequestTracker {

View File

@ -35,11 +35,11 @@ namespace dawn_native { namespace vulkan {
namespace { namespace {
VkIndexType VulkanIndexType(dawn::IndexFormat format) { VkIndexType VulkanIndexType(wgpu::IndexFormat format) {
switch (format) { switch (format) {
case dawn::IndexFormat::Uint16: case wgpu::IndexFormat::Uint16:
return VK_INDEX_TYPE_UINT16; return VK_INDEX_TYPE_UINT16;
case dawn::IndexFormat::Uint32: case wgpu::IndexFormat::Uint32:
return VK_INDEX_TYPE_UINT32; return VK_INDEX_TYPE_UINT32;
default: default:
UNREACHABLE(); UNREACHABLE();
@ -142,19 +142,19 @@ namespace dawn_native { namespace vulkan {
for (uint32_t index : IterateBitSet(mBindGroupLayoutsMask)) { for (uint32_t index : IterateBitSet(mBindGroupLayoutsMask)) {
for (uint32_t binding : IterateBitSet(mBuffersNeedingBarrier[index])) { for (uint32_t binding : IterateBitSet(mBuffersNeedingBarrier[index])) {
switch (mBindingTypes[index][binding]) { switch (mBindingTypes[index][binding]) {
case dawn::BindingType::StorageBuffer: case wgpu::BindingType::StorageBuffer:
ToBackend(mBuffers[index][binding]) ToBackend(mBuffers[index][binding])
->TransitionUsageNow(recordingContext, ->TransitionUsageNow(recordingContext,
dawn::BufferUsage::Storage); wgpu::BufferUsage::Storage);
break; break;
case dawn::BindingType::StorageTexture: case wgpu::BindingType::StorageTexture:
// Not implemented. // Not implemented.
case dawn::BindingType::UniformBuffer: case wgpu::BindingType::UniformBuffer:
case dawn::BindingType::ReadonlyStorageBuffer: case wgpu::BindingType::ReadonlyStorageBuffer:
case dawn::BindingType::Sampler: case wgpu::BindingType::Sampler:
case dawn::BindingType::SampledTexture: case wgpu::BindingType::SampledTexture:
// Don't require barriers. // Don't require barriers.
default: default:
@ -183,13 +183,13 @@ namespace dawn_native { namespace vulkan {
TextureView* view = ToBackend(attachmentInfo.view.Get()); TextureView* view = ToBackend(attachmentInfo.view.Get());
bool hasResolveTarget = attachmentInfo.resolveTarget.Get() != nullptr; bool hasResolveTarget = attachmentInfo.resolveTarget.Get() != nullptr;
dawn::LoadOp loadOp = attachmentInfo.loadOp; wgpu::LoadOp loadOp = attachmentInfo.loadOp;
ASSERT(view->GetLayerCount() == 1); ASSERT(view->GetLayerCount() == 1);
ASSERT(view->GetLevelCount() == 1); ASSERT(view->GetLevelCount() == 1);
if (loadOp == dawn::LoadOp::Load && if (loadOp == wgpu::LoadOp::Load &&
!view->GetTexture()->IsSubresourceContentInitialized( !view->GetTexture()->IsSubresourceContentInitialized(
view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1)) { view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1)) {
loadOp = dawn::LoadOp::Clear; loadOp = wgpu::LoadOp::Clear;
} }
if (hasResolveTarget) { if (hasResolveTarget) {
@ -204,12 +204,12 @@ namespace dawn_native { namespace vulkan {
} }
switch (attachmentInfo.storeOp) { switch (attachmentInfo.storeOp) {
case dawn::StoreOp::Store: { case wgpu::StoreOp::Store: {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
true, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1); true, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
} break; } break;
case dawn::StoreOp::Clear: { case wgpu::StoreOp::Clear: {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
false, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1); false, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
} break; } break;
@ -231,26 +231,26 @@ namespace dawn_native { namespace vulkan {
view->GetBaseMipLevel(), view->GetLevelCount(), view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount())) { view->GetBaseArrayLayer(), view->GetLayerCount())) {
if (view->GetTexture()->GetFormat().HasDepth() && if (view->GetTexture()->GetFormat().HasDepth() &&
attachmentInfo.depthLoadOp == dawn::LoadOp::Load) { attachmentInfo.depthLoadOp == wgpu::LoadOp::Load) {
attachmentInfo.clearDepth = 0.0f; attachmentInfo.clearDepth = 0.0f;
attachmentInfo.depthLoadOp = dawn::LoadOp::Clear; attachmentInfo.depthLoadOp = wgpu::LoadOp::Clear;
} }
if (view->GetTexture()->GetFormat().HasStencil() && if (view->GetTexture()->GetFormat().HasStencil() &&
attachmentInfo.stencilLoadOp == dawn::LoadOp::Load) { attachmentInfo.stencilLoadOp == wgpu::LoadOp::Load) {
attachmentInfo.clearStencil = 0u; attachmentInfo.clearStencil = 0u;
attachmentInfo.stencilLoadOp = dawn::LoadOp::Clear; attachmentInfo.stencilLoadOp = wgpu::LoadOp::Clear;
} }
} }
query.SetDepthStencil(view->GetTexture()->GetFormat().format, query.SetDepthStencil(view->GetTexture()->GetFormat().format,
attachmentInfo.depthLoadOp, attachmentInfo.stencilLoadOp); attachmentInfo.depthLoadOp, attachmentInfo.stencilLoadOp);
if (attachmentInfo.depthStoreOp == dawn::StoreOp::Store && if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Store &&
attachmentInfo.stencilStoreOp == dawn::StoreOp::Store) { attachmentInfo.stencilStoreOp == wgpu::StoreOp::Store) {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
true, view->GetBaseMipLevel(), view->GetLevelCount(), true, view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount()); view->GetBaseArrayLayer(), view->GetLayerCount());
} else if (attachmentInfo.depthStoreOp == dawn::StoreOp::Clear && } else if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Clear &&
attachmentInfo.stencilStoreOp == dawn::StoreOp::Clear) { attachmentInfo.stencilStoreOp == wgpu::StoreOp::Clear) {
view->GetTexture()->SetIsSubresourceContentInitialized( view->GetTexture()->SetIsSubresourceContentInitialized(
false, view->GetBaseMipLevel(), view->GetLevelCount(), false, view->GetBaseMipLevel(), view->GetLevelCount(),
view->GetBaseArrayLayer(), view->GetLayerCount()); view->GetBaseArrayLayer(), view->GetLayerCount());
@ -382,7 +382,7 @@ namespace dawn_native { namespace vulkan {
format.blockByteSize; format.blockByteSize;
BufferDescriptor tempBufferDescriptor; BufferDescriptor tempBufferDescriptor;
tempBufferDescriptor.size = tempBufferSize; tempBufferDescriptor.size = tempBufferSize;
tempBufferDescriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst; tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
Device* device = ToBackend(GetDevice()); Device* device = ToBackend(GetDevice());
Ref<Buffer> tempBuffer = AcquireRef(ToBackend(device->CreateBuffer(&tempBufferDescriptor))); Ref<Buffer> tempBuffer = AcquireRef(ToBackend(device->CreateBuffer(&tempBufferDescriptor)));
@ -397,7 +397,7 @@ namespace dawn_native { namespace vulkan {
VkImage srcImage = ToBackend(srcCopy.texture)->GetHandle(); VkImage srcImage = ToBackend(srcCopy.texture)->GetHandle();
VkImage dstImage = ToBackend(dstCopy.texture)->GetHandle(); VkImage dstImage = ToBackend(dstCopy.texture)->GetHandle();
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst); tempBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
VkBufferImageCopy srcToTempBufferRegion = VkBufferImageCopy srcToTempBufferRegion =
ComputeBufferImageCopyRegion(tempBufferCopy, srcCopy, copySize); ComputeBufferImageCopyRegion(tempBufferCopy, srcCopy, copySize);
@ -405,7 +405,7 @@ namespace dawn_native { namespace vulkan {
device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL, device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL,
tempBuffer->GetHandle(), 1, &srcToTempBufferRegion); tempBuffer->GetHandle(), 1, &srcToTempBufferRegion);
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc); tempBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopySrc);
VkBufferImageCopy tempBufferToDstRegion = VkBufferImageCopy tempBufferToDstRegion =
ComputeBufferImageCopyRegion(tempBufferCopy, dstCopy, copySize); ComputeBufferImageCopyRegion(tempBufferCopy, dstCopy, copySize);
@ -434,7 +434,7 @@ namespace dawn_native { namespace vulkan {
// Clear textures that are not output attachments. Output attachments will be // Clear textures that are not output attachments. Output attachments will be
// cleared in RecordBeginRenderPass by setting the loadop to clear when the // cleared in RecordBeginRenderPass by setting the loadop to clear when the
// texture subresource has not been initialized before the render pass. // texture subresource has not been initialized before the render pass.
if (!(usages.textureUsages[i] & dawn::TextureUsage::OutputAttachment)) { if (!(usages.textureUsages[i] & wgpu::TextureUsage::OutputAttachment)) {
texture->EnsureSubresourceContentInitialized(recordingContext, 0, texture->EnsureSubresourceContentInitialized(recordingContext, 0,
texture->GetNumMipLevels(), 0, texture->GetNumMipLevels(), 0,
texture->GetArrayLayers()); texture->GetArrayLayers());
@ -453,8 +453,8 @@ namespace dawn_native { namespace vulkan {
Buffer* srcBuffer = ToBackend(copy->source.Get()); Buffer* srcBuffer = ToBackend(copy->source.Get());
Buffer* dstBuffer = ToBackend(copy->destination.Get()); Buffer* dstBuffer = ToBackend(copy->destination.Get());
srcBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc); srcBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopySrc);
dstBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst); dstBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
VkBufferCopy region; VkBufferCopy region;
region.srcOffset = copy->sourceOffset; region.srcOffset = copy->sourceOffset;
@ -487,9 +487,9 @@ namespace dawn_native { namespace vulkan {
subresource.baseArrayLayer, 1); subresource.baseArrayLayer, 1);
} }
ToBackend(src.buffer) ToBackend(src.buffer)
->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc); ->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopySrc);
ToBackend(dst.texture) ToBackend(dst.texture)
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopyDst); ->TransitionUsageNow(recordingContext, wgpu::TextureUsage::CopyDst);
VkBuffer srcBuffer = ToBackend(src.buffer)->GetHandle(); VkBuffer srcBuffer = ToBackend(src.buffer)->GetHandle();
VkImage dstImage = ToBackend(dst.texture)->GetHandle(); VkImage dstImage = ToBackend(dst.texture)->GetHandle();
@ -515,9 +515,9 @@ namespace dawn_native { namespace vulkan {
subresource.baseArrayLayer, 1); subresource.baseArrayLayer, 1);
ToBackend(src.texture) ToBackend(src.texture)
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopySrc); ->TransitionUsageNow(recordingContext, wgpu::TextureUsage::CopySrc);
ToBackend(dst.buffer) ToBackend(dst.buffer)
->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst); ->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
VkImage srcImage = ToBackend(src.texture)->GetHandle(); VkImage srcImage = ToBackend(src.texture)->GetHandle();
VkBuffer dstBuffer = ToBackend(dst.buffer)->GetHandle(); VkBuffer dstBuffer = ToBackend(dst.buffer)->GetHandle();
@ -547,9 +547,9 @@ namespace dawn_native { namespace vulkan {
} }
ToBackend(src.texture) ToBackend(src.texture)
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopySrc); ->TransitionUsageNow(recordingContext, wgpu::TextureUsage::CopySrc);
ToBackend(dst.texture) ToBackend(dst.texture)
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopyDst); ->TransitionUsageNow(recordingContext, wgpu::TextureUsage::CopyDst);
// In some situations we cannot do texture-to-texture copies with vkCmdCopyImage // In some situations we cannot do texture-to-texture copies with vkCmdCopyImage
// because as Vulkan SPEC always validates image copies with the virtual size of // because as Vulkan SPEC always validates image copies with the virtual size of

View File

@ -572,7 +572,7 @@ namespace dawn_native { namespace vulkan {
// Insert pipeline barrier to ensure correct ordering with previous memory operations on the // Insert pipeline barrier to ensure correct ordering with previous memory operations on the
// buffer. // buffer.
ToBackend(destination)->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst); ToBackend(destination)->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
VkBufferCopy copy; VkBufferCopy copy;
copy.srcOffset = sourceOffset; copy.srcOffset = sourceOffset;

View File

@ -52,7 +52,7 @@ namespace dawn_native { namespace vulkan {
// driver. Need to generalize // driver. Need to generalize
config->nativeFormat = VK_FORMAT_B8G8R8A8_UNORM; config->nativeFormat = VK_FORMAT_B8G8R8A8_UNORM;
config->colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR; config->colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
config->format = dawn::TextureFormat::BGRA8Unorm; config->format = wgpu::TextureFormat::BGRA8Unorm;
config->minImageCount = 3; config->minImageCount = 3;
// TODO(cwallez@chromium.org): This is upside down compared to what we want, at least // TODO(cwallez@chromium.org): This is upside down compared to what we want, at least
// on Linux // on Linux
@ -121,7 +121,7 @@ namespace dawn_native { namespace vulkan {
createInfo.imageExtent.width = width; createInfo.imageExtent.width = width;
createInfo.imageExtent.height = height; createInfo.imageExtent.height = height;
createInfo.imageArrayLayers = 1; createInfo.imageArrayLayers = 1;
createInfo.imageUsage = VulkanImageUsage(static_cast<dawn::TextureUsage>(usage), createInfo.imageUsage = VulkanImageUsage(static_cast<wgpu::TextureUsage>(usage),
mDevice->GetValidInternalFormat(mConfig.format)); mDevice->GetValidInternalFormat(mConfig.format));
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE; createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
createInfo.queueFamilyIndexCount = 0; createInfo.queueFamilyIndexCount = 0;
@ -236,7 +236,7 @@ namespace dawn_native { namespace vulkan {
return DAWN_SWAP_CHAIN_NO_ERROR; return DAWN_SWAP_CHAIN_NO_ERROR;
} }
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const { wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
return mConfig.format; return mConfig.format;
} }

View File

@ -39,11 +39,11 @@ namespace dawn_native { namespace vulkan {
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture); DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
DawnSwapChainError Present(); DawnSwapChainError Present();
dawn::TextureFormat GetPreferredFormat() const; wgpu::TextureFormat GetPreferredFormat() const;
struct ChosenConfig { struct ChosenConfig {
VkFormat nativeFormat; VkFormat nativeFormat;
dawn::TextureFormat format; wgpu::TextureFormat format;
VkColorSpaceKHR colorSpace; VkColorSpaceKHR colorSpace;
VkSurfaceTransformFlagBitsKHR preTransform; VkSurfaceTransformFlagBitsKHR preTransform;
uint32_t minImageCount; uint32_t minImageCount;

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