mirror of
https://github.com/godotengine/godot-angle-static.git
synced 2026-01-06 02:09:55 +03:00
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/+/1715205 Reviewed-by: Mohan Maiya <m.maiya@samsung.com> Reviewed-by: Jamie Madill <jmadill@chromium.org> Commit-Queue: Shahbaz Youssefi <syoussefi@chromium.org>
This commit is contained in:
committed by
Commit Bot
parent
557e3853da
commit
08b97da894
@@ -2,9 +2,9 @@
|
||||
"src/libANGLE/renderer/FormatID_autogen.h":
|
||||
"5e017d47bc2eb942cf5717e05e7d072a",
|
||||
"src/libANGLE/renderer/Format_table_autogen.cpp":
|
||||
"d696378917e290bc41487a7e2311d555",
|
||||
"e22b7e416108ca2f738730d5a5be4c21",
|
||||
"src/libANGLE/renderer/angle_format.py":
|
||||
"ad11fef24bece29edfa62bcd2edff788",
|
||||
"7ed0a2469779c02567c98e0f2e476843",
|
||||
"src/libANGLE/renderer/angle_format_data.json":
|
||||
"e39704d451d108335e737c39ad423113",
|
||||
"src/libANGLE/renderer/angle_format_map.json":
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"src/libANGLE/renderer/angle_format.py":
|
||||
"ad11fef24bece29edfa62bcd2edff788",
|
||||
"7ed0a2469779c02567c98e0f2e476843",
|
||||
"src/libANGLE/renderer/d3d/d3d11/gen_texture_format_table.py":
|
||||
"bf11e3404d4622059b6e9c4e96abf95e",
|
||||
"src/libANGLE/renderer/d3d/d3d11/texture_format_data.json":
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"src/libANGLE/renderer/angle_format.py":
|
||||
"ad11fef24bece29edfa62bcd2edff788",
|
||||
"7ed0a2469779c02567c98e0f2e476843",
|
||||
"src/libANGLE/renderer/angle_format_map.json":
|
||||
"947fe0a2c3ca1a819a68b4a94bfcf614",
|
||||
"src/libANGLE/renderer/d3d/d3d11/dxgi_format_data.json":
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"scripts/gl.xml":
|
||||
"b470cb06b06cbbe7adb2c8129ec85708",
|
||||
"src/libANGLE/renderer/angle_format.py":
|
||||
"ad11fef24bece29edfa62bcd2edff788",
|
||||
"7ed0a2469779c02567c98e0f2e476843",
|
||||
"src/libANGLE/renderer/gl/DispatchTableGL_autogen.cpp":
|
||||
"96d06b3acf7826aee1ec813a8fa3a867",
|
||||
"src/libANGLE/renderer/gl/DispatchTableGL_autogen.h":
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"src/libANGLE/renderer/angle_format.py":
|
||||
"ad11fef24bece29edfa62bcd2edff788",
|
||||
"7ed0a2469779c02567c98e0f2e476843",
|
||||
"src/libANGLE/renderer/angle_format_map.json":
|
||||
"947fe0a2c3ca1a819a68b4a94bfcf614",
|
||||
"src/libANGLE/renderer/vulkan/gen_vk_format_table.py":
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"src/libANGLE/renderer/angle_format.py":
|
||||
"ad11fef24bece29edfa62bcd2edff788",
|
||||
"7ed0a2469779c02567c98e0f2e476843",
|
||||
"src/libANGLE/renderer/vulkan/gen_vk_mandatory_format_support_table.py":
|
||||
"dab4614bbee0c3fbc5b3ccaaa11ba9d3",
|
||||
"src/libANGLE/renderer/vulkan/vk_mandatory_format_support_data.json":
|
||||
|
||||
@@ -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_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::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 },
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
@@ -10,7 +10,7 @@ import json
|
||||
import os
|
||||
import re
|
||||
|
||||
kChannels = "ABDGLRSX"
|
||||
kChannels = "ABDEGLRSX"
|
||||
|
||||
|
||||
def get_angle_format_map_abs_path():
|
||||
|
||||
@@ -146,35 +146,30 @@ void Format::initBufferFallback(RendererVk *renderer, const BufferFormatInitInfo
|
||||
size_t Format::getImageCopyBufferAlignment() const
|
||||
{
|
||||
// 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
|
||||
//
|
||||
// We need lcm(4, blockSize) (lcm = least common multiplier). Since 4 is constant, this
|
||||
// can be calculated as:
|
||||
// We need lcm(4, texelSize) (lcm = least common multiplier). For compressed images,
|
||||
// |texelSize| would contain the block size. Since 4 is constant, this can be calculated as:
|
||||
//
|
||||
// | blockSize blockSize % 4 == 0
|
||||
// | 4 * blockSize blockSize % 4 == 1
|
||||
// lcm(4, blockSize) = <
|
||||
// | 2 * blockSize blockSize % 4 == 2
|
||||
// | 4 * blockSize blockSize % 4 == 3
|
||||
// | texelSize texelSize % 4 == 0
|
||||
// | 4 * texelSize texelSize % 4 == 1
|
||||
// lcm(4, texelSize) = <
|
||||
// | 2 * texelSize texelSize % 4 == 2
|
||||
// | 4 * texelSize texelSize % 4 == 3
|
||||
//
|
||||
// This means:
|
||||
//
|
||||
// - blockSize % 2 != 0 gives a 4x multiplier
|
||||
// - else blockSize % 4 != 0 gives a 2x multiplier
|
||||
// - texelSize % 2 != 0 gives a 4x multiplier
|
||||
// - else texelSize % 4 != 0 gives a 2x multiplier
|
||||
// - else there's no multiplier.
|
||||
//
|
||||
const angle::Format &format = imageFormat();
|
||||
|
||||
if (!format.isBlock)
|
||||
{
|
||||
// Currently, 4 is sufficient for any known non-block format.
|
||||
return 4;
|
||||
}
|
||||
|
||||
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;
|
||||
ASSERT(format.pixelBytes != 0);
|
||||
const size_t texelSize = format.pixelBytes;
|
||||
const size_t multiplier = texelSize % 2 != 0 ? 4 : texelSize % 4 != 0 ? 2 : 1;
|
||||
const size_t alignment = multiplier * texelSize;
|
||||
|
||||
return alignment;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user