yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

Ellie HermaszewskaMove switch statement bodies to their own lines (#5493)b118451e3

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