@@ -499,12 +499,9 @@ static int vmw_binding_scrub_shader(struct vmw_ctx_bindinfo *bi, bool rebind)
499499 SVGA3dCmdSetShader body ;
500500 } * cmd ;
501501
502- cmd = vmw_fifo_reserve (dev_priv , sizeof (* cmd ));
503- if (unlikely (cmd == NULL )) {
504- DRM_ERROR ("Failed reserving FIFO space for shader "
505- "unbinding.\n" );
502+ cmd = VMW_FIFO_RESERVE (dev_priv , sizeof (* cmd ));
503+ if (unlikely (cmd == NULL ))
506504 return - ENOMEM ;
507- }
508505
509506 cmd -> header .id = SVGA_3D_CMD_SET_SHADER ;
510507 cmd -> header .size = sizeof (cmd -> body );
@@ -534,12 +531,9 @@ static int vmw_binding_scrub_render_target(struct vmw_ctx_bindinfo *bi,
534531 SVGA3dCmdSetRenderTarget body ;
535532 } * cmd ;
536533
537- cmd = vmw_fifo_reserve (dev_priv , sizeof (* cmd ));
538- if (unlikely (cmd == NULL )) {
539- DRM_ERROR ("Failed reserving FIFO space for render target "
540- "unbinding.\n" );
534+ cmd = VMW_FIFO_RESERVE (dev_priv , sizeof (* cmd ));
535+ if (unlikely (cmd == NULL ))
541536 return - ENOMEM ;
542- }
543537
544538 cmd -> header .id = SVGA_3D_CMD_SETRENDERTARGET ;
545539 cmd -> header .size = sizeof (cmd -> body );
@@ -576,12 +570,9 @@ static int vmw_binding_scrub_texture(struct vmw_ctx_bindinfo *bi,
576570 } body ;
577571 } * cmd ;
578572
579- cmd = vmw_fifo_reserve (dev_priv , sizeof (* cmd ));
580- if (unlikely (cmd == NULL )) {
581- DRM_ERROR ("Failed reserving FIFO space for texture "
582- "unbinding.\n" );
573+ cmd = VMW_FIFO_RESERVE (dev_priv , sizeof (* cmd ));
574+ if (unlikely (cmd == NULL ))
583575 return - ENOMEM ;
584- }
585576
586577 cmd -> header .id = SVGA_3D_CMD_SETTEXTURESTATE ;
587578 cmd -> header .size = sizeof (cmd -> body );
@@ -610,12 +601,10 @@ static int vmw_binding_scrub_dx_shader(struct vmw_ctx_bindinfo *bi, bool rebind)
610601 SVGA3dCmdDXSetShader body ;
611602 } * cmd ;
612603
613- cmd = vmw_fifo_reserve_dx (dev_priv , sizeof (* cmd ), bi -> ctx -> id );
614- if (unlikely (cmd == NULL )) {
615- DRM_ERROR ("Failed reserving FIFO space for DX shader "
616- "unbinding.\n" );
604+ cmd = VMW_FIFO_RESERVE_DX (dev_priv , sizeof (* cmd ), bi -> ctx -> id );
605+ if (unlikely (cmd == NULL ))
617606 return - ENOMEM ;
618- }
607+
619608 cmd -> header .id = SVGA_3D_CMD_DX_SET_SHADER ;
620609 cmd -> header .size = sizeof (cmd -> body );
621610 cmd -> body .type = binding -> shader_slot + SVGA3D_SHADERTYPE_MIN ;
@@ -641,12 +630,9 @@ static int vmw_binding_scrub_cb(struct vmw_ctx_bindinfo *bi, bool rebind)
641630 SVGA3dCmdDXSetSingleConstantBuffer body ;
642631 } * cmd ;
643632
644- cmd = vmw_fifo_reserve_dx (dev_priv , sizeof (* cmd ), bi -> ctx -> id );
645- if (unlikely (cmd == NULL )) {
646- DRM_ERROR ("Failed reserving FIFO space for DX shader "
647- "unbinding.\n" );
633+ cmd = VMW_FIFO_RESERVE_DX (dev_priv , sizeof (* cmd ), bi -> ctx -> id );
634+ if (unlikely (cmd == NULL ))
648635 return - ENOMEM ;
649- }
650636
651637 cmd -> header .id = SVGA_3D_CMD_DX_SET_SINGLE_CONSTANT_BUFFER ;
652638 cmd -> header .size = sizeof (cmd -> body );
@@ -768,12 +754,9 @@ static int vmw_emit_set_sr(struct vmw_ctx_binding_state *cbs,
768754
769755 view_id_size = cbs -> bind_cmd_count * sizeof (uint32 );
770756 cmd_size = sizeof (* cmd ) + view_id_size ;
771- cmd = vmw_fifo_reserve_dx (ctx -> dev_priv , cmd_size , ctx -> id );
772- if (unlikely (cmd == NULL )) {
773- DRM_ERROR ("Failed reserving FIFO space for DX shader"
774- " resource binding.\n" );
757+ cmd = VMW_FIFO_RESERVE_DX (ctx -> dev_priv , cmd_size , ctx -> id );
758+ if (unlikely (cmd == NULL ))
775759 return - ENOMEM ;
776- }
777760
778761 cmd -> header .id = SVGA_3D_CMD_DX_SET_SHADER_RESOURCES ;
779762 cmd -> header .size = sizeof (cmd -> body ) + view_id_size ;
@@ -807,12 +790,9 @@ static int vmw_emit_set_rt(struct vmw_ctx_binding_state *cbs)
807790 vmw_collect_view_ids (cbs , loc , SVGA3D_MAX_SIMULTANEOUS_RENDER_TARGETS );
808791 view_id_size = cbs -> bind_cmd_count * sizeof (uint32 );
809792 cmd_size = sizeof (* cmd ) + view_id_size ;
810- cmd = vmw_fifo_reserve_dx (ctx -> dev_priv , cmd_size , ctx -> id );
811- if (unlikely (cmd == NULL )) {
812- DRM_ERROR ("Failed reserving FIFO space for DX render-target"
813- " binding.\n" );
793+ cmd = VMW_FIFO_RESERVE_DX (ctx -> dev_priv , cmd_size , ctx -> id );
794+ if (unlikely (cmd == NULL ))
814795 return - ENOMEM ;
815- }
816796
817797 cmd -> header .id = SVGA_3D_CMD_DX_SET_RENDERTARGETS ;
818798 cmd -> header .size = sizeof (cmd -> body ) + view_id_size ;
@@ -894,12 +874,9 @@ static int vmw_emit_set_so(struct vmw_ctx_binding_state *cbs)
894874
895875 so_target_size = cbs -> bind_cmd_count * sizeof (SVGA3dSoTarget );
896876 cmd_size = sizeof (* cmd ) + so_target_size ;
897- cmd = vmw_fifo_reserve_dx (ctx -> dev_priv , cmd_size , ctx -> id );
898- if (unlikely (cmd == NULL )) {
899- DRM_ERROR ("Failed reserving FIFO space for DX SO target"
900- " binding.\n" );
877+ cmd = VMW_FIFO_RESERVE_DX (ctx -> dev_priv , cmd_size , ctx -> id );
878+ if (unlikely (cmd == NULL ))
901879 return - ENOMEM ;
902- }
903880
904881 cmd -> header .id = SVGA_3D_CMD_DX_SET_SOTARGETS ;
905882 cmd -> header .size = sizeof (cmd -> body ) + so_target_size ;
@@ -1011,12 +988,9 @@ static int vmw_emit_set_vb(struct vmw_ctx_binding_state *cbs)
1011988
1012989 set_vb_size = cbs -> bind_cmd_count * sizeof (SVGA3dVertexBuffer );
1013990 cmd_size = sizeof (* cmd ) + set_vb_size ;
1014- cmd = vmw_fifo_reserve_dx (ctx -> dev_priv , cmd_size , ctx -> id );
1015- if (unlikely (cmd == NULL )) {
1016- DRM_ERROR ("Failed reserving FIFO space for DX vertex buffer"
1017- " binding.\n" );
991+ cmd = VMW_FIFO_RESERVE_DX (ctx -> dev_priv , cmd_size , ctx -> id );
992+ if (unlikely (cmd == NULL ))
1018993 return - ENOMEM ;
1019- }
1020994
1021995 cmd -> header .id = SVGA_3D_CMD_DX_SET_VERTEX_BUFFERS ;
1022996 cmd -> header .size = sizeof (cmd -> body ) + set_vb_size ;
@@ -1167,12 +1141,10 @@ static int vmw_binding_scrub_ib(struct vmw_ctx_bindinfo *bi, bool rebind)
11671141 SVGA3dCmdDXSetIndexBuffer body ;
11681142 } * cmd ;
11691143
1170- cmd = vmw_fifo_reserve_dx (dev_priv , sizeof (* cmd ), bi -> ctx -> id );
1171- if (unlikely (cmd == NULL )) {
1172- DRM_ERROR ("Failed reserving FIFO space for DX index buffer "
1173- "binding.\n" );
1144+ cmd = VMW_FIFO_RESERVE_DX (dev_priv , sizeof (* cmd ), bi -> ctx -> id );
1145+ if (unlikely (cmd == NULL ))
11741146 return - ENOMEM ;
1175- }
1147+
11761148 cmd -> header .id = SVGA_3D_CMD_DX_SET_INDEX_BUFFER ;
11771149 cmd -> header .size = sizeof (cmd -> body );
11781150 if (rebind ) {
@@ -1269,6 +1241,32 @@ void vmw_binding_state_reset(struct vmw_ctx_binding_state *cbs)
12691241 vmw_binding_drop (entry );
12701242}
12711243
1244+ /**
1245+ * vmw_binding_dirtying - Return whether a binding type is dirtying its resource
1246+ * @binding_type: The binding type
1247+ *
1248+ * Each time a resource is put on the validation list as the result of a
1249+ * context binding referencing it, we need to determine whether that resource
1250+ * will be dirtied (written to by the GPU) as a result of the corresponding
1251+ * GPU operation. Currently rendertarget-, depth-stencil-, and
1252+ * stream-output-target bindings are capable of dirtying its resource.
1253+ *
1254+ * Return: Whether the binding type dirties the resource its binding points to.
1255+ */
1256+ u32 vmw_binding_dirtying (enum vmw_ctx_binding_type binding_type )
1257+ {
1258+ static u32 is_binding_dirtying [vmw_ctx_binding_max ] = {
1259+ [vmw_ctx_binding_rt ] = VMW_RES_DIRTY_SET ,
1260+ [vmw_ctx_binding_dx_rt ] = VMW_RES_DIRTY_SET ,
1261+ [vmw_ctx_binding_ds ] = VMW_RES_DIRTY_SET ,
1262+ [vmw_ctx_binding_so ] = VMW_RES_DIRTY_SET ,
1263+ };
1264+
1265+ /* Review this function as new bindings are added. */
1266+ BUILD_BUG_ON (vmw_ctx_binding_max != 11 );
1267+ return is_binding_dirtying [binding_type ];
1268+ }
1269+
12721270/*
12731271 * This function is unused at run-time, and only used to hold various build
12741272 * asserts important for code optimization assumptions.
0 commit comments