提交 ba5c99c9 编写于 作者: M Matt Pharr

Improve ImageTexture ToString() methods.

Implement them for GPU textures.
Include the filename for all textures.
上级 399b8c79
......@@ -375,15 +375,15 @@ SampledSpectrum SpectrumImageTexture::Evaluate(TextureEvalContext ctx,
}
std::string SpectrumImageTexture::ToString() const {
return StringPrintf(
"[ SpectrumImageTexture mapping: %s scale: %f invert: %s mipmap: %s ]", mapping,
scale, invert, *mipmap);
return StringPrintf("[ SpectrumImageTexture filename: %s mapping: %s scale: %f "
"invert: %s mipmap: %s ]",
filename, mapping, scale, invert, *mipmap);
}
std::string FloatImageTexture::ToString() const {
return StringPrintf(
"[ FloatImageTexture mapping: %s scale: %f invert: %s mipmap: %s ]", mapping,
scale, invert, *mipmap);
"[ FloatImageTexture filename: %s mapping: %s scale: %f invert: %s mipmap: %s ]",
filename, mapping, scale, invert, *mipmap);
}
std::string TexInfo::ToString() const {
......@@ -1260,8 +1260,15 @@ GPUSpectrumImageTexture *GPUSpectrumImageTexture::Create(
Float scale = parameters.GetOneFloat("scale", 1.f);
bool invert = parameters.GetOneBool("invert", false);
return alloc.new_object<GPUSpectrumImageTexture>(
mapping, texObj, scale, invert, isSingleChannel, colorSpace, spectrumType);
return alloc.new_object<GPUSpectrumImageTexture>(filename, mapping, texObj, scale,
invert, isSingleChannel, colorSpace,
spectrumType);
}
std::string GPUSpectrumImageTexture::ToString() const {
return StringPrintf(
"[ GPUSpectrumImageTexture filename: %s mapping: %s scale: %f invert: %s ]",
filename, mapping, scale, invert);
}
GPUFloatImageTexture *GPUFloatImageTexture::Create(
......@@ -1366,7 +1373,14 @@ GPUFloatImageTexture *GPUFloatImageTexture::Create(
Float scale = parameters.GetOneFloat("scale", 1.f);
bool invert = parameters.GetOneBool("invert", false);
return alloc.new_object<GPUFloatImageTexture>(mapping, texObj, scale, invert);
return alloc.new_object<GPUFloatImageTexture>(filename, mapping, texObj, scale,
invert);
}
std::string GPUFloatImageTexture::ToString() const {
return StringPrintf(
"[ GPUFloatImageTexture filename: %s mapping: %s scale: %f invert: %s ]",
filename, mapping, scale, invert);
}
#endif // PBRT_BUILD_GPU_RENDERER
......
......@@ -530,7 +530,7 @@ class ImageTextureBase {
ImageTextureBase(TextureMapping2D mapping, std::string filename,
MIPMapFilterOptions filterOptions, WrapMode wrapMode, Float scale,
bool invert, ColorEncoding encoding, Allocator alloc)
: mapping(mapping), scale(scale), invert(invert) {
: mapping(mapping), filename(filename), scale(scale), invert(invert) {
// Get _MIPMap_ from texture cache if present
TexInfo texInfo(filename, filterOptions, wrapMode, encoding);
std::unique_lock<std::mutex> lock(textureCacheMutex);
......@@ -558,6 +558,7 @@ class ImageTextureBase {
protected:
// ImageTextureBase Protected Members
TextureMapping2D mapping;
std::string filename;
Float scale;
bool invert;
MIPMap *mipmap;
......@@ -629,10 +630,12 @@ class SpectrumImageTexture : public ImageTextureBase {
#if defined(PBRT_BUILD_GPU_RENDERER) && defined(__NVCC__)
class GPUSpectrumImageTexture {
public:
GPUSpectrumImageTexture(TextureMapping2D mapping, cudaTextureObject_t texObj,
Float scale, bool invert, bool isSingleChannel,
const RGBColorSpace *colorSpace, SpectrumType spectrumType)
GPUSpectrumImageTexture(std::string filename, TextureMapping2D mapping,
cudaTextureObject_t texObj, Float scale, bool invert,
bool isSingleChannel, const RGBColorSpace *colorSpace,
SpectrumType spectrumType)
: mapping(mapping),
filename(filename),
texObj(texObj),
scale(scale),
invert(invert),
......@@ -679,11 +682,12 @@ class GPUSpectrumImageTexture {
SpectrumType spectrumType, const FileLoc *loc,
Allocator alloc);
std::string ToString() const { return "GPUSpectrumImageTexture"; }
std::string ToString() const;
void MultiplyScale(Float s) { scale *= s; }
TextureMapping2D mapping;
std::string filename;
cudaTextureObject_t texObj;
Float scale;
bool invert, isSingleChannel;
......@@ -693,9 +697,13 @@ class GPUSpectrumImageTexture {
class GPUFloatImageTexture {
public:
GPUFloatImageTexture(TextureMapping2D mapping, cudaTextureObject_t texObj,
Float scale, bool invert)
: mapping(mapping), texObj(texObj), scale(scale), invert(invert) {}
GPUFloatImageTexture(std::string filename, TextureMapping2D mapping,
cudaTextureObject_t texObj, Float scale, bool invert)
: mapping(mapping),
filename(filename),
texObj(texObj),
scale(scale),
invert(invert) {}
PBRT_CPU_GPU
Float Evaluate(TextureEvalContext ctx) const {
......@@ -718,11 +726,12 @@ class GPUFloatImageTexture {
const TextureParameterDictionary &parameters,
const FileLoc *loc, Allocator alloc);
std::string ToString() const { return "GPUFloatImageTexture"; }
std::string ToString() const;
void MultiplyScale(Float s) { scale *= s; }
TextureMapping2D mapping;
std::string filename;
cudaTextureObject_t texObj;
Float scale;
bool invert;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册