d3d1x: add untested support for geometry shader translation
authorLuca Barbieri <luca@luca-barbieri.com>
Thu, 23 Sep 2010 16:03:34 +0000 (18:03 +0200)
committerLuca Barbieri <luca@luca-barbieri.com>
Fri, 24 Sep 2010 07:15:49 +0000 (09:15 +0200)
src/gallium/state_trackers/d3d1x/d3d1xstutil/include/d3d1xstutil.h
src/gallium/state_trackers/d3d1x/d3d1xstutil/src/d3d_sm4_enums.cpp [new file with mode: 0644]
src/gallium/state_trackers/d3d1x/gd3d1x/d3d1x_private.h
src/gallium/state_trackers/d3d1x/gd3d1x/d3d_enums.cpp
src/gallium/state_trackers/d3d1x/gd3d1x/sm4_to_tgsi.cpp

index 313aa10a37750c52369dc359b3459d32e67936ac..2b613b82d118a608782617f3995ab3457be978ad 100644 (file)
@@ -62,6 +62,12 @@ extern "C"
 #undef max
 #endif
 
+#define D3D_PRIMITIVE_TOPOLOGY_COUNT 65
+extern unsigned d3d_to_pipe_prim[D3D_PRIMITIVE_TOPOLOGY_COUNT];
+
+#define D3D_PRIMITIVE_COUNT 40
+extern unsigned d3d_to_pipe_prim_type[D3D_PRIMITIVE_COUNT];
+
 /* NOTE: this _depends_ on the vtable layout of the C++ compiler to be
  * binary compatible with Windows.
  * Furthermore some absurd vtable layout likely won't work at all, since
diff --git a/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/d3d_sm4_enums.cpp b/src/gallium/state_trackers/d3d1x/d3d1xstutil/src/d3d_sm4_enums.cpp
new file mode 100644 (file)
index 0000000..410a56c
--- /dev/null
@@ -0,0 +1,42 @@
+#include "d3d1xstutil.h"
+
+unsigned d3d_to_pipe_prim[D3D_PRIMITIVE_TOPOLOGY_COUNT] =
+{
+       0,
+       PIPE_PRIM_POINTS,
+       PIPE_PRIM_LINES,
+       PIPE_PRIM_LINE_STRIP,
+       PIPE_PRIM_TRIANGLES,
+       PIPE_PRIM_TRIANGLE_STRIP,
+       PIPE_PRIM_LINES_ADJACENCY,
+       PIPE_PRIM_LINE_STRIP_ADJACENCY,
+       PIPE_PRIM_TRIANGLES_ADJACENCY,
+       PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY,
+       /* gap */
+       0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0,
+       /* patches */
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+unsigned d3d_to_pipe_prim_type[D3D_PRIMITIVE_COUNT] =
+{
+       0,
+       PIPE_PRIM_POINTS,
+       PIPE_PRIM_LINES,
+       PIPE_PRIM_TRIANGLES,
+       0,
+       PIPE_PRIM_POINTS,
+       PIPE_PRIM_LINES_ADJACENCY,
+       PIPE_PRIM_TRIANGLES_ADJACENCY,
+       /* patches */
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+       0, 0, 0, 0, 0, 0, 0, 0,
+};
index d4b6a8fc957e36e995c4c41596e312573a9f8adc..977f0cd2cea7d3a236c51d8f840a1e81b4ed1fd8 100644 (file)
@@ -92,7 +92,4 @@ extern unsigned d3d11_to_pipe_wrap[D3D11_TEXTURE_ADDRESS_COUNT];
 extern unsigned d3d11_to_pipe_query[D3D11_QUERY_COUNT];
 extern unsigned d3d11_query_size[D3D11_QUERY_COUNT];
 
-#define D3D_PRIMITIVE_TOPOLOGY_COUNT 65
-extern unsigned d3d_to_pipe_prim[D3D_PRIMITIVE_TOPOLOGY_COUNT];
-
 #endif /* D3D1X_H_ */
index 37113a6ec91895d86af16219d68c1913a681575d..853d11410df5cc0ba976cf1de79cf5a25856d34d 100644 (file)
@@ -121,27 +121,3 @@ unsigned d3d11_query_size[D3D11_QUERY_COUNT] =
                0,
                0
 };
-
-unsigned d3d_to_pipe_prim[D3D_PRIMITIVE_TOPOLOGY_COUNT] =
-{
-       0,
-       PIPE_PRIM_POINTS,
-       PIPE_PRIM_LINES,
-       PIPE_PRIM_LINE_STRIP,
-       PIPE_PRIM_TRIANGLES,
-       PIPE_PRIM_TRIANGLE_STRIP,
-       PIPE_PRIM_LINES_ADJACENCY,
-       PIPE_PRIM_LINE_STRIP_ADJACENCY,
-       PIPE_PRIM_TRIANGLES_ADJACENCY,
-       PIPE_PRIM_TRIANGLE_STRIP_ADJACENCY,
-       /* gap */
-       0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0,
-       /* patches */
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0,
-};
index 4b43a3325ca3f5dfd318c7789f880318b0c5f604..7d03cecafc0a1cae42c71d7ba010e4839db35c2c 100644 (file)
@@ -24,6 +24,7 @@
  *
  **************************************************************************/
 
+#include "d3d1xstutil.h"
 #include "sm4.h"
 #include "tgsi/tgsi_ureg.h"
 #include <vector>
@@ -137,9 +138,16 @@ struct sm4_to_tgsi_converter
                        s = ureg_imm4f(ureg, op.imm_values[0].f32, op.imm_values[1].f32, op.imm_values[2].f32, op.imm_values[3].f32);
                        break;
                case SM4_FILE_INPUT:
-                       check(op.has_simple_index());
-                       check(op.indices[0].disp < inputs.size());
-                       s = inputs[op.indices[0].disp];
+                       check(op.is_index_simple(0));
+                       check(op.num_indices == 1 || op.num_indices == 2);
+                       // TODO: is this correct, or are incorrectly swapping the two indices in the GS case?
+                       check(op.indices[op.num_indices - 1].disp < inputs.size());
+                       s = inputs[op.indices[op.num_indices - 1].disp];
+                       if(op.num_indices == 2)
+                       {
+                               s.Dimension = 1;
+                               s.DimensionIndex = op.indices[0].disp;
+                       }
                        break;
                case SM4_FILE_CONSTANT_BUFFER:
                        // TODO: indirect addressing
@@ -700,7 +708,7 @@ next:;
                {
                        sm4_dcl& dcl = *program.dcls[insn_num];
                        int idx = -1;
-                       if(dcl.op.get() && dcl.op->has_simple_index())
+                       if(dcl.op.get() && dcl.op->is_index_simple(0))
                                idx = dcl.op->indices[0].disp;
                        switch(dcl.opcode)
                        {
@@ -716,6 +724,12 @@ next:;
                                        inputs.resize(idx + 1);
                                if(processor == TGSI_PROCESSOR_VERTEX)
                                        inputs[idx] = ureg_DECL_vs_input(ureg, idx);
+                               else if(processor == TGSI_PROCESSOR_GEOMETRY)
+                               {
+                                       // TODO: is this correct?
+                                       unsigned gsidx = dcl.op->indices[1].disp;
+                                       inputs[gsidx] = ureg_DECL_gs_input(ureg, gsidx, TGSI_SEMANTIC_GENERIC, gsidx);
+                               }
                                else
                                        check(0);
                                break;
@@ -792,6 +806,15 @@ next:;
                                idx = dcl.op->indices[0].disp;
                                ureg_DECL_constant2D(ureg, 0, (unsigned)dcl.op->indices[1].disp - 1, idx);
                                break;
+                       case SM4_OPCODE_DCL_GS_INPUT_PRIMITIVE:
+                               ureg_property_gs_input_prim(ureg, d3d_to_pipe_prim_type[dcl.dcl_gs_input_primitive.primitive]);
+                               break;
+                       case SM4_OPCODE_DCL_GS_OUTPUT_PRIMITIVE_TOPOLOGY:
+                               ureg_property_gs_output_prim(ureg, d3d_to_pipe_prim[dcl.dcl_gs_output_primitive_topology.primitive_topology]);
+                               break;
+                       case SM4_OPCODE_DCL_MAX_OUTPUT_VERTEX_COUNT:
+                               ureg_property_gs_max_vertices(ureg, dcl.num);
+                               break;
                        default:
                                check(0);
                        }