Commit e91097bf by Jamie Madill Committed by Commit Bot

Vulkan: Clean up "actual"/"intended" naming.

Clarifies that the GL internal format is an "intended" format and the Vulkan formats are "actual" formats. This makes all the format fields use the same consistent naming pattern. Bug: angleproject:5438 Change-Id: I935a49895109e9e06eae5ef98d5614dfd1128ff8 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2605728Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarShahbaz Youssefi <syoussefi@chromium.org> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent 973bd4ba
......@@ -4,9 +4,9 @@
"src/libANGLE/renderer/angle_format_map.json":
"aa4a0d3463b76858a75787b9cdec8e98",
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"b4d38f08a354849dcba2a8f9f2569069",
"bf2279d1d8da7e3e271a352e101c8956",
"src/libANGLE/renderer/vulkan/vk_format_map.json":
"b62588b1e9f6d9fa98aeea886d8ed2bd",
"src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp":
"dfb656a573582202fe813eb23d5052dc"
"4dfb7525b4f45690091d6642e77481a3"
}
\ No newline at end of file
......@@ -49,13 +49,13 @@ constexpr unsigned int kEmulatedAlphaValue = 1;
bool HasSrcBlitFeature(RendererVk *renderer, RenderTargetVk *srcRenderTarget)
{
const VkFormat srcFormat = srcRenderTarget->getImageFormat().vkImageFormat;
const VkFormat srcFormat = srcRenderTarget->getImageFormat().actualImageVkFormat;
return renderer->hasImageFormatFeatureBits(srcFormat, VK_FORMAT_FEATURE_BLIT_SRC_BIT);
}
bool HasDstBlitFeature(RendererVk *renderer, RenderTargetVk *dstRenderTarget)
{
const VkFormat dstFormat = dstRenderTarget->getImageFormat().vkImageFormat;
const VkFormat dstFormat = dstRenderTarget->getImageFormat().actualImageVkFormat;
return renderer->hasImageFormatFeatureBits(dstFormat, VK_FORMAT_FEATURE_BLIT_DST_BIT);
}
......@@ -87,7 +87,7 @@ bool AreSrcAndDstFormatsIdentical(RenderTargetVk *srcRenderTarget, RenderTargetV
const vk::Format &srcFormat = srcRenderTarget->getImageFormat();
const vk::Format &dstFormat = dstRenderTarget->getImageFormat();
return srcFormat.vkImageFormat == dstFormat.vkImageFormat;
return srcFormat.actualImageVkFormat == dstFormat.actualImageVkFormat;
}
bool AreSrcAndDstDepthStencilChannelsBlitCompatible(RenderTargetVk *srcRenderTarget,
......
......@@ -178,7 +178,7 @@ angle::Result MemoryObjectVk::createImage(ContextVk *contextVk,
// values constituting the bits of |usageFlags| are identical to their corresponding Vulkan
// value.
const VkImageUsageFlags imageUsageFlags =
vk::GetMaximalImageUsageFlags(renderer, vkFormat.vkImageFormat) & usageFlags;
vk::GetMaximalImageUsageFlags(renderer, vkFormat.actualImageVkFormat) & usageFlags;
VkExternalMemoryImageCreateInfo externalMemoryImageCreateInfo = {};
externalMemoryImageCreateInfo.sType = VK_STRUCTURE_TYPE_EXTERNAL_MEMORY_IMAGE_CREATE_INFO;
......
......@@ -217,7 +217,7 @@ angle::Result OverlayVk::onPresent(ContextVk *contextVk,
// If the swapchain image doesn't support storage image, we can't output to it.
VkFormatFeatureFlags featureBits = renderer->getImageFormatFeatureBits(
imageToPresent->getFormat().vkImageFormat, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT);
imageToPresent->getFormat().actualImageVkFormat, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT);
if ((featureBits & VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT) == 0)
{
return angle::Result::Continue;
......
......@@ -82,7 +82,7 @@ angle::Result RenderbufferVk::setStorageImpl(const gl::Context *context,
// causing it to be interpreted in a different colorspace. Create the VkImage accordingly.
VkImageCreateFlags imageCreateFlags = vk::kVkImageCreateFlagsNone;
VkImageFormatListCreateInfoKHR *additionalCreateInfo = nullptr;
VkFormat vkImageFormat = vkFormat.vkImageFormat;
VkFormat vkImageFormat = vkFormat.actualImageVkFormat;
VkFormat vkImageListFormat = vkFormat.actualImageFormat().isSRGB
? vk::ConvertToLinear(vkImageFormat)
: vk::ConvertToSRGB(vkImageFormat);
......
......@@ -136,7 +136,7 @@ angle::Result InitImageHelper(DisplayVk *displayVk,
// causing it to be interpreted in a different colorspace. Create the VkImage accordingly.
VkImageCreateFlags imageCreateFlags = vk::kVkImageCreateFlagsNone;
VkImageFormatListCreateInfoKHR *additionalCreateInfo = nullptr;
VkFormat vkImageFormat = vkFormat.vkImageFormat;
VkFormat vkImageFormat = vkFormat.actualImageVkFormat;
VkFormat vkImageListFormat = vkFormat.actualImageFormat().isSRGB
? vk::ConvertToLinear(vkImageFormat)
: vk::ConvertToSRGB(vkImageFormat);
......@@ -680,7 +680,7 @@ angle::Result WindowSurfaceVk::initializeImpl(DisplayVk *displayVk)
surfaceFormats.data()));
const vk::Format &format = renderer->getFormat(mState.config->renderTargetFormat);
VkFormat nativeFormat = format.vkImageFormat;
VkFormat nativeFormat = format.actualImageVkFormat;
if (surfaceFormatCount == 1u && surfaceFormats[0].format == VK_FORMAT_UNDEFINED)
{
......@@ -929,7 +929,7 @@ angle::Result WindowSurfaceVk::createSwapChain(vk::Context *context,
VkDevice device = renderer->getDevice();
const vk::Format &format = renderer->getFormat(mState.config->renderTargetFormat);
VkFormat nativeFormat = format.vkImageFormat;
VkFormat nativeFormat = format.actualImageVkFormat;
gl::Extents rotatedExtents = extents;
if (Is90DegreeRotation(getPreTransform()))
......
......@@ -151,10 +151,12 @@ bool CanCopyWithDraw(RendererVk *renderer,
VkImageTiling destTilingMode)
{
// Checks that the formats in copy by drawing have the appropriate feature bits
bool srcFormatHasNecessaryFeature = vk::FormatHasNecessaryFeature(
renderer, srcFormat.vkImageFormat, srcTilingMode, VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
bool dstFormatHasNecessaryFeature = vk::FormatHasNecessaryFeature(
renderer, destFormat.vkImageFormat, destTilingMode, VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
bool srcFormatHasNecessaryFeature =
vk::FormatHasNecessaryFeature(renderer, srcFormat.actualImageVkFormat, srcTilingMode,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT);
bool dstFormatHasNecessaryFeature =
vk::FormatHasNecessaryFeature(renderer, destFormat.actualImageVkFormat, destTilingMode,
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT);
return srcFormatHasNecessaryFeature && dstFormatHasNecessaryFeature;
}
......@@ -178,7 +180,7 @@ bool CanGenerateMipmapWithCompute(RendererVk *renderer,
// Format must have STORAGE support.
const bool hasStorageSupport = renderer->hasImageFormatFeatureBits(
format.vkImageFormat, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT);
format.actualImageVkFormat, VK_FORMAT_FEATURE_STORAGE_IMAGE_BIT);
// No support for sRGB formats yet.
const bool isSRGB = angleFormat.isSRGB;
......@@ -285,7 +287,7 @@ angle::Result CopyAndStageImageSubresource(ContextVk *contextVk,
// Stage an update to the new image
ASSERT(stagingBuffer);
const gl::InternalFormat &formatInfo =
gl::GetSizedInternalFormatInfo(dstImage->getFormat().internalFormat);
gl::GetSizedInternalFormatInfo(dstImage->getFormat().intendedGLFormat);
uint32_t bufferRowLength;
uint32_t bufferImageHeight;
ANGLE_VK_CHECK_MATH(contextVk,
......@@ -1434,13 +1436,13 @@ void TextureVk::initImageUsageFlags(ContextVk *contextVk, const vk::Format &form
{
// Work around a bug in the Mock ICD:
// https://github.com/KhronosGroup/Vulkan-Tools/issues/445
if (renderer->hasImageFormatFeatureBits(format.vkImageFormat,
if (renderer->hasImageFormatFeatureBits(format.actualImageVkFormat,
VK_FORMAT_FEATURE_DEPTH_STENCIL_ATTACHMENT_BIT))
{
mImageUsageFlags |= VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT;
}
}
else if (renderer->hasImageFormatFeatureBits(format.vkImageFormat,
else if (renderer->hasImageFormatFeatureBits(format.actualImageVkFormat,
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BIT))
{
mImageUsageFlags |=
......@@ -1857,7 +1859,7 @@ angle::Result TextureVk::generateMipmap(const gl::Context *context)
return generateMipmapsWithCompute(contextVk);
}
else if (renderer->hasImageFormatFeatureBits(mImage->getFormat().vkImageFormat,
else if (renderer->hasImageFormatFeatureBits(mImage->getFormat().actualImageVkFormat,
kBlitFeatureFlags))
{
// Otherwise, use blit if possible.
......@@ -2482,7 +2484,7 @@ bool TextureVk::shouldDecodeSRGB(ContextVk *contextVk,
bool decodeSRGB = format.actualImageFormat().isSRGB;
// If the SRGB override is enabled, we also decode SRGB.
if (isSRGBOverrideEnabled() && vk::IsOverridableLinearFormat(format.vkImageFormat))
if (isSRGBOverrideEnabled() && vk::IsOverridableLinearFormat(format.actualImageVkFormat))
{
decodeSRGB = true;
}
......@@ -2556,7 +2558,7 @@ const vk::ImageView &TextureVk::getCopyImageViewAndRecordUse(ContextVk *contextV
imageViews.retain(&contextVk->getResourceUseList());
ASSERT(mImage->getFormat().actualImageFormat().isSRGB ==
(vk::ConvertToLinear(mImage->getFormat().vkImageFormat) != VK_FORMAT_UNDEFINED));
(vk::ConvertToLinear(mImage->getFormat().actualImageVkFormat) != VK_FORMAT_UNDEFINED));
if (mImage->getFormat().actualImageFormat().isSRGB)
{
return imageViews.getSRGBCopyImageView();
......@@ -2596,7 +2598,7 @@ angle::Result TextureVk::getStorageImageView(ContextVk *contextVk,
return getImageViews().getLevelLayerStorageImageView(
contextVk, *mImage, nativeLevelVk, nativeLayer,
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, format.vkImageFormat,
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, format.actualImageVkFormat,
imageViewOut);
}
......@@ -2604,7 +2606,7 @@ angle::Result TextureVk::getStorageImageView(ContextVk *contextVk,
return getImageViews().getLevelStorageImageView(
contextVk, mState.getType(), *mImage, nativeLevelVk, nativeLayer,
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, format.vkImageFormat,
VK_IMAGE_USAGE_SAMPLED_BIT | VK_IMAGE_USAGE_STORAGE_BIT, format.actualImageVkFormat,
imageViewOut);
}
......@@ -2646,7 +2648,7 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
// With the introduction of sRGB related GLES extensions any texture could be respecified
// causing it to be interpreted in a different colorspace. Create the VkImage accordingly.
VkImageFormatListCreateInfoKHR *additionalCreateInfo = nullptr;
VkFormat imageFormat = format.vkImageFormat;
VkFormat imageFormat = format.actualImageVkFormat;
VkFormat imageListFormat = format.actualImageFormat().isSRGB ? vk::ConvertToLinear(imageFormat)
: vk::ConvertToSRGB(imageFormat);
......
......@@ -2134,9 +2134,9 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
shaderParams.rotateXY = 0;
shaderParams.srcIsSRGB =
gl::GetSizedInternalFormatInfo(srcFormat.internalFormat).colorEncoding == GL_SRGB;
gl::GetSizedInternalFormatInfo(srcFormat.intendedGLFormat).colorEncoding == GL_SRGB;
shaderParams.destIsSRGB =
gl::GetSizedInternalFormatInfo(dstFormat.internalFormat).colorEncoding == GL_SRGB;
gl::GetSizedInternalFormatInfo(dstFormat.intendedGLFormat).colorEncoding == GL_SRGB;
// If both src and dest are sRGB, and there is no alpha multiplication/division necessary, then
// the shader can work with sRGB data and pretend they are linear.
......
......@@ -199,7 +199,7 @@ angle::Result HardwareBufferImageSiblingVkAndroid::initImpl(DisplayVk *displayVk
// With the introduction of sRGB related GLES extensions any texture could be respecified
// causing it to be interpreted in a different colorspace. Create the VkImage accordingly.
VkImageCreateFlags imageCreateFlags = vk::kVkImageCreateFlagsNone;
VkFormat vkImageFormat = vkFormat.vkImageFormat;
VkFormat vkImageFormat = vkFormat.actualImageVkFormat;
VkFormat vkImageListFormat = vkFormat.actualImageFormat().isSRGB
? vk::ConvertToLinear(vkImageFormat)
: vk::ConvertToSRGB(vkImageFormat);
......@@ -290,15 +290,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->hasImageFormatFeatureBits(vkFormat.vkImageFormat, kColorRenderableRequiredBits) ||
renderer->hasImageFormatFeatureBits(vkFormat.vkImageFormat,
kDepthStencilRenderableRequiredBits);
mRenderable = renderer->hasImageFormatFeatureBits(vkFormat.actualImageVkFormat,
kColorRenderableRequiredBits) ||
renderer->hasImageFormatFeatureBits(vkFormat.actualImageVkFormat,
kDepthStencilRenderableRequiredBits);
constexpr uint32_t kTextureableRequiredBits =
VK_FORMAT_FEATURE_SAMPLED_IMAGE_BIT | VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT;
mTextureable =
renderer->hasImageFormatFeatureBits(vkFormat.vkImageFormat, kTextureableRequiredBits);
renderer->hasImageFormatFeatureBits(vkFormat.actualImageVkFormat, kTextureableRequiredBits);
return angle::Result::Continue;
}
......
......@@ -65,14 +65,14 @@ break;
"""
format_entry_template = """case angle::FormatID::{format_id}:
internalFormat = {internal_format};
intendedGLFormat = {internal_format};
{image_template}
{buffer_template}
break;
"""
image_basic_template = """actualImageFormatID = {image};
vkImageFormat = {vk_image_format};
actualImageVkFormat = {vk_image_format};
imageInitializerFunction = {image_initializer};"""
image_struct_template = "{{{image}, {vk_image_format}, {image_initializer}}}"
......@@ -83,7 +83,7 @@ initImageFallback(renderer, kInfo, ArraySize(kInfo));
}}"""
buffer_basic_template = """actualBufferFormatID = {buffer};
vkBufferFormat = {vk_buffer_format};
actualBufferVkFormat = {vk_buffer_format};
vkBufferFormatIsPacked = {vk_buffer_format_is_packed};
vertexLoadFunction = {vertex_load_function};
vertexLoadRequiresConversion = {vertex_load_converts};"""
......
......@@ -155,7 +155,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.vkImageFormat;
desc->format = format.actualImageVkFormat;
desc->samples = gl_vk::GetSamples(samples);
desc->loadOp = static_cast<VkAttachmentLoadOp>(ops.loadOp);
desc->storeOp =
......@@ -179,7 +179,7 @@ void UnpackColorResolveAttachmentDesc(VkAttachmentDescription *desc,
// attachments simultaneously, so this flag can likely be removed without any issue if it incurs
// a performance penalty.
desc->flags = VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT;
desc->format = format.vkImageFormat;
desc->format = format.actualImageVkFormat;
// This function is for color resolve attachments.
const angle::Format &angleFormat = format.actualImageFormat();
......@@ -212,7 +212,7 @@ void UnpackDepthStencilResolveAttachmentDesc(VkAttachmentDescription *desc,
// There cannot be simultaneous usages of the depth/stencil resolve image, as depth/stencil
// resolve currently only comes from depth/stencil renderbuffers.
desc->flags = 0;
desc->format = format.vkImageFormat;
desc->format = format.actualImageVkFormat;
// This function is for depth/stencil resolve attachment.
const angle::Format &angleFormat = format.intendedFormat();
......@@ -1712,8 +1712,8 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
angle::FormatID formatID = static_cast<angle::FormatID>(packedAttrib.format);
const Format &format = contextVk->getRenderer()->getFormat(formatID);
const angle::Format &angleFormat = format.intendedFormat();
VkFormat vkFormat =
packedAttrib.compressed ? format.vkCompressedBufferFormat : format.vkBufferFormat;
VkFormat vkFormat = packedAttrib.compressed ? format.actualCompressedBufferVkFormat
: format.actualBufferVkFormat;
gl::ComponentType attribType =
GetVertexAttributeComponentType(angleFormat.isPureInt(), angleFormat.vertexAttribType);
......
......@@ -40,12 +40,12 @@ bool HasShaderImageAtomicsSupport(const RendererVk *rendererVk,
const Format &formatVk = rendererVk->getFormat(GL_R32F);
const bool hasImageAtomicSupport = rendererVk->hasImageFormatFeatureBits(
formatVk.vkImageFormat, VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT);
formatVk.actualImageVkFormat, VK_FORMAT_FEATURE_STORAGE_IMAGE_ATOMIC_BIT);
bool hasBufferAtomicSupport = true;
if (supportedExtensions.textureBufferAny())
{
hasBufferAtomicSupport = rendererVk->hasBufferFormatFeatureBits(
formatVk.vkBufferFormat, VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT);
formatVk.actualBufferVkFormat, VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_ATOMIC_BIT);
}
return hasImageAtomicSupport && hasBufferAtomicSupport;
......@@ -66,10 +66,11 @@ bool FormatReinterpretationSupported(const std::vector<GLenum> &optionalSizedFor
const Format &vkFormat = rendererVk->getFormat(glFormat);
VkFormat reinterpretedFormat = checkLinearColorspace
? ConvertToLinear(vkFormat.vkImageFormat)
: ConvertToSRGB(vkFormat.vkImageFormat);
? ConvertToLinear(vkFormat.actualImageVkFormat)
: ConvertToSRGB(vkFormat.actualImageVkFormat);
if (!rendererVk->haveSameFormatFeatureBits(vkFormat.vkImageFormat, reinterpretedFormat))
if (!rendererVk->haveSameFormatFeatureBits(vkFormat.actualImageVkFormat,
reinterpretedFormat))
{
return false;
}
......@@ -178,7 +179,7 @@ bool HasTexelBufferSupport(const RendererVk *rendererVk, GLenum formatGL)
const Format &formatVk = rendererVk->getFormat(formatGL);
return rendererVk->hasBufferFormatFeatureBits(
formatVk.vkBufferFormat,
formatVk.actualBufferVkFormat,
VK_FORMAT_FEATURE_UNIFORM_TEXEL_BUFFER_BIT | VK_FORMAT_FEATURE_STORAGE_TEXEL_BUFFER_BIT);
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -111,13 +111,13 @@ namespace vk
// Format implementation.
Format::Format()
: intendedFormatID(angle::FormatID::NONE),
internalFormat(GL_NONE),
intendedGLFormat(GL_NONE),
actualImageFormatID(angle::FormatID::NONE),
vkImageFormat(VK_FORMAT_UNDEFINED),
actualImageVkFormat(VK_FORMAT_UNDEFINED),
actualBufferFormatID(angle::FormatID::NONE),
vkBufferFormat(VK_FORMAT_UNDEFINED),
actualBufferVkFormat(VK_FORMAT_UNDEFINED),
actualCompressedBufferFormatID(angle::FormatID::NONE),
vkCompressedBufferFormat(VK_FORMAT_UNDEFINED),
actualCompressedBufferVkFormat(VK_FORMAT_UNDEFINED),
imageInitializerFunction(nullptr),
textureLoadFunctions(),
vertexLoadFunction(nullptr),
......@@ -152,7 +152,7 @@ void Format::initImageFallback(RendererVk *renderer, const ImageFormatInitInfo *
int i = FindSupportedFormat(renderer, info, skip, static_cast<uint32_t>(numInfo), testFunction);
actualImageFormatID = info[i].format;
vkImageFormat = info[i].vkFormat;
actualImageVkFormat = info[i].vkFormat;
imageInitializerFunction = info[i].initializer;
}
......@@ -167,7 +167,7 @@ void Format::initBufferFallback(RendererVk *renderer,
HasFullBufferFormatSupport);
actualBufferFormatID = info[i].format;
vkBufferFormat = info[i].vkFormat;
actualBufferVkFormat = info[i].vkFormat;
vkBufferFormatIsPacked = info[i].vkFormatIsPacked;
vertexLoadFunction = info[i].vertexLoadFunction;
vertexLoadRequiresConversion = info[i].vertexLoadRequiresConversion;
......@@ -179,7 +179,7 @@ void Format::initBufferFallback(RendererVk *renderer,
HasFullBufferFormatSupport);
actualCompressedBufferFormatID = info[i].format;
vkCompressedBufferFormat = info[i].vkFormat;
actualCompressedBufferVkFormat = info[i].vkFormat;
vkCompressedBufferFormatIsPacked = info[i].vkFormatIsPacked;
compressedVertexLoadFunction = info[i].vertexLoadFunction;
compressedVertexLoadRequiresConversion = info[i].vertexLoadRequiresConversion;
......@@ -262,8 +262,7 @@ void FormatTable::initialize(RendererVk *renderer,
const angle::Format &angleFormat = angle::Format::Get(formatID);
format.initialize(renderer, angleFormat);
const GLenum internalFormat = format.internalFormat;
format.intendedFormatID = formatID;
format.intendedFormatID = formatID;
if (!format.valid())
{
......@@ -271,18 +270,18 @@ void FormatTable::initialize(RendererVk *renderer,
}
gl::TextureCaps textureCaps;
FillTextureFormatCaps(renderer, format.vkImageFormat, &textureCaps);
FillTextureFormatCaps(renderer, format.actualImageVkFormat, &textureCaps);
outTextureCapsMap->set(formatID, textureCaps);
if (textureCaps.texturable)
{
format.textureLoadFunctions =
GetLoadFunctionsMap(internalFormat, format.actualImageFormatID);
GetLoadFunctionsMap(format.intendedGLFormat, format.actualImageFormatID);
}
if (angleFormat.isBlock)
{
outCompressedTextureFormats->push_back(internalFormat);
outCompressedTextureFormats->push_back(format.intendedGLFormat);
}
}
}
......
......@@ -56,7 +56,7 @@ struct Format final : private angle::NonCopyable
{
Format();
bool valid() const { return internalFormat != 0; }
bool valid() const { return intendedGLFormat != 0; }
// The intended format is the front-end format. For Textures this usually correponds to a
// GLenum in the headers. Buffer formats don't always have a corresponding GLenum type.
......@@ -89,11 +89,11 @@ struct Format final : private angle::NonCopyable
return compressed ? compressedVertexLoadRequiresConversion : vertexLoadRequiresConversion;
}
// The |internalFormat| always correponds to a valid GLenum type. For types that don't have a
// |intendedGLFormat| always correponds to a valid GLenum type. For types that don't have a
// corresponding GLenum we do our best to specify a GLenum that is "close".
const gl::InternalFormat &getInternalFormatInfo(GLenum type) const
{
return gl::GetInternalFormatInfo(internalFormat, type);
return gl::GetInternalFormatInfo(intendedGLFormat, type);
}
// Returns buffer alignment for image-copy operations (to or from a buffer).
......@@ -117,13 +117,13 @@ struct Format final : private angle::NonCopyable
int compressedStartIndex);
angle::FormatID intendedFormatID;
GLenum internalFormat;
GLenum intendedGLFormat;
angle::FormatID actualImageFormatID;
VkFormat vkImageFormat;
VkFormat actualImageVkFormat;
angle::FormatID actualBufferFormatID;
VkFormat vkBufferFormat;
VkFormat actualBufferVkFormat;
angle::FormatID actualCompressedBufferFormatID;
VkFormat vkCompressedBufferFormat;
VkFormat actualCompressedBufferVkFormat;
InitializeTextureDataFunction imageInitializerFunction;
LoadFunctionMap textureLoadFunctions;
......
......@@ -711,9 +711,10 @@ bool CanCopyWithTransfer(RendererVk *renderer,
// Checks that the formats in the copy transfer have the appropriate tiling and transfer bits
bool isTilingCompatible = srcTilingMode == destTilingMode;
bool srcFormatHasNecessaryFeature = FormatHasNecessaryFeature(
renderer, srcFormat.vkImageFormat, srcTilingMode, VK_FORMAT_FEATURE_TRANSFER_SRC_BIT);
bool dstFormatHasNecessaryFeature = FormatHasNecessaryFeature(
renderer, destFormat.vkImageFormat, destTilingMode, VK_FORMAT_FEATURE_TRANSFER_DST_BIT);
renderer, srcFormat.actualImageVkFormat, srcTilingMode, VK_FORMAT_FEATURE_TRANSFER_SRC_BIT);
bool dstFormatHasNecessaryFeature =
FormatHasNecessaryFeature(renderer, destFormat.actualImageVkFormat, destTilingMode,
VK_FORMAT_FEATURE_TRANSFER_DST_BIT);
return isTilingCompatible && srcFormatHasNecessaryFeature && dstFormatHasNecessaryFeature;
}
......@@ -3619,7 +3620,7 @@ angle::Result ImageHelper::initExternal(Context *context,
imageInfo.pNext = externalImageCreateInfo;
imageInfo.flags = GetImageCreateFlags(textureType) | additionalCreateFlags;
imageInfo.imageType = mImageType;
imageInfo.format = format.vkImageFormat;
imageInfo.format = format.actualImageVkFormat;
imageInfo.extent = mExtents;
imageInfo.mipLevels = mipLevels;
imageInfo.arrayLayers = mLayerCount;
......@@ -3871,7 +3872,7 @@ angle::Result ImageHelper::initLayerImageView(Context *context,
{
return initLayerImageViewImpl(context, textureType, aspectMask, swizzleMap, imageViewOut,
baseMipLevelVk, levelCount, baseArrayLayer, layerCount,
mFormat->vkImageFormat, nullptr);
mFormat->actualImageVkFormat, nullptr);
}
angle::Result ImageHelper::initLayerImageViewWithFormat(Context *context,
......@@ -3887,7 +3888,7 @@ angle::Result ImageHelper::initLayerImageViewWithFormat(Context *context,
{
return initLayerImageViewImpl(context, textureType, aspectMask, swizzleMap, imageViewOut,
baseMipLevelVk, levelCount, baseArrayLayer, layerCount,
format.vkImageFormat, nullptr);
format.actualImageVkFormat, nullptr);
}
angle::Result ImageHelper::initLayerImageViewImpl(
......@@ -4038,7 +4039,7 @@ angle::Result ImageHelper::init2DStaging(Context *context,
imageInfo.sType = VK_STRUCTURE_TYPE_IMAGE_CREATE_INFO;
imageInfo.flags = 0;
imageInfo.imageType = mImageType;
imageInfo.format = format.vkImageFormat;
imageInfo.format = format.actualImageVkFormat;
imageInfo.extent = mExtents;
imageInfo.mipLevels = 1;
imageInfo.arrayLayers = mLayerCount;
......@@ -5944,7 +5945,7 @@ angle::Result ImageHelper::copyImageDataToBuffer(ContextVk *contextVk,
// per pixel which is sufficient to contain its depth aspect (no stencil aspect).
uint32_t pixelBytes = imageFormat.pixelBytes;
uint32_t depthBytesPerPixel = imageFormat.depthBits >> 3;
if (mFormat->vkImageFormat == VK_FORMAT_D24_UNORM_S8_UINT)
if (mFormat->actualImageVkFormat == VK_FORMAT_D24_UNORM_S8_UINT)
{
pixelBytes = 5;
depthBytesPerPixel = 4;
......@@ -6701,16 +6702,17 @@ angle::Result ImageViewHelper::initSRGBReadViewsImpl(ContextVk *contextVk,
// When we select the linear/srgb counterpart formats, we must first make sure they're
// actually supported by the ICD. If they are not supported by the ICD, then we treat that as if
// there is no counterpart format. (In this case, the relevant extension should not be exposed)
VkFormat srgbOverrideFormat = ConvertToSRGB(image.getFormat().vkImageFormat);
VkFormat srgbOverrideFormat = ConvertToSRGB(image.getFormat().actualImageVkFormat);
ASSERT((srgbOverrideFormat == VK_FORMAT_UNDEFINED) ||
(HasNonRenderableTextureFormatSupport(contextVk->getRenderer(), srgbOverrideFormat)));
VkFormat linearOverrideFormat = ConvertToLinear(image.getFormat().vkImageFormat);
VkFormat linearOverrideFormat = ConvertToLinear(image.getFormat().actualImageVkFormat);
ASSERT((linearOverrideFormat == VK_FORMAT_UNDEFINED) ||
(HasNonRenderableTextureFormatSupport(contextVk->getRenderer(), linearOverrideFormat)));
VkFormat linearFormat =
(linearOverrideFormat != VK_FORMAT_UNDEFINED) ? linearOverrideFormat : format.vkImageFormat;
VkFormat linearFormat = (linearOverrideFormat != VK_FORMAT_UNDEFINED)
? linearOverrideFormat
: format.actualImageVkFormat;
ASSERT(linearFormat != VK_FORMAT_UNDEFINED);
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(format.intendedFormat());
......@@ -6993,7 +6995,7 @@ angle::Result BufferViewHelper::getView(ContextVk *contextVk,
{
ASSERT(format.valid());
auto iter = mViews.find(format.vkBufferFormat);
auto iter = mViews.find(format.actualBufferVkFormat);
if (iter != mViews.end())
{
*viewOut = &iter->second;
......@@ -7010,7 +7012,7 @@ angle::Result BufferViewHelper::getView(ContextVk *contextVk,
VkBufferViewCreateInfo viewCreateInfo = {};
viewCreateInfo.sType = VK_STRUCTURE_TYPE_BUFFER_VIEW_CREATE_INFO;
viewCreateInfo.buffer = buffer.getBuffer().getHandle();
viewCreateInfo.format = format.vkBufferFormat;
viewCreateInfo.format = format.actualBufferVkFormat;
viewCreateInfo.offset = mOffset;
viewCreateInfo.range = size;
......@@ -7018,7 +7020,7 @@ angle::Result BufferViewHelper::getView(ContextVk *contextVk,
ANGLE_VK_TRY(contextVk, view.init(contextVk->getDevice(), viewCreateInfo));
// Cache the view
auto insertIter = mViews.insert({format.vkBufferFormat, std::move(view)});
auto insertIter = mViews.insert({format.actualBufferVkFormat, std::move(view)});
*viewOut = &insertIter.first->second;
ASSERT(insertIter.second);
......
......@@ -989,7 +989,7 @@ void InitExternalSemaphoreCapabilitiesFunctions(VkInstance instance)
GLenum CalculateGenerateMipmapFilter(ContextVk *contextVk, const vk::Format &format)
{
const bool formatSupportsLinearFiltering = contextVk->getRenderer()->hasImageFormatFeatureBits(
format.vkImageFormat, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
format.actualImageVkFormat, VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT);
const bool hintFastest = contextVk->getState().getGenerateMipmapHint() == GL_FASTEST;
return formatSupportsLinearFiltering && !hintFastest ? GL_LINEAR : GL_NEAREST;
......
......@@ -152,7 +152,6 @@ egl::ConfigSet DisplayVkWin32::generateConfigs()
void DisplayVkWin32::checkConfigSupport(egl::Config *config)
{
const vk::Format &formatVk = this->getRenderer()->getFormat(config->renderTargetFormat);
VkFormat nativeFormat = formatVk.vkImageFormat;
// If the format list includes just one entry of VK_FORMAT_UNDEFINED,
// the surface has no preferred format. Otherwise, at least one
......@@ -164,7 +163,7 @@ void DisplayVkWin32::checkConfigSupport(egl::Config *config)
for (const VkSurfaceFormatKHR &surfaceFormat : mSurfaceFormats)
{
if (surfaceFormat.format == nativeFormat)
if (surfaceFormat.format == formatVk.actualImageVkFormat)
{
return;
}
......
......@@ -73,17 +73,17 @@ TEST_P(VulkanFormatTablesTest, TestFormatSupport)
// Now let's verify that against vulkan.
VkFormatProperties formatProperties;
vkGetPhysicalDeviceFormatProperties(renderer->getPhysicalDevice(),
vkFormat.vkImageFormat, &formatProperties);
vkFormat.actualImageVkFormat, &formatProperties);
VkImageFormatProperties imageProperties;
// isTexturable?
bool isTexturable =
vkGetPhysicalDeviceImageFormatProperties(
renderer->getPhysicalDevice(), vkFormat.vkImageFormat, params.imageType,
renderer->getPhysicalDevice(), vkFormat.actualImageVkFormat, params.imageType,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_SAMPLED_BIT, params.createFlags,
&imageProperties) == VK_SUCCESS;
EXPECT_EQ(isTexturable, textureCaps.texturable) << vkFormat.vkImageFormat;
EXPECT_EQ(isTexturable, textureCaps.texturable) << vkFormat.actualImageVkFormat;
// 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.vkImageFormat;
EXPECT_EQ(isFilterable, textureCaps.filterable) << vkFormat.actualImageVkFormat;
// isRenderable?
const bool isRenderableColor =
(vkGetPhysicalDeviceImageFormatProperties(
renderer->getPhysicalDevice(), vkFormat.vkImageFormat, params.imageType,
renderer->getPhysicalDevice(), vkFormat.actualImageVkFormat, params.imageType,
VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT,
params.createFlags, &imageProperties)) == VK_SUCCESS;
const bool isRenderableDepthStencil =
(vkGetPhysicalDeviceImageFormatProperties(
renderer->getPhysicalDevice(), vkFormat.vkImageFormat, params.imageType,
renderer->getPhysicalDevice(), vkFormat.actualImageVkFormat, 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.vkImageFormat;
EXPECT_EQ(isRenderable, textureCaps.renderbuffer) << vkFormat.vkImageFormat;
EXPECT_EQ(isRenderable, textureCaps.textureAttachment) << vkFormat.actualImageVkFormat;
EXPECT_EQ(isRenderable, textureCaps.renderbuffer) << vkFormat.actualImageVkFormat;
}
}
}
......
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