Skip to content

Commit 9dc819c

Browse files
Falcor 8.0
Co-authored-by: Tomas Davidovic <[email protected]>
1 parent de2d654 commit 9dc819c

File tree

303 files changed

+10393
-2401
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

303 files changed

+10393
-2401
lines changed

.editorconfig

+3
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,6 @@ insert_final_newline = true
1515
# Override trailing whitespace setting for Markdown since there it's actually useful
1616
[*.{md}]
1717
trim_trailing_whitespace = false
18+
19+
[*.{yml,yaml}]
20+
indent_size = 2

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@
3030
*.mp4
3131
*.tlog
3232
*.bak
33+
*.swp

CMakeLists.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,11 @@ file(TO_NATIVE_PATH ${output_dir} output_dir)
349349

350350
if(FALCOR_WINDOWS)
351351
add_custom_target(deploy_dependencies ALL
352-
COMMAND ${CMAKE_SOURCE_DIR}/build_scripts/deploycommon.bat ${source_dir} ${output_dir} $<CONFIG> ${FALCOR_SLANG_CONFIG} ${FALCOR_DLSS_DIR}
352+
COMMAND ${CMAKE_SOURCE_DIR}/build_scripts/deploycommon.bat ${source_dir} ${output_dir} $<CONFIG> ${FALCOR_SLANG_DIR} ${FALCOR_DLSS_DIR}
353353
)
354354
elseif(FALCOR_LINUX)
355355
add_custom_target(deploy_dependencies ALL
356-
COMMAND ${CMAKE_SOURCE_DIR}/build_scripts/deploycommon.sh ${source_dir} ${output_dir} $<CONFIG> ${FALCOR_SLANG_CONFIG} ${FALCOR_DLSS_DIR}
356+
COMMAND ${CMAKE_SOURCE_DIR}/build_scripts/deploycommon.sh ${source_dir} ${output_dir} $<CONFIG> ${FALCOR_SLANG_DIR} ${FALCOR_DLSS_DIR}
357357
)
358358
endif()
359359
set_target_properties(deploy_dependencies PROPERTIES FOLDER "Misc")

CMakePresets.json

+1-4
Original file line numberDiff line numberDiff line change
@@ -69,15 +69,12 @@
6969
"hidden": true,
7070
"inherits": "windows-base",
7171
"generator": "Ninja Multi-Config",
72-
"environment": {
73-
"VCToolsVersion": "14.30"
74-
},
7572
"architecture": {
7673
"value": "x64",
7774
"strategy": "external"
7875
},
7976
"toolset": {
80-
"value": "host=x86,version=14.3",
77+
"value": "host=x86,v143",
8178
"strategy": "external"
8279
},
8380
"cacheVariables": {

Source/Falcor/CMakeLists.txt

+11-2
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ target_sources(Falcor PRIVATE
239239
Rendering/Materials/IsotropicGGX.slang
240240
Rendering/Materials/LayeredBSDF.slang
241241
Rendering/Materials/LobeType.slang
242+
Rendering/Materials/MaterialInstanceHints.slang
242243
Rendering/Materials/MERLCommon.slang
243244
Rendering/Materials/MERLMaterialInstance.slang
244245
Rendering/Materials/MERLMaterial.slang
@@ -326,6 +327,8 @@ target_sources(Falcor PRIVATE
326327
Scene/Importer.h
327328
Scene/ImporterError.h
328329
Scene/Intersection.slang
330+
Scene/IScene.cpp
331+
Scene/IScene.h
329332
Scene/MeshIO.cs.slang
330333
Scene/NullTrace.cs.slang
331334
Scene/Raster.slang
@@ -352,6 +355,7 @@ target_sources(Falcor PRIVATE
352355
Scene/TriangleMesh.cpp
353356
Scene/TriangleMesh.h
354357
Scene/VertexAttrib.slangh
358+
Scene/VertexData.slang
355359

356360
Scene/Animation/Animatable.cpp
357361
Scene/Animation/Animatable.h
@@ -392,6 +396,7 @@ target_sources(Falcor PRIVATE
392396
Scene/Lights/EnvMap.slang
393397
Scene/Lights/EnvMapData.slang
394398
Scene/Lights/FinalizeIntegration.cs.slang
399+
Scene/Lights/ILightCollection.h
395400
Scene/Lights/Light.cpp
396401
Scene/Lights/Light.h
397402
Scene/Lights/LightCollection.cpp
@@ -558,6 +563,7 @@ target_sources(Falcor PRIVATE
558563
Utils/Properties.h
559564
Utils/SharedCache.h
560565
Utils/SlangUtils.slang
566+
Utils/SplitBuffer.h
561567
Utils/StringFormatters.h
562568
Utils/StringUtils.cpp
563569
Utils/StringUtils.h
@@ -639,6 +645,7 @@ target_sources(Falcor PRIVATE
639645
Utils/Math/MathHelpers.h
640646
Utils/Math/MathHelpers.slang
641647
Utils/Math/Matrix.h
648+
Utils/Math/MatrixJson.h
642649
Utils/Math/MatrixMath.h
643650
Utils/Math/MatrixTypes.h
644651
Utils/Math/MatrixUtils.slang
@@ -652,11 +659,13 @@ target_sources(Falcor PRIVATE
652659
Utils/Math/Ray.slang
653660
Utils/Math/Rectangle.cpp
654661
Utils/Math/Rectangle.h
662+
Utils/Math/ScalarJson.h
655663
Utils/Math/ScalarMath.h
656664
Utils/Math/ScalarTypes.h
657665
Utils/Math/ShadingFrame.slang
658666
Utils/Math/SphericalHarmonics.slang
659667
Utils/Math/Vector.h
668+
Utils/Math/VectorJson.h
660669
Utils/Math/VectorMath.h
661670
Utils/Math/VectorTypes.h
662671

@@ -820,8 +829,8 @@ target_compile_options(Falcor
820829
# Configure warnings
821830
/WX # warnings as errors
822831
/W4 # increase warning level
832+
/wd4819 # the file contains a character that cannot be represented in the current code page(936)
823833
/wd4251 # 'type' : class 'type1' needs to have dll-interface to be used by clients of class 'type2'
824-
/wd4819 # The file contains a character that cannot be represented in the current code page(936)
825834
/wd4244 # 'conversion' conversion from 'type1' to 'type2', possible loss of data
826835
/wd4267 # 'var' : conversion from 'size_t' to 'type', possible loss of data
827836
/wd4100 # unreferenced formal parameter
@@ -947,6 +956,7 @@ target_compile_definitions(Falcor
947956
FALCOR_HAS_D3D12_AGILITY_SDK=$<BOOL:${FALCOR_HAS_D3D12_AGILITY_SDK}>
948957
# TODO: RTXDI is always available, we might want to remove the feature flag.
949958
FALCOR_HAS_RTXDI=1
959+
IMGUI_USER_CONFIG="Utils/UI/ImGuiConfig.h"
950960
PRIVATE
951961
#$<$<CONFIG:Debug>:_ITERATOR_DEBUG_LEVEL=0>
952962
FALCOR_PROJECT_DIR="${CMAKE_SOURCE_DIR}/"
@@ -989,7 +999,6 @@ target_link_libraries(Falcor
989999
$<$<PLATFORM_ID:Linux>:gtk3>
9901000
)
9911001

992-
9931002
target_include_directories(Falcor
9941003
PUBLIC
9951004
${CMAKE_CURRENT_SOURCE_DIR}

Source/Falcor/Core/API/Buffer.cpp

+52-33
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/***************************************************************************
2-
# Copyright (c) 2015-23, NVIDIA CORPORATION. All rights reserved.
2+
# Copyright (c) 2015-24, NVIDIA CORPORATION. All rights reserved.
33
#
44
# Redistribution and use in source and binary forms, with or without
55
# modification, are permitted provided that the following conditions
@@ -28,6 +28,7 @@
2828
#include "Buffer.h"
2929
#include "Device.h"
3030
#include "GFXAPI.h"
31+
#include "GFXHelpers.h"
3132
#include "NativeHandleTraits.h"
3233
#include "PythonHelpers.h"
3334
#include "Core/Error.h"
@@ -47,9 +48,18 @@ namespace Falcor
4748
// TODO: Replace with include?
4849
void getGFXResourceState(ResourceBindFlags flags, gfx::ResourceState& defaultState, gfx::ResourceStateSet& allowedStates);
4950

50-
static void prepareGFXBufferDesc(gfx::IBufferResource::Desc& bufDesc, size_t size, ResourceBindFlags bindFlags, MemoryType memoryType)
51+
static void prepareGFXBufferDesc(
52+
gfx::IBufferResource::Desc& bufDesc,
53+
size_t size,
54+
size_t elementSize,
55+
ResourceFormat format,
56+
ResourceBindFlags bindFlags,
57+
MemoryType memoryType
58+
)
5159
{
5260
bufDesc.sizeInBytes = size;
61+
bufDesc.elementSize = elementSize;
62+
bufDesc.format = getGFXFormat(format);
5363
switch (memoryType)
5464
{
5565
case MemoryType::DeviceLocal:
@@ -74,6 +84,8 @@ Slang::ComPtr<gfx::IBufferResource> createBufferResource(
7484
ref<Device> pDevice,
7585
Buffer::State initState,
7686
size_t size,
87+
size_t elementSize,
88+
ResourceFormat format,
7789
ResourceBindFlags bindFlags,
7890
MemoryType memoryType
7991
)
@@ -82,7 +94,7 @@ Slang::ComPtr<gfx::IBufferResource> createBufferResource(
8294

8395
// Create the buffer
8496
gfx::IBufferResource::Desc bufDesc = {};
85-
prepareGFXBufferDesc(bufDesc, size, bindFlags, memoryType);
97+
prepareGFXBufferDesc(bufDesc, size, elementSize, format, bindFlags, memoryType);
8698

8799
Slang::ComPtr<gfx::IBufferResource> pApiHandle;
88100
FALCOR_GFX_CALL(pDevice->getGfxDevice()->createBufferResource(bufDesc, nullptr, pApiHandle.writeRef()));
@@ -91,24 +103,31 @@ Slang::ComPtr<gfx::IBufferResource> createBufferResource(
91103
return pApiHandle;
92104
}
93105

94-
Buffer::Buffer(ref<Device> pDevice, size_t size, ResourceBindFlags bindFlags, MemoryType memoryType, const void* pInitData)
106+
Buffer::Buffer(
107+
ref<Device> pDevice,
108+
size_t size,
109+
size_t structSize,
110+
ResourceFormat format,
111+
ResourceBindFlags bindFlags,
112+
MemoryType memoryType,
113+
const void* pInitData
114+
)
95115
: Resource(pDevice, Type::Buffer, bindFlags, size), mMemoryType(memoryType)
96116
{
97117
FALCOR_CHECK(size > 0, "Can't create GPU buffer of size zero");
98118

99119
// Check that buffer size is within 4GB limit. Larger buffers are currently not well supported in D3D12.
100120
// TODO: Revisit this check in the future.
101-
if (size > (1ull << 32))
102-
{
103-
logWarning("Creating GPU buffer of size {} bytes. Buffers above 4GB are not currently well supported.", size);
104-
}
121+
FALCOR_CHECK(size <= (1ull << 32), "Creating GPU buffer of size {} bytes. Buffers above 4GB are not currently well supported.", size);
105122

106123
if (mMemoryType != MemoryType::DeviceLocal && is_set(mBindFlags, ResourceBindFlags::Shared))
107124
{
108125
FALCOR_THROW("Can't create shared resource with CPU access other than 'None'.");
109126
}
110127

111128
mSize = align_to(mpDevice->getBufferDataAlignment(bindFlags), mSize);
129+
mStructSize = structSize;
130+
mFormat = format;
112131

113132
if (mMemoryType == MemoryType::DeviceLocal)
114133
{
@@ -125,14 +144,18 @@ Buffer::Buffer(ref<Device> pDevice, size_t size, ResourceBindFlags bindFlags, Me
125144
mState.global = Resource::State::CopyDest;
126145
}
127146

128-
mGfxBufferResource = createBufferResource(mpDevice, mState.global, mSize, mBindFlags, mMemoryType);
147+
mGfxBufferResource = createBufferResource(mpDevice, mState.global, mSize, mStructSize, mFormat, mBindFlags, mMemoryType);
129148

130149
if (pInitData)
131150
setBlob(pInitData, 0, size);
132151

133152
mElementCount = uint32_t(size);
134153
}
135154

155+
Buffer::Buffer(ref<Device> pDevice, size_t size, ResourceBindFlags bindFlags, MemoryType memoryType, const void* pInitData)
156+
: Buffer(pDevice, size, 0, ResourceFormat::Unknown, bindFlags, memoryType, pInitData)
157+
{}
158+
136159
Buffer::Buffer(
137160
ref<Device> pDevice,
138161
ResourceFormat format,
@@ -141,9 +164,8 @@ Buffer::Buffer(
141164
MemoryType memoryType,
142165
const void* pInitData
143166
)
144-
: Buffer(pDevice, (size_t)getFormatBytesPerBlock(format) * elementCount, bindFlags, memoryType, pInitData)
167+
: Buffer(pDevice, (size_t)getFormatBytesPerBlock(format) * elementCount, 0, format, bindFlags, memoryType, pInitData)
145168
{
146-
mFormat = format;
147169
mElementCount = elementCount;
148170
}
149171

@@ -156,20 +178,28 @@ Buffer::Buffer(
156178
const void* pInitData,
157179
bool createCounter
158180
)
159-
: Buffer(pDevice, (size_t)structSize * elementCount, bindFlags, memoryType, pInitData)
181+
: Buffer(pDevice, (size_t)structSize * elementCount, structSize, ResourceFormat::Unknown, bindFlags, memoryType, pInitData)
160182
{
161183
mElementCount = elementCount;
162-
mStructSize = structSize;
163184
static const uint32_t zero = 0;
164185
if (createCounter)
165186
{
166-
mpUAVCounter = make_ref<Buffer>(mpDevice, sizeof(uint32_t), ResourceBindFlags::UnorderedAccess, MemoryType::DeviceLocal, &zero);
187+
FALCOR_CHECK(mStructSize > 0, "Can't create a counter buffer with struct size of 0.");
188+
mpUAVCounter = make_ref<Buffer>(
189+
mpDevice,
190+
sizeof(uint32_t),
191+
sizeof(uint32_t),
192+
ResourceFormat::Unknown,
193+
ResourceBindFlags::UnorderedAccess,
194+
MemoryType::DeviceLocal,
195+
&zero
196+
);
167197
}
168198
}
169199

170200
// TODO: Its wasteful to create a buffer just to replace it afterwards with the supplied one!
171201
Buffer::Buffer(ref<Device> pDevice, gfx::IBufferResource* pResource, size_t size, ResourceBindFlags bindFlags, MemoryType memoryType)
172-
: Buffer(pDevice, size, bindFlags, memoryType, nullptr)
202+
: Buffer(pDevice, size, 0, ResourceFormat::Unknown, bindFlags, memoryType, nullptr)
173203
{
174204
FALCOR_ASSERT(pResource);
175205
mGfxBufferResource = pResource;
@@ -184,7 +214,7 @@ inline Slang::ComPtr<gfx::IBufferResource> gfxResourceFromNativeHandle(
184214
)
185215
{
186216
gfx::IBufferResource::Desc bufDesc = {};
187-
prepareGFXBufferDesc(bufDesc, size, bindFlags, memoryType);
217+
prepareGFXBufferDesc(bufDesc, size, 0, ResourceFormat::Unknown, bindFlags, memoryType);
188218

189219
gfx::InteropHandle gfxNativeHandle = {};
190220
#if FALCOR_HAS_D3D12
@@ -225,12 +255,12 @@ gfx::IResource* Buffer::getGfxResource() const
225255
return mGfxBufferResource;
226256
}
227257

228-
ref<ShaderResourceView> Buffer::getSRV(uint32_t firstElement, uint32_t elementCount)
258+
ref<ShaderResourceView> Buffer::getSRV(uint64_t offset, uint64_t size)
229259
{
230-
ResourceViewInfo view = ResourceViewInfo(firstElement, elementCount);
260+
ResourceViewInfo view = ResourceViewInfo(offset, size);
231261

232262
if (mSrvs.find(view) == mSrvs.end())
233-
mSrvs[view] = ShaderResourceView::create(getDevice().get(), this, firstElement, elementCount);
263+
mSrvs[view] = ShaderResourceView::create(getDevice().get(), this, offset, size);
234264

235265
return mSrvs[view];
236266
}
@@ -240,12 +270,12 @@ ref<ShaderResourceView> Buffer::getSRV()
240270
return getSRV(0);
241271
}
242272

243-
ref<UnorderedAccessView> Buffer::getUAV(uint32_t firstElement, uint32_t elementCount)
273+
ref<UnorderedAccessView> Buffer::getUAV(uint64_t offset, uint64_t size)
244274
{
245-
ResourceViewInfo view = ResourceViewInfo(firstElement, elementCount);
275+
ResourceViewInfo view = ResourceViewInfo(offset, size);
246276

247277
if (mUavs.find(view) == mUavs.end())
248-
mUavs[view] = UnorderedAccessView::create(getDevice().get(), this, firstElement, elementCount);
278+
mUavs[view] = UnorderedAccessView::create(getDevice().get(), this, offset, size);
249279

250280
return mUavs[view];
251281
}
@@ -323,16 +353,6 @@ void Buffer::unmap() const
323353
}
324354
}
325355

326-
uint32_t Buffer::getElementSize() const
327-
{
328-
if (mStructSize != 0)
329-
return mStructSize;
330-
if (mFormat == ResourceFormat::Unknown)
331-
return 1;
332-
333-
FALCOR_THROW("Inferring element size from resource format is not implemented");
334-
}
335-
336356
bool Buffer::adjustSizeOffsetParams(size_t& size, size_t& offset) const
337357
{
338358
if (offset >= mSize)
@@ -455,7 +475,6 @@ FALCOR_SCRIPT_BINDING(Buffer)
455475
buffer.def_property_readonly("is_typed", &Buffer::isTyped);
456476
buffer.def_property_readonly("is_structured", &Buffer::isStructured);
457477
buffer.def_property_readonly("format", &Buffer::getFormat);
458-
buffer.def_property_readonly("element_size", &Buffer::getElementSize);
459478
buffer.def_property_readonly("element_count", &Buffer::getElementCount);
460479
buffer.def_property_readonly("struct_size", &Buffer::getStructSize);
461480

0 commit comments

Comments
 (0)