Commit 08b97da8 by Shahbaz Youssefi Committed by Commit Bot

Vulkan: Fix staging buffer alignment for pixel sizes > 4

Previously, all non-compressed formats were satisfied with a 4-byte alignment. The introduction of float formats changes this. This change calculates the necessary alignment using the same code path as compressed formats. Also fixes RGB9E5's pixelByte being calculated as 3 instead of 4. Bug: angleproject:3731 Change-Id: I6abfd1c294e7f863eb99d2468eaac09e5d714039 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1715205Reviewed-by: 's avatarMohan Maiya <m.maiya@samsung.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
parent 557e3853
...@@ -2,9 +2,9 @@ ...@@ -2,9 +2,9 @@
"src/libANGLE/renderer/FormatID_autogen.h": "src/libANGLE/renderer/FormatID_autogen.h":
"5e017d47bc2eb942cf5717e05e7d072a", "5e017d47bc2eb942cf5717e05e7d072a",
"src/libANGLE/renderer/Format_table_autogen.cpp": "src/libANGLE/renderer/Format_table_autogen.cpp":
"d696378917e290bc41487a7e2311d555", "e22b7e416108ca2f738730d5a5be4c21",
"src/libANGLE/renderer/angle_format.py": "src/libANGLE/renderer/angle_format.py":
"ad11fef24bece29edfa62bcd2edff788", "7ed0a2469779c02567c98e0f2e476843",
"src/libANGLE/renderer/angle_format_data.json": "src/libANGLE/renderer/angle_format_data.json":
"e39704d451d108335e737c39ad423113", "e39704d451d108335e737c39ad423113",
"src/libANGLE/renderer/angle_format_map.json": "src/libANGLE/renderer/angle_format_map.json":
......
{ {
"src/libANGLE/renderer/angle_format.py": "src/libANGLE/renderer/angle_format.py":
"ad11fef24bece29edfa62bcd2edff788", "7ed0a2469779c02567c98e0f2e476843",
"src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py": "src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py":
"bf11e3404d4622059b6e9c4e96abf95e", "bf11e3404d4622059b6e9c4e96abf95e",
"src/libANGLE/renderer/d3d/d3d11/texture_format_data.json": "src/libANGLE/renderer/d3d/d3d11/texture_format_data.json":
......
{ {
"src/libANGLE/renderer/angle_format.py": "src/libANGLE/renderer/angle_format.py":
"ad11fef24bece29edfa62bcd2edff788", "7ed0a2469779c02567c98e0f2e476843",
"src/libANGLE/renderer/angle_format_map.json": "src/libANGLE/renderer/angle_format_map.json":
"947fe0a2c3ca1a819a68b4a94bfcf614", "947fe0a2c3ca1a819a68b4a94bfcf614",
"src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json": "src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json":
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"scripts/gl.xml": "scripts/gl.xml":
"b470cb06b06cbbe7adb2c8129ec85708", "b470cb06b06cbbe7adb2c8129ec85708",
"src/libANGLE/renderer/angle_format.py": "src/libANGLE/renderer/angle_format.py":
"ad11fef24bece29edfa62bcd2edff788", "7ed0a2469779c02567c98e0f2e476843",
"src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp": "src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp":
"96d06b3acf7826aee1ec813a8fa3a867", "96d06b3acf7826aee1ec813a8fa3a867",
"src/libANGLE/renderer/gl/DispatchTableGL_autogen.h": "src/libANGLE/renderer/gl/DispatchTableGL_autogen.h":
......
{ {
"src/libANGLE/renderer/angle_format.py": "src/libANGLE/renderer/angle_format.py":
"ad11fef24bece29edfa62bcd2edff788", "7ed0a2469779c02567c98e0f2e476843",
"src/libANGLE/renderer/angle_format_map.json": "src/libANGLE/renderer/angle_format_map.json":
"947fe0a2c3ca1a819a68b4a94bfcf614", "947fe0a2c3ca1a819a68b4a94bfcf614",
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py": "src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
......
{ {
"src/libANGLE/renderer/angle_format.py": "src/libANGLE/renderer/angle_format.py":
"ad11fef24bece29edfa62bcd2edff788", "7ed0a2469779c02567c98e0f2e476843",
"src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py": "src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py":
"dab4614bbee0c3fbc5b3ccaaa11ba9d3", "dab4614bbee0c3fbc5b3ccaaa11ba9d3",
"src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json": "src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json":
......
...@@ -219,7 +219,7 @@ const Format gFormatInfoTable[] = { ...@@ -219,7 +219,7 @@ const Format gFormatInfoTable[] = {
{ FormatID::R8_UINT, GL_R8UI, GL_R8UI, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLuint>, WriteColor<R8, GLuint>, GL_UNSIGNED_INT, 8, 0, 0, 0, 0, 0, 0, 1, 0, false, false, false, gl::VertexAttribType::UnsignedByte }, { FormatID::R8_UINT, GL_R8UI, GL_R8UI, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLuint>, WriteColor<R8, GLuint>, GL_UNSIGNED_INT, 8, 0, 0, 0, 0, 0, 0, 1, 0, false, false, false, gl::VertexAttribType::UnsignedByte },
{ FormatID::R8_UNORM, GL_R8, GL_R8, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLfloat>, WriteColor<R8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 0, 0, 0, 0, 0, 0, 1, 0, false, false, false, gl::VertexAttribType::UnsignedByte }, { FormatID::R8_UNORM, GL_R8, GL_R8, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLfloat>, WriteColor<R8, GLfloat>, GL_UNSIGNED_NORMALIZED, 8, 0, 0, 0, 0, 0, 0, 1, 0, false, false, false, gl::VertexAttribType::UnsignedByte },
{ FormatID::R8_USCALED, GL_R8_USCALED_ANGLEX, GL_R8_USCALED_ANGLEX, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLuint>, WriteColor<R8, GLuint>, GL_UNSIGNED_INT, 8, 0, 0, 0, 0, 0, 0, 1, 0, false, false, true, gl::VertexAttribType::UnsignedByte }, { FormatID::R8_USCALED, GL_R8_USCALED_ANGLEX, GL_R8_USCALED_ANGLEX, GenerateMip<R8>, NoCopyFunctions, ReadColor<R8, GLuint>, WriteColor<R8, GLuint>, GL_UNSIGNED_INT, 8, 0, 0, 0, 0, 0, 0, 1, 0, false, false, true, gl::VertexAttribType::UnsignedByte },
{ FormatID::R9G9B9E5_SHAREDEXP, GL_RGB9_E5, GL_RGB9_E5, GenerateMip<R9G9B9E5>, NoCopyFunctions, ReadColor<R9G9B9E5, GLfloat>, WriteColor<R9G9B9E5, GLfloat>, GL_FLOAT, 9, 9, 9, 0, 0, 0, 0, 3, 0, false, false, false, gl::VertexAttribType::InvalidEnum }, { FormatID::R9G9B9E5_SHAREDEXP, GL_RGB9_E5, GL_RGB9_E5, GenerateMip<R9G9B9E5>, NoCopyFunctions, ReadColor<R9G9B9E5, GLfloat>, WriteColor<R9G9B9E5, GLfloat>, GL_FLOAT, 9, 9, 9, 0, 0, 0, 0, 4, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
{ FormatID::S8_UINT, GL_STENCIL_INDEX8, GL_STENCIL_INDEX8, nullptr, NoCopyFunctions, ReadDepthStencil<S8>, WriteDepthStencil<S8>, GL_UNSIGNED_INT, 0, 0, 0, 0, 0, 0, 8, 1, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum }, { FormatID::S8_UINT, GL_STENCIL_INDEX8, GL_STENCIL_INDEX8, nullptr, NoCopyFunctions, ReadDepthStencil<S8>, WriteDepthStencil<S8>, GL_UNSIGNED_INT, 0, 0, 0, 0, 0, 0, 8, 1, std::numeric_limits<GLuint>::max(), false, false, false, gl::VertexAttribType::InvalidEnum },
// clang-format on // clang-format on
}; };
......
...@@ -10,7 +10,7 @@ import json ...@@ -10,7 +10,7 @@ import json
import os import os
import re import re
kChannels = "ABDGLRSX" kChannels = "ABDEGLRSX"
def get_angle_format_map_abs_path(): def get_angle_format_map_abs_path():
......
...@@ -146,35 +146,30 @@ void Format::initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo ...@@ -146,35 +146,30 @@ void Format::initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo
size_t Format::getImageCopyBufferAlignment() const size_t Format::getImageCopyBufferAlignment() const
{ {
// vkCmdCopyBufferToImage must have an offset that is a multiple of 4 as well as a multiple // vkCmdCopyBufferToImage must have an offset that is a multiple of 4 as well as a multiple
// of the pixel block size. // of the texel size (if uncompressed) or pixel block size (if compressed).
// https://www.khronos.org/registry/vulkan/specs/1.0/man/html/VkBufferImageCopy.html // https://www.khronos.org/registry/vulkan/specs/1.0/man/html/VkBufferImageCopy.html
// //
// We need lcm(4, blockSize) (lcm = least common multiplier). Since 4 is constant, this // We need lcm(4, texelSize) (lcm = least common multiplier). For compressed images,
// can be calculated as: // |texelSize| would contain the block size. Since 4 is constant, this can be calculated as:
// //
// | blockSize blockSize % 4 == 0 // | texelSize texelSize % 4 == 0
// | 4 * blockSize blockSize % 4 == 1 // | 4 * texelSize texelSize % 4 == 1
// lcm(4, blockSize) = < // lcm(4, texelSize) = <
// | 2 * blockSize blockSize % 4 == 2 // | 2 * texelSize texelSize % 4 == 2
// | 4 * blockSize blockSize % 4 == 3 // | 4 * texelSize texelSize % 4 == 3
// //
// This means: // This means:
// //
// - blockSize % 2 != 0 gives a 4x multiplier // - texelSize % 2 != 0 gives a 4x multiplier
// - else blockSize % 4 != 0 gives a 2x multiplier // - else texelSize % 4 != 0 gives a 2x multiplier
// - else there's no multiplier. // - else there's no multiplier.
// //
const angle::Format &format = imageFormat(); const angle::Format &format = imageFormat();
if (!format.isBlock) ASSERT(format.pixelBytes != 0);
{ const size_t texelSize = format.pixelBytes;
// Currently, 4 is sufficient for any known non-block format. const size_t multiplier = texelSize % 2 != 0 ? 4 : texelSize % 4 != 0 ? 2 : 1;
return 4; const size_t alignment = multiplier * texelSize;
}
const size_t blockSize = format.pixelBytes;
const size_t multiplier = blockSize % 2 != 0 ? 4 : blockSize % 4 != 0 ? 2 : 1;
const size_t alignment = multiplier * blockSize;
return alignment; return alignment;
} }
......
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