Dawn: s/dawn::/wgpu::/g.
The new webgpu_cpp.h hotness for native apps brings with it a new
namespace: wgpu. This is a straight substitution.
Note: no Skia API changes.
Change-Id: I12b26417e76838cd8fa2b39b8161cbaa2cd8fa78
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/251660
Commit-Queue: Stephen White <senorblanco@chromium.org>
Commit-Queue: Mike Klein <mtklein@google.com>
Reviewed-by: Mike Klein <mtklein@google.com>
diff --git a/src/gpu/GrBackendSurface.cpp b/src/gpu/GrBackendSurface.cpp
index fa95520..e10b79e 100644
--- a/src/gpu/GrBackendSurface.cpp
+++ b/src/gpu/GrBackendSurface.cpp
@@ -128,14 +128,14 @@
}
#ifdef SK_DAWN
-GrBackendFormat::GrBackendFormat(dawn::TextureFormat format)
+GrBackendFormat::GrBackendFormat(wgpu::TextureFormat format)
: fBackend(GrBackendApi::kDawn)
, fValid(true)
, fDawnFormat(format)
, fTextureType(GrTextureType::k2D) {
}
-bool GrBackendFormat::asDawnFormat(dawn::TextureFormat* format) const {
+bool GrBackendFormat::asDawnFormat(wgpu::TextureFormat* format) const {
SkASSERT(format);
if (this->isValid() && GrBackendApi::kDawn == fBackend) {
*format = fDawnFormat;
diff --git a/src/gpu/GrLegacyDirectContext.cpp b/src/gpu/GrLegacyDirectContext.cpp
index 15746e9..afba0b9 100644
--- a/src/gpu/GrLegacyDirectContext.cpp
+++ b/src/gpu/GrLegacyDirectContext.cpp
@@ -222,12 +222,12 @@
#endif
#ifdef SK_DAWN
-sk_sp<GrContext> GrContext::MakeDawn(const dawn::Device& device) {
+sk_sp<GrContext> GrContext::MakeDawn(const wgpu::Device& device) {
GrContextOptions defaultOptions;
return MakeDawn(device, defaultOptions);
}
-sk_sp<GrContext> GrContext::MakeDawn(const dawn::Device& device, const GrContextOptions& options) {
+sk_sp<GrContext> GrContext::MakeDawn(const wgpu::Device& device, const GrContextOptions& options) {
sk_sp<GrContext> context(new GrLegacyDirectContext(GrBackendApi::kDawn, options));
context->fGpu = GrDawnGpu::Make(device, options, context.get());
diff --git a/src/gpu/dawn/GrDawnBuffer.cpp b/src/gpu/dawn/GrDawnBuffer.cpp
index b01cbcd..6af4133 100644
--- a/src/gpu/dawn/GrDawnBuffer.cpp
+++ b/src/gpu/dawn/GrDawnBuffer.cpp
@@ -10,19 +10,19 @@
#include "src/gpu/dawn/GrDawnGpu.h"
namespace {
- dawn::BufferUsage GrGpuBufferTypeToDawnUsageBit(GrGpuBufferType type) {
+ wgpu::BufferUsage GrGpuBufferTypeToDawnUsageBit(GrGpuBufferType type) {
switch (type) {
case GrGpuBufferType::kVertex:
- return dawn::BufferUsage::Vertex;
+ return wgpu::BufferUsage::Vertex;
case GrGpuBufferType::kIndex:
- return dawn::BufferUsage::Index;
+ return wgpu::BufferUsage::Index;
case GrGpuBufferType::kXferCpuToGpu:
- return dawn::BufferUsage::CopySrc;
+ return wgpu::BufferUsage::CopySrc;
case GrGpuBufferType::kXferGpuToCpu:
- return dawn::BufferUsage::CopyDst;
+ return wgpu::BufferUsage::CopyDst;
default:
SkASSERT(!"buffer type not supported by Dawn");
- return dawn::BufferUsage::Vertex;
+ return wgpu::BufferUsage::Vertex;
}
}
}
@@ -31,9 +31,9 @@
GrAccessPattern pattern)
: INHERITED(gpu, sizeInBytes, type, pattern)
, fStagingBuffer(nullptr) {
- dawn::BufferDescriptor bufferDesc;
+ wgpu::BufferDescriptor bufferDesc;
bufferDesc.size = sizeInBytes;
- bufferDesc.usage = GrGpuBufferTypeToDawnUsageBit(type) | dawn::BufferUsage::CopyDst;
+ bufferDesc.usage = GrGpuBufferTypeToDawnUsageBit(type) | wgpu::BufferUsage::CopyDst;
fBuffer = this->getDawnGpu()->device().CreateBuffer(&bufferDesc);
this->registerWithCache(SkBudgeted::kYes);
}
diff --git a/src/gpu/dawn/GrDawnBuffer.h b/src/gpu/dawn/GrDawnBuffer.h
index 17fa1c8..1d762e5 100644
--- a/src/gpu/dawn/GrDawnBuffer.h
+++ b/src/gpu/dawn/GrDawnBuffer.h
@@ -24,10 +24,10 @@
bool onUpdateData(const void* src, size_t srcSizeInBytes) override;
GrDawnGpu* getDawnGpu() const;
- dawn::Buffer get() const { return fBuffer; }
+ wgpu::Buffer get() const { return fBuffer; }
private:
- dawn::Buffer fBuffer;
+ wgpu::Buffer fBuffer;
GrDawnStagingBuffer* fStagingBuffer;
typedef GrGpuBuffer INHERITED;
};
diff --git a/src/gpu/dawn/GrDawnCaps.cpp b/src/gpu/dawn/GrDawnCaps.cpp
index 8caa134..c55a769 100644
--- a/src/gpu/dawn/GrDawnCaps.cpp
+++ b/src/gpu/dawn/GrDawnCaps.cpp
@@ -39,13 +39,13 @@
bool GrDawnCaps::isFormatTexturable(const GrBackendFormat& format) const {
// Currently, all the formats in GrDawnFormatToPixelConfig are texturable.
- dawn::TextureFormat dawnFormat;
+ wgpu::TextureFormat dawnFormat;
return format.asDawnFormat(&dawnFormat);
}
GrPixelConfig GrDawnCaps::onGetConfigFromBackendFormat(const GrBackendFormat& format,
GrColorType colorType) const {
- dawn::TextureFormat dawnFormat;
+ wgpu::TextureFormat dawnFormat;
if (!format.asDawnFormat(&dawnFormat)) {
return kUnknown_GrPixelConfig;
}
@@ -53,14 +53,14 @@
case GrColorType::kUnknown:
return kUnknown_GrPixelConfig;
case GrColorType::kAlpha_8:
- if (dawn::TextureFormat::R8Unorm == dawnFormat) {
+ if (wgpu::TextureFormat::R8Unorm == dawnFormat) {
return kAlpha_8_as_Red_GrPixelConfig;
}
break;
case GrColorType::kRGBA_8888:
- if (dawn::TextureFormat::RGBA8Unorm == dawnFormat) {
+ if (wgpu::TextureFormat::RGBA8Unorm == dawnFormat) {
return kRGBA_8888_GrPixelConfig;
- } else if (dawn::TextureFormat::BGRA8Unorm == dawnFormat) {
+ } else if (wgpu::TextureFormat::BGRA8Unorm == dawnFormat) {
// FIXME: This shouldn't be necessary, but on some platforms (Mac)
// Skia byte order is RGBA, while preferred swap format is BGRA.
return kBGRA_8888_GrPixelConfig;
@@ -69,9 +69,9 @@
case GrColorType::kRGB_888x:
break;
case GrColorType::kBGRA_8888:
- if (dawn::TextureFormat::BGRA8Unorm == dawnFormat) {
+ if (wgpu::TextureFormat::BGRA8Unorm == dawnFormat) {
return kBGRA_8888_GrPixelConfig;
- } else if (dawn::TextureFormat::RGBA8Unorm == dawnFormat) {
+ } else if (wgpu::TextureFormat::RGBA8Unorm == dawnFormat) {
return kRGBA_8888_GrPixelConfig;
}
break;
@@ -108,18 +108,18 @@
bool GrDawnCaps::isFormatTexturableAndUploadable(GrColorType ct,
const GrBackendFormat& format) const {
- dawn::TextureFormat dawnFormat;
+ wgpu::TextureFormat dawnFormat;
if (!format.asDawnFormat(&dawnFormat)) {
return false;
}
switch (ct) {
case GrColorType::kAlpha_8:
- return dawn::TextureFormat::R8Unorm == dawnFormat;
+ return wgpu::TextureFormat::R8Unorm == dawnFormat;
case GrColorType::kRGBA_8888:
case GrColorType::kRGB_888x:
case GrColorType::kBGRA_8888:
- return dawn::TextureFormat::RGBA8Unorm == dawnFormat ||
- dawn::TextureFormat::BGRA8Unorm == dawnFormat;
+ return wgpu::TextureFormat::RGBA8Unorm == dawnFormat ||
+ wgpu::TextureFormat::BGRA8Unorm == dawnFormat;
default:
return false;
}
@@ -127,7 +127,7 @@
bool GrDawnCaps::isFormatRenderable(const GrBackendFormat& format,
int sampleCount) const {
- dawn::TextureFormat dawnFormat;
+ wgpu::TextureFormat dawnFormat;
if (!format.isValid() || sampleCount > 1 || !format.asDawnFormat(&dawnFormat)) {
return false;
}
@@ -141,7 +141,7 @@
}
size_t GrDawnCaps::bytesPerPixel(const GrBackendFormat& backendFormat) const {
- dawn::TextureFormat dawnFormat;
+ wgpu::TextureFormat dawnFormat;
if (!backendFormat.asDawnFormat(&dawnFormat)) {
return 0;
}
@@ -150,7 +150,7 @@
int GrDawnCaps::getRenderTargetSampleCount(int requestedCount,
const GrBackendFormat& backendFormat) const {
- dawn::TextureFormat dawnFormat;
+ wgpu::TextureFormat dawnFormat;
if (!backendFormat.asDawnFormat(&dawnFormat)) {
return 0;
}
@@ -167,7 +167,7 @@
if (config == kUnknown_GrPixelConfig) {
return GrBackendFormat();
}
- dawn::TextureFormat format;
+ wgpu::TextureFormat format;
if (!GrPixelConfigToDawnFormat(config, &format)) {
return GrBackendFormat();
}
@@ -196,15 +196,15 @@
GrColorType GrDawnCaps::getYUVAColorTypeFromBackendFormat(const GrBackendFormat& backendFormat,
bool isAlphaChannel) const {
- dawn::TextureFormat textureFormat;
+ wgpu::TextureFormat textureFormat;
if (!backendFormat.asDawnFormat(&textureFormat)) {
return GrColorType::kUnknown;
}
switch (textureFormat) {
- case dawn::TextureFormat::R8Unorm: return isAlphaChannel ? GrColorType::kAlpha_8
+ case wgpu::TextureFormat::R8Unorm: return isAlphaChannel ? GrColorType::kAlpha_8
: GrColorType::kGray_8;
- case dawn::TextureFormat::RGBA8Unorm: return GrColorType::kRGBA_8888;
- case dawn::TextureFormat::BGRA8Unorm: return GrColorType::kBGRA_8888;
+ case wgpu::TextureFormat::RGBA8Unorm: return GrColorType::kRGBA_8888;
+ case wgpu::TextureFormat::BGRA8Unorm: return GrColorType::kBGRA_8888;
default: return GrColorType::kUnknown;
}
}
@@ -212,13 +212,13 @@
#if GR_TEST_UTILS
std::vector<GrCaps::TestFormatColorTypeCombination> GrDawnCaps::getTestingCombinations() const {
std::vector<GrCaps::TestFormatColorTypeCombination> combos = {
- { GrColorType::kAlpha_8, GrBackendFormat::MakeDawn(dawn::TextureFormat::R8Unorm) },
- { GrColorType::kRGBA_8888, GrBackendFormat::MakeDawn(dawn::TextureFormat::RGBA8Unorm) },
- { GrColorType::kRGBA_8888, GrBackendFormat::MakeDawn(dawn::TextureFormat::BGRA8Unorm) },
- { GrColorType::kRGB_888x, GrBackendFormat::MakeDawn(dawn::TextureFormat::RGBA8Unorm) },
- { GrColorType::kRGB_888x, GrBackendFormat::MakeDawn(dawn::TextureFormat::BGRA8Unorm) },
- { GrColorType::kBGRA_8888, GrBackendFormat::MakeDawn(dawn::TextureFormat::BGRA8Unorm) },
- { GrColorType::kBGRA_8888, GrBackendFormat::MakeDawn(dawn::TextureFormat::RGBA8Unorm) },
+ { GrColorType::kAlpha_8, GrBackendFormat::MakeDawn(wgpu::TextureFormat::R8Unorm) },
+ { GrColorType::kRGBA_8888, GrBackendFormat::MakeDawn(wgpu::TextureFormat::RGBA8Unorm) },
+ { GrColorType::kRGBA_8888, GrBackendFormat::MakeDawn(wgpu::TextureFormat::BGRA8Unorm) },
+ { GrColorType::kRGB_888x, GrBackendFormat::MakeDawn(wgpu::TextureFormat::RGBA8Unorm) },
+ { GrColorType::kRGB_888x, GrBackendFormat::MakeDawn(wgpu::TextureFormat::BGRA8Unorm) },
+ { GrColorType::kBGRA_8888, GrBackendFormat::MakeDawn(wgpu::TextureFormat::BGRA8Unorm) },
+ { GrColorType::kBGRA_8888, GrBackendFormat::MakeDawn(wgpu::TextureFormat::RGBA8Unorm) },
};
#ifdef SK_DEBUG
diff --git a/src/gpu/dawn/GrDawnGpu.cpp b/src/gpu/dawn/GrDawnGpu.cpp
index 186c1e6..2a89ac7 100644
--- a/src/gpu/dawn/GrDawnGpu.cpp
+++ b/src/gpu/dawn/GrDawnGpu.cpp
@@ -37,32 +37,32 @@
const int kMaxRenderPipelineEntries = 1024;
-static dawn::FilterMode to_dawn_filter_mode(GrSamplerState::Filter filter) {
+static wgpu::FilterMode to_dawn_filter_mode(GrSamplerState::Filter filter) {
switch (filter) {
case GrSamplerState::Filter::kNearest:
- return dawn::FilterMode::Nearest;
+ return wgpu::FilterMode::Nearest;
case GrSamplerState::Filter::kBilerp:
case GrSamplerState::Filter::kMipMap:
- return dawn::FilterMode::Linear;
+ return wgpu::FilterMode::Linear;
default:
SkASSERT(!"unsupported filter mode");
- return dawn::FilterMode::Nearest;
+ return wgpu::FilterMode::Nearest;
}
}
-static dawn::AddressMode to_dawn_address_mode(GrSamplerState::WrapMode wrapMode) {
+static wgpu::AddressMode to_dawn_address_mode(GrSamplerState::WrapMode wrapMode) {
switch (wrapMode) {
case GrSamplerState::WrapMode::kClamp:
- return dawn::AddressMode::ClampToEdge;
+ return wgpu::AddressMode::ClampToEdge;
case GrSamplerState::WrapMode::kRepeat:
- return dawn::AddressMode::Repeat;
+ return wgpu::AddressMode::Repeat;
case GrSamplerState::WrapMode::kMirrorRepeat:
- return dawn::AddressMode::MirrorRepeat;
+ return wgpu::AddressMode::MirrorRepeat;
case GrSamplerState::WrapMode::kClampToBorder:
SkASSERT(!"unsupported address mode");
}
SkASSERT(!"unsupported address mode");
- return dawn::AddressMode::ClampToEdge;
+ return wgpu::AddressMode::ClampToEdge;
}
@@ -108,7 +108,7 @@
}
};
-sk_sp<GrGpu> GrDawnGpu::Make(const dawn::Device& device,
+sk_sp<GrGpu> GrDawnGpu::Make(const wgpu::Device& device,
const GrContextOptions& options, GrContext* context) {
if (!device) {
return nullptr;
@@ -120,12 +120,12 @@
////////////////////////////////////////////////////////////////////////////////
GrDawnGpu::GrDawnGpu(GrContext* context, const GrContextOptions& options,
- const dawn::Device& device)
+ const wgpu::Device& device)
: INHERITED(context)
, fDevice(device)
, fQueue(device.CreateQueue())
, fCompiler(new SkSL::Compiler())
- , fUniformRingBuffer(this, dawn::BufferUsage::Uniform)
+ , fUniformRingBuffer(this, wgpu::BufferUsage::Uniform)
, fRenderPipelineCache(kMaxRenderPipelineEntries)
, fStagingManager(fDevice) {
fCaps.reset(new GrDawnCaps(options));
@@ -199,7 +199,7 @@
int mipLevelCount,
uint32_t levelClearMask) {
SkASSERT(!levelClearMask);
- dawn::TextureFormat format;
+ wgpu::TextureFormat format;
if (!backendFormat.asDawnFormat(&format)) {
return nullptr;
}
@@ -313,7 +313,7 @@
int numMipLevels,
const SkColor4f* color,
GrProtected isProtected) {
- dawn::TextureFormat format;
+ wgpu::TextureFormat format;
if (!backendFormat.asDawnFormat(&format)) {
return GrBackendTexture();
}
@@ -325,14 +325,14 @@
return GrBackendTexture();
}
- dawn::TextureDescriptor desc;
+ wgpu::TextureDescriptor desc;
desc.usage =
- dawn::TextureUsage::Sampled |
- dawn::TextureUsage::CopySrc |
- dawn::TextureUsage::CopyDst;
+ wgpu::TextureUsage::Sampled |
+ wgpu::TextureUsage::CopySrc |
+ wgpu::TextureUsage::CopyDst;
if (GrRenderable::kYes == renderable) {
- desc.usage |= dawn::TextureUsage::OutputAttachment;
+ desc.usage |= wgpu::TextureUsage::OutputAttachment;
}
desc.size.width = width;
@@ -347,7 +347,7 @@
desc.mipLevelCount = SkMipMap::ComputeLevelCount(width, height) + 1;
}
- dawn::Texture tex = this->device().CreateTexture(&desc);
+ wgpu::Texture tex = this->device().CreateTexture(&desc);
size_t bpp = GrDawnBytesPerPixel(format);
size_t baseLayerSize = bpp * width * height;
@@ -359,8 +359,8 @@
pixels = defaultStorage.get();
memset(defaultStorage.get(), 0, baseLayerSize);
}
- dawn::Device device = this->device();
- dawn::CommandEncoder copyEncoder = fDevice.CreateCommandEncoder();
+ wgpu::Device device = this->device();
+ wgpu::CommandEncoder copyEncoder = fDevice.CreateCommandEncoder();
int w = width, h = height;
for (uint32_t i = 0; i < desc.mipLevelCount; i++) {
size_t origRowBytes = bpp * w;
@@ -378,24 +378,24 @@
src += origRowBytes;
}
}
- dawn::Buffer buffer = stagingBuffer->fBuffer;
+ wgpu::Buffer buffer = stagingBuffer->fBuffer;
buffer.Unmap();
stagingBuffer->fData = nullptr;
- dawn::BufferCopyView srcBuffer;
+ wgpu::BufferCopyView srcBuffer;
srcBuffer.buffer = buffer;
srcBuffer.offset = 0;
srcBuffer.rowPitch = rowBytes;
srcBuffer.imageHeight = h;
- dawn::TextureCopyView dstTexture;
+ wgpu::TextureCopyView dstTexture;
dstTexture.texture = tex;
dstTexture.mipLevel = i;
dstTexture.origin = {0, 0, 0};
- dawn::Extent3D copySize = {(uint32_t) w, (uint32_t) h, 1};
+ wgpu::Extent3D copySize = {(uint32_t) w, (uint32_t) h, 1};
copyEncoder.CopyBufferToTexture(&srcBuffer, &dstTexture, ©Size);
w = SkTMax(1, w / 2);
h = SkTMax(1, h / 2);
}
- dawn::CommandBuffer cmdBuf = copyEncoder.Finish();
+ wgpu::CommandBuffer cmdBuf = copyEncoder.Finish();
fQueue.Submit(1, &cmdBuf);
GrDawnImageInfo info;
info.fTexture = tex;
@@ -429,22 +429,22 @@
return GrBackendRenderTarget();
}
- dawn::TextureFormat format;
+ wgpu::TextureFormat format;
if (!GrPixelConfigToDawnFormat(config, &format)) {
return GrBackendRenderTarget();
}
- dawn::TextureDescriptor desc;
+ wgpu::TextureDescriptor desc;
desc.usage =
- dawn::TextureUsage::CopySrc |
- dawn::TextureUsage::OutputAttachment;
+ wgpu::TextureUsage::CopySrc |
+ wgpu::TextureUsage::OutputAttachment;
desc.size.width = width;
desc.size.height = height;
desc.size.depth = 1;
desc.format = format;
- dawn::Texture tex = this->device().CreateTexture(&desc);
+ wgpu::Texture tex = this->device().CreateTexture(&desc);
GrDawnImageInfo info;
info.fTexture = tex;
@@ -481,7 +481,7 @@
this->flush();
}
-static dawn::Texture get_dawn_texture_from_surface(GrSurface* src) {
+static wgpu::Texture get_dawn_texture_from_surface(GrSurface* src) {
if (auto rt = static_cast<GrDawnRenderTarget*>(src->asRenderTarget())) {
return rt->texture();
} else if (auto t = static_cast<GrDawnTexture*>(src->asTexture())) {
@@ -495,21 +495,21 @@
GrSurface* src,
const SkIRect& srcRect,
const SkIPoint& dstPoint) {
- dawn::Texture srcTexture = get_dawn_texture_from_surface(src);
- dawn::Texture dstTexture = get_dawn_texture_from_surface(dst);
+ wgpu::Texture srcTexture = get_dawn_texture_from_surface(src);
+ wgpu::Texture dstTexture = get_dawn_texture_from_surface(dst);
if (!srcTexture || !dstTexture) {
return false;
}
uint32_t width = srcRect.width(), height = srcRect.height();
- dawn::TextureCopyView srcTextureView, dstTextureView;
+ wgpu::TextureCopyView srcTextureView, dstTextureView;
srcTextureView.texture = srcTexture;
srcTextureView.origin = {(uint32_t) srcRect.x(), (uint32_t) srcRect.y(), 0};
dstTextureView.texture = dstTexture;
dstTextureView.origin = {(uint32_t) dstPoint.x(), (uint32_t) dstPoint.y(), 0};
- dawn::Extent3D copySize = {width, height, 1};
+ wgpu::Extent3D copySize = {width, height, 1};
this->getCopyEncoder().CopyTextureToTexture(&srcTextureView, &dstTextureView, ©Size);
return true;
}
@@ -522,7 +522,7 @@
bool GrDawnGpu::onReadPixels(GrSurface* surface, int left, int top, int width, int height,
GrColorType surfaceColorType, GrColorType dstColorType, void* buffer,
size_t rowBytes) {
- dawn::Texture tex = get_dawn_texture_from_surface(surface);
+ wgpu::Texture tex = get_dawn_texture_from_surface(surface);
if (0 == rowBytes) {
return false;
@@ -532,23 +532,23 @@
rowBytes = GrDawnRoundRowBytes(rowBytes);
int sizeInBytes = rowBytes * height;
- dawn::BufferDescriptor desc;
- desc.usage = dawn::BufferUsage::CopyDst | dawn::BufferUsage::MapRead;
+ wgpu::BufferDescriptor desc;
+ desc.usage = wgpu::BufferUsage::CopyDst | wgpu::BufferUsage::MapRead;
desc.size = sizeInBytes;
- dawn::Buffer buf = device().CreateBuffer(&desc);
+ wgpu::Buffer buf = device().CreateBuffer(&desc);
- dawn::TextureCopyView srcTexture;
+ wgpu::TextureCopyView srcTexture;
srcTexture.texture = tex;
srcTexture.origin = {(uint32_t) left, (uint32_t) top, 0};
- dawn::BufferCopyView dstBuffer;
+ wgpu::BufferCopyView dstBuffer;
dstBuffer.buffer = buf;
dstBuffer.offset = 0;
dstBuffer.rowPitch = rowBytes;
dstBuffer.imageHeight = height;
- dawn::Extent3D copySize = {(uint32_t) width, (uint32_t) height, 1};
+ wgpu::Extent3D copySize = {(uint32_t) width, (uint32_t) height, 1};
this->getCopyEncoder().CopyTextureToBuffer(&srcTexture, &dstBuffer, ©Size);
flush();
@@ -640,9 +640,9 @@
return *program;
}
- dawn::TextureFormat colorFormat;
+ wgpu::TextureFormat colorFormat;
SkAssertResult(GrPixelConfigToDawnFormat(rt->config(), &colorFormat));
- dawn::TextureFormat stencilFormat = dawn::TextureFormat::Depth24PlusStencil8;
+ wgpu::TextureFormat stencilFormat = wgpu::TextureFormat::Depth24PlusStencil8;
sk_sp<GrDawnProgram> program = GrDawnProgramBuilder::Build(
this, rt, programInfo, primitiveType, colorFormat,
@@ -651,22 +651,22 @@
return program;
}
-dawn::Sampler GrDawnGpu::getOrCreateSampler(const GrSamplerState& samplerState) {
+wgpu::Sampler GrDawnGpu::getOrCreateSampler(const GrSamplerState& samplerState) {
auto i = fSamplers.find(samplerState);
if (i != fSamplers.end()) {
return i->second;
}
- dawn::SamplerDescriptor desc;
+ wgpu::SamplerDescriptor desc;
desc.addressModeU = to_dawn_address_mode(samplerState.wrapModeX());
desc.addressModeV = to_dawn_address_mode(samplerState.wrapModeY());
- desc.addressModeW = dawn::AddressMode::ClampToEdge;
+ desc.addressModeW = wgpu::AddressMode::ClampToEdge;
desc.magFilter = desc.minFilter = to_dawn_filter_mode(samplerState.filter());
- desc.mipmapFilter = dawn::FilterMode::Linear;
+ desc.mipmapFilter = wgpu::FilterMode::Linear;
desc.lodMinClamp = 0.0f;
desc.lodMaxClamp = 1000.0f;
- desc.compare = dawn::CompareFunction::Never;
- dawn::Sampler sampler = device().CreateSampler(&desc);
- fSamplers.insert(std::pair<GrSamplerState, dawn::Sampler>(samplerState, sampler));
+ desc.compare = wgpu::CompareFunction::Never;
+ wgpu::Sampler sampler = device().CreateSampler(&desc);
+ fSamplers.insert(std::pair<GrSamplerState, wgpu::Sampler>(samplerState, sampler));
return sampler;
}
@@ -678,13 +678,13 @@
return fStagingManager.findOrCreateStagingBuffer(size);
}
-void GrDawnGpu::appendCommandBuffer(dawn::CommandBuffer commandBuffer) {
+void GrDawnGpu::appendCommandBuffer(wgpu::CommandBuffer commandBuffer) {
if (commandBuffer) {
fCommandBuffers.push_back(commandBuffer);
}
}
-dawn::CommandEncoder GrDawnGpu::getCopyEncoder() {
+wgpu::CommandEncoder GrDawnGpu::getCopyEncoder() {
if (!fCopyEncoder) {
fCopyEncoder = fDevice.CreateCommandEncoder();
}
diff --git a/src/gpu/dawn/GrDawnGpu.h b/src/gpu/dawn/GrDawnGpu.h
index 96cb54b..e9bc06d 100644
--- a/src/gpu/dawn/GrDawnGpu.h
+++ b/src/gpu/dawn/GrDawnGpu.h
@@ -26,15 +26,15 @@
class GrDawnGpu : public GrGpu {
public:
- static sk_sp<GrGpu> Make(const dawn::Device& device, const GrContextOptions&, GrContext*);
- GrDawnGpu(GrContext* context, const GrContextOptions& options, const dawn::Device& device);
+ static sk_sp<GrGpu> Make(const wgpu::Device& device, const GrContextOptions&, GrContext*);
+ GrDawnGpu(GrContext* context, const GrContextOptions& options, const wgpu::Device& device);
~GrDawnGpu() override;
void disconnect(DisconnectType) override;
- const dawn::Device& device() const { return fDevice; }
- const dawn::Queue& queue() const { return fQueue; }
+ const wgpu::Device& device() const { return fDevice; }
+ const wgpu::Queue& queue() const { return fQueue; }
void xferBarrier(GrRenderTarget*, GrXferBarrierType) override {}
@@ -92,14 +92,14 @@
const GrProgramInfo& programInfo,
GrPrimitiveType primitiveType);
- dawn::Sampler getOrCreateSampler(const GrSamplerState& samplerState);
+ wgpu::Sampler getOrCreateSampler(const GrSamplerState& samplerState);
GrDawnRingBuffer::Slice allocateUniformRingBufferSlice(int size);
GrDawnStagingBuffer* getStagingBuffer(size_t size);
GrDawnStagingManager* getStagingManager() { return &fStagingManager; }
- dawn::CommandEncoder getCopyEncoder();
+ wgpu::CommandEncoder getCopyEncoder();
void flushCopyEncoder();
- void appendCommandBuffer(dawn::CommandBuffer commandBuffer);
+ void appendCommandBuffer(wgpu::CommandBuffer commandBuffer);
private:
void onResetContext(uint32_t resetBits) override {}
@@ -161,13 +161,13 @@
void onFinishFlush(GrSurfaceProxy*[], int n, SkSurface::BackendSurfaceAccess access,
const GrFlushInfo& info, const GrPrepareForExternalIORequests&) override;
- dawn::Device fDevice;
- dawn::Queue fQueue;
+ wgpu::Device fDevice;
+ wgpu::Queue fQueue;
std::unique_ptr<SkSL::Compiler> fCompiler;
std::unique_ptr<GrDawnOpsRenderPass> fOpsRenderPass;
GrDawnRingBuffer fUniformRingBuffer;
- dawn::CommandEncoder fCopyEncoder;
- std::vector<dawn::CommandBuffer> fCommandBuffers;
+ wgpu::CommandEncoder fCopyEncoder;
+ std::vector<wgpu::CommandBuffer> fCommandBuffers;
struct ProgramDescHash {
uint32_t operator()(const GrProgramDesc& desc) const {
@@ -182,7 +182,7 @@
};
SkLRUCache<GrProgramDesc, sk_sp<GrDawnProgram>, ProgramDescHash> fRenderPipelineCache;
- std::unordered_map<GrSamplerState, dawn::Sampler, SamplerHash> fSamplers;
+ std::unordered_map<GrSamplerState, wgpu::Sampler, SamplerHash> fSamplers;
GrDawnStagingManager fStagingManager;
typedef GrGpu INHERITED;
diff --git a/src/gpu/dawn/GrDawnOpsRenderPass.cpp b/src/gpu/dawn/GrDawnOpsRenderPass.cpp
index 144f16b..b0f4b1c 100644
--- a/src/gpu/dawn/GrDawnOpsRenderPass.cpp
+++ b/src/gpu/dawn/GrDawnOpsRenderPass.cpp
@@ -24,19 +24,19 @@
////////////////////////////////////////////////////////////////////////////////
-static dawn::LoadOp to_dawn_load_op(GrLoadOp loadOp) {
+static wgpu::LoadOp to_dawn_load_op(GrLoadOp loadOp) {
switch (loadOp) {
case GrLoadOp::kLoad:
- return dawn::LoadOp::Load;
+ return wgpu::LoadOp::Load;
case GrLoadOp::kDiscard:
// Use LoadOp::Load to emulate DontCare.
// Dawn doesn't have DontCare, for security reasons.
// Load should be equivalent to DontCare for desktop; Clear would
// probably be better for tilers. If Dawn does add DontCare
// as an extension, use it here.
- return dawn::LoadOp::Load;
+ return wgpu::LoadOp::Load;
case GrLoadOp::kClear:
- return dawn::LoadOp::Clear;
+ return wgpu::LoadOp::Clear;
default:
SK_ABORT("Invalid LoadOp");
}
@@ -49,40 +49,40 @@
, fGpu(gpu)
, fColorInfo(colorInfo) {
fEncoder = fGpu->device().CreateCommandEncoder();
- dawn::LoadOp colorOp = to_dawn_load_op(colorInfo.fLoadOp);
- dawn::LoadOp stencilOp = to_dawn_load_op(stencilInfo.fLoadOp);
+ wgpu::LoadOp colorOp = to_dawn_load_op(colorInfo.fLoadOp);
+ wgpu::LoadOp stencilOp = to_dawn_load_op(stencilInfo.fLoadOp);
fPassEncoder = beginRenderPass(colorOp, stencilOp);
}
-dawn::RenderPassEncoder GrDawnOpsRenderPass::beginRenderPass(dawn::LoadOp colorOp,
- dawn::LoadOp stencilOp) {
- dawn::Texture texture = static_cast<GrDawnRenderTarget*>(fRenderTarget)->texture();
+wgpu::RenderPassEncoder GrDawnOpsRenderPass::beginRenderPass(wgpu::LoadOp colorOp,
+ wgpu::LoadOp stencilOp) {
+ wgpu::Texture texture = static_cast<GrDawnRenderTarget*>(fRenderTarget)->texture();
auto stencilAttachment = static_cast<GrDawnStencilAttachment*>(
fRenderTarget->renderTargetPriv().getStencilAttachment());
- dawn::TextureViewDescriptor desc;
+ wgpu::TextureViewDescriptor desc;
desc.mipLevelCount = 1;
- dawn::TextureView colorView = texture.CreateView(&desc);
+ wgpu::TextureView colorView = texture.CreateView(&desc);
const float *c = fColorInfo.fClearColor.vec();
- dawn::RenderPassColorAttachmentDescriptor colorAttachment;
+ wgpu::RenderPassColorAttachmentDescriptor colorAttachment;
colorAttachment.attachment = colorView;
colorAttachment.resolveTarget = nullptr;
colorAttachment.clearColor = { c[0], c[1], c[2], c[3] };
colorAttachment.loadOp = colorOp;
- colorAttachment.storeOp = dawn::StoreOp::Store;
- dawn::RenderPassColorAttachmentDescriptor* colorAttachments = { &colorAttachment };
- dawn::RenderPassDescriptor renderPassDescriptor;
+ colorAttachment.storeOp = wgpu::StoreOp::Store;
+ wgpu::RenderPassColorAttachmentDescriptor* colorAttachments = { &colorAttachment };
+ wgpu::RenderPassDescriptor renderPassDescriptor;
renderPassDescriptor.colorAttachmentCount = 1;
renderPassDescriptor.colorAttachments = colorAttachments;
if (stencilAttachment) {
- dawn::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
+ wgpu::RenderPassDepthStencilAttachmentDescriptor depthStencilAttachment;
depthStencilAttachment.attachment = stencilAttachment->view();
depthStencilAttachment.depthLoadOp = stencilOp;
depthStencilAttachment.stencilLoadOp = stencilOp;
depthStencilAttachment.clearDepth = 1.0f;
depthStencilAttachment.clearStencil = 0;
- depthStencilAttachment.depthStoreOp = dawn::StoreOp::Store;
- depthStencilAttachment.stencilStoreOp = dawn::StoreOp::Store;
+ depthStencilAttachment.depthStoreOp = wgpu::StoreOp::Store;
+ depthStencilAttachment.stencilStoreOp = wgpu::StoreOp::Store;
renderPassDescriptor.depthStencilAttachment = &depthStencilAttachment;
} else {
renderPassDescriptor.depthStencilAttachment = nullptr;
@@ -109,12 +109,12 @@
void GrDawnOpsRenderPass::onClearStencilClip(const GrFixedClip& clip, bool insideStencilMask) {
fPassEncoder.EndPass();
- fPassEncoder = beginRenderPass(dawn::LoadOp::Load, dawn::LoadOp::Clear);
+ fPassEncoder = beginRenderPass(wgpu::LoadOp::Load, wgpu::LoadOp::Clear);
}
void GrDawnOpsRenderPass::onClear(const GrFixedClip& clip, const SkPMColor4f& color) {
fPassEncoder.EndPass();
- fPassEncoder = beginRenderPass(dawn::LoadOp::Clear, dawn::LoadOp::Load);
+ fPassEncoder = beginRenderPass(wgpu::LoadOp::Clear, wgpu::LoadOp::Load);
}
////////////////////////////////////////////////////////////////////////////////
@@ -155,7 +155,7 @@
}
GrXferProcessor::BlendInfo blendInfo = pipeline.getXferProcessor().getBlendInfo();
const float* c = blendInfo.fBlendConstant.vec();
- dawn::Color color{c[0], c[1], c[2], c[3]};
+ wgpu::Color color{c[0], c[1], c[2], c[3]};
fPassEncoder.SetBlendColor(&color);
this->setScissorState(programInfo);
}
@@ -180,7 +180,7 @@
const GrBuffer* instanceBuffer,
int instanceCount,
int baseInstance) {
- dawn::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get();
+ wgpu::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get();
fPassEncoder.SetVertexBuffer(0, vb);
fPassEncoder.Draw(vertexCount, 1, baseVertex, baseInstance);
fGpu->stats()->incNumDraws();
@@ -196,8 +196,8 @@
int instanceCount,
int baseInstance,
GrPrimitiveRestart restart) {
- dawn::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get();
- dawn::Buffer ib = static_cast<const GrDawnBuffer*>(indexBuffer)->get();
+ wgpu::Buffer vb = static_cast<const GrDawnBuffer*>(vertexBuffer)->get();
+ wgpu::Buffer ib = static_cast<const GrDawnBuffer*>(indexBuffer)->get();
fPassEncoder.SetIndexBuffer(ib);
fPassEncoder.SetVertexBuffer(0, vb);
fPassEncoder.DrawIndexed(indexCount, 1, baseIndex, baseVertex, baseInstance);
diff --git a/src/gpu/dawn/GrDawnOpsRenderPass.h b/src/gpu/dawn/GrDawnOpsRenderPass.h
index a1a9036..1573015 100644
--- a/src/gpu/dawn/GrDawnOpsRenderPass.h
+++ b/src/gpu/dawn/GrDawnOpsRenderPass.h
@@ -28,7 +28,7 @@
void begin() override { }
void end() override;
- dawn::RenderPassEncoder beginRenderPass(dawn::LoadOp colorOp, dawn::LoadOp stencilOp);
+ wgpu::RenderPassEncoder beginRenderPass(wgpu::LoadOp colorOp, wgpu::LoadOp stencilOp);
void insertEventMarker(const char*) override;
void inlineUpload(GrOpFlushState* state, GrDeferredTextureUploadFn& upload) override;
@@ -86,8 +86,8 @@
};
GrDawnGpu* fGpu;
- dawn::CommandEncoder fEncoder;
- dawn::RenderPassEncoder fPassEncoder;
+ wgpu::CommandEncoder fEncoder;
+ wgpu::RenderPassEncoder fPassEncoder;
LoadAndStoreInfo fColorInfo;
typedef GrOpsRenderPass INHERITED;
diff --git a/src/gpu/dawn/GrDawnProgramBuilder.cpp b/src/gpu/dawn/GrDawnProgramBuilder.cpp
index d8c0e0b..997d0f6 100644
--- a/src/gpu/dawn/GrDawnProgramBuilder.cpp
+++ b/src/gpu/dawn/GrDawnProgramBuilder.cpp
@@ -37,32 +37,32 @@
return code;
}
-static dawn::BlendFactor to_dawn_blend_factor(GrBlendCoeff coeff) {
+static wgpu::BlendFactor to_dawn_blend_factor(GrBlendCoeff coeff) {
switch (coeff) {
case kZero_GrBlendCoeff:
- return dawn::BlendFactor::Zero;
+ return wgpu::BlendFactor::Zero;
case kOne_GrBlendCoeff:
- return dawn::BlendFactor::One;
+ return wgpu::BlendFactor::One;
case kSC_GrBlendCoeff:
- return dawn::BlendFactor::SrcColor;
+ return wgpu::BlendFactor::SrcColor;
case kISC_GrBlendCoeff:
- return dawn::BlendFactor::OneMinusSrcColor;
+ return wgpu::BlendFactor::OneMinusSrcColor;
case kDC_GrBlendCoeff:
- return dawn::BlendFactor::DstColor;
+ return wgpu::BlendFactor::DstColor;
case kIDC_GrBlendCoeff:
- return dawn::BlendFactor::OneMinusDstColor;
+ return wgpu::BlendFactor::OneMinusDstColor;
case kSA_GrBlendCoeff:
- return dawn::BlendFactor::SrcAlpha;
+ return wgpu::BlendFactor::SrcAlpha;
case kISA_GrBlendCoeff:
- return dawn::BlendFactor::OneMinusSrcAlpha;
+ return wgpu::BlendFactor::OneMinusSrcAlpha;
case kDA_GrBlendCoeff:
- return dawn::BlendFactor::DstAlpha;
+ return wgpu::BlendFactor::DstAlpha;
case kIDA_GrBlendCoeff:
- return dawn::BlendFactor::OneMinusDstAlpha;
+ return wgpu::BlendFactor::OneMinusDstAlpha;
case kConstC_GrBlendCoeff:
- return dawn::BlendFactor::BlendColor;
+ return wgpu::BlendFactor::BlendColor;
case kIConstC_GrBlendCoeff:
- return dawn::BlendFactor::OneMinusBlendColor;
+ return wgpu::BlendFactor::OneMinusBlendColor;
case kConstA_GrBlendCoeff:
case kIConstA_GrBlendCoeff:
case kS2C_GrBlendCoeff:
@@ -71,152 +71,152 @@
case kIS2A_GrBlendCoeff:
default:
SkASSERT(!"unsupported blend coefficient");
- return dawn::BlendFactor::One;
+ return wgpu::BlendFactor::One;
}
}
-static dawn::BlendFactor to_dawn_blend_factor_for_alpha(GrBlendCoeff coeff) {
+static wgpu::BlendFactor to_dawn_blend_factor_for_alpha(GrBlendCoeff coeff) {
switch (coeff) {
// Force all srcColor used in alpha slot to alpha version.
case kSC_GrBlendCoeff:
- return dawn::BlendFactor::SrcAlpha;
+ return wgpu::BlendFactor::SrcAlpha;
case kISC_GrBlendCoeff:
- return dawn::BlendFactor::OneMinusSrcAlpha;
+ return wgpu::BlendFactor::OneMinusSrcAlpha;
case kDC_GrBlendCoeff:
- return dawn::BlendFactor::DstAlpha;
+ return wgpu::BlendFactor::DstAlpha;
case kIDC_GrBlendCoeff:
- return dawn::BlendFactor::OneMinusDstAlpha;
+ return wgpu::BlendFactor::OneMinusDstAlpha;
default:
return to_dawn_blend_factor(coeff);
}
}
-static dawn::BlendOperation to_dawn_blend_operation(GrBlendEquation equation) {
+static wgpu::BlendOperation to_dawn_blend_operation(GrBlendEquation equation) {
switch (equation) {
case kAdd_GrBlendEquation:
- return dawn::BlendOperation::Add;
+ return wgpu::BlendOperation::Add;
case kSubtract_GrBlendEquation:
- return dawn::BlendOperation::Subtract;
+ return wgpu::BlendOperation::Subtract;
case kReverseSubtract_GrBlendEquation:
- return dawn::BlendOperation::ReverseSubtract;
+ return wgpu::BlendOperation::ReverseSubtract;
default:
SkASSERT(!"unsupported blend equation");
- return dawn::BlendOperation::Add;
+ return wgpu::BlendOperation::Add;
}
}
-static dawn::CompareFunction to_dawn_compare_function(GrStencilTest test) {
+static wgpu::CompareFunction to_dawn_compare_function(GrStencilTest test) {
switch (test) {
case GrStencilTest::kAlways:
- return dawn::CompareFunction::Always;
+ return wgpu::CompareFunction::Always;
case GrStencilTest::kNever:
- return dawn::CompareFunction::Never;
+ return wgpu::CompareFunction::Never;
case GrStencilTest::kGreater:
- return dawn::CompareFunction::Greater;
+ return wgpu::CompareFunction::Greater;
case GrStencilTest::kGEqual:
- return dawn::CompareFunction::GreaterEqual;
+ return wgpu::CompareFunction::GreaterEqual;
case GrStencilTest::kLess:
- return dawn::CompareFunction::Less;
+ return wgpu::CompareFunction::Less;
case GrStencilTest::kLEqual:
- return dawn::CompareFunction::LessEqual;
+ return wgpu::CompareFunction::LessEqual;
case GrStencilTest::kEqual:
- return dawn::CompareFunction::Equal;
+ return wgpu::CompareFunction::Equal;
case GrStencilTest::kNotEqual:
- return dawn::CompareFunction::NotEqual;
+ return wgpu::CompareFunction::NotEqual;
default:
SkASSERT(!"unsupported stencil test");
- return dawn::CompareFunction::Always;
+ return wgpu::CompareFunction::Always;
}
}
-static dawn::StencilOperation to_dawn_stencil_operation(GrStencilOp op) {
+static wgpu::StencilOperation to_dawn_stencil_operation(GrStencilOp op) {
switch (op) {
case GrStencilOp::kKeep:
- return dawn::StencilOperation::Keep;
+ return wgpu::StencilOperation::Keep;
case GrStencilOp::kZero:
- return dawn::StencilOperation::Zero;
+ return wgpu::StencilOperation::Zero;
case GrStencilOp::kReplace:
- return dawn::StencilOperation::Replace;
+ return wgpu::StencilOperation::Replace;
case GrStencilOp::kInvert:
- return dawn::StencilOperation::Invert;
+ return wgpu::StencilOperation::Invert;
case GrStencilOp::kIncClamp:
- return dawn::StencilOperation::IncrementClamp;
+ return wgpu::StencilOperation::IncrementClamp;
case GrStencilOp::kDecClamp:
- return dawn::StencilOperation::DecrementClamp;
+ return wgpu::StencilOperation::DecrementClamp;
case GrStencilOp::kIncWrap:
- return dawn::StencilOperation::IncrementWrap;
+ return wgpu::StencilOperation::IncrementWrap;
case GrStencilOp::kDecWrap:
- return dawn::StencilOperation::DecrementWrap;
+ return wgpu::StencilOperation::DecrementWrap;
default:
SkASSERT(!"unsupported stencil function");
- return dawn::StencilOperation::Keep;
+ return wgpu::StencilOperation::Keep;
}
}
-static dawn::PrimitiveTopology to_dawn_primitive_topology(GrPrimitiveType primitiveType) {
+static wgpu::PrimitiveTopology to_dawn_primitive_topology(GrPrimitiveType primitiveType) {
switch (primitiveType) {
case GrPrimitiveType::kTriangles:
- return dawn::PrimitiveTopology::TriangleList;
+ return wgpu::PrimitiveTopology::TriangleList;
case GrPrimitiveType::kTriangleStrip:
- return dawn::PrimitiveTopology::TriangleStrip;
+ return wgpu::PrimitiveTopology::TriangleStrip;
case GrPrimitiveType::kPoints:
- return dawn::PrimitiveTopology::PointList;
+ return wgpu::PrimitiveTopology::PointList;
case GrPrimitiveType::kLines:
- return dawn::PrimitiveTopology::LineList;
+ return wgpu::PrimitiveTopology::LineList;
case GrPrimitiveType::kLineStrip:
- return dawn::PrimitiveTopology::LineStrip;
+ return wgpu::PrimitiveTopology::LineStrip;
case GrPrimitiveType::kPath:
default:
SkASSERT(!"unsupported primitive topology");
- return dawn::PrimitiveTopology::TriangleList;
+ return wgpu::PrimitiveTopology::TriangleList;
}
}
-static dawn::VertexFormat to_dawn_vertex_format(GrVertexAttribType type) {
+static wgpu::VertexFormat to_dawn_vertex_format(GrVertexAttribType type) {
switch (type) {
case kFloat_GrVertexAttribType:
case kHalf_GrVertexAttribType:
- return dawn::VertexFormat::Float;
+ return wgpu::VertexFormat::Float;
case kFloat2_GrVertexAttribType:
case kHalf2_GrVertexAttribType:
- return dawn::VertexFormat::Float2;
+ return wgpu::VertexFormat::Float2;
case kFloat3_GrVertexAttribType:
case kHalf3_GrVertexAttribType:
- return dawn::VertexFormat::Float3;
+ return wgpu::VertexFormat::Float3;
case kFloat4_GrVertexAttribType:
case kHalf4_GrVertexAttribType:
- return dawn::VertexFormat::Float4;
+ return wgpu::VertexFormat::Float4;
case kUShort2_GrVertexAttribType:
- return dawn::VertexFormat::UShort2;
+ return wgpu::VertexFormat::UShort2;
case kInt_GrVertexAttribType:
- return dawn::VertexFormat::Int;
+ return wgpu::VertexFormat::Int;
case kUByte4_norm_GrVertexAttribType:
- return dawn::VertexFormat::UChar4Norm;
+ return wgpu::VertexFormat::UChar4Norm;
default:
SkASSERT(!"unsupported vertex format");
- return dawn::VertexFormat::Float4;
+ return wgpu::VertexFormat::Float4;
}
}
-static dawn::ColorStateDescriptor create_color_state(const GrDawnGpu* gpu,
+static wgpu::ColorStateDescriptor create_color_state(const GrDawnGpu* gpu,
const GrPipeline& pipeline,
- dawn::TextureFormat colorFormat) {
+ wgpu::TextureFormat colorFormat) {
GrXferProcessor::BlendInfo blendInfo = pipeline.getXferProcessor().getBlendInfo();
GrBlendEquation equation = blendInfo.fEquation;
GrBlendCoeff srcCoeff = blendInfo.fSrcBlend;
GrBlendCoeff dstCoeff = blendInfo.fDstBlend;
- dawn::BlendFactor srcFactor = to_dawn_blend_factor(srcCoeff);
- dawn::BlendFactor dstFactor = to_dawn_blend_factor(dstCoeff);
- dawn::BlendFactor srcFactorAlpha = to_dawn_blend_factor_for_alpha(srcCoeff);
- dawn::BlendFactor dstFactorAlpha = to_dawn_blend_factor_for_alpha(dstCoeff);
- dawn::BlendOperation operation = to_dawn_blend_operation(equation);
- auto mask = blendInfo.fWriteColor ? dawn::ColorWriteMask::All : dawn::ColorWriteMask::None;
+ wgpu::BlendFactor srcFactor = to_dawn_blend_factor(srcCoeff);
+ wgpu::BlendFactor dstFactor = to_dawn_blend_factor(dstCoeff);
+ wgpu::BlendFactor srcFactorAlpha = to_dawn_blend_factor_for_alpha(srcCoeff);
+ wgpu::BlendFactor dstFactorAlpha = to_dawn_blend_factor_for_alpha(dstCoeff);
+ wgpu::BlendOperation operation = to_dawn_blend_operation(equation);
+ auto mask = blendInfo.fWriteColor ? wgpu::ColorWriteMask::All : wgpu::ColorWriteMask::None;
- dawn::BlendDescriptor colorDesc = {operation, srcFactor, dstFactor};
- dawn::BlendDescriptor alphaDesc = {operation, srcFactorAlpha, dstFactorAlpha};
+ wgpu::BlendDescriptor colorDesc = {operation, srcFactor, dstFactor};
+ wgpu::BlendDescriptor alphaDesc = {operation, srcFactorAlpha, dstFactorAlpha};
- dawn::ColorStateDescriptor descriptor;
+ wgpu::ColorStateDescriptor descriptor;
descriptor.format = colorFormat;
descriptor.alphaBlend = alphaDesc;
descriptor.colorBlend = colorDesc;
@@ -226,19 +226,19 @@
return descriptor;
}
-static dawn::StencilStateFaceDescriptor to_stencil_state_face(const GrStencilSettings::Face& face) {
- dawn::StencilStateFaceDescriptor desc;
+static wgpu::StencilStateFaceDescriptor to_stencil_state_face(const GrStencilSettings::Face& face) {
+ wgpu::StencilStateFaceDescriptor desc;
desc.compare = to_dawn_compare_function(face.fTest);
desc.failOp = desc.depthFailOp = to_dawn_stencil_operation(face.fFailOp);
desc.passOp = to_dawn_stencil_operation(face.fPassOp);
return desc;
}
-static dawn::DepthStencilStateDescriptor create_depth_stencil_state(
+static wgpu::DepthStencilStateDescriptor create_depth_stencil_state(
const GrStencilSettings& stencilSettings,
- dawn::TextureFormat depthStencilFormat,
+ wgpu::TextureFormat depthStencilFormat,
GrSurfaceOrigin origin) {
- dawn::DepthStencilStateDescriptor state;
+ wgpu::DepthStencilStateDescriptor state;
state.format = depthStencilFormat;
if (!stencilSettings.isDisabled()) {
if (stencilSettings.isTwoSided()) {
@@ -258,11 +258,11 @@
return state;
}
-static dawn::BindGroupBinding make_bind_group_binding(uint32_t binding, const dawn::Buffer& buffer,
+static wgpu::BindGroupBinding make_bind_group_binding(uint32_t binding, const wgpu::Buffer& buffer,
uint32_t offset, uint32_t size, const
- dawn::Sampler& sampler,
- const dawn::TextureView& textureView) {
- dawn::BindGroupBinding result;
+ wgpu::Sampler& sampler,
+ const wgpu::TextureView& textureView) {
+ wgpu::BindGroupBinding result;
result.binding = binding;
result.buffer = buffer;
result.offset = offset;
@@ -272,18 +272,18 @@
return result;
}
-static dawn::BindGroupBinding make_bind_group_binding(uint32_t binding, const dawn::Buffer& buffer,
+static wgpu::BindGroupBinding make_bind_group_binding(uint32_t binding, const wgpu::Buffer& buffer,
uint32_t offset, uint32_t size) {
return make_bind_group_binding(binding, buffer, offset, size, nullptr, nullptr);
}
-static dawn::BindGroupBinding make_bind_group_binding(uint32_t binding,
- const dawn::Sampler& sampler) {
+static wgpu::BindGroupBinding make_bind_group_binding(uint32_t binding,
+ const wgpu::Sampler& sampler) {
return make_bind_group_binding(binding, nullptr, 0, 0, sampler, nullptr);
}
-static dawn::BindGroupBinding make_bind_group_binding(uint32_t binding,
- const dawn::TextureView& textureView) {
+static wgpu::BindGroupBinding make_bind_group_binding(uint32_t binding,
+ const wgpu::TextureView& textureView) {
return make_bind_group_binding(binding, nullptr, 0, 0, nullptr, textureView);
}
@@ -291,9 +291,9 @@
GrRenderTarget* renderTarget,
const GrProgramInfo& programInfo,
GrPrimitiveType primitiveType,
- dawn::TextureFormat colorFormat,
+ wgpu::TextureFormat colorFormat,
bool hasDepthStencil,
- dawn::TextureFormat depthStencilFormat,
+ wgpu::TextureFormat depthStencilFormat,
GrProgramDesc* desc) {
GrDawnProgramBuilder builder(gpu, renderTarget, programInfo, desc);
if (!builder.emitAndInstallProcs()) {
@@ -320,31 +320,31 @@
result->fXferProcessor = std::move(builder.fXferProcessor);
result->fFragmentProcessors = std::move(builder.fFragmentProcessors);
result->fFragmentProcessorCnt = builder.fFragmentProcessorCnt;
- std::vector<dawn::BindGroupLayoutBinding> layoutBindings;
+ std::vector<wgpu::BindGroupLayoutBinding> layoutBindings;
if (0 != uniformBufferSize) {
layoutBindings.push_back({ GrDawnUniformHandler::kUniformBinding,
- dawn::ShaderStage::Vertex | dawn::ShaderStage::Fragment,
- dawn::BindingType::UniformBuffer});
+ wgpu::ShaderStage::Vertex | wgpu::ShaderStage::Fragment,
+ wgpu::BindingType::UniformBuffer});
}
uint32_t binding = GrDawnUniformHandler::kSamplerBindingBase;
for (int i = 0; i < builder.fUniformHandler.fSamplers.count(); ++i) {
- layoutBindings.push_back({ binding++, dawn::ShaderStage::Fragment,
- dawn::BindingType::Sampler});
- layoutBindings.push_back({ binding++, dawn::ShaderStage::Fragment,
- dawn::BindingType::SampledTexture});
+ layoutBindings.push_back({ binding++, wgpu::ShaderStage::Fragment,
+ wgpu::BindingType::Sampler});
+ layoutBindings.push_back({ binding++, wgpu::ShaderStage::Fragment,
+ wgpu::BindingType::SampledTexture});
}
- dawn::BindGroupLayoutDescriptor bindGroupLayoutDesc;
+ wgpu::BindGroupLayoutDescriptor bindGroupLayoutDesc;
bindGroupLayoutDesc.bindingCount = layoutBindings.size();
bindGroupLayoutDesc.bindings = layoutBindings.data();
result->fBindGroupLayout = gpu->device().CreateBindGroupLayout(&bindGroupLayoutDesc);
- dawn::PipelineLayoutDescriptor pipelineLayoutDesc;
+ wgpu::PipelineLayoutDescriptor pipelineLayoutDesc;
pipelineLayoutDesc.bindGroupLayoutCount = 1;
pipelineLayoutDesc.bindGroupLayouts = &result->fBindGroupLayout;
auto pipelineLayout = gpu->device().CreatePipelineLayout(&pipelineLayoutDesc);
result->fBuiltinUniformHandles = builder.fUniformHandles;
const GrPipeline& pipeline = programInfo.pipeline();
auto colorState = create_color_state(gpu, pipeline, colorFormat);
- dawn::DepthStencilStateDescriptor depthStencilState;
+ wgpu::DepthStencilStateDescriptor depthStencilState;
GrStencilSettings stencil;
if (pipeline.isStencilEnabled()) {
int numStencilBits = renderTarget->renderTargetPriv().numStencilBits();
@@ -353,15 +353,15 @@
depthStencilState = create_depth_stencil_state(stencil, depthStencilFormat,
programInfo.origin());
- std::vector<dawn::VertexBufferDescriptor> inputs;
+ std::vector<wgpu::VertexBufferDescriptor> inputs;
- std::vector<dawn::VertexAttributeDescriptor> vertexAttributes;
+ std::vector<wgpu::VertexAttributeDescriptor> vertexAttributes;
const GrPrimitiveProcessor& primProc = programInfo.primProc();
if (primProc.numVertexAttributes() > 0) {
size_t offset = 0;
int i = 0;
for (const auto& attrib : primProc.vertexAttributes()) {
- dawn::VertexAttributeDescriptor attribute;
+ wgpu::VertexAttributeDescriptor attribute;
attribute.shaderLocation = i;
attribute.offset = offset;
attribute.format = to_dawn_vertex_format(attrib.cpuType());
@@ -369,19 +369,19 @@
offset += attrib.sizeAlign4();
i++;
}
- dawn::VertexBufferDescriptor input;
+ wgpu::VertexBufferDescriptor input;
input.stride = offset;
- input.stepMode = dawn::InputStepMode::Vertex;
+ input.stepMode = wgpu::InputStepMode::Vertex;
input.attributeCount = vertexAttributes.size();
input.attributes = &vertexAttributes.front();
inputs.push_back(input);
}
- std::vector<dawn::VertexAttributeDescriptor> instanceAttributes;
+ std::vector<wgpu::VertexAttributeDescriptor> instanceAttributes;
if (primProc.numInstanceAttributes() > 0) {
size_t offset = 0;
int i = 0;
for (const auto& attrib : primProc.instanceAttributes()) {
- dawn::VertexAttributeDescriptor attribute;
+ wgpu::VertexAttributeDescriptor attribute;
attribute.shaderLocation = i;
attribute.offset = offset;
attribute.format = to_dawn_vertex_format(attrib.cpuType());
@@ -389,27 +389,27 @@
offset += attrib.sizeAlign4();
i++;
}
- dawn::VertexBufferDescriptor input;
+ wgpu::VertexBufferDescriptor input;
input.stride = offset;
- input.stepMode = dawn::InputStepMode::Instance;
+ input.stepMode = wgpu::InputStepMode::Instance;
input.attributeCount = instanceAttributes.size();
input.attributes = &instanceAttributes.front();
inputs.push_back(input);
}
- dawn::VertexInputDescriptor vertexInput;
- vertexInput.indexFormat = dawn::IndexFormat::Uint16;
+ wgpu::VertexInputDescriptor vertexInput;
+ vertexInput.indexFormat = wgpu::IndexFormat::Uint16;
vertexInput.bufferCount = inputs.size();
vertexInput.buffers = &inputs.front();
- dawn::ProgrammableStageDescriptor vsDesc;
+ wgpu::ProgrammableStageDescriptor vsDesc;
vsDesc.module = vsModule;
vsDesc.entryPoint = "main";
- dawn::ProgrammableStageDescriptor fsDesc;
+ wgpu::ProgrammableStageDescriptor fsDesc;
fsDesc.module = fsModule;
fsDesc.entryPoint = "main";
- dawn::RenderPipelineDescriptor rpDesc;
+ wgpu::RenderPipelineDescriptor rpDesc;
rpDesc.layout = pipelineLayout;
rpDesc.vertexStage = vsDesc;
rpDesc.fragmentStage = &fsDesc;
@@ -434,11 +434,11 @@
, fUniformHandler(this) {
}
-dawn::ShaderModule GrDawnProgramBuilder::createShaderModule(const GrGLSLShaderBuilder& builder,
+wgpu::ShaderModule GrDawnProgramBuilder::createShaderModule(const GrGLSLShaderBuilder& builder,
SkSL::Program::Kind kind,
bool flipY,
SkSL::Program::Inputs* inputs) {
- dawn::Device device = fGpu->device();
+ wgpu::Device device = fGpu->device();
SkString source(builder.fCompilerString.c_str());
#if 0
@@ -448,7 +448,7 @@
SkSL::String spirvSource = sksl_to_spirv(fGpu, source.c_str(), kind, flipY, inputs);
- dawn::ShaderModuleDescriptor desc;
+ wgpu::ShaderModuleDescriptor desc;
desc.codeSize = spirvSource.size() / 4;
desc.code = reinterpret_cast<const uint32_t*>(spirvSource.c_str());
@@ -481,18 +481,18 @@
}
static void setTexture(GrDawnGpu* gpu, const GrSamplerState& state, GrTexture* texture,
- std::vector<dawn::BindGroupBinding> *bindings, int* binding) {
+ std::vector<wgpu::BindGroupBinding> *bindings, int* binding) {
// FIXME: could probably cache samplers in GrDawnProgram
- dawn::Sampler sampler = gpu->getOrCreateSampler(state);
+ wgpu::Sampler sampler = gpu->getOrCreateSampler(state);
bindings->push_back(make_bind_group_binding((*binding)++, sampler));
GrDawnTexture* tex = static_cast<GrDawnTexture*>(texture);
- dawn::TextureView textureView = tex->textureView();
+ wgpu::TextureView textureView = tex->textureView();
bindings->push_back(make_bind_group_binding((*binding)++, textureView));
}
-dawn::BindGroup GrDawnProgram::setData(GrDawnGpu* gpu, const GrRenderTarget* renderTarget,
+wgpu::BindGroup GrDawnProgram::setData(GrDawnGpu* gpu, const GrRenderTarget* renderTarget,
const GrProgramInfo& programInfo) {
- std::vector<dawn::BindGroupBinding> bindings;
+ std::vector<wgpu::BindGroupBinding> bindings;
GrDawnRingBuffer::Slice slice;
uint32_t uniformBufferSize = fDataManager.uniformBufferSize();
if (0 != uniformBufferSize) {
@@ -536,7 +536,7 @@
setTexture(gpu, sampler.samplerState(), sampler.peekTexture(), &bindings, &binding);
}
fDataManager.uploadUniformBuffers(gpu, slice);
- dawn::BindGroupDescriptor descriptor;
+ wgpu::BindGroupDescriptor descriptor;
descriptor.layout = fBindGroupLayout;
descriptor.bindingCount = bindings.size();
descriptor.bindings = bindings.data();
diff --git a/src/gpu/dawn/GrDawnProgramBuilder.h b/src/gpu/dawn/GrDawnProgramBuilder.h
index ec500a0..be36a83 100644
--- a/src/gpu/dawn/GrDawnProgramBuilder.h
+++ b/src/gpu/dawn/GrDawnProgramBuilder.h
@@ -57,14 +57,14 @@
std::unique_ptr<GrGLSLXferProcessor> fXferProcessor;
std::unique_ptr<std::unique_ptr<GrGLSLFragmentProcessor>[]> fFragmentProcessors;
int fFragmentProcessorCnt;
- dawn::BindGroupLayout fBindGroupLayout;
- dawn::RenderPipeline fRenderPipeline;
+ wgpu::BindGroupLayout fBindGroupLayout;
+ wgpu::RenderPipeline fRenderPipeline;
GrDawnProgramDataManager fDataManager;
RenderTargetState fRenderTargetState;
BuiltinUniformHandles fBuiltinUniformHandles;
void setRenderTargetState(const GrRenderTarget*, GrSurfaceOrigin);
- dawn::BindGroup setData(GrDawnGpu* gpu, const GrRenderTarget*, const GrProgramInfo&);
+ wgpu::BindGroup setData(GrDawnGpu* gpu, const GrRenderTarget*, const GrProgramInfo&);
};
class GrDawnProgramBuilder : public GrGLSLProgramBuilder {
@@ -73,9 +73,9 @@
GrRenderTarget* rt,
const GrProgramInfo& programInfo,
GrPrimitiveType primitiveType,
- dawn::TextureFormat colorFormat,
+ wgpu::TextureFormat colorFormat,
bool hasDepthStencil,
- dawn::TextureFormat depthStencilFormat,
+ wgpu::TextureFormat depthStencilFormat,
GrProgramDesc* desc);
const GrCaps* caps() const override;
GrGLSLUniformHandler* uniformHandler() override { return &fUniformHandler; }
@@ -89,7 +89,7 @@
GrRenderTarget*,
const GrProgramInfo&,
GrProgramDesc*);
- dawn::ShaderModule createShaderModule(const GrGLSLShaderBuilder&, SkSL::Program::Kind,
+ wgpu::ShaderModule createShaderModule(const GrGLSLShaderBuilder&, SkSL::Program::Kind,
bool flipY, SkSL::Program::Inputs* inputs);
GrDawnGpu* fGpu;
GrDawnVaryingHandler fVaryingHandler;
diff --git a/src/gpu/dawn/GrDawnRenderTarget.h b/src/gpu/dawn/GrDawnRenderTarget.h
index 0af2a49..f93d498 100644
--- a/src/gpu/dawn/GrDawnRenderTarget.h
+++ b/src/gpu/dawn/GrDawnRenderTarget.h
@@ -27,7 +27,7 @@
GrBackendRenderTarget getBackendRenderTarget() const override;
GrBackendFormat backendFormat() const override;
- dawn::Texture texture() const { return fInfo.fTexture; }
+ wgpu::Texture texture() const { return fInfo.fTexture; }
protected:
GrDawnRenderTarget(GrDawnGpu* gpu,
diff --git a/src/gpu/dawn/GrDawnRingBuffer.cpp b/src/gpu/dawn/GrDawnRingBuffer.cpp
index caf0d57..74ea72f 100644
--- a/src/gpu/dawn/GrDawnRingBuffer.cpp
+++ b/src/gpu/dawn/GrDawnRingBuffer.cpp
@@ -14,7 +14,7 @@
const int kDefaultSize = 512 * 1024;
}
-GrDawnRingBuffer::GrDawnRingBuffer(GrDawnGpu* gpu, dawn::BufferUsage usage)
+GrDawnRingBuffer::GrDawnRingBuffer(GrDawnGpu* gpu, wgpu::BufferUsage usage)
: fGpu(gpu) , fUsage(usage) {
}
@@ -23,8 +23,8 @@
GrDawnRingBuffer::Slice GrDawnRingBuffer::allocate(int size) {
if (!fBuffer || fOffset + size > kDefaultSize) {
- dawn::BufferDescriptor desc;
- desc.usage = fUsage | dawn::BufferUsage::CopyDst;
+ wgpu::BufferDescriptor desc;
+ desc.usage = fUsage | wgpu::BufferUsage::CopyDst;
desc.size = kDefaultSize;
fBuffer = fGpu->device().CreateBuffer(&desc);
fOffset = 0;
diff --git a/src/gpu/dawn/GrDawnRingBuffer.h b/src/gpu/dawn/GrDawnRingBuffer.h
index 0dbe505..9b66f6f 100644
--- a/src/gpu/dawn/GrDawnRingBuffer.h
+++ b/src/gpu/dawn/GrDawnRingBuffer.h
@@ -16,11 +16,11 @@
class GrDawnRingBuffer : public SkRefCnt {
public:
- GrDawnRingBuffer(GrDawnGpu* gpu, dawn::BufferUsage usage);
+ GrDawnRingBuffer(GrDawnGpu* gpu, wgpu::BufferUsage usage);
~GrDawnRingBuffer() override;
struct Slice {
- Slice(dawn::Buffer buffer, int offset) : fBuffer(buffer), fOffset(offset) {}
+ Slice(wgpu::Buffer buffer, int offset) : fBuffer(buffer), fOffset(offset) {}
Slice() : fBuffer(nullptr), fOffset(0) {}
Slice(const Slice& other) : fBuffer(other.fBuffer), fOffset(other.fOffset) {}
Slice& operator=(const Slice& other) {
@@ -28,15 +28,15 @@
fOffset = other.fOffset;
return *this;
}
- dawn::Buffer fBuffer;
+ wgpu::Buffer fBuffer;
int fOffset;
};
Slice allocate(int size);
private:
GrDawnGpu* fGpu;
- dawn::BufferUsage fUsage;
- dawn::Buffer fBuffer;
+ wgpu::BufferUsage fUsage;
+ wgpu::Buffer fBuffer;
int fOffset = 0;
};
diff --git a/src/gpu/dawn/GrDawnStagingManager.cpp b/src/gpu/dawn/GrDawnStagingManager.cpp
index 68e0e97..51e11a4 100644
--- a/src/gpu/dawn/GrDawnStagingManager.cpp
+++ b/src/gpu/dawn/GrDawnStagingManager.cpp
@@ -9,7 +9,7 @@
#include "src/core/SkMathPriv.h"
-GrDawnStagingManager::GrDawnStagingManager(dawn::Device device) : fDevice(device) {
+GrDawnStagingManager::GrDawnStagingManager(wgpu::Device device) : fDevice(device) {
}
GrDawnStagingManager::~GrDawnStagingManager() {
@@ -27,10 +27,10 @@
stagingBuffer = i->second;
fReadyPool.erase(i);
} else {
- dawn::BufferDescriptor desc;
- desc.usage = dawn::BufferUsage::MapWrite | dawn::BufferUsage::CopySrc;
+ wgpu::BufferDescriptor desc;
+ desc.usage = wgpu::BufferUsage::MapWrite | wgpu::BufferUsage::CopySrc;
desc.size = sizePow2;
- dawn::CreateBufferMappedResult result = fDevice.CreateBufferMapped(&desc);
+ wgpu::CreateBufferMappedResult result = fDevice.CreateBufferMapped(&desc);
std::unique_ptr<GrDawnStagingBuffer> b(new GrDawnStagingBuffer(
this, result.buffer, sizePow2, result.data));
stagingBuffer = b.get();
diff --git a/src/gpu/dawn/GrDawnStagingManager.h b/src/gpu/dawn/GrDawnStagingManager.h
index b3974ad..32a1081 100644
--- a/src/gpu/dawn/GrDawnStagingManager.h
+++ b/src/gpu/dawn/GrDawnStagingManager.h
@@ -18,7 +18,7 @@
class GrDawnStagingManager {
public:
- GrDawnStagingManager(dawn::Device device);
+ GrDawnStagingManager(wgpu::Device device);
~GrDawnStagingManager();
GrDawnStagingBuffer* findOrCreateStagingBuffer(size_t size);
@@ -26,7 +26,7 @@
void mapBusyList();
private:
- dawn::Device fDevice;
+ wgpu::Device fDevice;
std::vector<std::unique_ptr<GrDawnStagingBuffer>> fBuffers;
std::multimap<size_t, GrDawnStagingBuffer*> fReadyPool;
std::vector<GrDawnStagingBuffer*> fBusyList;
@@ -34,14 +34,14 @@
};
struct GrDawnStagingBuffer {
- GrDawnStagingBuffer(GrDawnStagingManager* manager, dawn::Buffer buffer, size_t size,
+ GrDawnStagingBuffer(GrDawnStagingManager* manager, wgpu::Buffer buffer, size_t size,
void* data)
: fManager(manager), fBuffer(buffer), fSize(size), fData(data) {}
~GrDawnStagingBuffer() {
fManager = nullptr;
}
GrDawnStagingManager* fManager;
- dawn::Buffer fBuffer;
+ wgpu::Buffer fBuffer;
size_t fSize;
void* fData;
};
diff --git a/src/gpu/dawn/GrDawnStencilAttachment.cpp b/src/gpu/dawn/GrDawnStencilAttachment.cpp
index 7e4047a..b96107b 100644
--- a/src/gpu/dawn/GrDawnStencilAttachment.cpp
+++ b/src/gpu/dawn/GrDawnStencilAttachment.cpp
@@ -17,8 +17,8 @@
int height,
int bits,
int samples,
- dawn::Texture texture,
- dawn::TextureView view)
+ wgpu::Texture texture,
+ wgpu::TextureView view)
: INHERITED(gpu, width, height, bits, samples)
, fTexture(texture)
, fView(view) {
@@ -29,17 +29,17 @@
int width,
int height,
int sampleCnt) {
- dawn::TextureDescriptor desc;
- desc.usage = dawn::TextureUsage::OutputAttachment;
+ wgpu::TextureDescriptor desc;
+ desc.usage = wgpu::TextureUsage::OutputAttachment;
desc.size.width = width;
desc.size.height = height;
desc.size.depth = 1;
- desc.format = dawn::TextureFormat::Depth24PlusStencil8;
- dawn::Texture texture = gpu->device().CreateTexture(&desc);
+ desc.format = wgpu::TextureFormat::Depth24PlusStencil8;
+ wgpu::Texture texture = gpu->device().CreateTexture(&desc);
if (!texture) {
return nullptr;
}
- dawn::TextureView view = texture.CreateView();
+ wgpu::TextureView view = texture.CreateView();
if (!view) {
return nullptr;
}
diff --git a/src/gpu/dawn/GrDawnStencilAttachment.h b/src/gpu/dawn/GrDawnStencilAttachment.h
index b0afc23..0e4a891 100644
--- a/src/gpu/dawn/GrDawnStencilAttachment.h
+++ b/src/gpu/dawn/GrDawnStencilAttachment.h
@@ -20,7 +20,7 @@
int sampleCnt);
~GrDawnStencilAttachment() override;
- dawn::TextureView view() const { return fView; }
+ wgpu::TextureView view() const { return fView; }
protected:
void onRelease() override;
@@ -30,12 +30,12 @@
size_t onGpuMemorySize() const override;
GrDawnStencilAttachment(GrDawnGpu* gpu, int width, int height, int bits, int samples,
- dawn::Texture texture, dawn::TextureView view);
+ wgpu::Texture texture, wgpu::TextureView view);
GrDawnGpu* getDawnGpu() const;
- dawn::Texture fTexture;
- dawn::TextureView fView;
+ wgpu::Texture fTexture;
+ wgpu::TextureView fView;
typedef GrStencilAttachment INHERITED;
};
diff --git a/src/gpu/dawn/GrDawnTexture.cpp b/src/gpu/dawn/GrDawnTexture.cpp
index 795f439..a81e92b 100644
--- a/src/gpu/dawn/GrDawnTexture.cpp
+++ b/src/gpu/dawn/GrDawnTexture.cpp
@@ -15,7 +15,7 @@
GrDawnTexture::GrDawnTexture(GrDawnGpu* gpu,
const SkISize& dimensions,
GrPixelConfig config,
- dawn::TextureView textureView,
+ wgpu::TextureView textureView,
const GrDawnImageInfo& info,
GrMipMapsStatus mipMapsStatus)
: GrSurface(gpu, dimensions, config, GrProtected::kNo)
@@ -24,20 +24,20 @@
, fTextureView(textureView) {}
sk_sp<GrDawnTexture> GrDawnTexture::Make(GrDawnGpu* gpu, const SkISize& dimensions,
- GrPixelConfig config, dawn::TextureFormat format,
+ GrPixelConfig config, wgpu::TextureFormat format,
GrRenderable renderable, int sampleCnt,
SkBudgeted budgeted, int mipLevels,
GrMipMapsStatus status) {
bool renderTarget = renderable == GrRenderable::kYes;
- dawn::TextureDescriptor textureDesc;
+ wgpu::TextureDescriptor textureDesc;
textureDesc.usage =
- dawn::TextureUsage::Sampled |
- dawn::TextureUsage::CopySrc |
- dawn::TextureUsage::CopyDst;
+ wgpu::TextureUsage::Sampled |
+ wgpu::TextureUsage::CopySrc |
+ wgpu::TextureUsage::CopyDst;
if (renderTarget) {
- textureDesc.usage |= dawn::TextureUsage::OutputAttachment;
+ textureDesc.usage |= wgpu::TextureUsage::OutputAttachment;
}
textureDesc.size.width = dimensions.fWidth;
@@ -47,13 +47,13 @@
textureDesc.mipLevelCount = std::max(mipLevels, 1);
textureDesc.sampleCount = sampleCnt;
- dawn::Texture tex = gpu->device().CreateTexture(&textureDesc);
+ wgpu::Texture tex = gpu->device().CreateTexture(&textureDesc);
if (!tex) {
return nullptr;
}
- dawn::TextureView textureView = tex.CreateView();
+ wgpu::TextureView textureView = tex.CreateView();
if (!textureView) {
return nullptr;
@@ -89,7 +89,7 @@
int sampleCnt, GrMipMapsStatus status,
GrWrapCacheable cacheable,
const GrDawnImageInfo& info) {
- dawn::TextureView textureView = info.fTexture.CreateView();
+ wgpu::TextureView textureView = info.fTexture.CreateView();
if (!textureView) {
return nullptr;
}
@@ -127,13 +127,13 @@
}
void GrDawnTexture::upload(const GrMipLevel texels[], int mipLevels,
- dawn::CommandEncoder copyEncoder) {
+ wgpu::CommandEncoder copyEncoder) {
this->upload(texels, mipLevels, SkIRect::MakeWH(width(), height()), copyEncoder);
}
void GrDawnTexture::upload(const GrMipLevel texels[], int mipLevels, const SkIRect& rect,
- dawn::CommandEncoder copyEncoder) {
- dawn::Device device = this->getDawnGpu()->device();
+ wgpu::CommandEncoder copyEncoder) {
+ wgpu::Device device = this->getDawnGpu()->device();
uint32_t x = rect.x();
uint32_t y = rect.y();
@@ -149,22 +149,22 @@
size_t size = dstRowBytes * height;
GrDawnStagingBuffer* stagingBuffer = getDawnGpu()->getStagingBuffer(size);
SkRectMemcpy(stagingBuffer->fData, dstRowBytes, src, srcRowBytes, trimRowBytes, height);
- dawn::Buffer buffer = stagingBuffer->fBuffer;
+ wgpu::Buffer buffer = stagingBuffer->fBuffer;
buffer.Unmap();
stagingBuffer->fData = nullptr;
- dawn::BufferCopyView srcBuffer;
+ wgpu::BufferCopyView srcBuffer;
srcBuffer.buffer = buffer;
srcBuffer.offset = 0;
srcBuffer.rowPitch = dstRowBytes;
srcBuffer.imageHeight = height;
- dawn::TextureCopyView dstTexture;
+ wgpu::TextureCopyView dstTexture;
dstTexture.texture = fInfo.fTexture;
dstTexture.mipLevel = i;
dstTexture.origin = {x, y, 0};
- dawn::Extent3D copySize = {width, height, 1};
+ wgpu::Extent3D copySize = {width, height, 1};
copyEncoder.CopyBufferToTexture(&srcBuffer, &dstTexture, ©Size);
x /= 2;
y /= 2;
diff --git a/src/gpu/dawn/GrDawnTexture.h b/src/gpu/dawn/GrDawnTexture.h
index bbea6f8..5d25d8b 100644
--- a/src/gpu/dawn/GrDawnTexture.h
+++ b/src/gpu/dawn/GrDawnTexture.h
@@ -17,7 +17,7 @@
class GrDawnTexture : public GrTexture {
public:
static sk_sp<GrDawnTexture> Make(GrDawnGpu*, const SkISize& dimensions, GrPixelConfig config,
- dawn::TextureFormat format, GrRenderable, int sampleCnt,
+ wgpu::TextureFormat format, GrRenderable, int sampleCnt,
SkBudgeted, int mipLevels, GrMipMapsStatus);
static sk_sp<GrDawnTexture> MakeWrapped(GrDawnGpu*, const SkISize& dimensions,
@@ -32,14 +32,14 @@
void textureParamsModified() override {}
- void upload(const GrMipLevel texels[], int mipLevels, dawn::CommandEncoder copyEncoder);
+ void upload(const GrMipLevel texels[], int mipLevels, wgpu::CommandEncoder copyEncoder);
void upload(const GrMipLevel texels[], int mipLevels, const SkIRect& dstRect,
- dawn::CommandEncoder copyEncoder);
+ wgpu::CommandEncoder copyEncoder);
- dawn::Texture texture() const { return fInfo.fTexture; }
- dawn::TextureView textureView() const { return fTextureView; }
+ wgpu::Texture texture() const { return fInfo.fTexture; }
+ wgpu::TextureView textureView() const { return fTextureView; }
protected:
- GrDawnTexture(GrDawnGpu*, const SkISize& dimensions, GrPixelConfig config, dawn::TextureView,
+ GrDawnTexture(GrDawnGpu*, const SkISize& dimensions, GrPixelConfig config, wgpu::TextureView,
const GrDawnImageInfo&, GrMipMapsStatus);
GrDawnGpu* getDawnGpu() const;
@@ -55,7 +55,7 @@
GrDawnTexture(GrDawnGpu*, const GrSurfaceDesc&, const GrDawnImageInfo&, GrMipMapsStatus);
GrDawnImageInfo fInfo;
- dawn::TextureView fTextureView;
+ wgpu::TextureView fTextureView;
typedef GrTexture INHERITED;
};
diff --git a/src/gpu/dawn/GrDawnTextureRenderTarget.cpp b/src/gpu/dawn/GrDawnTextureRenderTarget.cpp
index e453379..d94fd24 100644
--- a/src/gpu/dawn/GrDawnTextureRenderTarget.cpp
+++ b/src/gpu/dawn/GrDawnTextureRenderTarget.cpp
@@ -15,7 +15,7 @@
GrDawnTextureRenderTarget::GrDawnTextureRenderTarget(GrDawnGpu* gpu,
const SkISize& dimensions,
GrPixelConfig config,
- dawn::TextureView textureView,
+ wgpu::TextureView textureView,
int sampleCnt,
const GrDawnImageInfo& info,
GrMipMapsStatus mipMapsStatus)
diff --git a/src/gpu/dawn/GrDawnTextureRenderTarget.h b/src/gpu/dawn/GrDawnTextureRenderTarget.h
index 73dbcc5..48a1bfa 100644
--- a/src/gpu/dawn/GrDawnTextureRenderTarget.h
+++ b/src/gpu/dawn/GrDawnTextureRenderTarget.h
@@ -24,7 +24,7 @@
GrDawnTextureRenderTarget(GrDawnGpu* gpu,
const SkISize& dimensions,
GrPixelConfig config,
- const dawn::TextureView textureView,
+ const wgpu::TextureView textureView,
int sampleCnt,
const GrDawnImageInfo& info,
GrMipMapsStatus mipMapsStatus);
diff --git a/src/gpu/dawn/GrDawnUtil.cpp b/src/gpu/dawn/GrDawnUtil.cpp
index 7404dac..9ec9047 100644
--- a/src/gpu/dawn/GrDawnUtil.cpp
+++ b/src/gpu/dawn/GrDawnUtil.cpp
@@ -7,14 +7,14 @@
#include "src/gpu/dawn/GrDawnUtil.h"
-size_t GrDawnBytesPerPixel(dawn::TextureFormat format) {
+size_t GrDawnBytesPerPixel(wgpu::TextureFormat format) {
switch (format) {
- case dawn::TextureFormat::RGBA8Unorm:
- case dawn::TextureFormat::BGRA8Unorm:
+ case wgpu::TextureFormat::RGBA8Unorm:
+ case wgpu::TextureFormat::BGRA8Unorm:
return 4;
- case dawn::TextureFormat::R8Unorm:
+ case wgpu::TextureFormat::R8Unorm:
return 1;
- case dawn::TextureFormat::Depth24PlusStencil8:
+ case wgpu::TextureFormat::Depth24PlusStencil8:
return 4;
default:
SkASSERT(false);
@@ -22,26 +22,26 @@
}
}
-bool GrDawnFormatIsRenderable(dawn::TextureFormat format) {
+bool GrDawnFormatIsRenderable(wgpu::TextureFormat format) {
// For now, all the formats above are renderable. If a non-renderable format is added
// (see dawn/src/dawn_native/Format.cpp), an exception should be added here.
return true;
}
-bool GrPixelConfigToDawnFormat(GrPixelConfig config, dawn::TextureFormat* format) {
+bool GrPixelConfigToDawnFormat(GrPixelConfig config, wgpu::TextureFormat* format) {
switch (config) {
case kRGBA_8888_GrPixelConfig:
case kRGBA_4444_GrPixelConfig:
case kRGB_565_GrPixelConfig:
case kGray_8_GrPixelConfig:
- *format = dawn::TextureFormat::RGBA8Unorm;
+ *format = wgpu::TextureFormat::RGBA8Unorm;
return true;
case kBGRA_8888_GrPixelConfig:
- *format = dawn::TextureFormat::BGRA8Unorm;
+ *format = wgpu::TextureFormat::BGRA8Unorm;
return true;
case kAlpha_8_GrPixelConfig:
case kAlpha_8_as_Red_GrPixelConfig:
- *format = dawn::TextureFormat::R8Unorm;
+ *format = wgpu::TextureFormat::R8Unorm;
return true;
default:
return false;
@@ -54,15 +54,15 @@
}
#if GR_TEST_UTILS
-const char* GrDawnFormatToStr(dawn::TextureFormat format) {
+const char* GrDawnFormatToStr(wgpu::TextureFormat format) {
switch (format) {
- case dawn::TextureFormat::RGBA8Unorm:
+ case wgpu::TextureFormat::RGBA8Unorm:
return "RGBA8Unorm";
- case dawn::TextureFormat::BGRA8Unorm:
+ case wgpu::TextureFormat::BGRA8Unorm:
return "BGRA8Unorm";
- case dawn::TextureFormat::R8Unorm:
+ case wgpu::TextureFormat::R8Unorm:
return "R8Unorm";
- case dawn::TextureFormat::Depth24PlusStencil8:
+ case wgpu::TextureFormat::Depth24PlusStencil8:
return "Depth24PlusStencil8";
default:
SkASSERT(false);
diff --git a/src/gpu/dawn/GrDawnUtil.h b/src/gpu/dawn/GrDawnUtil.h
index 0e5a41b..4592073 100644
--- a/src/gpu/dawn/GrDawnUtil.h
+++ b/src/gpu/dawn/GrDawnUtil.h
@@ -11,12 +11,12 @@
#include "include/private/GrTypesPriv.h"
#include "dawn/dawncpp.h"
-size_t GrDawnBytesPerPixel(dawn::TextureFormat format);
-bool GrDawnFormatIsRenderable(dawn::TextureFormat format);
-bool GrPixelConfigToDawnFormat(GrPixelConfig config, dawn::TextureFormat* format);
+size_t GrDawnBytesPerPixel(wgpu::TextureFormat format);
+bool GrDawnFormatIsRenderable(wgpu::TextureFormat format);
+bool GrPixelConfigToDawnFormat(GrPixelConfig config, wgpu::TextureFormat* format);
size_t GrDawnRoundRowBytes(size_t rowBytes);
#if GR_TEST_UTILS
-const char* GrDawnFormatToStr(dawn::TextureFormat format);
+const char* GrDawnFormatToStr(wgpu::TextureFormat format);
#endif
#endif // GrDawnUtil_DEFINED