mirror of
https://github.com/encounter/dawn-cmake.git
synced 2025-07-08 06:05:55 +00:00
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:
parent
c833c0c592
commit
1f6c8c4d54
4
BUILD.gn
4
BUILD.gn
@ -69,8 +69,8 @@ dawn_json_generator("libdawn_native_utils_gen") {
|
||||
target = "dawn_native_utils"
|
||||
outputs = [
|
||||
"src/dawn_native/ProcTable.cpp",
|
||||
"src/dawn_native/dawn_structs_autogen.h",
|
||||
"src/dawn_native/dawn_structs_autogen.cpp",
|
||||
"src/dawn_native/wgpu_structs_autogen.h",
|
||||
"src/dawn_native/wgpu_structs_autogen.cpp",
|
||||
"src/dawn_native/ValidationUtils_autogen.h",
|
||||
"src/dawn_native/ValidationUtils_autogen.cpp",
|
||||
]
|
||||
|
@ -448,7 +448,7 @@ def as_frontendType(typ):
|
||||
if typ.category == 'object':
|
||||
return typ.name.CamelCase() + 'Base*'
|
||||
elif typ.category in ['bitmask', 'enum']:
|
||||
return 'dawn::' + typ.name.CamelCase()
|
||||
return 'wgpu::' + typ.name.CamelCase()
|
||||
elif typ.category == 'structure':
|
||||
return as_cppType(typ.name)
|
||||
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.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/api_structs.cpp', 'src/dawn_native/dawn_structs_autogen.cpp', frontend_params))
|
||||
renders.append(FileRender('dawn_native/wgpu_structs.h', 'src/dawn_native/wgpu_structs_autogen.h', 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))
|
||||
|
||||
if 'dawn_wire' in targets:
|
||||
|
@ -17,10 +17,10 @@
|
||||
namespace dawn_native {
|
||||
|
||||
{% 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) {
|
||||
{% 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 {};
|
||||
{% endfor %}
|
||||
default:
|
||||
@ -31,8 +31,8 @@ namespace dawn_native {
|
||||
{% endfor %}
|
||||
|
||||
{% for type in by_category["bitmask"] %}
|
||||
MaybeError Validate{{type.name.CamelCase()}}(dawn::{{as_cppType(type.name)}} value) {
|
||||
if ((value & static_cast<dawn::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
|
||||
MaybeError Validate{{type.name.CamelCase()}}(wgpu::{{as_cppType(type.name)}} value) {
|
||||
if ((value & static_cast<wgpu::{{as_cppType(type.name)}}>(~{{type.full_mask}})) == 0) {
|
||||
return {};
|
||||
}
|
||||
return DAWN_VALIDATION_ERROR("Invalid value for {{as_cType(type.name)}}");
|
||||
|
@ -15,7 +15,7 @@
|
||||
#ifndef BACKEND_VALIDATIONUTILS_H_
|
||||
#define BACKEND_VALIDATIONUTILS_H_
|
||||
|
||||
#include "dawn/dawncpp.h"
|
||||
#include "dawn/webgpu_cpp.h"
|
||||
|
||||
#include "dawn_native/Error.h"
|
||||
|
||||
@ -23,7 +23,7 @@ namespace dawn_native {
|
||||
|
||||
// Helper functions to check the value of enums and bitmasks
|
||||
{% 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 %}
|
||||
|
||||
} // namespace dawn_native
|
||||
|
@ -12,7 +12,7 @@
|
||||
//* See the License for the specific language governing permissions and
|
||||
//* limitations under the License.
|
||||
|
||||
#include "dawn_native/dawn_structs_autogen.h"
|
||||
#include "dawn_native/wgpu_structs_autogen.h"
|
||||
|
||||
namespace dawn_native {
|
||||
|
@ -12,10 +12,10 @@
|
||||
//* See the License for the specific language governing permissions and
|
||||
//* limitations under the License.
|
||||
|
||||
#ifndef DAWNNATIVE_DAWN_STRUCTS_H_
|
||||
#define DAWNNATIVE_DAWN_STRUCTS_H_
|
||||
#ifndef DAWNNATIVE_WGPU_STRUCTS_H_
|
||||
#define DAWNNATIVE_WGPU_STRUCTS_H_
|
||||
|
||||
#include "dawn/dawncpp.h"
|
||||
#include "dawn/webgpu_cpp.h"
|
||||
#include "dawn_native/Forward.h"
|
||||
|
||||
namespace dawn_native {
|
||||
@ -24,7 +24,7 @@ namespace dawn_native {
|
||||
{%- if member.annotation in ["*", "const*", "const*const*"] and member.optional -%}
|
||||
{{" "}}= nullptr
|
||||
{%- 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 -%}
|
||||
{{" "}}= {{member.default_value}}
|
||||
{%- else -%}
|
||||
@ -46,4 +46,4 @@ namespace dawn_native {
|
||||
|
||||
} // namespace dawn_native
|
||||
|
||||
#endif // DAWNNATIVE_DAWN_STRUCTS_H_
|
||||
#endif // DAWNNATIVE_WGPU_STRUCTS_H_
|
@ -127,16 +127,16 @@ namespace dawn_native {
|
||||
return mColorAttachmentsSet;
|
||||
}
|
||||
|
||||
dawn::TextureFormat AttachmentState::GetColorAttachmentFormat(uint32_t index) const {
|
||||
wgpu::TextureFormat AttachmentState::GetColorAttachmentFormat(uint32_t index) const {
|
||||
ASSERT(mColorAttachmentsSet[index]);
|
||||
return mColorFormats[index];
|
||||
}
|
||||
|
||||
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());
|
||||
return mDepthStencilFormat;
|
||||
}
|
||||
|
@ -50,9 +50,9 @@ namespace dawn_native {
|
||||
|
||||
protected:
|
||||
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.
|
||||
dawn::TextureFormat mDepthStencilFormat = dawn::TextureFormat::Undefined;
|
||||
wgpu::TextureFormat mDepthStencilFormat = wgpu::TextureFormat::Undefined;
|
||||
uint32_t mSampleCount = 0;
|
||||
};
|
||||
|
||||
@ -62,9 +62,9 @@ namespace dawn_native {
|
||||
~AttachmentState() override;
|
||||
|
||||
std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const;
|
||||
dawn::TextureFormat GetColorAttachmentFormat(uint32_t index) const;
|
||||
wgpu::TextureFormat GetColorAttachmentFormat(uint32_t index) const;
|
||||
bool HasDepthStencilAttachment() const;
|
||||
dawn::TextureFormat GetDepthStencilFormat() const;
|
||||
wgpu::TextureFormat GetDepthStencilFormat() const;
|
||||
uint32_t GetSampleCount() const;
|
||||
|
||||
private:
|
||||
|
@ -30,7 +30,7 @@ namespace dawn_native {
|
||||
|
||||
MaybeError ValidateBufferBinding(const DeviceBase* device,
|
||||
const BindGroupBinding& binding,
|
||||
dawn::BufferUsage requiredUsage) {
|
||||
wgpu::BufferUsage requiredUsage) {
|
||||
if (binding.buffer == nullptr || binding.sampler != nullptr ||
|
||||
binding.textureView != nullptr) {
|
||||
return DAWN_VALIDATION_ERROR("expected buffer binding");
|
||||
@ -38,7 +38,7 @@ namespace dawn_native {
|
||||
DAWN_TRY(device->ValidateObject(binding.buffer));
|
||||
|
||||
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) {
|
||||
return DAWN_VALIDATION_ERROR("Buffer binding size larger than the buffer");
|
||||
}
|
||||
@ -63,10 +63,10 @@ namespace dawn_native {
|
||||
|
||||
MaybeError ValidateTextureBinding(const DeviceBase* device,
|
||||
const BindGroupBinding& binding,
|
||||
dawn::TextureUsage requiredUsage,
|
||||
wgpu::TextureUsage requiredUsage,
|
||||
bool multisampledBinding,
|
||||
dawn::TextureComponentType requiredComponentType,
|
||||
dawn::TextureViewDimension requiredDimension) {
|
||||
wgpu::TextureComponentType requiredComponentType,
|
||||
wgpu::TextureViewDimension requiredDimension) {
|
||||
if (binding.textureView == nullptr || binding.sampler != nullptr ||
|
||||
binding.buffer != nullptr) {
|
||||
return DAWN_VALIDATION_ERROR("expected texture binding");
|
||||
@ -143,23 +143,23 @@ namespace dawn_native {
|
||||
|
||||
// Perform binding-type specific validation.
|
||||
switch (layoutInfo.types[bindingIndex]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsage::Uniform));
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
DAWN_TRY(ValidateBufferBinding(device, binding, wgpu::BufferUsage::Uniform));
|
||||
break;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
DAWN_TRY(ValidateBufferBinding(device, binding, dawn::BufferUsage::Storage));
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
DAWN_TRY(ValidateBufferBinding(device, binding, wgpu::BufferUsage::Storage));
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
DAWN_TRY(ValidateTextureBinding(device, binding, dawn::TextureUsage::Sampled,
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
DAWN_TRY(ValidateTextureBinding(device, binding, wgpu::TextureUsage::Sampled,
|
||||
layoutInfo.multisampled[bindingIndex],
|
||||
layoutInfo.textureComponentTypes[bindingIndex],
|
||||
layoutInfo.textureDimensions[bindingIndex]));
|
||||
break;
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
DAWN_TRY(ValidateSamplerBinding(device, binding));
|
||||
break;
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
@ -193,7 +193,7 @@ namespace dawn_native {
|
||||
mBindings[bindingIndex] = binding.buffer;
|
||||
mOffsets[bindingIndex] = binding.offset;
|
||||
uint64_t bufferSize =
|
||||
(binding.size == dawn::kWholeSize) ? binding.buffer->GetSize() : binding.size;
|
||||
(binding.size == wgpu::kWholeSize) ? binding.buffer->GetSize() : binding.size;
|
||||
mSizes[bindingIndex] = bufferSize;
|
||||
continue;
|
||||
}
|
||||
@ -230,8 +230,8 @@ namespace dawn_native {
|
||||
ASSERT(!IsError());
|
||||
ASSERT(binding < kMaxBindingsPerGroup);
|
||||
ASSERT(mLayout->GetBindingInfo().mask[binding]);
|
||||
ASSERT(mLayout->GetBindingInfo().types[binding] == dawn::BindingType::UniformBuffer ||
|
||||
mLayout->GetBindingInfo().types[binding] == dawn::BindingType::StorageBuffer);
|
||||
ASSERT(mLayout->GetBindingInfo().types[binding] == wgpu::BindingType::UniformBuffer ||
|
||||
mLayout->GetBindingInfo().types[binding] == wgpu::BindingType::StorageBuffer);
|
||||
BufferBase* buffer = static_cast<BufferBase*>(mBindings[binding].Get());
|
||||
return {buffer, mOffsets[binding], mSizes[binding]};
|
||||
}
|
||||
@ -240,7 +240,7 @@ namespace dawn_native {
|
||||
ASSERT(!IsError());
|
||||
ASSERT(binding < kMaxBindingsPerGroup);
|
||||
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());
|
||||
}
|
||||
|
||||
@ -248,7 +248,7 @@ namespace dawn_native {
|
||||
ASSERT(!IsError());
|
||||
ASSERT(binding < kMaxBindingsPerGroup);
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -42,26 +42,26 @@ namespace dawn_native {
|
||||
const auto& info = layout->GetBindingInfo();
|
||||
|
||||
for (uint32_t binding : IterateBitSet(info.mask)) {
|
||||
if ((info.visibilities[binding] & dawn::ShaderStage::Compute) == 0) {
|
||||
if ((info.visibilities[binding] & wgpu::ShaderStage::Compute) == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mBindingTypes[index][binding] = info.types[binding];
|
||||
switch (info.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
// Don't require barriers.
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
mBuffersNeedingBarrier[index].set(binding);
|
||||
mBuffers[index][binding] =
|
||||
bindGroup->GetBindingAsBufferBinding(binding).buffer;
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
// Not implemented.
|
||||
|
||||
default:
|
||||
@ -76,7 +76,7 @@ namespace dawn_native {
|
||||
|
||||
protected:
|
||||
std::array<std::bitset<kMaxBindingsPerGroup>, kMaxBindGroups> mBuffersNeedingBarrier = {};
|
||||
std::array<std::array<dawn::BindingType, kMaxBindingsPerGroup>, kMaxBindGroups>
|
||||
std::array<std::array<wgpu::BindingType, kMaxBindingsPerGroup>, kMaxBindGroups>
|
||||
mBindingTypes = {};
|
||||
std::array<std::array<BufferBase*, kMaxBindingsPerGroup>, kMaxBindGroups> mBuffers = {};
|
||||
};
|
||||
|
@ -38,7 +38,7 @@ namespace dawn_native {
|
||||
DAWN_TRY(ValidateBindingType(binding.type));
|
||||
DAWN_TRY(ValidateTextureComponentType(binding.textureComponentType));
|
||||
|
||||
if (binding.textureDimension != dawn::TextureViewDimension::Undefined) {
|
||||
if (binding.textureDimension != wgpu::TextureViewDimension::Undefined) {
|
||||
DAWN_TRY(ValidateTextureViewDimension(binding.textureDimension));
|
||||
}
|
||||
|
||||
@ -50,25 +50,25 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
switch (binding.type) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
if (binding.hasDynamicOffset) {
|
||||
++dynamicUniformBufferCount;
|
||||
}
|
||||
break;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
if (binding.hasDynamicOffset) {
|
||||
++dynamicStorageBufferCount;
|
||||
}
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::Sampler:
|
||||
if (binding.hasDynamicOffset) {
|
||||
return DAWN_VALIDATION_ERROR("Samplers and textures cannot be dynamic");
|
||||
}
|
||||
break;
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
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)");
|
||||
}
|
||||
|
||||
@ -140,24 +140,24 @@ namespace dawn_native {
|
||||
mBindingInfo.types[index] = binding.type;
|
||||
mBindingInfo.textureComponentTypes[index] = binding.textureComponentType;
|
||||
|
||||
if (binding.textureDimension == dawn::TextureViewDimension::Undefined) {
|
||||
mBindingInfo.textureDimensions[index] = dawn::TextureViewDimension::e2D;
|
||||
if (binding.textureDimension == wgpu::TextureViewDimension::Undefined) {
|
||||
mBindingInfo.textureDimensions[index] = wgpu::TextureViewDimension::e2D;
|
||||
} else {
|
||||
mBindingInfo.textureDimensions[index] = binding.textureDimension;
|
||||
}
|
||||
if (binding.hasDynamicOffset) {
|
||||
mBindingInfo.hasDynamicOffset.set(index);
|
||||
switch (binding.type) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
++mDynamicUniformBufferCount;
|
||||
break;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
++mDynamicStorageBufferCount;
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
|
@ -40,10 +40,10 @@ namespace dawn_native {
|
||||
static BindGroupLayoutBase* MakeError(DeviceBase* device);
|
||||
|
||||
struct LayoutBindingInfo {
|
||||
std::array<dawn::ShaderStage, kMaxBindingsPerGroup> visibilities;
|
||||
std::array<dawn::BindingType, kMaxBindingsPerGroup> types;
|
||||
std::array<dawn::TextureComponentType, kMaxBindingsPerGroup> textureComponentTypes;
|
||||
std::array<dawn::TextureViewDimension, kMaxBindingsPerGroup> textureDimensions;
|
||||
std::array<wgpu::ShaderStage, kMaxBindingsPerGroup> visibilities;
|
||||
std::array<wgpu::BindingType, kMaxBindingsPerGroup> types;
|
||||
std::array<wgpu::TextureComponentType, kMaxBindingsPerGroup> textureComponentTypes;
|
||||
std::array<wgpu::TextureViewDimension, kMaxBindingsPerGroup> textureDimensions;
|
||||
std::bitset<kMaxBindingsPerGroup> hasDynamicOffset;
|
||||
std::bitset<kMaxBindingsPerGroup> multisampled;
|
||||
std::bitset<kMaxBindingsPerGroup> mask;
|
||||
|
@ -91,17 +91,17 @@ namespace dawn_native {
|
||||
|
||||
DAWN_TRY(ValidateBufferUsage(descriptor->usage));
|
||||
|
||||
dawn::BufferUsage usage = descriptor->usage;
|
||||
wgpu::BufferUsage usage = descriptor->usage;
|
||||
|
||||
const dawn::BufferUsage kMapWriteAllowedUsages =
|
||||
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
|
||||
if (usage & dawn::BufferUsage::MapWrite && (usage & kMapWriteAllowedUsages) != usage) {
|
||||
const wgpu::BufferUsage kMapWriteAllowedUsages =
|
||||
wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
|
||||
if (usage & wgpu::BufferUsage::MapWrite && (usage & kMapWriteAllowedUsages) != usage) {
|
||||
return DAWN_VALIDATION_ERROR("Only CopySrc is allowed with MapWrite");
|
||||
}
|
||||
|
||||
const dawn::BufferUsage kMapReadAllowedUsages =
|
||||
dawn::BufferUsage::MapRead | dawn::BufferUsage::CopyDst;
|
||||
if (usage & dawn::BufferUsage::MapRead && (usage & kMapReadAllowedUsages) != usage) {
|
||||
const wgpu::BufferUsage kMapReadAllowedUsages =
|
||||
wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopyDst;
|
||||
if (usage & wgpu::BufferUsage::MapRead && (usage & kMapReadAllowedUsages) != usage) {
|
||||
return DAWN_VALIDATION_ERROR("Only CopyDst is allowed with MapRead");
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ namespace dawn_native {
|
||||
return mSize;
|
||||
}
|
||||
|
||||
dawn::BufferUsage BufferBase::GetUsage() const {
|
||||
wgpu::BufferUsage BufferBase::GetUsage() const {
|
||||
ASSERT(!IsError());
|
||||
return mUsage;
|
||||
}
|
||||
@ -189,7 +189,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
void BufferBase::CallMapReadCallback(uint32_t serial,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
WGPUBufferMapAsyncStatus status,
|
||||
const void* pointer,
|
||||
uint32_t dataLength) {
|
||||
ASSERT(!IsError());
|
||||
@ -197,14 +197,14 @@ namespace dawn_native {
|
||||
ASSERT(mMapWriteCallback == nullptr);
|
||||
// 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.
|
||||
DawnBufferMapReadCallback callback = mMapReadCallback;
|
||||
WGPUBufferMapReadCallback callback = mMapReadCallback;
|
||||
mMapReadCallback = nullptr;
|
||||
callback(status, pointer, dataLength, mMapUserdata);
|
||||
}
|
||||
}
|
||||
|
||||
void BufferBase::CallMapWriteCallback(uint32_t serial,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
WGPUBufferMapAsyncStatus status,
|
||||
void* pointer,
|
||||
uint32_t dataLength) {
|
||||
ASSERT(!IsError());
|
||||
@ -212,7 +212,7 @@ namespace dawn_native {
|
||||
ASSERT(mMapReadCallback == nullptr);
|
||||
// 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.
|
||||
DawnBufferMapWriteCallback callback = mMapWriteCallback;
|
||||
WGPUBufferMapWriteCallback callback = mMapWriteCallback;
|
||||
mMapWriteCallback = nullptr;
|
||||
callback(status, pointer, dataLength, mMapUserdata);
|
||||
}
|
||||
@ -229,8 +229,8 @@ namespace dawn_native {
|
||||
}
|
||||
}
|
||||
|
||||
void BufferBase::MapReadAsync(DawnBufferMapReadCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsage::MapRead))) {
|
||||
void BufferBase::MapReadAsync(WGPUBufferMapReadCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(wgpu::BufferUsage::MapRead))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
return;
|
||||
}
|
||||
@ -265,8 +265,8 @@ namespace dawn_native {
|
||||
return {};
|
||||
}
|
||||
|
||||
void BufferBase::MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(dawn::BufferUsage::MapWrite))) {
|
||||
void BufferBase::MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateMap(wgpu::BufferUsage::MapWrite))) {
|
||||
callback(DAWN_BUFFER_MAP_ASYNC_STATUS_ERROR, nullptr, 0, userdata);
|
||||
return;
|
||||
}
|
||||
@ -374,14 +374,14 @@ namespace dawn_native {
|
||||
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 {};
|
||||
}
|
||||
|
||||
MaybeError BufferBase::ValidateMap(dawn::BufferUsage requiredUsage) const {
|
||||
MaybeError BufferBase::ValidateMap(wgpu::BufferUsage requiredUsage) const {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
|
||||
switch (mState) {
|
||||
@ -409,7 +409,7 @@ namespace dawn_native {
|
||||
// even if it did not have a mappable usage.
|
||||
return {};
|
||||
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 {};
|
||||
|
@ -27,12 +27,12 @@ namespace dawn_native {
|
||||
|
||||
MaybeError ValidateBufferDescriptor(DeviceBase* device, const BufferDescriptor* descriptor);
|
||||
|
||||
static constexpr dawn::BufferUsage kReadOnlyBufferUsages =
|
||||
dawn::BufferUsage::MapRead | dawn::BufferUsage::CopySrc | dawn::BufferUsage::Index |
|
||||
dawn::BufferUsage::Vertex | dawn::BufferUsage::Uniform;
|
||||
static constexpr wgpu::BufferUsage kReadOnlyBufferUsages =
|
||||
wgpu::BufferUsage::MapRead | wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::Index |
|
||||
wgpu::BufferUsage::Vertex | wgpu::BufferUsage::Uniform;
|
||||
|
||||
static constexpr dawn::BufferUsage kWritableBufferUsages =
|
||||
dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopyDst | dawn::BufferUsage::Storage;
|
||||
static constexpr wgpu::BufferUsage kWritableBufferUsages =
|
||||
wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::Storage;
|
||||
|
||||
class BufferBase : public ObjectBase {
|
||||
enum class BufferState {
|
||||
@ -51,7 +51,7 @@ namespace dawn_native {
|
||||
uint8_t** mappedPointer);
|
||||
|
||||
uint64_t GetSize() const;
|
||||
dawn::BufferUsage GetUsage() const;
|
||||
wgpu::BufferUsage GetUsage() const;
|
||||
|
||||
MaybeError MapAtCreation(uint8_t** mappedPointer);
|
||||
|
||||
@ -59,8 +59,8 @@ namespace dawn_native {
|
||||
|
||||
// Dawn API
|
||||
void SetSubData(uint32_t start, uint32_t count, const void* data);
|
||||
void MapReadAsync(DawnBufferMapReadCallback callback, void* userdata);
|
||||
void MapWriteAsync(DawnBufferMapWriteCallback callback, void* userdata);
|
||||
void MapReadAsync(WGPUBufferMapReadCallback callback, void* userdata);
|
||||
void MapWriteAsync(WGPUBufferMapWriteCallback callback, void* userdata);
|
||||
void Unmap();
|
||||
void Destroy();
|
||||
|
||||
@ -68,11 +68,11 @@ namespace dawn_native {
|
||||
BufferBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
void CallMapReadCallback(uint32_t serial,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
WGPUBufferMapAsyncStatus status,
|
||||
const void* pointer,
|
||||
uint32_t dataLength);
|
||||
void CallMapWriteCallback(uint32_t serial,
|
||||
DawnBufferMapAsyncStatus status,
|
||||
WGPUBufferMapAsyncStatus status,
|
||||
void* pointer,
|
||||
uint32_t dataLength);
|
||||
|
||||
@ -90,15 +90,15 @@ namespace dawn_native {
|
||||
MaybeError CopyFromStagingBuffer();
|
||||
|
||||
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 ValidateDestroy() const;
|
||||
|
||||
uint64_t mSize = 0;
|
||||
dawn::BufferUsage mUsage = dawn::BufferUsage::None;
|
||||
wgpu::BufferUsage mUsage = wgpu::BufferUsage::None;
|
||||
|
||||
DawnBufferMapReadCallback mMapReadCallback = nullptr;
|
||||
DawnBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||
WGPUBufferMapReadCallback mMapReadCallback = nullptr;
|
||||
WGPUBufferMapWriteCallback mMapWriteCallback = nullptr;
|
||||
void* mMapUserdata = 0;
|
||||
uint32_t mMapSerial = 0;
|
||||
|
||||
|
@ -242,8 +242,8 @@ namespace dawn_native {
|
||||
return {};
|
||||
}
|
||||
|
||||
MaybeError ValidateCanUseAs(BufferBase* buffer, dawn::BufferUsage usage) {
|
||||
ASSERT(dawn::HasZeroOrOneBits(usage));
|
||||
MaybeError ValidateCanUseAs(BufferBase* buffer, wgpu::BufferUsage usage) {
|
||||
ASSERT(wgpu::HasZeroOrOneBits(usage));
|
||||
if (!(buffer->GetUsage() & usage)) {
|
||||
return DAWN_VALIDATION_ERROR("buffer doesn't have the required usage.");
|
||||
}
|
||||
@ -251,8 +251,8 @@ namespace dawn_native {
|
||||
return {};
|
||||
}
|
||||
|
||||
MaybeError ValidateCanUseAs(TextureBase* texture, dawn::TextureUsage usage) {
|
||||
ASSERT(dawn::HasZeroOrOneBits(usage));
|
||||
MaybeError ValidateCanUseAs(TextureBase* texture, wgpu::TextureUsage usage) {
|
||||
ASSERT(wgpu::HasZeroOrOneBits(usage));
|
||||
if (!(texture->GetUsage() & 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");
|
||||
}
|
||||
|
||||
dawn::TextureFormat resolveTargetFormat = resolveTarget->GetFormat().format;
|
||||
wgpu::TextureFormat resolveTargetFormat = resolveTarget->GetFormat().format;
|
||||
if (resolveTargetFormat != attachment->GetFormat().format) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"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,
|
||||
copy->destinationOffset));
|
||||
|
||||
DAWN_TRY(ValidateCanUseAs(copy->source.Get(), dawn::BufferUsage::CopySrc));
|
||||
DAWN_TRY(ValidateCanUseAs(copy->destination.Get(), dawn::BufferUsage::CopyDst));
|
||||
DAWN_TRY(ValidateCanUseAs(copy->source.Get(), wgpu::BufferUsage::CopySrc));
|
||||
DAWN_TRY(ValidateCanUseAs(copy->destination.Get(), wgpu::BufferUsage::CopyDst));
|
||||
|
||||
mResourceUsages.topLevelBuffers.insert(copy->source.Get());
|
||||
mResourceUsages.topLevelBuffers.insert(copy->destination.Get());
|
||||
@ -789,9 +789,9 @@ namespace dawn_native {
|
||||
copy->destination.texture->GetFormat()));
|
||||
|
||||
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::TextureUsage::CopyDst));
|
||||
wgpu::TextureUsage::CopyDst));
|
||||
|
||||
mResourceUsages.topLevelBuffers.insert(copy->source.buffer.Get());
|
||||
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
|
||||
@ -824,9 +824,9 @@ namespace dawn_native {
|
||||
copy->source.texture->GetFormat()));
|
||||
|
||||
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::BufferUsage::CopyDst));
|
||||
wgpu::BufferUsage::CopyDst));
|
||||
|
||||
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
|
||||
mResourceUsages.topLevelBuffers.insert(copy->destination.buffer.Get());
|
||||
@ -852,9 +852,9 @@ namespace dawn_native {
|
||||
DAWN_TRY(ValidateCopySizeFitsInTexture(copy->destination, copy->copySize));
|
||||
|
||||
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::TextureUsage::CopyDst));
|
||||
wgpu::TextureUsage::CopyDst));
|
||||
|
||||
mResourceUsages.topLevelTextures.insert(copy->source.texture.Get());
|
||||
mResourceUsages.topLevelTextures.insert(copy->destination.texture.Get());
|
||||
|
@ -31,29 +31,29 @@ namespace dawn_native {
|
||||
const auto& layoutInfo = group->GetLayout()->GetBindingInfo();
|
||||
|
||||
for (uint32_t i : IterateBitSet(layoutInfo.mask)) {
|
||||
dawn::BindingType type = layoutInfo.types[i];
|
||||
wgpu::BindingType type = layoutInfo.types[i];
|
||||
|
||||
switch (type) {
|
||||
case dawn::BindingType::UniformBuffer: {
|
||||
case wgpu::BindingType::UniformBuffer: {
|
||||
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||
usageTracker->BufferUsedAs(buffer, dawn::BufferUsage::Uniform);
|
||||
usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Uniform);
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageBuffer: {
|
||||
case wgpu::BindingType::StorageBuffer: {
|
||||
BufferBase* buffer = group->GetBindingAsBufferBinding(i).buffer;
|
||||
usageTracker->BufferUsedAs(buffer, dawn::BufferUsage::Storage);
|
||||
usageTracker->BufferUsedAs(buffer, wgpu::BufferUsage::Storage);
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::SampledTexture: {
|
||||
case wgpu::BindingType::SampledTexture: {
|
||||
TextureBase* texture = group->GetBindingAsTextureView(i)->GetTexture();
|
||||
usageTracker->TextureUsedAs(texture, dawn::TextureUsage::Sampled);
|
||||
usageTracker->TextureUsedAs(texture, wgpu::TextureUsage::Sampled);
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
@ -82,14 +82,14 @@ namespace dawn_native {
|
||||
DrawIndirectCmd* cmd = commands->NextCommand<DrawIndirectCmd>();
|
||||
DAWN_TRY(commandBufferState->ValidateCanDraw());
|
||||
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
|
||||
dawn::BufferUsage::Indirect);
|
||||
wgpu::BufferUsage::Indirect);
|
||||
} break;
|
||||
|
||||
case Command::DrawIndexedIndirect: {
|
||||
DrawIndexedIndirectCmd* cmd = commands->NextCommand<DrawIndexedIndirectCmd>();
|
||||
DAWN_TRY(commandBufferState->ValidateCanDrawIndexed());
|
||||
usageTracker->BufferUsedAs(cmd->indirectBuffer.Get(),
|
||||
dawn::BufferUsage::Indirect);
|
||||
wgpu::BufferUsage::Indirect);
|
||||
} break;
|
||||
|
||||
case Command::InsertDebugMarker: {
|
||||
@ -132,14 +132,14 @@ namespace dawn_native {
|
||||
case Command::SetIndexBuffer: {
|
||||
SetIndexBufferCmd* cmd = commands->NextCommand<SetIndexBufferCmd>();
|
||||
|
||||
usageTracker->BufferUsedAs(cmd->buffer.Get(), dawn::BufferUsage::Index);
|
||||
usageTracker->BufferUsedAs(cmd->buffer.Get(), wgpu::BufferUsage::Index);
|
||||
commandBufferState->SetIndexBuffer();
|
||||
} break;
|
||||
|
||||
case Command::SetVertexBuffer: {
|
||||
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);
|
||||
} break;
|
||||
|
||||
@ -199,18 +199,18 @@ namespace dawn_native {
|
||||
for (uint32_t i : IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
RenderPassColorAttachmentInfo* colorAttachment = &renderPass->colorAttachments[i];
|
||||
TextureBase* texture = colorAttachment->view->GetTexture();
|
||||
usageTracker.TextureUsedAs(texture, dawn::TextureUsage::OutputAttachment);
|
||||
usageTracker.TextureUsedAs(texture, wgpu::TextureUsage::OutputAttachment);
|
||||
|
||||
TextureViewBase* resolveTarget = colorAttachment->resolveTarget.Get();
|
||||
if (resolveTarget != nullptr) {
|
||||
usageTracker.TextureUsedAs(resolveTarget->GetTexture(),
|
||||
dawn::TextureUsage::OutputAttachment);
|
||||
wgpu::TextureUsage::OutputAttachment);
|
||||
}
|
||||
}
|
||||
|
||||
if (renderPass->attachmentState->HasDepthStencilAttachment()) {
|
||||
TextureBase* texture = renderPass->depthStencilAttachment.view->GetTexture();
|
||||
usageTracker.TextureUsedAs(texture, dawn::TextureUsage::OutputAttachment);
|
||||
usageTracker.TextureUsedAs(texture, wgpu::TextureUsage::OutputAttachment);
|
||||
}
|
||||
|
||||
Command type;
|
||||
@ -310,7 +310,7 @@ namespace dawn_native {
|
||||
DispatchIndirectCmd* cmd = commands->NextCommand<DispatchIndirectCmd>();
|
||||
DAWN_TRY(commandBufferState.ValidateCanDispatch());
|
||||
usageTracker.BufferUsedAs(cmd->indirectBuffer.Get(),
|
||||
dawn::BufferUsage::Indirect);
|
||||
wgpu::BufferUsage::Indirect);
|
||||
} break;
|
||||
|
||||
case Command::InsertDebugMarker: {
|
||||
|
@ -66,17 +66,17 @@ namespace dawn_native {
|
||||
struct RenderPassColorAttachmentInfo {
|
||||
Ref<TextureViewBase> view;
|
||||
Ref<TextureViewBase> resolveTarget;
|
||||
dawn::LoadOp loadOp;
|
||||
dawn::StoreOp storeOp;
|
||||
wgpu::LoadOp loadOp;
|
||||
wgpu::StoreOp storeOp;
|
||||
dawn_native::Color clearColor;
|
||||
};
|
||||
|
||||
struct RenderPassDepthStencilAttachmentInfo {
|
||||
Ref<TextureViewBase> view;
|
||||
dawn::LoadOp depthLoadOp;
|
||||
dawn::StoreOp depthStoreOp;
|
||||
dawn::LoadOp stencilLoadOp;
|
||||
dawn::StoreOp stencilStoreOp;
|
||||
wgpu::LoadOp depthLoadOp;
|
||||
wgpu::StoreOp depthStoreOp;
|
||||
wgpu::LoadOp stencilLoadOp;
|
||||
wgpu::StoreOp stencilStoreOp;
|
||||
float clearDepth;
|
||||
uint32_t clearStencil;
|
||||
};
|
||||
|
@ -36,7 +36,7 @@ namespace dawn_native {
|
||||
ComputePipelineBase::ComputePipelineBase(DeviceBase* device,
|
||||
const ComputePipelineDescriptor* descriptor,
|
||||
bool blueprint)
|
||||
: PipelineBase(device, descriptor->layout, dawn::ShaderStage::Compute),
|
||||
: PipelineBase(device, descriptor->layout, wgpu::ShaderStage::Compute),
|
||||
mModule(descriptor->computeStage.module),
|
||||
mEntryPoint(descriptor->computeStage.entryPoint),
|
||||
mIsBlueprint(blueprint) {
|
||||
|
@ -94,16 +94,16 @@ namespace dawn_native {
|
||||
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);
|
||||
}
|
||||
|
||||
void DeviceBase::InjectError(dawn::ErrorType type, const char* message) {
|
||||
void DeviceBase::InjectError(wgpu::ErrorType type, const char* message) {
|
||||
if (ConsumedError(ValidateErrorType(type))) {
|
||||
return;
|
||||
}
|
||||
if (DAWN_UNLIKELY(type == dawn::ErrorType::NoError)) {
|
||||
HandleError(dawn::ErrorType::Validation, "Invalid injected error NoError");
|
||||
if (DAWN_UNLIKELY(type == wgpu::ErrorType::NoError)) {
|
||||
HandleError(wgpu::ErrorType::Validation, "Invalid injected error NoError");
|
||||
return;
|
||||
}
|
||||
HandleError(type, message);
|
||||
@ -115,18 +115,18 @@ namespace dawn_native {
|
||||
delete error;
|
||||
}
|
||||
|
||||
void DeviceBase::SetUncapturedErrorCallback(dawn::ErrorCallback callback, void* userdata) {
|
||||
void DeviceBase::SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata) {
|
||||
mRootErrorScope->SetCallback(callback, userdata);
|
||||
}
|
||||
|
||||
void DeviceBase::PushErrorScope(dawn::ErrorFilter filter) {
|
||||
void DeviceBase::PushErrorScope(wgpu::ErrorFilter filter) {
|
||||
if (ConsumedError(ValidateErrorFilter(filter))) {
|
||||
return;
|
||||
}
|
||||
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())) {
|
||||
return false;
|
||||
}
|
||||
@ -168,7 +168,7 @@ namespace dawn_native {
|
||||
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);
|
||||
if (index >= mFormatTable.size()) {
|
||||
return DAWN_VALIDATION_ERROR("Unknown texture format");
|
||||
@ -182,7 +182,7 @@ namespace dawn_native {
|
||||
return internalFormat;
|
||||
}
|
||||
|
||||
const Format& DeviceBase::GetValidInternalFormat(dawn::TextureFormat format) const {
|
||||
const Format& DeviceBase::GetValidInternalFormat(wgpu::TextureFormat format) const {
|
||||
size_t index = ComputeFormatIndex(format);
|
||||
ASSERT(index < mFormatTable.size());
|
||||
ASSERT(mFormatTable[index].isSupported);
|
||||
@ -413,7 +413,7 @@ namespace dawn_native {
|
||||
return result;
|
||||
}
|
||||
void DeviceBase::CreateBufferMappedAsync(const BufferDescriptor* descriptor,
|
||||
dawn::BufferCreateMappedCallback callback,
|
||||
wgpu::BufferCreateMappedCallback callback,
|
||||
void* userdata) {
|
||||
DawnCreateBufferMappedResult result = CreateBufferMapped(descriptor);
|
||||
|
||||
|
@ -46,7 +46,7 @@ namespace dawn_native {
|
||||
DeviceBase(AdapterBase* adapter, const DeviceDescriptor* descriptor);
|
||||
virtual ~DeviceBase();
|
||||
|
||||
void HandleError(dawn::ErrorType type, const char* message);
|
||||
void HandleError(wgpu::ErrorType type, const char* message);
|
||||
|
||||
bool ConsumedError(MaybeError maybeError) {
|
||||
if (DAWN_UNLIKELY(maybeError.IsError())) {
|
||||
@ -74,15 +74,15 @@ namespace dawn_native {
|
||||
ErrorScopeTracker* GetErrorScopeTracker() const;
|
||||
FenceSignalTracker* GetFenceSignalTracker() const;
|
||||
|
||||
// Returns the Format corresponding to the dawn::TextureFormat or an error if the format
|
||||
// isn't a valid dawn::TextureFormat or isn't supported by this device.
|
||||
// Returns the Format corresponding to the wgpu::TextureFormat or an error if the format
|
||||
// isn't a valid wgpu::TextureFormat or isn't supported by this 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.
|
||||
// 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(
|
||||
CommandEncoderBase* encoder,
|
||||
@ -143,7 +143,7 @@ namespace dawn_native {
|
||||
BufferBase* CreateBuffer(const BufferDescriptor* descriptor);
|
||||
DawnCreateBufferMappedResult CreateBufferMapped(const BufferDescriptor* descriptor);
|
||||
void CreateBufferMappedAsync(const BufferDescriptor* descriptor,
|
||||
dawn::BufferCreateMappedCallback callback,
|
||||
wgpu::BufferCreateMappedCallback callback,
|
||||
void* userdata);
|
||||
CommandEncoderBase* CreateCommandEncoder(const CommandEncoderDescriptor* descriptor);
|
||||
ComputePipelineBase* CreateComputePipeline(const ComputePipelineDescriptor* descriptor);
|
||||
@ -159,13 +159,13 @@ namespace dawn_native {
|
||||
TextureViewBase* CreateTextureView(TextureBase* texture,
|
||||
const TextureViewDescriptor* descriptor);
|
||||
|
||||
void InjectError(dawn::ErrorType type, const char* message);
|
||||
void InjectError(wgpu::ErrorType type, const char* message);
|
||||
|
||||
void Tick();
|
||||
|
||||
void SetUncapturedErrorCallback(dawn::ErrorCallback callback, void* userdata);
|
||||
void PushErrorScope(dawn::ErrorFilter filter);
|
||||
bool PopErrorScope(dawn::ErrorCallback callback, void* userdata);
|
||||
void SetUncapturedErrorCallback(wgpu::ErrorCallback callback, void* userdata);
|
||||
void PushErrorScope(wgpu::ErrorFilter filter);
|
||||
bool PopErrorScope(wgpu::ErrorCallback callback, void* userdata);
|
||||
ErrorScope* GetCurrentErrorScope();
|
||||
|
||||
void Reference();
|
||||
@ -261,7 +261,7 @@ namespace dawn_native {
|
||||
std::unique_ptr<Caches> mCaches;
|
||||
|
||||
struct DeferredCreateBufferMappedAsync {
|
||||
dawn::BufferCreateMappedCallback callback;
|
||||
wgpu::BufferCreateMappedCallback callback;
|
||||
DawnBufferMapAsyncStatus status;
|
||||
DawnCreateBufferMappedResult result;
|
||||
void* userdata;
|
||||
|
@ -45,7 +45,7 @@ namespace dawn_native {
|
||||
return &mIterator;
|
||||
}
|
||||
|
||||
void EncodingContext::HandleError(dawn::ErrorType type, const char* message) {
|
||||
void EncodingContext::HandleError(wgpu::ErrorType type, const char* message) {
|
||||
if (!IsFinished()) {
|
||||
// If the encoding context is not finished, errors are deferred until
|
||||
// Finish() is called.
|
||||
|
@ -38,7 +38,7 @@ namespace dawn_native {
|
||||
CommandIterator* GetIterator();
|
||||
|
||||
// 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) {
|
||||
HandleError(error->GetType(), error->GetMessage().c_str());
|
||||
@ -58,10 +58,10 @@ namespace dawn_native {
|
||||
if (DAWN_UNLIKELY(encoder != mCurrentEncoder)) {
|
||||
if (mCurrentEncoder != mTopLevelEncoder) {
|
||||
// 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");
|
||||
} else {
|
||||
HandleError(dawn::ErrorType::Validation,
|
||||
HandleError(wgpu::ErrorType::Validation,
|
||||
"Recording in an error or already ended pass encoder");
|
||||
}
|
||||
return false;
|
||||
|
@ -38,16 +38,16 @@ namespace dawn_native {
|
||||
return mType;
|
||||
}
|
||||
|
||||
dawn::ErrorType ErrorData::GetType() const {
|
||||
wgpu::ErrorType ErrorData::GetType() const {
|
||||
switch (mType) {
|
||||
case InternalErrorType::Validation:
|
||||
return dawn::ErrorType::Validation;
|
||||
return wgpu::ErrorType::Validation;
|
||||
case InternalErrorType::OutOfMemory:
|
||||
return dawn::ErrorType::OutOfMemory;
|
||||
return wgpu::ErrorType::OutOfMemory;
|
||||
case InternalErrorType::DeviceLost:
|
||||
return dawn::ErrorType::DeviceLost;
|
||||
return wgpu::ErrorType::DeviceLost;
|
||||
default:
|
||||
return dawn::ErrorType::Unknown;
|
||||
return wgpu::ErrorType::Unknown;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@ namespace dawn_native {
|
||||
void AppendBacktrace(const char* file, const char* function, int line);
|
||||
|
||||
InternalErrorType GetInternalType() const;
|
||||
dawn::ErrorType GetType() const;
|
||||
wgpu::ErrorType GetType() const;
|
||||
const std::string& GetMessage() const;
|
||||
const std::vector<BacktraceRecord>& GetBacktrace() const;
|
||||
|
||||
|
@ -20,7 +20,7 @@ namespace dawn_native {
|
||||
|
||||
ErrorScope::ErrorScope() = default;
|
||||
|
||||
ErrorScope::ErrorScope(dawn::ErrorFilter errorFilter, ErrorScope* parent)
|
||||
ErrorScope::ErrorScope(wgpu::ErrorFilter errorFilter, ErrorScope* parent)
|
||||
: RefCounted(), mErrorFilter(errorFilter), mParent(parent) {
|
||||
ASSERT(mParent.Get() != nullptr);
|
||||
}
|
||||
@ -29,10 +29,10 @@ namespace dawn_native {
|
||||
if (mCallback == nullptr || IsRoot()) {
|
||||
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;
|
||||
mUserdata = userdata;
|
||||
}
|
||||
@ -45,28 +45,28 @@ namespace dawn_native {
|
||||
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);
|
||||
}
|
||||
|
||||
// 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;
|
||||
for (; !currentScope->IsRoot(); currentScope = currentScope->GetParent()) {
|
||||
ASSERT(currentScope != nullptr);
|
||||
|
||||
bool consumed = false;
|
||||
switch (type) {
|
||||
case dawn::ErrorType::Validation:
|
||||
if (currentScope->mErrorFilter != dawn::ErrorFilter::Validation) {
|
||||
case wgpu::ErrorType::Validation:
|
||||
if (currentScope->mErrorFilter != wgpu::ErrorFilter::Validation) {
|
||||
// Error filter does not match. Move on to the next scope.
|
||||
continue;
|
||||
}
|
||||
consumed = true;
|
||||
break;
|
||||
|
||||
case dawn::ErrorType::OutOfMemory:
|
||||
if (currentScope->mErrorFilter != dawn::ErrorFilter::OutOfMemory) {
|
||||
case wgpu::ErrorType::OutOfMemory:
|
||||
if (currentScope->mErrorFilter != wgpu::ErrorFilter::OutOfMemory) {
|
||||
// Error filter does not match. Move on to the next scope.
|
||||
continue;
|
||||
}
|
||||
@ -75,19 +75,19 @@ namespace dawn_native {
|
||||
|
||||
// Unknown and DeviceLost are fatal. All error scopes capture them.
|
||||
// |consumed| is false because these should bubble to all scopes.
|
||||
case dawn::ErrorType::Unknown:
|
||||
case dawn::ErrorType::DeviceLost:
|
||||
case wgpu::ErrorType::Unknown:
|
||||
case wgpu::ErrorType::DeviceLost:
|
||||
consumed = false;
|
||||
break;
|
||||
|
||||
case dawn::ErrorType::NoError:
|
||||
case wgpu::ErrorType::NoError:
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return;
|
||||
}
|
||||
|
||||
// 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->mErrorMessage = message;
|
||||
}
|
||||
@ -100,14 +100,14 @@ namespace dawn_native {
|
||||
// The root error scope captures all uncaptured errors.
|
||||
ASSERT(currentScope->IsRoot());
|
||||
if (currentScope->mCallback) {
|
||||
currentScope->mCallback(static_cast<DawnErrorType>(type), message,
|
||||
currentScope->mCallback(static_cast<WGPUErrorType>(type), message,
|
||||
currentScope->mUserdata);
|
||||
}
|
||||
}
|
||||
|
||||
void ErrorScope::Destroy() {
|
||||
if (!IsRoot()) {
|
||||
mErrorType = dawn::ErrorType::Unknown;
|
||||
mErrorType = wgpu::ErrorType::Unknown;
|
||||
mErrorMessage = "Error scope destroyed";
|
||||
}
|
||||
}
|
||||
|
@ -38,27 +38,27 @@ namespace dawn_native {
|
||||
class ErrorScope : public RefCounted {
|
||||
public:
|
||||
ErrorScope(); // Constructor for the root error scope.
|
||||
ErrorScope(dawn::ErrorFilter errorFilter, ErrorScope* parent);
|
||||
ErrorScope(wgpu::ErrorFilter errorFilter, ErrorScope* parent);
|
||||
~ErrorScope();
|
||||
|
||||
void SetCallback(dawn::ErrorCallback callback, void* userdata);
|
||||
void SetCallback(wgpu::ErrorCallback callback, void* userdata);
|
||||
ErrorScope* GetParent();
|
||||
|
||||
void HandleError(dawn::ErrorType type, const char* message);
|
||||
void HandleError(wgpu::ErrorType type, const char* message);
|
||||
|
||||
void Destroy();
|
||||
|
||||
private:
|
||||
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;
|
||||
|
||||
dawn::ErrorCallback mCallback = nullptr;
|
||||
wgpu::ErrorCallback mCallback = nullptr;
|
||||
void* mUserdata = nullptr;
|
||||
|
||||
dawn::ErrorType mErrorType = dawn::ErrorType::NoError;
|
||||
wgpu::ErrorType mErrorType = wgpu::ErrorType::NoError;
|
||||
std::string mErrorMessage = "";
|
||||
};
|
||||
|
||||
|
@ -64,7 +64,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
void FenceBase::OnCompletion(uint64_t value,
|
||||
dawn::FenceOnCompletionCallback callback,
|
||||
wgpu::FenceOnCompletionCallback callback,
|
||||
void* userdata) {
|
||||
if (GetDevice()->ConsumedError(ValidateOnCompletion(value))) {
|
||||
callback(DAWN_FENCE_COMPLETION_STATUS_ERROR, userdata);
|
||||
|
@ -40,7 +40,7 @@ namespace dawn_native {
|
||||
|
||||
// Dawn API
|
||||
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:
|
||||
friend class QueueBase;
|
||||
@ -54,7 +54,7 @@ namespace dawn_native {
|
||||
MaybeError ValidateOnCompletion(uint64_t value) const;
|
||||
|
||||
struct OnCompletionData {
|
||||
dawn::FenceOnCompletionCallback completionCallback = nullptr;
|
||||
wgpu::FenceOnCompletionCallback completionCallback = nullptr;
|
||||
void* userdata = nullptr;
|
||||
};
|
||||
|
||||
|
@ -38,23 +38,23 @@ namespace dawn_native {
|
||||
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.
|
||||
if (aspect != Color) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Check that Type is correctly mirrors TextureComponentType except for "Other".
|
||||
static_assert(static_cast<dawn::TextureComponentType>(Type::Float) ==
|
||||
dawn::TextureComponentType::Float,
|
||||
static_assert(static_cast<wgpu::TextureComponentType>(Type::Float) ==
|
||||
wgpu::TextureComponentType::Float,
|
||||
"");
|
||||
static_assert(
|
||||
static_cast<dawn::TextureComponentType>(Type::Sint) == dawn::TextureComponentType::Sint,
|
||||
static_cast<wgpu::TextureComponentType>(Type::Sint) == wgpu::TextureComponentType::Sint,
|
||||
"");
|
||||
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 {
|
||||
@ -65,10 +65,10 @@ namespace dawn_native {
|
||||
|
||||
// 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.
|
||||
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
|
||||
// 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);
|
||||
}
|
||||
@ -92,7 +92,7 @@ namespace dawn_native {
|
||||
formatsSet.set(index);
|
||||
};
|
||||
|
||||
auto AddColorFormat = [&AddFormat](dawn::TextureFormat format, bool renderable,
|
||||
auto AddColorFormat = [&AddFormat](wgpu::TextureFormat format, bool renderable,
|
||||
uint32_t byteSize, Type type) {
|
||||
Format internalFormat;
|
||||
internalFormat.format = format;
|
||||
@ -107,7 +107,7 @@ namespace dawn_native {
|
||||
AddFormat(internalFormat);
|
||||
};
|
||||
|
||||
auto AddDepthStencilFormat = [&AddFormat](dawn::TextureFormat format, Format::Aspect aspect,
|
||||
auto AddDepthStencilFormat = [&AddFormat](wgpu::TextureFormat format, Format::Aspect aspect,
|
||||
uint32_t byteSize) {
|
||||
Format internalFormat;
|
||||
internalFormat.format = format;
|
||||
@ -122,7 +122,7 @@ namespace dawn_native {
|
||||
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) {
|
||||
Format internalFormat;
|
||||
internalFormat.format = format;
|
||||
@ -140,74 +140,74 @@ namespace dawn_native {
|
||||
// clang-format off
|
||||
|
||||
// 1 byte color formats
|
||||
AddColorFormat(dawn::TextureFormat::R8Unorm, true, 1, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::R8Snorm, false, 1, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::R8Uint, true, 1, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::R8Sint, true, 1, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::R8Unorm, true, 1, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::R8Snorm, false, 1, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::R8Uint, true, 1, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::R8Sint, true, 1, Type::Sint);
|
||||
|
||||
// 2 bytes color formats
|
||||
AddColorFormat(dawn::TextureFormat::R16Uint, true, 2, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::R16Sint, true, 2, Type::Sint);
|
||||
AddColorFormat(dawn::TextureFormat::R16Float, true, 2, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RG8Unorm, true, 2, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RG8Snorm, false, 2, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RG8Uint, true, 2, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::RG8Sint, true, 2, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::R16Uint, true, 2, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::R16Sint, true, 2, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::R16Float, true, 2, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RG8Unorm, true, 2, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RG8Snorm, false, 2, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RG8Uint, true, 2, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::RG8Sint, true, 2, Type::Sint);
|
||||
|
||||
// 4 bytes color formats
|
||||
AddColorFormat(dawn::TextureFormat::R32Uint, true, 4, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::R32Sint, true, 4, Type::Sint);
|
||||
AddColorFormat(dawn::TextureFormat::R32Float, true, 4, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RG16Uint, true, 4, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::RG16Sint, true, 4, Type::Sint);
|
||||
AddColorFormat(dawn::TextureFormat::RG16Float, true, 4, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA8Unorm, true, 4, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA8UnormSrgb, true, 4, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA8Snorm, false, 4, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA8Uint, true, 4, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA8Sint, true, 4, Type::Sint);
|
||||
AddColorFormat(dawn::TextureFormat::BGRA8Unorm, true, 4, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::BGRA8UnormSrgb, true, 4, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RGB10A2Unorm, true, 4, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::R32Uint, true, 4, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::R32Sint, true, 4, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::R32Float, true, 4, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RG16Uint, true, 4, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::RG16Sint, true, 4, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::RG16Float, true, 4, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA8Unorm, true, 4, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA8UnormSrgb, true, 4, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA8Snorm, false, 4, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA8Uint, true, 4, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA8Sint, true, 4, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::BGRA8Unorm, true, 4, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::BGRA8UnormSrgb, 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
|
||||
AddColorFormat(dawn::TextureFormat::RG32Uint, true, 8, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::RG32Sint, true, 8, Type::Sint);
|
||||
AddColorFormat(dawn::TextureFormat::RG32Float, true, 8, Type::Float);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA16Uint, true, 8, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA16Sint, true, 8, Type::Sint);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA16Float, true, 8, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RG32Uint, true, 8, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::RG32Sint, true, 8, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::RG32Float, true, 8, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA16Uint, true, 8, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA16Sint, true, 8, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA16Float, true, 8, Type::Float);
|
||||
|
||||
// 16 bytes color formats
|
||||
AddColorFormat(dawn::TextureFormat::RGBA32Uint, true, 16, Type::Uint);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA32Sint, true, 16, Type::Sint);
|
||||
AddColorFormat(dawn::TextureFormat::RGBA32Float, true, 16, Type::Float);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA32Uint, true, 16, Type::Uint);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA32Sint, true, 16, Type::Sint);
|
||||
AddColorFormat(wgpu::TextureFormat::RGBA32Float, true, 16, Type::Float);
|
||||
|
||||
// Depth stencil formats
|
||||
AddDepthStencilFormat(dawn::TextureFormat::Depth32Float, Aspect::Depth, 4);
|
||||
AddDepthStencilFormat(dawn::TextureFormat::Depth24Plus, Aspect::Depth, 4);
|
||||
AddDepthStencilFormat(wgpu::TextureFormat::Depth32Float, Aspect::Depth, 4);
|
||||
AddDepthStencilFormat(wgpu::TextureFormat::Depth24Plus, Aspect::Depth, 4);
|
||||
// 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?
|
||||
AddDepthStencilFormat(dawn::TextureFormat::Depth24PlusStencil8, Aspect::DepthStencil, 4);
|
||||
AddDepthStencilFormat(wgpu::TextureFormat::Depth24PlusStencil8, Aspect::DepthStencil, 4);
|
||||
|
||||
// BC compressed formats
|
||||
bool isBCFormatSupported = device->IsExtensionEnabled(Extension::TextureCompressionBC);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC1RGBAUnorm, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC1RGBAUnormSrgb, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC4RSnorm, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC4RUnorm, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC2RGBAUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC2RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC3RGBAUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC3RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC5RGSnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC5RGUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC6HRGBSfloat, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC6HRGBUfloat, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC7RGBAUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(dawn::TextureFormat::BC7RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnorm, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC1RGBAUnormSrgb, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC4RSnorm, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC4RUnorm, 8, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC2RGBAUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC2RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC3RGBAUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC3RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC5RGSnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC5RGUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC6HRGBSfloat, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC6HRGBUfloat, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC7RGBAUnorm, 16, 4, 4, isBCFormatSupported);
|
||||
AddCompressedFormat(wgpu::TextureFormat::BC7RGBAUnormSrgb, 16, 4, 4, isBCFormatSupported);
|
||||
|
||||
// clang-format on
|
||||
|
||||
|
@ -29,7 +29,7 @@ namespace dawn_native {
|
||||
// exact number of known format.
|
||||
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 {
|
||||
enum Aspect {
|
||||
Color,
|
||||
@ -45,7 +45,7 @@ namespace dawn_native {
|
||||
Other,
|
||||
};
|
||||
|
||||
dawn::TextureFormat format;
|
||||
wgpu::TextureFormat format;
|
||||
bool isRenderable;
|
||||
bool isCompressed;
|
||||
// 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 HasStencil() 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
|
||||
// in [0, kKnownFormatCount)
|
||||
@ -73,7 +73,7 @@ namespace dawn_native {
|
||||
using FormatTable = std::array<Format, kKnownFormatCount>;
|
||||
|
||||
// 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.
|
||||
FormatTable BuildFormatTable(const DeviceBase* device);
|
||||
|
||||
|
@ -30,10 +30,10 @@ namespace dawn_native {
|
||||
// re-compute it.
|
||||
struct PassResourceUsage {
|
||||
std::vector<BufferBase*> buffers;
|
||||
std::vector<dawn::BufferUsage> bufferUsages;
|
||||
std::vector<wgpu::BufferUsage> bufferUsages;
|
||||
|
||||
std::vector<TextureBase*> textures;
|
||||
std::vector<dawn::TextureUsage> textureUsages;
|
||||
std::vector<wgpu::TextureUsage> textureUsages;
|
||||
};
|
||||
|
||||
struct CommandBufferResourceUsage {
|
||||
|
@ -19,13 +19,13 @@
|
||||
|
||||
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
|
||||
// before.
|
||||
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
|
||||
// before.
|
||||
mTextureUsages[texture] |= usage;
|
||||
@ -44,14 +44,14 @@ namespace dawn_native {
|
||||
// Buffers can only be used as single-write or multiple read.
|
||||
for (auto& it : mBufferUsages) {
|
||||
BufferBase* buffer = it.first;
|
||||
dawn::BufferUsage usage = it.second;
|
||||
wgpu::BufferUsage usage = it.second;
|
||||
|
||||
if (usage & ~buffer->GetUsage()) {
|
||||
return DAWN_VALIDATION_ERROR("Buffer missing usage for the pass");
|
||||
}
|
||||
|
||||
bool readOnly = (usage & kReadOnlyBufferUsages) == usage;
|
||||
bool singleUse = dawn::HasZeroOrOneBits(usage);
|
||||
bool singleUse = wgpu::HasZeroOrOneBits(usage);
|
||||
|
||||
if (!readOnly && !singleUse) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
@ -63,7 +63,7 @@ namespace dawn_native {
|
||||
// TODO(cwallez@chromium.org): implement per-subresource tracking
|
||||
for (auto& it : mTextureUsages) {
|
||||
TextureBase* texture = it.first;
|
||||
dawn::TextureUsage usage = it.second;
|
||||
wgpu::TextureUsage usage = it.second;
|
||||
|
||||
if (usage & ~texture->GetUsage()) {
|
||||
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
|
||||
// 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");
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ namespace dawn_native {
|
||||
// information.
|
||||
class PassResourceUsageTracker {
|
||||
public:
|
||||
void BufferUsedAs(BufferBase* buffer, dawn::BufferUsage usage);
|
||||
void TextureUsedAs(TextureBase* texture, dawn::TextureUsage usage);
|
||||
void BufferUsedAs(BufferBase* buffer, wgpu::BufferUsage usage);
|
||||
void TextureUsedAs(TextureBase* texture, wgpu::TextureUsage usage);
|
||||
|
||||
MaybeError ValidateComputePassUsages() const;
|
||||
MaybeError ValidateRenderPassUsages() const;
|
||||
@ -46,8 +46,8 @@ namespace dawn_native {
|
||||
// Performs the per-pass usage validation checks
|
||||
MaybeError ValidateUsages() const;
|
||||
|
||||
std::map<BufferBase*, dawn::BufferUsage> mBufferUsages;
|
||||
std::map<TextureBase*, dawn::TextureUsage> mTextureUsages;
|
||||
std::map<BufferBase*, wgpu::BufferUsage> mBufferUsages;
|
||||
std::map<TextureBase*, wgpu::TextureUsage> mTextureUsages;
|
||||
};
|
||||
|
||||
} // namespace dawn_native
|
||||
|
@ -16,14 +16,14 @@
|
||||
|
||||
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));
|
||||
return BitSetIterator<kNumStages, SingleShaderStage>(bits);
|
||||
}
|
||||
|
||||
dawn::ShaderStage StageBit(SingleShaderStage stage) {
|
||||
wgpu::ShaderStage StageBit(SingleShaderStage stage) {
|
||||
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
|
||||
|
@ -31,21 +31,21 @@ namespace dawn_native {
|
||||
static_assert(static_cast<uint32_t>(SingleShaderStage::Fragment) < 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)),
|
||||
"");
|
||||
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)),
|
||||
"");
|
||||
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)),
|
||||
"");
|
||||
|
||||
BitSetIterator<kNumStages, SingleShaderStage> IterateStages(dawn::ShaderStage stages);
|
||||
dawn::ShaderStage StageBit(SingleShaderStage stage);
|
||||
BitSetIterator<kNumStages, SingleShaderStage> IterateStages(wgpu::ShaderStage stages);
|
||||
wgpu::ShaderStage StageBit(SingleShaderStage stage);
|
||||
|
||||
static constexpr dawn::ShaderStage kAllStages =
|
||||
static_cast<dawn::ShaderStage>((1 << kNumStages) - 1);
|
||||
static constexpr wgpu::ShaderStage kAllStages =
|
||||
static_cast<wgpu::ShaderStage>((1 << kNumStages) - 1);
|
||||
|
||||
template <typename T>
|
||||
class PerStage {
|
||||
@ -64,12 +64,12 @@ namespace dawn_native {
|
||||
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);
|
||||
DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
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);
|
||||
DAWN_ASSERT(bit != 0 && IsPowerOfTwo(bit) && bit <= (1 << kNumStages));
|
||||
return mData[Log2(bit)];
|
||||
|
@ -42,7 +42,7 @@ namespace dawn_native {
|
||||
|
||||
PipelineBase::PipelineBase(DeviceBase* device,
|
||||
PipelineLayoutBase* layout,
|
||||
dawn::ShaderStage stages)
|
||||
wgpu::ShaderStage stages)
|
||||
: ObjectBase(device), mStageMask(stages), mLayout(layout) {
|
||||
}
|
||||
|
||||
@ -50,7 +50,7 @@ namespace dawn_native {
|
||||
: ObjectBase(device, tag) {
|
||||
}
|
||||
|
||||
dawn::ShaderStage PipelineBase::GetStageMask() const {
|
||||
wgpu::ShaderStage PipelineBase::GetStageMask() const {
|
||||
ASSERT(!IsError());
|
||||
return mStageMask;
|
||||
}
|
||||
|
@ -35,16 +35,16 @@ namespace dawn_native {
|
||||
|
||||
class PipelineBase : public ObjectBase {
|
||||
public:
|
||||
dawn::ShaderStage GetStageMask() const;
|
||||
wgpu::ShaderStage GetStageMask() const;
|
||||
PipelineLayoutBase* GetLayout();
|
||||
const PipelineLayoutBase* GetLayout() const;
|
||||
|
||||
protected:
|
||||
PipelineBase(DeviceBase* device, PipelineLayoutBase* layout, dawn::ShaderStage stages);
|
||||
PipelineBase(DeviceBase* device, PipelineLayoutBase* layout, wgpu::ShaderStage stages);
|
||||
PipelineBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
private:
|
||||
dawn::ShaderStage mStageMask;
|
||||
wgpu::ShaderStage mStageMask;
|
||||
Ref<PipelineLayoutBase> mLayout;
|
||||
};
|
||||
|
||||
|
@ -24,7 +24,7 @@
|
||||
namespace dawn_native {
|
||||
|
||||
MaybeError ValidateColorAttachmentFormat(const DeviceBase* device,
|
||||
dawn::TextureFormat textureFormat) {
|
||||
wgpu::TextureFormat textureFormat) {
|
||||
DAWN_TRY(ValidateTextureFormat(textureFormat));
|
||||
const Format* format = nullptr;
|
||||
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(textureFormat));
|
||||
@ -36,7 +36,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
MaybeError ValidateDepthStencilAttachmentFormat(const DeviceBase* device,
|
||||
dawn::TextureFormat textureFormat) {
|
||||
wgpu::TextureFormat textureFormat) {
|
||||
DAWN_TRY(ValidateTextureFormat(textureFormat));
|
||||
const Format* format = nullptr;
|
||||
DAWN_TRY_ASSIGN(format, device->GetInternalFormat(textureFormat));
|
||||
@ -60,7 +60,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ namespace dawn_native {
|
||||
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));
|
||||
}
|
||||
|
||||
|
@ -177,100 +177,100 @@ namespace dawn_native {
|
||||
} // anonymous namespace
|
||||
|
||||
// Helper functions
|
||||
size_t IndexFormatSize(dawn::IndexFormat format) {
|
||||
size_t IndexFormatSize(wgpu::IndexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::IndexFormat::Uint16:
|
||||
case wgpu::IndexFormat::Uint16:
|
||||
return sizeof(uint16_t);
|
||||
case dawn::IndexFormat::Uint32:
|
||||
case wgpu::IndexFormat::Uint32:
|
||||
return sizeof(uint32_t);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t VertexFormatNumComponents(dawn::VertexFormat format) {
|
||||
uint32_t VertexFormatNumComponents(wgpu::VertexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::VertexFormat::UChar4:
|
||||
case dawn::VertexFormat::Char4:
|
||||
case dawn::VertexFormat::UChar4Norm:
|
||||
case dawn::VertexFormat::Char4Norm:
|
||||
case dawn::VertexFormat::UShort4:
|
||||
case dawn::VertexFormat::Short4:
|
||||
case dawn::VertexFormat::UShort4Norm:
|
||||
case dawn::VertexFormat::Short4Norm:
|
||||
case dawn::VertexFormat::Half4:
|
||||
case dawn::VertexFormat::Float4:
|
||||
case dawn::VertexFormat::UInt4:
|
||||
case dawn::VertexFormat::Int4:
|
||||
case wgpu::VertexFormat::UChar4:
|
||||
case wgpu::VertexFormat::Char4:
|
||||
case wgpu::VertexFormat::UChar4Norm:
|
||||
case wgpu::VertexFormat::Char4Norm:
|
||||
case wgpu::VertexFormat::UShort4:
|
||||
case wgpu::VertexFormat::Short4:
|
||||
case wgpu::VertexFormat::UShort4Norm:
|
||||
case wgpu::VertexFormat::Short4Norm:
|
||||
case wgpu::VertexFormat::Half4:
|
||||
case wgpu::VertexFormat::Float4:
|
||||
case wgpu::VertexFormat::UInt4:
|
||||
case wgpu::VertexFormat::Int4:
|
||||
return 4;
|
||||
case dawn::VertexFormat::Float3:
|
||||
case dawn::VertexFormat::UInt3:
|
||||
case dawn::VertexFormat::Int3:
|
||||
case wgpu::VertexFormat::Float3:
|
||||
case wgpu::VertexFormat::UInt3:
|
||||
case wgpu::VertexFormat::Int3:
|
||||
return 3;
|
||||
case dawn::VertexFormat::UChar2:
|
||||
case dawn::VertexFormat::Char2:
|
||||
case dawn::VertexFormat::UChar2Norm:
|
||||
case dawn::VertexFormat::Char2Norm:
|
||||
case dawn::VertexFormat::UShort2:
|
||||
case dawn::VertexFormat::Short2:
|
||||
case dawn::VertexFormat::UShort2Norm:
|
||||
case dawn::VertexFormat::Short2Norm:
|
||||
case dawn::VertexFormat::Half2:
|
||||
case dawn::VertexFormat::Float2:
|
||||
case dawn::VertexFormat::UInt2:
|
||||
case dawn::VertexFormat::Int2:
|
||||
case wgpu::VertexFormat::UChar2:
|
||||
case wgpu::VertexFormat::Char2:
|
||||
case wgpu::VertexFormat::UChar2Norm:
|
||||
case wgpu::VertexFormat::Char2Norm:
|
||||
case wgpu::VertexFormat::UShort2:
|
||||
case wgpu::VertexFormat::Short2:
|
||||
case wgpu::VertexFormat::UShort2Norm:
|
||||
case wgpu::VertexFormat::Short2Norm:
|
||||
case wgpu::VertexFormat::Half2:
|
||||
case wgpu::VertexFormat::Float2:
|
||||
case wgpu::VertexFormat::UInt2:
|
||||
case wgpu::VertexFormat::Int2:
|
||||
return 2;
|
||||
case dawn::VertexFormat::Float:
|
||||
case dawn::VertexFormat::UInt:
|
||||
case dawn::VertexFormat::Int:
|
||||
case wgpu::VertexFormat::Float:
|
||||
case wgpu::VertexFormat::UInt:
|
||||
case wgpu::VertexFormat::Int:
|
||||
return 1;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
size_t VertexFormatComponentSize(dawn::VertexFormat format) {
|
||||
size_t VertexFormatComponentSize(wgpu::VertexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::VertexFormat::UChar2:
|
||||
case dawn::VertexFormat::UChar4:
|
||||
case dawn::VertexFormat::Char2:
|
||||
case dawn::VertexFormat::Char4:
|
||||
case dawn::VertexFormat::UChar2Norm:
|
||||
case dawn::VertexFormat::UChar4Norm:
|
||||
case dawn::VertexFormat::Char2Norm:
|
||||
case dawn::VertexFormat::Char4Norm:
|
||||
case wgpu::VertexFormat::UChar2:
|
||||
case wgpu::VertexFormat::UChar4:
|
||||
case wgpu::VertexFormat::Char2:
|
||||
case wgpu::VertexFormat::Char4:
|
||||
case wgpu::VertexFormat::UChar2Norm:
|
||||
case wgpu::VertexFormat::UChar4Norm:
|
||||
case wgpu::VertexFormat::Char2Norm:
|
||||
case wgpu::VertexFormat::Char4Norm:
|
||||
return sizeof(char);
|
||||
case dawn::VertexFormat::UShort2:
|
||||
case dawn::VertexFormat::UShort4:
|
||||
case dawn::VertexFormat::UShort2Norm:
|
||||
case dawn::VertexFormat::UShort4Norm:
|
||||
case dawn::VertexFormat::Short2:
|
||||
case dawn::VertexFormat::Short4:
|
||||
case dawn::VertexFormat::Short2Norm:
|
||||
case dawn::VertexFormat::Short4Norm:
|
||||
case dawn::VertexFormat::Half2:
|
||||
case dawn::VertexFormat::Half4:
|
||||
case wgpu::VertexFormat::UShort2:
|
||||
case wgpu::VertexFormat::UShort4:
|
||||
case wgpu::VertexFormat::UShort2Norm:
|
||||
case wgpu::VertexFormat::UShort4Norm:
|
||||
case wgpu::VertexFormat::Short2:
|
||||
case wgpu::VertexFormat::Short4:
|
||||
case wgpu::VertexFormat::Short2Norm:
|
||||
case wgpu::VertexFormat::Short4Norm:
|
||||
case wgpu::VertexFormat::Half2:
|
||||
case wgpu::VertexFormat::Half4:
|
||||
return sizeof(uint16_t);
|
||||
case dawn::VertexFormat::Float:
|
||||
case dawn::VertexFormat::Float2:
|
||||
case dawn::VertexFormat::Float3:
|
||||
case dawn::VertexFormat::Float4:
|
||||
case wgpu::VertexFormat::Float:
|
||||
case wgpu::VertexFormat::Float2:
|
||||
case wgpu::VertexFormat::Float3:
|
||||
case wgpu::VertexFormat::Float4:
|
||||
return sizeof(float);
|
||||
case dawn::VertexFormat::UInt:
|
||||
case dawn::VertexFormat::UInt2:
|
||||
case dawn::VertexFormat::UInt3:
|
||||
case dawn::VertexFormat::UInt4:
|
||||
case dawn::VertexFormat::Int:
|
||||
case dawn::VertexFormat::Int2:
|
||||
case dawn::VertexFormat::Int3:
|
||||
case dawn::VertexFormat::Int4:
|
||||
case wgpu::VertexFormat::UInt:
|
||||
case wgpu::VertexFormat::UInt2:
|
||||
case wgpu::VertexFormat::UInt3:
|
||||
case wgpu::VertexFormat::UInt4:
|
||||
case wgpu::VertexFormat::Int:
|
||||
case wgpu::VertexFormat::Int2:
|
||||
case wgpu::VertexFormat::Int3:
|
||||
case wgpu::VertexFormat::Int4:
|
||||
return sizeof(int32_t);
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
size_t VertexFormatSize(dawn::VertexFormat format) {
|
||||
size_t VertexFormatSize(wgpu::VertexFormat format) {
|
||||
return VertexFormatNumComponents(format) * VertexFormatComponentSize(format);
|
||||
}
|
||||
|
||||
@ -344,23 +344,23 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState) {
|
||||
return mDepthStencilState->stencilBack.compare != dawn::CompareFunction::Always ||
|
||||
mDepthStencilState->stencilBack.failOp != dawn::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilBack.depthFailOp != dawn::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilBack.passOp != dawn::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilFront.compare != dawn::CompareFunction::Always ||
|
||||
mDepthStencilState->stencilFront.failOp != dawn::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilFront.depthFailOp != dawn::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilFront.passOp != dawn::StencilOperation::Keep;
|
||||
return mDepthStencilState->stencilBack.compare != wgpu::CompareFunction::Always ||
|
||||
mDepthStencilState->stencilBack.failOp != wgpu::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilBack.depthFailOp != wgpu::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilBack.passOp != wgpu::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilFront.compare != wgpu::CompareFunction::Always ||
|
||||
mDepthStencilState->stencilFront.failOp != wgpu::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilFront.depthFailOp != wgpu::StencilOperation::Keep ||
|
||||
mDepthStencilState->stencilFront.passOp != wgpu::StencilOperation::Keep;
|
||||
}
|
||||
|
||||
bool BlendEnabled(const ColorStateDescriptor* mColorState) {
|
||||
return mColorState->alphaBlend.operation != dawn::BlendOperation::Add ||
|
||||
mColorState->alphaBlend.srcFactor != dawn::BlendFactor::One ||
|
||||
mColorState->alphaBlend.dstFactor != dawn::BlendFactor::Zero ||
|
||||
mColorState->colorBlend.operation != dawn::BlendOperation::Add ||
|
||||
mColorState->colorBlend.srcFactor != dawn::BlendFactor::One ||
|
||||
mColorState->colorBlend.dstFactor != dawn::BlendFactor::Zero;
|
||||
return mColorState->alphaBlend.operation != wgpu::BlendOperation::Add ||
|
||||
mColorState->alphaBlend.srcFactor != wgpu::BlendFactor::One ||
|
||||
mColorState->alphaBlend.dstFactor != wgpu::BlendFactor::Zero ||
|
||||
mColorState->colorBlend.operation != wgpu::BlendOperation::Add ||
|
||||
mColorState->colorBlend.srcFactor != wgpu::BlendFactor::One ||
|
||||
mColorState->colorBlend.dstFactor != wgpu::BlendFactor::Zero;
|
||||
}
|
||||
|
||||
// RenderPipelineBase
|
||||
@ -370,7 +370,7 @@ namespace dawn_native {
|
||||
bool blueprint)
|
||||
: PipelineBase(device,
|
||||
descriptor->layout,
|
||||
dawn::ShaderStage::Vertex | dawn::ShaderStage::Fragment),
|
||||
wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Fragment),
|
||||
mAttachmentState(device->GetOrCreateAttachmentState(descriptor)),
|
||||
mPrimitiveTopology(descriptor->primitiveTopology),
|
||||
mSampleMask(descriptor->sampleMask),
|
||||
@ -419,16 +419,16 @@ namespace dawn_native {
|
||||
// The values indicate that depth and stencil test are disabled when backends
|
||||
// set their own depth stencil states/descriptors according to the values in
|
||||
// mDepthStencilState.
|
||||
mDepthStencilState.depthCompare = dawn::CompareFunction::Always;
|
||||
mDepthStencilState.depthCompare = wgpu::CompareFunction::Always;
|
||||
mDepthStencilState.depthWriteEnabled = false;
|
||||
mDepthStencilState.stencilBack.compare = dawn::CompareFunction::Always;
|
||||
mDepthStencilState.stencilBack.failOp = dawn::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilBack.depthFailOp = dawn::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilBack.passOp = dawn::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilFront.compare = dawn::CompareFunction::Always;
|
||||
mDepthStencilState.stencilFront.failOp = dawn::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilFront.depthFailOp = dawn::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilFront.passOp = dawn::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilBack.compare = wgpu::CompareFunction::Always;
|
||||
mDepthStencilState.stencilBack.failOp = wgpu::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilBack.depthFailOp = wgpu::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilBack.passOp = wgpu::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilFront.compare = wgpu::CompareFunction::Always;
|
||||
mDepthStencilState.stencilFront.failOp = wgpu::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilFront.depthFailOp = wgpu::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilFront.passOp = wgpu::StencilOperation::Keep;
|
||||
mDepthStencilState.stencilReadMask = 0xff;
|
||||
mDepthStencilState.stencilWriteMask = 0xff;
|
||||
}
|
||||
@ -496,17 +496,17 @@ namespace dawn_native {
|
||||
return &mDepthStencilState;
|
||||
}
|
||||
|
||||
dawn::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const {
|
||||
wgpu::PrimitiveTopology RenderPipelineBase::GetPrimitiveTopology() const {
|
||||
ASSERT(!IsError());
|
||||
return mPrimitiveTopology;
|
||||
}
|
||||
|
||||
dawn::CullMode RenderPipelineBase::GetCullMode() const {
|
||||
wgpu::CullMode RenderPipelineBase::GetCullMode() const {
|
||||
ASSERT(!IsError());
|
||||
return mRasterizationState.cullMode;
|
||||
}
|
||||
|
||||
dawn::FrontFace RenderPipelineBase::GetFrontFace() const {
|
||||
wgpu::FrontFace RenderPipelineBase::GetFrontFace() const {
|
||||
ASSERT(!IsError());
|
||||
return mRasterizationState.frontFace;
|
||||
}
|
||||
@ -521,12 +521,12 @@ namespace dawn_native {
|
||||
return mAttachmentState->HasDepthStencilAttachment();
|
||||
}
|
||||
|
||||
dawn::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(uint32_t attachment) const {
|
||||
wgpu::TextureFormat RenderPipelineBase::GetColorAttachmentFormat(uint32_t attachment) const {
|
||||
ASSERT(!IsError());
|
||||
return mColorStates[attachment].format;
|
||||
}
|
||||
|
||||
dawn::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const {
|
||||
wgpu::TextureFormat RenderPipelineBase::GetDepthStencilFormat() const {
|
||||
ASSERT(!IsError());
|
||||
ASSERT(mAttachmentState->HasDepthStencilAttachment());
|
||||
return mDepthStencilState.format;
|
||||
|
@ -32,10 +32,10 @@ namespace dawn_native {
|
||||
|
||||
MaybeError ValidateRenderPipelineDescriptor(const DeviceBase* device,
|
||||
const RenderPipelineDescriptor* descriptor);
|
||||
size_t IndexFormatSize(dawn::IndexFormat format);
|
||||
uint32_t VertexFormatNumComponents(dawn::VertexFormat format);
|
||||
size_t VertexFormatComponentSize(dawn::VertexFormat format);
|
||||
size_t VertexFormatSize(dawn::VertexFormat format);
|
||||
size_t IndexFormatSize(wgpu::IndexFormat format);
|
||||
uint32_t VertexFormatNumComponents(wgpu::VertexFormat format);
|
||||
size_t VertexFormatComponentSize(wgpu::VertexFormat format);
|
||||
size_t VertexFormatSize(wgpu::VertexFormat format);
|
||||
|
||||
bool StencilTestEnabled(const DepthStencilStateDescriptor* mDepthStencilState);
|
||||
bool BlendEnabled(const ColorStateDescriptor* mColorState);
|
||||
@ -44,12 +44,12 @@ namespace dawn_native {
|
||||
uint32_t shaderLocation;
|
||||
uint32_t inputSlot;
|
||||
uint64_t offset;
|
||||
dawn::VertexFormat format;
|
||||
wgpu::VertexFormat format;
|
||||
};
|
||||
|
||||
struct VertexBufferInfo {
|
||||
uint64_t stride;
|
||||
dawn::InputStepMode stepMode;
|
||||
wgpu::InputStepMode stepMode;
|
||||
};
|
||||
|
||||
class RenderPipelineBase : public PipelineBase {
|
||||
@ -69,14 +69,14 @@ namespace dawn_native {
|
||||
|
||||
const ColorStateDescriptor* GetColorStateDescriptor(uint32_t attachmentSlot) const;
|
||||
const DepthStencilStateDescriptor* GetDepthStencilStateDescriptor() const;
|
||||
dawn::PrimitiveTopology GetPrimitiveTopology() const;
|
||||
dawn::CullMode GetCullMode() const;
|
||||
dawn::FrontFace GetFrontFace() const;
|
||||
wgpu::PrimitiveTopology GetPrimitiveTopology() const;
|
||||
wgpu::CullMode GetCullMode() const;
|
||||
wgpu::FrontFace GetFrontFace() const;
|
||||
|
||||
std::bitset<kMaxColorAttachments> GetColorAttachmentsMask() const;
|
||||
bool HasDepthStencilAttachment() const;
|
||||
dawn::TextureFormat GetColorAttachmentFormat(uint32_t attachment) const;
|
||||
dawn::TextureFormat GetDepthStencilFormat() const;
|
||||
wgpu::TextureFormat GetColorAttachmentFormat(uint32_t attachment) const;
|
||||
wgpu::TextureFormat GetDepthStencilFormat() const;
|
||||
uint32_t GetSampleCount() const;
|
||||
|
||||
const AttachmentState* GetAttachmentState() const;
|
||||
@ -108,7 +108,7 @@ namespace dawn_native {
|
||||
std::array<ColorStateDescriptor, kMaxColorAttachments> mColorStates;
|
||||
|
||||
// Other state
|
||||
dawn::PrimitiveTopology mPrimitiveTopology;
|
||||
wgpu::PrimitiveTopology mPrimitiveTopology;
|
||||
RasterizationStateDescriptor mRasterizationState;
|
||||
uint32_t mSampleMask;
|
||||
bool mAlphaToCoverageEnabled;
|
||||
|
@ -47,15 +47,15 @@ namespace dawn_native {
|
||||
SamplerBase(DeviceBase* device, ObjectBase::ErrorTag tag);
|
||||
|
||||
// TODO(cwallez@chromium.org): Store a crypto hash of the items instead?
|
||||
dawn::AddressMode mAddressModeU;
|
||||
dawn::AddressMode mAddressModeV;
|
||||
dawn::AddressMode mAddressModeW;
|
||||
dawn::FilterMode mMagFilter;
|
||||
dawn::FilterMode mMinFilter;
|
||||
dawn::FilterMode mMipmapFilter;
|
||||
wgpu::AddressMode mAddressModeU;
|
||||
wgpu::AddressMode mAddressModeV;
|
||||
wgpu::AddressMode mAddressModeW;
|
||||
wgpu::FilterMode mMagFilter;
|
||||
wgpu::FilterMode mMinFilter;
|
||||
wgpu::FilterMode mMipmapFilter;
|
||||
float mLodMinClamp;
|
||||
float mLodMaxClamp;
|
||||
dawn::CompareFunction mCompareFunction;
|
||||
wgpu::CompareFunction mCompareFunction;
|
||||
bool mIsBlueprint = false;
|
||||
};
|
||||
|
||||
|
@ -132,7 +132,7 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
if (resources.push_constant_buffers.size() > 0) {
|
||||
GetDevice()->HandleError(dawn::ErrorType::Validation,
|
||||
GetDevice()->HandleError(wgpu::ErrorType::Validation,
|
||||
"Push constants aren't supported.");
|
||||
}
|
||||
|
||||
@ -140,7 +140,7 @@ namespace dawn_native {
|
||||
auto ExtractResourcesBinding = [this](const spirv_cross::SmallVector<spirv_cross::Resource>&
|
||||
resources,
|
||||
const spirv_cross::Compiler& compiler,
|
||||
dawn::BindingType bindingType) {
|
||||
wgpu::BindingType bindingType) {
|
||||
for (const auto& resource : resources) {
|
||||
ASSERT(compiler.get_decoration_bitset(resource.id).get(spv::DecorationBinding));
|
||||
ASSERT(
|
||||
@ -150,7 +150,7 @@ namespace dawn_native {
|
||||
uint32_t set = compiler.get_decoration(resource.id, spv::DecorationDescriptorSet);
|
||||
|
||||
if (binding >= kMaxBindingsPerGroup || set >= kMaxBindGroups) {
|
||||
GetDevice()->HandleError(dawn::ErrorType::Validation,
|
||||
GetDevice()->HandleError(wgpu::ErrorType::Validation,
|
||||
"Binding over limits in the SPIRV");
|
||||
continue;
|
||||
}
|
||||
@ -164,12 +164,12 @@ namespace dawn_native {
|
||||
};
|
||||
|
||||
ExtractResourcesBinding(resources.uniform_buffers, compiler,
|
||||
dawn::BindingType::UniformBuffer);
|
||||
wgpu::BindingType::UniformBuffer);
|
||||
ExtractResourcesBinding(resources.separate_images, compiler,
|
||||
dawn::BindingType::SampledTexture);
|
||||
ExtractResourcesBinding(resources.separate_samplers, compiler, dawn::BindingType::Sampler);
|
||||
wgpu::BindingType::SampledTexture);
|
||||
ExtractResourcesBinding(resources.separate_samplers, compiler, wgpu::BindingType::Sampler);
|
||||
ExtractResourcesBinding(resources.storage_buffers, compiler,
|
||||
dawn::BindingType::StorageBuffer);
|
||||
wgpu::BindingType::StorageBuffer);
|
||||
|
||||
// Extract the vertex attributes
|
||||
if (mExecutionModel == SingleShaderStage::Vertex) {
|
||||
@ -178,7 +178,7 @@ namespace dawn_native {
|
||||
uint32_t location = compiler.get_decoration(attrib.id, spv::DecorationLocation);
|
||||
|
||||
if (location >= kMaxVertexAttributes) {
|
||||
device->HandleError(dawn::ErrorType::Validation,
|
||||
device->HandleError(wgpu::ErrorType::Validation,
|
||||
"Attribute location over limits in the SPIRV");
|
||||
return;
|
||||
}
|
||||
@ -190,7 +190,7 @@ namespace dawn_native {
|
||||
// all the location 0, causing a compile error.
|
||||
for (const auto& attrib : resources.stage_outputs) {
|
||||
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");
|
||||
return;
|
||||
}
|
||||
@ -202,7 +202,7 @@ namespace dawn_native {
|
||||
// all the location 0, causing a compile error.
|
||||
for (const auto& attrib : resources.stage_inputs) {
|
||||
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");
|
||||
return;
|
||||
}
|
||||
@ -214,7 +214,7 @@ namespace dawn_native {
|
||||
uint32_t location =
|
||||
compiler.get_decoration(fragmentOutput.id, spv::DecorationLocation);
|
||||
if (location >= kMaxColorAttachments) {
|
||||
device->HandleError(dawn::ErrorType::Validation,
|
||||
device->HandleError(wgpu::ErrorType::Validation,
|
||||
"Fragment output location over limits in the SPIRV");
|
||||
return;
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ namespace dawn_native {
|
||||
// The SPIRV ID of the resource.
|
||||
uint32_t id;
|
||||
uint32_t base_type_id;
|
||||
dawn::BindingType type;
|
||||
wgpu::BindingType type;
|
||||
bool used = false;
|
||||
};
|
||||
using ModuleBindingInfo =
|
||||
|
@ -80,8 +80,8 @@ namespace dawn_native {
|
||||
return new ErrorSwapChain(device);
|
||||
}
|
||||
|
||||
void SwapChainBase::Configure(dawn::TextureFormat format,
|
||||
dawn::TextureUsage allowedUsage,
|
||||
void SwapChainBase::Configure(wgpu::TextureFormat format,
|
||||
wgpu::TextureUsage allowedUsage,
|
||||
uint32_t width,
|
||||
uint32_t height) {
|
||||
if (GetDevice()->ConsumedError(ValidateConfigure(format, allowedUsage, width, height))) {
|
||||
@ -89,7 +89,7 @@ namespace dawn_native {
|
||||
}
|
||||
ASSERT(!IsError());
|
||||
|
||||
allowedUsage |= dawn::TextureUsage::Present;
|
||||
allowedUsage |= wgpu::TextureUsage::Present;
|
||||
|
||||
mFormat = format;
|
||||
mAllowedUsage = allowedUsage;
|
||||
@ -106,7 +106,7 @@ namespace dawn_native {
|
||||
ASSERT(!IsError());
|
||||
|
||||
TextureDescriptor descriptor;
|
||||
descriptor.dimension = dawn::TextureDimension::e2D;
|
||||
descriptor.dimension = wgpu::TextureDimension::e2D;
|
||||
descriptor.size.width = mWidth;
|
||||
descriptor.size.height = mHeight;
|
||||
descriptor.size.depth = 1;
|
||||
@ -138,8 +138,8 @@ namespace dawn_native {
|
||||
return mImplementation;
|
||||
}
|
||||
|
||||
MaybeError SwapChainBase::ValidateConfigure(dawn::TextureFormat format,
|
||||
dawn::TextureUsage allowedUsage,
|
||||
MaybeError SwapChainBase::ValidateConfigure(wgpu::TextureFormat format,
|
||||
wgpu::TextureUsage allowedUsage,
|
||||
uint32_t width,
|
||||
uint32_t height) const {
|
||||
DAWN_TRY(GetDevice()->ValidateObject(this));
|
||||
|
@ -35,8 +35,8 @@ namespace dawn_native {
|
||||
static SwapChainBase* MakeError(DeviceBase* device);
|
||||
|
||||
// Dawn API
|
||||
void Configure(dawn::TextureFormat format,
|
||||
dawn::TextureUsage allowedUsage,
|
||||
void Configure(wgpu::TextureFormat format,
|
||||
wgpu::TextureUsage allowedUsage,
|
||||
uint32_t width,
|
||||
uint32_t height);
|
||||
TextureBase* GetNextTexture();
|
||||
@ -50,16 +50,16 @@ namespace dawn_native {
|
||||
virtual MaybeError OnBeforePresent(TextureBase* texture) = 0;
|
||||
|
||||
private:
|
||||
MaybeError ValidateConfigure(dawn::TextureFormat format,
|
||||
dawn::TextureUsage allowedUsage,
|
||||
MaybeError ValidateConfigure(wgpu::TextureFormat format,
|
||||
wgpu::TextureUsage allowedUsage,
|
||||
uint32_t width,
|
||||
uint32_t height) const;
|
||||
MaybeError ValidateGetNextTexture() const;
|
||||
MaybeError ValidatePresent(TextureBase* texture) const;
|
||||
|
||||
DawnSwapChainImplementation mImplementation = {};
|
||||
dawn::TextureFormat mFormat = {};
|
||||
dawn::TextureUsage mAllowedUsage;
|
||||
wgpu::TextureFormat mFormat = {};
|
||||
wgpu::TextureUsage mAllowedUsage;
|
||||
uint32_t mWidth = 0;
|
||||
uint32_t mHeight = 0;
|
||||
TextureBase* mLastNextTexture = nullptr;
|
||||
|
@ -37,14 +37,14 @@ namespace dawn_native {
|
||||
|
||||
// TODO(jiawei.shao@intel.com): support validation on all texture view dimensions
|
||||
bool IsTextureViewDimensionCompatibleWithTextureDimension(
|
||||
dawn::TextureViewDimension textureViewDimension,
|
||||
dawn::TextureDimension textureDimension) {
|
||||
wgpu::TextureViewDimension textureViewDimension,
|
||||
wgpu::TextureDimension textureDimension) {
|
||||
switch (textureViewDimension) {
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
return textureDimension == dawn::TextureDimension::e2D;
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return textureDimension == wgpu::TextureDimension::e2D;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
return false;
|
||||
@ -53,16 +53,16 @@ namespace dawn_native {
|
||||
|
||||
// TODO(jiawei.shao@intel.com): support validation on all texture view dimensions
|
||||
bool IsArrayLayerValidForTextureViewDimension(
|
||||
dawn::TextureViewDimension textureViewDimension,
|
||||
wgpu::TextureViewDimension textureViewDimension,
|
||||
uint32_t textureViewArrayLayer) {
|
||||
switch (textureViewDimension) {
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
return textureViewArrayLayer == 1u;
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
return true;
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
return textureViewArrayLayer == 6u;
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return textureViewArrayLayer % 6 == 0;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -71,14 +71,14 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
bool IsTextureSizeValidForTextureViewDimension(
|
||||
dawn::TextureViewDimension textureViewDimension,
|
||||
wgpu::TextureViewDimension textureViewDimension,
|
||||
const Extent3D& textureSize) {
|
||||
switch (textureViewDimension) {
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return textureSize.width == textureSize.height;
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
return true;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -159,21 +159,21 @@ namespace dawn_native {
|
||||
MaybeError ValidateTextureUsage(const TextureDescriptor* descriptor, const Format* format) {
|
||||
DAWN_TRY(dawn_native::ValidateTextureUsage(descriptor->usage));
|
||||
|
||||
constexpr dawn::TextureUsage kValidCompressedUsages = dawn::TextureUsage::Sampled |
|
||||
dawn::TextureUsage::CopySrc |
|
||||
dawn::TextureUsage::CopyDst;
|
||||
constexpr wgpu::TextureUsage kValidCompressedUsages = wgpu::TextureUsage::Sampled |
|
||||
wgpu::TextureUsage::CopySrc |
|
||||
wgpu::TextureUsage::CopyDst;
|
||||
if (format->isCompressed && (descriptor->usage & (~kValidCompressedUsages))) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"Compressed texture format is incompatible with the texture usage");
|
||||
}
|
||||
|
||||
if (!format->isRenderable &&
|
||||
(descriptor->usage & dawn::TextureUsage::OutputAttachment)) {
|
||||
(descriptor->usage & wgpu::TextureUsage::OutputAttachment)) {
|
||||
return DAWN_VALIDATION_ERROR(
|
||||
"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)");
|
||||
}
|
||||
|
||||
@ -205,7 +205,7 @@ namespace dawn_native {
|
||||
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)");
|
||||
}
|
||||
|
||||
@ -228,15 +228,15 @@ namespace dawn_native {
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateTextureViewDimension(descriptor->dimension));
|
||||
if (descriptor->dimension == dawn::TextureViewDimension::e1D ||
|
||||
descriptor->dimension == dawn::TextureViewDimension::e3D) {
|
||||
if (descriptor->dimension == wgpu::TextureViewDimension::e1D ||
|
||||
descriptor->dimension == wgpu::TextureViewDimension::e3D) {
|
||||
return DAWN_VALIDATION_ERROR("Texture view dimension must be 2D compatible.");
|
||||
}
|
||||
|
||||
DAWN_TRY(ValidateTextureFormat(descriptor->format));
|
||||
|
||||
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'");
|
||||
}
|
||||
|
||||
@ -273,22 +273,22 @@ namespace dawn_native {
|
||||
|
||||
// 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.
|
||||
if (desc.dimension == dawn::TextureViewDimension::Undefined) {
|
||||
if (desc.dimension == wgpu::TextureViewDimension::Undefined) {
|
||||
switch (texture->GetDimension()) {
|
||||
case dawn::TextureDimension::e1D:
|
||||
desc.dimension = dawn::TextureViewDimension::e1D;
|
||||
case wgpu::TextureDimension::e1D:
|
||||
desc.dimension = wgpu::TextureViewDimension::e1D;
|
||||
break;
|
||||
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
if (texture->GetArrayLayers() > 1u && desc.arrayLayerCount == 0) {
|
||||
desc.dimension = dawn::TextureViewDimension::e2DArray;
|
||||
desc.dimension = wgpu::TextureViewDimension::e2DArray;
|
||||
} else {
|
||||
desc.dimension = dawn::TextureViewDimension::e2D;
|
||||
desc.dimension = wgpu::TextureViewDimension::e2D;
|
||||
}
|
||||
break;
|
||||
|
||||
case dawn::TextureDimension::e3D:
|
||||
desc.dimension = dawn::TextureViewDimension::e3D;
|
||||
case wgpu::TextureDimension::e3D:
|
||||
desc.dimension = wgpu::TextureViewDimension::e3D;
|
||||
break;
|
||||
|
||||
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;
|
||||
}
|
||||
if (desc.arrayLayerCount == 0) {
|
||||
@ -349,7 +349,7 @@ namespace dawn_native {
|
||||
return new TextureBase(device, ObjectBase::kError);
|
||||
}
|
||||
|
||||
dawn::TextureDimension TextureBase::GetDimension() const {
|
||||
wgpu::TextureDimension TextureBase::GetDimension() const {
|
||||
ASSERT(!IsError());
|
||||
return mDimension;
|
||||
}
|
||||
@ -375,7 +375,7 @@ namespace dawn_native {
|
||||
ASSERT(!IsError());
|
||||
return mSampleCount;
|
||||
}
|
||||
dawn::TextureUsage TextureBase::GetUsage() const {
|
||||
wgpu::TextureUsage TextureBase::GetUsage() const {
|
||||
ASSERT(!IsError());
|
||||
return mUsage;
|
||||
}
|
||||
@ -527,7 +527,7 @@ namespace dawn_native {
|
||||
return mFormat;
|
||||
}
|
||||
|
||||
dawn::TextureViewDimension TextureViewBase::GetDimension() const {
|
||||
wgpu::TextureViewDimension TextureViewBase::GetDimension() const {
|
||||
ASSERT(!IsError());
|
||||
return mDimension;
|
||||
}
|
||||
|
@ -34,12 +34,12 @@ namespace dawn_native {
|
||||
|
||||
bool IsValidSampleCount(uint32_t sampleCount);
|
||||
|
||||
static constexpr dawn::TextureUsage kReadOnlyTextureUsages =
|
||||
dawn::TextureUsage::CopySrc | dawn::TextureUsage::Sampled | dawn::TextureUsage::Present;
|
||||
static constexpr wgpu::TextureUsage kReadOnlyTextureUsages =
|
||||
wgpu::TextureUsage::CopySrc | wgpu::TextureUsage::Sampled | wgpu::TextureUsage::Present;
|
||||
|
||||
static constexpr dawn::TextureUsage kWritableTextureUsages =
|
||||
dawn::TextureUsage::CopyDst | dawn::TextureUsage::Storage |
|
||||
dawn::TextureUsage::OutputAttachment;
|
||||
static constexpr wgpu::TextureUsage kWritableTextureUsages =
|
||||
wgpu::TextureUsage::CopyDst | wgpu::TextureUsage::Storage |
|
||||
wgpu::TextureUsage::OutputAttachment;
|
||||
|
||||
class TextureBase : public ObjectBase {
|
||||
public:
|
||||
@ -49,13 +49,13 @@ namespace dawn_native {
|
||||
|
||||
static TextureBase* MakeError(DeviceBase* device);
|
||||
|
||||
dawn::TextureDimension GetDimension() const;
|
||||
wgpu::TextureDimension GetDimension() const;
|
||||
const Format& GetFormat() const;
|
||||
const Extent3D& GetSize() const;
|
||||
uint32_t GetArrayLayers() const;
|
||||
uint32_t GetNumMipLevels() const;
|
||||
uint32_t GetSampleCount() const;
|
||||
dawn::TextureUsage GetUsage() const;
|
||||
wgpu::TextureUsage GetUsage() const;
|
||||
TextureState GetTextureState() const;
|
||||
uint32_t GetSubresourceIndex(uint32_t mipLevel, uint32_t arraySlice) const;
|
||||
bool IsSubresourceContentInitialized(uint32_t baseMipLevel,
|
||||
@ -92,14 +92,14 @@ namespace dawn_native {
|
||||
virtual void DestroyImpl();
|
||||
|
||||
MaybeError ValidateDestroy() const;
|
||||
dawn::TextureDimension mDimension;
|
||||
wgpu::TextureDimension mDimension;
|
||||
// TODO(cwallez@chromium.org): This should be deduplicated in the Device
|
||||
const Format& mFormat;
|
||||
Extent3D mSize;
|
||||
uint32_t mArrayLayerCount;
|
||||
uint32_t mMipLevelCount;
|
||||
uint32_t mSampleCount;
|
||||
dawn::TextureUsage mUsage = dawn::TextureUsage::None;
|
||||
wgpu::TextureUsage mUsage = wgpu::TextureUsage::None;
|
||||
TextureState mState;
|
||||
|
||||
// TODO(natlee@microsoft.com): Use a more optimized data structure to save space
|
||||
@ -116,7 +116,7 @@ namespace dawn_native {
|
||||
TextureBase* GetTexture();
|
||||
|
||||
const Format& GetFormat() const;
|
||||
dawn::TextureViewDimension GetDimension() const;
|
||||
wgpu::TextureViewDimension GetDimension() const;
|
||||
uint32_t GetBaseMipLevel() const;
|
||||
uint32_t GetLevelCount() const;
|
||||
uint32_t GetBaseArrayLayer() const;
|
||||
@ -129,7 +129,7 @@ namespace dawn_native {
|
||||
|
||||
// TODO(cwallez@chromium.org): This should be deduplicated in the Device
|
||||
const Format& mFormat;
|
||||
dawn::TextureViewDimension mDimension;
|
||||
wgpu::TextureViewDimension mDimension;
|
||||
uint32_t mBaseMipLevel;
|
||||
uint32_t mMipLevelCount;
|
||||
uint32_t mBaseArrayLayer;
|
||||
|
@ -49,7 +49,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
switch (layout.types[bindingIndex]) {
|
||||
case dawn::BindingType::UniformBuffer: {
|
||||
case wgpu::BindingType::UniformBuffer: {
|
||||
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
||||
|
||||
D3D12_CONSTANT_BUFFER_VIEW_DESC desc;
|
||||
@ -62,7 +62,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
&desc, cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
||||
bindingOffsets[bindingIndex]));
|
||||
} break;
|
||||
case dawn::BindingType::StorageBuffer: {
|
||||
case wgpu::BindingType::StorageBuffer: {
|
||||
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
||||
|
||||
// Since SPIRV-Cross outputs HLSL shaders with RWByteAddressBuffer,
|
||||
@ -86,7 +86,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
||||
bindingOffsets[bindingIndex]));
|
||||
} break;
|
||||
case dawn::BindingType::SampledTexture: {
|
||||
case wgpu::BindingType::SampledTexture: {
|
||||
auto* view = ToBackend(GetBindingAsTextureView(bindingIndex));
|
||||
auto& srv = view->GetSRVDescriptor();
|
||||
d3d12Device->CreateShaderResourceView(
|
||||
@ -94,7 +94,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
cbvUavSrvHeapStart.GetCPUHandle(*cbvUavSrvHeapOffset +
|
||||
bindingOffsets[bindingIndex]));
|
||||
} break;
|
||||
case dawn::BindingType::Sampler: {
|
||||
case wgpu::BindingType::Sampler: {
|
||||
auto* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
|
||||
auto& samplerDesc = sampler->GetSamplerDescriptor();
|
||||
d3d12Device->CreateSampler(
|
||||
@ -102,8 +102,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
bindingOffsets[bindingIndex]));
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
|
@ -32,21 +32,21 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
switch (groupInfo.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
mBindingOffsets[binding] = mDescriptorCounts[CBV]++;
|
||||
break;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
mBindingOffsets[binding] = mDescriptorCounts[UAV]++;
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
mBindingOffsets[binding] = mDescriptorCounts[SRV]++;
|
||||
break;
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
mBindingOffsets[binding] = mDescriptorCounts[Sampler]++;
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
@ -99,14 +99,14 @@ namespace dawn_native { namespace d3d12 {
|
||||
// Root descriptor needs to set this value to set correct register number in
|
||||
// generated HLSL shader.
|
||||
switch (groupInfo.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
mBindingOffsets[binding] = baseRegister++;
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
@ -114,21 +114,21 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
switch (groupInfo.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
mBindingOffsets[binding] += descriptorOffsets[CBV];
|
||||
break;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
mBindingOffsets[binding] += descriptorOffsets[UAV];
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
mBindingOffsets[binding] += descriptorOffsets[SRV];
|
||||
break;
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
mBindingOffsets[binding] += descriptorOffsets[Sampler];
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
|
@ -24,45 +24,45 @@
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
namespace {
|
||||
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::BufferUsage usage) {
|
||||
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(wgpu::BufferUsage usage) {
|
||||
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;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_STATES D3D12BufferUsage(dawn::BufferUsage usage) {
|
||||
D3D12_RESOURCE_STATES D3D12BufferUsage(wgpu::BufferUsage usage) {
|
||||
D3D12_RESOURCE_STATES resourceState = D3D12_RESOURCE_STATE_COMMON;
|
||||
|
||||
if (usage & dawn::BufferUsage::CopySrc) {
|
||||
if (usage & wgpu::BufferUsage::CopySrc) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::CopyDst) {
|
||||
if (usage & wgpu::BufferUsage::CopyDst) {
|
||||
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;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Index) {
|
||||
if (usage & wgpu::BufferUsage::Index) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_INDEX_BUFFER;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Storage) {
|
||||
if (usage & wgpu::BufferUsage::Storage) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_UNORDERED_ACCESS;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Indirect) {
|
||||
if (usage & wgpu::BufferUsage::Indirect) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT;
|
||||
}
|
||||
|
||||
return resourceState;
|
||||
}
|
||||
|
||||
D3D12_HEAP_TYPE D3D12HeapType(dawn::BufferUsage allowedUsage) {
|
||||
if (allowedUsage & dawn::BufferUsage::MapRead) {
|
||||
D3D12_HEAP_TYPE D3D12HeapType(wgpu::BufferUsage allowedUsage) {
|
||||
if (allowedUsage & wgpu::BufferUsage::MapRead) {
|
||||
return D3D12_HEAP_TYPE_READBACK;
|
||||
} else if (allowedUsage & dawn::BufferUsage::MapWrite) {
|
||||
} else if (allowedUsage & wgpu::BufferUsage::MapWrite) {
|
||||
return D3D12_HEAP_TYPE_UPLOAD;
|
||||
} else {
|
||||
return D3D12_HEAP_TYPE_DEFAULT;
|
||||
@ -88,7 +88,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
resourceDescriptor.Layout = D3D12_TEXTURE_LAYOUT_ROW_MAJOR;
|
||||
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
|
||||
// and robust resource initialization.
|
||||
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage() | dawn::BufferUsage::CopyDst);
|
||||
resourceDescriptor.Flags = D3D12ResourceFlags(GetUsage() | wgpu::BufferUsage::CopyDst);
|
||||
|
||||
auto heapType = D3D12HeapType(GetUsage());
|
||||
auto bufferUsage = D3D12_RESOURCE_STATE_COMMON;
|
||||
@ -98,7 +98,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
if (heapType == D3D12_HEAP_TYPE_READBACK) {
|
||||
bufferUsage |= D3D12_RESOURCE_STATE_COPY_DEST;
|
||||
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
|
||||
@ -106,7 +106,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
if (heapType == D3D12_HEAP_TYPE_UPLOAD) {
|
||||
bufferUsage |= D3D12_RESOURCE_STATE_GENERIC_READ;
|
||||
mFixedResourceState = true;
|
||||
mLastUsage = dawn::BufferUsage::CopySrc;
|
||||
mLastUsage = wgpu::BufferUsage::CopySrc;
|
||||
}
|
||||
|
||||
DAWN_TRY_ASSIGN(
|
||||
@ -133,7 +133,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
// cause subsequent errors.
|
||||
bool Buffer::TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
|
||||
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
|
||||
if (mFixedResourceState) {
|
||||
ASSERT(mLastUsage == newUsage);
|
||||
@ -204,7 +204,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
void Buffer::TransitionUsageNow(CommandRecordingContext* commandContext,
|
||||
dawn::BufferUsage usage) {
|
||||
wgpu::BufferUsage usage) {
|
||||
D3D12_RESOURCE_BARRIER barrier;
|
||||
|
||||
if (TransitionUsageAndGetResourceBarrier(commandContext, &barrier, usage)) {
|
||||
@ -226,7 +226,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
bool Buffer::IsMapWritable() const {
|
||||
// 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) {
|
||||
|
@ -39,8 +39,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
void OnMapCommandSerialFinished(uint32_t mapSerial, void* data, bool isWrite);
|
||||
bool TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
|
||||
D3D12_RESOURCE_BARRIER* barrier,
|
||||
dawn::BufferUsage newUsage);
|
||||
void TransitionUsageNow(CommandRecordingContext* commandContext, dawn::BufferUsage usage);
|
||||
wgpu::BufferUsage newUsage);
|
||||
void TransitionUsageNow(CommandRecordingContext* commandContext, wgpu::BufferUsage usage);
|
||||
|
||||
private:
|
||||
// Dawn API
|
||||
@ -54,7 +54,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
ResourceHeapAllocation mResourceAllocation;
|
||||
bool mFixedResourceState = false;
|
||||
dawn::BufferUsage mLastUsage = dawn::BufferUsage::None;
|
||||
wgpu::BufferUsage mLastUsage = wgpu::BufferUsage::None;
|
||||
Serial mLastUsedSerial = UINT64_MAX;
|
||||
D3D12_RANGE mWrittenMappedRange;
|
||||
};
|
||||
|
@ -40,11 +40,11 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
namespace {
|
||||
|
||||
DXGI_FORMAT DXGIIndexFormat(dawn::IndexFormat format) {
|
||||
DXGI_FORMAT DXGIIndexFormat(wgpu::IndexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::IndexFormat::Uint16:
|
||||
case wgpu::IndexFormat::Uint16:
|
||||
return DXGI_FORMAT_R16_UINT;
|
||||
case dawn::IndexFormat::Uint32:
|
||||
case wgpu::IndexFormat::Uint32:
|
||||
return DXGI_FORMAT_R32_UINT;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -149,21 +149,21 @@ namespace dawn_native { namespace d3d12 {
|
||||
if (mInCompute) {
|
||||
for (uint32_t index : IterateBitSet(mBindGroupLayoutsMask)) {
|
||||
for (uint32_t binding : IterateBitSet(mBuffersNeedingBarrier[index])) {
|
||||
dawn::BindingType bindingType = mBindingTypes[index][binding];
|
||||
wgpu::BindingType bindingType = mBindingTypes[index][binding];
|
||||
switch (bindingType) {
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
ToBackend(mBuffers[index][binding])
|
||||
->TransitionUsageNow(commandContext,
|
||||
dawn::BufferUsage::Storage);
|
||||
wgpu::BufferUsage::Storage);
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
// Not implemented.
|
||||
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
// Don't require barriers.
|
||||
|
||||
default:
|
||||
@ -224,7 +224,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
ToBackend(binding.buffer)->GetVA() + offset;
|
||||
|
||||
switch (layout.types[bindingIndex]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
if (mInCompute) {
|
||||
commandList->SetComputeRootConstantBufferView(parameterIndex,
|
||||
bufferLocation);
|
||||
@ -233,7 +233,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
bufferLocation);
|
||||
}
|
||||
break;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
if (mInCompute) {
|
||||
commandList->SetComputeRootUnorderedAccessView(parameterIndex,
|
||||
bufferLocation);
|
||||
@ -242,10 +242,10 @@ namespace dawn_native { namespace d3d12 {
|
||||
bufferLocation);
|
||||
}
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
@ -619,7 +619,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
// Clear textures that are not output attachments. Output attachments will be
|
||||
// cleared during record render pass if the 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(commandContext, 0,
|
||||
texture->GetNumMipLevels(), 0,
|
||||
texture->GetArrayLayers());
|
||||
@ -673,8 +673,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
Buffer* srcBuffer = ToBackend(copy->source.Get());
|
||||
Buffer* dstBuffer = ToBackend(copy->destination.Get());
|
||||
|
||||
srcBuffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopySrc);
|
||||
dstBuffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopyDst);
|
||||
srcBuffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopySrc);
|
||||
dstBuffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopyDst);
|
||||
|
||||
commandList->CopyBufferRegion(
|
||||
dstBuffer->GetD3D12Resource().Get(), copy->destinationOffset,
|
||||
@ -696,8 +696,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
copy->destination.arrayLayer, 1);
|
||||
}
|
||||
|
||||
buffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopySrc);
|
||||
texture->TransitionUsageNow(commandContext, dawn::TextureUsage::CopyDst);
|
||||
buffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopySrc);
|
||||
texture->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopyDst);
|
||||
|
||||
auto copySplit = ComputeTextureCopySplit(
|
||||
copy->destination.origin, copy->copySize, texture->GetFormat(),
|
||||
@ -731,8 +731,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
texture->EnsureSubresourceContentInitialized(
|
||||
commandContext, copy->source.mipLevel, 1, copy->source.arrayLayer, 1);
|
||||
|
||||
texture->TransitionUsageNow(commandContext, dawn::TextureUsage::CopySrc);
|
||||
buffer->TransitionUsageNow(commandContext, dawn::BufferUsage::CopyDst);
|
||||
texture->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopySrc);
|
||||
buffer->TransitionUsageNow(commandContext, wgpu::BufferUsage::CopyDst);
|
||||
|
||||
TextureCopySplit copySplit = ComputeTextureCopySplit(
|
||||
copy->source.origin, copy->copySize, texture->GetFormat(),
|
||||
@ -778,8 +778,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
commandContext, copy->destination.mipLevel, 1,
|
||||
copy->destination.arrayLayer, 1);
|
||||
}
|
||||
source->TransitionUsageNow(commandContext, dawn::TextureUsage::CopySrc);
|
||||
destination->TransitionUsageNow(commandContext, dawn::TextureUsage::CopyDst);
|
||||
source->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopySrc);
|
||||
destination->TransitionUsageNow(commandContext, wgpu::TextureUsage::CopyDst);
|
||||
|
||||
if (CanUseCopyResource(source->GetNumMipLevels(), source->GetSize(),
|
||||
destination->GetSize(), copy->copySize)) {
|
||||
@ -928,8 +928,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
// Load op - color
|
||||
ASSERT(view->GetLevelCount() == 1);
|
||||
ASSERT(view->GetLayerCount() == 1);
|
||||
if (attachmentInfo.loadOp == dawn::LoadOp::Clear ||
|
||||
(attachmentInfo.loadOp == dawn::LoadOp::Load &&
|
||||
if (attachmentInfo.loadOp == wgpu::LoadOp::Clear ||
|
||||
(attachmentInfo.loadOp == wgpu::LoadOp::Load &&
|
||||
!view->GetTexture()->IsSubresourceContentInitialized(
|
||||
view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1))) {
|
||||
D3D12_CPU_DESCRIPTOR_HANDLE handle = args.RTVs[i];
|
||||
@ -949,12 +949,12 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
switch (attachmentInfo.storeOp) {
|
||||
case dawn::StoreOp::Store: {
|
||||
case wgpu::StoreOp::Store: {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
true, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
|
||||
} break;
|
||||
|
||||
case dawn::StoreOp::Clear: {
|
||||
case wgpu::StoreOp::Clear: {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
false, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
|
||||
} break;
|
||||
@ -974,9 +974,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
// Load op - depth/stencil
|
||||
bool doDepthClear = texture->GetFormat().HasDepth() &&
|
||||
(attachmentInfo.depthLoadOp == dawn::LoadOp::Clear);
|
||||
(attachmentInfo.depthLoadOp == wgpu::LoadOp::Clear);
|
||||
bool doStencilClear = texture->GetFormat().HasStencil() &&
|
||||
(attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear);
|
||||
(attachmentInfo.stencilLoadOp == wgpu::LoadOp::Clear);
|
||||
|
||||
D3D12_CLEAR_FLAGS clearFlags = {};
|
||||
if (doDepthClear) {
|
||||
@ -991,12 +991,12 @@ namespace dawn_native { namespace d3d12 {
|
||||
view->GetBaseMipLevel(), view->GetLevelCount(), view->GetBaseArrayLayer(),
|
||||
view->GetLayerCount())) {
|
||||
if (texture->GetFormat().HasDepth() &&
|
||||
attachmentInfo.depthLoadOp == dawn::LoadOp::Load) {
|
||||
attachmentInfo.depthLoadOp == wgpu::LoadOp::Load) {
|
||||
clearDepth = 0.0f;
|
||||
clearFlags |= D3D12_CLEAR_FLAG_DEPTH;
|
||||
}
|
||||
if (texture->GetFormat().HasStencil() &&
|
||||
attachmentInfo.stencilLoadOp == dawn::LoadOp::Load) {
|
||||
attachmentInfo.stencilLoadOp == wgpu::LoadOp::Load) {
|
||||
clearStencil = 0u;
|
||||
clearFlags |= D3D12_CLEAR_FLAG_STENCIL;
|
||||
}
|
||||
@ -1008,13 +1008,13 @@ namespace dawn_native { namespace d3d12 {
|
||||
0, nullptr);
|
||||
}
|
||||
|
||||
if (attachmentInfo.depthStoreOp == dawn::StoreOp::Store &&
|
||||
attachmentInfo.stencilStoreOp == dawn::StoreOp::Store) {
|
||||
if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Store &&
|
||||
attachmentInfo.stencilStoreOp == wgpu::StoreOp::Store) {
|
||||
texture->SetIsSubresourceContentInitialized(
|
||||
true, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount());
|
||||
} else if (attachmentInfo.depthStoreOp == dawn::StoreOp::Clear &&
|
||||
attachmentInfo.stencilStoreOp == dawn::StoreOp::Clear) {
|
||||
} else if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Clear &&
|
||||
attachmentInfo.stencilStoreOp == wgpu::StoreOp::Clear) {
|
||||
texture->SetIsSubresourceContentInitialized(
|
||||
false, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount());
|
||||
|
@ -304,7 +304,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
DAWN_TRY_ASSIGN(commandRecordingContext, GetPendingCommandContext());
|
||||
|
||||
ToBackend(destination)
|
||||
->TransitionUsageNow(commandRecordingContext, dawn::BufferUsage::CopyDst);
|
||||
->TransitionUsageNow(commandRecordingContext, wgpu::BufferUsage::CopyDst);
|
||||
|
||||
commandRecordingContext->GetCommandList()->CopyBufferRegion(
|
||||
ToBackend(destination)->GetD3D12Resource().Get(), destinationOffset,
|
||||
|
@ -113,8 +113,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
return dawn::TextureFormat::RGBA8Unorm;
|
||||
wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
return wgpu::TextureFormat::RGBA8Unorm;
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
@ -41,7 +41,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError Present();
|
||||
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
wgpu::TextureFormat GetPreferredFormat() const;
|
||||
|
||||
private:
|
||||
HWND mWindow = nullptr;
|
||||
|
@ -25,14 +25,14 @@ using Microsoft::WRL::ComPtr;
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
namespace {
|
||||
D3D12_SHADER_VISIBILITY ShaderVisibilityType(dawn::ShaderStage visibility) {
|
||||
ASSERT(visibility != dawn::ShaderStage::None);
|
||||
D3D12_SHADER_VISIBILITY ShaderVisibilityType(wgpu::ShaderStage visibility) {
|
||||
ASSERT(visibility != wgpu::ShaderStage::None);
|
||||
|
||||
if (visibility == dawn::ShaderStage::Vertex) {
|
||||
if (visibility == wgpu::ShaderStage::Vertex) {
|
||||
return D3D12_SHADER_VISIBILITY_VERTEX;
|
||||
}
|
||||
|
||||
if (visibility == dawn::ShaderStage::Fragment) {
|
||||
if (visibility == wgpu::ShaderStage::Fragment) {
|
||||
return D3D12_SHADER_VISIBILITY_PIXEL;
|
||||
}
|
||||
|
||||
@ -40,16 +40,16 @@ namespace dawn_native { namespace d3d12 {
|
||||
return D3D12_SHADER_VISIBILITY_ALL;
|
||||
}
|
||||
|
||||
D3D12_ROOT_PARAMETER_TYPE RootParameterType(dawn::BindingType type) {
|
||||
D3D12_ROOT_PARAMETER_TYPE RootParameterType(wgpu::BindingType type) {
|
||||
switch (type) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
return D3D12_ROOT_PARAMETER_TYPE_CBV;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
return D3D12_ROOT_PARAMETER_TYPE_UAV;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
@ -28,95 +28,95 @@
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
namespace {
|
||||
DXGI_FORMAT VertexFormatType(dawn::VertexFormat format) {
|
||||
DXGI_FORMAT VertexFormatType(wgpu::VertexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::VertexFormat::UChar2:
|
||||
case wgpu::VertexFormat::UChar2:
|
||||
return DXGI_FORMAT_R8G8_UINT;
|
||||
case dawn::VertexFormat::UChar4:
|
||||
case wgpu::VertexFormat::UChar4:
|
||||
return DXGI_FORMAT_R8G8B8A8_UINT;
|
||||
case dawn::VertexFormat::Char2:
|
||||
case wgpu::VertexFormat::Char2:
|
||||
return DXGI_FORMAT_R8G8_SINT;
|
||||
case dawn::VertexFormat::Char4:
|
||||
case wgpu::VertexFormat::Char4:
|
||||
return DXGI_FORMAT_R8G8B8A8_SINT;
|
||||
case dawn::VertexFormat::UChar2Norm:
|
||||
case wgpu::VertexFormat::UChar2Norm:
|
||||
return DXGI_FORMAT_R8G8_UNORM;
|
||||
case dawn::VertexFormat::UChar4Norm:
|
||||
case wgpu::VertexFormat::UChar4Norm:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
case dawn::VertexFormat::Char2Norm:
|
||||
case wgpu::VertexFormat::Char2Norm:
|
||||
return DXGI_FORMAT_R8G8_SNORM;
|
||||
case dawn::VertexFormat::Char4Norm:
|
||||
case wgpu::VertexFormat::Char4Norm:
|
||||
return DXGI_FORMAT_R8G8B8A8_SNORM;
|
||||
case dawn::VertexFormat::UShort2:
|
||||
case wgpu::VertexFormat::UShort2:
|
||||
return DXGI_FORMAT_R16G16_UINT;
|
||||
case dawn::VertexFormat::UShort4:
|
||||
case wgpu::VertexFormat::UShort4:
|
||||
return DXGI_FORMAT_R16G16B16A16_UINT;
|
||||
case dawn::VertexFormat::Short2:
|
||||
case wgpu::VertexFormat::Short2:
|
||||
return DXGI_FORMAT_R16G16_SINT;
|
||||
case dawn::VertexFormat::Short4:
|
||||
case wgpu::VertexFormat::Short4:
|
||||
return DXGI_FORMAT_R16G16B16A16_SINT;
|
||||
case dawn::VertexFormat::UShort2Norm:
|
||||
case wgpu::VertexFormat::UShort2Norm:
|
||||
return DXGI_FORMAT_R16G16_UNORM;
|
||||
case dawn::VertexFormat::UShort4Norm:
|
||||
case wgpu::VertexFormat::UShort4Norm:
|
||||
return DXGI_FORMAT_R16G16B16A16_UNORM;
|
||||
case dawn::VertexFormat::Short2Norm:
|
||||
case wgpu::VertexFormat::Short2Norm:
|
||||
return DXGI_FORMAT_R16G16_SNORM;
|
||||
case dawn::VertexFormat::Short4Norm:
|
||||
case wgpu::VertexFormat::Short4Norm:
|
||||
return DXGI_FORMAT_R16G16B16A16_SNORM;
|
||||
case dawn::VertexFormat::Half2:
|
||||
case wgpu::VertexFormat::Half2:
|
||||
return DXGI_FORMAT_R16G16_FLOAT;
|
||||
case dawn::VertexFormat::Half4:
|
||||
case wgpu::VertexFormat::Half4:
|
||||
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
case dawn::VertexFormat::Float:
|
||||
case wgpu::VertexFormat::Float:
|
||||
return DXGI_FORMAT_R32_FLOAT;
|
||||
case dawn::VertexFormat::Float2:
|
||||
case wgpu::VertexFormat::Float2:
|
||||
return DXGI_FORMAT_R32G32_FLOAT;
|
||||
case dawn::VertexFormat::Float3:
|
||||
case wgpu::VertexFormat::Float3:
|
||||
return DXGI_FORMAT_R32G32B32_FLOAT;
|
||||
case dawn::VertexFormat::Float4:
|
||||
case wgpu::VertexFormat::Float4:
|
||||
return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
case dawn::VertexFormat::UInt:
|
||||
case wgpu::VertexFormat::UInt:
|
||||
return DXGI_FORMAT_R32_UINT;
|
||||
case dawn::VertexFormat::UInt2:
|
||||
case wgpu::VertexFormat::UInt2:
|
||||
return DXGI_FORMAT_R32G32_UINT;
|
||||
case dawn::VertexFormat::UInt3:
|
||||
case wgpu::VertexFormat::UInt3:
|
||||
return DXGI_FORMAT_R32G32B32_UINT;
|
||||
case dawn::VertexFormat::UInt4:
|
||||
case wgpu::VertexFormat::UInt4:
|
||||
return DXGI_FORMAT_R32G32B32A32_UINT;
|
||||
case dawn::VertexFormat::Int:
|
||||
case wgpu::VertexFormat::Int:
|
||||
return DXGI_FORMAT_R32_SINT;
|
||||
case dawn::VertexFormat::Int2:
|
||||
case wgpu::VertexFormat::Int2:
|
||||
return DXGI_FORMAT_R32G32_SINT;
|
||||
case dawn::VertexFormat::Int3:
|
||||
case wgpu::VertexFormat::Int3:
|
||||
return DXGI_FORMAT_R32G32B32_SINT;
|
||||
case dawn::VertexFormat::Int4:
|
||||
case wgpu::VertexFormat::Int4:
|
||||
return DXGI_FORMAT_R32G32B32A32_SINT;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
D3D12_INPUT_CLASSIFICATION InputStepModeFunction(dawn::InputStepMode mode) {
|
||||
D3D12_INPUT_CLASSIFICATION InputStepModeFunction(wgpu::InputStepMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::InputStepMode::Vertex:
|
||||
case wgpu::InputStepMode::Vertex:
|
||||
return D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA;
|
||||
case dawn::InputStepMode::Instance:
|
||||
case wgpu::InputStepMode::Instance:
|
||||
return D3D12_INPUT_CLASSIFICATION_PER_INSTANCE_DATA;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
D3D12_PRIMITIVE_TOPOLOGY D3D12PrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
|
||||
D3D12_PRIMITIVE_TOPOLOGY D3D12PrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) {
|
||||
switch (primitiveTopology) {
|
||||
case dawn::PrimitiveTopology::PointList:
|
||||
case wgpu::PrimitiveTopology::PointList:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_POINTLIST;
|
||||
case dawn::PrimitiveTopology::LineList:
|
||||
case wgpu::PrimitiveTopology::LineList:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_LINELIST;
|
||||
case dawn::PrimitiveTopology::LineStrip:
|
||||
case wgpu::PrimitiveTopology::LineStrip:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_LINESTRIP;
|
||||
case dawn::PrimitiveTopology::TriangleList:
|
||||
case wgpu::PrimitiveTopology::TriangleList:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST;
|
||||
case dawn::PrimitiveTopology::TriangleStrip:
|
||||
case wgpu::PrimitiveTopology::TriangleStrip:
|
||||
return D3D_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -124,95 +124,95 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
D3D12_PRIMITIVE_TOPOLOGY_TYPE D3D12PrimitiveTopologyType(
|
||||
dawn::PrimitiveTopology primitiveTopology) {
|
||||
wgpu::PrimitiveTopology primitiveTopology) {
|
||||
switch (primitiveTopology) {
|
||||
case dawn::PrimitiveTopology::PointList:
|
||||
case wgpu::PrimitiveTopology::PointList:
|
||||
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_POINT;
|
||||
case dawn::PrimitiveTopology::LineList:
|
||||
case dawn::PrimitiveTopology::LineStrip:
|
||||
case wgpu::PrimitiveTopology::LineList:
|
||||
case wgpu::PrimitiveTopology::LineStrip:
|
||||
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_LINE;
|
||||
case dawn::PrimitiveTopology::TriangleList:
|
||||
case dawn::PrimitiveTopology::TriangleStrip:
|
||||
case wgpu::PrimitiveTopology::TriangleList:
|
||||
case wgpu::PrimitiveTopology::TriangleStrip:
|
||||
return D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
D3D12_CULL_MODE D3D12CullMode(dawn::CullMode mode) {
|
||||
D3D12_CULL_MODE D3D12CullMode(wgpu::CullMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::CullMode::None:
|
||||
case wgpu::CullMode::None:
|
||||
return D3D12_CULL_MODE_NONE;
|
||||
case dawn::CullMode::Front:
|
||||
case wgpu::CullMode::Front:
|
||||
return D3D12_CULL_MODE_FRONT;
|
||||
case dawn::CullMode::Back:
|
||||
case wgpu::CullMode::Back:
|
||||
return D3D12_CULL_MODE_BACK;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
D3D12_BLEND D3D12Blend(dawn::BlendFactor factor) {
|
||||
D3D12_BLEND D3D12Blend(wgpu::BlendFactor factor) {
|
||||
switch (factor) {
|
||||
case dawn::BlendFactor::Zero:
|
||||
case wgpu::BlendFactor::Zero:
|
||||
return D3D12_BLEND_ZERO;
|
||||
case dawn::BlendFactor::One:
|
||||
case wgpu::BlendFactor::One:
|
||||
return D3D12_BLEND_ONE;
|
||||
case dawn::BlendFactor::SrcColor:
|
||||
case wgpu::BlendFactor::SrcColor:
|
||||
return D3D12_BLEND_SRC_COLOR;
|
||||
case dawn::BlendFactor::OneMinusSrcColor:
|
||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
||||
return D3D12_BLEND_INV_SRC_COLOR;
|
||||
case dawn::BlendFactor::SrcAlpha:
|
||||
case wgpu::BlendFactor::SrcAlpha:
|
||||
return D3D12_BLEND_SRC_ALPHA;
|
||||
case dawn::BlendFactor::OneMinusSrcAlpha:
|
||||
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
||||
return D3D12_BLEND_INV_SRC_ALPHA;
|
||||
case dawn::BlendFactor::DstColor:
|
||||
case wgpu::BlendFactor::DstColor:
|
||||
return D3D12_BLEND_DEST_COLOR;
|
||||
case dawn::BlendFactor::OneMinusDstColor:
|
||||
case wgpu::BlendFactor::OneMinusDstColor:
|
||||
return D3D12_BLEND_INV_DEST_COLOR;
|
||||
case dawn::BlendFactor::DstAlpha:
|
||||
case wgpu::BlendFactor::DstAlpha:
|
||||
return D3D12_BLEND_DEST_ALPHA;
|
||||
case dawn::BlendFactor::OneMinusDstAlpha:
|
||||
case wgpu::BlendFactor::OneMinusDstAlpha:
|
||||
return D3D12_BLEND_INV_DEST_ALPHA;
|
||||
case dawn::BlendFactor::SrcAlphaSaturated:
|
||||
case wgpu::BlendFactor::SrcAlphaSaturated:
|
||||
return D3D12_BLEND_SRC_ALPHA_SAT;
|
||||
case dawn::BlendFactor::BlendColor:
|
||||
case wgpu::BlendFactor::BlendColor:
|
||||
return D3D12_BLEND_BLEND_FACTOR;
|
||||
case dawn::BlendFactor::OneMinusBlendColor:
|
||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
||||
return D3D12_BLEND_INV_BLEND_FACTOR;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
D3D12_BLEND_OP D3D12BlendOperation(dawn::BlendOperation operation) {
|
||||
D3D12_BLEND_OP D3D12BlendOperation(wgpu::BlendOperation operation) {
|
||||
switch (operation) {
|
||||
case dawn::BlendOperation::Add:
|
||||
case wgpu::BlendOperation::Add:
|
||||
return D3D12_BLEND_OP_ADD;
|
||||
case dawn::BlendOperation::Subtract:
|
||||
case wgpu::BlendOperation::Subtract:
|
||||
return D3D12_BLEND_OP_SUBTRACT;
|
||||
case dawn::BlendOperation::ReverseSubtract:
|
||||
case wgpu::BlendOperation::ReverseSubtract:
|
||||
return D3D12_BLEND_OP_REV_SUBTRACT;
|
||||
case dawn::BlendOperation::Min:
|
||||
case wgpu::BlendOperation::Min:
|
||||
return D3D12_BLEND_OP_MIN;
|
||||
case dawn::BlendOperation::Max:
|
||||
case wgpu::BlendOperation::Max:
|
||||
return D3D12_BLEND_OP_MAX;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t D3D12RenderTargetWriteMask(dawn::ColorWriteMask writeMask) {
|
||||
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(dawn::ColorWriteMask::Red) ==
|
||||
uint8_t D3D12RenderTargetWriteMask(wgpu::ColorWriteMask writeMask) {
|
||||
static_assert(static_cast<D3D12_COLOR_WRITE_ENABLE>(wgpu::ColorWriteMask::Red) ==
|
||||
D3D12_COLOR_WRITE_ENABLE_RED,
|
||||
"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,
|
||||
"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,
|
||||
"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,
|
||||
"ColorWriteMask values must match");
|
||||
return static_cast<uint8_t>(writeMask);
|
||||
@ -233,23 +233,23 @@ namespace dawn_native { namespace d3d12 {
|
||||
return blendDesc;
|
||||
}
|
||||
|
||||
D3D12_STENCIL_OP StencilOp(dawn::StencilOperation op) {
|
||||
D3D12_STENCIL_OP StencilOp(wgpu::StencilOperation op) {
|
||||
switch (op) {
|
||||
case dawn::StencilOperation::Keep:
|
||||
case wgpu::StencilOperation::Keep:
|
||||
return D3D12_STENCIL_OP_KEEP;
|
||||
case dawn::StencilOperation::Zero:
|
||||
case wgpu::StencilOperation::Zero:
|
||||
return D3D12_STENCIL_OP_ZERO;
|
||||
case dawn::StencilOperation::Replace:
|
||||
case wgpu::StencilOperation::Replace:
|
||||
return D3D12_STENCIL_OP_REPLACE;
|
||||
case dawn::StencilOperation::IncrementClamp:
|
||||
case wgpu::StencilOperation::IncrementClamp:
|
||||
return D3D12_STENCIL_OP_INCR_SAT;
|
||||
case dawn::StencilOperation::DecrementClamp:
|
||||
case wgpu::StencilOperation::DecrementClamp:
|
||||
return D3D12_STENCIL_OP_DECR_SAT;
|
||||
case dawn::StencilOperation::Invert:
|
||||
case wgpu::StencilOperation::Invert:
|
||||
return D3D12_STENCIL_OP_INVERT;
|
||||
case dawn::StencilOperation::IncrementWrap:
|
||||
case wgpu::StencilOperation::IncrementWrap:
|
||||
return D3D12_STENCIL_OP_INCR;
|
||||
case dawn::StencilOperation::DecrementWrap:
|
||||
case wgpu::StencilOperation::DecrementWrap:
|
||||
return D3D12_STENCIL_OP_DECR;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -313,7 +313,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
PerStage<ComPtr<ID3DBlob>> compiledShader;
|
||||
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)) {
|
||||
const ShaderModule* module = nullptr;
|
||||
const char* entryPoint = nullptr;
|
||||
@ -366,7 +366,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
descriptorD3D12.RasterizerState.FillMode = D3D12_FILL_MODE_SOLID;
|
||||
descriptorD3D12.RasterizerState.CullMode = D3D12CullMode(GetCullMode());
|
||||
descriptorD3D12.RasterizerState.FrontCounterClockwise =
|
||||
(GetFrontFace() == dawn::FrontFace::CCW) ? TRUE : FALSE;
|
||||
(GetFrontFace() == wgpu::FrontFace::CCW) ? TRUE : FALSE;
|
||||
descriptorD3D12.RasterizerState.DepthBias = D3D12_DEFAULT_DEPTH_BIAS;
|
||||
descriptorD3D12.RasterizerState.DepthBiasClamp = D3D12_DEFAULT_DEPTH_BIAS_CLAMP;
|
||||
descriptorD3D12.RasterizerState.SlopeScaledDepthBias =
|
||||
|
@ -20,13 +20,13 @@
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
namespace {
|
||||
D3D12_TEXTURE_ADDRESS_MODE AddressMode(dawn::AddressMode mode) {
|
||||
D3D12_TEXTURE_ADDRESS_MODE AddressMode(wgpu::AddressMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::AddressMode::Repeat:
|
||||
case wgpu::AddressMode::Repeat:
|
||||
return D3D12_TEXTURE_ADDRESS_MODE_WRAP;
|
||||
case dawn::AddressMode::MirrorRepeat:
|
||||
case wgpu::AddressMode::MirrorRepeat:
|
||||
return D3D12_TEXTURE_ADDRESS_MODE_MIRROR;
|
||||
case dawn::AddressMode::ClampToEdge:
|
||||
case wgpu::AddressMode::ClampToEdge:
|
||||
return D3D12_TEXTURE_ADDRESS_MODE_CLAMP;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -54,25 +54,25 @@ namespace dawn_native { namespace d3d12 {
|
||||
uint8_t mode = 0;
|
||||
|
||||
switch (descriptor->minFilter) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
break;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
mode += 16;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (descriptor->magFilter) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
break;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
mode += 4;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (descriptor->mipmapFilter) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
break;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
mode += 1;
|
||||
break;
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
im.Init(im.userData, &wsiContext);
|
||||
|
||||
ASSERT(im.textureUsage != DAWN_TEXTURE_USAGE_NONE);
|
||||
mTextureUsage = static_cast<dawn::TextureUsage>(im.textureUsage);
|
||||
mTextureUsage = static_cast<wgpu::TextureUsage>(im.textureUsage);
|
||||
}
|
||||
|
||||
SwapChain::~SwapChain() {
|
||||
@ -40,7 +40,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
DawnSwapChainNextTexture next = {};
|
||||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(dawn::ErrorType::Unknown, error);
|
||||
GetDevice()->HandleError(wgpu::ErrorType::Unknown, error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
TextureBase* GetNextTextureImpl(const TextureDescriptor* descriptor) override;
|
||||
MaybeError OnBeforePresent(TextureBase* texture) override;
|
||||
|
||||
dawn::TextureUsage mTextureUsage;
|
||||
wgpu::TextureUsage mTextureUsage;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::d3d12
|
||||
|
@ -30,28 +30,28 @@
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
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;
|
||||
|
||||
// Present is an exclusive flag.
|
||||
if (usage & dawn::TextureUsage::Present) {
|
||||
if (usage & wgpu::TextureUsage::Present) {
|
||||
return D3D12_RESOURCE_STATE_PRESENT;
|
||||
}
|
||||
|
||||
if (usage & dawn::TextureUsage::CopySrc) {
|
||||
if (usage & wgpu::TextureUsage::CopySrc) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_COPY_SOURCE;
|
||||
}
|
||||
if (usage & dawn::TextureUsage::CopyDst) {
|
||||
if (usage & wgpu::TextureUsage::CopyDst) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_COPY_DEST;
|
||||
}
|
||||
if (usage & dawn::TextureUsage::Sampled) {
|
||||
if (usage & wgpu::TextureUsage::Sampled) {
|
||||
resourceState |= (D3D12_RESOURCE_STATE_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;
|
||||
}
|
||||
if (usage & dawn::TextureUsage::OutputAttachment) {
|
||||
if (usage & wgpu::TextureUsage::OutputAttachment) {
|
||||
if (format.HasDepthOrStencil()) {
|
||||
resourceState |= D3D12_RESOURCE_STATE_DEPTH_WRITE;
|
||||
} else {
|
||||
@ -62,12 +62,12 @@ namespace dawn_native { namespace d3d12 {
|
||||
return resourceState;
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(dawn::TextureUsage usage,
|
||||
D3D12_RESOURCE_FLAGS D3D12ResourceFlags(wgpu::TextureUsage usage,
|
||||
const Format& format,
|
||||
bool isMultisampledTexture) {
|
||||
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;
|
||||
}
|
||||
|
||||
@ -79,7 +79,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
// flag is invalid.
|
||||
// TODO(natlee@microsoft.com, jiawei.shao@intel.com): do not require render target for
|
||||
// lazy clearing.
|
||||
if ((usage & dawn::TextureUsage::OutputAttachment) || isMultisampledTexture ||
|
||||
if ((usage & wgpu::TextureUsage::OutputAttachment) || isMultisampledTexture ||
|
||||
!format.isCompressed) {
|
||||
if (format.HasDepthOrStencil()) {
|
||||
flags |= D3D12_RESOURCE_FLAG_ALLOW_DEPTH_STENCIL;
|
||||
@ -93,9 +93,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
return flags;
|
||||
}
|
||||
|
||||
D3D12_RESOURCE_DIMENSION D3D12TextureDimension(dawn::TextureDimension dimension) {
|
||||
D3D12_RESOURCE_DIMENSION D3D12TextureDimension(wgpu::TextureDimension dimension) {
|
||||
switch (dimension) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
return D3D12_RESOURCE_DIMENSION_TEXTURE2D;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -103,117 +103,117 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
} // namespace
|
||||
|
||||
DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format) {
|
||||
DXGI_FORMAT D3D12TextureFormat(wgpu::TextureFormat format) {
|
||||
switch (format) {
|
||||
case dawn::TextureFormat::R8Unorm:
|
||||
case wgpu::TextureFormat::R8Unorm:
|
||||
return DXGI_FORMAT_R8_UNORM;
|
||||
case dawn::TextureFormat::R8Snorm:
|
||||
case wgpu::TextureFormat::R8Snorm:
|
||||
return DXGI_FORMAT_R8_SNORM;
|
||||
case dawn::TextureFormat::R8Uint:
|
||||
case wgpu::TextureFormat::R8Uint:
|
||||
return DXGI_FORMAT_R8_UINT;
|
||||
case dawn::TextureFormat::R8Sint:
|
||||
case wgpu::TextureFormat::R8Sint:
|
||||
return DXGI_FORMAT_R8_SINT;
|
||||
|
||||
case dawn::TextureFormat::R16Uint:
|
||||
case wgpu::TextureFormat::R16Uint:
|
||||
return DXGI_FORMAT_R16_UINT;
|
||||
case dawn::TextureFormat::R16Sint:
|
||||
case wgpu::TextureFormat::R16Sint:
|
||||
return DXGI_FORMAT_R16_SINT;
|
||||
case dawn::TextureFormat::R16Float:
|
||||
case wgpu::TextureFormat::R16Float:
|
||||
return DXGI_FORMAT_R16_FLOAT;
|
||||
case dawn::TextureFormat::RG8Unorm:
|
||||
case wgpu::TextureFormat::RG8Unorm:
|
||||
return DXGI_FORMAT_R8G8_UNORM;
|
||||
case dawn::TextureFormat::RG8Snorm:
|
||||
case wgpu::TextureFormat::RG8Snorm:
|
||||
return DXGI_FORMAT_R8G8_SNORM;
|
||||
case dawn::TextureFormat::RG8Uint:
|
||||
case wgpu::TextureFormat::RG8Uint:
|
||||
return DXGI_FORMAT_R8G8_UINT;
|
||||
case dawn::TextureFormat::RG8Sint:
|
||||
case wgpu::TextureFormat::RG8Sint:
|
||||
return DXGI_FORMAT_R8G8_SINT;
|
||||
|
||||
case dawn::TextureFormat::R32Uint:
|
||||
case wgpu::TextureFormat::R32Uint:
|
||||
return DXGI_FORMAT_R32_UINT;
|
||||
case dawn::TextureFormat::R32Sint:
|
||||
case wgpu::TextureFormat::R32Sint:
|
||||
return DXGI_FORMAT_R32_SINT;
|
||||
case dawn::TextureFormat::R32Float:
|
||||
case wgpu::TextureFormat::R32Float:
|
||||
return DXGI_FORMAT_R32_FLOAT;
|
||||
case dawn::TextureFormat::RG16Uint:
|
||||
case wgpu::TextureFormat::RG16Uint:
|
||||
return DXGI_FORMAT_R16G16_UINT;
|
||||
case dawn::TextureFormat::RG16Sint:
|
||||
case wgpu::TextureFormat::RG16Sint:
|
||||
return DXGI_FORMAT_R16G16_SINT;
|
||||
case dawn::TextureFormat::RG16Float:
|
||||
case wgpu::TextureFormat::RG16Float:
|
||||
return DXGI_FORMAT_R16G16_FLOAT;
|
||||
case dawn::TextureFormat::RGBA8Unorm:
|
||||
case wgpu::TextureFormat::RGBA8Unorm:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
case dawn::TextureFormat::RGBA8UnormSrgb:
|
||||
case wgpu::TextureFormat::RGBA8UnormSrgb:
|
||||
return DXGI_FORMAT_R8G8B8A8_UNORM_SRGB;
|
||||
case dawn::TextureFormat::RGBA8Snorm:
|
||||
case wgpu::TextureFormat::RGBA8Snorm:
|
||||
return DXGI_FORMAT_R8G8B8A8_SNORM;
|
||||
case dawn::TextureFormat::RGBA8Uint:
|
||||
case wgpu::TextureFormat::RGBA8Uint:
|
||||
return DXGI_FORMAT_R8G8B8A8_UINT;
|
||||
case dawn::TextureFormat::RGBA8Sint:
|
||||
case wgpu::TextureFormat::RGBA8Sint:
|
||||
return DXGI_FORMAT_R8G8B8A8_SINT;
|
||||
case dawn::TextureFormat::BGRA8Unorm:
|
||||
case wgpu::TextureFormat::BGRA8Unorm:
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM;
|
||||
case dawn::TextureFormat::BGRA8UnormSrgb:
|
||||
case wgpu::TextureFormat::BGRA8UnormSrgb:
|
||||
return DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
|
||||
case dawn::TextureFormat::RGB10A2Unorm:
|
||||
case wgpu::TextureFormat::RGB10A2Unorm:
|
||||
return DXGI_FORMAT_R10G10B10A2_UNORM;
|
||||
case dawn::TextureFormat::RG11B10Float:
|
||||
case wgpu::TextureFormat::RG11B10Float:
|
||||
return DXGI_FORMAT_R11G11B10_FLOAT;
|
||||
|
||||
case dawn::TextureFormat::RG32Uint:
|
||||
case wgpu::TextureFormat::RG32Uint:
|
||||
return DXGI_FORMAT_R32G32_UINT;
|
||||
case dawn::TextureFormat::RG32Sint:
|
||||
case wgpu::TextureFormat::RG32Sint:
|
||||
return DXGI_FORMAT_R32G32_SINT;
|
||||
case dawn::TextureFormat::RG32Float:
|
||||
case wgpu::TextureFormat::RG32Float:
|
||||
return DXGI_FORMAT_R32G32_FLOAT;
|
||||
case dawn::TextureFormat::RGBA16Uint:
|
||||
case wgpu::TextureFormat::RGBA16Uint:
|
||||
return DXGI_FORMAT_R16G16B16A16_UINT;
|
||||
case dawn::TextureFormat::RGBA16Sint:
|
||||
case wgpu::TextureFormat::RGBA16Sint:
|
||||
return DXGI_FORMAT_R16G16B16A16_SINT;
|
||||
case dawn::TextureFormat::RGBA16Float:
|
||||
case wgpu::TextureFormat::RGBA16Float:
|
||||
return DXGI_FORMAT_R16G16B16A16_FLOAT;
|
||||
|
||||
case dawn::TextureFormat::RGBA32Uint:
|
||||
case wgpu::TextureFormat::RGBA32Uint:
|
||||
return DXGI_FORMAT_R32G32B32A32_UINT;
|
||||
case dawn::TextureFormat::RGBA32Sint:
|
||||
case wgpu::TextureFormat::RGBA32Sint:
|
||||
return DXGI_FORMAT_R32G32B32A32_SINT;
|
||||
case dawn::TextureFormat::RGBA32Float:
|
||||
case wgpu::TextureFormat::RGBA32Float:
|
||||
return DXGI_FORMAT_R32G32B32A32_FLOAT;
|
||||
|
||||
case dawn::TextureFormat::Depth32Float:
|
||||
case wgpu::TextureFormat::Depth32Float:
|
||||
return DXGI_FORMAT_D32_FLOAT;
|
||||
case dawn::TextureFormat::Depth24Plus:
|
||||
case wgpu::TextureFormat::Depth24Plus:
|
||||
return DXGI_FORMAT_D32_FLOAT;
|
||||
case dawn::TextureFormat::Depth24PlusStencil8:
|
||||
case wgpu::TextureFormat::Depth24PlusStencil8:
|
||||
return DXGI_FORMAT_D32_FLOAT_S8X24_UINT;
|
||||
|
||||
case dawn::TextureFormat::BC1RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC1RGBAUnorm:
|
||||
return DXGI_FORMAT_BC1_UNORM;
|
||||
case dawn::TextureFormat::BC1RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC1RGBAUnormSrgb:
|
||||
return DXGI_FORMAT_BC1_UNORM_SRGB;
|
||||
case dawn::TextureFormat::BC2RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC2RGBAUnorm:
|
||||
return DXGI_FORMAT_BC2_UNORM;
|
||||
case dawn::TextureFormat::BC2RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC2RGBAUnormSrgb:
|
||||
return DXGI_FORMAT_BC2_UNORM_SRGB;
|
||||
case dawn::TextureFormat::BC3RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC3RGBAUnorm:
|
||||
return DXGI_FORMAT_BC3_UNORM;
|
||||
case dawn::TextureFormat::BC3RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC3RGBAUnormSrgb:
|
||||
return DXGI_FORMAT_BC3_UNORM_SRGB;
|
||||
case dawn::TextureFormat::BC4RSnorm:
|
||||
case wgpu::TextureFormat::BC4RSnorm:
|
||||
return DXGI_FORMAT_BC4_SNORM;
|
||||
case dawn::TextureFormat::BC4RUnorm:
|
||||
case wgpu::TextureFormat::BC4RUnorm:
|
||||
return DXGI_FORMAT_BC4_UNORM;
|
||||
case dawn::TextureFormat::BC5RGSnorm:
|
||||
case wgpu::TextureFormat::BC5RGSnorm:
|
||||
return DXGI_FORMAT_BC5_SNORM;
|
||||
case dawn::TextureFormat::BC5RGUnorm:
|
||||
case wgpu::TextureFormat::BC5RGUnorm:
|
||||
return DXGI_FORMAT_BC5_UNORM;
|
||||
case dawn::TextureFormat::BC6HRGBSfloat:
|
||||
case wgpu::TextureFormat::BC6HRGBSfloat:
|
||||
return DXGI_FORMAT_BC6H_SF16;
|
||||
case dawn::TextureFormat::BC6HRGBUfloat:
|
||||
case wgpu::TextureFormat::BC6HRGBUfloat:
|
||||
return DXGI_FORMAT_BC6H_UF16;
|
||||
case dawn::TextureFormat::BC7RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC7RGBAUnorm:
|
||||
return DXGI_FORMAT_BC7_UNORM;
|
||||
case dawn::TextureFormat::BC7RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC7RGBAUnormSrgb:
|
||||
return DXGI_FORMAT_BC7_UNORM_SRGB;
|
||||
|
||||
default:
|
||||
@ -222,7 +222,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
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");
|
||||
}
|
||||
|
||||
@ -397,7 +397,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
|
||||
UINT16 Texture::GetDepthOrArraySize() {
|
||||
switch (GetDimension()) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
return static_cast<UINT16>(GetArrayLayers());
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -409,7 +409,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
// cause subsequent errors.
|
||||
bool Texture::TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
|
||||
D3D12_RESOURCE_BARRIER* barrier,
|
||||
dawn::TextureUsage newUsage) {
|
||||
wgpu::TextureUsage newUsage) {
|
||||
return TransitionUsageAndGetResourceBarrier(commandContext, barrier,
|
||||
D3D12TextureUsage(newUsage, GetFormat()));
|
||||
}
|
||||
@ -493,7 +493,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
}
|
||||
|
||||
void Texture::TransitionUsageNow(CommandRecordingContext* commandContext,
|
||||
dawn::TextureUsage usage) {
|
||||
wgpu::TextureUsage usage) {
|
||||
TransitionUsageNow(commandContext, D3D12TextureUsage(usage, GetFormat()));
|
||||
}
|
||||
|
||||
@ -509,7 +509,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
D3D12_RENDER_TARGET_VIEW_DESC Texture::GetRTVDescriptor(uint32_t baseMipLevel,
|
||||
uint32_t baseArrayLayer,
|
||||
uint32_t layerCount) const {
|
||||
ASSERT(GetDimension() == dawn::TextureDimension::e2D);
|
||||
ASSERT(GetDimension() == wgpu::TextureDimension::e2D);
|
||||
D3D12_RENDER_TARGET_VIEW_DESC rtvDesc;
|
||||
rtvDesc.Format = GetD3D12Format();
|
||||
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 creating SRV on multisampled textures.
|
||||
switch (descriptor->dimension) {
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D);
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
|
||||
mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURE2DARRAY;
|
||||
mSrvDesc.Texture2DArray.ArraySize = descriptor->arrayLayerCount;
|
||||
mSrvDesc.Texture2DArray.FirstArraySlice = descriptor->baseArrayLayer;
|
||||
@ -707,9 +707,9 @@ namespace dawn_native { namespace d3d12 {
|
||||
mSrvDesc.Texture2DArray.PlaneSlice = 0;
|
||||
mSrvDesc.Texture2DArray.ResourceMinLODClamp = 0;
|
||||
break;
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D);
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
|
||||
ASSERT(descriptor->arrayLayerCount % 6 == 0);
|
||||
mSrvDesc.ViewDimension = D3D12_SRV_DIMENSION_TEXTURECUBEARRAY;
|
||||
mSrvDesc.TextureCubeArray.First2DArrayFace = descriptor->baseArrayLayer;
|
||||
|
@ -26,7 +26,7 @@ namespace dawn_native { namespace d3d12 {
|
||||
class CommandRecordingContext;
|
||||
class Device;
|
||||
|
||||
DXGI_FORMAT D3D12TextureFormat(dawn::TextureFormat format);
|
||||
DXGI_FORMAT D3D12TextureFormat(wgpu::TextureFormat format);
|
||||
MaybeError ValidateD3D12TextureCanBeWrapped(ID3D12Resource* d3d12Resource,
|
||||
const TextureDescriptor* descriptor);
|
||||
MaybeError ValidateTextureDescriptorCanBeWrapped(const TextureDescriptor* descriptor);
|
||||
@ -49,8 +49,8 @@ namespace dawn_native { namespace d3d12 {
|
||||
ID3D12Resource* GetD3D12Resource() const;
|
||||
bool TransitionUsageAndGetResourceBarrier(CommandRecordingContext* commandContext,
|
||||
D3D12_RESOURCE_BARRIER* barrier,
|
||||
dawn::TextureUsage newUsage);
|
||||
void TransitionUsageNow(CommandRecordingContext* commandContext, dawn::TextureUsage usage);
|
||||
wgpu::TextureUsage newUsage);
|
||||
void TransitionUsageNow(CommandRecordingContext* commandContext, wgpu::TextureUsage usage);
|
||||
void TransitionUsageNow(CommandRecordingContext* commandContext,
|
||||
D3D12_RESOURCE_STATES newState);
|
||||
|
||||
|
@ -18,23 +18,23 @@
|
||||
|
||||
namespace dawn_native { namespace d3d12 {
|
||||
|
||||
D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(dawn::CompareFunction func) {
|
||||
D3D12_COMPARISON_FUNC ToD3D12ComparisonFunc(wgpu::CompareFunction func) {
|
||||
switch (func) {
|
||||
case dawn::CompareFunction::Always:
|
||||
case wgpu::CompareFunction::Always:
|
||||
return D3D12_COMPARISON_FUNC_ALWAYS;
|
||||
case dawn::CompareFunction::Equal:
|
||||
case wgpu::CompareFunction::Equal:
|
||||
return D3D12_COMPARISON_FUNC_EQUAL;
|
||||
case dawn::CompareFunction::Greater:
|
||||
case wgpu::CompareFunction::Greater:
|
||||
return D3D12_COMPARISON_FUNC_GREATER;
|
||||
case dawn::CompareFunction::GreaterEqual:
|
||||
case wgpu::CompareFunction::GreaterEqual:
|
||||
return D3D12_COMPARISON_FUNC_GREATER_EQUAL;
|
||||
case dawn::CompareFunction::Less:
|
||||
case wgpu::CompareFunction::Less:
|
||||
return D3D12_COMPARISON_FUNC_LESS;
|
||||
case dawn::CompareFunction::LessEqual:
|
||||
case wgpu::CompareFunction::LessEqual:
|
||||
return D3D12_COMPARISON_FUNC_LESS_EQUAL;
|
||||
case dawn::CompareFunction::Never:
|
||||
case wgpu::CompareFunction::Never:
|
||||
return D3D12_COMPARISON_FUNC_NEVER;
|
||||
case dawn::CompareFunction::NotEqual:
|
||||
case wgpu::CompareFunction::NotEqual:
|
||||
return D3D12_COMPARISON_FUNC_NOT_EQUAL;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -23,7 +23,7 @@
|
||||
|
||||
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,
|
||||
uint32_t level,
|
||||
|
@ -15,11 +15,11 @@
|
||||
#ifndef DAWNNATIVE_DAWNPLATFORM_H_
|
||||
#define DAWNNATIVE_DAWNPLATFORM_H_
|
||||
|
||||
// Use dawncpp to have the enum and bitfield definitions
|
||||
#include <dawn/dawncpp.h>
|
||||
// Use webgpu_cpp to have the enum and bitfield definitions
|
||||
#include <dawn/webgpu_cpp.h>
|
||||
|
||||
// Use our autogenerated version of the dawn structures that point to dawn_native object types
|
||||
// (dawn::Buffer is dawn_native::BufferBase*)
|
||||
#include <dawn_native/dawn_structs_autogen.h>
|
||||
// Use our autogenerated version of the wgpu structures that point to dawn_native object types
|
||||
// (wgpu::Buffer is dawn_native::BufferBase*)
|
||||
#include <dawn_native/wgpu_structs_autogen.h>
|
||||
|
||||
#endif // DAWNNATIVE_DAWNPLATFORM_H_
|
||||
|
@ -25,7 +25,7 @@ namespace dawn_native { namespace metal {
|
||||
Buffer::Buffer(Device* device, const BufferDescriptor* descriptor)
|
||||
: BufferBase(device, descriptor) {
|
||||
MTLResourceOptions storageMode;
|
||||
if (GetUsage() & (dawn::BufferUsage::MapRead | dawn::BufferUsage::MapWrite)) {
|
||||
if (GetUsage() & (wgpu::BufferUsage::MapRead | wgpu::BufferUsage::MapWrite)) {
|
||||
storageMode = MTLResourceStorageModeShared;
|
||||
} else {
|
||||
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
|
||||
// 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.
|
||||
if (GetUsage() & (dawn::BufferUsage::Uniform | dawn::BufferUsage::Storage)) {
|
||||
if (GetUsage() & (wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage)) {
|
||||
currentSize = Align(currentSize, kMinUniformOrStorageBufferAlignment);
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
bool Buffer::IsMapWritable() const {
|
||||
// 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) {
|
||||
|
@ -56,7 +56,7 @@ namespace dawn_native { namespace metal {
|
||||
IterateBitSet(renderPass->attachmentState->GetColorAttachmentsMask())) {
|
||||
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].clearColor =
|
||||
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].slice = attachmentInfo.view->GetBaseArrayLayer();
|
||||
|
||||
if (attachmentInfo.storeOp == dawn::StoreOp::Store) {
|
||||
if (attachmentInfo.storeOp == wgpu::StoreOp::Store) {
|
||||
if (attachmentInfo.resolveTarget.Get() != nullptr) {
|
||||
descriptor.colorAttachments[i].resolveTexture =
|
||||
ToBackend(attachmentInfo.resolveTarget->GetTexture())->GetMTLTexture();
|
||||
@ -98,7 +98,7 @@ namespace dawn_native { namespace metal {
|
||||
descriptor.depthAttachment.texture = texture;
|
||||
descriptor.depthAttachment.storeAction = MTLStoreActionStore;
|
||||
|
||||
if (attachmentInfo.depthLoadOp == dawn::LoadOp::Clear) {
|
||||
if (attachmentInfo.depthLoadOp == wgpu::LoadOp::Clear) {
|
||||
descriptor.depthAttachment.loadAction = MTLLoadActionClear;
|
||||
descriptor.depthAttachment.clearDepth = attachmentInfo.clearDepth;
|
||||
} else {
|
||||
@ -110,7 +110,7 @@ namespace dawn_native { namespace metal {
|
||||
descriptor.stencilAttachment.texture = texture;
|
||||
descriptor.stencilAttachment.storeAction = MTLStoreActionStore;
|
||||
|
||||
if (attachmentInfo.stencilLoadOp == dawn::LoadOp::Clear) {
|
||||
if (attachmentInfo.stencilLoadOp == wgpu::LoadOp::Clear) {
|
||||
descriptor.stencilAttachment.loadAction = MTLLoadActionClear;
|
||||
descriptor.stencilAttachment.clearStencil = attachmentInfo.clearStencil;
|
||||
} 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
|
||||
// needed for a draw or a dispatch.
|
||||
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
|
||||
// MSL code generated by SPIRV-Cross expects.
|
||||
PerStage<std::array<uint32_t, kGenericMetalBufferSlots>> data;
|
||||
|
||||
void Apply(id<MTLRenderCommandEncoder> render, RenderPipeline* pipeline) {
|
||||
dawn::ShaderStage stagesToApply =
|
||||
wgpu::ShaderStage stagesToApply =
|
||||
dirtyStages & pipeline->GetStagesRequiringStorageBufferLength();
|
||||
|
||||
if (stagesToApply == dawn::ShaderStage::None) {
|
||||
if (stagesToApply == wgpu::ShaderStage::None) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (stagesToApply & dawn::ShaderStage::Vertex) {
|
||||
if (stagesToApply & wgpu::ShaderStage::Vertex) {
|
||||
uint32_t bufferCount = ToBackend(pipeline->GetLayout())
|
||||
->GetBufferBindingCount(SingleShaderStage::Vertex);
|
||||
[render setVertexBytes:data[SingleShaderStage::Vertex].data()
|
||||
@ -223,7 +223,7 @@ namespace dawn_native { namespace metal {
|
||||
atIndex:kBufferLengthBufferSlot];
|
||||
}
|
||||
|
||||
if (stagesToApply & dawn::ShaderStage::Fragment) {
|
||||
if (stagesToApply & wgpu::ShaderStage::Fragment) {
|
||||
uint32_t bufferCount = ToBackend(pipeline->GetLayout())
|
||||
->GetBufferBindingCount(SingleShaderStage::Fragment);
|
||||
[render setFragmentBytes:data[SingleShaderStage::Fragment].data()
|
||||
@ -236,7 +236,7 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
|
||||
void Apply(id<MTLComputeCommandEncoder> compute, ComputePipeline* pipeline) {
|
||||
if (!(dirtyStages & dawn::ShaderStage::Compute)) {
|
||||
if (!(dirtyStages & wgpu::ShaderStage::Compute)) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -250,7 +250,7 @@ namespace dawn_native { namespace metal {
|
||||
length:sizeof(uint32_t) * bufferCount
|
||||
atIndex:kBufferLengthBufferSlot];
|
||||
|
||||
dirtyStages ^= dawn::ShaderStage::Compute;
|
||||
dirtyStages ^= wgpu::ShaderStage::Compute;
|
||||
}
|
||||
};
|
||||
|
||||
@ -430,9 +430,9 @@ namespace dawn_native { namespace metal {
|
||||
// call here.
|
||||
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
|
||||
auto stage = layout.visibilities[bindingIndex];
|
||||
bool hasVertStage = stage & dawn::ShaderStage::Vertex && render != nil;
|
||||
bool hasFragStage = stage & dawn::ShaderStage::Fragment && render != nil;
|
||||
bool hasComputeStage = stage & dawn::ShaderStage::Compute && compute != nil;
|
||||
bool hasVertStage = stage & wgpu::ShaderStage::Vertex && render != nil;
|
||||
bool hasFragStage = stage & wgpu::ShaderStage::Fragment && render != nil;
|
||||
bool hasComputeStage = stage & wgpu::ShaderStage::Compute && compute != nil;
|
||||
|
||||
uint32_t vertIndex = 0;
|
||||
uint32_t fragIndex = 0;
|
||||
@ -452,8 +452,8 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
|
||||
switch (layout.types[bindingIndex]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case dawn::BindingType::StorageBuffer: {
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::StorageBuffer: {
|
||||
const BufferBinding& binding =
|
||||
group->GetBindingAsBufferBinding(bindingIndex);
|
||||
const id<MTLBuffer> buffer = ToBackend(binding.buffer)->GetMTLBuffer();
|
||||
@ -469,7 +469,7 @@ namespace dawn_native { namespace metal {
|
||||
if (hasVertStage) {
|
||||
mLengthTracker->data[SingleShaderStage::Vertex][vertIndex] =
|
||||
binding.size;
|
||||
mLengthTracker->dirtyStages |= dawn::ShaderStage::Vertex;
|
||||
mLengthTracker->dirtyStages |= wgpu::ShaderStage::Vertex;
|
||||
[render setVertexBuffers:&buffer
|
||||
offsets:&offset
|
||||
withRange:NSMakeRange(vertIndex, 1)];
|
||||
@ -477,7 +477,7 @@ namespace dawn_native { namespace metal {
|
||||
if (hasFragStage) {
|
||||
mLengthTracker->data[SingleShaderStage::Fragment][fragIndex] =
|
||||
binding.size;
|
||||
mLengthTracker->dirtyStages |= dawn::ShaderStage::Fragment;
|
||||
mLengthTracker->dirtyStages |= wgpu::ShaderStage::Fragment;
|
||||
[render setFragmentBuffers:&buffer
|
||||
offsets:&offset
|
||||
withRange:NSMakeRange(fragIndex, 1)];
|
||||
@ -485,7 +485,7 @@ namespace dawn_native { namespace metal {
|
||||
if (hasComputeStage) {
|
||||
mLengthTracker->data[SingleShaderStage::Compute][computeIndex] =
|
||||
binding.size;
|
||||
mLengthTracker->dirtyStages |= dawn::ShaderStage::Compute;
|
||||
mLengthTracker->dirtyStages |= wgpu::ShaderStage::Compute;
|
||||
[compute setBuffers:&buffer
|
||||
offsets:&offset
|
||||
withRange:NSMakeRange(computeIndex, 1)];
|
||||
@ -493,7 +493,7 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::Sampler: {
|
||||
case wgpu::BindingType::Sampler: {
|
||||
auto sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
|
||||
if (hasVertStage) {
|
||||
[render setVertexSamplerState:sampler->GetMTLSamplerState()
|
||||
@ -509,7 +509,7 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::SampledTexture: {
|
||||
case wgpu::BindingType::SampledTexture: {
|
||||
auto textureView =
|
||||
ToBackend(group->GetBindingAsTextureView(bindingIndex));
|
||||
if (hasVertStage) {
|
||||
@ -526,8 +526,8 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
|
@ -33,7 +33,7 @@ namespace dawn_native { namespace metal {
|
||||
[mtlDevice newComputePipelineStateWithFunction:computeData.function error:&error];
|
||||
if (error != nil) {
|
||||
NSLog(@" error => %@", error);
|
||||
GetDevice()->HandleError(dawn::ErrorType::DeviceLost, "Error creating pipeline state");
|
||||
GetDevice()->HandleError(wgpu::ErrorType::DeviceLost, "Error creating pipeline state");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -39,21 +39,21 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
|
||||
switch (groupInfo.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
mIndexInfo[stage][group][binding] = bufferIndex;
|
||||
bufferIndex++;
|
||||
break;
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
mIndexInfo[stage][group][binding] = samplerIndex;
|
||||
samplerIndex++;
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
mIndexInfo[stage][group][binding] = textureIndex;
|
||||
textureIndex++;
|
||||
break;
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ namespace dawn_native { namespace metal {
|
||||
// vertex buffer table.
|
||||
uint32_t GetMtlVertexBufferIndex(uint32_t dawnIndex) const;
|
||||
|
||||
dawn::ShaderStage GetStagesRequiringStorageBufferLength() const;
|
||||
wgpu::ShaderStage GetStagesRequiringStorageBufferLength() const;
|
||||
|
||||
private:
|
||||
MTLVertexDescriptor* MakeVertexDesc();
|
||||
@ -54,7 +54,7 @@ namespace dawn_native { namespace metal {
|
||||
id<MTLDepthStencilState> mMtlDepthStencilState = nil;
|
||||
std::array<uint32_t, kMaxVertexBuffers> mMtlVertexBufferIndices;
|
||||
|
||||
dawn::ShaderStage mStagesRequiringStorageBufferLength = dawn::ShaderStage::None;
|
||||
wgpu::ShaderStage mStagesRequiringStorageBufferLength = wgpu::ShaderStage::None;
|
||||
};
|
||||
|
||||
}} // namespace dawn_native::metal
|
||||
|
@ -23,166 +23,166 @@
|
||||
namespace dawn_native { namespace metal {
|
||||
|
||||
namespace {
|
||||
MTLVertexFormat VertexFormatType(dawn::VertexFormat format) {
|
||||
MTLVertexFormat VertexFormatType(wgpu::VertexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::VertexFormat::UChar2:
|
||||
case wgpu::VertexFormat::UChar2:
|
||||
return MTLVertexFormatUChar2;
|
||||
case dawn::VertexFormat::UChar4:
|
||||
case wgpu::VertexFormat::UChar4:
|
||||
return MTLVertexFormatUChar4;
|
||||
case dawn::VertexFormat::Char2:
|
||||
case wgpu::VertexFormat::Char2:
|
||||
return MTLVertexFormatChar2;
|
||||
case dawn::VertexFormat::Char4:
|
||||
case wgpu::VertexFormat::Char4:
|
||||
return MTLVertexFormatChar4;
|
||||
case dawn::VertexFormat::UChar2Norm:
|
||||
case wgpu::VertexFormat::UChar2Norm:
|
||||
return MTLVertexFormatUChar2Normalized;
|
||||
case dawn::VertexFormat::UChar4Norm:
|
||||
case wgpu::VertexFormat::UChar4Norm:
|
||||
return MTLVertexFormatUChar4Normalized;
|
||||
case dawn::VertexFormat::Char2Norm:
|
||||
case wgpu::VertexFormat::Char2Norm:
|
||||
return MTLVertexFormatChar2Normalized;
|
||||
case dawn::VertexFormat::Char4Norm:
|
||||
case wgpu::VertexFormat::Char4Norm:
|
||||
return MTLVertexFormatChar4Normalized;
|
||||
case dawn::VertexFormat::UShort2:
|
||||
case wgpu::VertexFormat::UShort2:
|
||||
return MTLVertexFormatUShort2;
|
||||
case dawn::VertexFormat::UShort4:
|
||||
case wgpu::VertexFormat::UShort4:
|
||||
return MTLVertexFormatUShort4;
|
||||
case dawn::VertexFormat::Short2:
|
||||
case wgpu::VertexFormat::Short2:
|
||||
return MTLVertexFormatShort2;
|
||||
case dawn::VertexFormat::Short4:
|
||||
case wgpu::VertexFormat::Short4:
|
||||
return MTLVertexFormatShort4;
|
||||
case dawn::VertexFormat::UShort2Norm:
|
||||
case wgpu::VertexFormat::UShort2Norm:
|
||||
return MTLVertexFormatUShort2Normalized;
|
||||
case dawn::VertexFormat::UShort4Norm:
|
||||
case wgpu::VertexFormat::UShort4Norm:
|
||||
return MTLVertexFormatUShort4Normalized;
|
||||
case dawn::VertexFormat::Short2Norm:
|
||||
case wgpu::VertexFormat::Short2Norm:
|
||||
return MTLVertexFormatShort2Normalized;
|
||||
case dawn::VertexFormat::Short4Norm:
|
||||
case wgpu::VertexFormat::Short4Norm:
|
||||
return MTLVertexFormatShort4Normalized;
|
||||
case dawn::VertexFormat::Half2:
|
||||
case wgpu::VertexFormat::Half2:
|
||||
return MTLVertexFormatHalf2;
|
||||
case dawn::VertexFormat::Half4:
|
||||
case wgpu::VertexFormat::Half4:
|
||||
return MTLVertexFormatHalf4;
|
||||
case dawn::VertexFormat::Float:
|
||||
case wgpu::VertexFormat::Float:
|
||||
return MTLVertexFormatFloat;
|
||||
case dawn::VertexFormat::Float2:
|
||||
case wgpu::VertexFormat::Float2:
|
||||
return MTLVertexFormatFloat2;
|
||||
case dawn::VertexFormat::Float3:
|
||||
case wgpu::VertexFormat::Float3:
|
||||
return MTLVertexFormatFloat3;
|
||||
case dawn::VertexFormat::Float4:
|
||||
case wgpu::VertexFormat::Float4:
|
||||
return MTLVertexFormatFloat4;
|
||||
case dawn::VertexFormat::UInt:
|
||||
case wgpu::VertexFormat::UInt:
|
||||
return MTLVertexFormatUInt;
|
||||
case dawn::VertexFormat::UInt2:
|
||||
case wgpu::VertexFormat::UInt2:
|
||||
return MTLVertexFormatUInt2;
|
||||
case dawn::VertexFormat::UInt3:
|
||||
case wgpu::VertexFormat::UInt3:
|
||||
return MTLVertexFormatUInt3;
|
||||
case dawn::VertexFormat::UInt4:
|
||||
case wgpu::VertexFormat::UInt4:
|
||||
return MTLVertexFormatUInt4;
|
||||
case dawn::VertexFormat::Int:
|
||||
case wgpu::VertexFormat::Int:
|
||||
return MTLVertexFormatInt;
|
||||
case dawn::VertexFormat::Int2:
|
||||
case wgpu::VertexFormat::Int2:
|
||||
return MTLVertexFormatInt2;
|
||||
case dawn::VertexFormat::Int3:
|
||||
case wgpu::VertexFormat::Int3:
|
||||
return MTLVertexFormatInt3;
|
||||
case dawn::VertexFormat::Int4:
|
||||
case wgpu::VertexFormat::Int4:
|
||||
return MTLVertexFormatInt4;
|
||||
}
|
||||
}
|
||||
|
||||
MTLVertexStepFunction InputStepModeFunction(dawn::InputStepMode mode) {
|
||||
MTLVertexStepFunction InputStepModeFunction(wgpu::InputStepMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::InputStepMode::Vertex:
|
||||
case wgpu::InputStepMode::Vertex:
|
||||
return MTLVertexStepFunctionPerVertex;
|
||||
case dawn::InputStepMode::Instance:
|
||||
case wgpu::InputStepMode::Instance:
|
||||
return MTLVertexStepFunctionPerInstance;
|
||||
}
|
||||
}
|
||||
|
||||
MTLPrimitiveType MTLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
|
||||
MTLPrimitiveType MTLPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) {
|
||||
switch (primitiveTopology) {
|
||||
case dawn::PrimitiveTopology::PointList:
|
||||
case wgpu::PrimitiveTopology::PointList:
|
||||
return MTLPrimitiveTypePoint;
|
||||
case dawn::PrimitiveTopology::LineList:
|
||||
case wgpu::PrimitiveTopology::LineList:
|
||||
return MTLPrimitiveTypeLine;
|
||||
case dawn::PrimitiveTopology::LineStrip:
|
||||
case wgpu::PrimitiveTopology::LineStrip:
|
||||
return MTLPrimitiveTypeLineStrip;
|
||||
case dawn::PrimitiveTopology::TriangleList:
|
||||
case wgpu::PrimitiveTopology::TriangleList:
|
||||
return MTLPrimitiveTypeTriangle;
|
||||
case dawn::PrimitiveTopology::TriangleStrip:
|
||||
case wgpu::PrimitiveTopology::TriangleStrip:
|
||||
return MTLPrimitiveTypeTriangleStrip;
|
||||
}
|
||||
}
|
||||
|
||||
MTLPrimitiveTopologyClass MTLInputPrimitiveTopology(
|
||||
dawn::PrimitiveTopology primitiveTopology) {
|
||||
wgpu::PrimitiveTopology primitiveTopology) {
|
||||
switch (primitiveTopology) {
|
||||
case dawn::PrimitiveTopology::PointList:
|
||||
case wgpu::PrimitiveTopology::PointList:
|
||||
return MTLPrimitiveTopologyClassPoint;
|
||||
case dawn::PrimitiveTopology::LineList:
|
||||
case dawn::PrimitiveTopology::LineStrip:
|
||||
case wgpu::PrimitiveTopology::LineList:
|
||||
case wgpu::PrimitiveTopology::LineStrip:
|
||||
return MTLPrimitiveTopologyClassLine;
|
||||
case dawn::PrimitiveTopology::TriangleList:
|
||||
case dawn::PrimitiveTopology::TriangleStrip:
|
||||
case wgpu::PrimitiveTopology::TriangleList:
|
||||
case wgpu::PrimitiveTopology::TriangleStrip:
|
||||
return MTLPrimitiveTopologyClassTriangle;
|
||||
}
|
||||
}
|
||||
|
||||
MTLIndexType MTLIndexFormat(dawn::IndexFormat format) {
|
||||
MTLIndexType MTLIndexFormat(wgpu::IndexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::IndexFormat::Uint16:
|
||||
case wgpu::IndexFormat::Uint16:
|
||||
return MTLIndexTypeUInt16;
|
||||
case dawn::IndexFormat::Uint32:
|
||||
case wgpu::IndexFormat::Uint32:
|
||||
return MTLIndexTypeUInt32;
|
||||
}
|
||||
}
|
||||
|
||||
MTLBlendFactor MetalBlendFactor(dawn::BlendFactor factor, bool alpha) {
|
||||
MTLBlendFactor MetalBlendFactor(wgpu::BlendFactor factor, bool alpha) {
|
||||
switch (factor) {
|
||||
case dawn::BlendFactor::Zero:
|
||||
case wgpu::BlendFactor::Zero:
|
||||
return MTLBlendFactorZero;
|
||||
case dawn::BlendFactor::One:
|
||||
case wgpu::BlendFactor::One:
|
||||
return MTLBlendFactorOne;
|
||||
case dawn::BlendFactor::SrcColor:
|
||||
case wgpu::BlendFactor::SrcColor:
|
||||
return MTLBlendFactorSourceColor;
|
||||
case dawn::BlendFactor::OneMinusSrcColor:
|
||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
||||
return MTLBlendFactorOneMinusSourceColor;
|
||||
case dawn::BlendFactor::SrcAlpha:
|
||||
case wgpu::BlendFactor::SrcAlpha:
|
||||
return MTLBlendFactorSourceAlpha;
|
||||
case dawn::BlendFactor::OneMinusSrcAlpha:
|
||||
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
||||
return MTLBlendFactorOneMinusSourceAlpha;
|
||||
case dawn::BlendFactor::DstColor:
|
||||
case wgpu::BlendFactor::DstColor:
|
||||
return MTLBlendFactorDestinationColor;
|
||||
case dawn::BlendFactor::OneMinusDstColor:
|
||||
case wgpu::BlendFactor::OneMinusDstColor:
|
||||
return MTLBlendFactorOneMinusDestinationColor;
|
||||
case dawn::BlendFactor::DstAlpha:
|
||||
case wgpu::BlendFactor::DstAlpha:
|
||||
return MTLBlendFactorDestinationAlpha;
|
||||
case dawn::BlendFactor::OneMinusDstAlpha:
|
||||
case wgpu::BlendFactor::OneMinusDstAlpha:
|
||||
return MTLBlendFactorOneMinusDestinationAlpha;
|
||||
case dawn::BlendFactor::SrcAlphaSaturated:
|
||||
case wgpu::BlendFactor::SrcAlphaSaturated:
|
||||
return MTLBlendFactorSourceAlphaSaturated;
|
||||
case dawn::BlendFactor::BlendColor:
|
||||
case wgpu::BlendFactor::BlendColor:
|
||||
return alpha ? MTLBlendFactorBlendAlpha : MTLBlendFactorBlendColor;
|
||||
case dawn::BlendFactor::OneMinusBlendColor:
|
||||
case wgpu::BlendFactor::OneMinusBlendColor:
|
||||
return alpha ? MTLBlendFactorOneMinusBlendAlpha
|
||||
: MTLBlendFactorOneMinusBlendColor;
|
||||
}
|
||||
}
|
||||
|
||||
MTLBlendOperation MetalBlendOperation(dawn::BlendOperation operation) {
|
||||
MTLBlendOperation MetalBlendOperation(wgpu::BlendOperation operation) {
|
||||
switch (operation) {
|
||||
case dawn::BlendOperation::Add:
|
||||
case wgpu::BlendOperation::Add:
|
||||
return MTLBlendOperationAdd;
|
||||
case dawn::BlendOperation::Subtract:
|
||||
case wgpu::BlendOperation::Subtract:
|
||||
return MTLBlendOperationSubtract;
|
||||
case dawn::BlendOperation::ReverseSubtract:
|
||||
case wgpu::BlendOperation::ReverseSubtract:
|
||||
return MTLBlendOperationReverseSubtract;
|
||||
case dawn::BlendOperation::Min:
|
||||
case wgpu::BlendOperation::Min:
|
||||
return MTLBlendOperationMin;
|
||||
case dawn::BlendOperation::Max:
|
||||
case wgpu::BlendOperation::Max:
|
||||
return MTLBlendOperationMax;
|
||||
}
|
||||
}
|
||||
|
||||
MTLColorWriteMask MetalColorWriteMask(dawn::ColorWriteMask writeMask,
|
||||
MTLColorWriteMask MetalColorWriteMask(wgpu::ColorWriteMask writeMask,
|
||||
bool isDeclaredInFragmentShader) {
|
||||
if (!isDeclaredInFragmentShader) {
|
||||
return MTLColorWriteMaskNone;
|
||||
@ -190,16 +190,16 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
MTLColorWriteMask mask = MTLColorWriteMaskNone;
|
||||
|
||||
if (writeMask & dawn::ColorWriteMask::Red) {
|
||||
if (writeMask & wgpu::ColorWriteMask::Red) {
|
||||
mask |= MTLColorWriteMaskRed;
|
||||
}
|
||||
if (writeMask & dawn::ColorWriteMask::Green) {
|
||||
if (writeMask & wgpu::ColorWriteMask::Green) {
|
||||
mask |= MTLColorWriteMaskGreen;
|
||||
}
|
||||
if (writeMask & dawn::ColorWriteMask::Blue) {
|
||||
if (writeMask & wgpu::ColorWriteMask::Blue) {
|
||||
mask |= MTLColorWriteMaskBlue;
|
||||
}
|
||||
if (writeMask & dawn::ColorWriteMask::Alpha) {
|
||||
if (writeMask & wgpu::ColorWriteMask::Alpha) {
|
||||
mask |= MTLColorWriteMaskAlpha;
|
||||
}
|
||||
|
||||
@ -224,23 +224,23 @@ namespace dawn_native { namespace metal {
|
||||
MetalColorWriteMask(descriptor->writeMask, isDeclaredInFragmentShader);
|
||||
}
|
||||
|
||||
MTLStencilOperation MetalStencilOperation(dawn::StencilOperation stencilOperation) {
|
||||
MTLStencilOperation MetalStencilOperation(wgpu::StencilOperation stencilOperation) {
|
||||
switch (stencilOperation) {
|
||||
case dawn::StencilOperation::Keep:
|
||||
case wgpu::StencilOperation::Keep:
|
||||
return MTLStencilOperationKeep;
|
||||
case dawn::StencilOperation::Zero:
|
||||
case wgpu::StencilOperation::Zero:
|
||||
return MTLStencilOperationZero;
|
||||
case dawn::StencilOperation::Replace:
|
||||
case wgpu::StencilOperation::Replace:
|
||||
return MTLStencilOperationReplace;
|
||||
case dawn::StencilOperation::Invert:
|
||||
case wgpu::StencilOperation::Invert:
|
||||
return MTLStencilOperationInvert;
|
||||
case dawn::StencilOperation::IncrementClamp:
|
||||
case wgpu::StencilOperation::IncrementClamp:
|
||||
return MTLStencilOperationIncrementClamp;
|
||||
case dawn::StencilOperation::DecrementClamp:
|
||||
case wgpu::StencilOperation::DecrementClamp:
|
||||
return MTLStencilOperationDecrementClamp;
|
||||
case dawn::StencilOperation::IncrementWrap:
|
||||
case wgpu::StencilOperation::IncrementWrap:
|
||||
return MTLStencilOperationIncrementWrap;
|
||||
case dawn::StencilOperation::DecrementWrap:
|
||||
case wgpu::StencilOperation::DecrementWrap:
|
||||
return MTLStencilOperationDecrementWrap;
|
||||
}
|
||||
}
|
||||
@ -289,22 +289,22 @@ namespace dawn_native { namespace metal {
|
||||
return mtlDepthStencilDescriptor;
|
||||
}
|
||||
|
||||
MTLWinding MTLFrontFace(dawn::FrontFace face) {
|
||||
MTLWinding MTLFrontFace(wgpu::FrontFace face) {
|
||||
switch (face) {
|
||||
case dawn::FrontFace::CW:
|
||||
case wgpu::FrontFace::CW:
|
||||
return MTLWindingClockwise;
|
||||
case dawn::FrontFace::CCW:
|
||||
case wgpu::FrontFace::CCW:
|
||||
return MTLWindingCounterClockwise;
|
||||
}
|
||||
}
|
||||
|
||||
MTLCullMode ToMTLCullMode(dawn::CullMode mode) {
|
||||
MTLCullMode ToMTLCullMode(wgpu::CullMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::CullMode::None:
|
||||
case wgpu::CullMode::None:
|
||||
return MTLCullModeNone;
|
||||
case dawn::CullMode::Front:
|
||||
case wgpu::CullMode::Front:
|
||||
return MTLCullModeFront;
|
||||
case dawn::CullMode::Back:
|
||||
case wgpu::CullMode::Back:
|
||||
return MTLCullModeBack;
|
||||
}
|
||||
}
|
||||
@ -327,7 +327,7 @@ namespace dawn_native { namespace metal {
|
||||
vertexEntryPoint, SingleShaderStage::Vertex, ToBackend(GetLayout()));
|
||||
descriptorMTL.vertexFunction = vertexData.function;
|
||||
if (vertexData.needsStorageBufferLength) {
|
||||
mStagesRequiringStorageBufferLength |= dawn::ShaderStage::Vertex;
|
||||
mStagesRequiringStorageBufferLength |= wgpu::ShaderStage::Vertex;
|
||||
}
|
||||
|
||||
const ShaderModule* fragmentModule = ToBackend(descriptor->fragmentStage->module);
|
||||
@ -336,12 +336,12 @@ namespace dawn_native { namespace metal {
|
||||
fragmentEntryPoint, SingleShaderStage::Fragment, ToBackend(GetLayout()));
|
||||
descriptorMTL.fragmentFunction = fragmentData.function;
|
||||
if (fragmentData.needsStorageBufferLength) {
|
||||
mStagesRequiringStorageBufferLength |= dawn::ShaderStage::Fragment;
|
||||
mStagesRequiringStorageBufferLength |= wgpu::ShaderStage::Fragment;
|
||||
}
|
||||
|
||||
if (HasDepthStencilAttachment()) {
|
||||
// TODO(kainino@chromium.org): Handle depth-only and stencil-only formats.
|
||||
dawn::TextureFormat depthStencilFormat = GetDepthStencilFormat();
|
||||
wgpu::TextureFormat depthStencilFormat = GetDepthStencilFormat();
|
||||
descriptorMTL.depthAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
|
||||
descriptorMTL.stencilAttachmentPixelFormat = MetalPixelFormat(depthStencilFormat);
|
||||
}
|
||||
@ -372,7 +372,7 @@ namespace dawn_native { namespace metal {
|
||||
[descriptorMTL release];
|
||||
if (error != nil) {
|
||||
NSLog(@" error => %@", error);
|
||||
device->HandleError(dawn::ErrorType::DeviceLost,
|
||||
device->HandleError(wgpu::ErrorType::DeviceLost,
|
||||
"Error creating rendering pipeline state");
|
||||
return;
|
||||
}
|
||||
@ -421,7 +421,7 @@ namespace dawn_native { namespace metal {
|
||||
return mMtlVertexBufferIndices[dawnIndex];
|
||||
}
|
||||
|
||||
dawn::ShaderStage RenderPipeline::GetStagesRequiringStorageBufferLength() const {
|
||||
wgpu::ShaderStage RenderPipeline::GetStagesRequiringStorageBufferLength() const {
|
||||
return mStagesRequiringStorageBufferLength;
|
||||
}
|
||||
|
||||
|
@ -20,31 +20,31 @@
|
||||
namespace dawn_native { namespace metal {
|
||||
|
||||
namespace {
|
||||
MTLSamplerMinMagFilter FilterModeToMinMagFilter(dawn::FilterMode mode) {
|
||||
MTLSamplerMinMagFilter FilterModeToMinMagFilter(wgpu::FilterMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
return MTLSamplerMinMagFilterNearest;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
return MTLSamplerMinMagFilterLinear;
|
||||
}
|
||||
}
|
||||
|
||||
MTLSamplerMipFilter FilterModeToMipFilter(dawn::FilterMode mode) {
|
||||
MTLSamplerMipFilter FilterModeToMipFilter(wgpu::FilterMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
return MTLSamplerMipFilterNearest;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
return MTLSamplerMipFilterLinear;
|
||||
}
|
||||
}
|
||||
|
||||
MTLSamplerAddressMode AddressMode(dawn::AddressMode mode) {
|
||||
MTLSamplerAddressMode AddressMode(wgpu::AddressMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::AddressMode::Repeat:
|
||||
case wgpu::AddressMode::Repeat:
|
||||
return MTLSamplerAddressModeRepeat;
|
||||
case dawn::AddressMode::MirrorRepeat:
|
||||
case wgpu::AddressMode::MirrorRepeat:
|
||||
return MTLSamplerAddressModeMirrorRepeat;
|
||||
case dawn::AddressMode::ClampToEdge:
|
||||
case wgpu::AddressMode::ClampToEdge:
|
||||
return MTLSamplerAddressModeClampToEdge;
|
||||
}
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ namespace dawn_native { namespace metal {
|
||||
DawnSwapChainNextTexture next = {};
|
||||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(dawn::ErrorType::Unknown, error);
|
||||
GetDevice()->HandleError(wgpu::ErrorType::Unknown, error);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace dawn_native { namespace metal {
|
||||
|
||||
class Device;
|
||||
|
||||
MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format);
|
||||
MTLPixelFormat MetalPixelFormat(wgpu::TextureFormat format);
|
||||
MaybeError ValidateIOSurfaceCanBeWrapped(const DeviceBase* device,
|
||||
const TextureDescriptor* descriptor,
|
||||
IOSurfaceRef ioSurface,
|
||||
|
@ -20,24 +20,24 @@
|
||||
namespace dawn_native { namespace metal {
|
||||
|
||||
namespace {
|
||||
bool UsageNeedsTextureView(dawn::TextureUsage usage) {
|
||||
constexpr dawn::TextureUsage kUsageNeedsTextureView =
|
||||
dawn::TextureUsage::Storage | dawn::TextureUsage::Sampled;
|
||||
bool UsageNeedsTextureView(wgpu::TextureUsage usage) {
|
||||
constexpr wgpu::TextureUsage kUsageNeedsTextureView =
|
||||
wgpu::TextureUsage::Storage | wgpu::TextureUsage::Sampled;
|
||||
return usage & kUsageNeedsTextureView;
|
||||
}
|
||||
|
||||
MTLTextureUsage MetalTextureUsage(dawn::TextureUsage usage) {
|
||||
MTLTextureUsage MetalTextureUsage(wgpu::TextureUsage usage) {
|
||||
MTLTextureUsage result = MTLTextureUsageUnknown; // This is 0
|
||||
|
||||
if (usage & (dawn::TextureUsage::Storage)) {
|
||||
if (usage & (wgpu::TextureUsage::Storage)) {
|
||||
result |= MTLTextureUsageShaderWrite | MTLTextureUsageShaderRead;
|
||||
}
|
||||
|
||||
if (usage & (dawn::TextureUsage::Sampled)) {
|
||||
if (usage & (wgpu::TextureUsage::Sampled)) {
|
||||
result |= MTLTextureUsageShaderRead;
|
||||
}
|
||||
|
||||
if (usage & (dawn::TextureUsage::OutputAttachment)) {
|
||||
if (usage & (wgpu::TextureUsage::OutputAttachment)) {
|
||||
result |= MTLTextureUsageRenderTarget;
|
||||
}
|
||||
|
||||
@ -48,11 +48,11 @@ namespace dawn_native { namespace metal {
|
||||
return result;
|
||||
}
|
||||
|
||||
MTLTextureType MetalTextureType(dawn::TextureDimension dimension,
|
||||
MTLTextureType MetalTextureType(wgpu::TextureDimension dimension,
|
||||
unsigned int arrayLayers,
|
||||
unsigned int sampleCount) {
|
||||
switch (dimension) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
if (sampleCount > 1) {
|
||||
ASSERT(arrayLayers == 1);
|
||||
return MTLTextureType2DMultisample;
|
||||
@ -64,16 +64,16 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
}
|
||||
|
||||
MTLTextureType MetalTextureViewType(dawn::TextureViewDimension dimension,
|
||||
MTLTextureType MetalTextureViewType(wgpu::TextureViewDimension dimension,
|
||||
unsigned int sampleCount) {
|
||||
switch (dimension) {
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
return (sampleCount > 1) ? MTLTextureType2DMultisample : MTLTextureType2D;
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
return MTLTextureType2DArray;
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
return MTLTextureTypeCube;
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return MTLTextureTypeCubeArray;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -96,8 +96,8 @@ namespace dawn_native { namespace metal {
|
||||
}
|
||||
|
||||
switch (textureViewDescriptor->dimension) {
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
@ -106,16 +106,16 @@ namespace dawn_native { namespace metal {
|
||||
return false;
|
||||
}
|
||||
|
||||
ResultOrError<dawn::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t format) {
|
||||
ResultOrError<wgpu::TextureFormat> GetFormatEquivalentToIOSurfaceFormat(uint32_t format) {
|
||||
switch (format) {
|
||||
case 'RGBA':
|
||||
return dawn::TextureFormat::RGBA8Unorm;
|
||||
return wgpu::TextureFormat::RGBA8Unorm;
|
||||
case 'BGRA':
|
||||
return dawn::TextureFormat::BGRA8Unorm;
|
||||
return wgpu::TextureFormat::BGRA8Unorm;
|
||||
case '2C08':
|
||||
return dawn::TextureFormat::RG8Unorm;
|
||||
return wgpu::TextureFormat::RG8Unorm;
|
||||
case 'L008':
|
||||
return dawn::TextureFormat::R8Unorm;
|
||||
return wgpu::TextureFormat::R8Unorm;
|
||||
default:
|
||||
return DAWN_VALIDATION_ERROR("Unsupported IOSurface format");
|
||||
}
|
||||
@ -130,118 +130,118 @@ namespace dawn_native { namespace metal {
|
||||
#endif
|
||||
}
|
||||
|
||||
MTLPixelFormat MetalPixelFormat(dawn::TextureFormat format) {
|
||||
MTLPixelFormat MetalPixelFormat(wgpu::TextureFormat format) {
|
||||
switch (format) {
|
||||
case dawn::TextureFormat::R8Unorm:
|
||||
case wgpu::TextureFormat::R8Unorm:
|
||||
return MTLPixelFormatR8Unorm;
|
||||
case dawn::TextureFormat::R8Snorm:
|
||||
case wgpu::TextureFormat::R8Snorm:
|
||||
return MTLPixelFormatR8Snorm;
|
||||
case dawn::TextureFormat::R8Uint:
|
||||
case wgpu::TextureFormat::R8Uint:
|
||||
return MTLPixelFormatR8Uint;
|
||||
case dawn::TextureFormat::R8Sint:
|
||||
case wgpu::TextureFormat::R8Sint:
|
||||
return MTLPixelFormatR8Sint;
|
||||
|
||||
case dawn::TextureFormat::R16Uint:
|
||||
case wgpu::TextureFormat::R16Uint:
|
||||
return MTLPixelFormatR16Uint;
|
||||
case dawn::TextureFormat::R16Sint:
|
||||
case wgpu::TextureFormat::R16Sint:
|
||||
return MTLPixelFormatR16Sint;
|
||||
case dawn::TextureFormat::R16Float:
|
||||
case wgpu::TextureFormat::R16Float:
|
||||
return MTLPixelFormatR16Float;
|
||||
case dawn::TextureFormat::RG8Unorm:
|
||||
case wgpu::TextureFormat::RG8Unorm:
|
||||
return MTLPixelFormatRG8Unorm;
|
||||
case dawn::TextureFormat::RG8Snorm:
|
||||
case wgpu::TextureFormat::RG8Snorm:
|
||||
return MTLPixelFormatRG8Snorm;
|
||||
case dawn::TextureFormat::RG8Uint:
|
||||
case wgpu::TextureFormat::RG8Uint:
|
||||
return MTLPixelFormatRG8Uint;
|
||||
case dawn::TextureFormat::RG8Sint:
|
||||
case wgpu::TextureFormat::RG8Sint:
|
||||
return MTLPixelFormatRG8Sint;
|
||||
|
||||
case dawn::TextureFormat::R32Uint:
|
||||
case wgpu::TextureFormat::R32Uint:
|
||||
return MTLPixelFormatR32Uint;
|
||||
case dawn::TextureFormat::R32Sint:
|
||||
case wgpu::TextureFormat::R32Sint:
|
||||
return MTLPixelFormatR32Sint;
|
||||
case dawn::TextureFormat::R32Float:
|
||||
case wgpu::TextureFormat::R32Float:
|
||||
return MTLPixelFormatR32Float;
|
||||
case dawn::TextureFormat::RG16Uint:
|
||||
case wgpu::TextureFormat::RG16Uint:
|
||||
return MTLPixelFormatRG16Uint;
|
||||
case dawn::TextureFormat::RG16Sint:
|
||||
case wgpu::TextureFormat::RG16Sint:
|
||||
return MTLPixelFormatRG16Sint;
|
||||
case dawn::TextureFormat::RG16Float:
|
||||
case wgpu::TextureFormat::RG16Float:
|
||||
return MTLPixelFormatRG16Float;
|
||||
case dawn::TextureFormat::RGBA8Unorm:
|
||||
case wgpu::TextureFormat::RGBA8Unorm:
|
||||
return MTLPixelFormatRGBA8Unorm;
|
||||
case dawn::TextureFormat::RGBA8UnormSrgb:
|
||||
case wgpu::TextureFormat::RGBA8UnormSrgb:
|
||||
return MTLPixelFormatRGBA8Unorm_sRGB;
|
||||
case dawn::TextureFormat::RGBA8Snorm:
|
||||
case wgpu::TextureFormat::RGBA8Snorm:
|
||||
return MTLPixelFormatRGBA8Snorm;
|
||||
case dawn::TextureFormat::RGBA8Uint:
|
||||
case wgpu::TextureFormat::RGBA8Uint:
|
||||
return MTLPixelFormatRGBA8Uint;
|
||||
case dawn::TextureFormat::RGBA8Sint:
|
||||
case wgpu::TextureFormat::RGBA8Sint:
|
||||
return MTLPixelFormatRGBA8Sint;
|
||||
case dawn::TextureFormat::BGRA8Unorm:
|
||||
case wgpu::TextureFormat::BGRA8Unorm:
|
||||
return MTLPixelFormatBGRA8Unorm;
|
||||
case dawn::TextureFormat::BGRA8UnormSrgb:
|
||||
case wgpu::TextureFormat::BGRA8UnormSrgb:
|
||||
return MTLPixelFormatBGRA8Unorm_sRGB;
|
||||
case dawn::TextureFormat::RGB10A2Unorm:
|
||||
case wgpu::TextureFormat::RGB10A2Unorm:
|
||||
return MTLPixelFormatRGB10A2Unorm;
|
||||
case dawn::TextureFormat::RG11B10Float:
|
||||
case wgpu::TextureFormat::RG11B10Float:
|
||||
return MTLPixelFormatRG11B10Float;
|
||||
|
||||
case dawn::TextureFormat::RG32Uint:
|
||||
case wgpu::TextureFormat::RG32Uint:
|
||||
return MTLPixelFormatRG32Uint;
|
||||
case dawn::TextureFormat::RG32Sint:
|
||||
case wgpu::TextureFormat::RG32Sint:
|
||||
return MTLPixelFormatRG32Sint;
|
||||
case dawn::TextureFormat::RG32Float:
|
||||
case wgpu::TextureFormat::RG32Float:
|
||||
return MTLPixelFormatRG32Float;
|
||||
case dawn::TextureFormat::RGBA16Uint:
|
||||
case wgpu::TextureFormat::RGBA16Uint:
|
||||
return MTLPixelFormatRGBA16Uint;
|
||||
case dawn::TextureFormat::RGBA16Sint:
|
||||
case wgpu::TextureFormat::RGBA16Sint:
|
||||
return MTLPixelFormatRGBA16Sint;
|
||||
case dawn::TextureFormat::RGBA16Float:
|
||||
case wgpu::TextureFormat::RGBA16Float:
|
||||
return MTLPixelFormatRGBA16Float;
|
||||
|
||||
case dawn::TextureFormat::RGBA32Uint:
|
||||
case wgpu::TextureFormat::RGBA32Uint:
|
||||
return MTLPixelFormatRGBA32Uint;
|
||||
case dawn::TextureFormat::RGBA32Sint:
|
||||
case wgpu::TextureFormat::RGBA32Sint:
|
||||
return MTLPixelFormatRGBA32Sint;
|
||||
case dawn::TextureFormat::RGBA32Float:
|
||||
case wgpu::TextureFormat::RGBA32Float:
|
||||
return MTLPixelFormatRGBA32Float;
|
||||
|
||||
case dawn::TextureFormat::Depth32Float:
|
||||
case wgpu::TextureFormat::Depth32Float:
|
||||
return MTLPixelFormatDepth32Float;
|
||||
case dawn::TextureFormat::Depth24Plus:
|
||||
case wgpu::TextureFormat::Depth24Plus:
|
||||
return MTLPixelFormatDepth32Float;
|
||||
case dawn::TextureFormat::Depth24PlusStencil8:
|
||||
case wgpu::TextureFormat::Depth24PlusStencil8:
|
||||
return MTLPixelFormatDepth32Float_Stencil8;
|
||||
|
||||
#if defined(DAWN_PLATFORM_MACOS)
|
||||
case dawn::TextureFormat::BC1RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC1RGBAUnorm:
|
||||
return MTLPixelFormatBC1_RGBA;
|
||||
case dawn::TextureFormat::BC1RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC1RGBAUnormSrgb:
|
||||
return MTLPixelFormatBC1_RGBA_sRGB;
|
||||
case dawn::TextureFormat::BC2RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC2RGBAUnorm:
|
||||
return MTLPixelFormatBC2_RGBA;
|
||||
case dawn::TextureFormat::BC2RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC2RGBAUnormSrgb:
|
||||
return MTLPixelFormatBC2_RGBA_sRGB;
|
||||
case dawn::TextureFormat::BC3RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC3RGBAUnorm:
|
||||
return MTLPixelFormatBC3_RGBA;
|
||||
case dawn::TextureFormat::BC3RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC3RGBAUnormSrgb:
|
||||
return MTLPixelFormatBC3_RGBA_sRGB;
|
||||
case dawn::TextureFormat::BC4RSnorm:
|
||||
case wgpu::TextureFormat::BC4RSnorm:
|
||||
return MTLPixelFormatBC4_RSnorm;
|
||||
case dawn::TextureFormat::BC4RUnorm:
|
||||
case wgpu::TextureFormat::BC4RUnorm:
|
||||
return MTLPixelFormatBC4_RUnorm;
|
||||
case dawn::TextureFormat::BC5RGSnorm:
|
||||
case wgpu::TextureFormat::BC5RGSnorm:
|
||||
return MTLPixelFormatBC5_RGSnorm;
|
||||
case dawn::TextureFormat::BC5RGUnorm:
|
||||
case wgpu::TextureFormat::BC5RGUnorm:
|
||||
return MTLPixelFormatBC5_RGUnorm;
|
||||
case dawn::TextureFormat::BC6HRGBSfloat:
|
||||
case wgpu::TextureFormat::BC6HRGBSfloat:
|
||||
return MTLPixelFormatBC6H_RGBFloat;
|
||||
case dawn::TextureFormat::BC6HRGBUfloat:
|
||||
case wgpu::TextureFormat::BC6HRGBUfloat:
|
||||
return MTLPixelFormatBC6H_RGBUfloat;
|
||||
case dawn::TextureFormat::BC7RGBAUnorm:
|
||||
case wgpu::TextureFormat::BC7RGBAUnorm:
|
||||
return MTLPixelFormatBC7_RGBAUnorm;
|
||||
case dawn::TextureFormat::BC7RGBAUnormSrgb:
|
||||
case wgpu::TextureFormat::BC7RGBAUnormSrgb:
|
||||
return MTLPixelFormatBC7_RGBAUnorm_sRGB;
|
||||
#endif
|
||||
|
||||
@ -261,7 +261,7 @@ namespace dawn_native { namespace metal {
|
||||
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");
|
||||
}
|
||||
|
||||
@ -283,7 +283,7 @@ namespace dawn_native { namespace metal {
|
||||
return DAWN_VALIDATION_ERROR("IOSurface size doesn't match descriptor");
|
||||
}
|
||||
|
||||
dawn::TextureFormat ioSurfaceFormat;
|
||||
wgpu::TextureFormat ioSurfaceFormat;
|
||||
DAWN_TRY_ASSIGN(ioSurfaceFormat,
|
||||
GetFormatEquivalentToIOSurfaceFormat(IOSurfaceGetPixelFormat(ioSurface)));
|
||||
if (descriptor->format != ioSurfaceFormat) {
|
||||
|
@ -21,7 +21,7 @@
|
||||
|
||||
namespace dawn_native { namespace metal {
|
||||
|
||||
MTLCompareFunction ToMetalCompareFunction(dawn::CompareFunction compareFunction);
|
||||
MTLCompareFunction ToMetalCompareFunction(wgpu::CompareFunction compareFunction);
|
||||
|
||||
}} // namespace dawn_native::metal
|
||||
|
||||
|
@ -16,23 +16,23 @@
|
||||
|
||||
namespace dawn_native { namespace metal {
|
||||
|
||||
MTLCompareFunction ToMetalCompareFunction(dawn::CompareFunction compareFunction) {
|
||||
MTLCompareFunction ToMetalCompareFunction(wgpu::CompareFunction compareFunction) {
|
||||
switch (compareFunction) {
|
||||
case dawn::CompareFunction::Never:
|
||||
case wgpu::CompareFunction::Never:
|
||||
return MTLCompareFunctionNever;
|
||||
case dawn::CompareFunction::Less:
|
||||
case wgpu::CompareFunction::Less:
|
||||
return MTLCompareFunctionLess;
|
||||
case dawn::CompareFunction::LessEqual:
|
||||
case wgpu::CompareFunction::LessEqual:
|
||||
return MTLCompareFunctionLessEqual;
|
||||
case dawn::CompareFunction::Greater:
|
||||
case wgpu::CompareFunction::Greater:
|
||||
return MTLCompareFunctionGreater;
|
||||
case dawn::CompareFunction::GreaterEqual:
|
||||
case wgpu::CompareFunction::GreaterEqual:
|
||||
return MTLCompareFunctionGreaterEqual;
|
||||
case dawn::CompareFunction::NotEqual:
|
||||
case wgpu::CompareFunction::NotEqual:
|
||||
return MTLCompareFunctionNotEqual;
|
||||
case dawn::CompareFunction::Equal:
|
||||
case wgpu::CompareFunction::Equal:
|
||||
return MTLCompareFunctionEqual;
|
||||
case dawn::CompareFunction::Always:
|
||||
case wgpu::CompareFunction::Always:
|
||||
return MTLCompareFunctionAlways;
|
||||
}
|
||||
}
|
||||
|
@ -241,7 +241,7 @@ namespace dawn_native { namespace null {
|
||||
bool Buffer::IsMapWritable() const {
|
||||
// Only return true for mappable buffers so we can test cases that need / don't need a
|
||||
// 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) {
|
||||
@ -363,8 +363,8 @@ namespace dawn_native { namespace null {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
return dawn::TextureFormat::RGBA8Unorm;
|
||||
wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
return wgpu::TextureFormat::RGBA8Unorm;
|
||||
}
|
||||
|
||||
// StagingBuffer
|
||||
|
@ -214,7 +214,7 @@ namespace dawn_native { namespace null {
|
||||
uint32_t height);
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError Present();
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
wgpu::TextureFormat GetPreferredFormat() const;
|
||||
};
|
||||
|
||||
class StagingBuffer : public StagingBufferBase {
|
||||
|
@ -36,96 +36,96 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
namespace {
|
||||
|
||||
GLenum IndexFormatType(dawn::IndexFormat format) {
|
||||
GLenum IndexFormatType(wgpu::IndexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::IndexFormat::Uint16:
|
||||
case wgpu::IndexFormat::Uint16:
|
||||
return GL_UNSIGNED_SHORT;
|
||||
case dawn::IndexFormat::Uint32:
|
||||
case wgpu::IndexFormat::Uint32:
|
||||
return GL_UNSIGNED_INT;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
GLenum VertexFormatType(dawn::VertexFormat format) {
|
||||
GLenum VertexFormatType(wgpu::VertexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::VertexFormat::UChar2:
|
||||
case dawn::VertexFormat::UChar4:
|
||||
case dawn::VertexFormat::UChar2Norm:
|
||||
case dawn::VertexFormat::UChar4Norm:
|
||||
case wgpu::VertexFormat::UChar2:
|
||||
case wgpu::VertexFormat::UChar4:
|
||||
case wgpu::VertexFormat::UChar2Norm:
|
||||
case wgpu::VertexFormat::UChar4Norm:
|
||||
return GL_UNSIGNED_BYTE;
|
||||
case dawn::VertexFormat::Char2:
|
||||
case dawn::VertexFormat::Char4:
|
||||
case dawn::VertexFormat::Char2Norm:
|
||||
case dawn::VertexFormat::Char4Norm:
|
||||
case wgpu::VertexFormat::Char2:
|
||||
case wgpu::VertexFormat::Char4:
|
||||
case wgpu::VertexFormat::Char2Norm:
|
||||
case wgpu::VertexFormat::Char4Norm:
|
||||
return GL_BYTE;
|
||||
case dawn::VertexFormat::UShort2:
|
||||
case dawn::VertexFormat::UShort4:
|
||||
case dawn::VertexFormat::UShort2Norm:
|
||||
case dawn::VertexFormat::UShort4Norm:
|
||||
case wgpu::VertexFormat::UShort2:
|
||||
case wgpu::VertexFormat::UShort4:
|
||||
case wgpu::VertexFormat::UShort2Norm:
|
||||
case wgpu::VertexFormat::UShort4Norm:
|
||||
return GL_UNSIGNED_SHORT;
|
||||
case dawn::VertexFormat::Short2:
|
||||
case dawn::VertexFormat::Short4:
|
||||
case dawn::VertexFormat::Short2Norm:
|
||||
case dawn::VertexFormat::Short4Norm:
|
||||
case wgpu::VertexFormat::Short2:
|
||||
case wgpu::VertexFormat::Short4:
|
||||
case wgpu::VertexFormat::Short2Norm:
|
||||
case wgpu::VertexFormat::Short4Norm:
|
||||
return GL_SHORT;
|
||||
case dawn::VertexFormat::Half2:
|
||||
case dawn::VertexFormat::Half4:
|
||||
case wgpu::VertexFormat::Half2:
|
||||
case wgpu::VertexFormat::Half4:
|
||||
return GL_HALF_FLOAT;
|
||||
case dawn::VertexFormat::Float:
|
||||
case dawn::VertexFormat::Float2:
|
||||
case dawn::VertexFormat::Float3:
|
||||
case dawn::VertexFormat::Float4:
|
||||
case wgpu::VertexFormat::Float:
|
||||
case wgpu::VertexFormat::Float2:
|
||||
case wgpu::VertexFormat::Float3:
|
||||
case wgpu::VertexFormat::Float4:
|
||||
return GL_FLOAT;
|
||||
case dawn::VertexFormat::UInt:
|
||||
case dawn::VertexFormat::UInt2:
|
||||
case dawn::VertexFormat::UInt3:
|
||||
case dawn::VertexFormat::UInt4:
|
||||
case wgpu::VertexFormat::UInt:
|
||||
case wgpu::VertexFormat::UInt2:
|
||||
case wgpu::VertexFormat::UInt3:
|
||||
case wgpu::VertexFormat::UInt4:
|
||||
return GL_UNSIGNED_INT;
|
||||
case dawn::VertexFormat::Int:
|
||||
case dawn::VertexFormat::Int2:
|
||||
case dawn::VertexFormat::Int3:
|
||||
case dawn::VertexFormat::Int4:
|
||||
case wgpu::VertexFormat::Int:
|
||||
case wgpu::VertexFormat::Int2:
|
||||
case wgpu::VertexFormat::Int3:
|
||||
case wgpu::VertexFormat::Int4:
|
||||
return GL_INT;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
GLboolean VertexFormatIsNormalized(dawn::VertexFormat format) {
|
||||
GLboolean VertexFormatIsNormalized(wgpu::VertexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::VertexFormat::UChar2Norm:
|
||||
case dawn::VertexFormat::UChar4Norm:
|
||||
case dawn::VertexFormat::Char2Norm:
|
||||
case dawn::VertexFormat::Char4Norm:
|
||||
case dawn::VertexFormat::UShort2Norm:
|
||||
case dawn::VertexFormat::UShort4Norm:
|
||||
case dawn::VertexFormat::Short2Norm:
|
||||
case dawn::VertexFormat::Short4Norm:
|
||||
case wgpu::VertexFormat::UChar2Norm:
|
||||
case wgpu::VertexFormat::UChar4Norm:
|
||||
case wgpu::VertexFormat::Char2Norm:
|
||||
case wgpu::VertexFormat::Char4Norm:
|
||||
case wgpu::VertexFormat::UShort2Norm:
|
||||
case wgpu::VertexFormat::UShort4Norm:
|
||||
case wgpu::VertexFormat::Short2Norm:
|
||||
case wgpu::VertexFormat::Short4Norm:
|
||||
return GL_TRUE;
|
||||
default:
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
bool VertexFormatIsInt(dawn::VertexFormat format) {
|
||||
bool VertexFormatIsInt(wgpu::VertexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::VertexFormat::UChar2:
|
||||
case dawn::VertexFormat::UChar4:
|
||||
case dawn::VertexFormat::Char2:
|
||||
case dawn::VertexFormat::Char4:
|
||||
case dawn::VertexFormat::UShort2:
|
||||
case dawn::VertexFormat::UShort4:
|
||||
case dawn::VertexFormat::Short2:
|
||||
case dawn::VertexFormat::Short4:
|
||||
case dawn::VertexFormat::UInt:
|
||||
case dawn::VertexFormat::UInt2:
|
||||
case dawn::VertexFormat::UInt3:
|
||||
case dawn::VertexFormat::UInt4:
|
||||
case dawn::VertexFormat::Int:
|
||||
case dawn::VertexFormat::Int2:
|
||||
case dawn::VertexFormat::Int3:
|
||||
case dawn::VertexFormat::Int4:
|
||||
case wgpu::VertexFormat::UChar2:
|
||||
case wgpu::VertexFormat::UChar4:
|
||||
case wgpu::VertexFormat::Char2:
|
||||
case wgpu::VertexFormat::Char4:
|
||||
case wgpu::VertexFormat::UShort2:
|
||||
case wgpu::VertexFormat::UShort4:
|
||||
case wgpu::VertexFormat::Short2:
|
||||
case wgpu::VertexFormat::Short4:
|
||||
case wgpu::VertexFormat::UInt:
|
||||
case wgpu::VertexFormat::UInt2:
|
||||
case wgpu::VertexFormat::UInt3:
|
||||
case wgpu::VertexFormat::UInt4:
|
||||
case wgpu::VertexFormat::Int:
|
||||
case wgpu::VertexFormat::Int2:
|
||||
case wgpu::VertexFormat::Int3:
|
||||
case wgpu::VertexFormat::Int4:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
@ -242,7 +242,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
for (uint32_t bindingIndex : IterateBitSet(layout.mask)) {
|
||||
switch (layout.types[bindingIndex]) {
|
||||
case dawn::BindingType::UniformBuffer: {
|
||||
case wgpu::BindingType::UniformBuffer: {
|
||||
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||
GLuint buffer = ToBackend(binding.buffer)->GetHandle();
|
||||
GLuint uboIndex = indices[bindingIndex];
|
||||
@ -257,7 +257,7 @@ namespace dawn_native { namespace opengl {
|
||||
binding.size);
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::Sampler: {
|
||||
case wgpu::BindingType::Sampler: {
|
||||
Sampler* sampler = ToBackend(group->GetBindingAsSampler(bindingIndex));
|
||||
GLuint samplerIndex = indices[bindingIndex];
|
||||
|
||||
@ -273,7 +273,7 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::SampledTexture: {
|
||||
case wgpu::BindingType::SampledTexture: {
|
||||
TextureView* view =
|
||||
ToBackend(group->GetBindingAsTextureView(bindingIndex));
|
||||
GLuint handle = view->GetHandle();
|
||||
@ -286,7 +286,7 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageBuffer: {
|
||||
case wgpu::BindingType::StorageBuffer: {
|
||||
BufferBinding binding = group->GetBindingAsBufferBinding(bindingIndex);
|
||||
GLuint buffer = ToBackend(binding.buffer)->GetHandle();
|
||||
GLuint ssboIndex = indices[bindingIndex];
|
||||
@ -301,8 +301,8 @@ namespace dawn_native { namespace opengl {
|
||||
binding.size);
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
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
|
||||
// backdoor lazy clear counts in Vulkan and D3D12.
|
||||
bool isLazyClear =
|
||||
!(usages.textureUsages[i] & dawn::TextureUsage::OutputAttachment);
|
||||
!(usages.textureUsages[i] & wgpu::TextureUsage::OutputAttachment);
|
||||
texture->EnsureSubresourceContentInitialized(
|
||||
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_DEPTH, 1);
|
||||
|
||||
ASSERT(texture->GetDimension() == dawn::TextureDimension::e2D);
|
||||
ASSERT(texture->GetDimension() == wgpu::TextureDimension::e2D);
|
||||
uint64_t copyDataSize = (copySize.width / formatInfo.blockWidth) *
|
||||
(copySize.height / formatInfo.blockHeight) *
|
||||
formatInfo.blockByteSize;
|
||||
@ -503,7 +503,7 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
} else {
|
||||
switch (texture->GetDimension()) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
if (texture->GetArrayLayers() > 1) {
|
||||
gl.TexSubImage3D(target, dst.mipLevel, dst.origin.x,
|
||||
dst.origin.y, dst.arrayLayer, copySize.width,
|
||||
@ -556,7 +556,7 @@ namespace dawn_native { namespace opengl {
|
||||
gl.GenFramebuffers(1, &readFBO);
|
||||
gl.BindFramebuffer(GL_READ_FRAMEBUFFER, readFBO);
|
||||
switch (texture->GetDimension()) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
if (texture->GetArrayLayers() > 1) {
|
||||
gl.FramebufferTextureLayer(
|
||||
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
|
||||
// when that's fixed will lose precision on integer formats when converting to
|
||||
// float.
|
||||
if (attachmentInfo->loadOp == dawn::LoadOp::Clear) {
|
||||
if (attachmentInfo->loadOp == wgpu::LoadOp::Clear) {
|
||||
gl.ColorMaski(i, true, true, true, true);
|
||||
gl.ClearBufferfv(GL_COLOR, i, &attachmentInfo->clearColor.r);
|
||||
}
|
||||
|
||||
switch (attachmentInfo->storeOp) {
|
||||
case dawn::StoreOp::Store: {
|
||||
case wgpu::StoreOp::Store: {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
true, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount());
|
||||
} break;
|
||||
|
||||
case dawn::StoreOp::Clear: {
|
||||
case wgpu::StoreOp::Clear: {
|
||||
// TODO(natlee@microsoft.com): call glDiscard to do optimization
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
false, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
@ -817,9 +817,9 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
// Load op - depth/stencil
|
||||
bool doDepthClear = attachmentFormat.HasDepth() &&
|
||||
(attachmentInfo->depthLoadOp == dawn::LoadOp::Clear);
|
||||
(attachmentInfo->depthLoadOp == wgpu::LoadOp::Clear);
|
||||
bool doStencilClear = attachmentFormat.HasStencil() &&
|
||||
(attachmentInfo->stencilLoadOp == dawn::LoadOp::Clear);
|
||||
(attachmentInfo->stencilLoadOp == wgpu::LoadOp::Clear);
|
||||
|
||||
if (doDepthClear) {
|
||||
gl.DepthMask(GL_TRUE);
|
||||
@ -838,13 +838,13 @@ namespace dawn_native { namespace opengl {
|
||||
gl.ClearBufferiv(GL_STENCIL, 0, &clearStencil);
|
||||
}
|
||||
|
||||
if (attachmentInfo->depthStoreOp == dawn::StoreOp::Store &&
|
||||
attachmentInfo->stencilStoreOp == dawn::StoreOp::Store) {
|
||||
if (attachmentInfo->depthStoreOp == wgpu::StoreOp::Store &&
|
||||
attachmentInfo->stencilStoreOp == wgpu::StoreOp::Store) {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
true, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount());
|
||||
} else if (attachmentInfo->depthStoreOp == dawn::StoreOp::Clear &&
|
||||
attachmentInfo->stencilStoreOp == dawn::StoreOp::Clear) {
|
||||
} else if (attachmentInfo->depthStoreOp == wgpu::StoreOp::Clear &&
|
||||
attachmentInfo->stencilStoreOp == wgpu::StoreOp::Clear) {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
false, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount());
|
||||
@ -882,7 +882,7 @@ namespace dawn_native { namespace opengl {
|
||||
inputBuffers.Apply(gl);
|
||||
bindGroupTracker.Apply(gl);
|
||||
|
||||
dawn::IndexFormat indexFormat =
|
||||
wgpu::IndexFormat indexFormat =
|
||||
lastPipeline->GetVertexInputDescriptor()->indexFormat;
|
||||
size_t formatSize = IndexFormatSize(indexFormat);
|
||||
GLenum formatType = IndexFormatType(indexFormat);
|
||||
@ -922,7 +922,7 @@ namespace dawn_native { namespace opengl {
|
||||
inputBuffers.Apply(gl);
|
||||
bindGroupTracker.Apply(gl);
|
||||
|
||||
dawn::IndexFormat indexFormat =
|
||||
wgpu::IndexFormat indexFormat =
|
||||
lastPipeline->GetVertexInputDescriptor()->indexFormat;
|
||||
GLenum formatType = IndexFormatType(indexFormat);
|
||||
|
||||
|
@ -21,7 +21,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
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) {
|
||||
size_t index = ComputeFormatIndex(dawnFormat);
|
||||
ASSERT(index < table.size());
|
||||
@ -44,71 +44,71 @@ namespace dawn_native { namespace opengl {
|
||||
// clang-format off
|
||||
|
||||
// 1 byte color formats
|
||||
AddFormat(dawn::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(dawn::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::R8Unorm, GL_R8, GL_RED, GL_UNSIGNED_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::R8Snorm, GL_R8_SNORM, GL_RED, GL_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::R8Uint, GL_R8UI, GL_RED_INTEGER, GL_UNSIGNED_BYTE, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::R8Sint, GL_R8I, GL_RED_INTEGER, GL_BYTE, Type::Int);
|
||||
|
||||
// 2 bytes color formats
|
||||
AddFormat(dawn::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(dawn::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(dawn::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(dawn::TextureFormat::RG8Sint, GL_RG8I, GL_RG_INTEGER, GL_BYTE, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::R16Uint, GL_R16UI, GL_RED_INTEGER, GL_UNSIGNED_SHORT, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::R16Sint, GL_R16I, GL_RED_INTEGER, GL_SHORT, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::R16Float, GL_R16F, GL_RED, GL_HALF_FLOAT, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RG8Unorm, GL_RG8, GL_RG, GL_UNSIGNED_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RG8Snorm, GL_RG8_SNORM, GL_RG, GL_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RG8Uint, GL_RG8UI, GL_RG_INTEGER, GL_UNSIGNED_BYTE, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::RG8Sint, GL_RG8I, GL_RG_INTEGER, GL_BYTE, Type::Int);
|
||||
|
||||
// 4 bytes color formats
|
||||
AddFormat(dawn::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(dawn::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(dawn::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(dawn::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(dawn::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(dawn::TextureFormat::RGBA8Sint, GL_RGBA8I, GL_RGBA_INTEGER, GL_BYTE, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::R32Uint, GL_R32UI, GL_RED_INTEGER, GL_UNSIGNED_INT, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::R32Sint, GL_R32I, GL_RED_INTEGER, GL_INT, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::R32Float, GL_R32F, GL_RED, GL_FLOAT, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RG16Uint, GL_RG16UI, GL_RG_INTEGER, GL_UNSIGNED_SHORT, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::RG16Sint, GL_RG16I, GL_RG_INTEGER, GL_SHORT, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::RG16Float, GL_RG16F, GL_RG, GL_HALF_FLOAT, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RGBA8Unorm, GL_RGBA8, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RGBA8UnormSrgb, GL_SRGB8_ALPHA8, GL_RGBA, GL_UNSIGNED_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RGBA8Snorm, GL_RGBA8_SNORM, GL_RGBA, GL_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RGBA8Uint, GL_RGBA8UI, GL_RGBA_INTEGER, GL_UNSIGNED_BYTE, Type::Uint);
|
||||
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.
|
||||
AddFormat(dawn::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(dawn::TextureFormat::RG11B10Float, GL_R11F_G11F_B10F, GL_RGB, GL_UNSIGNED_INT_10F_11F_11F_REV, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::BGRA8Unorm, GL_RGBA8, GL_BGRA, GL_UNSIGNED_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RGB10A2Unorm, GL_RGB10_A2, GL_RGBA, GL_UNSIGNED_INT_2_10_10_10_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
|
||||
AddFormat(dawn::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(dawn::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(dawn::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::RG32Uint, GL_RG32UI, GL_RG_INTEGER, GL_UNSIGNED_INT, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::RG32Sint, GL_RG32I, GL_RG_INTEGER, GL_INT, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::RG32Float, GL_RG32F, GL_RG, GL_FLOAT, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RGBA16Uint, GL_RGBA16UI, GL_RGBA_INTEGER, GL_UNSIGNED_SHORT, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::RGBA16Sint, GL_RGBA16I, GL_RGBA_INTEGER, GL_SHORT, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::RGBA16Float, GL_RGBA16F, GL_RGBA, GL_HALF_FLOAT, Type::Float);
|
||||
|
||||
// 16 bytes color formats
|
||||
AddFormat(dawn::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(dawn::TextureFormat::RGBA32Float, GL_RGBA32F, GL_RGBA, GL_FLOAT, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::RGBA32Uint, GL_RGBA32UI, GL_RGBA_INTEGER, GL_UNSIGNED_INT, Type::Uint);
|
||||
AddFormat(wgpu::TextureFormat::RGBA32Sint, GL_RGBA32I, GL_RGBA_INTEGER, GL_INT, Type::Int);
|
||||
AddFormat(wgpu::TextureFormat::RGBA32Float, GL_RGBA32F, GL_RGBA, GL_FLOAT, Type::Float);
|
||||
|
||||
// Depth stencil formats
|
||||
AddFormat(dawn::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(dawn::TextureFormat::Depth24PlusStencil8, GL_DEPTH32F_STENCIL8, GL_DEPTH_STENCIL, GL_FLOAT_32_UNSIGNED_INT_24_8_REV, Type::DepthStencil);
|
||||
AddFormat(wgpu::TextureFormat::Depth32Float, GL_DEPTH_COMPONENT32F, GL_DEPTH, GL_FLOAT, Type::DepthStencil);
|
||||
AddFormat(wgpu::TextureFormat::Depth24Plus, GL_DEPTH_COMPONENT32F, GL_DEPTH, GL_FLOAT, 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
|
||||
AddFormat(dawn::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(dawn::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(dawn::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(dawn::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(dawn::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(dawn::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(dawn::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::BC1RGBAUnorm, GL_COMPRESSED_RGBA_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(wgpu::TextureFormat::BC2RGBAUnorm, GL_COMPRESSED_RGBA_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(wgpu::TextureFormat::BC3RGBAUnorm, GL_COMPRESSED_RGBA_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(wgpu::TextureFormat::BC4RSnorm, GL_COMPRESSED_SIGNED_RED_RGTC1, GL_RED, GL_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::BC4RUnorm, GL_COMPRESSED_RED_RGTC1, GL_RED, GL_UNSIGNED_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::BC5RGSnorm, GL_COMPRESSED_SIGNED_RG_RGTC2, GL_RG, GL_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::BC5RGUnorm, GL_COMPRESSED_RG_RGTC2, GL_RG, GL_UNSIGNED_BYTE, Type::Float);
|
||||
AddFormat(wgpu::TextureFormat::BC6HRGBSfloat, GL_COMPRESSED_RGB_BPTC_SIGNED_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(wgpu::TextureFormat::BC7RGBAUnorm, GL_COMPRESSED_RGBA_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
|
||||
|
||||
|
@ -80,8 +80,8 @@ namespace dawn_native { namespace opengl {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
return dawn::TextureFormat::RGBA8Unorm;
|
||||
wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
return wgpu::TextureFormat::RGBA8Unorm;
|
||||
}
|
||||
|
||||
}} // namespace dawn_native::opengl
|
||||
|
@ -39,7 +39,7 @@ namespace dawn_native { namespace opengl {
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError Present();
|
||||
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
wgpu::TextureFormat GetPreferredFormat() const;
|
||||
|
||||
private:
|
||||
PresentCallback mPresentCallback;
|
||||
|
@ -74,7 +74,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
mProgram = gl.CreateProgram();
|
||||
|
||||
dawn::ShaderStage activeStages = dawn::ShaderStage::None;
|
||||
wgpu::ShaderStage activeStages = wgpu::ShaderStage::None;
|
||||
for (SingleShaderStage stage : IterateStages(kAllStages)) {
|
||||
if (modules[stage] != nullptr) {
|
||||
activeStages |= StageBit(stage);
|
||||
@ -118,14 +118,14 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
std::string name = GetBindingName(group, binding);
|
||||
switch (groupInfo.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer: {
|
||||
case wgpu::BindingType::UniformBuffer: {
|
||||
GLint location = gl.GetUniformBlockIndex(mProgram, name.c_str());
|
||||
if (location != -1) {
|
||||
gl.UniformBlockBinding(mProgram, location, indices[group][binding]);
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::StorageBuffer: {
|
||||
case wgpu::BindingType::StorageBuffer: {
|
||||
GLuint location = gl.GetProgramResourceIndex(
|
||||
mProgram, GL_SHADER_STORAGE_BLOCK, name.c_str());
|
||||
if (location != GL_INVALID_INDEX) {
|
||||
@ -134,14 +134,14 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
// These binding types are handled in the separate sampler and texture
|
||||
// emulation
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
@ -177,11 +177,11 @@ namespace dawn_native { namespace opengl {
|
||||
indices[combined.textureLocation.group][combined.textureLocation.binding];
|
||||
mUnitsForTextures[textureIndex].push_back(textureUnit);
|
||||
|
||||
dawn::TextureComponentType componentType =
|
||||
wgpu::TextureComponentType componentType =
|
||||
layout->GetBindGroupLayout(combined.textureLocation.group)
|
||||
->GetBindingInfo()
|
||||
.textureComponentTypes[combined.textureLocation.binding];
|
||||
bool shouldUseFiltering = componentType == dawn::TextureComponentType::Float;
|
||||
bool shouldUseFiltering = componentType == wgpu::TextureComponentType::Float;
|
||||
|
||||
GLuint samplerIndex =
|
||||
indices[combined.samplerLocation.group][combined.samplerLocation.binding];
|
||||
|
@ -36,26 +36,26 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
|
||||
switch (groupInfo.types[binding]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
mIndexInfo[group][binding] = uboIndex;
|
||||
uboIndex++;
|
||||
break;
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
mIndexInfo[group][binding] = samplerIndex;
|
||||
samplerIndex++;
|
||||
break;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
mIndexInfo[group][binding] = sampledTextureIndex;
|
||||
sampledTextureIndex++;
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
mIndexInfo[group][binding] = ssboIndex;
|
||||
ssboIndex++;
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
UNREACHABLE();
|
||||
break;
|
||||
|
||||
|
@ -23,17 +23,17 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
namespace {
|
||||
|
||||
GLenum GLPrimitiveTopology(dawn::PrimitiveTopology primitiveTopology) {
|
||||
GLenum GLPrimitiveTopology(wgpu::PrimitiveTopology primitiveTopology) {
|
||||
switch (primitiveTopology) {
|
||||
case dawn::PrimitiveTopology::PointList:
|
||||
case wgpu::PrimitiveTopology::PointList:
|
||||
return GL_POINTS;
|
||||
case dawn::PrimitiveTopology::LineList:
|
||||
case wgpu::PrimitiveTopology::LineList:
|
||||
return GL_LINES;
|
||||
case dawn::PrimitiveTopology::LineStrip:
|
||||
case wgpu::PrimitiveTopology::LineStrip:
|
||||
return GL_LINE_STRIP;
|
||||
case dawn::PrimitiveTopology::TriangleList:
|
||||
case wgpu::PrimitiveTopology::TriangleList:
|
||||
return GL_TRIANGLES;
|
||||
case dawn::PrimitiveTopology::TriangleStrip:
|
||||
case wgpu::PrimitiveTopology::TriangleStrip:
|
||||
return GL_TRIANGLE_STRIP;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -41,66 +41,66 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
|
||||
void ApplyFrontFaceAndCulling(const OpenGLFunctions& gl,
|
||||
dawn::FrontFace face,
|
||||
dawn::CullMode mode) {
|
||||
if (mode == dawn::CullMode::None) {
|
||||
wgpu::FrontFace face,
|
||||
wgpu::CullMode mode) {
|
||||
if (mode == wgpu::CullMode::None) {
|
||||
gl.Disable(GL_CULL_FACE);
|
||||
} else {
|
||||
gl.Enable(GL_CULL_FACE);
|
||||
// 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).
|
||||
GLenum direction = (face == dawn::FrontFace::CCW) ? GL_CW : GL_CCW;
|
||||
GLenum direction = (face == wgpu::FrontFace::CCW) ? GL_CW : GL_CCW;
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
GLenum GLBlendFactor(dawn::BlendFactor factor, bool alpha) {
|
||||
GLenum GLBlendFactor(wgpu::BlendFactor factor, bool alpha) {
|
||||
switch (factor) {
|
||||
case dawn::BlendFactor::Zero:
|
||||
case wgpu::BlendFactor::Zero:
|
||||
return GL_ZERO;
|
||||
case dawn::BlendFactor::One:
|
||||
case wgpu::BlendFactor::One:
|
||||
return GL_ONE;
|
||||
case dawn::BlendFactor::SrcColor:
|
||||
case wgpu::BlendFactor::SrcColor:
|
||||
return GL_SRC_COLOR;
|
||||
case dawn::BlendFactor::OneMinusSrcColor:
|
||||
case wgpu::BlendFactor::OneMinusSrcColor:
|
||||
return GL_ONE_MINUS_SRC_COLOR;
|
||||
case dawn::BlendFactor::SrcAlpha:
|
||||
case wgpu::BlendFactor::SrcAlpha:
|
||||
return GL_SRC_ALPHA;
|
||||
case dawn::BlendFactor::OneMinusSrcAlpha:
|
||||
case wgpu::BlendFactor::OneMinusSrcAlpha:
|
||||
return GL_ONE_MINUS_SRC_ALPHA;
|
||||
case dawn::BlendFactor::DstColor:
|
||||
case wgpu::BlendFactor::DstColor:
|
||||
return GL_DST_COLOR;
|
||||
case dawn::BlendFactor::OneMinusDstColor:
|
||||
case wgpu::BlendFactor::OneMinusDstColor:
|
||||
return GL_ONE_MINUS_DST_COLOR;
|
||||
case dawn::BlendFactor::DstAlpha:
|
||||
case wgpu::BlendFactor::DstAlpha:
|
||||
return GL_DST_ALPHA;
|
||||
case dawn::BlendFactor::OneMinusDstAlpha:
|
||||
case wgpu::BlendFactor::OneMinusDstAlpha:
|
||||
return GL_ONE_MINUS_DST_ALPHA;
|
||||
case dawn::BlendFactor::SrcAlphaSaturated:
|
||||
case wgpu::BlendFactor::SrcAlphaSaturated:
|
||||
return GL_SRC_ALPHA_SATURATE;
|
||||
case dawn::BlendFactor::BlendColor:
|
||||
case wgpu::BlendFactor::BlendColor:
|
||||
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;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
GLenum GLBlendMode(dawn::BlendOperation operation) {
|
||||
GLenum GLBlendMode(wgpu::BlendOperation operation) {
|
||||
switch (operation) {
|
||||
case dawn::BlendOperation::Add:
|
||||
case wgpu::BlendOperation::Add:
|
||||
return GL_FUNC_ADD;
|
||||
case dawn::BlendOperation::Subtract:
|
||||
case wgpu::BlendOperation::Subtract:
|
||||
return GL_FUNC_SUBTRACT;
|
||||
case dawn::BlendOperation::ReverseSubtract:
|
||||
case wgpu::BlendOperation::ReverseSubtract:
|
||||
return GL_FUNC_REVERSE_SUBTRACT;
|
||||
case dawn::BlendOperation::Min:
|
||||
case wgpu::BlendOperation::Min:
|
||||
return GL_MIN;
|
||||
case dawn::BlendOperation::Max:
|
||||
case wgpu::BlendOperation::Max:
|
||||
return GL_MAX;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -122,29 +122,29 @@ namespace dawn_native { namespace opengl {
|
||||
} else {
|
||||
gl.Disablei(GL_BLEND, attachment);
|
||||
}
|
||||
gl.ColorMaski(attachment, descriptor->writeMask & dawn::ColorWriteMask::Red,
|
||||
descriptor->writeMask & dawn::ColorWriteMask::Green,
|
||||
descriptor->writeMask & dawn::ColorWriteMask::Blue,
|
||||
descriptor->writeMask & dawn::ColorWriteMask::Alpha);
|
||||
gl.ColorMaski(attachment, descriptor->writeMask & wgpu::ColorWriteMask::Red,
|
||||
descriptor->writeMask & wgpu::ColorWriteMask::Green,
|
||||
descriptor->writeMask & wgpu::ColorWriteMask::Blue,
|
||||
descriptor->writeMask & wgpu::ColorWriteMask::Alpha);
|
||||
}
|
||||
|
||||
GLuint OpenGLStencilOperation(dawn::StencilOperation stencilOperation) {
|
||||
GLuint OpenGLStencilOperation(wgpu::StencilOperation stencilOperation) {
|
||||
switch (stencilOperation) {
|
||||
case dawn::StencilOperation::Keep:
|
||||
case wgpu::StencilOperation::Keep:
|
||||
return GL_KEEP;
|
||||
case dawn::StencilOperation::Zero:
|
||||
case wgpu::StencilOperation::Zero:
|
||||
return GL_ZERO;
|
||||
case dawn::StencilOperation::Replace:
|
||||
case wgpu::StencilOperation::Replace:
|
||||
return GL_REPLACE;
|
||||
case dawn::StencilOperation::Invert:
|
||||
case wgpu::StencilOperation::Invert:
|
||||
return GL_INVERT;
|
||||
case dawn::StencilOperation::IncrementClamp:
|
||||
case wgpu::StencilOperation::IncrementClamp:
|
||||
return GL_INCR;
|
||||
case dawn::StencilOperation::DecrementClamp:
|
||||
case wgpu::StencilOperation::DecrementClamp:
|
||||
return GL_DECR;
|
||||
case dawn::StencilOperation::IncrementWrap:
|
||||
case wgpu::StencilOperation::IncrementWrap:
|
||||
return GL_INCR_WRAP;
|
||||
case dawn::StencilOperation::DecrementWrap:
|
||||
case wgpu::StencilOperation::DecrementWrap:
|
||||
return GL_DECR_WRAP;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -155,7 +155,7 @@ namespace dawn_native { namespace opengl {
|
||||
const DepthStencilStateDescriptor* descriptor,
|
||||
PersistentPipelineState* persistentPipelineState) {
|
||||
// Depth writes only occur if depth is enabled
|
||||
if (descriptor->depthCompare == dawn::CompareFunction::Always &&
|
||||
if (descriptor->depthCompare == wgpu::CompareFunction::Always &&
|
||||
!descriptor->depthWriteEnabled) {
|
||||
gl.Disable(GL_DEPTH_TEST);
|
||||
} else {
|
||||
@ -234,9 +234,9 @@ namespace dawn_native { namespace opengl {
|
||||
gl.VertexAttribDivisor(location, 0xffffffff);
|
||||
} else {
|
||||
switch (input.stepMode) {
|
||||
case dawn::InputStepMode::Vertex:
|
||||
case wgpu::InputStepMode::Vertex:
|
||||
break;
|
||||
case dawn::InputStepMode::Instance:
|
||||
case wgpu::InputStepMode::Instance:
|
||||
gl.VertexAttribDivisor(location, 1);
|
||||
break;
|
||||
default:
|
||||
|
@ -21,33 +21,33 @@
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
namespace {
|
||||
GLenum MagFilterMode(dawn::FilterMode filter) {
|
||||
GLenum MagFilterMode(wgpu::FilterMode filter) {
|
||||
switch (filter) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
return GL_NEAREST;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
return GL_LINEAR;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
GLenum MinFilterMode(dawn::FilterMode minFilter, dawn::FilterMode mipMapFilter) {
|
||||
GLenum MinFilterMode(wgpu::FilterMode minFilter, wgpu::FilterMode mipMapFilter) {
|
||||
switch (minFilter) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
switch (mipMapFilter) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
return GL_NEAREST_MIPMAP_NEAREST;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
return GL_NEAREST_MIPMAP_LINEAR;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
switch (mipMapFilter) {
|
||||
case dawn::FilterMode::Nearest:
|
||||
case wgpu::FilterMode::Nearest:
|
||||
return GL_LINEAR_MIPMAP_NEAREST;
|
||||
case dawn::FilterMode::Linear:
|
||||
case wgpu::FilterMode::Linear:
|
||||
return GL_LINEAR_MIPMAP_LINEAR;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -57,13 +57,13 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
}
|
||||
|
||||
GLenum WrapMode(dawn::AddressMode mode) {
|
||||
GLenum WrapMode(wgpu::AddressMode mode) {
|
||||
switch (mode) {
|
||||
case dawn::AddressMode::Repeat:
|
||||
case wgpu::AddressMode::Repeat:
|
||||
return GL_REPEAT;
|
||||
case dawn::AddressMode::MirrorRepeat:
|
||||
case wgpu::AddressMode::MirrorRepeat:
|
||||
return GL_MIRRORED_REPEAT;
|
||||
case dawn::AddressMode::ClampToEdge:
|
||||
case wgpu::AddressMode::ClampToEdge:
|
||||
return GL_CLAMP_TO_EDGE;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -36,7 +36,7 @@ namespace dawn_native { namespace opengl {
|
||||
DawnSwapChainNextTexture next = {};
|
||||
DawnSwapChainError error = im.GetNextTexture(im.userData, &next);
|
||||
if (error) {
|
||||
GetDevice()->HandleError(dawn::ErrorType::Unknown, error);
|
||||
GetDevice()->HandleError(wgpu::ErrorType::Unknown, error);
|
||||
return nullptr;
|
||||
}
|
||||
GLuint nativeTexture = next.texture.u32;
|
||||
|
@ -27,7 +27,7 @@ namespace dawn_native { namespace opengl {
|
||||
|
||||
GLenum TargetForTexture(const TextureDescriptor* descriptor) {
|
||||
switch (descriptor->dimension) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
if (descriptor->arrayLayerCount > 1) {
|
||||
ASSERT(descriptor->sampleCount == 1);
|
||||
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) {
|
||||
switch (dimension) {
|
||||
case dawn::TextureViewDimension::e2D:
|
||||
case wgpu::TextureViewDimension::e2D:
|
||||
return (sampleCount > 1) ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
|
||||
case dawn::TextureViewDimension::e2DArray:
|
||||
case wgpu::TextureViewDimension::e2DArray:
|
||||
ASSERT(sampleCount == 1);
|
||||
return GL_TEXTURE_2D_ARRAY;
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
return GL_TEXTURE_CUBE_MAP;
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return GL_TEXTURE_CUBE_MAP_ARRAY;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -69,9 +69,9 @@ namespace dawn_native { namespace opengl {
|
||||
return handle;
|
||||
}
|
||||
|
||||
bool UsageNeedsTextureView(dawn::TextureUsage usage) {
|
||||
constexpr dawn::TextureUsage kUsageNeedingTextureView =
|
||||
dawn::TextureUsage::Storage | dawn::TextureUsage::Sampled;
|
||||
bool UsageNeedsTextureView(wgpu::TextureUsage usage) {
|
||||
constexpr wgpu::TextureUsage kUsageNeedingTextureView =
|
||||
wgpu::TextureUsage::Storage | wgpu::TextureUsage::Sampled;
|
||||
return usage & kUsageNeedingTextureView;
|
||||
}
|
||||
|
||||
@ -90,8 +90,8 @@ namespace dawn_native { namespace opengl {
|
||||
}
|
||||
|
||||
switch (textureViewDescriptor->dimension) {
|
||||
case dawn::TextureViewDimension::Cube:
|
||||
case dawn::TextureViewDimension::CubeArray:
|
||||
case wgpu::TextureViewDimension::Cube:
|
||||
case wgpu::TextureViewDimension::CubeArray:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
@ -122,7 +122,7 @@ namespace dawn_native { namespace opengl {
|
||||
// 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
|
||||
switch (GetDimension()) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
if (arrayLayers > 1) {
|
||||
ASSERT(!IsMultisampledTexture());
|
||||
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.");
|
||||
}
|
||||
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
|
||||
Ref<Buffer> srcBuffer = ToBackend(device->CreateBuffer(&descriptor));
|
||||
// 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);
|
||||
switch (GetDimension()) {
|
||||
case dawn::TextureDimension::e2D:
|
||||
case wgpu::TextureDimension::e2D:
|
||||
// TODO(natlee@microsoft.com): This will break when layerCount is greater
|
||||
// than 1, because the buffer is only sized for one layer.
|
||||
ASSERT(layerCount == 1);
|
||||
|
@ -18,32 +18,32 @@
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
GLuint ToOpenGLCompareFunction(dawn::CompareFunction compareFunction) {
|
||||
GLuint ToOpenGLCompareFunction(wgpu::CompareFunction compareFunction) {
|
||||
switch (compareFunction) {
|
||||
case dawn::CompareFunction::Never:
|
||||
case wgpu::CompareFunction::Never:
|
||||
return GL_NEVER;
|
||||
case dawn::CompareFunction::Less:
|
||||
case wgpu::CompareFunction::Less:
|
||||
return GL_LESS;
|
||||
case dawn::CompareFunction::LessEqual:
|
||||
case wgpu::CompareFunction::LessEqual:
|
||||
return GL_LEQUAL;
|
||||
case dawn::CompareFunction::Greater:
|
||||
case wgpu::CompareFunction::Greater:
|
||||
return GL_GREATER;
|
||||
case dawn::CompareFunction::GreaterEqual:
|
||||
case wgpu::CompareFunction::GreaterEqual:
|
||||
return GL_GEQUAL;
|
||||
case dawn::CompareFunction::NotEqual:
|
||||
case wgpu::CompareFunction::NotEqual:
|
||||
return GL_NOTEQUAL;
|
||||
case dawn::CompareFunction::Equal:
|
||||
case wgpu::CompareFunction::Equal:
|
||||
return GL_EQUAL;
|
||||
case dawn::CompareFunction::Always:
|
||||
case wgpu::CompareFunction::Always:
|
||||
return GL_ALWAYS;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
GLint GetStencilMaskFromStencilFormat(dawn::TextureFormat depthStencilFormat) {
|
||||
GLint GetStencilMaskFromStencilFormat(wgpu::TextureFormat depthStencilFormat) {
|
||||
switch (depthStencilFormat) {
|
||||
case dawn::TextureFormat::Depth24PlusStencil8:
|
||||
case wgpu::TextureFormat::Depth24PlusStencil8:
|
||||
return 0xFF;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
namespace dawn_native { namespace opengl {
|
||||
|
||||
GLuint ToOpenGLCompareFunction(dawn::CompareFunction compareFunction);
|
||||
GLint GetStencilMaskFromStencilFormat(dawn::TextureFormat depthStencilFormat);
|
||||
GLuint ToOpenGLCompareFunction(wgpu::CompareFunction compareFunction);
|
||||
GLint GetStencilMaskFromStencilFormat(wgpu::TextureFormat depthStencilFormat);
|
||||
}} // namespace dawn_native::opengl
|
||||
|
||||
#endif // DAWNNATIVE_OPENGL_UTILSGL_H_
|
||||
|
@ -22,16 +22,16 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
namespace {
|
||||
|
||||
VkShaderStageFlags VulkanShaderStageFlags(dawn::ShaderStage stages) {
|
||||
VkShaderStageFlags VulkanShaderStageFlags(wgpu::ShaderStage stages) {
|
||||
VkShaderStageFlags flags = 0;
|
||||
|
||||
if (stages & dawn::ShaderStage::Vertex) {
|
||||
if (stages & wgpu::ShaderStage::Vertex) {
|
||||
flags |= VK_SHADER_STAGE_VERTEX_BIT;
|
||||
}
|
||||
if (stages & dawn::ShaderStage::Fragment) {
|
||||
if (stages & wgpu::ShaderStage::Fragment) {
|
||||
flags |= VK_SHADER_STAGE_FRAGMENT_BIT;
|
||||
}
|
||||
if (stages & dawn::ShaderStage::Compute) {
|
||||
if (stages & wgpu::ShaderStage::Compute) {
|
||||
flags |= VK_SHADER_STAGE_COMPUTE_BIT;
|
||||
}
|
||||
|
||||
@ -40,18 +40,18 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
VkDescriptorType VulkanDescriptorType(dawn::BindingType type, bool isDynamic) {
|
||||
VkDescriptorType VulkanDescriptorType(wgpu::BindingType type, bool isDynamic) {
|
||||
switch (type) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
if (isDynamic) {
|
||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC;
|
||||
}
|
||||
return VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER;
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
return VK_DESCRIPTOR_TYPE_SAMPLER;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
return VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
if (isDynamic) {
|
||||
return VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC;
|
||||
}
|
||||
@ -132,15 +132,15 @@ namespace dawn_native { namespace vulkan {
|
||||
MAX_TYPE,
|
||||
};
|
||||
static_assert(MAX_TYPE == kMaxPoolSizesNeeded, "");
|
||||
auto ToDescriptorType = [](dawn::BindingType type) -> DescriptorType {
|
||||
auto ToDescriptorType = [](wgpu::BindingType type) -> DescriptorType {
|
||||
switch (type) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
return UNIFORM_BUFFER;
|
||||
case dawn::BindingType::Sampler:
|
||||
case wgpu::BindingType::Sampler:
|
||||
return SAMPLER;
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
return SAMPLED_IMAGE;
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
return STORAGE_BUFFER;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
|
@ -23,7 +23,7 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
class Device;
|
||||
|
||||
VkDescriptorType VulkanDescriptorType(dawn::BindingType type, bool isDynamic);
|
||||
VkDescriptorType VulkanDescriptorType(wgpu::BindingType type, bool isDynamic);
|
||||
|
||||
class BindGroupLayout : public BindGroupLayoutBase {
|
||||
public:
|
||||
|
@ -88,8 +88,8 @@ namespace dawn_native { namespace vulkan {
|
||||
layoutInfo.hasDynamicOffset[bindingIndex]);
|
||||
|
||||
switch (layoutInfo.types[bindingIndex]) {
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case dawn::BindingType::StorageBuffer: {
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::StorageBuffer: {
|
||||
BufferBinding binding = GetBindingAsBufferBinding(bindingIndex);
|
||||
|
||||
writeBufferInfo[numWrites].buffer = ToBackend(binding.buffer)->GetHandle();
|
||||
@ -98,13 +98,13 @@ namespace dawn_native { namespace vulkan {
|
||||
write.pBufferInfo = &writeBufferInfo[numWrites];
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::Sampler: {
|
||||
case wgpu::BindingType::Sampler: {
|
||||
Sampler* sampler = ToBackend(GetBindingAsSampler(bindingIndex));
|
||||
writeImageInfo[numWrites].sampler = sampler->GetHandle();
|
||||
write.pImageInfo = &writeImageInfo[numWrites];
|
||||
} break;
|
||||
|
||||
case dawn::BindingType::SampledTexture: {
|
||||
case wgpu::BindingType::SampledTexture: {
|
||||
TextureView* view = ToBackend(GetBindingAsTextureView(bindingIndex));
|
||||
|
||||
writeImageInfo[numWrites].imageView = view->GetHandle();
|
||||
|
@ -26,86 +26,86 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
namespace {
|
||||
|
||||
VkBufferUsageFlags VulkanBufferUsage(dawn::BufferUsage usage) {
|
||||
VkBufferUsageFlags VulkanBufferUsage(wgpu::BufferUsage usage) {
|
||||
VkBufferUsageFlags flags = 0;
|
||||
|
||||
if (usage & dawn::BufferUsage::CopySrc) {
|
||||
if (usage & wgpu::BufferUsage::CopySrc) {
|
||||
flags |= VK_BUFFER_USAGE_TRANSFER_SRC_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::CopyDst) {
|
||||
if (usage & wgpu::BufferUsage::CopyDst) {
|
||||
flags |= VK_BUFFER_USAGE_TRANSFER_DST_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Index) {
|
||||
if (usage & wgpu::BufferUsage::Index) {
|
||||
flags |= VK_BUFFER_USAGE_INDEX_BUFFER_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Vertex) {
|
||||
if (usage & wgpu::BufferUsage::Vertex) {
|
||||
flags |= VK_BUFFER_USAGE_VERTEX_BUFFER_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Uniform) {
|
||||
if (usage & wgpu::BufferUsage::Uniform) {
|
||||
flags |= VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Storage) {
|
||||
if (usage & wgpu::BufferUsage::Storage) {
|
||||
flags |= VK_BUFFER_USAGE_STORAGE_BUFFER_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Indirect) {
|
||||
if (usage & wgpu::BufferUsage::Indirect) {
|
||||
flags |= VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
VkPipelineStageFlags VulkanPipelineStage(dawn::BufferUsage usage) {
|
||||
VkPipelineStageFlags VulkanPipelineStage(wgpu::BufferUsage usage) {
|
||||
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;
|
||||
}
|
||||
if (usage & (dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst)) {
|
||||
if (usage & (wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst)) {
|
||||
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;
|
||||
}
|
||||
if (usage & (dawn::BufferUsage::Uniform | dawn::BufferUsage::Storage)) {
|
||||
if (usage & (wgpu::BufferUsage::Uniform | wgpu::BufferUsage::Storage)) {
|
||||
flags |= VK_PIPELINE_STAGE_VERTEX_SHADER_BIT |
|
||||
VK_PIPELINE_STAGE_FRAGMENT_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;
|
||||
}
|
||||
|
||||
return flags;
|
||||
}
|
||||
|
||||
VkAccessFlags VulkanAccessFlags(dawn::BufferUsage usage) {
|
||||
VkAccessFlags VulkanAccessFlags(wgpu::BufferUsage usage) {
|
||||
VkAccessFlags flags = 0;
|
||||
|
||||
if (usage & dawn::BufferUsage::MapRead) {
|
||||
if (usage & wgpu::BufferUsage::MapRead) {
|
||||
flags |= VK_ACCESS_HOST_READ_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::MapWrite) {
|
||||
if (usage & wgpu::BufferUsage::MapWrite) {
|
||||
flags |= VK_ACCESS_HOST_WRITE_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::CopySrc) {
|
||||
if (usage & wgpu::BufferUsage::CopySrc) {
|
||||
flags |= VK_ACCESS_TRANSFER_READ_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::CopyDst) {
|
||||
if (usage & wgpu::BufferUsage::CopyDst) {
|
||||
flags |= VK_ACCESS_TRANSFER_WRITE_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Index) {
|
||||
if (usage & wgpu::BufferUsage::Index) {
|
||||
flags |= VK_ACCESS_INDEX_READ_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Vertex) {
|
||||
if (usage & wgpu::BufferUsage::Vertex) {
|
||||
flags |= VK_ACCESS_VERTEX_ATTRIBUTE_READ_BIT;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Uniform) {
|
||||
if (usage & wgpu::BufferUsage::Uniform) {
|
||||
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;
|
||||
}
|
||||
if (usage & dawn::BufferUsage::Indirect) {
|
||||
if (usage & wgpu::BufferUsage::Indirect) {
|
||||
flags |= VK_ACCESS_INDIRECT_COMMAND_READ_BIT;
|
||||
}
|
||||
|
||||
@ -129,7 +129,7 @@ namespace dawn_native { namespace vulkan {
|
||||
createInfo.size = GetSize();
|
||||
// Add CopyDst for non-mappable buffer initialization in CreateBufferMapped
|
||||
// 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.queueFamilyIndexCount = 0;
|
||||
createInfo.pQueueFamilyIndices = 0;
|
||||
@ -143,7 +143,7 @@ namespace dawn_native { namespace vulkan {
|
||||
device->fn.GetBufferMemoryRequirements(device->GetVkDevice(), mHandle, &requirements);
|
||||
|
||||
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(CheckVkSuccess(
|
||||
@ -172,7 +172,7 @@ namespace dawn_native { namespace vulkan {
|
||||
}
|
||||
|
||||
void Buffer::TransitionUsageNow(CommandRecordingContext* recordingContext,
|
||||
dawn::BufferUsage usage) {
|
||||
wgpu::BufferUsage usage) {
|
||||
bool lastIncludesTarget = (mLastUsage & usage) == usage;
|
||||
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.
|
||||
if (mLastUsage == dawn::BufferUsage::None) {
|
||||
if (mLastUsage == wgpu::BufferUsage::None) {
|
||||
mLastUsage = usage;
|
||||
return;
|
||||
}
|
||||
@ -222,7 +222,7 @@ namespace dawn_native { namespace vulkan {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
||||
TransitionUsageNow(recordingContext, dawn::BufferUsage::MapRead);
|
||||
TransitionUsageNow(recordingContext, wgpu::BufferUsage::MapRead);
|
||||
|
||||
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
|
||||
ASSERT(memory != nullptr);
|
||||
@ -236,7 +236,7 @@ namespace dawn_native { namespace vulkan {
|
||||
Device* device = ToBackend(GetDevice());
|
||||
|
||||
CommandRecordingContext* recordingContext = device->GetPendingRecordingContext();
|
||||
TransitionUsageNow(recordingContext, dawn::BufferUsage::MapWrite);
|
||||
TransitionUsageNow(recordingContext, wgpu::BufferUsage::MapWrite);
|
||||
|
||||
uint8_t* memory = mMemoryAllocation.GetMappedPointer();
|
||||
ASSERT(memory != nullptr);
|
||||
|
@ -40,7 +40,7 @@ namespace dawn_native { namespace vulkan {
|
||||
// Transitions the buffer to be used as `usage`, recording any necessary barrier in
|
||||
// `commands`.
|
||||
// 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:
|
||||
using BufferBase::BufferBase;
|
||||
@ -58,7 +58,7 @@ namespace dawn_native { namespace vulkan {
|
||||
VkBuffer mHandle = VK_NULL_HANDLE;
|
||||
ResourceMemoryAllocation mMemoryAllocation;
|
||||
|
||||
dawn::BufferUsage mLastUsage = dawn::BufferUsage::None;
|
||||
wgpu::BufferUsage mLastUsage = wgpu::BufferUsage::None;
|
||||
};
|
||||
|
||||
class MapRequestTracker {
|
||||
|
@ -35,11 +35,11 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
namespace {
|
||||
|
||||
VkIndexType VulkanIndexType(dawn::IndexFormat format) {
|
||||
VkIndexType VulkanIndexType(wgpu::IndexFormat format) {
|
||||
switch (format) {
|
||||
case dawn::IndexFormat::Uint16:
|
||||
case wgpu::IndexFormat::Uint16:
|
||||
return VK_INDEX_TYPE_UINT16;
|
||||
case dawn::IndexFormat::Uint32:
|
||||
case wgpu::IndexFormat::Uint32:
|
||||
return VK_INDEX_TYPE_UINT32;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
@ -142,19 +142,19 @@ namespace dawn_native { namespace vulkan {
|
||||
for (uint32_t index : IterateBitSet(mBindGroupLayoutsMask)) {
|
||||
for (uint32_t binding : IterateBitSet(mBuffersNeedingBarrier[index])) {
|
||||
switch (mBindingTypes[index][binding]) {
|
||||
case dawn::BindingType::StorageBuffer:
|
||||
case wgpu::BindingType::StorageBuffer:
|
||||
ToBackend(mBuffers[index][binding])
|
||||
->TransitionUsageNow(recordingContext,
|
||||
dawn::BufferUsage::Storage);
|
||||
wgpu::BufferUsage::Storage);
|
||||
break;
|
||||
|
||||
case dawn::BindingType::StorageTexture:
|
||||
case wgpu::BindingType::StorageTexture:
|
||||
// Not implemented.
|
||||
|
||||
case dawn::BindingType::UniformBuffer:
|
||||
case dawn::BindingType::ReadonlyStorageBuffer:
|
||||
case dawn::BindingType::Sampler:
|
||||
case dawn::BindingType::SampledTexture:
|
||||
case wgpu::BindingType::UniformBuffer:
|
||||
case wgpu::BindingType::ReadonlyStorageBuffer:
|
||||
case wgpu::BindingType::Sampler:
|
||||
case wgpu::BindingType::SampledTexture:
|
||||
// Don't require barriers.
|
||||
|
||||
default:
|
||||
@ -183,13 +183,13 @@ namespace dawn_native { namespace vulkan {
|
||||
TextureView* view = ToBackend(attachmentInfo.view.Get());
|
||||
bool hasResolveTarget = attachmentInfo.resolveTarget.Get() != nullptr;
|
||||
|
||||
dawn::LoadOp loadOp = attachmentInfo.loadOp;
|
||||
wgpu::LoadOp loadOp = attachmentInfo.loadOp;
|
||||
ASSERT(view->GetLayerCount() == 1);
|
||||
ASSERT(view->GetLevelCount() == 1);
|
||||
if (loadOp == dawn::LoadOp::Load &&
|
||||
if (loadOp == wgpu::LoadOp::Load &&
|
||||
!view->GetTexture()->IsSubresourceContentInitialized(
|
||||
view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1)) {
|
||||
loadOp = dawn::LoadOp::Clear;
|
||||
loadOp = wgpu::LoadOp::Clear;
|
||||
}
|
||||
|
||||
if (hasResolveTarget) {
|
||||
@ -204,12 +204,12 @@ namespace dawn_native { namespace vulkan {
|
||||
}
|
||||
|
||||
switch (attachmentInfo.storeOp) {
|
||||
case dawn::StoreOp::Store: {
|
||||
case wgpu::StoreOp::Store: {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
true, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
|
||||
} break;
|
||||
|
||||
case dawn::StoreOp::Clear: {
|
||||
case wgpu::StoreOp::Clear: {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
false, view->GetBaseMipLevel(), 1, view->GetBaseArrayLayer(), 1);
|
||||
} break;
|
||||
@ -231,26 +231,26 @@ namespace dawn_native { namespace vulkan {
|
||||
view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount())) {
|
||||
if (view->GetTexture()->GetFormat().HasDepth() &&
|
||||
attachmentInfo.depthLoadOp == dawn::LoadOp::Load) {
|
||||
attachmentInfo.depthLoadOp == wgpu::LoadOp::Load) {
|
||||
attachmentInfo.clearDepth = 0.0f;
|
||||
attachmentInfo.depthLoadOp = dawn::LoadOp::Clear;
|
||||
attachmentInfo.depthLoadOp = wgpu::LoadOp::Clear;
|
||||
}
|
||||
if (view->GetTexture()->GetFormat().HasStencil() &&
|
||||
attachmentInfo.stencilLoadOp == dawn::LoadOp::Load) {
|
||||
attachmentInfo.stencilLoadOp == wgpu::LoadOp::Load) {
|
||||
attachmentInfo.clearStencil = 0u;
|
||||
attachmentInfo.stencilLoadOp = dawn::LoadOp::Clear;
|
||||
attachmentInfo.stencilLoadOp = wgpu::LoadOp::Clear;
|
||||
}
|
||||
}
|
||||
query.SetDepthStencil(view->GetTexture()->GetFormat().format,
|
||||
attachmentInfo.depthLoadOp, attachmentInfo.stencilLoadOp);
|
||||
|
||||
if (attachmentInfo.depthStoreOp == dawn::StoreOp::Store &&
|
||||
attachmentInfo.stencilStoreOp == dawn::StoreOp::Store) {
|
||||
if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Store &&
|
||||
attachmentInfo.stencilStoreOp == wgpu::StoreOp::Store) {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
true, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount());
|
||||
} else if (attachmentInfo.depthStoreOp == dawn::StoreOp::Clear &&
|
||||
attachmentInfo.stencilStoreOp == dawn::StoreOp::Clear) {
|
||||
} else if (attachmentInfo.depthStoreOp == wgpu::StoreOp::Clear &&
|
||||
attachmentInfo.stencilStoreOp == wgpu::StoreOp::Clear) {
|
||||
view->GetTexture()->SetIsSubresourceContentInitialized(
|
||||
false, view->GetBaseMipLevel(), view->GetLevelCount(),
|
||||
view->GetBaseArrayLayer(), view->GetLayerCount());
|
||||
@ -382,7 +382,7 @@ namespace dawn_native { namespace vulkan {
|
||||
format.blockByteSize;
|
||||
BufferDescriptor tempBufferDescriptor;
|
||||
tempBufferDescriptor.size = tempBufferSize;
|
||||
tempBufferDescriptor.usage = dawn::BufferUsage::CopySrc | dawn::BufferUsage::CopyDst;
|
||||
tempBufferDescriptor.usage = wgpu::BufferUsage::CopySrc | wgpu::BufferUsage::CopyDst;
|
||||
|
||||
Device* device = ToBackend(GetDevice());
|
||||
Ref<Buffer> tempBuffer = AcquireRef(ToBackend(device->CreateBuffer(&tempBufferDescriptor)));
|
||||
@ -397,7 +397,7 @@ namespace dawn_native { namespace vulkan {
|
||||
VkImage srcImage = ToBackend(srcCopy.texture)->GetHandle();
|
||||
VkImage dstImage = ToBackend(dstCopy.texture)->GetHandle();
|
||||
|
||||
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst);
|
||||
tempBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
|
||||
VkBufferImageCopy srcToTempBufferRegion =
|
||||
ComputeBufferImageCopyRegion(tempBufferCopy, srcCopy, copySize);
|
||||
|
||||
@ -405,7 +405,7 @@ namespace dawn_native { namespace vulkan {
|
||||
device->fn.CmdCopyImageToBuffer(commands, srcImage, VK_IMAGE_LAYOUT_GENERAL,
|
||||
tempBuffer->GetHandle(), 1, &srcToTempBufferRegion);
|
||||
|
||||
tempBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc);
|
||||
tempBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopySrc);
|
||||
VkBufferImageCopy tempBufferToDstRegion =
|
||||
ComputeBufferImageCopyRegion(tempBufferCopy, dstCopy, copySize);
|
||||
|
||||
@ -434,7 +434,7 @@ namespace dawn_native { namespace vulkan {
|
||||
// Clear textures that are not output attachments. Output attachments will be
|
||||
// cleared in RecordBeginRenderPass by setting the loadop to clear when the
|
||||
// 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->GetNumMipLevels(), 0,
|
||||
texture->GetArrayLayers());
|
||||
@ -453,8 +453,8 @@ namespace dawn_native { namespace vulkan {
|
||||
Buffer* srcBuffer = ToBackend(copy->source.Get());
|
||||
Buffer* dstBuffer = ToBackend(copy->destination.Get());
|
||||
|
||||
srcBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc);
|
||||
dstBuffer->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst);
|
||||
srcBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopySrc);
|
||||
dstBuffer->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
|
||||
|
||||
VkBufferCopy region;
|
||||
region.srcOffset = copy->sourceOffset;
|
||||
@ -487,9 +487,9 @@ namespace dawn_native { namespace vulkan {
|
||||
subresource.baseArrayLayer, 1);
|
||||
}
|
||||
ToBackend(src.buffer)
|
||||
->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopySrc);
|
||||
->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopySrc);
|
||||
ToBackend(dst.texture)
|
||||
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopyDst);
|
||||
->TransitionUsageNow(recordingContext, wgpu::TextureUsage::CopyDst);
|
||||
VkBuffer srcBuffer = ToBackend(src.buffer)->GetHandle();
|
||||
VkImage dstImage = ToBackend(dst.texture)->GetHandle();
|
||||
|
||||
@ -515,9 +515,9 @@ namespace dawn_native { namespace vulkan {
|
||||
subresource.baseArrayLayer, 1);
|
||||
|
||||
ToBackend(src.texture)
|
||||
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopySrc);
|
||||
->TransitionUsageNow(recordingContext, wgpu::TextureUsage::CopySrc);
|
||||
ToBackend(dst.buffer)
|
||||
->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst);
|
||||
->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
|
||||
|
||||
VkImage srcImage = ToBackend(src.texture)->GetHandle();
|
||||
VkBuffer dstBuffer = ToBackend(dst.buffer)->GetHandle();
|
||||
@ -547,9 +547,9 @@ namespace dawn_native { namespace vulkan {
|
||||
}
|
||||
|
||||
ToBackend(src.texture)
|
||||
->TransitionUsageNow(recordingContext, dawn::TextureUsage::CopySrc);
|
||||
->TransitionUsageNow(recordingContext, wgpu::TextureUsage::CopySrc);
|
||||
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
|
||||
// because as Vulkan SPEC always validates image copies with the virtual size of
|
||||
|
@ -572,7 +572,7 @@ namespace dawn_native { namespace vulkan {
|
||||
|
||||
// Insert pipeline barrier to ensure correct ordering with previous memory operations on the
|
||||
// buffer.
|
||||
ToBackend(destination)->TransitionUsageNow(recordingContext, dawn::BufferUsage::CopyDst);
|
||||
ToBackend(destination)->TransitionUsageNow(recordingContext, wgpu::BufferUsage::CopyDst);
|
||||
|
||||
VkBufferCopy copy;
|
||||
copy.srcOffset = sourceOffset;
|
||||
|
@ -52,7 +52,7 @@ namespace dawn_native { namespace vulkan {
|
||||
// driver. Need to generalize
|
||||
config->nativeFormat = VK_FORMAT_B8G8R8A8_UNORM;
|
||||
config->colorSpace = VK_COLOR_SPACE_SRGB_NONLINEAR_KHR;
|
||||
config->format = dawn::TextureFormat::BGRA8Unorm;
|
||||
config->format = wgpu::TextureFormat::BGRA8Unorm;
|
||||
config->minImageCount = 3;
|
||||
// TODO(cwallez@chromium.org): This is upside down compared to what we want, at least
|
||||
// on Linux
|
||||
@ -121,7 +121,7 @@ namespace dawn_native { namespace vulkan {
|
||||
createInfo.imageExtent.width = width;
|
||||
createInfo.imageExtent.height = height;
|
||||
createInfo.imageArrayLayers = 1;
|
||||
createInfo.imageUsage = VulkanImageUsage(static_cast<dawn::TextureUsage>(usage),
|
||||
createInfo.imageUsage = VulkanImageUsage(static_cast<wgpu::TextureUsage>(usage),
|
||||
mDevice->GetValidInternalFormat(mConfig.format));
|
||||
createInfo.imageSharingMode = VK_SHARING_MODE_EXCLUSIVE;
|
||||
createInfo.queueFamilyIndexCount = 0;
|
||||
@ -236,7 +236,7 @@ namespace dawn_native { namespace vulkan {
|
||||
return DAWN_SWAP_CHAIN_NO_ERROR;
|
||||
}
|
||||
|
||||
dawn::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
wgpu::TextureFormat NativeSwapChainImpl::GetPreferredFormat() const {
|
||||
return mConfig.format;
|
||||
}
|
||||
|
||||
|
@ -39,11 +39,11 @@ namespace dawn_native { namespace vulkan {
|
||||
DawnSwapChainError GetNextTexture(DawnSwapChainNextTexture* nextTexture);
|
||||
DawnSwapChainError Present();
|
||||
|
||||
dawn::TextureFormat GetPreferredFormat() const;
|
||||
wgpu::TextureFormat GetPreferredFormat() const;
|
||||
|
||||
struct ChosenConfig {
|
||||
VkFormat nativeFormat;
|
||||
dawn::TextureFormat format;
|
||||
wgpu::TextureFormat format;
|
||||
VkColorSpaceKHR colorSpace;
|
||||
VkSurfaceTransformFlagBitsKHR preTransform;
|
||||
uint32_t minImageCount;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user