Commit beacd8c8 by Jamie Madill Committed by Commit Bot

Vulkan: Rename format fields.

Renames 'angleFormat' to 'intendedFormat'. Also renames 'bufferFormat' and 'imageFormat' to 'actualImageFormat' and 'actualBufferFormat'. This renaming should make it clearer to the reader what the meaning of the different format fields are. Intended format is the front-end format and the actual formats are the formats we pass to Vulkan. Also updates the documentation. Bug: angleproject:4009 Change-Id: If61bf7250e88f7ed3d452718574c963d718e27b2 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1866077 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent d739727b
......@@ -4,9 +4,9 @@
"src/libANGLE/renderer/angle_format_map.json":
"bca5e686001f6dd0af306af234a36677",
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
"ed6800108a872709e5e53fde2833aa86",
"fae056a92c84cfd35594836cd5c14ab8",
"src/libANGLE/renderer/vulkan/vk_format_map.json":
"ef0c23a6620215cfacfc690e9995ba31",
"src/libANGLE/renderer/vulkan/vk_format_table_autogen.cpp":
"8363fab619a371c0892f2bebaa480965"
"ca21d0ab4ea9908b76b73f446606a79f"
}
\ No newline at end of file
......@@ -51,7 +51,7 @@ const gl::InternalFormat &GetReadAttachmentInfo(const gl::Context *context,
RenderTargetVk *renderTarget)
{
GLenum implFormat =
renderTarget->getImageFormat().imageFormat().fboImplementationInternalFormat;
renderTarget->getImageFormat().actualImageFormat().fboImplementationInternalFormat;
return gl::GetSizedInternalFormatInfo(implFormat);
}
......@@ -72,8 +72,8 @@ bool HasDstBlitFeature(RendererVk *renderer, RenderTargetVk *dstRenderTarget)
bool areSrcAndDstColorChannelsBlitCompatible(RenderTargetVk *srcRenderTarget,
RenderTargetVk *dstRenderTarget)
{
const angle::Format &srcFormat = srcRenderTarget->getImageFormat().angleFormat();
const angle::Format &dstFormat = dstRenderTarget->getImageFormat().angleFormat();
const angle::Format &srcFormat = srcRenderTarget->getImageFormat().intendedFormat();
const angle::Format &dstFormat = dstRenderTarget->getImageFormat().intendedFormat();
// Luminance/alpha formats are not renderable, so they can't have ended up in a framebuffer to
// participate in a blit.
......@@ -90,8 +90,8 @@ bool areSrcAndDstColorChannelsBlitCompatible(RenderTargetVk *srcRenderTarget,
bool areSrcAndDstDepthStencilChannelsBlitCompatible(RenderTargetVk *srcRenderTarget,
RenderTargetVk *dstRenderTarget)
{
const angle::Format &srcFormat = srcRenderTarget->getImageFormat().angleFormat();
const angle::Format &dstFormat = dstRenderTarget->getImageFormat().angleFormat();
const angle::Format &srcFormat = srcRenderTarget->getImageFormat().intendedFormat();
const angle::Format &dstFormat = dstRenderTarget->getImageFormat().intendedFormat();
return (dstFormat.depthBits > 0 || srcFormat.depthBits == 0) &&
(dstFormat.stencilBits > 0 || srcFormat.stencilBits == 0);
......@@ -983,14 +983,13 @@ angle::Result FramebufferVk::updateColorAttachment(const gl::Context *context, s
RenderTargetVk *renderTarget = mRenderTargetCache.getColors()[colorIndexGL];
if (renderTarget)
{
const angle::Format &emulatedFormat = renderTarget->getImageFormat().imageFormat();
updateActiveColorMasks(colorIndexGL, emulatedFormat.redBits > 0,
emulatedFormat.greenBits > 0, emulatedFormat.blueBits > 0,
emulatedFormat.alphaBits > 0);
const angle::Format &actualFormat = renderTarget->getImageFormat().actualImageFormat();
updateActiveColorMasks(colorIndexGL, actualFormat.redBits > 0, actualFormat.greenBits > 0,
actualFormat.blueBits > 0, actualFormat.alphaBits > 0);
const angle::Format &sourceFormat = renderTarget->getImageFormat().angleFormat();
mEmulatedAlphaAttachmentMask.set(
colorIndexGL, sourceFormat.alphaBits == 0 && emulatedFormat.alphaBits > 0);
const angle::Format &sourceFormat = renderTarget->getImageFormat().intendedFormat();
mEmulatedAlphaAttachmentMask.set(colorIndexGL,
sourceFormat.alphaBits == 0 && actualFormat.alphaBits > 0);
contextVk->updateColorMask(context->getState().getBlendState());
}
......@@ -1168,7 +1167,7 @@ void FramebufferVk::updateRenderPassDesc()
RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndexGL];
ASSERT(colorRenderTarget);
mRenderPassDesc.packColorAttachment(
colorIndexGL, colorRenderTarget->getImage().getFormat().angleFormatID);
colorIndexGL, colorRenderTarget->getImage().getFormat().intendedFormatID);
}
else
{
......@@ -1180,7 +1179,7 @@ void FramebufferVk::updateRenderPassDesc()
if (depthStencilRenderTarget)
{
mRenderPassDesc.packDepthStencilAttachment(
depthStencilRenderTarget->getImage().getFormat().angleFormatID);
depthStencilRenderTarget->getImage().getFormat().intendedFormatID);
}
}
......@@ -1350,7 +1349,7 @@ angle::Result FramebufferVk::clearWithDraw(ContextVk *contextVk,
const RenderTargetVk *colorRenderTarget = colorRenderTargets[colorIndexGL];
ASSERT(colorRenderTarget);
params.colorFormat = &colorRenderTarget->getImage().getFormat().imageFormat();
params.colorFormat = &colorRenderTarget->getImage().getFormat().actualImageFormat();
params.colorAttachmentIndexGL = static_cast<uint32_t>(colorIndexGL);
params.colorMaskFlags = colorMaskFlags;
if (mEmulatedAlphaAttachmentMask[colorIndexGL])
......@@ -1458,7 +1457,7 @@ angle::Result FramebufferVk::readPixelsImpl(ContextVk *contextVk,
vk::ImageHelper *srcImage = renderTarget->getImageForRead(
contextVk, &mFramebuffer, vk::ImageLayout::TransferSrc, commandBuffer);
const angle::Format *readFormat = &srcImage->getFormat().imageFormat();
const angle::Format *readFormat = &srcImage->getFormat().actualImageFormat();
if (copyAspectFlags != VK_IMAGE_ASPECT_COLOR_BIT)
{
......
......@@ -28,3 +28,6 @@ Implementation details can be found in the `doc` directory.
- [Shader Module Compilation](doc/ShaderModuleCompilation.md)
- [OpenGL Line Segment Rasterization](doc/OpenGLLineSegmentRasterization.md)
- [Format Tables and Emulation](doc/FormatTablesAndEmulation.md)
[VkDevice]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkDevice.html
[VkQueue]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkQueue.html
......@@ -54,7 +54,7 @@ angle::Result RenderTargetVk::onColorDraw(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer)
{
ASSERT(commandBuffer->valid());
ASSERT(!mImage->getFormat().imageFormat().hasDepthOrStencilBits());
ASSERT(!mImage->getFormat().actualImageFormat().hasDepthOrStencilBits());
// TODO(jmadill): Use automatic layout transition. http://anglebug.com/2361
mImage->changeLayout(VK_IMAGE_ASPECT_COLOR_BIT, vk::ImageLayout::ColorAttachment,
......@@ -71,10 +71,10 @@ angle::Result RenderTargetVk::onDepthStencilDraw(ContextVk *contextVk,
vk::CommandBuffer *commandBuffer)
{
ASSERT(commandBuffer->valid());
ASSERT(mImage->getFormat().imageFormat().hasDepthOrStencilBits());
ASSERT(mImage->getFormat().actualImageFormat().hasDepthOrStencilBits());
// TODO(jmadill): Use automatic layout transition. http://anglebug.com/2361
const angle::Format &format = mImage->getFormat().imageFormat();
const angle::Format &format = mImage->getFormat().actualImageFormat();
VkImageAspectFlags aspectFlags = vk::GetDepthStencilAspectFlags(format);
mImage->changeLayout(aspectFlags, vk::ImageLayout::DepthStencilAttachment, commandBuffer);
......
......@@ -63,7 +63,7 @@ angle::Result RenderbufferVk::setStorageImpl(const gl::Context *context,
mOwnsImage = true;
}
const angle::Format &textureFormat = vkFormat.imageFormat();
const angle::Format &textureFormat = vkFormat.actualImageFormat();
bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0;
const VkImageUsageFlags usage =
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
......@@ -104,7 +104,7 @@ angle::Result RenderbufferVk::setStorageMultisample(const gl::Context *context,
// If the specific number of samples requested is not supported, the smallest number that's at
// least that many needs to be selected.
const RendererVk *renderer = vk::GetImpl(context)->getRenderer();
const angle::Format &format = renderer->getFormat(internalformat).imageFormat();
const angle::Format &format = renderer->getFormat(internalformat).actualImageFormat();
const VkPhysicalDeviceLimits &limits = renderer->getPhysicalDeviceProperties().limits;
const uint32_t colorSampleCounts = limits.framebufferColorSampleCounts;
......@@ -147,7 +147,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.imageFormat();
const angle::Format &textureFormat = vkFormat.actualImageFormat();
VkImageAspectFlags aspect = vk::GetFormatAspectFlags(textureFormat);
......@@ -189,7 +189,8 @@ angle::Result RenderbufferVk::getAttachmentRenderTarget(const gl::Context *conte
angle::Result RenderbufferVk::initializeContents(const gl::Context *context,
const gl::ImageIndex &imageIndex)
{
mImage->stageSubresourceRobustClear(imageIndex, mImage->getFormat().angleFormat());
// Note: stageSubresourceRobustClear only uses the intended format to count channels.
mImage->stageSubresourceRobustClear(imageIndex, mImage->getFormat().intendedFormat());
return mImage->flushAllStagedUpdates(vk::GetImpl(context));
}
......
......@@ -136,7 +136,7 @@ angle::Result OffscreenSurfaceVk::AttachmentImage::initialize(DisplayVk *display
{
RendererVk *renderer = displayVk->getRenderer();
const angle::Format &textureFormat = vkFormat.imageFormat();
const angle::Format &textureFormat = vkFormat.actualImageFormat();
bool isDepthOrStencilFormat = textureFormat.depthBits > 0 || textureFormat.stencilBits > 0;
const VkImageUsageFlags usage = isDepthOrStencilFormat ? kSurfaceVKDepthStencilImageUsageFlags
: kSurfaceVKColorImageUsageFlags;
......@@ -293,14 +293,14 @@ angle::Result OffscreenSurfaceVk::initializeContents(const gl::Context *context,
if (mColorAttachment.image.valid())
{
mColorAttachment.image.stageSubresourceRobustClear(
imageIndex, mColorAttachment.image.getFormat().angleFormat());
imageIndex, mColorAttachment.image.getFormat().intendedFormat());
ANGLE_TRY(mColorAttachment.image.flushAllStagedUpdates(contextVk));
}
if (mDepthStencilAttachment.image.valid())
{
mDepthStencilAttachment.image.stageSubresourceRobustClear(
imageIndex, mDepthStencilAttachment.image.getFormat().angleFormat());
imageIndex, mDepthStencilAttachment.image.getFormat().intendedFormat());
ANGLE_TRY(mDepthStencilAttachment.image.flushAllStagedUpdates(contextVk));
}
return angle::Result::Continue;
......@@ -1346,13 +1346,13 @@ angle::Result WindowSurfaceVk::initializeContents(const gl::Context *context,
vk::ImageHelper *image =
isMultiSampled() ? &mColorImageMS : &mSwapchainImages[mCurrentSwapchainImageIndex].image;
image->stageSubresourceRobustClear(imageIndex, image->getFormat().angleFormat());
image->stageSubresourceRobustClear(imageIndex, image->getFormat().intendedFormat());
ANGLE_TRY(image->flushAllStagedUpdates(contextVk));
if (mDepthStencilImage.valid())
{
mDepthStencilImage.stageSubresourceRobustClear(
gl::ImageIndex::Make2D(0), mDepthStencilImage.getFormat().angleFormat());
gl::ImageIndex::Make2D(0), mDepthStencilImage.getFormat().intendedFormat());
ANGLE_TRY(mDepthStencilImage.flushAllStagedUpdates(contextVk));
}
......
......@@ -469,8 +469,8 @@ angle::Result TextureVk::copySubTextureImpl(ContextVk *contextVk,
ANGLE_TRY(source->copyImageDataToBufferAndGetData(contextVk, sourceLevel, 1, sourceArea,
&sourceData));
const angle::Format &sourceTextureFormat = sourceVkFormat.imageFormat();
const angle::Format &destTextureFormat = destVkFormat.imageFormat();
const angle::Format &sourceTextureFormat = sourceVkFormat.actualImageFormat();
const angle::Format &destTextureFormat = destVkFormat.actualImageFormat();
size_t destinationAllocationSize =
sourceArea.width * sourceArea.height * destTextureFormat.pixelBytes;
......@@ -491,13 +491,13 @@ angle::Result TextureVk::copySubTextureImpl(ContextVk *contextVk,
// Fix up the read/write functions for the sake of luminance/alpha that are emulated with
// formats whose channels don't correspond to the original format (alpha is emulated with red,
// and luminance/alpha is emulated with red/green).
if (sourceVkFormat.angleFormat().isLUMA())
if (sourceVkFormat.intendedFormat().isLUMA())
{
pixelReadFunction = sourceVkFormat.angleFormat().pixelReadFunction;
pixelReadFunction = sourceVkFormat.intendedFormat().pixelReadFunction;
}
if (destVkFormat.angleFormat().isLUMA())
if (destVkFormat.intendedFormat().isLUMA())
{
pixelWriteFunction = destVkFormat.angleFormat().pixelWriteFunction;
pixelWriteFunction = destVkFormat.intendedFormat().pixelWriteFunction;
}
CopyImageCHROMIUM(sourceData, sourceDataRowPitch, sourceTextureFormat.pixelBytes, 0,
......@@ -979,7 +979,7 @@ angle::Result TextureVk::copyImageDataToBuffer(ContextVk *contextVk,
{
ANGLE_TRACE_EVENT0("gpu.angle", "TextureVk::copyImageDataToBuffer");
const angle::Format &imageFormat = getImage().getFormat().imageFormat();
const angle::Format &imageFormat = getImage().getFormat().actualImageFormat();
size_t sourceCopyAllocationSize = sourceArea.width * sourceArea.height * sourceArea.depth *
imageFormat.pixelBytes * layerCount;
......@@ -1033,7 +1033,7 @@ angle::Result TextureVk::generateMipmapsWithCPU(const gl::Context *context)
ANGLE_TRY(copyImageDataToBufferAndGetData(contextVk, mState.getEffectiveBaseLevel(),
imageLayerCount, imageArea, &imageData));
const angle::Format &angleFormat = mImage->getFormat().imageFormat();
const angle::Format &angleFormat = mImage->getFormat().actualImageFormat();
GLuint sourceRowPitch = baseLevelExtents.width * angleFormat.pixelBytes;
size_t baseLevelAllocationSize = sourceRowPitch * baseLevelExtents.height;
......@@ -1442,7 +1442,7 @@ angle::Result TextureVk::initializeContents(const gl::Context *context,
const vk::Format &format =
vk::GetImpl(context)->getRenderer()->getFormat(desc.format.info->sizedInternalFormat);
mImage->stageSubresourceRobustClear(imageIndex, format.angleFormat());
mImage->stageSubresourceRobustClear(imageIndex, format.intendedFormat());
// Note that we cannot ensure the image is initialized because we might be calling subImage
// on a non-complete cube map.
......@@ -1571,7 +1571,7 @@ angle::Result TextureVk::initImage(ContextVk *contextVk,
for (uint32_t level = 0; level < levelCount; ++level)
{
gl::ImageIndex index = gl::ImageIndex::Make2DArrayRange(level, 0, layerCount);
mImage->stageSubresourceEmulatedClear(index, format.angleFormat());
mImage->stageSubresourceEmulatedClear(index, format.intendedFormat());
onStagingBufferChange();
}
}
......
......@@ -53,7 +53,7 @@ constexpr uint32_t kOverlayDrawFontBinding = 4;
uint32_t GetBufferUtilsFlags(size_t dispatchSize, const vk::Format &format)
{
uint32_t flags = dispatchSize % 64 == 0 ? BufferUtils_comp::kIsAligned : 0;
const angle::Format &bufferFormat = format.bufferFormat();
const angle::Format &bufferFormat = format.actualBufferFormat();
if (bufferFormat.isSint())
{
......@@ -281,16 +281,16 @@ uint32_t GetFormatFlags(const angle::Format &format,
return floatFlag;
}
uint32_t GetImageCopyFlags(const vk::Format &srcFormat, const vk::Format &destFormat)
uint32_t GetImageCopyFlags(const vk::Format &srcFormat, const vk::Format &dstFormat)
{
const angle::Format &srcAngleFormat = srcFormat.angleFormat();
const angle::Format &destAngleFormat = destFormat.angleFormat();
const angle::Format &srcIntendedFormat = srcFormat.intendedFormat();
const angle::Format &dstIntendedFormat = dstFormat.intendedFormat();
uint32_t flags = 0;
flags |= GetFormatFlags(srcAngleFormat, ImageCopy_frag::kSrcIsSint, ImageCopy_frag::kSrcIsUint,
ImageCopy_frag::kSrcIsFloat);
flags |= GetFormatFlags(destAngleFormat, ImageCopy_frag::kDestIsSint,
flags |= GetFormatFlags(srcIntendedFormat, ImageCopy_frag::kSrcIsSint,
ImageCopy_frag::kSrcIsUint, ImageCopy_frag::kSrcIsFloat);
flags |= GetFormatFlags(dstIntendedFormat, ImageCopy_frag::kDestIsSint,
ImageCopy_frag::kDestIsUint, ImageCopy_frag::kDestIsFloat);
return flags;
......@@ -303,9 +303,9 @@ uint32_t GetBlitResolveFlags(bool blitColor,
{
if (blitColor)
{
const angle::Format &angleFormat = format.angleFormat();
const angle::Format &intendedFormat = format.intendedFormat();
return GetFormatFlags(angleFormat, BlitResolve_frag::kBlitColorInt,
return GetFormatFlags(intendedFormat, BlitResolve_frag::kBlitColorInt,
BlitResolve_frag::kBlitColorUint, BlitResolve_frag::kBlitColorFloat);
}
......@@ -330,15 +330,15 @@ uint32_t GetFormatDefaultChannelMask(const vk::Format &format)
{
uint32_t mask = 0;
const angle::Format &angleFormat = format.angleFormat();
const angle::Format &textureFormat = format.imageFormat();
const angle::Format &intendedFormat = format.intendedFormat();
const angle::Format &imageFormat = format.actualImageFormat();
// Red can never be introduced due to format emulation (except for luma which is handled
// especially)
ASSERT(((angleFormat.redBits > 0) == (textureFormat.redBits > 0)) || angleFormat.isLUMA());
mask |= angleFormat.greenBits == 0 && textureFormat.greenBits > 0 ? 2 : 0;
mask |= angleFormat.blueBits == 0 && textureFormat.blueBits > 0 ? 4 : 0;
mask |= angleFormat.alphaBits == 0 && textureFormat.alphaBits > 0 ? 8 : 0;
ASSERT(((intendedFormat.redBits > 0) == (imageFormat.redBits > 0)) || intendedFormat.isLUMA());
mask |= intendedFormat.greenBits == 0 && imageFormat.greenBits > 0 ? 2 : 0;
mask |= intendedFormat.blueBits == 0 && imageFormat.blueBits > 0 ? 4 : 0;
mask |= intendedFormat.alphaBits == 0 && imageFormat.alphaBits > 0 ? 8 : 0;
return mask;
}
......@@ -1720,17 +1720,17 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
{
ANGLE_TRY(ensureImageCopyResourcesInitialized(contextVk));
const vk::Format &srcFormat = src->getFormat();
const vk::Format &destFormat = dest->getFormat();
const vk::Format &srcFormat = src->getFormat();
const vk::Format &dstFormat = dest->getFormat();
const angle::Format &dstIntendedFormat = dstFormat.intendedFormat();
ImageCopyShaderParams shaderParams;
shaderParams.flipY = params.srcFlipY || params.destFlipY;
shaderParams.premultiplyAlpha = params.srcPremultiplyAlpha;
shaderParams.unmultiplyAlpha = params.srcUnmultiplyAlpha;
shaderParams.destHasLuminance = destFormat.angleFormat().luminanceBits > 0;
shaderParams.destIsAlpha =
destFormat.angleFormat().isLUMA() && destFormat.angleFormat().alphaBits > 0;
shaderParams.destDefaultChannelsMask = GetFormatDefaultChannelMask(destFormat);
shaderParams.destHasLuminance = dstIntendedFormat.luminanceBits > 0;
shaderParams.destIsAlpha = dstIntendedFormat.isLUMA() && dstIntendedFormat.alphaBits > 0;
shaderParams.destDefaultChannelsMask = GetFormatDefaultChannelMask(dstFormat);
shaderParams.srcMip = params.srcMip;
shaderParams.srcLayer = params.srcLayer;
shaderParams.srcOffset[0] = params.srcOffset[0];
......@@ -1752,7 +1752,7 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
shaderParams.srcOffset[1] = params.srcOffset[1] + params.srcExtents[1] - 1;
}
uint32_t flags = GetImageCopyFlags(srcFormat, destFormat);
uint32_t flags = GetImageCopyFlags(srcFormat, dstFormat);
flags |= src->getLayerCount() > 1 ? ImageCopy_frag::kSrcIsArray : 0;
VkDescriptorSet descriptorSet;
......@@ -1762,7 +1762,7 @@ angle::Result UtilsVk::copyImage(ContextVk *contextVk,
vk::RenderPassDesc renderPassDesc;
renderPassDesc.setSamples(dest->getSamples());
renderPassDesc.packColorAttachment(0, destFormat.angleFormatID);
renderPassDesc.packColorAttachment(0, dstFormat.intendedFormatID);
// Multisampled copy is not yet supported.
ASSERT(src->getSamples() == 1 && dest->getSamples() == 1);
......
......@@ -362,8 +362,8 @@ angle::Result VertexArrayVk::convertVertexBufferGPU(ContextVk *contextVk,
ConversionBuffer *conversion,
GLuint relativeOffset)
{
const angle::Format &srcFormat = vertexFormat.angleFormat();
const angle::Format &destFormat = vertexFormat.bufferFormat();
const angle::Format &srcFormat = vertexFormat.intendedFormat();
const angle::Format &destFormat = vertexFormat.actualBufferFormat();
ASSERT(binding.getStride() % (srcFormat.pixelBytes / srcFormat.channelCount) == 0);
......@@ -410,8 +410,8 @@ angle::Result VertexArrayVk::convertVertexBufferCPU(ContextVk *contextVk,
{
ANGLE_TRACE_EVENT0("gpu.angle", "VertexArrayVk::convertVertexBufferCpu");
unsigned srcFormatSize = vertexFormat.angleFormat().pixelBytes;
unsigned dstFormatSize = vertexFormat.bufferFormat().pixelBytes;
unsigned srcFormatSize = vertexFormat.intendedFormat().pixelBytes;
unsigned dstFormatSize = vertexFormat.actualBufferFormat().pixelBytes;
conversion->data.releaseInFlightBuffers(contextVk);
......@@ -560,15 +560,15 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
if (!isStreamingVertexAttrib)
{
BufferVk *bufferVk = vk::GetImpl(bufferGL);
const angle::Format &angleFormat = vertexFormat.angleFormat();
bool bindingIsAligned = BindingIsAligned(binding, angleFormat, angleFormat.channelCount,
attrib.relativeOffset);
BufferVk *bufferVk = vk::GetImpl(bufferGL);
const angle::Format &intendedFormat = vertexFormat.intendedFormat();
bool bindingIsAligned = BindingIsAligned(
binding, intendedFormat, intendedFormat.channelCount, attrib.relativeOffset);
if (vertexFormat.vertexLoadRequiresConversion || !bindingIsAligned)
{
ConversionBuffer *conversion = bufferVk->getVertexConversionBuffer(
renderer, angleFormat.id, binding.getStride(),
renderer, intendedFormat.id, binding.getStride(),
binding.getOffset() + attrib.relativeOffset);
if (conversion->dirty)
{
......@@ -599,7 +599,7 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
mCurrentArrayBufferOffsets[attribIndex] = conversion->lastAllocationOffset;
// Converted buffer is tightly packed
stride = vertexFormat.bufferFormat().pixelBytes;
stride = vertexFormat.actualBufferFormat().pixelBytes;
}
else
{
......@@ -627,7 +627,7 @@ angle::Result VertexArrayVk::syncDirtyAttrib(ContextVk *contextVk,
mCurrentArrayBufferHandles[attribIndex] = mTheNullBuffer.getBuffer().getHandle();
mCurrentArrayBufferOffsets[attribIndex] = 0;
// Client side buffer will be transfered to a tightly packed buffer later
stride = vertexFormat.bufferFormat().pixelBytes;
stride = vertexFormat.actualBufferFormat().pixelBytes;
}
if (bufferOnly)
......@@ -700,8 +700,7 @@ angle::Result VertexArrayVk::updateStreamedAttribs(const gl::Context *context,
const gl::VertexBinding &binding = bindings[attrib.bindingIndex];
const vk::Format &vertexFormat = renderer->getFormat(attrib.format->id);
GLuint stride = vertexFormat.bufferFormat().pixelBytes;
GLuint stride = vertexFormat.actualBufferFormat().pixelBytes;
ASSERT(GetVertexInputAlignment(vertexFormat) <= vk::kVertexBufferAlignment);
......
......@@ -99,7 +99,7 @@ angle::Result HardwareBufferImageSiblingVkAndroid::initImpl(DisplayVk *displayVk
&bufferProperties));
const vk::Format &vkFormat = renderer->getFormat(internalFormat);
const angle::Format &imageFormat = vkFormat.imageFormat();
const angle::Format &imageFormat = vkFormat.actualImageFormat();
bool isDepthOrStencilFormat = imageFormat.depthBits > 0 || imageFormat.stencilBits > 0;
const VkImageUsageFlags usage =
VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT |
......
......@@ -35,8 +35,6 @@ applications map from one state to many this will slow down the transition time.
improved in the future using a faster look up. For instance we could keep a sorted transition table
or use a small hash map for transitions.
[VkDevice]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkDevice.html
[VkQueue]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkQueue.html
[VkPipeline]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPipeline.html
[VkPipelineCache]: https://www.khronos.org/registry/vulkan/specs/1.1-extensions/man/html/VkPipelineCache.html
[GraphicsPipelineCache]: https://chromium.googlesource.com/angle/angle/+/225f08bf85a368f905362cdd1366e4795680452c/src/libANGLE/renderer/vulkan/vk_cache_utils.h#498
......
......@@ -26,10 +26,10 @@ To update the tables please modify the format map JSON and then run
[`scripts/run_code_generation.py`][RunCodeGeneration].
The [`vk::Format`](../vk_format_utils.h) class describes the information ANGLE needs for a particular
`VkFormat`. The 'ANGLE' format ID is a reference to the front-end format. The 'Image' or 'Buffer'
format are the native Vulkan formats that implement a particular front-end format for `VkImages` and
`VkBuffers`. For the above example of `R8_UNORM` overriding `L8_UNORM`, `L8_UNORM` is the ANGLE
format and `R8_UNORM` is the Image format.
`VkFormat`. The 'intended' format ID is a reference to the front-end format. The 'actual Image' and
'actual Buffer' formats are the native Vulkan formats that implement a particular front-end format
for `VkImages` and `VkBuffers`. For the above example of `R8_UNORM` overriding `L8_UNORM`,
`L8_UNORM` is the intended format and `R8_UNORM` is the actual Image format.
For more information please see the source files.
......
......@@ -71,7 +71,7 @@ internalFormat = {internal_format};
break;
"""
image_basic_template = """imageFormatID = {image};
image_basic_template = """actualImageFormatID = {image};
vkImageFormat = {vk_image_format};
imageInitializerFunction = {image_initializer};"""
......@@ -82,7 +82,7 @@ static constexpr ImageFormatInitInfo kInfo[] = {{{image_list}}};
initImageFallback(renderer, kInfo, ArraySize(kInfo));
}}"""
buffer_basic_template = """bufferFormatID = {buffer};
buffer_basic_template = """actualBufferFormatID = {buffer};
vkBufferFormat = {vk_buffer_format};
vkBufferFormatIsPacked = {vk_buffer_format_is_packed};
vertexLoadFunction = {vertex_load_function};
......
......@@ -699,7 +699,7 @@ angle::Result GraphicsPipelineDesc::initializePipeline(
// Get the corresponding VkFormat for the attrib's format.
angle::FormatID formatID = static_cast<angle::FormatID>(packedAttrib.format);
const vk::Format &format = contextVk->getRenderer()->getFormat(formatID);
const angle::Format &angleFormat = format.angleFormat();
const angle::Format &angleFormat = format.intendedFormat();
VkFormat vkFormat = format.vkBufferFormat;
gl::ComponentType attribType =
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -94,11 +94,11 @@ namespace vk
// Format implementation.
Format::Format()
: angleFormatID(angle::FormatID::NONE),
: intendedFormatID(angle::FormatID::NONE),
internalFormat(GL_NONE),
imageFormatID(angle::FormatID::NONE),
actualImageFormatID(angle::FormatID::NONE),
vkImageFormat(VK_FORMAT_UNDEFINED),
bufferFormatID(angle::FormatID::NONE),
actualBufferFormatID(angle::FormatID::NONE),
vkBufferFormat(VK_FORMAT_UNDEFINED),
imageInitializerFunction(nullptr),
textureLoadFunctions(),
......@@ -132,7 +132,7 @@ void Format::initImageFallback(RendererVk *renderer, const ImageFormatInitInfo *
testFunction);
i += skip;
imageFormatID = info[i].format;
actualImageFormatID = info[i].format;
vkImageFormat = info[i].vkFormat;
imageInitializerFunction = info[i].initializer;
}
......@@ -144,7 +144,7 @@ void Format::initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo
HasFullBufferFormatSupport);
i += skip;
bufferFormatID = info[i].format;
actualBufferFormatID = info[i].format;
vkBufferFormat = info[i].vkFormat;
vkBufferFormatIsPacked = info[i].vkFormatIsPacked;
vertexLoadFunction = info[i].vertexLoadFunction;
......@@ -172,7 +172,7 @@ size_t Format::getImageCopyBufferAlignment() const
// - else texelSize % 4 != 0 gives a 2x multiplier
// - else there's no multiplier.
//
const angle::Format &format = imageFormat();
const angle::Format &format = actualImageFormat();
ASSERT(format.pixelBytes != 0);
const size_t texelSize = format.pixelBytes;
......@@ -184,8 +184,8 @@ size_t Format::getImageCopyBufferAlignment() const
bool Format::hasEmulatedImageChannels() const
{
const angle::Format &angleFmt = angleFormat();
const angle::Format &textureFmt = imageFormat();
const angle::Format &angleFmt = intendedFormat();
const angle::Format &textureFmt = actualImageFormat();
return (angleFmt.alphaBits == 0 && textureFmt.alphaBits > 0) ||
(angleFmt.blueBits == 0 && textureFmt.blueBits > 0) ||
......@@ -221,7 +221,7 @@ void FormatTable::initialize(RendererVk *renderer,
format.initialize(renderer, angleFormat);
const GLenum internalFormat = format.internalFormat;
format.angleFormatID = formatID;
format.intendedFormatID = formatID;
if (!format.valid())
{
......@@ -234,7 +234,8 @@ void FormatTable::initialize(RendererVk *renderer,
if (textureCaps.texturable)
{
format.textureLoadFunctions = GetLoadFunctionsMap(internalFormat, format.imageFormatID);
format.textureLoadFunctions =
GetLoadFunctionsMap(internalFormat, format.actualImageFormatID);
}
if (angleFormat.isBlock)
......@@ -304,7 +305,7 @@ bool HasNonRenderableTextureFormatSupport(RendererVk *renderer, VkFormat vkForma
size_t GetVertexInputAlignment(const vk::Format &format)
{
const angle::Format &bufferFormat = format.bufferFormat();
const angle::Format &bufferFormat = format.actualBufferFormat();
size_t pixelBytes = bufferFormat.pixelBytes;
return format.vkBufferFormatIsPacked ? pixelBytes : (pixelBytes / bufferFormat.channelCount);
}
......@@ -343,7 +344,7 @@ void MapSwizzleState(const ContextVk *contextVk,
const gl::SwizzleState &swizzleState,
gl::SwizzleState *swizzleStateOut)
{
const angle::Format &angleFormat = format.angleFormat();
const angle::Format &angleFormat = format.intendedFormat();
gl::SwizzleState internalSwizzle;
......
......@@ -51,28 +51,39 @@ struct BufferFormatInitInfo final
bool vertexLoadRequiresConversion;
};
// Describes a Vulkan format. For more information on formats in the Vulkan back-end please see
// https://chromium.googlesource.com/angle/angle/+/master/src/libANGLE/renderer/vulkan/doc/FormatTablesAndEmulation.md
struct Format final : private angle::NonCopyable
{
Format();
bool valid() const { return internalFormat != 0; }
// The ANGLE format is the front-end format.
const angle::Format &angleFormat() const { return angle::Format::Get(angleFormatID); }
// 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.
// Some Surface formats and unsized types also don't have a corresponding GLenum.
const angle::Format &intendedFormat() const { return angle::Format::Get(intendedFormatID); }
// 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); }
// The actual Image format is used to implement the front-end format for Texture/Renderbuffers.
const angle::Format &actualImageFormat() const
{
return angle::Format::Get(actualImageFormatID);
}
// 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); }
// The actual Buffer format is used to implement the front-end format for Buffers.
const angle::Format &actualBufferFormat() const
{
return angle::Format::Get(actualBufferFormatID);
}
// Returns OpenGL format information for the front-end format.
// The |internalFormat| 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);
}
// Get buffer alignment for image-copy operations (to or from a buffer).
// Returns buffer alignment for image-copy operations (to or from a buffer).
size_t getImageCopyBufferAlignment() const;
// Returns true if the Image format has more channels than the ANGLE format.
......@@ -85,11 +96,11 @@ struct Format final : private angle::NonCopyable
void initImageFallback(RendererVk *renderer, const ImageFormatInitInfo *info, int numInfo);
void initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo *info, int numInfo);
angle::FormatID angleFormatID;
angle::FormatID intendedFormatID;
GLenum internalFormat;
angle::FormatID imageFormatID;
angle::FormatID actualImageFormatID;
VkFormat vkImageFormat;
angle::FormatID bufferFormatID;
angle::FormatID actualBufferFormatID;
VkFormat vkBufferFormat;
InitializeTextureDataFunction imageInitializerFunction;
......
......@@ -1836,7 +1836,7 @@ angle::Result ImageHelper::init2DStaging(Context *context,
VkImageAspectFlags ImageHelper::getAspectFlags() const
{
return GetFormatAspectFlags(mFormat->imageFormat());
return GetFormatAspectFlags(mFormat->actualImageFormat());
}
VkImageLayout ImageHelper::getCurrentLayout() const
......@@ -1999,12 +1999,13 @@ void ImageHelper::clear(const VkClearValue &value,
uint32_t layerCount,
vk::CommandBuffer *commandBuffer)
{
const angle::Format &angleFormat = mFormat->angleFormat();
const angle::Format &angleFormat = mFormat->intendedFormat();
bool isDepthStencil = angleFormat.depthBits > 0 || angleFormat.stencilBits > 0;
if (isDepthStencil)
{
const VkImageAspectFlags aspect = vk::GetDepthStencilAspectFlags(mFormat->imageFormat());
const VkImageAspectFlags aspect =
vk::GetDepthStencilAspectFlags(mFormat->actualImageFormat());
clearDepthStencil(aspect, aspect, value.depthStencil, mipLevel, 1, baseArrayLayer,
layerCount, commandBuffer);
}
......@@ -2193,7 +2194,7 @@ angle::Result ImageHelper::stageSubresourceUpdate(ContextVk *contextVk,
formatInfo.computeSkipBytes(type, inputRowPitch, inputDepthPitch, unpack,
index.usesTex3D(), &inputSkipBytes));
const angle::Format &storageFormat = vkFormat.imageFormat();
const angle::Format &storageFormat = vkFormat.actualImageFormat();
size_t outputRowPitch;
size_t outputDepthPitch;
......@@ -2307,7 +2308,7 @@ angle::Result ImageHelper::stageSubresourceUpdate(ContextVk *contextVk,
outputDepthPitch);
VkBufferImageCopy copy = {};
VkImageAspectFlags aspectFlags = GetFormatAspectFlags(vkFormat.imageFormat());
VkImageAspectFlags aspectFlags = GetFormatAspectFlags(vkFormat.actualImageFormat());
copy.bufferOffset = stagingOffset;
copy.bufferRowLength = bufferRowLength;
......@@ -2485,7 +2486,7 @@ angle::Result ImageHelper::stageSubresourceUpdateFromFramebuffer(
RendererVk *renderer = contextVk->getRenderer();
const vk::Format &vkFormat = renderer->getFormat(formatInfo.sizedInternalFormat);
const angle::Format &storageFormat = vkFormat.imageFormat();
const angle::Format &storageFormat = vkFormat.actualImageFormat();
LoadImageFunctionInfo loadFunction = vkFormat.textureLoadFunctions(formatInfo.type);
size_t outputRowPitch = storageFormat.pixelBytes * clippedRectangle.width;
......@@ -2603,7 +2604,7 @@ void ImageHelper::stageClearIfEmulatedFormat(const gl::ImageIndex &index, const
{
if (format.hasEmulatedImageChannels())
{
stageSubresourceEmulatedClear(index, format.angleFormat());
stageSubresourceEmulatedClear(index, format.intendedFormat());
}
}
......@@ -2658,7 +2659,7 @@ angle::Result ImageHelper::flushStagedUpdates(ContextVk *contextVk,
ANGLE_TRY(mStagingBuffer.flush(contextVk));
std::vector<SubresourceUpdate> updatesToKeep;
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(mFormat->imageFormat());
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(mFormat->actualImageFormat());
// Upload levels and layers that don't conflict in parallel. The (level, layer) pair is hashed
// to `(level * mLayerCount + layer) % 64` and used to track whether that subresource is
......@@ -2997,7 +2998,7 @@ angle::Result ImageViewHelper::initReadViews(ContextVk *contextVk,
uint32_t baseLayer,
uint32_t layerCount)
{
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(format.angleFormat());
const VkImageAspectFlags aspectFlags = GetFormatAspectFlags(format.intendedFormat());
if (HasBothDepthAndStencilAspects(aspectFlags))
{
ANGLE_TRY(image.initLayerImageView(contextVk, viewType, VK_IMAGE_ASPECT_DEPTH_BIT,
......@@ -3056,7 +3057,7 @@ angle::Result ImageViewHelper::getLevelLayerDrawImageView(Context *context,
const ImageView **imageViewOut)
{
ASSERT(image.valid());
ASSERT(!image.getFormat().imageFormat().isBlock);
ASSERT(!image.getFormat().actualImageFormat().isBlock);
uint32_t layerCount = GetImageLayerCountForView(image);
......
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