drm/vmwgfx: Support SM5 shader type in command buffer
authorDeepak Rawat <drawat.floss@gmail.com>
Thu, 13 Dec 2018 21:43:20 +0000 (13:43 -0800)
committerRoland Scheidegger <sroland@vmware.com>
Mon, 23 Mar 2020 21:39:34 +0000 (22:39 +0100)
Virtual device now supports new shader types, allow them as valid shader
type in command buffer. Also add per shader bind info in binding manager
state for new shader type.

Signed-off-by: Deepak Rawat <drawat.floss@gmail.com>
Reviewed-by: Thomas Hellström (VMware) <thomas_os@shipmail.org>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Signed-off-by: Roland Scheidegger <sroland@vmware.com>
drivers/gpu/drm/vmwgfx/vmwgfx_binding.c
drivers/gpu/drm/vmwgfx/vmwgfx_execbuf.c

index 66e14e3..5a7e8db 100644 (file)
@@ -98,7 +98,7 @@ struct vmw_ctx_binding_state {
        struct vmw_ctx_bindinfo_so so_targets[SVGA3D_DX_MAX_SOTARGETS];
        struct vmw_ctx_bindinfo_vb vertex_buffers[SVGA3D_DX_MAX_VERTEXBUFFERS];
        struct vmw_ctx_bindinfo_ib index_buffer;
-       struct vmw_dx_shader_bindings per_shader[SVGA3D_NUM_SHADERTYPE_DX10];
+       struct vmw_dx_shader_bindings per_shader[SVGA3D_NUM_SHADERTYPE];
 
        unsigned long dirty;
        DECLARE_BITMAP(dirty_vb, SVGA3D_DX_MAX_VERTEXBUFFERS);
@@ -151,6 +151,9 @@ static const size_t vmw_binding_shader_offsets[] = {
        offsetof(struct vmw_ctx_binding_state, per_shader[0].shader),
        offsetof(struct vmw_ctx_binding_state, per_shader[1].shader),
        offsetof(struct vmw_ctx_binding_state, per_shader[2].shader),
+       offsetof(struct vmw_ctx_binding_state, per_shader[3].shader),
+       offsetof(struct vmw_ctx_binding_state, per_shader[4].shader),
+       offsetof(struct vmw_ctx_binding_state, per_shader[5].shader),
 };
 static const size_t vmw_binding_rt_offsets[] = {
        offsetof(struct vmw_ctx_binding_state, render_targets),
@@ -162,6 +165,9 @@ static const size_t vmw_binding_cb_offsets[] = {
        offsetof(struct vmw_ctx_binding_state, per_shader[0].const_buffers),
        offsetof(struct vmw_ctx_binding_state, per_shader[1].const_buffers),
        offsetof(struct vmw_ctx_binding_state, per_shader[2].const_buffers),
+       offsetof(struct vmw_ctx_binding_state, per_shader[3].const_buffers),
+       offsetof(struct vmw_ctx_binding_state, per_shader[4].const_buffers),
+       offsetof(struct vmw_ctx_binding_state, per_shader[5].const_buffers),
 };
 static const size_t vmw_binding_dx_ds_offsets[] = {
        offsetof(struct vmw_ctx_binding_state, ds_view),
@@ -170,6 +176,9 @@ static const size_t vmw_binding_sr_offsets[] = {
        offsetof(struct vmw_ctx_binding_state, per_shader[0].shader_res),
        offsetof(struct vmw_ctx_binding_state, per_shader[1].shader_res),
        offsetof(struct vmw_ctx_binding_state, per_shader[2].shader_res),
+       offsetof(struct vmw_ctx_binding_state, per_shader[3].shader_res),
+       offsetof(struct vmw_ctx_binding_state, per_shader[4].shader_res),
+       offsetof(struct vmw_ctx_binding_state, per_shader[5].shader_res),
 };
 static const size_t vmw_binding_so_offsets[] = {
        offsetof(struct vmw_ctx_binding_state, so_targets),
index 73f19f0..4abed13 100644 (file)
@@ -2118,6 +2118,9 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
                                      SVGA3dCmdHeader *header)
 {
        VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetSingleConstantBuffer);
+       SVGA3dShaderType max_shader_num = has_sm5_context(dev_priv) ?
+               SVGA3D_NUM_SHADERTYPE : SVGA3D_NUM_SHADERTYPE_DX10;
+
        struct vmw_resource *res = NULL;
        struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context);
        struct vmw_ctx_bindinfo_cb binding;
@@ -2141,7 +2144,7 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
        binding.size = cmd->body.sizeInBytes;
        binding.slot = cmd->body.slot;
 
-       if (binding.shader_slot >= SVGA3D_NUM_SHADERTYPE_DX10 ||
+       if (binding.shader_slot >= max_shader_num ||
            binding.slot >= SVGA3D_DX_MAX_CONSTBUFFERS) {
                VMW_DEBUG_USER("Illegal const buffer shader %u slot %u.\n",
                               (unsigned int) cmd->body.type,
@@ -2169,12 +2172,15 @@ static int vmw_cmd_dx_set_shader_res(struct vmw_private *dev_priv,
 {
        VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetShaderResources) =
                container_of(header, typeof(*cmd), header);
+       SVGA3dShaderType max_allowed = has_sm5_context(dev_priv) ?
+               SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX;
+
        u32 num_sr_view = (cmd->header.size - sizeof(cmd->body)) /
                sizeof(SVGA3dShaderResourceViewId);
 
        if ((u64) cmd->body.startView + (u64) num_sr_view >
            (u64) SVGA3D_DX_MAX_SRVIEWS ||
-           cmd->body.type >= SVGA3D_SHADERTYPE_DX10_MAX) {
+           cmd->body.type >= max_allowed) {
                VMW_DEBUG_USER("Invalid shader binding.\n");
                return -EINVAL;
        }
@@ -2198,6 +2204,8 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
                                 SVGA3dCmdHeader *header)
 {
        VMW_DECLARE_CMD_VAR(*cmd, SVGA3dCmdDXSetShader);
+       SVGA3dShaderType max_allowed = has_sm5_context(dev_priv) ?
+               SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX;
        struct vmw_resource *res = NULL;
        struct vmw_ctx_validation_info *ctx_node = VMW_GET_CTX_NODE(sw_context);
        struct vmw_ctx_bindinfo_shader binding;
@@ -2208,7 +2216,7 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
 
        cmd = container_of(header, typeof(*cmd), header);
 
-       if (cmd->body.type >= SVGA3D_SHADERTYPE_DX10_MAX ||
+       if (cmd->body.type >= max_allowed ||
            cmd->body.type < SVGA3D_SHADERTYPE_MIN) {
                VMW_DEBUG_USER("Illegal shader type %u.\n",
                               (unsigned int) cmd->body.type);