yum-mirror/slang
Making it easier to work with shaders
git clone https://git.yummers.dev/yum-mirror/slang
b118451e3
master
1#include "resource-desc-utils.h" 2 3namespace gfx 4{ 5IBufferResource ::Desc fixupBufferDesc (const IBufferResource ::Desc & desc ) 6{ 7IBufferResource ::Desc result = desc ; 8result .allowedStates .add (result .defaultState ); 9return result ; 10} 11 12ITextureResource ::Desc fixupTextureDesc (const ITextureResource ::Desc & desc ) 13{ 14ITextureResource ::Desc rs = desc ; 15if (desc .numMipLevels == 0 ) 16rs .numMipLevels = calcNumMipLevels (desc .type ,desc .size ); 17rs .allowedStates .add (rs .defaultState ); 18return rs ; 19} 20 21Format srgbToLinearFormat (Format format ) 22{ 23switch (format ) 24 { 25case Format ::BC1_UNORM_SRGB : 26return Format ::BC1_UNORM ; 27case Format ::BC2_UNORM_SRGB : 28return Format ::BC2_UNORM ; 29case Format ::BC3_UNORM_SRGB : 30return Format ::BC3_UNORM ; 31case Format ::BC7_UNORM_SRGB : 32return Format ::BC7_UNORM ; 33case Format ::B8G8R8A8_UNORM_SRGB : 34return Format ::B8G8R8A8_UNORM ; 35case Format ::B8G8R8X8_UNORM_SRGB : 36return Format ::B8G8R8X8_UNORM ; 37case Format ::R8G8B8A8_UNORM_SRGB : 38return Format ::R8G8B8A8_UNORM ; 39default : 40return format ; 41 } 42} 43}// namespace gfx