Make dawn_native use the webgpu.h header

BUG=dawn:22

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

View File

@@ -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);

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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];

View File

@@ -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;

View File

@@ -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:

View File

@@ -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();

View File

@@ -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;

View File

@@ -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);

View File

@@ -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();

View File

@@ -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_