Skip to content

Comments

Created a new example to test the compilation and concepts of samplers#252

Open
karimsayedre wants to merge 2 commits intomasterfrom
sampler-concepts
Open

Created a new example to test the compilation and concepts of samplers#252
karimsayedre wants to merge 2 commits intomasterfrom
sampler-concepts

Conversation

@karimsayedre
Copy link

No description provided.

Comment on lines 1 to 35
// Compile test: instantiate sampling types to verify DXC compilation
#include <nbl/builtin/hlsl/sampling/concentric_mapping.hlsl>
#include <nbl/builtin/hlsl/sampling/linear.hlsl>
#include <nbl/builtin/hlsl/sampling/bilinear.hlsl>
#include <nbl/builtin/hlsl/sampling/uniform_spheres.hlsl>
#include <nbl/builtin/hlsl/sampling/cos_weighted_spheres.hlsl>
#include <nbl/builtin/hlsl/sampling/box_muller_transform.hlsl>
#include <nbl/builtin/hlsl/sampling/spherical_triangle.hlsl>
#include <nbl/builtin/hlsl/sampling/projected_spherical_triangle.hlsl>
#include <nbl/builtin/hlsl/sampling/spherical_rectangle.hlsl>
using namespace nbl::hlsl;

[[vk::binding(0, 0)]] RWStructuredBuffer<float32_t4> output;

[numthreads(1, 1, 1)] void main()
{
float32_t2 u2 = float32_t2(0.5, 0.5);
float32_t3 u3 = float32_t3(0.5, 0.5, 0.5);
float32_t4 acc = float32_t4(0, 0, 0, 0);

// concentric mapping (free function)
float32_t2 concentric = sampling::concentricMapping<float32_t>(u2);
acc.xy += concentric;

// Linear
sampling::Linear<float32_t> lin = sampling::Linear<float32_t>::create(u2);
acc.x += lin.generate(0.5f);

// Bilinear
sampling::Bilinear<float32_t> bilinear = sampling::Bilinear<float32_t>::create(float32_t4(1, 2, 3, 4));
float32_t rcpPdf;
float32_t2 bilSample = bilinear.generate(rcpPdf, u2);
acc.xy += bilSample;
acc.z += rcpPdf;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you use the Testing harness introduced by @Przemog1 to actually run this with some random number seed and compare results between CPU and GPU

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually lets turn it up to 11, and make a benchmark of samplers, requires one entry point & pipelineper sampler though to have meaningful tests for spilling, register usage etc.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you also need a unit test which does Jacobian testing on all Bijective Samplers

CMakeLists.txt Outdated
endif()

add_subdirectory(74_QuantizedSequenceTests)
add_subdirectory(75_HLSLSamplingTests)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the example should have a low number like the BxDF unit tests, since its so foundational (actually bXdfs depend somewhat on the samplers - at least the basic projected hemisphere and sphere ones)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't want to collide with other examples, 37 is good?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants