Code refactor: device memory cleanups, preparing for mapped host memory.

This commit is contained in:
Brecht Van Lommel
2017-11-05 00:34:30 +01:00
parent 5475314f49
commit 5801ef71e4
18 changed files with 152 additions and 140 deletions

View File

@@ -173,8 +173,8 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp
/* Approximate variance as E[x^2] - 1/N * (E[x])^2, since online variance
* update does not work efficiently with atomics in the kernel. */
int mean_offset = offset - components;
float *mean = (float*)buffer.data_pointer + mean_offset;
float *var = (float*)buffer.data_pointer + offset;
float *mean = buffer.data() + mean_offset;
float *var = buffer.data() + offset;
assert(mean_offset >= 0);
if(components == 1) {
@@ -194,7 +194,7 @@ bool RenderBuffers::get_denoising_pass_rect(int offset, float exposure, int samp
}
}
else {
float *in = (float*)buffer.data_pointer + offset;
float *in = buffer.data() + offset;
if(components == 1) {
for(int i = 0; i < size; i++, in += pass_stride, pixels++) {
@@ -228,7 +228,7 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
continue;
}
float *in = (float*)buffer.data_pointer + pass_offset;
float *in = buffer.data() + pass_offset;
int pass_stride = params.get_passes_size();
float scale = (pass.filter)? 1.0f/(float)sample: 1.0f;
@@ -295,7 +295,7 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pass_offset += color_pass.components;
}
float *in_divide = (float*)buffer.data_pointer + pass_offset;
float *in_divide = buffer.data() + pass_offset;
for(int i = 0; i < size; i++, in += pass_stride, in_divide += pass_stride, pixels += 3) {
float3 f = make_float3(in[0], in[1], in[2]);
@@ -344,7 +344,7 @@ bool RenderBuffers::get_pass_rect(PassType type, float exposure, int sample, int
pass_offset += color_pass.components;
}
float *in_weight = (float*)buffer.data_pointer + pass_offset;
float *in_weight = buffer.data() + pass_offset;
for(int i = 0; i < size; i++, in += pass_stride, in_weight += pass_stride, pixels += 4) {
float4 f = make_float4(in[0], in[1], in[2], in[3]);