dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Thomas Hellstrom <thellstrom@vmware.com>
To: dri-devel@lists.freedesktop.org
Cc: Thomas Hellstrom <thellstrom@vmware.com>,
	Deepak Rawat <drawat@vmware.com>,
	linux-graphics-maintainer@vmware.com
Subject: [PATCH -next 8/9] drm/vmwgfx: Add support for multisampling
Date: Wed,  4 Jul 2018 17:57:49 +0200	[thread overview]
Message-ID: <20180704155750.2749-9-thellstrom@vmware.com> (raw)
In-Reply-To: <20180704155750.2749-1-thellstrom@vmware.com>

From: Deepak Rawat <drawat@vmware.com>

Support for SVGA3D_SURFACE_MULTISAMPLE and surface mob size according
to sample count.

Signed-off-by: Deepak Rawat <drawat@vmware.com>
Reviewed-by: Sinclair Yeh <syeh@vmware.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
Reviewed-by: Thomas Hellstrom <thellstrom@vmware.com>
Reviewed-by: Charmaine Lee <charmainel@vmware.com>
Signed-off-by: Thomas Hellstrom <thellstrom@vmware.com>
---
 .../device_include/svga3d_surfacedefs.h       | 20 +++++++++++++++++++
 drivers/gpu/drm/vmwgfx/vmwgfx_drv.h           |  2 +-
 drivers/gpu/drm/vmwgfx/vmwgfx_surface.c       | 17 ++++++++++++----
 3 files changed, 34 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h b/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h
index 6422e3899cdf..809a4ec68e89 100644
--- a/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h
+++ b/drivers/gpu/drm/vmwgfx/device_include/svga3d_surfacedefs.h
@@ -1235,6 +1235,26 @@ svga3dsurface_get_serialized_size(SVGA3dSurfaceFormat format,
 	return total_size * num_layers;
 }
 
+/**
+ * svga3dsurface_get_serialized_size_extended - Returns the number of bytes
+ * required for a surface with given parameters. Support for sample count.
+ */
+static inline u32
+svga3dsurface_get_serialized_size_extended(SVGA3dSurfaceFormat format,
+					   surf_size_struct base_level_size,
+					   u32 num_mip_levels,
+					   u32 num_layers,
+					   u32 num_samples)
+{
+	uint64_t total_size =
+		svga3dsurface_get_serialized_size(format,
+						  base_level_size,
+						  num_mip_levels,
+						  num_layers);
+	total_size *= max_t(u32, 1, num_samples);
+
+	return min_t(uint64_t, total_size, (uint64_t)U32_MAX);
+}
 
 /**
  * svga3dsurface_get_pixel_offset - Compute the offset (in bytes) to a pixel
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
index 59af14714797..a67b54e4fd50 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_drv.h
@@ -83,7 +83,7 @@
 struct vmw_fpriv {
 	struct drm_master *locked_master;
 	struct ttm_object_file *tfile;
-	bool gb_aware;
+	bool gb_aware; /* user-space is guest-backed aware */
 };
 
 struct vmw_buffer_object {
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
index 1d4c010a0e48..7636bf2db17e 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
@@ -1399,6 +1399,7 @@ int vmw_surface_gb_priv_define(struct drm_device *dev,
 	struct vmw_surface *srf;
 	int ret;
 	u32 num_layers = 1;
+	u32 sample_count = 1;
 
 	*srf_out = NULL;
 
@@ -1481,11 +1482,15 @@ int vmw_surface_gb_priv_define(struct drm_device *dev,
 	else if (svga3d_flags & SVGA3D_SURFACE_CUBEMAP)
 		num_layers = SVGA3D_MAX_SURFACE_FACES;
 
+	if (srf->flags & SVGA3D_SURFACE_MULTISAMPLE)
+		sample_count = srf->multisample_count;
+
 	srf->res.backup_size   =
-		svga3dsurface_get_serialized_size(srf->format,
-						  srf->base_size,
-						  srf->mip_levels[0],
-						  num_layers);
+		svga3dsurface_get_serialized_size_extended(srf->format,
+							   srf->base_size,
+							   srf->mip_levels[0],
+							   num_layers,
+							   sample_count);
 
 	if (srf->flags & SVGA3D_SURFACE_BIND_STREAM_OUTPUT)
 		srf->res.backup_size += sizeof(SVGA3dDXSOState);
@@ -1595,6 +1600,10 @@ vmw_gb_surface_define_internal(struct drm_device *dev,
 			return -EINVAL;
 	}
 
+	if ((svga3d_flags_64 & SVGA3D_SURFACE_MULTISAMPLE) &&
+	    req->base.multisample_count == 0)
+		return -EINVAL;
+
 	if (req->base.mip_levels > DRM_VMW_MAX_MIP_LEVELS)
 		return -EINVAL;
 
-- 
2.18.0.rc1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2018-07-04 15:58 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 15:57 [PATCH -next 0/9] vmwgfx multisample support Thomas Hellstrom
2018-07-04 15:57 ` [PATCH -next 1/9] drm/vmwgfx: Update the device headers Thomas Hellstrom
2018-07-04 15:57 ` [PATCH -next 2/9] drm/vmwgfx: Add CAP2 support in vmwgfx Thomas Hellstrom
2018-07-04 15:57 ` [PATCH -next 3/9] drm/vmwgfx: Add support for SVGA3dCmdIntraSurfaceCopy command Thomas Hellstrom
2018-07-04 15:57 ` [PATCH -next 4/9] drm/vmwgfx: Add SM4_1 flag Thomas Hellstrom
2018-07-04 15:57 ` [PATCH -next 5/9] drm/vmwgfx: Add support for SVGA3dCmdDefineGBSurface_v3 Thomas Hellstrom
2018-07-04 15:57 ` [PATCH -next 6/9] drm/vmwgfx: Support for SVGA3dSurfaceAllFlags in vmwgfx Thomas Hellstrom
2018-07-04 15:57 ` [PATCH -next 7/9] drm/vmwgfx: Add new ioctl for GB surface create and reference Thomas Hellstrom
2018-07-04 15:57 ` Thomas Hellstrom [this message]
2018-07-04 15:57 ` [PATCH -next 9/9] drm/vmwgfx: Expose SM4_1 param to user space Thomas Hellstrom

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180704155750.2749-9-thellstrom@vmware.com \
    --to=thellstrom@vmware.com \
    --cc=drawat@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-graphics-maintainer@vmware.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox