svga: Add function svga_resource_type()
authorNeha Bhende <bhenden@vmware.com>
Thu, 1 Sep 2016 16:40:43 +0000 (09:40 -0700)
committerBrian Paul <brianp@vmware.com>
Sat, 17 Sep 2016 16:08:59 +0000 (10:08 -0600)
This function returns svga texture type for corresponding pipe texture.

Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/drivers/svga/svga_surface.c
src/gallium/drivers/svga/svga_surface.h

index f6a791332c919c71db235374c8794e912d9d7b4c..81b0f48e53e52fee0e933da9431d8c8af8a48e8e 100644 (file)
@@ -442,25 +442,7 @@ svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s)
 
       s->view_id = util_bitmask_add(svga->surface_view_id_bm);
 
-      switch (s->base.texture->target) {
-      case PIPE_TEXTURE_1D:
-      case PIPE_TEXTURE_1D_ARRAY:
-         resType = SVGA3D_RESOURCE_TEXTURE1D;
-         break;
-      case PIPE_TEXTURE_RECT:
-      case PIPE_TEXTURE_2D:
-      case PIPE_TEXTURE_2D_ARRAY:
-      case PIPE_TEXTURE_CUBE:
-         /* drawing to cube map is treated as drawing to 2D array */
-         resType = SVGA3D_RESOURCE_TEXTURE2D;
-         break;
-      case PIPE_TEXTURE_3D:
-         resType = SVGA3D_RESOURCE_TEXTURE3D;
-         break;
-      default:
-         assert(!"Unexpected texture target");
-         resType = SVGA3D_RESOURCE_TEXTURE2D;
-      }
+      resType = svga_resource_type(s->base.texture->target);
 
       if (util_format_is_depth_or_stencil(s->base.format)) {
          ret = SVGA3D_vgpu10_DefineDepthStencilView(svga->swc,
index ed9f37a74a68541c19a7b24f79ecf432e6c68790..18cb9c1869d9844d86c4e5592a22590ec678d33b 100644 (file)
@@ -125,5 +125,25 @@ svga_surface_const(const struct pipe_surface *surface)
 struct pipe_surface *
 svga_validate_surface_view(struct svga_context *svga, struct svga_surface *s);
 
+static inline SVGA3dResourceType
+svga_resource_type(enum pipe_texture_target target)
+{
+   switch (target) {
+   case PIPE_TEXTURE_1D:
+   case PIPE_TEXTURE_1D_ARRAY:
+      return SVGA3D_RESOURCE_TEXTURE1D;
+   case PIPE_TEXTURE_RECT:
+   case PIPE_TEXTURE_2D:
+   case PIPE_TEXTURE_2D_ARRAY:
+   case PIPE_TEXTURE_CUBE:
+      /* drawing to cube map is treated as drawing to 2D array */
+      return SVGA3D_RESOURCE_TEXTURE2D;
+   case PIPE_TEXTURE_3D:
+      return SVGA3D_RESOURCE_TEXTURE3D;
+   default:
+      assert(!"Unexpected texture target");
+      return SVGA3D_RESOURCE_TEXTURE2D;
+   }
+}
 
 #endif