Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan dump resources: Drop astc format #1905

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
61 changes: 3 additions & 58 deletions framework/decode/vulkan_replay_dump_resources_common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,18 +54,8 @@ PipelineBindPoints VkPipelineBindPointToPipelineBindPoint(VkPipelineBindPoint bi
}
}

bool IsFormatAstcCompressed(VkFormat format)
{
return vkuFormatIsCompressed_ASTC_HDR(format) || vkuFormatIsCompressed_ASTC_LDR(format);
}

static util::imagewriter::DataFormats VkFormatToImageWriterDataFormat(VkFormat format)
{
if (IsFormatAstcCompressed(format))
{
return util::imagewriter::DataFormats::kFormat_ASTC;
}

switch (format)
{
case VK_FORMAT_R8G8B8_UNORM:
Expand Down Expand Up @@ -107,9 +97,6 @@ const char* ImageFileExtension(DumpedImageFormat image_format)
case KFormatPNG:
return ".png";

case KFormatAstc:
return ".astc";

case KFormatRaw:
default:
return ".bin";
Expand Down Expand Up @@ -559,21 +546,7 @@ VkResult DumpImageToFile(const VulkanImageInfo* image_info,
const uint32_t texel_size = vkuFormatElementSizeWithAspect(dst_format, aspects[i]);
const uint32_t stride = texel_size * scaled_extent.width;

if (output_image_format == KFormatAstc)
{
VKU_FORMAT_INFO format_info = vkuGetFormatInfo(image_info->format);

util::imagewriter::WriteAstcImage(filename,
scaled_extent.width,
scaled_extent.width,
1,
format_info.block_extent.width,
format_info.block_extent.height,
format_info.block_extent.depth,
data.data(),
subresource_sizes[0]);
}
else if (output_image_format == kFormatBMP)
if (output_image_format == kFormatBMP)
{
if (dump_separate_alpha)
{
Expand Down Expand Up @@ -667,21 +640,7 @@ VkResult DumpImageToFile(const VulkanImageInfo* image_info,
const uint32_t texel_size = vkuFormatElementSizeWithAspect(image_info->format, aspect);
const uint32_t stride = texel_size * scaled_extent.width;

if (output_image_format == KFormatAstc)
{
VKU_FORMAT_INFO format_info = vkuGetFormatInfo(image_info->format);

util::imagewriter::WriteAstcImage(filename,
scaled_extent.width,
scaled_extent.width,
1,
format_info.block_extent.width,
format_info.block_extent.height,
format_info.block_extent.depth,
data.data(),
subresource_sizes[sub_res_idx]);
}
else if (output_image_format == kFormatBMP)
if (output_image_format == kFormatBMP)
{
if (dump_separate_alpha)
{
Expand Down Expand Up @@ -937,21 +896,7 @@ DumpedImageFormat GetDumpedImageFormat(const VulkanDeviceInfo* device
// If there's a request for images to be dumped as raw bin files
if (dump_raw)
{
// We consider astc as a raw bin format
if (IsFormatAstcCompressed(src_format))
{
return KFormatAstc;
}
else
{
return KFormatRaw;
}
}

// Astc images will be dumped as .astc files
if (IsFormatAstcCompressed(src_format))
{
return KFormatAstc;
return KFormatRaw;
}

graphics::VulkanResourcesUtil resource_util(device_info->handle,
Expand Down
3 changes: 0 additions & 3 deletions framework/decode/vulkan_replay_dump_resources_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,10 @@ static bool IsInsideRange(const std::vector<T>& vec, T value)

PipelineBindPoints VkPipelineBindPointToPipelineBindPoint(VkPipelineBindPoint bind_point);

bool IsFormatAstcCompressed(VkFormat format);

enum DumpedImageFormat
{
kFormatBMP,
KFormatPNG,
KFormatAstc,
KFormatRaw
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1430,7 +1430,7 @@ std::string DispatchTraceRaysDumpingContext::GenerateImageDescriptorFilename(VkF
image_file_format,
dump_images_raw);

if (output_image_format != KFormatRaw && output_image_format != KFormatAstc)
if (output_image_format != KFormatRaw)
{
base_filename << "image_" << image_id << "_qs_" << qs_index << "_bcb_" << bcb_index << "_aspect_" << aspect_str;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1852,7 +1852,7 @@ std::string DrawCallsDumpingContext::GenerateImageDescriptorFilename(VkFormat
image_file_format,
dump_images_raw);

if (output_image_format != KFormatRaw && output_image_format != KFormatAstc)
if (output_image_format != KFormatRaw)
{
base_filename << "image_" << image_id << "_qs_" << qs_index << "_bcb_" << bcb_index << "_rp_" << rp
<< "_aspect_" << aspect_str;
Expand Down
72 changes: 0 additions & 72 deletions framework/util/image_writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -569,78 +569,6 @@ bool WritePngImageSeparateAlpha(const std::string& filename,
return success;
}

bool WriteAstcImage(const std::string& filename,
uint32_t width,
uint32_t height,
uint32_t depth,
uint8_t block_size_x,
uint8_t block_size_y,
uint8_t block_size_z,
const void* data,
size_t size)
{
if (data == nullptr || !size)
{
return true;
}

GFXRECON_LOG_INFO("%s(): Writing file \"%s\"", __func__, filename.c_str())

AstcFileHeader header;

header.magic[0] = 0x13;
header.magic[1] = 0xab;
header.magic[2] = 0xa1;
header.magic[3] = 0x5c;

header.dim_x[0] = static_cast<uint8_t>((width >> 0) & 0xff);
header.dim_x[1] = static_cast<uint8_t>((width >> 8) & 0xff);
header.dim_x[2] = static_cast<uint8_t>((width >> 16) & 0xff);

header.dim_y[0] = static_cast<uint8_t>((height >> 0) & 0xff);
header.dim_y[1] = static_cast<uint8_t>((height >> 8) & 0xff);
header.dim_y[2] = static_cast<uint8_t>((height >> 16) & 0xff);

header.dim_z[0] = static_cast<uint8_t>((depth >> 0) & 0xff);
header.dim_z[1] = static_cast<uint8_t>((depth >> 8) & 0xff);
header.dim_z[2] = static_cast<uint8_t>((depth >> 16) & 0xff);

header.block_x = block_size_x;
header.block_y = block_size_y;
header.block_z = block_size_z;

bool success = false;
FILE* file = nullptr;
int32_t result = util::platform::FileOpen(&file, filename.c_str(), "wb");
if (!result && file != nullptr)
{
// Write the header
bool ret = util::platform::FileWrite(&header, sizeof(header), file);
CheckFwriteRetVal(ret, file);

// Write the binary payload
ret = util::platform::FileWrite(data, size, file);
CheckFwriteRetVal(ret, file);

if (!ferror(file))
{
success = true;
}

if (util::platform::FileClose(file))
{
GFXRECON_LOG_ERROR("%s() fclose failed (%s)", __func__, strerror(result));
}
}
else
{
success = false;
GFXRECON_LOG_ERROR("%s() Failed to open file (%s)", __func__, strerror(result));
}

return success;
}

GFXRECON_END_NAMESPACE(imagewriter)
GFXRECON_END_NAMESPACE(util)
GFXRECON_END_NAMESPACE(gfxrecon)
29 changes: 1 addition & 28 deletions framework/util/image_writer.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ enum DataFormats
kFormat_BGRA,
kFormat_D32_FLOAT,
kFormat_D24_UNORM,
kFormat_D16_UNORM,
kFormat_ASTC
kFormat_D16_UNORM
};

constexpr bool DataFormatHasAlpha(DataFormats format)
Expand All @@ -90,7 +89,6 @@ constexpr bool DataFormatHasAlpha(DataFormats format)
case kFormat_D32_FLOAT:
case kFormat_D24_UNORM:
case kFormat_D16_UNORM:
case kFormat_ASTC:
return false;

default:
Expand All @@ -116,10 +114,6 @@ constexpr size_t DataFormatsSizes(DataFormats format)
case kFormat_D32_FLOAT:
return 4;

case kFormat_ASTC:
GFXRECON_LOG_WARNING("%s(): Cannot calculate element size for ASTC.", __func__);
return 0;

case kFormat_UNSPECIFIED:
default:
GFXRECON_LOG_WARNING("%s(): Unrecognized format %u", __func__, static_cast<uint32_t>(format));
Expand All @@ -128,17 +122,6 @@ constexpr size_t DataFormatsSizes(DataFormats format)
}
}

struct AstcFileHeader
{
uint8_t magic[4];
uint8_t block_x;
uint8_t block_y;
uint8_t block_z;
uint8_t dim_x[3];
uint8_t dim_y[3];
uint8_t dim_z[3];
};

bool WriteBmpImage(const std::string& filename,
uint32_t width,
uint32_t height,
Expand Down Expand Up @@ -173,16 +156,6 @@ bool WritePngImageSeparateAlpha(const std::string& filename,
uint32_t pitch,
DataFormats format);

bool WriteAstcImage(const std::string& filename,
uint32_t width,
uint32_t height,
uint32_t depth,
uint8_t block_size_x,
uint8_t block_size_y,
uint8_t block_size_z,
const void* data,
size_t size);

GFXRECON_END_NAMESPACE(imagewriter)
GFXRECON_END_NAMESPACE(util)
GFXRECON_END_NAMESPACE(gfxrecon)
Expand Down
3 changes: 1 addition & 2 deletions vulkan_dump_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -471,8 +471,7 @@ Here is an example of a json output file:

### Image file output

The image files that created are either images (in one of the supported image formats), `.astc` files, or raw binary files (`.bin`).
Astc compressed images are dumped as .astc files which can be decompressed and converted into a plain image file offline on the host.
The image files that created are either images (in one of the supported image formats), or raw binary files (`.bin`).
Raw binary files are created when the dumped resource is an image with a format which cannot be converted into a plain 32bit RGBA layout.

### Buffer file output
Expand Down
Loading