summaryrefslogtreecommitdiff
path: root/rtl/gfx
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2023-11-22 01:38:58 -0600
committerAlejandro Soto <alejandro@34project.org>2023-11-22 02:31:52 -0600
commit11231e7173d16415d45f809dc570cba0a2aae0cd (patch)
tree9a2a3e984b7b8e6c2ccc6da1b54d847a020c45ac /rtl/gfx
parent1e064f29139a45061a8082914e9ee75c15e803a4 (diff)
rtl/gfx: implement perspective correction
Diffstat (limited to 'rtl/gfx')
-rw-r--r--rtl/gfx/gfx.sv26
-rw-r--r--rtl/gfx/gfx_persp.sv49
-rw-r--r--rtl/gfx/gfx_persp_vertex.sv52
3 files changed, 123 insertions, 4 deletions
diff --git a/rtl/gfx/gfx.sv b/rtl/gfx/gfx.sv
index 2398826..6bead44 100644
--- a/rtl/gfx/gfx.sv
+++ b/rtl/gfx/gfx.sv
@@ -62,6 +62,24 @@ module gfx
.*
);
+ logic persp_ready, persp_valid;
+ raster_xyzw persp_vertex_a, persp_vertex_b, persp_vertex_c;
+
+ gfx_persp perspective
+ (
+ .in_ready(persp_ready),
+ .in_valid(0), //TODO
+ .out_ready(raster_ready),
+ .out_valid(persp_valid),
+ .in_vertex_a(), //TODO
+ .in_vertex_b(), //TODO
+ .in_vertex_c(), //TODO
+ .out_vertex_a(persp_vertex_a),
+ .out_vertex_b(persp_vertex_b),
+ .out_vertex_c(persp_vertex_c),
+ .*
+ );
+
logic raster_ready;
fixed_tri raster_ws;
bary_lanes barys;
@@ -72,13 +90,13 @@ module gfx
(
.ws(raster_ws),
.in_ready(raster_ready),
- .in_valid(0), //TODO
+ .in_valid(persp_valid),
.out_ready(funnel_ready),
.out_valid(raster_valid),
- .vertex_a(), //TODO
- .vertex_b(), //TODO
- .vertex_c(), //TODO
+ .vertex_a(persp_vertex_a),
+ .vertex_b(persp_vertex_b),
+ .vertex_c(persp_vertex_c),
.*
);
diff --git a/rtl/gfx/gfx_persp.sv b/rtl/gfx/gfx_persp.sv
new file mode 100644
index 0000000..0a75d39
--- /dev/null
+++ b/rtl/gfx/gfx_persp.sv
@@ -0,0 +1,49 @@
+`include "gfx/gfx_defs.sv"
+
+module gfx_persp
+(
+ input logic clk,
+ rst_n,
+
+ input raster_xyzw in_vertex_a,
+ in_vertex_b,
+ in_vertex_c,
+ input logic in_valid,
+ output logic in_ready,
+
+ input logic out_ready,
+ output logic out_valid,
+ output raster_xyzw out_vertex_a,
+ out_vertex_b,
+ out_vertex_c
+);
+
+ logic stall;
+
+ gfx_pipeline_flow #(.STAGES(`FIXED_DIV_STAGES)) flow
+ (
+ .*
+ );
+
+ gfx_persp_vertex persp_a
+ (
+ .in_vertex(in_vertex_a),
+ .out_vertex(out_vertex_a),
+ .*
+ );
+
+ gfx_persp_vertex persp_b
+ (
+ .in_vertex(in_vertex_b),
+ .out_vertex(out_vertex_b),
+ .*
+ );
+
+ gfx_persp_vertex persp_c
+ (
+ .in_vertex(in_vertex_c),
+ .out_vertex(out_vertex_c),
+ .*
+ );
+
+endmodule
diff --git a/rtl/gfx/gfx_persp_vertex.sv b/rtl/gfx/gfx_persp_vertex.sv
new file mode 100644
index 0000000..f7434f0
--- /dev/null
+++ b/rtl/gfx/gfx_persp_vertex.sv
@@ -0,0 +1,52 @@
+`include "gfx/gfx_defs.sv"
+
+module gfx_persp_vertex
+(
+ input logic clk,
+
+ input raster_xyzw in_vertex,
+ input logic stall,
+
+ output raster_xyzw out_vertex
+);
+
+ raster_xyzw skid_vertex;
+
+ gfx_fixed_div x_div
+ (
+ .z(in_vertex.xy.x),
+ .d(in_vertex.zw.w),
+ .q(skid_vertex.xy.x),
+ .*
+ );
+
+ gfx_fixed_div y_div
+ (
+ .z(in_vertex.xy.y),
+ .d(in_vertex.zw.w),
+ .q(skid_vertex.xy.y),
+ .*
+ );
+
+ gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`FIXED_DIV_STAGES)) z_pipes
+ (
+ .in(in_vertex.zw.z),
+ .out(skid_vertex.zw.z),
+ .*
+ );
+
+ gfx_pipes #(.WIDTH($bits(fixed)), .DEPTH(`FIXED_DIV_STAGES)) w_pipes
+ (
+ .in(in_vertex.zw.w),
+ .out(skid_vertex.zw.w),
+ .*
+ );
+
+ gfx_skid_buf #(.WIDTH($bits(out_vertex))) vertex_skid
+ (
+ .in(skid_vertex),
+ .out(out_vertex),
+ .*
+ );
+
+endmodule