From fb6f5aac2ea10e12303f20ff343be688a0023ae1 Mon Sep 17 00:00:00 2001 From: walbourn_cp Date: Mon, 17 Jun 2013 12:32:11 -0700 Subject: [PATCH] DirectXTex: Integrated some Code Review feedback (no code impact) --- DirectXTex/DirectXTex.h | 2 +- DirectXTex/DirectXTexConvert.cpp | 18 +++++++++++++----- DirectXTex/DirectXTexUtil.cpp | 4 ++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/DirectXTex/DirectXTex.h b/DirectXTex/DirectXTex.h index 4c50b48..6a0057e 100644 --- a/DirectXTex/DirectXTex.h +++ b/DirectXTex/DirectXTex.h @@ -59,7 +59,7 @@ namespace DirectX bool IsPacked( _In_ DXGI_FORMAT fmt ); bool IsVideo( _In_ DXGI_FORMAT fmt ); bool IsSRGB( _In_ DXGI_FORMAT fmt ); - bool IsTypeless( _In_ DXGI_FORMAT fmt, _In_ bool partialTypeless=true ); + bool IsTypeless( _In_ DXGI_FORMAT fmt, _In_ bool partialTypeless = true ); bool HasAlpha( _In_ DXGI_FORMAT fmt ); diff --git a/DirectXTex/DirectXTexConvert.cpp b/DirectXTex/DirectXTexConvert.cpp index 866fbed..d9e59f9 100644 --- a/DirectXTex/DirectXTexConvert.cpp +++ b/DirectXTex/DirectXTexConvert.cpp @@ -530,7 +530,7 @@ bool _LoadScanline( XMVECTOR* pDestination, size_t count, { assert( pDestination && count > 0 && (((uintptr_t)pDestination & 0xF) == 0) ); assert( pSource && size > 0 ); - assert( IsValid(format) && !IsVideo(format) && !IsTypeless(format,false) && !IsCompressed(format) ); + assert( IsValid(format) && !IsVideo(format) && !IsTypeless(format, false) && !IsCompressed(format) ); XMVECTOR* __restrict dPtr = pDestination; if ( !dPtr ) @@ -1834,9 +1834,12 @@ HRESULT _ConvertFromR32G32B32A32( const Image* srcImages, size_t nimages, const //------------------------------------------------------------------------------------- -// Linear RGB -> sRGB +// Convert from Linear RGB to sRGB +// +// if C_linear <= 0.0031308 -> C_srgb = 12.92 * C_linear +// if C_linear > 0.0031308 -> C_srgb = ( 1 + a ) * pow( C_Linear, 1 / 2.4 ) - a +// where a = 0.055 //------------------------------------------------------------------------------------- - static inline XMVECTOR RGBToSRGB( FXMVECTOR rgb ) { static const XMVECTORF32 Cutoff = { 0.0031308f, 0.0031308f, 0.0031308f, 1.f }; @@ -1919,9 +1922,12 @@ bool _StoreScanlineLinear( LPVOID pDestination, size_t size, DXGI_FORMAT format, //------------------------------------------------------------------------------------- -// sRGB -> Linear RGB +// Convert from sRGB to Linear RGB +// +// if C_srgb <= 0.04045 -> C_linear = C_srgb / 12.92 +// if C_srgb > 0.04045 -> C_linear = pow( ( C_srgb + a ) / ( 1 + a ), 2.4 ) +// where a = 0.055 //------------------------------------------------------------------------------------- - static inline XMVECTOR SRGBToRGB( FXMVECTOR srgb ) { static const XMVECTORF32 Cutoff = { 0.04045f, 0.04045f, 0.04045f, 1.f }; @@ -2502,6 +2508,7 @@ static const XMVECTORF32 g_ErrorWeight7 = { 7.f/16.f, 7.f/16.f, 7.f/16.f, 7.f/16 return false; #define STORE_SCANLINE2( type, scalev, clampzero, norm, itype, mask, row ) \ + /* The 2 component cases are always bgr=false */ \ if ( size >= sizeof(type) ) \ { \ type * __restrict dest = reinterpret_cast(pDestination); \ @@ -2553,6 +2560,7 @@ static const XMVECTORF32 g_ErrorWeight7 = { 7.f/16.f, 7.f/16.f, 7.f/16.f, 7.f/16 return false; #define STORE_SCANLINE1( type, scalev, clampzero, norm, mask, row, selectw ) \ + /* The 1 component cases are always bgr=false */ \ if ( size >= sizeof(type) ) \ { \ type * __restrict dest = reinterpret_cast(pDestination); \ diff --git a/DirectXTex/DirectXTexUtil.cpp b/DirectXTex/DirectXTexUtil.cpp index 9e4a55c..33fab51 100644 --- a/DirectXTex/DirectXTexUtil.cpp +++ b/DirectXTex/DirectXTexUtil.cpp @@ -449,8 +449,8 @@ size_t BitsPerPixel( DXGI_FORMAT fmt ) //------------------------------------------------------------------------------------- -// Returns bits-per-color (i.e. bit-depth) for a given DXGI format, or 0 on failure -// For mixed formats, it returns the largest bit-depth in the format +// Returns bits-per-color-channel for a given DXGI format, or 0 on failure +// For mixed formats, it returns the largest color-depth in the format //------------------------------------------------------------------------------------- _Use_decl_annotations_ size_t BitsPerColor( DXGI_FORMAT fmt )