mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-07-01 13:56:06 -04:00
More Linux work. This has Render, Animate and Genome building and running on Linux.
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#include "EmberCLPch.h"
|
||||
#include "DEOpenCLKernelCreator.h"
|
||||
|
||||
namespace EmberCLns
|
||||
namespace EmberCLns
|
||||
{
|
||||
/// <summary>
|
||||
/// Empty constructor that does nothing. The user must call the one which takes a bool
|
||||
@ -219,7 +219,7 @@ template <typename T>
|
||||
string DEOpenCLKernelCreator<T>::CreateLogScaleAssignDEKernelString()
|
||||
{
|
||||
ostringstream os;
|
||||
|
||||
|
||||
os <<
|
||||
ConstantDefinesString(typeid(T) == typeid(double)) <<
|
||||
DensityFilterCLStructString <<
|
||||
@ -243,7 +243,7 @@ string DEOpenCLKernelCreator<T>::CreateLogScaleAssignDEKernelString()
|
||||
" barrier(CLK_GLOBAL_MEM_FENCE);\n"//Just to be safe. Makes no speed difference to do all of the time or only when there's a hit.
|
||||
" }\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
return os.str();
|
||||
}
|
||||
|
||||
@ -354,7 +354,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernel(size_t ss)
|
||||
" if (bucket.w != 0)\n"
|
||||
" cacheLog = (densityFilter->m_K1 * log(1.0 + bucket.w * densityFilter->m_K2)) / bucket.w;\n"
|
||||
"\n";
|
||||
|
||||
|
||||
if (doSS)
|
||||
{
|
||||
os <<
|
||||
@ -626,7 +626,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernel(size_t ss)
|
||||
" if (bucket.w != 0)\n"
|
||||
" {\n"
|
||||
" cacheLog = (densityFilter->m_K1 * log(1.0 + bucket.w * densityFilter->m_K2)) / bucket.w;\n";
|
||||
|
||||
|
||||
if (doSS)
|
||||
{
|
||||
os <<
|
||||
@ -644,7 +644,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernel(size_t ss)
|
||||
" }\n"
|
||||
" }\n"
|
||||
"\n";
|
||||
|
||||
|
||||
if (doScf)
|
||||
os << " filterSelect *= scfact;\n";
|
||||
}
|
||||
@ -653,7 +653,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernel(size_t ss)
|
||||
os
|
||||
<< " filterSelect = bucket.w;\n";
|
||||
}
|
||||
|
||||
|
||||
os <<
|
||||
"\n"
|
||||
" if (filterSelect > densityFilter->m_MaxFilteredCounts)\n"
|
||||
@ -764,7 +764,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernelNoLocalCache(size_t ss)
|
||||
" ((((BLOCK_ID_Y * chunkSizeH) + chunkH) * BLOCK_SIZE_Y) + THREAD_ID_Y >= densityFilter->m_SuperRasH))\n"
|
||||
" return;\n"
|
||||
"\n";
|
||||
|
||||
|
||||
if (doSS)
|
||||
{
|
||||
os <<
|
||||
@ -777,7 +777,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernelNoLocalCache(size_t ss)
|
||||
if (doScf)
|
||||
os << " real_t scfact = pow((real_t)densityFilter->m_Supersample / ((real_t)densityFilter->m_Supersample + 1.0), 2.0);\n";
|
||||
}
|
||||
|
||||
|
||||
os <<
|
||||
//Compute the bounds of the area to be sampled, which is just the ends minus the super sample minus 1.
|
||||
" uint leftBound = densityFilter->m_Supersample - 1;\n"
|
||||
@ -807,7 +807,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernelNoLocalCache(size_t ss)
|
||||
" if (bucket.w != 0)\n"
|
||||
" {\n"
|
||||
" cacheLog = (densityFilter->m_K1 * log(1.0 + bucket.w * densityFilter->m_K2)) / bucket.w;\n";
|
||||
|
||||
|
||||
if (doSS)
|
||||
{
|
||||
os <<
|
||||
@ -825,7 +825,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernelNoLocalCache(size_t ss)
|
||||
" }\n"
|
||||
" }\n"
|
||||
"\n";
|
||||
|
||||
|
||||
if (doScf)
|
||||
os << " filterSelect *= scfact;\n";
|
||||
}
|
||||
@ -834,7 +834,7 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernelNoLocalCache(size_t ss)
|
||||
os
|
||||
<< " filterSelect = bucket.w;\n";
|
||||
}
|
||||
|
||||
|
||||
os <<
|
||||
"\n"
|
||||
" if (filterSelect > densityFilter->m_MaxFilteredCounts)\n"
|
||||
@ -876,4 +876,10 @@ string DEOpenCLKernelCreator<T>::CreateGaussianDEKernelNoLocalCache(size_t ss)
|
||||
|
||||
return os.str();
|
||||
}
|
||||
}
|
||||
|
||||
template EMBERCL_API class DEOpenCLKernelCreator<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class DEOpenCLKernelCreator<double>;
|
||||
#endif
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "EmberCLPch.h"
|
||||
#include "EmberCLStructs.h"
|
||||
#include "EmberCLFunctions.h"
|
||||
@ -52,7 +52,7 @@ private:
|
||||
string CreateLogScaleAssignDEKernelString();
|
||||
string CreateGaussianDEKernel(size_t ss);
|
||||
string CreateGaussianDEKernelNoLocalCache(size_t ss);
|
||||
|
||||
|
||||
string m_LogScaleAssignDEKernel;
|
||||
string m_LogScaleAssignDEEntryPoint;
|
||||
|
||||
@ -77,9 +77,9 @@ private:
|
||||
bool m_NVidia;
|
||||
};
|
||||
|
||||
template EMBERCL_API class DEOpenCLKernelCreator<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class DEOpenCLKernelCreator<double>;
|
||||
#endif
|
||||
//template EMBERCL_API class DEOpenCLKernelCreator<float>;
|
||||
//
|
||||
//#ifdef DO_DOUBLE
|
||||
// template EMBERCL_API class DEOpenCLKernelCreator<double>;
|
||||
//#endif
|
||||
}
|
||||
|
@ -8,9 +8,14 @@
|
||||
#define WIN32_LEAN_AND_MEAN//Exclude rarely-used stuff from Windows headers.
|
||||
#define _USE_MATH_DEFINES
|
||||
|
||||
#include "Timing.h"
|
||||
#include "Renderer.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#include <SDKDDKVer.h>
|
||||
#else
|
||||
#include "GL/glx.h"
|
||||
#endif
|
||||
|
||||
#include <utility>
|
||||
@ -25,16 +30,17 @@
|
||||
#include <iterator>
|
||||
#include <time.h>
|
||||
|
||||
#include "Timing.h"
|
||||
#include "Renderer.h"
|
||||
|
||||
#if defined(BUILDING_EMBERCL)
|
||||
#define EMBERCL_API __declspec(dllexport)
|
||||
#ifdef _WIN32
|
||||
#if defined(BUILDING_EMBERCL)
|
||||
#define EMBERCL_API __declspec(dllexport)
|
||||
#else
|
||||
#define EMBERCL_API __declspec(dllimport)
|
||||
#endif
|
||||
#else
|
||||
#define EMBERCL_API __declspec(dllimport)
|
||||
#define EMBERCL_API
|
||||
#endif
|
||||
|
||||
using namespace std;
|
||||
using namespace EmberNs;
|
||||
//#define TEST_CL 1
|
||||
//#define TEST_CL_BUFFERS 1
|
||||
//#define TEST_CL_BUFFERS 1
|
||||
|
@ -13,7 +13,13 @@
|
||||
|
||||
namespace EmberCLns
|
||||
{
|
||||
#define ALIGN __declspec(align(16))//These two must always match.
|
||||
//These two must always match.
|
||||
#ifdef WIN32
|
||||
#define ALIGN __declspec(align(16))
|
||||
#else
|
||||
#define ALIGN __attribute__ ((aligned (16)))
|
||||
#endif
|
||||
|
||||
#define ALIGN_CL "((aligned (16)))"//The extra parens are necessary.
|
||||
|
||||
/// <summary>
|
||||
@ -378,4 +384,4 @@ static const char* UnionCLStructString =
|
||||
" real_t m_Reals[4];\n"
|
||||
"} real4reals;\n"
|
||||
"\n";
|
||||
}
|
||||
}
|
||||
|
@ -275,7 +275,7 @@ string FinalAccumOpenCLKernelCreator<T>::CreateFinalAccumKernelString(bool early
|
||||
" finalColor.m_Float4.x = (float)newBucket.m_Real4.x;\n"//CPU side clamps, skip here because write_imagef() does the clamping for us.
|
||||
" finalColor.m_Float4.y = (float)newBucket.m_Real4.y;\n"
|
||||
" finalColor.m_Float4.z = (float)newBucket.m_Real4.z;\n";
|
||||
|
||||
|
||||
if (alphaAccum)
|
||||
{
|
||||
if (alphaCalc)
|
||||
@ -374,13 +374,13 @@ string FinalAccumOpenCLKernelCreator<T>::CreateGammaCorrectionFunctionString(boo
|
||||
<< " else\n"
|
||||
<< " a = 0;\n";
|
||||
}
|
||||
|
||||
|
||||
os <<
|
||||
"\n"
|
||||
" correctedChannels[rgbi] = (" << dataType << ")clamp(a, 0.0, 255.0);\n"
|
||||
" }\n"
|
||||
"\n";
|
||||
|
||||
|
||||
//The CPU code has 3 cases for assigning alpha:
|
||||
//[3] = alpha.//Early clip.
|
||||
//[3] = alpha * 255.//Final Rgba with transparency.
|
||||
@ -513,4 +513,10 @@ string FinalAccumOpenCLKernelCreator<T>::CreateGammaCorrectionKernelString(bool
|
||||
|
||||
return os.str();
|
||||
}
|
||||
}
|
||||
|
||||
template EMBERCL_API class FinalAccumOpenCLKernelCreator<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class FinalAccumOpenCLKernelCreator<double>;
|
||||
#endif
|
||||
}
|
||||
|
@ -1,5 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
|
||||
#include "EmberCLPch.h"
|
||||
#include "EmberCLStructs.h"
|
||||
#include "EmberCLFunctions.h"
|
||||
@ -26,7 +26,7 @@ class EMBERCL_API FinalAccumOpenCLKernelCreator
|
||||
{
|
||||
public:
|
||||
FinalAccumOpenCLKernelCreator();
|
||||
|
||||
|
||||
string GammaCorrectionWithAlphaCalcKernel();
|
||||
string GammaCorrectionWithAlphaCalcEntryPoint();
|
||||
|
||||
@ -79,9 +79,9 @@ private:
|
||||
string m_FinalAccumLateClipWithoutAlphaCalcWithAlphaAccumEntryPoint;
|
||||
};
|
||||
|
||||
template EMBERCL_API class FinalAccumOpenCLKernelCreator<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class FinalAccumOpenCLKernelCreator<double>;
|
||||
#endif
|
||||
}
|
||||
//template EMBERCL_API class FinalAccumOpenCLKernelCreator<float>;
|
||||
//
|
||||
//#ifdef DO_DOUBLE
|
||||
// template EMBERCL_API class FinalAccumOpenCLKernelCreator<double>;
|
||||
//#endif
|
||||
}
|
||||
|
@ -60,7 +60,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
for (i = 0; i < totalXformCount; i++)
|
||||
{
|
||||
Xform<T>* xform = ember.GetTotalXform(i);
|
||||
size_t totalVarCount = xform->TotalVariationCount();
|
||||
//size_t totalVarCount = xform->TotalVariationCount();
|
||||
bool needPrecalcSumSquares = false;
|
||||
bool needPrecalcSqrtSumSquares = false;
|
||||
bool needPrecalcAngles = false;
|
||||
@ -73,7 +73,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
"{\n"
|
||||
" real_t transX, transY, transZ;\n"
|
||||
" real4 vIn, vOut = 0.0;\n";
|
||||
|
||||
|
||||
//Determine if any variations, regular, pre, or post need precalcs.
|
||||
while (Variation<T>* var = xform->GetVariation(v++))
|
||||
{
|
||||
@ -204,7 +204,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (xform->HasPost())
|
||||
{
|
||||
xformFuncs <<
|
||||
@ -267,7 +267,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
" uint threadXDivRows = (THREAD_ID_X / (NTHREADS / THREADS_PER_WARP));\n"
|
||||
" uint threadsMinus1 = NTHREADS - 1;\n"
|
||||
;
|
||||
|
||||
|
||||
os <<
|
||||
"\n"
|
||||
#ifndef STRAIGHT_RAND
|
||||
@ -294,7 +294,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
" firstPoint = points[pointsIndex];\n"
|
||||
" }\n"
|
||||
"\n";
|
||||
|
||||
|
||||
//This is done once initially here and then again after each swap-sync in the main loop.
|
||||
//This along with the randomness that the point shuffle provides gives sufficient randomness
|
||||
//to produce results identical to those produced on the CPU.
|
||||
@ -346,7 +346,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
" switch (secondPoint.m_LastXfUsed)\n"
|
||||
" {\n";
|
||||
}
|
||||
|
||||
|
||||
os <<
|
||||
" case " << i << ":\n"
|
||||
" {\n" <<
|
||||
@ -430,7 +430,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
" continue;\n"
|
||||
" }\n"
|
||||
"\n";
|
||||
|
||||
|
||||
if (ember.UseFinalXform())
|
||||
{
|
||||
size_t finalIndex = ember.TotalXformCount() - 1;
|
||||
@ -446,7 +446,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
" }\n"
|
||||
"\n";
|
||||
}
|
||||
|
||||
|
||||
os << CreateProjectionString(ember);
|
||||
|
||||
if (doAccum)
|
||||
@ -549,7 +549,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
"\n"
|
||||
" barrier(CLK_GLOBAL_MEM_FENCE);\n";//Barrier every time, whether or not the point was in bounds, else artifacts will occur when doing strips.
|
||||
}
|
||||
|
||||
|
||||
os <<
|
||||
" }\n"//Main for loop.
|
||||
"\n"
|
||||
@ -578,7 +578,7 @@ string IterOpenCLKernelCreator<T>::CreateIterKernelString(Ember<T>& ember, strin
|
||||
/// the length of the parametric values is unknown.
|
||||
/// This is solved by passing a separate buffer of values dedicated specifically
|
||||
/// to parametric variations.
|
||||
/// In OpenCL, a series of #define constants are declared which specify the indices in
|
||||
/// In OpenCL, a series of #define constants are declared which specify the indices in
|
||||
/// the buffer where the various values are stored.
|
||||
/// The possibility of a parametric variation type being present in multiple xforms is taken
|
||||
/// into account by appending the xform index to the #define, thus making each unique.
|
||||
@ -622,7 +622,7 @@ void IterOpenCLKernelCreator<T>::ParVarIndexDefines(Ember<T>& ember, pair<string
|
||||
|
||||
for (i = 0; i < xformCount; i++)
|
||||
{
|
||||
if (xform = ember.GetTotalXform(i))
|
||||
if ((xform = ember.GetTotalXform(i)))
|
||||
{
|
||||
size_t varCount = xform->TotalVariationCount();
|
||||
|
||||
@ -672,7 +672,7 @@ template <typename T>
|
||||
bool IterOpenCLKernelCreator<T>::IsBuildRequired(Ember<T>& ember1, Ember<T>& ember2)
|
||||
{
|
||||
size_t i, j, xformCount = ember1.TotalXformCount();
|
||||
|
||||
|
||||
if (xformCount != ember2.TotalXformCount())
|
||||
return true;
|
||||
|
||||
@ -834,4 +834,10 @@ string IterOpenCLKernelCreator<T>::CreateProjectionString(Ember<T>& ember)
|
||||
|
||||
return os.str();
|
||||
}
|
||||
}
|
||||
|
||||
template EMBERCL_API class IterOpenCLKernelCreator<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class IterOpenCLKernelCreator<double>;
|
||||
#endif
|
||||
}
|
||||
|
@ -41,12 +41,12 @@ private:
|
||||
string m_ZeroizeEntryPoint;
|
||||
bool m_NVidia;
|
||||
};
|
||||
|
||||
template EMBERCL_API class IterOpenCLKernelCreator<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class IterOpenCLKernelCreator<double>;
|
||||
#endif
|
||||
//
|
||||
//template EMBERCL_API class IterOpenCLKernelCreator<float>;
|
||||
//
|
||||
//#ifdef DO_DOUBLE
|
||||
// template EMBERCL_API class IterOpenCLKernelCreator<double>;
|
||||
//#endif
|
||||
|
||||
//
|
||||
//template EMBERCL_API string IterOpenCLKernelCreator::CreateIterKernelString<float>(Ember<float>& ember, string& parVarDefines, bool lockAccum, bool doAccum);
|
||||
|
@ -48,13 +48,13 @@ bool OpenCLWrapper::Init(unsigned int platform, unsigned int device, bool shared
|
||||
|
||||
m_Init = false;
|
||||
m_ErrorReport.clear();
|
||||
|
||||
|
||||
if (m_Platforms.size() > 0)
|
||||
{
|
||||
if (platform < m_Platforms.size() && platform < m_Devices.size())
|
||||
{
|
||||
m_PlatformIndex = platform;//Platform is ok, now do context.
|
||||
|
||||
|
||||
if (CreateContext(shared))
|
||||
{
|
||||
//Context is ok, now do device.
|
||||
@ -90,10 +90,10 @@ bool OpenCLWrapper::Init(unsigned int platform, unsigned int device, bool shared
|
||||
/// <param name="program">The program source</param>
|
||||
/// <param name="entryPoint">The name of the entry point kernel function in the program</param>
|
||||
/// <returns>True if success, else false.</returns>
|
||||
bool OpenCLWrapper::AddProgram(std::string name, std::string& program, std::string& entryPoint, bool doublePrecision)
|
||||
bool OpenCLWrapper::AddProgram(const string& name, const string& program, const string& entryPoint, bool doublePrecision)
|
||||
{
|
||||
Spk spk;
|
||||
|
||||
|
||||
if (CreateSPK(name, program, entryPoint, spk, doublePrecision))
|
||||
{
|
||||
for (size_t i = 0; i < m_Programs.size(); i++)
|
||||
@ -109,7 +109,7 @@ bool OpenCLWrapper::AddProgram(std::string name, std::string& program, std::stri
|
||||
m_Programs.push_back(spk);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -135,14 +135,14 @@ void OpenCLWrapper::ClearPrograms()
|
||||
bool OpenCLWrapper::AddBuffer(const string& name, size_t size, cl_mem_flags flags)
|
||||
{
|
||||
cl_int err;
|
||||
|
||||
|
||||
if (m_Init)
|
||||
{
|
||||
int bufferIndex = FindBufferIndex(name);
|
||||
|
||||
if (bufferIndex == -1)//If the buffer didn't exist, create and add.
|
||||
{
|
||||
cl::Buffer buff(m_Context, flags, size, NULL, &err);
|
||||
cl::Buffer buff(m_Context, flags, size, nullptr, &err);
|
||||
|
||||
if (!CheckCL(err, "cl::Buffer()"))
|
||||
return false;
|
||||
@ -153,9 +153,9 @@ bool OpenCLWrapper::AddBuffer(const string& name, size_t size, cl_mem_flags flag
|
||||
}
|
||||
else if (GetBufferSize(bufferIndex) != size)//If it did exist, only create and add if the sizes were different.
|
||||
{
|
||||
m_Buffers[bufferIndex] = NamedBuffer(cl::Buffer(m_Context, flags, 0, NULL, &err), "emptybuffer");//First clear out the original so the two don't exist in memory at once.
|
||||
m_Buffers[bufferIndex] = NamedBuffer(cl::Buffer(m_Context, flags, 0, nullptr, &err), "emptybuffer");//First clear out the original so the two don't exist in memory at once.
|
||||
|
||||
cl::Buffer buff(m_Context, flags, size, NULL, &err);//Create the new buffer.
|
||||
cl::Buffer buff(m_Context, flags, size, nullptr, &err);//Create the new buffer.
|
||||
|
||||
if (!CheckCL(err, "cl::Buffer()"))
|
||||
return false;
|
||||
@ -205,7 +205,7 @@ bool OpenCLWrapper::WriteBuffer(const string& name, void* data, size_t size)
|
||||
{
|
||||
int bufferIndex = FindBufferIndex(name);
|
||||
|
||||
return bufferIndex != -1 ? WriteBuffer(bufferIndex, data, size) : false;
|
||||
return bufferIndex != -1 ? WriteBuffer(bufferIndex, data, size) : false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -220,7 +220,7 @@ bool OpenCLWrapper::WriteBuffer(unsigned int bufferIndex, void* data, size_t siz
|
||||
if (m_Init && (bufferIndex < m_Buffers.size()) && (GetBufferSize(bufferIndex) == size))
|
||||
{
|
||||
cl::Event e;
|
||||
cl_int err = m_Queue.enqueueWriteBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, NULL, &e);
|
||||
cl_int err = m_Queue.enqueueWriteBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, nullptr, &e);
|
||||
|
||||
e.wait();
|
||||
m_Queue.finish();
|
||||
@ -243,7 +243,7 @@ bool OpenCLWrapper::ReadBuffer(const string& name, void* data, size_t size)
|
||||
{
|
||||
int bufferIndex = FindBufferIndex(name);
|
||||
|
||||
return bufferIndex != -1 ? ReadBuffer(bufferIndex, data, size) : false;
|
||||
return bufferIndex != -1 ? ReadBuffer(bufferIndex, data, size) : false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -258,7 +258,7 @@ bool OpenCLWrapper::ReadBuffer(unsigned int bufferIndex, void* data, size_t size
|
||||
if (m_Init && (bufferIndex < m_Buffers.size()) && (GetBufferSize(bufferIndex) == size))
|
||||
{
|
||||
cl::Event e;
|
||||
cl_int err = m_Queue.enqueueReadBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, NULL, &e);
|
||||
cl_int err = m_Queue.enqueueReadBuffer(m_Buffers[bufferIndex].m_Buffer, CL_TRUE, 0, size, data, nullptr, &e);
|
||||
|
||||
e.wait();
|
||||
m_Queue.finish();
|
||||
@ -291,9 +291,9 @@ int OpenCLWrapper::FindBufferIndex(const string& name)
|
||||
/// <returns>The size of the buffer if found, else 0.</returns>
|
||||
unsigned int OpenCLWrapper::GetBufferSize(const string& name)
|
||||
{
|
||||
unsigned int bufferIndex = FindBufferIndex(name);
|
||||
int bufferIndex = FindBufferIndex(name);
|
||||
|
||||
return bufferIndex != -1 ? GetBufferSize(bufferIndex) : 0;
|
||||
return bufferIndex != -1 ? GetBufferSize(bufferIndex) : 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -304,7 +304,7 @@ unsigned int OpenCLWrapper::GetBufferSize(const string& name)
|
||||
unsigned int OpenCLWrapper::GetBufferSize(unsigned int bufferIndex)
|
||||
{
|
||||
if (m_Init && bufferIndex < m_Buffers.size())
|
||||
return (unsigned int)m_Buffers[bufferIndex].m_Buffer.getInfo<CL_MEM_SIZE>();
|
||||
return (unsigned int)m_Buffers[bufferIndex].m_Buffer.getInfo<CL_MEM_SIZE>(nullptr);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -437,7 +437,7 @@ bool OpenCLWrapper::WriteImage2D(unsigned int index, bool shared, ::size_t width
|
||||
cl_int err;
|
||||
cl::Event e;
|
||||
cl::size_t<3> origin, region;
|
||||
|
||||
|
||||
origin[0] = 0;
|
||||
origin[1] = 0;
|
||||
origin[2] = 0;
|
||||
@ -452,7 +452,7 @@ bool OpenCLWrapper::WriteImage2D(unsigned int index, bool shared, ::size_t width
|
||||
|
||||
if (EnqueueAcquireGLObjects(imageGL))
|
||||
{
|
||||
err = m_Queue.enqueueWriteImage(imageGL, CL_TRUE, origin, region, row_pitch, 0, data, NULL, &e);
|
||||
err = m_Queue.enqueueWriteImage(imageGL, CL_TRUE, origin, region, row_pitch, 0, data, nullptr, &e);
|
||||
e.wait();
|
||||
m_Queue.finish();
|
||||
|
||||
@ -462,7 +462,7 @@ bool OpenCLWrapper::WriteImage2D(unsigned int index, bool shared, ::size_t width
|
||||
}
|
||||
else if (!shared && index < m_Images.size())
|
||||
{
|
||||
err = m_Queue.enqueueWriteImage(m_Images[index].m_Image, CL_TRUE, origin, region, row_pitch, 0, data, NULL, &e);
|
||||
err = m_Queue.enqueueWriteImage(m_Images[index].m_Image, CL_TRUE, origin, region, row_pitch, 0, data, nullptr, &e);
|
||||
e.wait();
|
||||
m_Queue.finish();
|
||||
return CheckCL(err, "cl::enqueueWriteImage()");
|
||||
@ -512,7 +512,7 @@ bool OpenCLWrapper::ReadImage(unsigned int imageIndex, ::size_t width, ::size_t
|
||||
cl_int err;
|
||||
cl::Event e;
|
||||
cl::size_t<3> origin, region;
|
||||
|
||||
|
||||
origin[0] = 0;
|
||||
origin[1] = 0;
|
||||
origin[2] = 0;
|
||||
@ -595,16 +595,16 @@ unsigned int OpenCLWrapper::GetImageSize(unsigned int imageIndex, bool shared)
|
||||
vector<cl::Memory> images;
|
||||
images.push_back(m_GLImages[imageIndex].m_Image);
|
||||
IMAGEGL2D image = m_GLImages[imageIndex].m_Image;
|
||||
|
||||
|
||||
if (EnqueueAcquireGLObjects(&images))
|
||||
size = image.getImageInfo<CL_IMAGE_WIDTH>() * image.getImageInfo<CL_IMAGE_HEIGHT>() * image.getImageInfo<CL_IMAGE_ELEMENT_SIZE>();//Should pitch be checked here?
|
||||
size = image.getImageInfo<CL_IMAGE_WIDTH>(nullptr) * image.getImageInfo<CL_IMAGE_HEIGHT>(nullptr) * image.getImageInfo<CL_IMAGE_ELEMENT_SIZE>(nullptr);//Should pitch be checked here?
|
||||
|
||||
EnqueueReleaseGLObjects(&images);
|
||||
}
|
||||
else if (!shared && imageIndex < m_Images.size())
|
||||
{
|
||||
cl::Image2D image = m_Images[imageIndex].m_Image;
|
||||
size = image.getImageInfo<CL_IMAGE_WIDTH>() * image.getImageInfo<CL_IMAGE_HEIGHT>() * image.getImageInfo<CL_IMAGE_ELEMENT_SIZE>();//Should pitch be checked here?
|
||||
size = image.getImageInfo<CL_IMAGE_WIDTH>(nullptr) * image.getImageInfo<CL_IMAGE_HEIGHT>(nullptr) * image.getImageInfo<CL_IMAGE_ELEMENT_SIZE>(nullptr);//Should pitch be checked here?
|
||||
}
|
||||
}
|
||||
|
||||
@ -623,13 +623,13 @@ unsigned int OpenCLWrapper::GetImageSize(unsigned int imageIndex, bool shared)
|
||||
/// <returns>True if all parameters matched, else false.</returns>
|
||||
bool OpenCLWrapper::CompareImageParams(cl::Image& image, cl_mem_flags flags, const cl::ImageFormat& format, ::size_t width, ::size_t height, ::size_t row_pitch)
|
||||
{
|
||||
cl_image_format tempFormat = image.getImageInfo<CL_IMAGE_FORMAT>();
|
||||
cl_image_format tempFormat = image.getImageInfo<CL_IMAGE_FORMAT>(nullptr);
|
||||
|
||||
return (/*image.getImageInfo<CL_MEM_FLAGS>() == flags &&*/
|
||||
tempFormat.image_channel_data_type == format.image_channel_data_type &&
|
||||
tempFormat.image_channel_order == format.image_channel_order &&
|
||||
image.getImageInfo<CL_IMAGE_WIDTH>() == width &&
|
||||
image.getImageInfo<CL_IMAGE_HEIGHT>() == height/* &&
|
||||
tempFormat.image_channel_data_type == format.image_channel_data_type &&
|
||||
tempFormat.image_channel_order == format.image_channel_order &&
|
||||
image.getImageInfo<CL_IMAGE_WIDTH>(nullptr) == width &&
|
||||
image.getImageInfo<CL_IMAGE_HEIGHT>(nullptr) == height/* &&
|
||||
image.getImageInfo<CL_IMAGE_ROW_PITCH>() == row_pitch*/);//Pitch will be (width * bytes per pixel) + padding.
|
||||
}
|
||||
|
||||
@ -822,7 +822,7 @@ bool OpenCLWrapper::EnqueueReleaseGLObjects(const VECTOR_CLASS<cl::Memory>* memO
|
||||
bool OpenCLWrapper::CreateSampler(cl::Sampler& sampler, cl_bool normalizedCoords, cl_addressing_mode addressingMode, cl_filter_mode filterMode)
|
||||
{
|
||||
cl_int err;
|
||||
|
||||
|
||||
sampler = cl::Sampler(m_Context,
|
||||
normalizedCoords,
|
||||
addressingMode,
|
||||
@ -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, string name)
|
||||
bool OpenCLWrapper::SetBufferArg(unsigned int kernelIndex, unsigned int argIndex, const string& name)
|
||||
{
|
||||
int bufferIndex = OpenCLWrapper::FindBufferIndex(name);
|
||||
|
||||
@ -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, string name)
|
||||
bool OpenCLWrapper::SetImageArg(unsigned int kernelIndex, unsigned int argIndex, bool shared, const string& name)
|
||||
{
|
||||
if (m_Init)
|
||||
{
|
||||
@ -948,7 +948,7 @@ bool OpenCLWrapper::RunKernel(unsigned int kernelIndex, unsigned int totalGridWi
|
||||
cl::NullRange,
|
||||
cl::NDRange(totalGridWidth, totalGridHeight, totalGridDepth),
|
||||
cl::NDRange(blockWidth, blockHeight, blockDepth),
|
||||
NULL,
|
||||
nullptr,
|
||||
&e);
|
||||
|
||||
e.wait();
|
||||
@ -984,7 +984,7 @@ T OpenCLWrapper::GetInfo(size_t platform, size_t device, cl_device_info name)
|
||||
string OpenCLWrapper::PlatformName(size_t platform)
|
||||
{
|
||||
if (platform < m_Platforms.size())
|
||||
return m_Platforms[platform].getInfo<CL_PLATFORM_VENDOR>() + " " + m_Platforms[platform].getInfo<CL_PLATFORM_NAME>() + " " + m_Platforms[platform].getInfo<CL_PLATFORM_VERSION>();
|
||||
return m_Platforms[platform].getInfo<CL_PLATFORM_VENDOR>(nullptr) + " " + m_Platforms[platform].getInfo<CL_PLATFORM_NAME>(nullptr) + " " + m_Platforms[platform].getInfo<CL_PLATFORM_VERSION>(nullptr);
|
||||
else
|
||||
return "";
|
||||
}
|
||||
@ -1018,7 +1018,7 @@ string OpenCLWrapper::DeviceName(size_t platform, size_t device)
|
||||
|
||||
if (platform < m_Platforms.size() && platform < m_Devices.size())
|
||||
if (device < m_Devices[platform].size())
|
||||
s = m_Devices[platform][device].getInfo<CL_DEVICE_VENDOR>() + " " + m_Devices[platform][device].getInfo<CL_DEVICE_NAME>();// + " " + m_Devices[platform][device].getInfo<CL_DEVICE_VERSION>();
|
||||
s = m_Devices[platform][device].getInfo<CL_DEVICE_VENDOR>(nullptr) + " " + m_Devices[platform][device].getInfo<CL_DEVICE_NAME>(nullptr);// + " " + m_Devices[platform][device].getInfo<CL_DEVICE_VERSION>();
|
||||
|
||||
return s;
|
||||
}
|
||||
@ -1043,7 +1043,7 @@ vector<string> OpenCLWrapper::DeviceNames(size_t platform)
|
||||
|
||||
i++;
|
||||
} while (s != "");
|
||||
|
||||
|
||||
return devices;
|
||||
}
|
||||
|
||||
@ -1094,13 +1094,13 @@ string OpenCLWrapper::DumpInfo()
|
||||
os << "CL_DEVICE_MAX_READ_IMAGE_ARGS: " << GetInfo<cl_uint> (platform, device, CL_DEVICE_MAX_READ_IMAGE_ARGS) << endl;
|
||||
os << "CL_DEVICE_MAX_WRITE_IMAGE_ARGS: " << GetInfo<cl_uint> (platform, device, CL_DEVICE_MAX_WRITE_IMAGE_ARGS) << endl;
|
||||
os << "CL_DEVICE_MAX_MEM_ALLOC_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_MAX_MEM_ALLOC_SIZE) << endl;
|
||||
|
||||
|
||||
os << "CL_DEVICE_GLOBAL_MEM_CACHE_TYPE: " << GetInfo<cl_uint> (platform, device, CL_DEVICE_GLOBAL_MEM_CACHE_TYPE) << endl;
|
||||
os << "CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE: " << GetInfo<cl_uint> (platform, device, CL_DEVICE_GLOBAL_MEM_CACHELINE_SIZE) << endl;
|
||||
os << "CL_DEVICE_GLOBAL_MEM_CACHE_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_GLOBAL_MEM_CACHE_SIZE) << endl;
|
||||
os << "CL_DEVICE_GLOBAL_MEM_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_GLOBAL_MEM_SIZE) << endl;
|
||||
os << "CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE: " << GetInfo<cl_ulong>(platform, device, CL_DEVICE_MAX_CONSTANT_BUFFER_SIZE) << endl;
|
||||
|
||||
|
||||
os << "CL_DEVICE_MAX_CONSTANT_ARGS: " << GetInfo<cl_uint> (platform, device, CL_DEVICE_MAX_CONSTANT_ARGS) << endl;
|
||||
os << "CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS: " << GetInfo<cl_uint> (platform, device, CL_DEVICE_MAX_WORK_ITEM_DIMENSIONS) << endl;
|
||||
os << "CL_DEVICE_MAX_WORK_GROUP_SIZE: " << GetInfo<::size_t>(platform, device, CL_DEVICE_MAX_WORK_GROUP_SIZE) << endl;
|
||||
@ -1165,7 +1165,7 @@ bool OpenCLWrapper::CreateContext(bool shared)
|
||||
0
|
||||
};
|
||||
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_GPU, props, NULL, NULL, &err);//May need to tinker with this on Mac.
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_GPU, props, nullptr, nullptr, &err);//May need to tinker with this on Mac.
|
||||
#else
|
||||
#if defined WIN32
|
||||
cl_context_properties props[] =
|
||||
@ -1175,18 +1175,18 @@ bool OpenCLWrapper::CreateContext(bool shared)
|
||||
CL_CONTEXT_PLATFORM, (cl_context_properties)(m_Platforms[m_PlatformIndex])(),
|
||||
0
|
||||
};
|
||||
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_GPU, props, NULL, NULL, &err);
|
||||
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_GPU, props, nullptr, nullptr, &err);
|
||||
#else
|
||||
cl_context_properties props[] =
|
||||
{
|
||||
CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
|
||||
CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
|
||||
CL_CONTEXT_PLATFORM, (cl_context_properties)(m_Platforms[m_Platform])(),
|
||||
CL_CONTEXT_PLATFORM, (cl_context_properties)(m_Platforms[m_PlatformIndex])(),
|
||||
0
|
||||
};
|
||||
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_GPU, props, NULL, NULL, &err);
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_GPU, props, nullptr, nullptr, &err);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
@ -1199,7 +1199,7 @@ bool OpenCLWrapper::CreateContext(bool shared)
|
||||
0
|
||||
};
|
||||
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_ALL, props, NULL, NULL, &err);
|
||||
m_Context = cl::Context(CL_DEVICE_TYPE_ALL, props, nullptr, nullptr, &err);
|
||||
}
|
||||
|
||||
return CheckCL(err, "cl::Context()");
|
||||
@ -1213,7 +1213,7 @@ bool OpenCLWrapper::CreateContext(bool shared)
|
||||
/// <param name="entryPoint">The name of the entry point kernel function in the program</param>
|
||||
/// <param name="spk">The Spk object to store the resulting compiled program in</param>
|
||||
/// <returns>True if success, else false.</returns>
|
||||
bool OpenCLWrapper::CreateSPK(std::string& name, std::string& program, std::string& entryPoint, Spk& spk, bool doublePrecision)
|
||||
bool OpenCLWrapper::CreateSPK(const string& name, const string& program, const string& entryPoint, Spk& spk, bool doublePrecision)
|
||||
{
|
||||
if (m_Init)
|
||||
{
|
||||
@ -1231,12 +1231,12 @@ bool OpenCLWrapper::CreateSPK(std::string& name, std::string& program, std::stri
|
||||
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant");
|
||||
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-no-signed-zeros -cl-fast-relaxed-math -cl-single-precision-constant");//This can cause some rounding.
|
||||
//err = spk.m_Program.build(m_DeviceVec, "-cl-mad-enable -cl-single-precision-constant");
|
||||
|
||||
|
||||
if (CheckCL(err, "cl::Program::build()"))
|
||||
{
|
||||
//Building of program is ok, now create kernel with the specified entry point.
|
||||
spk.m_Kernel = cl::Kernel(spk.m_Program, entryPoint.c_str(), &err);
|
||||
|
||||
|
||||
if (CheckCL(err, "cl::Kernel()"))
|
||||
return true;//Everything is ok.
|
||||
}
|
||||
@ -1330,4 +1330,4 @@ std::string OpenCLWrapper::ErrorToStringCL(cl_int err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
NamedBuffer(cl::Buffer& buff, string name)
|
||||
NamedBuffer(const cl::Buffer& buff, const string& name)
|
||||
{
|
||||
m_Buffer = buff;
|
||||
m_Name = name;
|
||||
@ -57,7 +57,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
NamedImage2D(cl::Image2D& image, string name)
|
||||
NamedImage2D(const cl::Image2D& image, const string& name)
|
||||
{
|
||||
m_Image = image;
|
||||
m_Name = name;
|
||||
@ -78,7 +78,7 @@ public:
|
||||
{
|
||||
}
|
||||
|
||||
NamedImage2DGL(IMAGEGL2D& image, string name)
|
||||
NamedImage2DGL(const IMAGEGL2D& image, const string& name)
|
||||
{
|
||||
m_Image = image;
|
||||
m_Name = name;
|
||||
@ -107,7 +107,7 @@ public:
|
||||
bool Init(unsigned int platform, unsigned int device, bool shared = false);
|
||||
|
||||
//Programs.
|
||||
bool AddProgram(std::string name, std::string& program, std::string& entryPoint, bool doublePrecision);
|
||||
bool AddProgram(const string& name, const string& program, const string& entryPoint, bool doublePrecision);
|
||||
void ClearPrograms();
|
||||
|
||||
//Buffers.
|
||||
@ -141,13 +141,13 @@ public:
|
||||
bool EnqueueAcquireGLObjects(const VECTOR_CLASS<cl::Memory>* memObjects = NULL);
|
||||
bool EnqueueReleaseGLObjects(const VECTOR_CLASS<cl::Memory>* memObjects = NULL);
|
||||
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, string name);
|
||||
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, string name);
|
||||
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);
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Set an argument in the specified kernel, at the specified argument index.
|
||||
/// Must keep this here in the .h because it's templated.
|
||||
@ -195,7 +195,7 @@ public:
|
||||
|
||||
private:
|
||||
bool CreateContext(bool shared);
|
||||
bool CreateSPK(std::string& name, std::string& program, std::string& entryPoint, Spk& spk, bool doublePrecision);
|
||||
bool CreateSPK(const string& name, const string& program, const string& entryPoint, Spk& spk, bool doublePrecision);
|
||||
bool CheckCL(cl_int err, const char* name);
|
||||
std::string ErrorToStringCL(cl_int err);
|
||||
|
||||
@ -216,4 +216,4 @@ private:
|
||||
std::vector<NamedImage2D> m_Images;
|
||||
std::vector<NamedImage2DGL> m_GLImages;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -52,7 +52,7 @@ RendererCL<T>::RendererCL(unsigned int platform, unsigned int device, bool share
|
||||
m_PaletteFormat.image_channel_data_type = CL_FLOAT;
|
||||
m_FinalFormat.image_channel_order = CL_RGBA;
|
||||
m_FinalFormat.image_channel_data_type = CL_UNORM_INT8;//Change if this ever supports 2BPC outputs for PNG.
|
||||
|
||||
|
||||
FillSeeds();
|
||||
Init(platform, device, shared, outputTexID);//Init OpenCL upon construction and create programs that will not change.
|
||||
}
|
||||
@ -73,7 +73,7 @@ RendererCL<T>::~RendererCL()
|
||||
/// Initialize OpenCL.
|
||||
/// In addition to initializing, this function will create the zeroization program,
|
||||
/// as well as the basic log scale filtering programs. This is done to ensure basic
|
||||
/// compilation works. Further compilation will be done later for iteration, density filtering,
|
||||
/// compilation works. Further compilation will be done later for iteration, density filtering,
|
||||
/// and final accumulation.
|
||||
/// </summary>
|
||||
/// <param name="platform">The index platform of the platform to use</param>
|
||||
@ -146,7 +146,7 @@ bool RendererCL<T>::SetOutputTexture(GLuint outputTexID)
|
||||
m_ErrorReport.push_back(loc);
|
||||
success = false;
|
||||
}
|
||||
|
||||
|
||||
LeaveResize();
|
||||
return success;
|
||||
}
|
||||
@ -312,7 +312,7 @@ bool RendererCL<T>::ClearFinal()
|
||||
vector<unsigned char> v;
|
||||
unsigned int index = m_Wrapper.FindImageIndex(m_FinalImageName, m_Wrapper.Shared());
|
||||
|
||||
if (PrepFinalAccumVector(v))
|
||||
if (this->PrepFinalAccumVector(v))
|
||||
{
|
||||
bool b = m_Wrapper.WriteImage2D(index, m_Wrapper.Shared(), FinalRasW(), FinalRasH(), 0, v.data());
|
||||
|
||||
@ -472,7 +472,7 @@ eRendererType RendererCL<T>::RendererType() const
|
||||
/// </summary>
|
||||
/// <returns>The concatenated error report string</returns>
|
||||
template <typename T>
|
||||
string RendererCL<T>::ErrorReportString()
|
||||
string RendererCL<T>::ErrorReportString()
|
||||
{
|
||||
return EmberReport::ErrorReportString() + m_Wrapper.ErrorReportString();
|
||||
}
|
||||
@ -527,9 +527,11 @@ bool RendererCL<T>::RandVec(vector<QTIsaac<ISAAC_SIZE, ISAAC_INT>>& randVec)
|
||||
template <typename T>
|
||||
void RendererCL<T>::MakeDmap(T colorScalar)
|
||||
{
|
||||
m_Ember.m_Palette.MakeDmap<float>(m_Dmap, colorScalar);
|
||||
//m_Ember.m_Palette.MakeDmap<float>(m_DmapCL, colorScalar);
|
||||
m_Ember.m_Palette.MakeDmap(m_DmapCL, colorScalar);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Allocate all buffers required for running as well as the final
|
||||
/// 2D image.
|
||||
@ -561,9 +563,10 @@ bool RendererCL<T>::Alloc()
|
||||
if (b && !(b = m_Wrapper.AddBuffer(m_AccumBufferName, accumLength))) { m_ErrorReport.push_back(loc); }//Accum buffer.
|
||||
if (b && !(b = m_Wrapper.AddBuffer(m_PointsBufferName, IterGridKernelCount() * sizeof(PointCL<T>)))) { m_ErrorReport.push_back(loc); }//Points between iter calls.
|
||||
|
||||
LeaveResize();
|
||||
|
||||
if (b && !(b = SetOutputTexture(m_OutputTexID))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
LeaveResize();
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
@ -706,7 +709,7 @@ EmberStats RendererCL<T>::Iterate(size_t iterCount, size_t temporalSample)
|
||||
else
|
||||
{
|
||||
m_Abort = true;
|
||||
m_ErrorReport.push_back(loc);
|
||||
m_ErrorReport.push_back(loc);
|
||||
}
|
||||
|
||||
return stats;
|
||||
@ -787,9 +790,9 @@ bool RendererCL<T>::RunIter(size_t iterCount, size_t temporalSample, size_t& ite
|
||||
if (b && !(b = m_Wrapper.WriteBuffer (m_XformsBufferName, (void*)m_XformsCL.data(), sizeof(m_XformsCL[0]) * m_XformsCL.size()))) { m_ErrorReport.push_back(loc); }
|
||||
if (b && !(b = m_Wrapper.AddAndWriteBuffer(m_DistBufferName, (void*)XformDistributions(), XformDistributionsSize()))) { m_ErrorReport.push_back(loc); }//Will be resized for xaos.
|
||||
if (b && !(b = m_Wrapper.WriteBuffer (m_CarToRasBufferName, (void*)&m_CarToRasCL, sizeof(m_CarToRasCL)))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
if (b && !(b = m_Wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, m_Dmap.m_Entries.size(), 1, 0, m_Dmap.m_Entries.data()))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
|
||||
if (b && !(b = m_Wrapper.AddAndWriteImage("Palette", CL_MEM_READ_ONLY, m_PaletteFormat, m_DmapCL.m_Entries.size(), 1, 0, m_DmapCL.m_Entries.data()))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
//If animating, treat each temporal sample as a newly started render for fusing purposes.
|
||||
if (temporalSample > 0)
|
||||
m_Calls = 0;
|
||||
@ -830,7 +833,7 @@ bool RendererCL<T>::RunIter(size_t iterCount, size_t temporalSample, size_t& ite
|
||||
if (b && !(b = m_Wrapper.SetArg (kernelIndex, argIndex++, supersize))) { m_ErrorReport.push_back(loc); }//Histogram size.
|
||||
if (b && !(b = m_Wrapper.SetImageArg (kernelIndex, argIndex++, false, "Palette"))) { m_ErrorReport.push_back(loc); }//Palette.
|
||||
if (b && !(b = m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_PointsBufferName))) { m_ErrorReport.push_back(loc); }//Random start points.
|
||||
|
||||
|
||||
if (b && !(b = m_Wrapper.RunKernel(kernelIndex,
|
||||
gridW * IterBlockKernelWidth(),//Total grid dims.
|
||||
gridH * IterBlockKernelHeight(),
|
||||
@ -840,10 +843,10 @@ bool RendererCL<T>::RunIter(size_t iterCount, size_t temporalSample, size_t& ite
|
||||
1)))
|
||||
{
|
||||
m_Abort = true;
|
||||
m_ErrorReport.push_back(loc);
|
||||
m_ErrorReport.push_back(loc);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
itersRan += iterCountThisLaunch;
|
||||
m_Calls++;
|
||||
|
||||
@ -863,14 +866,14 @@ bool RendererCL<T>::RunIter(size_t iterCount, size_t temporalSample, size_t& ite
|
||||
|
||||
double percentDiff = percent - m_LastIterPercent;
|
||||
double toc = m_ProgressTimer.Toc();
|
||||
|
||||
|
||||
if (percentDiff >= 10 || (toc > 1000 && percentDiff >= 1))//Call callback function if either 10% has passed, or one second (and 1%).
|
||||
{
|
||||
etaMs = ((100.0 - percent) / percent) * m_RenderTimer.Toc();
|
||||
|
||||
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 0, etaMs))
|
||||
Abort();
|
||||
|
||||
|
||||
m_LastIterPercent = percent;
|
||||
m_ProgressTimer.Tic();
|
||||
}
|
||||
@ -901,7 +904,7 @@ eRenderStatus RendererCL<T>::RunLogScaleFilter()
|
||||
eRenderStatus status = RENDER_OK;
|
||||
|
||||
if (kernelIndex != -1)
|
||||
{
|
||||
{
|
||||
m_DensityFilterCL = ConvertDensityFilter();
|
||||
unsigned int argIndex = 0;
|
||||
unsigned int blockW = m_WarpSize;
|
||||
@ -910,7 +913,7 @@ eRenderStatus RendererCL<T>::RunLogScaleFilter()
|
||||
unsigned int gridH = m_DensityFilterCL.m_SuperRasH;
|
||||
|
||||
OpenCLWrapper::MakeEvenGridDims(blockW, blockH, gridW, gridH);
|
||||
|
||||
|
||||
if (b && !(b = m_Wrapper.AddAndWriteBuffer(m_DEFilterParamsBufferName, (void*)&m_DensityFilterCL, sizeof(m_DensityFilterCL)))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
if (b && !(b = m_Wrapper.SetBufferArg(kernelIndex, argIndex++, m_HistBufferName))) { m_ErrorReport.push_back(loc); }//Histogram.
|
||||
@ -926,7 +929,7 @@ eRenderStatus RendererCL<T>::RunLogScaleFilter()
|
||||
b = false;
|
||||
m_ErrorReport.push_back(loc);
|
||||
}
|
||||
|
||||
|
||||
if (b && m_Callback)
|
||||
m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, 100.0, 1, 0.0);
|
||||
|
||||
@ -1030,7 +1033,7 @@ eRenderStatus RendererCL<T>::RunDensityFilter()
|
||||
{
|
||||
double percent = (double((rowChunk * chunkSizeW) + (colChunk + 1)) / totalChunks) * 100.0;
|
||||
double etaMs = ((100.0 - percent) / percent) * t.Toc();
|
||||
|
||||
|
||||
if (!m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, percent, 1, etaMs))
|
||||
Abort();
|
||||
}
|
||||
@ -1040,7 +1043,7 @@ eRenderStatus RendererCL<T>::RunDensityFilter()
|
||||
|
||||
if (b && m_Callback)
|
||||
m_Callback->ProgressFunc(m_Ember, m_ProgressParameter, 100.0, 1, 0.0);
|
||||
|
||||
|
||||
//t2.Toc(__FUNCTION__ " all passes");
|
||||
}
|
||||
else
|
||||
@ -1048,10 +1051,10 @@ eRenderStatus RendererCL<T>::RunDensityFilter()
|
||||
b = false;
|
||||
m_ErrorReport.push_back(loc);
|
||||
}
|
||||
|
||||
|
||||
return m_Abort ? RENDER_ABORT : (b ? RENDER_OK : RENDER_ERROR);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Run final accumulation to the 2D output image.
|
||||
/// </summary>
|
||||
@ -1096,13 +1099,13 @@ eRenderStatus RendererCL<T>::RunFinalAccum()
|
||||
|
||||
if (b && !(b = m_Wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_AccumBufferName))) { m_ErrorReport.push_back(loc); }//Accumulator.
|
||||
if (b && !(b = m_Wrapper.SetBufferArg(gammaCorrectKernelIndex, argIndex++, m_SpatialFilterParamsBufferName))) { m_ErrorReport.push_back(loc); }//SpatialFilterCL.
|
||||
|
||||
|
||||
if (b && !(b = m_Wrapper.RunKernel(gammaCorrectKernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { m_ErrorReport.push_back(loc); }
|
||||
}
|
||||
else
|
||||
{
|
||||
b = false;
|
||||
m_ErrorReport.push_back(loc);
|
||||
m_ErrorReport.push_back(loc);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1122,9 +1125,9 @@ eRenderStatus RendererCL<T>::RunFinalAccum()
|
||||
|
||||
if (b && m_Wrapper.Shared())
|
||||
if (b && !(b = m_Wrapper.EnqueueAcquireGLObjects(m_FinalImageName))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
|
||||
if (b && !(b = m_Wrapper.RunKernel(accumKernelIndex, gridW, gridH, 1, blockW, blockH, 1))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
|
||||
if (b && m_Wrapper.Shared())
|
||||
if (b && !(b = m_Wrapper.EnqueueReleaseGLObjects(m_FinalImageName))) { m_ErrorReport.push_back(loc); }
|
||||
|
||||
@ -1135,7 +1138,7 @@ eRenderStatus RendererCL<T>::RunFinalAccum()
|
||||
b = false;
|
||||
m_ErrorReport.push_back(loc);
|
||||
}
|
||||
|
||||
|
||||
return b ? RENDER_OK : RENDER_ERROR;
|
||||
}
|
||||
|
||||
@ -1350,7 +1353,7 @@ SpatialFilterCL<T> RendererCL<T>::ConvertSpatialFilter()
|
||||
Color<T> background;
|
||||
SpatialFilterCL<T> filterCL;
|
||||
|
||||
PrepFinalAccumVals(background, g, linRange, vibrancy);
|
||||
this->PrepFinalAccumVals(background, g, linRange, vibrancy);
|
||||
|
||||
filterCL.m_SuperRasW = (unsigned int)SuperRasW();
|
||||
filterCL.m_SuperRasH = (unsigned int)SuperRasH();
|
||||
@ -1368,7 +1371,7 @@ SpatialFilterCL<T> RendererCL<T>::ConvertSpatialFilter()
|
||||
filterCL.m_Gamma = g;
|
||||
filterCL.m_LinRange = linRange;
|
||||
filterCL.m_Background = background;
|
||||
|
||||
|
||||
return filterCL;
|
||||
}
|
||||
|
||||
@ -1467,4 +1470,10 @@ void RendererCL<T>::FillSeeds()
|
||||
m_Seeds[i].y = m_Rand[0].Rand();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template EMBERCL_API class RendererCL<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class RendererCL<double>;
|
||||
#endif
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ namespace EmberCLns
|
||||
class EMBERCL_API RendererCLBase
|
||||
{
|
||||
public:
|
||||
virtual ~RendererCLBase() { }
|
||||
virtual bool ReadFinal(unsigned char* pixels) = 0;
|
||||
virtual bool ClearFinal() = 0;
|
||||
};
|
||||
@ -33,8 +34,25 @@ public:
|
||||
/// and uses both for the base.
|
||||
/// </summary>
|
||||
template <typename T>
|
||||
class EMBERCL_API RendererCL : public RendererCLBase, public Renderer<T, T>
|
||||
class EMBERCL_API RendererCL : public Renderer<T, T>, public RendererCLBase
|
||||
{
|
||||
using EmberNs::Renderer<T, T>::RendererBase::EmberReport::m_ErrorReport;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_ProgressParameter;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_YAxisUp;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_LockAccum;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_Abort;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_NumChannels;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_LastIter;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_LastIterPercent;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_Stats;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_Callback;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_Rand;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_RenderTimer;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_IterTimer;
|
||||
using EmberNs::Renderer<T, T>::RendererBase::m_ProgressTimer;
|
||||
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();
|
||||
@ -158,7 +176,7 @@ private:
|
||||
|
||||
//Kernels.
|
||||
string m_IterKernel;
|
||||
|
||||
|
||||
OpenCLWrapper m_Wrapper;
|
||||
cl::ImageFormat m_PaletteFormat;
|
||||
cl::ImageFormat m_FinalFormat;
|
||||
@ -168,7 +186,7 @@ private:
|
||||
EmberCL<T> m_EmberCL;
|
||||
vector<XformCL<T>> m_XformsCL;
|
||||
vector<glm::highp_uvec2> m_Seeds;
|
||||
Palette<float> m_Dmap;//Used instead of the base class' m_Dmap because OpenCL only supports float textures.
|
||||
Palette<float> m_DmapCL;//Used instead of the base class' m_Dmap because OpenCL only supports float textures.
|
||||
CarToRasCL<T> m_CarToRasCL;
|
||||
DensityFilterCL<T> m_DensityFilterCL;
|
||||
SpatialFilterCL<T> m_SpatialFilterCL;
|
||||
@ -179,9 +197,9 @@ private:
|
||||
Ember<T> m_LastBuiltEmber;
|
||||
};
|
||||
|
||||
template EMBERCL_API class RendererCL<float>;
|
||||
|
||||
#ifdef DO_DOUBLE
|
||||
template EMBERCL_API class RendererCL<double>;
|
||||
#endif
|
||||
}
|
||||
//template EMBERCL_API class RendererCL<float>;
|
||||
//
|
||||
//#ifdef DO_DOUBLE
|
||||
// template EMBERCL_API class RendererCL<double>;
|
||||
//#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user