Skip to content

Commit 6e7d6d6

Browse files
committed
Merge branch 'shader_pipeline' into BallotBitCountTest
2 parents d1b2a97 + e7a536b commit 6e7d6d6

File tree

66 files changed

+5853
-4471
lines changed

Some content is hidden

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

66 files changed

+5853
-4471
lines changed

3rdparty/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ update_git_submodule(./openssl)
3434
update_git_submodule(./libjpeg-turbo)
3535
update_git_submodule(./libjpeg) # soon to be killed
3636
update_git_submodule(./parallel-hashmap)
37+
update_git_submodule(./gli)
3738
# exceptions that get automatically cloned
3839
update_git_submodule(./glm)
3940
update_git_submodule(./freetype2)
@@ -454,6 +455,9 @@ if (IRR_COMPILE_WITH_CUDA)
454455
endif()
455456

456457
set(IRR_3RDPARTY_TARGETS
458+
RadeonRays
459+
CLW
460+
Calc
457461
lzma
458462
lz4
459463
aesGladman
@@ -507,4 +511,4 @@ install(
507511
DIRECTORY ./parallel-hashmap/parallel_hashmap
508512
DESTINATION ./relwithdebinfo/include/parallel-hashmap
509513
CONFIGURATIONS RelWithDebInfo
510-
)
514+
)

examples_tests/18.MitsubaLoader/main.cpp

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,11 @@ layout(set = 2, binding = 1) uniform sampler2D envMap;
3535
layout(set = 2, binding = 2) uniform usamplerBuffer sampleSequence;
3636
layout(set = 2, binding = 3) uniform usampler2D scramblebuf;
3737
38-
vec2 rand2d(in uint _sample, inout irr_glsl_xoroshiro64star_state_t scramble_state)
38+
vec3 rand3d(in uint _sample, inout irr_glsl_xoroshiro64star_state_t scramble_state)
3939
{
40-
uvec2 seqVal = texelFetch(sampleSequence,int(_sample)).xy;
41-
seqVal ^= uvec2(irr_glsl_xoroshiro64star(scramble_state),irr_glsl_xoroshiro64star(scramble_state));
42-
return vec2(seqVal)*uintBitsToFloat(0x2f800004u);
40+
uvec3 seqVal = texelFetch(sampleSequence,int(_sample)).xyz;
41+
seqVal ^= uvec3(irr_glsl_xoroshiro64star(scramble_state),irr_glsl_xoroshiro64star(scramble_state),irr_glsl_xoroshiro64star(scramble_state));
42+
return vec3(seqVal)*uintBitsToFloat(0x2f800004u);
4343
}
4444
4545
vec2 SampleSphericalMap(in vec3 v)
@@ -50,7 +50,7 @@ vec2 SampleSphericalMap(in vec3 v)
5050
return uv;
5151
}
5252
53-
vec3 irr_computeLighting(inout irr_glsl_IsotropicViewSurfaceInteraction out_interaction, in mat2 dUV)
53+
vec3 irr_computeLighting(inout irr_glsl_IsotropicViewSurfaceInteraction out_interaction, in mat2 dUV, in MC_precomputed_t precomp)
5454
{
5555
irr_glsl_xoroshiro64star_state_t scramble_start_state = textureLod(scramblebuf,gl_FragCoord.xy/VIEWPORT_SZ,0).rg;
5656
@@ -59,32 +59,30 @@ vec3 irr_computeLighting(inout irr_glsl_IsotropicViewSurfaceInteraction out_inte
5959
vec3 color = vec3(0.0);
6060
6161
#ifdef USE_ENVMAP
62-
instr_stream_t gcs = getGenChoiceStream();
62+
instr_stream_t gcs = getGenChoiceStream(precomp);
63+
instr_stream_t rnps = getRemAndPdfStream(precomp);
6364
for (int i = 0; i < SAMPLE_COUNT; ++i)
6465
{
6566
irr_glsl_xoroshiro64star_state_t scramble_state = scramble_start_state;
6667
67-
instr_stream_t gcs = getGenChoiceStream();
68-
instr_stream_t rnps = getRemAndPdfStream();
69-
70-
vec2 rand = rand2d(i,scramble_state);//TODO has to be 3d
68+
vec3 rand = rand3d(i,scramble_state);
7169
float pdf;
72-
runGenerateAndRemainderStream(gcs, rnps, rand, pdf);
70+
irr_glsl_LightSample s;
71+
vec3 rem = runGenerateAndRemainderStream(precomp, gcs, rnps, rand, pdf, s);
7372
74-
vec2 uv = SampleSphericalMap(L);
73+
vec2 uv = SampleSphericalMap(s.L);
7574
color += rem*textureLod(envMap, uv, 0.0).xyz;
7675
}
7776
color /= float(SAMPLE_COUNT);
7877
#endif
7978
80-
irr_glsl_BSDFIsotropicParams params;
8179
for (int i = 0; i < LIGHT_COUNT; ++i)
8280
{
8381
SLight l = lights[i];
8482
vec3 L = l.position-WorldPos;
85-
params.L = L;
83+
//params.L = L;
8684
const float intensityScale = LIGHT_INTENSITY_SCALE;//ehh might want to render to hdr fbo and do tonemapping
87-
color += irr_bsdf_cos_eval(params, out_interaction, dUV)*l.intensity*intensityScale / dot(L,L);
85+
color += irr_bsdf_cos_eval(precomp, normalize(L), out_interaction, dUV)*l.intensity*intensityScale / dot(L,L);
8886
}
8987
9088
return color+emissive;
@@ -344,7 +342,7 @@ int main()
344342
meshmetas.push_back(static_cast<const ext::MitsubaLoader::IMeshMetadata*>(cpumesh->getMetadata()));
345343
const auto& instances = meshmetas.back()->getInstances();
346344

347-
auto computeAreaAndAvgPos = [](asset::ICPUMeshBuffer* mb, const core::matrix3x4SIMD& tform, core::vectorSIMDf& _outAvgPos) {
345+
auto computeAreaAndAvgPos = [](const asset::ICPUMeshBuffer* mb, const core::matrix3x4SIMD& tform, core::vectorSIMDf& _outAvgPos) {
348346
uint32_t triCount = 0u;
349347
asset::IMeshManipulator::getPolyCount(triCount, mb);
350348
assert(triCount>0u);
@@ -392,7 +390,7 @@ int main()
392390
}
393391
}
394392

395-
constexpr uint32_t ENVMAP_SAMPLE_COUNT = 64u;
393+
constexpr uint32_t ENVMAP_SAMPLE_COUNT = 16u;
396394
constexpr float LIGHT_INTENSITY_SCALE = 0.01f;
397395

398396
core::unordered_set<const asset::ICPURenderpassIndependentPipeline*> modifiedPipelines;
@@ -440,18 +438,8 @@ int main()
440438
}
441439
}
442440

443-
auto gpuVT = core::make_smart_refctd_ptr<video::IGPUVirtualTexture>(driver, globalMeta->VT.get());
441+
//auto gpuVT = core::make_smart_refctd_ptr<video::IGPUVirtualTexture>(driver, globalMeta->VT.get());
444442
auto gpuds0 = driver->getGPUObjectsFromAssets(&cpuds0.get(), &cpuds0.get()+1)->front();
445-
{
446-
auto count = gpuVT->getDescriptorSetWrites(nullptr, nullptr, nullptr);
447-
448-
auto writes = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<video::IGPUDescriptorSet::SWriteDescriptorSet>>(count.first);
449-
auto info = core::make_refctd_dynamic_array<core::smart_refctd_dynamic_array<video::IGPUDescriptorSet::SDescriptorInfo>>(count.second);
450-
451-
gpuVT->getDescriptorSetWrites(writes->data(), info->data(), gpuds0.get());
452-
453-
driver->updateDescriptorSets(writes->size(), writes->data(), 0u, nullptr);
454-
}
455443

456444
auto gpuds1layout = driver->getGPUObjectsFromAssets(&ds1layout, &ds1layout+1)->front();
457445

@@ -477,18 +465,20 @@ int main()
477465
smart_refctd_ptr<video::IGPUBufferView> gpuSequenceBufferView;
478466
{
479467
constexpr uint32_t MaxSamples = ENVMAP_SAMPLE_COUNT;
468+
constexpr uint32_t Channels = 3u;
480469

481-
auto sampleSequence = core::make_smart_refctd_ptr<asset::ICPUBuffer>(sizeof(uint32_t) * MaxSamples*2u);
470+
auto sampleSequence = core::make_smart_refctd_ptr<asset::ICPUBuffer>(sizeof(uint32_t) * MaxSamples*Channels);
482471

483-
core::OwenSampler sampler(1u, 0xdeadbeefu);
472+
core::OwenSampler sampler(Channels, 0xdeadbeefu);
484473

485474
auto out = reinterpret_cast<uint32_t*>(sampleSequence->getPointer());
486-
for (uint32_t i = 0; i < MaxSamples*2u; i++)
475+
for (uint32_t c = 0; c < Channels; ++c)
476+
for (uint32_t i = 0; i < MaxSamples; i++)
487477
{
488-
out[i] = sampler.sample(i&1u, i>>1);
478+
out[Channels*i + c] = sampler.sample(c, i);
489479
}
490480
auto gpuSequenceBuffer = driver->createFilledDeviceLocalGPUBufferOnDedMem(sampleSequence->getSize(), sampleSequence->getPointer());
491-
gpuSequenceBufferView = driver->createGPUBufferView(gpuSequenceBuffer.get(), asset::EF_R32G32_UINT);
481+
gpuSequenceBufferView = driver->createGPUBufferView(gpuSequenceBuffer.get(), asset::EF_R32G32B32_UINT);
492482
}
493483

494484
smart_refctd_ptr<video::IGPUImageView> gpuScrambleImageView;

0 commit comments

Comments
 (0)