Compare commits

..

5 Commits

203 changed files with 1472 additions and 2166 deletions

View File

@@ -35,11 +35,7 @@ void WASAPIDevice::start()
{ {
lock(); lock();
// thread is still running, we can abort stopping it if(!m_playing)
if(m_stop)
m_stop = false;
// thread is not running, let's start it
else if(!m_playing)
{ {
if(m_thread.joinable()) if(m_thread.joinable())
m_thread.join(); m_thread.join();
@@ -57,35 +53,20 @@ void WASAPIDevice::updateStream()
UINT32 buffer_size; UINT32 buffer_size;
data_t* buffer; data_t* buffer;
lock();
if(FAILED(m_audio_client->GetBufferSize(&buffer_size))) if(FAILED(m_audio_client->GetBufferSize(&buffer_size)))
{
m_playing = false;
m_stop = false;
unlock();
return; return;
}
IAudioRenderClient* render_client = nullptr; IAudioRenderClient* render_client = nullptr;
const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient); const IID IID_IAudioRenderClient = __uuidof(IAudioRenderClient);
if(FAILED(m_audio_client->GetService(IID_IAudioRenderClient, reinterpret_cast<void**>(&render_client)))) if(FAILED(m_audio_client->GetService(IID_IAudioRenderClient, reinterpret_cast<void**>(&render_client))))
{
m_playing = false;
m_stop = false;
unlock();
return; return;
}
UINT32 padding; UINT32 padding;
if(FAILED(m_audio_client->GetCurrentPadding(&padding))) if(FAILED(m_audio_client->GetCurrentPadding(&padding)))
{ {
SafeRelease(&render_client); SafeRelease(&render_client);
m_playing = false;
m_stop = false;
unlock();
return; return;
} }
@@ -94,40 +75,31 @@ void WASAPIDevice::updateStream()
if(FAILED(render_client->GetBuffer(length, &buffer))) if(FAILED(render_client->GetBuffer(length, &buffer)))
{ {
SafeRelease(&render_client); SafeRelease(&render_client);
m_playing = false;
m_stop = false;
unlock();
return; return;
} }
lock();
mix((data_t*)buffer, length); mix((data_t*)buffer, length);
unlock();
if(FAILED(render_client->ReleaseBuffer(length, 0))) if(FAILED(render_client->ReleaseBuffer(length, 0)))
{ {
SafeRelease(&render_client); SafeRelease(&render_client);
m_playing = false;
m_stop = false;
unlock();
return; return;
} }
unlock();
m_audio_client->Start(); m_audio_client->Start();
auto sleepDuration = std::chrono::milliseconds(buffer_size * 1000 / int(m_specs.rate) / 2); auto sleepDuration = std::chrono::milliseconds(buffer_size * 1000 / int(m_specs.rate) / 2);
for(;;) for(;;)
{ {
lock();
if(FAILED(m_audio_client->GetCurrentPadding(&padding))) if(FAILED(m_audio_client->GetCurrentPadding(&padding)))
{ {
m_audio_client->Stop(); m_audio_client->Stop();
SafeRelease(&render_client); SafeRelease(&render_client);
m_playing = false;
m_stop = false;
unlock();
return; return;
} }
@@ -137,52 +109,44 @@ void WASAPIDevice::updateStream()
{ {
m_audio_client->Stop(); m_audio_client->Stop();
SafeRelease(&render_client); SafeRelease(&render_client);
m_playing = false;
m_stop = false;
unlock();
return; return;
} }
lock();
mix((data_t*)buffer, length); mix((data_t*)buffer, length);
unlock();
if(FAILED(render_client->ReleaseBuffer(length, 0))) if(FAILED(render_client->ReleaseBuffer(length, 0)))
{ {
m_audio_client->Stop(); m_audio_client->Stop();
SafeRelease(&render_client); SafeRelease(&render_client);
m_playing = false;
m_stop = false;
unlock();
return; return;
} }
// stop thread // stop thread
if(m_stop) if(!m_playing)
{ {
m_audio_client->Stop(); m_audio_client->Stop();
SafeRelease(&render_client); SafeRelease(&render_client);
m_playing = false;
m_stop = false;
unlock();
return; return;
} }
unlock();
std::this_thread::sleep_for(sleepDuration); std::this_thread::sleep_for(sleepDuration);
} }
} }
void WASAPIDevice::playing(bool playing) void WASAPIDevice::playing(bool playing)
{ {
if((!m_playing || m_stop) && playing) if(!m_playing && playing)
start(); start();
else else
m_stop = true; m_playing = playing;
} }
WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) : WASAPIDevice::WASAPIDevice(DeviceSpecs specs, int buffersize) :
m_playing(false), m_playing(false),
m_stop(false),
m_imm_device_enumerator(nullptr), m_imm_device_enumerator(nullptr),
m_imm_device(nullptr), m_imm_device(nullptr),

View File

@@ -48,11 +48,6 @@ private:
*/ */
bool m_playing; bool m_playing;
/**
* Whether the current playback should stop.
*/
bool m_stop;
IMMDeviceEnumerator* m_imm_device_enumerator; IMMDeviceEnumerator* m_imm_device_enumerator;
IMMDevice* m_imm_device; IMMDevice* m_imm_device;
IAudioClient* m_audio_client; IAudioClient* m_audio_client;

View File

@@ -825,7 +825,6 @@ const bTheme U_theme_default = {
.vertex_size = 3, .vertex_size = 3,
.outline_width = 1, .outline_width = 1,
.facedot_size = 4, .facedot_size = 4,
.noodle_curving = 4,
.grid_levels = 2, .grid_levels = 2,
.syntaxl = RGBA(0x565656ff), .syntaxl = RGBA(0x565656ff),
.syntaxs = RGBA(0x975b5bff), .syntaxs = RGBA(0x975b5bff),

View File

@@ -953,7 +953,7 @@
frame_node="#9b9b9ba0" frame_node="#9b9b9ba0"
matte_node="#977474" matte_node="#977474"
distor_node="#749797" distor_node="#749797"
noodle_curving="4" noodle_curving="0"
grid_levels="2" grid_levels="2"
input_node="#cb3d4a" input_node="#cb3d4a"
output_node="#cb3d4a" output_node="#cb3d4a"

View File

@@ -441,7 +441,6 @@ class QuickSmoke(ObjectModeOperator, Operator):
class QuickLiquid(Operator): class QuickLiquid(Operator):
"""Make selected objects liquid"""
bl_idname = "object.quick_liquid" bl_idname = "object.quick_liquid"
bl_label = "Quick Liquid" bl_label = "Quick Liquid"
bl_options = {'REGISTER', 'UNDO'} bl_options = {'REGISTER', 'UNDO'}

View File

@@ -97,12 +97,7 @@ class DATA_PT_EEVEE_light(DataButtonsPanel, Panel):
col = layout.column() col = layout.column()
col.prop(light, "color") col.prop(light, "color")
col.prop(light, "energy") col.prop(light, "energy")
col.separator()
col.prop(light, "diffuse_factor", text="Diffuse")
col.prop(light, "specular_factor", text="Specular") col.prop(light, "specular_factor", text="Specular")
col.prop(light, "volume_factor", text="Volume")
col.separator() col.separator()

View File

@@ -352,12 +352,8 @@ class SEQUENCER_MT_view(Menu):
if is_sequencer_view: if is_sequencer_view:
layout.prop(st, "show_region_hud") layout.prop(st, "show_region_hud")
layout.separator()
if st.view_type == 'SEQUENCER': if st.view_type == 'SEQUENCER':
layout.prop(st, "show_backdrop", text="Preview as Backdrop") layout.prop(st, "show_backdrop", text="Preview as Backdrop")
if is_preview or st.show_backdrop:
layout.prop(st, "show_transform_preview", text="Preview During Transform")
layout.separator() layout.separator()
@@ -728,7 +724,6 @@ class SEQUENCER_MT_strip_image_transform(Menu):
layout.operator("sequencer.strip_transform_clear", text="Clear Rotation").property = 'ROTATION' layout.operator("sequencer.strip_transform_clear", text="Clear Rotation").property = 'ROTATION'
layout.operator("sequencer.strip_transform_clear", text="Clear All").property = 'ALL' layout.operator("sequencer.strip_transform_clear", text="Clear All").property = 'ALL'
class SEQUENCER_MT_strip_transform(Menu): class SEQUENCER_MT_strip_transform(Menu):
bl_label = "Transform" bl_label = "Transform"
@@ -1276,13 +1271,7 @@ class SEQUENCER_PT_effect_text_style(SequencerButtonsPanel, Panel):
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
col = layout.column() col = layout.column()
col.template_ID(strip, "font", open="font.open", unlink="font.unlink")
row = col.row(align=True)
row.use_property_decorate = False
row.template_ID(strip, "font", open="font.open", unlink="font.unlink")
row.prop(strip, "use_bold", text="", icon="BOLD")
row.prop(strip, "use_italic", text="", icon="ITALIC")
col.prop(strip, "font_size") col.prop(strip, "font_size")
col.prop(strip, "color") col.prop(strip, "color")
@@ -1305,6 +1294,7 @@ class SEQUENCER_PT_effect_text_style(SequencerButtonsPanel, Panel):
row.prop_decorator(strip, "box_color") row.prop_decorator(strip, "box_color")
row = layout.row(align=True, heading="Box Margin") row = layout.row(align=True, heading="Box Margin")
row.use_property_decorate = False
sub = row.row(align=True) sub = row.row(align=True)
sub.prop(strip, "box_margin") sub.prop(strip, "box_margin")
sub.active = strip.use_box and (not strip.mute) sub.active = strip.use_box and (not strip.mute)
@@ -1425,36 +1415,36 @@ class SEQUENCER_PT_scene(SequencerButtonsPanel, Panel):
return (strip.type == 'SCENE') return (strip.type == 'SCENE')
def draw(self, context): def draw(self, context):
strip = act_strip(context)
scene = strip.scene
layout = self.layout layout = self.layout
layout.use_property_split = True layout.use_property_split = True
layout.use_property_decorate = False layout.use_property_decorate = False
strip = act_strip(context)
layout.active = not strip.mute layout.active = not strip.mute
layout.template_ID(strip, "scene", text="Scene") layout.template_ID(strip, "scene")
layout.prop(strip, "scene_input", text="Input")
if strip.scene_input == 'CAMERA': scene = strip.scene
layout.template_ID(strip, "scene_camera", text="Camera") layout.prop(strip, "scene_input")
if scene: if scene:
# Build a manual split layout as a hack to get proper alignment with the rest of the buttons. layout.prop(scene, "audio_volume", text="Volume")
sub = layout.row(align=True)
sub.use_property_decorate = True
split = sub.split(factor=0.4, align=True)
split.alignment = 'RIGHT'
split.label(text="Volume")
split.prop(scene, "audio_volume", text="")
sub.use_property_decorate = False
if strip.scene_input == 'CAMERA': if strip.scene_input == 'CAMERA':
layout = layout.column(heading="Show") layout.alignment = 'RIGHT'
layout.prop(strip, "use_grease_pencil", text="Grease Pencil") sub = layout.column(align=True)
split = sub.split(factor=0.5, align=True)
split.alignment = 'RIGHT'
split.label(text="Camera")
split.template_ID(strip, "scene_camera")
layout.prop(strip, "use_grease_pencil", text="Show Grease Pencil")
if scene: if scene:
# Warning, this is not a good convention to follow. # Warning, this is not a good convention to follow.
# Expose here because setting the alpha from the 'Render' menu is very inconvenient. # Expose here because setting the alpha from the 'Render' menu is very inconvenient.
# layout.label(text="Preview")
layout.prop(scene.render, "film_transparent") layout.prop(scene.render, "film_transparent")

View File

@@ -42,7 +42,6 @@
extern "C" { extern "C" {
#endif #endif
struct Collection;
struct ID; struct ID;
struct IDOverrideLibrary; struct IDOverrideLibrary;
struct IDOverrideLibraryProperty; struct IDOverrideLibraryProperty;
@@ -82,7 +81,6 @@ bool BKE_lib_override_library_resync(struct Main *bmain,
struct Scene *scene, struct Scene *scene,
struct ViewLayer *view_layer, struct ViewLayer *view_layer,
struct ID *id_root, struct ID *id_root,
struct Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce); const bool do_hierarchy_enforce);
void BKE_lib_override_library_main_resync(struct Main *bmain, void BKE_lib_override_library_main_resync(struct Main *bmain,
struct Scene *scene, struct Scene *scene,

View File

@@ -663,7 +663,6 @@ static void lib_override_library_create_post_process(Main *bmain,
ViewLayer *view_layer, ViewLayer *view_layer,
ID *id_root, ID *id_root,
ID *id_reference, ID *id_reference,
Collection *residual_storage,
const bool is_resync) const bool is_resync)
{ {
BKE_main_collection_sync(bmain); BKE_main_collection_sync(bmain);
@@ -719,12 +718,7 @@ static void lib_override_library_create_post_process(Main *bmain,
Object *ob_new = (Object *)id_root->newid; Object *ob_new = (Object *)id_root->newid;
if (!lib_override_library_create_post_process_object_is_instantiated( if (!lib_override_library_create_post_process_object_is_instantiated(
view_layer, ob_new, is_resync)) { view_layer, ob_new, is_resync)) {
if (is_resync && residual_storage != NULL) { BKE_collection_object_add_from(bmain, scene, (Object *)id_root, ob_new);
BKE_collection_object_add(bmain, residual_storage, ob_new);
}
else {
BKE_collection_object_add_from(bmain, scene, (Object *)id_root, ob_new);
}
} }
break; break;
} }
@@ -740,7 +734,7 @@ static void lib_override_library_create_post_process(Main *bmain,
BLI_assert(ob_new->id.override_library != NULL && BLI_assert(ob_new->id.override_library != NULL &&
ob_new->id.override_library->reference == &ob->id); ob_new->id.override_library->reference == &ob->id);
Collection *default_instantiating_collection = residual_storage; Collection *default_instantiating_collection = NULL;
if (!lib_override_library_create_post_process_object_is_instantiated( if (!lib_override_library_create_post_process_object_is_instantiated(
view_layer, ob_new, is_resync)) { view_layer, ob_new, is_resync)) {
if (default_instantiating_collection == NULL) { if (default_instantiating_collection == NULL) {
@@ -805,8 +799,7 @@ bool BKE_lib_override_library_create(
return success; return success;
} }
lib_override_library_create_post_process( lib_override_library_create_post_process(bmain, scene, view_layer, id_root, id_reference, false);
bmain, scene, view_layer, id_root, id_reference, NULL, false);
/* Cleanup. */ /* Cleanup. */
BKE_main_id_clear_newpoins(bmain); BKE_main_id_clear_newpoins(bmain);
@@ -865,12 +858,8 @@ bool BKE_lib_override_library_proxy_convert(Main *bmain,
* \param id_root: The root liboverride ID to resync from. * \param id_root: The root liboverride ID to resync from.
* \return true if override was successfully resynced. * \return true if override was successfully resynced.
*/ */
bool BKE_lib_override_library_resync(Main *bmain, bool BKE_lib_override_library_resync(
Scene *scene, Main *bmain, Scene *scene, ViewLayer *view_layer, ID *id_root, const bool do_hierarchy_enforce)
ViewLayer *view_layer,
ID *id_root,
Collection *override_resync_residual_storage,
const bool do_hierarchy_enforce)
{ {
BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root)); BLI_assert(ID_IS_OVERRIDE_LIBRARY_REAL(id_root));
BLI_assert(!ID_IS_LINKED(id_root)); BLI_assert(!ID_IS_LINKED(id_root));
@@ -1081,13 +1070,8 @@ bool BKE_lib_override_library_resync(Main *bmain,
* since we already relinked old root override collection to new resync'ed one above. So this * since we already relinked old root override collection to new resync'ed one above. So this
* call is not expected to instantiate this new resync'ed collection anywhere, just to ensure * call is not expected to instantiate this new resync'ed collection anywhere, just to ensure
* that we do not have any stray objects. */ * that we do not have any stray objects. */
lib_override_library_create_post_process(bmain, lib_override_library_create_post_process(
scene, bmain, scene, view_layer, id_root_reference, id_root, true);
view_layer,
id_root_reference,
id_root,
override_resync_residual_storage,
true);
/* Cleanup. */ /* Cleanup. */
BLI_ghash_free(linkedref_to_old_override, NULL, NULL); BLI_ghash_free(linkedref_to_old_override, NULL, NULL);
@@ -1114,23 +1098,6 @@ bool BKE_lib_override_library_resync(Main *bmain,
*/ */
void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *view_layer) void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *view_layer)
{ {
/* We use a specific collection to gather/store all 'orphaned' override collections and objects
* generated by resyncprocess. This avoids putting them in scene's master collection. */
#define OVERRIDE_RESYNC_RESIDUAL_STORAGE_NAME "OVERRIDE_RESYNC_LEFTOVERS"
Collection *override_resync_residual_storage = BLI_findstring(
&bmain->collections, OVERRIDE_RESYNC_RESIDUAL_STORAGE_NAME, offsetof(ID, name) + 2);
if (override_resync_residual_storage != NULL &&
override_resync_residual_storage->id.lib != NULL) {
override_resync_residual_storage = NULL;
}
if (override_resync_residual_storage == NULL) {
override_resync_residual_storage = BKE_collection_add(
bmain, scene->master_collection, OVERRIDE_RESYNC_RESIDUAL_STORAGE_NAME);
/* Hide the collection from viewport and render. */
override_resync_residual_storage->flag |= COLLECTION_RESTRICT_VIEWPORT |
COLLECTION_RESTRICT_RENDER;
}
BKE_main_relations_create(bmain, 0); BKE_main_relations_create(bmain, 0);
BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false); BKE_main_id_tag_all(bmain, LIB_TAG_DOIT, false);
@@ -1220,8 +1187,7 @@ void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *
} }
do_continue = true; do_continue = true;
CLOG_INFO(&LOG, 2, "Resyncing %s...", id->name); CLOG_INFO(&LOG, 2, "Resyncing %s...", id->name);
const bool success = BKE_lib_override_library_resync( const bool success = BKE_lib_override_library_resync(bmain, scene, view_layer, id, false);
bmain, scene, view_layer, id, override_resync_residual_storage, false);
CLOG_INFO(&LOG, 2, "\tSuccess: %d", success); CLOG_INFO(&LOG, 2, "\tSuccess: %d", success);
break; break;
} }
@@ -1232,10 +1198,6 @@ void BKE_lib_override_library_main_resync(Main *bmain, Scene *scene, ViewLayer *
} }
FOREACH_MAIN_LISTBASE_END; FOREACH_MAIN_LISTBASE_END;
} }
if (BKE_collection_is_empty(override_resync_residual_storage)) {
BKE_collection_delete(bmain, override_resync_residual_storage, true);
}
} }
/** /**

View File

@@ -60,16 +60,6 @@ template<
*/ */
typename Allocator = GuardedAllocator> typename Allocator = GuardedAllocator>
class Array { class Array {
public:
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = T &;
using const_reference = const T &;
using iterator = T *;
using const_iterator = const T *;
using size_type = int64_t;
private: private:
/** The beginning of the array. It might point into the inline buffer. */ /** The beginning of the array. It might point into the inline buffer. */
T *data_; T *data_;

View File

@@ -94,7 +94,6 @@ struct float4x4 {
return float3(values[3]); return float3(values[3]);
} }
/* Assumes XYZ rotation order. */
float3 to_euler() const float3 to_euler() const
{ {
float3 euler; float3 euler;

View File

@@ -82,18 +82,11 @@ class IndexRange {
} }
class Iterator { class Iterator {
public:
using iterator_category = std::forward_iterator_tag;
using value_type = int64_t;
using pointer = const int64_t *;
using reference = const int64_t &;
using difference_type = std::ptrdiff_t;
private: private:
int64_t current_; int64_t current_;
public: public:
constexpr explicit Iterator(int64_t current) : current_(current) constexpr Iterator(int64_t current) : current_(current)
{ {
} }
@@ -103,21 +96,9 @@ class IndexRange {
return *this; return *this;
} }
constexpr Iterator operator++(int) const constexpr bool operator!=(const Iterator &iterator) const
{ {
Iterator copied_iterator = *this; return current_ != iterator.current_;
++copied_iterator;
return copied_iterator;
}
constexpr friend bool operator!=(const Iterator &a, const Iterator &b)
{
return a.current_ != b.current_;
}
constexpr friend bool operator==(const Iterator &a, const Iterator &b)
{
return a.current_ == b.current_;
} }
constexpr int64_t operator*() const constexpr int64_t operator*() const

View File

@@ -120,9 +120,6 @@ template<
*/ */
typename Allocator = GuardedAllocator> typename Allocator = GuardedAllocator>
class Map { class Map {
public:
using size_type = int64_t;
private: private:
/** /**
* Slots are either empty, occupied or removed. The number of occupied slots can be computed by * Slots are either empty, occupied or removed. The number of occupied slots can be computed by
@@ -626,9 +623,6 @@ class Map {
* This uses the "curiously recurring template pattern" (CRTP). * This uses the "curiously recurring template pattern" (CRTP).
*/ */
template<typename SubIterator> struct BaseIterator { template<typename SubIterator> struct BaseIterator {
using iterator_category = std::forward_iterator_tag;
using difference_type = std::ptrdiff_t;
Slot *slots_; Slot *slots_;
int64_t total_slots_; int64_t total_slots_;
int64_t current_slot_; int64_t current_slot_;
@@ -648,13 +642,6 @@ class Map {
return *this; return *this;
} }
BaseIterator operator++(int) const
{
BaseIterator copied_iterator = *this;
++copied_iterator;
return copied_iterator;
}
friend bool operator!=(const BaseIterator &a, const BaseIterator &b) friend bool operator!=(const BaseIterator &a, const BaseIterator &b)
{ {
BLI_assert(a.slots_ == b.slots_); BLI_assert(a.slots_ == b.slots_);
@@ -662,11 +649,6 @@ class Map {
return a.current_slot_ != b.current_slot_; return a.current_slot_ != b.current_slot_;
} }
friend bool operator==(const BaseIterator &a, const BaseIterator &b)
{
return !(a != b);
}
SubIterator begin() const SubIterator begin() const
{ {
for (int64_t i = 0; i < total_slots_; i++) { for (int64_t i = 0; i < total_slots_; i++) {
@@ -690,10 +672,6 @@ class Map {
class KeyIterator final : public BaseIterator<KeyIterator> { class KeyIterator final : public BaseIterator<KeyIterator> {
public: public:
using value_type = Key;
using pointer = const Key *;
using reference = const Key &;
KeyIterator(const Slot *slots, int64_t total_slots, int64_t current_slot) KeyIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<KeyIterator>(slots, total_slots, current_slot) : BaseIterator<KeyIterator>(slots, total_slots, current_slot)
{ {
@@ -707,10 +685,6 @@ class Map {
class ValueIterator final : public BaseIterator<ValueIterator> { class ValueIterator final : public BaseIterator<ValueIterator> {
public: public:
using value_type = Value;
using pointer = const Value *;
using reference = const Value &;
ValueIterator(const Slot *slots, int64_t total_slots, int64_t current_slot) ValueIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<ValueIterator>(slots, total_slots, current_slot) : BaseIterator<ValueIterator>(slots, total_slots, current_slot)
{ {
@@ -724,10 +698,6 @@ class Map {
class MutableValueIterator final : public BaseIterator<MutableValueIterator> { class MutableValueIterator final : public BaseIterator<MutableValueIterator> {
public: public:
using value_type = Value;
using pointer = Value *;
using reference = Value &;
MutableValueIterator(const Slot *slots, int64_t total_slots, int64_t current_slot) MutableValueIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<MutableValueIterator>(slots, total_slots, current_slot) : BaseIterator<MutableValueIterator>(slots, total_slots, current_slot)
{ {
@@ -756,10 +726,6 @@ class Map {
class ItemIterator final : public BaseIterator<ItemIterator> { class ItemIterator final : public BaseIterator<ItemIterator> {
public: public:
using value_type = Item;
using pointer = Item *;
using reference = Item &;
ItemIterator(const Slot *slots, int64_t total_slots, int64_t current_slot) ItemIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<ItemIterator>(slots, total_slots, current_slot) : BaseIterator<ItemIterator>(slots, total_slots, current_slot)
{ {
@@ -774,10 +740,6 @@ class Map {
class MutableItemIterator final : public BaseIterator<MutableItemIterator> { class MutableItemIterator final : public BaseIterator<MutableItemIterator> {
public: public:
using value_type = MutableItem;
using pointer = MutableItem *;
using reference = MutableItem &;
MutableItemIterator(const Slot *slots, int64_t total_slots, int64_t current_slot) MutableItemIterator(const Slot *slots, int64_t total_slots, int64_t current_slot)
: BaseIterator<MutableItemIterator>(slots, total_slots, current_slot) : BaseIterator<MutableItemIterator>(slots, total_slots, current_slot)
{ {

View File

@@ -38,9 +38,6 @@
namespace blender { namespace blender {
template<typename Key, typename Value> class MultiValueMap { template<typename Key, typename Value> class MultiValueMap {
public:
using size_type = int64_t;
private: private:
using MapType = Map<Key, Vector<Value>>; using MapType = Map<Key, Vector<Value>>;
MapType map_; MapType map_;

View File

@@ -119,16 +119,6 @@ template<
*/ */
typename Allocator = GuardedAllocator> typename Allocator = GuardedAllocator>
class Set { class Set {
public:
class Iterator;
using value_type = Key;
using pointer = Key *;
using const_pointer = const Key *;
using reference = Key &;
using const_reference = const Key &;
using iterator = Iterator;
using size_type = int64_t;
private: private:
/** /**
* Slots are either empty, occupied or removed. The number of occupied slots can be computed by * Slots are either empty, occupied or removed. The number of occupied slots can be computed by
@@ -411,13 +401,6 @@ class Set {
* also change their hash. * also change their hash.
*/ */
class Iterator { class Iterator {
public:
using iterator_category = std::forward_iterator_tag;
using value_type = Key;
using pointer = const Key *;
using reference = const Key &;
using difference_type = std::ptrdiff_t;
private: private:
const Slot *slots_; const Slot *slots_;
int64_t total_slots_; int64_t total_slots_;
@@ -439,34 +422,17 @@ class Set {
return *this; return *this;
} }
Iterator operator++(int) const
{
Iterator copied_iterator = *this;
++copied_iterator;
return copied_iterator;
}
const Key &operator*() const const Key &operator*() const
{ {
return *slots_[current_slot_].key(); return *slots_[current_slot_].key();
} }
const Key *operator->() const
{
return slots_[current_slot_].key();
}
friend bool operator!=(const Iterator &a, const Iterator &b) friend bool operator!=(const Iterator &a, const Iterator &b)
{ {
BLI_assert(a.slots_ == b.slots_); BLI_assert(a.slots_ == b.slots_);
BLI_assert(a.total_slots_ == b.total_slots_); BLI_assert(a.total_slots_ == b.total_slots_);
return a.current_slot_ != b.current_slot_; return a.current_slot_ != b.current_slot_;
} }
friend bool operator==(const Iterator &a, const Iterator &b)
{
return !(a != b);
}
}; };
Iterator begin() const Iterator begin() const

View File

@@ -85,15 +85,6 @@ namespace blender {
* modified. * modified.
*/ */
template<typename T> class Span { template<typename T> class Span {
public:
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = T &;
using const_reference = const T &;
using iterator = const T *;
using size_type = int64_t;
private: private:
const T *data_ = nullptr; const T *data_ = nullptr;
int64_t size_ = 0; int64_t size_ = 0;
@@ -468,15 +459,6 @@ template<typename T> class Span {
* MutableSpan. * MutableSpan.
*/ */
template<typename T> class MutableSpan { template<typename T> class MutableSpan {
public:
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = T &;
using const_reference = const T &;
using iterator = T *;
using size_type = int64_t;
private: private:
T *data_; T *data_;
int64_t size_; int64_t size_;

View File

@@ -80,14 +80,6 @@ template<
*/ */
typename Allocator = GuardedAllocator> typename Allocator = GuardedAllocator>
class Stack { class Stack {
public:
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = T &;
using const_reference = const T &;
using size_type = int64_t;
private: private:
using Chunk = StackChunk<T>; using Chunk = StackChunk<T>;

View File

@@ -76,16 +76,6 @@ template<
*/ */
typename Allocator = GuardedAllocator> typename Allocator = GuardedAllocator>
class Vector { class Vector {
public:
using value_type = T;
using pointer = T *;
using const_pointer = const T *;
using reference = T &;
using const_reference = const T &;
using iterator = T *;
using const_iterator = const T *;
using size_type = int64_t;
private: private:
/** /**
* Use pointers instead of storing the size explicitly. This reduces the number of instructions * Use pointers instead of storing the size explicitly. This reduces the number of instructions

View File

@@ -100,16 +100,6 @@ template<
*/ */
typename Allocator = GuardedAllocator> typename Allocator = GuardedAllocator>
class VectorSet { class VectorSet {
public:
using value_type = Key;
using pointer = Key *;
using const_pointer = const Key *;
using reference = Key &;
using const_reference = const Key &;
using iterator = Key *;
using const_iterator = const Key *;
using size_type = int64_t;
private: private:
/** /**
* Slots are either empty, occupied or removed. The number of occupied slots can be computed by * Slots are either empty, occupied or removed. The number of occupied slots can be computed by

View File

@@ -147,13 +147,4 @@ TEST(index_range, constexpr_)
BLI_STATIC_ASSERT(range.size() == 1, ""); BLI_STATIC_ASSERT(range.size() == 1, "");
EXPECT_EQ(compiles[0], 1); EXPECT_EQ(compiles[0], 1);
} }
TEST(index_range, GenericAlgorithms)
{
IndexRange range{4, 10};
EXPECT_TRUE(std::any_of(range.begin(), range.end(), [](int v) { return v == 6; }));
EXPECT_FALSE(std::any_of(range.begin(), range.end(), [](int v) { return v == 20; }));
EXPECT_EQ(std::count_if(range.begin(), range.end(), [](int v) { return v < 7; }), 3);
}
} // namespace blender::tests } // namespace blender::tests

View File

@@ -587,23 +587,6 @@ TEST(map, EnumKey)
EXPECT_EQ(map.lookup(TestEnum::B), 10); EXPECT_EQ(map.lookup(TestEnum::B), 10);
} }
TEST(map, GenericAlgorithms)
{
Map<int, int> map;
map.add(5, 2);
map.add(1, 4);
map.add(2, 2);
map.add(7, 1);
map.add(8, 6);
EXPECT_TRUE(std::any_of(map.keys().begin(), map.keys().end(), [](int v) { return v == 1; }));
EXPECT_TRUE(std::any_of(map.values().begin(), map.values().end(), [](int v) { return v == 1; }));
EXPECT_TRUE(std::any_of(
map.items().begin(), map.items().end(), [](auto item) { return item.value == 1; }));
EXPECT_EQ(std::count(map.values().begin(), map.values().end(), 2), 2);
EXPECT_EQ(std::count(map.values().begin(), map.values().end(), 4), 1);
EXPECT_EQ(std::count(map.keys().begin(), map.keys().end(), 7), 1);
}
/** /**
* Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot. * Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot.
*/ */

View File

@@ -526,24 +526,6 @@ TEST(set, AddExceptions)
EXPECT_EQ(set.size(), 0); EXPECT_EQ(set.size(), 0);
} }
TEST(set, ForwardIterator)
{
Set<int> set = {5, 2, 6, 4, 1};
Set<int>::iterator iter1 = set.begin();
int value1 = *iter1;
Set<int>::iterator iter2 = iter1++;
EXPECT_EQ(*iter1, value1);
EXPECT_EQ(*iter2, *(++iter1));
}
TEST(set, GenericAlgorithms)
{
Set<int> set = {1, 20, 30, 40};
EXPECT_FALSE(std::any_of(set.begin(), set.end(), [](int v) { return v == 5; }));
EXPECT_TRUE(std::any_of(set.begin(), set.end(), [](int v) { return v == 30; }));
EXPECT_EQ(std::count(set.begin(), set.end(), 20), 1);
}
/** /**
* Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot. * Set this to 1 to activate the benchmark. It is disabled by default, because it prints a lot.
*/ */

View File

@@ -36,7 +36,6 @@
#include "DNA_gpencil_modifier_types.h" #include "DNA_gpencil_modifier_types.h"
#include "DNA_gpencil_types.h" #include "DNA_gpencil_types.h"
#include "DNA_hair_types.h" #include "DNA_hair_types.h"
#include "DNA_light_types.h"
#include "DNA_mesh_types.h" #include "DNA_mesh_types.h"
#include "DNA_meshdata_types.h" #include "DNA_meshdata_types.h"
#include "DNA_modifier_types.h" #include "DNA_modifier_types.h"
@@ -1916,12 +1915,5 @@ void blo_do_versions_290(FileData *fd, Library *UNUSED(lib), Main *bmain)
*/ */
{ {
/* Keep this block, even when empty. */ /* Keep this block, even when empty. */
if (!DNA_struct_elem_find(fd->filesdna, "Light", "float", "diff_fac")) {
LISTBASE_FOREACH (Light *, light, &bmain->lights) {
light->diff_fac = 1.0f;
light->volume_fac = 1.0f;
}
}
} }
} }

View File

@@ -102,13 +102,13 @@ extern "C" {
* ExecutionGroups that have no viewer-node, * ExecutionGroups that have no viewer-node,
* will use a default one. * will use a default one.
* There are several possible chunk orders * There are several possible chunk orders
* - [@ref ChunkOrdering.CenterOut]: * - [@ref OrderOfChunks.COM_TO_CENTER_OUT]:
* Start calculating from a configurable point and order by nearest chunk. * Start calculating from a configurable point and order by nearest chunk.
* - [@ref ChunkOrdering.Random]: * - [@ref OrderOfChunks.COM_TO_RANDOM]:
* Randomize all chunks. * Randomize all chunks.
* - [@ref ChunkOrdering.TopDown]: * - [@ref OrderOfChunks.COM_TO_TOP_DOWN]:
* Start calculation from the bottom to the top of the image. * Start calculation from the bottom to the top of the image.
* - [@ref ChunkOrdering.RuleOfThirds]: * - [@ref OrderOfChunks.COM_TO_RULE_OF_THIRDS]:
* Experimental order based on 9 hot-spots in the image. * Experimental order based on 9 hot-spots in the image.
* *
* When the chunk-order is determined, the first few chunks will be checked if they can be scheduled. * When the chunk-order is determined, the first few chunks will be checked if they can be scheduled.
@@ -122,7 +122,7 @@ extern "C" {
* *
* \see ExecutionGroup.execute * \see ExecutionGroup.execute
* \see ViewerOperation.getChunkOrder * \see ViewerOperation.getChunkOrder
* \see ChunkOrdering * \see OrderOfChunks
* *
* \section interest Area of interest * \section interest Area of interest
* An ExecutionGroup can have dependencies to other ExecutionGroup's. * An ExecutionGroup can have dependencies to other ExecutionGroup's.

View File

@@ -22,41 +22,41 @@
* \brief possible data types for sockets * \brief possible data types for sockets
* \ingroup Model * \ingroup Model
*/ */
enum class DataType { typedef enum DataType {
/** \brief Value data type */ /** \brief Value data type */
Value = 0, COM_DT_VALUE = 1,
/** \brief Vector data type */ /** \brief Vector data type */
Vector = 1, COM_DT_VECTOR = 2,
/** \brief Color data type */ /** \brief Color data type */
Color = 2, COM_DT_COLOR = 4,
}; } DataType;
/** /**
* \brief Possible quality settings * \brief Possible quality settings
* \see CompositorContext.quality * \see CompositorContext.quality
* \ingroup Execution * \ingroup Execution
*/ */
enum class CompositorQuality { typedef enum CompositorQuality {
/** \brief High quality setting */ /** \brief High quality setting */
High = 0, COM_QUALITY_HIGH = 0,
/** \brief Medium quality setting */ /** \brief Medium quality setting */
Medium = 1, COM_QUALITY_MEDIUM = 1,
/** \brief Low quality setting */ /** \brief Low quality setting */
Low = 2, COM_QUALITY_LOW = 2,
}; } CompositorQuality;
/** /**
* \brief Possible priority settings * \brief Possible priority settings
* \ingroup Execution * \ingroup Execution
*/ */
enum class CompositorPriority { typedef enum CompositorPriority {
/** \brief High quality setting */ /** \brief High quality setting */
High = 2, COM_PRIORITY_HIGH = 2,
/** \brief Medium quality setting */ /** \brief Medium quality setting */
Medium = 1, COM_PRIORITY_MEDIUM = 1,
/** \brief Low quality setting */ /** \brief Low quality setting */
Low = 0, COM_PRIORITY_LOW = 0,
}; } CompositorPriority;
// configurable items // configurable items
@@ -87,18 +87,18 @@ enum class CompositorPriority {
* \brief The order of chunks to be scheduled * \brief The order of chunks to be scheduled
* \ingroup Execution * \ingroup Execution
*/ */
enum class ChunkOrdering { typedef enum OrderOfChunks {
/** \brief order from a distance to centerX/centerY */ /** \brief order from a distance to centerX/centerY */
CenterOut = 0, COM_TO_CENTER_OUT = 0,
/** \brief order randomly */ /** \brief order randomly */
Random = 1, COM_TO_RANDOM = 1,
/** \brief no ordering */ /** \brief no ordering */
TopDown = 2, COM_TO_TOP_DOWN = 2,
/** \brief experimental ordering with 9 hot-spots. */ /** \brief experimental ordering with 9 hot-spots. */
RuleOfThirds = 3, COM_TO_RULE_OF_THIRDS = 3,
} OrderOfChunks;
Default = ChunkOrdering::CenterOut, #define COM_ORDER_OF_CHUNKS_DEFAULT COM_TO_CENTER_OUT
};
#define COM_RULE_OF_THIRDS_DIVIDER 100.0f #define COM_RULE_OF_THIRDS_DIVIDER 100.0f

View File

@@ -17,14 +17,22 @@
*/ */
#include "COM_ChunkOrder.h" #include "COM_ChunkOrder.h"
#include "BLI_math.h" #include "BLI_math.h"
void ChunkOrder::update_distance(ChunkOrderHotspot *hotspots, unsigned int len_hotspots) ChunkOrder::ChunkOrder()
{ {
double new_distance = DBL_MAX; distance = 0.0;
number = 0;
x = 0;
y = 0;
}
void ChunkOrder::update_distance(ChunkOrderHotspot **hotspots, unsigned int len_hotspots)
{
double new_distance = FLT_MAX;
for (int index = 0; index < len_hotspots; index++) { for (int index = 0; index < len_hotspots; index++) {
double distance_to_hotspot = hotspots[index].calc_distance(x, y); ChunkOrderHotspot *hotspot = hotspots[index];
double distance_to_hotspot = hotspot->calc_distance(x, y);
if (distance_to_hotspot < new_distance) { if (distance_to_hotspot < new_distance) {
new_distance = distance_to_hotspot; new_distance = distance_to_hotspot;
} }

View File

@@ -23,17 +23,17 @@
#endif #endif
#include "COM_ChunkOrderHotspot.h" #include "COM_ChunkOrderHotspot.h"
/** Helper to determine the order how chunks are prioritized during execution. */
struct ChunkOrder { struct ChunkOrder {
unsigned int index = 0; unsigned int number;
int x = 0; int x;
int y = 0; int y;
double distance = 0.0; double distance;
ChunkOrder();
friend bool operator<(const ChunkOrder &a, const ChunkOrder &b); friend bool operator<(const ChunkOrder &a, const ChunkOrder &b);
void update_distance(ChunkOrderHotspot *hotspots, unsigned int len_hotspots); void update_distance(ChunkOrderHotspot **hotspots, unsigned int len_hotspots);
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot") MEM_CXX_CLASS_ALLOC_FUNCS("COM:ChunkOrderHotspot")

View File

@@ -24,7 +24,7 @@ CompositorContext::CompositorContext()
{ {
this->m_scene = nullptr; this->m_scene = nullptr;
this->m_rd = nullptr; this->m_rd = nullptr;
this->m_quality = CompositorQuality::High; this->m_quality = COM_QUALITY_HIGH;
this->m_hasActiveOpenCLDevices = false; this->m_hasActiveOpenCLDevices = false;
this->m_fastCalculation = false; this->m_fastCalculation = false;
this->m_viewSettings = nullptr; this->m_viewSettings = nullptr;

View File

@@ -428,22 +428,22 @@ NodeOperation *COM_convert_data_type(const NodeOperationOutput &from, const Node
const DataType src_data_type = from.getDataType(); const DataType src_data_type = from.getDataType();
const DataType dst_data_type = to.getDataType(); const DataType dst_data_type = to.getDataType();
if (src_data_type == DataType::Value && dst_data_type == DataType::Color) { if (src_data_type == COM_DT_VALUE && dst_data_type == COM_DT_COLOR) {
return new ConvertValueToColorOperation(); return new ConvertValueToColorOperation();
} }
if (src_data_type == DataType::Value && dst_data_type == DataType::Vector) { if (src_data_type == COM_DT_VALUE && dst_data_type == COM_DT_VECTOR) {
return new ConvertValueToVectorOperation(); return new ConvertValueToVectorOperation();
} }
if (src_data_type == DataType::Color && dst_data_type == DataType::Value) { if (src_data_type == COM_DT_COLOR && dst_data_type == COM_DT_VALUE) {
return new ConvertColorToValueOperation(); return new ConvertColorToValueOperation();
} }
if (src_data_type == DataType::Color && dst_data_type == DataType::Vector) { if (src_data_type == COM_DT_COLOR && dst_data_type == COM_DT_VECTOR) {
return new ConvertColorToVectorOperation(); return new ConvertColorToVectorOperation();
} }
if (src_data_type == DataType::Vector && dst_data_type == DataType::Value) { if (src_data_type == COM_DT_VECTOR && dst_data_type == COM_DT_VALUE) {
return new ConvertVectorToValueOperation(); return new ConvertVectorToValueOperation();
} }
if (src_data_type == DataType::Vector && dst_data_type == DataType::Color) { if (src_data_type == COM_DT_VECTOR && dst_data_type == COM_DT_COLOR) {
return new ConvertVectorToColorOperation(); return new ConvertVectorToColorOperation();
} }

View File

@@ -165,13 +165,13 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
} }
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<IN_%p>", socket);
switch (socket->getDataType()) { switch (socket->getDataType()) {
case DataType::Value: case COM_DT_VALUE:
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
break; break;
case DataType::Vector: case COM_DT_VECTOR:
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector");
break; break;
case DataType::Color: case COM_DT_COLOR:
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color");
break; break;
} }
@@ -203,13 +203,13 @@ int DebugInfo::graphviz_operation(const ExecutionSystem *system,
} }
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "<OUT_%p>", socket);
switch (socket->getDataType()) { switch (socket->getDataType()) {
case DataType::Value: case COM_DT_VALUE:
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Value");
break; break;
case DataType::Vector: case COM_DT_VECTOR:
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Vector");
break; break;
case DataType::Color: case COM_DT_COLOR:
len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color"); len += snprintf(str + len, maxlen > len ? maxlen - len : 0, "Color");
break; break;
} }
@@ -390,13 +390,13 @@ bool DebugInfo::graphviz_system(const ExecutionSystem *system, char *str, int ma
std::string color; std::string color;
switch (from->getDataType()) { switch (from->getDataType()) {
case DataType::Value: case COM_DT_VALUE:
color = "gray"; color = "gray";
break; break;
case DataType::Vector: case COM_DT_VECTOR:
color = "blue"; color = "blue";
break; break;
case DataType::Color: case COM_DT_COLOR:
color = "orange"; color = "orange";
break; break;
} }

View File

@@ -34,15 +34,10 @@
#include "COM_defines.h" #include "COM_defines.h"
#include "BLI_math.h" #include "BLI_math.h"
#include "BLI_rand.hh"
#include "BLI_string.h" #include "BLI_string.h"
#include "BLT_translation.h" #include "BLT_translation.h"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
#include "PIL_time.h" #include "PIL_time.h"
#include "WM_api.h" #include "WM_api.h"
#include "WM_types.h" #include "WM_types.h"
@@ -70,19 +65,19 @@ CompositorPriority ExecutionGroup::getRenderPriotrity()
return this->getOutputOperation()->getRenderPriority(); return this->getOutputOperation()->getRenderPriority();
} }
bool ExecutionGroup::can_contain(NodeOperation &operation) bool ExecutionGroup::canContainOperation(NodeOperation *operation)
{ {
if (!this->m_initialized) { if (!this->m_initialized) {
return true; return true;
} }
if (operation.isReadBufferOperation()) { if (operation->isReadBufferOperation()) {
return true; return true;
} }
if (operation.isWriteBufferOperation()) { if (operation->isWriteBufferOperation()) {
return false; return false;
} }
if (operation.isSetOperation()) { if (operation->isSetOperation()) {
return true; return true;
} }
@@ -92,7 +87,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
} }
/* complex ops can't be added to other groups (except their own, which they initialize, see /* complex ops can't be added to other groups (except their own, which they initialize, see
* above) */ * above) */
if (operation.isComplex()) { if (operation->isComplex()) {
return false; return false;
} }
@@ -101,7 +96,7 @@ bool ExecutionGroup::can_contain(NodeOperation &operation)
bool ExecutionGroup::addOperation(NodeOperation *operation) bool ExecutionGroup::addOperation(NodeOperation *operation)
{ {
if (!can_contain(*operation)) { if (!canContainOperation(operation)) {
return false; return false;
} }
@@ -183,103 +178,6 @@ void ExecutionGroup::determineNumberOfChunks()
} }
} }
blender::Array<unsigned int> ExecutionGroup::determine_chunk_execution_order() const
{
int index;
blender::Array<unsigned int> chunk_order(m_chunks_len);
for (int chunk_index = 0; chunk_index < this->m_chunks_len; chunk_index++) {
chunk_order[chunk_index] = chunk_index;
}
NodeOperation *operation = this->getOutputOperation();
float centerX = 0.5f;
float centerY = 0.5f;
ChunkOrdering order_type = ChunkOrdering::Default;
if (operation->isViewerOperation()) {
ViewerOperation *viewer = (ViewerOperation *)operation;
centerX = viewer->getCenterX();
centerY = viewer->getCenterY();
order_type = viewer->getChunkOrder();
}
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
switch (order_type) {
case ChunkOrdering::Random: {
static blender::RandomNumberGenerator rng;
blender::MutableSpan<unsigned int> span = chunk_order.as_mutable_span();
/* Shuffle twice to make it more random. */
rng.shuffle(span);
rng.shuffle(span);
break;
}
case ChunkOrdering::CenterOut: {
ChunkOrderHotspot hotspot(border_width * centerX, border_height * centerY, 0.0f);
blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
for (index = 0; index < this->m_chunks_len; index++) {
rcti rect;
determineChunkRect(&rect, index);
chunk_orders[index].index = index;
chunk_orders[index].x = rect.xmin - this->m_viewerBorder.xmin;
chunk_orders[index].y = rect.ymin - this->m_viewerBorder.ymin;
chunk_orders[index].update_distance(&hotspot, 1);
}
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len - 1]);
for (index = 0; index < this->m_chunks_len; index++) {
chunk_order[index] = chunk_orders[index].index;
}
break;
}
case ChunkOrdering::RuleOfThirds: {
unsigned int tx = border_width / 6;
unsigned int ty = border_height / 6;
unsigned int mx = border_width / 2;
unsigned int my = border_height / 2;
unsigned int bx = mx + 2 * tx;
unsigned int by = my + 2 * ty;
float addition = this->m_chunks_len / COM_RULE_OF_THIRDS_DIVIDER;
ChunkOrderHotspot hotspots[9]{
ChunkOrderHotspot(mx, my, addition * 0),
ChunkOrderHotspot(tx, my, addition * 1),
ChunkOrderHotspot(bx, my, addition * 2),
ChunkOrderHotspot(bx, by, addition * 3),
ChunkOrderHotspot(tx, ty, addition * 4),
ChunkOrderHotspot(bx, ty, addition * 5),
ChunkOrderHotspot(tx, by, addition * 6),
ChunkOrderHotspot(mx, ty, addition * 7),
ChunkOrderHotspot(mx, by, addition * 8),
};
blender::Array<ChunkOrder> chunk_orders(m_chunks_len);
for (index = 0; index < this->m_chunks_len; index++) {
rcti rect;
determineChunkRect(&rect, index);
chunk_orders[index].index = index;
chunk_orders[index].x = rect.xmin - this->m_viewerBorder.xmin;
chunk_orders[index].y = rect.ymin - this->m_viewerBorder.ymin;
chunk_orders[index].update_distance(hotspots, 9);
}
std::sort(&chunk_orders[0], &chunk_orders[this->m_chunks_len]);
for (index = 0; index < this->m_chunks_len; index++) {
chunk_order[index] = chunk_orders[index].index;
}
break;
}
case ChunkOrdering::TopDown:
default:
break;
}
return chunk_order;
}
/** /**
* this method is called for the top execution groups. containing the compositor node or the * this method is called for the top execution groups. containing the compositor node or the
* preview node or the viewer node) * preview node or the viewer node)
@@ -297,15 +195,119 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
if (this->m_chunks_len == 0) { if (this->m_chunks_len == 0) {
return; return;
} /** \note Early break out. */ } /** \note Early break out. */
unsigned int chunk_index; unsigned int chunkNumber;
this->m_executionStartTime = PIL_check_seconds_timer(); this->m_executionStartTime = PIL_check_seconds_timer();
this->m_chunks_finished = 0; this->m_chunks_finished = 0;
this->m_bTree = bTree; this->m_bTree = bTree;
unsigned int index; unsigned int index;
unsigned int *chunkOrder = (unsigned int *)MEM_mallocN(sizeof(unsigned int) * this->m_chunks_len,
__func__);
blender::Array<unsigned int> chunk_order = determine_chunk_execution_order(); for (chunkNumber = 0; chunkNumber < this->m_chunks_len; chunkNumber++) {
chunkOrder[chunkNumber] = chunkNumber;
}
NodeOperation *operation = this->getOutputOperation();
float centerX = 0.5;
float centerY = 0.5;
OrderOfChunks chunkorder = COM_ORDER_OF_CHUNKS_DEFAULT;
if (operation->isViewerOperation()) {
ViewerOperation *viewer = (ViewerOperation *)operation;
centerX = viewer->getCenterX();
centerY = viewer->getCenterY();
chunkorder = viewer->getChunkOrder();
}
const int border_width = BLI_rcti_size_x(&this->m_viewerBorder);
const int border_height = BLI_rcti_size_y(&this->m_viewerBorder);
switch (chunkorder) {
case COM_TO_RANDOM:
for (index = 0; index < 2 * this->m_chunks_len; index++) {
int index1 = rand() % this->m_chunks_len;
int index2 = rand() % this->m_chunks_len;
int s = chunkOrder[index1];
chunkOrder[index1] = chunkOrder[index2];
chunkOrder[index2] = s;
}
break;
case COM_TO_CENTER_OUT: {
ChunkOrderHotspot *hotspots[1];
hotspots[0] = new ChunkOrderHotspot(border_width * centerX, border_height * centerY, 0.0f);
rcti rect;
ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(sizeof(ChunkOrder) * this->m_chunks_len,
__func__);
for (index = 0; index < this->m_chunks_len; index++) {
determineChunkRect(&rect, index);
chunkOrders[index].number = index;
chunkOrders[index].x = rect.xmin - this->m_viewerBorder.xmin;
chunkOrders[index].y = rect.ymin - this->m_viewerBorder.ymin;
chunkOrders[index].update_distance(hotspots, 1);
}
std::sort(&chunkOrders[0], &chunkOrders[this->m_chunks_len - 1]);
for (index = 0; index < this->m_chunks_len; index++) {
chunkOrder[index] = chunkOrders[index].number;
}
delete hotspots[0];
MEM_freeN(chunkOrders);
break;
}
case COM_TO_RULE_OF_THIRDS: {
ChunkOrderHotspot *hotspots[9];
unsigned int tx = border_width / 6;
unsigned int ty = border_height / 6;
unsigned int mx = border_width / 2;
unsigned int my = border_height / 2;
unsigned int bx = mx + 2 * tx;
unsigned int by = my + 2 * ty;
float addition = this->m_chunks_len / COM_RULE_OF_THIRDS_DIVIDER;
hotspots[0] = new ChunkOrderHotspot(mx, my, addition * 0);
hotspots[1] = new ChunkOrderHotspot(tx, my, addition * 1);
hotspots[2] = new ChunkOrderHotspot(bx, my, addition * 2);
hotspots[3] = new ChunkOrderHotspot(bx, by, addition * 3);
hotspots[4] = new ChunkOrderHotspot(tx, ty, addition * 4);
hotspots[5] = new ChunkOrderHotspot(bx, ty, addition * 5);
hotspots[6] = new ChunkOrderHotspot(tx, by, addition * 6);
hotspots[7] = new ChunkOrderHotspot(mx, ty, addition * 7);
hotspots[8] = new ChunkOrderHotspot(mx, by, addition * 8);
rcti rect;
ChunkOrder *chunkOrders = (ChunkOrder *)MEM_mallocN(sizeof(ChunkOrder) * this->m_chunks_len,
__func__);
for (index = 0; index < this->m_chunks_len; index++) {
determineChunkRect(&rect, index);
chunkOrders[index].number = index;
chunkOrders[index].x = rect.xmin - this->m_viewerBorder.xmin;
chunkOrders[index].y = rect.ymin - this->m_viewerBorder.ymin;
chunkOrders[index].update_distance(hotspots, 9);
}
std::sort(&chunkOrders[0], &chunkOrders[this->m_chunks_len]);
for (index = 0; index < this->m_chunks_len; index++) {
chunkOrder[index] = chunkOrders[index].number;
}
delete hotspots[0];
delete hotspots[1];
delete hotspots[2];
delete hotspots[3];
delete hotspots[4];
delete hotspots[5];
delete hotspots[6];
delete hotspots[7];
delete hotspots[8];
MEM_freeN(chunkOrders);
break;
}
case COM_TO_TOP_DOWN:
default:
break;
}
DebugInfo::execution_group_started(this); DebugInfo::execution_group_started(this);
DebugInfo::graphviz(graph); DebugInfo::graphviz(graph);
@@ -322,10 +324,10 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
for (index = startIndex; index < this->m_chunks_len && numberEvaluated < maxNumberEvaluated; for (index = startIndex; index < this->m_chunks_len && numberEvaluated < maxNumberEvaluated;
index++) { index++) {
chunk_index = chunk_order[index]; chunkNumber = chunkOrder[index];
int yChunk = chunk_index / this->m_x_chunks_len; int yChunk = chunkNumber / this->m_x_chunks_len;
int xChunk = chunk_index - (yChunk * this->m_x_chunks_len); int xChunk = chunkNumber - (yChunk * this->m_x_chunks_len);
switch (m_chunk_execution_states[chunk_index]) { switch (m_chunk_execution_states[chunkNumber]) {
case eChunkExecutionState::NOT_SCHEDULED: { case eChunkExecutionState::NOT_SCHEDULED: {
scheduleChunkWhenPossible(graph, xChunk, yChunk); scheduleChunkWhenPossible(graph, xChunk, yChunk);
finished = false; finished = false;
@@ -359,13 +361,17 @@ void ExecutionGroup::execute(ExecutionSystem *graph)
} }
DebugInfo::execution_group_finished(this); DebugInfo::execution_group_finished(this);
DebugInfo::graphviz(graph); DebugInfo::graphviz(graph);
MEM_freeN(chunkOrder);
} }
MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber) MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
{ {
rcti rect; rcti rect;
std::vector<MemoryProxy *> memoryproxies;
determineChunkRect(&rect, chunkNumber); determineChunkRect(&rect, chunkNumber);
this->determineDependingMemoryProxies(&memoryproxies);
MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN( MemoryBuffer **memoryBuffers = (MemoryBuffer **)MEM_callocN(
sizeof(MemoryBuffer *) * this->m_max_read_buffer_offset, __func__); sizeof(MemoryBuffer *) * this->m_max_read_buffer_offset, __func__);
rcti output; rcti output;
@@ -373,18 +379,18 @@ MemoryBuffer **ExecutionGroup::getInputBuffersOpenCL(int chunkNumber)
MemoryProxy *memoryProxy = readOperation->getMemoryProxy(); MemoryProxy *memoryProxy = readOperation->getMemoryProxy();
this->determineDependingAreaOfInterest(&rect, readOperation, &output); this->determineDependingAreaOfInterest(&rect, readOperation, &output);
MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer( MemoryBuffer *memoryBuffer = memoryProxy->getExecutor()->constructConsolidatedMemoryBuffer(
*memoryProxy, output); memoryProxy, &output);
memoryBuffers[readOperation->getOffset()] = memoryBuffer; memoryBuffers[readOperation->getOffset()] = memoryBuffer;
} }
return memoryBuffers; return memoryBuffers;
} }
MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, MemoryBuffer *ExecutionGroup::constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy,
rcti &rect) rcti *rect)
{ {
MemoryBuffer *imageBuffer = memoryProxy.getBuffer(); MemoryBuffer *imageBuffer = memoryProxy->getBuffer();
MemoryBuffer *result = new MemoryBuffer(&memoryProxy, rect, MemoryBufferState::Temporary); MemoryBuffer *result = new MemoryBuffer(memoryProxy, rect);
result->fill_from(*imageBuffer); result->copyContentFrom(imageBuffer);
return result; return result;
} }
@@ -454,14 +460,13 @@ void ExecutionGroup::determineChunkRect(rcti *rect, const unsigned int chunkNumb
determineChunkRect(rect, xChunk, yChunk); determineChunkRect(rect, xChunk, yChunk);
} }
MemoryBuffer *ExecutionGroup::allocateOutputBuffer(rcti &rect) MemoryBuffer *ExecutionGroup::allocateOutputBuffer(int /*chunkNumber*/, rcti *rect)
{ {
// we assume that this method is only called from complex execution groups. // we assume that this method is only called from complex execution groups.
NodeOperation *operation = this->getOutputOperation(); NodeOperation *operation = this->getOutputOperation();
if (operation->isWriteBufferOperation()) { if (operation->isWriteBufferOperation()) {
WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation; WriteBufferOperation *writeOperation = (WriteBufferOperation *)operation;
MemoryBuffer *buffer = new MemoryBuffer( MemoryBuffer *buffer = new MemoryBuffer(writeOperation->getMemoryProxy(), rect);
writeOperation->getMemoryProxy(), rect, MemoryBufferState::Temporary);
return buffer; return buffer;
} }
return nullptr; return nullptr;
@@ -511,44 +516,54 @@ bool ExecutionGroup::scheduleChunk(unsigned int chunkNumber)
return false; return false;
} }
bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, bool ExecutionGroup::scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk)
const int chunk_x,
const int chunk_y)
{ {
if (chunk_x < 0 || chunk_x >= (int)this->m_x_chunks_len) { if (xChunk < 0 || xChunk >= (int)this->m_x_chunks_len) {
return true; return true;
} }
if (chunk_y < 0 || chunk_y >= (int)this->m_y_chunks_len) { if (yChunk < 0 || yChunk >= (int)this->m_y_chunks_len) {
return true;
}
int chunkNumber = yChunk * this->m_x_chunks_len + xChunk;
// chunk is already executed
if (this->m_chunk_execution_states[chunkNumber] == eChunkExecutionState::EXECUTED) {
return true; return true;
} }
// Check if chunk is already executed or scheduled and not yet executed. // chunk is scheduled, but not executed
const int chunk_index = chunk_y * this->m_x_chunks_len + chunk_x; if (this->m_chunk_execution_states[chunkNumber] == eChunkExecutionState::SCHEDULED) {
if (this->m_chunk_execution_states[chunk_index] == eChunkExecutionState::EXECUTED) {
return true;
}
if (this->m_chunk_execution_states[chunk_index] == eChunkExecutionState::SCHEDULED) {
return false; return false;
} }
// chunk is nor executed nor scheduled.
std::vector<MemoryProxy *> memoryProxies;
this->determineDependingMemoryProxies(&memoryProxies);
rcti rect; rcti rect;
determineChunkRect(&rect, chunk_x, chunk_y); determineChunkRect(&rect, xChunk, yChunk);
bool can_be_executed = true; unsigned int index;
bool canBeExecuted = true;
rcti area; rcti area;
for (ReadBufferOperation *read_operation : m_read_operations) { for (index = 0; index < m_read_operations.size(); index++) {
ReadBufferOperation *readOperation = m_read_operations[index];
BLI_rcti_init(&area, 0, 0, 0, 0); BLI_rcti_init(&area, 0, 0, 0, 0);
MemoryProxy *memory_proxy = read_operation->getMemoryProxy(); MemoryProxy *memoryProxy = memoryProxies[index];
determineDependingAreaOfInterest(&rect, read_operation, &area); determineDependingAreaOfInterest(&rect, readOperation, &area);
ExecutionGroup *group = memory_proxy->getExecutor(); ExecutionGroup *group = memoryProxy->getExecutor();
if (!group->scheduleAreaWhenPossible(graph, &area)) { if (group != nullptr) {
can_be_executed = false; if (!group->scheduleAreaWhenPossible(graph, &area)) {
canBeExecuted = false;
}
}
else {
throw "ERROR";
} }
} }
if (can_be_executed) { if (canBeExecuted) {
scheduleChunk(chunk_index); scheduleChunk(chunkNumber);
} }
return false; return false;
@@ -561,6 +576,13 @@ void ExecutionGroup::determineDependingAreaOfInterest(rcti *input,
this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output); this->getOutputOperation()->determineDependingAreaOfInterest(input, readOperation, output);
} }
void ExecutionGroup::determineDependingMemoryProxies(std::vector<MemoryProxy *> *memoryProxies)
{
for (ReadBufferOperation *readOperation : m_read_operations) {
memoryProxies->push_back(readOperation->getMemoryProxy());
}
}
bool ExecutionGroup::isOpenCL() bool ExecutionGroup::isOpenCL()
{ {
return this->m_openCL; return this->m_openCL;

View File

@@ -22,7 +22,6 @@
# include "MEM_guardedalloc.h" # include "MEM_guardedalloc.h"
#endif #endif
#include "BLI_array.hh"
#include "BLI_rect.h" #include "BLI_rect.h"
#include "BLI_vector.hh" #include "BLI_vector.hh"
@@ -184,7 +183,7 @@ class ExecutionGroup {
* \brief check whether parameter operation can be added to the execution group * \brief check whether parameter operation can be added to the execution group
* \param operation: the operation to be added * \param operation: the operation to be added
*/ */
bool can_contain(NodeOperation &operation); bool canContainOperation(NodeOperation *operation);
/** /**
* \brief calculate the actual chunk size of this execution group. * \brief calculate the actual chunk size of this execution group.
@@ -218,7 +217,7 @@ class ExecutionGroup {
* true: package(s) are scheduled * true: package(s) are scheduled
* false: scheduling is deferred (depending workpackages are scheduled) * false: scheduling is deferred (depending workpackages are scheduled)
*/ */
bool scheduleChunkWhenPossible(ExecutionSystem *graph, const int chunk_x, const int chunk_y); bool scheduleChunkWhenPossible(ExecutionSystem *graph, int xChunk, int yChunk);
/** /**
* \brief try to schedule a specific area. * \brief try to schedule a specific area.
@@ -249,11 +248,6 @@ class ExecutionGroup {
ReadBufferOperation *readOperation, ReadBufferOperation *readOperation,
rcti *output); rcti *output);
/**
* Return the execution order of the user visible chunks.
*/
blender::Array<unsigned int> determine_chunk_execution_order() const;
public: public:
// constructors // constructors
ExecutionGroup(); ExecutionGroup();
@@ -339,7 +333,7 @@ class ExecutionGroup {
* \brief compose multiple chunks into a single chunk * \brief compose multiple chunks into a single chunk
* \return Memorybuffer *consolidated chunk * \return Memorybuffer *consolidated chunk
*/ */
MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy &memoryProxy, rcti &rect); MemoryBuffer *constructConsolidatedMemoryBuffer(MemoryProxy *memoryProxy, rcti *rect);
/** /**
* \brief initExecution is called just before the execution of the whole graph will be done. * \brief initExecution is called just before the execution of the whole graph will be done.
@@ -369,7 +363,7 @@ class ExecutionGroup {
* \param rect: the rect of that chunk * \param rect: the rect of that chunk
* \see determineChunkRect * \see determineChunkRect
*/ */
MemoryBuffer *allocateOutputBuffer(rcti &rect); MemoryBuffer *allocateOutputBuffer(int chunkNumber, rcti *rect);
/** /**
* \brief after a chunk is executed the needed resources can be freed or unlocked. * \brief after a chunk is executed the needed resources can be freed or unlocked.
@@ -402,6 +396,14 @@ class ExecutionGroup {
*/ */
void execute(ExecutionSystem *graph); void execute(ExecutionSystem *graph);
/**
* \brief this method determines the MemoryProxy's where this execution group depends on.
* \note After this method determineDependingAreaOfInterest can be called to determine
* \note the area of the MemoryProxy.creator that has to be executed.
* \param memoryProxies: result
*/
void determineDependingMemoryProxies(std::vector<MemoryProxy *> *memoryProxies);
/** /**
* \brief Determine the rect (minx, maxx, miny, maxy) of a chunk. * \brief Determine the rect (minx, maxx, miny, maxy) of a chunk.
* \note Only gives useful results after the determination of the chunksize * \note Only gives useful results after the determination of the chunksize

View File

@@ -177,10 +177,10 @@ void ExecutionSystem::execute()
WorkScheduler::start(this->m_context); WorkScheduler::start(this->m_context);
execute_groups(CompositorPriority::High); execute_groups(COM_PRIORITY_HIGH);
if (!this->getContext().isFastCalculation()) { if (!this->getContext().isFastCalculation()) {
execute_groups(CompositorPriority::Medium); execute_groups(COM_PRIORITY_MEDIUM);
execute_groups(CompositorPriority::Low); execute_groups(COM_PRIORITY_LOW);
} }
WorkScheduler::finish(); WorkScheduler::finish();

View File

@@ -64,8 +64,8 @@ class ExecutionGroup;
* \see NodeOperation base class for all operations in the system * \see NodeOperation base class for all operations in the system
* *
* \section EM_Step3 Step3: add additional conversions to the operation system * \section EM_Step3 Step3: add additional conversions to the operation system
* - Data type conversions: the system has 3 data types DataType::Value, DataType::Vector, * - Data type conversions: the system has 3 data types COM_DT_VALUE, COM_DT_VECTOR,
* DataType::Color. The user can connect a Value socket to a color socket. As values are ordered * COM_DT_COLOR. The user can connect a Value socket to a color socket. As values are ordered
* differently than colors a conversion happens. * differently than colors a conversion happens.
* *
* - Image size conversions: the system can automatically convert when resolutions do not match. * - Image size conversions: the system can automatically convert when resolutions do not match.

View File

@@ -23,53 +23,88 @@
static unsigned int determine_num_channels(DataType datatype) static unsigned int determine_num_channels(DataType datatype)
{ {
switch (datatype) { switch (datatype) {
case DataType::Value: case COM_DT_VALUE:
return COM_NUM_CHANNELS_VALUE; return COM_NUM_CHANNELS_VALUE;
case DataType::Vector: case COM_DT_VECTOR:
return COM_NUM_CHANNELS_VECTOR; return COM_NUM_CHANNELS_VECTOR;
case DataType::Color: case COM_DT_COLOR:
default: default:
return COM_NUM_CHANNELS_COLOR; return COM_NUM_CHANNELS_COLOR;
} }
} }
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state) unsigned int MemoryBuffer::determineBufferSize()
{ {
m_rect = rect; return getWidth() * getHeight();
}
int MemoryBuffer::getWidth() const
{
return this->m_width;
}
int MemoryBuffer::getHeight() const
{
return this->m_height;
}
MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect)
{
BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
this->m_width = BLI_rcti_size_x(&this->m_rect);
this->m_height = BLI_rcti_size_y(&this->m_rect);
this->m_memoryProxy = memoryProxy; this->m_memoryProxy = memoryProxy;
this->m_chunkNumber = chunkNumber;
this->m_num_channels = determine_num_channels(memoryProxy->getDataType()); this->m_num_channels = determine_num_channels(memoryProxy->getDataType());
this->m_buffer = (float *)MEM_mallocN_aligned( this->m_buffer = (float *)MEM_mallocN_aligned(
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer"); sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
this->m_state = state; this->m_state = COM_MB_ALLOCATED;
this->m_datatype = memoryProxy->getDataType(); this->m_datatype = memoryProxy->getDataType();
} }
MemoryBuffer::MemoryBuffer(DataType dataType, const rcti &rect) MemoryBuffer::MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect)
{ {
m_rect = rect; BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
this->m_width = BLI_rcti_size_x(&this->m_rect);
this->m_height = BLI_rcti_size_y(&this->m_rect);
this->m_memoryProxy = memoryProxy;
this->m_chunkNumber = -1;
this->m_num_channels = determine_num_channels(memoryProxy->getDataType());
this->m_buffer = (float *)MEM_mallocN_aligned(
sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
this->m_state = COM_MB_TEMPORARILY;
this->m_datatype = memoryProxy->getDataType();
}
MemoryBuffer::MemoryBuffer(DataType dataType, rcti *rect)
{
BLI_rcti_init(&this->m_rect, rect->xmin, rect->xmax, rect->ymin, rect->ymax);
this->m_width = BLI_rcti_size_x(&this->m_rect);
this->m_height = BLI_rcti_size_y(&this->m_rect);
this->m_height = this->m_rect.ymax - this->m_rect.ymin;
this->m_memoryProxy = nullptr; this->m_memoryProxy = nullptr;
this->m_chunkNumber = -1;
this->m_num_channels = determine_num_channels(dataType); this->m_num_channels = determine_num_channels(dataType);
this->m_buffer = (float *)MEM_mallocN_aligned( this->m_buffer = (float *)MEM_mallocN_aligned(
sizeof(float) * buffer_len() * this->m_num_channels, 16, "COM_MemoryBuffer"); sizeof(float) * determineBufferSize() * this->m_num_channels, 16, "COM_MemoryBuffer");
this->m_state = MemoryBufferState::Temporary; this->m_state = COM_MB_TEMPORARILY;
this->m_datatype = dataType; this->m_datatype = dataType;
} }
MemoryBuffer *MemoryBuffer::duplicate()
MemoryBuffer::MemoryBuffer(const MemoryBuffer &src)
: MemoryBuffer(src.m_memoryProxy, src.m_rect, MemoryBufferState::Temporary)
{ {
memcpy(m_buffer, src.m_buffer, buffer_len() * m_num_channels * sizeof(float)); MemoryBuffer *result = new MemoryBuffer(this->m_memoryProxy, &this->m_rect);
memcpy(result->m_buffer,
this->m_buffer,
this->determineBufferSize() * this->m_num_channels * sizeof(float));
return result;
} }
void MemoryBuffer::clear() void MemoryBuffer::clear()
{ {
memset(m_buffer, 0, buffer_len() * m_num_channels * sizeof(float)); memset(this->m_buffer, 0, this->determineBufferSize() * this->m_num_channels * sizeof(float));
} }
float MemoryBuffer::get_max_value() const float MemoryBuffer::getMaximumValue()
{ {
float result = this->m_buffer[0]; float result = this->m_buffer[0];
const unsigned int size = this->buffer_len(); const unsigned int size = this->determineBufferSize();
unsigned int i; unsigned int i;
const float *fp_src = this->m_buffer; const float *fp_src = this->m_buffer;
@@ -84,17 +119,19 @@ float MemoryBuffer::get_max_value() const
return result; return result;
} }
float MemoryBuffer::get_max_value(const rcti &rect) const float MemoryBuffer::getMaximumValue(rcti *rect)
{ {
rcti rect_clamp; rcti rect_clamp;
/* first clamp the rect by the bounds or we get un-initialized values */ /* first clamp the rect by the bounds or we get un-initialized values */
BLI_rcti_isect(&rect, &this->m_rect, &rect_clamp); BLI_rcti_isect(rect, &this->m_rect, &rect_clamp);
if (!BLI_rcti_is_empty(&rect_clamp)) { if (!BLI_rcti_is_empty(&rect_clamp)) {
MemoryBuffer temp_buffer(this->m_datatype, rect_clamp); MemoryBuffer *temp = new MemoryBuffer(this->m_datatype, &rect_clamp);
temp_buffer.fill_from(*this); temp->copyContentFrom(this);
return temp_buffer.get_max_value(); float result = temp->getMaximumValue();
delete temp;
return result;
} }
BLI_assert(0); BLI_assert(0);
@@ -109,23 +146,28 @@ MemoryBuffer::~MemoryBuffer()
} }
} }
void MemoryBuffer::fill_from(const MemoryBuffer &src) void MemoryBuffer::copyContentFrom(MemoryBuffer *otherBuffer)
{ {
if (!otherBuffer) {
BLI_assert(0);
return;
}
unsigned int otherY; unsigned int otherY;
unsigned int minX = MAX2(this->m_rect.xmin, src.m_rect.xmin); unsigned int minX = MAX2(this->m_rect.xmin, otherBuffer->m_rect.xmin);
unsigned int maxX = MIN2(this->m_rect.xmax, src.m_rect.xmax); unsigned int maxX = MIN2(this->m_rect.xmax, otherBuffer->m_rect.xmax);
unsigned int minY = MAX2(this->m_rect.ymin, src.m_rect.ymin); unsigned int minY = MAX2(this->m_rect.ymin, otherBuffer->m_rect.ymin);
unsigned int maxY = MIN2(this->m_rect.ymax, src.m_rect.ymax); unsigned int maxY = MIN2(this->m_rect.ymax, otherBuffer->m_rect.ymax);
int offset; int offset;
int otherOffset; int otherOffset;
for (otherY = minY; otherY < maxY; otherY++) { for (otherY = minY; otherY < maxY; otherY++) {
otherOffset = ((otherY - src.m_rect.ymin) * src.getWidth() + minX - src.m_rect.xmin) * otherOffset = ((otherY - otherBuffer->m_rect.ymin) * otherBuffer->m_width + minX -
otherBuffer->m_rect.xmin) *
this->m_num_channels; this->m_num_channels;
offset = ((otherY - this->m_rect.ymin) * getWidth() + minX - this->m_rect.xmin) * offset = ((otherY - this->m_rect.ymin) * this->m_width + minX - this->m_rect.xmin) *
this->m_num_channels; this->m_num_channels;
memcpy(&this->m_buffer[offset], memcpy(&this->m_buffer[offset],
&src.m_buffer[otherOffset], &otherBuffer->m_buffer[otherOffset],
(maxX - minX) * this->m_num_channels * sizeof(float)); (maxX - minX) * this->m_num_channels * sizeof(float));
} }
} }
@@ -134,7 +176,7 @@ void MemoryBuffer::writePixel(int x, int y, const float color[4])
{ {
if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin && if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
y < this->m_rect.ymax) { y < this->m_rect.ymax) {
const int offset = (getWidth() * (y - this->m_rect.ymin) + x - this->m_rect.xmin) * const int offset = (this->m_width * (y - this->m_rect.ymin) + x - this->m_rect.xmin) *
this->m_num_channels; this->m_num_channels;
memcpy(&this->m_buffer[offset], color, sizeof(float) * this->m_num_channels); memcpy(&this->m_buffer[offset], color, sizeof(float) * this->m_num_channels);
} }
@@ -144,7 +186,7 @@ void MemoryBuffer::addPixel(int x, int y, const float color[4])
{ {
if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin && if (x >= this->m_rect.xmin && x < this->m_rect.xmax && y >= this->m_rect.ymin &&
y < this->m_rect.ymax) { y < this->m_rect.ymax) {
const int offset = (getWidth() * (y - this->m_rect.ymin) + x - this->m_rect.xmin) * const int offset = (this->m_width * (y - this->m_rect.ymin) + x - this->m_rect.xmin) *
this->m_num_channels; this->m_num_channels;
float *dst = &this->m_buffer[offset]; float *dst = &this->m_buffer[offset];
const float *src = color; const float *src = color;
@@ -162,7 +204,7 @@ static void read_ewa_pixel_sampled(void *userdata, int x, int y, float result[4]
void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2]) void MemoryBuffer::readEWA(float *result, const float uv[2], const float derivatives[2][2])
{ {
BLI_assert(this->m_datatype == DataType::Color); BLI_assert(this->m_datatype == COM_DT_COLOR);
float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight(); float inv_width = 1.0f / (float)this->getWidth(), inv_height = 1.0f / (float)this->getHeight();
/* TODO(sergey): Render pipeline uses normalized coordinates and derivatives, /* TODO(sergey): Render pipeline uses normalized coordinates and derivatives,
* but compositor uses pixel space. For now let's just divide the values and * but compositor uses pixel space. For now let's just divide the values and

View File

@@ -31,19 +31,21 @@ class MemoryBuffer;
* \brief state of a memory buffer * \brief state of a memory buffer
* \ingroup Memory * \ingroup Memory
*/ */
enum class MemoryBufferState { typedef enum MemoryBufferState {
/** \brief memory has been allocated on creator device and CPU machine, /** \brief memory has been allocated on creator device and CPU machine,
* but kernel has not been executed */ * but kernel has not been executed */
Default = 0, COM_MB_ALLOCATED = 1,
/** \brief memory is available for use, content has been created */
COM_MB_AVAILABLE = 2,
/** \brief chunk is consolidated from other chunks. special state.*/ /** \brief chunk is consolidated from other chunks. special state.*/
Temporary = 6, COM_MB_TEMPORARILY = 6,
}; } MemoryBufferState;
enum class MemoryBufferExtend { typedef enum MemoryBufferExtend {
Clip, COM_MB_CLIP,
Extend, COM_MB_EXTEND,
Repeat, COM_MB_REPEAT,
}; } MemoryBufferExtend;
class MemoryProxy; class MemoryProxy;
@@ -58,7 +60,7 @@ class MemoryBuffer {
MemoryProxy *m_memoryProxy; MemoryProxy *m_memoryProxy;
/** /**
* \brief the type of buffer DataType::Value, DataType::Vector, DataType::Color * \brief the type of buffer COM_DT_VALUE, COM_DT_VECTOR, COM_DT_COLOR
*/ */
DataType m_datatype; DataType m_datatype;
@@ -67,6 +69,12 @@ class MemoryBuffer {
*/ */
rcti m_rect; rcti m_rect;
/**
* brief refers to the chunk-number within the execution-group where related to the MemoryProxy
* \see memoryProxy
*/
unsigned int m_chunkNumber;
/** /**
* \brief state of the buffer * \brief state of the buffer
*/ */
@@ -81,30 +89,41 @@ class MemoryBuffer {
* \brief the number of channels of a single value in the buffer. * \brief the number of channels of a single value in the buffer.
* For value buffers this is 1, vector 3 and color 4 * For value buffers this is 1, vector 3 and color 4
*/ */
uint8_t m_num_channels; unsigned int m_num_channels;
int m_width;
int m_height;
public: public:
/** /**
* \brief construct new temporarily MemoryBuffer for an area * \brief construct new MemoryBuffer for a chunk
*/ */
MemoryBuffer(MemoryProxy *memoryProxy, const rcti &rect, MemoryBufferState state); MemoryBuffer(MemoryProxy *memoryProxy, unsigned int chunkNumber, rcti *rect);
/** /**
* \brief construct new temporarily MemoryBuffer for an area * \brief construct new temporarily MemoryBuffer for an area
*/ */
MemoryBuffer(DataType datatype, const rcti &rect); MemoryBuffer(MemoryProxy *memoryProxy, rcti *rect);
/** /**
* Copy constructor * \brief construct new temporarily MemoryBuffer for an area
*/ */
MemoryBuffer(const MemoryBuffer &src); MemoryBuffer(DataType datatype, rcti *rect);
/** /**
* \brief destructor * \brief destructor
*/ */
~MemoryBuffer(); ~MemoryBuffer();
uint8_t get_num_channels() /**
* \brief read the ChunkNumber of this MemoryBuffer
*/
unsigned int getChunkNumber()
{
return this->m_chunkNumber;
}
unsigned int get_num_channels()
{ {
return this->m_num_channels; return this->m_num_channels;
} }
@@ -118,17 +137,25 @@ class MemoryBuffer {
return this->m_buffer; return this->m_buffer;
} }
/**
* \brief after execution the state will be set to available by calling this method
*/
void setCreatedState()
{
this->m_state = COM_MB_AVAILABLE;
}
inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y) inline void wrap_pixel(int &x, int &y, MemoryBufferExtend extend_x, MemoryBufferExtend extend_y)
{ {
const int w = getWidth(); int w = this->m_width;
const int h = getHeight(); int h = this->m_height;
x = x - m_rect.xmin; x = x - m_rect.xmin;
y = y - m_rect.ymin; y = y - m_rect.ymin;
switch (extend_x) { switch (extend_x) {
case MemoryBufferExtend::Clip: case COM_MB_CLIP:
break; break;
case MemoryBufferExtend::Extend: case COM_MB_EXTEND:
if (x < 0) { if (x < 0) {
x = 0; x = 0;
} }
@@ -136,15 +163,15 @@ class MemoryBuffer {
x = w; x = w;
} }
break; break;
case MemoryBufferExtend::Repeat: case COM_MB_REPEAT:
x = (x >= 0.0f ? (x % w) : (x % w) + w); x = (x >= 0.0f ? (x % w) : (x % w) + w);
break; break;
} }
switch (extend_y) { switch (extend_y) {
case MemoryBufferExtend::Clip: case COM_MB_CLIP:
break; break;
case MemoryBufferExtend::Extend: case COM_MB_EXTEND:
if (y < 0) { if (y < 0) {
y = 0; y = 0;
} }
@@ -152,7 +179,7 @@ class MemoryBuffer {
y = h; y = h;
} }
break; break;
case MemoryBufferExtend::Repeat: case COM_MB_REPEAT:
y = (y >= 0.0f ? (y % h) : (y % h) + h); y = (y >= 0.0f ? (y % h) : (y % h) + h);
break; break;
} }
@@ -163,15 +190,15 @@ class MemoryBuffer {
MemoryBufferExtend extend_x, MemoryBufferExtend extend_x,
MemoryBufferExtend extend_y) MemoryBufferExtend extend_y)
{ {
const float w = (float)getWidth(); float w = (float)this->m_width;
const float h = (float)getHeight(); float h = (float)this->m_height;
x = x - m_rect.xmin; x = x - m_rect.xmin;
y = y - m_rect.ymin; y = y - m_rect.ymin;
switch (extend_x) { switch (extend_x) {
case MemoryBufferExtend::Clip: case COM_MB_CLIP:
break; break;
case MemoryBufferExtend::Extend: case COM_MB_EXTEND:
if (x < 0) { if (x < 0) {
x = 0.0f; x = 0.0f;
} }
@@ -179,15 +206,15 @@ class MemoryBuffer {
x = w; x = w;
} }
break; break;
case MemoryBufferExtend::Repeat: case COM_MB_REPEAT:
x = fmodf(x, w); x = fmodf(x, w);
break; break;
} }
switch (extend_y) { switch (extend_y) {
case MemoryBufferExtend::Clip: case COM_MB_CLIP:
break; break;
case MemoryBufferExtend::Extend: case COM_MB_EXTEND:
if (y < 0) { if (y < 0) {
y = 0.0f; y = 0.0f;
} }
@@ -195,7 +222,7 @@ class MemoryBuffer {
y = h; y = h;
} }
break; break;
case MemoryBufferExtend::Repeat: case COM_MB_REPEAT:
y = fmodf(y, h); y = fmodf(y, h);
break; break;
} }
@@ -204,11 +231,11 @@ class MemoryBuffer {
inline void read(float *result, inline void read(float *result,
int x, int x,
int y, int y,
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, MemoryBufferExtend extend_x = COM_MB_CLIP,
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) MemoryBufferExtend extend_y = COM_MB_CLIP)
{ {
bool clip_x = (extend_x == MemoryBufferExtend::Clip && (x < m_rect.xmin || x >= m_rect.xmax)); bool clip_x = (extend_x == COM_MB_CLIP && (x < m_rect.xmin || x >= m_rect.xmax));
bool clip_y = (extend_y == MemoryBufferExtend::Clip && (y < m_rect.ymin || y >= m_rect.ymax)); bool clip_y = (extend_y == COM_MB_CLIP && (y < m_rect.ymin || y >= m_rect.ymax));
if (clip_x || clip_y) { if (clip_x || clip_y) {
/* clip result outside rect is zero */ /* clip result outside rect is zero */
memset(result, 0, this->m_num_channels * sizeof(float)); memset(result, 0, this->m_num_channels * sizeof(float));
@@ -217,7 +244,7 @@ class MemoryBuffer {
int u = x; int u = x;
int v = y; int v = y;
this->wrap_pixel(u, v, extend_x, extend_y); this->wrap_pixel(u, v, extend_x, extend_y);
const int offset = (getWidth() * y + x) * this->m_num_channels; const int offset = (this->m_width * y + x) * this->m_num_channels;
float *buffer = &this->m_buffer[offset]; float *buffer = &this->m_buffer[offset];
memcpy(result, buffer, sizeof(float) * this->m_num_channels); memcpy(result, buffer, sizeof(float) * this->m_num_channels);
} }
@@ -226,19 +253,19 @@ class MemoryBuffer {
inline void readNoCheck(float *result, inline void readNoCheck(float *result,
int x, int x,
int y, int y,
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, MemoryBufferExtend extend_x = COM_MB_CLIP,
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) MemoryBufferExtend extend_y = COM_MB_CLIP)
{ {
int u = x; int u = x;
int v = y; int v = y;
this->wrap_pixel(u, v, extend_x, extend_y); this->wrap_pixel(u, v, extend_x, extend_y);
const int offset = (getWidth() * v + u) * this->m_num_channels; const int offset = (this->m_width * v + u) * this->m_num_channels;
BLI_assert(offset >= 0); BLI_assert(offset >= 0);
BLI_assert(offset < this->buffer_len() * this->m_num_channels); BLI_assert(offset < this->determineBufferSize() * this->m_num_channels);
BLI_assert(!(extend_x == MemoryBufferExtend::Clip && (u < m_rect.xmin || u >= m_rect.xmax)) && BLI_assert(!(extend_x == COM_MB_CLIP && (u < m_rect.xmin || u >= m_rect.xmax)) &&
!(extend_y == MemoryBufferExtend::Clip && (v < m_rect.ymin || v >= m_rect.ymax))); !(extend_y == COM_MB_CLIP && (v < m_rect.ymin || v >= m_rect.ymax)));
float *buffer = &this->m_buffer[offset]; float *buffer = &this->m_buffer[offset];
memcpy(result, buffer, sizeof(float) * this->m_num_channels); memcpy(result, buffer, sizeof(float) * this->m_num_channels);
} }
@@ -248,26 +275,26 @@ class MemoryBuffer {
inline void readBilinear(float *result, inline void readBilinear(float *result,
float x, float x,
float y, float y,
MemoryBufferExtend extend_x = MemoryBufferExtend::Clip, MemoryBufferExtend extend_x = COM_MB_CLIP,
MemoryBufferExtend extend_y = MemoryBufferExtend::Clip) MemoryBufferExtend extend_y = COM_MB_CLIP)
{ {
float u = x; float u = x;
float v = y; float v = y;
this->wrap_pixel(u, v, extend_x, extend_y); this->wrap_pixel(u, v, extend_x, extend_y);
if ((extend_x != MemoryBufferExtend::Repeat && (u < 0.0f || u >= getWidth())) || if ((extend_x != COM_MB_REPEAT && (u < 0.0f || u >= this->m_width)) ||
(extend_y != MemoryBufferExtend::Repeat && (v < 0.0f || v >= getHeight()))) { (extend_y != COM_MB_REPEAT && (v < 0.0f || v >= this->m_height))) {
copy_vn_fl(result, this->m_num_channels, 0.0f); copy_vn_fl(result, this->m_num_channels, 0.0f);
return; return;
} }
BLI_bilinear_interpolation_wrap_fl(this->m_buffer, BLI_bilinear_interpolation_wrap_fl(this->m_buffer,
result, result,
getWidth(), this->m_width,
getHeight(), this->m_height,
this->m_num_channels, this->m_num_channels,
u, u,
v, v,
extend_x == MemoryBufferExtend::Repeat, extend_x == COM_MB_REPEAT,
extend_y == MemoryBufferExtend::Repeat); extend_y == COM_MB_REPEAT);
} }
void readEWA(float *result, const float uv[2], const float derivatives[2][2]); void readEWA(float *result, const float uv[2], const float derivatives[2][2]);
@@ -277,7 +304,7 @@ class MemoryBuffer {
*/ */
inline bool isTemporarily() const inline bool isTemporarily() const
{ {
return this->m_state == MemoryBufferState::Temporary; return this->m_state == COM_MB_TEMPORARILY;
} }
/** /**
@@ -287,45 +314,38 @@ class MemoryBuffer {
* \note take care when running this on a new buffer since it wont fill in * \note take care when running this on a new buffer since it wont fill in
* uninitialized values in areas where the buffers don't overlap. * uninitialized values in areas where the buffers don't overlap.
*/ */
void fill_from(const MemoryBuffer &src); void copyContentFrom(MemoryBuffer *otherBuffer);
/** /**
* \brief get the rect of this MemoryBuffer * \brief get the rect of this MemoryBuffer
*/ */
const rcti &get_rect() const rcti *getRect()
{ {
return this->m_rect; return &this->m_rect;
} }
/** /**
* \brief get the width of this MemoryBuffer * \brief get the width of this MemoryBuffer
*/ */
const int getWidth() const int getWidth() const;
{
return BLI_rcti_size_x(&m_rect);
}
/** /**
* \brief get the height of this MemoryBuffer * \brief get the height of this MemoryBuffer
*/ */
const int getHeight() const int getHeight() const;
{
return BLI_rcti_size_y(&m_rect);
}
/** /**
* \brief clear the buffer. Make all pixels black transparent. * \brief clear the buffer. Make all pixels black transparent.
*/ */
void clear(); void clear();
float get_max_value() const; MemoryBuffer *duplicate();
float get_max_value(const rcti &rect) const;
float getMaximumValue();
float getMaximumValue(rcti *rect);
private: private:
const int buffer_len() const unsigned int determineBufferSize();
{
return getWidth() * getHeight();
}
#ifdef WITH_CXX_GUARDEDALLOC #ifdef WITH_CXX_GUARDEDALLOC
MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer") MEM_CXX_CLASS_ALLOC_FUNCS("COM:MemoryBuffer")

View File

@@ -33,7 +33,7 @@ void MemoryProxy::allocate(unsigned int width, unsigned int height)
result.ymin = 0; result.ymin = 0;
result.ymax = height; result.ymax = height;
this->m_buffer = new MemoryBuffer(this, result, MemoryBufferState::Default); this->m_buffer = new MemoryBuffer(this, 1, &result);
} }
void MemoryProxy::free() void MemoryProxy::free()

View File

@@ -45,12 +45,12 @@ Node::Node(bNode *editorNode, bool create_sockets)
if (create_sockets) { if (create_sockets) {
bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first; bNodeSocket *input = (bNodeSocket *)editorNode->inputs.first;
while (input != nullptr) { while (input != nullptr) {
DataType dt = DataType::Value; DataType dt = COM_DT_VALUE;
if (input->type == SOCK_RGBA) { if (input->type == SOCK_RGBA) {
dt = DataType::Color; dt = COM_DT_COLOR;
} }
if (input->type == SOCK_VECTOR) { if (input->type == SOCK_VECTOR) {
dt = DataType::Vector; dt = COM_DT_VECTOR;
} }
this->addInputSocket(dt, input); this->addInputSocket(dt, input);
@@ -58,12 +58,12 @@ Node::Node(bNode *editorNode, bool create_sockets)
} }
bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first; bNodeSocket *output = (bNodeSocket *)editorNode->outputs.first;
while (output != nullptr) { while (output != nullptr) {
DataType dt = DataType::Value; DataType dt = COM_DT_VALUE;
if (output->type == SOCK_RGBA) { if (output->type == SOCK_RGBA) {
dt = DataType::Color; dt = COM_DT_COLOR;
} }
if (output->type == SOCK_VECTOR) { if (output->type == SOCK_VECTOR) {
dt = DataType::Vector; dt = COM_DT_VECTOR;
} }
this->addOutputSocket(dt, output); this->addOutputSocket(dt, output);

View File

@@ -326,7 +326,7 @@ class NodeOperation : public SocketReader {
*/ */
virtual CompositorPriority getRenderPriority() const virtual CompositorPriority getRenderPriority() const
{ {
return CompositorPriority::Low; return COM_PRIORITY_LOW;
} }
/** /**

View File

@@ -297,7 +297,7 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
const NodeInput *node_input) const NodeInput *node_input)
{ {
switch (input->getDataType()) { switch (input->getDataType()) {
case DataType::Value: { case COM_DT_VALUE: {
float value; float value;
if (node_input && node_input->getbNodeSocket()) { if (node_input && node_input->getbNodeSocket()) {
value = node_input->getEditorValueFloat(); value = node_input->getEditorValueFloat();
@@ -312,7 +312,7 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
addLink(op->getOutputSocket(), input); addLink(op->getOutputSocket(), input);
break; break;
} }
case DataType::Color: { case COM_DT_COLOR: {
float value[4]; float value[4];
if (node_input && node_input->getbNodeSocket()) { if (node_input && node_input->getbNodeSocket()) {
node_input->getEditorValueColor(value); node_input->getEditorValueColor(value);
@@ -327,7 +327,7 @@ void NodeOperationBuilder::add_input_constant_value(NodeOperationInput *input,
addLink(op->getOutputSocket(), input); addLink(op->getOutputSocket(), input);
break; break;
} }
case DataType::Vector: { case COM_DT_VECTOR: {
float value[3]; float value[3];
if (node_input && node_input->getbNodeSocket()) { if (node_input && node_input->getbNodeSocket()) {
node_input->getEditorValueVector(value); node_input->getEditorValueVector(value);

View File

@@ -67,7 +67,7 @@ void OpenCLDevice::execute(WorkPackage *work)
executionGroup->determineChunkRect(&rect, chunkNumber); executionGroup->determineChunkRect(&rect, chunkNumber);
MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber); MemoryBuffer **inputBuffers = executionGroup->getInputBuffersOpenCL(chunkNumber);
MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(rect); MemoryBuffer *outputBuffer = executionGroup->allocateOutputBuffer(chunkNumber, &rect);
executionGroup->getOutputOperation()->executeOpenCLRegion( executionGroup->getOutputOperation()->executeOpenCLRegion(
this, &rect, chunkNumber, inputBuffers, outputBuffer); this, &rect, chunkNumber, inputBuffers, outputBuffer);
@@ -93,21 +93,19 @@ cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBuffer) const cl_image_format *OpenCLDevice::determineImageFormat(MemoryBuffer *memoryBuffer)
{ {
switch (memoryBuffer->get_num_channels()) { const cl_image_format *imageFormat;
case 1: int num_channels = memoryBuffer->get_num_channels();
return &IMAGE_FORMAT_VALUE; if (num_channels == 1) {
break; imageFormat = &IMAGE_FORMAT_VALUE;
case 3: }
return &IMAGE_FORMAT_VECTOR; else if (num_channels == 3) {
break; imageFormat = &IMAGE_FORMAT_VECTOR;
case 4: }
return &IMAGE_FORMAT_COLOR; else {
break; imageFormat = &IMAGE_FORMAT_COLOR;
default:
BLI_assert(!"Unsupported num_channels.");
} }
return &IMAGE_FORMAT_COLOR; return imageFormat;
} }
cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel, cl_mem OpenCLDevice::COM_clAttachMemoryBufferToKernelParameter(cl_kernel kernel,
@@ -154,8 +152,8 @@ void OpenCLDevice::COM_clAttachMemoryBufferOffsetToKernelParameter(cl_kernel ker
{ {
if (offsetIndex != -1) { if (offsetIndex != -1) {
cl_int error; cl_int error;
const rcti &rect = memoryBuffer->get_rect(); rcti *rect = memoryBuffer->getRect();
cl_int2 offset = {{rect.xmin, rect.ymin}}; cl_int2 offset = {{rect->xmin, rect->ymin}};
error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset); error = clSetKernelArg(kernel, offsetIndex, sizeof(cl_int2), &offset);
if (error != CL_SUCCESS) { if (error != CL_SUCCESS) {

View File

@@ -125,7 +125,7 @@ void CryptomatteNode::input_operations_from_render_source(
const std::string combined_name = combined_layer_pass_name(render_layer, render_pass); const std::string combined_name = combined_layer_pass_name(render_layer, render_pass);
if (blender::StringRef(combined_name).startswith(prefix)) { if (blender::StringRef(combined_name).startswith(prefix)) {
RenderLayersProg *op = new RenderLayersProg( RenderLayersProg *op = new RenderLayersProg(
render_pass->name, DataType::Color, render_pass->channels); render_pass->name, COM_DT_COLOR, render_pass->channels);
op->setScene(scene); op->setScene(scene);
op->setLayerId(cryptomatte_layer_id); op->setLayerId(cryptomatte_layer_id);
op->setRenderData(context.getRenderData()); op->setRenderData(context.getRenderData());

View File

@@ -110,7 +110,7 @@ void DefocusNode::convertToOperations(NodeConverter &converter,
VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation(); VariableSizeBokehBlurOperation *operation = new VariableSizeBokehBlurOperation();
if (data->preview) { if (data->preview) {
operation->setQuality(CompositorQuality::Low); operation->setQuality(COM_QUALITY_LOW);
} }
else { else {
operation->setQuality(context.getQuality()); operation->setQuality(context.getQuality());

View File

@@ -30,7 +30,7 @@ void DisplaceNode::convertToOperations(NodeConverter &converter,
const CompositorContext &context) const const CompositorContext &context) const
{ {
NodeOperation *operation; NodeOperation *operation;
if (context.getQuality() == CompositorQuality::Low) { if (context.getQuality() == COM_QUALITY_LOW) {
operation = new DisplaceSimpleOperation(); operation = new DisplaceSimpleOperation();
} }
else { else {

View File

@@ -46,13 +46,13 @@ NodeOperation *ImageNode::doMultilayerCheck(NodeConverter &converter,
NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex); NodeOutput *outputSocket = this->getOutputSocket(outputsocketIndex);
MultilayerBaseOperation *operation = nullptr; MultilayerBaseOperation *operation = nullptr;
switch (datatype) { switch (datatype) {
case DataType::Value: case COM_DT_VALUE:
operation = new MultilayerValueOperation(render_layer, render_pass, view); operation = new MultilayerValueOperation(render_layer, render_pass, view);
break; break;
case DataType::Vector: case COM_DT_VECTOR:
operation = new MultilayerVectorOperation(render_layer, render_pass, view); operation = new MultilayerVectorOperation(render_layer, render_pass, view);
break; break;
case DataType::Color: case COM_DT_COLOR:
operation = new MultilayerColorOperation(render_layer, render_pass, view); operation = new MultilayerColorOperation(render_layer, render_pass, view);
break; break;
default: default:
@@ -137,7 +137,7 @@ void ImageNode::convertToOperations(NodeConverter &converter,
framenumber, framenumber,
index, index,
view, view,
DataType::Value); COM_DT_VALUE);
break; break;
/* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */ /* using image operations for both 3 and 4 channels (RGB and RGBA respectively) */
/* XXX any way to detect actual vector images? */ /* XXX any way to detect actual vector images? */
@@ -150,7 +150,7 @@ void ImageNode::convertToOperations(NodeConverter &converter,
framenumber, framenumber,
index, index,
view, view,
DataType::Vector); COM_DT_VECTOR);
break; break;
case 4: case 4:
operation = doMultilayerCheck(converter, operation = doMultilayerCheck(converter,
@@ -161,7 +161,7 @@ void ImageNode::convertToOperations(NodeConverter &converter,
framenumber, framenumber,
index, index,
view, view,
DataType::Color); COM_DT_COLOR);
break; break;
default: default:
/* dummy operation is added below */ /* dummy operation is added below */
@@ -263,13 +263,13 @@ void ImageNode::convertToOperations(NodeConverter &converter,
NodeOutput *output = this->getOutputSocket(i); NodeOutput *output = this->getOutputSocket(i);
NodeOperation *operation = nullptr; NodeOperation *operation = nullptr;
switch (output->getDataType()) { switch (output->getDataType()) {
case DataType::Value: { case COM_DT_VALUE: {
SetValueOperation *valueoperation = new SetValueOperation(); SetValueOperation *valueoperation = new SetValueOperation();
valueoperation->setValue(0.0f); valueoperation->setValue(0.0f);
operation = valueoperation; operation = valueoperation;
break; break;
} }
case DataType::Vector: { case COM_DT_VECTOR: {
SetVectorOperation *vectoroperation = new SetVectorOperation(); SetVectorOperation *vectoroperation = new SetVectorOperation();
vectoroperation->setX(0.0f); vectoroperation->setX(0.0f);
vectoroperation->setY(0.0f); vectoroperation->setY(0.0f);
@@ -277,7 +277,7 @@ void ImageNode::convertToOperations(NodeConverter &converter,
operation = vectoroperation; operation = vectoroperation;
break; break;
} }
case DataType::Color: { case COM_DT_COLOR: {
SetColorOperation *coloroperation = new SetColorOperation(); SetColorOperation *coloroperation = new SetColorOperation();
coloroperation->setChannel1(0.0f); coloroperation->setChannel1(0.0f);
coloroperation->setChannel2(0.0f); coloroperation->setChannel2(0.0f);

View File

@@ -86,28 +86,28 @@ void RenderLayersNode::testRenderLink(NodeConverter &converter,
bool is_preview; bool is_preview;
if (STREQ(rpass->name, RE_PASSNAME_COMBINED) && if (STREQ(rpass->name, RE_PASSNAME_COMBINED) &&
STREQ(output->getbNodeSocket()->name, "Alpha")) { STREQ(output->getbNodeSocket()->name, "Alpha")) {
operation = new RenderLayersAlphaProg(rpass->name, DataType::Value, rpass->channels); operation = new RenderLayersAlphaProg(rpass->name, COM_DT_VALUE, rpass->channels);
is_preview = false; is_preview = false;
} }
else if (STREQ(rpass->name, RE_PASSNAME_Z)) { else if (STREQ(rpass->name, RE_PASSNAME_Z)) {
operation = new RenderLayersDepthProg(rpass->name, DataType::Value, rpass->channels); operation = new RenderLayersDepthProg(rpass->name, COM_DT_VALUE, rpass->channels);
is_preview = false; is_preview = false;
} }
else { else {
DataType type; DataType type;
switch (rpass->channels) { switch (rpass->channels) {
case 4: case 4:
type = DataType::Color; type = COM_DT_COLOR;
break; break;
case 3: case 3:
type = DataType::Vector; type = COM_DT_VECTOR;
break; break;
case 1: case 1:
type = DataType::Value; type = COM_DT_VALUE;
break; break;
default: default:
BLI_assert(!"Unexpected number of channels for pass"); BLI_assert(!"Unexpected number of channels for pass");
type = DataType::Value; type = COM_DT_VALUE;
break; break;
} }
operation = new RenderLayersProg(rpass->name, type, rpass->channels); operation = new RenderLayersProg(rpass->name, type, rpass->channels);
@@ -121,21 +121,21 @@ void RenderLayersNode::missingSocketLink(NodeConverter &converter, NodeOutput *o
{ {
NodeOperation *operation; NodeOperation *operation;
switch (output->getDataType()) { switch (output->getDataType()) {
case DataType::Color: { case COM_DT_COLOR: {
const float color[4] = {0.0f, 0.0f, 0.0f, 0.0f}; const float color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
SetColorOperation *color_operation = new SetColorOperation(); SetColorOperation *color_operation = new SetColorOperation();
color_operation->setChannels(color); color_operation->setChannels(color);
operation = color_operation; operation = color_operation;
break; break;
} }
case DataType::Vector: { case COM_DT_VECTOR: {
const float vector[3] = {0.0f, 0.0f, 0.0f}; const float vector[3] = {0.0f, 0.0f, 0.0f};
SetVectorOperation *vector_operation = new SetVectorOperation(); SetVectorOperation *vector_operation = new SetVectorOperation();
vector_operation->setVector(vector); vector_operation->setVector(vector);
operation = vector_operation; operation = vector_operation;
break; break;
} }
case DataType::Value: { case COM_DT_VALUE: {
SetValueOperation *value_operation = new SetValueOperation(); SetValueOperation *value_operation = new SetValueOperation();
value_operation->setValue(0.0f); value_operation->setValue(0.0f);
operation = value_operation; operation = value_operation;

View File

@@ -33,21 +33,21 @@ SocketProxyNode::SocketProxyNode(bNode *editorNode,
{ {
DataType dt; DataType dt;
dt = DataType::Value; dt = COM_DT_VALUE;
if (editorInput->type == SOCK_RGBA) { if (editorInput->type == SOCK_RGBA) {
dt = DataType::Color; dt = COM_DT_COLOR;
} }
if (editorInput->type == SOCK_VECTOR) { if (editorInput->type == SOCK_VECTOR) {
dt = DataType::Vector; dt = COM_DT_VECTOR;
} }
this->addInputSocket(dt, editorInput); this->addInputSocket(dt, editorInput);
dt = DataType::Value; dt = COM_DT_VALUE;
if (editorOutput->type == SOCK_RGBA) { if (editorOutput->type == SOCK_RGBA) {
dt = DataType::Color; dt = COM_DT_COLOR;
} }
if (editorOutput->type == SOCK_VECTOR) { if (editorOutput->type == SOCK_VECTOR) {
dt = DataType::Vector; dt = COM_DT_VECTOR;
} }
this->addOutputSocket(dt, editorOutput); this->addOutputSocket(dt, editorOutput);
} }
@@ -66,21 +66,21 @@ SocketBufferNode::SocketBufferNode(bNode *editorNode,
{ {
DataType dt; DataType dt;
dt = DataType::Value; dt = COM_DT_VALUE;
if (editorInput->type == SOCK_RGBA) { if (editorInput->type == SOCK_RGBA) {
dt = DataType::Color; dt = COM_DT_COLOR;
} }
if (editorInput->type == SOCK_VECTOR) { if (editorInput->type == SOCK_VECTOR) {
dt = DataType::Vector; dt = COM_DT_VECTOR;
} }
this->addInputSocket(dt, editorInput); this->addInputSocket(dt, editorInput);
dt = DataType::Value; dt = COM_DT_VALUE;
if (editorOutput->type == SOCK_RGBA) { if (editorOutput->type == SOCK_RGBA) {
dt = DataType::Color; dt = COM_DT_COLOR;
} }
if (editorOutput->type == SOCK_VECTOR) { if (editorOutput->type == SOCK_VECTOR) {
dt = DataType::Vector; dt = COM_DT_VECTOR;
} }
this->addOutputSocket(dt, editorOutput); this->addOutputSocket(dt, editorOutput);
} }

View File

@@ -60,7 +60,7 @@ void SplitViewerNode::convertToOperations(NodeConverter &converter,
/* defaults - the viewer node has these options but not exposed for split view /* defaults - the viewer node has these options but not exposed for split view
* we could use the split to define an area of interest on one axis at least */ * we could use the split to define an area of interest on one axis at least */
viewerOperation->setChunkOrder(ChunkOrdering::Default); viewerOperation->setChunkOrder(COM_ORDER_OF_CHUNKS_DEFAULT);
viewerOperation->setCenterX(0.5f); viewerOperation->setCenterX(0.5f);
viewerOperation->setCenterY(0.5f); viewerOperation->setCenterY(0.5f);

View File

@@ -55,8 +55,8 @@ void TranslateNode::convertToOperations(NodeConverter &converter,
converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0)); converter.mapOutputSocket(outputSocket, operation->getOutputSocket(0));
if (data->wrap_axis) { if (data->wrap_axis) {
WriteBufferOperation *writeOperation = new WriteBufferOperation(DataType::Color); WriteBufferOperation *writeOperation = new WriteBufferOperation(COM_DT_COLOR);
WrapOperation *wrapOperation = new WrapOperation(DataType::Color); WrapOperation *wrapOperation = new WrapOperation(COM_DT_COLOR);
wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy()); wrapOperation->setMemoryProxy(writeOperation->getMemoryProxy());
wrapOperation->setWrapping(data->wrap_axis); wrapOperation->setWrapping(data->wrap_axis);

View File

@@ -47,7 +47,7 @@ void ViewerNode::convertToOperations(NodeConverter &converter,
viewerOperation->setbNodeTree(context.getbNodeTree()); viewerOperation->setbNodeTree(context.getbNodeTree());
viewerOperation->setImage(image); viewerOperation->setImage(image);
viewerOperation->setImageUser(imageUser); viewerOperation->setImageUser(imageUser);
viewerOperation->setChunkOrder((ChunkOrdering)editorNode->custom1); viewerOperation->setChunkOrder((OrderOfChunks)editorNode->custom1);
viewerOperation->setCenterX(editorNode->custom3); viewerOperation->setCenterX(editorNode->custom3);
viewerOperation->setCenterY(editorNode->custom4); viewerOperation->setCenterY(editorNode->custom4);
/* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */ /* alpha socket gives either 1 or a custom alpha value if "use alpha" is enabled */

View File

@@ -114,8 +114,8 @@ static int extrapolate9(float *E0,
AntiAliasOperation::AntiAliasOperation() AntiAliasOperation::AntiAliasOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_valueReader = nullptr; this->m_valueReader = nullptr;
this->setComplex(true); this->setComplex(true);
} }

View File

@@ -23,9 +23,9 @@
BilateralBlurOperation::BilateralBlurOperation() BilateralBlurOperation::BilateralBlurOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true); this->setComplex(true);
this->m_inputColorProgram = nullptr; this->m_inputColorProgram = nullptr;

View File

@@ -24,9 +24,9 @@
BlurBaseOperation::BlurBaseOperation(DataType data_type) BlurBaseOperation::BlurBaseOperation(DataType data_type)
{ {
/* data_type is almost always DataType::Color except for alpha-blur */ /* data_type is almost always COM_DT_COLOR except for alpha-blur */
this->addInputSocket(data_type); this->addInputSocket(data_type);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(data_type); this->addOutputSocket(data_type);
this->setComplex(true); this->setComplex(true);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;

View File

@@ -24,11 +24,11 @@
BokehBlurOperation::BokehBlurOperation() BokehBlurOperation::BokehBlurOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Color, COM_SC_NO_RESIZE); this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true); this->setComplex(true);
this->setOpenCL(true); this->setOpenCL(true);
@@ -80,11 +80,10 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
if (tempBoundingBox[0] > 0.0f) { if (tempBoundingBox[0] > 0.0f) {
float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float multiplier_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
const rcti &input_rect = inputBuffer->get_rect();
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth(); int bufferwidth = inputBuffer->getWidth();
int bufferstartx = input_rect.xmin; int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = input_rect.ymin; int bufferstarty = inputBuffer->getRect()->ymin;
const float max_dim = MAX2(this->getWidth(), this->getHeight()); const float max_dim = MAX2(this->getWidth(), this->getHeight());
int pixelSize = this->m_size * max_dim / 100.0f; int pixelSize = this->m_size * max_dim / 100.0f;
zero_v4(color_accum); zero_v4(color_accum);
@@ -100,10 +99,10 @@ void BokehBlurOperation::executePixel(float output[4], int x, int y, void *data)
int maxy = y + pixelSize; int maxy = y + pixelSize;
int minx = x - pixelSize; int minx = x - pixelSize;
int maxx = x + pixelSize; int maxx = x + pixelSize;
miny = MAX2(miny, input_rect.ymin); miny = MAX2(miny, inputBuffer->getRect()->ymin);
minx = MAX2(minx, input_rect.xmin); minx = MAX2(minx, inputBuffer->getRect()->xmin);
maxy = MIN2(maxy, input_rect.ymax); maxy = MIN2(maxy, inputBuffer->getRect()->ymax);
maxx = MIN2(maxx, input_rect.xmax); maxx = MIN2(maxx, inputBuffer->getRect()->xmax);
int step = getStep(); int step = getStep();
int offsetadd = getOffsetAdd() * COM_NUM_CHANNELS_COLOR; int offsetadd = getOffsetAdd() * COM_NUM_CHANNELS_COLOR;

View File

@@ -21,7 +21,7 @@
BokehImageOperation::BokehImageOperation() BokehImageOperation::BokehImageOperation()
{ {
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_deleteData = false; this->m_deleteData = false;
} }
void BokehImageOperation::initExecution() void BokehImageOperation::initExecution()

View File

@@ -22,9 +22,9 @@
BoxMaskOperation::BoxMaskOperation() BoxMaskOperation::BoxMaskOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_inputMask = nullptr; this->m_inputMask = nullptr;
this->m_inputValue = nullptr; this->m_inputValue = nullptr;
this->m_cosine = 0.0f; this->m_cosine = 0.0f;

View File

@@ -20,10 +20,10 @@
BrightnessOperation::BrightnessOperation() BrightnessOperation::BrightnessOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
this->m_use_premultiply = false; this->m_use_premultiply = false;
} }

View File

@@ -24,8 +24,8 @@
CalculateMeanOperation::CalculateMeanOperation() CalculateMeanOperation::CalculateMeanOperation()
{ {
this->addInputSocket(DataType::Color, COM_SC_NO_RESIZE); this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_imageReader = nullptr; this->m_imageReader = nullptr;
this->m_iscalculated = false; this->m_iscalculated = false;
this->m_setting = 1; this->m_setting = 1;

View File

@@ -20,11 +20,11 @@
ChangeHSVOperation::ChangeHSVOperation() ChangeHSVOperation::ChangeHSVOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
} }

View File

@@ -21,8 +21,8 @@
ChannelMatteOperation::ChannelMatteOperation() ChannelMatteOperation::ChannelMatteOperation()
{ {
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addOutputSocket(DataType::Value); addOutputSocket(COM_DT_VALUE);
this->m_inputImageProgram = nullptr; this->m_inputImageProgram = nullptr;
} }

View File

@@ -21,9 +21,9 @@
ChromaMatteOperation::ChromaMatteOperation() ChromaMatteOperation::ChromaMatteOperation()
{ {
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addOutputSocket(DataType::Value); addOutputSocket(COM_DT_VALUE);
this->m_inputImageProgram = nullptr; this->m_inputImageProgram = nullptr;
this->m_inputKeyProgram = nullptr; this->m_inputKeyProgram = nullptr;

View File

@@ -33,9 +33,9 @@ inline float colorbalance_cdl(float in, float offset, float power, float slope)
ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation() ColorBalanceASCCDLOperation::ColorBalanceASCCDLOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputValueOperation = nullptr; this->m_inputValueOperation = nullptr;
this->m_inputColorOperation = nullptr; this->m_inputColorOperation = nullptr;
this->setResolutionInputSocketIndex(1); this->setResolutionInputSocketIndex(1);

View File

@@ -38,9 +38,9 @@ inline float colorbalance_lgg(float in, float lift_lgg, float gamma_inv, float g
ColorBalanceLGGOperation::ColorBalanceLGGOperation() ColorBalanceLGGOperation::ColorBalanceLGGOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputValueOperation = nullptr; this->m_inputValueOperation = nullptr;
this->m_inputColorOperation = nullptr; this->m_inputColorOperation = nullptr;
this->setResolutionInputSocketIndex(1); this->setResolutionInputSocketIndex(1);

View File

@@ -23,9 +23,9 @@
ColorCorrectionOperation::ColorCorrectionOperation() ColorCorrectionOperation::ColorCorrectionOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputImage = nullptr; this->m_inputImage = nullptr;
this->m_inputMask = nullptr; this->m_inputMask = nullptr;
this->m_redChannelEnabled = true; this->m_redChannelEnabled = true;

View File

@@ -24,11 +24,11 @@
ColorCurveOperation::ColorCurveOperation() ColorCurveOperation::ColorCurveOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputFacProgram = nullptr; this->m_inputFacProgram = nullptr;
this->m_inputImageProgram = nullptr; this->m_inputImageProgram = nullptr;
@@ -100,9 +100,9 @@ void ColorCurveOperation::deinitExecution()
ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation() ConstantLevelColorCurveOperation::ConstantLevelColorCurveOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputFacProgram = nullptr; this->m_inputFacProgram = nullptr;
this->m_inputImageProgram = nullptr; this->m_inputImageProgram = nullptr;

View File

@@ -20,9 +20,9 @@
ExposureOperation::ExposureOperation() ExposureOperation::ExposureOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
} }

View File

@@ -21,9 +21,9 @@
ColorMatteOperation::ColorMatteOperation() ColorMatteOperation::ColorMatteOperation()
{ {
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addOutputSocket(DataType::Value); addOutputSocket(COM_DT_VALUE);
this->m_inputImageProgram = nullptr; this->m_inputImageProgram = nullptr;
this->m_inputKeyProgram = nullptr; this->m_inputKeyProgram = nullptr;

View File

@@ -22,8 +22,8 @@
ColorRampOperation::ColorRampOperation() ColorRampOperation::ColorRampOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
this->m_colorBand = nullptr; this->m_colorBand = nullptr;

View File

@@ -22,9 +22,9 @@
ColorSpillOperation::ColorSpillOperation() ColorSpillOperation::ColorSpillOperation()
{ {
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addInputSocket(DataType::Value); addInputSocket(COM_DT_VALUE);
addOutputSocket(DataType::Color); addOutputSocket(COM_DT_COLOR);
this->m_inputImageReader = nullptr; this->m_inputImageReader = nullptr;
this->m_inputFacReader = nullptr; this->m_inputFacReader = nullptr;

View File

@@ -33,9 +33,9 @@
CompositorOperation::CompositorOperation() CompositorOperation::CompositorOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->setRenderData(nullptr); this->setRenderData(nullptr);
this->m_outputBuffer = nullptr; this->m_outputBuffer = nullptr;

View File

@@ -111,7 +111,7 @@ class CompositorOperation : public NodeOperation {
void deinitExecution(); void deinitExecution();
CompositorPriority getRenderPriority() const CompositorPriority getRenderPriority() const
{ {
return CompositorPriority::Medium; return COM_PRIORITY_MEDIUM;
} }
void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]); void determineResolution(unsigned int resolution[2], unsigned int preferredResolution[2]);
void setUseAlphaInput(bool value) void setUseAlphaInput(bool value)

View File

@@ -22,8 +22,8 @@
ConvertColorProfileOperation::ConvertColorProfileOperation() ConvertColorProfileOperation::ConvertColorProfileOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
this->m_predivided = false; this->m_predivided = false;
} }

View File

@@ -23,8 +23,8 @@
ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation() ConvertDepthToRadiusOperation::ConvertDepthToRadiusOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
this->m_fStop = 128.0f; this->m_fStop = 128.0f;
this->m_cameraObject = nullptr; this->m_cameraObject = nullptr;

View File

@@ -39,8 +39,8 @@ void ConvertBaseOperation::deinitExecution()
ConvertValueToColorOperation::ConvertValueToColorOperation() : ConvertBaseOperation() ConvertValueToColorOperation::ConvertValueToColorOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertValueToColorOperation::executePixelSampled(float output[4], void ConvertValueToColorOperation::executePixelSampled(float output[4],
@@ -58,8 +58,8 @@ void ConvertValueToColorOperation::executePixelSampled(float output[4],
ConvertColorToValueOperation::ConvertColorToValueOperation() : ConvertBaseOperation() ConvertColorToValueOperation::ConvertColorToValueOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
} }
void ConvertColorToValueOperation::executePixelSampled(float output[4], void ConvertColorToValueOperation::executePixelSampled(float output[4],
@@ -76,8 +76,8 @@ void ConvertColorToValueOperation::executePixelSampled(float output[4],
ConvertColorToBWOperation::ConvertColorToBWOperation() : ConvertBaseOperation() ConvertColorToBWOperation::ConvertColorToBWOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
} }
void ConvertColorToBWOperation::executePixelSampled(float output[4], void ConvertColorToBWOperation::executePixelSampled(float output[4],
@@ -94,8 +94,8 @@ void ConvertColorToBWOperation::executePixelSampled(float output[4],
ConvertColorToVectorOperation::ConvertColorToVectorOperation() : ConvertBaseOperation() ConvertColorToVectorOperation::ConvertColorToVectorOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Vector); this->addOutputSocket(COM_DT_VECTOR);
} }
void ConvertColorToVectorOperation::executePixelSampled(float output[4], void ConvertColorToVectorOperation::executePixelSampled(float output[4],
@@ -112,8 +112,8 @@ void ConvertColorToVectorOperation::executePixelSampled(float output[4],
ConvertValueToVectorOperation::ConvertValueToVectorOperation() : ConvertBaseOperation() ConvertValueToVectorOperation::ConvertValueToVectorOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Vector); this->addOutputSocket(COM_DT_VECTOR);
} }
void ConvertValueToVectorOperation::executePixelSampled(float output[4], void ConvertValueToVectorOperation::executePixelSampled(float output[4],
@@ -130,8 +130,8 @@ void ConvertValueToVectorOperation::executePixelSampled(float output[4],
ConvertVectorToColorOperation::ConvertVectorToColorOperation() : ConvertBaseOperation() ConvertVectorToColorOperation::ConvertVectorToColorOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Vector); this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertVectorToColorOperation::executePixelSampled(float output[4], void ConvertVectorToColorOperation::executePixelSampled(float output[4],
@@ -147,8 +147,8 @@ void ConvertVectorToColorOperation::executePixelSampled(float output[4],
ConvertVectorToValueOperation::ConvertVectorToValueOperation() : ConvertBaseOperation() ConvertVectorToValueOperation::ConvertVectorToValueOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Vector); this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
} }
void ConvertVectorToValueOperation::executePixelSampled(float output[4], void ConvertVectorToValueOperation::executePixelSampled(float output[4],
@@ -165,8 +165,8 @@ void ConvertVectorToValueOperation::executePixelSampled(float output[4],
ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : ConvertBaseOperation() ConvertRGBToYCCOperation::ConvertRGBToYCCOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertRGBToYCCOperation::setMode(int mode) void ConvertRGBToYCCOperation::setMode(int mode)
@@ -207,8 +207,8 @@ void ConvertRGBToYCCOperation::executePixelSampled(float output[4],
ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : ConvertBaseOperation() ConvertYCCToRGBOperation::ConvertYCCToRGBOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertYCCToRGBOperation::setMode(int mode) void ConvertYCCToRGBOperation::setMode(int mode)
@@ -253,8 +253,8 @@ void ConvertYCCToRGBOperation::executePixelSampled(float output[4],
ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : ConvertBaseOperation() ConvertRGBToYUVOperation::ConvertRGBToYUVOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertRGBToYUVOperation::executePixelSampled(float output[4], void ConvertRGBToYUVOperation::executePixelSampled(float output[4],
@@ -278,8 +278,8 @@ void ConvertRGBToYUVOperation::executePixelSampled(float output[4],
ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : ConvertBaseOperation() ConvertYUVToRGBOperation::ConvertYUVToRGBOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertYUVToRGBOperation::executePixelSampled(float output[4], void ConvertYUVToRGBOperation::executePixelSampled(float output[4],
@@ -303,8 +303,8 @@ void ConvertYUVToRGBOperation::executePixelSampled(float output[4],
ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : ConvertBaseOperation() ConvertRGBToHSVOperation::ConvertRGBToHSVOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertRGBToHSVOperation::executePixelSampled(float output[4], void ConvertRGBToHSVOperation::executePixelSampled(float output[4],
@@ -322,8 +322,8 @@ void ConvertRGBToHSVOperation::executePixelSampled(float output[4],
ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : ConvertBaseOperation() ConvertHSVToRGBOperation::ConvertHSVToRGBOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertHSVToRGBOperation::executePixelSampled(float output[4], void ConvertHSVToRGBOperation::executePixelSampled(float output[4],
@@ -344,8 +344,8 @@ void ConvertHSVToRGBOperation::executePixelSampled(float output[4],
ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : ConvertBaseOperation() ConvertPremulToStraightOperation::ConvertPremulToStraightOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertPremulToStraightOperation::executePixelSampled(float output[4], void ConvertPremulToStraightOperation::executePixelSampled(float output[4],
@@ -374,8 +374,8 @@ void ConvertPremulToStraightOperation::executePixelSampled(float output[4],
ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : ConvertBaseOperation() ConvertStraightToPremulOperation::ConvertStraightToPremulOperation() : ConvertBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
} }
void ConvertStraightToPremulOperation::executePixelSampled(float output[4], void ConvertStraightToPremulOperation::executePixelSampled(float output[4],
@@ -399,8 +399,8 @@ void ConvertStraightToPremulOperation::executePixelSampled(float output[4],
SeparateChannelOperation::SeparateChannelOperation() SeparateChannelOperation::SeparateChannelOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
} }
void SeparateChannelOperation::initExecution() void SeparateChannelOperation::initExecution()
@@ -427,11 +427,11 @@ void SeparateChannelOperation::executePixelSampled(float output[4],
CombineChannelsOperation::CombineChannelsOperation() CombineChannelsOperation::CombineChannelsOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0); this->setResolutionInputSocketIndex(0);
this->m_inputChannel1Operation = nullptr; this->m_inputChannel1Operation = nullptr;
this->m_inputChannel2Operation = nullptr; this->m_inputChannel2Operation = nullptr;

View File

@@ -24,9 +24,9 @@
ConvolutionFilterOperation::ConvolutionFilterOperation() ConvolutionFilterOperation::ConvolutionFilterOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0); this->setResolutionInputSocketIndex(0);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
this->setComplex(true); this->setComplex(true);

View File

@@ -21,8 +21,8 @@
CropBaseOperation::CropBaseOperation() CropBaseOperation::CropBaseOperation()
{ {
this->addInputSocket(DataType::Color, COM_SC_NO_RESIZE); this->addInputSocket(COM_DT_COLOR, COM_SC_NO_RESIZE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
this->m_settings = nullptr; this->m_settings = nullptr;
} }

View File

@@ -21,10 +21,10 @@
CryptomatteOperation::CryptomatteOperation(size_t num_inputs) CryptomatteOperation::CryptomatteOperation(size_t num_inputs)
{ {
for (size_t i = 0; i < num_inputs; i++) { for (size_t i = 0; i < num_inputs; i++) {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
} }
inputs.resize(num_inputs); inputs.resize(num_inputs);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true); this->setComplex(true);
} }

View File

@@ -28,10 +28,10 @@ static pthread_mutex_t oidn_lock = BLI_MUTEX_INITIALIZER;
DenoiseOperation::DenoiseOperation() DenoiseOperation::DenoiseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Vector); this->addInputSocket(COM_DT_VECTOR);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_settings = nullptr; this->m_settings = nullptr;
} }
void DenoiseOperation::initExecution() void DenoiseOperation::initExecution()
@@ -60,7 +60,7 @@ MemoryBuffer *DenoiseOperation::createMemoryBuffer(rcti *rect2)
rect.ymin = 0; rect.ymin = 0;
rect.xmax = getWidth(); rect.xmax = getWidth();
rect.ymax = getHeight(); rect.ymax = getHeight();
MemoryBuffer *result = new MemoryBuffer(DataType::Color, rect); MemoryBuffer *result = new MemoryBuffer(COM_DT_COLOR, &rect);
float *data = result->getBuffer(); float *data = result->getBuffer();
this->generateDenoise(data, tileColor, tileNormal, tileAlbedo, this->m_settings); this->generateDenoise(data, tileColor, tileNormal, tileAlbedo, this->m_settings);
return result; return result;

View File

@@ -24,9 +24,9 @@
DespeckleOperation::DespeckleOperation() DespeckleOperation::DespeckleOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0); this->setResolutionInputSocketIndex(0);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
this->setComplex(true); this->setComplex(true);

View File

@@ -21,9 +21,9 @@
DifferenceMatteOperation::DifferenceMatteOperation() DifferenceMatteOperation::DifferenceMatteOperation()
{ {
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addInputSocket(DataType::Color); addInputSocket(COM_DT_COLOR);
addOutputSocket(DataType::Value); addOutputSocket(COM_DT_VALUE);
this->m_inputImage1Program = nullptr; this->m_inputImage1Program = nullptr;
this->m_inputImage2Program = nullptr; this->m_inputImage2Program = nullptr;

View File

@@ -25,8 +25,8 @@
// DilateErode Distance Threshold // DilateErode Distance Threshold
DilateErodeThresholdOperation::DilateErodeThresholdOperation() DilateErodeThresholdOperation::DilateErodeThresholdOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->setComplex(true); this->setComplex(true);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
this->m_inset = 0.0f; this->m_inset = 0.0f;
@@ -70,19 +70,19 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
const rcti &input_rect = inputBuffer->get_rect(); rcti *rect = inputBuffer->getRect();
const int minx = MAX2(x - this->m_scope, input_rect.xmin); const int minx = MAX2(x - this->m_scope, rect->xmin);
const int miny = MAX2(y - this->m_scope, input_rect.ymin); const int miny = MAX2(y - this->m_scope, rect->ymin);
const int maxx = MIN2(x + this->m_scope, input_rect.xmax); const int maxx = MIN2(x + this->m_scope, rect->xmax);
const int maxy = MIN2(y + this->m_scope, input_rect.ymax); const int maxy = MIN2(y + this->m_scope, rect->ymax);
const int bufferWidth = inputBuffer->getWidth(); const int bufferWidth = BLI_rcti_size_x(rect);
int offset; int offset;
inputBuffer->read(inputValue, x, y); inputBuffer->read(inputValue, x, y);
if (inputValue[0] > sw) { if (inputValue[0] > sw) {
for (int yi = miny; yi < maxy; yi++) { for (int yi = miny; yi < maxy; yi++) {
const float dy = yi - y; const float dy = yi - y;
offset = ((yi - input_rect.ymin) * bufferWidth + (minx - input_rect.xmin)); offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
for (int xi = minx; xi < maxx; xi++) { for (int xi = minx; xi < maxx; xi++) {
if (buffer[offset] < sw) { if (buffer[offset] < sw) {
const float dx = xi - x; const float dx = xi - x;
@@ -97,7 +97,7 @@ void DilateErodeThresholdOperation::executePixel(float output[4], int x, int y,
else { else {
for (int yi = miny; yi < maxy; yi++) { for (int yi = miny; yi < maxy; yi++) {
const float dy = yi - y; const float dy = yi - y;
offset = ((yi - input_rect.ymin) * bufferWidth + (minx - input_rect.xmin)); offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
for (int xi = minx; xi < maxx; xi++) { for (int xi = minx; xi < maxx; xi++) {
if (buffer[offset] > sw) { if (buffer[offset] > sw) {
const float dx = xi - x; const float dx = xi - x;
@@ -161,8 +161,8 @@ bool DilateErodeThresholdOperation::determineDependingAreaOfInterest(
// Dilate Distance // Dilate Distance
DilateDistanceOperation::DilateDistanceOperation() DilateDistanceOperation::DilateDistanceOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->setComplex(true); this->setComplex(true);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
this->m_distance = 0.0f; this->m_distance = 0.0f;
@@ -190,19 +190,19 @@ void DilateDistanceOperation::executePixel(float output[4], int x, int y, void *
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
const rcti &input_rect = inputBuffer->get_rect(); rcti *rect = inputBuffer->getRect();
const int minx = MAX2(x - this->m_scope, input_rect.xmin); const int minx = MAX2(x - this->m_scope, rect->xmin);
const int miny = MAX2(y - this->m_scope, input_rect.ymin); const int miny = MAX2(y - this->m_scope, rect->ymin);
const int maxx = MIN2(x + this->m_scope, input_rect.xmax); const int maxx = MIN2(x + this->m_scope, rect->xmax);
const int maxy = MIN2(y + this->m_scope, input_rect.ymax); const int maxy = MIN2(y + this->m_scope, rect->ymax);
const int bufferWidth = inputBuffer->getWidth(); const int bufferWidth = BLI_rcti_size_x(rect);
int offset; int offset;
float value = 0.0f; float value = 0.0f;
for (int yi = miny; yi < maxy; yi++) { for (int yi = miny; yi < maxy; yi++) {
const float dy = yi - y; const float dy = yi - y;
offset = ((yi - input_rect.ymin) * bufferWidth + (minx - input_rect.xmin)); offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
for (int xi = minx; xi < maxx; xi++) { for (int xi = minx; xi < maxx; xi++) {
const float dx = xi - x; const float dx = xi - x;
const float dis = dx * dx + dy * dy; const float dis = dx * dx + dy * dy;
@@ -269,19 +269,19 @@ void ErodeDistanceOperation::executePixel(float output[4], int x, int y, void *d
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
const rcti &input_rect = inputBuffer->get_rect(); rcti *rect = inputBuffer->getRect();
const int minx = MAX2(x - this->m_scope, input_rect.xmin); const int minx = MAX2(x - this->m_scope, rect->xmin);
const int miny = MAX2(y - this->m_scope, input_rect.ymin); const int miny = MAX2(y - this->m_scope, rect->ymin);
const int maxx = MIN2(x + this->m_scope, input_rect.xmax); const int maxx = MIN2(x + this->m_scope, rect->xmax);
const int maxy = MIN2(y + this->m_scope, input_rect.ymax); const int maxy = MIN2(y + this->m_scope, rect->ymax);
const int bufferWidth = inputBuffer->getWidth(); const int bufferWidth = BLI_rcti_size_x(rect);
int offset; int offset;
float value = 1.0f; float value = 1.0f;
for (int yi = miny; yi < maxy; yi++) { for (int yi = miny; yi < maxy; yi++) {
const float dy = yi - y; const float dy = yi - y;
offset = ((yi - input_rect.ymin) * bufferWidth + (minx - input_rect.xmin)); offset = ((yi - rect->ymin) * bufferWidth + (minx - rect->xmin));
for (int xi = minx; xi < maxx; xi++) { for (int xi = minx; xi < maxx; xi++) {
const float dx = xi - x; const float dx = xi - x;
const float dis = dx * dx + dy * dy; const float dis = dx * dx + dy * dy;
@@ -319,8 +319,8 @@ void ErodeDistanceOperation::executeOpenCL(OpenCLDevice *device,
// Dilate step // Dilate step
DilateStepOperation::DilateStepOperation() DilateStepOperation::DilateStepOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->setComplex(true); this->setComplex(true);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
} }

View File

@@ -25,8 +25,8 @@
DirectionalBlurOperation::DirectionalBlurOperation() DirectionalBlurOperation::DirectionalBlurOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true); this->setComplex(true);
this->setOpenCL(true); this->setOpenCL(true);

View File

@@ -22,11 +22,11 @@
DisplaceOperation::DisplaceOperation() DisplaceOperation::DisplaceOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Vector); this->addInputSocket(COM_DT_VECTOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setComplex(true); this->setComplex(true);
this->m_inputColorProgram = nullptr; this->m_inputColorProgram = nullptr;

View File

@@ -22,11 +22,11 @@
DisplaceSimpleOperation::DisplaceSimpleOperation() DisplaceSimpleOperation::DisplaceSimpleOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Vector); this->addInputSocket(COM_DT_VECTOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputColorProgram = nullptr; this->m_inputColorProgram = nullptr;
this->m_inputVectorProgram = nullptr; this->m_inputVectorProgram = nullptr;

View File

@@ -21,9 +21,9 @@
DistanceRGBMatteOperation::DistanceRGBMatteOperation() DistanceRGBMatteOperation::DistanceRGBMatteOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_inputImageProgram = nullptr; this->m_inputImageProgram = nullptr;
this->m_inputKeyProgram = nullptr; this->m_inputKeyProgram = nullptr;

View File

@@ -20,9 +20,9 @@
DotproductOperation::DotproductOperation() DotproductOperation::DotproductOperation()
{ {
this->addInputSocket(DataType::Vector); this->addInputSocket(COM_DT_VECTOR);
this->addInputSocket(DataType::Vector); this->addInputSocket(COM_DT_VECTOR);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->setResolutionInputSocketIndex(0); this->setResolutionInputSocketIndex(0);
this->m_input1Operation = nullptr; this->m_input1Operation = nullptr;
this->m_input2Operation = nullptr; this->m_input2Operation = nullptr;

View File

@@ -1308,9 +1308,9 @@ void DoubleEdgeMaskOperation::doDoubleEdgeMask(float *imask, float *omask, float
DoubleEdgeMaskOperation::DoubleEdgeMaskOperation() DoubleEdgeMaskOperation::DoubleEdgeMaskOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_inputInnerMask = nullptr; this->m_inputInnerMask = nullptr;
this->m_inputOuterMask = nullptr; this->m_inputOuterMask = nullptr;
this->m_adjacentOnly = false; this->m_adjacentOnly = false;

View File

@@ -22,9 +22,9 @@
EllipseMaskOperation::EllipseMaskOperation() EllipseMaskOperation::EllipseMaskOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_inputMask = nullptr; this->m_inputMask = nullptr;
this->m_inputValue = nullptr; this->m_inputValue = nullptr;
this->m_cosine = 0.0f; this->m_cosine = 0.0f;

View File

@@ -22,7 +22,7 @@
#include "COM_FastGaussianBlurOperation.h" #include "COM_FastGaussianBlurOperation.h"
#include "MEM_guardedalloc.h" #include "MEM_guardedalloc.h"
FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(DataType::Color) FastGaussianBlurOperation::FastGaussianBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{ {
this->m_iirgaus = nullptr; this->m_iirgaus = nullptr;
} }
@@ -80,7 +80,7 @@ void *FastGaussianBlurOperation::initializeTileData(rcti *rect)
lockMutex(); lockMutex();
if (!this->m_iirgaus) { if (!this->m_iirgaus) {
MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect); MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputProgram->initializeTileData(rect);
MemoryBuffer *copy = new MemoryBuffer(*newBuf); MemoryBuffer *copy = newBuf->duplicate();
updateSize(); updateSize();
int c; int c;
@@ -122,7 +122,7 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
unsigned int x, y, sz; unsigned int x, y, sz;
unsigned int i; unsigned int i;
float *buffer = src->getBuffer(); float *buffer = src->getBuffer();
const uint8_t num_channels = src->get_num_channels(); const unsigned int num_channels = src->get_num_channels();
// <0.5 not valid, though can have a possibly useful sort of sharpening effect // <0.5 not valid, though can have a possibly useful sort of sharpening effect
if (sigma < 0.5f) { if (sigma < 0.5f) {
@@ -258,8 +258,8 @@ void FastGaussianBlurOperation::IIR_gauss(MemoryBuffer *src,
/// ///
FastGaussianBlurValueOperation::FastGaussianBlurValueOperation() FastGaussianBlurValueOperation::FastGaussianBlurValueOperation()
{ {
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Value); this->addOutputSocket(COM_DT_VALUE);
this->m_iirgaus = nullptr; this->m_iirgaus = nullptr;
this->m_inputprogram = nullptr; this->m_inputprogram = nullptr;
this->m_sigma = 1.0f; this->m_sigma = 1.0f;
@@ -310,7 +310,7 @@ void *FastGaussianBlurValueOperation::initializeTileData(rcti *rect)
lockMutex(); lockMutex();
if (!this->m_iirgaus) { if (!this->m_iirgaus) {
MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect); MemoryBuffer *newBuf = (MemoryBuffer *)this->m_inputprogram->initializeTileData(rect);
MemoryBuffer *copy = new MemoryBuffer(*newBuf); MemoryBuffer *copy = newBuf->duplicate();
FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3); FastGaussianBlurOperation::IIR_gauss(copy, this->m_sigma, 0, 3);
if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) { if (this->m_overlay == FAST_GAUSS_OVERLAY_MIN) {

View File

@@ -20,8 +20,8 @@
FlipOperation::FlipOperation() FlipOperation::FlipOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->setResolutionInputSocketIndex(0); this->setResolutionInputSocketIndex(0);
this->m_inputOperation = nullptr; this->m_inputOperation = nullptr;
this->m_flipX = true; this->m_flipX = true;

View File

@@ -21,8 +21,8 @@
GammaCorrectOperation::GammaCorrectOperation() GammaCorrectOperation::GammaCorrectOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
} }
void GammaCorrectOperation::initExecution() void GammaCorrectOperation::initExecution()
@@ -63,8 +63,8 @@ void GammaCorrectOperation::deinitExecution()
GammaUncorrectOperation::GammaUncorrectOperation() GammaUncorrectOperation::GammaUncorrectOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
} }
void GammaUncorrectOperation::initExecution() void GammaUncorrectOperation::initExecution()

View File

@@ -21,9 +21,9 @@
GammaOperation::GammaOperation() GammaOperation::GammaOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addInputSocket(DataType::Value); this->addInputSocket(COM_DT_VALUE);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_inputProgram = nullptr; this->m_inputProgram = nullptr;
this->m_inputGammaProgram = nullptr; this->m_inputGammaProgram = nullptr;
} }

View File

@@ -22,7 +22,7 @@
#include "RE_pipeline.h" #include "RE_pipeline.h"
GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(DataType::Value) GaussianAlphaXBlurOperation::GaussianAlphaXBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{ {
this->m_gausstab = nullptr; this->m_gausstab = nullptr;
this->m_filtersize = 0; this->m_filtersize = 0;
@@ -87,11 +87,10 @@ void GaussianAlphaXBlurOperation::executePixel(float output[4], int x, int y, vo
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth(); int bufferwidth = inputBuffer->getWidth();
const rcti &input_rect = inputBuffer->get_rect(); int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstartx = input_rect.xmin; int bufferstarty = inputBuffer->getRect()->ymin;
int bufferstarty = input_rect.ymin;
const rcti &rect = inputBuffer->get_rect(); rcti &rect = *inputBuffer->getRect();
int xmin = max_ii(x - m_filtersize, rect.xmin); int xmin = max_ii(x - m_filtersize, rect.xmin);
int xmax = min_ii(x + m_filtersize + 1, rect.xmax); int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
int ymin = max_ii(y, rect.ymin); int ymin = max_ii(y, rect.ymin);

View File

@@ -22,7 +22,7 @@
#include "RE_pipeline.h" #include "RE_pipeline.h"
GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(DataType::Value) GaussianAlphaYBlurOperation::GaussianAlphaYBlurOperation() : BlurBaseOperation(COM_DT_VALUE)
{ {
this->m_gausstab = nullptr; this->m_gausstab = nullptr;
this->m_filtersize = 0; this->m_filtersize = 0;
@@ -85,15 +85,15 @@ void GaussianAlphaYBlurOperation::executePixel(float output[4], int x, int y, vo
{ {
const bool do_invert = this->m_do_subtract; const bool do_invert = this->m_do_subtract;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
const rcti &input_rect = inputBuffer->get_rect();
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth(); int bufferwidth = inputBuffer->getWidth();
int bufferstartx = input_rect.xmin; int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = input_rect.ymin; int bufferstarty = inputBuffer->getRect()->ymin;
int xmin = max_ii(x, input_rect.xmin); rcti &rect = *inputBuffer->getRect();
int ymin = max_ii(y - m_filtersize, input_rect.ymin); int xmin = max_ii(x, rect.xmin);
int ymax = min_ii(y + m_filtersize + 1, input_rect.ymax); int ymin = max_ii(y - m_filtersize, rect.ymin);
int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
/* *** this is the main part which is different to 'GaussianYBlurOperation' *** */ /* *** this is the main part which is different to 'GaussianYBlurOperation' *** */
int step = getStep(); int step = getStep();

View File

@@ -22,7 +22,7 @@
#include "RE_pipeline.h" #include "RE_pipeline.h"
GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(DataType::Color) GaussianBokehBlurOperation::GaussianBokehBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{ {
this->m_gausstab = nullptr; this->m_gausstab = nullptr;
} }
@@ -121,14 +121,14 @@ void GaussianBokehBlurOperation::executePixel(float output[4], int x, int y, voi
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth(); int bufferwidth = inputBuffer->getWidth();
const rcti &input_rect = inputBuffer->get_rect(); int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstartx = input_rect.xmin; int bufferstarty = inputBuffer->getRect()->ymin;
int bufferstarty = input_rect.ymin;
int ymin = max_ii(y - this->m_rady, input_rect.ymin); rcti &rect = *inputBuffer->getRect();
int ymax = min_ii(y + this->m_rady + 1, input_rect.ymax); int ymin = max_ii(y - this->m_rady, rect.ymin);
int xmin = max_ii(x - this->m_radx, input_rect.xmin); int ymax = min_ii(y + this->m_rady + 1, rect.ymax);
int xmax = min_ii(x + this->m_radx + 1, input_rect.xmax); int xmin = max_ii(x - this->m_radx, rect.xmin);
int xmax = min_ii(x + this->m_radx + 1, rect.xmax);
int index; int index;
int step = QualityStepHelper::getStep(); int step = QualityStepHelper::getStep();
@@ -195,8 +195,7 @@ bool GaussianBokehBlurOperation::determineDependingAreaOfInterest(
} }
// reference image // reference image
GaussianBlurReferenceOperation::GaussianBlurReferenceOperation() GaussianBlurReferenceOperation::GaussianBlurReferenceOperation() : BlurBaseOperation(COM_DT_COLOR)
: BlurBaseOperation(DataType::Color)
{ {
this->m_maintabs = nullptr; this->m_maintabs = nullptr;
} }

View File

@@ -23,7 +23,7 @@
#include "RE_pipeline.h" #include "RE_pipeline.h"
GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(DataType::Color) GaussianXBlurOperation::GaussianXBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{ {
this->m_gausstab = nullptr; this->m_gausstab = nullptr;
#ifdef BLI_HAVE_SSE2 #ifdef BLI_HAVE_SSE2
@@ -81,15 +81,15 @@ void GaussianXBlurOperation::executePixel(float output[4], int x, int y, void *d
float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float multiplier_accum = 0.0f; float multiplier_accum = 0.0f;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
const rcti &input_rect = inputBuffer->get_rect();
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth(); int bufferwidth = inputBuffer->getWidth();
int bufferstartx = input_rect.xmin; int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = input_rect.ymin; int bufferstarty = inputBuffer->getRect()->ymin;
int xmin = max_ii(x - m_filtersize, input_rect.xmin); rcti &rect = *inputBuffer->getRect();
int xmax = min_ii(x + m_filtersize + 1, input_rect.xmax); int xmin = max_ii(x - m_filtersize, rect.xmin);
int ymin = max_ii(y, input_rect.ymin); int xmax = min_ii(x + m_filtersize + 1, rect.xmax);
int ymin = max_ii(y, rect.ymin);
int step = getStep(); int step = getStep();
int offsetadd = getOffsetAdd(); int offsetadd = getOffsetAdd();

View File

@@ -23,7 +23,7 @@
#include "RE_pipeline.h" #include "RE_pipeline.h"
GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(DataType::Color) GaussianYBlurOperation::GaussianYBlurOperation() : BlurBaseOperation(COM_DT_COLOR)
{ {
this->m_gausstab = nullptr; this->m_gausstab = nullptr;
#ifdef BLI_HAVE_SSE2 #ifdef BLI_HAVE_SSE2
@@ -80,15 +80,15 @@ void GaussianYBlurOperation::executePixel(float output[4], int x, int y, void *d
float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f}; float ATTR_ALIGN(16) color_accum[4] = {0.0f, 0.0f, 0.0f, 0.0f};
float multiplier_accum = 0.0f; float multiplier_accum = 0.0f;
MemoryBuffer *inputBuffer = (MemoryBuffer *)data; MemoryBuffer *inputBuffer = (MemoryBuffer *)data;
const rcti &input_rect = inputBuffer->get_rect();
float *buffer = inputBuffer->getBuffer(); float *buffer = inputBuffer->getBuffer();
int bufferwidth = inputBuffer->getWidth(); int bufferwidth = inputBuffer->getWidth();
int bufferstartx = input_rect.xmin; int bufferstartx = inputBuffer->getRect()->xmin;
int bufferstarty = input_rect.ymin; int bufferstarty = inputBuffer->getRect()->ymin;
int xmin = max_ii(x, input_rect.xmin); rcti &rect = *inputBuffer->getRect();
int ymin = max_ii(y - m_filtersize, input_rect.ymin); int xmin = max_ii(x, rect.xmin);
int ymax = min_ii(y + m_filtersize + 1, input_rect.ymax); int ymin = max_ii(y - m_filtersize, rect.ymin);
int ymax = min_ii(y + m_filtersize + 1, rect.ymax);
int index; int index;
int step = getStep(); int step = getStep();

View File

@@ -21,8 +21,8 @@
GlareBaseOperation::GlareBaseOperation() GlareBaseOperation::GlareBaseOperation()
{ {
this->addInputSocket(DataType::Color); this->addInputSocket(COM_DT_COLOR);
this->addOutputSocket(DataType::Color); this->addOutputSocket(COM_DT_COLOR);
this->m_settings = nullptr; this->m_settings = nullptr;
} }
void GlareBaseOperation::initExecution() void GlareBaseOperation::initExecution()
@@ -45,7 +45,7 @@ MemoryBuffer *GlareBaseOperation::createMemoryBuffer(rcti *rect2)
rect.ymin = 0; rect.ymin = 0;
rect.xmax = getWidth(); rect.xmax = getWidth();
rect.ymax = getHeight(); rect.ymax = getHeight();
MemoryBuffer *result = new MemoryBuffer(DataType::Color, rect); MemoryBuffer *result = new MemoryBuffer(COM_DT_COLOR, &rect);
float *data = result->getBuffer(); float *data = result->getBuffer();
this->generateGlare(data, tile, this->m_settings); this->generateGlare(data, tile, this->m_settings);
return result; return result;

View File

@@ -268,7 +268,7 @@ static void convolve(float *dst, MemoryBuffer *in1, MemoryBuffer *in2)
float *kernelBuffer = in2->getBuffer(); float *kernelBuffer = in2->getBuffer();
float *imageBuffer = in1->getBuffer(); float *imageBuffer = in1->getBuffer();
MemoryBuffer *rdst = new MemoryBuffer(DataType::Color, in1->get_rect()); MemoryBuffer *rdst = new MemoryBuffer(COM_DT_COLOR, in1->getRect());
memset(rdst->getBuffer(), memset(rdst->getBuffer(),
0, 0,
rdst->getWidth() * rdst->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float)); rdst->getWidth() * rdst->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
@@ -417,7 +417,7 @@ void GlareFogGlowOperation::generateGlare(float *data,
// make the convolution kernel // make the convolution kernel
rcti kernelRect; rcti kernelRect;
BLI_rcti_init(&kernelRect, 0, sz, 0, sz); BLI_rcti_init(&kernelRect, 0, sz, 0, sz);
ckrn = new MemoryBuffer(DataType::Color, kernelRect); ckrn = new MemoryBuffer(COM_DT_COLOR, &kernelRect);
scale = 0.25f * sqrtf((float)(sz * sz)); scale = 0.25f * sqrtf((float)(sz * sz));

View File

@@ -41,41 +41,41 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
float sc, isc, u, v, sm, s, t, ofs, scalef[64]; float sc, isc, u, v, sm, s, t, ofs, scalef[64];
const float cmo = 1.0f - settings->colmod; const float cmo = 1.0f - settings->colmod;
MemoryBuffer gbuf(*inputTile); MemoryBuffer *gbuf = inputTile->duplicate();
MemoryBuffer tbuf1(*inputTile); MemoryBuffer *tbuf1 = inputTile->duplicate();
bool breaked = false; bool breaked = false;
FastGaussianBlurOperation::IIR_gauss(&tbuf1, s1, 0, 3); FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 0, 3);
if (!breaked) { if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(&tbuf1, s1, 1, 3); FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 1, 3);
} }
if (isBraked()) { if (isBraked()) {
breaked = true; breaked = true;
} }
if (!breaked) { if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(&tbuf1, s1, 2, 3); FastGaussianBlurOperation::IIR_gauss(tbuf1, s1, 2, 3);
} }
MemoryBuffer tbuf2(tbuf1); MemoryBuffer *tbuf2 = tbuf1->duplicate();
if (isBraked()) { if (isBraked()) {
breaked = true; breaked = true;
} }
if (!breaked) { if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(&tbuf2, s2, 0, 3); FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 0, 3);
} }
if (isBraked()) { if (isBraked()) {
breaked = true; breaked = true;
} }
if (!breaked) { if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(&tbuf2, s2, 1, 3); FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 1, 3);
} }
if (isBraked()) { if (isBraked()) {
breaked = true; breaked = true;
} }
if (!breaked) { if (!breaked) {
FastGaussianBlurOperation::IIR_gauss(&tbuf2, s2, 2, 3); FastGaussianBlurOperation::IIR_gauss(tbuf2, s2, 2, 3);
} }
ofs = (settings->iter & 1) ? 0.5f : 0.0f; ofs = (settings->iter & 1) ? 0.5f : 0.0f;
@@ -99,57 +99,61 @@ void GlareGhostOperation::generateGlare(float *data, MemoryBuffer *inputTile, No
sc = 2.13; sc = 2.13;
isc = -0.97; isc = -0.97;
for (y = 0; y < gbuf.getHeight() && (!breaked); y++) { for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
v = ((float)y + 0.5f) / (float)gbuf.getHeight(); v = ((float)y + 0.5f) / (float)gbuf->getHeight();
for (x = 0; x < gbuf.getWidth(); x++) { for (x = 0; x < gbuf->getWidth(); x++) {
u = ((float)x + 0.5f) / (float)gbuf.getWidth(); u = ((float)x + 0.5f) / (float)gbuf->getWidth();
s = (u - 0.5f) * sc + 0.5f; s = (u - 0.5f) * sc + 0.5f;
t = (v - 0.5f) * sc + 0.5f; t = (v - 0.5f) * sc + 0.5f;
tbuf1.readBilinear(c, s * gbuf.getWidth(), t * gbuf.getHeight()); tbuf1->readBilinear(c, s * gbuf->getWidth(), t * gbuf->getHeight());
sm = smoothMask(s, t); sm = smoothMask(s, t);
mul_v3_fl(c, sm); mul_v3_fl(c, sm);
s = (u - 0.5f) * isc + 0.5f; s = (u - 0.5f) * isc + 0.5f;
t = (v - 0.5f) * isc + 0.5f; t = (v - 0.5f) * isc + 0.5f;
tbuf2.readBilinear(tc, s * gbuf.getWidth() - 0.5f, t * gbuf.getHeight() - 0.5f); tbuf2->readBilinear(tc, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
sm = smoothMask(s, t); sm = smoothMask(s, t);
madd_v3_v3fl(c, tc, sm); madd_v3_v3fl(c, tc, sm);
gbuf.writePixel(x, y, c); gbuf->writePixel(x, y, c);
} }
if (isBraked()) { if (isBraked()) {
breaked = true; breaked = true;
} }
} }
memset(tbuf1.getBuffer(), memset(tbuf1->getBuffer(),
0, 0,
tbuf1.getWidth() * tbuf1.getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float)); tbuf1->getWidth() * tbuf1->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
for (n = 1; n < settings->iter && (!breaked); n++) { for (n = 1; n < settings->iter && (!breaked); n++) {
for (y = 0; y < gbuf.getHeight() && (!breaked); y++) { for (y = 0; y < gbuf->getHeight() && (!breaked); y++) {
v = ((float)y + 0.5f) / (float)gbuf.getHeight(); v = ((float)y + 0.5f) / (float)gbuf->getHeight();
for (x = 0; x < gbuf.getWidth(); x++) { for (x = 0; x < gbuf->getWidth(); x++) {
u = ((float)x + 0.5f) / (float)gbuf.getWidth(); u = ((float)x + 0.5f) / (float)gbuf->getWidth();
tc[0] = tc[1] = tc[2] = 0.0f; tc[0] = tc[1] = tc[2] = 0.0f;
for (p = 0; p < 4; p++) { for (p = 0; p < 4; p++) {
np = (n << 2) + p; np = (n << 2) + p;
s = (u - 0.5f) * scalef[np] + 0.5f; s = (u - 0.5f) * scalef[np] + 0.5f;
t = (v - 0.5f) * scalef[np] + 0.5f; t = (v - 0.5f) * scalef[np] + 0.5f;
gbuf.readBilinear(c, s * gbuf.getWidth() - 0.5f, t * gbuf.getHeight() - 0.5f); gbuf->readBilinear(c, s * gbuf->getWidth() - 0.5f, t * gbuf->getHeight() - 0.5f);
mul_v3_v3(c, cm[np]); mul_v3_v3(c, cm[np]);
sm = smoothMask(s, t) * 0.25f; sm = smoothMask(s, t) * 0.25f;
madd_v3_v3fl(tc, c, sm); madd_v3_v3fl(tc, c, sm);
} }
tbuf1.addPixel(x, y, tc); tbuf1->addPixel(x, y, tc);
} }
if (isBraked()) { if (isBraked()) {
breaked = true; breaked = true;
} }
} }
memcpy(gbuf.getBuffer(), memcpy(gbuf->getBuffer(),
tbuf1.getBuffer(), tbuf1->getBuffer(),
tbuf1.getWidth() * tbuf1.getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float)); tbuf1->getWidth() * tbuf1->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
} }
memcpy(data, memcpy(data,
gbuf.getBuffer(), gbuf->getBuffer(),
gbuf.getWidth() * gbuf.getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float)); gbuf->getWidth() * gbuf->getHeight() * COM_NUM_CHANNELS_COLOR * sizeof(float));
delete gbuf;
delete tbuf1;
delete tbuf2;
} }

Some files were not shown because too many files have changed in this diff Show More