Remove useless 'target' parameter
VkImage objects' internal memory size is always allocated
by taking into account that the image might be used as a
render target, so this CL removes the useless boolean.
Bug: b/171406764
Change-Id: Ibdc6919350f8d1b45b0e77b35998e9a386873f84
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/56368
Presubmit-Ready: Alexis Hétu <sugoi@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alexis Hétu <sugoi@google.com>
diff --git a/src/Vulkan/VkFormat.cpp b/src/Vulkan/VkFormat.cpp
index 4b7db41..48340ab 100644
--- a/src/Vulkan/VkFormat.cpp
+++ b/src/Vulkan/VkFormat.cpp
@@ -1703,15 +1703,10 @@
return 0;
}
-int Format::pitchB(int width, int border, bool target) const
+int Format::pitchB(int width, int border) const
{
- width += 2 * border;
-
// Render targets require 2x2 quads
- if(target || isDepth() || isStencil())
- {
- width = sw::align<2>(width);
- }
+ width = sw::align<2>(width + 2 * border);
switch(format)
{
@@ -1784,15 +1779,10 @@
}
}
-int Format::sliceBUnpadded(int width, int height, int border, bool target) const
+int Format::sliceBUnpadded(int width, int height, int border) const
{
- height += 2 * border;
-
// Render targets require 2x2 quads
- if(target || isDepth() || isStencil())
- {
- height = sw::align<2>(height);
- }
+ height = sw::align<2>(height + 2 * border);
switch(format)
{
@@ -1822,7 +1812,7 @@
case VK_FORMAT_ASTC_4x4_SRGB_BLOCK:
case VK_FORMAT_ASTC_5x4_UNORM_BLOCK:
case VK_FORMAT_ASTC_5x4_SRGB_BLOCK:
- return pitchB(width, border, target) * ((height + 3) / 4); // Pitch computed per 4 rows
+ return pitchB(width, border) * ((height + 3) / 4); // Pitch computed per 4 rows
case VK_FORMAT_ASTC_5x5_UNORM_BLOCK:
case VK_FORMAT_ASTC_5x5_SRGB_BLOCK:
case VK_FORMAT_ASTC_6x5_UNORM_BLOCK:
@@ -1831,39 +1821,39 @@
case VK_FORMAT_ASTC_8x5_SRGB_BLOCK:
case VK_FORMAT_ASTC_10x5_UNORM_BLOCK:
case VK_FORMAT_ASTC_10x5_SRGB_BLOCK:
- return pitchB(width, border, target) * ((height + 4) / 5); // Pitch computed per 5 rows
+ return pitchB(width, border) * ((height + 4) / 5); // Pitch computed per 5 rows
case VK_FORMAT_ASTC_6x6_UNORM_BLOCK:
case VK_FORMAT_ASTC_6x6_SRGB_BLOCK:
case VK_FORMAT_ASTC_8x6_UNORM_BLOCK:
case VK_FORMAT_ASTC_8x6_SRGB_BLOCK:
case VK_FORMAT_ASTC_10x6_UNORM_BLOCK:
case VK_FORMAT_ASTC_10x6_SRGB_BLOCK:
- return pitchB(width, border, target) * ((height + 5) / 6); // Pitch computed per 6 rows
+ return pitchB(width, border) * ((height + 5) / 6); // Pitch computed per 6 rows
case VK_FORMAT_ASTC_8x8_UNORM_BLOCK:
case VK_FORMAT_ASTC_8x8_SRGB_BLOCK:
case VK_FORMAT_ASTC_10x8_UNORM_BLOCK:
case VK_FORMAT_ASTC_10x8_SRGB_BLOCK:
- return pitchB(width, border, target) * ((height + 7) / 8); // Pitch computed per 8 rows
+ return pitchB(width, border) * ((height + 7) / 8); // Pitch computed per 8 rows
case VK_FORMAT_ASTC_10x10_UNORM_BLOCK:
case VK_FORMAT_ASTC_10x10_SRGB_BLOCK:
case VK_FORMAT_ASTC_12x10_UNORM_BLOCK:
case VK_FORMAT_ASTC_12x10_SRGB_BLOCK:
- return pitchB(width, border, target) * ((height + 9) / 10); // Pitch computed per 10 rows
+ return pitchB(width, border) * ((height + 9) / 10); // Pitch computed per 10 rows
case VK_FORMAT_ASTC_12x12_UNORM_BLOCK:
case VK_FORMAT_ASTC_12x12_SRGB_BLOCK:
- return pitchB(width, border, target) * ((height + 11) / 12); // Pitch computed per 12 rows
+ return pitchB(width, border) * ((height + 11) / 12); // Pitch computed per 12 rows
case VK_FORMAT_G8_B8_R8_3PLANE_420_UNORM:
case VK_FORMAT_G8_B8R8_2PLANE_420_UNORM:
// "Images in this format must be defined with a width and height that is a multiple of two."
- return pitchB(width, border, target) * (height + height / 2); // U and V planes are 1/4 size of Y plane.
+ return pitchB(width, border) * (height + height / 2); // U and V planes are 1/4 size of Y plane.
default:
- return pitchB(width, border, target) * height; // Pitch computed per row
+ return pitchB(width, border) * height; // Pitch computed per row
}
}
-int Format::sliceB(int width, int height, int border, bool target) const
+int Format::sliceB(int width, int height, int border) const
{
- return sw::align<16>(sliceBUnpadded(width, height, border, target) + 15);
+ return sw::align<16>(sliceBUnpadded(width, height, border) + 15);
}
sw::float4 Format::getScale() const
diff --git a/src/Vulkan/VkFormat.hpp b/src/Vulkan/VkFormat.hpp
index 6c5e74f..dd26314 100644
--- a/src/Vulkan/VkFormat.hpp
+++ b/src/Vulkan/VkFormat.hpp
@@ -55,8 +55,8 @@
bool isUnsignedComponent(int component) const;
int bytes() const;
- int pitchB(int width, int border, bool target) const;
- int sliceB(int width, int height, int border, bool target) const;
+ int pitchB(int width, int border) const;
+ int sliceB(int width, int height, int border) const;
sw::float4 getScale() const;
@@ -74,7 +74,7 @@
private:
VkFormat compatibleFormat() const;
- int sliceBUnpadded(int width, int height, int border, bool target) const;
+ int sliceBUnpadded(int width, int height, int border) const;
VkFormat format = VK_FORMAT_UNDEFINED;
};
diff --git a/src/Vulkan/VkImage.cpp b/src/Vulkan/VkImage.cpp
index 6814eef..534281f 100644
--- a/src/Vulkan/VkImage.cpp
+++ b/src/Vulkan/VkImage.cpp
@@ -807,7 +807,7 @@
return extentInBlocks.width * usedFormat.bytesPerBlock();
}
- return usedFormat.pitchB(mipLevelExtent.width, borderSize(), true);
+ return usedFormat.pitchB(mipLevelExtent.width, borderSize());
}
int Image::slicePitchBytes(VkImageAspectFlagBits aspect, uint32_t mipLevel) const
@@ -824,7 +824,7 @@
return extentInBlocks.height * extentInBlocks.width * usedFormat.bytesPerBlock();
}
- return usedFormat.sliceB(mipLevelExtent.width, mipLevelExtent.height, borderSize(), true);
+ return usedFormat.sliceB(mipLevelExtent.width, mipLevelExtent.height, borderSize());
}
Format Image::getFormat(VkImageAspectFlagBits aspect) const