Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
3cdc3a9e
P
pbrt-v4
项目概览
imjiangjun
/
pbrt-v4
11 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
pbrt-v4
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
3cdc3a9e
编写于
7月 30, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ParsedScene: create (some) lights asynchronously
上级
dea86d6a
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
60 addition
and
27 deletion
+60
-27
src/pbrt/cpu/render.cpp
src/pbrt/cpu/render.cpp
+1
-2
src/pbrt/scene.cpp
src/pbrt/scene.cpp
+50
-17
src/pbrt/scene.h
src/pbrt/scene.h
+8
-7
src/pbrt/wavefront/integrator.cpp
src/pbrt/wavefront/integrator.cpp
+1
-1
未找到文件。
src/pbrt/cpu/render.cpp
浏览文件 @
3cdc3a9e
...
...
@@ -79,8 +79,7 @@ void RenderCPU(ParsedScene &parsedScene) {
// Lights
std
::
map
<
int
,
pstd
::
vector
<
Light
>
*>
shapeIndexToAreaLights
;
std
::
vector
<
Light
>
lights
=
parsedScene
.
CreateLights
(
alloc
,
media
,
textures
,
&
shapeIndexToAreaLights
);
std
::
vector
<
Light
>
lights
=
parsedScene
.
CreateLights
(
textures
,
&
shapeIndexToAreaLights
);
LOG_VERBOSE
(
"Starting materials"
);
std
::
map
<
std
::
string
,
pbrt
::
Material
>
namedMaterials
;
...
...
src/pbrt/scene.cpp
浏览文件 @
3cdc3a9e
...
...
@@ -797,7 +797,30 @@ void ParsedScene::AddSpectrumTexture(std::string name, TextureSceneEntity textur
void
ParsedScene
::
AddLight
(
LightSceneEntity
light
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
lightMutex
);
lights
.
push_back
(
std
::
move
(
light
));
if
(
!
light
.
medium
.
empty
())
{
// If the light has a medium associated with it, punt for now since
// the Medium may not yet be initialized; these lights will be
// taken care of when CreateLights() is called. At the cost of
// some complexity, we could check and see if it's already in the
// medium map and wait for its in-flight future if it's not yet
// ready, though the most important case here is probably infinite
// image lights and those can't have media associated with them
// anyway...
lightsWithMedia
.
push_back
(
std
::
move
(
light
));
return
;
}
if
(
light
.
renderFromObject
.
IsAnimated
())
Warning
(
&
light
.
loc
,
"Animated lights aren't supported. Using the start transform."
);
auto
create
=
[
this
](
LightSceneEntity
light
)
{
return
Light
::
Create
(
light
.
name
,
light
.
parameters
,
light
.
renderFromObject
.
startTransform
,
camera
.
cameraTransform
,
nullptr
/* Medium */
,
&
light
.
loc
,
threadAllocators
.
Get
());
};
lightFutures
.
push_back
(
RunAsync
(
create
,
light
));
}
int
ParsedScene
::
AddAreaLight
(
SceneEntity
light
)
{
...
...
@@ -875,10 +898,10 @@ void ParsedScene::Done() {
}
LOG_VERBOSE
(
"Scene stats: %d shapes, %d animated shapes, %d instance definitions, "
"%d instance uses, %d
lights, %d
float textures, %d spectrum textures, "
"%d instance uses, %d float textures, %d spectrum textures, "
"%d named materials, %d materials"
,
shapes
.
size
(),
animatedShapes
.
size
(),
instanceDefinitions
.
size
(),
instances
.
size
(),
lights
.
size
(),
floatTextures
.
size
(),
instances
.
size
(),
floatTextures
.
size
(),
spectrumTextures
.
size
(),
namedMaterials
.
size
(),
materials
.
size
());
// And complain about what's left.
...
...
@@ -1131,33 +1154,38 @@ NamedTextures ParsedScene::CreateTextures(ThreadLocal<Allocator> &threadAllocato
return
textures
;
}
std
::
map
<
std
::
string
,
Medium
>
ParsedScene
::
CreateMedia
()
const
{
std
::
map
<
std
::
string
,
Medium
>
mediaMap
;
std
::
map
<
std
::
string
,
Medium
>
ParsedScene
::
CreateMedia
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
mediaMutex
)
;
LOG_VERBOSE
(
"Consume media futures start"
);
for
(
auto
&
m
:
mediaFutures
)
for
(
auto
&
m
:
mediaFutures
)
{
CHECK
(
mediaMap
.
find
(
m
.
first
)
==
mediaMap
.
end
());
mediaMap
[
m
.
first
]
=
m
.
second
.
Get
();
LOG_VERBOSE
(
"Consume media futures finished"
);
}
mediaFutures
.
clear
();
LOG_VERBOSE
(
"Consume media futures finished"
);
return
mediaMap
;
}
std
::
vector
<
Light
>
ParsedScene
::
CreateLights
(
Allocator
alloc
,
const
std
::
map
<
std
::
string
,
Medium
>
&
media
,
const
NamedTextures
&
textures
,
std
::
map
<
int
,
pstd
::
vector
<
Light
>
*>
*
shapeIndexToAreaLights
)
{
auto
findMedium
=
[
&
media
](
const
std
::
string
&
s
,
const
FileLoc
*
loc
)
->
Medium
{
// Ensure that media are all ready
(
void
)
CreateMedia
();
auto
findMedium
=
[
this
](
const
std
::
string
&
s
,
const
FileLoc
*
loc
)
->
Medium
{
if
(
s
.
empty
())
return
nullptr
;
auto
iter
=
media
.
find
(
s
);
if
(
iter
==
media
.
end
())
auto
iter
=
media
Map
.
find
(
s
);
if
(
iter
==
media
Map
.
end
())
ErrorExit
(
loc
,
"%s: medium not defined"
,
s
);
return
iter
->
second
;
};
Allocator
alloc
=
threadAllocators
.
Get
();
auto
getAlphaTexture
=
[
&
](
const
ParameterDictionary
&
parameters
,
const
FileLoc
*
loc
)
->
FloatTexture
{
std
::
string
alphaTexName
=
parameters
.
GetTexture
(
"alpha"
);
...
...
@@ -1178,11 +1206,11 @@ std::vector<Light> ParsedScene::CreateLights(
return
nullptr
;
};
// Lights (area lights will be done later, with shapes...)
LOG_VERBOSE
(
"Starting lights"
);
LOG_VERBOSE
(
"Starting non-future lights"
);
std
::
vector
<
Light
>
lights
;
lights
.
reserve
(
lights
.
size
()
+
areaLights
.
size
());
for
(
const
auto
&
light
:
this
->
lights
)
{
// Lights with media (punted in AddLight() earlier.)
for
(
const
auto
&
light
:
lightsWithMedia
)
{
Medium
outsideMedium
=
findMedium
(
light
.
medium
,
&
light
.
loc
);
if
(
light
.
renderFromObject
.
IsAnimated
())
Warning
(
&
light
.
loc
,
...
...
@@ -1243,8 +1271,13 @@ std::vector<Light> ParsedScene::CreateLights(
(
*
shapeIndexToAreaLights
)[
i
]
=
shapeLights
;
}
LOG_VERBOSE
(
"Finished non-future lights"
);
LOG_VERBOSE
(
"Starting to consume non-area light futures"
);
for
(
auto
&
fut
:
lightFutures
)
lights
.
push_back
(
fut
.
Get
());
LOG_VERBOSE
(
"Finished consuming non-area light futures"
);
LOG_VERBOSE
(
"Finished Lights"
);
return
lights
;
}
...
...
src/pbrt/scene.h
浏览文件 @
3cdc3a9e
...
...
@@ -334,11 +334,9 @@ class ParsedScene : public SceneProcessor {
std
::
map
<
std
::
string
,
Material
>
*
namedMaterials
,
std
::
vector
<
Material
>
*
materials
)
const
;
std
::
map
<
std
::
string
,
Medium
>
CreateMedia
()
const
;
std
::
map
<
std
::
string
,
Medium
>
CreateMedia
();
std
::
vector
<
Light
>
CreateLights
(
Allocator
alloc
,
const
std
::
map
<
std
::
string
,
Medium
>
&
media
,
const
NamedTextures
&
textures
,
std
::
vector
<
Light
>
CreateLights
(
const
NamedTextures
&
textures
,
std
::
map
<
int
,
pstd
::
vector
<
Light
>
*>
*
shapeIndexToAreaLights
);
Primitive
CreateAggregate
(
...
...
@@ -359,8 +357,6 @@ class ParsedScene : public SceneProcessor {
std
::
map
<
std
::
string
,
TransformedSceneEntity
>
media
;
std
::
vector
<
std
::
pair
<
std
::
string
,
TextureSceneEntity
>>
floatTextures
;
std
::
vector
<
std
::
pair
<
std
::
string
,
TextureSceneEntity
>>
spectrumTextures
;
std
::
vector
<
LightSceneEntity
>
lights
;
std
::
vector
<
SceneEntity
>
areaLights
;
std
::
vector
<
ShapeSceneEntity
>
shapes
;
std
::
vector
<
AnimatedShapeSceneEntity
>
animatedShapes
;
std
::
vector
<
InstanceSceneEntity
>
instances
;
...
...
@@ -369,7 +365,12 @@ class ParsedScene : public SceneProcessor {
private:
ThreadLocal
<
Allocator
>
&
threadAllocators
;
mutable
std
::
map
<
std
::
string
,
Future
<
Medium
>>
mediaFutures
;
std
::
map
<
std
::
string
,
Future
<
Medium
>>
mediaFutures
;
std
::
map
<
std
::
string
,
Medium
>
mediaMap
;
std
::
vector
<
LightSceneEntity
>
lightsWithMedia
;
std
::
vector
<
Future
<
Light
>>
lightFutures
;
std
::
vector
<
SceneEntity
>
areaLights
;
std
::
mutex
namedMaterialMutex
,
materialMutex
,
mediaMutex
;
std
::
mutex
floatTextureMutex
,
spectrumTextureMutex
;
...
...
src/pbrt/wavefront/integrator.cpp
浏览文件 @
3cdc3a9e
...
...
@@ -152,7 +152,7 @@ WavefrontPathIntegrator::WavefrontPathIntegrator(
std
::
map
<
int
,
pstd
::
vector
<
Light
>
*>
shapeIndexToAreaLights
;
infiniteLights
=
alloc
.
new_object
<
pstd
::
vector
<
Light
>>
(
alloc
);
for
(
Light
l
:
scene
.
CreateLights
(
alloc
,
media
,
textures
,
&
shapeIndexToAreaLights
))
{
for
(
Light
l
:
scene
.
CreateLights
(
textures
,
&
shapeIndexToAreaLights
))
{
if
(
l
.
Is
<
UniformInfiniteLight
>
()
||
l
.
Is
<
ImageInfiniteLight
>
()
||
l
.
Is
<
PortalImageInfiniteLight
>
())
infiniteLights
->
push_back
(
l
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录