Replace unsigned int, and char with uint and uchar.

This commit is contained in:
mfeemster
2014-12-05 21:05:09 -08:00
parent 8a3521206b
commit 47dd9fe35c
63 changed files with 2013 additions and 2007 deletions

View File

@ -97,7 +97,7 @@ template <typename T> string DEOpenCLKernelCreator<T>::LogScaleAssignDEEntryPoin
/// <param name="filterWidth">Filter width</param>
/// <returns>The kernel source</returns>
template <typename T>
string DEOpenCLKernelCreator<T>::GaussianDEKernel(size_t ss, unsigned int filterWidth)
string DEOpenCLKernelCreator<T>::GaussianDEKernel(size_t ss, uint filterWidth)
{
#ifndef ROW_ONLY_DE
if ((typeid(T) == typeid(double)) || (filterWidth > MaxDEFilterSize()))//Type double does not use cache.
@ -134,7 +134,7 @@ string DEOpenCLKernelCreator<T>::GaussianDEKernel(size_t ss, unsigned int filter
/// <param name="filterWidth">Filter width</param>
/// <returns>The name of the density estimation filtering entry point kernel function</returns>
template <typename T>
string DEOpenCLKernelCreator<T>::GaussianDEEntryPoint(size_t ss, unsigned int filterWidth)
string DEOpenCLKernelCreator<T>::GaussianDEEntryPoint(size_t ss, uint filterWidth)
{
#ifndef ROW_ONLY_DE
if ((typeid(T) == typeid(double)) || (filterWidth > MaxDEFilterSize()))//Type double does not use cache.
@ -170,11 +170,11 @@ string DEOpenCLKernelCreator<T>::GaussianDEEntryPoint(size_t ss, unsigned int fi
/// </summary>
/// <returns>The maximum filter size allowed for running the local memory version of density filtering</returns>
template <typename T>
unsigned int DEOpenCLKernelCreator<T>::MaxDEFilterSize() { return 9; }//The true max would be (maxBoxSize - 1) / 2, but that's impractical because it can give us a tiny block size.
uint DEOpenCLKernelCreator<T>::MaxDEFilterSize() { return 9; }//The true max would be (maxBoxSize - 1) / 2, but that's impractical because it can give us a tiny block size.
/// <summary>
/// Solve for the maximum filter radius.
/// The final filter width is calculated by: (unsigned int)(ceil(m_MaxRad) * (T)m_Supersample) + (m_Supersample - 1);
/// The final filter width is calculated by: (uint)(ceil(m_MaxRad) * (T)m_Supersample) + (m_Supersample - 1);
/// Must solve for what max rad should be in order to give a maximum final width of (maxBoxSize - 1) / 2, assuming
/// a minimum block size of 1 which processes 1 pixel.
/// Example: If a box size of 20 was allowed, a filter
@ -186,9 +186,9 @@ unsigned int DEOpenCLKernelCreator<T>::MaxDEFilterSize() { return 9; }//The true
/// <param name="ss">The supersample being used</param>
/// <returns>The maximum filter radius allowed</returns>
template <typename T>
T DEOpenCLKernelCreator<T>::SolveMaxDERad(unsigned int maxBoxSize, T desiredFilterSize, T ss)
T DEOpenCLKernelCreator<T>::SolveMaxDERad(uint maxBoxSize, T desiredFilterSize, T ss)
{
unsigned int finalFilterSize = (unsigned int)((ceil(desiredFilterSize) * ss) + (ss - 1.0));
uint finalFilterSize = (uint)((ceil(desiredFilterSize) * ss) + (ss - 1.0));
//Return the desired size if the final size of it will fit.
if (finalFilterSize <= MaxDEFilterSize())
@ -205,9 +205,9 @@ T DEOpenCLKernelCreator<T>::SolveMaxDERad(unsigned int maxBoxSize, T desiredFilt
/// <param name="localMem">The local memory available to a block</param>
/// <returns>The maximum filter box size allowed</returns>
template <typename T>
unsigned int DEOpenCLKernelCreator<T>::SolveMaxBoxSize(unsigned int localMem)
uint DEOpenCLKernelCreator<T>::SolveMaxBoxSize(uint localMem)
{
return (unsigned int)floor(sqrt(floor((T)localMem / 16.0)));//Divide by 16 because each element is float4.
return (uint)floor(sqrt(floor((T)localMem / 16.0)));//Divide by 16 because each element is float4.
}
/// <summary>

View File

@ -39,13 +39,13 @@ public:
//Accessors.
string LogScaleAssignDEKernel();
string LogScaleAssignDEEntryPoint();
string GaussianDEKernel(size_t ss, unsigned int filterWidth);
string GaussianDEEntryPoint(size_t ss, unsigned int filterWidth);
string GaussianDEKernel(size_t ss, uint filterWidth);
string GaussianDEEntryPoint(size_t ss, uint filterWidth);
//Miscellaneous static functions.
static unsigned int MaxDEFilterSize();
static T SolveMaxDERad(unsigned int maxBoxSize, T desiredFilterSize, T ss);
static unsigned int SolveMaxBoxSize(unsigned int localMem);
static uint MaxDEFilterSize();
static T SolveMaxDERad(uint maxBoxSize, T desiredFilterSize, T ss);
static uint SolveMaxBoxSize(uint localMem);
private:
//Kernel creators.

View File

@ -322,9 +322,9 @@ static const char* AddToAccumWithCheckFunctionString =
/// OpenCL equivalent various CarToRas member functions.
/// </summary>
static const char* CarToRasFunctionString =
"inline void CarToRasConvertPointToSingle(__constant CarToRasCL* carToRas, Point* point, unsigned int* singleBufferIndex)\n"
"inline void CarToRasConvertPointToSingle(__constant CarToRasCL* carToRas, Point* point, uint* singleBufferIndex)\n"
"{\n"
" *singleBufferIndex = (unsigned int)(carToRas->m_PixPerImageUnitW * point->m_X - carToRas->m_RasLlX) + (carToRas->m_RasWidth * (unsigned int)(carToRas->m_PixPerImageUnitH * point->m_Y - carToRas->m_RasLlY));\n"
" *singleBufferIndex = (uint)(carToRas->m_PixPerImageUnitW * point->m_X - carToRas->m_RasLlX) + (carToRas->m_RasWidth * (uint)(carToRas->m_PixPerImageUnitH * point->m_Y - carToRas->m_RasLlY));\n"
"}\n"
"\n"
"inline bool CarToRasInBounds(__constant CarToRasCL* carToRas, Point* point)\n"

View File

@ -48,7 +48,7 @@ static string ConstantDefinesString(bool doublePrecision)
else
{
os << "typedef int intPrec;\n"
"typedef unsigned int atomi;\n"
"typedef uint atomi;\n"
"typedef float real_t;\n"
"typedef float4 real4;\n"
"#define EPS (FLT_EPSILON)\n"
@ -131,7 +131,7 @@ struct ALIGN PointCL
T m_Y;
T m_Z;
T m_ColorX;
unsigned int m_LastXfUsed;
uint m_LastXfUsed;
};
/// <summary>
@ -239,7 +239,7 @@ template <typename T>
struct ALIGN CarToRasCL
{
T m_PixPerImageUnitW, m_RasLlX;
unsigned int m_RasWidth;
uint m_RasWidth;
T m_PixPerImageUnitH, m_RasLlY;
T m_CarLlX, m_CarUrX, m_CarUrY, m_CarLlY;
};
@ -268,13 +268,13 @@ struct ALIGN DensityFilterCL
T m_Curve;
T m_K1;
T m_K2;
unsigned int m_Supersample;
unsigned int m_SuperRasW;
unsigned int m_SuperRasH;
unsigned int m_KernelSize;
unsigned int m_MaxFilterIndex;
unsigned int m_MaxFilteredCounts;
unsigned int m_FilterWidth;
uint m_Supersample;
uint m_SuperRasW;
uint m_SuperRasH;
uint m_KernelSize;
uint m_MaxFilterIndex;
uint m_MaxFilteredCounts;
uint m_FilterWidth;
};
/// <summary>
@ -304,17 +304,17 @@ static const char* DensityFilterCLStructString =
template <typename T>
struct ALIGN SpatialFilterCL
{
unsigned int m_SuperRasW;
unsigned int m_SuperRasH;
unsigned int m_FinalRasW;
unsigned int m_FinalRasH;
unsigned int m_Supersample;
unsigned int m_FilterWidth;
unsigned int m_NumChannels;
unsigned int m_BytesPerChannel;
unsigned int m_DensityFilterOffset;
unsigned int m_Transparency;
unsigned int m_YAxisUp;
uint m_SuperRasW;
uint m_SuperRasH;
uint m_FinalRasW;
uint m_FinalRasH;
uint m_Supersample;
uint m_FilterWidth;
uint m_NumChannels;
uint m_BytesPerChannel;
uint m_DensityFilterOffset;
uint m_Transparency;
uint m_YAxisUp;
T m_Vibrancy;
T m_HighlightPower;
T m_Gamma;

View File

@ -239,15 +239,15 @@ string FinalAccumOpenCLKernelCreator<T>::CreateFinalAccumKernelString(bool early
" if ((GLOBAL_ID_Y >= spatialFilter->m_FinalRasH) || (GLOBAL_ID_X >= spatialFilter->m_FinalRasW))\n"
" return;\n"
"\n"
" unsigned int accumX = spatialFilter->m_DensityFilterOffset + (GLOBAL_ID_X * spatialFilter->m_Supersample);\n"
" unsigned int accumY = spatialFilter->m_DensityFilterOffset + (GLOBAL_ID_Y * spatialFilter->m_Supersample);\n"
" uint accumX = spatialFilter->m_DensityFilterOffset + (GLOBAL_ID_X * spatialFilter->m_Supersample);\n"
" uint accumY = spatialFilter->m_DensityFilterOffset + (GLOBAL_ID_Y * spatialFilter->m_Supersample);\n"
" int2 finalCoord;\n"
" finalCoord.x = GLOBAL_ID_X;\n"
" finalCoord.y = (int)((spatialFilter->m_YAxisUp == 1) ? ((spatialFilter->m_FinalRasH - GLOBAL_ID_Y) - 1) : GLOBAL_ID_Y);\n"
" float4floats finalColor;\n"
" real_t alpha, ls;\n"
" int ii, jj;\n"
" unsigned int filterKRowIndex;\n"
" uint filterKRowIndex;\n"
" const __global real4reals* accumBucket;\n"
" real4reals newBucket;\n"
" newBucket.m_Real4 = 0;\n"
@ -356,7 +356,7 @@ string FinalAccumOpenCLKernelCreator<T>::CreateGammaCorrectionFunctionString(boo
<< "\n"
<< " CalcNewRgb(bucket, ls, highlightPower, &newRgb);\n"
<< "\n"
<< " for (unsigned int rgbi = 0; rgbi < 3; rgbi++)\n"
<< " for (uint rgbi = 0; rgbi < 3; rgbi++)\n"
<< " {\n"
<< " a = newRgb.m_Reals[rgbi] + ((1.0 - vibrancy) * 256.0 * pow(bucket->m_Reals[rgbi], g));\n"
<< "\n";
@ -504,7 +504,7 @@ string FinalAccumOpenCLKernelCreator<T>::CreateGammaCorrectionKernelString(bool
" if (GLOBAL_ID_Y >= (spatialFilter->m_SuperRasH - testGutter) || GLOBAL_ID_X >= (spatialFilter->m_SuperRasW - testGutter))\n"
" return;\n"
"\n"
" unsigned int superIndex = (GLOBAL_ID_Y * spatialFilter->m_SuperRasW) + GLOBAL_ID_X;\n"
" uint superIndex = (GLOBAL_ID_Y * spatialFilter->m_SuperRasW) + GLOBAL_ID_X;\n"
" __global real4reals* bucket = accumulator + superIndex;\n"
//Pass in an alphaBase and alphaScale of 0, 1 which means to just directly assign the computed alpha value.
" GammaCorrectionFloats(bucket, &(spatialFilter->m_Background[0]), spatialFilter->m_Gamma, spatialFilter->m_LinRange, spatialFilter->m_Vibrancy, spatialFilter->m_HighlightPower, 0.0, 1.0, &(bucket->m_Reals[0]));\n"

View File

@ -59,10 +59,10 @@ private:
//template EMBERCL_API bool IterOpenCLKernelCreator::IsBuildRequired<double>(Ember<double>& ember1, Ember<double>& ember2);
#ifdef OPEN_CL_TEST_AREA
typedef void (*KernelFuncPointer) (unsigned int gridWidth, unsigned int gridHeight, unsigned int blockWidth, unsigned int blockHeight,
unsigned int BLOCK_ID_X, unsigned int BLOCK_ID_Y, unsigned int THREAD_ID_X, unsigned int THREAD_ID_Y);
typedef void (*KernelFuncPointer) (uint gridWidth, uint gridHeight, uint blockWidth, uint blockHeight,
uint BLOCK_ID_X, uint BLOCK_ID_Y, uint THREAD_ID_X, uint THREAD_ID_Y);
static void OpenCLSim(unsigned int gridWidth, unsigned int gridHeight, unsigned int blockWidth, unsigned int blockHeight, KernelFuncPointer func)
static void OpenCLSim(uint gridWidth, uint gridHeight, uint blockWidth, uint blockHeight, KernelFuncPointer func)
{
cout << "OpenCLSim(): " << endl;
cout << " Params: " << endl;
@ -71,13 +71,13 @@ static void OpenCLSim(unsigned int gridWidth, unsigned int gridHeight, unsigned
cout << " blockW: " << blockWidth << endl;
cout << " blockH: " << blockHeight << endl;
for (unsigned int i = 0; i < gridHeight; i += blockHeight)
for (uint i = 0; i < gridHeight; i += blockHeight)
{
for (unsigned int j = 0; j < gridWidth; j += blockWidth)
for (uint j = 0; j < gridWidth; j += blockWidth)
{
for (unsigned int k = 0; k < blockHeight; k++)
for (uint k = 0; k < blockHeight; k++)
{
for (unsigned int l = 0; l < blockWidth; l++)
for (uint l = 0; l < blockWidth; l++)
{
func(gridWidth, gridHeight, blockWidth, blockHeight, j / blockWidth, i / blockHeight, l, k);
}

View File

@ -42,7 +42,7 @@ bool OpenCLWrapper::CheckOpenCL()
/// <param name="device">The index device of the device to use</param>
/// <param name="shared">True if shared with OpenGL, else false.</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::Init(unsigned int platform, unsigned int device, bool shared)
bool OpenCLWrapper::Init(uint platform, uint device, bool shared)
{
cl_int err;
@ -70,7 +70,7 @@ bool OpenCLWrapper::Init(unsigned int platform, unsigned int device, bool shared
m_Device = m_Devices[m_PlatformIndex][device];
m_DeviceVec.clear();
m_DeviceVec.push_back(m_Device);
m_LocalMemSize = (unsigned int)GetInfo<cl_ulong>(m_PlatformIndex, m_DeviceIndex, CL_DEVICE_LOCAL_MEM_SIZE);
m_LocalMemSize = (uint)GetInfo<cl_ulong>(m_PlatformIndex, m_DeviceIndex, CL_DEVICE_LOCAL_MEM_SIZE);
m_Shared = shared;
m_Init = true;//Command queue is ok, it's now ok to begin building and running programs.
}
@ -215,7 +215,7 @@ bool OpenCLWrapper::WriteBuffer(const string& name, void* data, size_t size)
/// <param name="data">A pointer to the buffer</param>
/// <param name="size">The size in bytes of the buffer</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::WriteBuffer(unsigned int bufferIndex, void* data, size_t size)
bool OpenCLWrapper::WriteBuffer(uint bufferIndex, void* data, size_t size)
{
if (m_Init && (bufferIndex < m_Buffers.size()) && (GetBufferSize(bufferIndex) == size))
{
@ -253,7 +253,7 @@ bool OpenCLWrapper::ReadBuffer(const string& name, void* data, size_t size)
/// <param name="data">A pointer to a buffer to copy the data to</param>
/// <param name="size">The size in bytes of the buffer</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::ReadBuffer(unsigned int bufferIndex, void* data, size_t size)
bool OpenCLWrapper::ReadBuffer(uint bufferIndex, void* data, size_t size)
{
if (m_Init && (bufferIndex < m_Buffers.size()) && (GetBufferSize(bufferIndex) == size))
{
@ -277,7 +277,7 @@ bool OpenCLWrapper::ReadBuffer(unsigned int bufferIndex, void* data, size_t size
/// <returns>The index if found, else -1.</returns>
int OpenCLWrapper::FindBufferIndex(const string& name)
{
for (unsigned int i = 0; i < m_Buffers.size(); i++)
for (uint i = 0; i < m_Buffers.size(); i++)
if (m_Buffers[i].m_Name == name)
return (int)i;
@ -289,7 +289,7 @@ int OpenCLWrapper::FindBufferIndex(const string& name)
/// </summary>
/// <param name="name">The name of the buffer to search for</param>
/// <returns>The size of the buffer if found, else 0.</returns>
unsigned int OpenCLWrapper::GetBufferSize(const string& name)
uint OpenCLWrapper::GetBufferSize(const string& name)
{
int bufferIndex = FindBufferIndex(name);
@ -301,10 +301,10 @@ unsigned int OpenCLWrapper::GetBufferSize(const string& name)
/// </summary>
/// <param name="name">The index of the buffer to get the size of</param>
/// <returns>The size of the buffer if found, else 0.</returns>
unsigned int OpenCLWrapper::GetBufferSize(unsigned int bufferIndex)
uint OpenCLWrapper::GetBufferSize(uint bufferIndex)
{
if (m_Init && bufferIndex < m_Buffers.size())
return (unsigned int)m_Buffers[bufferIndex].m_Buffer.getInfo<CL_MEM_SIZE>(nullptr);
return (uint)m_Buffers[bufferIndex].m_Buffer.getInfo<CL_MEM_SIZE>(nullptr);
return 0;
}
@ -355,7 +355,7 @@ bool OpenCLWrapper::AddAndWriteImage(const string& name, cl_mem_flags flags, con
m_GLImages.push_back(namedImageGL);
if (data)
return WriteImage2D((unsigned int)m_GLImages.size() - 1, true, width, height, row_pitch, data);//OpenGL images/textures require a separate write.
return WriteImage2D((uint)m_GLImages.size() - 1, true, width, height, row_pitch, data);//OpenGL images/textures require a separate write.
else
return true;
}
@ -430,7 +430,7 @@ bool OpenCLWrapper::AddAndWriteImage(const string& name, cl_mem_flags flags, con
/// <param name="row_pitch">The row pitch (usually zero)</param>
/// <param name="data">The image data</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::WriteImage2D(unsigned int index, bool shared, ::size_t width, ::size_t height, ::size_t row_pitch, void* data)
bool OpenCLWrapper::WriteImage2D(uint index, bool shared, ::size_t width, ::size_t height, ::size_t row_pitch, void* data)
{
if (m_Init)
{
@ -505,7 +505,7 @@ bool OpenCLWrapper::ReadImage(const string& name, ::size_t width, ::size_t heigh
/// <param name="shared">True if shared with an OpenGL texture, else false.</param>
/// <param name="data">A pointer to a buffer to copy the data to</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::ReadImage(unsigned int imageIndex, ::size_t width, ::size_t height, ::size_t row_pitch, bool shared, void* data)
bool OpenCLWrapper::ReadImage(uint imageIndex, ::size_t width, ::size_t height, ::size_t row_pitch, bool shared, void* data)
{
if (m_Init)
{
@ -552,13 +552,13 @@ int OpenCLWrapper::FindImageIndex(const string& name, bool shared)
{
if (shared)
{
for (unsigned int i = 0; i < m_GLImages.size(); i++)
for (uint i = 0; i < m_GLImages.size(); i++)
if (m_GLImages[i].m_Name == name)
return i;
}
else
{
for (unsigned int i = 0; i < m_Images.size(); i++)
for (uint i = 0; i < m_Images.size(); i++)
if (m_Images[i].m_Name == name)
return i;
}
@ -572,7 +572,7 @@ int OpenCLWrapper::FindImageIndex(const string& name, bool shared)
/// <param name="name">The name of the image to search for</param>
/// <param name="shared">True if shared with an OpenGL texture, else false.</param>
/// <returns>The size of the 2D image if found, else 0.</returns>
unsigned int OpenCLWrapper::GetImageSize(const string& name, bool shared)
uint OpenCLWrapper::GetImageSize(const string& name, bool shared)
{
int imageIndex = FindImageIndex(name, shared);
return GetImageSize(imageIndex, shared);
@ -584,7 +584,7 @@ unsigned int OpenCLWrapper::GetImageSize(const string& name, bool shared)
/// <param name="imageIndex">Index of the image to search for</param>
/// <param name="shared">True if shared with an OpenGL texture, else false.</param>
/// <returns>The size of the 2D image if found, else 0.</returns>
unsigned int OpenCLWrapper::GetImageSize(unsigned int imageIndex, bool shared)
uint OpenCLWrapper::GetImageSize(uint imageIndex, bool shared)
{
size_t size = 0;
@ -608,7 +608,7 @@ unsigned int OpenCLWrapper::GetImageSize(unsigned int imageIndex, bool shared)
}
}
return (unsigned int)size;
return (uint)size;
}
/// <summary>
@ -840,7 +840,7 @@ bool OpenCLWrapper::CreateSampler(cl::Sampler& sampler, cl_bool normalizedCoords
/// <param name="argIndex">Index of the argument</param>
/// <param name="name">The name of the buffer</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::SetBufferArg(unsigned int kernelIndex, unsigned int argIndex, const string& name)
bool OpenCLWrapper::SetBufferArg(uint kernelIndex, uint argIndex, const string& name)
{
int bufferIndex = OpenCLWrapper::FindBufferIndex(name);
@ -855,7 +855,7 @@ bool OpenCLWrapper::SetBufferArg(unsigned int kernelIndex, unsigned int argIndex
/// <param name="argIndex">Index of the argument</param>
/// <param name="bufferIndex">Index of the buffer</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::SetBufferArg(unsigned int kernelIndex, unsigned int argIndex, unsigned int bufferIndex)
bool OpenCLWrapper::SetBufferArg(uint kernelIndex, uint argIndex, uint bufferIndex)
{
if (m_Init && bufferIndex < m_Buffers.size())
return SetArg<cl::Buffer>(kernelIndex, argIndex, m_Buffers[bufferIndex].m_Buffer);
@ -872,7 +872,7 @@ bool OpenCLWrapper::SetBufferArg(unsigned int kernelIndex, unsigned int argIndex
/// <param name="shared">True if shared with an OpenGL texture, else false</param>
/// <param name="name">The name of the 2D image</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::SetImageArg(unsigned int kernelIndex, unsigned int argIndex, bool shared, const string& name)
bool OpenCLWrapper::SetImageArg(uint kernelIndex, uint argIndex, bool shared, const string& name)
{
if (m_Init)
{
@ -892,7 +892,7 @@ bool OpenCLWrapper::SetImageArg(unsigned int kernelIndex, unsigned int argIndex,
/// <param name="shared">True if shared with an OpenGL texture, else false</param>
/// <param name="imageIndex">Index of the 2D image</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::SetImageArg(unsigned int kernelIndex, unsigned int argIndex, bool shared, unsigned int imageIndex)
bool OpenCLWrapper::SetImageArg(uint kernelIndex, uint argIndex, bool shared, uint imageIndex)
{
cl_int err;
@ -920,7 +920,7 @@ bool OpenCLWrapper::SetImageArg(unsigned int kernelIndex, unsigned int argIndex,
/// <returns>The index if found, else -1.</returns>
int OpenCLWrapper::FindKernelIndex(const string& name)
{
for (unsigned int i = 0; i < m_Programs.size(); i++)
for (uint i = 0; i < m_Programs.size(); i++)
if (m_Programs[i].m_Name == name)
return (int)i;
@ -938,8 +938,8 @@ int OpenCLWrapper::FindKernelIndex(const string& name)
/// <param name="blockHeight">Height of each block</param>
/// <param name="blockDepth">Depth of each block</param>
/// <returns>True if success, else false.</returns>
bool OpenCLWrapper::RunKernel(unsigned int kernelIndex, unsigned int totalGridWidth, unsigned int totalGridHeight, unsigned int totalGridDepth,
unsigned int blockWidth, unsigned int blockHeight, unsigned int blockDepth)
bool OpenCLWrapper::RunKernel(uint kernelIndex, uint totalGridWidth, uint totalGridHeight, uint totalGridDepth,
uint blockWidth, uint blockHeight, uint blockDepth)
{
if (m_Init && kernelIndex < m_Programs.size())
{
@ -999,7 +999,7 @@ vector<string> OpenCLWrapper::PlatformNames()
platforms.reserve(m_Platforms.size());
for (unsigned int i = 0; i < m_Platforms.size(); i++)
for (uint i = 0; i < m_Platforms.size(); i++)
platforms.push_back(PlatformName(i));
return platforms;
@ -1030,7 +1030,7 @@ string OpenCLWrapper::DeviceName(size_t platform, size_t device)
/// <returns>All available device names on the platform at the specified index as a vector of strings</returns>
vector<string> OpenCLWrapper::DeviceNames(size_t platform)
{
unsigned int i = 0;
uint i = 0;
string s;
vector<string> devices;
@ -1124,9 +1124,9 @@ string OpenCLWrapper::DumpInfo()
bool OpenCLWrapper::Ok() const { return m_Init; }
bool OpenCLWrapper::Shared() const { return m_Shared; }
cl::Context OpenCLWrapper::Context() const { return m_Context; }
unsigned int OpenCLWrapper::PlatformIndex() const { return m_PlatformIndex; }
unsigned int OpenCLWrapper::DeviceIndex() const { return m_DeviceIndex; }
unsigned int OpenCLWrapper::LocalMemSize() const { return m_LocalMemSize; }
uint OpenCLWrapper::PlatformIndex() const { return m_PlatformIndex; }
uint OpenCLWrapper::DeviceIndex() const { return m_DeviceIndex; }
uint OpenCLWrapper::LocalMemSize() const { return m_LocalMemSize; }
/// <summary>
/// Makes the even grid dims.
@ -1135,7 +1135,7 @@ unsigned int OpenCLWrapper::LocalMemSize() const { return m_LocalMemSize; }
/// <param name="blockH">The block h.</param>
/// <param name="gridW">The grid w.</param>
/// <param name="gridH">The grid h.</param>
void OpenCLWrapper::MakeEvenGridDims(unsigned int blockW, unsigned int blockH, unsigned int& gridW, unsigned int& gridH)
void OpenCLWrapper::MakeEvenGridDims(uint blockW, uint blockH, uint& gridW, uint& gridH)
{
if (gridW % blockW != 0)
gridW += (blockW - (gridW % blockW));

View File

@ -104,7 +104,7 @@ class EMBERCL_API OpenCLWrapper : public EmberReport
public:
OpenCLWrapper();
bool CheckOpenCL();
bool Init(unsigned int platform, unsigned int device, bool shared = false);
bool Init(uint platform, uint device, bool shared = false);
//Programs.
bool AddProgram(const string& name, const string& program, const string& entryPoint, bool doublePrecision);
@ -114,22 +114,22 @@ public:
bool AddBuffer(const string& name, size_t size, cl_mem_flags flags = CL_MEM_READ_WRITE);
bool AddAndWriteBuffer(const string& name, void* data, size_t size, cl_mem_flags flags = CL_MEM_READ_WRITE);
bool WriteBuffer(const string& name, void* data, size_t size);
bool WriteBuffer(unsigned int bufferIndex, void* data, size_t size);
bool WriteBuffer(uint bufferIndex, void* data, size_t size);
bool ReadBuffer(const string& name, void* data, size_t size);
bool ReadBuffer(unsigned int bufferIndex, void* data, size_t size);
bool ReadBuffer(uint bufferIndex, void* data, size_t size);
int FindBufferIndex(const string& name);
unsigned int GetBufferSize(const string& name);
unsigned int GetBufferSize(unsigned int bufferIndex);
uint GetBufferSize(const string& name);
uint GetBufferSize(uint bufferIndex);
void ClearBuffers();
//Images.
bool AddAndWriteImage(const string& name, cl_mem_flags flags, const cl::ImageFormat& format, ::size_t width, ::size_t height, ::size_t row_pitch, void* data = NULL, bool shared = false, GLuint texName = 0);
bool WriteImage2D(unsigned int index, bool shared, ::size_t width, ::size_t height, ::size_t row_pitch, void* data);
bool WriteImage2D(uint index, bool shared, ::size_t width, ::size_t height, ::size_t row_pitch, void* data);
bool ReadImage(const string& name, ::size_t width, ::size_t height, ::size_t row_pitch, bool shared, void* data);
bool ReadImage(unsigned int imageIndex, ::size_t width, ::size_t height, ::size_t row_pitch, bool shared, void* data);
bool ReadImage(uint imageIndex, ::size_t width, ::size_t height, ::size_t row_pitch, bool shared, void* data);
int FindImageIndex(const string& name, bool shared);
unsigned int GetImageSize(const string& name, bool shared);
unsigned int GetImageSize(unsigned int imageIndex, bool shared);
uint GetImageSize(const string& name, bool shared);
uint GetImageSize(uint imageIndex, bool shared);
bool CompareImageParams(cl::Image& image, cl_mem_flags flags, const cl::ImageFormat& format, ::size_t width, ::size_t height, ::size_t row_pitch);
void ClearImages(bool shared);
bool CreateImage2D(cl::Image2D& image2D, cl_mem_flags flags, cl::ImageFormat format, ::size_t width, ::size_t height, ::size_t row_pitch = 0, void* data = NULL);
@ -143,10 +143,10 @@ public:
bool CreateSampler(cl::Sampler& sampler, cl_bool normalizedCoords, cl_addressing_mode addressingMode, cl_filter_mode filterMode);
//Arguments.
bool SetBufferArg(unsigned int kernelIndex, unsigned int argIndex, const string& name);
bool SetBufferArg(unsigned int kernelIndex, unsigned int argIndex, unsigned int bufferIndex);
bool SetImageArg(unsigned int kernelIndex, unsigned int argIndex, bool shared, const string& name);
bool SetImageArg(unsigned int kernelIndex, unsigned int argIndex, bool shared, unsigned int imageIndex);
bool SetBufferArg(uint kernelIndex, uint argIndex, const string& name);
bool SetBufferArg(uint kernelIndex, uint argIndex, uint bufferIndex);
bool SetImageArg(uint kernelIndex, uint argIndex, bool shared, const string& name);
bool SetImageArg(uint kernelIndex, uint argIndex, bool shared, uint imageIndex);
/// <summary>
/// Set an argument in the specified kernel, at the specified argument index.
@ -157,7 +157,7 @@ public:
/// <param name="arg">The argument value to set</param>
/// <returns>True if success, else false</returns>
template <typename T>
bool SetArg(unsigned int kernelIndex, unsigned int argIndex, T arg)
bool SetArg(uint kernelIndex, uint argIndex, T arg)
{
if (m_Init && kernelIndex < m_Programs.size())
{
@ -171,7 +171,7 @@ public:
//Kernels.
int FindKernelIndex(const string& name);
bool RunKernel(unsigned int kernelIndex, unsigned int totalGridWidth, unsigned int totalGridHeight, unsigned int totalGridDepth, unsigned int blockWidth, unsigned int blockHeight, unsigned int blockDepth);
bool RunKernel(uint kernelIndex, uint totalGridWidth, uint totalGridHeight, uint totalGridDepth, uint blockWidth, uint blockHeight, uint blockDepth);
//Info.
template<typename T>
@ -187,11 +187,11 @@ public:
bool Ok() const;
bool Shared() const;
cl::Context Context() const;
unsigned int PlatformIndex() const;
unsigned int DeviceIndex() const;
unsigned int LocalMemSize() const;
uint PlatformIndex() const;
uint DeviceIndex() const;
uint LocalMemSize() const;
static void MakeEvenGridDims(unsigned int blockW, unsigned int blockH, unsigned int& gridW, unsigned int& gridH);
static void MakeEvenGridDims(uint blockW, uint blockH, uint& gridW, uint& gridH);
private:
bool CreateContext(bool shared);
@ -201,9 +201,9 @@ private:
bool m_Init;
bool m_Shared;
unsigned int m_PlatformIndex;
unsigned int m_DeviceIndex;
unsigned int m_LocalMemSize;
uint m_PlatformIndex;
uint m_DeviceIndex;
uint m_LocalMemSize;
cl::Platform m_Platform;
cl::Context m_Context;
cl::Device m_Device;

File diff suppressed because it is too large Load Diff

View File

@ -19,7 +19,7 @@ class EMBERCL_API RendererCLBase
{
public:
virtual ~RendererCLBase() { }
virtual bool ReadFinal(unsigned char* pixels) = 0;
virtual bool ReadFinal(byte* pixels) = 0;
virtual bool ClearFinal() = 0;
};
@ -54,35 +54,35 @@ using EmberNs::Renderer<T, T>::m_RotMat;
using EmberNs::Renderer<T, T>::m_Ember;
public:
RendererCL(unsigned int platform = 0, unsigned int device = 0, bool shared = false, GLuint outputTexID = 0);
RendererCL(uint platform = 0, uint device = 0, bool shared = false, GLuint outputTexID = 0);
~RendererCL();
//Non-virtual member functions for OpenCL specific tasks.
bool Init(unsigned int platform, unsigned int device, bool shared, GLuint outputTexID);
bool Init(uint platform, uint device, bool shared, GLuint outputTexID);
bool SetOutputTexture(GLuint outputTexID);
//Iters per kernel/block/grid.
inline unsigned int IterCountPerKernel() const;
inline unsigned int IterCountPerBlock() const;
inline unsigned int IterCountPerGrid() const;
inline uint IterCountPerKernel() const;
inline uint IterCountPerBlock() const;
inline uint IterCountPerGrid() const;
//Kernels per block.
inline unsigned int IterBlockKernelWidth() const;
inline unsigned int IterBlockKernelHeight() const;
inline unsigned int IterBlockKernelCount() const;
inline uint IterBlockKernelWidth() const;
inline uint IterBlockKernelHeight() const;
inline uint IterBlockKernelCount() const;
//Kernels per grid.
inline unsigned int IterGridKernelWidth() const;
inline unsigned int IterGridKernelHeight() const;
inline unsigned int IterGridKernelCount() const;
inline uint IterGridKernelWidth() const;
inline uint IterGridKernelHeight() const;
inline uint IterGridKernelCount() const;
//Blocks per grid.
inline unsigned int IterGridBlockWidth() const;
inline unsigned int IterGridBlockHeight() const;
inline unsigned int IterGridBlockCount() const;
inline uint IterGridBlockWidth() const;
inline uint IterGridBlockHeight() const;
inline uint IterGridBlockCount() const;
unsigned int PlatformIndex();
unsigned int DeviceIndex();
uint PlatformIndex();
uint DeviceIndex();
bool ReadHist();
bool ReadAccum();
bool ReadPoints(vector<PointCL<T>>& vec);
@ -95,7 +95,7 @@ public:
string IterKernel();
//Virtual functions overridden from RendererCLBase.
virtual bool ReadFinal(unsigned char* pixels);
virtual bool ReadFinal(byte* pixels);
virtual bool ClearFinal();
//Public virtual functions overridden from Renderer or RendererBase.
@ -122,7 +122,7 @@ protected:
virtual bool ResetBuckets(bool resetHist = true, bool resetAccum = true) override;
virtual eRenderStatus LogScaleDensityFilter() override;
virtual eRenderStatus GaussianDensityFilter() override;
virtual eRenderStatus AccumulatorToFinalImage(unsigned char* pixels, size_t finalOffset) override;
virtual eRenderStatus AccumulatorToFinalImage(byte* pixels, size_t finalOffset) override;
virtual EmberStats Iterate(size_t iterCount, size_t temporalSample) override;
private:
@ -132,9 +132,9 @@ private:
eRenderStatus RunLogScaleFilter();
eRenderStatus RunDensityFilter();
eRenderStatus RunFinalAccum();
bool ClearBuffer(const string& bufferName, unsigned int width, unsigned int height, unsigned int elementSize);
bool RunDensityFilterPrivate(unsigned int kernelIndex, unsigned int gridW, unsigned int gridH, unsigned int blockW, unsigned int blockH, unsigned int chunkSizeW, unsigned int chunkSizeH, unsigned int chunkW, unsigned int chunkH);
int MakeAndGetDensityFilterProgram(size_t ss, unsigned int filterWidth);
bool ClearBuffer(const string& bufferName, uint width, uint height, uint elementSize);
bool RunDensityFilterPrivate(uint kernelIndex, uint gridW, uint gridH, uint blockW, uint blockH, uint chunkSizeW, uint chunkSizeH, uint chunkW, uint chunkH);
int MakeAndGetDensityFilterProgram(size_t ss, uint filterWidth);
int MakeAndGetFinalAccumProgram(T& alphaBase, T& alphaScale);
int MakeAndGetGammaCorrectionProgram();
void FillSeeds();
@ -148,12 +148,12 @@ private:
bool m_Init;
bool m_NVidia;
bool m_DoublePrecision;
unsigned int m_IterCountPerKernel;
unsigned int m_IterBlocksWide, m_IterBlockWidth;
unsigned int m_IterBlocksHigh, m_IterBlockHeight;
unsigned int m_MaxDEBlockSizeW;
unsigned int m_MaxDEBlockSizeH;
unsigned int m_WarpSize;
uint m_IterCountPerKernel;
uint m_IterBlocksWide, m_IterBlockWidth;
uint m_IterBlocksHigh, m_IterBlockHeight;
uint m_MaxDEBlockSizeW;
uint m_MaxDEBlockSizeH;
uint m_WarpSize;
size_t m_Calls;
//Buffer names.