Skip to content

Commit cab34cc

Browse files
committed
Tutorial - HybridPro demo.
1 parent bb41529 commit cab34cc

File tree

4 files changed

+30
-16
lines changed

4 files changed

+30
-16
lines changed

tutorials/63_hybrid/main.cpp

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,9 @@ int main()
4242

4343
std::string hybridPluginName =
4444
#if defined(WIN32)
45-
"Hybrid.dll";
45+
"HybridPro.dll";
4646
#elif defined(__LINUX__)
47-
"Hybrid.so";
47+
"HybridPro.so";
4848
#elif defined(__APPLE__)
4949
""; // no Hybrid plugin released on MacOS
5050
#endif
@@ -56,7 +56,12 @@ int main()
5656
size_t pluginCount = sizeof(plugins) / sizeof(plugins[0]);
5757

5858
// Create context using a single GPU
59-
CHECK(rprCreateContext(RPR_API_VERSION, plugins, pluginCount, g_ContextCreationFlags, NULL, NULL, &context));
59+
rpr_status ctxCreateStatus = rprCreateContext(RPR_API_VERSION, plugins, pluginCount, g_ContextCreationFlags, NULL, NULL, &context);
60+
if ( ctxCreateStatus != RPR_SUCCESS )
61+
{
62+
std::cout << "Error creating context - maybe the GPU is not compatible with " << hybridPluginName << "\n" ;
63+
return 0;
64+
}
6065

6166
// Set active plugin.
6267
CHECK(rprContextSetActivePlugin(context, plugins[0]));
@@ -108,8 +113,20 @@ int main()
108113
// Apply this new Uber Material to the shapes
109114
matBall0.SetMaterial(uberMat2);
110115

116+
117+
int iterationCount = 100;
118+
119+
120+
// if using Hybrid ( not HybridPro ) then disable iteration count
121+
if ( hybridPluginName.find("Hybrid.") != std::string::npos )
122+
iterationCount = -1;
123+
124+
111125
// rendering.
112-
matballScene.Render("63.png");
126+
matballScene.Render("63.png",
127+
iterationCount,
128+
false // for Hybrid and HybridPro , no need of framebuffer resolve
129+
);
113130

114131
// Clean
115132
CHECK(rprObjectDelete(uberMat2_img1));uberMat2_img1=nullptr;

tutorials/common/common.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,20 +284,20 @@ MatballScene::MatballScene()
284284
return;
285285
}
286286

287-
void MatballScene::Render(const std::string& outImgFileName, int iterationCount)
287+
void MatballScene::Render(const std::string& outImgFileName, int iterationCount, bool useResolveFramebuffer)
288288
{
289289
// clear framebuffer before starting a new rendering.
290290
CHECK( rprFrameBufferClear(m_frame_buffer) );
291291

292-
if ( !m_usingHybridContext ) // there is no iteration for Hyrbid
292+
if ( iterationCount > 0 ) // if iterationCount=-1 , we ignore this parameter ( may be needed if using Hybrid.DLL )
293293
{
294294
CHECK( rprContextSetParameterByKey1u(m_context, RPR_CONTEXT_ITERATIONS, iterationCount) );
295295
}
296296

297297
std::cout<<"Rendering "<<outImgFileName<<" ..."<<std::endl;
298298
CHECK( rprContextRender(m_context) );
299299

300-
if ( !m_usingHybridContext ) // There is no framebuffer resolve for Hyrbid
300+
if ( useResolveFramebuffer )
301301
{
302302
// last argument is FALSE because we want to apply the display gamma (changed with RPR_CONTEXT_DISPLAY_GAMMA) to this COLOR AOV.
303303
CHECK( rprContextResolveFrameBuffer(m_context, m_frame_buffer, m_frame_buffer_res, false) );
@@ -339,10 +339,8 @@ void MatballScene::Clean()
339339
}
340340

341341

342-
MatballScene::MATBALL MatballScene::Init(rpr_context context, int shapeShiftX, int shapeShiftY, bool usingHybridContext)
342+
MatballScene::MATBALL MatballScene::Init(rpr_context context, int shapeShiftX, int shapeShiftY, bool forceUberMaterialForFloor)
343343
{
344-
345-
m_usingHybridContext = usingHybridContext;
346344
m_context = context;
347345

348346
//create scene
@@ -387,12 +385,12 @@ MatballScene::MATBALL MatballScene::Init(rpr_context context, int shapeShiftX, i
387385
CHECK( rprMaterialSystemCreateNode(m_matsys,RPR_MATERIAL_NODE_IMAGE_TEXTURE,&m_floorImageMaterial) );
388386
CHECK( rprMaterialNodeSetInputImageDataByKey(m_floorImageMaterial,RPR_MATERIAL_INPUT_DATA,m_floorImage) );
389387

390-
if ( !usingHybridContext )
388+
if ( !forceUberMaterialForFloor )
391389
{
392390
CHECK( rprMaterialSystemCreateNode(m_matsys,RPR_MATERIAL_NODE_DIFFUSE,&m_floorMaterial) );
393391
CHECK( rprMaterialNodeSetInputNByKey(m_floorMaterial, RPR_MATERIAL_INPUT_COLOR, m_floorImageMaterial) );
394392
}
395-
else // Hybrid only manages UBER material meaning we can't use the RPR_MATERIAL_NODE_DIFFUSE like with Northstar.
393+
else // Hybrid/HybridPro only manages UBER material meaning we can't use the RPR_MATERIAL_NODE_DIFFUSE like with Northstar.
396394
{
397395
CHECK(rprMaterialSystemCreateNode(m_matsys,RPR_MATERIAL_NODE_UBERV2,&m_floorMaterial));
398396
CHECK(rprMaterialNodeSetInputNByKey(m_floorMaterial, RPR_MATERIAL_INPUT_UBER_DIFFUSE_COLOR, m_floorImageMaterial));

tutorials/common/common.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,11 @@ class MatballScene
127127
}
128128
};
129129

130-
MATBALL Init(rpr_context context, int shapeShiftX, int shapeShiftY, bool usingHybridContext=false);
130+
MATBALL Init(rpr_context context, int shapeShiftX, int shapeShiftY, bool forceUberMaterialForFloor=false);
131131

132132
void Clean();
133133

134-
void Render(const std::string& outImgFileName, int iterationCount = 100);
134+
void Render(const std::string& outImgFileName, int iterationCount = 100, bool useResolveFramebuffer=true);
135135

136136
MATBALL AddMatball(int shiftX, int shiftY, bool createAsInstance=true);
137137

@@ -158,8 +158,6 @@ class MatballScene
158158

159159
const rpr_framebuffer_desc m_framebuffer_desc = { 640 , 480};
160160
const rpr_framebuffer_format m_framebuffer_fmt = { 4, RPR_COMPONENT_TYPE_FLOAT32 };
161-
162-
bool m_usingHybridContext;
163161
};
164162

165163

tutorials/premake5.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ solution "Tutorials"
4444
os.execute("xcopy /Y \"..\\RadeonProRender\\binWin64\\Tahoe64.dll\" \".\\Bin\\\"")
4545
os.execute("xcopy /Y \"..\\RadeonProRender\\binWin64\\Northstar64.dll\" \".\\Bin\\\"")
4646
os.execute("xcopy /Y \"..\\RadeonProRender\\binWin64\\Hybrid.dll\" \".\\Bin\\\"")
47+
os.execute("xcopy /Y \"..\\RadeonProRender\\binWin64\\HybridPro.dll\" \".\\Bin\\\"")
4748
os.execute("xcopy /Y \"..\\RadeonProRender\\binWin64\\ProRenderGLTF.dll\" \".\\Bin\\\"")
4849
end
4950

0 commit comments

Comments
 (0)