00001 00002 // Copyright 1986, 2015 NVIDIA ARC GmbH. All rights reserved. 00004 // Created: 27.02.08 00005 // Module: api 00006 // Purpose: mental ray C++ shader interface extensions 00008 00017 00018 00019 #ifndef SHADER_FRAMEBUFFER_H 00020 #define SHADER_FRAMEBUFFER_H 00021 #include "mi_shader_if.h" 00022 00023 namespace mi { 00024 namespace shader_v3 { 00025 00026 00038 class Framebuffer { 00039 public: 00044 virtual bool set( 00045 const char *buffer, 00046 const char *param, 00047 const bool value) = 0; 00048 00053 virtual bool set( 00054 const char *buffer, 00055 const char *param, 00056 const float value) = 0; 00057 00062 virtual bool set( 00063 const char *buffer, 00064 const char *param, 00065 const int value) = 0; 00066 00071 virtual bool set( 00072 const char *buffer, 00073 const char *param, 00074 const char *value) = 0; 00075 00082 virtual bool get( 00083 const char *buffer, 00084 const char *param, 00085 bool &value) const = 0; 00086 00093 virtual bool get( 00094 const char *buffer, 00095 const char *param, 00096 float &value) const = 0; 00097 00104 virtual bool get( 00105 const char *buffer, 00106 const char *param, 00107 int &value) const = 0; 00108 00115 virtual bool get( 00116 const char *buffer, 00117 const char *param, 00118 const char *&value) const = 0; 00119 00126 virtual bool get_index(const char *buffer, size_t &index) const = 0; 00127 00131 virtual bool reset() = 0; 00132 00134 virtual void echo(FILE *) const = 0; 00135 00139 virtual bool get_buffercount(size_t &buffercount) const = 0; 00140 00147 virtual bool get_buffername(size_t num, const char *&name) const = 0; 00148 00152 virtual bool remove(const char *buffer) = 0; 00153 00161 virtual bool map_old_index(const unsigned int rc_index, int &index) const = 0; 00162 00168 virtual bool get_datatype(size_t num, miImg_type& type) const = 0; 00169 00170 }; 00171 00176 class Access_fb { 00177 public: 00180 Access_fb( 00181 miTag tag); 00182 00184 ~Access_fb(); 00185 00187 const Framebuffer * operator->() const; 00188 private: 00189 Access_fb(); 00190 Access_fb(const Access_fb &); 00191 const Access_fb & operator=(const Access_fb &); 00192 mi::shader_v3::Interface *m_iface; 00193 const Framebuffer *const m_fb; 00194 const miTag m_tag; 00195 }; 00196 00197 00201 00202 class Edit_fb { 00203 public: 00206 Edit_fb( 00207 miTag tag); 00208 00210 ~Edit_fb(); 00211 00213 Framebuffer * operator->() const; 00214 private: 00215 Edit_fb(); 00216 Edit_fb(const Edit_fb &); 00217 const Edit_fb & operator=(const Edit_fb &); 00218 mi::shader_v3::Interface *m_iface; 00219 Framebuffer *const m_fb; 00220 const miTag m_tag; 00221 }; 00222 00225 inline Access_fb::Access_fb( 00226 miTag tag) 00227 : m_iface(mi_get_shader_interface()) 00228 , m_fb(m_iface->accessFramebuffer(tag)) 00229 , m_tag(tag) 00230 { 00231 } 00232 00233 inline Access_fb::~Access_fb() 00234 { 00235 if (m_fb != 0) { 00236 m_iface->releaseFramebuffer(m_fb, m_tag); 00237 } 00238 m_iface->release(); 00239 } 00240 00241 inline const Framebuffer * Access_fb::operator->() const 00242 { 00243 return m_fb; 00244 } 00245 00248 inline Edit_fb::Edit_fb( 00249 miTag tag) 00250 : m_iface(mi_get_shader_interface()) 00251 , m_fb(m_iface->editFramebuffer(tag)) 00252 , m_tag(tag) 00253 { 00254 } 00255 00256 inline Edit_fb::~Edit_fb() 00257 { 00258 if (m_fb != 0) { 00259 m_iface->releaseFramebuffer(m_fb, m_tag); 00260 } 00261 m_iface->release(); 00262 } 00263 00264 inline Framebuffer * Edit_fb::operator->() const 00265 { 00266 return m_fb; 00267 } 00268 00269 00327 00328 class Merge_pass 00329 { 00330 public: 00332 Merge_pass(miState* state); 00333 00338 const void* get_cur_sample( 00339 const char* fb_name); 00340 00345 const void* get_pass_sample( 00346 const char* fb_name); 00347 00351 bool set_sample( 00352 const char* fb_name, 00353 void* sample); 00354 00359 const void* get_cur_sample( 00360 size_t fb_index); 00365 const void* get_pass_sample( 00366 size_t fb_index); 00367 00371 bool set_sample( 00372 size_t fb_index, 00373 void* sample); 00374 00377 size_t get_cur_pass_number(); 00378 00379 private: 00380 mi::shader_v3::Interface *m_iface; 00381 miState *m_state; 00382 }; 00383 00384 00385 inline Merge_pass::Merge_pass( 00386 miState* state) 00387 : m_iface(mi_get_shader_interface()) 00388 , m_state(state) 00389 { 00390 } 00391 00392 inline const void* Merge_pass::get_cur_sample( 00393 const char* fb_name) 00394 { 00395 size_t index(size_t(-1)); 00396 Access_fb fb(m_state->camera->buffertag); 00397 if(!fb->get_index(fb_name, index)) 00398 return NULL; 00399 00400 return m_iface->renderpass_get_cur_sample(m_state, index); 00401 } 00402 00403 inline const void* Merge_pass::get_pass_sample( 00404 const char* fb_name) 00405 { 00406 size_t index(size_t(-1)); 00407 Access_fb fb(m_state->camera->buffertag); 00408 if(!fb->get_index(fb_name, index)) 00409 return NULL; 00410 00411 return m_iface->renderpass_get_pass_sample(m_state, index); 00412 } 00413 00414 inline bool Merge_pass::set_sample( 00415 const char* fb_name, 00416 void* sample) 00417 { 00418 size_t index(size_t(-1)); 00419 Access_fb fb(m_state->camera->buffertag); 00420 if(!fb->get_index(fb_name, index)) 00421 return false; 00422 00423 return m_iface->renderpass_set_sample(m_state, index, sample); 00424 } 00425 00426 00427 inline const void* Merge_pass::get_cur_sample( 00428 size_t index) 00429 { 00430 return m_iface->renderpass_get_cur_sample(m_state, index); 00431 } 00432 00433 inline const void* Merge_pass::get_pass_sample( 00434 size_t index) 00435 { 00436 return m_iface->renderpass_get_pass_sample(m_state, index); 00437 } 00438 00439 inline bool Merge_pass::set_sample( 00440 size_t index, 00441 void* sample) 00442 { 00443 return m_iface->renderpass_set_sample(m_state, index, sample); 00444 } 00445 00446 inline size_t Merge_pass::get_cur_pass_number() 00447 { 00448 return m_iface->renderpass_get_pass_number(m_state); 00449 } 00450 00451 }} 00452 00453 #endif //SHADER_FRAMEBUFFER_H
Copyright © 1986, 2015 NVIDIA ARC GmbH. All rights reserved.