本文整理汇总了C++中ProgramFactory类的典型用法代码示例。如果您正苦于以下问题:C++ ProgramFactory类的具体用法?C++ ProgramFactory怎么用?C++ ProgramFactory使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ProgramFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mWindowWidth
OverlayEffect::OverlayEffect(ProgramFactory& factory, int windowWidth,
int windowHeight, int textureWidth, int textureHeight,
SamplerState::Filter filter, SamplerState::Mode mode0,
SamplerState::Mode mode1, bool useColorPShader)
:
mWindowWidth(static_cast<float>(windowWidth)),
mWindowHeight(static_cast<float>(windowHeight))
{
Initialize(windowWidth, windowHeight, textureWidth, textureHeight);
int i = factory.GetAPI();
std::string psSource =
(useColorPShader ? *msPSColorSource[i] : *msPSGraySource[i]);
mProgram = factory.CreateFromSources(*msVSSource[i], psSource, "");
if (mProgram)
{
std::shared_ptr<SamplerState> sampler =
std::make_shared<SamplerState>();
sampler->filter = filter;
sampler->mode[0] = mode0;
sampler->mode[1] = mode1;
mProgram->GetPShader()->Set("imageSampler", sampler);
mEffect = std::make_shared<VisualEffect>(mProgram);
}
}
示例2: 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();
}
示例3: 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();
}
示例4: mPVWMatrix
SimpleBumpMapEffect::SimpleBumpMapEffect(ProgramFactory& factory,
Environment const& environment, bool& created)
:
mPVWMatrix(nullptr)
{
created = false;
// Load and compile the shaders.
std::string path = environment.GetPath("SimpleBumpMap.hlsl");
#if !defined(GTE_DEV_OPENGL)
// The flags are chosen to allow you to debug the shaders through MSVS.
// The menu path is "Debug | Graphics | Start Diagnostics" (ALT+F5).
factory.PushFlags();
factory.flags =
D3DCOMPILE_ENABLE_STRICTNESS |
D3DCOMPILE_IEEE_STRICTNESS |
D3DCOMPILE_DEBUG |
D3DCOMPILE_SKIP_OPTIMIZATION;
#endif
mProgram = factory.CreateFromFiles(path, path, "");
#if !defined(GTE_DEV_OPENGL)
factory.PopFlags();
#endif
if (!mProgram)
{
// The program factory will generate Log* messages.
return;
}
// Load the textures.
path = environment.GetPath("Bricks.png");
mBaseTexture.reset(WICFileIO::Load(path, true));
mBaseTexture->AutogenerateMipmaps();
path = environment.GetPath("BricksNormal.png");
mNormalTexture.reset(WICFileIO::Load(path, true));
mNormalTexture->AutogenerateMipmaps();
// Create the shader constants.
mPVWMatrixConstant =
std::make_shared<ConstantBuffer>(sizeof(Matrix4x4<float>), true);
mPVWMatrix = mPVWMatrixConstant->Get<Matrix4x4<float>>();
*mPVWMatrix = Matrix4x4<float>::Identity();
// Create the texture sampler for mipmapping.
mCommonSampler = std::make_shared<SamplerState>();
mCommonSampler->filter = SamplerState::MIN_L_MAG_L_MIP_L;
mCommonSampler->mode[0] = SamplerState::WRAP;
mCommonSampler->mode[1] = SamplerState::WRAP;
// Set the resources for the shaders.
std::shared_ptr<VertexShader> vshader = mProgram->GetVShader();
std::shared_ptr<PixelShader> pshader = mProgram->GetPShader();
vshader->Set("PVWMatrix", mPVWMatrixConstant);
pshader->Set("baseTexture", mBaseTexture);
pshader->Set("normalTexture", mNormalTexture);
pshader->Set("commonSampler", mCommonSampler);
created = true;
}
示例5: updateVAO
void Mesh::updateVAO()
{
ProgramFactory programFactory;
ProgramSP shaderprogram;
for (uint32_t materialIndex = 0; materialIndex < surfaceMaterials.size(); materialIndex++)
{
SurfaceMaterialSP currentSurfaceMaterial = getSurfaceMaterialAt(materialIndex);
SubMeshSP currentSubMesh = getSubMeshAt(materialIndex);
shaderprogram = programFactory.createPhongProgram();
SubMeshVAOSP vao = SubMeshVAOSP(new SubMeshVAO(shaderprogram, *this));
currentSubMesh->addVAO(vao);
shaderprogram = programFactory.createPhongRenderToCubeMapProgram();
vao = SubMeshVAOSP(new SubMeshVAO(shaderprogram, *this));
currentSubMesh->addVAO(vao);
shaderprogram = programFactory.createPhongRenderToShadowMapProgram();
vao = SubMeshVAOSP(new SubMeshVAO(shaderprogram, *this));
currentSubMesh->addVAO(vao);
}
}
示例6: width
Font::Font(const string& filename, float width, float height, int32_t columns, int32_t rows, float cellWidth, float cellHeight, float fontWidth, float fontHeight) :
width(width), height(height), columns(columns), rows(rows), cellWidth(cellWidth), cellHeight(cellHeight), fontWidth(fontWidth), fontHeight(fontHeight)
{
cellWidthNormalized = cellWidth / width;
cellHeightNormalized = cellHeight / height;
fontTextureName = Texture2DManager::getInstance()->createTexture(filename, false, GL_LINEAR, GL_LINEAR)->getTextureName();
camera = CameraManager::getInstance()->getDefaultOrthographicCamera();
ProgramFactory programFactory;
program = programFactory.createFontProgram();
GLUSshape rectangularPlane;
glusCreateRectangularPlanef(&rectangularPlane, cellWidth / 2.0f, cellHeight / 2.0f);
numberIndices = rectangularPlane.numberIndices;
glGenBuffers(1, &vboVertices);
glBindBuffer(GL_ARRAY_BUFFER, vboVertices);
glBufferData(GL_ARRAY_BUFFER, rectangularPlane.numberVertices * 4 * sizeof(GLfloat), (GLfloat*) rectangularPlane.vertices, GL_STATIC_DRAW);
glGenBuffers(1, &vboTexCoords);
glBindBuffer(GL_ARRAY_BUFFER, vboTexCoords);
glBufferData(GL_ARRAY_BUFFER, rectangularPlane.numberVertices * 2 * sizeof(GLfloat), (GLfloat*) rectangularPlane.texCoords, GL_STATIC_DRAW);
glGenBuffers(1, &vboIndices);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, rectangularPlane.numberIndices * sizeof(GLuint), (GLuint*) rectangularPlane.indices, GL_STATIC_DRAW);
fontVAO = FontVAOSP(new FontVAO(program, *this));
glusDestroyShapef(&rectangularPlane);
}
示例7: vboVertices
Sky::Sky(const Shape& shape, float radiusX, float radiusY, float radiusZ, const string& filename) : vboVertices(0), vboIndices(0), writeBrightColor(false), brightColorLimit(1.0f)
{
ProgramFactory programFactory;
program = programFactory.createSkyProgram();
numberIndices = shape.getShape().numberIndices;
glGenBuffers(1, &vboVertices);
glBindBuffer(GL_ARRAY_BUFFER, vboVertices);
glBufferData(GL_ARRAY_BUFFER,
shape.getShape().numberVertices * 4 * sizeof(GLfloat),
(GLfloat*) shape.getShape().vertices, GL_STATIC_DRAW);
glGenBuffers(1, &vboIndices);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER,
shape.getShape().numberIndices * sizeof(GLuint),
(GLuint*) shape.getShape().indices, GL_STATIC_DRAW);
skyVAO = SkyVAOSP(new SkyVAO(program, *this));
//
scaleMatrix.scale(radiusX, radiusY, radiusZ);
//
skyTexture = TextureCubeMapManager::getInstance()->createTexture(filename);
}
示例8: mPVWMatrix
VertexColorEffect::VertexColorEffect(ProgramFactory& factory)
:
mPVWMatrix(nullptr)
{
int i = factory.GetAPI();
mProgram = factory.CreateFromSources(*msVSSource[i], *msPSSource[i], "");
if (mProgram)
{
mPVWMatrixConstant = std::make_shared<ConstantBuffer>(
sizeof(Matrix4x4<float>), true);
mPVWMatrix = mPVWMatrixConstant->Get<Matrix4x4<float>>();
*mPVWMatrix = Matrix4x4<float>::Identity();
mProgram->GetVShader()->Set("PVWMatrix", mPVWMatrixConstant);
}
}
示例9: 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();
}
示例10: boundingSphere
Ground::Ground(const BoundingSphere& boundingSphere, const GridPlaneShape& gridPlaneShape) :
boundingSphere(boundingSphere), numberVertices(gridPlaneShape.getShape().numberVertices), numberIndices(gridPlaneShape.getShape().numberIndices), allVAOs()
{
glGenBuffers(1, &vboVertices);
glBindBuffer(GL_ARRAY_BUFFER, vboVertices);
glBufferData(GL_ARRAY_BUFFER, numberVertices * 4 * sizeof(GLfloat), (GLfloat*)gridPlaneShape.getShape().vertices, GL_STATIC_DRAW);
glGenBuffers(1, &vboNormals);
glBindBuffer(GL_ARRAY_BUFFER, vboNormals);
glBufferData(GL_ARRAY_BUFFER, numberVertices * 3 * sizeof(GLfloat), (GLfloat*)gridPlaneShape.getShape().normals, GL_STATIC_DRAW);
glGenBuffers(1, &vboBitangents);
glBindBuffer(GL_ARRAY_BUFFER, vboBitangents);
glBufferData(GL_ARRAY_BUFFER, numberVertices * 3 * sizeof(GLfloat), (GLfloat*)gridPlaneShape.getShape().bitangents, GL_STATIC_DRAW);
glGenBuffers(1, &vboTangents);
glBindBuffer(GL_ARRAY_BUFFER, vboTangents);
glBufferData(GL_ARRAY_BUFFER, numberVertices * 3 * sizeof(GLfloat), (GLfloat*)gridPlaneShape.getShape().tangents, GL_STATIC_DRAW);
glGenBuffers(1, &vboTexCoords);
glBindBuffer(GL_ARRAY_BUFFER, vboTexCoords);
glBufferData(GL_ARRAY_BUFFER, numberVertices * 2 * sizeof(GLfloat), (GLfloat*)gridPlaneShape.getShape().texCoords, GL_STATIC_DRAW);
glGenBuffers(1, &vboIndices);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboIndices);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numberIndices * sizeof(GLuint), (GLuint*)gridPlaneShape.getShape().indices, GL_STATIC_DRAW);
//
ProgramFactory programFactory;
ProgramSP shaderprogram = programFactory.createGroundProgram();
GroundVAOSP vao = GroundVAOSP(new GroundVAO(shaderprogram, *this));
addVAO(vao);
shaderprogram = programFactory.createGroundRenderToCubeMapProgram();
vao = GroundVAOSP(new GroundVAO(shaderprogram, *this));
addVAO(vao);
shaderprogram = programFactory.createGroundRenderToShadowMapProgram();
vao = GroundVAOSP(new GroundVAO(shaderprogram, *this));
addVAO(vao);
}
示例11: 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();
}
示例12: 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();
}
示例13: mPVWMatrix
BlendedTerrainEffect::BlendedTerrainEffect(ProgramFactory& factory,
Environment const& environment, bool& created)
:
mPVWMatrix(nullptr),
mFlowDirection(nullptr),
mPowerFactor(nullptr)
{
created = false;
// Load and compile the shaders.
std::string path = environment.GetPath("BlendedTerrain.hlsl");
#if !defined(GTE_DEV_OPENGL)
// The flags are chosen to allow you to debug the shaders through MSVS.
// The menu path is "Debug | Graphics | Start Diagnostics" (ALT+F5).
factory.PushFlags();
factory.flags =
D3DCOMPILE_ENABLE_STRICTNESS |
D3DCOMPILE_IEEE_STRICTNESS |
D3DCOMPILE_DEBUG |
D3DCOMPILE_SKIP_OPTIMIZATION;
#endif
mProgram = factory.CreateFromFiles(path, path, "");
#if !defined(GTE_DEV_OPENGL)
factory.PopFlags();
#endif
if (!mProgram)
{
// The program factory will generate Log* messages.
return;
}
// Load the textures.
path = environment.GetPath("BTGrass.png");
mGrassTexture.reset(WICFileIO::Load(path, true));
mGrassTexture->AutogenerateMipmaps();
path = environment.GetPath("BTStone.png");
mStoneTexture.reset(WICFileIO::Load(path, true));
mStoneTexture->AutogenerateMipmaps();
path = environment.GetPath("BTCloud.png");
mCloudTexture.reset(WICFileIO::Load(path, true));
mCloudTexture->AutogenerateMipmaps();
// Create the shader constants.
mPVWMatrixConstant = std::make_shared<ConstantBuffer>(sizeof(Matrix4x4<float>), true);
mPVWMatrix = mPVWMatrixConstant->Get<Matrix4x4<float>>();
*mPVWMatrix = Matrix4x4<float>::Identity();
mFlowDirectionConstant = std::make_shared<ConstantBuffer>(sizeof(Vector2<float>), true);
mFlowDirection = mFlowDirectionConstant->Get<Vector2<float>>();
*mFlowDirection = { 0.0f, 0.0f };
mPowerFactorConstant = std::make_shared<ConstantBuffer>(sizeof(float), true);
mPowerFactor = mPowerFactorConstant->Get<float>();
*mPowerFactor = 1.0f;
// Create a 1-dimensional texture whose intensities are proportional to
// height.
unsigned int const numTexels = 256;
mBlendTexture = std::make_shared<Texture1>(DF_R8_UNORM, numTexels);
unsigned char* texels = mBlendTexture->Get<unsigned char>();
for (unsigned int i = 0; i < numTexels; ++i, ++texels)
{
*texels = static_cast<unsigned char>(i);
}
// Create the texture samplers. The common sampler uses trilinear
// interpolation (mipmapping). The blend sample uses bilinear
// interpolation (no mipmapping).
mCommonSampler = std::make_shared<SamplerState>();
mCommonSampler->filter = SamplerState::MIN_L_MAG_L_MIP_L;
mCommonSampler->mode[0] = SamplerState::WRAP;
mCommonSampler->mode[1] = SamplerState::WRAP;
mBlendSampler = std::make_shared<SamplerState>();
mBlendSampler->filter = SamplerState::MIN_L_MAG_L_MIP_P;
mBlendSampler->mode[0] = SamplerState::WRAP;
// Set the resources for the shaders.
std::shared_ptr<VertexShader> vshader = mProgram->GetVShader();
std::shared_ptr<PixelShader> pshader = mProgram->GetPShader();
vshader->Set("PVWMatrix", mPVWMatrixConstant);
vshader->Set("FlowDirection", mFlowDirectionConstant);
pshader->Set("PowerFactor", mPowerFactorConstant);
pshader->Set("grassTexture", mGrassTexture);
pshader->Set("stoneTexture", mStoneTexture);
pshader->Set("blendTexture", mBlendTexture);
pshader->Set("cloudTexture", mCloudTexture);
pshader->Set("commonSampler", mCommonSampler);
pshader->Set("blendSampler", mBlendSampler);
created = true;
}
示例14: 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();
}
示例15: TEST_CASE
#include "catch.hpp"
#include "AST/Expressions/AdditionExpression.hpp"
#include "AST/Expressions/LiteralExpression.hpp"
#include "AST/Expressions/MemoryAccessExpression.hpp"
#include "ProgramFactory.hpp"
TEST_CASE("LiteralExpression", "[expression]")
{
ProgramFactory factory;
SECTION("Positive Literals")
{
auto s = factory.literal("two", 2).exprstr("two");
auto exp = R"(BB1:
li $1, 2
)";
REQUIRE(s == exp);
s = factory.literal("25", 25).exprstr("25");
exp = R"(BB1:
li $1, 25
)";
REQUIRE(s == exp);
s = factory.literal("a", 'a').exprstr("a");
exp = R"(BB1:
li $1, 97
)";
REQUIRE(s == exp);
s = factory.literal("true", true).exprstr("true");