Tomas Dougan 2 週間 前
コミット
3a70fb171f
5 ファイル変更17 行追加13 行削除
  1. 17 12
      pipe.c
  2. 0 1
      sr.h
  3. 0 0
      tests/unity.c
  4. 0 0
      tests/unity.h
  5. 0 0
      tests/unity_internals.h

+ 17 - 12
pipe.c

@@ -3,14 +3,13 @@
 #include <string.h>
 
 #include "sr.h"
-#include "rast.h"
-#include "clip.h"
+#include "sr_priv.h"
 
 /**
  * sr_pipe.c
  * --------
  * implementation of the internal graphics pipeline,
- * resembling loosley how its done in hardware
+ * resembling roughly how its done in hardware
  * 
  */
 
@@ -145,7 +144,7 @@ sr_render(struct sr_pipeline* pipe, int* indices,
 {
     /* setup variables */
     
-    struct raster_context rast = {
+    struct raster rast = {
         .fbuf = pipe->fbuf, 
         .uniform = pipe->uniform, 
         .fs = pipe->fs, 
@@ -153,15 +152,20 @@ sr_render(struct sr_pipeline* pipe, int* indices,
         .winding = pipe->winding
     };
 
-    int prim_size = 0;
+    int prim_size, n_prims;
+
+    float* pts_out;
+    float tmp[16 * SR_MAX_ATTRIBUTE_COUNT]; /* holds current face */;
+    uint8_t* clip_flags;
+
+    prim_size = 0;
     split_prim(prim_type, &prim_size);
-    int n_prims = n_indices / prim_size;
+    n_prims = n_indices / prim_size;
 
     /* vertex processing */
     
-    float* pts_out = malloc(pipe->n_pts * pipe->n_attr_out * 
-                            sizeof(float));
-    uint8_t* clip_flags = malloc(pipe->n_pts * sizeof(uint8_t));
+    pts_out = malloc(pipe->n_pts * pipe->n_attr_out * sizeof(float));
+    clip_flags = malloc(pipe->n_pts * sizeof(uint8_t));
 
     for (int i = 0; i < pipe->n_pts; i++) {    /* per point */
 
@@ -174,13 +178,14 @@ sr_render(struct sr_pipeline* pipe, int* indices,
         clip_test(pts_out + i * pipe->n_attr_out, clip_flags + i);
     }
 
-    float tmp[16 * SR_MAX_ATTRIBUTE_COUNT]; /* holds current face */
-
     for (int i = 0; i < n_prims * prim_size; i += prim_size) {
 
         /* primitive assembly */
 
-        uint8_t clip_and = 0, clip_or = 0;
+        uint8_t clip_and, clip_or;
+
+        clip_and = 0;
+        clip_or = 0;
 
         for (int j = 0; j < prim_size; j++) {
             /* fill buffer with primitive data */

+ 0 - 1
sr.h

@@ -74,7 +74,6 @@ enum sr_light_type {
  *                                                                   *
  *********************************************************************/
 
-typedef void (*vs_f)(float* out, float* in, void* uniform);
 typedef void (*fs_f)(uint32_t* out, float* in, void* uniform);
 
 /******************

+ 0 - 0
unity/unity.c → tests/unity.c


+ 0 - 0
unity/unity.h → tests/unity.h


+ 0 - 0
unity/unity_internals.h → tests/unity_internals.h