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