layers: GL168, fix bad compressed texel block size

The image<->buffer copy validation was checking against texel block
sizes, but needed the block size in byte. Fixed the bad validation
errors and renamed existing util function and updated a compressed
texture size to match the spec.

Change-Id: I40b9635a4fab131ab1525da51e94c4c5577217be
diff --git a/layers/buffer_validation.cpp b/layers/buffer_validation.cpp
index e5fb798..b9f15df 100644
--- a/layers/buffer_validation.cpp
+++ b/layers/buffer_validation.cpp
@@ -983,7 +983,7 @@
         granularity =
             GetPhysDevProperties(device_data)->queue_family_properties[pPool->queueFamilyIndex].minImageTransferGranularity;
         if (vk_format_is_compressed(img->createInfo.format)) {
-            auto block_size = vk_format_compressed_block_size(img->createInfo.format);
+            auto block_size = vk_format_compressed_texel_block_extents(img->createInfo.format);
             granularity.width *= block_size.width;
             granularity.height *= block_size.height;
         }
@@ -2572,7 +2572,7 @@
             //       reserves a place for these compressed image checks.  This block of code could move there once the image
             //       stuff is moved into core validation.
             if (vk_format_is_compressed(image_state->createInfo.format)) {
-                VkExtent2D block_size = vk_format_compressed_block_size(image_state->createInfo.format);
+                VkExtent2D block_size = vk_format_compressed_texel_block_extents(image_state->createInfo.format);
 
                 //  BufferRowLength must be a multiple of block width
                 if (vk_safe_modulo(pRegions[i].bufferRowLength, block_size.width) != 0) {
@@ -2605,12 +2605,12 @@
                 }
 
                 // bufferOffset must be a multiple of block size (linear bytes)
-                int block_size_in_bytes = block_size.width * block_size.height;
+                size_t block_size_in_bytes = vk_format_get_size(image_state->createInfo.format);
                 if (vk_safe_modulo(pRegions[i].bufferOffset, block_size_in_bytes) != 0) {
                     skip |= log_msg(report_data, VK_DEBUG_REPORT_ERROR_BIT_EXT, VK_DEBUG_REPORT_OBJECT_TYPE_IMAGE_EXT,
                                     reinterpret_cast<uint64_t &>(image_state->image), __LINE__, VALIDATION_ERROR_01274, "IMAGE",
                                     "%s(): pRegion[%d] bufferOffset (0x%" PRIxLEAST64 ") must be a multiple of the compressed image's texel block "
-                                    "size (0x%x). %s.",
+                                    "size (" PRINTF_SIZE_T_SPECIFIER "). %s.",
                                     function, i, pRegions[i].bufferOffset, block_size_in_bytes,
                                     validation_error_map[VALIDATION_ERROR_01274]);
                 }
@@ -2631,10 +2631,9 @@
         VkOffset3D offset = pRegions[i].imageOffset;
         VkExtent3D image_extent = image_info->extent;
 
-        // for compressed images, the image createInfo.extent is in texel blocks
-        // convert to texels here
+        // for compressed images, the image createInfo.extent is in texel blocks convert to texels here
         if (vk_format_is_compressed(image_info->format)) {
-            VkExtent2D texel_block_extent = vk_format_compressed_block_size(image_info->format);
+            VkExtent2D texel_block_extent = vk_format_compressed_texel_block_extents(image_info->format);
             image_extent.width *= texel_block_extent.width;
             image_extent.height *= texel_block_extent.height;
         }
@@ -2709,7 +2708,7 @@
         }
 
         if (vk_format_is_compressed(image_state->createInfo.format)) {
-            VkExtent2D texel_block_extent = vk_format_compressed_block_size(image_state->createInfo.format);
+            VkExtent2D texel_block_extent = vk_format_compressed_texel_block_extents(image_state->createInfo.format);
             buffer_width /= texel_block_extent.width;  // switch to texel block units
             buffer_height /= texel_block_extent.height;
             copy_extent.width /= texel_block_extent.width;
diff --git a/layers/vk_layer_utils.cpp b/layers/vk_layer_utils.cpp
index 18a42b9..cd23563 100644
--- a/layers/vk_layer_utils.cpp
+++ b/layers/vk_layer_utils.cpp
@@ -189,7 +189,7 @@
     {VK_FORMAT_ETC2_R8G8B8A1_UNORM_BLOCK,   {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT}},
     {VK_FORMAT_ETC2_R8G8B8A1_SRGB_BLOCK,    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_RGBA_BIT}},
     {VK_FORMAT_ETC2_R8G8B8A8_UNORM_BLOCK,   {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}},
-    {VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,    {16, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}},
+    {VK_FORMAT_ETC2_R8G8B8A8_SRGB_BLOCK,    {8, 4, VK_FORMAT_COMPATIBILITY_CLASS_ETC2_EAC_RGBA_BIT}},
     {VK_FORMAT_EAC_R11_UNORM_BLOCK,         {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT}},
     {VK_FORMAT_EAC_R11_SNORM_BLOCK,         {8, 1, VK_FORMAT_COMPATIBILITY_CLASS_EAC_R_BIT}},
     {VK_FORMAT_EAC_R11G11_UNORM_BLOCK,      {16, 2, VK_FORMAT_COMPATIBILITY_CLASS_EAC_RG_BIT}},
@@ -559,8 +559,8 @@
     }
 }
 
-// Return compressed block sizes for block compressed formats
-VK_LAYER_EXPORT VkExtent2D vk_format_compressed_block_size(VkFormat format) {
+// Return compressed texel block sizes for block compressed formats
+VK_LAYER_EXPORT VkExtent2D vk_format_compressed_texel_block_extents(VkFormat format) {
     VkExtent2D block_size = {1, 1};
     switch (format) {
         case VK_FORMAT_BC1_RGB_UNORM_BLOCK:
diff --git a/layers/vk_layer_utils.h b/layers/vk_layer_utils.h
index 4151ffe..fcd33ee 100644
--- a/layers/vk_layer_utils.h
+++ b/layers/vk_layer_utils.h
@@ -120,7 +120,7 @@
 VK_LAYER_EXPORT bool vk_format_is_float(VkFormat format);
 VK_LAYER_EXPORT bool vk_format_is_srgb(VkFormat format);
 VK_LAYER_EXPORT bool vk_format_is_compressed(VkFormat format);
-VK_LAYER_EXPORT VkExtent2D vk_format_compressed_block_size(VkFormat format);
+VK_LAYER_EXPORT VkExtent2D vk_format_compressed_texel_block_extents(VkFormat format);
 VK_LAYER_EXPORT size_t vk_format_get_size(VkFormat format);
 VK_LAYER_EXPORT unsigned int vk_format_get_channel_count(VkFormat format);
 VK_LAYER_EXPORT VkFormatCompatibilityClass vk_format_get_compatibility_class(VkFormat format);