summaryrefslogtreecommitdiffstats
path: root/tools/gfx/resource-desc-utils.cpp
blob: 8d70d0487ebe74c31918fc3ae9122113c07aa6af (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include "resource-desc-utils.h"

namespace gfx
{
IBufferResource::Desc fixupBufferDesc(const IBufferResource::Desc& desc)
{
    IBufferResource::Desc result = desc;
    result.allowedStates.add(result.defaultState);
    return result;
}

ITextureResource::Desc fixupTextureDesc(const ITextureResource::Desc& desc)
{
    ITextureResource::Desc rs = desc;
    if (desc.numMipLevels == 0)
        rs.numMipLevels = calcNumMipLevels(desc.type, desc.size);
    rs.allowedStates.add(rs.defaultState);
    return rs;
}

Format srgbToLinearFormat(Format format)
{
    switch (format)
    {
    case Format::BC1_UNORM_SRGB:
        return Format::BC1_UNORM;
    case Format::BC2_UNORM_SRGB:
        return Format::BC2_UNORM;
    case Format::BC3_UNORM_SRGB:
        return Format::BC3_UNORM;
    case Format::BC7_UNORM_SRGB:
        return Format::BC7_UNORM;
    case Format::B8G8R8A8_UNORM_SRGB:
        return Format::B8G8R8A8_UNORM;
    case Format::B8G8R8X8_UNORM_SRGB:
        return Format::B8G8R8X8_UNORM;
    case Format::R8G8B8A8_UNORM_SRGB:
        return Format::R8G8B8A8_UNORM;
    default:
        return format;
    }
}
} // namespace gfx