mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 09:00:44 +00:00
Print better error messages for failures to save textures to disk
This commit is contained in:
@@ -694,7 +694,10 @@ bool write_dds_to_file(FILE *f, const dds_data &data)
|
||||
headerDXT10.arraySize = data.slices;
|
||||
|
||||
if(headerDXT10.dxgiFormat == DXGI_FORMAT_UNKNOWN)
|
||||
{
|
||||
RDCERR("Couldn't convert resource format to DXGI format");
|
||||
return false;
|
||||
}
|
||||
|
||||
if(data.cubemap)
|
||||
{
|
||||
|
||||
@@ -254,6 +254,8 @@ size_t fwrite(const void *buf, size_t elementSize, size_t count, FILE *f);
|
||||
|
||||
bool exists(const char *filename);
|
||||
|
||||
std::string ErrorString();
|
||||
|
||||
std::string getline(FILE *f);
|
||||
|
||||
uint64_t ftell64(FILE *f);
|
||||
|
||||
@@ -326,6 +326,17 @@ FILE *fopen(const char *filename, const char *mode)
|
||||
return ::fopen(filename, mode);
|
||||
}
|
||||
|
||||
std::string ErrorString()
|
||||
{
|
||||
int err = errno;
|
||||
|
||||
char buf[256] = {0};
|
||||
|
||||
strerror_r(err, buf, 256);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
string getline(FILE *f)
|
||||
{
|
||||
string ret;
|
||||
|
||||
@@ -476,6 +476,17 @@ bool exists(const char *filename)
|
||||
return (res == 0);
|
||||
}
|
||||
|
||||
std::string ErrorString()
|
||||
{
|
||||
int err = errno;
|
||||
|
||||
char buf[256] = {0};
|
||||
|
||||
strerror_s(buf, err);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
string getline(FILE *f)
|
||||
{
|
||||
string ret;
|
||||
|
||||
@@ -946,6 +946,7 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
if(!f)
|
||||
{
|
||||
success = false;
|
||||
RDCERR("Couldn't write to path %s, error: %s", path, FileIO::ErrorString().c_str());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -969,6 +970,9 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
int ret = stbi_write_bmp_to_func(fileWriteFunc, (void *)f, td.width, td.height, numComps,
|
||||
subdata[0]);
|
||||
success = (ret != 0);
|
||||
|
||||
if(!success)
|
||||
RDCERR("stbi_write_bmp_to_func failed: %d", ret);
|
||||
}
|
||||
else if(sd.destType == FileType::PNG)
|
||||
{
|
||||
@@ -979,6 +983,9 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
int ret = stbi_write_png_to_func(fileWriteFunc, (void *)f, td.width, td.height, numComps,
|
||||
subdata[0], rowPitch);
|
||||
success = (ret != 0);
|
||||
|
||||
if(!success)
|
||||
RDCERR("stbi_write_png_to_func failed: %d", ret);
|
||||
}
|
||||
else if(sd.destType == FileType::TGA)
|
||||
{
|
||||
@@ -989,6 +996,9 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
int ret = stbi_write_tga_to_func(fileWriteFunc, (void *)f, td.width, td.height, numComps,
|
||||
subdata[0]);
|
||||
success = (ret != 0);
|
||||
|
||||
if(!success)
|
||||
RDCERR("stbi_write_tga_to_func failed: %d", ret);
|
||||
}
|
||||
else if(sd.destType == FileType::JPG)
|
||||
{
|
||||
@@ -1005,6 +1015,9 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
success = jpge::compress_image_to_jpeg_file_in_memory(jpgdst, len, td.width, td.height,
|
||||
numComps, subdata[0], p);
|
||||
|
||||
if(!success)
|
||||
RDCERR("jpge::compress_image_to_jpeg_file_in_memory failed");
|
||||
|
||||
if(success)
|
||||
fwrite(jpgdst, 1, len, f);
|
||||
|
||||
@@ -1144,6 +1157,9 @@ bool ReplayController::SaveTexture(const TextureSave &saveData, const char *path
|
||||
{
|
||||
int ret = stbi_write_hdr_to_func(fileWriteFunc, (void *)f, td.width, td.height, 4, fldata);
|
||||
success = (ret != 0);
|
||||
|
||||
if(!success)
|
||||
RDCERR("stbi_write_hdr_to_func failed: %d", ret);
|
||||
}
|
||||
else if(sd.destType == FileType::EXR)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user