make "tri_shader" an int instead of a float
authorMartijn Berger <mberger@denc.com>
Wed, 24 Sep 2014 11:34:28 +0000 (13:34 +0200)
committerMartijn Berger <mberger@denc.com>
Wed, 24 Sep 2014 11:34:28 +0000 (13:34 +0200)
tri_shader does no longer need to a float.

Reviewers: dingto, sergey

Reviewed By: dingto, sergey

Subscribers: dingto

Projects: #cycles

Differential Revision: https://developer.blender.org/D789

intern/cycles/kernel/geom/geom_bvh_shadow.h
intern/cycles/kernel/geom/geom_motion_triangle.h
intern/cycles/kernel/geom/geom_triangle.h
intern/cycles/kernel/kernel_shader.h
intern/cycles/kernel/kernel_textures.h
intern/cycles/render/mesh.cpp
intern/cycles/render/mesh.h
intern/cycles/render/scene.h

index 1f6e4942fab0fde76ee4ac4f118ae76c2ab938ba..aee4097d77ee877458f693faa86b9babf14bbedd 100644 (file)
@@ -252,7 +252,7 @@ ccl_device bool BVH_FUNCTION_NAME
                                                        if(kernel_tex_fetch(__prim_type, isect_array->prim) & PRIMITIVE_ALL_TRIANGLE)
 #endif
                                                        {
-                                                               shader =  __float_as_int(kernel_tex_fetch(__tri_shader, prim));
+                                                               shader =  kernel_tex_fetch(__tri_shader, prim);
                                                        }
 #ifdef __HAIR__
                                                        else {
index 7409aa0d014986be92e3d2136811428739341cfd..b275b89a8a4ba9fc3c42ee84f4c6f696d5348686 100644 (file)
@@ -233,7 +233,7 @@ ccl_device_inline float3 motion_triangle_refine_subsurface(KernelGlobals *kg, Sh
 ccl_device_noinline void motion_triangle_shader_setup(KernelGlobals *kg, ShaderData *sd, const Intersection *isect, const Ray *ray, bool subsurface)
 {
        /* get shader */
-       sd->shader =  __float_as_int(kernel_tex_fetch(__tri_shader, sd->prim));
+       sd->shader =  kernel_tex_fetch(__tri_shader, sd->prim);
 
        /* get motion info */
        int numsteps, numverts;
index 41e9d183a96853755e022c0fb0b20f8a668cd70b..3d3a5e7248531a474c32e2dacfd689800f73c51d 100644 (file)
@@ -157,7 +157,7 @@ ccl_device_inline void triangle_point_normal(KernelGlobals *kg, int object, int
                *Ng = normalize(cross(v1 - v0, v2 - v0));
 
        /* shader`*/
-       *shader = __float_as_int(kernel_tex_fetch(__tri_shader, prim));
+       *shader = kernel_tex_fetch(__tri_shader, prim);
 }
 
 /* Triangle vertex locations */
index e7c16c1db6e43c165c05176b91c0deb5d144d98e..db08c328d7e9f32d0bcd4682c7287019211db170 100644 (file)
@@ -87,7 +87,7 @@ ccl_device void shader_setup_from_ray(KernelGlobals *kg, ShaderData *sd,
        if(sd->type & PRIMITIVE_TRIANGLE) {
                /* static triangle */
                float3 Ng = triangle_normal(kg, sd);
-               sd->shader =  __float_as_int(kernel_tex_fetch(__tri_shader, sd->prim));
+               sd->shader =  kernel_tex_fetch(__tri_shader, sd->prim);
 
                /* vectors */
                sd->P = triangle_refine(kg, sd, isect, ray);
@@ -166,7 +166,7 @@ ccl_device_inline void shader_setup_from_subsurface(KernelGlobals *kg, ShaderDat
        /* fetch triangle data */
        if(sd->type == PRIMITIVE_TRIANGLE) {
                float3 Ng = triangle_normal(kg, sd);
-               sd->shader =  __float_as_int(kernel_tex_fetch(__tri_shader, sd->prim));
+               sd->shader =  kernel_tex_fetch(__tri_shader, sd->prim);
 
                /* static triangle */
                sd->P = triangle_refine_subsurface(kg, sd, isect, ray);
@@ -1026,7 +1026,7 @@ ccl_device bool shader_transparent_shadow(KernelGlobals *kg, Intersection *isect
 #ifdef __HAIR__
        if(kernel_tex_fetch(__prim_type, isect->prim) & PRIMITIVE_ALL_TRIANGLE) {
 #endif
-               shader = __float_as_int(kernel_tex_fetch(__tri_shader, prim));
+               shader = kernel_tex_fetch(__tri_shader, prim);
 #ifdef __HAIR__
        }
        else {
index f60ed8ccd07cf39a77fea21dd7a969fc1953d53c..ef46b2f707f4ab85645e9981702df4c3a610a584 100644 (file)
@@ -36,7 +36,7 @@ KERNEL_TEX(float4, texture_float4, __objects)
 KERNEL_TEX(float4, texture_float4, __objects_vector)
 
 /* triangles */
-KERNEL_TEX(float, texture_float, __tri_shader)
+KERNEL_TEX(uint, texture_uint, __tri_shader)
 KERNEL_TEX(float4, texture_float4, __tri_vnormal)
 KERNEL_TEX(float4, texture_float4, __tri_vindex)
 KERNEL_TEX(float4, texture_float4, __tri_verts)
index 8299cd02fefd2c42316e8d831fa4d5dcf5ecd05b..5602609c0308182c1ba09cb29900b36fbb521aa4 100644 (file)
@@ -378,12 +378,12 @@ void Mesh::add_vertex_normals()
        }
 }
 
-void Mesh::pack_normals(Scene *scene, float *tri_shader, float4 *vnormal)
+void Mesh::pack_normals(Scene *scene, uint *tri_shader, float4 *vnormal)
 {
        Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
 
        float3 *vN = attr_vN->data_float3();
-       int shader_id = 0;
+       uint shader_id = 0;
        uint last_shader = -1;
        bool last_smooth = false;
 
@@ -401,7 +401,7 @@ void Mesh::pack_normals(Scene *scene, float *tri_shader, float4 *vnormal)
                        shader_id = scene->shader_manager->get_shader_id(last_shader, this, last_smooth);
                }
 
-               tri_shader[i] = __int_as_float(shader_id);
+               tri_shader[i] = shader_id;
        }
 
        size_t verts_size = verts.size();
@@ -936,7 +936,7 @@ void MeshManager::device_update_mesh(Device *device, DeviceScene *dscene, Scene
                /* normals */
                progress.set_status("Updating Mesh", "Computing normals");
 
-               float *tri_shader = dscene->tri_shader.resize(tri_size);
+               uint *tri_shader = dscene->tri_shader.resize(tri_size);
                float4 *vnormal = dscene->tri_vnormal.resize(vert_size);
                float4 *tri_verts = dscene->tri_verts.resize(vert_size);
                float4 *tri_vindex = dscene->tri_vindex.resize(tri_size);
index d45905611fa9b10f8f943f20f41ed18539378cd9..28cee5745eaa536b051e52747daf7af74e47685a 100644 (file)
@@ -123,7 +123,7 @@ public:
        void add_face_normals();
        void add_vertex_normals();
 
-       void pack_normals(Scene *scene, float *shader, float4 *vnormal);
+       void pack_normals(Scene *scene, uint *shader, float4 *vnormal);
        void pack_verts(float4 *tri_verts, float4 *tri_vindex, size_t vert_offset);
        void pack_curves(Scene *scene, float4 *curve_key_co, float4 *curve_data, size_t curvekey_offset);
        void compute_bvh(SceneParams *params, Progress *progress, int n, int total);
index e5c7444c92da18a1e3047ec81ff825b798a13499..5d205225d97f4137d5a82442da5fb12adad640e2 100644 (file)
@@ -69,7 +69,7 @@ public:
        device_vector<uint> prim_object;
 
        /* mesh */
-       device_vector<float> tri_shader;
+       device_vector<uint> tri_shader;
        device_vector<float4> tri_vnormal;
        device_vector<float4> tri_vindex;
        device_vector<float4> tri_verts;