Commit 0631e19b by Jamie Madill Committed by Commit Bot

Vulkan: Rename Vulkan "Texture" format to "Image"

Also adds some comments to vk_format_utils.h. Bug: angleproject:3372 Change-Id: I529b9b189e4cdfd400c3c981a47139727d9954ab Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1565062 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 3b775865
......@@ -186,11 +186,11 @@
"Vulkan format:src/libANGLE/renderer/angle_format_map.json":
"be9f9bdbdf785dda05920146e8c55dbb",
"Vulkan format:src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"9937d3c942f0a5fe08f1ca080d40d47e",
"c1f153d67fa50e5f6683170c83b610d4",
"Vulkan format:src/libANGLE/renderer/vulkan/vk_format_map.json":
"9b5a784d36ea31610e143d23860425d7",
"a6522dc0af17eebfee8b3d6d4723594f",
"Vulkan format:src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp":
"ef0ea80cf33e60f76391bcfed10b3c0a",
"34dcf4f106f94b03f74c9fd08b22f6ed",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/gen_vk_internal_shaders.py":
"1262e5e903c7dad214ded83625f9d3c4",
"Vulkan internal shader programs:src/libANGLE/renderer/vulkan/shaders/gen/BufferUtils.comp.00000000.inc":
......
......@@ -45,7 +45,7 @@ const gl::InternalFormat &GetReadAttachmentInfo(const gl::Context *context,
RenderTargetVk *renderTarget)
{
GLenum implFormat =
renderTarget->getImageFormat().textureFormat().fboImplementationInternalFormat;
renderTarget->getImageFormat().imageFormat().fboImplementationInternalFormat;
return gl::GetSizedInternalFormatInfo(implFormat);
}
......@@ -62,12 +62,12 @@ bool HasSrcAndDstBlitProperties(RendererVk *renderer,
RenderTargetVk *srcRenderTarget,
RenderTargetVk *dstRenderTarget)
{
const VkFormat srcFormat = srcRenderTarget->getImageFormat().vkTextureFormat;
const VkFormat dstFormat = dstRenderTarget->getImageFormat().vkTextureFormat;
const VkFormat srcFormat = srcRenderTarget->getImageFormat().vkImageFormat;
const VkFormat dstFormat = dstRenderTarget->getImageFormat().vkImageFormat;
// Verifies if the draw and read images have the necessary prerequisites for blitting.
return renderer->hasTextureFormatFeatureBits(srcFormat, VK_FORMAT_FEATURE_BLIT_SRC_BIT) &&
renderer->hasTextureFormatFeatureBits(dstFormat, VK_FORMAT_FEATURE_BLIT_DST_BIT);
return renderer->hasImageFormatFeatureBits(srcFormat, VK_FORMAT_FEATURE_BLIT_SRC_BIT) &&
renderer->hasImageFormatFeatureBits(dstFormat, VK_FORMAT_FEATURE_BLIT_DST_BIT);
}
// Special rules apply to VkBufferImageCopy with depth/stencil. The components are tightly packed
......@@ -539,7 +539,7 @@ angle::Result FramebufferVk::blitWithReadback(ContextVk *contextVk,
RenderTargetVk *drawRenderTarget)
{
RendererVk *renderer = contextVk->getRenderer();
const angle::Format &readFormat = readRenderTarget->getImageFormat().textureFormat();
const angle::Format &readFormat = readRenderTarget->getImageFormat().imageFormat();
ASSERT(aspect == VK_IMAGE_ASPECT_DEPTH_BIT || aspect == VK_IMAGE_ASPECT_STENCIL_BIT);
......@@ -752,7 +752,7 @@ angle::Result FramebufferVk::blitWithCommand(ContextVk *contextVk,
const vk::Format &readImageFormat = readRenderTarget->getImageFormat();
VkImageAspectFlags aspectMask =
colorBlit ? VK_IMAGE_ASPECT_COLOR_BIT
: vk::GetDepthStencilAspectFlags(readImageFormat.textureFormat());
: vk::GetDepthStencilAspectFlags(readImageFormat.imageFormat());
vk::ImageHelper *srcImage = readRenderTarget->getImageForRead(
&mFramebuffer, vk::ImageLayout::TransferSrc, commandBuffer);
......@@ -845,7 +845,7 @@ angle::Result FramebufferVk::syncState(const gl::Context *context,
if (renderTarget)
{
const angle::Format &emulatedFormat =
renderTarget->getImageFormat().textureFormat();
renderTarget->getImageFormat().imageFormat();
updateActiveColorMasks(
colorIndex, emulatedFormat.redBits > 0, emulatedFormat.greenBits > 0,
emulatedFormat.blueBits > 0, emulatedFormat.alphaBits > 0);
......@@ -1064,7 +1064,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
const RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndex];
ASSERT(colorRenderTarget);
params.colorFormat = &colorRenderTarget->getImage().getFormat().textureFormat();
params.colorFormat = &colorRenderTarget->getImage().getFormat().imageFormat();
params.colorAttachmentIndex = colorIndex;
params.colorMaskFlags = colorMaskFlags;
if (mEmulatedAlphaAttachmentMask[colorIndex])
......@@ -1177,7 +1177,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
vk::ImageHelper *srcImage =
renderTarget->getImageForRead(&mFramebuffer, vk::ImageLayout::TransferSrc, commandBuffer);
const angle::Format *readFormat = &srcImage->getFormat().textureFormat();
const angle::Format *readFormat = &srcImage->getFormat().imageFormat();
if (copyAspectFlags != VK_IMAGE_ASPECT_COLOR_BIT)
{
......
......@@ -58,7 +58,7 @@ angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk,
vk::RenderPassDesc *renderPassDesc)
{
ASSERT(commandBuffer->valid());
ASSERT(!mImage->getFormat().textureFormat().hasDepthOrStencilBits());
ASSERT(!mImage->getFormat().imageFormat().hasDepthOrStencilBits());
// Store the attachment info in the renderPassDesc.
renderPassDesc->packAttachment(mImage->getFormat());
......@@ -81,13 +81,13 @@ angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk,
vk::RenderPassDesc *renderPassDesc)
{
ASSERT(commandBuffer->valid());
ASSERT(mImage->getFormat().textureFormat().hasDepthOrStencilBits());
ASSERT(mImage->getFormat().imageFormat().hasDepthOrStencilBits());
// Store the attachment info in the renderPassDesc.
renderPassDesc->packAttachment(mImage->getFormat());
// TODO(jmadill): Use automatic layout transition. http://anglebug.com/2361
const angle::Format &format = mImage->getFormat().textureFormat();
const angle::Format &format = mImage->getFormat().imageFormat();
VkImageAspectFlags aspectFlags = vk::GetDepthStencilAspectFlags(format);
ANGLE_TRY(ensureImageInitialized(contextVk));
......
......@@ -63,7 +63,7 @@ angle::Result RenderbufferVk::setStorage(const gl::Context *context,
mOwnsImage = true;
}
const angle::Format &textureFormat = vkFormat.textureFormat();
const angle::Format &textureFormat = vkFormat.imageFormat();
bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0;
const VkImageUsageFlags usage =
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
......@@ -117,7 +117,7 @@ angle::Result RenderbufferVk::setStorageEGLImageTarget(const gl::Context *contex
mOwnsImage = false;
const vk::Format &vkFormat = renderer->getFormat(image->getFormat().info->sizedInternalFormat);
const angle::Format &textureFormat = vkFormat.textureFormat();
const angle::Format &textureFormat = vkFormat.imageFormat();
VkImageAspectFlags aspect = vk::GetFormatAspectFlags(textureFormat);
......
......@@ -1818,14 +1818,13 @@ angle::Result RendererVk::getTimestamp(vk::Context *context, uint64_t *timestamp
// These functions look at the mandatory format for support, and fallback to querying the device (if
// necessary) to test the availability of the bits.
bool RendererVk::hasLinearTextureFormatFeatureBits(VkFormat format,
const VkFormatFeatureFlags featureBits)
bool RendererVk::hasLinearImageFormatFeatureBits(VkFormat format,
const VkFormatFeatureFlags featureBits)
{
return hasFormatFeatureBits<&VkFormatProperties::linearTilingFeatures>(format, featureBits);
}
bool RendererVk::hasTextureFormatFeatureBits(VkFormat format,
const VkFormatFeatureFlags featureBits)
bool RendererVk::hasImageFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits)
{
return hasFormatFeatureBits<&VkFormatProperties::optimalTilingFeatures>(format, featureBits);
}
......
......@@ -202,8 +202,8 @@ class RendererVk : angle::NonCopyable
// Query the format properties for select bits (linearTilingFeatures, optimalTilingFeatures and
// bufferFeatures). Looks through mandatory features first, and falls back to querying the
// device (first time only).
bool hasLinearTextureFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits);
bool hasTextureFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits);
bool hasLinearImageFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits);
bool hasImageFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits);
bool hasBufferFormatFeatureBits(VkFormat format, const VkFormatFeatureFlags featureBits);
void insertDebugMarker(GLenum source, GLuint id, std::string &&marker);
......
......@@ -92,7 +92,7 @@ angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *display
{
RendererVk *renderer = displayVk->getRenderer();
const angle::Format &textureFormat = vkFormat.textureFormat();
const angle::Format &textureFormat = vkFormat.imageFormat();
bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0;
const VkImageUsageFlags usage = isDepthOrStencilFormat ? kSurfaceVKDepthStencilImageUsageFlags
: kSurfaceVKColorImageUsageFlags;
......@@ -464,7 +464,7 @@ angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk)
surfaceFormats.data()));
const vk::Format &format = renderer->getFormat(mState.config->renderTargetFormat);
VkFormat nativeFormat = format.vkTextureFormat;
VkFormat nativeFormat = format.vkImageFormat;
if (surfaceFormatCount == 1u && surfaceFormats[0].format == VK_FORMAT_UNDEFINED)
{
......@@ -522,7 +522,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
releaseSwapchainImages(renderer);
const vk::Format &format = renderer->getFormat(mState.config->renderTargetFormat);
VkFormat nativeFormat = format.vkTextureFormat;
VkFormat nativeFormat = format.vkImageFormat;
// We need transfer src for reading back from the backbuffer.
constexpr VkImageUsageFlags kImageUsageFlags = kSurfaceVKColorImageUsageFlags;
......@@ -588,7 +588,7 @@ angle::Result WindowSurfaceVk::recreateSwapchain(DisplayVk *displayVk,
ANGLE_TRY(mDepthStencilImage.initMemory(displayVk, renderer->getMemoryProperties(),
VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT));
const VkImageAspectFlags aspect = vk::GetDepthStencilAspectFlags(dsFormat.textureFormat());
const VkImageAspectFlags aspect = vk::GetDepthStencilAspectFlags(dsFormat.imageFormat());
ANGLE_TRY(mDepthStencilImage.initImageView(displayVk, gl::TextureType::_2D, aspect,
gl::SwizzleState(), &mDepthStencilImageView, 0,
1));
......@@ -742,10 +742,10 @@ angle::Result WindowSurfaceVk::present(DisplayVk *displayVk,
presentInfo.sType = VK_STRUCTURE_TYPE_PRESENT_INFO_KHR;
presentInfo.waitSemaphoreCount = 1;
presentInfo.pWaitSemaphores = mFlushSemaphoreChain.back().ptr();
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &mSwapchain;
presentInfo.pImageIndices = &mCurrentSwapchainImageIndex;
presentInfo.pResults = nullptr;
presentInfo.swapchainCount = 1;
presentInfo.pSwapchains = &mSwapchain;
presentInfo.pImageIndices = &mCurrentSwapchainImageIndex;
presentInfo.pResults = nullptr;
VkPresentRegionKHR presentRegion = {};
VkPresentRegionsKHR presentRegions = {};
......@@ -825,7 +825,7 @@ angle::Result WindowSurfaceVk::swapImpl(DisplayVk *displayVk, EGLint *rects, EGL
angle::Result WindowSurfaceVk::nextSwapchainImage(DisplayVk *displayVk)
{
VkDevice device = displayVk->getDevice();
VkDevice device = displayVk->getDevice();
vk::Semaphore aquireImageSemaphore;
ANGLE_VK_TRY(displayVk, aquireImageSemaphore.init(device));
......
......@@ -45,20 +45,20 @@ bool CanCopyWithTransfer(RendererVk *renderer,
// NOTE(syoussefi): technically, you can transfer between formats as long as they have the same
// size and are compatible, but for now, let's just support same-format copies with transfer.
return srcFormat.internalFormat == destFormat.internalFormat &&
renderer->hasTextureFormatFeatureBits(srcFormat.vkTextureFormat,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) &&
renderer->hasTextureFormatFeatureBits(destFormat.vkTextureFormat,
VK_FORMAT_FEATURE_TRANSFER_DST_BIT);
renderer->hasImageFormatFeatureBits(srcFormat.vkImageFormat,
VK_FORMAT_FEATURE_TRANSFER_SRC_BIT) &&
renderer->hasImageFormatFeatureBits(destFormat.vkImageFormat,
VK_FORMAT_FEATURE_TRANSFER_DST_BIT);
}
bool CanCopyWithDraw(RendererVk *renderer,
const vk::Format &srcFormat,
const vk::Format &destFormat)
{
return renderer->hasTextureFormatFeatureBits(srcFormat.vkTextureFormat,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) &&
renderer->hasTextureFormatFeatureBits(destFormat.vkTextureFormat,
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
return renderer->hasImageFormatFeatureBits(srcFormat.vkImageFormat,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT) &&
renderer->hasImageFormatFeatureBits(destFormat.vkImageFormat,
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
}
bool ForceCpuPathForCopy(RendererVk *renderer, vk::ImageHelper *image)
......@@ -492,8 +492,8 @@ angle::Result TextureVk::copySubTextureImpl(ContextVk *contextVk,
uint8_t *sourceData = nullptr;
ANGLE_TRY(source->copyImageDataToBuffer(contextVk, sourceLevel, 1, sourceArea, &sourceData));
const angle::Format &sourceTextureFormat = sourceVkFormat.textureFormat();
const angle::Format &destTextureFormat = destVkFormat.textureFormat();
const angle::Format &sourceTextureFormat = sourceVkFormat.imageFormat();
const angle::Format &destTextureFormat = destVkFormat.imageFormat();
size_t destinationAllocationSize =
sourceArea.width * sourceArea.height * destTextureFormat.pixelBytes;
......@@ -670,7 +670,7 @@ angle::Result TextureVk::copySubImageImplWithDraw(ContextVk *contextVk,
// TODO(syoussefi): If the cube map is LUMA, we need swizzle. http://anglebug.com/2911
// This can't happen when copying from framebuffers, so only source of concern would be
// copy[Sub]Texture copying from a LUMA cube map.
ASSERT(!srcImage->getFormat().textureFormat().isLUMA());
ASSERT(!srcImage->getFormat().imageFormat().isLUMA());
gl::TextureType arrayTextureType =
Get2DTextureType(srcImage->getLayerCount(), srcImage->getSamples());
......@@ -991,7 +991,7 @@ angle::Result TextureVk::copyImageDataToBuffer(ContextVk *contextVk,
// Make sure the source is initialized and it's images are flushed.
ANGLE_TRY(ensureImageInitialized(contextVk));
const angle::Format &imageFormat = getImage().getFormat().textureFormat();
const angle::Format &imageFormat = getImage().getFormat().imageFormat();
size_t sourceCopyAllocationSize =
sourceArea.width * sourceArea.height * imageFormat.pixelBytes * layerCount;
......@@ -1044,7 +1044,7 @@ angle::Result TextureVk::generateMipmapsWithCPU(const gl::Context *context)
ANGLE_TRY(copyImageDataToBuffer(contextVk, mState.getEffectiveBaseLevel(), imageLayerCount,
imageArea, &imageData));
const angle::Format &angleFormat = mImage->getFormat().textureFormat();
const angle::Format &angleFormat = mImage->getFormat().imageFormat();
GLuint sourceRowPitch = baseLevelExtents.width * angleFormat.pixelBytes;
size_t baseLevelAllocationSize = sourceRowPitch * baseLevelExtents.height;
......@@ -1092,8 +1092,7 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context)
// Check if the image supports blit. If it does, we can do the mipmap generation on the gpu
// only.
if (renderer->hasTextureFormatFeatureBits(mImage->getFormat().vkTextureFormat,
kBlitFeatureFlags))
if (renderer->hasImageFormatFeatureBits(mImage->getFormat().vkImageFormat, kBlitFeatureFlags))
{
ANGLE_TRY(ensureImageInitialized(contextVk));
ANGLE_TRY(mImage->generateMipmapsWithBlit(contextVk, mState.getMipmapMaxLevel()));
......@@ -1317,7 +1316,7 @@ angle::Result TextureVk::getLayerLevelDrawImageView(vk::Context *context,
vk::ImageView **imageViewOut)
{
ASSERT(mImage->valid());
ASSERT(!mImage->getFormat().textureFormat().isBlock);
ASSERT(!mImage->getFormat().imageFormat().isBlock);
// Lazily allocate the storage for image views
if (mLayerLevelDrawImageViews.empty())
......@@ -1359,7 +1358,7 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer)
{
const RendererVk *renderer = contextVk->getRenderer();
const angle::Format &textureFormat = format.textureFormat();
const angle::Format &textureFormat = format.imageFormat();
VkImageUsageFlags imageUsageFlags = VK_IMAGE_USAGE_TRANSFER_DST_BIT |
VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
......@@ -1382,7 +1381,7 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
// If the image has an emulated channel, always clear it. These channels will be masked out in
// future writes, and shouldn't contain uninitialized values.
if (format.hasEmulatedChannels())
if (format.hasEmulatedImageChannels())
{
uint32_t levelCount = mImage->getLevelCount();
uint32_t layerCount = mImage->getLayerCount();
......@@ -1418,7 +1417,7 @@ angle::Result TextureVk::initImageViews(ContextVk *contextVk,
ANGLE_TRY(mImage->initLayerImageView(contextVk, mState.getType(), VK_IMAGE_ASPECT_COLOR_BIT,
mappedSwizzle, &mReadBaseLevelImageView, baseLevel, 1,
baseLayer, layerCount));
if (!format.textureFormat().isBlock)
if (!format.imageFormat().isBlock)
{
ANGLE_TRY(mImage->initLayerImageView(contextVk, mState.getType(), VK_IMAGE_ASPECT_COLOR_BIT,
gl::SwizzleState(), &mDrawBaseLevelImageView,
......
......@@ -159,7 +159,7 @@ uint32_t GetFormatDefaultChannelMask(const vk::Format &format)
uint32_t mask = 0;
const angle::Format &angleFormat = format.angleFormat();
const angle::Format &textureFormat = format.textureFormat();
const angle::Format &textureFormat = format.imageFormat();
// Red can never be introduced due to format emulation (except for luma which is handled
// especially)
......
......@@ -98,13 +98,13 @@ angle::Result HardwareBufferImageSiblingVkAndroid::initImpl(DisplayVk *displayVk
ANGLE_VK_TRY(displayVk, vkGetAndroidHardwareBufferPropertiesANDROID(device, hardwareBuffer,
&bufferProperties));
const vk::Format &vkFormat = renderer->getFormat(internalFormat);
const angle::Format &textureFormat = vkFormat.textureFormat();
bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0;
const vk::Format &vkFormat = renderer->getFormat(internalFormat);
const angle::Format &imageFormat = vkFormat.imageFormat();
bool isDepthOrStencilFormat = imageFormat.depthBits > 0 || imageFormat.stencilBits > 0;
const VkImageUsageFlags usage =
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
VK_IMAGE_USAGE_SAMPLED_BIT |
(textureFormat.redBits > 0 ? VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT : 0) |
(imageFormat.redBits > 0 ? VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT : 0) |
(isDepthOrStencilFormat ? VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT : 0);
VkExternalFormatANDROID externalFormat = {};
......@@ -149,15 +149,15 @@ angle::Result HardwareBufferImageSiblingVkAndroid::initImpl(DisplayVk *displayVk
constexpr uint32_t kColorRenderableRequiredBits = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
constexpr uint32_t kDepthStencilRenderableRequiredBits = VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
mRenderable = renderer->hasTextureFormatFeatureBits(vkFormat.vkTextureFormat,
kColorRenderableRequiredBits) ||
renderer->hasTextureFormatFeatureBits(vkFormat.vkTextureFormat,
kDepthStencilRenderableRequiredBits);
mRenderable =
renderer->hasImageFormatFeatureBits(vkFormat.vkImageFormat, kColorRenderableRequiredBits) ||
renderer->hasImageFormatFeatureBits(vkFormat.vkImageFormat,
kDepthStencilRenderableRequiredBits);
constexpr uint32_t kTextureableRequiredBits =
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
mTextureable =
renderer->hasTextureFormatFeatureBits(vkFormat.vkTextureFormat, kTextureableRequiredBits);
renderer->hasImageFormatFeatureBits(vkFormat.vkImageFormat, kTextureableRequiredBits);
return angle::Result::Continue;
}
......
......@@ -66,20 +66,20 @@ break;
format_entry_template = """case angle::FormatID::{format_id}:
internalFormat = {internal_format};
{texture_template}
{image_template}
{buffer_template}
break;
"""
texture_basic_template = """textureFormatID = {texture};
vkTextureFormat = {vk_texture_format};
textureInitializerFunction = {texture_initializer};"""
image_basic_template = """imageFormatID = {image};
vkImageFormat = {vk_image_format};
imageInitializerFunction = {image_initializer};"""
texture_struct_template="{{{texture}, {vk_texture_format}, {texture_initializer}}}"
image_struct_template="{{{image}, {vk_image_format}, {image_initializer}}}"
texture_fallback_template = """{{
static constexpr TextureFormatInitInfo kInfo[] = {{{texture_list}}};
initTextureFallback(renderer, kInfo, ArraySize(kInfo));
image_fallback_template = """{{
static constexpr ImageFormatInitInfo kInfo[] = {{{image_list}}};
initImageFallback(renderer, kInfo, ArraySize(kInfo));
}}"""
buffer_basic_template = """bufferFormatID = {buffer};
......@@ -108,7 +108,7 @@ def gen_format_case(angle, internal_format, vk_json_data):
args = dict(
format_id=angle,
internal_format=internal_format,
texture_template="",
image_template="",
buffer_template="")
if ((angle not in vk_map) and (angle not in vk_overrides) and
......@@ -124,11 +124,11 @@ def gen_format_case(angle, internal_format, vk_json_data):
fallbacks = [fallbacks]
return [format] + fallbacks
def texture_args(format):
def image_args(format):
return dict(
texture="angle::FormatID::" + format,
vk_texture_format=vk_map[format],
texture_initializer=angle_format.get_internal_format_initializer(
image="angle::FormatID::" + format,
vk_image_format=vk_map[format],
image_initializer=angle_format.get_internal_format_initializer(
internal_format, format))
def buffer_args(format):
......@@ -141,16 +141,16 @@ def gen_format_case(angle, internal_format, vk_json_data):
vertex_load_converts='false' if angle == format else 'true',
)
textures = get_formats(angle, "texture")
if len(textures) == 1:
args.update(texture_template=texture_basic_template)
args.update(texture_args(textures[0]))
elif len(textures) > 1:
images = get_formats(angle, "image")
if len(images) == 1:
args.update(image_template=image_basic_template)
args.update(image_args(images[0]))
elif len(images) > 1:
args.update(
texture_template=texture_fallback_template,
texture_list=", ".join(
texture_struct_template.format(**texture_args(i))
for i in textures))
image_template=image_fallback_template,
image_list=", ".join(
image_struct_template.format(**image_args(i))
for i in images))
buffers = get_formats(angle, "buffer")
if len(buffers) == 1:
......
......@@ -144,7 +144,7 @@ void UnpackAttachmentDesc(VkAttachmentDescription *desc,
{
// We would only need this flag for duplicated attachments. Apply it conservatively.
desc->flags = VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT;
desc->format = format.vkTextureFormat;
desc->format = format.vkImageFormat;
desc->samples = gl_vk::GetSamples(samples);
desc->loadOp = static_cast<VkAttachmentLoadOp>(ops.loadOp);
desc->storeOp = static_cast<VkAttachmentStoreOp>(ops.storeOp);
......
......@@ -4,7 +4,7 @@
"Use of this source code is governed by a BSD-style license that can be",
"found in the LICENSE file.",
"",
"vk_format_map.json: Texture format mapping between OpenGL and Vulkan.",
"vk_format_map.json: Format mapping between OpenGL and Vulkan.",
"",
"The format of the map is a dictionary where the key of each entry is the",
"ANGLE format ID, and the value is the Vulkan format enum. Note some formats",
......@@ -14,7 +14,7 @@
"",
"We implement formats that aren't natively supported in Vulkan using",
"fallback and override formats. These are specified as dictionaries (also keyed on",
"the angle format ID), with two optional entries for Buffer and Texture/Image",
"the angle format ID), with two optional entries for Buffer and Image",
"formats. Each entry specifies a fallback or override format.",
"",
"Override formats are used for emulated support for formats we assume are never",
......@@ -190,43 +190,43 @@
},
"overrides": {
"A16_FLOAT": {
"texture": "R16_FLOAT"
"image": "R16_FLOAT"
},
"A32_FLOAT": {
"texture": "R32_FLOAT"
"image": "R32_FLOAT"
},
"A8_UNORM": {
"texture": "R8_UNORM"
"image": "R8_UNORM"
},
"L8_UNORM": {
"texture": "R8_UNORM"
"image": "R8_UNORM"
},
"L8A8_UNORM": {
"texture": "R8G8_UNORM"
"image": "R8G8_UNORM"
},
"R4G4B4A4_UNORM": {
"texture": "R8G8B8A8_UNORM"
"image": "R8G8B8A8_UNORM"
},
"R5G5B5A1_UNORM": {
"texture": "A1R5G5B5_UNORM"
"image": "A1R5G5B5_UNORM"
},
"R8G8B8_UNORM": {
"texture": "R8G8B8A8_UNORM"
"image": "R8G8B8A8_UNORM"
},
"R8G8B8_UNORM_SRGB": {
"texture": "R8G8B8A8_UNORM_SRGB"
"image": "R8G8B8A8_UNORM_SRGB"
},
"B8G8R8X8_UNORM": {
"buffer": "NONE",
"texture": "B8G8R8A8_UNORM"
"image": "B8G8R8A8_UNORM"
},
"D24_UNORM_X8_UINT": {
"buffer": "NONE",
"texture": "D24_UNORM_S8_UINT"
"image": "D24_UNORM_S8_UINT"
},
"ETC1_R8G8B8_UNORM_BLOCK": {
"buffer": "NONE",
"texture": "ETC2_R8G8B8_UNORM_BLOCK"
"image": "ETC2_R8G8B8_UNORM_BLOCK"
},
"R32_FIXED": {
"buffer": "R32_FLOAT"
......@@ -243,16 +243,16 @@
},
"fallbacks": {
"D32_FLOAT_S8X24_UINT": {
"texture": ["D24_UNORM_S8_UINT", "D32_FLOAT_S8X24_UINT"]
"image": ["D24_UNORM_S8_UINT", "D32_FLOAT_S8X24_UINT"]
},
"D24_UNORM_S8_UINT": {
"texture": ["D32_FLOAT_S8X24_UINT", "D24_UNORM_S8_UINT"]
"image": ["D32_FLOAT_S8X24_UINT", "D24_UNORM_S8_UINT"]
},
"D24_UNORM_X8_UINT": {
"texture": ["D32_FLOAT_S8X24_UINT", "D24_UNORM_S8_UINT"]
"image": ["D32_FLOAT_S8X24_UINT", "D24_UNORM_S8_UINT"]
},
"S8_UINT": {
"texture": ["D24_UNORM_S8_UINT", "D32_FLOAT_S8X24_UINT", "S8_UINT"]
"image": ["D24_UNORM_S8_UINT", "D32_FLOAT_S8X24_UINT", "S8_UINT"]
},
"R8_UNORM": {
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -36,13 +36,13 @@ void FillTextureFormatCaps(RendererVk *renderer, VkFormat format, gl::TextureCap
const VkPhysicalDeviceLimits &physicalDeviceLimits =
renderer->getPhysicalDeviceProperties().limits;
bool hasColorAttachmentFeatureBit =
renderer->hasTextureFormatFeatureBits(format, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
bool hasDepthAttachmentFeatureBit = renderer->hasTextureFormatFeatureBits(
format, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);
renderer->hasImageFormatFeatureBits(format, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
bool hasDepthAttachmentFeatureBit =
renderer->hasImageFormatFeatureBits(format, VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT);
outTextureCaps->texturable =
renderer->hasTextureFormatFeatureBits(format, VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
outTextureCaps->filterable = renderer->hasTextureFormatFeatureBits(
renderer->hasImageFormatFeatureBits(format, VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
outTextureCaps->filterable = renderer->hasImageFormatFeatureBits(
format, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
outTextureCaps->textureAttachment =
hasColorAttachmentFeatureBit || hasDepthAttachmentFeatureBit;
......@@ -103,11 +103,11 @@ namespace vk
Format::Format()
: angleFormatID(angle::FormatID::NONE),
internalFormat(GL_NONE),
textureFormatID(angle::FormatID::NONE),
vkTextureFormat(VK_FORMAT_UNDEFINED),
imageFormatID(angle::FormatID::NONE),
vkImageFormat(VK_FORMAT_UNDEFINED),
bufferFormatID(angle::FormatID::NONE),
vkBufferFormat(VK_FORMAT_UNDEFINED),
textureInitializerFunction(nullptr),
imageInitializerFunction(nullptr),
textureLoadFunctions(),
vertexLoadRequiresConversion(false),
vkBufferFormatIsPacked(false),
......@@ -116,17 +116,15 @@ Format::Format()
vkFormatIsUnsigned(false)
{}
void Format::initTextureFallback(RendererVk *renderer,
const TextureFormatInitInfo *info,
int numInfo)
void Format::initImageFallback(RendererVk *renderer, const ImageFormatInitInfo *info, int numInfo)
{
size_t skip = renderer->getFeatures().forceFallbackFormat ? 1 : 0;
int i = FindSupportedFormat(renderer, info + skip, numInfo - skip, HasFullTextureFormatSupport);
i += skip;
textureFormatID = info[i].format;
vkTextureFormat = info[i].vkFormat;
textureInitializerFunction = info[i].initializer;
imageFormatID = info[i].format;
vkImageFormat = info[i].vkFormat;
imageInitializerFunction = info[i].initializer;
}
void Format::initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo *info, int numInfo)
......@@ -163,7 +161,7 @@ size_t Format::getImageCopyBufferAlignment() const
// - else blockSize % 4 != 0 gives a 2x multiplier
// - else there's no multiplier.
//
const angle::Format &format = textureFormat();
const angle::Format &format = imageFormat();
if (!format.isBlock)
{
......@@ -178,10 +176,10 @@ size_t Format::getImageCopyBufferAlignment() const
return alignment;
}
bool Format::hasEmulatedChannels() const
bool Format::hasEmulatedImageChannels() const
{
const angle::Format &angleFmt = angleFormat();
const angle::Format &textureFmt = textureFormat();
const angle::Format &textureFmt = imageFormat();
return (angleFmt.alphaBits == 0 && textureFmt.alphaBits > 0) ||
(angleFmt.blueBits == 0 && textureFmt.blueBits > 0) ||
......@@ -228,13 +226,12 @@ void FormatTable::initialize(RendererVk *renderer,
format.vkBufferFormat, VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT);
gl::TextureCaps textureCaps;
FillTextureFormatCaps(renderer, format.vkTextureFormat, &textureCaps);
FillTextureFormatCaps(renderer, format.vkImageFormat, &textureCaps);
outTextureCapsMap->set(formatID, textureCaps);
if (textureCaps.texturable)
{
format.textureLoadFunctions =
GetLoadFunctionsMap(internalFormat, format.textureFormatID);
format.textureLoadFunctions = GetLoadFunctionsMap(internalFormat, format.imageFormatID);
}
if (angleFormat.isBlock)
......@@ -252,8 +249,8 @@ bool HasFullTextureFormatSupport(RendererVk *renderer, VkFormat vkFormat)
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT;
constexpr uint32_t kBitsDepth = VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT;
return renderer->hasTextureFormatFeatureBits(vkFormat, kBitsColor) ||
renderer->hasTextureFormatFeatureBits(vkFormat, kBitsDepth);
return renderer->hasImageFormatFeatureBits(vkFormat, kBitsColor) ||
renderer->hasImageFormatFeatureBits(vkFormat, kBitsDepth);
}
size_t GetVertexInputAlignment(const vk::Format &format)
......
......@@ -34,7 +34,7 @@ namespace vk
// VkFormat values in range [0, kNumVkFormats) are used as indices in various tables.
constexpr uint32_t kNumVkFormats = 185;
struct TextureFormatInitInfo final
struct ImageFormatInitInfo final
{
angle::FormatID format;
VkFormat vkFormat;
......@@ -56,32 +56,42 @@ struct Format final : private angle::NonCopyable
bool valid() const { return internalFormat != 0; }
// This is an auto-generated method in vk_format_table_autogen.cpp.
void initialize(RendererVk *renderer, const angle::Format &angleFormat);
// The ANGLE format is the front-end format.
const angle::Format &angleFormat() const { return angle::Format::Get(angleFormatID); }
void initTextureFallback(RendererVk *renderer, const TextureFormatInitInfo *info, int numInfo);
void initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo *info, int numInfo);
// The Image format is the VkFormat used to implement the front-end format for VkImages.
const angle::Format &imageFormat() const { return angle::Format::Get(imageFormatID); }
const angle::Format &angleFormat() const { return angle::Format::Get(angleFormatID); }
const angle::Format &textureFormat() const { return angle::Format::Get(textureFormatID); }
// The Buffer format is the VkFormat used to implement the front-end format for VkBuffers.
const angle::Format &bufferFormat() const { return angle::Format::Get(bufferFormatID); }
// Get buffer alignment for image-copy operations (to or from a buffer).
// Returns OpenGL format information for the front-end format.
const gl::InternalFormat &getInternalFormatInfo(GLenum type) const
{
return gl::GetInternalFormatInfo(internalFormat, type);
}
// Get buffer alignment for image-copy operations (to or from a buffer).
size_t getImageCopyBufferAlignment() const;
bool hasEmulatedChannels() const;
// Returns true if the Image format has more channels than the ANGLE format.
bool hasEmulatedImageChannels() const;
// This is an auto-generated method in vk_format_table_autogen.cpp.
void initialize(RendererVk *renderer, const angle::Format &angleFormat);
// These are used in the format table init.
void initImageFallback(RendererVk *renderer, const ImageFormatInitInfo *info, int numInfo);
void initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo *info, int numInfo);
angle::FormatID angleFormatID;
GLenum internalFormat;
angle::FormatID textureFormatID;
VkFormat vkTextureFormat;
angle::FormatID imageFormatID;
VkFormat vkImageFormat;
angle::FormatID bufferFormatID;
VkFormat vkBufferFormat;
InitializeTextureDataFunction textureInitializerFunction;
InitializeTextureDataFunction imageInitializerFunction;
LoadFunctionMap textureLoadFunctions;
VertexCopyFunction vertexLoadFunction;
......
......@@ -1324,7 +1324,7 @@ angle::Result ImageHelper::initExternal(Context *context,
imageInfo.pNext = externalImageCreateInfo;
imageInfo.flags = GetImageCreateFlags(textureType);
imageInfo.imageType = gl_vk::GetImageType(textureType);
imageInfo.format = format.vkTextureFormat;
imageInfo.format = format.vkImageFormat;
imageInfo.extent.width = static_cast<uint32_t>(extents.width);
imageInfo.extent.height = static_cast<uint32_t>(extents.height);
imageInfo.extent.depth = 1;
......@@ -1419,7 +1419,7 @@ angle::Result ImageHelper::initLayerImageView(Context *context,
viewInfo.flags = 0;
viewInfo.image = mImage.getHandle();
viewInfo.viewType = gl_vk::GetImageViewType(textureType);
viewInfo.format = mFormat->vkTextureFormat;
viewInfo.format = mFormat->vkImageFormat;
if (swizzleMap.swizzleRequired())
{
viewInfo.components.r = gl_vk::GetSwizzle(swizzleMap.swizzleRed);
......@@ -1491,7 +1491,7 @@ angle::Result ImageHelper::init2DStaging(Context *context,
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
imageInfo.flags = 0;
imageInfo.imageType = VK_IMAGE_TYPE_2D;
imageInfo.format = format.vkTextureFormat;
imageInfo.format = format.vkImageFormat;
imageInfo.extent.width = static_cast<uint32_t>(extents.width);
imageInfo.extent.height = static_cast<uint32_t>(extents.height);
imageInfo.extent.depth = 1;
......@@ -1516,7 +1516,7 @@ angle::Result ImageHelper::init2DStaging(Context *context,
VkImageAspectFlags ImageHelper::getAspectFlags() const
{
return GetFormatAspectFlags(mFormat->textureFormat());
return GetFormatAspectFlags(mFormat->imageFormat());
}
void ImageHelper::dumpResources(Serial serial, std::vector<GarbageObject> *garbageQueue)
......@@ -1654,7 +1654,7 @@ void ImageHelper::clear(const VkClearValue &value,
if (isDepthStencil)
{
ASSERT(mipLevel == 0 && baseArrayLayer == 0 && layerCount == 1);
const VkImageAspectFlags aspect = vk::GetDepthStencilAspectFlags(mFormat->textureFormat());
const VkImageAspectFlags aspect = vk::GetDepthStencilAspectFlags(mFormat->imageFormat());
clearDepthStencil(aspect, aspect, value.depthStencil, commandBuffer);
}
else
......@@ -1828,7 +1828,7 @@ angle::Result ImageHelper::stageSubresourceUpdate(ContextVk *contextVk,
formatInfo.computeSkipBytes(type, inputRowPitch, inputDepthPitch, unpack,
applySkipImages, &inputSkipBytes));
const angle::Format &storageFormat = vkFormat.textureFormat();
const angle::Format &storageFormat = vkFormat.imageFormat();
size_t outputRowPitch;
size_t outputDepthPitch;
......@@ -1965,7 +1965,7 @@ angle::Result ImageHelper::stageSubresourceUpdateFromFramebuffer(
RendererVk *renderer = contextVk->getRenderer();
const vk::Format &vkFormat = renderer->getFormat(formatInfo.sizedInternalFormat);
const angle::Format &storageFormat = vkFormat.textureFormat();
const angle::Format &storageFormat = vkFormat.imageFormat();
LoadImageFunctionInfo loadFunction = vkFormat.textureLoadFunctions(formatInfo.type);
size_t outputRowPitch = storageFormat.pixelBytes * clippedRectangle.width;
......@@ -2065,7 +2065,7 @@ angle::Result ImageHelper::clearIfEmulatedFormat(Context *context,
const gl::ImageIndex &index,
const Format &format)
{
if (format.hasEmulatedChannels())
if (format.hasEmulatedImageChannels())
{
stageSubresourceEmulatedClear(index, format.angleFormat());
ANGLE_TRY(flushAllStagedUpdates(context));
......@@ -2124,7 +2124,7 @@ angle::Result ImageHelper::flushStagedUpdates(Context *context,
ANGLE_TRY(mStagingBuffer.flush(context));
std::vector<SubresourceUpdate> updatesToKeep;
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(mFormat->textureFormat());
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(mFormat->imageFormat());
for (SubresourceUpdate &update : mSubresourceUpdates)
{
......
......@@ -73,17 +73,17 @@ TEST_P(VulkanFormatTablesTest, TestFormatSupport)
// Now lets verify that that agaisnt vulkan.
VkFormatProperties formatProperties;
vkGetPhysicalDeviceFormatProperties(renderer->getPhysicalDevice(),
vkFormat.vkTextureFormat, &formatProperties);
vkFormat.vkImageFormat, &formatProperties);
VkImageFormatProperties imageProperties;
// isTexturable?
bool isTexturable =
vkGetPhysicalDeviceImageFormatProperties(
renderer->getPhysicalDevice(), vkFormat.vkTextureFormat, params.imageType,
renderer->getPhysicalDevice(), vkFormat.vkImageFormat, params.imageType,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, params.createFlags,
&imageProperties) == VK_SUCCESS;
EXPECT_EQ(isTexturable, textureCaps.texturable) << vkFormat.vkTextureFormat;
EXPECT_EQ(isTexturable, textureCaps.texturable) << vkFormat.vkImageFormat;
// TODO(jmadill): Support ES3 textures.
......@@ -91,23 +91,23 @@ TEST_P(VulkanFormatTablesTest, TestFormatSupport)
bool isFilterable = (formatProperties.optimalTilingFeatures &
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT) ==
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
EXPECT_EQ(isFilterable, textureCaps.filterable) << vkFormat.vkTextureFormat;
EXPECT_EQ(isFilterable, textureCaps.filterable) << vkFormat.vkImageFormat;
// isRenderable?
const bool isRenderableColor =
(vkGetPhysicalDeviceImageFormatProperties(
renderer->getPhysicalDevice(), vkFormat.vkTextureFormat, params.imageType,
renderer->getPhysicalDevice(), vkFormat.vkImageFormat, params.imageType,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
params.createFlags, &imageProperties)) == VK_SUCCESS;
const bool isRenderableDepthStencil =
(vkGetPhysicalDeviceImageFormatProperties(
renderer->getPhysicalDevice(), vkFormat.vkTextureFormat, params.imageType,
renderer->getPhysicalDevice(), vkFormat.vkImageFormat, params.imageType,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT,
params.createFlags, &imageProperties)) == VK_SUCCESS;
bool isRenderable = isRenderableColor || isRenderableDepthStencil;
EXPECT_EQ(isRenderable, textureCaps.textureAttachment) << vkFormat.vkTextureFormat;
EXPECT_EQ(isRenderable, textureCaps.renderbuffer) << vkFormat.vkTextureFormat;
EXPECT_EQ(isRenderable, textureCaps.textureAttachment) << vkFormat.vkImageFormat;
EXPECT_EQ(isRenderable, textureCaps.renderbuffer) << vkFormat.vkImageFormat;
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment