Fix #162650: Failing vulkan texture view tests

Vulkan backend used the texture format to perform data conversions,
it ignored the format of the view, resulting in incorrect or missing
data conversions. This is fixed by using the view format to perform
data conversions.

These texture view conversions aren't used in Blender, but having all
3 backends providing the same result is a very welcome.

Pull Request: https://projects.blender.org/blender/blender/pulls/163202
This commit is contained in:
Jeroen Bakker 2026-09-03 14:28:25 +02:00
parent aae30c8a13
commit c85babd2e5
2 changed files with 4 additions and 16 deletions

View file

@ -178,9 +178,6 @@ static void texture_view_create_format_test()
static void test_texture_view_SFLOAT_32_32_32_32()
{
if (GPU_backend_get_type() == GPUBackendType::GPU_BACKEND_VULKAN) {
GTEST_SKIP() << "TODO: See #162650.";
}
texture_view_create_format_test<TextureFormat::SFLOAT_32_32_32_32,
TextureFormat::SFLOAT_32_32_32_32>();
texture_view_create_format_test<TextureFormat::SFLOAT_32_32_32_32,
@ -192,9 +189,6 @@ GPU_TEST(texture_view_SFLOAT_32_32_32_32);
static void test_texture_view_SFLOAT_32_32()
{
if (GPU_backend_get_type() == GPUBackendType::GPU_BACKEND_VULKAN) {
GTEST_SKIP() << "TODO: See #162650.";
}
if (GPU_type_matches_ex(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) {
GTEST_SKIP() << "Broken on AMD.";
}
@ -213,9 +207,6 @@ GPU_TEST(texture_view_SFLOAT_32_32);
static void test_texture_view_SFLOAT_32()
{
if (GPU_backend_get_type() == GPUBackendType::GPU_BACKEND_VULKAN) {
GTEST_SKIP() << "TODO: See #162650.";
}
if (GPU_type_matches_ex(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) {
GTEST_SKIP() << "Broken on AMD.";
}
@ -245,9 +236,6 @@ GPU_TEST(texture_view_SFLOAT_32);
static void test_texture_view_SFLOAT_16()
{
if (GPU_backend_get_type() == GPUBackendType::GPU_BACKEND_VULKAN) {
GTEST_SKIP() << "TODO: See #162650.";
}
if (GPU_type_matches_ex(GPU_DEVICE_ATI, GPU_OS_ANY, GPU_DRIVER_ANY, GPU_BACKEND_OPENGL)) {
GTEST_SKIP() << "Broken on AMD.";
}
@ -266,9 +254,6 @@ GPU_TEST(texture_view_SFLOAT_16);
static void test_texture_view_UINT_8()
{
if (GPU_backend_get_type() == GPUBackendType::GPU_BACKEND_VULKAN) {
GTEST_SKIP() << "TODO: See #162650.";
}
texture_view_create_format_test<TextureFormat::UINT_8, TextureFormat::UINT_8>();
texture_view_create_format_test<TextureFormat::UINT_8, TextureFormat::SINT_8>();
texture_view_create_format_test<TextureFormat::UINT_8, TextureFormat::SNORM_8>();

View file

@ -209,6 +209,9 @@ void VKTexture::read_sub(
TransferRegion full_transfer_region({offset, extent, layers});
const VkDeviceSize sample_bytesize = to_bytesize(device_format_);
const VkDeviceSize host_sample_bytesize = to_bytesize(format_, format);
/* For a texture view the raw bytes are reinterpretable with the base format but must be read
* back as the view (#format_) for them to be numerically correct. */
const TextureFormat data_storage_format = is_texture_view() ? format_ : device_format_;
const uint64_t x_bytesize = sample_bytesize * extent.x;
const uint64_t xy_bytesize = x_bytesize * extent.y;
const uint64_t xyz_bytesize = xy_bytesize * extent.z;
@ -326,7 +329,7 @@ void VKTexture::read_sub(
sample_len,
format,
format_,
device_format_);
data_storage_format);
}
}