switch back to r10g10b10a2 backbuffer format + screenshot conversion
This commit is contained in:
@@ -23,7 +23,7 @@ namespace wiGraphicsTypes
|
||||
bool TESSELLATION, MULTITHREADED_RENDERING, CONSERVATIVE_RASTERIZATION, RASTERIZER_ORDERED_VIEWS, UNORDEREDACCESSTEXTURE_LOAD_EXT;
|
||||
public:
|
||||
GraphicsDevice()
|
||||
:FRAMECOUNT(0), VSYNC(true), SCREENWIDTH(0), SCREENHEIGHT(0), FULLSCREEN(false), RESOLUTIONCHANGED(false), BACKBUFFER_FORMAT(FORMAT_R8G8B8A8_UNORM/*FORMAT_R10G10B10A2_UNORM*/),
|
||||
:FRAMECOUNT(0), VSYNC(true), SCREENWIDTH(0), SCREENHEIGHT(0), FULLSCREEN(false), RESOLUTIONCHANGED(false), BACKBUFFER_FORMAT(FORMAT_R10G10B10A2_UNORM),
|
||||
TESSELLATION(false), MULTITHREADED_RENDERING(false), CONSERVATIVE_RASTERIZATION(false),RASTERIZER_ORDERED_VIEWS(false), UNORDEREDACCESSTEXTURE_LOAD_EXT(false)
|
||||
{}
|
||||
|
||||
|
||||
@@ -113,6 +113,34 @@ namespace wiHelper
|
||||
bool download_success = device->DownloadResource(&tex, stagingTex, data, GRAPHICSTHREAD_IMMEDIATE);
|
||||
assert(download_success);
|
||||
|
||||
if (desc.Format == FORMAT_R10G10B10A2_UNORM)
|
||||
{
|
||||
// So this should be converted first to rgba8 before saving to common format...
|
||||
|
||||
uint32_t* data32 = (uint32_t*)data;
|
||||
|
||||
for (UINT i = 0; i < data_count; ++i)
|
||||
{
|
||||
uint32_t pixel = data32[i];
|
||||
float r = ((pixel >> 0 ) & 1023) / 1023.0f;
|
||||
float g = ((pixel >> 10) & 1023) / 1023.0f;
|
||||
float b = ((pixel >> 20) & 1023) / 1023.0f;
|
||||
float a = ((pixel >> 30) & 3 ) / 3.0f;
|
||||
|
||||
uint32_t rgba8 = 0;
|
||||
rgba8 |= (uint32_t)(r * 255.0f) << 0;
|
||||
rgba8 |= (uint32_t)(g * 255.0f) << 8;
|
||||
rgba8 |= (uint32_t)(b * 255.0f) << 16;
|
||||
rgba8 |= (uint32_t)(a * 255.0f) << 24;
|
||||
|
||||
data32[i] = rgba8;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(desc.Format == FORMAT_R8G8B8A8_UNORM); // If you need to save other backbuffer format, convert the data here yourself...
|
||||
}
|
||||
|
||||
// TODO: png would be better, but it has some problems now...
|
||||
|
||||
//int write_result = stbi_write_png(ss.str().c_str(), (int)desc.Width, (int)desc.Height, 4, data, (int)data_stride);
|
||||
|
||||
Reference in New Issue
Block a user