Skip to content

Commit

Permalink
Automatic update
Browse files Browse the repository at this point in the history
  • Loading branch information
skallweitNV committed Dec 11, 2023
1 parent a464cc1 commit a271dd1
Show file tree
Hide file tree
Showing 118 changed files with 2,824 additions and 955 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ For more information on how to use Falcor as a Python module see [Falcor In Pyth
## Microsoft DirectX 12 Agility SDK
Falcor uses the [Microsoft DirectX 12 Agility SDK](https://devblogs.microsoft.com/directx/directx12agility/) to get access to the latest DirectX 12 features. Applications can enable the Agility SDK by putting `FALCOR_EXPORT_D3D12_AGILITY_SDK` in the main `.cpp` file. `Mogwai`, `FalcorTest` and `RenderGraphEditor` have the Agility SDK enabled by default.

## NVAPI
To enable NVAPI support, head over to https://developer.nvidia.com/nvapi and download the latest version of NVAPI (this build is tested against version R535).
Extract the content of the zip file into `external/packman/` and rename `R535-developer` to `nvapi`.

## NSight Aftermath
To enable NSight Aftermath support, head over to https://developer.nvidia.com/nsight-aftermath and download the latest version of Aftermath (this build is tested against version 2023.1).
Extract the content of the zip file into `external/packman/aftermath`.
Expand Down
18 changes: 14 additions & 4 deletions Source/Falcor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ target_sources(Falcor PRIVATE
Core/State/StateGraph.h

DiffRendering/AggregateGradients.cs.slang
DiffRendering/DiffDebug.slang
DiffRendering/DiffDebugParams.slang
DiffRendering/DiffMaterialData.slang
DiffRendering/DiffSceneIO.slang
DiffRendering/DiffSceneQuery.slang
DiffRendering/GradientIOWrapper.slang
DiffRendering/InverseOptimizationParams.slang
DiffRendering/SceneGradientInfo.slang
DiffRendering/SceneGradients.cpp
DiffRendering/SceneGradients.h
Expand Down Expand Up @@ -543,6 +544,7 @@ target_sources(Falcor PRIVATE
Utils/Dictionary.h
Utils/fast_vector.h
Utils/HostDeviceShared.slangh
Utils/IndexedVector.h
Utils/Logger.cpp
Utils/Logger.h
Utils/NumericRange.h
Expand All @@ -554,13 +556,13 @@ target_sources(Falcor PRIVATE
Utils/PathResolving.h
Utils/Properties.cpp
Utils/Properties.h
Utils/Settings.cpp
Utils/Settings.h
Utils/SharedCache.h
Utils/SlangUtils.slang
Utils/StringFormatters.h
Utils/StringUtils.cpp
Utils/StringUtils.h
Utils/TaskManager.cpp
Utils/TaskManager.h
Utils/TermColor.cpp
Utils/TermColor.h
Utils/Threading.cpp
Expand Down Expand Up @@ -700,6 +702,13 @@ target_sources(Falcor PRIVATE
Utils/SDF/SDFOperations.slang
Utils/SDF/SDFOperationType.slang

Utils/Settings/AttributeFilters.cpp
Utils/Settings/AttributeFilters.h
Utils/Settings/Attributes.h
Utils/Settings/Settings.cpp
Utils/Settings/Settings.h
Utils/Settings/SettingsUtils.h

Utils/Timing/Clock.cpp
Utils/Timing/Clock.h
Utils/Timing/CpuTimer.h
Expand Down Expand Up @@ -923,6 +932,7 @@ target_compile_definitions(Falcor
$<$<CXX_COMPILER_ID:MSVC>:_SCL_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_CRT_SECURE_NO_WARNINGS>
$<$<CXX_COMPILER_ID:MSVC>:_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING>
$<$<CXX_COMPILER_ID:MSVC>:_SILENCE_ALL_MS_EXT_DEPRECATION_WARNINGS>
# Clang.
$<$<CXX_COMPILER_ID:Clang>:_MSC_EXTENSIONS> # enable MS extensions
# Falcor feature flags.
Expand Down Expand Up @@ -963,7 +973,7 @@ target_link_libraries(Falcor
$<$<BOOL:${FALCOR_HAS_CUDA}>:CUDA::cudart_static>
PRIVATE
git_version
FreeImage assimp OpenEXR OpenVDB lz4 zlib pugixml
FreeImage assimp OpenEXR OpenVDB lz4 zlib pugixml opensubdiv
glfw mikktspace nvtt
$<$<BOOL:${FALCOR_HAS_D3D12}>:d3d12>
$<$<BOOL:${FALCOR_HAS_D3D12_AGILITY_SDK}>:agility-sdk>
Expand Down
18 changes: 7 additions & 11 deletions Source/Falcor/Core/API/Buffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ void Buffer::setBlob(const void* pData, size_t offset, size_t size)
if (mMemoryType == MemoryType::Upload)
{
bool wasMapped = mMappedPtr != nullptr;
uint8_t* pDst = (uint8_t*)map(MapType::Write) + offset;
uint8_t* pDst = (uint8_t*)map() + offset;
std::memcpy(pDst, pData, size);
if (!wasMapped)
unmap();
Expand All @@ -286,7 +286,7 @@ void Buffer::getBlob(void* pData, size_t offset, size_t size) const
if (mMemoryType == MemoryType::ReadBack)
{
bool wasMapped = mMappedPtr != nullptr;
const uint8_t* pSrc = (const uint8_t*)map(MapType::Read) + offset;
const uint8_t* pSrc = (const uint8_t*)map() + offset;
std::memcpy(pData, pSrc, size);
if (!wasMapped)
unmap();
Expand All @@ -301,16 +301,12 @@ void Buffer::getBlob(void* pData, size_t offset, size_t size) const
}
}

void* Buffer::map(MapType type) const
void* Buffer::map() const
{
if (type == MapType::WriteDiscard)
FALCOR_THROW("MapType::WriteDiscard not supported anymore");

if (type == MapType::Write && mMemoryType != MemoryType::Upload)
FALCOR_THROW("Trying to map a buffer for writing, but it wasn't created with the write permissions.");

if (type == MapType::Read && mMemoryType != MemoryType::ReadBack)
FALCOR_THROW("Trying to map a buffer for reading, but it wasn't created with the read permissions.");
FALCOR_CHECK(
mMemoryType == MemoryType::Upload || mMemoryType == MemoryType::ReadBack,
"Trying to map a buffer that wasn't created with the upload or readback flags."
);

if (!mMappedPtr)
FALCOR_GFX_CALL(mGfxBufferResource->map(nullptr, &mMappedPtr));
Expand Down
28 changes: 1 addition & 27 deletions Source/Falcor/Core/API/Buffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,6 @@ class FALCOR_API Buffer : public Resource
{
FALCOR_OBJECT(Buffer)
public:
enum class MapType
{
Read, ///< Map the buffer for read access.
Write, ///< Map the buffer for write access.
WriteDiscard, ///< Deprecated and not supported.
};

/// Constructor for raw buffer.
Buffer(ref<Device> pDevice, size_t size, ResourceBindFlags bindFlags, MemoryType memoryType, const void* pInitData);

Expand Down Expand Up @@ -272,11 +265,8 @@ class FALCOR_API Buffer : public Resource

/**
* Map the buffer.
* Only buffers with MemoryType::Upload or MemoryType::ReadBack can be mapped.
* To map a buffer with MemoryType::Upload, use MapType::Write.
* To map a buffer with MemoryType::ReadBack, use MapType::Read.
*/
void* map(MapType Type) const;
void* map() const;

/**
* Unmap the buffer
Expand Down Expand Up @@ -364,20 +354,4 @@ inline std::string to_string(MemoryType c)
#undef a2s
}

inline std::string to_string(Buffer::MapType mt)
{
#define t2s(t_) \
case Buffer::MapType::t_: \
return #t_;
switch (mt)
{
t2s(Read);
t2s(Write);
t2s(WriteDiscard);
default:
FALCOR_UNREACHABLE();
return "";
}
#undef t2s
}
} // namespace Falcor
2 changes: 1 addition & 1 deletion Source/Falcor/Core/API/CopyContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ void CopyContext::ReadTextureTask::getData(void* pData, size_t size) const
mpFence->wait();

uint8_t* pDst = reinterpret_cast<uint8_t*>(pData);
const uint8_t* pSrc = reinterpret_cast<const uint8_t*>(mpBuffer->map(Buffer::MapType::Read));
const uint8_t* pSrc = reinterpret_cast<const uint8_t*>(mpBuffer->map());

for (uint32_t z = 0; z < mDepth; z++)
{
Expand Down
2 changes: 1 addition & 1 deletion Source/Falcor/Core/API/GpuTimer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ double GpuTimer::getElapsedTime()
if (mDataPending)
{
uint64_t result[2];
uint64_t* pRes = (uint64_t*)mpResolveStagingBuffer->map(Buffer::MapType::Read);
uint64_t* pRes = (uint64_t*)mpResolveStagingBuffer->map();
result[0] = pRes[0];
result[1] = pRes[1];
mpResolveStagingBuffer->unmap();
Expand Down
18 changes: 18 additions & 0 deletions Source/Falcor/Core/API/RenderContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ void RenderContext::raytrace(Program* pProgram, RtProgramVars* pVars, uint32_t w

void RenderContext::resolveSubresource(const ref<Texture>& pSrc, uint32_t srcSubresource, const ref<Texture>& pDst, uint32_t dstSubresource)
{
// TODO it would be better to just use barriers on the subresources.
resourceBarrier(pSrc.get(), Resource::State::ResolveSource);
resourceBarrier(pDst.get(), Resource::State::ResolveDest);

auto resourceEncoder = getLowLevelData()->getResourceCommandEncoder();
gfx::SubresourceRange srcRange = {};
srcRange.baseArrayLayer = pSrc->getSubresourceArraySlice(srcSubresource);
Expand All @@ -570,13 +574,27 @@ void RenderContext::resolveSubresource(const ref<Texture>& pSrc, uint32_t srcSub

void RenderContext::resolveResource(const ref<Texture>& pSrc, const ref<Texture>& pDst)
{
FALCOR_CHECK(pSrc->getType() == Resource::Type::Texture2DMultisample, "Source texture must be multi-sampled.");
FALCOR_CHECK(pDst->getType() == Resource::Type::Texture2D, "Destination texture must not be multi-sampled.");
FALCOR_CHECK(pSrc->getFormat() == pDst->getFormat(), "Source and destination textures must have the same format.");
FALCOR_CHECK(
pSrc->getWidth() == pDst->getWidth() && pSrc->getHeight() == pDst->getHeight(),
"Source and destination textures must have the same dimensions."
);
FALCOR_CHECK(pSrc->getArraySize() == pDst->getArraySize(), "Source and destination textures must have the same array size.");
FALCOR_CHECK(pSrc->getMipCount() == pDst->getMipCount(), "Source and destination textures must have the same mip count.");

resourceBarrier(pSrc.get(), Resource::State::ResolveSource);
resourceBarrier(pDst.get(), Resource::State::ResolveDest);

auto resourceEncoder = getLowLevelData()->getResourceCommandEncoder();

gfx::SubresourceRange srcRange = {};
srcRange.layerCount = pSrc->getArraySize();
srcRange.mipLevelCount = pSrc->getMipCount();
gfx::SubresourceRange dstRange = {};
dstRange.layerCount = pDst->getArraySize();
dstRange.mipLevelCount = pDst->getMipCount();

resourceEncoder->resolveResource(
pSrc->getGfxTextureResource(),
Expand Down
14 changes: 9 additions & 5 deletions Source/Falcor/Core/API/Texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,8 @@ ref<Texture> Texture::createMippedFromFiles(
ref<Device> pDevice,
fstd::span<const std::filesystem::path> paths,
bool loadAsSrgb,
ResourceBindFlags bindFlags
ResourceBindFlags bindFlags,
Bitmap::ImportFlags importFlags
)
{
std::vector<Bitmap::UniqueConstPtr> mips;
Expand All @@ -281,7 +282,7 @@ ref<Texture> Texture::createMippedFromFiles(
}
else
{
pBitmap = Bitmap::createFromFile(path, kTopDown);
pBitmap = Bitmap::createFromFile(path, kTopDown, importFlags);
}
if (!pBitmap)
{
Expand Down Expand Up @@ -335,14 +336,15 @@ ref<Texture> Texture::createMippedFromFiles(
if (loadAsSrgb)
texFormat = linearToSrgbFormat(texFormat);

// Create mip mapped latent texture
// Create mip mapped texture.
pTex =
pDevice->createTexture2D(mips[0]->getWidth(), mips[0]->getHeight(), texFormat, 1, mips.size(), combinedData.get(), bindFlags);
}

if (pTex != nullptr)
{
pTex->setSourcePath(fullPathMip0);
pTex->mImportFlags = importFlags;

// Log debug info.
std::string str = fmt::format(
Expand All @@ -364,7 +366,8 @@ ref<Texture> Texture::createFromFile(
const std::filesystem::path& path,
bool generateMipLevels,
bool loadAsSrgb,
ResourceBindFlags bindFlags
ResourceBindFlags bindFlags,
Bitmap::ImportFlags importFlags
)
{
if (!std::filesystem::exists(path))
Expand All @@ -387,7 +390,7 @@ ref<Texture> Texture::createFromFile(
}
else
{
Bitmap::UniqueConstPtr pBitmap = Bitmap::createFromFile(path, kTopDown);
Bitmap::UniqueConstPtr pBitmap = Bitmap::createFromFile(path, kTopDown, importFlags);
if (pBitmap)
{
ResourceFormat texFormat = pBitmap->getFormat();
Expand All @@ -411,6 +414,7 @@ ref<Texture> Texture::createFromFile(
if (pTex != nullptr)
{
pTex->setSourcePath(path);
pTex->mImportFlags = importFlags;

// Log debug info.
std::string str = fmt::format(
Expand Down
14 changes: 12 additions & 2 deletions Source/Falcor/Core/API/Texture.h
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,15 @@ class FALCOR_API Texture : public Resource
* @param[in] paths List of full paths of all mips, starting from mip0.
* @param[in] loadAsSrgb Load the texture using sRGB format. Only valid for 3 or 4 component textures.
* @param[in] bindFlags The bind flags to create the texture with.
* @param[in] importFlags Optional flags for the file import.
* @return A new texture, or nullptr if the texture failed to load.
*/
static ref<Texture> createMippedFromFiles(
ref<Device> pDevice,
fstd::span<const std::filesystem::path> paths,
bool loadAsSrgb,
ResourceBindFlags bindFlags = ResourceBindFlags::ShaderResource
ResourceBindFlags bindFlags = ResourceBindFlags::ShaderResource,
Bitmap::ImportFlags importFlags = Bitmap::ImportFlags::None
);

/**
Expand All @@ -181,14 +183,16 @@ class FALCOR_API Texture : public Resource
* @param[in] generateMipLevels Whether the mip-chain should be generated.
* @param[in] loadAsSrgb Load the texture using sRGB format. Only valid for 3 or 4 component textures.
* @param[in] bindFlags The bind flags to create the texture with.
* @param[in] importFlags Optional flags for the file import.
* @return A new texture, or nullptr if the texture failed to load.
*/
static ref<Texture> createFromFile(
ref<Device> pDevice,
const std::filesystem::path& path,
bool generateMipLevels,
bool loadAsSrgb,
ResourceBindFlags bindFlags = ResourceBindFlags::ShaderResource
ResourceBindFlags bindFlags = ResourceBindFlags::ShaderResource,
Bitmap::ImportFlags importFlags = Bitmap::ImportFlags::None
);

gfx::ITextureResource* getGfxTextureResource() const { return mGfxTextureResource; }
Expand Down Expand Up @@ -306,6 +310,11 @@ class FALCOR_API Texture : public Resource
*/
const std::filesystem::path& getSourcePath() const { return mSourcePath; }

/**
* In case the texture was loaded from a file, get the import flags used.
*/
Bitmap::ImportFlags getImportFlags() const { return mImportFlags; }

/**
* Returns the total number of texels across all mip levels and array slices.
*/
Expand All @@ -329,6 +338,7 @@ class FALCOR_API Texture : public Resource

bool mReleaseRtvsAfterGenMips = true;
std::filesystem::path mSourcePath;
Bitmap::ImportFlags mImportFlags = Bitmap::ImportFlags::None; ///< Flags used for import if loaded from file.

ResourceFormat mFormat = ResourceFormat::Unknown;
uint32_t mWidth = 0;
Expand Down
2 changes: 1 addition & 1 deletion Source/Falcor/Core/SampleApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
#include "Utils/Scripting/Scripting.h"
#include "Utils/Scripting/ScriptBindings.h"
#include "Utils/UI/TextRenderer.h"
#include "Utils/Settings.h"
#include "Utils/Settings/Settings.h"
#include "Utils/StringUtils.h"

#include <imgui.h>
Expand Down
File renamed without changes.
Loading

0 comments on commit a271dd1

Please sign in to comment.