|
15 | 15 |
|
16 | 16 | #include "CommonPushConstants.h"
|
17 | 17 |
|
18 |
| -/* |
19 |
| - Uncomment bellow define to perform |
20 |
| - DDS input/output Denoiser Tonemapper's |
21 |
| - data saving. |
22 |
| -*/ |
23 |
| - |
24 |
| -#define DDSInputOutputDenoiserSave |
25 |
| - |
26 | 18 | using namespace nbl;
|
27 | 19 | using namespace asset;
|
28 | 20 | using namespace video;
|
@@ -882,124 +874,6 @@ void main()
|
882 | 874 | denoiserInputs[k].rowStrideInBytes = param.width * forcedOptiXFormatPixelStride;
|
883 | 875 | denoiserInputs[k].format = forcedOptiXFormat;
|
884 | 876 | denoiserInputs[k].pixelStrideInBytes = forcedOptiXFormatPixelStride;
|
885 |
| - |
886 |
| - #ifdef DDSInputOutputDenoiserSave |
887 |
| - |
888 |
| - auto createImage = [&](core::smart_refctd_ptr<ICPUBuffer> referecceTexelBuffer, uint64_t memoryOffset, bool isInputFilterImage = true) -> core::smart_refctd_ptr<ICPUImage> |
889 |
| - { |
890 |
| - asset::ICPUImage::SCreationParams imgInfo; |
891 |
| - imgInfo.format = isInputFilterImage ? EF_R16G16B16_SFLOAT : EF_R16G16B16A16_SFLOAT; |
892 |
| - imgInfo.type = asset::ICPUImage::ET_2D; |
893 |
| - imgInfo.extent.width = param.width; |
894 |
| - imgInfo.extent.height = param.height; |
895 |
| - imgInfo.extent.depth = 1u; |
896 |
| - imgInfo.mipLevels = 1u; |
897 |
| - imgInfo.arrayLayers = 1u; |
898 |
| - imgInfo.samples = asset::ICPUImage::ESCF_1_BIT; |
899 |
| - imgInfo.flags = static_cast<asset::IImage::E_CREATE_FLAGS>(0u); |
900 |
| - |
901 |
| - auto image = asset::ICPUImage::create(std::move(imgInfo)); |
902 |
| - const auto texelFormatBytesize = getTexelOrBlockBytesize(image->getCreationParameters().format); |
903 |
| - |
904 |
| - auto createTexelBuffer = [&]() -> core::smart_refctd_ptr<asset::ICPUBuffer> |
905 |
| - { |
906 |
| - if (isInputFilterImage) |
907 |
| - return core::make_smart_refctd_ptr<asset::CCustomAllocatorCPUBuffer<core::null_allocator<uint8_t>>>(image->getImageDataSizeInBytes(), reinterpret_cast<uint8_t*>(referecceTexelBuffer->getPointer()) + memoryOffset, core::adopt_memory); |
908 |
| - else |
909 |
| - { |
910 |
| - auto texelBuffer = core::make_smart_refctd_ptr<asset::ICPUBuffer>(image->getImageDataSizeInBytes()); |
911 |
| - memset(texelBuffer->getPointer(), 0, texelBuffer->getSize()); |
912 |
| - return texelBuffer; |
913 |
| - } |
914 |
| - }; |
915 |
| - |
916 |
| - auto texelBuffer = createTexelBuffer(); |
917 |
| - auto regions = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<asset::ICPUImage::SBufferCopy>>(1u); |
918 |
| - asset::ICPUImage::SBufferCopy& region = regions->front(); |
919 |
| - |
920 |
| - region.imageSubresource.mipLevel = 0u; |
921 |
| - region.imageSubresource.baseArrayLayer = 0u; |
922 |
| - region.imageSubresource.layerCount = 1u; |
923 |
| - region.bufferOffset = 0u; |
924 |
| - region.bufferRowLength = image->getCreationParameters().extent.width; |
925 |
| - region.bufferImageHeight = 0u; |
926 |
| - region.imageOffset = { 0u, 0u, 0u }; |
927 |
| - region.imageExtent = image->getCreationParameters().extent; |
928 |
| - |
929 |
| - image->setBufferAndRegions(std::move(texelBuffer), regions); |
930 |
| - |
931 |
| - return image; |
932 |
| - }; |
933 |
| - |
934 |
| - auto getConvertedOptixData = [&](core::smart_refctd_ptr<ICPUBuffer> texelBuffer, uint64_t memoryOffset) -> core::smart_refctd_ptr<ICPUImageView> |
935 |
| - { |
936 |
| - core::smart_refctd_ptr<asset::ICPUImage> inputFilterImage = createImage(texelBuffer, memoryOffset); |
937 |
| - core::smart_refctd_ptr<asset::ICPUImage> outputFilterImage = createImage(texelBuffer, memoryOffset, false); |
938 |
| - |
939 |
| - using ConvertFilter = asset::CConvertFormatImageFilter<EF_R16G16B16_SFLOAT, EF_R16G16B16A16_SFLOAT>; |
940 |
| - ConvertFilter convertFilter; |
941 |
| - ConvertFilter::state_type state; |
942 |
| - |
943 |
| - state.extent = { param.width, param.height, 1 }; |
944 |
| - state.inBaseLayer = 0; |
945 |
| - state.inImage = inputFilterImage.get(); |
946 |
| - state.inMipLevel = 0; |
947 |
| - state.inOffset = { 0, 0, 0 }; |
948 |
| - state.layerCount = 1; |
949 |
| - state.outBaseLayer = 0; |
950 |
| - state.outImage = outputFilterImage.get(); |
951 |
| - state.outMipLevel = 0; |
952 |
| - state.outOffset = { 0, 0, 0 }; |
953 |
| - |
954 |
| - if (!convertFilter.execute(&state)) |
955 |
| - os::Printer::log("WARNING (" + std::to_string(__LINE__) + " line): Something went wrong while converting the image!", ELL_WARNING); |
956 |
| - |
957 |
| - ICPUImageView::SCreationParams imageViewParams; |
958 |
| - imageViewParams.flags = static_cast<ICPUImageView::E_CREATE_FLAGS>(0u); |
959 |
| - imageViewParams.format = outputFilterImage->getCreationParameters().format; |
960 |
| - imageViewParams.image = std::move(outputFilterImage); |
961 |
| - imageViewParams.viewType = ICPUImageView::ET_2D; |
962 |
| - imageViewParams.subresourceRange = { static_cast<IImage::E_ASPECT_FLAGS>(0u),0u,1u,0u,1u }; |
963 |
| - |
964 |
| - return ICPUImageView::create(std::move(imageViewParams)); |
965 |
| - }; |
966 |
| - |
967 |
| - core::smart_refctd_ptr<ICPUImageView> inputDenoiserImageData = getConvertedOptixData(denoiserInputsTexelBuffer, shaderConstants.outImageOffset[k] * sizeof(uint16_t)); |
968 |
| - { |
969 |
| - IAssetWriter::SAssetWriteParams wp(inputDenoiserImageData.get()); |
970 |
| - auto getInputTerminateName = [&]() -> std::string |
971 |
| - { |
972 |
| - switch (k) |
973 |
| - { |
974 |
| - case EII_COLOR: |
975 |
| - return "color"; |
976 |
| - case EII_ALBEDO: |
977 |
| - return "albedo"; |
978 |
| - case EII_NORMAL: |
979 |
| - return "normal"; |
980 |
| - default: |
981 |
| - ""; |
982 |
| - } |
983 |
| - }; |
984 |
| - |
985 |
| - std::string removedExtensionFile = outputFileBundle[i].value().substr(0, outputFileBundle[i].value().size() - 4); |
986 |
| - std::string fileName = removedExtensionFile + "_optix_input_" + getInputTerminateName() + ".dds"; |
987 |
| - |
988 |
| - if(!am->writeAsset(fileName , wp)) |
989 |
| - os::Printer::log("ERROR (" + std::to_string(__LINE__) + " line): Could not save input denoiser .dds file!", ELL_ERROR); |
990 |
| - |
991 |
| - if (k >= denoiserInputCount - 1) |
992 |
| - { |
993 |
| - core::smart_refctd_ptr<ICPUImageView> outputDenoiserImageData = getConvertedOptixData(denoiserOutputTexelBuffer, shaderConstants.inImageTexelOffset[EII_COLOR]); |
994 |
| - fileName = removedExtensionFile + "_optix_output.dds"; |
995 |
| - IAssetWriter::SAssetWriteParams wp(outputDenoiserImageData.get()); |
996 |
| - |
997 |
| - if (!am->writeAsset(fileName, wp)) |
998 |
| - os::Printer::log("ERROR (" + std::to_string(__LINE__) + " line): Could not save output denoiser .dds file!", ELL_ERROR); |
999 |
| - } |
1000 |
| - } |
1001 |
| - |
1002 |
| - #endif // DDSInputOutputDenoiserSave |
1003 | 877 |
|
1004 | 878 | }
|
1005 | 879 |
|
|
0 commit comments