forked from NVIDIA-RTX/RTXNTC
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtils.h
More file actions
66 lines (53 loc) · 2.07 KB
/
Utils.h
File metadata and controls
66 lines (53 loc) · 2.07 KB
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*
* SPDX-FileCopyrightText: Copyright (c) 2024 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
* SPDX-License-Identifier: LicenseRef-NvidiaProprietary
*
* NVIDIA CORPORATION, its affiliates and licensors retain all intellectual
* property and proprietary rights in and to this material, related
* documentation and any modifications thereto. Any use, reproduction,
* disclosure or distribution of this material and related documentation
* without an express license agreement from NVIDIA CORPORATION or
* its affiliates is strictly prohibited.
*/
#pragma once
#include <nvrhi/nvrhi.h>
#include <libntc/ntc.h>
#include <functional>
#include <optional>
#include <ntc-utils/DDSHeader.h>
#define CHECK_NTC_RESULT(fname) \
if (ntcStatus != ntc::Status::Ok) { \
fprintf(stderr, "Call to " #fname " failed, code = %s\n%s\n", ntc::StatusToString(ntcStatus), ntc::GetLastErrorMessage()); \
return false; \
}
struct BcFormatDefinition
{
ntc::BlockCompressedFormat ntcFormat;
DXGI_FORMAT dxgiFormat;
DXGI_FORMAT dxgiFormatSrgb;
nvrhi::Format nvrhiFormat;
int bytesPerBlock;
int channels;
};
BcFormatDefinition const* GetBcFormatDefinition(ntc::BlockCompressedFormat format);
float Median(std::vector<float>& items);
bool WriteDdsHeader(ntc::IStream* ddsFile, int width, int height, int mipLevels,
BcFormatDefinition const* outputFormatDefinition, ntc::ColorSpace colorSpace);
bool SavePNG(uint8_t* data, int mipWidth, int mipHeight, int numChannels, bool is16Bit, char const* fileName);
void StartAsyncTask(std::function<void()> function);
void WaitForAllTasks();
enum class ImageContainer
{
Auto,
BMP,
EXR,
JPG,
PNG,
PNG16,
TGA,
};
std::optional<ImageContainer> ParseImageContainer(char const* s);
ntc::ChannelFormat GetContainerChannelFormat(ImageContainer container);
char const* GetContainerExtension(ImageContainer container);
bool SaveImageToContainer(ImageContainer container, void const* data, int width, int height, int channels, char const* fileName);
std::optional<int> ParseNetworkVersion(char const* version);