[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [40044] branches/cycles/intern/cycles: Cycles: some warning fixes, cpu device task tweaks, avoid unnecessary
Brecht Van Lommel
brechtvanlommel at pandora.be
Thu Sep 8 20:58:08 CEST 2011
Revision: 40044
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=40044
Author: blendix
Date: 2011-09-08 18:58:07 +0000 (Thu, 08 Sep 2011)
Log Message:
-----------
Cycles: some warning fixes, cpu device task tweaks, avoid unnecessary
tonemap in non-viewport render, and some utility functions.
Modified Paths:
--------------
branches/cycles/intern/cycles/device/device.cpp
branches/cycles/intern/cycles/device/device_cpu.cpp
branches/cycles/intern/cycles/kernel/kernel_types.h
branches/cycles/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h
branches/cycles/intern/cycles/kernel/svm/bsdf_diffuse.h
branches/cycles/intern/cycles/kernel/svm/bsdf_microfacet.h
branches/cycles/intern/cycles/kernel/svm/bsdf_reflection.h
branches/cycles/intern/cycles/kernel/svm/bsdf_refraction.h
branches/cycles/intern/cycles/kernel/svm/bsdf_ward.h
branches/cycles/intern/cycles/kernel/svm/bsdf_westin.h
branches/cycles/intern/cycles/render/session.cpp
branches/cycles/intern/cycles/util/util_cuda.cpp
branches/cycles/intern/cycles/util/util_cuda.h
branches/cycles/intern/cycles/util/util_opencl.h
branches/cycles/intern/cycles/util/util_path.cpp
branches/cycles/intern/cycles/util/util_path.h
branches/cycles/intern/cycles/util/util_system.cpp
branches/cycles/intern/cycles/util/util_system.h
Modified: branches/cycles/intern/cycles/device/device.cpp
===================================================================
--- branches/cycles/intern/cycles/device/device.cpp 2011-09-08 13:22:26 UTC (rev 40043)
+++ branches/cycles/intern/cycles/device/device.cpp 2011-09-08 18:58:07 UTC (rev 40044)
@@ -24,6 +24,7 @@
#include "util_cuda.h"
#include "util_debug.h"
+#include "util_math.h"
#include "util_opencl.h"
#include "util_opengl.h"
#include "util_types.h"
@@ -43,6 +44,8 @@
void DeviceTask::split(ThreadQueue<DeviceTask>& tasks, int num)
{
if(type == DISPLACE) {
+ num = min(displace_w, num);
+
for(int i = 0; i < num; i++) {
int tx = displace_x + (displace_w/num)*i;
int tw = (i == num-1)? displace_w - i*(displace_w/num): displace_w/num;
@@ -56,6 +59,8 @@
}
}
else {
+ num = min(h, num);
+
for(int i = 0; i < num; i++) {
int ty = y + (h/num)*i;
int th = (i == num-1)? h - i*(h/num): h/num;
Modified: branches/cycles/intern/cycles/device/device_cpu.cpp
===================================================================
--- branches/cycles/intern/cycles/device/device_cpu.cpp 2011-09-08 13:22:26 UTC (rev 40043)
+++ branches/cycles/intern/cycles/device/device_cpu.cpp 2011-09-08 18:58:07 UTC (rev 40044)
@@ -194,10 +194,9 @@
void task_add(DeviceTask& task)
{
- if(task.type == DeviceTask::TONEMAP)
- tasks.push(task);
- else
- task.split(tasks, threads.size());
+ /* split task into smaller ones, more than number of threads for uneven
+ workloads where some parts of the image render slower than others */
+ task.split(tasks, threads.size()*10);
}
void task_wait()
Modified: branches/cycles/intern/cycles/kernel/kernel_types.h
===================================================================
--- branches/cycles/intern/cycles/kernel/kernel_types.h 2011-09-08 13:22:26 UTC (rev 40043)
+++ branches/cycles/intern/cycles/kernel/kernel_types.h 2011-09-08 18:58:07 UTC (rev 40044)
@@ -246,7 +246,9 @@
* memory usage, svm_closure_data contains closure parameters. */
ClosureType svm_closure;
float3 svm_closure_weight;
- float svm_closure_data[3]; /* CUDA gives compile error if out of bounds */
+ float svm_closure_data0;
+ float svm_closure_data1;
+ float svm_closure_data2;
#if !defined(__KERNEL_GPU__) && defined(WITH_OSL)
/* OSL closure data and context. we store all closures flattened into
Modified: branches/cycles/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h
===================================================================
--- branches/cycles/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h 2011-09-08 13:22:26 UTC (rev 40043)
+++ branches/cycles/intern/cycles/kernel/svm/bsdf_ashikhmin_velvet.h 2011-09-08 18:58:07 UTC (rev 40044)
@@ -42,15 +42,13 @@
__device void bsdf_ashikhmin_velvet_setup(ShaderData *sd, float3 N, float sigma)
{
- BsdfAshikhminVelvetClosure *self = (BsdfAshikhminVelvetClosure*)sd->svm_closure_data;
-
sigma = fmaxf(sigma, 0.01f);
- //self->m_N = N;
- self->m_invsigma2 = 1.0f/(sigma * sigma);
+ float m_invsigma2 = 1.0f/(sigma * sigma);
sd->svm_closure = CLOSURE_BSDF_ASHIKHMIN_VELVET_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL;
+ sd->svm_closure_data0 = m_invsigma2;
}
__device void bsdf_ashikhmin_velvet_blur(ShaderData *sd, float roughness)
@@ -59,7 +57,7 @@
__device float3 bsdf_ashikhmin_velvet_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfAshikhminVelvetClosure *self = (const BsdfAshikhminVelvetClosure*)sd->svm_closure_data;
+ float m_invsigma2 = sd->svm_closure_data0;
float3 m_N = sd->N;
float cosNO = dot(m_N, I);
@@ -80,7 +78,7 @@
float sinNH4 = sinNH2 * sinNH2;
float cotangent2 = (cosNH * cosNH) / sinNH2;
- float D = expf(-cotangent2 * self->m_invsigma2) * self->m_invsigma2 * M_1_PI_F / sinNH4;
+ float D = expf(-cotangent2 * m_invsigma2) * m_invsigma2 * M_1_PI_F / sinNH4;
float G = min(1.0f, min(fac1, fac2)); // TODO: derive G from D analytically
float out = 0.25f * (D * G) / cosNO;
@@ -103,7 +101,7 @@
__device int bsdf_ashikhmin_velvet_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- const BsdfAshikhminVelvetClosure *self = (const BsdfAshikhminVelvetClosure*)sd->svm_closure_data;
+ float m_invsigma2 = sd->svm_closure_data0;
float3 m_N = sd->N;
// we are viewing the surface from above - send a ray out with uniform
@@ -128,7 +126,7 @@
float sinNH4 = sinNH2 * sinNH2;
float cotangent2 = (cosNH * cosNH) / sinNH2;
- float D = expf(-cotangent2 * self->m_invsigma2) * self->m_invsigma2 * M_1_PI_F / sinNH4;
+ float D = expf(-cotangent2 * m_invsigma2) * m_invsigma2 * M_1_PI_F / sinNH4;
float G = min(1.0f, min(fac1, fac2)); // TODO: derive G from D analytically
float power = 0.25f * (D * G) / cosNO;
Modified: branches/cycles/intern/cycles/kernel/svm/bsdf_diffuse.h
===================================================================
--- branches/cycles/intern/cycles/kernel/svm/bsdf_diffuse.h 2011-09-08 13:22:26 UTC (rev 40043)
+++ branches/cycles/intern/cycles/kernel/svm/bsdf_diffuse.h 2011-09-08 18:58:07 UTC (rev 40044)
@@ -43,9 +43,6 @@
__device void bsdf_diffuse_setup(ShaderData *sd, float3 N)
{
- //BsdfDiffuseClosure *self = (BsdfDiffuseClosure*)sd->svm_closure_data;
- //self->m_N = N;
-
sd->svm_closure = CLOSURE_BSDF_DIFFUSE_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL;
}
@@ -56,7 +53,6 @@
__device float3 bsdf_diffuse_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- //const BsdfDiffuseClosure *self = (const BsdfDiffuseClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
float cos_pi = fmaxf(dot(m_N, omega_in), 0.0f) * M_1_PI_F;
@@ -76,7 +72,6 @@
__device int bsdf_diffuse_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- //const BsdfDiffuseClosure *self = (const BsdfDiffuseClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
// distribution over the hemisphere
@@ -106,9 +101,6 @@
__device void bsdf_translucent_setup(ShaderData *sd, float3 N)
{
- //BsdfTranslucentClosure *self = (BsdfTranslucentClosure*)sd->svm_closure_data;
- //self->m_N = N;
-
sd->svm_closure = CLOSURE_BSDF_TRANSLUCENT_ID;
sd->flag |= SD_BSDF|SD_BSDF_HAS_EVAL;
}
@@ -124,7 +116,6 @@
__device float3 bsdf_translucent_eval_transmit(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- //const BsdfTranslucentClosure *self = (const BsdfTranslucentClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
float cos_pi = fmaxf(-dot(m_N, omega_in), 0.0f) * M_1_PI_F;
@@ -139,7 +130,6 @@
__device int bsdf_translucent_sample(const ShaderData *sd, float randu, float randv, float3 *eval, float3 *omega_in, float3 *domega_in_dx, float3 *domega_in_dy, float *pdf)
{
- //const BsdfTranslucentClosure *self = (const BsdfTranslucentClosure*)sd->svm_closure_data;
float3 m_N = sd->N;
// we are viewing the surface from the right side - send a ray out with cosine
Modified: branches/cycles/intern/cycles/kernel/svm/bsdf_microfacet.h
===================================================================
--- branches/cycles/intern/cycles/kernel/svm/bsdf_microfacet.h 2011-09-08 13:22:26 UTC (rev 40043)
+++ branches/cycles/intern/cycles/kernel/svm/bsdf_microfacet.h 2011-09-08 18:58:07 UTC (rev 40044)
@@ -46,12 +46,13 @@
__device void bsdf_microfacet_ggx_setup(ShaderData *sd, float3 N, float ag, float eta, bool refractive)
{
- BsdfMicrofacetGGXClosure *self = (BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
+ float m_ag = clamp(ag, 1e-5f, 1.0f);
+ float m_eta = eta;
+ int m_refractive = (refractive)? 1: 0;
- //self->m_N = N;
- self->m_ag = clamp(ag, 1e-5f, 1.0f);
- self->m_eta = eta;
- self->m_refractive = (refractive)? 1: 0;
+ sd->svm_closure_data0 = m_ag;
+ sd->svm_closure_data1 = m_eta;
+ sd->svm_closure_data2 = __int_as_float(m_refractive);
if(refractive)
sd->svm_closure = CLOSURE_BSDF_MICROFACET_GGX_REFRACTION_ID;
@@ -63,16 +64,19 @@
__device void bsdf_microfacet_ggx_blur(ShaderData *sd, float roughness)
{
- BsdfMicrofacetGGXClosure *self = (BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
- self->m_ag = fmaxf(roughness, self->m_ag);
+ float m_ag = sd->svm_closure_data0;
+ m_ag = fmaxf(roughness, m_ag);
+ sd->svm_closure_data0 = m_ag;
}
__device float3 bsdf_microfacet_ggx_eval_reflect(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfMicrofacetGGXClosure *self = (const BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
+ float m_ag = sd->svm_closure_data0;
+ //float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
- if(self->m_refractive == 1) return make_float3 (0, 0, 0);
+ if(m_refractive == 1) return make_float3 (0, 0, 0);
float cosNO = dot(m_N, I);
float cosNI = dot(m_N, omega_in);
if(cosNI > 0 && cosNO > 0) {
@@ -80,7 +84,7 @@
float3 Hr = normalize(omega_in + I);
// eq. 20: (F*G*D)/(4*in*on)
// eq. 33: first we calculate D(m) with m=Hr:
- float alpha2 = self->m_ag * self->m_ag;
+ float alpha2 = m_ag * m_ag;
float cosThetaM = dot(m_N, Hr);
float cosThetaM2 = cosThetaM * cosThetaM;
float tanThetaM2 = (1 - cosThetaM2) / cosThetaM2;
@@ -104,22 +108,24 @@
__device float3 bsdf_microfacet_ggx_eval_transmit(const ShaderData *sd, const float3 I, const float3 omega_in, float *pdf)
{
- const BsdfMicrofacetGGXClosure *self = (const BsdfMicrofacetGGXClosure*)sd->svm_closure_data;
+ float m_ag = sd->svm_closure_data0;
+ float m_eta = sd->svm_closure_data1;
+ int m_refractive = __float_as_int(sd->svm_closure_data2);
float3 m_N = sd->N;
- if(self->m_refractive == 0) return make_float3 (0, 0, 0);
+ if(m_refractive == 0) return make_float3 (0, 0, 0);
float cosNO = dot(m_N, I);
float cosNI = dot(m_N, omega_in);
if(cosNO <= 0 || cosNI >= 0)
return make_float3 (0, 0, 0); // vectors on same side -- not possible
// compute half-vector of the refraction (eq. 16)
- float3 ht = -(self->m_eta * omega_in + I);
+ float3 ht = -(m_eta * omega_in + I);
float3 Ht = normalize(ht);
float cosHO = dot(Ht, I);
float cosHI = dot(Ht, omega_in);
// eq. 33: first we calculate D(m) with m=Ht:
- float alpha2 = self->m_ag * self->m_ag;
+ float alpha2 = m_ag * m_ag;
float cosThetaM = dot(m_N, Ht);
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list