texdiag analyze compute max luminance

This commit is contained in:
Chuck Walbourn 2016-09-26 22:54:21 -07:00
parent 8891860a60
commit 787bfa9053

View File

@ -490,6 +490,7 @@ namespace
XMFLOAT4 imageAvg;
XMFLOAT4 imageVariance;
XMFLOAT4 imageStdDev;
float luminance;
size_t specials_x;
size_t specials_y;
size_t specials_z;
@ -503,6 +504,8 @@ namespace
wprintf(L"\t Variance - (%f %f %f %f)\n", imageVariance.x, imageVariance.y, imageVariance.z, imageVariance.w);
wprintf(L"\t Std Dev - (%f %f %f %f)\n", imageStdDev.x, imageStdDev.y, imageStdDev.z, imageStdDev.w);
wprintf(L"\tLuminance - %f (maximum)\n", luminance);
if ((specials_x > 0) || (specials_y > 0) || (specials_z > 0) || (specials_w > 0))
{
wprintf(L" FP specials - (%Iu %Iu %Iu %Iu)\n", specials_x, specials_y, specials_z, specials_w);
@ -518,16 +521,20 @@ namespace
XMVECTOR minv = g_XMFltMax;
XMVECTOR maxv = XMVectorNegate(g_XMFltMax);
XMVECTOR acc = g_XMZero;
XMVECTOR luminance = g_XMZero;
size_t totalPixels = 0;
HRESULT hr = EvaluateImage(image, [&](const XMVECTOR * pixels, size_t width, size_t y)
{
static const XMVECTORF32 s_luminance = { 0.3f, 0.59f, 0.11f, 0.f };
UNREFERENCED_PARAMETER(y);
for (size_t x = 0; x < width; ++x)
{
XMVECTOR v = *pixels++;
luminance = XMVectorMax(luminance, XMVector3Dot(v, s_luminance) );
minv = XMVectorMin(minv, v);
maxv = XMVectorMax(maxv, v);
acc = XMVectorAdd(v, acc);
@ -562,6 +569,7 @@ namespace
if (!totalPixels)
return S_FALSE;
result.luminance = XMVectorGetX(luminance);
XMStoreFloat4(&result.imageMin, minv);
XMStoreFloat4(&result.imageMax, maxv);