isl: Add a helper for filling a buffer surface state
authorJason Ekstrand <jason.ekstrand@intel.com>
Tue, 23 Feb 2016 00:48:19 +0000 (16:48 -0800)
committerJason Ekstrand <jason.ekstrand@intel.com>
Sat, 27 Feb 2016 18:26:14 +0000 (10:26 -0800)
src/intel/isl/isl.c
src/intel/isl/isl.h
src/intel/isl/isl_priv.h
src/intel/isl/isl_surface_state.c

index f7f276f16df64f9eb23ebba29f60009222e25d32..f7b4c70184143f981012f362265f05470de493ae 100644 (file)
@@ -1203,6 +1203,29 @@ isl_surf_fill_state_s(const struct isl_device *dev, void *state,
    }
 }
 
+void
+isl_buffer_fill_state_s(const struct isl_device *dev, void *state,
+                        const struct isl_buffer_fill_state_info *restrict info)
+{
+   switch (ISL_DEV_GEN(dev)) {
+   case 7:
+      if (ISL_DEV_IS_HASWELL(dev)) {
+         isl_gen75_buffer_fill_state_s(state, info);
+      } else {
+         isl_gen7_buffer_fill_state_s(state, info);
+      }
+      break;
+   case 8:
+      isl_gen8_buffer_fill_state_s(state, info);
+      break;
+   case 9:
+      isl_gen9_buffer_fill_state_s(state, info);
+      break;
+   default:
+      assert(!"Cannot fill surface state for this gen");
+   }
+}
+
 /**
  * A variant of isl_surf_get_image_offset_sa() specific to
  * ISL_DIM_LAYOUT_GEN4_2D.
index dbd480c51cebde31807d010aac7394ad557240fc..151f1ca27cb5caedcb44d130409c4cd5467a32e2 100644 (file)
@@ -789,6 +789,35 @@ struct isl_surf_fill_state_info {
    union isl_color_value clear_color;
 };
 
+struct isl_buffer_fill_state_info {
+   /**
+    * The address of the surface in GPU memory.
+    */
+   uint64_t address;
+
+   /**
+    * The size of the buffer
+    */
+   uint64_t size;
+
+   /**
+    * The Memory Object Control state for the filled surface state.
+    *
+    * The exact format of this value depends on hardware generation.
+    */
+   uint32_t mocs;
+
+   /**
+    * The format to use in the surface state
+    *
+    * This may differ from the format of the actual isl_surf but have the
+    * same block size.
+    */
+   enum isl_format format;
+
+   uint32_t stride;
+};
+
 extern const struct isl_format_layout isl_format_layouts[];
 
 void
@@ -991,6 +1020,14 @@ void
 isl_surf_fill_state_s(const struct isl_device *dev, void *state,
                       const struct isl_surf_fill_state_info *restrict info);
 
+#define isl_buffer_fill_state(dev, state, ...) \
+   isl_buffer_fill_state_s((dev), (state), \
+                           &(struct isl_buffer_fill_state_info) {  __VA_ARGS__ });
+
+void
+isl_buffer_fill_state_s(const struct isl_device *dev, void *state,
+                        const struct isl_buffer_fill_state_info *restrict info);
+
 /**
  * Alignment of the upper-left sample of each subimage, in units of surface
  * elements.
index d3f08094df9b048abc7992fe9f4394752d04b651..7b222594fd4c0f9ee5efac543b41531a7cfc2fb5 100644 (file)
@@ -152,3 +152,19 @@ isl_gen8_surf_fill_state_s(const struct isl_device *dev, void *state,
 void
 isl_gen9_surf_fill_state_s(const struct isl_device *dev, void *state,
                            const struct isl_surf_fill_state_info *restrict info);
+
+void
+isl_gen7_buffer_fill_state_s(void *state,
+                             const struct isl_buffer_fill_state_info *restrict info);
+
+void
+isl_gen75_buffer_fill_state_s(void *state,
+                              const struct isl_buffer_fill_state_info *restrict info);
+
+void
+isl_gen8_buffer_fill_state_s(void *state,
+                             const struct isl_buffer_fill_state_info *restrict info);
+
+void
+isl_gen9_buffer_fill_state_s(void *state,
+                             const struct isl_buffer_fill_state_info *restrict info);
index fe3c083c574eebb0babef57a750f667918862c84..12f4fb6bd98d3571e050198b02ca5d0b93ed16cc 100644 (file)
@@ -392,3 +392,48 @@ isl_genX(surf_fill_state_s)(const struct isl_device *dev, void *state,
 
    GENX(RENDER_SURFACE_STATE_pack)(NULL, state, &s);
 }
+
+void
+isl_genX(buffer_fill_state_s)(void *state,
+                              const struct isl_buffer_fill_state_info *restrict info)
+{
+   uint32_t num_elements = info->size / info->stride;
+
+   struct GENX(RENDER_SURFACE_STATE) surface_state = {
+      .SurfaceType = SURFTYPE_BUFFER,
+      .SurfaceArray = false,
+      .SurfaceFormat = info->format,
+      .SurfaceVerticalAlignment = isl_to_gen_valign[4],
+      .SurfaceHorizontalAlignment = isl_to_gen_halign[4],
+      .Height = ((num_elements - 1) >> 7) & 0x3fff,
+      .Width = (num_elements - 1) & 0x7f,
+      .Depth = ((num_elements - 1) >> 21) & 0x3f,
+      .SurfacePitch = info->stride - 1,
+      .NumberofMultisamples = MULTISAMPLECOUNT_1,
+
+#if (GEN_GEN >= 8)
+      .TileMode = LINEAR,
+#else
+      .TiledSurface = false,
+#endif
+
+#if (GEN_GEN >= 8)
+      .SamplerL2BypassModeDisable = true,
+      .RenderCacheReadWriteMode = WriteOnlyCache,
+#else
+      .RenderCacheReadWriteMode = 0,
+#endif
+
+      .MOCS = info->mocs,
+
+#if (GEN_GEN >= 8 || GEN_IS_HASWELL)
+      .ShaderChannelSelectRed = SCS_RED,
+      .ShaderChannelSelectGreen = SCS_GREEN,
+      .ShaderChannelSelectBlue = SCS_BLUE,
+      .ShaderChannelSelectAlpha = SCS_ALPHA,
+#endif
+      .SurfaceBaseAddress = info->address,
+   };
+
+   GENX(RENDER_SURFACE_STATE_pack)(NULL, state, &surface_state);
+}