Skip to content

Commit

Permalink
minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
cuteday committed Nov 18, 2023
1 parent 78b8cce commit 8232ae4
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 11 deletions.
5 changes: 2 additions & 3 deletions src/core/device/context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,8 @@ void Context::initialize() {
// set up context
const int deviceID = 0;
CUDA_CHECK(cudaSetDevice(deviceID));
//CUDA_CHECK(cudaStreamCreate(&cudaStream));
cudaStream = 0;

CUDA_CHECK(cudaStreamCreate(&cudaStream));

cudaGetDeviceProperties(&deviceProps, deviceID);
Log(Success, "KiRaRay is running on " + string(deviceProps.name));
if (!deviceProps.concurrentManagedAccess)
Expand Down
13 changes: 6 additions & 7 deletions src/render/wavefront/integrator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,7 @@ void WavefrontPathTracer::traceShadow() {
params.colorSpace = KRR_DEFAULT_COLORSPACE;
params.shadowRayQueue = shadowRayQueue;
params.pixelState = pixelState;
if(enableMedium) backend->launch(params, "ShadowTr", maxQueueSize, 1, 1);
else backend->launch(params, "Shadow", maxQueueSize, 1, 1);
backend->launch(params, enableMedium ? "ShadowTr" : "Shadow", maxQueueSize, 1, 1);
}

void WavefrontPathTracer::handleHit() {
Expand All @@ -80,25 +79,25 @@ void WavefrontPathTracer::handleHit() {
Le /= (w.pl * lightPdf + w.pu).mean();
} else Le /= w.pu.mean();
pixelState->addRadiance(w.pixelId, Le);
});
}, gpContext->cudaStream);
}

void WavefrontPathTracer::handleMiss() {
PROFILE("Process escaped rays");
const rt::SceneData &sceneData = mScene->mSceneRT->getSceneData();
const auto &infiniteLights = backend->getSceneData().infiniteLights;
ForAllQueued(
missRayQueue, maxQueueSize, KRR_DEVICE_LAMBDA(const MissRayWorkItem &w) {
Spectrum L = {};
SampledWavelengths lambda = pixelState->lambda[w.pixelId];
Interaction intr(w.ray.origin);
for (const rt::InfiniteLight &light : sceneData.infiniteLights) {
for (const rt::InfiniteLight &light : infiniteLights) {
if (enableNEE && w.depth && !(w.bsdfType & BSDF_SPECULAR)) {
float lightPdf = light.pdfLi(intr, w.ctx) * lightSampler.pdf(&light);
L += light.Li(w.ray.dir, lambda) / (w.pu + w.pl * lightPdf).mean();
} else L += light.Li(w.ray.dir, lambda) / w.pu.mean();
}
pixelState->addRadiance(w.pixelId, w.thp * L);
});
}, gpContext->cudaStream);
}

void WavefrontPathTracer::generateScatterRays(int depth) {
Expand Down Expand Up @@ -155,7 +154,7 @@ void WavefrontPathTracer::generateScatterRays(int depth) {
r.thp = w.thp * sample.f * fabs(sample.wi[2]) / sample.pdf;
if (any(r.thp)) nextRayQueue(depth)->push(r);
}
});
}, gpContext->cudaStream);
}

void WavefrontPathTracer::generateCameraRays(int sampleId) {
Expand Down
2 changes: 1 addition & 1 deletion src/render/wavefront/integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class WavefrontPathTracer : public RenderPass {
void render(RenderContext *context) override;
void renderUI() override;

void initialize();
void initialize() override;

string getName() const override { return "WavefrontPathTracer"; }

Expand Down

0 comments on commit 8232ae4

Please sign in to comment.