@@ -1998,7 +1998,7 @@ static int vmw_cmd_set_shader(struct vmw_private *dev_priv,
1998
1998
1999
1999
cmd = container_of (header , typeof (* cmd ), header );
2000
2000
2001
- if (cmd -> body .type >= SVGA3D_SHADERTYPE_PREDX_MAX ) {
2001
+ if (! vmw_shadertype_is_valid ( VMW_SM_LEGACY , cmd -> body .type ) ) {
2002
2002
VMW_DEBUG_USER ("Illegal shader type %u.\n" ,
2003
2003
(unsigned int ) cmd -> body .type );
2004
2004
return - EINVAL ;
@@ -2120,8 +2120,6 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
2120
2120
SVGA3dCmdHeader * header )
2121
2121
{
2122
2122
VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetSingleConstantBuffer );
2123
- SVGA3dShaderType max_shader_num = has_sm5_context (dev_priv ) ?
2124
- SVGA3D_NUM_SHADERTYPE : SVGA3D_NUM_SHADERTYPE_DX10 ;
2125
2123
2126
2124
struct vmw_resource * res = NULL ;
2127
2125
struct vmw_ctx_validation_info * ctx_node = VMW_GET_CTX_NODE (sw_context );
@@ -2138,6 +2136,14 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
2138
2136
if (unlikely (ret != 0 ))
2139
2137
return ret ;
2140
2138
2139
+ if (!vmw_shadertype_is_valid (dev_priv -> sm_type , cmd -> body .type ) ||
2140
+ cmd -> body .slot >= SVGA3D_DX_MAX_CONSTBUFFERS ) {
2141
+ VMW_DEBUG_USER ("Illegal const buffer shader %u slot %u.\n" ,
2142
+ (unsigned int ) cmd -> body .type ,
2143
+ (unsigned int ) cmd -> body .slot );
2144
+ return - EINVAL ;
2145
+ }
2146
+
2141
2147
binding .bi .ctx = ctx_node -> ctx ;
2142
2148
binding .bi .res = res ;
2143
2149
binding .bi .bt = vmw_ctx_binding_cb ;
@@ -2146,14 +2152,6 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
2146
2152
binding .size = cmd -> body .sizeInBytes ;
2147
2153
binding .slot = cmd -> body .slot ;
2148
2154
2149
- if (binding .shader_slot >= max_shader_num ||
2150
- binding .slot >= SVGA3D_DX_MAX_CONSTBUFFERS ) {
2151
- VMW_DEBUG_USER ("Illegal const buffer shader %u slot %u.\n" ,
2152
- (unsigned int ) cmd -> body .type ,
2153
- (unsigned int ) binding .slot );
2154
- return - EINVAL ;
2155
- }
2156
-
2157
2155
vmw_binding_add (ctx_node -> staged , & binding .bi , binding .shader_slot ,
2158
2156
binding .slot );
2159
2157
@@ -2174,15 +2172,13 @@ static int vmw_cmd_dx_set_shader_res(struct vmw_private *dev_priv,
2174
2172
{
2175
2173
VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetShaderResources ) =
2176
2174
container_of (header , typeof (* cmd ), header );
2177
- SVGA3dShaderType max_allowed = has_sm5_context (dev_priv ) ?
2178
- SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX ;
2179
2175
2180
2176
u32 num_sr_view = (cmd -> header .size - sizeof (cmd -> body )) /
2181
2177
sizeof (SVGA3dShaderResourceViewId );
2182
2178
2183
2179
if ((u64 ) cmd -> body .startView + (u64 ) num_sr_view >
2184
2180
(u64 ) SVGA3D_DX_MAX_SRVIEWS ||
2185
- cmd -> body .type >= max_allowed ) {
2181
+ ! vmw_shadertype_is_valid ( dev_priv -> sm_type , cmd -> body .type ) ) {
2186
2182
VMW_DEBUG_USER ("Invalid shader binding.\n" );
2187
2183
return - EINVAL ;
2188
2184
}
@@ -2206,8 +2202,6 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
2206
2202
SVGA3dCmdHeader * header )
2207
2203
{
2208
2204
VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetShader );
2209
- SVGA3dShaderType max_allowed = has_sm5_context (dev_priv ) ?
2210
- SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX ;
2211
2205
struct vmw_resource * res = NULL ;
2212
2206
struct vmw_ctx_validation_info * ctx_node = VMW_GET_CTX_NODE (sw_context );
2213
2207
struct vmw_ctx_bindinfo_shader binding ;
@@ -2218,8 +2212,7 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
2218
2212
2219
2213
cmd = container_of (header , typeof (* cmd ), header );
2220
2214
2221
- if (cmd -> body .type >= max_allowed ||
2222
- cmd -> body .type < SVGA3D_SHADERTYPE_MIN ) {
2215
+ if (!vmw_shadertype_is_valid (dev_priv -> sm_type , cmd -> body .type )) {
2223
2216
VMW_DEBUG_USER ("Illegal shader type %u.\n" ,
2224
2217
(unsigned int ) cmd -> body .type );
2225
2218
return - EINVAL ;
0 commit comments