Skip to content

Commit 8921def

Browse files
author
Konstantin Zverev
committed
TileRender + AOV.
1 parent 80b420c commit 8921def

File tree

7 files changed

+366
-70
lines changed

7 files changed

+366
-70
lines changed

App/Renderers/PT/ptrenderer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,14 +868,14 @@ namespace Baikal
868868
m_context.Flush(0);
869869

870870
//samples statisticks
871-
m_output->Clear(0.f);
871+
output->Clear(0.f);
872872
start = std::chrono::high_resolution_clock::now();
873873
for (auto i = 0U; i < num_passes; ++i)
874874
{
875875
Render(scene);
876876
}
877877
delta = std::chrono::high_resolution_clock::now() - start;
878878

879-
stats.samples_pes_sec = m_output->width() * m_output->height() / ((float)std::chrono::duration_cast<std::chrono::milliseconds>(delta).count() / num_passes) / 1000.f;
879+
stats.samples_pes_sec = output->width() * output->height() / ((float)std::chrono::duration_cast<std::chrono::milliseconds>(delta).count() / num_passes) / 1000.f;
880880
}
881881
}

Rpr/RadeonProRender.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -324,9 +324,18 @@ rpr_int rprContextRender(rpr_context in_context)
324324
return RPR_SUCCESS;
325325
}
326326

327-
rpr_int rprContextRenderTile(rpr_context context, rpr_uint xmin, rpr_uint xmax, rpr_uint ymin, rpr_uint ymax)
327+
rpr_int rprContextRenderTile(rpr_context in_context, rpr_uint xmin, rpr_uint xmax, rpr_uint ymin, rpr_uint ymax)
328328
{
329-
UNIMLEMENTED_FUNCTION
329+
//cast data
330+
ContextObject* context = WrapObject::Cast<ContextObject>(in_context);
331+
if (!context)
332+
{
333+
return RPR_ERROR_INVALID_CONTEXT;
334+
}
335+
336+
context->RenderTile(xmin, xmax, ymin, ymax);
337+
338+
return RPR_SUCCESS;
330339
}
331340

332341
rpr_int rprContextClearMemory(rpr_context context)

Rpr/Rpr.lua

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ project "Rpr"
33
location "../Rpr"
44
links {"RadeonRays", "CLW", "Calc"}
55
files { "../Rpr/**.h", "../Rpr/**.cpp", "../App/**.h", "../App/**.cpp" }
6-
removefiles{"../App/main.cpp","../App/main_benchmark.cpp"}
6+
removefiles{"../App/main.cpp","../App/main_benchmark.cpp", "../App/ImGUI/imgui_impl_glfw_gl3.cpp"}
77
includedirs{ "../RadeonRays/include", "../CLW", "../App", "." }
88

99
if os.is("macosx") then
@@ -15,11 +15,11 @@ project "Rpr"
1515
end
1616

1717
if os.is("windows") then
18-
includedirs { "../3rdparty/glew/include", "../3rdparty/freeglut/include", "../3rdparty/oiio/include" }
18+
includedirs { "../3rdparty/glew/include", "../3rdparty/oiio/include" }
1919
linkoptions { '/DEF:"RadeonProRender.def"' }
2020

2121
links {"RadeonRays",}
22-
links {"freeglut", "glew"}
22+
links {"glew", "OpenGL32"}
2323
libdirs { "../3rdparty/glew/lib/%{cfg.platform}",
2424
"../3rdparty/freeglut/lib/%{cfg.platform}",
2525
"../3rdparty/embree/lib/%{cfg.platform}",
@@ -78,7 +78,6 @@ project "Rpr"
7878
if os.is("windows") then
7979
postbuildcommands {
8080
'copy "..\\3rdparty\\glew\\bin\\%{cfg.platform}\\glew32.dll" "%{cfg.buildtarget.directory}"',
81-
'copy "..\\3rdparty\\freeglut\\bin\\%{cfg.platform}\\freeglut.dll" "%{cfg.buildtarget.directory}"',
8281
'copy "..\\3rdparty\\embree\\bin\\%{cfg.platform}\\embree.dll" "%{cfg.buildtarget.directory}"',
8382
'copy "..\\3rdparty\\embree\\bin\\%{cfg.platform}\\tbb.dll" "%{cfg.buildtarget.directory}"',
8483
'copy "..\\3rdparty\\oiio\\bin\\%{cfg.platform}\\OpenImageIO.dll" "%{cfg.buildtarget.directory}"',

Rpr/WrapObject/ContextObject.cpp

Lines changed: 55 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ namespace
9393
{ RPR_CONTEXT_CPU_NAME,{ "cpuname", "Name of the CPU in context. Constant value.", RPR_PARAMETER_TYPE_STRING } },
9494
};
9595

96+
std::map<uint32_t, Baikal::Renderer::OutputType> kOutputTypeMap = { {RPR_AOV_COLOR, Baikal::Renderer::OutputType::kColor},
97+
{RPR_AOV_GEOMETRIC_NORMAL, Baikal::Renderer::OutputType::kWorldGeometricNormal},
98+
{RPR_AOV_SHADING_NORMAL, Baikal::Renderer::OutputType::kWorldShadingNormal},
99+
{RPR_AOV_UV, Baikal::Renderer::OutputType::kUv},
100+
{RPR_AOV_WORLD_COORDINATE, Baikal::Renderer::OutputType::kWorldPosition},
101+
};
102+
96103
}// anonymous
97104

98105
ContextObject::ContextObject(rpr_creation_flags creation_flags)
@@ -146,53 +153,50 @@ void ContextObject::GetRenderStatistics(void * out_data, size_t * out_size_ret)
146153

147154
void ContextObject::SetAOV(rpr_int in_aov, FramebufferObject* buffer)
148155
{
149-
switch (in_aov)
156+
FramebufferObject* old_buf = GetAOV(in_aov);
157+
158+
auto aov = kOutputTypeMap.find(in_aov);
159+
if (aov == kOutputTypeMap.end())
160+
{
161+
throw Exception(RPR_ERROR_UNIMPLEMENTED, "Context: requested AOV not implemented.");
162+
}
163+
164+
for (auto& c : m_cfgs)
150165
{
151-
case RPR_AOV_COLOR:
152-
for (auto& c : m_cfgs)
153-
c.renderer->SetOutput(buffer->GetOutput());
154-
break;
155-
case RPR_AOV_DEPTH:
156-
case RPR_AOV_GEOMETRIC_NORMAL:
157-
case RPR_AOV_MATERIAL_IDX:
158-
case RPR_AOV_MAX:
159-
case RPR_AOV_OBJECT_GROUP_ID:
160-
case RPR_AOV_OBJECT_ID:
161-
case RPR_AOV_OPACITY:
162-
case RPR_AOV_SHADING_NORMAL:
163-
case RPR_AOV_UV:
164-
case RPR_AOV_WORLD_COORDINATE:
165-
throw Exception(RPR_ERROR_UNSUPPORTED, "Context: only RPR_AOV_COLOR supported now");
166-
default:
167-
throw Exception(RPR_ERROR_INVALID_PARAMETER, "Context: unrecognized AOV");
166+
c.renderer->SetOutput(aov->second, buffer->GetOutput());
168167
}
168+
169+
//update registered output framebuffer
170+
m_output_framebuffers.erase(old_buf);
171+
m_output_framebuffers.insert(buffer);
169172
}
170173

171174

172175
FramebufferObject* ContextObject::GetAOV(rpr_int in_aov)
173176
{
174-
switch (in_aov)
177+
auto aov = kOutputTypeMap.find(in_aov);
178+
if (aov == kOutputTypeMap.end())
179+
{
180+
throw Exception(RPR_ERROR_UNIMPLEMENTED, "Context: requested AOV not implemented.");
181+
}
182+
183+
Baikal::Output* out = m_cfgs[0].renderer->GetOutput(aov->second);
184+
if (!out)
185+
{
186+
return nullptr;
187+
}
188+
189+
//find framebuffer
190+
auto it = find_if(m_output_framebuffers.begin(), m_output_framebuffers.end(), [out](FramebufferObject* buff)
191+
{
192+
return buff->GetOutput() == out;
193+
});
194+
if (it == m_output_framebuffers.end())
175195
{
176-
case RPR_AOV_COLOR:
177-
//TODO: implement
178-
throw Exception(RPR_ERROR_UNIMPLEMENTED, "Context: unimplemented");
179-
break;
180-
case RPR_AOV_DEPTH:
181-
case RPR_AOV_GEOMETRIC_NORMAL:
182-
case RPR_AOV_MATERIAL_IDX:
183-
case RPR_AOV_MAX:
184-
case RPR_AOV_OBJECT_GROUP_ID:
185-
case RPR_AOV_OBJECT_ID:
186-
case RPR_AOV_OPACITY:
187-
case RPR_AOV_SHADING_NORMAL:
188-
case RPR_AOV_UV:
189-
case RPR_AOV_WORLD_COORDINATE:
190-
throw Exception(RPR_ERROR_UNSUPPORTED, "Context: only RPR_AOV_COLOR supported now");
191-
default:
192-
throw Exception(RPR_ERROR_INVALID_PARAMETER, "Context: unrecognized AOV");
196+
throw Exception(RPR_ERROR_INTERNAL_ERROR, "Context: unknown framebuffer.");
193197
}
194198

195-
return nullptr;
199+
return *it;
196200
}
197201

198202
void ContextObject::Render()
@@ -206,6 +210,20 @@ void ContextObject::Render()
206210
}
207211

208212
}
213+
214+
void ContextObject::RenderTile(rpr_uint xmin, rpr_uint xmax, rpr_uint ymin, rpr_uint ymax)
215+
{
216+
m_current_scene->AddEmissive();
217+
const RadeonRays::int2 origin = { (int)xmin, (int)ymin };
218+
const RadeonRays::int2 size = { (int)xmax - (int)xmin, (int)ymax - (int)ymin };
219+
//render
220+
for (auto& c : m_cfgs)
221+
{
222+
c.renderer->RenderTile(*m_current_scene->GetScene(), origin, size);
223+
}
224+
}
225+
226+
209227
SceneObject* ContextObject::CreateScene()
210228
{
211229
return new SceneObject();

Rpr/WrapObject/ContextObject.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class ContextObject
6060

6161
//render
6262
void Render();
63-
void RenderTile();
63+
void RenderTile(rpr_uint xmin, rpr_uint xmax, rpr_uint ymin, rpr_uint ymax);
6464

6565
//create methods
6666
SceneObject* CreateScene();
@@ -81,5 +81,7 @@ class ContextObject
8181
private:
8282
//render configs
8383
std::vector<ConfigManager::Config> m_cfgs;
84+
//know framefubbers used as AOV outputs
85+
std::set<FramebufferObject*> m_output_framebuffers;
8486
SceneObject* m_current_scene;
8587
};

RprTest/RprTest.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ project "RprTest"
1616
if os.is("windows") then
1717
includedirs { "../3rdparty/oiio/include" }
1818
links {"RadeonRays",}
19-
links {"freeglut", "glew"}
19+
links {"glew"}
2020
libdirs { "../3rdparty/glew/lib/%{cfg.platform}",
2121
"../3rdparty/freeglut/lib/%{cfg.platform}",
2222
"../3rdparty/embree/lib/%{cfg.platform}",

0 commit comments

Comments
 (0)