Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Source/Falcor/Scene/GVDB/gvdbNodes.slang
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ VDBNode getNodeUnrolledThreeLevel(VDBInfo gvdb, int mipId, int lev, int start_id

{
vmax = vmin + 4096.f;
if (any((pos < vmin) || (pos >= vmax)))
if (any(pos < vmin) || any(pos >= vmax))
{
node_id = ID_UNDEFL;
return {};
Expand All @@ -202,7 +202,7 @@ VDBNode getNodeUnrolledThreeLevel(VDBInfo gvdb, int mipId, int lev, int start_id

{
vmax = vmin + 128.f;
if (any((pos < vmin) || (pos >= vmax)))
if (any(pos < vmin) || any(pos >= vmax))
{
node_id = ID_UNDEFL;
return {};
Expand Down Expand Up @@ -234,7 +234,7 @@ VDBNode getNodeUnrolledTwoLevel(VDBInfo gvdb, int mipId, int lev, int start_id,

{
vmax = vmin + 128.f;
if (any((pos < vmin) || (pos >= vmax)))
if (any(pos < vmin) || any(pos >= vmax))
{
node_id = ID_UNDEFL;
return {};
Expand Down
6 changes: 3 additions & 3 deletions Source/Falcor/Utils/Algorithm/ComputeParallelReduction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,9 @@ namespace Falcor

// Check that reduction type T is compatible with the resource format.
if (sizeof(typename T::value_type) != 4 || // The shader is written for 32-bit types
(formatType == FORMAT_TYPE_FLOAT && !std::is_floating_point<T::value_type>::value) ||
(formatType == FORMAT_TYPE_SINT && (!std::is_integral<T::value_type>::value || !std::is_signed<T::value_type>::value)) ||
(formatType == FORMAT_TYPE_UINT && (!std::is_integral<T::value_type>::value || !std::is_unsigned<T::value_type>::value)))
(formatType == FORMAT_TYPE_FLOAT && !std::is_floating_point<typename T::value_type>::value) ||
(formatType == FORMAT_TYPE_SINT && (!std::is_integral<typename T::value_type>::value || !std::is_signed<typename T::value_type>::value)) ||
(formatType == FORMAT_TYPE_UINT && (!std::is_integral<typename T::value_type>::value || !std::is_unsigned<typename T::value_type>::value)))
{
logError("ComputeParallelReduction::execute() - Template type T is not compatible with resource format. Aborting.");
return false;
Expand Down
9 changes: 7 additions & 2 deletions Source/Falcor/Utils/Helpers.slang
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,16 @@ float3 computeRayOrigin(float3 pos, float3 normal)

// Per-component integer offset to bit representation of fp32 position.
int3 iOff = int3(normal * iScale);
float3 iPos = asfloat(asint(pos) + (pos < 0.f ? -iOff : iOff));
float3 iPos = asfloat(asint(pos) + int3(pos.x < 0.f ? -iOff.x : iOff.x,
pos.y < 0.f ? -iOff.y : iOff.y,
pos.z < 0.f ? -iOff.z : iOff.z));

// Select per-component between small fixed offset or above variable offset depending on distance to origin.
float3 fOff = normal * fScale;
return abs(pos) < origin ? pos + fOff : iPos;
bool3 s = abs(pos) < origin;
return float3(s.x ? pos.x + fOff.x : iPos.x,
s.y ? pos.y + fOff.y : iPos.y,
s.z ? pos.z + fOff.z : iPos.z);
}

/** Ray-sphere intersection.
Expand Down
2 changes: 1 addition & 1 deletion Source/Falcor/Utils/Math/MathHelpers.slang
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ float3 latlong_map_to_world(float2 uv)
*/
float2 oct_wrap(float2 v)
{
return (1.f - abs(v.yx)) * (v.xy >= 0.f ? 1.f : -1.f);
return (1.f - abs(v.yx)) * float2(v.x >= 0.f ? 1.f : -1.f, v.y >= 0.f ? 1.f : -1.f);
}

/** Converts normalized direction to the octahedral map (non-equal area, signed normalized).
Expand Down
14 changes: 7 additions & 7 deletions Source/Falcor/Utils/UI/Gui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -753,19 +753,19 @@ namespace Falcor
template<typename T>
bool GuiImpl::addVecVar(const char label[], T& var, typename T::value_type minVal, typename T::value_type maxVal, float step, bool sameLine, const char* displayFormat)
{
if (std::is_same<T::value_type, int32_t>::value)
if (std::is_same<typename T::value_type, int32_t>::value)
{
return addVecVarHelper(label, var, ImGuiDataType_S32, minVal, maxVal, step, sameLine, displayFormat);
}
else if (std::is_same<T::value_type, uint32_t>::value)
else if (std::is_same<typename T::value_type, uint32_t>::value)
{
return addVecVarHelper(label, var, ImGuiDataType_U32, minVal, maxVal, step, sameLine, displayFormat);
}
else if (std::is_same<T::value_type, float>::value)
else if (std::is_same<typename T::value_type, float>::value)
{
return addVecVarHelper(label, var, ImGuiDataType_Float, minVal, maxVal, step, sameLine, displayFormat);
}
else if (std::is_same<T::value_type, uint64_t>::value)
else if (std::is_same<typename T::value_type, uint64_t>::value)
{
return addVecVarHelper(label, var, ImGuiDataType_U64, minVal, maxVal, step, sameLine, displayFormat);
}
Expand All @@ -789,15 +789,15 @@ namespace Falcor
template<typename T>
bool GuiImpl::addVecSlider(const char label[], T& var, typename T::value_type minVal, typename T::value_type maxVal, bool sameLine, const char* displayFormat)
{
if (std::is_same<T::value_type, int32_t>::value)
if (std::is_same<typename T::value_type, int32_t>::value)
{
return addVecSliderHelper(label, var, ImGuiDataType_S32, minVal, maxVal, sameLine, displayFormat);
}
else if (std::is_same<T::value_type, uint32_t>::value)
else if (std::is_same<typename T::value_type, uint32_t>::value)
{
return addVecSliderHelper(label, var, ImGuiDataType_U32, minVal, maxVal, sameLine, displayFormat);
}
else if (std::is_same<T::value_type, float>::value)
else if (std::is_same<typename T::value_type, float>::value)
{
return addVecSliderHelper(label, var, ImGuiDataType_Float, minVal, maxVal, sameLine, displayFormat);
}
Expand Down
2 changes: 1 addition & 1 deletion Source/RenderPasses/VolumetricReSTIR/FinalShading.cs.slang
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ void main(uint3 DTid : SV_DispatchThreadID)

pixelPos = DTid.xy;

if (any(isnan(curColor) || isinf(curColor))) curColor = 0.f;
if (any(isnan(curColor)) || any(isinf(curColor))) curColor = 0.f;

gOutputFrame[pixelPos] = curColor;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ struct MediumTrAnalyticAdapterGVDB : IVolumeTrackingAdapterGVDB

dda_leaf.PrepareLeaf(vmin_leaf);

for (int iter = 0; iter < MAX_BRICK_STEPS && all(dda_leaf.p >= 0 && dda_leaf.p < gvdb.res[mipLevel * 3]); iter++)
for (int iter = 0; iter < MAX_BRICK_STEPS && all(dda_leaf.p >= 0) && all(dda_leaf.p < gvdb.res[mipLevel * 3]); iter++)
{
// compute the next step location, but don't step yet
dda_leaf.Next();
Expand Down Expand Up @@ -181,7 +181,7 @@ struct MediumTrRayMarchingAdapterGVDB : IVolumeTrackingAdapterGVDB
float3 p = wp - vmin_leaf; // Sample point in sub-volume (in units of voxels)
const float3 wpt = tStepMultipler * tStep * ray.dir;

for (int iter = 0; iter < MAX_BRICK_STEPS && all(p >= 0 && p < gvdb.res[mipLevel * 3]); iter++)
for (int iter = 0; iter < MAX_BRICK_STEPS && all(p >= 0) && all(p < gvdb.res[mipLevel * 3]); iter++)
{
if (t >= tFar)
{
Expand Down Expand Up @@ -271,7 +271,7 @@ struct SampleMediumAnalyticAdapterGVDB : IVolumeTrackingAdapterGVDB
HDDAState dda_leaf = dda;
dda_leaf.PrepareLeaf(vmin_leaf);

for (int iter = 0; iter < MAX_BRICK_STEPS && all(dda_leaf.p >= 0 && dda_leaf.p < gvdb.res[mipLevel * 3]); iter++)
for (int iter = 0; iter < MAX_BRICK_STEPS && all(dda_leaf.p >= 0) && all(dda_leaf.p < gvdb.res[mipLevel * 3]); iter++)
{
// compute the next step location, but don't step yet
dda_leaf.Next();
Expand Down Expand Up @@ -472,7 +472,7 @@ struct SampleVolumeCellByDensityAdapterGVDB : IVolumeTrackingAdapterGVDB
HDDAState dda_leaf = dda;
dda_leaf.PrepareLeaf(vmin_leaf);

for (int iter = 0; iter < MAX_BRICK_STEPS && all(dda_leaf.p >= 0 && dda_leaf.p < gvdb.res[mipLevel * 3]); iter++)
for (int iter = 0; iter < MAX_BRICK_STEPS && all(dda_leaf.p >= 0) && all(dda_leaf.p < gvdb.res[mipLevel * 3]); iter++)
{
// find density
float density = DensityInAtlas(dda_leaf.p + o + 0.5f, mipLevel, false);
Expand Down Expand Up @@ -561,7 +561,7 @@ struct ReservoirFeatureRayMarchingAdapterGVDB : IVolumeTrackingAdapterGVDB
float3 p = wp - vmin_leaf; // Sample point in sub-volume (in units of voxels)
const float3 wpt = tStep * ray.dir;

for (int iter = 0; iter < MAX_BRICK_STEPS && all(p >= 0 && p < gvdb.res[mipLevel * 3]); iter++)
for (int iter = 0; iter < MAX_BRICK_STEPS && all(p >= 0) && all(p < gvdb.res[mipLevel * 3]); iter++)
{
float curTransmittance = exp(Tr);
if (curTransmittance < 0.01f)
Expand Down
4 changes: 2 additions & 2 deletions Source/RenderPasses/VolumetricReSTIR/VolumeUtils.slang
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void VolumeTrackingGVDB<VolumeTrackingAdapterGVDB:IVolumeTrackingAdapterGVDB>(Ra
if (vertexCenter)
{
int iter = 0;
while (iter++<3 && (any(dda.p < 0 || dda.p > gvdb.res[lev + mipLevel * 3]))) // guarantee that the point "enters"
while (iter++<3 && any(dda.p < 0) || any(dda.p > gvdb.res[lev + mipLevel * 3])) // guarantee that the point "enters"
{
dda.Next();
dda.Step();
Expand All @@ -228,7 +228,7 @@ void VolumeTrackingGVDB<VolumeTrackingAdapterGVDB:IVolumeTrackingAdapterGVDB>(Ra

float Tr = 0.f;

for (; iter < 4096 && lev > 0 && lev <= topLev && all(dda.p >= 0 && dda.p <= gvdb.res[lev + mipLevel * 3]); iter++) {
for (; iter < 4096 && lev > 0 && lev <= topLev && all(dda.p >= 0) && all(dda.p <= gvdb.res[lev + mipLevel * 3]); iter++) {

dda.Next();

Expand Down
5 changes: 4 additions & 1 deletion Source/Tools/FalcorTest/Tests/Core/BufferTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace Falcor
StructuredBuffer = 2,
};

// static_assert must depend on template parameter, otherwise it will be evaluated before template instantiation (and always evaluate false)
template <Type...> inline constexpr bool alwaysFalse = false;

template <Type type>
void testBuffer(GPUUnitTestContext& ctx, uint32_t numElems, uint32_t index = 0, uint32_t count = 0)
{
Expand All @@ -63,7 +66,7 @@ namespace Falcor
if constexpr (type == Type::ByteAddressBuffer) pBuffer = Buffer::create(numElems * sizeof(uint32_t), ResourceBindFlags::UnorderedAccess, Buffer::CpuAccess::None);
else if constexpr (type == Type::TypedBuffer) pBuffer = Buffer::createTyped<uint32_t>(numElems, ResourceBindFlags::UnorderedAccess);
else if constexpr (type == Type::StructuredBuffer) pBuffer = Buffer::createStructured(ctx.getProgram(), "buffer", numElems, ResourceBindFlags::UnorderedAccess);
else static_assert(false);
else static_assert(alwaysFalse);

ctx["buffer"] = pBuffer;

Expand Down
17 changes: 17 additions & 0 deletions Source/slangdconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"slang.predefinedMacros": [
"SAMPLE_GENERATOR_TYPE=SAMPLE_GENERATOR_UNIFORM",

"MAX_BOUNCES=2",
"SURFACE_SCENE",
"VBUFFERDECLARE=VBufferItem vItem,",
"VBUFFERITEM=vItem,",
"VERTEX_REUSE",
"REUSETYPE=inout"

],
"slang.additionalSearchPaths": [
"./",
"./Falcor"
]
}