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