Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/appleseed.studio/mainwindow/mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1254,6 +1254,9 @@ void MainWindow::start_rendering(const RenderingMode rendering_mode)
rendering_mode == RenderingMode::InteractiveRendering ? "interactive" : "final";
const ParamArray params = get_project_params(configuration_name);

if (!project->has_texture_store())
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having to manually initialize the texture store before a render is a big problem. In fact, you haven't updated all the other places where we start a render, meaning that rendering there is now broken (appleseed.cli, appleseed.bench, Max plugin, Maya plugin, Blender plugin, Gaffer integration and possibly many others).

project->initialize_texture_store(params.child("texture_store"));

// Effectively start rendering.
m_rendering_manager.start_rendering(
project,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,15 @@ namespace appleseed {
namespace studio {

MaterialDropHandler::MaterialDropHandler(
const renderer::Project& project,
RenderingManager& rendering_manager)
const renderer::Project& project,
RenderingManager& rendering_manager)
: m_project(project), m_rendering_manager(rendering_manager)
{
}

void MaterialDropHandler::slot_material_dropped(
const foundation::Vector2d& drop_pos,
const QString& material_name)
const foundation::Vector2d& drop_pos,
const QString& material_name)
{
m_drop_pos = drop_pos;
m_material_name = material_name.toStdString();
Expand Down
12 changes: 6 additions & 6 deletions src/appleseed.studio/mainwindow/rendering/materialdrophandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,19 +55,19 @@ class MaterialDropHandler

public:
MaterialDropHandler(
const renderer::Project& project,
RenderingManager& rendering_manager);
const renderer::Project& project,
RenderingManager& rendering_manager);

public slots:
void slot_material_dropped(
const foundation::Vector2d& drop_pos,
const QString& material_name);

private:
const renderer::Project& m_project;
RenderingManager& m_rendering_manager;
foundation::Vector2d m_drop_pos;
std::string m_material_name;
const renderer::Project& m_project;
RenderingManager& m_rendering_manager;
foundation::Vector2d m_drop_pos;
std::string m_material_name;

void assign_material(const renderer::ObjectInstance::Side side);

Expand Down
1 change: 0 additions & 1 deletion src/appleseed.studio/mainwindow/rendering/rendertab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,6 @@ void RenderTab::recreate_handlers()
// Set initial state.
m_pixel_inspector_handler->set_enabled(false);
m_camera_controller->set_enabled(false);
m_scene_picking_handler->set_enabled(true);
}

} // namespace studio
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/foundation/string/internedstring.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace foundation
//
// There are also some disadvantages:
//
// - Constructing an interned string can be slower that a normal string.
// - Constructing an interned string can be slower than a normal string.
// - Memory for the string characters is never freed.
//
// This implementation relies internally on OpenImageIO's ustring class.
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/renderer/device/cpu/cpurenderdevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ CPURenderDevice::CPURenderDevice(
Project& project,
const ParamArray& params)
: RenderDeviceBase(project, params)
, m_texture_store(*project.get_scene(), params.child("texture_store"))
, m_texture_store(project.get_texture_store())
{
m_error_handler = new OIIOErrorHandler();
#ifndef NDEBUG
Expand Down
2 changes: 1 addition & 1 deletion src/appleseed/renderer/device/cpu/cpurenderdevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class CPURenderDevice
RendererServices* m_renderer_services;
OSLShadingSystem* m_shading_system;
foundation::auto_release_ptr<ShaderCompiler> m_osl_compiler;
TextureStore m_texture_store;
TextureStore& m_texture_store;
std::unique_ptr<RendererComponents> m_components;
};

Expand Down
14 changes: 7 additions & 7 deletions src/appleseed/renderer/kernel/intersection/assemblytree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,9 @@ namespace renderer
// AssemblyTree class implementation.
//

AssemblyTree::AssemblyTree(const Scene& scene)
AssemblyTree::AssemblyTree(const Project& project)
: TreeType(AlignedAllocator<void>(System::get_l1_data_cache_line_size()))
, m_scene(scene)
, m_project(project)
#ifdef APPLESEED_WITH_EMBREE
, m_use_embree(false)
, m_dirty(false)
Expand Down Expand Up @@ -163,7 +163,7 @@ void AssemblyTree::rebuild_assembly_tree()
RENDERER_LOG_INFO("collecting assembly instances...");
AABBVector assembly_instance_bboxes;
collect_assembly_instances(
m_scene.assembly_instances(),
m_project.get_scene()->assembly_instances(),
TransformSequence(),
assembly_instance_bboxes);

Expand All @@ -185,7 +185,7 @@ void AssemblyTree::rebuild_assembly_tree()
Builder builder;
builder.build<DefaultWallclockTimer>(*this, partitioner, m_items.size(), AssemblyTreeMaxLeafSize);
statistics.insert_time("build time", builder.get_build_time());
statistics.merge(bvh::TreeStatistics<AssemblyTree>(*this, AABB3d(m_scene.compute_bbox())));
statistics.merge(bvh::TreeStatistics<AssemblyTree>(*this, AABB3d(m_project.get_scene()->compute_bbox())));

if (!m_items.empty())
{
Expand Down Expand Up @@ -407,7 +407,7 @@ void AssemblyTree::create_triangle_tree(const Assembly& assembly)
std::unique_ptr<ILazyFactory<TriangleTree>> triangle_tree_factory(
new TriangleTreeFactory(
TriangleTree::Arguments(
m_scene,
m_project,
assembly.get_uid(),
assembly_bbox,
assembly)));
Expand Down Expand Up @@ -435,7 +435,7 @@ void AssemblyTree::create_curve_tree(const Assembly& assembly)
std::unique_ptr<ILazyFactory<CurveTree>> curve_tree_factory(
new CurveTreeFactory(
CurveTree::Arguments(
m_scene,
*m_project.get_scene(),
assembly.get_uid(),
assembly_bbox,
assembly)));
Expand Down Expand Up @@ -473,7 +473,7 @@ void AssemblyTree::create_embree_scene(const Assembly& assembly)
std::unique_ptr<ILazyFactory<EmbreeScene>> embree_scene_factory(
new EmbreeSceneFactory(
EmbreeScene::Arguments(
m_scene.get_embree_device(),
m_project.get_scene()->get_embree_device(),
assembly
)));

Expand Down
6 changes: 3 additions & 3 deletions src/appleseed/renderer/kernel/intersection/assemblytree.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
// Forward declarations.
namespace foundation { class Statistics; }
namespace renderer { class AssemblyInstance; }
namespace renderer { class Scene; }
namespace renderer { class Project; }
namespace renderer { class ShadingPoint; }

namespace renderer
Expand All @@ -77,7 +77,7 @@ class AssemblyTree
{
public:
// Constructor, builds the tree for a given scene.
explicit AssemblyTree(const Scene& scene);
explicit AssemblyTree(const Project& project);

// Destructor.
~AssemblyTree();
Expand Down Expand Up @@ -126,7 +126,7 @@ class AssemblyTree
typedef std::vector<const Assembly*> AssemblyVector;
typedef std::map<foundation::UniqueID, foundation::VersionID> AssemblyVersionMap;

const Scene& m_scene;
const Project& m_project;
ItemVector m_items;
AssemblyVersionMap m_assembly_versions;

Expand Down
6 changes: 3 additions & 3 deletions src/appleseed/renderer/kernel/intersection/tracecontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@ namespace renderer
// TraceContext class implementation.
//

TraceContext::TraceContext(const Scene& scene)
: m_scene(scene)
, m_assembly_tree(new AssemblyTree(scene))
TraceContext::TraceContext(const Project& project)
: m_project(project)
, m_assembly_tree(new AssemblyTree(project))
{
RENDERER_LOG_DEBUG(
"data structures size:\n"
Expand Down
9 changes: 6 additions & 3 deletions src/appleseed/renderer/kernel/intersection/tracecontext.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
// appleseed.foundation headers.
#include "foundation/core/concepts/noncopyable.h"

// appleseed.renderer headers.
#include "renderer/modeling/project/project.h"

// appleseed.main headers.
#include "main/dllsymbol.h"

Expand All @@ -54,7 +57,7 @@ class APPLESEED_DLLSYMBOL TraceContext
{
public:
// Constructor, initializes the trace context for a given scene.
explicit TraceContext(const Scene& scene);
explicit TraceContext(const Project& project);

// Destructor.
~TraceContext();
Expand All @@ -73,7 +76,7 @@ class APPLESEED_DLLSYMBOL TraceContext
#endif

private:
const Scene& m_scene;
const Project& m_project;
AssemblyTree* m_assembly_tree;
};

Expand All @@ -84,7 +87,7 @@ class APPLESEED_DLLSYMBOL TraceContext

inline const Scene& TraceContext::get_scene() const
{
return m_scene;
return *m_project.get_scene();
}

inline const AssemblyTree& TraceContext::get_assembly_tree() const
Expand Down
7 changes: 3 additions & 4 deletions src/appleseed/renderer/kernel/intersection/triangletree.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -383,11 +383,11 @@ namespace
}

TriangleTree::Arguments::Arguments(
const Scene& scene,
const Project& project,
const UniqueID triangle_tree_uid,
const GAABB3& bbox,
const Assembly& assembly)
: m_scene(scene)
: m_project(project)
, m_triangle_tree_uid(triangle_tree_uid)
, m_bbox(bbox)
, m_assembly(assembly)
Expand Down Expand Up @@ -1262,8 +1262,7 @@ void TriangleTree::update_intersection_filters()
object_instances_to_filter_keys);

// Create missing intersection filters and update existing ones.
TextureStore texture_store(m_arguments.m_scene);
TextureCache texture_cache(texture_store);
TextureCache texture_cache(m_arguments.m_project.get_texture_store());
create_missing_intersection_filters(
texture_cache,
filter_keys,
Expand Down
7 changes: 4 additions & 3 deletions src/appleseed/renderer/kernel/intersection/triangletree.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
#include "renderer/kernel/intersection/probevisitorbase.h"
#include "renderer/kernel/intersection/trianglekey.h"
#include "renderer/kernel/intersection/trianglevertexinfo.h"
#include "renderer/modeling/project/project.h"
#include "renderer/modeling/scene/visibilityflags.h"

// appleseed.foundation headers.
Expand All @@ -59,7 +60,7 @@ namespace foundation { class Statistics; }
namespace renderer { class Assembly; }
namespace renderer { class IntersectionFilter; }
namespace renderer { class ParamArray; }
namespace renderer { class Scene; }
namespace renderer { class Project; }
namespace renderer { class ShadingPoint; }

namespace renderer
Expand All @@ -83,14 +84,14 @@ class TriangleTree
// Construction arguments.
struct Arguments
{
const Scene& m_scene;
const Project& m_project;
const foundation::UniqueID m_triangle_tree_uid;
const GAABB3 m_bbox;
const Assembly& m_assembly;

// Constructor.
Arguments(
const Scene& scene,
const Project& project,
const foundation::UniqueID triangle_tree_uid,
const GAABB3& bbox,
const Assembly& assembly);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ BackwardLightSampler::BackwardLightSampler(
}
else
{
// Prepare the light-emitting shapes CDF for smapling.
// Prepare the light-emitting shapes CDF for sampling.
if (m_emitting_shapes_cdf.valid())
m_emitting_shapes_cdf.prepare();

Expand Down
4 changes: 2 additions & 2 deletions src/appleseed/renderer/kernel/rendering/scenepicker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,14 @@ struct ScenePicker::Impl
{
const Project& m_project;
const TraceContext& m_trace_context;
TextureStore m_texture_store;
TextureStore& m_texture_store;
TextureCache m_texture_cache;
Intersector m_intersector;

explicit Impl(const Project& project)
: m_project(project)
, m_trace_context(m_project.get_trace_context())
, m_texture_store(m_trace_context.get_scene())
, m_texture_store(m_project.get_texture_store())
, m_texture_cache(m_texture_store)
, m_intersector(m_trace_context, m_texture_cache)
{
Expand Down
6 changes: 3 additions & 3 deletions src/appleseed/renderer/meta/tests/test_intersector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,13 @@ TEST_SUITE(Renderer_Kernel_Intersection_Intersector)
: public StaticTestSceneContext<TestScene>
{
TraceContext m_trace_context;
TextureStore m_texture_store;
TextureStore& m_texture_store;
TextureCache m_texture_cache;
Intersector m_intersector;

Fixture()
: m_trace_context(m_scene)
, m_texture_store(m_scene)
: m_trace_context(m_project)
, m_texture_store(m_project.get_texture_store())
, m_texture_cache(m_texture_store)
, m_intersector(m_trace_context, m_texture_cache)
{
Expand Down
6 changes: 3 additions & 3 deletions src/appleseed/renderer/meta/tests/test_tracer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ TEST_SUITE(Renderer_Kernel_Lighting_Tracer)
: public StaticTestSceneContext<typename FixtureParams::FixtureBaseClass>
{
TraceContext m_trace_context;
TextureStore m_texture_store;
TextureStore& m_texture_store;
TextureCache m_texture_cache;
Intersector m_intersector;
std::shared_ptr<OIIOTextureSystem> m_texture_system;
Expand All @@ -228,8 +228,8 @@ TEST_SUITE(Renderer_Kernel_Lighting_Tracer)
Tracer m_tracer;

Fixture()
: m_trace_context(FixtureParams::FixtureBaseClass::m_scene)
, m_texture_store(FixtureParams::FixtureBaseClass::m_scene)
: m_trace_context(FixtureParams::FixtureBaseClass::m_project)
, m_texture_store(FixtureParams::FixtureBaseClass::m_project.get_texture_store())
, m_texture_cache(m_texture_store)
, m_intersector(m_trace_context, m_texture_cache)
, m_texture_system(
Expand Down
26 changes: 22 additions & 4 deletions src/appleseed/renderer/modeling/project/project.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "renderer/global/globallogger.h"
#include "renderer/kernel/intersection/tracecontext.h"
#include "renderer/kernel/lighting/lightpathrecorder.h"
#include "renderer/kernel/texturing/texturestore.h"
#include "renderer/modeling/aov/aovfactoryregistrar.h"
#include "renderer/modeling/bsdf/bsdffactoryregistrar.h"
#include "renderer/modeling/bssrdf/bssrdffactoryregistrar.h"
Expand Down Expand Up @@ -126,6 +127,7 @@ struct Project::Impl
LightPathRecorder m_light_path_recorder;
std::unique_ptr<TraceContext> m_trace_context;
RenderingTimer m_rendering_timer;
std::unique_ptr<TextureStore> m_texture_store;

explicit Impl(const Project& project)
: m_format_revision(ProjectFormatRevision)
Expand Down Expand Up @@ -358,10 +360,7 @@ bool Project::has_trace_context() const
const TraceContext& Project::get_trace_context() const
{
if (!impl->m_trace_context)
{
assert(impl->m_scene.get());
impl->m_trace_context.reset(new TraceContext(*impl->m_scene));
}
impl->m_trace_context.reset(new TraceContext(*this));

return *impl->m_trace_context;
}
Expand Down Expand Up @@ -436,6 +435,25 @@ void Project::on_frame_end(
impl->m_rendering_timer.measure();
}

void Project::initialize_texture_store(const ParamArray& params)
{
assert(impl->m_scene.get());

impl->m_texture_store.reset(new TextureStore(*impl->m_scene, params));
}

bool Project::has_texture_store() const
{
return impl->m_texture_store.get() != nullptr;
}

TextureStore& Project::get_texture_store() const
{
assert(impl->m_texture_store);

return *impl->m_texture_store;
}

void Project::add_base_configurations()
{
impl->m_configurations.insert(BaseConfigurationFactory::create_base_final());
Expand Down
Loading