Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
imjiangjun
pbrt-v4
提交
faac34d1
P
pbrt-v4
项目概览
imjiangjun
/
pbrt-v4
12 个月 前同步成功
通知
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,发现更多精彩内容 >>
提交
faac34d1
编写于
10月 22, 2021
作者:
M
Matt Pharr
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Switch to std::hash for default hasher for InternCache
上级
4607f0e4
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
53 addition
and
35 deletion
+53
-35
src/pbrt/lights.cpp
src/pbrt/lights.cpp
+4
-6
src/pbrt/lights.h
src/pbrt/lights.h
+14
-2
src/pbrt/lightsamplers.h
src/pbrt/lightsamplers.h
+3
-9
src/pbrt/lightsamplers_test.cpp
src/pbrt/lightsamplers_test.cpp
+2
-2
src/pbrt/scene.h
src/pbrt/scene.h
+1
-6
src/pbrt/util/containers.h
src/pbrt/util/containers.h
+1
-1
src/pbrt/util/spectrum.h
src/pbrt/util/spectrum.h
+14
-7
src/pbrt/util/transform.h
src/pbrt/util/transform.h
+14
-2
未找到文件。
src/pbrt/lights.cpp
浏览文件 @
faac34d1
...
...
@@ -76,20 +76,18 @@ std::string LightBase::BaseToString() const {
mediumInterface
,
renderFromLight
);
}
InternCache
<
DenselySampledSpectrum
,
DenselySampledSpectrum
::
Hash
>
*
LightBase
::
spectrumCache
;
InternCache
<
DenselySampledSpectrum
>
*
LightBase
::
spectrumCache
;
const
DenselySampledSpectrum
*
LightBase
::
LookupSpectrum
(
Spectrum
s
)
{
// Initialize _spectrumCache_ on first call
static
std
::
mutex
mutex
;
mutex
.
lock
();
if
(
!
spectrumCache
)
spectrumCache
=
new
InternCache
<
DenselySampledSpectrum
,
DenselySampledSpectrum
::
Hash
>
(
spectrumCache
=
new
InternCache
<
DenselySampledSpectrum
>
(
#ifdef PBRT_BUILD_GPU_RENDERER
Options
->
useGPU
?
Allocator
(
&
CUDATrackedMemoryResource
::
singleton
)
:
Options
->
useGPU
?
Allocator
(
&
CUDATrackedMemoryResource
::
singleton
)
:
#endif
Allocator
{});
Allocator
{});
mutex
.
unlock
();
// Return unique _DenselySampledSpectrum_ from intern cache for _s_
...
...
src/pbrt/lights.h
浏览文件 @
faac34d1
...
...
@@ -25,6 +25,7 @@
#include <pbrt/util/transform.h>
#include <pbrt/util/vecmath.h>
#include <functional>
#include <memory>
#include <string>
...
...
@@ -181,8 +182,7 @@ class LightBase {
LightType
type
;
Transform
renderFromLight
;
MediumInterface
mediumInterface
;
static
InternCache
<
DenselySampledSpectrum
,
DenselySampledSpectrum
::
Hash
>
*
spectrumCache
;
static
InternCache
<
DenselySampledSpectrum
>
*
spectrumCache
;
};
// PointLight Definition
...
...
@@ -822,4 +822,16 @@ inline LightType Light::Type() const {
}
// namespace pbrt
namespace
std
{
template
<
>
struct
hash
<
pbrt
::
Light
>
{
PBRT_CPU_GPU
size_t
operator
()(
pbrt
::
Light
light
)
const
noexcept
{
return
pbrt
::
Hash
(
light
.
ptr
());
}
};
}
// namespace std
#endif // PBRT_LIGHTS_H
src/pbrt/lightsamplers.h
浏览文件 @
faac34d1
...
...
@@ -22,12 +22,6 @@
namespace
pbrt
{
// LightHash Definition
struct
LightHash
{
PBRT_CPU_GPU
size_t
operator
()(
Light
light
)
const
{
return
Hash
(
light
.
ptr
());
}
};
// UniformLightSampler Definition
class
UniformLightSampler
{
public:
...
...
@@ -100,7 +94,7 @@ class PowerLightSampler {
private:
// PowerLightSampler Private Members
pstd
::
vector
<
Light
>
lights
;
HashMap
<
Light
,
size_t
,
LightHash
>
lightToIndex
;
HashMap
<
Light
,
size_t
>
lightToIndex
;
AliasTable
aliasTable
;
};
...
...
@@ -406,7 +400,7 @@ class BVHLightSampler {
pstd
::
vector
<
Light
>
infiniteLights
;
Bounds3f
allLightBounds
;
pstd
::
vector
<
LightBVHNode
>
nodes
;
HashMap
<
Light
,
uint32_t
,
LightHash
>
lightToBitTrail
;
HashMap
<
Light
,
uint32_t
>
lightToBitTrail
;
};
// ExhaustiveLightSampler Definition
...
...
@@ -441,7 +435,7 @@ class ExhaustiveLightSampler {
private:
pstd
::
vector
<
Light
>
lights
,
boundedLights
,
infiniteLights
;
pstd
::
vector
<
LightBounds
>
lightBounds
;
HashMap
<
Light
,
size_t
,
LightHash
>
lightToBoundedIndex
;
HashMap
<
Light
,
size_t
>
lightToBoundedIndex
;
};
inline
pstd
::
optional
<
SampledLight
>
LightSampler
::
Sample
(
const
LightSampleContext
&
ctx
,
...
...
src/pbrt/lightsamplers_test.cpp
浏览文件 @
faac34d1
...
...
@@ -68,7 +68,7 @@ TEST(BVHLightSampling, OneSpot) {
TEST
(
BVHLightSampling
,
Point
)
{
RNG
rng
;
std
::
vector
<
Light
>
lights
;
std
::
unordered_map
<
Light
,
int
,
LightHash
>
lightToIndex
;
std
::
unordered_map
<
Light
,
int
>
lightToIndex
;
ConstantSpectrum
one
(
1.
f
);
for
(
int
i
=
0
;
i
<
33
;
++
i
)
{
// Random point in [-5, 5]
...
...
@@ -116,7 +116,7 @@ TEST(BVHLightSampling, PointVaryPower) {
std
::
vector
<
Float
>
lightPower
;
std
::
vector
<
std
::
unique_ptr
<
ConstantSpectrum
>>
lightSpectra
;
Float
sumPower
=
0
;
std
::
unordered_map
<
Light
,
int
,
LightHash
>
lightToIndex
;
std
::
unordered_map
<
Light
,
int
>
lightToIndex
;
for
(
int
i
=
0
;
i
<
82
;
++
i
)
{
// Random point in [-5, 5]
Vector3f
p
{
Lerp
(
rng
.
Uniform
<
Float
>
(),
-
5
,
5
),
Lerp
(
rng
.
Uniform
<
Float
>
(),
-
5
,
5
),
...
...
src/pbrt/scene.h
浏览文件 @
faac34d1
...
...
@@ -221,11 +221,6 @@ struct InstanceSceneEntity {
const
Transform
*
renderFromInstance
=
nullptr
;
};
// TransformHash Definition
struct
TransformHash
{
size_t
operator
()(
const
Transform
&
t
)
const
{
return
t
.
Hash
();
}
};
// MaxTransforms Definition
constexpr
int
MaxTransforms
=
2
;
...
...
@@ -494,7 +489,7 @@ class BasicSceneBuilder : public ParserTarget {
static
constexpr
int
AllTransformsBits
=
(
1
<<
MaxTransforms
)
-
1
;
std
::
map
<
std
::
string
,
TransformSet
>
namedCoordinateSystems
;
class
Transform
renderFromWorld
;
InternCache
<
class
Transform
,
TransformHash
>
transformCache
;
InternCache
<
class
Transform
>
transformCache
;
std
::
vector
<
GraphicsState
>
pushedGraphicsStates
;
std
::
vector
<
std
::
pair
<
char
,
FileLoc
>>
pushStack
;
// 'a': attribute, 'o': object
struct
ActiveInstanceDefinition
{
...
...
src/pbrt/util/containers.h
浏览文件 @
faac34d1
...
...
@@ -621,7 +621,7 @@ class InlinedVector {
};
// HashMap Definition
template
<
typename
Key
,
typename
Value
,
typename
Hash
,
template
<
typename
Key
,
typename
Value
,
typename
Hash
=
std
::
hash
<
Key
>
,
typename
Allocator
=
pstd
::
pmr
::
polymorphic_allocator
<
pstd
::
optional
<
std
::
pair
<
Key
,
Value
>>>>
class
HashMap
{
...
...
src/pbrt/util/spectrum.h
浏览文件 @
faac34d1
...
...
@@ -22,6 +22,7 @@
#include <algorithm>
#include <cmath>
#include <functional>
#include <memory>
#include <numeric>
#include <string>
...
...
@@ -448,14 +449,8 @@ class DenselySampledSpectrum {
return
true
;
}
struct
Hash
{
size_t
operator
()(
const
DenselySampledSpectrum
&
s
)
const
{
return
HashBuffer
(
s
.
values
.
data
(),
s
.
values
.
size
());
}
};
private:
friend
struct
Hash
;
friend
struct
std
::
hash
<
pbrt
::
DenselySampledSpectrum
>
;
// DenselySampledSpectrum Private Members
int
lambda_min
,
lambda_max
;
pstd
::
vector
<
Float
>
values
;
...
...
@@ -793,4 +788,16 @@ inline Float Spectrum::MaxValue() const {
}
// namespace pbrt
namespace
std
{
template
<
>
struct
hash
<
pbrt
::
DenselySampledSpectrum
>
{
PBRT_CPU_GPU
size_t
operator
()(
const
pbrt
::
DenselySampledSpectrum
&
s
)
const
{
return
pbrt
::
HashBuffer
(
s
.
values
.
data
(),
s
.
values
.
size
());
}
};
}
// namespace std
#endif // PBRT_UTIL_SPECTRUM_H
src/pbrt/util/transform.h
浏览文件 @
faac34d1
...
...
@@ -16,6 +16,7 @@
#include <stdio.h>
#include <cmath>
#include <functional>
#include <limits>
#include <memory>
...
...
@@ -35,8 +36,6 @@ class Transform {
template
<
typename
T
>
PBRT_CPU_GPU
inline
Normal3
<
T
>
ApplyInverse
(
Normal3
<
T
>
)
const
;
uint64_t
Hash
()
const
{
return
HashBuffer
<
sizeof
(
m
)
>
(
&
m
);
}
std
::
string
ToString
()
const
;
Transform
()
=
default
;
...
...
@@ -538,4 +537,17 @@ class AnimatedTransform {
}
// namespace pbrt
namespace
std
{
template
<
>
struct
hash
<
pbrt
::
Transform
>
{
PBRT_CPU_GPU
size_t
operator
()(
const
pbrt
::
Transform
&
t
)
const
{
pbrt
::
SquareMatrix
<
4
>
m
=
t
.
GetMatrix
();
return
pbrt
::
HashBuffer
<
sizeof
(
m
)
>
(
&
m
);
}
};
}
// namespace std
#endif // PBRT_UTIL_TRANSFORM_H
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录