Paul Gofman : wined3d: Implement parallel point lights in process_vertices_strided().

Alexandre Julliard julliard at winehq.org
Tue May 21 16:45:21 CDT 2019


Module: wine
Branch: master
Commit: 9344d58a9ac066db6277e0fded32f5102a2409e8
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=9344d58a9ac066db6277e0fded32f5102a2409e8

Author: Paul Gofman <gofmanp at gmail.com>
Date:   Tue May 21 01:45:38 2019 +0430

wined3d: Implement parallel point lights in process_vertices_strided().

Signed-off-by: Paul Gofman <gofmanp at gmail.com>
Signed-off-by: Henri Verbeet <hverbeet at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/ddraw/tests/ddraw1.c | 22 ++++++++++++++++++++++
 dlls/wined3d/device.c     | 31 +++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+)

diff --git a/dlls/ddraw/tests/ddraw1.c b/dlls/ddraw/tests/ddraw1.c
index ee0b1b4..68428e2 100644
--- a/dlls/ddraw/tests/ddraw1.c
+++ b/dlls/ddraw/tests/ddraw1.c
@@ -6380,6 +6380,14 @@ static void test_specular_lighting(void)
         0.0f, 0.0f, 1.0f,
         M_PI / 12.0f, M_PI / 3.0f
     },
+    parallelpoint =
+    {
+        sizeof(D3DLIGHT2),
+        D3DLIGHT_PARALLELPOINT,
+        {{1.0f}, {1.0f}, {1.0f}, {0.0f}},
+        {{0.5f}, {0.0f}, {-1.0f}},
+        {{0.0f}, {0.0f}, {0.0f}},
+    },
     point_side =
     {
         sizeof(D3DLIGHT2),
@@ -6443,6 +6451,18 @@ static void test_specular_lighting(void)
         {320, 360, 0x00020202},
         {480, 360, 0x00000000},
     },
+    expected_parallelpoint[] =
+    {
+        {160, 120, 0x00050505},
+        {320, 120, 0x002c2c2c},
+        {480, 120, 0x006e6e6e},
+        {160, 240, 0x00090909},
+        {320, 240, 0x00717171},
+        {480, 240, 0x00ffffff},
+        {160, 360, 0x00050505},
+        {320, 360, 0x002c2c2c},
+        {480, 360, 0x006e6e6e},
+    },
     expected_point_far[] =
     {
         {160, 120, 0x00000000},
@@ -6479,11 +6499,13 @@ static void test_specular_lighting(void)
         {&directional, 30.0f, expected_directional_local, ARRAY_SIZE(expected_directional_local)},
         {&point, 30.0f, expected_point_local, ARRAY_SIZE(expected_point_local)},
         {&spot, 30.0f, expected_spot_local, ARRAY_SIZE(expected_spot_local)},
+        {&parallelpoint, 30.0f, expected_parallelpoint, ARRAY_SIZE(expected_parallelpoint)},
         {&point_side, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)},
         {&point_far, 1.0f, expected_point_far, ARRAY_SIZE(expected_point_far)},
         {&directional, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)},
         {&point, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)},
         {&spot, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)},
+        {&parallelpoint, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)},
         {&point_far, 0.0f, expected_zero, ARRAY_SIZE(expected_zero)},
     };
 
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 33aba88..751676b 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -3300,6 +3300,10 @@ static void init_transformed_lights(struct lights_settings *ls,
                     ++ls->spot_light_count;
                     break;
 
+                case WINED3D_LIGHT_PARALLELPOINT:
+                    ++ls->parallel_point_light_count;
+                    break;
+
                 default:
                     FIXME("Unhandled light type %#x.\n", light_info->OriginalParms.type);
                     continue;
@@ -3373,6 +3377,23 @@ static void init_transformed_lights(struct lights_settings *ls,
         light->specular = light_info->OriginalParms.specular;
         ++index;
     }
+
+    for (i = 0; i < light_count; ++i)
+    {
+        light_info = lights[i];
+        if (light_info->OriginalParms.type != WINED3D_LIGHT_PARALLELPOINT)
+            continue;
+
+        light = &ls->lights[index];
+
+        wined3d_vec4_transform(&vec4, &light_info->position, &state->transforms[WINED3D_TS_VIEW]);
+        *(struct wined3d_vec3 *)&light->position = *(struct wined3d_vec3 *)&vec4;
+        wined3d_vec3_normalise((struct wined3d_vec3 *)&light->position);
+        light->diffuse = light_info->OriginalParms.diffuse;
+        light->ambient = light_info->OriginalParms.ambient;
+        light->specular = light_info->OriginalParms.specular;
+        ++index;
+    }
 }
 
 static void update_light_diffuse_specular(struct wined3d_color *diffuse, struct wined3d_color *specular,
@@ -3520,6 +3541,16 @@ static void compute_light(struct wined3d_color *ambient, struct wined3d_color *d
             update_light_diffuse_specular(diffuse, specular, &dir, att, material_shininess,
                     &normal_transformed, &position_transformed_normalised, light, ls);
     }
+
+    for (i = 0; i < ls->parallel_point_light_count; ++i, ++index)
+    {
+        light = &ls->lights[index];
+
+        wined3d_color_rgb_mul_add(ambient, &light->ambient, 1.0f);
+        if (normal)
+            update_light_diffuse_specular(diffuse, specular, (const struct wined3d_vec3 *)&light->position,
+                    1.0f, material_shininess, &normal_transformed, &position_transformed_normalised, light, ls);
+    }
 }
 
 /* Context activation is done by the caller. */




More information about the wine-cvs mailing list