History

drm/vmwgfx: Add surface define v4 command

Surface define v4 added new member buffer_byte_stride. With this patch add buffer_byte_stride in surface metadata and create surface using new command if support is available. Also with this patch replace device specific data types with kernel types.

Deepak Rawat committed 7 years ago

Commit 2a50f061 parent 504901d3 files · +43 −7Browse files

Unified · Split

3 files
  1. drivers/gpu/drm/vmwgfx/vmwgfx_drv.h +2 −0
  2. drivers/gpu/drm/vmwgfx/vmwgfx_surface.c +34 −2
  3. include/uapi/drm/vmwgfx_drm.h +7 −5
drivers/gpu/drm/vmwgfx/vmwgfx_drv.h+2−0
@@ -238,6 +238,7 @@ struct vmw_surface_offset; · 237 unmodified lines
238238 * @array_size: Number of array elements for a 1D/2D texture. For cubemap
239239 texture number of faces * array_size. This should be 0 for pre
240240 SM4 device.
241+ * @buffer_byte_stride: Buffer byte stride.
241242 * @num_sizes: Size of @sizes. For GB surface this should always be 1.
242243 * @base_size: Surface dimension.
243244 * @sizes: Array representing mip sizes. Legacy only.
@@ -255,6 +256,7 @@ struct vmw_surface_metadata { · 11 unmodified lines
255256 u32 autogen_filter;
256257 u32 array_size;
257258 u32 num_sizes;
259+ u32 buffer_byte_stride;
258260 struct drm_vmw_size base_size;
259261 struct drm_vmw_size *sizes;
260262 bool scanout;
drivers/gpu/drm/vmwgfx/vmwgfx_surface.c+34−2
@@ -1082,6 +1082,10 @@ static int vmw_gb_surface_create(struct vmw_resource *res) · 1081 unmodified lines
10821082 SVGA3dCmdHeader header;
10831083 SVGA3dCmdDefineGBSurface_v3 body;
10841084 } *cmd3;
1085+ struct {
1086+ SVGA3dCmdHeader header;
1087+ SVGA3dCmdDefineGBSurface_v4 body;
1088+ } *cmd4;
10851089
10861090 if (likely(res->id != -1))
10871091 return 0;
@@ -1098,7 +1102,11 @@ static int vmw_gb_surface_create(struct vmw_resource *res) · 10 unmodified lines
10981102 goto out_no_fifo;
10991103 }
11001104
1101− if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
1105+ if (has_sm5_context(dev_priv) && metadata->array_size > 0) {
1106+ cmd_id = SVGA_3D_CMD_DEFINE_GB_SURFACE_V4;
1107+ cmd_len = sizeof(cmd4->body);
1108+ submit_len = sizeof(*cmd4);
1109+ } else if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
11021110 cmd_id = SVGA_3D_CMD_DEFINE_GB_SURFACE_V3;
11031111 cmd_len = sizeof(cmd3->body);
11041112 submit_len = sizeof(*cmd3);
@@ -1116,12 +1124,29 @@ static int vmw_gb_surface_create(struct vmw_resource *res) · 11 unmodified lines
11161124 cmd = VMW_FIFO_RESERVE(dev_priv, submit_len);
11171125 cmd2 = (typeof(cmd2))cmd;
11181126 cmd3 = (typeof(cmd3))cmd;
1127+ cmd4 = (typeof(cmd4))cmd;
11191128 if (unlikely(!cmd)) {
11201129 ret = -ENOMEM;
11211130 goto out_no_fifo;
11221131 }
11231132
1124− if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
1133+ if (has_sm5_context(dev_priv) && metadata->array_size > 0) {
1134+ cmd4->header.id = cmd_id;
1135+ cmd4->header.size = cmd_len;
1136+ cmd4->body.sid = srf->res.id;
1137+ cmd4->body.surfaceFlags = metadata->flags;
1138+ cmd4->body.format = metadata->format;
1139+ cmd4->body.numMipLevels = metadata->mip_levels[0];
1140+ cmd4->body.multisampleCount = metadata->multisample_count;
1141+ cmd4->body.multisamplePattern = metadata->multisample_pattern;
1142+ cmd4->body.qualityLevel = metadata->quality_level;
1143+ cmd4->body.autogenFilter = metadata->autogen_filter;
1144+ cmd4->body.size.width = metadata->base_size.width;
1145+ cmd4->body.size.height = metadata->base_size.height;
1146+ cmd4->body.size.depth = metadata->base_size.depth;
1147+ cmd4->body.arraySize = metadata->array_size;
1148+ cmd4->body.bufferByteStride = metadata->buffer_byte_stride;
1149+ } else if (has_sm4_1_context(dev_priv) && metadata->array_size > 0) {
11251150 cmd3->header.id = cmd_id;
11261151 cmd3->header.size = cmd_len;
11271152 cmd3->body.sid = srf->res.id;
@@ -1341,6 +1366,7 @@ int vmw_gb_surface_define_ioctl(struct drm_device *dev, void *data, · 213 unmodified lines
13411366 req_ext.svga3d_flags_upper_32_bits = 0;
13421367 req_ext.multisample_pattern = SVGA3D_MS_PATTERN_NONE;
13431368 req_ext.quality_level = SVGA3D_MS_QUALITY_NONE;
1369+ req_ext.buffer_byte_stride = 0;
13441370 req_ext.must_be_zero = 0;
13451371
13461372 return vmw_gb_surface_define_internal(dev, &req_ext, rep, file_priv);
@@ -1467,6 +1493,11 @@ vmw_gb_surface_define_internal(struct drm_device *dev, · 120 unmodified lines
14671493 }
14681494 }
14691495
1496+ if (req->buffer_byte_stride > 0 && !has_sm5_context(dev_priv)) {
1497+ VMW_DEBUG_USER("SM5 surface not supported.\n");
1498+ return -EINVAL;
1499+ }
1500+
14701501 if ((svga3d_flags_64 & SVGA3D_SURFACE_MULTISAMPLE) &&
14711502 req->base.multisample_count == 0) {
14721503 VMW_DEBUG_USER("Invalid sample count.\n");
@@ -1491,6 +1522,7 @@ vmw_gb_surface_define_internal(struct drm_device *dev, · 18 unmodified lines
14911522 metadata.multisample_pattern = req->multisample_pattern;
14921523 metadata.quality_level = req->quality_level;
14931524 metadata.array_size = req->base.array_size;
1525+ metadata.buffer_byte_stride = req->buffer_byte_stride;
14941526 metadata.num_sizes = 1;
14951527 metadata.base_size = req->base.base_size;
14961528 metadata.scanout = req->base.drm_surface_flags &
include/uapi/drm/vmwgfx_drm.h+7−5
@@ -1133,7 +1133,7 @@ struct drm_vmw_handle_close_arg { · 1132 unmodified lines
11331133 * svga3d surface flags split into 2, upper half and lower half.
11341134 */
11351135 enum drm_vmw_surface_version {
1136− drm_vmw_gb_surface_v1
1136+ drm_vmw_gb_surface_v1,
11371137 };
11381138
11391139 /**
@@ -1144,6 +1144,7 @@ enum drm_vmw_surface_version { · 4 unmodified lines
11441144 * @svga3d_flags_upper_32_bits: Upper 32 bits of svga3d flags.
11451145 * @multisample_pattern: Multisampling pattern when msaa is supported.
11461146 * @quality_level: Precision settings for each sample.
1147+ * @buffer_byte_stride: Buffer byte stride.
11471148 * @must_be_zero: Reserved for future usage.
11481149 *
11491150 * Input argument to the DRM_VMW_GB_SURFACE_CREATE_EXT Ioctl.
@@ -1152,10 +1153,11 @@ enum drm_vmw_surface_version { · 2 unmodified lines
11521153 struct drm_vmw_gb_surface_create_ext_req {
11531154 struct drm_vmw_gb_surface_create_req base;
11541155 enum drm_vmw_surface_version version;
1155− uint32_t svga3d_flags_upper_32_bits;
1156− SVGA3dMSPattern multisample_pattern;
1157− SVGA3dMSQualityLevel quality_level;
1158− uint64_t must_be_zero;
1156+ __u32 svga3d_flags_upper_32_bits;
1157+ __u32 multisample_pattern;
1158+ __u32 quality_level;
1159+ __u32 buffer_byte_stride;
1160+ __u32 must_be_zero;
11591161 };
11601162
11611163 /**

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t