@@ -1992,7 +1992,7 @@ static int vmw_cmd_set_shader(struct vmw_private *dev_priv,
1992
1992
1993
1993
cmd = container_of (header , typeof (* cmd ), header );
1994
1994
1995
- if (cmd -> body .type >= SVGA3D_SHADERTYPE_PREDX_MAX ) {
1995
+ if (! vmw_shadertype_is_valid ( VMW_SM_LEGACY , cmd -> body .type ) ) {
1996
1996
VMW_DEBUG_USER ("Illegal shader type %u.\n" ,
1997
1997
(unsigned int ) cmd -> body .type );
1998
1998
return - EINVAL ;
@@ -2115,8 +2115,6 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
2115
2115
SVGA3dCmdHeader * header )
2116
2116
{
2117
2117
VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetSingleConstantBuffer );
2118
- SVGA3dShaderType max_shader_num = has_sm5_context (dev_priv ) ?
2119
- SVGA3D_NUM_SHADERTYPE : SVGA3D_NUM_SHADERTYPE_DX10 ;
2120
2118
2121
2119
struct vmw_resource * res = NULL ;
2122
2120
struct vmw_ctx_validation_info * ctx_node = VMW_GET_CTX_NODE (sw_context );
@@ -2133,6 +2131,14 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
2133
2131
if (unlikely (ret != 0 ))
2134
2132
return ret ;
2135
2133
2134
+ if (!vmw_shadertype_is_valid (dev_priv -> sm_type , cmd -> body .type ) ||
2135
+ cmd -> body .slot >= SVGA3D_DX_MAX_CONSTBUFFERS ) {
2136
+ VMW_DEBUG_USER ("Illegal const buffer shader %u slot %u.\n" ,
2137
+ (unsigned int ) cmd -> body .type ,
2138
+ (unsigned int ) cmd -> body .slot );
2139
+ return - EINVAL ;
2140
+ }
2141
+
2136
2142
binding .bi .ctx = ctx_node -> ctx ;
2137
2143
binding .bi .res = res ;
2138
2144
binding .bi .bt = vmw_ctx_binding_cb ;
@@ -2141,14 +2147,6 @@ vmw_cmd_dx_set_single_constant_buffer(struct vmw_private *dev_priv,
2141
2147
binding .size = cmd -> body .sizeInBytes ;
2142
2148
binding .slot = cmd -> body .slot ;
2143
2149
2144
- if (binding .shader_slot >= max_shader_num ||
2145
- binding .slot >= SVGA3D_DX_MAX_CONSTBUFFERS ) {
2146
- VMW_DEBUG_USER ("Illegal const buffer shader %u slot %u.\n" ,
2147
- (unsigned int ) cmd -> body .type ,
2148
- (unsigned int ) binding .slot );
2149
- return - EINVAL ;
2150
- }
2151
-
2152
2150
vmw_binding_add (ctx_node -> staged , & binding .bi , binding .shader_slot ,
2153
2151
binding .slot );
2154
2152
@@ -2207,15 +2205,13 @@ static int vmw_cmd_dx_set_shader_res(struct vmw_private *dev_priv,
2207
2205
{
2208
2206
VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetShaderResources ) =
2209
2207
container_of (header , typeof (* cmd ), header );
2210
- SVGA3dShaderType max_allowed = has_sm5_context (dev_priv ) ?
2211
- SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX ;
2212
2208
2213
2209
u32 num_sr_view = (cmd -> header .size - sizeof (cmd -> body )) /
2214
2210
sizeof (SVGA3dShaderResourceViewId );
2215
2211
2216
2212
if ((u64 ) cmd -> body .startView + (u64 ) num_sr_view >
2217
2213
(u64 ) SVGA3D_DX_MAX_SRVIEWS ||
2218
- cmd -> body .type >= max_allowed ) {
2214
+ ! vmw_shadertype_is_valid ( dev_priv -> sm_type , cmd -> body .type ) ) {
2219
2215
VMW_DEBUG_USER ("Invalid shader binding.\n" );
2220
2216
return - EINVAL ;
2221
2217
}
@@ -2239,8 +2235,6 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
2239
2235
SVGA3dCmdHeader * header )
2240
2236
{
2241
2237
VMW_DECLARE_CMD_VAR (* cmd , SVGA3dCmdDXSetShader );
2242
- SVGA3dShaderType max_allowed = has_sm5_context (dev_priv ) ?
2243
- SVGA3D_SHADERTYPE_MAX : SVGA3D_SHADERTYPE_DX10_MAX ;
2244
2238
struct vmw_resource * res = NULL ;
2245
2239
struct vmw_ctx_validation_info * ctx_node = VMW_GET_CTX_NODE (sw_context );
2246
2240
struct vmw_ctx_bindinfo_shader binding ;
@@ -2251,8 +2245,7 @@ static int vmw_cmd_dx_set_shader(struct vmw_private *dev_priv,
2251
2245
2252
2246
cmd = container_of (header , typeof (* cmd ), header );
2253
2247
2254
- if (cmd -> body .type >= max_allowed ||
2255
- cmd -> body .type < SVGA3D_SHADERTYPE_MIN ) {
2248
+ if (!vmw_shadertype_is_valid (dev_priv -> sm_type , cmd -> body .type )) {
2256
2249
VMW_DEBUG_USER ("Illegal shader type %u.\n" ,
2257
2250
(unsigned int ) cmd -> body .type );
2258
2251
return - EINVAL ;
0 commit comments