Merge changes from the witness.
This commit is contained in:
parent
95811dfdff
commit
fcd296cd81
@ -169,6 +169,17 @@ void FloatImage::clear(uint c, float f/*= 0.0f*/)
|
||||
}
|
||||
}
|
||||
|
||||
void FloatImage::copyChannel(uint src, uint dst)
|
||||
{
|
||||
nvCheck(src < m_componentCount);
|
||||
nvCheck(dst < m_componentCount);
|
||||
|
||||
const float * srcChannel = this->channel(src);
|
||||
float * dstChannel = this->channel(dst);
|
||||
|
||||
memcpy(dstChannel, srcChannel, sizeof(float)*m_pixelCount);
|
||||
}
|
||||
|
||||
void FloatImage::normalize(uint baseComponent)
|
||||
{
|
||||
nvCheck(baseComponent + 3 <= m_componentCount);
|
||||
|
@ -150,8 +150,8 @@ namespace nv {
|
||||
private:
|
||||
// don't provide operator = or == ; make the client write Store( Load() )
|
||||
NV_FORBID_COPY(Atomic);
|
||||
|
||||
NV_COMPILER_CHECK(sizeof(T) == sizeof(uint32) || sizeof(T) == sizeof(uint64));
|
||||
|
||||
NV_COMPILER_CHECK(sizeof(T) == sizeof(uint32) || sizeof(T) == sizeof(uint64));
|
||||
|
||||
T m_value;
|
||||
};
|
||||
|
@ -48,6 +48,6 @@ void Event::wait() {
|
||||
}
|
||||
|
||||
#elif NV_OS_UNIX
|
||||
// @@ TODO
|
||||
// @@ TODO
|
||||
#pragma NV_MESSAGE("Implement event using pthreads!")
|
||||
#endif
|
||||
|
@ -18,8 +18,8 @@ namespace nv
|
||||
Event();
|
||||
~Event();
|
||||
|
||||
void post();
|
||||
void wait(); // Wait resets the event.
|
||||
void post();
|
||||
void wait(); // Wait resets the event.
|
||||
|
||||
static void post(Event * events, uint count);
|
||||
static void wait(Event * events, uint count);
|
||||
|
@ -18,14 +18,14 @@ namespace nv
|
||||
Mutex ();
|
||||
~Mutex ();
|
||||
|
||||
void lock();
|
||||
bool tryLock();
|
||||
void unlock();
|
||||
void lock();
|
||||
bool tryLock();
|
||||
void unlock();
|
||||
|
||||
private:
|
||||
struct Private;
|
||||
AutoPtr<Private> m;
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
// Templated lock that can be used with any mutex.
|
||||
@ -35,8 +35,8 @@ namespace nv
|
||||
NV_FORBID_COPY(Lock);
|
||||
public:
|
||||
|
||||
Lock (M & m) : m_mutex (m) { m_mutex.lock(); }
|
||||
~Lock () { m_mutex.unlock(); }
|
||||
Lock (M & m) : m_mutex (m) { m_mutex.lock(); }
|
||||
~Lock () { m_mutex.unlock(); }
|
||||
|
||||
private:
|
||||
M & m_mutex;
|
||||
|
@ -19,21 +19,21 @@ namespace nv
|
||||
Thread();
|
||||
~Thread();
|
||||
|
||||
void start(ThreadFunc * func, void * arg);
|
||||
void wait();
|
||||
void start(ThreadFunc * func, void * arg);
|
||||
void wait();
|
||||
|
||||
bool isRunning() const;
|
||||
bool isRunning() const;
|
||||
|
||||
static void spinWait(uint count);
|
||||
static void yield();
|
||||
static void sleep(uint ms);
|
||||
static void spinWait(uint count);
|
||||
static void yield();
|
||||
static void sleep(uint ms);
|
||||
|
||||
static void wait(Thread * threads, uint count);
|
||||
static void wait(Thread * threads, uint count);
|
||||
|
||||
private:
|
||||
|
||||
struct Private;
|
||||
AutoPtr<Private> p;
|
||||
struct Private;
|
||||
AutoPtr<Private> p;
|
||||
|
||||
public: // @@ Why public? Also in private?!
|
||||
ThreadFunc * func;
|
||||
|
@ -1,8 +1,8 @@
|
||||
// This code is in the public domain -- castano@gmail.com
|
||||
|
||||
#pragma once
|
||||
#ifndef NV_THREAD_THREADPOOL_H
|
||||
#define NV_THREAD_THREADPOOL_H
|
||||
// This code is in the public domain -- castano@gmail.com
|
||||
|
||||
#pragma once
|
||||
#ifndef NV_THREAD_THREADPOOL_H
|
||||
#define NV_THREAD_THREADPOOL_H
|
||||
|
||||
#include "nvthread.h"
|
||||
|
||||
|
@ -5,10 +5,10 @@
|
||||
#include "Thread.h"
|
||||
|
||||
#if NV_OS_WIN32
|
||||
#include "Win32.h"
|
||||
#include "Win32.h"
|
||||
#elif NV_OS_UNIX
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/sysctl.h>
|
||||
#endif
|
||||
|
||||
|
||||
@ -40,12 +40,12 @@ uint nv::hardwareThreadCount() {
|
||||
sysctl(mib, 2, &numCPU, &len, NULL, 0);
|
||||
|
||||
if (numCPU < 1) {
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl( mib, 2, &numCPU, &len, NULL, 0 );
|
||||
mib[1] = HW_NCPU;
|
||||
sysctl( mib, 2, &numCPU, &len, NULL, 0 );
|
||||
|
||||
if (numCPU < 1) {
|
||||
return 1; // Assume single core.
|
||||
}
|
||||
if (numCPU < 1) {
|
||||
return 1; // Assume single core.
|
||||
}
|
||||
}
|
||||
|
||||
return numCPU;
|
||||
|
@ -152,6 +152,26 @@ int Compressor::estimateSize(const TexImage & tex, int mipmapCount, const Compre
|
||||
return estimateSize(w, h, d, mipmapCount, compressionOptions);
|
||||
}
|
||||
|
||||
bool Compressor::outputHeader(const CubeImage & cube, int mipmapCount, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const
|
||||
{
|
||||
return m.outputHeader(TextureType_Cube, cube.size(), cube.size(), 1, mipmapCount, false, compressionOptions.m, outputOptions.m);
|
||||
}
|
||||
|
||||
bool Compressor::compress(const CubeImage & cube, int mipmap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const
|
||||
{
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if(!m.compress(cube.face(i), i, mipmap, compressionOptions.m, outputOptions.m)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int Compressor::estimateSize(const CubeImage & cube, int mipmapCount, const CompressionOptions & compressionOptions) const
|
||||
{
|
||||
return 6 * estimateSize(cube.size(), cube.size(), 1, mipmapCount, compressionOptions);
|
||||
}
|
||||
|
||||
|
||||
// Raw API.
|
||||
bool Compressor::outputHeader(TextureType type, int w, int h, int d, int mipmapCount, bool isNormalMap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const
|
||||
|
@ -87,32 +87,57 @@ TexImage & CubeImage::face(int f)
|
||||
return m->face[f];
|
||||
}
|
||||
|
||||
const TexImage & CubeImage::face(int f) const
|
||||
{
|
||||
nvDebugCheck(f >= 0 && f < 6);
|
||||
return m->face[f];
|
||||
}
|
||||
|
||||
|
||||
bool CubeImage::load(const char * fileName)
|
||||
{
|
||||
// @@ TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CubeImage::save(const char * fileName) const
|
||||
{
|
||||
// @@ TODO
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
void CubeImage::fold(const TexImage & tex, CubeLayout layout)
|
||||
{
|
||||
|
||||
// @@ TODO
|
||||
}
|
||||
|
||||
TexImage CubeImage::unfold(CubeLayout layout)
|
||||
TexImage CubeImage::unfold(CubeLayout layout) const
|
||||
{
|
||||
|
||||
// @@ TODO
|
||||
return TexImage();
|
||||
}
|
||||
|
||||
|
||||
CubeImage CubeImage::irradianceFilter(int size) const
|
||||
{
|
||||
// @@ TODO
|
||||
return CubeImage();
|
||||
}
|
||||
|
||||
CubeImage CubeImage::cosinePowerFilter(int size, float cosinePower) const
|
||||
{
|
||||
// @@ TODO
|
||||
return CubeImage();
|
||||
}
|
||||
|
||||
|
||||
void CubeImage::toLinear(float gamma)
|
||||
{
|
||||
if (isNull()) return;
|
||||
|
||||
detach();
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
m->face[i].toLinear(gamma);
|
||||
}
|
||||
@ -120,6 +145,10 @@ void CubeImage::toLinear(float gamma)
|
||||
|
||||
void CubeImage::toGamma(float gamma)
|
||||
{
|
||||
if (isNull()) return;
|
||||
|
||||
detach();
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
m->face[i].toGamma(gamma);
|
||||
}
|
||||
|
@ -1224,8 +1224,7 @@ void TexImage::toRGBM(float range/*= 1*/, float threshold/*= 0.25*/)
|
||||
|
||||
detach();
|
||||
|
||||
//threshold = clamp(threshold, 1e-6f, 1.0f);
|
||||
threshold = 1e-6f;
|
||||
threshold = ::clamp(threshold, 1e-6f, 1.0f);
|
||||
float irange = 1.0f / range;
|
||||
|
||||
FloatImage * img = m->image;
|
||||
|
@ -68,6 +68,7 @@ namespace nvtt
|
||||
{
|
||||
// Forward declarations.
|
||||
struct TexImage;
|
||||
struct CubeImage;
|
||||
|
||||
/// Supported compression formats.
|
||||
enum Format
|
||||
@ -382,6 +383,11 @@ namespace nvtt
|
||||
NVTT_API bool compress(const TexImage & tex, int face, int mipmap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
|
||||
NVTT_API int estimateSize(const TexImage & tex, int mipmapCount, const CompressionOptions & compressionOptions) const;
|
||||
|
||||
// CubeImage API.
|
||||
NVTT_API bool outputHeader(const CubeImage & cube, int mipmapCount, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
|
||||
NVTT_API bool compress(const CubeImage & cube, int mipmap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
|
||||
NVTT_API int estimateSize(const CubeImage & cube, int mipmapCount, const CompressionOptions & compressionOptions) const;
|
||||
|
||||
// Raw API.
|
||||
NVTT_API bool outputHeader(TextureType type, int w, int h, int d, int mipmapCount, bool isNormalMap, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
|
||||
NVTT_API bool compress(int w, int h, int d, int face, int mipmap, const float * rgba, const CompressionOptions & compressionOptions, const OutputOptions & outputOptions) const;
|
||||
@ -541,17 +547,20 @@ namespace nvtt
|
||||
NVTT_API bool save(const char * fileName) const;
|
||||
|
||||
TexImage & face(int face);
|
||||
const TexImage & face(int face) const;
|
||||
|
||||
// Layout conversion.
|
||||
void fold(const TexImage & img, CubeLayout layout);
|
||||
TexImage unfold(CubeLayout layout);
|
||||
TexImage unfold(CubeLayout layout) const;
|
||||
|
||||
// @@ Angular extent filtering.
|
||||
|
||||
// @@ Add resizing methods.
|
||||
|
||||
// @@ Irradiance cubemaps.
|
||||
CubeImage irradiance(int size);
|
||||
// Filtering.
|
||||
CubeImage irradianceFilter(int size) const;
|
||||
CubeImage cosinePowerFilter(int size, float cosinePower) const;
|
||||
|
||||
|
||||
/*
|
||||
NVTT_API void resize(int w, int h, ResizeFilter filter);
|
||||
|
Loading…
Reference in New Issue
Block a user