diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-21 17:48:35 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2011-12-21 17:48:35 +0400 |
commit | 34909c64e57149c997ebb7e3d794c6ceff0541b0 (patch) | |
tree | eddc440c3e8d9a0eaef3476411bca2219f266285 | |
parent | 045a91a37860dd40a2604f8208325b8d11c9e3a9 (diff) |
Cycles: some small code refactoring related to buffer parameters.
-rw-r--r-- | intern/cycles/render/buffers.h | 6 | ||||
-rw-r--r-- | intern/cycles/render/session.cpp | 24 | ||||
-rw-r--r-- | intern/cycles/render/tile.cpp | 16 | ||||
-rw-r--r-- | intern/cycles/render/tile.h | 6 |
4 files changed, 26 insertions, 26 deletions
diff --git a/intern/cycles/render/buffers.h b/intern/cycles/render/buffers.h index 66bd03c8893..f4a9b37c09b 100644 --- a/intern/cycles/render/buffers.h +++ b/intern/cycles/render/buffers.h @@ -56,6 +56,12 @@ public: full_height = 0; } + void get_offset_stride(int& offset, int& stride) + { + offset = -(full_x + full_y*width); + stride = width; + } + bool modified(const BufferParams& params) { return !(full_x == params.full_x diff --git a/intern/cycles/render/session.cpp b/intern/cycles/render/session.cpp index 26c4dbfbb7a..be2e493dc7f 100644 --- a/intern/cycles/render/session.cpp +++ b/intern/cycles/render/session.cpp @@ -515,10 +515,8 @@ void Session::update_scene() knows nothing about progressive or cropped rendering, it just gets the image dimensions passed in */ Camera *cam = scene->camera; - float progressive_x = tile_manager.state.width/(float)tile_manager.params.width; - float progressive_y = tile_manager.state.height/(float)tile_manager.params.height; - int width = tile_manager.params.full_width*progressive_x; - int height = tile_manager.params.full_height*progressive_y; + int width = tile_manager.state.buffer.full_width; + int height = tile_manager.state.buffer.full_height; if(width != cam->width || height != cam->height) { cam->width = width; @@ -574,16 +572,15 @@ void Session::path_trace(Tile& tile) /* add path trace task */ DeviceTask task(DeviceTask::PATH_TRACE); - task.x = tile_manager.state.full_x + tile.x; - task.y = tile_manager.state.full_y + tile.y; + task.x = tile_manager.state.buffer.full_x + tile.x; + task.y = tile_manager.state.buffer.full_y + tile.y; task.w = tile.w; task.h = tile.h; task.buffer = buffers->buffer.device_pointer; task.rng_state = buffers->rng_state.device_pointer; task.sample = tile_manager.state.sample; task.resolution = tile_manager.state.resolution; - task.offset = -(tile_manager.state.full_x + tile_manager.state.full_y*tile_manager.state.width); - task.stride = tile_manager.state.width; + tile_manager.state.buffer.get_offset_stride(task.offset, task.stride); device->task_add(task); } @@ -593,16 +590,15 @@ void Session::tonemap() /* add tonemap task */ DeviceTask task(DeviceTask::TONEMAP); - task.x = tile_manager.state.full_x; - task.y = tile_manager.state.full_y; - task.w = tile_manager.state.width; - task.h = tile_manager.state.height; + task.x = tile_manager.state.buffer.full_x; + task.y = tile_manager.state.buffer.full_y; + task.w = tile_manager.state.buffer.width; + task.h = tile_manager.state.buffer.height; task.rgba = display->rgba.device_pointer; task.buffer = buffers->buffer.device_pointer; task.sample = tile_manager.state.sample; task.resolution = tile_manager.state.resolution; - task.offset = -(tile_manager.state.full_x + tile_manager.state.full_y*tile_manager.state.width); - task.stride = tile_manager.state.width; + tile_manager.state.buffer.get_offset_stride(task.offset, task.stride); if(task.w > 0 && task.h > 0) { device->task_add(task); diff --git a/intern/cycles/render/tile.cpp b/intern/cycles/render/tile.cpp index b118a7ba478..40833e5b08b 100644 --- a/intern/cycles/render/tile.cpp +++ b/intern/cycles/render/tile.cpp @@ -55,10 +55,7 @@ void TileManager::reset(BufferParams& params_, int samples_) samples = samples_; - state.full_x = 0; - state.full_y = 0; - state.width = 0; - state.height = 0; + state.buffer = BufferParams(); state.sample = -1; state.resolution = start_resolution; state.tiles.clear(); @@ -92,10 +89,13 @@ void TileManager::set_tiles() } } - state.full_x = params.full_x/resolution; - state.full_y = params.full_y/resolution; - state.width = image_w; - state.height = image_h; + state.buffer.width = image_w; + state.buffer.height = image_h; + + state.buffer.full_x = params.full_x/resolution; + state.buffer.full_y = params.full_y/resolution; + state.buffer.full_width = max(1, params.full_width/resolution); + state.buffer.full_height = max(1, params.full_height/resolution); } bool TileManager::done() diff --git a/intern/cycles/render/tile.h b/intern/cycles/render/tile.h index 76863d23498..b6e610c8d90 100644 --- a/intern/cycles/render/tile.h +++ b/intern/cycles/render/tile.h @@ -41,11 +41,9 @@ public: class TileManager { public: BufferParams params; + struct State { - int full_x; - int full_y; - int width; - int height; + BufferParams buffer; int sample; int resolution; list<Tile> tiles; |