swr: [rasterizer core] implement depth bounds test
[mesa.git] / src / gallium / drivers / swr / rasterizer / core / state.h
index 9fc304a8c3f1b5b3664a0c9f67f0baf6bf3ddd90..93e4565735a45405c518d430c2ad03d49e91b360 100644 (file)
@@ -340,6 +340,8 @@ struct SWR_PS_CONTEXT
     uint32_t primID;            // IN: primitive ID
     uint32_t sampleIndex;       // IN: sampleIndex
 
+    uint32_t rasterizerSampleCount; // IN: sample count used by the rasterizer
+
 };
 
 //////////////////////////////////////////////////////////////////////////
@@ -556,26 +558,35 @@ struct SWR_FETCH_CONTEXT
 /// @brief All statistics generated by SWR go here. These are public
 ///        to driver.
 /////////////////////////////////////////////////////////////////////////
-struct SWR_STATS
+OSALIGNLINE(struct) SWR_STATS
 {
     // Occlusion Query
     uint64_t DepthPassCount; // Number of passing depth tests. Not exact.
 
     // Pipeline Stats
+    uint64_t PsInvocations;  // Number of Pixel Shader invocations
+    uint64_t CsInvocations;  // Number of Compute Shader invocations
+
+};
+
+//////////////////////////////////////////////////////////////////////////
+/// SWR_STATS
+///
+/// @brief All statistics generated by FE.
+/////////////////////////////////////////////////////////////////////////
+OSALIGNLINE(struct) SWR_STATS_FE
+{
     uint64_t IaVertices;    // Number of Fetch Shader vertices
     uint64_t IaPrimitives;  // Number of PA primitives.
     uint64_t VsInvocations; // Number of Vertex Shader invocations
     uint64_t HsInvocations; // Number of Hull Shader invocations
     uint64_t DsInvocations; // Number of Domain Shader invocations
     uint64_t GsInvocations; // Number of Geometry Shader invocations
-    uint64_t PsInvocations; // Number of Pixel Shader invocations
-    uint64_t CsInvocations; // Number of Compute Shader invocations
+    uint64_t GsPrimitives;  // Number of prims GS outputs.
     uint64_t CInvocations;  // Number of clipper invocations
     uint64_t CPrimitives;   // Number of clipper primitives.
-    uint64_t GsPrimitives;  // Number of prims GS outputs.
 
     // Streamout Stats
-    uint32_t SoWriteOffset[4];
     uint64_t SoPrimStorageNeeded[4];
     uint64_t SoNumPrimsWritten[4];
 };
@@ -585,11 +596,13 @@ struct SWR_STATS
 /////////////////////////////////////////////////////////////////////////
 
 #define MAX_SO_STREAMS 4
+#define MAX_SO_BUFFERS 4
 #define MAX_ATTRIBUTES 32
 
 struct SWR_STREAMOUT_BUFFER
 {
     bool enable;
+    bool soWriteEnable;
 
     // Pointers to streamout buffers.
     uint32_t* pBuffer;
@@ -761,7 +774,7 @@ enum SWR_MULTISAMPLE_COUNT
     SWR_MULTISAMPLE_4X,
     SWR_MULTISAMPLE_8X,
     SWR_MULTISAMPLE_16X,
-    SWR_MULTISAMPLE_TYPE_MAX
+    SWR_MULTISAMPLE_TYPE_COUNT
 };
 
 struct SWR_BLEND_STATE
@@ -830,6 +843,19 @@ struct SWR_VIEWPORT_MATRIX
     float m32;
 };
 
+//////////////////////////////////////////////////////////////////////////
+/// VIEWPORT_MATRIXES
+/////////////////////////////////////////////////////////////////////////
+struct SWR_VIEWPORT_MATRICES
+{
+    float m00[KNOB_NUM_VIEWPORTS_SCISSORS];
+    float m11[KNOB_NUM_VIEWPORTS_SCISSORS];
+    float m22[KNOB_NUM_VIEWPORTS_SCISSORS];
+    float m30[KNOB_NUM_VIEWPORTS_SCISSORS];
+    float m31[KNOB_NUM_VIEWPORTS_SCISSORS];
+    float m32[KNOB_NUM_VIEWPORTS_SCISSORS];
+};
+
 //////////////////////////////////////////////////////////////////////////
 /// SWR_VIEWPORT
 /////////////////////////////////////////////////////////////////////////
@@ -872,7 +898,7 @@ enum SWR_MSAA_SAMPLE_PATTERN
 {
     SWR_MSAA_CENTER_PATTERN,
     SWR_MSAA_STANDARD_PATTERN,
-    SWR_MSAA_SAMPLE_PATTERN_MAX
+    SWR_MSAA_SAMPLE_PATTERN_COUNT
 };
 
 enum SWR_PIXEL_LOCATION
@@ -938,13 +964,34 @@ struct SWR_RASTSTATE
     uint8_t clipDistanceMask;
 };
 
+enum SWR_CONSTANT_SOURCE
+{
+    SWR_CONSTANT_SOURCE_CONST_0000,
+    SWR_CONSTANT_SOURCE_CONST_0001_FLOAT,
+    SWR_CONSTANT_SOURCE_CONST_1111_FLOAT,
+    SWR_CONSTANT_SOURCE_PRIM_ID
+};
+
+struct SWR_ATTRIB_SWIZZLE
+{
+    uint16_t sourceAttrib : 5;          // source attribute 
+    uint16_t constantSource : 2;        // constant source to apply
+    uint16_t componentOverrideMask : 4; // override component with constant source
+};
+
 // backend state
 struct SWR_BACKEND_STATE
 {
-    uint32_t constantInterpolationMask;
-    uint32_t pointSpriteTexCoordMask;
-    uint8_t numAttributes;
-    uint8_t numComponents[KNOB_NUM_ATTRIBUTES];
+    uint32_t constantInterpolationMask;     // bitmask indicating which attributes have constant interpolation
+    uint32_t pointSpriteTexCoordMask;       // bitmask indicating the attribute(s) which should be interpreted as tex coordinates
+
+    uint8_t numAttributes;                  // total number of attributes to send to backend (up to 32)
+    uint8_t numComponents[32];              // number of components to setup per attribute, this reduces some calculations for unneeded components
+
+    bool swizzleEnable;                 // when enabled, core will parse the swizzle map when 
+                                        // setting up attributes for the backend, otherwise
+                                        // all attributes up to numAttributes will be sent
+    SWR_ATTRIB_SWIZZLE swizzleMap[32];
 };
 
 
@@ -987,7 +1034,7 @@ enum SWR_SHADING_RATE
 {
     SWR_SHADING_RATE_PIXEL,
     SWR_SHADING_RATE_SAMPLE,
-    SWR_SHADING_RATE_MAX,
+    SWR_SHADING_RATE_COUNT,
 };
 
 enum SWR_INPUT_COVERAGE
@@ -995,7 +1042,7 @@ enum SWR_INPUT_COVERAGE
     SWR_INPUT_COVERAGE_NONE,
     SWR_INPUT_COVERAGE_NORMAL,
     SWR_INPUT_COVERAGE_INNER_CONSERVATIVE,
-    SWR_INPUT_COVERAGE_MAX,
+    SWR_INPUT_COVERAGE_COUNT,
 };
 
 enum SWR_PS_POSITION_OFFSET
@@ -1003,7 +1050,7 @@ enum SWR_PS_POSITION_OFFSET
     SWR_PS_POSITION_SAMPLE_NONE, 
     SWR_PS_POSITION_SAMPLE_OFFSET, 
     SWR_PS_POSITION_CENTROID_OFFSET,
-    SWR_PS_POSITION_OFFSET_MAX,
+    SWR_PS_POSITION_OFFSET_COUNT,
 };
 
 enum SWR_BARYCENTRICS_MASK
@@ -1011,7 +1058,6 @@ enum SWR_BARYCENTRICS_MASK
     SWR_BARYCENTRIC_PER_PIXEL_MASK = 0x1,
     SWR_BARYCENTRIC_CENTROID_MASK = 0x2,
     SWR_BARYCENTRIC_PER_SAMPLE_MASK = 0x4,
-    SWR_BARYCENTRICS_MASK_MAX = 0x8
 };
 
 // pixel shader state
@@ -1033,3 +1079,12 @@ struct SWR_PS_STATE
     uint32_t forceEarlyZ        : 1;    // force execution of early depth/stencil test
 
 };
+
+// depth bounds state
+struct SWR_DEPTH_BOUNDS_STATE
+{
+    bool    depthBoundsTestEnable;
+    float   depthBoundsTestMinValue;
+    float   depthBoundsTestMaxValue;
+};
+