本文整理汇总了C++中ProgramFactory::PopDefines方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramFactory::PopDefines方法的具体用法?C++ ProgramFactory::PopDefines怎么用?C++ ProgramFactory::PopDefines使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramFactory
的用法示例。
在下文中一共展示了ProgramFactory::PopDefines方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mNumXGroups
Fluid3InitializeSource::Fluid3InitializeSource(ProgramFactory& factory,
int xSize, int ySize, int zSize, int numXThreads, int numYThreads,
int numZThreads, std::shared_ptr<ConstantBuffer> const& parameters)
:
mNumXGroups(xSize/numXThreads),
mNumYGroups(ySize/numYThreads),
mNumZGroups(zSize/numZThreads)
{
// Create the resources for generating velocity from vortices.
mVortex = std::make_shared<ConstantBuffer>(sizeof(Vortex), true);
mVelocity0 = std::make_shared<Texture3>(DF_R32G32B32A32_FLOAT, xSize,
ySize, zSize);
mVelocity0->SetUsage(Resource::SHADER_OUTPUT);
mVelocity1 = std::make_shared<Texture3>(DF_R32G32B32A32_FLOAT, xSize,
ySize, zSize);
mVelocity1->SetUsage(Resource::SHADER_OUTPUT);
// Create the resources for generating velocity from wind and gravity.
mExternal = std::make_shared<ConstantBuffer>(sizeof(External), false);
External& e = *mExternal->Get<External>();
e.densityProducer = { 0.5f, 0.5f, 0.5f, 0.0f };
e.densityPData = { 0.01f, 16.0f, 0.0f, 0.0f };
e.densityConsumer = { 0.75f, 0.75f, 0.75f, 0.0f };
e.densityCData = { 0.01f, 0.0f, 0.0f, 0.0f };
e.gravity = { 0.0f, 0.0f, 0.0f, 0.0f };
e.windData = { 0.001f, 0.0f, 0.0f, 0.0f };
mSource = std::make_shared<Texture3>(DF_R32G32B32A32_FLOAT, xSize, ySize,
zSize);
mSource->SetUsage(Resource::SHADER_OUTPUT);
// Create the shader for generating velocity from vortices.
int i = factory.GetAPI();
factory.PushDefines();
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
factory.defines.Set("NUM_Z_THREADS", numZThreads);
std::shared_ptr<ComputeShader> cshader;
mGenerateVortex = factory.CreateFromSource(*msGenerateSource[i]);
if (mGenerateVortex)
{
cshader = mGenerateVortex->GetCShader();
cshader->Set("Parameters", parameters);
cshader->Set("Vortex", mVortex);
cshader->Set("inVelocity", mVelocity0);
cshader->Set("outVelocity", mVelocity1);
}
// Create the shader for generating the sources to the fluid simulation.
mInitializeSource = factory.CreateFromSource(*msInitializeSource[i]);
if (mInitializeSource)
{
cshader = mInitializeSource->GetCShader();
cshader->Set("Parameters", parameters);
cshader->Set("External", mExternal);
cshader->Set("source", mSource);
}
factory.PopDefines();
}
示例2: mNumXGroups
Fluid3ComputeDivergence::Fluid3ComputeDivergence(ProgramFactory& factory,
int xSize, int ySize, int zSize, int numXThreads, int numYThreads,
int numZThreads, std::shared_ptr<ConstantBuffer> const& parameters)
:
mNumXGroups(xSize/numXThreads),
mNumYGroups(ySize/numYThreads),
mNumZGroups(zSize/numZThreads)
{
mDivergence = std::make_shared<Texture3>(DF_R32_FLOAT, xSize, ySize,
zSize);
mDivergence->SetUsage(Resource::SHADER_OUTPUT);
int i = factory.GetAPI();
factory.PushDefines();
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
factory.defines.Set("NUM_Z_THREADS", numZThreads);
mComputeDivergence = factory.CreateFromSource(*msSource[i]);
if (mComputeDivergence)
{
mComputeDivergence->GetCShader()->Set("Parameters", parameters);
mComputeDivergence->GetCShader()->Set("divergence", mDivergence);
}
factory.PopDefines();
}
示例3: mNumXGroups
Fluid2InitializeState::Fluid2InitializeState(ProgramFactory& factory,
int xSize, int ySize, int numXThreads, int numYThreads)
:
mNumXGroups(xSize/numXThreads),
mNumYGroups(ySize/numYThreads)
{
// Use a Mersenne twister engine for random numbers.
std::mt19937 mte;
std::uniform_real_distribution<float> unirnd(0.0f, 1.0f);
// Initial density values are randomly generated.
mDensity = std::make_shared<Texture2>(DF_R32_FLOAT, xSize, ySize);
float* data = mDensity->Get<float>();
for (unsigned int i = 0; i < mDensity->GetNumElements(); ++i, ++data)
{
*data = unirnd(mte);
}
// Initial velocity values are zero.
mVelocity = std::make_shared<Texture2>(DF_R32G32_FLOAT, xSize, ySize);
memset(mVelocity->GetData(), 0, mVelocity->GetNumBytes());
// The states at time 0 and time -dt are initialized by a compute shader.
mStateTm1 = std::make_shared<Texture2>(DF_R32G32B32A32_FLOAT, xSize,
ySize);
mStateTm1->SetUsage(Resource::SHADER_OUTPUT);
mStateT = std::make_shared<Texture2>(DF_R32G32B32A32_FLOAT, xSize, ySize);
mStateT->SetUsage(Resource::SHADER_OUTPUT);
// Create the shader for initializing velocity and density.
int i = factory.GetAPI();
factory.PushDefines();
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
mInitializeState = factory.CreateFromSource(*msSource[i]);
if (mInitializeState)
{
std::shared_ptr<ComputeShader> cshader =
mInitializeState->GetCShader();
cshader->Set("density", mDensity);
cshader->Set("velocity", mVelocity);
cshader->Set("stateTm1", mStateTm1);
cshader->Set("stateT", mStateT);
}
factory.PopDefines();
}
示例4: mNumXGroups
Fluid2SolvePoisson::Fluid2SolvePoisson(ProgramFactory& factory, int xSize,
int ySize, int numXThreads, int numYThreads,
std::shared_ptr<ConstantBuffer> const& parameters, int numIterations)
:
mNumXGroups(xSize/numXThreads),
mNumYGroups(ySize/numYThreads),
mNumIterations(numIterations)
{
mPoisson0 = std::make_shared<Texture2>(DF_R32_FLOAT, xSize, ySize);
mPoisson0->SetUsage(Resource::SHADER_OUTPUT);
mPoisson1 = std::make_shared<Texture2>(DF_R32_FLOAT, xSize, ySize);
mPoisson1->SetUsage(Resource::SHADER_OUTPUT);
int i = factory.GetAPI();
factory.PushDefines();
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
// For zeroing mPoisson0 on the GPU.
mZeroPoisson = factory.CreateFromSource(*msZeroSource[i]);
if (mZeroPoisson)
{
mZeroPoisson->GetCShader()->Set("poisson", mPoisson0);
}
// Create the shader for generating velocity from vortices.
mSolvePoisson = factory.CreateFromSource(*msSolveSource[i]);
if (mSolvePoisson)
{
mSolvePoisson->GetCShader()->Set("Parameters", parameters);
}
factory.defines.Clear();
factory.defines.Set("USE_ZERO_X_EDGE", 1);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
mWriteXEdge = factory.CreateFromSource(*msEnforceSource[i]);
factory.defines.Clear();
factory.defines.Set("USE_ZERO_Y_EDGE", 1);
factory.defines.Set("NUM_X_THREADS", numXThreads);
mWriteYEdge = factory.CreateFromSource(*msEnforceSource[i]);
factory.PopDefines();
}
示例5: mNumXGroups
Fluid2AdjustVelocity::Fluid2AdjustVelocity(ProgramFactory& factory,
int xSize, int ySize, int numXThreads, int numYThreads,
std::shared_ptr<ConstantBuffer> const& parameters)
:
mNumXGroups(xSize/numXThreads),
mNumYGroups(ySize/numYThreads)
{
int i = factory.GetAPI();
factory.PushDefines();
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
mAdjustVelocity = factory.CreateFromSource(*msSource[i]);
if (mAdjustVelocity)
{
mAdjustVelocity->GetCShader()->Set("Parameters", parameters);
}
factory.PopDefines();
}
示例6: mNumColumns
//.........这里部分代码省略.........
std::shared_ptr<ComputeShader> cshader = mRK4Shader[0]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("constantC", mConstantC);
cshader->Set("lengthC", mLengthC);
cshader->Set("constantR", mConstantR);
cshader->Set("lengthR", mLengthR);
cshader->Set("constantS", mConstantS);
cshader->Set("lengthS", mLengthS);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
cshader->Set("position", mPosition);
cshader->Set("velocity", mVelocity);
cshader = mRK4Shader[1]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("pTmp", mPTmp);
cshader->Set("vTmp", mVTmp);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
cshader->Set("position", mPosition);
cshader->Set("velocity", mVelocity);
cshader = mRK4Shader[2]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("constantC", mConstantC);
cshader->Set("lengthC", mLengthC);
cshader->Set("constantR", mConstantR);
cshader->Set("lengthR", mLengthR);
cshader->Set("constantS", mConstantS);
cshader->Set("lengthS", mLengthS);
cshader->Set("pTmp", mPTmp);
cshader->Set("vTmp", mVTmp);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
cshader->Set("velocity", mVelocity);
cshader = mRK4Shader[3]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("pTmp", mPTmp);
cshader->Set("vTmp", mVTmp);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
cshader->Set("position", mPosition);
cshader->Set("velocity", mVelocity);
cshader = mRK4Shader[4]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("constantC", mConstantC);
cshader->Set("lengthC", mLengthC);
cshader->Set("constantR", mConstantR);
cshader->Set("lengthR", mLengthR);
cshader->Set("constantS", mConstantS);
cshader->Set("lengthS", mLengthS);
cshader->Set("pTmp", mPTmp);
cshader->Set("vTmp", mVTmp);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
cshader->Set("velocity", mVelocity);
cshader = mRK4Shader[5]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("pTmp", mPTmp);
cshader->Set("vTmp", mVTmp);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
cshader->Set("position", mPosition);
cshader->Set("velocity", mVelocity);
cshader = mRK4Shader[6]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("constantC", mConstantC);
cshader->Set("lengthC", mLengthC);
cshader->Set("constantR", mConstantR);
cshader->Set("lengthR", mLengthR);
cshader->Set("constantS", mConstantS);
cshader->Set("lengthS", mLengthS);
cshader->Set("pTmp", mPTmp);
cshader->Set("vTmp", mVTmp);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
cshader->Set("velocity", mVelocity);
cshader = mRK4Shader[7]->GetCShader();
cshader->Set("SimulationParameters", mParameters);
cshader->Set("invMass", mInvMass);
cshader->Set("position", mPosition);
cshader->Set("velocity", mVelocity);
cshader->Set("pAllTmp", mPAllTmp);
cshader->Set("vAllTmp", mVAllTmp);
factory.PopDefines();
created = true;
}
示例7: mSize
GpuShortestPath::GpuShortestPath(ProgramFactory& factory,
std::shared_ptr<Texture2> const& weights, Environment const& env,
bool& created)
:
mSize(static_cast<int>(weights->GetWidth()))
{
created = false;
mLogSize = Log2OfPowerOfTwo(mSize);
mDistance = std::make_shared<Texture2>(DF_R32_FLOAT, mSize, mSize);
mDistance->SetUsage(Resource::SHADER_OUTPUT);
memset(mDistance->GetData(), 0, mDistance->GetNumBytes());
mPrevious = std::make_shared<Texture2>(DF_R32G32_SINT, mSize, mSize);
mPrevious->SetUsage(Resource::SHADER_OUTPUT);
mPrevious->SetCopyType(Resource::COPY_STAGING_TO_CPU);
mSegment = std::make_shared<ConstantBuffer>(3 * sizeof(int), true);
factory.PushDefines();
factory.defines.Set("ISIZE", mSize);
mInitializeDiagToRow = factory.CreateFromFile(
env.GetPath("InitializeDiagToRow.hlsl"));
if (!mInitializeDiagToRow)
{
return;
}
std::shared_ptr<ComputeShader> cshader =
mInitializeDiagToRow->GetCShader();
cshader->Set("weights", weights);
cshader->Set("previous", mPrevious);
cshader->Set("sum", mDistance);
mInitializeDiagToCol = factory.CreateFromFile(
env.GetPath("InitializeDiagToCol.hlsl"));
if (!mInitializeDiagToCol)
{
return;
}
cshader = mInitializeDiagToCol->GetCShader();
cshader->Set("weights", weights);
cshader->Set("previous", mPrevious);
cshader->Set("sum", mDistance);
mPartialSumDiagToRow.resize(mLogSize);
mPartialSumDiagToCol.resize(mLogSize);
for (int i = 0; i < mLogSize; ++i)
{
factory.defines.Set("LOGN", mLogSize);
factory.defines.Set("P", i + 1);
mPartialSumDiagToRow[i] = factory.CreateFromFile(
env.GetPath("PartialSumsDiagToRow.hlsl"));
if (!mPartialSumDiagToRow[i])
{
return;
}
mPartialSumDiagToRow[i]->GetCShader()->Set("sum", mDistance);
mPartialSumDiagToCol[i] = factory.CreateFromFile(
env.GetPath("PartialSumsDiagToCol.hlsl"));
if (!mPartialSumDiagToCol[i])
{
return;
}
mPartialSumDiagToCol[i]->GetCShader()->Set("sum", mDistance);
}
mUpdate = factory.CreateFromFile(env.GetPath("UpdateShader.hlsl"));
if (!mUpdate)
{
return;
}
cshader = mUpdate->GetCShader();
cshader->Set("Segment", mSegment);
cshader->Set("weights", weights);
cshader->Set("distance", mDistance);
cshader->Set("previous", mPrevious);
factory.PopDefines();
created = true;
}
示例8: mNumXGroups
Fluid3EnforceStateBoundary::Fluid3EnforceStateBoundary(
ProgramFactory& factory, int xSize, int ySize, int zSize, int numXThreads,
int numYThreads, int numZThreads)
:
mNumXGroups(xSize/numXThreads),
mNumYGroups(ySize/numYThreads),
mNumZGroups(zSize/numZThreads)
{
mXMin = std::make_shared<Texture2>(DF_R32G32_FLOAT, ySize, zSize);
mXMin->SetUsage(Resource::SHADER_OUTPUT);
mXMax = std::make_shared<Texture2>(DF_R32G32_FLOAT, ySize, zSize);
mXMax->SetUsage(Resource::SHADER_OUTPUT);
mYMin = std::make_shared<Texture2>(DF_R32G32_FLOAT, xSize, zSize);
mYMin->SetUsage(Resource::SHADER_OUTPUT);
mYMax = std::make_shared<Texture2>(DF_R32G32_FLOAT, xSize, zSize);
mYMax->SetUsage(Resource::SHADER_OUTPUT);
mZMin = std::make_shared<Texture2>(DF_R32G32_FLOAT, xSize, ySize);
mZMin->SetUsage(Resource::SHADER_OUTPUT);
mZMax = std::make_shared<Texture2>(DF_R32G32_FLOAT, xSize, ySize);
mZMax->SetUsage(Resource::SHADER_OUTPUT);
int i = factory.GetAPI();
factory.PushDefines();
factory.defines.Set("USE_COPY_X_FACE", 1);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
factory.defines.Set("NUM_Z_THREADS", numZThreads);
mCopyXFace = factory.CreateFromSource(*msSource[i]);
if (mCopyXFace)
{
mCopyXFace->GetCShader()->Set("xMin", mXMin);
mCopyXFace->GetCShader()->Set("xMax", mXMax);
}
factory.defines.Clear();
factory.defines.Set("USE_WRITE_X_FACE", 1);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
factory.defines.Set("NUM_Z_THREADS", numZThreads);
mWriteXFace = factory.CreateFromSource(*msSource[i]);
if (mWriteXFace)
{
mWriteXFace->GetCShader()->Set("xMin", mXMin);
mWriteXFace->GetCShader()->Set("xMax", mXMax);
}
factory.defines.Clear();
factory.defines.Set("USE_COPY_Y_FACE", 1);
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Z_THREADS", numZThreads);
mCopyYFace = factory.CreateFromSource(*msSource[i]);
if (mCopyYFace)
{
mCopyYFace->GetCShader()->Set("yMin", mYMin);
mCopyYFace->GetCShader()->Set("yMax", mYMax);
}
factory.defines.Clear();
factory.defines.Set("USE_WRITE_Y_FACE", 1);
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Z_THREADS", numZThreads);
mWriteYFace = factory.CreateFromSource(*msSource[i]);
if (mWriteYFace)
{
mWriteYFace->GetCShader()->Set("yMin", mYMin);
mWriteYFace->GetCShader()->Set("yMax", mYMax);
}
factory.defines.Clear();
factory.defines.Set("USE_COPY_Z_FACE", 1);
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
mCopyZFace = factory.CreateFromSource(*msSource[i]);
if (mCopyZFace)
{
mCopyZFace->GetCShader()->Set("zMin", mZMin);
mCopyZFace->GetCShader()->Set("zMax", mZMax);
}
factory.defines.Clear();
factory.defines.Set("USE_WRITE_Z_FACE", 1);
factory.defines.Set("NUM_X_THREADS", numXThreads);
factory.defines.Set("NUM_Y_THREADS", numYThreads);
mWriteZFace = factory.CreateFromSource(*msSource[i]);
if (mWriteZFace)
{
mWriteZFace->GetCShader()->Set("zMin", mZMin);
mWriteZFace->GetCShader()->Set("zMax", mZMax);
}
factory.PopDefines();
}